@typecad/cuttlefish 0.1.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +79 -0
- package/dist/api/board-types.d.ts +1 -0
- package/dist/api/board-types.js +4 -0
- package/dist/api/capabilities.d.ts +12 -0
- package/dist/api/capabilities.js +1 -0
- package/dist/api/config.d.ts +120 -0
- package/dist/api/config.js +7 -0
- package/dist/api/index.d.ts +5 -0
- package/dist/api/index.js +2 -0
- package/dist/api/schema/builder.d.ts +14 -0
- package/dist/api/schema/builder.js +15 -0
- package/dist/api/schema/index.d.ts +2 -0
- package/dist/api/schema/index.js +1 -0
- package/dist/api/schema/types.d.ts +257 -0
- package/dist/api/schema/types.js +4 -0
- package/dist/api/shared/async-runtime-static.d.ts +8 -0
- package/dist/api/shared/async-runtime-static.js +201 -0
- package/dist/api/shared/async-types.d.ts +42 -0
- package/dist/api/shared/async-types.js +8 -0
- package/dist/api/shared/board-resolver.d.ts +12 -0
- package/dist/api/shared/board-resolver.js +7 -0
- package/dist/api/shared/cpp-type-ir.d.ts +229 -0
- package/dist/api/shared/cpp-type-ir.js +672 -0
- package/dist/api/shared/display-adapter.d.ts +12 -0
- package/dist/api/shared/display-adapter.js +145 -0
- package/dist/api/shared/display-adapters/eink-mono.d.ts +2 -0
- package/dist/api/shared/display-adapters/eink-mono.js +53 -0
- package/dist/api/shared/display-adapters/sdl.d.ts +2 -0
- package/dist/api/shared/display-adapters/sdl.js +452 -0
- package/dist/api/shared/display-adapters/ssd1309.d.ts +2 -0
- package/dist/api/shared/display-adapters/ssd1309.js +136 -0
- package/dist/api/shared/display-adapters/st7796.d.ts +2 -0
- package/dist/api/shared/display-adapters/st7796.js +132 -0
- package/dist/api/shared/display-capabilities.d.ts +45 -0
- package/dist/api/shared/display-capabilities.js +54 -0
- package/dist/api/shared/display-op-ir.d.ts +62 -0
- package/dist/api/shared/display-op-ir.js +19 -0
- package/dist/api/shared/display-profile.d.ts +265 -0
- package/dist/api/shared/display-profile.js +338 -0
- package/dist/api/shared/graphics-strategy.d.ts +29 -0
- package/dist/api/shared/graphics-strategy.js +11 -0
- package/dist/api/shared/hal-op-ir.d.ts +393 -0
- package/dist/api/shared/hal-op-ir.js +18 -0
- package/dist/api/shared/index.d.ts +26 -0
- package/dist/api/shared/index.js +21 -0
- package/dist/api/shared/ir-core.d.ts +363 -0
- package/dist/api/shared/ir-core.js +8 -0
- package/dist/api/shared/ir-declarations.d.ts +201 -0
- package/dist/api/shared/ir-declarations.js +26 -0
- package/dist/api/shared/ir.d.ts +85 -0
- package/dist/api/shared/ir.js +13 -0
- package/dist/api/shared/platform-strategy.d.ts +402 -0
- package/dist/api/shared/platform-strategy.js +14 -0
- package/dist/api/shared/polyfill-helper-registry.d.ts +11 -0
- package/dist/api/shared/polyfill-helper-registry.js +86 -0
- package/dist/api/shared/polyfill-types.d.ts +33 -0
- package/dist/api/shared/polyfill-types.js +76 -0
- package/dist/api/shared/promise-runtime.d.ts +10 -0
- package/dist/api/shared/promise-runtime.js +244 -0
- package/dist/api/shared/snprintf-types.d.ts +29 -0
- package/dist/api/shared/snprintf-types.js +8 -0
- package/dist/api/shared/string-method-registry.d.ts +53 -0
- package/dist/api/shared/string-method-registry.js +168 -0
- package/dist/api/shared/toolchain-types.d.ts +63 -0
- package/dist/api/shared/toolchain-types.js +71 -0
- package/dist/api/shared/types.d.ts +50 -0
- package/dist/api/shared/types.js +6 -0
- package/dist/ast/parse.d.ts +2 -0
- package/dist/ast/parse.js +4 -0
- package/dist/cache.d.ts +26 -0
- package/dist/cache.js +95 -0
- package/dist/cli-utils.d.ts +37 -0
- package/dist/cli-utils.js +250 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +635 -0
- package/dist/config-loader.d.ts +78 -0
- package/dist/config-loader.js +508 -0
- package/dist/config-schema.d.ts +233 -0
- package/dist/config-schema.js +83 -0
- package/dist/create/board-checklist.d.ts +2 -0
- package/dist/create/board-checklist.js +52 -0
- package/dist/create/board-codegen.d.ts +9 -0
- package/dist/create/board-codegen.js +238 -0
- package/dist/create/board-generators.d.ts +12 -0
- package/dist/create/board-generators.js +652 -0
- package/dist/create/board-spec.d.ts +640 -0
- package/dist/create/board-spec.js +215 -0
- package/dist/create/eslint-rules-template.d.ts +2 -0
- package/dist/create/eslint-rules-template.js +672 -0
- package/dist/create/index.d.ts +11 -0
- package/dist/create/index.js +8 -0
- package/dist/create/init-scaffold.d.ts +27 -0
- package/dist/create/init-scaffold.js +150 -0
- package/dist/create/init-templates.d.ts +24 -0
- package/dist/create/init-templates.js +379 -0
- package/dist/create/init-wizard.d.ts +8 -0
- package/dist/create/init-wizard.js +168 -0
- package/dist/debug/breakpoint-loader.d.ts +24 -0
- package/dist/debug/breakpoint-loader.js +137 -0
- package/dist/debug/index.d.ts +3 -0
- package/dist/debug/index.js +7 -0
- package/dist/debug/preprocessor.d.ts +9 -0
- package/dist/debug/preprocessor.js +214 -0
- package/dist/debug/types.d.ts +32 -0
- package/dist/debug/types.js +6 -0
- package/dist/diagnostics/diagnostics-report.d.ts +51 -0
- package/dist/diagnostics/diagnostics-report.js +333 -0
- package/dist/diagnostics/json-schema.d.ts +138 -0
- package/dist/diagnostics/json-schema.js +27 -0
- package/dist/diagnostics/md-writer.d.ts +10 -0
- package/dist/diagnostics/md-writer.js +336 -0
- package/dist/diagnostics/mermaid-builder.d.ts +65 -0
- package/dist/diagnostics/mermaid-builder.js +681 -0
- package/dist/emit/cpp-emitter.d.ts +6 -0
- package/dist/emit/cpp-emitter.js +48 -0
- package/dist/emit/emitters/class-emitter.d.ts +2 -0
- package/dist/emit/emitters/class-emitter.js +523 -0
- package/dist/emit/emitters/emitter-context.d.ts +174 -0
- package/dist/emit/emitters/emitter-context.js +1 -0
- package/dist/emit/emitters/entrypoint-synthesizer.d.ts +2 -0
- package/dist/emit/emitters/entrypoint-synthesizer.js +175 -0
- package/dist/emit/emitters/function-emitter-impl.d.ts +19 -0
- package/dist/emit/emitters/function-emitter-impl.js +428 -0
- package/dist/emit/emitters/line-appender.d.ts +15 -0
- package/dist/emit/emitters/line-appender.js +344 -0
- package/dist/emit/emitters/namespace-emitter.d.ts +2 -0
- package/dist/emit/emitters/namespace-emitter.js +324 -0
- package/dist/emit/emitters/output-finalizer.d.ts +4 -0
- package/dist/emit/emitters/output-finalizer.js +267 -0
- package/dist/emit/emitters/setup.d.ts +3 -0
- package/dist/emit/emitters/setup.js +851 -0
- package/dist/emit/emitters/top-level-prep.d.ts +2 -0
- package/dist/emit/emitters/top-level-prep.js +706 -0
- package/dist/emit/emitters/type-decl-emitter.d.ts +2 -0
- package/dist/emit/emitters/type-decl-emitter.js +251 -0
- package/dist/emit/emitters/ui-emitter.d.ts +21 -0
- package/dist/emit/emitters/ui-emitter.js +564 -0
- package/dist/emit/enum-emitter.d.ts +1 -0
- package/dist/emit/enum-emitter.js +1 -0
- package/dist/emit/expression-renderer.d.ts +283 -0
- package/dist/emit/expression-renderer.js +1477 -0
- package/dist/emit/native-helpers-emitter.d.ts +11 -0
- package/dist/emit/native-helpers-emitter.js +34 -0
- package/dist/emit/route-hal-op.d.ts +5 -0
- package/dist/emit/route-hal-op.js +13 -0
- package/dist/emit/snprintf-helpers.d.ts +17 -0
- package/dist/emit/snprintf-helpers.js +462 -0
- package/dist/emit/statement-renderer.d.ts +189 -0
- package/dist/emit/statement-renderer.js +948 -0
- package/dist/emit/utils/async-state-machine.d.ts +42 -0
- package/dist/emit/utils/async-state-machine.js +343 -0
- package/dist/emit/utils/comment-helpers.d.ts +20 -0
- package/dist/emit/utils/comment-helpers.js +31 -0
- package/dist/emit/utils/cpp-helpers.d.ts +47 -0
- package/dist/emit/utils/cpp-helpers.js +85 -0
- package/dist/emit/utils/include-resolver.d.ts +58 -0
- package/dist/emit/utils/include-resolver.js +155 -0
- package/dist/emit/utils/index.d.ts +8 -0
- package/dist/emit/utils/index.js +12 -0
- package/dist/emit/utils/type-inference.d.ts +159 -0
- package/dist/emit/utils/type-inference.js +559 -0
- package/dist/eslint-check.d.ts +10 -0
- package/dist/eslint-check.js +102 -0
- package/dist/framework-package.d.ts +10 -0
- package/dist/framework-package.js +58 -0
- package/dist/framework-registry.d.ts +39 -0
- package/dist/framework-registry.js +30 -0
- package/dist/incremental-cache.d.ts +116 -0
- package/dist/incremental-cache.js +335 -0
- package/dist/ir/adc-range-validation.d.ts +11 -0
- package/dist/ir/adc-range-validation.js +250 -0
- package/dist/ir/ast-node-utils.d.ts +8 -0
- package/dist/ir/ast-node-utils.js +32 -0
- package/dist/ir/board-pin-utils.d.ts +13 -0
- package/dist/ir/board-pin-utils.js +65 -0
- package/dist/ir/board-resolver.d.ts +36 -0
- package/dist/ir/board-resolver.js +437 -0
- package/dist/ir/build-ir-state.d.ts +167 -0
- package/dist/ir/build-ir-state.js +306 -0
- package/dist/ir/build-ir.d.ts +2 -0
- package/dist/ir/build-ir.js +808 -0
- package/dist/ir/call-graph.d.ts +35 -0
- package/dist/ir/call-graph.js +194 -0
- package/dist/ir/compile-time-only.d.ts +2 -0
- package/dist/ir/compile-time-only.js +16 -0
- package/dist/ir/declaration-builders.d.ts +9 -0
- package/dist/ir/declaration-builders.js +608 -0
- package/dist/ir/entry-points.d.ts +30 -0
- package/dist/ir/entry-points.js +191 -0
- package/dist/ir/expression-to-ir.d.ts +5 -0
- package/dist/ir/expression-to-ir.js +2249 -0
- package/dist/ir/extract-property-chain.d.ts +10 -0
- package/dist/ir/extract-property-chain.js +30 -0
- package/dist/ir/feature-prescan.d.ts +3 -0
- package/dist/ir/feature-prescan.js +43 -0
- package/dist/ir/feature-registry.d.ts +30 -0
- package/dist/ir/feature-registry.js +816 -0
- package/dist/ir/filter.d.ts +7 -0
- package/dist/ir/filter.js +85 -0
- package/dist/ir/function-builder.d.ts +19 -0
- package/dist/ir/function-builder.js +670 -0
- package/dist/ir/hal/hal-emitter.d.ts +62 -0
- package/dist/ir/hal/hal-emitter.js +735 -0
- package/dist/ir/hal/hal-parser.d.ts +61 -0
- package/dist/ir/hal/hal-parser.js +473 -0
- package/dist/ir/hal/hal-plugins.d.ts +34 -0
- package/dist/ir/hal/hal-plugins.js +706 -0
- package/dist/ir/hal-resolver.d.ts +5 -0
- package/dist/ir/hal-resolver.js +5 -0
- package/dist/ir/heap-analysis.d.ts +8 -0
- package/dist/ir/heap-analysis.js +350 -0
- package/dist/ir/heap-array-validation.d.ts +24 -0
- package/dist/ir/heap-array-validation.js +29 -0
- package/dist/ir/identifier-collector.d.ts +18 -0
- package/dist/ir/identifier-collector.js +439 -0
- package/dist/ir/interrupt-analysis.d.ts +39 -0
- package/dist/ir/interrupt-analysis.js +467 -0
- package/dist/ir/memory-budget-validation.d.ts +10 -0
- package/dist/ir/memory-budget-validation.js +86 -0
- package/dist/ir/namespace-builder.d.ts +7 -0
- package/dist/ir/namespace-builder.js +152 -0
- package/dist/ir/ownership-analysis.d.ts +9 -0
- package/dist/ir/ownership-analysis.js +1207 -0
- package/dist/ir/peripheral-ownership.d.ts +3 -0
- package/dist/ir/peripheral-ownership.js +152 -0
- package/dist/ir/peripheral-symbols.d.ts +7 -0
- package/dist/ir/peripheral-symbols.js +57 -0
- package/dist/ir/peripheral-usage.d.ts +54 -0
- package/dist/ir/peripheral-usage.js +691 -0
- package/dist/ir/peripheral-validation.d.ts +8 -0
- package/dist/ir/peripheral-validation.js +77 -0
- package/dist/ir/pin-alias-conflict.d.ts +4 -0
- package/dist/ir/pin-alias-conflict.js +34 -0
- package/dist/ir/pin-capability-validation.d.ts +6 -0
- package/dist/ir/pin-capability-validation.js +413 -0
- package/dist/ir/pin-mode-validation.d.ts +10 -0
- package/dist/ir/pin-mode-validation.js +301 -0
- package/dist/ir/pin-safety.d.ts +11 -0
- package/dist/ir/pin-safety.js +58 -0
- package/dist/ir/program-analysis.d.ts +44 -0
- package/dist/ir/program-analysis.js +589 -0
- package/dist/ir/pulldown-validation.d.ts +7 -0
- package/dist/ir/pulldown-validation.js +49 -0
- package/dist/ir/pwm-timer-sharing.d.ts +4 -0
- package/dist/ir/pwm-timer-sharing.js +93 -0
- package/dist/ir/reachability.d.ts +68 -0
- package/dist/ir/reachability.js +224 -0
- package/dist/ir/register-decorators.d.ts +6 -0
- package/dist/ir/register-decorators.js +49 -0
- package/dist/ir/render-expr.d.ts +4 -0
- package/dist/ir/render-expr.js +127 -0
- package/dist/ir/resource-analysis.d.ts +19 -0
- package/dist/ir/resource-analysis.js +153 -0
- package/dist/ir/statement-to-ir.d.ts +23 -0
- package/dist/ir/statement-to-ir.js +349 -0
- package/dist/ir/symbol-table.d.ts +68 -0
- package/dist/ir/symbol-table.js +179 -0
- package/dist/ir/symbol-types.d.ts +56 -0
- package/dist/ir/symbol-types.js +107 -0
- package/dist/ir/timer0-pwm-timing-conflict.d.ts +4 -0
- package/dist/ir/timer0-pwm-timing-conflict.js +71 -0
- package/dist/ir/timing-validation.d.ts +7 -0
- package/dist/ir/timing-validation.js +95 -0
- package/dist/ir/transformers/array-methods.d.ts +8 -0
- package/dist/ir/transformers/array-methods.js +493 -0
- package/dist/ir/transformers/call-statement.d.ts +5 -0
- package/dist/ir/transformers/call-statement.js +758 -0
- package/dist/ir/transformers/callback-context-registry.d.ts +20 -0
- package/dist/ir/transformers/callback-context-registry.js +55 -0
- package/dist/ir/transformers/canvas-lowering.d.ts +42 -0
- package/dist/ir/transformers/canvas-lowering.js +249 -0
- package/dist/ir/transformers/control-flow.d.ts +8 -0
- package/dist/ir/transformers/control-flow.js +508 -0
- package/dist/ir/transformers/expressions.d.ts +7 -0
- package/dist/ir/transformers/expressions.js +406 -0
- package/dist/ir/transformers/hal-call-resolver.d.ts +29 -0
- package/dist/ir/transformers/hal-call-resolver.js +274 -0
- package/dist/ir/transformers/hal-emit-helpers.d.ts +14 -0
- package/dist/ir/transformers/hal-emit-helpers.js +63 -0
- package/dist/ir/transformers/namespace-methods.d.ts +20 -0
- package/dist/ir/transformers/namespace-methods.js +110 -0
- package/dist/ir/transformers/register-assignment.d.ts +5 -0
- package/dist/ir/transformers/register-assignment.js +56 -0
- package/dist/ir/transformers/ui-call-resolver.d.ts +149 -0
- package/dist/ir/transformers/ui-call-resolver.js +1136 -0
- package/dist/ir/transformers/ui-callback-lowering.d.ts +62 -0
- package/dist/ir/transformers/ui-callback-lowering.js +623 -0
- package/dist/ir/transformers/ui-mount.d.ts +20 -0
- package/dist/ir/transformers/ui-mount.js +35 -0
- package/dist/ir/transformers/ui-reactive.d.ts +68 -0
- package/dist/ir/transformers/ui-reactive.js +129 -0
- package/dist/ir/transformers/variables.d.ts +14 -0
- package/dist/ir/transformers/variables.js +1045 -0
- package/dist/ir/try-catch-validation.d.ts +26 -0
- package/dist/ir/try-catch-validation.js +128 -0
- package/dist/ir/type-resolution.d.ts +31 -0
- package/dist/ir/type-resolution.js +977 -0
- package/dist/ir/ui-element-auto-wire.d.ts +50 -0
- package/dist/ir/ui-element-auto-wire.js +218 -0
- package/dist/ir/unit-suspicion-validation.d.ts +12 -0
- package/dist/ir/unit-suspicion-validation.js +296 -0
- package/dist/ir/utils/walk-ir.d.ts +6 -0
- package/dist/ir/utils/walk-ir.js +162 -0
- package/dist/ir/validation-orchestrator.d.ts +4 -0
- package/dist/ir/validation-orchestrator.js +45 -0
- package/dist/libdef/base-class-resolver.d.ts +23 -0
- package/dist/libdef/base-class-resolver.js +50 -0
- package/dist/libdef/cpp-to-decl.d.ts +34 -0
- package/dist/libdef/cpp-to-decl.js +584 -0
- package/dist/libdef/header-parser.d.ts +53 -0
- package/dist/libdef/header-parser.js +269 -0
- package/dist/libdef/registry.d.ts +10 -0
- package/dist/libdef/registry.js +142 -0
- package/dist/mapping/peripheral-names.d.ts +23 -0
- package/dist/mapping/peripheral-names.js +63 -0
- package/dist/mapping/source-map.d.ts +46 -0
- package/dist/mapping/source-map.js +207 -0
- package/dist/orchestrator/dts-generator.d.ts +17 -0
- package/dist/orchestrator/dts-generator.js +83 -0
- package/dist/orchestrator/graph-builder.d.ts +18 -0
- package/dist/orchestrator/graph-builder.js +218 -0
- package/dist/orchestrator/semantic-facts-verifier.d.ts +38 -0
- package/dist/orchestrator/semantic-facts-verifier.js +121 -0
- package/dist/orchestrator/semantic-facts.d.ts +141 -0
- package/dist/orchestrator/semantic-facts.js +652 -0
- package/dist/orchestrator/type-checker.d.ts +39 -0
- package/dist/orchestrator/type-checker.js +760 -0
- package/dist/platform/async-runtime.d.ts +8 -0
- package/dist/platform/async-runtime.js +26 -0
- package/dist/platform/generic-strategy.d.ts +101 -0
- package/dist/platform/generic-strategy.js +289 -0
- package/dist/platform/index.d.ts +4 -0
- package/dist/platform/index.js +9 -0
- package/dist/platform/registry.d.ts +21 -0
- package/dist/platform/registry.js +42 -0
- package/dist/platform/toolchain.d.ts +4 -0
- package/dist/platform/toolchain.js +43 -0
- package/dist/preview/client.d.ts +1 -0
- package/dist/preview/client.js +137 -0
- package/dist/preview/server.d.ts +5 -0
- package/dist/preview/server.js +199 -0
- package/dist/profiler/index.d.ts +28 -0
- package/dist/profiler/index.js +28 -0
- package/dist/profiler/profiler.d.ts +95 -0
- package/dist/profiler/profiler.js +338 -0
- package/dist/profiler/types.d.ts +87 -0
- package/dist/profiler/types.js +12 -0
- package/dist/stores/display-profile-store.d.ts +16 -0
- package/dist/stores/display-profile-store.js +48 -0
- package/dist/stores/theme-store.d.ts +13 -0
- package/dist/stores/theme-store.js +30 -0
- package/dist/testing.d.ts +45 -0
- package/dist/testing.js +47 -0
- package/dist/transpile/resolution.d.ts +29 -0
- package/dist/transpile/resolution.js +282 -0
- package/dist/transpile.d.ts +3 -0
- package/dist/transpile.js +722 -0
- package/dist/types.d.ts +217 -0
- package/dist/types.js +1 -0
- package/dist/ui/ui-bridge.d.ts +4 -0
- package/dist/ui/ui-bridge.js +34 -0
- package/dist/ui-hook.d.ts +84 -0
- package/dist/ui-hook.js +45 -0
- package/dist/utils/cli.d.ts +3 -0
- package/dist/utils/cli.js +463 -0
- package/dist/utils/fs.d.ts +4 -0
- package/dist/utils/fs.js +23 -0
- package/dist/utils/logger.d.ts +2 -0
- package/dist/utils/logger.js +8 -0
- package/dist/utils/strings.d.ts +35 -0
- package/dist/utils/strings.js +142 -0
- package/dist/utils/ui.d.ts +66 -0
- package/dist/utils/ui.js +149 -0
- package/dist/watch.d.ts +35 -0
- package/dist/watch.js +111 -0
- package/package.json +127 -0
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
// ---------------------------------------------------------------------------
|
|
2
|
+
// Static (heap-free) async runtime C++ code generator
|
|
3
|
+
//
|
|
4
|
+
// For memory-constrained targets that lack <vector>, <string>, and a heap
|
|
5
|
+
// (e.g. AVR: ATmega328P with 2 KB SRAM), the full Promise<T> runtime in
|
|
6
|
+
// promise-runtime.ts cannot be emitted. This generator produces a drop-in
|
|
7
|
+
// replacement that defines the SAME global symbols the HAL `Async` singleton
|
|
8
|
+
// lowers to:
|
|
9
|
+
//
|
|
10
|
+
// __cuttlefish_async_sleep(ms)
|
|
11
|
+
// __cuttlefish_async_yield()
|
|
12
|
+
// __cuttlefish_async_sleep_until(pollMs)
|
|
13
|
+
// __cuttlefish_async_current_task()
|
|
14
|
+
// cuttlefish_pump_microtasks()
|
|
15
|
+
//
|
|
16
|
+
// with zero dynamic allocation: fixed-size arrays of timer slots and one-shot
|
|
17
|
+
// task slots, function-pointer + void* context (no std::function), and plain
|
|
18
|
+
// C strings (no std::string).
|
|
19
|
+
//
|
|
20
|
+
// Scope: this covers the HAL `Async` API contract (fire-and-forget scheduling
|
|
21
|
+
// and task introspection). It does NOT implement Promise<T>/.then/.catch
|
|
22
|
+
// chaining — AVR cannot host that without heap + type erasure. The separate
|
|
23
|
+
// async-state-machine.ts path already handles `async function` + `await`
|
|
24
|
+
// heap-free on AVR and is not touched here.
|
|
25
|
+
// ---------------------------------------------------------------------------
|
|
26
|
+
/**
|
|
27
|
+
* Generate a heap-free static async runtime for C++ targets without <vector>.
|
|
28
|
+
*
|
|
29
|
+
* @param capacity Fixed number of timer/task slots. Keep small on constrained
|
|
30
|
+
* targets (e.g. 8 on AVR). Caps the number of simultaneously pending
|
|
31
|
+
* Async.sleep / sleepUntil / yield operations.
|
|
32
|
+
*/
|
|
33
|
+
export function generateStaticAsyncRuntime(capacity) {
|
|
34
|
+
return `
|
|
35
|
+
// TypeCAD static (heap-free) async runtime — for targets without <vector>.
|
|
36
|
+
namespace typecad_async_static {
|
|
37
|
+
|
|
38
|
+
// A one-shot callback with an opaque context. The callback returns true while
|
|
39
|
+
// it wants to keep running, false once complete. Function pointer + void* only
|
|
40
|
+
// (no std::function) so no allocation occurs.
|
|
41
|
+
typedef bool (*AsyncCallback)(void*);
|
|
42
|
+
|
|
43
|
+
struct AsyncTask {
|
|
44
|
+
bool active;
|
|
45
|
+
AsyncCallback fn;
|
|
46
|
+
void* ctx;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
struct AsyncTimer {
|
|
50
|
+
bool active;
|
|
51
|
+
bool repeat; // false = one-shot (Async.sleep), true = periodic (Async.sleepUntil)
|
|
52
|
+
unsigned long deadline;
|
|
53
|
+
unsigned long periodMs;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
class StaticAsyncRuntime {
|
|
57
|
+
public:
|
|
58
|
+
static StaticAsyncRuntime& instance() {
|
|
59
|
+
static StaticAsyncRuntime r;
|
|
60
|
+
return r;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// Arm a one-shot timer that elapses after 'ms' milliseconds. Used by
|
|
64
|
+
// Async.sleep(ms). Returns false if no slot is free.
|
|
65
|
+
bool armTimeout(unsigned long ms) {
|
|
66
|
+
for (int i = 0; i < CAP; ++i) {
|
|
67
|
+
if (!_timers[i].active) {
|
|
68
|
+
_timers[i].active = true;
|
|
69
|
+
_timers[i].repeat = false;
|
|
70
|
+
_timers[i].deadline = millis() + ms;
|
|
71
|
+
_timers[i].periodMs = 0;
|
|
72
|
+
return true;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// Arm a periodic timer that re-arms every 'ms' milliseconds. Used by
|
|
79
|
+
// Async.sleepUntil(pollMs) — the condition re-check happens caller-side, so
|
|
80
|
+
// the timer simply fires on a fixed cadence. Returns false if no slot free.
|
|
81
|
+
bool armInterval(unsigned long ms) {
|
|
82
|
+
for (int i = 0; i < CAP; ++i) {
|
|
83
|
+
if (!_timers[i].active) {
|
|
84
|
+
_timers[i].active = true;
|
|
85
|
+
_timers[i].repeat = true;
|
|
86
|
+
_timers[i].deadline = millis() + ms;
|
|
87
|
+
_timers[i].periodMs = ms;
|
|
88
|
+
return true;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return false;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// Enqueue a one-shot task that runs on the next pump cycle. Used by
|
|
95
|
+
// Async.yield(). Returns false if the task table is full.
|
|
96
|
+
bool enqueue(AsyncCallback fn, void* ctx) {
|
|
97
|
+
if (!fn) return false;
|
|
98
|
+
for (int i = 0; i < CAP; ++i) {
|
|
99
|
+
if (!_tasks[i].active) {
|
|
100
|
+
_tasks[i].active = true;
|
|
101
|
+
_tasks[i].fn = fn;
|
|
102
|
+
_tasks[i].ctx = ctx;
|
|
103
|
+
return true;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return false;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// Advance the runtime: expire due timers and run ready tasks. Called from
|
|
110
|
+
// cuttlefish_pump_microtasks(), which the transpiler injects into loop().
|
|
111
|
+
void pump() {
|
|
112
|
+
const unsigned long now = millis();
|
|
113
|
+
// Timers: one-shot slots deactivate on expiry; periodic slots re-arm.
|
|
114
|
+
for (int i = 0; i < CAP; ++i) {
|
|
115
|
+
if (_timers[i].active) {
|
|
116
|
+
// (now - deadline) handles the millis() 32-bit wrap correctly
|
|
117
|
+
if ((long)(now - _timers[i].deadline) >= 0) {
|
|
118
|
+
if (_timers[i].repeat) {
|
|
119
|
+
_timers[i].deadline = now + _timers[i].periodMs;
|
|
120
|
+
} else {
|
|
121
|
+
_timers[i].active = false;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
// One-shot tasks: run once, then deactivate regardless of return value
|
|
127
|
+
// (yield is a single deferred step).
|
|
128
|
+
for (int i = 0; i < CAP; ++i) {
|
|
129
|
+
if (_tasks[i].active) {
|
|
130
|
+
AsyncTask t = _tasks[i];
|
|
131
|
+
_tasks[i].active = false;
|
|
132
|
+
if (t.fn) t.fn(t.ctx);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
private:
|
|
138
|
+
static const int CAP = ${capacity};
|
|
139
|
+
AsyncTimer _timers[CAP];
|
|
140
|
+
AsyncTask _tasks[CAP];
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
// Trivial no-op callback for Async.yield(): it only needs to occupy a slot for
|
|
144
|
+
// one pump cycle so that awaiting code observes a deferred step.
|
|
145
|
+
static bool __yieldNoop(void*) { return false; }
|
|
146
|
+
|
|
147
|
+
} // namespace typecad_async_static
|
|
148
|
+
|
|
149
|
+
// ── Global-scope HAL symbols (the names the HAL Async module emits) ──
|
|
150
|
+
|
|
151
|
+
// Async.sleep(ms) — arm a one-shot timer. No value is returned; on heap-free
|
|
152
|
+
// targets the HAL method's result is fire-and-forget scheduling.
|
|
153
|
+
inline void __cuttlefish_async_sleep(unsigned long ms) {
|
|
154
|
+
typecad_async_static::StaticAsyncRuntime::instance().armTimeout(ms);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// Async.yield() — defer one pump cycle.
|
|
158
|
+
inline void __cuttlefish_async_yield() {
|
|
159
|
+
typecad_async_static::StaticAsyncRuntime::instance().enqueue(
|
|
160
|
+
typecad_async_static::__yieldNoop, 0);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
// Async.sleepUntil(pollMs) — arm a periodic timer at the poll cadence. The
|
|
164
|
+
// caller's condition is re-evaluated each time the timer elapses.
|
|
165
|
+
inline void __cuttlefish_async_sleep_until(unsigned long pollMs) {
|
|
166
|
+
typecad_async_static::StaticAsyncRuntime::instance().armInterval(pollMs);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// Async.currentTask() — name of the currently executing task.
|
|
170
|
+
inline const char* __cuttlefish_async_current_task() {
|
|
171
|
+
return "main";
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
// Pump entry called from the transpiler-generated loop(). Advances timers and
|
|
175
|
+
// drains one-shot tasks. Same name as the heap-based runtime so the emitter's
|
|
176
|
+
// loop injection is identical across targets.
|
|
177
|
+
inline void cuttlefish_pump_microtasks() {
|
|
178
|
+
typecad_async_static::StaticAsyncRuntime::instance().pump();
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
// HAL-level wait for pin edge — polling-based implementation for static
|
|
182
|
+
// (heap-free) targets. Blocks the current task until the pin edge is detected
|
|
183
|
+
// or the timeout elapses. An edge is a transition: for RISING, the pin must
|
|
184
|
+
// first be LOW then go HIGH; for FALLING, first HIGH then go LOW.
|
|
185
|
+
inline void __cuttlefish_wait_pin_edge(int pin, int mode, long timeout) {
|
|
186
|
+
int targetState = (mode == RISING) ? HIGH : LOW;
|
|
187
|
+
int idleState = (mode == RISING) ? LOW : HIGH;
|
|
188
|
+
unsigned long start = millis();
|
|
189
|
+
// Phase 1: wait for the pin to be in the idle state (the "before" level)
|
|
190
|
+
while (digitalRead(pin) != idleState) {
|
|
191
|
+
if (timeout >= 0 && (millis() - start >= (unsigned long)timeout)) return;
|
|
192
|
+
delay(1);
|
|
193
|
+
}
|
|
194
|
+
// Phase 2: wait for the transition to the target state (the actual edge)
|
|
195
|
+
while (digitalRead(pin) != targetState) {
|
|
196
|
+
if (timeout >= 0 && (millis() - start >= (unsigned long)timeout)) return;
|
|
197
|
+
delay(1);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
`;
|
|
201
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration for the async runtime on a given platform.
|
|
3
|
+
* Framework packages (Arduino, Native, etc.) return this from their
|
|
4
|
+
* PlatformAsyncStrategy implementation.
|
|
5
|
+
*
|
|
6
|
+
* `scheduler` controls how cooperative microtasks are dispatched:
|
|
7
|
+
* - "microtask" — simple FIFO queue pumped in loop()/main() (current default)
|
|
8
|
+
* - "freertos" — FreeRTOS task notifications / queue (future)
|
|
9
|
+
* - "thread" — std::async background thread (native hosted)
|
|
10
|
+
*
|
|
11
|
+
* `waitForPinEdge` controls how GPIO edge-waiting is implemented:
|
|
12
|
+
* - "interrupt" — attachInterrupt-based (real ISR, preferred)
|
|
13
|
+
* - "polling" — busy-wait loop polling digitalRead (fallback)
|
|
14
|
+
* - "stub" — resolve immediately (testing/debug only)
|
|
15
|
+
*/
|
|
16
|
+
export interface AsyncRuntimeConfig {
|
|
17
|
+
/** Queue capacity for the microtask ring buffer (default: 256). */
|
|
18
|
+
queueCapacity: number;
|
|
19
|
+
/**
|
|
20
|
+
* The co-operative scheduling strategy.
|
|
21
|
+
*/
|
|
22
|
+
scheduler: "microtask" | "freertos" | "thread";
|
|
23
|
+
/**
|
|
24
|
+
* How waitForRising/waitForFalling resolve.
|
|
25
|
+
*/
|
|
26
|
+
waitForPinEdge: "interrupt" | "polling" | "stub";
|
|
27
|
+
/**
|
|
28
|
+
* Whether to include the std::vector / std::function based Promise runtime.
|
|
29
|
+
* Targets without stdlib support (e.g. AVR) set this to false.
|
|
30
|
+
*/
|
|
31
|
+
hasPromiseRuntime: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Whether the platform supports timer-based setTimeout/setInterval
|
|
34
|
+
* (as opposed to cooperative polling).
|
|
35
|
+
*/
|
|
36
|
+
hasTimers: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Names of C++ headers required by the async runtime.
|
|
39
|
+
* e.g. ["<functional>", "<vector>", "<utility>", "<string>"]
|
|
40
|
+
*/
|
|
41
|
+
requiredIncludes: string[];
|
|
42
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// ---------------------------------------------------------------------------
|
|
2
|
+
// Shared async runtime configuration types
|
|
3
|
+
//
|
|
4
|
+
// Defines the PlatformAsyncStrategy sub-interface that framework packages
|
|
5
|
+
// implement to provide platform-specific async/scheduling behavior.
|
|
6
|
+
// The Async HAL module uses these to emit the correct C++ runtime code.
|
|
7
|
+
// ---------------------------------------------------------------------------
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Flat map from dot-path key to scalar constant value.
|
|
3
|
+
*
|
|
4
|
+
* Examples (for Arduino Uno):
|
|
5
|
+
* "id" → "arduino-uno"
|
|
6
|
+
* "mcu" → "ATmega328P"
|
|
7
|
+
* "clockSpeed" → 16000000
|
|
8
|
+
* "memory.flash" → 32768
|
|
9
|
+
* "memory.sram" → 2048
|
|
10
|
+
* "memory.eeprom"→ 1024
|
|
11
|
+
*/
|
|
12
|
+
export type BoardConstants = Map<string, string | number | boolean>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// ---------------------------------------------------------------------------
|
|
2
|
+
// Board constant types
|
|
3
|
+
//
|
|
4
|
+
// Types for compile-time constant extraction from board definitions.
|
|
5
|
+
// The implementation (which uses TypeScript compiler API) remains in CLI.
|
|
6
|
+
// ---------------------------------------------------------------------------
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
/** Fixed-width / builtin scalar type names used by the transpiler. */
|
|
2
|
+
export type CppPrimitiveName = "int" | "long" | "long long" | "unsigned int" | "unsigned long" | "unsigned long long" | "short" | "unsigned short" | "float" | "double" | "long double" | "bool" | "void" | "char" | "signed char" | "unsigned char" | "size_t" | "ssize_t" | "intptr_t" | "uintptr_t" | "ptrdiff_t" | "int8_t" | "int16_t" | "int32_t" | "int64_t" | "uint8_t" | "uint16_t" | "uint32_t" | "uint64_t";
|
|
3
|
+
/**
|
|
4
|
+
* Structured representation of a C++ type.
|
|
5
|
+
*
|
|
6
|
+
* Construct via the `CppTypeIR.*` builders or by parsing a string with
|
|
7
|
+
* `parseCppType`. Inspect via `kind`. Render back to a string with
|
|
8
|
+
* `renderCppType`.
|
|
9
|
+
*/
|
|
10
|
+
export type CppTypeIR =
|
|
11
|
+
/** Builtin scalar (`int`, `double`, `uint8_t`, `void`, …). */
|
|
12
|
+
{
|
|
13
|
+
kind: "primitive";
|
|
14
|
+
name: CppPrimitiveName;
|
|
15
|
+
}
|
|
16
|
+
/** Unresolved / template-parameter / unknown — renders as the literal `auto`. */
|
|
17
|
+
| {
|
|
18
|
+
kind: "auto";
|
|
19
|
+
}
|
|
20
|
+
/** `std::string`. Modeled separately from `primitive` because it is a class
|
|
21
|
+
* type with reference semantics and is detected by `isStringLike`. */
|
|
22
|
+
| {
|
|
23
|
+
kind: "string";
|
|
24
|
+
}
|
|
25
|
+
/** `__tc_str_ptr` sentinel — marks an expression that must be passed as `.c_str()`. */
|
|
26
|
+
| {
|
|
27
|
+
kind: "strPtr";
|
|
28
|
+
}
|
|
29
|
+
/** A user-defined named type (struct/class/enum/typedef/typename) with
|
|
30
|
+
* optional template arguments. The `args` are the *parsed* template args. */
|
|
31
|
+
| {
|
|
32
|
+
kind: "named";
|
|
33
|
+
name: string;
|
|
34
|
+
args?: CppTypeIR[];
|
|
35
|
+
}
|
|
36
|
+
/** Pointer to `base`. Renders as `${render(base)}*`. */
|
|
37
|
+
| {
|
|
38
|
+
kind: "pointer";
|
|
39
|
+
base: CppTypeIR;
|
|
40
|
+
}
|
|
41
|
+
/** Reference to `base`. `isConst` distinguishes `T&` from `const T&`. */
|
|
42
|
+
| {
|
|
43
|
+
kind: "reference";
|
|
44
|
+
base: CppTypeIR;
|
|
45
|
+
isConst: boolean;
|
|
46
|
+
}
|
|
47
|
+
/** Top-level const qualification: `const T` (prefix) or `T const` (suffix). */
|
|
48
|
+
| {
|
|
49
|
+
kind: "qualified";
|
|
50
|
+
base: CppTypeIR;
|
|
51
|
+
isConst: boolean;
|
|
52
|
+
}
|
|
53
|
+
/** `std::vector<element>`. */
|
|
54
|
+
| {
|
|
55
|
+
kind: "vector";
|
|
56
|
+
element: CppTypeIR;
|
|
57
|
+
}
|
|
58
|
+
/** `std::set<element>`. */
|
|
59
|
+
| {
|
|
60
|
+
kind: "set";
|
|
61
|
+
element: CppTypeIR;
|
|
62
|
+
}
|
|
63
|
+
/** `std::map<key, value>`. */
|
|
64
|
+
| {
|
|
65
|
+
kind: "map";
|
|
66
|
+
key: CppTypeIR;
|
|
67
|
+
value: CppTypeIR;
|
|
68
|
+
}
|
|
69
|
+
/** `std::tuple<...elements>`. */
|
|
70
|
+
| {
|
|
71
|
+
kind: "tuple";
|
|
72
|
+
elements: CppTypeIR[];
|
|
73
|
+
}
|
|
74
|
+
/** `std::variant<...members>`. */
|
|
75
|
+
| {
|
|
76
|
+
kind: "variant";
|
|
77
|
+
members: CppTypeIR[];
|
|
78
|
+
}
|
|
79
|
+
/** `std::function<returnType(params...)>`. */
|
|
80
|
+
| {
|
|
81
|
+
kind: "function";
|
|
82
|
+
returnType: CppTypeIR;
|
|
83
|
+
params: CppTypeIR[];
|
|
84
|
+
}
|
|
85
|
+
/** Compile-time fixed-size array: `__tc_StaticArray<element, size>` or
|
|
86
|
+
* C-array `element[size]`. `size` is undefined for `element[]`. */
|
|
87
|
+
| {
|
|
88
|
+
kind: "staticArray";
|
|
89
|
+
element: CppTypeIR;
|
|
90
|
+
size?: number;
|
|
91
|
+
}
|
|
92
|
+
/** C-array decayed form `element[]` / `element[size]` (distinct from
|
|
93
|
+
* `staticArray` which carries the `__tc_StaticArray` marker). */
|
|
94
|
+
| {
|
|
95
|
+
kind: "cArray";
|
|
96
|
+
element: CppTypeIR;
|
|
97
|
+
size?: number;
|
|
98
|
+
}
|
|
99
|
+
/** Coroutine generator pseudo-type `__tc_Generator<yieldType>`. */
|
|
100
|
+
| {
|
|
101
|
+
kind: "generator";
|
|
102
|
+
yieldType: CppTypeIR;
|
|
103
|
+
}
|
|
104
|
+
/** Smart pointer wrappers `std::shared_ptr<inner>` / `std::unique_ptr<inner>`.
|
|
105
|
+
* `wrapper` is the smart-pointer class name. */
|
|
106
|
+
| {
|
|
107
|
+
kind: "smartPointer";
|
|
108
|
+
wrapper: "std::shared_ptr" | "std::unique_ptr";
|
|
109
|
+
inner: CppTypeIR;
|
|
110
|
+
}
|
|
111
|
+
/** Escape hatch for a type token the parser does not yet model explicitly.
|
|
112
|
+
* Renders back as `raw` unchanged. Lets migration be incremental. */
|
|
113
|
+
| {
|
|
114
|
+
kind: "opaque";
|
|
115
|
+
raw: string;
|
|
116
|
+
};
|
|
117
|
+
/** All discriminator strings, useful for exhaustive switches. */
|
|
118
|
+
export type CppTypeKind = CppTypeIR["kind"];
|
|
119
|
+
export declare function splitTemplateArgs(inner: string): string[];
|
|
120
|
+
export declare function parseCppType(s: string): CppTypeIR;
|
|
121
|
+
export declare function renderCppType(ir: CppTypeIR): string;
|
|
122
|
+
/** True for `T*` (any depth of indirection). */
|
|
123
|
+
export declare function isPointer(ir: CppTypeIR): boolean;
|
|
124
|
+
/** True for `T&` (and `const T&`). */
|
|
125
|
+
export declare function isReference(ir: CppTypeIR): boolean;
|
|
126
|
+
/** True for any container that supports element/index access:
|
|
127
|
+
* vector, set, map, staticArray, cArray. */
|
|
128
|
+
export declare function isContainer(ir: CppTypeIR): boolean;
|
|
129
|
+
export declare function isVector(ir: CppTypeIR): boolean;
|
|
130
|
+
export declare function isMap(ir: CppTypeIR): boolean;
|
|
131
|
+
export declare function isSet(ir: CppTypeIR): boolean;
|
|
132
|
+
export declare function isTuple(ir: CppTypeIR): boolean;
|
|
133
|
+
export declare function isVariant(ir: CppTypeIR): boolean;
|
|
134
|
+
export declare function isStdFunction(ir: CppTypeIR): boolean;
|
|
135
|
+
export declare function isStaticArray(ir: CppTypeIR): boolean;
|
|
136
|
+
export declare function isCArray(ir: CppTypeIR): boolean;
|
|
137
|
+
/** True for `std::string` / `__tc_str_ptr` / `const char*`-ish string types.
|
|
138
|
+
* Does NOT consult platform strategy — callers that need platform-aware string
|
|
139
|
+
* detection (e.g. Arduino `String`) should still call `strategy.isStringLikeType`. */
|
|
140
|
+
export declare function isStringLike(ir: CppTypeIR): boolean;
|
|
141
|
+
/** True for builtin scalars (`int`, `double`, …) and `std::string`/`bool`.
|
|
142
|
+
* Corresponds to the `isPrimitiveCppType` helpers in statement-renderer. */
|
|
143
|
+
export declare function isPrimitive(ir: CppTypeIR): boolean;
|
|
144
|
+
/** Peel pointer/reference/const qualification and return the underlying type.
|
|
145
|
+
* `Foo*` → `Foo`, `const Bar&` → `Bar`, `std::vector<T>*` → `std::vector<T>`.
|
|
146
|
+
* Corresponds to the `replace(/\*$/, "").replace(/^const\s+/, "").trim()`
|
|
147
|
+
* idiom scattered through expression-renderer / setup. */
|
|
148
|
+
export declare function bareType(ir: CppTypeIR): CppTypeIR;
|
|
149
|
+
/** Element type of a vector/set/staticArray/cArray, or the value type of a map.
|
|
150
|
+
* Returns undefined for non-containers. Replaces the duplicated
|
|
151
|
+
* `slice("std::vector<".length, -1).trim()` copies. */
|
|
152
|
+
export declare function elementOf(ir: CppTypeIR): CppTypeIR | undefined;
|
|
153
|
+
/** Coarse kind bucket for the snprintf format-specifier dispatcher
|
|
154
|
+
* (`emit/snprintf-helpers.ts`). Replaces the `cppType === "int" || ...` ladder. */
|
|
155
|
+
export type CppFormatKind = "bool" | "int" | "uint" | "long" | "ulong" | "float" | "string" | "char" | "pointer" | "other";
|
|
156
|
+
export declare function formatKindOf(ir: CppTypeIR): CppFormatKind;
|
|
157
|
+
export declare const CppTypeIR: {
|
|
158
|
+
primitive: (name: CppPrimitiveName) => CppTypeIR;
|
|
159
|
+
auto: () => CppTypeIR;
|
|
160
|
+
string: () => CppTypeIR;
|
|
161
|
+
bool: () => CppTypeIR;
|
|
162
|
+
void: () => CppTypeIR;
|
|
163
|
+
int: () => CppTypeIR;
|
|
164
|
+
double: () => CppTypeIR;
|
|
165
|
+
named: (name: string, args?: CppTypeIR[]) => CppTypeIR;
|
|
166
|
+
pointer: (base: CppTypeIR) => CppTypeIR;
|
|
167
|
+
reference: (base: CppTypeIR, isConst?: boolean) => CppTypeIR;
|
|
168
|
+
const_: (base: CppTypeIR) => CppTypeIR;
|
|
169
|
+
vector: (element: CppTypeIR) => CppTypeIR;
|
|
170
|
+
set: (element: CppTypeIR) => CppTypeIR;
|
|
171
|
+
map: (key: CppTypeIR, value: CppTypeIR) => CppTypeIR;
|
|
172
|
+
tuple: (elements: CppTypeIR[]) => CppTypeIR;
|
|
173
|
+
variant: (members: CppTypeIR[]) => CppTypeIR;
|
|
174
|
+
function: (returnType: CppTypeIR, params: CppTypeIR[]) => CppTypeIR;
|
|
175
|
+
staticArray: (element: CppTypeIR, size?: number) => CppTypeIR;
|
|
176
|
+
cArray: (element: CppTypeIR, size?: number) => CppTypeIR;
|
|
177
|
+
generator: (yieldType: CppTypeIR) => CppTypeIR;
|
|
178
|
+
smartPointer: (wrapper: "std::shared_ptr" | "std::unique_ptr", inner: CppTypeIR) => CppTypeIR;
|
|
179
|
+
strPtr: () => CppTypeIR;
|
|
180
|
+
opaque: (raw: string) => CppTypeIR;
|
|
181
|
+
};
|
|
182
|
+
export declare function parsedIsPointer(cppType: string): boolean;
|
|
183
|
+
export declare function parsedIsStringLike(cppType: string): boolean;
|
|
184
|
+
export declare function parsedIsPrimitive(cppType: string): boolean;
|
|
185
|
+
export declare function parsedIsContainer(cppType: string): boolean;
|
|
186
|
+
export declare function parsedIsVector(cppType: string): boolean;
|
|
187
|
+
export declare function parsedIsMap(cppType: string): boolean;
|
|
188
|
+
export declare function parsedIsSet(cppType: string): boolean;
|
|
189
|
+
export declare function parsedIsTuple(cppType: string): boolean;
|
|
190
|
+
export declare function parsedIsVariant(cppType: string): boolean;
|
|
191
|
+
export declare function parsedIsStaticArray(cppType: string): boolean;
|
|
192
|
+
/** True for `std::string` (and `std::string&`, `const std::string`, etc.). */
|
|
193
|
+
export declare function parsedIsStdString(cppType: string): boolean;
|
|
194
|
+
export declare function parsedElementOf(cppType: string): CppTypeIR | undefined;
|
|
195
|
+
/** Element/value type of a container, rendered back to a string. Replaces the
|
|
196
|
+
* `slice("std::vector<".length, -1).trim()` idiom at consumer sites. */
|
|
197
|
+
export declare function parsedElementString(cppType: string): string | undefined;
|
|
198
|
+
/** Bare (pointer/const/reference-stripped) type rendered as a string. Replaces
|
|
199
|
+
* `cppType.replace(/\*$/, "").replace(/^const\s+/, "").trim()` at consumer sites. */
|
|
200
|
+
export declare function parsedBareString(cppType: string): string;
|
|
201
|
+
export declare function parsedBareType(cppType: string): CppTypeIR;
|
|
202
|
+
/**
|
|
203
|
+
* Collect every user-named type referenced anywhere inside a C++ type string
|
|
204
|
+
* (including nested template args, pointer bases, vector elements, etc.).
|
|
205
|
+
* Replaces the historical "match all identifiers then filter primitives"
|
|
206
|
+
* idiom used for dependency tracking in call-graph analysis.
|
|
207
|
+
*
|
|
208
|
+
* Returns only `named`-kind names — primitives, `std::string`, `auto`, etc.
|
|
209
|
+
* are excluded because they are not user-defined types.
|
|
210
|
+
*/
|
|
211
|
+
export declare function collectNamedTypes(ir: CppTypeIR): string[];
|
|
212
|
+
/** String-in convenience for `collectNamedTypes(parseCppType(s))`. */
|
|
213
|
+
export declare function parsedCollectNamedTypes(cppType: string): string[];
|
|
214
|
+
/** True if the type is a plain struct/class name with no template args, pointer,
|
|
215
|
+
* reference, array, or container wrapper — i.e. the kind of type that a
|
|
216
|
+
* `return null` should lower to `return {};` (value-init).
|
|
217
|
+
* Replaces the `!includes("<") && !endsWith("*") && !endsWith("]")` idiom. */
|
|
218
|
+
export declare function parsedIsPlainStructType(cppType: string): boolean;
|
|
219
|
+
/**
|
|
220
|
+
* True for types that own a string buffer and therefore need `.c_str()` when
|
|
221
|
+
* passed to a C variadic (printf/snprintf): `std::string`, `__tc_str_ptr`,
|
|
222
|
+
* and platform string types like Arduino `String`. NOT true for `const char*`
|
|
223
|
+
* / `char*`, which are already C-strings.
|
|
224
|
+
*
|
|
225
|
+
* This is the structured replacement for the
|
|
226
|
+
* `normalized === "std::string" || normalized === "String" || normalized === "__tc_str_ptr"`
|
|
227
|
+
* idiom in the snprintf/expression renderers.
|
|
228
|
+
*/
|
|
229
|
+
export declare function needsCStrForStringLike(cppType: string): boolean;
|