Commit Graph
12 Commits
Author SHA1 Message Date
adrien 7451defb60 fix: double return 0 in generated C output
- wcprogram.js.generateCode now checks if the body already contains
  a return or exit statement before appending the hardcoded return 0;
  This eliminates the duplicate return 0 from the END block.
2026-06-23 01:19:53 +02:00
adrien 439cc6e7ba feat: loop support via goto labels on each block
- Every block now emits a C label (its id) before its code
- generateNextCode emits goto label; for back-edges (visited targets)
- _emitBranch delegates to generateCode (not generateOwnCode), so labels
  are emitted consistently in both main and branch traversals
- generateCallWithError threads a shared visited set across all three
  emitBranch calls, preventing duplicate label emission for shared blocks
- emitBranch skips roots already visited by previous roots in the same
  branch (prevents spurious gotos from shared-block traversal)
2026-06-23 01:16:14 +02:00
adrien f1eed2d4e0 refactor: extract pure codegen into shared module, remove duplication
- Create codegen/index.js with pure branchDescendants, emitBranch,
  generateCallWithError, and generateCFile — zero DOM dependencies
- blocks-proc.js adapters delegate to CodeGen with browser instanceof check
- run.js uses the same CodeGen module instead of duplicating block classes
  with their own branchDescendants/emitBranch logic
- Load codegen/index.js in browser before blocks-proc.js
2026-06-23 01:07:08 +02:00
adrien 9dd79c2ce5 chore: remove stale test-compile.js (replaced by run.js) 2026-06-23 01:01:06 +02:00
adrien 8522ece371 test: C compilation tests for generated template code
- Add gcc and mesa to shell.nix for C compilation
- Fix warning icon overlap with ::after message by adding padding-right
  to proccall-header and end-header when warnings are active
- Add tests/compile/ with Makefile (pkg-config based) and run.js
  which generates C source from block-like data structures, then
  compiles with gcc -Wall -Wextra -fsyntax-only
- Tests cover: console template, simple error, error merge,
  sequential errors, value-return error style
2026-06-23 01:01:03 +02:00
adrien 3657a22125 fix: WCEnd editor modal pre-loads correct colour and errno value
- Default colour now checks dataset.exitError instead of tagName === 'WC-END',
  so success (exit 0) END blocks default to blue, error END blocks to red
- _selectByCode now also sets the HTML value attribute via setAttribute(),
  ensuring cloneNode(true) preserves the formatted display value
- Add 4 regression tests for colour defaults, attribute sync, and clone value
2026-06-23 00:52:56 +02:00
adrien 68da5592ef refactor: unwrap nested if-else in error-path code generation
- Replace if/else wrapping in WCProcCall.generateOwnCode with branch-aware
  generation via _branchDescendants, _emitBranch, and _generateCallWithError
- Shared blocks (reachable from both error and success paths) now appear
  only once after the if-block, avoiding deeply nested code
- Add 8 browser tests covering merge, decision passthrough, value style,
  sequential calls, and shared-only error paths
- Increase template block spacing (16px -> 40px) for readability
- Add error WCEnd blocks to console and SDL3 templates with error-hook
  connections to all failure-mode proc calls
- Hide editable WCProcCall input fields behind field-display spans,
  matching existing algorithm-block convention
2026-06-23 00:51:54 +02:00
adrien 5caa306503 fix: prevent deletion of library procedures
- Skip delete button creation for readonly blocks (data-readonly)
- Add WCProcedure.delete() override that guards against readonly
2026-06-22 18:39:55 +02:00
adrien 087c836c60 restructure: move icons into libraries/, vendor files out of git
- lib-icons/ -> libraries/icons/ (C library icon SVGs stay with their libs)
- libraries/highlight/ -> vendor/highlight/ (not committed, downloaded)
- lib/mathjax/ -> vendor/mathjax/ (not committed, downloaded)
- vendor/download.sh fetches highlight.js v11.10.0 and MathJax v3.2.2
- index.html paths updated to vendor/
- .gitignore ignores vendor/* (except download.sh)
- Removes ~1.2MB of binary font files from git tracking
2026-06-22 18:35:45 +02:00
adrien b8e8ef9113 overhaul: modular architecture, tests, doc generation, warning system, and UX improvements
- Modular block files: split into blocks-algo, blocks-data, blocks-proc
- New modules: sections.js (labelled canvas areas), proc-browser.js (procedure tree modal), lib-loader.js (lazy library loading), templates.js (project templates), errno-data.js (errno table)
- Test infrastructure: browser test suite (28 tests) and Node pure-function tests (75 tests)
- Warning system: unified .block-warn for disconnected inputs, unconnected error hooks, and zero-exit-in-error-path
- Error path highlighting: red flow paths and block borders for error-only subgraphs
- Input hooks: hidden by default, shown during linking; outputs always at bottom
- Block editor modal: pencil icon, colour picker for accent, compact field labels
- Doc generation: standalone node script extracts JSDoc -> docs/API.md (124 declarations)
- Persistence: save/restore sections, errno selection, block colours
- Fixes: _segmentsIntersect bug, WCEnd crash from closest(this), drawpath guard on detached elements
2026-06-22 18:31:23 +02:00
adrien 36fc63780a early version: modular block files, full template set, tab UI, OpenGL defaults 2026-06-19 01:18:36 +02:00
adrien 91f583c51c Initial commit: visual programming framework with web components
HTML defines template-based UI for flow chart nodes (start, end, output, decision, datum). CSS provides grid-based canvas and node styling. JS implements custom elements with drag-and-drop, linkable connections, and C code generation.
2026-06-16 12:52:53 +02:00