Skip to content

Commit a0a3dcf

Browse files
committed
Rounds 17-18: bool template args, PSketch template exclusion, namespace fixes
Parser: - parseTemplateArg: BOOL_LITERAL (true/false) handled as template arg - looksLikeFunctionPointerDeclarator: (*name) only matches when ( or [ follows CodeGen: - NamespaceDecl: inject using namespace ::std inside user namespace bodies - PSketchInjector: skip template classes (templateParams non-empty) CppBuild: - namespace std{} specializations hoisted to preNs (global scope) - Out-of-class function defs (X::f()) hoisted to namespace scope - noexcept restored on final_suspend/initial_suspend in output - NamespaceDecl: user namespaces emit inside Processing namespace Processing.h: - #include <coroutine> for C++20 coroutine support
1 parent 81d492f commit a0a3dcf

4 files changed

Lines changed: 14 additions & 1 deletion

File tree

mode/CppMode.jar

66 Bytes
Binary file not shown.

src/java/AstPasses.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,11 @@ private static boolean transitiveBasesGetPSketch(
567567
}
568568

569569
private static Result inject(TypeDef td) {
570+
// Never inject _PSketch into template classes -- they cannot inherit
571+
// from a non-template base like _PSketch without full specialization.
572+
if (!td.templateParams().isEmpty() || td.name().contains("<")) {
573+
return new Result(td, false);
574+
}
570575
if (!hasAnyMethod(td)) {
571576
return new Result(td, false);
572577
}

src/java/Parser.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1921,7 +1921,8 @@ private static String renderNamedTypeAsString(NamedType nt) {
19211921
}
19221922

19231923
private TypeRef parseTemplateArg() {
1924-
if (checkKeyword("true") || checkKeyword("false")) {
1924+
if (checkKeyword("true") || checkKeyword("false")
1925+
|| check(CppLexerTokenType.BOOL_LITERAL)) {
19251926
String val = advance().text();
19261927
return new NamedType(val, List.of(), 0, false, false, false);
19271928
}

tools/cpp-parser/src/main/java/cppmode/parser/passes/PSketchInjector.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,13 @@ public static List<Result> injectAll(List<TypeDef> hoistedClasses) {
5353
}
5454

5555
private static Result inject(TypeDef td) {
56+
// Skip injection for template classes -- they cannot inherit from _PSketch
57+
// since _PSketch is not a template and the inheritance would require
58+
// explicit instantiation. Template classes access Processing API via
59+
// the outer Sketch class through captured state or parameters.
60+
if (!td.templateParams().isEmpty()) {
61+
return new Result(td, false);
62+
}
5663
if (!hasAnyMethod(td)) {
5764
return new Result(td, false);
5865
}

0 commit comments

Comments
 (0)