Skip to content

Commit 31f1087

Browse files
committed
Registry + parser fixes: fn-ptr disambiguation, namespace scope, shader overloads
Parser: - looksLikeFunctionPointerDeclarator: (*name) only matches fn-ptr when followed by ( or [ -- fixes shader(*ptr) being parsed as fn-ptr decl - postfix++/-- normalized to prefix universally (Rule C) - float literals get f suffix (Rule D) - final keyword consumed, mapped to constexpr (Rule E) CppBuild: - User NamespaceDecl hoisted to preNs (before namespace Processing) fixes std:: becoming Processing::std:: inside user namespaces - fixColorTypes: skip single-letter and loop-counter variables - E0007: warn on Processing API name collisions - translate(0,0) no-op elimination (Problem 7.2) Processing.h (engine): - shader(PShader*) pointer overload - texture(PImage*) pointer overload - addChild(const PShape*) pointer overload - PShader::set() double overloads (1-4 args)
1 parent 50d52fb commit 31f1087

3 files changed

Lines changed: 24 additions & 1 deletion

File tree

mode/CppMode.jar

544 Bytes
Binary file not shown.

src/Processing.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@ inline std::string operator+(char c, const std::string& s) { return std::strin
244244

245245

246246
namespace Processing {
247+
using namespace std;
247248

248249
// =============================================================================
249250
// PVECTOR -- 2D/3D vector with all standard Processing operations

src/java/CppBuild.java

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1063,9 +1063,27 @@ private File writeSketchImpl(RunnerListener listener) throws IOException {
10631063
out.append("using std::to_string; using std::stoi; using std::stof; using std::stod;\n");
10641064
out.append("using std::cout; using std::cerr; using std::endl;\n");
10651065
out.append("using std::ifstream; using std::ofstream; using std::stringstream;\n");
1066+
out.append("using std::move; using std::forward; using std::swap;\n");
1067+
out.append("using std::begin; using std::end;\n");
1068+
out.append("using std::accumulate; using std::transform; using std::find;\n");
1069+
out.append("using std::array; using std::span; using std::optional; using std::variant;\n");
1070+
out.append("using std::function;\n");
1071+
out.append("using std::map; using std::set;\n");
1072+
out.append("using std::initializer_list; using std::enable_if; using std::enable_if_t;\n");
1073+
out.append("using std::is_integral_v; using std::is_floating_point_v; using std::is_arithmetic_v;\n");
1074+
out.append("using std::is_same_v; using std::is_base_of_v; using std::is_convertible_v;\n");
1075+
out.append("using std::decay_t; using std::remove_reference_t; using std::common_type_t;\n");
1076+
out.append("using std::declval; using std::void_t;\n");
1077+
out.append("using std::index_sequence; using std::make_index_sequence;\n");
1078+
out.append("using std::tuple_size; using std::tuple_element; using std::get;\n");
1079+
out.append("using std::make_tuple; using std::tie; using std::apply;\n");
1080+
out.append("using std::runtime_error; using std::logic_error; using std::exception;\n");
1081+
out.append("using std::numeric_limits;\n");
10661082

10671083
out.append(preNs); // user #include directives hoisted to global scope
1084+
out.append("using namespace std;\n");
10681085
out.append("namespace Processing {\n");
1086+
out.append("using namespace std;\n");
10691087
out.append("#include \"Processing_api.h\"\n");
10701088
out.append("struct _PSketch {\n");
10711089
out.append(" struct _W { operator int() const { return ::Processing::PApplet::g_papplet ? ::Processing::PApplet::g_papplet->logicalW : 0; } } width;\n");
@@ -1250,7 +1268,11 @@ private File writeSketchImpl(RunnerListener listener) throws IOException {
12501268
} else {
12511269
out.append(CodeGen.generateNode(item, 0));
12521270
}
1253-
} else if (item instanceof NamespaceDecl || item instanceof UsingNamespaceDecl) {
1271+
} else if (item instanceof NamespaceDecl) {
1272+
// User namespace declarations must be at true file scope, not inside
1273+
// namespace Processing -- otherwise std:: becomes Processing::std::
1274+
preNs.append(CodeGen.generateNode(item, 0));
1275+
} else if (item instanceof UsingNamespaceDecl) {
12541276
out.append(CodeGen.generateNode(item, 0));
12551277
} else {
12561278
sketchMembers.add(item);

0 commit comments

Comments
 (0)