Skip to content

Releases: processing-cpp/processing.cpp

C++ Mode v0.3.1

Choose a tag to compare

@pepc84 pepc84 released this 22 Jul 04:31

What's new?

Parser Hardening: Function Pointers, Template Defaults, Bitfields, and More

This release continues the parser hardening work from v0.3.0, targeting a new batch of valid C++17/20 constructs that were previously mishandled. Fixes span the parser, CodeGen, and the Windows install wizard.


Parser

  • Function pointer parameters with defaults: float (*fn)(float) = nullptr now parses correctly. The ref-to-array branch ((&arr)[N]) now discriminates against function pointer params by checking whether ( or [ follows the closing ), rather than consuming both forms the same way.
  • Function pointer parameter encoding: parser encodes fn-ptr params as name__fnptr__(sig) so CodeGen can round-trip the full declarator shape rettype (*name)(sig).
  • Template default values with comparisons: template<int N = (sizeof(float) > 2 ? 8 : 4)> now parses correctly. parseTemplateDefaultValue now tracks parenDepth and angleDepth separately, so > inside parentheses is treated as a comparison operator rather than a template closer.
  • Explicit empty <>: Foo<> x now emits Foo<> x rather than Foo x. The parser stores a sentinel NamedType("<>") to distinguish explicit empty args from no args.
  • Array-new value-init: new float[n]() trailing () is now consumed correctly instead of being left in the stream and breaking the enclosing constructor init-list parser.
  • Trailing ref-qualifiers: T& operator=(const T&) & and T& operator=(T&&) && — trailing & and && ref-qualifiers on member functions are now consumed in the trailing qualifier loop.
  • Bitfields: named (unsigned int active : 1) and unnamed (unsigned int : 2) bitfield declarations now parse correctly inside struct bodies. Unnamed bitfields return an empty name before expectIdentifier() would throw.
  • Throw as expression: cond ? val : throw std::runtime_error("null")throw in ternary else position now handled in parseTernary() before delegating to parseLogicalOr().
  • Template speculation and ternary: looksLikeTemplateArgList now rejects speculation when a bare ? appears at depth 0, preventing v < lo ? lo : v > hi from being misread as a template instantiation.

CodeGen

  • Function pointer param emission: decodes name__fnptr__(sig) encoding and emits rettype (*name)(sig) correctly.
  • Array-of-function-pointer dims: void (*ops[4])(int) now emits with [4] inside the parens rather than outside — discriminates array-of-fn-ptr from ptr-to-array using paramTypes.isEmpty().
  • Long double literals: L/l suffix now excluded from the float f-append pass — 180.0L was becoming 180.0Lf.

CppBuild / InstallWizard

  • E0005 false positive fixed: Array<T>.get().field no longer triggers E0005. The check now requires positive confirmation that the receiver is an ArrayList before firing — Array<T> is value-storage and .field is correct there.
  • Windows install wizard now fires reliably: PATH g++ (Git for Windows, Cygwin, other MinGW installs) is no longer trusted on Windows. Only g++ at known MSYS2 mingw64 paths is accepted. Previously, any g++ on PATH would silently bypass the wizard, leading to linker errors at build time due to missing GLFW/GLEW. Both CppBuild.checkGppAvailable() and InstallWizard.detectWindowsMissing() now check MSYS2 paths exclusively.

Stress Test Coverage

Rounds 21–23 of the parser stress test suite, covering: inline function pointer parameters with defaults, arrays of function pointers, reference-to-array parameters, nested template closes (>>), conditional expression NTTPs, pointer-to-member template parameters, cast inside brace-init, pack expansion in member init-lists, operator overloads with ref-qualifiers, structured bindings in range-for, if/switch-with-init, template type aliases, using X::Y qualified imports, three-link postfix chains on temporaries, trailing return types with decltype, constexpr if, fold expressions, C++20 lambda template parameters, requires clauses on free functions, concept definitions, structured bindings from arrays, immediately invoked lambdas, variable templates, bitfield members, conditional noexcept, and throw-expressions in ternary context.

C++ Mode v0.3.0

Choose a tag to compare

@pepc84 pepc84 released this 15 Jul 00:24

v0.3.0 — Parser Hardening: C++17/20 Syntax Coverage

This release is a major parser hardening milestone. Across stress test rounds 4 through 10, the recursive-descent parser was pushed against increasingly exotic C++17/20 constructs until it either passed or was fixed. The result is substantially broader syntax coverage with fewer silent misparsings.


Critical Bug Fix

peek() was mutating pos as a side effect. peek() called skipCommentsAt() which advanced pos past comment tokens. This meant that when a comment appeared between two tokens, checkKeyword("template") would see the keyword correctly, but the immediately following checkOp("<") would see the keyword again instead of <, because pos had already moved. This caused template<Numeric T> to be misidentified as an explicit template instantiation, silently swallowing entire function definitions. Fixed by making peek() scan forward without mutating pos.


Parser

  • consteval and constinit added to the keyword set and all qualifier loops
  • Explicit template instantiation (template class std::vector<int>;) consumed verbatim before namespace wrapping
  • Concept-constrained template parameters (template<Numeric T> where Numeric is a concept name)
  • Global structured binding (auto [a, b] = MyPair{...}; at file scope) hoisted to namespace scope
  • Bit field declarations (unsigned int x : 1; in struct members)
  • __attribute__((...)) in trailing and inline positions after function declarations and variable names
  • Variadic pack expansion in params (Args&&... args) now sets isVariadic from the type-level ...
  • Pack expansion in call arguments (f(args...)) emits correctly
  • Local struct definitions inside function bodies now emit the struct before the following variable declaration
  • Local struct forward declarations (struct Foo; inside a function) consumed silently
  • Variable template specialization (zero<float> = 0.0f) parsed correctly in parseFunctionOrVariableName
  • extern "C" and extern "C++" linkage specifications parsed; block form recurses into items
  • explicit(...) conditional explicit specifier (C++20) consumed before constructor dispatch
  • friend declarations and definitions consumed verbatim in class bodies, including templated friends with bodies
  • alignas(...) before struct/class names (struct alignas(64) CacheLine)
  • [[attributes]] before struct/class names consumed in parseTypeDef
  • Constructor name matching for specializations (Grid<T, N, false> matches constructor Grid(...) by base name)
  • parseTemplateDefaultValue now tracks {} depth so < inside lambda bodies does not abort angle bracket parsing
  • looksLikeTemplateArgList now tracks () and {} depth so { inside decltype(T{}) does not cause the lookahead to bail
  • Brace initialization in constructor initializer lists (m{{1,0},{0,1}})
  • Specialization args in parseTypeDef use a manual depth-tracked token scan rather than parseTemplateArgList, which handles cases like Grid<T, N, false>
  • System header filtering in preprocessMacros: g++ -E output is now filtered to only keep tokens from the sketch file itself, preventing STL internals from reaching the parser

AST

  • FunctionDecl.isDefault and FunctionDecl.isDelete store and emit = default and = delete, fixing linker errors from virtual ~Base() = default
  • LambdaExpr.isMutable stores the mutable keyword

CodeGen

  • = default and = delete emitted for function declarations
  • mutable emitted after the lambda parameter list, before the -> return type
  • Trailing decltype(...) return types emitted as auto name(params) -> decltype(...)

CppBuild

  • TopLevelStatement items like structured bindings hoisted to namespace scope rather than emitted as struct Sketch members
  • Explicit template instantiations emitted before namespace Processing {
  • preprocessMacros filters system header content out of g++ -E output

Stress Test Coverage

Rounds 4 through 10 cover: nested namespaces, constexpr virtual, designated initializers, pack expansion, operator new/delete overloads, placement new, partial template specialization, variadic templates, template template parameters, requires clauses, the spaceship operator, constexpr if, multiple inheritance, user-defined literals, CRTP, policy-based design, concept constraints, variable templates, lambda default template arguments, structured bindings, three-way comparison, __builtin_* functions, enum class with bitwise operators, nested initializer lists, and complex SFINAE patterns.

C++ Mode v0.2.3

Choose a tag to compare

@pepc84 pepc84 released this 29 Jun 19:41

This is a temporary stabilization release focused on resolving parser issues introduced in v0.2.2. While this is not a feature release, it significantly improves compiler stability and restores compatibility with a wide range of Processing sketches.

What's Fixed

  • Fixed numerous parser bugs that prevented valid Processing code from compiling.
  • Improved parsing of variable declarations and initializers.
  • Fixed multiple expression parsing edge cases.
  • Improved handling of array related syntax.
  • Resolved several parser crashes and invalid AST generation issues.
  • Improved parser diagnostics and error messages.
  • General parser stability improvements and internal cleanup.

C++ Mode v0.2.2

Choose a tag to compare

@pepc84 pepc84 released this 24 Jun 20:35

Fixed

  • Editor: Enter/Tab indentation now matches Java mode. The C++ mode editor's auto-indent on Enter previously hard-coded a 4-space indent after { (ignoring the editor.tabs.size preference) and copied raw tab characters into new lines instead of normalizing to spaces, which made whitespace behave inconsistently compared to Java sketches.
  • Closing braces now auto-dedent. Typing } on its own line now outdents to match its corresponding {, mirroring Java mode. This was previously missing entirely in C++ mode.
  • Tab / Shift+Tab now respect editor preferences. Tab now inserts spaces or a literal tab according to editor.tabs.expand/editor.tabs.size, and Shift+Tab now outdents — previously Tab always inserted a literal tab and Shift+Tab had no effect.
  • No more duplicated whitespace on Enter. Pressing Enter in the middle of a line with trailing spaces no longer doubles up the indent.
  • Ctrl+Up / Ctrl+Down jump-to-blank-line navigation, present in Java mode, is now available in C++ mode as well.

Internal

  • Added CppInputHandler (mirrors upstream Processing's JavaInputHandler) to own all of this key-handling logic in one place, replacing a set of ad-hoc key bindings in CppEditor.

Full diff: src/java/CppEditor.java, src/java/CppInputHandler.java (new)

C++ Mode v0.2.1

Choose a tag to compare

@pepc84 pepc84 released this 23 Jun 22:45

C++ Mode v0.2.1

New language features

Primitive wrapper classes. Integer, Float, Double, Long, Byte, and Character are now real wrapper classes matching Java's actual boxing semantics: constructors, valueOf(), parseXxx(), and implicit conversion to and from the underlying primitive. Previously these were silently rewritten to bare primitives, which broke anything relying on real wrapper-object behavior.

Array. A new fixed-size array type matching real Java array semantics exactly: zero-initialized by default, fixed length, and bounds-checked (throwing a clear error on an out-of-range index instead of silently corrupting memory). Comes with the full set of array utility functions: append, arrayCopy, concat, expand, reverse, shorten, sort, splice, and subset.Release title

Explicit pointer types are now required. PImage, PFont, PShape, and PGraphics declarations are no longer silently rewritten from value-style to pointer-style behind the scenes. Sketches now declare these explicitly as pointers (PImage* img;) and use -> for method calls, matching real C++ semantics. This removes a category of bugs that came from CppBuild guessing at a sketch's intent.

New compiler error system

CppMode now reports several common mistakes with clear, numbered errors (E0001 through E0004) linking to a dedicated reference page on the website, instead of generic, hard to parse compiler output.

E0001 through E0003: attempting to use PGraphics, PImage, or PShader as a value instead of a pointer.

E0004: writing Java-style array declarations (int[] a = new int[5];) instead of Array.

Engine fixes

Fixed a GLSL shader corruption bug that broke all lit 3D rendering.

Fixed rect()'s stroke centering and mitering.

PGraphics buffers now have fully independent style state (fill, stroke, text settings) instead of sharing the main canvas's.

Fixed MSAA antialiasing for PGraphics buffers, including a regression where 2D sketches disabled it engine wide.

Fixed a bug where image(pg, ...) would silently call the wrong overload for a PGraphics*, displaying nothing or stale content, due to an implicit conversion to PImage*.

Fixed lighting and depth testing state leaking into unrelated 2D drawing (text, image buffers) when called in the same frame as 3D content.

Fixed PGraphics buffers created with the P3D renderer using the wrong (flat 2D) projection, clipping away all 3D content.

Fixed viewport and matrix stack corruption that could propagate from an improperly closed PGraphics buffer into later drawing in the same frame.

Fixed the CODED key constant, which was 0xFF instead of the correct 0xFFFF, and widened key's type from char to char16_t so it can actually hold that value.

Fixed ArrayList's value/reference type detection to correctly recognize String and the new primitive wrapper classes as value types.

Tooling

config/cppmode.properties consolidates the debug toggle and the website base URL into a single file, read by both the build pipeline and the standalone engine rebuild script.

scripts/rebuild-engine.sh: single, authoritative way to rebuild the C++ engine, reading debug mode from the config file.

scripts/rebuild-jar.py: one command rebuild and deploy of CppMode.jar.

scripts/create-release.py: packages a clean release zip, excluding build caches and repo metadata, with optional version bumping across mode.properties and CppMode.txt.

C++ Mode v0.1.4

Choose a tag to compare

@pepc84 pepc84 released this 10 Jun 20:17

What's new

Improved Linux support with auto-installers for missing dependencies.

  • Added "Install Automatically" button when g++ is not found on Linux — detects apt, pacman, dnf, and zypper and installs with one click
  • Added "Install Automatically" button when GLFW or GLEW headers are missing — same package manager detection
  • Install output is streamed directly to the Processing console so you can see what's happening
  • Fixed library detection to check for headers instead of .so files, which correctly catches systems missing libglfw3-dev and libglew-dev
  • Library check now runs before compile so you get a clear error dialog instead of a raw compiler error

Requirements

Linux: g++, libglfw3-dev, libglew-dev — CppMode will prompt you to install these automatically if missing

Windows: MSYS2 with g++ (auto-installer included)

macOS: Homebrew with gcc, glfw, glew — CppMode will open the Homebrew download page if not installed

v0.1.3 BROKEN

Choose a tag to compare

@pepc84 pepc84 released this 10 Jun 02:03

What's new

  • Bundled GLEW and GLFW for Linux — no need to install dev libraries manually
  • Added Linux g++ not found dialog with clear install instructions for all major distros
  • Fixed library detection on Pop!_OS, Ubuntu, Debian, Mint and other apt-based systems

Requirements

Linux: g++ only — sudo apt install g++ / sudo pacman -S gcc / sudo dnf install gcc-c++

Windows: MSYS2 with g++ (auto-installer included)

macOS: not yet supported

C++ Mode v0.1.2

Choose a tag to compare

@pepc84 pepc84 released this 09 Jun 01:27

Third release of C++ Mode for Processing4.

Installation

  1. Download CppMode.zip
  2. Unzip into your Processing sketchbook modes/ folder
  3. Restart Processing4
  4. Select C++ Mode from the mode dropdown

Requirements

  • Processing 4
  • g++ (Linux: sudo apt install g++ libglfw3-dev libglew-dev, Windows: MSYS2)
  • OpenGL (GLFW + GLEW)

C++ Mode v0.1.1

Choose a tag to compare

@pepc84 pepc84 released this 06 Jun 20:13

Second release of C++ Mode for Processing4.

Installation

  1. Download CppMode.zip
  2. Unzip into your Processing sketchbook modes/ folder
  3. Restart Processing4
  4. Select C++ Mode from the mode dropdown

Requirements

  • Processing 4
  • g++ (Linux: sudo apt install g++ libglfw3-dev libglew-dev, Windows: MSYS2)
  • OpenGL (GLFW + GLEW)

C++ Mode v0.1.0

Choose a tag to compare

@pepc84 pepc84 released this 15 May 04:51

First release of C++ Mode for Processing4.

Installation

  1. Download CppMode.zip
  2. Unzip into your Processing sketchbook modes/ folder
  3. Restart Processing4
  4. Select C++ Mode from the mode dropdown

Requirements

  • Processing 4
  • g++ (Linux: sudo apt install g++ libglfw3-dev libglew-dev, Windows: MSYS2)
  • OpenGL (GLFW + GLEW)