xbintsc 0.6.28 → 0.7.6
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/dist/src/ast/common.d.ts +10 -0
- package/dist/src/binder/declarations.d.ts +1 -0
- package/dist/src/binder/declarations.js +37 -0
- package/dist/src/binder/declarations.js.map +1 -1
- package/dist/src/binder/references.js +12 -0
- package/dist/src/binder/references.js.map +1 -1
- package/dist/src/checker/globals.js +1 -0
- package/dist/src/checker/globals.js.map +1 -1
- package/dist/src/checker/source.js +4 -0
- package/dist/src/checker/source.js.map +1 -1
- package/dist/src/checker/type-system.d.ts +5 -0
- package/dist/src/checker/type-system.js +22 -3
- package/dist/src/checker/type-system.js.map +1 -1
- package/dist/src/cli/help.d.ts +1 -1
- package/dist/src/cli/main.js +15 -3
- package/dist/src/cli/main.js.map +1 -1
- package/dist/src/codegen/generator/calls/access.js +29 -11
- package/dist/src/codegen/generator/calls/access.js.map +1 -1
- package/dist/src/codegen/generator/calls/element-inline.d.ts +42 -0
- package/dist/src/codegen/generator/calls/element-inline.js +388 -0
- package/dist/src/codegen/generator/calls/element-inline.js.map +1 -0
- package/dist/src/codegen/generator/calls/invocation.js +95 -1
- package/dist/src/codegen/generator/calls/invocation.js.map +1 -1
- package/dist/src/codegen/generator/calls/super.js +3 -4
- package/dist/src/codegen/generator/calls/super.js.map +1 -1
- package/dist/src/codegen/generator/calls/unwrap.d.ts +18 -0
- package/dist/src/codegen/generator/calls/unwrap.js +45 -0
- package/dist/src/codegen/generator/calls/unwrap.js.map +1 -0
- package/dist/src/codegen/generator/calls.d.ts +3 -1
- package/dist/src/codegen/generator/calls.js +3 -1
- package/dist/src/codegen/generator/calls.js.map +1 -1
- package/dist/src/codegen/generator/debug.js +20 -3
- package/dist/src/codegen/generator/debug.js.map +1 -1
- package/dist/src/codegen/generator/expressions/assignment.js +24 -2
- package/dist/src/codegen/generator/expressions/assignment.js.map +1 -1
- package/dist/src/codegen/generator/expressions/global-values.d.ts +19 -0
- package/dist/src/codegen/generator/expressions/global-values.js +49 -0
- package/dist/src/codegen/generator/expressions/global-values.js.map +1 -0
- package/dist/src/codegen/generator/expressions/module-values.d.ts +6 -0
- package/dist/src/codegen/generator/expressions/module-values.js +51 -17
- package/dist/src/codegen/generator/expressions/module-values.js.map +1 -1
- package/dist/src/codegen/generator/expressions/primary.d.ts +0 -2
- package/dist/src/codegen/generator/expressions/primary.js +13 -29
- package/dist/src/codegen/generator/expressions/primary.js.map +1 -1
- package/dist/src/codegen/generator/expressions.d.ts +2 -1
- package/dist/src/codegen/generator/expressions.js +2 -1
- package/dist/src/codegen/generator/expressions.js.map +1 -1
- package/dist/src/codegen/generator/generator.js +4 -0
- package/dist/src/codegen/generator/generator.js.map +1 -1
- package/dist/src/codegen/generator/layout.d.ts +65 -0
- package/dist/src/codegen/generator/layout.js +50 -0
- package/dist/src/codegen/generator/layout.js.map +1 -0
- package/dist/src/codegen/generator/lookup-tables.d.ts +22 -0
- package/dist/src/codegen/generator/lookup-tables.js +48 -0
- package/dist/src/codegen/generator/lookup-tables.js.map +1 -0
- package/dist/src/codegen/generator/module.js +38 -7
- package/dist/src/codegen/generator/module.js.map +1 -1
- package/dist/src/codegen/generator/state.js +21 -0
- package/dist/src/codegen/generator/state.js.map +1 -1
- package/dist/src/codegen/generator/tables.d.ts +2 -6
- package/dist/src/codegen/generator/tables.js +18 -12
- package/dist/src/codegen/generator/tables.js.map +1 -1
- package/dist/src/diagnostics/diagnostic.js +1 -1
- package/dist/src/diagnostics/diagnostic.js.map +1 -1
- package/dist/src/diagnostics/source-text.d.ts +37 -9
- package/dist/src/diagnostics/source-text.js +124 -23
- package/dist/src/diagnostics/source-text.js.map +1 -1
- package/dist/src/diagnostics/source.d.ts +16 -6
- package/dist/src/diagnostics/source.js +25 -4
- package/dist/src/diagnostics/source.js.map +1 -1
- package/dist/src/driver/build-key.d.ts +14 -0
- package/dist/src/driver/build-key.js +6 -1
- package/dist/src/driver/build-key.js.map +1 -1
- package/dist/src/driver/bundler/commonjs.d.ts +9 -2
- package/dist/src/driver/bundler/commonjs.js +11 -4
- package/dist/src/driver/bundler/commonjs.js.map +1 -1
- package/dist/src/driver/bundler/concatenate.d.ts +20 -0
- package/dist/src/driver/bundler/concatenate.js +79 -8
- package/dist/src/driver/bundler/concatenate.js.map +1 -1
- package/dist/src/driver/bundler/deferred.d.ts +29 -1
- package/dist/src/driver/bundler/deferred.js +114 -5
- package/dist/src/driver/bundler/deferred.js.map +1 -1
- package/dist/src/driver/bundler/dynamic-import.d.ts +6 -0
- package/dist/src/driver/bundler/dynamic-import.js +59 -3
- package/dist/src/driver/bundler/dynamic-import.js.map +1 -1
- package/dist/src/driver/bundler/graph.d.ts +13 -0
- package/dist/src/driver/bundler/graph.js +4 -4
- package/dist/src/driver/bundler/graph.js.map +1 -1
- package/dist/src/driver/bundler/merge.js +43 -13
- package/dist/src/driver/bundler/merge.js.map +1 -1
- package/dist/src/driver/bundler/namespace-object.d.ts +11 -0
- package/dist/src/driver/bundler/namespace-object.js +32 -0
- package/dist/src/driver/bundler/namespace-object.js.map +1 -1
- package/dist/src/driver/bundler/reexport-resolution.js +11 -2
- package/dist/src/driver/bundler/reexport-resolution.js.map +1 -1
- package/dist/src/driver/bundler/symbols.d.ts +4 -0
- package/dist/src/driver/bundler/symbols.js +14 -1
- package/dist/src/driver/bundler/symbols.js.map +1 -1
- package/dist/src/driver/compiler.js +13 -3
- package/dist/src/driver/compiler.js.map +1 -1
- package/dist/src/driver/config.d.ts +1 -1
- package/dist/src/driver/frontend.js +3 -4
- package/dist/src/driver/frontend.js.map +1 -1
- package/dist/src/driver/options.d.ts +1 -4
- package/dist/src/driver/runtime-lib.d.ts +27 -0
- package/dist/src/driver/runtime-lib.js +78 -2
- package/dist/src/driver/runtime-lib.js.map +1 -1
- package/dist/src/driver/runtime-objects.d.ts +1 -1
- package/dist/src/driver/runtime-objects.js +28 -5
- package/dist/src/driver/runtime-objects.js.map +1 -1
- package/dist/src/driver/toolchain.js +28 -5
- package/dist/src/driver/toolchain.js.map +1 -1
- package/dist/src/driver/version.d.ts +1 -1
- package/dist/src/driver/version.js +1 -1
- package/dist/src/driver/version.js.map +1 -1
- package/dist/src/extensions/gui/html.js +42 -10
- package/dist/src/extensions/gui/html.js.map +1 -1
- package/dist/src/extensions/gui/index.js +48 -0
- package/dist/src/extensions/gui/index.js.map +1 -1
- package/dist/src/extensions/node/buffer/index.d.ts +5 -4
- package/dist/src/extensions/node/buffer/index.js +5 -4
- package/dist/src/extensions/node/buffer/index.js.map +1 -1
- package/dist/src/extensions/node/events/index.js +8 -1
- package/dist/src/extensions/node/events/index.js.map +1 -1
- package/dist/src/extensions/node/fs/callbacks.d.ts +9 -0
- package/dist/src/extensions/node/fs/callbacks.js +42 -0
- package/dist/src/extensions/node/fs/callbacks.js.map +1 -0
- package/dist/src/extensions/node/fs/index.d.ts +2 -3
- package/dist/src/extensions/node/fs/index.js +11 -4
- package/dist/src/extensions/node/fs/index.js.map +1 -1
- package/dist/src/extensions/node/process/index.d.ts +10 -3
- package/dist/src/extensions/node/process/index.js +30 -5
- package/dist/src/extensions/node/process/index.js.map +1 -1
- package/dist/src/extensions/registry.d.ts +27 -0
- package/dist/src/extensions/registry.js +13 -4
- package/dist/src/extensions/registry.js.map +1 -1
- package/dist/src/lexer/scanner.d.ts +7 -1
- package/dist/src/lexer/scanner.js +15 -0
- package/dist/src/lexer/scanner.js.map +1 -1
- package/dist/src/parser/context.d.ts +10 -0
- package/dist/src/parser/context.js +42 -3
- package/dist/src/parser/context.js.map +1 -1
- package/dist/src/parser/expressions.js +2 -2
- package/dist/src/parser/expressions.js.map +1 -1
- package/dist/src/parser/helpers.d.ts +8 -0
- package/dist/src/parser/helpers.js +21 -0
- package/dist/src/parser/helpers.js.map +1 -1
- package/dist/src/parser/literals.js +6 -2
- package/dist/src/parser/literals.js.map +1 -1
- package/dist/tests/binder/binder.test.js +43 -0
- package/dist/tests/binder/binder.test.js.map +1 -1
- package/dist/tests/cli/main.test.js +9 -0
- package/dist/tests/cli/main.test.js.map +1 -1
- package/dist/tests/codegen/element-layout.test.d.ts +19 -0
- package/dist/tests/codegen/element-layout.test.js +80 -0
- package/dist/tests/codegen/element-layout.test.js.map +1 -0
- package/dist/tests/codegen/expressions.test.js +25 -0
- package/dist/tests/codegen/expressions.test.js.map +1 -1
- package/dist/tests/codegen/llvm.test.js +28 -0
- package/dist/tests/codegen/llvm.test.js.map +1 -1
- package/dist/tests/diagnostics/diagnostic.test.js +9 -0
- package/dist/tests/diagnostics/diagnostic.test.js.map +1 -1
- package/dist/tests/diagnostics/source-text.test.d.ts +1 -0
- package/dist/tests/diagnostics/source-text.test.js +50 -0
- package/dist/tests/diagnostics/source-text.test.js.map +1 -0
- package/dist/tests/diagnostics/source.test.js +17 -0
- package/dist/tests/diagnostics/source.test.js.map +1 -1
- package/dist/tests/driver/build-key.test.d.ts +1 -0
- package/dist/tests/driver/build-key.test.js +49 -0
- package/dist/tests/driver/build-key.test.js.map +1 -0
- package/dist/tests/driver/bundler-resolve.test.js +12 -0
- package/dist/tests/driver/bundler-resolve.test.js.map +1 -1
- package/dist/tests/driver/commonjs-prelude.test.d.ts +11 -0
- package/dist/tests/driver/commonjs-prelude.test.js +69 -0
- package/dist/tests/driver/commonjs-prelude.test.js.map +1 -0
- package/dist/tests/driver/compiler.test.js +42 -1
- package/dist/tests/driver/compiler.test.js.map +1 -1
- package/dist/tests/driver/html-deferred-cycles.test.d.ts +10 -0
- package/dist/tests/driver/html-deferred-cycles.test.js +75 -0
- package/dist/tests/driver/html-deferred-cycles.test.js.map +1 -0
- package/dist/tests/driver/namespace-type-exports.test.d.ts +9 -0
- package/dist/tests/driver/namespace-type-exports.test.js +59 -0
- package/dist/tests/driver/namespace-type-exports.test.js.map +1 -0
- package/dist/tests/driver/runtime-lib.test.js +49 -1
- package/dist/tests/driver/runtime-lib.test.js.map +1 -1
- package/dist/tests/driver/toolchain.test.js +8 -1
- package/dist/tests/driver/toolchain.test.js.map +1 -1
- package/dist/tests/driver/usage.test.js +2 -1
- package/dist/tests/driver/usage.test.js.map +1 -1
- package/dist/tests/e2e/async-await.test.js +16 -0
- package/dist/tests/e2e/async-await.test.js.map +1 -1
- package/dist/tests/e2e/compile-basics.test.js +53 -0
- package/dist/tests/e2e/compile-basics.test.js.map +1 -1
- package/dist/tests/e2e/compile-builtins.test.js +29 -0
- package/dist/tests/e2e/compile-builtins.test.js.map +1 -1
- package/dist/tests/e2e/compile-deferred-marker.test.d.ts +14 -0
- package/dist/tests/e2e/compile-deferred-marker.test.js +68 -0
- package/dist/tests/e2e/compile-deferred-marker.test.js.map +1 -0
- package/dist/tests/e2e/compile-deferred-reexport.test.d.ts +12 -0
- package/dist/tests/e2e/compile-deferred-reexport.test.js +89 -0
- package/dist/tests/e2e/compile-deferred-reexport.test.js.map +1 -0
- package/dist/tests/e2e/compile-error-module.test.d.ts +9 -0
- package/dist/tests/e2e/compile-error-module.test.js +29 -0
- package/dist/tests/e2e/compile-error-module.test.js.map +1 -0
- package/dist/tests/e2e/compile-gc-promises.test.d.ts +11 -0
- package/dist/tests/e2e/compile-gc-promises.test.js +52 -0
- package/dist/tests/e2e/compile-gc-promises.test.js.map +1 -0
- package/dist/tests/e2e/compile-modules.test.js +53 -0
- package/dist/tests/e2e/compile-modules.test.js.map +1 -1
- package/dist/tests/e2e/compile-node-fs-callbacks.test.d.ts +6 -0
- package/dist/tests/e2e/compile-node-fs-callbacks.test.js +46 -0
- package/dist/tests/e2e/compile-node-fs-callbacks.test.js.map +1 -0
- package/dist/tests/e2e/compile-node-inheritance.test.d.ts +6 -0
- package/dist/tests/e2e/compile-node-inheritance.test.js +48 -0
- package/dist/tests/e2e/compile-node-inheritance.test.js.map +1 -0
- package/dist/tests/e2e/compile-node-require.test.d.ts +9 -0
- package/dist/tests/e2e/compile-node-require.test.js +29 -0
- package/dist/tests/e2e/compile-node-require.test.js.map +1 -0
- package/dist/tests/e2e/compile-node-stats.test.d.ts +8 -0
- package/dist/tests/e2e/compile-node-stats.test.js +26 -0
- package/dist/tests/e2e/compile-node-stats.test.js.map +1 -0
- package/dist/tests/e2e/compile-objects-classes.test.js.map +1 -1
- package/dist/tests/e2e/compile-prototype-chain.test.d.ts +8 -0
- package/dist/tests/e2e/compile-prototype-chain.test.js +24 -0
- package/dist/tests/e2e/compile-prototype-chain.test.js.map +1 -0
- package/dist/tests/e2e/compile-proxy.test.d.ts +6 -0
- package/dist/tests/e2e/compile-proxy.test.js +66 -0
- package/dist/tests/e2e/compile-proxy.test.js.map +1 -0
- package/dist/tests/e2e/compile-web-globals.test.d.ts +6 -0
- package/dist/tests/e2e/compile-web-globals.test.js +94 -0
- package/dist/tests/e2e/compile-web-globals.test.js.map +1 -0
- package/dist/tests/e2e/differential-language.test.js +25 -0
- package/dist/tests/e2e/differential-language.test.js.map +1 -1
- package/dist/tests/e2e/differential-values.test.js +59 -0
- package/dist/tests/e2e/differential-values.test.js.map +1 -1
- package/dist/tests/e2e/fetch.test.js +1 -1
- package/dist/tests/e2e/gc.test.js +22 -0
- package/dist/tests/e2e/gc.test.js.map +1 -1
- package/dist/tests/e2e/gui-audio-extra.test.d.ts +12 -0
- package/dist/tests/e2e/gui-audio-extra.test.js +185 -0
- package/dist/tests/e2e/gui-audio-extra.test.js.map +1 -0
- package/dist/tests/e2e/gui-browser.test.js +35 -2
- package/dist/tests/e2e/gui-browser.test.js.map +1 -1
- package/dist/tests/e2e/gui-dom.test.js +88 -0
- package/dist/tests/e2e/gui-dom.test.js.map +1 -1
- package/dist/tests/e2e/gui-script-import-order.test.js +24 -0
- package/dist/tests/e2e/gui-script-import-order.test.js.map +1 -1
- package/dist/tests/e2e/gui-webgl-declarations.test.d.ts +13 -0
- package/dist/tests/e2e/gui-webgl-declarations.test.js +136 -0
- package/dist/tests/e2e/gui-webgl-declarations.test.js.map +1 -0
- package/dist/tests/e2e/gui-webgl-texture-units.test.d.ts +12 -0
- package/dist/tests/e2e/gui-webgl-texture-units.test.js +86 -0
- package/dist/tests/e2e/gui-webgl-texture-units.test.js.map +1 -0
- package/dist/tests/e2e/gui-webgl2-blit.test.js +6 -2
- package/dist/tests/e2e/gui-webgl2-blit.test.js.map +1 -1
- package/dist/tests/e2e/gui-webgl2-msaa-float.test.d.ts +12 -0
- package/dist/tests/e2e/gui-webgl2-msaa-float.test.js +157 -0
- package/dist/tests/e2e/gui-webgl2-msaa-float.test.js.map +1 -0
- package/dist/tests/e2e/gui-webgl2-msaa.test.d.ts +10 -0
- package/dist/tests/e2e/gui-webgl2-msaa.test.js +344 -0
- package/dist/tests/e2e/gui-webgl2-msaa.test.js.map +1 -0
- package/dist/tests/e2e/gui-webgl2-target-orientation.test.d.ts +15 -0
- package/dist/tests/e2e/gui-webgl2-target-orientation.test.js +287 -0
- package/dist/tests/e2e/gui-webgl2-target-orientation.test.js.map +1 -0
- package/dist/tests/e2e/gui-webgl2.test.js +59 -1
- package/dist/tests/e2e/gui-webgl2.test.js.map +1 -1
- package/dist/tests/e2e/hang-watchdog.test.d.ts +10 -0
- package/dist/tests/e2e/hang-watchdog.test.js +50 -0
- package/dist/tests/e2e/hang-watchdog.test.js.map +1 -0
- package/dist/tests/e2e/json-stringify-to-json.test.d.ts +10 -0
- package/dist/tests/e2e/json-stringify-to-json.test.js +61 -0
- package/dist/tests/e2e/json-stringify-to-json.test.js.map +1 -0
- package/dist/tests/e2e/method-call-cache.test.d.ts +5 -0
- package/dist/tests/e2e/method-call-cache.test.js +65 -0
- package/dist/tests/e2e/method-call-cache.test.js.map +1 -0
- package/dist/tests/e2e/node-process.test.d.ts +7 -0
- package/dist/tests/e2e/node-process.test.js +50 -0
- package/dist/tests/e2e/node-process.test.js.map +1 -0
- package/dist/tests/e2e/performance-now.test.d.ts +9 -0
- package/dist/tests/e2e/performance-now.test.js +36 -0
- package/dist/tests/e2e/performance-now.test.js.map +1 -0
- package/dist/tests/e2e/property-ic.test.js +33 -0
- package/dist/tests/e2e/property-ic.test.js.map +1 -1
- package/dist/tests/e2e/runtime-coverage-buffer.test.js +31 -0
- package/dist/tests/e2e/runtime-coverage-buffer.test.js.map +1 -1
- package/dist/tests/e2e/shape-interning.test.d.ts +16 -0
- package/dist/tests/e2e/shape-interning.test.js +55 -0
- package/dist/tests/e2e/shape-interning.test.js.map +1 -0
- package/dist/tests/e2e/string-utf16.test.js +9 -0
- package/dist/tests/e2e/string-utf16.test.js.map +1 -1
- package/dist/tests/e2e/typed-array-views.test.js +26 -0
- package/dist/tests/e2e/typed-array-views.test.js.map +1 -1
- package/dist/tests/e2e/url-search-params.test.js +19 -0
- package/dist/tests/e2e/url-search-params.test.js.map +1 -1
- package/dist/tests/e2e/web-streams.test.js +44 -29
- package/dist/tests/e2e/web-streams.test.js.map +1 -1
- package/dist/tests/extensions/gui.test.js +16 -1
- package/dist/tests/extensions/gui.test.js.map +1 -1
- package/dist/tests/helpers.js +1 -0
- package/dist/tests/helpers.js.map +1 -1
- package/dist/tests/parser/expressions.test.js +36 -0
- package/dist/tests/parser/expressions.test.js.map +1 -1
- package/dist/tests/parser/literals.test.js +19 -0
- package/dist/tests/parser/literals.test.js.map +1 -1
- package/dist/tests/parser/statements.test.js +13 -0
- package/dist/tests/parser/statements.test.js.map +1 -1
- package/doc/ai/cli.md +1 -0
- package/doc/ai/contributing.md +8 -5
- package/doc/ai/extensions.md +12 -3
- package/doc/ai/language-support.md +2 -1
- package/doc/ai/troubleshooting.md +14 -0
- package/doc/ai/zh-CN/cli.md +1 -0
- package/doc/ai/zh-CN/contributing.md +6 -3
- package/doc/ai/zh-CN/extensions.md +10 -2
- package/doc/ai/zh-CN/language-support.md +2 -1
- package/doc/ai/zh-CN/troubleshooting.md +12 -0
- package/doc/gui/api.md +26 -4
- package/doc/gui/dom.md +8 -0
- package/doc/gui/known-issues.md +35 -6
- package/doc/gui/runtime.md +16 -1
- package/doc/gui/webgl.md +97 -26
- package/doc/gui-scripts.md +2 -1
- package/doc/gui.md +8 -5
- package/doc/implemented/binder.md +2 -1
- package/doc/implemented/checker.md +14 -0
- package/doc/implemented/codegen.md +7 -0
- package/doc/implemented/lexer.md +1 -1
- package/doc/implemented/modules.md +23 -1
- package/doc/implemented/node/buffer.md +18 -5
- package/doc/implemented/node/fs.md +22 -1
- package/doc/implemented/node/process.md +65 -5
- package/doc/implemented/node.md +7 -1
- package/doc/implemented/operators.md +3 -1
- package/doc/implemented/parser.md +3 -2
- package/doc/implemented/runtime-core.md +13 -2
- package/doc/implemented/stdlib.md +79 -4
- package/doc/implemented/typed-arrays.md +18 -2
- package/doc/unimplemented/classes.md +1 -0
- package/doc/unimplemented/modules.md +1 -0
- package/doc/unimplemented/stdlib.md +2 -1
- package/doc/xbintsc.config.schema.json +5 -0
- package/doc/zh-CN/gui/api.md +19 -5
- package/doc/zh-CN/gui/dom.md +6 -0
- package/doc/zh-CN/gui/known-issues.md +24 -5
- package/doc/zh-CN/gui/runtime.md +13 -1
- package/doc/zh-CN/gui/webgl.md +20 -7
- package/doc/zh-CN/gui-scripts.md +2 -1
- package/doc/zh-CN/gui.md +4 -1
- package/doc/zh-CN/implemented/binder.md +2 -1
- package/doc/zh-CN/implemented/checker.md +10 -0
- package/doc/zh-CN/implemented/codegen.md +7 -0
- package/doc/zh-CN/implemented/lexer.md +1 -1
- package/doc/zh-CN/implemented/modules.md +17 -1
- package/doc/zh-CN/implemented/node/buffer.md +3 -1
- package/doc/zh-CN/implemented/node/fs.md +19 -1
- package/doc/zh-CN/implemented/node/process.md +59 -5
- package/doc/zh-CN/implemented/node.md +1 -1
- package/doc/zh-CN/implemented/operators.md +2 -1
- package/doc/zh-CN/implemented/parser.md +3 -2
- package/doc/zh-CN/implemented/runtime-core.md +10 -2
- package/doc/zh-CN/implemented/stdlib.md +64 -4
- package/doc/zh-CN/implemented/typed-arrays.md +14 -2
- package/doc/zh-CN/unimplemented/classes.md +1 -0
- package/doc/zh-CN/unimplemented/modules.md +1 -0
- package/doc/zh-CN/unimplemented/stdlib.md +2 -1
- package/package.json +7 -7
- package/runtime/ext_gui/audio.cpp +39 -3
- package/runtime/ext_gui/audio_extra.cpp +353 -0
- package/runtime/ext_gui/audio_extra.h +47 -0
- package/runtime/ext_gui/audio_fft.h +76 -0
- package/runtime/ext_gui/audio_internal.h +21 -0
- package/runtime/ext_gui/audio_mixer.cpp +46 -1
- package/runtime/ext_gui/audio_mixer.h +89 -1
- package/runtime/ext_gui/audio_mixer_extra.cpp +126 -0
- package/runtime/ext_gui/audio_nodes.cpp +242 -0
- package/runtime/ext_gui/audio_nodes_internal.h +81 -0
- package/runtime/ext_gui/audio_nodes_spatial.cpp +375 -0
- package/runtime/ext_gui/browser.cpp +9 -0
- package/runtime/ext_gui/browser_screen.cpp +73 -0
- package/runtime/ext_gui/dom_api_canvas.cpp +9 -1
- package/runtime/ext_gui/dom_api_internal.h +3 -0
- package/runtime/ext_gui/dom_api_node.cpp +21 -0
- package/runtime/ext_gui/dom_api_node_read.cpp +29 -0
- package/runtime/ext_gui/dom_api_proto.cpp +3 -0
- package/runtime/ext_gui/dom_api_webgl2.cpp +16 -11
- package/runtime/ext_gui/dom_api_webgl2_msaa.cpp +64 -0
- package/runtime/ext_gui/dom_api_webgl_compressed.cpp +2 -2
- package/runtime/ext_gui/dom_api_webgl_framebuffer.cpp +68 -11
- package/runtime/ext_gui/dom_api_webgl_methods.h +3 -0
- package/runtime/ext_gui/dom_api_webgl_state.cpp +4 -2
- package/runtime/ext_gui/dom_api_webgl_texture.cpp +6 -6
- package/runtime/ext_gui/gui.cpp +6 -1
- package/runtime/ext_gui/gui_engine.h +2 -0
- package/runtime/ext_gui/gui_events.cpp +13 -8
- package/runtime/ext_gui/gui_webgl.cpp +3 -2
- package/runtime/ext_gui/style_ua.cpp +4 -0
- package/runtime/ext_gui/warnings.cpp +1 -1
- package/runtime/ext_gui/webgl.h +102 -7
- package/runtime/ext_gui/webgl_api.h +3 -2
- package/runtime/ext_gui/webgl_blit.cpp +109 -15
- package/runtime/ext_gui/webgl_blit_color.cpp +264 -0
- package/runtime/ext_gui/webgl_blit_depth.cpp +26 -8
- package/runtime/ext_gui/webgl_buffer.cpp +20 -170
- package/runtime/ext_gui/webgl_context.cpp +117 -169
- package/runtime/ext_gui/webgl_draw.cpp +116 -5
- package/runtime/ext_gui/webgl_draw_buffers.cpp +21 -6
- package/runtime/ext_gui/webgl_draw_setup.cpp +1 -0
- package/runtime/ext_gui/webgl_draw_state.h +2 -0
- package/runtime/ext_gui/webgl_feature.cpp +2 -2
- package/runtime/ext_gui/webgl_feature.h +4 -3
- package/runtime/ext_gui/webgl_framebuffer.cpp +346 -0
- package/runtime/ext_gui/webgl_glsl_rewrite.cpp +78 -47
- package/runtime/ext_gui/webgl_objects.h +16 -2
- package/runtime/ext_gui/webgl_pipeline.cpp +1 -1
- package/runtime/ext_gui/webgl_state.cpp +45 -36
- package/runtime/ext_gui/webgl_targets.cpp +440 -0
- package/runtime/ext_gui/webgl_texture.cpp +81 -25
- package/runtime/ext_gui/window.cpp +8 -0
- package/runtime/ext_node/buffer/buffer.c +5 -4
- package/runtime/ext_node/buffer/parts/byte-access.inc +115 -11
- package/runtime/ext_node/buffer/parts/prototype.inc +4 -1
- package/runtime/ext_node/events/events.c +9 -0
- package/runtime/ext_node/fs/callbacks.c +138 -0
- package/runtime/ext_node/fs/fs_ops.c +28 -15
- package/runtime/ext_node/module/module.c +18 -9
- package/runtime/ext_node/process/process.c +117 -32
- package/runtime/ext_node/process/streams.c +370 -0
- package/runtime/ext_node/process/streams.h +20 -0
- package/runtime/rt.h +63 -27
- package/runtime/rt_binary.h +44 -0
- package/runtime/rt_internal.h +61 -69
- package/runtime/rt_object.h +83 -0
- package/runtime/rt_profile.h +45 -0
- package/runtime/xt_alloc.c +154 -181
- package/runtime/xt_array_buffer.c +99 -71
- package/runtime/xt_async_io.c +3 -0
- package/runtime/xt_builtins.c +29 -24
- package/runtime/xt_constructors.c +102 -2
- package/runtime/xt_containers/access.inc +125 -12
- package/runtime/xt_containers/arrays.inc +2 -1
- package/runtime/xt_containers/cstr_cache.inc +56 -0
- package/runtime/xt_containers/function_prototypes.inc +58 -0
- package/runtime/xt_containers/method_cache.inc +121 -0
- package/runtime/xt_containers/object_keys.inc +58 -0
- package/runtime/xt_containers/objects.inc +59 -75
- package/runtime/xt_containers/shapes.inc +153 -8
- package/runtime/xt_containers.c +5 -0
- package/runtime/xt_exit.c +34 -0
- package/runtime/xt_fetch/headers.inc +1 -0
- package/runtime/xt_fetch/response.inc +28 -8
- package/runtime/xt_fetch/webapi.inc +82 -0
- package/runtime/xt_fetch.c +5 -0
- package/runtime/xt_gc_release.c +70 -0
- package/runtime/xt_gc_stack.c +83 -0
- package/runtime/xt_gc_verify.c +136 -0
- package/runtime/xt_intl.c +224 -0
- package/runtime/xt_io/console.inc +66 -0
- package/runtime/xt_io/exception.inc +66 -1
- package/runtime/xt_io/watchdog.inc +101 -0
- package/runtime/xt_io.c +1 -0
- package/runtime/xt_loop.c +23 -3
- package/runtime/xt_module_values.c +82 -0
- package/runtime/xt_pool.c +151 -0
- package/runtime/xt_profile.c +126 -0
- package/runtime/xt_proxy.c +140 -0
- package/runtime/xt_stdlib/dispatch.inc +104 -9
- package/runtime/xt_stdlib/math.inc +272 -57
- package/runtime/xt_stdlib2/date.inc +7 -1
- package/runtime/xt_stdlib2/json.inc +28 -0
- package/runtime/xt_stdlib2/json_stringify.inc +71 -55
- package/runtime/xt_stdlib2/regexp-match.inc +17 -0
- package/runtime/xt_storage/indexed_db.c +4 -1
- package/runtime/xt_structured_clone.c +2 -1
- package/runtime/xt_typed_array/construction.inc +10 -0
- package/runtime/xt_typed_array/elements.inc +43 -23
- package/runtime/xt_url.c +50 -0
- package/runtime/xt_values/constructors.inc +4 -1
- package/runtime/xt_values/strings.inc +3 -1
- package/runtime/xt_web.h +27 -0
- package/runtime/xt_web_abort.c +373 -0
- package/scripts/build-runtime.ts +8 -0
- package/src/ast/common.ts +10 -0
- package/src/binder/declarations.ts +34 -0
- package/src/binder/references.ts +12 -0
- package/src/checker/globals.ts +1 -0
- package/src/checker/source.ts +3 -0
- package/src/checker/type-system.ts +23 -3
- package/src/cli/main.ts +14 -3
- package/src/codegen/generator/calls/access.ts +28 -10
- package/src/codegen/generator/calls/element-inline.ts +433 -0
- package/src/codegen/generator/calls/invocation.ts +99 -1
- package/src/codegen/generator/calls/super.ts +5 -4
- package/src/codegen/generator/calls/unwrap.ts +47 -0
- package/src/codegen/generator/calls.ts +5 -0
- package/src/codegen/generator/debug.ts +21 -3
- package/src/codegen/generator/expressions/assignment.ts +26 -2
- package/src/codegen/generator/expressions/global-values.ts +57 -0
- package/src/codegen/generator/expressions/module-values.ts +57 -19
- package/src/codegen/generator/expressions/primary.ts +13 -36
- package/src/codegen/generator/expressions.ts +3 -0
- package/src/codegen/generator/generator.ts +4 -0
- package/src/codegen/generator/layout.ts +54 -0
- package/src/codegen/generator/lookup-tables.ts +63 -0
- package/src/codegen/generator/module.ts +38 -7
- package/src/codegen/generator/state.ts +22 -0
- package/src/codegen/generator/tables.ts +18 -12
- package/src/diagnostics/diagnostic.ts +1 -1
- package/src/diagnostics/source-text.ts +118 -22
- package/src/diagnostics/source.ts +29 -7
- package/src/driver/build-key.ts +21 -1
- package/src/driver/bundler/commonjs.ts +12 -5
- package/src/driver/bundler/concatenate.ts +96 -12
- package/src/driver/bundler/deferred.ts +122 -6
- package/src/driver/bundler/dynamic-import.ts +75 -2
- package/src/driver/bundler/graph.ts +4 -4
- package/src/driver/bundler/merge.ts +42 -9
- package/src/driver/bundler/namespace-object.ts +44 -0
- package/src/driver/bundler/reexport-resolution.ts +14 -2
- package/src/driver/bundler/symbols.ts +17 -0
- package/src/driver/compiler.ts +14 -3
- package/src/driver/config.ts +1 -1
- package/src/driver/frontend.ts +3 -4
- package/src/driver/options.ts +1 -4
- package/src/driver/runtime-lib.ts +87 -2
- package/src/driver/runtime-objects.ts +28 -5
- package/src/driver/toolchain.ts +28 -5
- package/src/driver/version.ts +1 -1
- package/src/extensions/gui/html.ts +41 -11
- package/src/extensions/gui/index.ts +50 -1
- package/src/extensions/node/buffer/index.ts +5 -4
- package/src/extensions/node/events/index.ts +8 -1
- package/src/extensions/node/fs/callbacks.ts +45 -0
- package/src/extensions/node/fs/index.ts +11 -4
- package/src/extensions/node/process/index.ts +30 -5
- package/src/extensions/registry.ts +41 -4
- package/src/lexer/scanner.ts +16 -1
- package/src/parser/context.ts +39 -3
- package/src/parser/expressions.ts +2 -2
- package/src/parser/helpers.ts +22 -0
- package/src/parser/literals.ts +6 -2
|
@@ -0,0 +1,370 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* `process.stdin`, `process.stdout` and `process.stderr` for xbintsc.
|
|
3
|
+
*
|
|
4
|
+
* Each stream is an object carrying the base EventEmitter surface from
|
|
5
|
+
* `node_common.h`, so `stdout.on("resize", fn)` and `stdin.on("data", fn)`
|
|
6
|
+
* behave like Node's. The write side is a direct `fputs`/`fflush`; the read side
|
|
7
|
+
* has no portable readiness notification (Windows `select(2)` only understands
|
|
8
|
+
* sockets), so a blocking read runs on the shared async I/O pool and its
|
|
9
|
+
* completion — which executes on the main thread — decodes the bytes and emits
|
|
10
|
+
* the `data` event. Raw mode flips the console/terminal into single-key bytes so
|
|
11
|
+
* a TUI receives escape sequences instead of line-buffered text.
|
|
12
|
+
*
|
|
13
|
+
* The terminal mode is restored by an `atexit` handler: a compiled TUI that
|
|
14
|
+
* exits without calling `setRawMode(false)` (a crash, `process.exit`) must not
|
|
15
|
+
* leave the shell in raw mode.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
#include "../node_common.h"
|
|
19
|
+
#include "streams.h"
|
|
20
|
+
|
|
21
|
+
#include <stdio.h>
|
|
22
|
+
#include <stdlib.h>
|
|
23
|
+
#include <string.h>
|
|
24
|
+
|
|
25
|
+
#if defined(_WIN32)
|
|
26
|
+
#include <fcntl.h>
|
|
27
|
+
#include <io.h>
|
|
28
|
+
#include <windows.h>
|
|
29
|
+
#define XT_STREAM_FILENO _fileno
|
|
30
|
+
#define XT_STREAM_ISATTY _isatty
|
|
31
|
+
#define XT_STREAM_READ _read
|
|
32
|
+
#if !defined(ENABLE_VIRTUAL_TERMINAL_INPUT)
|
|
33
|
+
#define ENABLE_VIRTUAL_TERMINAL_INPUT 0x0200
|
|
34
|
+
#endif
|
|
35
|
+
#else
|
|
36
|
+
#include <errno.h>
|
|
37
|
+
#include <sys/ioctl.h>
|
|
38
|
+
#include <termios.h>
|
|
39
|
+
#include <unistd.h>
|
|
40
|
+
#define XT_STREAM_FILENO fileno
|
|
41
|
+
#define XT_STREAM_ISATTY isatty
|
|
42
|
+
#define XT_STREAM_READ read
|
|
43
|
+
#endif
|
|
44
|
+
|
|
45
|
+
/** Bytes requested per stdin read; also the largest chunk a `data` event sees. */
|
|
46
|
+
#define XT_STDIN_CHUNK 4096
|
|
47
|
+
|
|
48
|
+
static xt_value xt_stream_stdout = 0;
|
|
49
|
+
static xt_value xt_stream_stderr = 0;
|
|
50
|
+
static xt_value xt_stream_stdin = 0;
|
|
51
|
+
|
|
52
|
+
/* -- terminal geometry ---------------------------------------------------- */
|
|
53
|
+
|
|
54
|
+
static int xt_stream_is_tty(FILE *stream) {
|
|
55
|
+
int fd = XT_STREAM_FILENO(stream);
|
|
56
|
+
return fd >= 0 && XT_STREAM_ISATTY(fd) ? 1 : 0;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
static int xt_stream_columns(FILE *stream) {
|
|
60
|
+
#if defined(_WIN32)
|
|
61
|
+
(void)stream;
|
|
62
|
+
#endif
|
|
63
|
+
const char *configured = getenv("COLUMNS");
|
|
64
|
+
if (configured) {
|
|
65
|
+
int columns = atoi(configured);
|
|
66
|
+
if (columns > 0) return columns;
|
|
67
|
+
}
|
|
68
|
+
#if defined(_WIN32)
|
|
69
|
+
CONSOLE_SCREEN_BUFFER_INFO info;
|
|
70
|
+
if (GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &info)) {
|
|
71
|
+
return (int)(info.srWindow.Right - info.srWindow.Left + 1);
|
|
72
|
+
}
|
|
73
|
+
#else
|
|
74
|
+
struct winsize size;
|
|
75
|
+
if (ioctl(XT_STREAM_FILENO(stream), TIOCGWINSZ, &size) == 0 && size.ws_col > 0) return (int)size.ws_col;
|
|
76
|
+
#endif
|
|
77
|
+
return 80;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
static int xt_stream_rows(FILE *stream) {
|
|
81
|
+
#if defined(_WIN32)
|
|
82
|
+
(void)stream;
|
|
83
|
+
#endif
|
|
84
|
+
const char *configured = getenv("LINES");
|
|
85
|
+
if (configured) {
|
|
86
|
+
int rows = atoi(configured);
|
|
87
|
+
if (rows > 0) return rows;
|
|
88
|
+
}
|
|
89
|
+
#if defined(_WIN32)
|
|
90
|
+
CONSOLE_SCREEN_BUFFER_INFO info;
|
|
91
|
+
if (GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &info)) {
|
|
92
|
+
return (int)(info.srWindow.Bottom - info.srWindow.Top + 1);
|
|
93
|
+
}
|
|
94
|
+
#else
|
|
95
|
+
struct winsize size;
|
|
96
|
+
if (ioctl(XT_STREAM_FILENO(stream), TIOCGWINSZ, &size) == 0 && size.ws_row > 0) return (int)size.ws_row;
|
|
97
|
+
#endif
|
|
98
|
+
return 24;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/* -- output streams ------------------------------------------------------- */
|
|
102
|
+
|
|
103
|
+
static xt_value xt_stream_write(FILE *stream, int32_t argc, xt_value *argv) {
|
|
104
|
+
if (argc > 0) {
|
|
105
|
+
const char *text = xt_string_data(xt_to_string(argv[0]));
|
|
106
|
+
if (text) fputs(text, stream);
|
|
107
|
+
fflush(stream);
|
|
108
|
+
}
|
|
109
|
+
return xt_bool(1);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
static xt_value xt_stream_stdout_write(xt_value thisValue, xt_value env, int32_t argc, xt_value *argv) {
|
|
113
|
+
(void)thisValue;
|
|
114
|
+
(void)env;
|
|
115
|
+
return xt_stream_write(stdout, argc, argv);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
static xt_value xt_stream_stderr_write(xt_value thisValue, xt_value env, int32_t argc, xt_value *argv) {
|
|
119
|
+
(void)thisValue;
|
|
120
|
+
(void)env;
|
|
121
|
+
return xt_stream_write(stderr, argc, argv);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/** `end()` / `destroy()`: flushing is immediate, so ending is a no-op. */
|
|
125
|
+
static xt_value xt_stream_noop(xt_value thisValue, xt_value env, int32_t argc, xt_value *argv) {
|
|
126
|
+
(void)env;
|
|
127
|
+
(void)argc;
|
|
128
|
+
(void)argv;
|
|
129
|
+
return thisValue;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
static xt_value xt_stream_output(FILE *stream, void *write_fn, int fd) {
|
|
133
|
+
xt_value object = xt_object_new();
|
|
134
|
+
xt_node_install_emitter(object);
|
|
135
|
+
xt_node_define_method(object, "write", write_fn);
|
|
136
|
+
xt_node_define_method(object, "end", (void *)xt_stream_noop);
|
|
137
|
+
xt_node_define_method(object, "destroy", (void *)xt_stream_noop);
|
|
138
|
+
xt_node_set(object, "fd", xt_number((double)fd));
|
|
139
|
+
xt_node_set(object, "isTTY", xt_bool(xt_stream_is_tty(stream)));
|
|
140
|
+
xt_node_set(object, "columns", xt_number((double)xt_stream_columns(stream)));
|
|
141
|
+
xt_node_set(object, "rows", xt_number((double)xt_stream_rows(stream)));
|
|
142
|
+
xt_node_set(object, "writable", xt_bool(1));
|
|
143
|
+
return object;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
xt_value xt_process_stdout_object(void) {
|
|
147
|
+
xt_gc_add_root(&xt_stream_stdout);
|
|
148
|
+
if (!xt_stream_stdout) xt_stream_stdout = xt_stream_output(stdout, (void *)xt_stream_stdout_write, 1);
|
|
149
|
+
return xt_stream_stdout;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
xt_value xt_process_stderr_object(void) {
|
|
153
|
+
xt_gc_add_root(&xt_stream_stderr);
|
|
154
|
+
if (!xt_stream_stderr) xt_stream_stderr = xt_stream_output(stderr, (void *)xt_stream_stderr_write, 2);
|
|
155
|
+
return xt_stream_stderr;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/* -- raw mode ------------------------------------------------------------- */
|
|
159
|
+
|
|
160
|
+
#if defined(_WIN32)
|
|
161
|
+
static DWORD xt_stdin_saved_mode;
|
|
162
|
+
static int xt_stdin_saved = 0;
|
|
163
|
+
#else
|
|
164
|
+
static struct termios xt_stdin_saved_termios;
|
|
165
|
+
static int xt_stdin_saved = 0;
|
|
166
|
+
#endif
|
|
167
|
+
static int xt_stdin_raw = 0;
|
|
168
|
+
static int xt_stream_atexit_installed = 0;
|
|
169
|
+
|
|
170
|
+
static void xt_stdin_apply_raw_mode(int enable);
|
|
171
|
+
|
|
172
|
+
static void xt_stdin_restore_terminal(void) { xt_stdin_apply_raw_mode(0); }
|
|
173
|
+
|
|
174
|
+
#if defined(_WIN32)
|
|
175
|
+
static void xt_stdin_apply_raw_mode(int enable) {
|
|
176
|
+
HANDLE handle = GetStdHandle(STD_INPUT_HANDLE);
|
|
177
|
+
DWORD mode;
|
|
178
|
+
if (handle == INVALID_HANDLE_VALUE || !GetConsoleMode(handle, &mode)) return;
|
|
179
|
+
if (!xt_stdin_saved) {
|
|
180
|
+
xt_stdin_saved_mode = mode;
|
|
181
|
+
xt_stdin_saved = 1;
|
|
182
|
+
}
|
|
183
|
+
if (enable) {
|
|
184
|
+
mode &= ~(DWORD)(ENABLE_ECHO_INPUT | ENABLE_LINE_INPUT | ENABLE_PROCESSED_INPUT);
|
|
185
|
+
mode |= ENABLE_VIRTUAL_TERMINAL_INPUT;
|
|
186
|
+
} else if (xt_stdin_saved) {
|
|
187
|
+
mode = xt_stdin_saved_mode;
|
|
188
|
+
}
|
|
189
|
+
SetConsoleMode(handle, mode);
|
|
190
|
+
xt_stdin_raw = enable;
|
|
191
|
+
}
|
|
192
|
+
#else
|
|
193
|
+
static void xt_stdin_apply_raw_mode(int enable) {
|
|
194
|
+
if (!XT_STREAM_ISATTY(0)) return;
|
|
195
|
+
if (!xt_stdin_saved) {
|
|
196
|
+
if (tcgetattr(0, &xt_stdin_saved_termios) != 0) return;
|
|
197
|
+
xt_stdin_saved = 1;
|
|
198
|
+
}
|
|
199
|
+
if (enable) {
|
|
200
|
+
struct termios raw = xt_stdin_saved_termios;
|
|
201
|
+
raw.c_iflag &= ~(tcflag_t)(IXON | ICRNL | BRKINT | INPCK | ISTRIP);
|
|
202
|
+
raw.c_lflag &= ~(tcflag_t)(ICANON | ECHO | ISIG);
|
|
203
|
+
raw.c_cc[VMIN] = 1;
|
|
204
|
+
raw.c_cc[VTIME] = 0;
|
|
205
|
+
tcsetattr(0, TCSAFLUSH, &raw);
|
|
206
|
+
} else {
|
|
207
|
+
tcsetattr(0, TCSAFLUSH, &xt_stdin_saved_termios);
|
|
208
|
+
}
|
|
209
|
+
xt_stdin_raw = enable;
|
|
210
|
+
}
|
|
211
|
+
#endif
|
|
212
|
+
|
|
213
|
+
/* -- stdin reader --------------------------------------------------------- */
|
|
214
|
+
|
|
215
|
+
typedef struct {
|
|
216
|
+
xt_async_job job;
|
|
217
|
+
char *buffer;
|
|
218
|
+
int32_t length;
|
|
219
|
+
int eof;
|
|
220
|
+
} xt_stdin_job;
|
|
221
|
+
|
|
222
|
+
static int xt_stdin_active = 0;
|
|
223
|
+
static int xt_stdin_in_flight = 0;
|
|
224
|
+
static int xt_stdin_eof = 0;
|
|
225
|
+
|
|
226
|
+
static void xt_stdin_job_release(xt_async_job *job) {
|
|
227
|
+
free(((xt_stdin_job *)job)->buffer);
|
|
228
|
+
free(job);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/* Worker thread: only plain memory and a blocking read. */
|
|
232
|
+
static void xt_stdin_job_run(xt_async_job *job) {
|
|
233
|
+
xt_stdin_job *req = (xt_stdin_job *)job;
|
|
234
|
+
int32_t received = 0;
|
|
235
|
+
for (;;) {
|
|
236
|
+
int got = (int)XT_STREAM_READ(0, req->buffer, (unsigned)XT_STDIN_CHUNK);
|
|
237
|
+
if (got > 0) {
|
|
238
|
+
received = (int32_t)got;
|
|
239
|
+
break;
|
|
240
|
+
}
|
|
241
|
+
#if !defined(_WIN32)
|
|
242
|
+
if (got < 0 && errno == EINTR) continue;
|
|
243
|
+
#endif
|
|
244
|
+
received = 0;
|
|
245
|
+
break;
|
|
246
|
+
}
|
|
247
|
+
req->length = received;
|
|
248
|
+
req->eof = received <= 0;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
static void xt_stdin_submit(void);
|
|
252
|
+
|
|
253
|
+
/* Main thread: turn the bytes into a `data` event and queue the next read. */
|
|
254
|
+
static void xt_stdin_job_complete(xt_async_job *job) {
|
|
255
|
+
xt_stdin_job *req = (xt_stdin_job *)job;
|
|
256
|
+
xt_stdin_in_flight = 0;
|
|
257
|
+
xt_value stream = xt_process_stdin_object();
|
|
258
|
+
if (req->length > 0) {
|
|
259
|
+
xt_value chunk = xt_string_new(req->buffer, (size_t)req->length);
|
|
260
|
+
xt_node_emit(stream, "data", 1, &chunk);
|
|
261
|
+
}
|
|
262
|
+
if (req->eof) {
|
|
263
|
+
xt_stdin_eof = 1;
|
|
264
|
+
xt_stdin_active = 0;
|
|
265
|
+
xt_node_emit0(stream, "end");
|
|
266
|
+
xt_node_emit0(stream, "close");
|
|
267
|
+
return;
|
|
268
|
+
}
|
|
269
|
+
if (xt_stdin_active) xt_stdin_submit();
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
static void xt_stdin_submit(void) {
|
|
273
|
+
if (xt_stdin_in_flight || xt_stdin_eof) return;
|
|
274
|
+
xt_stdin_job *req = (xt_stdin_job *)calloc(1, sizeof(xt_stdin_job));
|
|
275
|
+
if (!req) return;
|
|
276
|
+
req->buffer = (char *)malloc(XT_STDIN_CHUNK);
|
|
277
|
+
if (!req->buffer) {
|
|
278
|
+
free(req);
|
|
279
|
+
return;
|
|
280
|
+
}
|
|
281
|
+
req->job.run = xt_stdin_job_run;
|
|
282
|
+
req->job.complete = xt_stdin_job_complete;
|
|
283
|
+
req->job.release = xt_stdin_job_release;
|
|
284
|
+
/* Keep the stream (and therefore its listeners) alive while the read runs. */
|
|
285
|
+
req->job.roots[0] = xt_process_stdin_object();
|
|
286
|
+
xt_stdin_in_flight = 1;
|
|
287
|
+
xt_async_submit(&req->job);
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
/* -- stdin methods -------------------------------------------------------- */
|
|
291
|
+
|
|
292
|
+
static xt_value xt_stdin_resume(xt_value thisValue, xt_value env, int32_t argc, xt_value *argv) {
|
|
293
|
+
(void)env;
|
|
294
|
+
(void)argc;
|
|
295
|
+
(void)argv;
|
|
296
|
+
xt_stdin_active = 1;
|
|
297
|
+
xt_stdin_submit();
|
|
298
|
+
return thisValue;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
static xt_value xt_stdin_pause(xt_value thisValue, xt_value env, int32_t argc, xt_value *argv) {
|
|
302
|
+
(void)env;
|
|
303
|
+
(void)argc;
|
|
304
|
+
(void)argv;
|
|
305
|
+
xt_stdin_active = 0;
|
|
306
|
+
return thisValue;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
static xt_value xt_stdin_set_encoding(xt_value thisValue, xt_value env, int32_t argc, xt_value *argv) {
|
|
310
|
+
(void)env;
|
|
311
|
+
xt_value encoding = xt_arg(argc, argv, 0);
|
|
312
|
+
xt_node_set(thisValue, "encoding", XT_IS_STRING(encoding) ? encoding : xt_string_from_cstr("utf8"));
|
|
313
|
+
return thisValue;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
static xt_value xt_stdin_set_raw_mode(xt_value thisValue, xt_value env, int32_t argc, xt_value *argv) {
|
|
317
|
+
(void)env;
|
|
318
|
+
int enable = argc > 0 && xt_truthy(argv[0]);
|
|
319
|
+
if (!xt_stream_atexit_installed) {
|
|
320
|
+
xt_stream_atexit_installed = 1;
|
|
321
|
+
atexit(xt_stdin_restore_terminal);
|
|
322
|
+
}
|
|
323
|
+
xt_stdin_apply_raw_mode(enable);
|
|
324
|
+
xt_node_set(thisValue, "isRaw", xt_bool(xt_stdin_raw));
|
|
325
|
+
return thisValue;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
/* `stdin.on("data", ...)` switches the stream to flowing mode, like Node. */
|
|
329
|
+
static xt_value xt_stdin_on(xt_value thisValue, xt_value env, int32_t argc, xt_value *argv) {
|
|
330
|
+
xt_value result = xt_node_on_impl(thisValue, env, argc, argv);
|
|
331
|
+
const char *event = xt_node_cstr(xt_arg(argc, argv, 0));
|
|
332
|
+
if (event && strcmp(event, "data") == 0) {
|
|
333
|
+
xt_stdin_active = 1;
|
|
334
|
+
xt_stdin_submit();
|
|
335
|
+
}
|
|
336
|
+
return result;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
static xt_value xt_stdin_destroy(xt_value thisValue, xt_value env, int32_t argc, xt_value *argv) {
|
|
340
|
+
(void)env;
|
|
341
|
+
(void)argc;
|
|
342
|
+
(void)argv;
|
|
343
|
+
xt_stdin_active = 0;
|
|
344
|
+
return thisValue;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
xt_value xt_process_stdin_object(void) {
|
|
348
|
+
xt_gc_add_root(&xt_stream_stdin);
|
|
349
|
+
if (xt_stream_stdin) return xt_stream_stdin;
|
|
350
|
+
#if defined(_WIN32)
|
|
351
|
+
/* Raw reads must not be CRLF-translated by the CRT. */
|
|
352
|
+
_setmode(_fileno(stdin), _O_BINARY);
|
|
353
|
+
#endif
|
|
354
|
+
xt_value object = xt_object_new();
|
|
355
|
+
xt_node_install_emitter(object);
|
|
356
|
+
xt_node_define_method(object, "on", (void *)xt_stdin_on);
|
|
357
|
+
xt_node_define_method(object, "addListener", (void *)xt_stdin_on);
|
|
358
|
+
xt_node_define_method(object, "resume", (void *)xt_stdin_resume);
|
|
359
|
+
xt_node_define_method(object, "pause", (void *)xt_stdin_pause);
|
|
360
|
+
xt_node_define_method(object, "setEncoding", (void *)xt_stdin_set_encoding);
|
|
361
|
+
xt_node_define_method(object, "setRawMode", (void *)xt_stdin_set_raw_mode);
|
|
362
|
+
xt_node_define_method(object, "destroy", (void *)xt_stdin_destroy);
|
|
363
|
+
xt_node_set(object, "fd", xt_number(0));
|
|
364
|
+
xt_node_set(object, "isTTY", xt_bool(xt_stream_is_tty(stdin)));
|
|
365
|
+
xt_node_set(object, "isRaw", xt_bool(0));
|
|
366
|
+
xt_node_set(object, "readable", xt_bool(1));
|
|
367
|
+
xt_node_set(object, "encoding", xt_string_from_cstr("utf8"));
|
|
368
|
+
xt_stream_stdin = object;
|
|
369
|
+
return xt_stream_stdin;
|
|
370
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* The `process.stdin` / `process.stdout` / `process.stderr` singletons.
|
|
3
|
+
*
|
|
4
|
+
* Declared separately from `process.c` so the module stays within the
|
|
5
|
+
* repository's file-size budget; both translation units are compiled by
|
|
6
|
+
* `src/extensions/node/process/index.ts`.
|
|
7
|
+
*/
|
|
8
|
+
#ifndef XT_PROCESS_STREAMS_H
|
|
9
|
+
#define XT_PROCESS_STREAMS_H
|
|
10
|
+
|
|
11
|
+
#include "rt.h"
|
|
12
|
+
|
|
13
|
+
/** The cached `process.stdout` object (an EventEmitter with `write`). */
|
|
14
|
+
xt_value xt_process_stdout_object(void);
|
|
15
|
+
/** The cached `process.stderr` object. */
|
|
16
|
+
xt_value xt_process_stderr_object(void);
|
|
17
|
+
/** The cached `process.stdin` object (an EventEmitter feeding "data" chunks). */
|
|
18
|
+
xt_value xt_process_stdin_object(void);
|
|
19
|
+
|
|
20
|
+
#endif /* XT_PROCESS_STREAMS_H */
|
package/runtime/rt.h
CHANGED
|
@@ -129,6 +129,8 @@ typedef xt_value (*xt_code_fn)(xt_value thisValue, xt_value env, int32_t argc, x
|
|
|
129
129
|
|
|
130
130
|
xt_value xt_arg(int32_t argc, xt_value *argv, int32_t index);
|
|
131
131
|
xt_value xt_closure_new(void *fn, int32_t env_count, xt_value *env);
|
|
132
|
+
/** `import(<expr>)`: resolve a specifier against the linked module table. */
|
|
133
|
+
xt_value xt_dynamic_import(xt_value table, xt_value specifier);
|
|
132
134
|
xt_value xt_closure_call(xt_value fn, int32_t argc, xt_value *argv);
|
|
133
135
|
xt_value xt_call_with_this(xt_value fn, xt_value thisValue, int32_t argc, xt_value *argv);
|
|
134
136
|
xt_value xt_closure_env(xt_value fn, int32_t index);
|
|
@@ -136,6 +138,13 @@ int32_t xt_closure_arity(xt_value fn);
|
|
|
136
138
|
xt_value xt_function_set_metadata(xt_value fn, xt_value name, int32_t arity);
|
|
137
139
|
xt_value xt_this(void);
|
|
138
140
|
xt_value xt_new(xt_value ctor, int32_t argc, xt_value *argv);
|
|
141
|
+
/** The global object value (`globalThis` / Node's `global`), a plain bag. */
|
|
142
|
+
xt_value xt_global_object(void);
|
|
143
|
+
/** The prototype a class chains onto for its `extends` clause. */
|
|
144
|
+
xt_value xt_parent_prototype(xt_value ctor);
|
|
145
|
+
/** `super(...)` from a derived constructor: see `xt_constructors.c`. */
|
|
146
|
+
xt_value xt_super_construct(xt_value thisValue, xt_value owner, xt_value parentProto,
|
|
147
|
+
int32_t argc, xt_value *argv);
|
|
139
148
|
xt_value xt_instance_of(xt_value value, xt_value ctor);
|
|
140
149
|
/** `value instanceof <built-in constructor>`; id from `BUILTIN_INSTANCEOF`. */
|
|
141
150
|
xt_value xt_instance_of_builtin(xt_value value, int32_t id);
|
|
@@ -215,6 +224,16 @@ xt_value xt_object_set_hooks(xt_value obj, const xt_object_hooks *hooks, void *d
|
|
|
215
224
|
xt_value xt_object_prototype(void);
|
|
216
225
|
/** The shared `Function.prototype` object. */
|
|
217
226
|
xt_value xt_function_prototype(void);
|
|
227
|
+
/** A function value's own `.prototype` object, created (with `constructor`) on
|
|
228
|
+
* first use so `Foo.prototype.bar = ...` and `new Foo()` agree. */
|
|
229
|
+
xt_value xt_function_prototype_object(xt_value value);
|
|
230
|
+
/**
|
|
231
|
+
* Install the built-in methods of `kind` (a constructor name such as "Map") on
|
|
232
|
+
* `proto` as unbound first-class closures, so `Map.prototype.get.bind(m)` works.
|
|
233
|
+
*/
|
|
234
|
+
void xt_install_proto_methods(xt_value proto, const char *kind);
|
|
235
|
+
/** `Function.prototype[Symbol.hasInstance]` (cached). */
|
|
236
|
+
xt_value xt_function_has_instance_method(void);
|
|
218
237
|
xt_value xt_object_get(xt_value obj, xt_value key);
|
|
219
238
|
xt_value xt_object_get_prototype(xt_value obj);
|
|
220
239
|
xt_value xt_object_set_prototype(xt_value obj, xt_value proto);
|
|
@@ -258,6 +277,12 @@ xt_value xt_array_ctor(int32_t argc, xt_value *argv);
|
|
|
258
277
|
xt_value xt_object_ctor(int32_t argc, xt_value *argv);
|
|
259
278
|
/** Call `target[name](...)`, falling back to built-in Array/String methods. */
|
|
260
279
|
xt_value xt_call_method(xt_value target, xt_value name, int32_t argc, xt_value *argv);
|
|
280
|
+
/** `obj.name(...)` with a monomorphic method inline cache: `cache` points at
|
|
281
|
+
* three zero-initialised i64 words owned by the generated code. A hit calls the
|
|
282
|
+
* cached slot's current value with `target` as `this`; a miss runs the full
|
|
283
|
+
* dispatch and then fills the cache. */
|
|
284
|
+
xt_value xt_call_method_ic(xt_value target, xt_value name, int32_t argc, xt_value *argv,
|
|
285
|
+
int64_t *cache);
|
|
261
286
|
/** Implements `Math.<name>(...)`; the name is interned by the compiler. */
|
|
262
287
|
xt_value xt_math_call(xt_value name, int32_t argc, xt_value *argv);
|
|
263
288
|
/* The first-class `Math` object (function members as native closures). */
|
|
@@ -272,33 +297,7 @@ xt_value xt_object_static(xt_value name, int32_t argc, xt_value *argv);
|
|
|
272
297
|
/** Implements `Number.<name>(...)` / `String.<name>(...)` statics. */
|
|
273
298
|
xt_value xt_number_static(xt_value name, int32_t argc, xt_value *argv);
|
|
274
299
|
xt_value xt_string_static(xt_value name, int32_t argc, xt_value *argv);
|
|
275
|
-
|
|
276
|
-
xt_value xt_typed_array_ctor_by_name(xt_value name, int32_t argc, xt_value *argv);
|
|
277
|
-
xt_value xt_typed_array_static_by_name(xt_value name, xt_value method, int32_t argc, xt_value *argv);
|
|
278
|
-
xt_value xt_typed_array_prototype(xt_value name);
|
|
279
|
-
/** Bulk access to the bytes an `ArrayBuffer` (or a typed array's backing
|
|
280
|
-
* store) holds, for decoders and encoders that cannot afford one property read
|
|
281
|
-
* per byte. `offset` and `count` are clamped to the buffer and the number of
|
|
282
|
-
* bytes actually transferred is returned. Extensions pass the backing buffer
|
|
283
|
-
* plus a view's `byteOffset`/`byteLength`; see `runtime/ext_gui/audio.cpp`. */
|
|
284
|
-
uint32_t xt_array_buffer_copy_bytes_out(xt_value buffer, uint32_t offset, uint8_t *dst,
|
|
285
|
-
uint32_t count);
|
|
286
|
-
uint32_t xt_array_buffer_copy_bytes_in(xt_value buffer, uint32_t offset, const uint8_t *src,
|
|
287
|
-
uint32_t count);
|
|
288
|
-
/** Allocate a zero-filled `ArrayBuffer` of `byte_length` bytes (the native
|
|
289
|
-
* counterpart of `new ArrayBuffer(n)`). */
|
|
290
|
-
xt_value xt_array_buffer_alloc(uint32_t byte_length);
|
|
291
|
-
/** Typed-array view internals for extensions: whether `value` is a view, the
|
|
292
|
-
* `ArrayBuffer` it views, and the byte offset of the view inside it. */
|
|
293
|
-
int xt_is_typed_array(xt_value value);
|
|
294
|
-
/** Element kind (0..8: U8, I8, U8C, U16, I16, U32, I32, F32, F64), or -1. */
|
|
295
|
-
int xt_typed_array_kind_of(xt_value value);
|
|
296
|
-
/** Read one element (coerced to a number) from a typed-array view. */
|
|
297
|
-
xt_value xt_typed_array_read(xt_value array, uint32_t index);
|
|
298
|
-
xt_value xt_typed_array_backing_buffer(xt_value value);
|
|
299
|
-
uint32_t xt_typed_array_view_offset(xt_value value);
|
|
300
|
-
/** Number of elements in a typed-array view. */
|
|
301
|
-
uint32_t xt_typed_array_length(xt_value value);
|
|
300
|
+
#include "rt_binary.h"
|
|
302
301
|
/** Error-family construction and prototype lookup by constructor name. */
|
|
303
302
|
xt_value xt_error_ctor_by_name(xt_value name, int32_t argc, xt_value *argv);
|
|
304
303
|
xt_value xt_error_prototype(xt_value name);
|
|
@@ -410,6 +409,23 @@ int xt_loop_poll(int timeout_ms);
|
|
|
410
409
|
typedef void (*xt_main_loop_fn)(void);
|
|
411
410
|
void xt_loop_set_main(xt_main_loop_fn fn);
|
|
412
411
|
|
|
412
|
+
/* -- program termination --------------------------------------------------- */
|
|
413
|
+
/*
|
|
414
|
+
* The generated `main` ends with `xt_finish()`, which runs the registered exit
|
|
415
|
+
* hook once (Node's `process` "exit" listeners) and yields the status the
|
|
416
|
+
* program asked for, so `process.exitCode` and `process.exit(n)` reach the
|
|
417
|
+
* shell. Both are core runtime entry points; a program that never touches them
|
|
418
|
+
* links the same code and exits 0.
|
|
419
|
+
*/
|
|
420
|
+
typedef void (*xt_exit_hook)(void);
|
|
421
|
+
/** Register the hook `xt_finish` runs once; replaces any previous hook. */
|
|
422
|
+
void xt_at_exit(xt_exit_hook hook);
|
|
423
|
+
/** Run the exit hook (at most once) and return the program's exit status. */
|
|
424
|
+
int xt_finish(void);
|
|
425
|
+
/** Status reported by `xt_finish`; `process.exitCode = n` sets it. */
|
|
426
|
+
void xt_set_exit_status(int status);
|
|
427
|
+
int xt_get_exit_status(void);
|
|
428
|
+
|
|
413
429
|
/* -- timers --------------------------------------------------------------- */
|
|
414
430
|
/* The JS timer globals, implemented on top of the reactor above. Each returns
|
|
415
431
|
* a numeric id (or `undefined` for the `clear*` pair); callbacks are ordinary
|
|
@@ -475,6 +491,11 @@ xt_value xt_get(xt_value target, xt_value key);
|
|
|
475
491
|
* two zero-initialised i64 words owned by the generated code. */
|
|
476
492
|
xt_value xt_get_ic(xt_value target, xt_value key, int64_t *cache);
|
|
477
493
|
xt_value xt_set(xt_value target, xt_value key, xt_value value);
|
|
494
|
+
/** `obj[key]` read with an element fast path: typed arrays and plain arrays are
|
|
495
|
+
* answered without the general dispatch, everything else goes to `xt_get_ic`. */
|
|
496
|
+
xt_value xt_get_element(xt_value target, xt_value key, int64_t *cache);
|
|
497
|
+
/** `obj[key] = value` with the same element fast path. */
|
|
498
|
+
xt_value xt_set_element(xt_value target, xt_value key, xt_value value);
|
|
478
499
|
/* Materialise a first-class runtime method value (`arr.map`) as an unbound
|
|
479
500
|
* closure that expects the receiver through `this`. Returns `XT_UNDEFINED` when
|
|
480
501
|
* `name` is not a method of `target`, so it can be used as a property fallback. */
|
|
@@ -510,6 +531,10 @@ void xt_stack_push(const char *name, const char *file, int32_t line);
|
|
|
510
531
|
void xt_stack_pop(void);
|
|
511
532
|
/** Set the innermost frame's line (called just before `new Error(...)`). */
|
|
512
533
|
void xt_stack_set_line(int32_t line);
|
|
534
|
+
|
|
535
|
+
/** Milliseconds since the program's time origin — the clock behind
|
|
536
|
+
* `performance.now()` and the timestamp an animation-frame callback receives. */
|
|
537
|
+
double xt_monotonic_ms(void);
|
|
513
538
|
void xt_console_log(int32_t argc, xt_value *argv);
|
|
514
539
|
void xt_console_info(int32_t argc, xt_value *argv);
|
|
515
540
|
void xt_console_warn(int32_t argc, xt_value *argv);
|
|
@@ -525,6 +550,9 @@ xt_value xt_console_table(int32_t argc, xt_value *argv);
|
|
|
525
550
|
xt_value xt_console_time(int32_t argc, xt_value *argv);
|
|
526
551
|
xt_value xt_console_time_end(int32_t argc, xt_value *argv);
|
|
527
552
|
xt_value xt_console_time_log(int32_t argc, xt_value *argv);
|
|
553
|
+
/** The global `console` object: one cached object whose methods are closures,
|
|
554
|
+
* so `const log = console.log` / `console.error.bind(console)` work. */
|
|
555
|
+
xt_value xt_console_object(int32_t argc, xt_value *argv);
|
|
528
556
|
void xt_print(xt_value v);
|
|
529
557
|
void xt_println(xt_value v);
|
|
530
558
|
|
|
@@ -538,6 +566,11 @@ size_t xt_heap_allocations(void);
|
|
|
538
566
|
* that lives outside the heap graph. The slot may be registered before it
|
|
539
567
|
* holds a value; it is marked on every collection and registration is
|
|
540
568
|
* idempotent. `xt_gc_add_root_range` registers `count` consecutive cells.
|
|
569
|
+
*
|
|
570
|
+
* A lazily built value must be registered *before* the allocations that build
|
|
571
|
+
* it. A static cell is outside the conservative stack scan, so a collection
|
|
572
|
+
* between storing the value and registering its slot would sweep an object the
|
|
573
|
+
* program still holds.
|
|
541
574
|
*/
|
|
542
575
|
void xt_gc_add_root(xt_value *slot);
|
|
543
576
|
void xt_gc_add_root_range(xt_value *base, size_t count);
|
|
@@ -557,3 +590,6 @@ void xt_gc_mark_value(xt_value value);
|
|
|
557
590
|
#endif
|
|
558
591
|
|
|
559
592
|
#endif /* xbintsc_RUNTIME_H */
|
|
593
|
+
|
|
594
|
+
|
|
595
|
+
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* xbintsc runtime — binary data: `ArrayBuffer`, typed arrays and `DataView`.
|
|
3
|
+
*
|
|
4
|
+
* Included by `rt.h`. An `ArrayBuffer` owns one `calloc`ed byte block (see
|
|
5
|
+
* `xt_object.buffer_bytes`), and a typed-array view caches the block plus its
|
|
6
|
+
* byte offset, so element access is a `memcpy`-sized read/write instead of a
|
|
7
|
+
* property lookup. The helpers here are what the compiler, the standard library
|
|
8
|
+
* and extensions (audio/image decoders, wasm memories) share.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
#ifndef XT_RT_BINARY_H
|
|
12
|
+
#define XT_RT_BINARY_H
|
|
13
|
+
|
|
14
|
+
/** Typed-array constructor/static/prototype dispatch by constructor name. */
|
|
15
|
+
xt_value xt_typed_array_ctor_by_name(xt_value name, int32_t argc, xt_value *argv);
|
|
16
|
+
xt_value xt_typed_array_static_by_name(xt_value name, xt_value method, int32_t argc, xt_value *argv);
|
|
17
|
+
xt_value xt_typed_array_prototype(xt_value name);
|
|
18
|
+
|
|
19
|
+
/** Bulk access to the bytes an `ArrayBuffer` (or a typed array's backing
|
|
20
|
+
* store) holds, for decoders and encoders that cannot afford one property read
|
|
21
|
+
* per byte. `offset` and `count` are clamped to the buffer and the number of
|
|
22
|
+
* bytes actually transferred is returned. Extensions pass the backing buffer
|
|
23
|
+
* plus a view's `byteOffset`/`byteLength`; see `runtime/ext_gui/audio.cpp`. */
|
|
24
|
+
uint32_t xt_array_buffer_copy_bytes_out(xt_value buffer, uint32_t offset, uint8_t *dst,
|
|
25
|
+
uint32_t count);
|
|
26
|
+
uint32_t xt_array_buffer_copy_bytes_in(xt_value buffer, uint32_t offset, const uint8_t *src,
|
|
27
|
+
uint32_t count);
|
|
28
|
+
/** Allocate a zero-filled `ArrayBuffer` of `byte_length` bytes (the native
|
|
29
|
+
* counterpart of `new ArrayBuffer(n)`). */
|
|
30
|
+
xt_value xt_array_buffer_alloc(uint32_t byte_length);
|
|
31
|
+
|
|
32
|
+
/** Typed-array view internals for extensions: whether `value` is a view, the
|
|
33
|
+
* `ArrayBuffer` it views, and the byte offset of the view inside it. */
|
|
34
|
+
int xt_is_typed_array(xt_value value);
|
|
35
|
+
/** Element kind (0..8: U8, I8, U8C, U16, I16, U32, I32, F32, F64), or -1. */
|
|
36
|
+
int xt_typed_array_kind_of(xt_value value);
|
|
37
|
+
/** Read one element (coerced to a number) from a typed-array view. */
|
|
38
|
+
xt_value xt_typed_array_read(xt_value array, uint32_t index);
|
|
39
|
+
xt_value xt_typed_array_backing_buffer(xt_value value);
|
|
40
|
+
uint32_t xt_typed_array_view_offset(xt_value value);
|
|
41
|
+
/** Number of elements in a typed-array view. */
|
|
42
|
+
uint32_t xt_typed_array_length(xt_value value);
|
|
43
|
+
|
|
44
|
+
#endif /* XT_RT_BINARY_H */
|