diff --git a/example/js/lib/api/DataProvider.d.ts b/example/js/lib/api/DataProvider.d.ts index c4a015644..b590e7bb7 100644 --- a/example/js/lib/api/DataProvider.d.ts +++ b/example/js/lib/api/DataProvider.d.ts @@ -1,18 +1,18 @@ // generated by diplomat-tool import type { pointer, codepoint } from "./diplomat-runtime.d.ts"; - + /** An data provider, capable of loading data keys from some source. * -*See the [Rust documentation for `icu_provider`](https://docs.rs/icu_provider/latest/icu_provider/index.html) for more information. -*/ - - -export class DataProvider { +*See the [Rust documentation for `icu_provider`](https://docs.rs/icu_provider/latest/icu_provider/index.html) for more information. +*/ + + +export class DataProvider { - get ffiValue(): pointer; - - static newStatic(): DataProvider; - - static returnsResult(): boolean; + get ffiValue(): pointer; + + static newStatic(): DataProvider; + + static returnsResult(): boolean; } \ No newline at end of file diff --git a/example/js/lib/api/DataProvider.mjs b/example/js/lib/api/DataProvider.mjs index 01da00c18..c5a07bda8 100644 --- a/example/js/lib/api/DataProvider.mjs +++ b/example/js/lib/api/DataProvider.mjs @@ -2,16 +2,16 @@ import wasm from "./diplomat-wasm.mjs"; import * as diplomatRuntime from "./diplomat-runtime.mjs"; - + /** An data provider, capable of loading data keys from some source. * -*See the [Rust documentation for `icu_provider`](https://docs.rs/icu_provider/latest/icu_provider/index.html) for more information. -*/ +*See the [Rust documentation for `icu_provider`](https://docs.rs/icu_provider/latest/icu_provider/index.html) for more information. +*/ const DataProvider_box_destroy_registry = new FinalizationRegistry((ptr) => { wasm.icu4x_DataProvider_destroy_mv1(ptr); -}); - -export class DataProvider { +}); + +export class DataProvider { // Internal ptr reference: #ptr = null; @@ -38,8 +38,8 @@ export class DataProvider { } get ffiValue() { return this.#ptr; - } - + } + static newStatic() { const result = wasm.icu4x_DataProvider_new_static_mv1(); @@ -48,8 +48,8 @@ export class DataProvider { } finally {} - } - + } + static returnsResult() { const result = wasm.icu4x_DataProvider_returns_result_mv1(); @@ -58,9 +58,9 @@ export class DataProvider { } finally {} - } - - constructor(symbol, ptr, selfEdge) { - return this.#internalConstructor(...arguments) - } + } + + constructor(symbol, ptr, selfEdge) { + return this.#internalConstructor(...arguments) + } } \ No newline at end of file diff --git a/example/js/lib/api/FixedDecimal.d.ts b/example/js/lib/api/FixedDecimal.d.ts index 0b0bf8091..94775de15 100644 --- a/example/js/lib/api/FixedDecimal.d.ts +++ b/example/js/lib/api/FixedDecimal.d.ts @@ -1,18 +1,18 @@ // generated by diplomat-tool import type { pointer, codepoint } from "./diplomat-runtime.d.ts"; - -/** See the [Rust documentation for `FixedDecimal`](https://docs.rs/fixed_decimal/latest/fixed_decimal/struct.FixedDecimal.html) for more information. -*/ - - -export class FixedDecimal { + +/** See the [Rust documentation for `FixedDecimal`](https://docs.rs/fixed_decimal/latest/fixed_decimal/struct.FixedDecimal.html) for more information. +*/ + + +export class FixedDecimal { - get ffiValue(): pointer; - - multiplyPow10(power: number): void; - - toString(): string | null; - - constructor(v: number); + get ffiValue(): pointer; + + multiplyPow10(power: number): void; + + toString(): string | null; + + constructor(v: number); } \ No newline at end of file diff --git a/example/js/lib/api/FixedDecimal.mjs b/example/js/lib/api/FixedDecimal.mjs index 77d08296c..8a8e64335 100644 --- a/example/js/lib/api/FixedDecimal.mjs +++ b/example/js/lib/api/FixedDecimal.mjs @@ -2,14 +2,14 @@ import wasm from "./diplomat-wasm.mjs"; import * as diplomatRuntime from "./diplomat-runtime.mjs"; - -/** See the [Rust documentation for `FixedDecimal`](https://docs.rs/fixed_decimal/latest/fixed_decimal/struct.FixedDecimal.html) for more information. -*/ + +/** See the [Rust documentation for `FixedDecimal`](https://docs.rs/fixed_decimal/latest/fixed_decimal/struct.FixedDecimal.html) for more information. +*/ const FixedDecimal_box_destroy_registry = new FinalizationRegistry((ptr) => { wasm.icu4x_FixedDecimal_destroy_mv1(ptr); -}); - -export class FixedDecimal { +}); + +export class FixedDecimal { // Internal ptr reference: #ptr = null; @@ -36,8 +36,8 @@ export class FixedDecimal { } get ffiValue() { return this.#ptr; - } - + } + #defaultConstructor(v) { const result = wasm.icu4x_FixedDecimal_new_mv1(v); @@ -46,15 +46,15 @@ export class FixedDecimal { } finally {} - } - + } + multiplyPow10(power) {wasm.icu4x_FixedDecimal_multiply_pow10_mv1(this.ffiValue, power); try {} finally {} - } - + } + toString() { const write = new diplomatRuntime.DiplomatWriteBuf(wasm); @@ -67,15 +67,15 @@ export class FixedDecimal { finally { write.free(); } - } - - constructor(v) { - if (arguments[0] === diplomatRuntime.exposeConstructor) { - return this.#internalConstructor(...Array.prototype.slice.call(arguments, 1)); - } else if (arguments[0] === diplomatRuntime.internalConstructor) { - return this.#internalConstructor(...arguments); - } else { - return this.#defaultConstructor(...arguments); - } - } + } + + constructor(v) { + if (arguments[0] === diplomatRuntime.exposeConstructor) { + return this.#internalConstructor(...Array.prototype.slice.call(arguments, 1)); + } else if (arguments[0] === diplomatRuntime.internalConstructor) { + return this.#internalConstructor(...arguments); + } else { + return this.#defaultConstructor(...arguments); + } + } } \ No newline at end of file diff --git a/example/js/lib/api/FixedDecimalFormatter.d.ts b/example/js/lib/api/FixedDecimalFormatter.d.ts index b287f5c48..00f5dad7c 100644 --- a/example/js/lib/api/FixedDecimalFormatter.d.ts +++ b/example/js/lib/api/FixedDecimalFormatter.d.ts @@ -6,18 +6,18 @@ import type { FixedDecimalFormatterOptions_obj } from "./FixedDecimalFormatterOp import type { Locale } from "./Locale" import type { pointer, codepoint } from "./diplomat-runtime.d.ts"; - + /** An Fixed Decimal Format object, capable of formatting a [`FixedDecimal`] as a string. * -*See the [Rust documentation for `FixedDecimalFormatter`](https://docs.rs/icu/latest/icu/decimal/struct.FixedDecimalFormatter.html) for more information. -*/ - - -export class FixedDecimalFormatter { +*See the [Rust documentation for `FixedDecimalFormatter`](https://docs.rs/icu/latest/icu/decimal/struct.FixedDecimalFormatter.html) for more information. +*/ + + +export class FixedDecimalFormatter { - get ffiValue(): pointer; - - static tryNew(locale: Locale, provider: DataProvider, options: FixedDecimalFormatterOptions_obj): FixedDecimalFormatter | null; - - formatWrite(value: FixedDecimal): string; + get ffiValue(): pointer; + + static tryNew(locale: Locale, provider: DataProvider, options: FixedDecimalFormatterOptions_obj): FixedDecimalFormatter | null; + + formatWrite(value: FixedDecimal): string; } \ No newline at end of file diff --git a/example/js/lib/api/FixedDecimalFormatter.mjs b/example/js/lib/api/FixedDecimalFormatter.mjs index 660a7e738..74b513480 100644 --- a/example/js/lib/api/FixedDecimalFormatter.mjs +++ b/example/js/lib/api/FixedDecimalFormatter.mjs @@ -6,16 +6,16 @@ import { Locale } from "./Locale.mjs" import wasm from "./diplomat-wasm.mjs"; import * as diplomatRuntime from "./diplomat-runtime.mjs"; - + /** An Fixed Decimal Format object, capable of formatting a [`FixedDecimal`] as a string. * -*See the [Rust documentation for `FixedDecimalFormatter`](https://docs.rs/icu/latest/icu/decimal/struct.FixedDecimalFormatter.html) for more information. -*/ +*See the [Rust documentation for `FixedDecimalFormatter`](https://docs.rs/icu/latest/icu/decimal/struct.FixedDecimalFormatter.html) for more information. +*/ const FixedDecimalFormatter_box_destroy_registry = new FinalizationRegistry((ptr) => { wasm.icu4x_FixedDecimalFormatter_destroy_mv1(ptr); -}); - -export class FixedDecimalFormatter { +}); + +export class FixedDecimalFormatter { // Internal ptr reference: #ptr = null; @@ -42,8 +42,8 @@ export class FixedDecimalFormatter { } get ffiValue() { return this.#ptr; - } - + } + static tryNew(locale, provider, options) { let functionCleanupArena = new diplomatRuntime.CleanupArena(); @@ -63,8 +63,8 @@ export class FixedDecimalFormatter { diplomatReceive.free(); } - } - + } + formatWrite(value) { const write = new diplomatRuntime.DiplomatWriteBuf(wasm); wasm.icu4x_FixedDecimalFormatter_format_write_mv1(this.ffiValue, value.ffiValue, write.buffer); @@ -76,9 +76,9 @@ export class FixedDecimalFormatter { finally { write.free(); } - } - - constructor(symbol, ptr, selfEdge) { - return this.#internalConstructor(...arguments) - } + } + + constructor(symbol, ptr, selfEdge) { + return this.#internalConstructor(...arguments) + } } \ No newline at end of file diff --git a/example/js/lib/api/FixedDecimalFormatterOptions.d.ts b/example/js/lib/api/FixedDecimalFormatterOptions.d.ts index e4c232ae2..b1b02c6b1 100644 --- a/example/js/lib/api/FixedDecimalFormatterOptions.d.ts +++ b/example/js/lib/api/FixedDecimalFormatterOptions.d.ts @@ -7,9 +7,9 @@ type FixedDecimalFormatterOptions_obj = { someOtherConfig: boolean; }; - - -export class FixedDecimalFormatterOptions { + + +export class FixedDecimalFormatterOptions { get groupingStrategy() : FixedDecimalGroupingStrategy; set groupingStrategy(value: FixedDecimalGroupingStrategy); @@ -21,7 +21,7 @@ export class FixedDecimalFormatterOptions { * Optional fields do not need to be included in the provided object. */ static fromFields(structObj : FixedDecimalFormatterOptions_obj) : FixedDecimalFormatterOptions; - - - constructor(); + + + constructor(); } \ No newline at end of file diff --git a/example/js/lib/api/FixedDecimalFormatterOptions.mjs b/example/js/lib/api/FixedDecimalFormatterOptions.mjs index ce900e0ef..9ed425581 100644 --- a/example/js/lib/api/FixedDecimalFormatterOptions.mjs +++ b/example/js/lib/api/FixedDecimalFormatterOptions.mjs @@ -3,9 +3,9 @@ import { FixedDecimalGroupingStrategy } from "./FixedDecimalGroupingStrategy.mjs import wasm from "./diplomat-wasm.mjs"; import * as diplomatRuntime from "./diplomat-runtime.mjs"; - - -export class FixedDecimalFormatterOptions { + + +export class FixedDecimalFormatterOptions { #groupingStrategy; @@ -31,7 +31,7 @@ export class FixedDecimalFormatterOptions { static fromFields(structObj) { return new FixedDecimalFormatterOptions(diplomatRuntime.exposeConstructor, structObj); } - + #internalConstructor(structObj) { if (typeof structObj !== "object") { throw new Error("FixedDecimalFormatterOptions's constructor takes an object of FixedDecimalFormatterOptions's fields."); @@ -105,8 +105,8 @@ export class FixedDecimalFormatterOptions { structObj.someOtherConfig = someOtherConfigDeref; return new FixedDecimalFormatterOptions(diplomatRuntime.exposeConstructor, structObj); - } - + } + #defaultConstructor() { const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 8, 4, false); @@ -119,15 +119,15 @@ export class FixedDecimalFormatterOptions { finally { diplomatReceive.free(); } - } - - constructor() { - if (arguments[0] === diplomatRuntime.exposeConstructor) { - return this.#internalConstructor(...Array.prototype.slice.call(arguments, 1)); - } else if (arguments[0] === diplomatRuntime.internalConstructor) { - return this.#internalConstructor(...arguments); - } else { - return this.#defaultConstructor(...arguments); - } - } + } + + constructor() { + if (arguments[0] === diplomatRuntime.exposeConstructor) { + return this.#internalConstructor(...Array.prototype.slice.call(arguments, 1)); + } else if (arguments[0] === diplomatRuntime.internalConstructor) { + return this.#internalConstructor(...arguments); + } else { + return this.#defaultConstructor(...arguments); + } + } } \ No newline at end of file diff --git a/example/js/lib/api/FixedDecimalGroupingStrategy.d.ts b/example/js/lib/api/FixedDecimalGroupingStrategy.d.ts index 3e5f5b60b..731fdd844 100644 --- a/example/js/lib/api/FixedDecimalGroupingStrategy.d.ts +++ b/example/js/lib/api/FixedDecimalGroupingStrategy.d.ts @@ -1,9 +1,9 @@ // generated by diplomat-tool import type { pointer, codepoint } from "./diplomat-runtime.d.ts"; - - -export class FixedDecimalGroupingStrategy { + + +export class FixedDecimalGroupingStrategy { static fromValue(value : FixedDecimalGroupingStrategy | string) : FixedDecimalGroupingStrategy; @@ -15,7 +15,7 @@ export class FixedDecimalGroupingStrategy { static Auto : FixedDecimalGroupingStrategy; static Never : FixedDecimalGroupingStrategy; static Always : FixedDecimalGroupingStrategy; - static Min2 : FixedDecimalGroupingStrategy; - - constructor(value: FixedDecimalGroupingStrategy | string ); + static Min2 : FixedDecimalGroupingStrategy; + + constructor(value: FixedDecimalGroupingStrategy | string ); } \ No newline at end of file diff --git a/example/js/lib/api/FixedDecimalGroupingStrategy.mjs b/example/js/lib/api/FixedDecimalGroupingStrategy.mjs index 966d389d5..5a24cb463 100644 --- a/example/js/lib/api/FixedDecimalGroupingStrategy.mjs +++ b/example/js/lib/api/FixedDecimalGroupingStrategy.mjs @@ -2,9 +2,9 @@ import wasm from "./diplomat-wasm.mjs"; import * as diplomatRuntime from "./diplomat-runtime.mjs"; - - -export class FixedDecimalGroupingStrategy { + + +export class FixedDecimalGroupingStrategy { #value = undefined; @@ -65,9 +65,9 @@ export class FixedDecimalGroupingStrategy { static Auto = FixedDecimalGroupingStrategy.#objectValues[0]; static Never = FixedDecimalGroupingStrategy.#objectValues[1]; static Always = FixedDecimalGroupingStrategy.#objectValues[2]; - static Min2 = FixedDecimalGroupingStrategy.#objectValues[3]; - - constructor(value) { - return this.#internalConstructor(...arguments) - } + static Min2 = FixedDecimalGroupingStrategy.#objectValues[3]; + + constructor(value) { + return this.#internalConstructor(...arguments) + } } \ No newline at end of file diff --git a/example/js/lib/api/Locale.d.ts b/example/js/lib/api/Locale.d.ts index 6d53d14d0..058ccd264 100644 --- a/example/js/lib/api/Locale.d.ts +++ b/example/js/lib/api/Locale.d.ts @@ -1,16 +1,16 @@ // generated by diplomat-tool import type { pointer, codepoint } from "./diplomat-runtime.d.ts"; - + /** An Locale, capable of representing strings like `"en-US"`. * -*See the [Rust documentation for `Locale`](https://docs.rs/icu/latest/icu/locid/struct.Locale.html) for more information. -*/ - - -export class Locale { +*See the [Rust documentation for `Locale`](https://docs.rs/icu/latest/icu/locid/struct.Locale.html) for more information. +*/ + + +export class Locale { - get ffiValue(): pointer; - - constructor(name: string); + get ffiValue(): pointer; + + constructor(name: string); } \ No newline at end of file diff --git a/example/js/lib/api/Locale.mjs b/example/js/lib/api/Locale.mjs index 0a4fce0ec..a24990ecd 100644 --- a/example/js/lib/api/Locale.mjs +++ b/example/js/lib/api/Locale.mjs @@ -2,16 +2,16 @@ import wasm from "./diplomat-wasm.mjs"; import * as diplomatRuntime from "./diplomat-runtime.mjs"; - + /** An Locale, capable of representing strings like `"en-US"`. * -*See the [Rust documentation for `Locale`](https://docs.rs/icu/latest/icu/locid/struct.Locale.html) for more information. -*/ +*See the [Rust documentation for `Locale`](https://docs.rs/icu/latest/icu/locid/struct.Locale.html) for more information. +*/ const Locale_box_destroy_registry = new FinalizationRegistry((ptr) => { wasm.icu4x_Locale_destroy_mv1(ptr); -}); - -export class Locale { +}); + +export class Locale { // Internal ptr reference: #ptr = null; @@ -38,8 +38,8 @@ export class Locale { } get ffiValue() { return this.#ptr; - } - + } + #defaultConstructor(name) { let functionCleanupArena = new diplomatRuntime.CleanupArena(); @@ -54,15 +54,15 @@ export class Locale { finally { functionCleanupArena.free(); } - } - - constructor(name) { - if (arguments[0] === diplomatRuntime.exposeConstructor) { - return this.#internalConstructor(...Array.prototype.slice.call(arguments, 1)); - } else if (arguments[0] === diplomatRuntime.internalConstructor) { - return this.#internalConstructor(...arguments); - } else { - return this.#defaultConstructor(...arguments); - } - } + } + + constructor(name) { + if (arguments[0] === diplomatRuntime.exposeConstructor) { + return this.#internalConstructor(...Array.prototype.slice.call(arguments, 1)); + } else if (arguments[0] === diplomatRuntime.internalConstructor) { + return this.#internalConstructor(...arguments); + } else { + return this.#defaultConstructor(...arguments); + } + } } \ No newline at end of file diff --git a/feature_tests/js/api/AttrOpaque1Renamed.d.ts b/feature_tests/js/api/AttrOpaque1Renamed.d.ts index 5c4acdc8e..4b4b2bfbc 100644 --- a/feature_tests/js/api/AttrOpaque1Renamed.d.ts +++ b/feature_tests/js/api/AttrOpaque1Renamed.d.ts @@ -3,19 +3,19 @@ import type { RenamedAttrEnum } from "./RenamedAttrEnum" import type { Unnamespaced } from "./Unnamespaced" import type { pointer, codepoint } from "./diplomat-runtime.d.ts"; - - -export class AttrOpaque1Renamed { + + +export class AttrOpaque1Renamed { - get ffiValue(): pointer; - - get methodRenamed(): number; - - get abirenamed(): number; - - useUnnamespaced(un: Unnamespaced): void; - - useNamespaced(n: RenamedAttrEnum): void; - - constructor(); + get ffiValue(): pointer; + + get methodRenamed(): number; + + get abirenamed(): number; + + useUnnamespaced(un: Unnamespaced): void; + + useNamespaced(n: RenamedAttrEnum): void; + + constructor(); } \ No newline at end of file diff --git a/feature_tests/js/api/AttrOpaque1Renamed.mjs b/feature_tests/js/api/AttrOpaque1Renamed.mjs index 0394d140b..74dd11dfb 100644 --- a/feature_tests/js/api/AttrOpaque1Renamed.mjs +++ b/feature_tests/js/api/AttrOpaque1Renamed.mjs @@ -6,9 +6,9 @@ import * as diplomatRuntime from "./diplomat-runtime.mjs"; const AttrOpaque1Renamed_box_destroy_registry = new FinalizationRegistry((ptr) => { wasm.namespace_AttrOpaque1_destroy(ptr); -}); - -export class AttrOpaque1Renamed { +}); + +export class AttrOpaque1Renamed { // Internal ptr reference: #ptr = null; @@ -35,8 +35,8 @@ export class AttrOpaque1Renamed { } get ffiValue() { return this.#ptr; - } - + } + #defaultConstructor() { const result = wasm.namespace_AttrOpaque1_new(); @@ -45,8 +45,8 @@ export class AttrOpaque1Renamed { } finally {} - } - + } + get methodRenamed() { const result = wasm.namespace_AttrOpaque1_method(this.ffiValue); @@ -55,8 +55,8 @@ export class AttrOpaque1Renamed { } finally {} - } - + } + get abirenamed() { const result = wasm.renamed_on_abi_only(this.ffiValue); @@ -65,29 +65,29 @@ export class AttrOpaque1Renamed { } finally {} - } - + } + useUnnamespaced(un) {wasm.namespace_AttrOpaque1_use_unnamespaced(this.ffiValue, un.ffiValue); try {} finally {} - } - + } + useNamespaced(n) {wasm.namespace_AttrOpaque1_use_namespaced(this.ffiValue, n.ffiValue); try {} finally {} - } - - constructor() { - if (arguments[0] === diplomatRuntime.exposeConstructor) { - return this.#internalConstructor(...Array.prototype.slice.call(arguments, 1)); - } else if (arguments[0] === diplomatRuntime.internalConstructor) { - return this.#internalConstructor(...arguments); - } else { - return this.#defaultConstructor(...arguments); - } - } + } + + constructor() { + if (arguments[0] === diplomatRuntime.exposeConstructor) { + return this.#internalConstructor(...Array.prototype.slice.call(arguments, 1)); + } else if (arguments[0] === diplomatRuntime.internalConstructor) { + return this.#internalConstructor(...arguments); + } else { + return this.#defaultConstructor(...arguments); + } + } } \ No newline at end of file diff --git a/feature_tests/js/api/Bar.d.ts b/feature_tests/js/api/Bar.d.ts index 34f0bf15d..94def81a4 100644 --- a/feature_tests/js/api/Bar.d.ts +++ b/feature_tests/js/api/Bar.d.ts @@ -2,11 +2,11 @@ import type { Foo } from "./Foo" import type { pointer, codepoint } from "./diplomat-runtime.d.ts"; - - -export class Bar { + + +export class Bar { - get ffiValue(): pointer; - - get foo(): Foo; + get ffiValue(): pointer; + + get foo(): Foo; } \ No newline at end of file diff --git a/feature_tests/js/api/Bar.mjs b/feature_tests/js/api/Bar.mjs index 04e7dfab4..cddbc459d 100644 --- a/feature_tests/js/api/Bar.mjs +++ b/feature_tests/js/api/Bar.mjs @@ -5,9 +5,9 @@ import * as diplomatRuntime from "./diplomat-runtime.mjs"; const Bar_box_destroy_registry = new FinalizationRegistry((ptr) => { wasm.Bar_destroy(ptr); -}); - -export class Bar { +}); + +export class Bar { // Internal ptr reference: #ptr = null; @@ -42,8 +42,8 @@ export class Bar { } get ffiValue() { return this.#ptr; - } - + } + get foo() { // This lifetime edge depends on lifetimes 'b, 'a let bEdges = [this]; @@ -58,9 +58,9 @@ export class Bar { } finally {} - } - - constructor(symbol, ptr, selfEdge, bEdge, aEdge) { - return this.#internalConstructor(...arguments) - } + } + + constructor(symbol, ptr, selfEdge, bEdge, aEdge) { + return this.#internalConstructor(...arguments) + } } \ No newline at end of file diff --git a/feature_tests/js/api/BigStructWithStuff.d.ts b/feature_tests/js/api/BigStructWithStuff.d.ts index ba2294585..264024a29 100644 --- a/feature_tests/js/api/BigStructWithStuff.d.ts +++ b/feature_tests/js/api/BigStructWithStuff.d.ts @@ -3,9 +3,9 @@ import type { ScalarPairWithPadding } from "./ScalarPairWithPadding" import type { ScalarPairWithPadding_obj } from "./ScalarPairWithPadding" import type { pointer, codepoint } from "./diplomat-runtime.d.ts"; - -/** Testing JS-specific layout/padding behavior -*/ + +/** Testing JS-specific layout/padding behavior +*/ type BigStructWithStuff_obj = { first: number; second: number; @@ -14,9 +14,9 @@ type BigStructWithStuff_obj = { fifth: number; }; - - -export class BigStructWithStuff { + + +export class BigStructWithStuff { get first() : number; set first(value: number); @@ -37,9 +37,9 @@ export class BigStructWithStuff { * Optional fields do not need to be included in the provided object. */ static fromFields(structObj : BigStructWithStuff_obj) : BigStructWithStuff; - - - assertValue(extraVal: number): void; - - constructor(structObj : BigStructWithStuff_obj); + + + assertValue(extraVal: number): void; + + constructor(structObj : BigStructWithStuff_obj); } \ No newline at end of file diff --git a/feature_tests/js/api/BigStructWithStuff.mjs b/feature_tests/js/api/BigStructWithStuff.mjs index 9ad39095e..f27e51acf 100644 --- a/feature_tests/js/api/BigStructWithStuff.mjs +++ b/feature_tests/js/api/BigStructWithStuff.mjs @@ -3,12 +3,12 @@ import { ScalarPairWithPadding } from "./ScalarPairWithPadding.mjs" import wasm from "./diplomat-wasm.mjs"; import * as diplomatRuntime from "./diplomat-runtime.mjs"; - -/** Testing JS-specific layout/padding behavior -*/ - - -export class BigStructWithStuff { + +/** Testing JS-specific layout/padding behavior +*/ + + +export class BigStructWithStuff { #first; @@ -61,7 +61,7 @@ export class BigStructWithStuff { static fromFields(structObj) { return new BigStructWithStuff(structObj); } - + #internalConstructor(structObj) { if (typeof structObj !== "object") { throw new Error("BigStructWithStuff's constructor takes an object of BigStructWithStuff's fields."); @@ -157,8 +157,8 @@ export class BigStructWithStuff { structObj.fifth = fifthDeref; return new BigStructWithStuff(structObj); - } - + } + assertValue(extraVal) { let functionCleanupArena = new diplomatRuntime.CleanupArena(); wasm.BigStructWithStuff_assert_value(...this._intoFFI(), extraVal); @@ -168,9 +168,9 @@ export class BigStructWithStuff { finally { functionCleanupArena.free(); } - } - - constructor(structObj) { - return this.#internalConstructor(...arguments) - } + } + + constructor(structObj) { + return this.#internalConstructor(...arguments) + } } \ No newline at end of file diff --git a/feature_tests/js/api/BorrowedFields.d.ts b/feature_tests/js/api/BorrowedFields.d.ts index ae73f2444..1eeeb9c80 100644 --- a/feature_tests/js/api/BorrowedFields.d.ts +++ b/feature_tests/js/api/BorrowedFields.d.ts @@ -8,9 +8,9 @@ type BorrowedFields_obj = { c: string; }; - - -export class BorrowedFields { + + +export class BorrowedFields { get a() : string; set a(value: string); @@ -25,9 +25,9 @@ export class BorrowedFields { * Optional fields do not need to be included in the provided object. */ static fromFields(structObj : BorrowedFields_obj) : BorrowedFields; - - - static fromBarAndStrings(bar: Bar, dstr16: string, utf8Str: string): BorrowedFields; - - constructor(structObj : BorrowedFields_obj); + + + static fromBarAndStrings(bar: Bar, dstr16: string, utf8Str: string): BorrowedFields; + + constructor(structObj : BorrowedFields_obj); } \ No newline at end of file diff --git a/feature_tests/js/api/BorrowedFields.mjs b/feature_tests/js/api/BorrowedFields.mjs index e3eb72854..2aadcc0e1 100644 --- a/feature_tests/js/api/BorrowedFields.mjs +++ b/feature_tests/js/api/BorrowedFields.mjs @@ -3,9 +3,9 @@ import { Bar } from "./Bar.mjs" import wasm from "./diplomat-wasm.mjs"; import * as diplomatRuntime from "./diplomat-runtime.mjs"; - - -export class BorrowedFields { + + +export class BorrowedFields { #a; @@ -40,7 +40,7 @@ export class BorrowedFields { static fromFields(structObj) { return new BorrowedFields(structObj); } - + #internalConstructor(structObj) { if (typeof structObj !== "object") { throw new Error("BorrowedFields's constructor takes an object of BorrowedFields's fields."); @@ -125,8 +125,8 @@ export class BorrowedFields { // the caller should take care to also call _fieldsForLifetimeOther get _fieldsForLifetimeA() { return [a, b, c]; - }; - + }; + static fromBarAndStrings(bar, dstr16, utf8Str) { let functionGarbageCollectorGrip = new diplomatRuntime.GarbageCollectorGrip(); const dstr16Slice = functionGarbageCollectorGrip.alloc(diplomatRuntime.DiplomatBuf.str16(wasm, dstr16)); @@ -149,9 +149,9 @@ export class BorrowedFields { diplomatReceive.free(); } - } - - constructor(structObj) { - return this.#internalConstructor(...arguments) - } + } + + constructor(structObj) { + return this.#internalConstructor(...arguments) + } } \ No newline at end of file diff --git a/feature_tests/js/api/BorrowedFieldsReturning.d.ts b/feature_tests/js/api/BorrowedFieldsReturning.d.ts index 0ea70a813..c24b5c70e 100644 --- a/feature_tests/js/api/BorrowedFieldsReturning.d.ts +++ b/feature_tests/js/api/BorrowedFieldsReturning.d.ts @@ -5,9 +5,9 @@ type BorrowedFieldsReturning_obj = { bytes: string; }; - - -export class BorrowedFieldsReturning { + + +export class BorrowedFieldsReturning { get bytes() : string; set bytes(value: string); @@ -16,7 +16,7 @@ export class BorrowedFieldsReturning { * Optional fields do not need to be included in the provided object. */ static fromFields(structObj : BorrowedFieldsReturning_obj) : BorrowedFieldsReturning; - - - constructor(structObj : BorrowedFieldsReturning_obj); + + + constructor(structObj : BorrowedFieldsReturning_obj); } \ No newline at end of file diff --git a/feature_tests/js/api/BorrowedFieldsReturning.mjs b/feature_tests/js/api/BorrowedFieldsReturning.mjs index 3f117c0d8..ea1ade42b 100644 --- a/feature_tests/js/api/BorrowedFieldsReturning.mjs +++ b/feature_tests/js/api/BorrowedFieldsReturning.mjs @@ -2,9 +2,9 @@ import wasm from "./diplomat-wasm.mjs"; import * as diplomatRuntime from "./diplomat-runtime.mjs"; - - -export class BorrowedFieldsReturning { + + +export class BorrowedFieldsReturning { #bytes; @@ -21,7 +21,7 @@ export class BorrowedFieldsReturning { static fromFields(structObj) { return new BorrowedFieldsReturning(structObj); } - + #internalConstructor(structObj) { if (typeof structObj !== "object") { throw new Error("BorrowedFieldsReturning's constructor takes an object of BorrowedFieldsReturning's fields."); @@ -88,9 +88,9 @@ export class BorrowedFieldsReturning { // the caller should take care to also call _fieldsForLifetimeOther get _fieldsForLifetimeA() { return [bytes]; - }; - - constructor(structObj) { - return this.#internalConstructor(...arguments) - } + }; + + constructor(structObj) { + return this.#internalConstructor(...arguments) + } } \ No newline at end of file diff --git a/feature_tests/js/api/BorrowedFieldsWithBounds.d.ts b/feature_tests/js/api/BorrowedFieldsWithBounds.d.ts index d012c95e7..79d24e7c9 100644 --- a/feature_tests/js/api/BorrowedFieldsWithBounds.d.ts +++ b/feature_tests/js/api/BorrowedFieldsWithBounds.d.ts @@ -8,9 +8,9 @@ type BorrowedFieldsWithBounds_obj = { fieldC: string; }; - - -export class BorrowedFieldsWithBounds { + + +export class BorrowedFieldsWithBounds { get fieldA() : string; set fieldA(value: string); @@ -25,9 +25,9 @@ export class BorrowedFieldsWithBounds { * Optional fields do not need to be included in the provided object. */ static fromFields(structObj : BorrowedFieldsWithBounds_obj) : BorrowedFieldsWithBounds; - - - static fromFooAndStrings(foo: Foo, dstr16X: string, utf8StrZ: string): BorrowedFieldsWithBounds; - - constructor(structObj : BorrowedFieldsWithBounds_obj); + + + static fromFooAndStrings(foo: Foo, dstr16X: string, utf8StrZ: string): BorrowedFieldsWithBounds; + + constructor(structObj : BorrowedFieldsWithBounds_obj); } \ No newline at end of file diff --git a/feature_tests/js/api/BorrowedFieldsWithBounds.mjs b/feature_tests/js/api/BorrowedFieldsWithBounds.mjs index 2fb1e63ed..f3e4da1db 100644 --- a/feature_tests/js/api/BorrowedFieldsWithBounds.mjs +++ b/feature_tests/js/api/BorrowedFieldsWithBounds.mjs @@ -3,9 +3,9 @@ import { Foo } from "./Foo.mjs" import wasm from "./diplomat-wasm.mjs"; import * as diplomatRuntime from "./diplomat-runtime.mjs"; - - -export class BorrowedFieldsWithBounds { + + +export class BorrowedFieldsWithBounds { #fieldA; @@ -40,7 +40,7 @@ export class BorrowedFieldsWithBounds { static fromFields(structObj) { return new BorrowedFieldsWithBounds(structObj); } - + #internalConstructor(structObj) { if (typeof structObj !== "object") { throw new Error("BorrowedFieldsWithBounds's constructor takes an object of BorrowedFieldsWithBounds's fields."); @@ -145,8 +145,8 @@ export class BorrowedFieldsWithBounds { // the caller should take care to also call _fieldsForLifetimeOther get _fieldsForLifetimeC() { return [fieldC]; - }; - + }; + static fromFooAndStrings(foo, dstr16X, utf8StrZ) { let functionGarbageCollectorGrip = new diplomatRuntime.GarbageCollectorGrip(); const dstr16XSlice = functionGarbageCollectorGrip.alloc(diplomatRuntime.DiplomatBuf.str16(wasm, dstr16X)); @@ -175,9 +175,9 @@ export class BorrowedFieldsWithBounds { diplomatReceive.free(); } - } - - constructor(structObj) { - return this.#internalConstructor(...arguments) - } + } + + constructor(structObj) { + return this.#internalConstructor(...arguments) + } } \ No newline at end of file diff --git a/feature_tests/js/api/ContiguousEnum.d.ts b/feature_tests/js/api/ContiguousEnum.d.ts index 7750755be..b2b35a388 100644 --- a/feature_tests/js/api/ContiguousEnum.d.ts +++ b/feature_tests/js/api/ContiguousEnum.d.ts @@ -1,9 +1,9 @@ // generated by diplomat-tool import type { pointer, codepoint } from "./diplomat-runtime.d.ts"; - - -export class ContiguousEnum { + + +export class ContiguousEnum { static fromValue(value : ContiguousEnum | string) : ContiguousEnum; @@ -15,7 +15,7 @@ export class ContiguousEnum { static C : ContiguousEnum; static D : ContiguousEnum; static E : ContiguousEnum; - static F : ContiguousEnum; - - constructor(value: ContiguousEnum | string ); + static F : ContiguousEnum; + + constructor(value: ContiguousEnum | string ); } \ No newline at end of file diff --git a/feature_tests/js/api/ContiguousEnum.mjs b/feature_tests/js/api/ContiguousEnum.mjs index 34c5f99ec..a5aec7173 100644 --- a/feature_tests/js/api/ContiguousEnum.mjs +++ b/feature_tests/js/api/ContiguousEnum.mjs @@ -2,9 +2,9 @@ import wasm from "./diplomat-wasm.mjs"; import * as diplomatRuntime from "./diplomat-runtime.mjs"; - - -export class ContiguousEnum { + + +export class ContiguousEnum { #value = undefined; @@ -65,9 +65,9 @@ export class ContiguousEnum { static C = ContiguousEnum.#objectValues[0]; static D = ContiguousEnum.#objectValues[1]; static E = ContiguousEnum.#objectValues[2]; - static F = ContiguousEnum.#objectValues[3]; - - constructor(value) { - return this.#internalConstructor(...arguments) - } + static F = ContiguousEnum.#objectValues[3]; + + constructor(value) { + return this.#internalConstructor(...arguments) + } } \ No newline at end of file diff --git a/feature_tests/js/api/CyclicStructA.d.ts b/feature_tests/js/api/CyclicStructA.d.ts index 26b0ecf16..ff7e1744c 100644 --- a/feature_tests/js/api/CyclicStructA.d.ts +++ b/feature_tests/js/api/CyclicStructA.d.ts @@ -7,9 +7,9 @@ type CyclicStructA_obj = { a: CyclicStructB_obj; }; - - -export class CyclicStructA { + + +export class CyclicStructA { get a() : CyclicStructB; set a(value: CyclicStructB); @@ -18,15 +18,15 @@ export class CyclicStructA { * Optional fields do not need to be included in the provided object. */ static fromFields(structObj : CyclicStructA_obj) : CyclicStructA; - - - static getB(): CyclicStructB; - - cyclicOut(): string; - - doubleCyclicOut(cyclicStructA: CyclicStructA_obj): string; - - get getterOut(): string; - - constructor(structObj : CyclicStructA_obj); + + + static getB(): CyclicStructB; + + cyclicOut(): string; + + doubleCyclicOut(cyclicStructA: CyclicStructA_obj): string; + + get getterOut(): string; + + constructor(structObj : CyclicStructA_obj); } \ No newline at end of file diff --git a/feature_tests/js/api/CyclicStructA.mjs b/feature_tests/js/api/CyclicStructA.mjs index 9f28fcea6..933088e37 100644 --- a/feature_tests/js/api/CyclicStructA.mjs +++ b/feature_tests/js/api/CyclicStructA.mjs @@ -3,9 +3,9 @@ import { CyclicStructB } from "./CyclicStructB.mjs" import wasm from "./diplomat-wasm.mjs"; import * as diplomatRuntime from "./diplomat-runtime.mjs"; - - -export class CyclicStructA { + + +export class CyclicStructA { #a; @@ -22,7 +22,7 @@ export class CyclicStructA { static fromFields(structObj) { return new CyclicStructA(structObj); } - + #internalConstructor(structObj) { if (typeof structObj !== "object") { throw new Error("CyclicStructA's constructor takes an object of CyclicStructA's fields."); @@ -82,8 +82,8 @@ export class CyclicStructA { structObj.a = CyclicStructB._fromFFI(diplomatRuntime.internalConstructor, aDeref); return new CyclicStructA(structObj); - } - + } + static getB() { const result = wasm.CyclicStructA_get_b(); @@ -92,8 +92,8 @@ export class CyclicStructA { } finally {} - } - + } + cyclicOut() { let functionCleanupArena = new diplomatRuntime.CleanupArena(); @@ -109,8 +109,8 @@ export class CyclicStructA { write.free(); } - } - + } + doubleCyclicOut(cyclicStructA) { let functionCleanupArena = new diplomatRuntime.CleanupArena(); @@ -126,8 +126,8 @@ export class CyclicStructA { write.free(); } - } - + } + get getterOut() { let functionCleanupArena = new diplomatRuntime.CleanupArena(); @@ -143,9 +143,9 @@ export class CyclicStructA { write.free(); } - } - - constructor(structObj) { - return this.#internalConstructor(...arguments) - } + } + + constructor(structObj) { + return this.#internalConstructor(...arguments) + } } \ No newline at end of file diff --git a/feature_tests/js/api/CyclicStructB.d.ts b/feature_tests/js/api/CyclicStructB.d.ts index 6cc3a4f2c..41fcdb2d8 100644 --- a/feature_tests/js/api/CyclicStructB.d.ts +++ b/feature_tests/js/api/CyclicStructB.d.ts @@ -6,9 +6,9 @@ type CyclicStructB_obj = { field: number; }; - - -export class CyclicStructB { + + +export class CyclicStructB { get field() : number; set field(value: number); @@ -17,11 +17,11 @@ export class CyclicStructB { * Optional fields do not need to be included in the provided object. */ static fromFields(structObj : CyclicStructB_obj) : CyclicStructB; - - - static getA(): CyclicStructA; - - static getAOption(): CyclicStructA | null; - - constructor(structObj : CyclicStructB_obj); + + + static getA(): CyclicStructA; + + static getAOption(): CyclicStructA | null; + + constructor(structObj : CyclicStructB_obj); } \ No newline at end of file diff --git a/feature_tests/js/api/CyclicStructB.mjs b/feature_tests/js/api/CyclicStructB.mjs index 063cf553b..3aa5cec6c 100644 --- a/feature_tests/js/api/CyclicStructB.mjs +++ b/feature_tests/js/api/CyclicStructB.mjs @@ -3,9 +3,9 @@ import { CyclicStructA } from "./CyclicStructA.mjs" import wasm from "./diplomat-wasm.mjs"; import * as diplomatRuntime from "./diplomat-runtime.mjs"; - - -export class CyclicStructB { + + +export class CyclicStructB { #field; @@ -22,7 +22,7 @@ export class CyclicStructB { static fromFields(structObj) { return new CyclicStructB(structObj); } - + #internalConstructor(structObj) { if (typeof structObj !== "object") { throw new Error("CyclicStructB's constructor takes an object of CyclicStructB's fields."); @@ -82,8 +82,8 @@ export class CyclicStructB { return new CyclicStructB(structObj); - } - + } + static getA() { const result = wasm.CyclicStructB_get_a(); @@ -92,8 +92,8 @@ export class CyclicStructB { } finally {} - } - + } + static getAOption() { const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 2, 1, true); @@ -109,9 +109,9 @@ export class CyclicStructB { finally { diplomatReceive.free(); } - } - - constructor(structObj) { - return this.#internalConstructor(...arguments) - } + } + + constructor(structObj) { + return this.#internalConstructor(...arguments) + } } \ No newline at end of file diff --git a/feature_tests/js/api/CyclicStructC.d.ts b/feature_tests/js/api/CyclicStructC.d.ts index 22ec416e1..88ede81ca 100644 --- a/feature_tests/js/api/CyclicStructC.d.ts +++ b/feature_tests/js/api/CyclicStructC.d.ts @@ -7,9 +7,9 @@ type CyclicStructC_obj = { a: CyclicStructA_obj; }; - - -export class CyclicStructC { + + +export class CyclicStructC { get a() : CyclicStructA; set a(value: CyclicStructA); @@ -18,11 +18,11 @@ export class CyclicStructC { * Optional fields do not need to be included in the provided object. */ static fromFields(structObj : CyclicStructC_obj) : CyclicStructC; - - - static takesNestedParameters(c: CyclicStructC_obj): CyclicStructC; - - cyclicOut(): string; - - constructor(structObj : CyclicStructC_obj); + + + static takesNestedParameters(c: CyclicStructC_obj): CyclicStructC; + + cyclicOut(): string; + + constructor(structObj : CyclicStructC_obj); } \ No newline at end of file diff --git a/feature_tests/js/api/CyclicStructC.mjs b/feature_tests/js/api/CyclicStructC.mjs index 2ccfece3a..229ef5188 100644 --- a/feature_tests/js/api/CyclicStructC.mjs +++ b/feature_tests/js/api/CyclicStructC.mjs @@ -3,9 +3,9 @@ import { CyclicStructA } from "./CyclicStructA.mjs" import wasm from "./diplomat-wasm.mjs"; import * as diplomatRuntime from "./diplomat-runtime.mjs"; - - -export class CyclicStructC { + + +export class CyclicStructC { #a; @@ -22,7 +22,7 @@ export class CyclicStructC { static fromFields(structObj) { return new CyclicStructC(structObj); } - + #internalConstructor(structObj) { if (typeof structObj !== "object") { throw new Error("CyclicStructC's constructor takes an object of CyclicStructC's fields."); @@ -82,8 +82,8 @@ export class CyclicStructC { structObj.a = CyclicStructA._fromFFI(diplomatRuntime.internalConstructor, aDeref); return new CyclicStructC(structObj); - } - + } + static takesNestedParameters(c) { let functionCleanupArena = new diplomatRuntime.CleanupArena(); @@ -96,8 +96,8 @@ export class CyclicStructC { finally { functionCleanupArena.free(); } - } - + } + cyclicOut() { let functionCleanupArena = new diplomatRuntime.CleanupArena(); @@ -113,9 +113,9 @@ export class CyclicStructC { write.free(); } - } - - constructor(structObj) { - return this.#internalConstructor(...arguments) - } + } + + constructor(structObj) { + return this.#internalConstructor(...arguments) + } } \ No newline at end of file diff --git a/feature_tests/js/api/DefaultEnum.d.ts b/feature_tests/js/api/DefaultEnum.d.ts index 8e27209ff..55788997f 100644 --- a/feature_tests/js/api/DefaultEnum.d.ts +++ b/feature_tests/js/api/DefaultEnum.d.ts @@ -1,9 +1,9 @@ // generated by diplomat-tool import type { pointer, codepoint } from "./diplomat-runtime.d.ts"; - - -export class DefaultEnum { + + +export class DefaultEnum { static fromValue(value : DefaultEnum | string) : DefaultEnum; @@ -13,7 +13,7 @@ export class DefaultEnum { get ffiValue() : number; static A : DefaultEnum; - static B : DefaultEnum; - - constructor(); + static B : DefaultEnum; + + constructor(); } \ No newline at end of file diff --git a/feature_tests/js/api/DefaultEnum.mjs b/feature_tests/js/api/DefaultEnum.mjs index 3afd89aeb..ccdbfda81 100644 --- a/feature_tests/js/api/DefaultEnum.mjs +++ b/feature_tests/js/api/DefaultEnum.mjs @@ -2,9 +2,9 @@ import wasm from "./diplomat-wasm.mjs"; import * as diplomatRuntime from "./diplomat-runtime.mjs"; - - -export class DefaultEnum { + + +export class DefaultEnum { #value = undefined; @@ -59,8 +59,8 @@ export class DefaultEnum { ]; static A = DefaultEnum.#objectValues[0]; - static B = DefaultEnum.#objectValues[1]; - + static B = DefaultEnum.#objectValues[1]; + #defaultConstructor() { const result = wasm.DefaultEnum_new(); @@ -69,15 +69,15 @@ export class DefaultEnum { } finally {} - } - - constructor() { - if (arguments[0] === diplomatRuntime.exposeConstructor) { - return this.#internalConstructor(...Array.prototype.slice.call(arguments, 1)); - } else if (arguments[0] === diplomatRuntime.internalConstructor) { - return this.#internalConstructor(...arguments); - } else { - return this.#defaultConstructor(...arguments); - } - } + } + + constructor() { + if (arguments[0] === diplomatRuntime.exposeConstructor) { + return this.#internalConstructor(...Array.prototype.slice.call(arguments, 1)); + } else if (arguments[0] === diplomatRuntime.internalConstructor) { + return this.#internalConstructor(...arguments); + } else { + return this.#defaultConstructor(...arguments); + } + } } \ No newline at end of file diff --git a/feature_tests/js/api/ErrorEnum.d.ts b/feature_tests/js/api/ErrorEnum.d.ts index 918bbd0ae..09b94638a 100644 --- a/feature_tests/js/api/ErrorEnum.d.ts +++ b/feature_tests/js/api/ErrorEnum.d.ts @@ -1,9 +1,9 @@ // generated by diplomat-tool import type { pointer, codepoint } from "./diplomat-runtime.d.ts"; - - -export class ErrorEnum { + + +export class ErrorEnum { static fromValue(value : ErrorEnum | string) : ErrorEnum; @@ -13,7 +13,7 @@ export class ErrorEnum { get ffiValue() : number; static Foo : ErrorEnum; - static Bar : ErrorEnum; - - constructor(value: ErrorEnum | string ); + static Bar : ErrorEnum; + + constructor(value: ErrorEnum | string ); } \ No newline at end of file diff --git a/feature_tests/js/api/ErrorEnum.mjs b/feature_tests/js/api/ErrorEnum.mjs index de3f78f44..57f305f66 100644 --- a/feature_tests/js/api/ErrorEnum.mjs +++ b/feature_tests/js/api/ErrorEnum.mjs @@ -2,9 +2,9 @@ import wasm from "./diplomat-wasm.mjs"; import * as diplomatRuntime from "./diplomat-runtime.mjs"; - - -export class ErrorEnum { + + +export class ErrorEnum { #value = undefined; @@ -59,9 +59,9 @@ export class ErrorEnum { ]; static Foo = ErrorEnum.#objectValues[0]; - static Bar = ErrorEnum.#objectValues[1]; - - constructor(value) { - return this.#internalConstructor(...arguments) - } + static Bar = ErrorEnum.#objectValues[1]; + + constructor(value) { + return this.#internalConstructor(...arguments) + } } \ No newline at end of file diff --git a/feature_tests/js/api/ErrorStruct.d.ts b/feature_tests/js/api/ErrorStruct.d.ts index 79169f34d..f578c76a4 100644 --- a/feature_tests/js/api/ErrorStruct.d.ts +++ b/feature_tests/js/api/ErrorStruct.d.ts @@ -6,9 +6,9 @@ type ErrorStruct_obj = { j: number; }; - - -export class ErrorStruct { + + +export class ErrorStruct { get i() : number; set i(value: number); @@ -20,7 +20,7 @@ export class ErrorStruct { * Optional fields do not need to be included in the provided object. */ static fromFields(structObj : ErrorStruct_obj) : ErrorStruct; - - - constructor(structObj : ErrorStruct_obj); + + + constructor(structObj : ErrorStruct_obj); } \ No newline at end of file diff --git a/feature_tests/js/api/ErrorStruct.mjs b/feature_tests/js/api/ErrorStruct.mjs index ec8aa6333..0c9ab83f1 100644 --- a/feature_tests/js/api/ErrorStruct.mjs +++ b/feature_tests/js/api/ErrorStruct.mjs @@ -2,9 +2,9 @@ import wasm from "./diplomat-wasm.mjs"; import * as diplomatRuntime from "./diplomat-runtime.mjs"; - - -export class ErrorStruct { + + +export class ErrorStruct { #i; @@ -30,7 +30,7 @@ export class ErrorStruct { static fromFields(structObj) { return new ErrorStruct(structObj); } - + #internalConstructor(structObj) { if (typeof structObj !== "object") { throw new Error("ErrorStruct's constructor takes an object of ErrorStruct's fields."); @@ -99,9 +99,9 @@ export class ErrorStruct { structObj.j = jDeref; return new ErrorStruct(structObj); - } - - constructor(structObj) { - return this.#internalConstructor(...arguments) - } + } + + constructor(structObj) { + return this.#internalConstructor(...arguments) + } } \ No newline at end of file diff --git a/feature_tests/js/api/Float64Vec.d.ts b/feature_tests/js/api/Float64Vec.d.ts index 29e90209f..5ab6e1fca 100644 --- a/feature_tests/js/api/Float64Vec.d.ts +++ b/feature_tests/js/api/Float64Vec.d.ts @@ -1,35 +1,35 @@ // generated by diplomat-tool import type { pointer, codepoint } from "./diplomat-runtime.d.ts"; - - -export class Float64Vec { + + +export class Float64Vec { - get ffiValue(): pointer; - - static newBool(v: Array): Float64Vec; - - static newI16(v: Array): Float64Vec; - - static newU16(v: Array): Float64Vec; - - static newIsize(v: Array): Float64Vec; - - static newUsize(v: Array): Float64Vec; - - static newF64BeBytes(v: Uint8Array): Float64Vec; - - get asSlice(): Array; - - fillSlice(v: Array): void; - - setValue(newSlice: Array): void; - - toString(): string; - - borrow(): Array; - - get(i: number): number | null; - - constructor(v: Array); + get ffiValue(): pointer; + + static newBool(v: Array): Float64Vec; + + static newI16(v: Array): Float64Vec; + + static newU16(v: Array): Float64Vec; + + static newIsize(v: Array): Float64Vec; + + static newUsize(v: Array): Float64Vec; + + static newF64BeBytes(v: Uint8Array): Float64Vec; + + get asSlice(): Array; + + fillSlice(v: Array): void; + + setValue(newSlice: Array): void; + + toString(): string; + + borrow(): Array; + + get(i: number): number | null; + + constructor(v: Array); } \ No newline at end of file diff --git a/feature_tests/js/api/Float64Vec.mjs b/feature_tests/js/api/Float64Vec.mjs index 203275b4f..00d9b4e0e 100644 --- a/feature_tests/js/api/Float64Vec.mjs +++ b/feature_tests/js/api/Float64Vec.mjs @@ -4,9 +4,9 @@ import * as diplomatRuntime from "./diplomat-runtime.mjs"; const Float64Vec_box_destroy_registry = new FinalizationRegistry((ptr) => { wasm.Float64Vec_destroy(ptr); -}); - -export class Float64Vec { +}); + +export class Float64Vec { // Internal ptr reference: #ptr = null; @@ -33,8 +33,8 @@ export class Float64Vec { } get ffiValue() { return this.#ptr; - } - + } + static newBool(v) { let functionCleanupArena = new diplomatRuntime.CleanupArena(); @@ -49,8 +49,8 @@ export class Float64Vec { finally { functionCleanupArena.free(); } - } - + } + static newI16(v) { let functionCleanupArena = new diplomatRuntime.CleanupArena(); @@ -65,8 +65,8 @@ export class Float64Vec { finally { functionCleanupArena.free(); } - } - + } + static newU16(v) { let functionCleanupArena = new diplomatRuntime.CleanupArena(); @@ -81,8 +81,8 @@ export class Float64Vec { finally { functionCleanupArena.free(); } - } - + } + static newIsize(v) { let functionCleanupArena = new diplomatRuntime.CleanupArena(); @@ -97,8 +97,8 @@ export class Float64Vec { finally { functionCleanupArena.free(); } - } - + } + static newUsize(v) { let functionCleanupArena = new diplomatRuntime.CleanupArena(); @@ -113,8 +113,8 @@ export class Float64Vec { finally { functionCleanupArena.free(); } - } - + } + static newF64BeBytes(v) { let functionCleanupArena = new diplomatRuntime.CleanupArena(); @@ -129,8 +129,8 @@ export class Float64Vec { finally { functionCleanupArena.free(); } - } - + } + #defaultConstructor(v) { let functionCleanupArena = new diplomatRuntime.CleanupArena(); @@ -145,8 +145,8 @@ export class Float64Vec { finally { functionCleanupArena.free(); } - } - + } + get asSlice() { const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 8, 4, false); @@ -162,8 +162,8 @@ export class Float64Vec { finally { diplomatReceive.free(); } - } - + } + fillSlice(v) { let functionCleanupArena = new diplomatRuntime.CleanupArena(); @@ -175,8 +175,8 @@ export class Float64Vec { finally { functionCleanupArena.free(); } - } - + } + setValue(newSlice) { let functionCleanupArena = new diplomatRuntime.CleanupArena(); @@ -188,8 +188,8 @@ export class Float64Vec { finally { functionCleanupArena.free(); } - } - + } + toString() { const write = new diplomatRuntime.DiplomatWriteBuf(wasm); wasm.Float64Vec_to_string(this.ffiValue, write.buffer); @@ -201,8 +201,8 @@ export class Float64Vec { finally { write.free(); } - } - + } + borrow() { const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 8, 4, false); @@ -218,8 +218,8 @@ export class Float64Vec { finally { diplomatReceive.free(); } - } - + } + get(i) { const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 9, 8, true); @@ -235,15 +235,15 @@ export class Float64Vec { finally { diplomatReceive.free(); } - } - - constructor(v) { - if (arguments[0] === diplomatRuntime.exposeConstructor) { - return this.#internalConstructor(...Array.prototype.slice.call(arguments, 1)); - } else if (arguments[0] === diplomatRuntime.internalConstructor) { - return this.#internalConstructor(...arguments); - } else { - return this.#defaultConstructor(...arguments); - } - } + } + + constructor(v) { + if (arguments[0] === diplomatRuntime.exposeConstructor) { + return this.#internalConstructor(...Array.prototype.slice.call(arguments, 1)); + } else if (arguments[0] === diplomatRuntime.internalConstructor) { + return this.#internalConstructor(...arguments); + } else { + return this.#defaultConstructor(...arguments); + } + } } \ No newline at end of file diff --git a/feature_tests/js/api/Foo.d.ts b/feature_tests/js/api/Foo.d.ts index 6db0ce682..c09837fa0 100644 --- a/feature_tests/js/api/Foo.d.ts +++ b/feature_tests/js/api/Foo.d.ts @@ -7,19 +7,19 @@ import type { BorrowedFieldsWithBounds_obj } from "./BorrowedFieldsWithBounds" import type { BorrowedFields_obj } from "./BorrowedFields" import type { pointer, codepoint } from "./diplomat-runtime.d.ts"; - - -export class Foo { + + +export class Foo { - get ffiValue(): pointer; - - get bar(): Bar; - - asReturning(): BorrowedFieldsReturning; - - static extractFromFields(fields: BorrowedFields_obj): Foo; - - static extractFromBounds(bounds: BorrowedFieldsWithBounds_obj, anotherString: string): Foo; - - constructor(x: string); + get ffiValue(): pointer; + + get bar(): Bar; + + asReturning(): BorrowedFieldsReturning; + + static extractFromFields(fields: BorrowedFields_obj): Foo; + + static extractFromBounds(bounds: BorrowedFieldsWithBounds_obj, anotherString: string): Foo; + + constructor(x: string); } \ No newline at end of file diff --git a/feature_tests/js/api/Foo.mjs b/feature_tests/js/api/Foo.mjs index f102c967c..69353f057 100644 --- a/feature_tests/js/api/Foo.mjs +++ b/feature_tests/js/api/Foo.mjs @@ -8,9 +8,9 @@ import * as diplomatRuntime from "./diplomat-runtime.mjs"; const Foo_box_destroy_registry = new FinalizationRegistry((ptr) => { wasm.Foo_destroy(ptr); -}); - -export class Foo { +}); + +export class Foo { // Internal ptr reference: #ptr = null; @@ -41,8 +41,8 @@ export class Foo { } get ffiValue() { return this.#ptr; - } - + } + #defaultConstructor(x) { let functionGarbageCollectorGrip = new diplomatRuntime.GarbageCollectorGrip(); const xSlice = functionGarbageCollectorGrip.alloc(diplomatRuntime.DiplomatBuf.str8(wasm, x)); @@ -59,8 +59,8 @@ export class Foo { finally { functionGarbageCollectorGrip.releaseToGarbageCollector(); } - } - + } + get bar() { // This lifetime edge depends on lifetimes 'a let aEdges = [this]; @@ -75,8 +75,8 @@ export class Foo { } finally {} - } - + } + asReturning() { const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 8, 4, false); @@ -92,8 +92,8 @@ export class Foo { finally { diplomatReceive.free(); } - } - + } + static extractFromFields(fields) { let functionCleanupArena = new diplomatRuntime.CleanupArena(); @@ -109,8 +109,8 @@ export class Foo { finally { functionCleanupArena.free(); } - } - + } + static extractFromBounds(bounds, anotherString) { let functionCleanupArena = new diplomatRuntime.CleanupArena(); @@ -131,15 +131,15 @@ export class Foo { functionGarbageCollectorGrip.releaseToGarbageCollector(); } - } - - constructor(x) { - if (arguments[0] === diplomatRuntime.exposeConstructor) { - return this.#internalConstructor(...Array.prototype.slice.call(arguments, 1)); - } else if (arguments[0] === diplomatRuntime.internalConstructor) { - return this.#internalConstructor(...arguments); - } else { - return this.#defaultConstructor(...arguments); - } - } + } + + constructor(x) { + if (arguments[0] === diplomatRuntime.exposeConstructor) { + return this.#internalConstructor(...Array.prototype.slice.call(arguments, 1)); + } else if (arguments[0] === diplomatRuntime.internalConstructor) { + return this.#internalConstructor(...arguments); + } else { + return this.#defaultConstructor(...arguments); + } + } } \ No newline at end of file diff --git a/feature_tests/js/api/ImportedStruct.d.ts b/feature_tests/js/api/ImportedStruct.d.ts index 6d24956d9..11c28dc5d 100644 --- a/feature_tests/js/api/ImportedStruct.d.ts +++ b/feature_tests/js/api/ImportedStruct.d.ts @@ -7,9 +7,9 @@ type ImportedStruct_obj = { count: number; }; - - -export class ImportedStruct { + + +export class ImportedStruct { get foo() : UnimportedEnum; set foo(value: UnimportedEnum); @@ -21,7 +21,7 @@ export class ImportedStruct { * Optional fields do not need to be included in the provided object. */ static fromFields(structObj : ImportedStruct_obj) : ImportedStruct; - - - constructor(structObj : ImportedStruct_obj); + + + constructor(structObj : ImportedStruct_obj); } \ No newline at end of file diff --git a/feature_tests/js/api/ImportedStruct.mjs b/feature_tests/js/api/ImportedStruct.mjs index 0b86eeb22..0f6eb0342 100644 --- a/feature_tests/js/api/ImportedStruct.mjs +++ b/feature_tests/js/api/ImportedStruct.mjs @@ -3,9 +3,9 @@ import { UnimportedEnum } from "./UnimportedEnum.mjs" import wasm from "./diplomat-wasm.mjs"; import * as diplomatRuntime from "./diplomat-runtime.mjs"; - - -export class ImportedStruct { + + +export class ImportedStruct { #foo; @@ -31,7 +31,7 @@ export class ImportedStruct { static fromFields(structObj) { return new ImportedStruct(structObj); } - + #internalConstructor(structObj) { if (typeof structObj !== "object") { throw new Error("ImportedStruct's constructor takes an object of ImportedStruct's fields."); @@ -105,9 +105,9 @@ export class ImportedStruct { structObj.count = countDeref; return new ImportedStruct(structObj); - } - - constructor(structObj) { - return this.#internalConstructor(...arguments) - } + } + + constructor(structObj) { + return this.#internalConstructor(...arguments) + } } \ No newline at end of file diff --git a/feature_tests/js/api/MyEnum.d.ts b/feature_tests/js/api/MyEnum.d.ts index 1566f177f..c83b61625 100644 --- a/feature_tests/js/api/MyEnum.d.ts +++ b/feature_tests/js/api/MyEnum.d.ts @@ -1,9 +1,9 @@ // generated by diplomat-tool import type { pointer, codepoint } from "./diplomat-runtime.d.ts"; - - -export class MyEnum { + + +export class MyEnum { static fromValue(value : MyEnum | string) : MyEnum; @@ -17,11 +17,11 @@ export class MyEnum { static C : MyEnum; static D : MyEnum; static E : MyEnum; - static F : MyEnum; - - intoValue(): number; - - static getA(): MyEnum; - - constructor(value: MyEnum | string ); + static F : MyEnum; + + intoValue(): number; + + static getA(): MyEnum; + + constructor(value: MyEnum | string ); } \ No newline at end of file diff --git a/feature_tests/js/api/MyEnum.mjs b/feature_tests/js/api/MyEnum.mjs index ed674ed55..c976036fc 100644 --- a/feature_tests/js/api/MyEnum.mjs +++ b/feature_tests/js/api/MyEnum.mjs @@ -2,9 +2,9 @@ import wasm from "./diplomat-wasm.mjs"; import * as diplomatRuntime from "./diplomat-runtime.mjs"; - - -export class MyEnum { + + +export class MyEnum { #value = undefined; @@ -75,8 +75,8 @@ export class MyEnum { static C = MyEnum.#objectValues[0]; static D = MyEnum.#objectValues[1]; static E = MyEnum.#objectValues[2]; - static F = MyEnum.#objectValues[3]; - + static F = MyEnum.#objectValues[3]; + intoValue() { const result = wasm.MyEnum_into_value(this.ffiValue); @@ -85,8 +85,8 @@ export class MyEnum { } finally {} - } - + } + static getA() { const result = wasm.MyEnum_get_a(); @@ -95,9 +95,9 @@ export class MyEnum { } finally {} - } - - constructor(value) { - return this.#internalConstructor(...arguments) - } + } + + constructor(value) { + return this.#internalConstructor(...arguments) + } } \ No newline at end of file diff --git a/feature_tests/js/api/MyOpaqueEnum.d.ts b/feature_tests/js/api/MyOpaqueEnum.d.ts index f462bd143..8321f0a63 100644 --- a/feature_tests/js/api/MyOpaqueEnum.d.ts +++ b/feature_tests/js/api/MyOpaqueEnum.d.ts @@ -1,13 +1,13 @@ // generated by diplomat-tool import type { pointer, codepoint } from "./diplomat-runtime.d.ts"; - - -export class MyOpaqueEnum { + + +export class MyOpaqueEnum { - get ffiValue(): pointer; - - static new_(): MyOpaqueEnum; - - toString(): string; + get ffiValue(): pointer; + + static new_(): MyOpaqueEnum; + + toString(): string; } \ No newline at end of file diff --git a/feature_tests/js/api/MyOpaqueEnum.mjs b/feature_tests/js/api/MyOpaqueEnum.mjs index f0c65e94a..8ffa43e3f 100644 --- a/feature_tests/js/api/MyOpaqueEnum.mjs +++ b/feature_tests/js/api/MyOpaqueEnum.mjs @@ -4,9 +4,9 @@ import * as diplomatRuntime from "./diplomat-runtime.mjs"; const MyOpaqueEnum_box_destroy_registry = new FinalizationRegistry((ptr) => { wasm.MyOpaqueEnum_destroy(ptr); -}); - -export class MyOpaqueEnum { +}); + +export class MyOpaqueEnum { // Internal ptr reference: #ptr = null; @@ -33,8 +33,8 @@ export class MyOpaqueEnum { } get ffiValue() { return this.#ptr; - } - + } + static new_() { const result = wasm.MyOpaqueEnum_new(); @@ -43,8 +43,8 @@ export class MyOpaqueEnum { } finally {} - } - + } + toString() { const write = new diplomatRuntime.DiplomatWriteBuf(wasm); wasm.MyOpaqueEnum_to_string(this.ffiValue, write.buffer); @@ -56,9 +56,9 @@ export class MyOpaqueEnum { finally { write.free(); } - } - - constructor(symbol, ptr, selfEdge) { - return this.#internalConstructor(...arguments) - } + } + + constructor(symbol, ptr, selfEdge) { + return this.#internalConstructor(...arguments) + } } \ No newline at end of file diff --git a/feature_tests/js/api/MyString.d.ts b/feature_tests/js/api/MyString.d.ts index 221cf17b7..c910df449 100644 --- a/feature_tests/js/api/MyString.d.ts +++ b/feature_tests/js/api/MyString.d.ts @@ -1,25 +1,25 @@ // generated by diplomat-tool import type { pointer, codepoint } from "./diplomat-runtime.d.ts"; - - -export class MyString { + + +export class MyString { - get ffiValue(): pointer; - - static newUnsafe(v: string): MyString; - - static newOwned(v: string): MyString; - - static newFromFirst(v: Array): MyString; - - set str(newStr: string); - - get str(): string; - - static stringTransform(foo: string): string; - - borrow(): string; - - constructor(v: string); + get ffiValue(): pointer; + + static newUnsafe(v: string): MyString; + + static newOwned(v: string): MyString; + + static newFromFirst(v: Array): MyString; + + set str(newStr: string); + + get str(): string; + + static stringTransform(foo: string): string; + + borrow(): string; + + constructor(v: string); } \ No newline at end of file diff --git a/feature_tests/js/api/MyString.mjs b/feature_tests/js/api/MyString.mjs index 0b547e634..dde85fbd6 100644 --- a/feature_tests/js/api/MyString.mjs +++ b/feature_tests/js/api/MyString.mjs @@ -4,9 +4,9 @@ import * as diplomatRuntime from "./diplomat-runtime.mjs"; const MyString_box_destroy_registry = new FinalizationRegistry((ptr) => { wasm.MyString_destroy(ptr); -}); - -export class MyString { +}); + +export class MyString { // Internal ptr reference: #ptr = null; @@ -33,8 +33,8 @@ export class MyString { } get ffiValue() { return this.#ptr; - } - + } + #defaultConstructor(v) { let functionCleanupArena = new diplomatRuntime.CleanupArena(); @@ -49,8 +49,8 @@ export class MyString { finally { functionCleanupArena.free(); } - } - + } + static newUnsafe(v) { let functionCleanupArena = new diplomatRuntime.CleanupArena(); @@ -65,8 +65,8 @@ export class MyString { finally { functionCleanupArena.free(); } - } - + } + static newOwned(v) { let functionCleanupArena = new diplomatRuntime.CleanupArena(); @@ -81,8 +81,8 @@ export class MyString { finally { functionCleanupArena.free(); } - } - + } + static newFromFirst(v) { let functionCleanupArena = new diplomatRuntime.CleanupArena(); @@ -97,8 +97,8 @@ export class MyString { finally { functionCleanupArena.free(); } - } - + } + set str(newStr) { let functionCleanupArena = new diplomatRuntime.CleanupArena(); @@ -110,8 +110,8 @@ export class MyString { finally { functionCleanupArena.free(); } - } - + } + get str() { const write = new diplomatRuntime.DiplomatWriteBuf(wasm); wasm.MyString_get_str(this.ffiValue, write.buffer); @@ -123,8 +123,8 @@ export class MyString { finally { write.free(); } - } - + } + static stringTransform(foo) { let functionCleanupArena = new diplomatRuntime.CleanupArena(); @@ -142,8 +142,8 @@ export class MyString { write.free(); } - } - + } + borrow() { const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 8, 4, false); @@ -159,15 +159,15 @@ export class MyString { finally { diplomatReceive.free(); } - } - - constructor(v) { - if (arguments[0] === diplomatRuntime.exposeConstructor) { - return this.#internalConstructor(...Array.prototype.slice.call(arguments, 1)); - } else if (arguments[0] === diplomatRuntime.internalConstructor) { - return this.#internalConstructor(...arguments); - } else { - return this.#defaultConstructor(...arguments); - } - } + } + + constructor(v) { + if (arguments[0] === diplomatRuntime.exposeConstructor) { + return this.#internalConstructor(...Array.prototype.slice.call(arguments, 1)); + } else if (arguments[0] === diplomatRuntime.internalConstructor) { + return this.#internalConstructor(...arguments); + } else { + return this.#defaultConstructor(...arguments); + } + } } \ No newline at end of file diff --git a/feature_tests/js/api/MyStruct.d.ts b/feature_tests/js/api/MyStruct.d.ts index f53f35835..8cbbd3b8c 100644 --- a/feature_tests/js/api/MyStruct.d.ts +++ b/feature_tests/js/api/MyStruct.d.ts @@ -13,9 +13,9 @@ type MyStruct_obj = { g: MyEnum; }; - - -export class MyStruct { + + +export class MyStruct { get a() : number; set a(value: number); @@ -42,13 +42,13 @@ export class MyStruct { * Optional fields do not need to be included in the provided object. */ static fromFields(structObj : MyStruct_obj) : MyStruct; - - - intoA(): number; - - static returnsZstResult(): void; - - static failsZstResult(): void; - - constructor(); + + + intoA(): number; + + static returnsZstResult(): void; + + static failsZstResult(): void; + + constructor(); } \ No newline at end of file diff --git a/feature_tests/js/api/MyStruct.mjs b/feature_tests/js/api/MyStruct.mjs index 1b087f277..4a4765558 100644 --- a/feature_tests/js/api/MyStruct.mjs +++ b/feature_tests/js/api/MyStruct.mjs @@ -4,9 +4,9 @@ import { MyZst } from "./MyZst.mjs" import wasm from "./diplomat-wasm.mjs"; import * as diplomatRuntime from "./diplomat-runtime.mjs"; - - -export class MyStruct { + + +export class MyStruct { #a; @@ -77,7 +77,7 @@ export class MyStruct { static fromFields(structObj) { return new MyStruct(diplomatRuntime.exposeConstructor, structObj); } - + #internalConstructor(structObj) { if (typeof structObj !== "object") { throw new Error("MyStruct's constructor takes an object of MyStruct's fields."); @@ -191,8 +191,8 @@ export class MyStruct { structObj.g = new MyEnum(diplomatRuntime.internalConstructor, gDeref); return new MyStruct(diplomatRuntime.exposeConstructor, structObj); - } - + } + #defaultConstructor() { const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 32, 8, false); @@ -205,8 +205,8 @@ export class MyStruct { finally { diplomatReceive.free(); } - } - + } + intoA() { let functionCleanupArena = new diplomatRuntime.CleanupArena(); @@ -219,8 +219,8 @@ export class MyStruct { finally { functionCleanupArena.free(); } - } - + } + static returnsZstResult() { const result = wasm.MyStruct_returns_zst_result(); @@ -233,8 +233,8 @@ export class MyStruct { } finally {} - } - + } + static failsZstResult() { const result = wasm.MyStruct_fails_zst_result(); @@ -247,15 +247,15 @@ export class MyStruct { } finally {} - } - - constructor() { - if (arguments[0] === diplomatRuntime.exposeConstructor) { - return this.#internalConstructor(...Array.prototype.slice.call(arguments, 1)); - } else if (arguments[0] === diplomatRuntime.internalConstructor) { - return this.#internalConstructor(...arguments); - } else { - return this.#defaultConstructor(...arguments); - } - } + } + + constructor() { + if (arguments[0] === diplomatRuntime.exposeConstructor) { + return this.#internalConstructor(...Array.prototype.slice.call(arguments, 1)); + } else if (arguments[0] === diplomatRuntime.internalConstructor) { + return this.#internalConstructor(...arguments); + } else { + return this.#defaultConstructor(...arguments); + } + } } \ No newline at end of file diff --git a/feature_tests/js/api/MyZst.d.ts b/feature_tests/js/api/MyZst.d.ts index 058d1250b..6a265c5a4 100644 --- a/feature_tests/js/api/MyZst.d.ts +++ b/feature_tests/js/api/MyZst.d.ts @@ -4,15 +4,15 @@ import type { pointer, codepoint } from "./diplomat-runtime.d.ts"; type MyZst_obj = { }; - - -export class MyZst { + + +export class MyZst { /** Create `MyZst` from an object that contains all of `MyZst`s fields. * Optional fields do not need to be included in the provided object. */ static fromFields(structObj : MyZst_obj) : MyZst; - - - constructor(structObj : MyZst_obj); + + + constructor(structObj : MyZst_obj); } \ No newline at end of file diff --git a/feature_tests/js/api/MyZst.mjs b/feature_tests/js/api/MyZst.mjs index 06d1b8dd0..9a2194103 100644 --- a/feature_tests/js/api/MyZst.mjs +++ b/feature_tests/js/api/MyZst.mjs @@ -2,9 +2,9 @@ import wasm from "./diplomat-wasm.mjs"; import * as diplomatRuntime from "./diplomat-runtime.mjs"; - - -export class MyZst { + + +export class MyZst { /** Create `MyZst` from an object that contains all of `MyZst`s fields. * Optional fields do not need to be included in the provided object. @@ -12,7 +12,7 @@ export class MyZst { static fromFields(structObj) { return new MyZst(structObj); } - + #internalConstructor(structObj) { if (typeof structObj !== "object") { throw new Error("MyZst's constructor takes an object of MyZst's fields."); @@ -20,9 +20,9 @@ export class MyZst { return this; } - - - constructor(structObj) { - return this.#internalConstructor(...arguments) - } + + + constructor(structObj) { + return this.#internalConstructor(...arguments) + } } \ No newline at end of file diff --git a/feature_tests/js/api/NestedBorrowedFields.d.ts b/feature_tests/js/api/NestedBorrowedFields.d.ts index b19f1b032..8d9d4c6eb 100644 --- a/feature_tests/js/api/NestedBorrowedFields.d.ts +++ b/feature_tests/js/api/NestedBorrowedFields.d.ts @@ -13,9 +13,9 @@ type NestedBorrowedFields_obj = { bounds2: BorrowedFieldsWithBounds_obj; }; - - -export class NestedBorrowedFields { + + +export class NestedBorrowedFields { get fields() : BorrowedFields; set fields(value: BorrowedFields); @@ -30,9 +30,9 @@ export class NestedBorrowedFields { * Optional fields do not need to be included in the provided object. */ static fromFields(structObj : NestedBorrowedFields_obj) : NestedBorrowedFields; - - - static fromBarAndFooAndStrings(bar: Bar, foo: Foo, dstr16X: string, dstr16Z: string, utf8StrY: string, utf8StrZ: string): NestedBorrowedFields; - - constructor(structObj : NestedBorrowedFields_obj); + + + static fromBarAndFooAndStrings(bar: Bar, foo: Foo, dstr16X: string, dstr16Z: string, utf8StrY: string, utf8StrZ: string): NestedBorrowedFields; + + constructor(structObj : NestedBorrowedFields_obj); } \ No newline at end of file diff --git a/feature_tests/js/api/NestedBorrowedFields.mjs b/feature_tests/js/api/NestedBorrowedFields.mjs index f52500a10..67832479e 100644 --- a/feature_tests/js/api/NestedBorrowedFields.mjs +++ b/feature_tests/js/api/NestedBorrowedFields.mjs @@ -6,9 +6,9 @@ import { Foo } from "./Foo.mjs" import wasm from "./diplomat-wasm.mjs"; import * as diplomatRuntime from "./diplomat-runtime.mjs"; - - -export class NestedBorrowedFields { + + +export class NestedBorrowedFields { #fields; @@ -43,7 +43,7 @@ export class NestedBorrowedFields { static fromFields(structObj) { return new NestedBorrowedFields(structObj); } - + #internalConstructor(structObj) { if (typeof structObj !== "object") { throw new Error("NestedBorrowedFields's constructor takes an object of NestedBorrowedFields's fields."); @@ -148,8 +148,8 @@ export class NestedBorrowedFields { // the caller should take care to also call _fieldsForLifetimeOther get _fieldsForLifetimeZ() { return [...bounds2._fieldsForLifetimeA, ...bounds2._fieldsForLifetimeB, ...bounds2._fieldsForLifetimeC]; - }; - + }; + static fromBarAndFooAndStrings(bar, foo, dstr16X, dstr16Z, utf8StrY, utf8StrZ) { let functionGarbageCollectorGrip = new diplomatRuntime.GarbageCollectorGrip(); const dstr16XSlice = functionGarbageCollectorGrip.alloc(diplomatRuntime.DiplomatBuf.str16(wasm, dstr16X)); @@ -182,9 +182,9 @@ export class NestedBorrowedFields { diplomatReceive.free(); } - } - - constructor(structObj) { - return this.#internalConstructor(...arguments) - } + } + + constructor(structObj) { + return this.#internalConstructor(...arguments) + } } \ No newline at end of file diff --git a/feature_tests/js/api/One.d.ts b/feature_tests/js/api/One.d.ts index 271f8538c..c0a2fa446 100644 --- a/feature_tests/js/api/One.d.ts +++ b/feature_tests/js/api/One.d.ts @@ -2,31 +2,31 @@ import type { Two } from "./Two" import type { pointer, codepoint } from "./diplomat-runtime.d.ts"; - - -export class One { + + +export class One { - get ffiValue(): pointer; - - static transitivity(hold: One, nohold: One): One; - - static cycle(hold: Two, nohold: One): One; - - static manyDependents(a: One, b: One, c: Two, d: Two, nohold: Two): One; - - static returnOutlivesParam(hold: Two, nohold: One): One; - - static diamondTop(top: One, left: One, right: One, bottom: One): One; - - static diamondLeft(top: One, left: One, right: One, bottom: One): One; - - static diamondRight(top: One, left: One, right: One, bottom: One): One; - - static diamondBottom(top: One, left: One, right: One, bottom: One): One; - - static diamondAndNestedTypes(a: One, b: One, c: One, d: One, nohold: One): One; - - static implicitBounds(explicitHold: One, implicitHold: One, nohold: One): One; - - static implicitBoundsDeep(explicit: One, implicit1: One, implicit2: One, nohold: One): One; + get ffiValue(): pointer; + + static transitivity(hold: One, nohold: One): One; + + static cycle(hold: Two, nohold: One): One; + + static manyDependents(a: One, b: One, c: Two, d: Two, nohold: Two): One; + + static returnOutlivesParam(hold: Two, nohold: One): One; + + static diamondTop(top: One, left: One, right: One, bottom: One): One; + + static diamondLeft(top: One, left: One, right: One, bottom: One): One; + + static diamondRight(top: One, left: One, right: One, bottom: One): One; + + static diamondBottom(top: One, left: One, right: One, bottom: One): One; + + static diamondAndNestedTypes(a: One, b: One, c: One, d: One, nohold: One): One; + + static implicitBounds(explicitHold: One, implicitHold: One, nohold: One): One; + + static implicitBoundsDeep(explicit: One, implicit1: One, implicit2: One, nohold: One): One; } \ No newline at end of file diff --git a/feature_tests/js/api/One.mjs b/feature_tests/js/api/One.mjs index ad09ffc1d..077a61335 100644 --- a/feature_tests/js/api/One.mjs +++ b/feature_tests/js/api/One.mjs @@ -5,9 +5,9 @@ import * as diplomatRuntime from "./diplomat-runtime.mjs"; const One_box_destroy_registry = new FinalizationRegistry((ptr) => { wasm.One_destroy(ptr); -}); - -export class One { +}); + +export class One { // Internal ptr reference: #ptr = null; @@ -38,8 +38,8 @@ export class One { } get ffiValue() { return this.#ptr; - } - + } + static transitivity(hold, nohold) { // This lifetime edge depends on lifetimes 'a, 'b, 'c, 'd, 'e let aEdges = [hold]; @@ -51,8 +51,8 @@ export class One { } finally {} - } - + } + static cycle(hold, nohold) { // This lifetime edge depends on lifetimes 'a, 'b, 'c let aEdges = [hold]; @@ -64,8 +64,8 @@ export class One { } finally {} - } - + } + static manyDependents(a, b, c, d, nohold) { // This lifetime edge depends on lifetimes 'a, 'b, 'c, 'd let aEdges = [a, b, c, d]; @@ -77,8 +77,8 @@ export class One { } finally {} - } - + } + static returnOutlivesParam(hold, nohold) { // This lifetime edge depends on lifetimes 'long let longEdges = [hold]; @@ -90,8 +90,8 @@ export class One { } finally {} - } - + } + static diamondTop(top, left, right, bottom) { // This lifetime edge depends on lifetimes 'top, 'left, 'right, 'bottom let topEdges = [top, left, right, bottom]; @@ -103,8 +103,8 @@ export class One { } finally {} - } - + } + static diamondLeft(top, left, right, bottom) { // This lifetime edge depends on lifetimes 'left, 'bottom let leftEdges = [left, bottom]; @@ -116,8 +116,8 @@ export class One { } finally {} - } - + } + static diamondRight(top, left, right, bottom) { // This lifetime edge depends on lifetimes 'right, 'bottom let rightEdges = [right, bottom]; @@ -129,8 +129,8 @@ export class One { } finally {} - } - + } + static diamondBottom(top, left, right, bottom) { // This lifetime edge depends on lifetimes 'bottom let bottomEdges = [bottom]; @@ -142,8 +142,8 @@ export class One { } finally {} - } - + } + static diamondAndNestedTypes(a, b, c, d, nohold) { // This lifetime edge depends on lifetimes 'a, 'b, 'c, 'd let aEdges = [a, b, c, d]; @@ -155,8 +155,8 @@ export class One { } finally {} - } - + } + static implicitBounds(explicitHold, implicitHold, nohold) { // This lifetime edge depends on lifetimes 'a, 'b, 'c, 'd, 'x let aEdges = [explicitHold, implicitHold]; @@ -168,8 +168,8 @@ export class One { } finally {} - } - + } + static implicitBoundsDeep(explicit, implicit1, implicit2, nohold) { // This lifetime edge depends on lifetimes 'a, 'b, 'c, 'd let aEdges = [explicit, implicit1, implicit2]; @@ -181,9 +181,9 @@ export class One { } finally {} - } - - constructor(symbol, ptr, selfEdge, aEdge) { - return this.#internalConstructor(...arguments) - } + } + + constructor(symbol, ptr, selfEdge, aEdge) { + return this.#internalConstructor(...arguments) + } } \ No newline at end of file diff --git a/feature_tests/js/api/Opaque.d.ts b/feature_tests/js/api/Opaque.d.ts index 65f6a288e..67b9eeee2 100644 --- a/feature_tests/js/api/Opaque.d.ts +++ b/feature_tests/js/api/Opaque.d.ts @@ -4,25 +4,25 @@ import type { MyStruct } from "./MyStruct" import type { MyStruct_obj } from "./MyStruct" import type { pointer, codepoint } from "./diplomat-runtime.d.ts"; - - -export class Opaque { + + +export class Opaque { - get ffiValue(): pointer; - - static tryFromUtf8(input: string): Opaque | null; - - static fromStr(input: string): Opaque; - - getDebugStr(): string; - - assertStruct(s: MyStruct_obj): void; - - static returnsUsize(): number; - - static returnsImported(): ImportedStruct; - - static cmp(): number; - - constructor(); + get ffiValue(): pointer; + + static tryFromUtf8(input: string): Opaque | null; + + static fromStr(input: string): Opaque; + + getDebugStr(): string; + + assertStruct(s: MyStruct_obj): void; + + static returnsUsize(): number; + + static returnsImported(): ImportedStruct; + + static cmp(): number; + + constructor(); } \ No newline at end of file diff --git a/feature_tests/js/api/Opaque.mjs b/feature_tests/js/api/Opaque.mjs index 8024206bf..b31005d1b 100644 --- a/feature_tests/js/api/Opaque.mjs +++ b/feature_tests/js/api/Opaque.mjs @@ -6,9 +6,9 @@ import * as diplomatRuntime from "./diplomat-runtime.mjs"; const Opaque_box_destroy_registry = new FinalizationRegistry((ptr) => { wasm.Opaque_destroy(ptr); -}); - -export class Opaque { +}); + +export class Opaque { // Internal ptr reference: #ptr = null; @@ -35,8 +35,8 @@ export class Opaque { } get ffiValue() { return this.#ptr; - } - + } + #defaultConstructor() { const result = wasm.Opaque_new(); @@ -45,8 +45,8 @@ export class Opaque { } finally {} - } - + } + static tryFromUtf8(input) { let functionCleanupArena = new diplomatRuntime.CleanupArena(); @@ -61,8 +61,8 @@ export class Opaque { finally { functionCleanupArena.free(); } - } - + } + static fromStr(input) { let functionCleanupArena = new diplomatRuntime.CleanupArena(); @@ -77,8 +77,8 @@ export class Opaque { finally { functionCleanupArena.free(); } - } - + } + getDebugStr() { const write = new diplomatRuntime.DiplomatWriteBuf(wasm); wasm.Opaque_get_debug_str(this.ffiValue, write.buffer); @@ -90,8 +90,8 @@ export class Opaque { finally { write.free(); } - } - + } + assertStruct(s) { let functionCleanupArena = new diplomatRuntime.CleanupArena(); wasm.Opaque_assert_struct(this.ffiValue, ...MyStruct._fromSuppliedValue(diplomatRuntime.internalConstructor, s)._intoFFI(functionCleanupArena, {})); @@ -101,8 +101,8 @@ export class Opaque { finally { functionCleanupArena.free(); } - } - + } + static returnsUsize() { const result = wasm.Opaque_returns_usize(); @@ -111,8 +111,8 @@ export class Opaque { } finally {} - } - + } + static returnsImported() { const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 8, 4, false); @@ -125,8 +125,8 @@ export class Opaque { finally { diplomatReceive.free(); } - } - + } + static cmp() { const result = wasm.Opaque_cmp(); @@ -135,15 +135,15 @@ export class Opaque { } finally {} - } - - constructor() { - if (arguments[0] === diplomatRuntime.exposeConstructor) { - return this.#internalConstructor(...Array.prototype.slice.call(arguments, 1)); - } else if (arguments[0] === diplomatRuntime.internalConstructor) { - return this.#internalConstructor(...arguments); - } else { - return this.#defaultConstructor(...arguments); - } - } + } + + constructor() { + if (arguments[0] === diplomatRuntime.exposeConstructor) { + return this.#internalConstructor(...Array.prototype.slice.call(arguments, 1)); + } else if (arguments[0] === diplomatRuntime.internalConstructor) { + return this.#internalConstructor(...arguments); + } else { + return this.#defaultConstructor(...arguments); + } + } } \ No newline at end of file diff --git a/feature_tests/js/api/OpaqueMutexedString.d.ts b/feature_tests/js/api/OpaqueMutexedString.d.ts index 97d593a1c..12b55914a 100644 --- a/feature_tests/js/api/OpaqueMutexedString.d.ts +++ b/feature_tests/js/api/OpaqueMutexedString.d.ts @@ -2,27 +2,27 @@ import type { Utf16Wrap } from "./Utf16Wrap" import type { pointer, codepoint } from "./diplomat-runtime.d.ts"; - - -export class OpaqueMutexedString { + + +export class OpaqueMutexedString { - get ffiValue(): pointer; - - static fromUsize(number: number): OpaqueMutexedString; - - change(number: number): void; - - borrow(): OpaqueMutexedString; - - static borrowOther(other: OpaqueMutexedString): OpaqueMutexedString; - - borrowSelfOrOther(other: OpaqueMutexedString): OpaqueMutexedString; - - getLenAndAdd(other: number): number; - - dummyStr(): string; - - wrapper(): Utf16Wrap; - - toUnsignedFromUnsigned(input: number): number; + get ffiValue(): pointer; + + static fromUsize(number: number): OpaqueMutexedString; + + change(number: number): void; + + borrow(): OpaqueMutexedString; + + static borrowOther(other: OpaqueMutexedString): OpaqueMutexedString; + + borrowSelfOrOther(other: OpaqueMutexedString): OpaqueMutexedString; + + getLenAndAdd(other: number): number; + + dummyStr(): string; + + wrapper(): Utf16Wrap; + + toUnsignedFromUnsigned(input: number): number; } \ No newline at end of file diff --git a/feature_tests/js/api/OpaqueMutexedString.mjs b/feature_tests/js/api/OpaqueMutexedString.mjs index d9f49401e..01482bd6d 100644 --- a/feature_tests/js/api/OpaqueMutexedString.mjs +++ b/feature_tests/js/api/OpaqueMutexedString.mjs @@ -5,9 +5,9 @@ import * as diplomatRuntime from "./diplomat-runtime.mjs"; const OpaqueMutexedString_box_destroy_registry = new FinalizationRegistry((ptr) => { wasm.OpaqueMutexedString_destroy(ptr); -}); - -export class OpaqueMutexedString { +}); + +export class OpaqueMutexedString { // Internal ptr reference: #ptr = null; @@ -34,8 +34,8 @@ export class OpaqueMutexedString { } get ffiValue() { return this.#ptr; - } - + } + static fromUsize(number) { const result = wasm.OpaqueMutexedString_from_usize(number); @@ -44,15 +44,15 @@ export class OpaqueMutexedString { } finally {} - } - + } + change(number) {wasm.OpaqueMutexedString_change(this.ffiValue, number); try {} finally {} - } - + } + borrow() { // This lifetime edge depends on lifetimes 'a let aEdges = [this]; @@ -64,8 +64,8 @@ export class OpaqueMutexedString { } finally {} - } - + } + static borrowOther(other) { // This lifetime edge depends on lifetimes 'a let aEdges = [other]; @@ -77,8 +77,8 @@ export class OpaqueMutexedString { } finally {} - } - + } + borrowSelfOrOther(other) { // This lifetime edge depends on lifetimes 'a let aEdges = [this, other]; @@ -90,8 +90,8 @@ export class OpaqueMutexedString { } finally {} - } - + } + getLenAndAdd(other) { const result = wasm.OpaqueMutexedString_get_len_and_add(this.ffiValue, other); @@ -100,8 +100,8 @@ export class OpaqueMutexedString { } finally {} - } - + } + dummyStr() { const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 8, 4, false); @@ -117,8 +117,8 @@ export class OpaqueMutexedString { finally { diplomatReceive.free(); } - } - + } + wrapper() { const result = wasm.OpaqueMutexedString_wrapper(this.ffiValue); @@ -127,8 +127,8 @@ export class OpaqueMutexedString { } finally {} - } - + } + toUnsignedFromUnsigned(input) { const result = wasm.OpaqueMutexedString_to_unsigned_from_unsigned(this.ffiValue, input); @@ -137,9 +137,9 @@ export class OpaqueMutexedString { } finally {} - } - - constructor(symbol, ptr, selfEdge) { - return this.#internalConstructor(...arguments) - } + } + + constructor(symbol, ptr, selfEdge) { + return this.#internalConstructor(...arguments) + } } \ No newline at end of file diff --git a/feature_tests/js/api/OptionEnum.d.ts b/feature_tests/js/api/OptionEnum.d.ts index 56048a898..530579256 100644 --- a/feature_tests/js/api/OptionEnum.d.ts +++ b/feature_tests/js/api/OptionEnum.d.ts @@ -1,9 +1,9 @@ // generated by diplomat-tool import type { pointer, codepoint } from "./diplomat-runtime.d.ts"; - - -export class OptionEnum { + + +export class OptionEnum { static fromValue(value : OptionEnum | string) : OptionEnum; @@ -13,7 +13,7 @@ export class OptionEnum { get ffiValue() : number; static Foo : OptionEnum; - static Bar : OptionEnum; - - constructor(value: OptionEnum | string ); + static Bar : OptionEnum; + + constructor(value: OptionEnum | string ); } \ No newline at end of file diff --git a/feature_tests/js/api/OptionEnum.mjs b/feature_tests/js/api/OptionEnum.mjs index 2bf479abb..554cdd734 100644 --- a/feature_tests/js/api/OptionEnum.mjs +++ b/feature_tests/js/api/OptionEnum.mjs @@ -2,9 +2,9 @@ import wasm from "./diplomat-wasm.mjs"; import * as diplomatRuntime from "./diplomat-runtime.mjs"; - - -export class OptionEnum { + + +export class OptionEnum { #value = undefined; @@ -59,9 +59,9 @@ export class OptionEnum { ]; static Foo = OptionEnum.#objectValues[0]; - static Bar = OptionEnum.#objectValues[1]; - - constructor(value) { - return this.#internalConstructor(...arguments) - } + static Bar = OptionEnum.#objectValues[1]; + + constructor(value) { + return this.#internalConstructor(...arguments) + } } \ No newline at end of file diff --git a/feature_tests/js/api/OptionInputStruct.d.ts b/feature_tests/js/api/OptionInputStruct.d.ts index 7671d9d94..f8943af00 100644 --- a/feature_tests/js/api/OptionInputStruct.d.ts +++ b/feature_tests/js/api/OptionInputStruct.d.ts @@ -8,9 +8,9 @@ type OptionInputStruct_obj = { c?: OptionEnum | null; }; - - -export class OptionInputStruct { + + +export class OptionInputStruct { get a() : number | null; set a(value: number | null); @@ -25,7 +25,7 @@ export class OptionInputStruct { * Optional fields do not need to be included in the provided object. */ static fromFields(structObj : OptionInputStruct_obj) : OptionInputStruct; - - - constructor(structObj : OptionInputStruct_obj); + + + constructor(structObj : OptionInputStruct_obj); } \ No newline at end of file diff --git a/feature_tests/js/api/OptionInputStruct.mjs b/feature_tests/js/api/OptionInputStruct.mjs index 5fb088136..3ef3d2ff8 100644 --- a/feature_tests/js/api/OptionInputStruct.mjs +++ b/feature_tests/js/api/OptionInputStruct.mjs @@ -3,9 +3,9 @@ import { OptionEnum } from "./OptionEnum.mjs" import wasm from "./diplomat-wasm.mjs"; import * as diplomatRuntime from "./diplomat-runtime.mjs"; - - -export class OptionInputStruct { + + +export class OptionInputStruct { #a; @@ -40,7 +40,7 @@ export class OptionInputStruct { static fromFields(structObj) { return new OptionInputStruct(structObj); } - + #internalConstructor(structObj) { if (typeof structObj !== "object") { throw new Error("OptionInputStruct's constructor takes an object of OptionInputStruct's fields."); @@ -118,9 +118,9 @@ export class OptionInputStruct { structObj.c = diplomatRuntime.readOption(wasm, cDeref, 4, (wasm, offset) => { const deref = diplomatRuntime.enumDiscriminant(wasm, offset); return new OptionEnum(diplomatRuntime.internalConstructor, deref) }); return new OptionInputStruct(structObj); - } - - constructor(structObj) { - return this.#internalConstructor(...arguments) - } + } + + constructor(structObj) { + return this.#internalConstructor(...arguments) + } } \ No newline at end of file diff --git a/feature_tests/js/api/OptionOpaque.d.ts b/feature_tests/js/api/OptionOpaque.d.ts index daef25477..848751f41 100644 --- a/feature_tests/js/api/OptionOpaque.d.ts +++ b/feature_tests/js/api/OptionOpaque.d.ts @@ -4,39 +4,39 @@ import type { OptionInputStruct } from "./OptionInputStruct" import type { OptionStruct } from "./OptionStruct" import type { pointer, codepoint } from "./diplomat-runtime.d.ts"; - - -export class OptionOpaque { + + +export class OptionOpaque { - get ffiValue(): pointer; - - static new_(i: number): OptionOpaque | null; - - static newNone(): OptionOpaque | null; - - static returns(): OptionStruct | null; - - optionIsize(): number | null; - - optionUsize(): number | null; - - optionI32(): number | null; - - optionU32(): number | null; - - static newStruct(): OptionStruct; - - static newStructNones(): OptionStruct; - - assertInteger(i: number): void; - - static optionOpaqueArgument(arg: OptionOpaque | null): boolean; - - static acceptsOptionU8(arg: number | null): number | null; - - static acceptsOptionEnum(arg: OptionEnum | null): OptionEnum | null; - - static acceptsOptionInputStruct(arg: OptionInputStruct | null): OptionInputStruct | null; - - static returnsOptionInputStruct(): OptionInputStruct; + get ffiValue(): pointer; + + static new_(i: number): OptionOpaque | null; + + static newNone(): OptionOpaque | null; + + static returns(): OptionStruct | null; + + optionIsize(): number | null; + + optionUsize(): number | null; + + optionI32(): number | null; + + optionU32(): number | null; + + static newStruct(): OptionStruct; + + static newStructNones(): OptionStruct; + + assertInteger(i: number): void; + + static optionOpaqueArgument(arg: OptionOpaque | null): boolean; + + static acceptsOptionU8(arg: number | null): number | null; + + static acceptsOptionEnum(arg: OptionEnum | null): OptionEnum | null; + + static acceptsOptionInputStruct(arg: OptionInputStruct | null): OptionInputStruct | null; + + static returnsOptionInputStruct(): OptionInputStruct; } \ No newline at end of file diff --git a/feature_tests/js/api/OptionOpaque.mjs b/feature_tests/js/api/OptionOpaque.mjs index 9d733cdd0..406442395 100644 --- a/feature_tests/js/api/OptionOpaque.mjs +++ b/feature_tests/js/api/OptionOpaque.mjs @@ -7,9 +7,9 @@ import * as diplomatRuntime from "./diplomat-runtime.mjs"; const OptionOpaque_box_destroy_registry = new FinalizationRegistry((ptr) => { wasm.OptionOpaque_destroy(ptr); -}); - -export class OptionOpaque { +}); + +export class OptionOpaque { // Internal ptr reference: #ptr = null; @@ -36,8 +36,8 @@ export class OptionOpaque { } get ffiValue() { return this.#ptr; - } - + } + static new_(i) { const result = wasm.OptionOpaque_new(i); @@ -46,8 +46,8 @@ export class OptionOpaque { } finally {} - } - + } + static newNone() { const result = wasm.OptionOpaque_new_none(); @@ -56,8 +56,8 @@ export class OptionOpaque { } finally {} - } - + } + static returns() { const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 17, 4, true); @@ -73,8 +73,8 @@ export class OptionOpaque { finally { diplomatReceive.free(); } - } - + } + optionIsize() { const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true); @@ -90,8 +90,8 @@ export class OptionOpaque { finally { diplomatReceive.free(); } - } - + } + optionUsize() { const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true); @@ -107,8 +107,8 @@ export class OptionOpaque { finally { diplomatReceive.free(); } - } - + } + optionI32() { const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true); @@ -124,8 +124,8 @@ export class OptionOpaque { finally { diplomatReceive.free(); } - } - + } + optionU32() { const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true); @@ -141,8 +141,8 @@ export class OptionOpaque { finally { diplomatReceive.free(); } - } - + } + static newStruct() { const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 16, 4, false); @@ -155,8 +155,8 @@ export class OptionOpaque { finally { diplomatReceive.free(); } - } - + } + static newStructNones() { const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 16, 4, false); @@ -169,15 +169,15 @@ export class OptionOpaque { finally { diplomatReceive.free(); } - } - + } + assertInteger(i) {wasm.OptionOpaque_assert_integer(this.ffiValue, i); try {} finally {} - } - + } + static optionOpaqueArgument(arg) { const result = wasm.OptionOpaque_option_opaque_argument(arg.ffiValue ?? 0); @@ -186,8 +186,8 @@ export class OptionOpaque { } finally {} - } - + } + static acceptsOptionU8(arg) { const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 2, 1, true); @@ -203,8 +203,8 @@ export class OptionOpaque { finally { diplomatReceive.free(); } - } - + } + static acceptsOptionEnum(arg) { const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true); @@ -220,8 +220,8 @@ export class OptionOpaque { finally { diplomatReceive.free(); } - } - + } + static acceptsOptionInputStruct(arg) { let functionCleanupArena = new diplomatRuntime.CleanupArena(); @@ -241,8 +241,8 @@ export class OptionOpaque { diplomatReceive.free(); } - } - + } + static returnsOptionInputStruct() { const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 20, 4, false); @@ -255,9 +255,9 @@ export class OptionOpaque { finally { diplomatReceive.free(); } - } - - constructor(symbol, ptr, selfEdge) { - return this.#internalConstructor(...arguments) - } + } + + constructor(symbol, ptr, selfEdge) { + return this.#internalConstructor(...arguments) + } } \ No newline at end of file diff --git a/feature_tests/js/api/OptionOpaqueChar.d.ts b/feature_tests/js/api/OptionOpaqueChar.d.ts index dfb5334fe..2994dec21 100644 --- a/feature_tests/js/api/OptionOpaqueChar.d.ts +++ b/feature_tests/js/api/OptionOpaqueChar.d.ts @@ -1,11 +1,11 @@ // generated by diplomat-tool import type { pointer, codepoint } from "./diplomat-runtime.d.ts"; - - -export class OptionOpaqueChar { + + +export class OptionOpaqueChar { - get ffiValue(): pointer; - - assertChar(ch: codepoint): void; + get ffiValue(): pointer; + + assertChar(ch: codepoint): void; } \ No newline at end of file diff --git a/feature_tests/js/api/OptionOpaqueChar.mjs b/feature_tests/js/api/OptionOpaqueChar.mjs index 668c35e87..64f26395f 100644 --- a/feature_tests/js/api/OptionOpaqueChar.mjs +++ b/feature_tests/js/api/OptionOpaqueChar.mjs @@ -4,9 +4,9 @@ import * as diplomatRuntime from "./diplomat-runtime.mjs"; const OptionOpaqueChar_box_destroy_registry = new FinalizationRegistry((ptr) => { wasm.OptionOpaqueChar_destroy(ptr); -}); - -export class OptionOpaqueChar { +}); + +export class OptionOpaqueChar { // Internal ptr reference: #ptr = null; @@ -33,16 +33,16 @@ export class OptionOpaqueChar { } get ffiValue() { return this.#ptr; - } - + } + assertChar(ch) {wasm.OptionOpaqueChar_assert_char(this.ffiValue, ch); try {} finally {} - } - - constructor(symbol, ptr, selfEdge) { - return this.#internalConstructor(...arguments) - } + } + + constructor(symbol, ptr, selfEdge) { + return this.#internalConstructor(...arguments) + } } \ No newline at end of file diff --git a/feature_tests/js/api/OptionString.d.ts b/feature_tests/js/api/OptionString.d.ts index 7a9c3858a..32cb2a6fb 100644 --- a/feature_tests/js/api/OptionString.d.ts +++ b/feature_tests/js/api/OptionString.d.ts @@ -1,15 +1,15 @@ // generated by diplomat-tool import type { pointer, codepoint } from "./diplomat-runtime.d.ts"; - - -export class OptionString { + + +export class OptionString { - get ffiValue(): pointer; - - static new_(diplomatStr: string): OptionString | null; - - write(): string | null; - - borrow(): string | null; + get ffiValue(): pointer; + + static new_(diplomatStr: string): OptionString | null; + + write(): string | null; + + borrow(): string | null; } \ No newline at end of file diff --git a/feature_tests/js/api/OptionString.mjs b/feature_tests/js/api/OptionString.mjs index 3239065d2..b80a03163 100644 --- a/feature_tests/js/api/OptionString.mjs +++ b/feature_tests/js/api/OptionString.mjs @@ -4,9 +4,9 @@ import * as diplomatRuntime from "./diplomat-runtime.mjs"; const OptionString_box_destroy_registry = new FinalizationRegistry((ptr) => { wasm.OptionString_destroy(ptr); -}); - -export class OptionString { +}); + +export class OptionString { // Internal ptr reference: #ptr = null; @@ -33,8 +33,8 @@ export class OptionString { } get ffiValue() { return this.#ptr; - } - + } + static new_(diplomatStr) { let functionCleanupArena = new diplomatRuntime.CleanupArena(); @@ -49,8 +49,8 @@ export class OptionString { finally { functionCleanupArena.free(); } - } - + } + write() { const write = new diplomatRuntime.DiplomatWriteBuf(wasm); @@ -63,8 +63,8 @@ export class OptionString { finally { write.free(); } - } - + } + borrow() { const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 9, 4, true); @@ -83,9 +83,9 @@ export class OptionString { finally { diplomatReceive.free(); } - } - - constructor(symbol, ptr, selfEdge) { - return this.#internalConstructor(...arguments) - } + } + + constructor(symbol, ptr, selfEdge) { + return this.#internalConstructor(...arguments) + } } \ No newline at end of file diff --git a/feature_tests/js/api/OptionStruct.d.ts b/feature_tests/js/api/OptionStruct.d.ts index dcfb00617..87c3ad737 100644 --- a/feature_tests/js/api/OptionStruct.d.ts +++ b/feature_tests/js/api/OptionStruct.d.ts @@ -3,9 +3,9 @@ import type { OptionOpaque } from "./OptionOpaque" import type { OptionOpaqueChar } from "./OptionOpaqueChar" import type { pointer, codepoint } from "./diplomat-runtime.d.ts"; - - -export class OptionStruct { + + +export class OptionStruct { get a() : OptionOpaque | null; @@ -14,5 +14,5 @@ export class OptionStruct { get c() : number; get d() : OptionOpaque; - + } \ No newline at end of file diff --git a/feature_tests/js/api/OptionStruct.mjs b/feature_tests/js/api/OptionStruct.mjs index dfcd8b80e..97435cdc1 100644 --- a/feature_tests/js/api/OptionStruct.mjs +++ b/feature_tests/js/api/OptionStruct.mjs @@ -4,9 +4,9 @@ import { OptionOpaqueChar } from "./OptionOpaqueChar.mjs" import wasm from "./diplomat-wasm.mjs"; import * as diplomatRuntime from "./diplomat-runtime.mjs"; - - -export class OptionStruct { + + +export class OptionStruct { #a; @@ -121,9 +121,9 @@ export class OptionStruct { structObj.d = new OptionOpaque(diplomatRuntime.internalConstructor, dDeref, []); return new OptionStruct(structObj, internalConstructor); - } - - constructor(structObj, internalConstructor) { - return this.#internalConstructor(...arguments) - } + } + + constructor(structObj, internalConstructor) { + return this.#internalConstructor(...arguments) + } } \ No newline at end of file diff --git a/feature_tests/js/api/RefList.d.ts b/feature_tests/js/api/RefList.d.ts index 5e198f07e..26103408c 100644 --- a/feature_tests/js/api/RefList.d.ts +++ b/feature_tests/js/api/RefList.d.ts @@ -2,11 +2,11 @@ import type { RefListParameter } from "./RefListParameter" import type { pointer, codepoint } from "./diplomat-runtime.d.ts"; - - -export class RefList { + + +export class RefList { - get ffiValue(): pointer; - - static node(data: RefListParameter): RefList; + get ffiValue(): pointer; + + static node(data: RefListParameter): RefList; } \ No newline at end of file diff --git a/feature_tests/js/api/RefList.mjs b/feature_tests/js/api/RefList.mjs index ca56f8b24..a0caa4b0d 100644 --- a/feature_tests/js/api/RefList.mjs +++ b/feature_tests/js/api/RefList.mjs @@ -5,9 +5,9 @@ import * as diplomatRuntime from "./diplomat-runtime.mjs"; const RefList_box_destroy_registry = new FinalizationRegistry((ptr) => { wasm.RefList_destroy(ptr); -}); - -export class RefList { +}); + +export class RefList { // Internal ptr reference: #ptr = null; @@ -38,8 +38,8 @@ export class RefList { } get ffiValue() { return this.#ptr; - } - + } + static node(data) { // This lifetime edge depends on lifetimes 'b let bEdges = [data]; @@ -51,9 +51,9 @@ export class RefList { } finally {} - } - - constructor(symbol, ptr, selfEdge, aEdge) { - return this.#internalConstructor(...arguments) - } + } + + constructor(symbol, ptr, selfEdge, aEdge) { + return this.#internalConstructor(...arguments) + } } \ No newline at end of file diff --git a/feature_tests/js/api/RefListParameter.d.ts b/feature_tests/js/api/RefListParameter.d.ts index 79d32e33c..9d0ccfdc5 100644 --- a/feature_tests/js/api/RefListParameter.d.ts +++ b/feature_tests/js/api/RefListParameter.d.ts @@ -1,9 +1,9 @@ // generated by diplomat-tool import type { pointer, codepoint } from "./diplomat-runtime.d.ts"; - - -export class RefListParameter { + + +export class RefListParameter { - get ffiValue(): pointer; + get ffiValue(): pointer; } \ No newline at end of file diff --git a/feature_tests/js/api/RefListParameter.mjs b/feature_tests/js/api/RefListParameter.mjs index 3ce913683..6e916ca62 100644 --- a/feature_tests/js/api/RefListParameter.mjs +++ b/feature_tests/js/api/RefListParameter.mjs @@ -4,9 +4,9 @@ import * as diplomatRuntime from "./diplomat-runtime.mjs"; const RefListParameter_box_destroy_registry = new FinalizationRegistry((ptr) => { wasm.RefListParameter_destroy(ptr); -}); - -export class RefListParameter { +}); + +export class RefListParameter { // Internal ptr reference: #ptr = null; @@ -33,9 +33,9 @@ export class RefListParameter { } get ffiValue() { return this.#ptr; - } - - constructor(symbol, ptr, selfEdge) { - return this.#internalConstructor(...arguments) - } + } + + constructor(symbol, ptr, selfEdge) { + return this.#internalConstructor(...arguments) + } } \ No newline at end of file diff --git a/feature_tests/js/api/RenamedAttrEnum.d.ts b/feature_tests/js/api/RenamedAttrEnum.d.ts index dc76f2434..be54c97fe 100644 --- a/feature_tests/js/api/RenamedAttrEnum.d.ts +++ b/feature_tests/js/api/RenamedAttrEnum.d.ts @@ -1,9 +1,9 @@ // generated by diplomat-tool import type { pointer, codepoint } from "./diplomat-runtime.d.ts"; - - -export class RenamedAttrEnum { + + +export class RenamedAttrEnum { static fromValue(value : RenamedAttrEnum | string) : RenamedAttrEnum; @@ -14,7 +14,7 @@ export class RenamedAttrEnum { static A : RenamedAttrEnum; static B : RenamedAttrEnum; - static Renamed : RenamedAttrEnum; - - constructor(value: RenamedAttrEnum | string ); + static Renamed : RenamedAttrEnum; + + constructor(value: RenamedAttrEnum | string ); } \ No newline at end of file diff --git a/feature_tests/js/api/RenamedAttrEnum.mjs b/feature_tests/js/api/RenamedAttrEnum.mjs index 2813efa42..1a23fe75c 100644 --- a/feature_tests/js/api/RenamedAttrEnum.mjs +++ b/feature_tests/js/api/RenamedAttrEnum.mjs @@ -2,9 +2,9 @@ import wasm from "./diplomat-wasm.mjs"; import * as diplomatRuntime from "./diplomat-runtime.mjs"; - - -export class RenamedAttrEnum { + + +export class RenamedAttrEnum { #value = undefined; @@ -62,9 +62,9 @@ export class RenamedAttrEnum { static A = RenamedAttrEnum.#objectValues[0]; static B = RenamedAttrEnum.#objectValues[1]; - static Renamed = RenamedAttrEnum.#objectValues[2]; - - constructor(value) { - return this.#internalConstructor(...arguments) - } + static Renamed = RenamedAttrEnum.#objectValues[2]; + + constructor(value) { + return this.#internalConstructor(...arguments) + } } \ No newline at end of file diff --git a/feature_tests/js/api/RenamedAttrOpaque2.d.ts b/feature_tests/js/api/RenamedAttrOpaque2.d.ts index ecf22d1d9..d17c8056c 100644 --- a/feature_tests/js/api/RenamedAttrOpaque2.d.ts +++ b/feature_tests/js/api/RenamedAttrOpaque2.d.ts @@ -1,9 +1,9 @@ // generated by diplomat-tool import type { pointer, codepoint } from "./diplomat-runtime.d.ts"; - - -export class RenamedAttrOpaque2 { + + +export class RenamedAttrOpaque2 { - get ffiValue(): pointer; + get ffiValue(): pointer; } \ No newline at end of file diff --git a/feature_tests/js/api/RenamedAttrOpaque2.mjs b/feature_tests/js/api/RenamedAttrOpaque2.mjs index b4abed1d2..a417216a5 100644 --- a/feature_tests/js/api/RenamedAttrOpaque2.mjs +++ b/feature_tests/js/api/RenamedAttrOpaque2.mjs @@ -4,9 +4,9 @@ import * as diplomatRuntime from "./diplomat-runtime.mjs"; const RenamedAttrOpaque2_box_destroy_registry = new FinalizationRegistry((ptr) => { wasm.namespace_AttrOpaque2_destroy(ptr); -}); - -export class RenamedAttrOpaque2 { +}); + +export class RenamedAttrOpaque2 { // Internal ptr reference: #ptr = null; @@ -33,9 +33,9 @@ export class RenamedAttrOpaque2 { } get ffiValue() { return this.#ptr; - } - - constructor(symbol, ptr, selfEdge) { - return this.#internalConstructor(...arguments) - } + } + + constructor(symbol, ptr, selfEdge) { + return this.#internalConstructor(...arguments) + } } \ No newline at end of file diff --git a/feature_tests/js/api/RenamedMyIterable.d.ts b/feature_tests/js/api/RenamedMyIterable.d.ts index 31427daa7..aaab79aeb 100644 --- a/feature_tests/js/api/RenamedMyIterable.d.ts +++ b/feature_tests/js/api/RenamedMyIterable.d.ts @@ -2,13 +2,13 @@ import type { RenamedMyIterator } from "./RenamedMyIterator" import type { pointer, codepoint } from "./diplomat-runtime.d.ts"; - - -export class RenamedMyIterable { + + +export class RenamedMyIterable { - get ffiValue(): pointer; - - [Symbol.iterator](): RenamedMyIterator; - - constructor(x: Array); + get ffiValue(): pointer; + + [Symbol.iterator](): RenamedMyIterator; + + constructor(x: Array); } \ No newline at end of file diff --git a/feature_tests/js/api/RenamedMyIterable.mjs b/feature_tests/js/api/RenamedMyIterable.mjs index a3d227d6f..f8b2f3b81 100644 --- a/feature_tests/js/api/RenamedMyIterable.mjs +++ b/feature_tests/js/api/RenamedMyIterable.mjs @@ -5,9 +5,9 @@ import * as diplomatRuntime from "./diplomat-runtime.mjs"; const RenamedMyIterable_box_destroy_registry = new FinalizationRegistry((ptr) => { wasm.namespace_MyIterable_destroy(ptr); -}); - -export class RenamedMyIterable { +}); + +export class RenamedMyIterable { // Internal ptr reference: #ptr = null; @@ -34,8 +34,8 @@ export class RenamedMyIterable { } get ffiValue() { return this.#ptr; - } - + } + #defaultConstructor(x) { let functionCleanupArena = new diplomatRuntime.CleanupArena(); @@ -50,8 +50,8 @@ export class RenamedMyIterable { finally { functionCleanupArena.free(); } - } - + } + [Symbol.iterator]() { // This lifetime edge depends on lifetimes 'a let aEdges = [this]; @@ -63,15 +63,15 @@ export class RenamedMyIterable { } finally {} - } - - constructor(x) { - if (arguments[0] === diplomatRuntime.exposeConstructor) { - return this.#internalConstructor(...Array.prototype.slice.call(arguments, 1)); - } else if (arguments[0] === diplomatRuntime.internalConstructor) { - return this.#internalConstructor(...arguments); - } else { - return this.#defaultConstructor(...arguments); - } - } + } + + constructor(x) { + if (arguments[0] === diplomatRuntime.exposeConstructor) { + return this.#internalConstructor(...Array.prototype.slice.call(arguments, 1)); + } else if (arguments[0] === diplomatRuntime.internalConstructor) { + return this.#internalConstructor(...arguments); + } else { + return this.#defaultConstructor(...arguments); + } + } } \ No newline at end of file diff --git a/feature_tests/js/api/RenamedMyIterator.d.ts b/feature_tests/js/api/RenamedMyIterator.d.ts index 63f97d326..cb661b42e 100644 --- a/feature_tests/js/api/RenamedMyIterator.d.ts +++ b/feature_tests/js/api/RenamedMyIterator.d.ts @@ -1,11 +1,11 @@ // generated by diplomat-tool import type { pointer, codepoint } from "./diplomat-runtime.d.ts"; - - -export class RenamedMyIterator { + + +export class RenamedMyIterator { - get ffiValue(): pointer; - - next() : IteratorResult; + get ffiValue(): pointer; + + next() : IteratorResult; } \ No newline at end of file diff --git a/feature_tests/js/api/RenamedMyIterator.mjs b/feature_tests/js/api/RenamedMyIterator.mjs index e3d7736d5..1d97ed3bd 100644 --- a/feature_tests/js/api/RenamedMyIterator.mjs +++ b/feature_tests/js/api/RenamedMyIterator.mjs @@ -4,9 +4,9 @@ import * as diplomatRuntime from "./diplomat-runtime.mjs"; const RenamedMyIterator_box_destroy_registry = new FinalizationRegistry((ptr) => { wasm.namespace_MyIterator_destroy(ptr); -}); - -export class RenamedMyIterator { +}); + +export class RenamedMyIterator { // Internal ptr reference: #ptr = null; @@ -37,8 +37,8 @@ export class RenamedMyIterator { } get ffiValue() { return this.#ptr; - } - + } + #iteratorNext() { const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 2, 1, true); @@ -54,18 +54,18 @@ export class RenamedMyIterator { finally { diplomatReceive.free(); } - } - - next() { - const out = this.#iteratorNext(); - - return { - value: out, - done: out === null, - }; - } - - constructor(symbol, ptr, selfEdge, aEdge) { - return this.#internalConstructor(...arguments) - } + } + + next() { + const out = this.#iteratorNext(); + + return { + value: out, + done: out === null, + }; + } + + constructor(symbol, ptr, selfEdge, aEdge) { + return this.#internalConstructor(...arguments) + } } \ No newline at end of file diff --git a/feature_tests/js/api/RenamedNested.d.ts b/feature_tests/js/api/RenamedNested.d.ts index 0789b90cd..60ff8298f 100644 --- a/feature_tests/js/api/RenamedNested.d.ts +++ b/feature_tests/js/api/RenamedNested.d.ts @@ -1,9 +1,9 @@ // generated by diplomat-tool import type { pointer, codepoint } from "./diplomat-runtime.d.ts"; - - -export class RenamedNested { + + +export class RenamedNested { - get ffiValue(): pointer; + get ffiValue(): pointer; } \ No newline at end of file diff --git a/feature_tests/js/api/RenamedNested.mjs b/feature_tests/js/api/RenamedNested.mjs index 4966774a4..4cf847493 100644 --- a/feature_tests/js/api/RenamedNested.mjs +++ b/feature_tests/js/api/RenamedNested.mjs @@ -4,9 +4,9 @@ import * as diplomatRuntime from "./diplomat-runtime.mjs"; const RenamedNested_box_destroy_registry = new FinalizationRegistry((ptr) => { wasm.namespace_Nested_destroy(ptr); -}); - -export class RenamedNested { +}); + +export class RenamedNested { // Internal ptr reference: #ptr = null; @@ -33,9 +33,9 @@ export class RenamedNested { } get ffiValue() { return this.#ptr; - } - - constructor(symbol, ptr, selfEdge) { - return this.#internalConstructor(...arguments) - } + } + + constructor(symbol, ptr, selfEdge) { + return this.#internalConstructor(...arguments) + } } \ No newline at end of file diff --git a/feature_tests/js/api/RenamedNested2.d.ts b/feature_tests/js/api/RenamedNested2.d.ts index 3bf349a79..df24ae45b 100644 --- a/feature_tests/js/api/RenamedNested2.d.ts +++ b/feature_tests/js/api/RenamedNested2.d.ts @@ -1,9 +1,9 @@ // generated by diplomat-tool import type { pointer, codepoint } from "./diplomat-runtime.d.ts"; - - -export class RenamedNested2 { + + +export class RenamedNested2 { - get ffiValue(): pointer; + get ffiValue(): pointer; } \ No newline at end of file diff --git a/feature_tests/js/api/RenamedNested2.mjs b/feature_tests/js/api/RenamedNested2.mjs index f03b6d503..cff7f7709 100644 --- a/feature_tests/js/api/RenamedNested2.mjs +++ b/feature_tests/js/api/RenamedNested2.mjs @@ -4,9 +4,9 @@ import * as diplomatRuntime from "./diplomat-runtime.mjs"; const RenamedNested2_box_destroy_registry = new FinalizationRegistry((ptr) => { wasm.namespace_Nested2_destroy(ptr); -}); - -export class RenamedNested2 { +}); + +export class RenamedNested2 { // Internal ptr reference: #ptr = null; @@ -33,9 +33,9 @@ export class RenamedNested2 { } get ffiValue() { return this.#ptr; - } - - constructor(symbol, ptr, selfEdge) { - return this.#internalConstructor(...arguments) - } + } + + constructor(symbol, ptr, selfEdge) { + return this.#internalConstructor(...arguments) + } } \ No newline at end of file diff --git a/feature_tests/js/api/RenamedOpaqueIterable.d.ts b/feature_tests/js/api/RenamedOpaqueIterable.d.ts index 719fccf9e..865fb442f 100644 --- a/feature_tests/js/api/RenamedOpaqueIterable.d.ts +++ b/feature_tests/js/api/RenamedOpaqueIterable.d.ts @@ -2,11 +2,11 @@ import type { RenamedOpaqueIterator } from "./RenamedOpaqueIterator" import type { pointer, codepoint } from "./diplomat-runtime.d.ts"; - - -export class RenamedOpaqueIterable { + + +export class RenamedOpaqueIterable { - get ffiValue(): pointer; - - [Symbol.iterator](): RenamedOpaqueIterator; + get ffiValue(): pointer; + + [Symbol.iterator](): RenamedOpaqueIterator; } \ No newline at end of file diff --git a/feature_tests/js/api/RenamedOpaqueIterable.mjs b/feature_tests/js/api/RenamedOpaqueIterable.mjs index 7ba7d9f38..ff945c246 100644 --- a/feature_tests/js/api/RenamedOpaqueIterable.mjs +++ b/feature_tests/js/api/RenamedOpaqueIterable.mjs @@ -5,9 +5,9 @@ import * as diplomatRuntime from "./diplomat-runtime.mjs"; const RenamedOpaqueIterable_box_destroy_registry = new FinalizationRegistry((ptr) => { wasm.namespace_OpaqueIterable_destroy(ptr); -}); - -export class RenamedOpaqueIterable { +}); + +export class RenamedOpaqueIterable { // Internal ptr reference: #ptr = null; @@ -34,8 +34,8 @@ export class RenamedOpaqueIterable { } get ffiValue() { return this.#ptr; - } - + } + [Symbol.iterator]() { // This lifetime edge depends on lifetimes 'a let aEdges = [this]; @@ -47,9 +47,9 @@ export class RenamedOpaqueIterable { } finally {} - } - - constructor(symbol, ptr, selfEdge) { - return this.#internalConstructor(...arguments) - } + } + + constructor(symbol, ptr, selfEdge) { + return this.#internalConstructor(...arguments) + } } \ No newline at end of file diff --git a/feature_tests/js/api/RenamedOpaqueIterator.d.ts b/feature_tests/js/api/RenamedOpaqueIterator.d.ts index 5de94022c..f75cfa2d2 100644 --- a/feature_tests/js/api/RenamedOpaqueIterator.d.ts +++ b/feature_tests/js/api/RenamedOpaqueIterator.d.ts @@ -2,11 +2,11 @@ import type { AttrOpaque1Renamed } from "./AttrOpaque1Renamed" import type { pointer, codepoint } from "./diplomat-runtime.d.ts"; - - -export class RenamedOpaqueIterator { + + +export class RenamedOpaqueIterator { - get ffiValue(): pointer; - - next() : IteratorResult; + get ffiValue(): pointer; + + next() : IteratorResult; } \ No newline at end of file diff --git a/feature_tests/js/api/RenamedOpaqueIterator.mjs b/feature_tests/js/api/RenamedOpaqueIterator.mjs index 18e1612b9..7c3123cb4 100644 --- a/feature_tests/js/api/RenamedOpaqueIterator.mjs +++ b/feature_tests/js/api/RenamedOpaqueIterator.mjs @@ -5,9 +5,9 @@ import * as diplomatRuntime from "./diplomat-runtime.mjs"; const RenamedOpaqueIterator_box_destroy_registry = new FinalizationRegistry((ptr) => { wasm.namespace_OpaqueIterator_destroy(ptr); -}); - -export class RenamedOpaqueIterator { +}); + +export class RenamedOpaqueIterator { // Internal ptr reference: #ptr = null; @@ -38,8 +38,8 @@ export class RenamedOpaqueIterator { } get ffiValue() { return this.#ptr; - } - + } + #iteratorNext() { const result = wasm.namespace_OpaqueIterator_next(this.ffiValue); @@ -48,18 +48,18 @@ export class RenamedOpaqueIterator { } finally {} - } - - next() { - const out = this.#iteratorNext(); - - return { - value: out, - done: out === null, - }; - } - - constructor(symbol, ptr, selfEdge, aEdge) { - return this.#internalConstructor(...arguments) - } + } + + next() { + const out = this.#iteratorNext(); + + return { + value: out, + done: out === null, + }; + } + + constructor(symbol, ptr, selfEdge, aEdge) { + return this.#internalConstructor(...arguments) + } } \ No newline at end of file diff --git a/feature_tests/js/api/ResultOpaque.d.ts b/feature_tests/js/api/ResultOpaque.d.ts index c5da9daea..ed8455a29 100644 --- a/feature_tests/js/api/ResultOpaque.d.ts +++ b/feature_tests/js/api/ResultOpaque.d.ts @@ -3,27 +3,27 @@ import type { ErrorEnum } from "./ErrorEnum" import type { ErrorStruct } from "./ErrorStruct" import type { pointer, codepoint } from "./diplomat-runtime.d.ts"; - - -export class ResultOpaque { + + +export class ResultOpaque { - get ffiValue(): pointer; - - static newFailingFoo(): ResultOpaque; - - static newFailingBar(): ResultOpaque; - - static newFailingUnit(): ResultOpaque | null; - - static newFailingStruct(i: number): ResultOpaque; - - static newInErr(i: number): void; - - static newInt(i: number): number | null; - - static newInEnumErr(i: number): ErrorEnum; - - assertInteger(i: number): void; - - constructor(i: number); + get ffiValue(): pointer; + + static newFailingFoo(): ResultOpaque; + + static newFailingBar(): ResultOpaque; + + static newFailingUnit(): ResultOpaque | null; + + static newFailingStruct(i: number): ResultOpaque; + + static newInErr(i: number): void; + + static newInt(i: number): number | null; + + static newInEnumErr(i: number): ErrorEnum; + + assertInteger(i: number): void; + + constructor(i: number); } \ No newline at end of file diff --git a/feature_tests/js/api/ResultOpaque.mjs b/feature_tests/js/api/ResultOpaque.mjs index a59a3cc71..d1271a949 100644 --- a/feature_tests/js/api/ResultOpaque.mjs +++ b/feature_tests/js/api/ResultOpaque.mjs @@ -6,9 +6,9 @@ import * as diplomatRuntime from "./diplomat-runtime.mjs"; const ResultOpaque_box_destroy_registry = new FinalizationRegistry((ptr) => { wasm.ResultOpaque_destroy(ptr); -}); - -export class ResultOpaque { +}); + +export class ResultOpaque { // Internal ptr reference: #ptr = null; @@ -35,8 +35,8 @@ export class ResultOpaque { } get ffiValue() { return this.#ptr; - } - + } + #defaultConstructor(i) { const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true); @@ -53,8 +53,8 @@ export class ResultOpaque { finally { diplomatReceive.free(); } - } - + } + static newFailingFoo() { const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true); @@ -71,8 +71,8 @@ export class ResultOpaque { finally { diplomatReceive.free(); } - } - + } + static newFailingBar() { const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true); @@ -89,8 +89,8 @@ export class ResultOpaque { finally { diplomatReceive.free(); } - } - + } + static newFailingUnit() { const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true); @@ -106,8 +106,8 @@ export class ResultOpaque { finally { diplomatReceive.free(); } - } - + } + static newFailingStruct(i) { const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 9, 4, true); @@ -124,8 +124,8 @@ export class ResultOpaque { finally { diplomatReceive.free(); } - } - + } + static newInErr(i) { const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true); @@ -142,8 +142,8 @@ export class ResultOpaque { finally { diplomatReceive.free(); } - } - + } + static newInt(i) { const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true); @@ -159,8 +159,8 @@ export class ResultOpaque { finally { diplomatReceive.free(); } - } - + } + static newInEnumErr(i) { const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true); @@ -177,22 +177,22 @@ export class ResultOpaque { finally { diplomatReceive.free(); } - } - + } + assertInteger(i) {wasm.ResultOpaque_assert_integer(this.ffiValue, i); try {} finally {} - } - - constructor(i) { - if (arguments[0] === diplomatRuntime.exposeConstructor) { - return this.#internalConstructor(...Array.prototype.slice.call(arguments, 1)); - } else if (arguments[0] === diplomatRuntime.internalConstructor) { - return this.#internalConstructor(...arguments); - } else { - return this.#defaultConstructor(...arguments); - } - } + } + + constructor(i) { + if (arguments[0] === diplomatRuntime.exposeConstructor) { + return this.#internalConstructor(...Array.prototype.slice.call(arguments, 1)); + } else if (arguments[0] === diplomatRuntime.internalConstructor) { + return this.#internalConstructor(...arguments); + } else { + return this.#defaultConstructor(...arguments); + } + } } \ No newline at end of file diff --git a/feature_tests/js/api/ScalarPairWithPadding.d.ts b/feature_tests/js/api/ScalarPairWithPadding.d.ts index a6f0b5f50..040fe0440 100644 --- a/feature_tests/js/api/ScalarPairWithPadding.d.ts +++ b/feature_tests/js/api/ScalarPairWithPadding.d.ts @@ -1,17 +1,17 @@ // generated by diplomat-tool import type { pointer, codepoint } from "./diplomat-runtime.d.ts"; - -/** Testing JS-specific layout/padding behavior -*/ + +/** Testing JS-specific layout/padding behavior +*/ type ScalarPairWithPadding_obj = { first: number; second: number; }; - - -export class ScalarPairWithPadding { + + +export class ScalarPairWithPadding { get first() : number; set first(value: number); @@ -23,9 +23,9 @@ export class ScalarPairWithPadding { * Optional fields do not need to be included in the provided object. */ static fromFields(structObj : ScalarPairWithPadding_obj) : ScalarPairWithPadding; - - - assertValue(): void; - - constructor(structObj : ScalarPairWithPadding_obj); + + + assertValue(): void; + + constructor(structObj : ScalarPairWithPadding_obj); } \ No newline at end of file diff --git a/feature_tests/js/api/ScalarPairWithPadding.mjs b/feature_tests/js/api/ScalarPairWithPadding.mjs index 68ca5a3a1..f4f2f45c7 100644 --- a/feature_tests/js/api/ScalarPairWithPadding.mjs +++ b/feature_tests/js/api/ScalarPairWithPadding.mjs @@ -2,12 +2,12 @@ import wasm from "./diplomat-wasm.mjs"; import * as diplomatRuntime from "./diplomat-runtime.mjs"; - -/** Testing JS-specific layout/padding behavior -*/ - - -export class ScalarPairWithPadding { + +/** Testing JS-specific layout/padding behavior +*/ + + +export class ScalarPairWithPadding { #first; @@ -33,7 +33,7 @@ export class ScalarPairWithPadding { static fromFields(structObj) { return new ScalarPairWithPadding(structObj); } - + #internalConstructor(structObj) { if (typeof structObj !== "object") { throw new Error("ScalarPairWithPadding's constructor takes an object of ScalarPairWithPadding's fields."); @@ -107,8 +107,8 @@ export class ScalarPairWithPadding { structObj.second = secondDeref; return new ScalarPairWithPadding(structObj); - } - + } + assertValue() { let functionCleanupArena = new diplomatRuntime.CleanupArena(); wasm.ScalarPairWithPadding_assert_value(...this._intoFFI()); @@ -118,9 +118,9 @@ export class ScalarPairWithPadding { finally { functionCleanupArena.free(); } - } - - constructor(structObj) { - return this.#internalConstructor(...arguments) - } + } + + constructor(structObj) { + return this.#internalConstructor(...arguments) + } } \ No newline at end of file diff --git a/feature_tests/js/api/Two.d.ts b/feature_tests/js/api/Two.d.ts index 5bb22ea54..85af5913e 100644 --- a/feature_tests/js/api/Two.d.ts +++ b/feature_tests/js/api/Two.d.ts @@ -1,9 +1,9 @@ // generated by diplomat-tool import type { pointer, codepoint } from "./diplomat-runtime.d.ts"; - - -export class Two { + + +export class Two { - get ffiValue(): pointer; + get ffiValue(): pointer; } \ No newline at end of file diff --git a/feature_tests/js/api/Two.mjs b/feature_tests/js/api/Two.mjs index 7bb95029b..125538ed6 100644 --- a/feature_tests/js/api/Two.mjs +++ b/feature_tests/js/api/Two.mjs @@ -4,9 +4,9 @@ import * as diplomatRuntime from "./diplomat-runtime.mjs"; const Two_box_destroy_registry = new FinalizationRegistry((ptr) => { wasm.Two_destroy(ptr); -}); - -export class Two { +}); + +export class Two { // Internal ptr reference: #ptr = null; @@ -41,9 +41,9 @@ export class Two { } get ffiValue() { return this.#ptr; - } - - constructor(symbol, ptr, selfEdge, aEdge, bEdge) { - return this.#internalConstructor(...arguments) - } + } + + constructor(symbol, ptr, selfEdge, aEdge, bEdge) { + return this.#internalConstructor(...arguments) + } } \ No newline at end of file diff --git a/feature_tests/js/api/UnimportedEnum.d.ts b/feature_tests/js/api/UnimportedEnum.d.ts index d2af86908..6743d794b 100644 --- a/feature_tests/js/api/UnimportedEnum.d.ts +++ b/feature_tests/js/api/UnimportedEnum.d.ts @@ -1,9 +1,9 @@ // generated by diplomat-tool import type { pointer, codepoint } from "./diplomat-runtime.d.ts"; - - -export class UnimportedEnum { + + +export class UnimportedEnum { static fromValue(value : UnimportedEnum | string) : UnimportedEnum; @@ -14,7 +14,7 @@ export class UnimportedEnum { static A : UnimportedEnum; static B : UnimportedEnum; - static C : UnimportedEnum; - - constructor(value: UnimportedEnum | string ); + static C : UnimportedEnum; + + constructor(value: UnimportedEnum | string ); } \ No newline at end of file diff --git a/feature_tests/js/api/UnimportedEnum.mjs b/feature_tests/js/api/UnimportedEnum.mjs index 4434235eb..d09f750cb 100644 --- a/feature_tests/js/api/UnimportedEnum.mjs +++ b/feature_tests/js/api/UnimportedEnum.mjs @@ -2,9 +2,9 @@ import wasm from "./diplomat-wasm.mjs"; import * as diplomatRuntime from "./diplomat-runtime.mjs"; - - -export class UnimportedEnum { + + +export class UnimportedEnum { #value = undefined; @@ -62,9 +62,9 @@ export class UnimportedEnum { static A = UnimportedEnum.#objectValues[0]; static B = UnimportedEnum.#objectValues[1]; - static C = UnimportedEnum.#objectValues[2]; - - constructor(value) { - return this.#internalConstructor(...arguments) - } + static C = UnimportedEnum.#objectValues[2]; + + constructor(value) { + return this.#internalConstructor(...arguments) + } } \ No newline at end of file diff --git a/feature_tests/js/api/Unnamespaced.d.ts b/feature_tests/js/api/Unnamespaced.d.ts index 5e433df4a..f92092ba2 100644 --- a/feature_tests/js/api/Unnamespaced.d.ts +++ b/feature_tests/js/api/Unnamespaced.d.ts @@ -3,13 +3,13 @@ import type { AttrOpaque1Renamed } from "./AttrOpaque1Renamed" import type { RenamedAttrEnum } from "./RenamedAttrEnum" import type { pointer, codepoint } from "./diplomat-runtime.d.ts"; - - -export class Unnamespaced { + + +export class Unnamespaced { - get ffiValue(): pointer; - - static make(e: RenamedAttrEnum): Unnamespaced; - - useNamespaced(n: AttrOpaque1Renamed): void; + get ffiValue(): pointer; + + static make(e: RenamedAttrEnum): Unnamespaced; + + useNamespaced(n: AttrOpaque1Renamed): void; } \ No newline at end of file diff --git a/feature_tests/js/api/Unnamespaced.mjs b/feature_tests/js/api/Unnamespaced.mjs index 2fedcab79..9b38fe382 100644 --- a/feature_tests/js/api/Unnamespaced.mjs +++ b/feature_tests/js/api/Unnamespaced.mjs @@ -6,9 +6,9 @@ import * as diplomatRuntime from "./diplomat-runtime.mjs"; const Unnamespaced_box_destroy_registry = new FinalizationRegistry((ptr) => { wasm.namespace_Unnamespaced_destroy(ptr); -}); - -export class Unnamespaced { +}); + +export class Unnamespaced { // Internal ptr reference: #ptr = null; @@ -35,8 +35,8 @@ export class Unnamespaced { } get ffiValue() { return this.#ptr; - } - + } + static make(e) { const result = wasm.namespace_Unnamespaced_make(e.ffiValue); @@ -45,16 +45,16 @@ export class Unnamespaced { } finally {} - } - + } + useNamespaced(n) {wasm.namespace_Unnamespaced_use_namespaced(this.ffiValue, n.ffiValue); try {} finally {} - } - - constructor(symbol, ptr, selfEdge) { - return this.#internalConstructor(...arguments) - } + } + + constructor(symbol, ptr, selfEdge) { + return this.#internalConstructor(...arguments) + } } \ No newline at end of file diff --git a/feature_tests/js/api/Utf16Wrap.d.ts b/feature_tests/js/api/Utf16Wrap.d.ts index 802f599c4..4085773c6 100644 --- a/feature_tests/js/api/Utf16Wrap.d.ts +++ b/feature_tests/js/api/Utf16Wrap.d.ts @@ -1,15 +1,15 @@ // generated by diplomat-tool import type { pointer, codepoint } from "./diplomat-runtime.d.ts"; - - -export class Utf16Wrap { + + +export class Utf16Wrap { - get ffiValue(): pointer; - - getDebugStr(): string; - - borrowCont(): string; - - constructor(input: string); + get ffiValue(): pointer; + + getDebugStr(): string; + + borrowCont(): string; + + constructor(input: string); } \ No newline at end of file diff --git a/feature_tests/js/api/Utf16Wrap.mjs b/feature_tests/js/api/Utf16Wrap.mjs index 6124774d8..1f51dccf6 100644 --- a/feature_tests/js/api/Utf16Wrap.mjs +++ b/feature_tests/js/api/Utf16Wrap.mjs @@ -4,9 +4,9 @@ import * as diplomatRuntime from "./diplomat-runtime.mjs"; const Utf16Wrap_box_destroy_registry = new FinalizationRegistry((ptr) => { wasm.Utf16Wrap_destroy(ptr); -}); - -export class Utf16Wrap { +}); + +export class Utf16Wrap { // Internal ptr reference: #ptr = null; @@ -33,8 +33,8 @@ export class Utf16Wrap { } get ffiValue() { return this.#ptr; - } - + } + #defaultConstructor(input) { let functionCleanupArena = new diplomatRuntime.CleanupArena(); @@ -49,8 +49,8 @@ export class Utf16Wrap { finally { functionCleanupArena.free(); } - } - + } + getDebugStr() { const write = new diplomatRuntime.DiplomatWriteBuf(wasm); wasm.Utf16Wrap_get_debug_str(this.ffiValue, write.buffer); @@ -62,8 +62,8 @@ export class Utf16Wrap { finally { write.free(); } - } - + } + borrowCont() { const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 8, 4, false); @@ -79,15 +79,15 @@ export class Utf16Wrap { finally { diplomatReceive.free(); } - } - - constructor(input) { - if (arguments[0] === diplomatRuntime.exposeConstructor) { - return this.#internalConstructor(...Array.prototype.slice.call(arguments, 1)); - } else if (arguments[0] === diplomatRuntime.internalConstructor) { - return this.#internalConstructor(...arguments); - } else { - return this.#defaultConstructor(...arguments); - } - } + } + + constructor(input) { + if (arguments[0] === diplomatRuntime.exposeConstructor) { + return this.#internalConstructor(...Array.prototype.slice.call(arguments, 1)); + } else if (arguments[0] === diplomatRuntime.internalConstructor) { + return this.#internalConstructor(...arguments); + } else { + return this.#defaultConstructor(...arguments); + } + } } \ No newline at end of file diff --git a/tool/templates/js/js_class.js.jinja b/tool/templates/js/js_class.js.jinja index 3325e4a95..8c1e00a4b 100644 --- a/tool/templates/js/js_class.js.jinja +++ b/tool/templates/js/js_class.js.jinja @@ -1,65 +1,65 @@ -{% if !doc_str.is_empty() %} -/** {{doc_str}} -*/ -{% endif -%} -{%- let overrides_constructor = methods.special_methods.constructor.is_some() -%} - -{% block header_info %}{% endblock %} - -export class {{type_name}} { - {% block class_body %}{% endblock %} - - {%- for method in methods.methods -%} - - {#- Do not include the method in typescript if it is meant to be private: -#} - {%- if !method.method_decl.starts_with('#') || !typescript %} - - {{ method|indent(4) }} - {%- endif -%} -{%- endfor -%} - {%- if let Some(it) = methods.special_methods.iterator %} - - next() {% if typescript %}: IteratorResult<{{it}}>;{% else %}{ - const out = this.#iteratorNext(); - - return { - value: out, - done: out === null, - }; - }{%- endif -%} - {%- endif -%} - -{%- if show_default_ctor || overrides_constructor %} - - constructor( - {%- if let Some(ctor) = methods.special_methods.constructor %} - {%- for param in ctor.parameters -%} - {{- param.name -}} - {%- if typescript %}: {{ param.ty -}}{%- endif -%} - {%- if !loop.last -%}, {% endif -%} - {%- endfor -%} - {%- else -%} - {%- block internal_ctor_params -%}{%- endblock -%} - {%- endif -%} - ) {%- if typescript -%} ; {%- else %} { - {#- Quick and dirty way to access an exposed constructor if we don't want to provide the internalConstructor - symbol to our constructor (for instance, if we are a struct that only takes structObj as a parameter for the constructor) -#} - {%- if let Some(ctor) = methods.special_methods.constructor %} - if (arguments[0] === diplomatRuntime.exposeConstructor) { - return this.#internalConstructor(...Array.prototype.slice.call(arguments, 1)); - } else if (arguments[0] === diplomatRuntime.internalConstructor) { - {#- - If the first symbol is an internal constructor symbol, that means we can't possibly be looking for the internal - #defaultConstructor. So instead we just pass along all of the arguments to the internalConstructor. - #} - return this.#internalConstructor(...arguments); - } else { - return this.#defaultConstructor(...arguments); - } - {%- else %} - return this.#internalConstructor(...arguments) - {%- endif %} - } - {%- endif -%} -{%- endif %} -} \ No newline at end of file +{% if !doc_str.is_empty() %} +/** {{doc_str}} +*/ +{% endif -%} +{%- let overrides_constructor = methods.special_methods.constructor.is_some() -%} + +{% block header_info %}{% endblock %} + +export class {{type_name}} { + {% block class_body %}{% endblock %} + + {%- for method in methods.methods -%} + + {#- Do not include the method in typescript if it is meant to be private: -#} + {%- if !method.method_decl.starts_with('#') || !typescript %} + + {{ method|indent(4) }} + {%- endif -%} +{%- endfor -%} + {%- if let Some(it) = methods.special_methods.iterator %} + + next() {% if typescript %}: IteratorResult<{{it}}>;{% else %}{ + const out = this.#iteratorNext(); + + return { + value: out, + done: out === null, + }; + }{%- endif -%} + {%- endif -%} + +{%- if show_default_ctor || overrides_constructor %} + + constructor( + {%- if let Some(ctor) = methods.special_methods.constructor %} + {%- for param in ctor.parameters -%} + {{- param.name -}} + {%- if typescript %}: {{ param.ty -}}{%- endif -%} + {%- if !loop.last -%}, {% endif -%} + {%- endfor -%} + {%- else -%} + {%- block internal_ctor_params -%}{%- endblock -%} + {%- endif -%} + ) {%- if typescript -%} ; {%- else %} { + {#- Quick and dirty way to access an exposed constructor if we don't want to provide the internalConstructor + symbol to our constructor (for instance, if we are a struct that only takes structObj as a parameter for the constructor) -#} + {%- if let Some(ctor) = methods.special_methods.constructor %} + if (arguments[0] === diplomatRuntime.exposeConstructor) { + return this.#internalConstructor(...Array.prototype.slice.call(arguments, 1)); + } else if (arguments[0] === diplomatRuntime.internalConstructor) { + {#- + If the first symbol is an internal constructor symbol, that means we can't possibly be looking for the internal + #defaultConstructor. So instead we just pass along all of the arguments to the internalConstructor. + #} + return this.#internalConstructor(...arguments); + } else { + return this.#defaultConstructor(...arguments); + } + {%- else %} + return this.#internalConstructor(...arguments) + {%- endif %} + } + {%- endif -%} +{%- endif %} +} diff --git a/tool/templates/js/struct.js.jinja b/tool/templates/js/struct.js.jinja index d5c362fd3..8093e4d5d 100644 --- a/tool/templates/js/struct.js.jinja +++ b/tool/templates/js/struct.js.jinja @@ -43,7 +43,7 @@ structObj {%- if typescript %} : {{type_name}}_obj {%- endif -%} {%- if is_out & static fromFields(structObj {%- if typescript %} : {{type_name}}_obj {%- endif -%}) {% if typescript %}: {{type_name}}; {%- else -%} { return new {{type_name}}({% if overrides_constructor %}diplomatRuntime.exposeConstructor, {% endif -%} structObj); } {%- endif %} - {% endif -%} + {%~ endif -%} {%- if !(typescript && is_out) %} {%- if !typescript %} @@ -53,7 +53,7 @@ structObj {%- if typescript %} : {{type_name}}_obj {%- endif -%} {%- if is_out & if (typeof structObj !== "object") { throw new Error("{{type_name}}'s constructor takes an object of {{type_name}}'s fields."); } - + {%~ if is_out %} if (internalConstructor !== diplomatRuntime.internalConstructor) { throw new Error("{{type_name}} is an out struct and can only be created internally."); @@ -75,7 +75,7 @@ structObj {%- if typescript %} : {{type_name}}_obj {%- endif -%} {%- if is_out & } {%- endif -%} {%- endif -%} - + {%- endif -%} {%- if !typescript %} @@ -187,4 +187,4 @@ structObj {%- if typescript %} : {{type_name}}_obj {%- endif -%} {%- if is_out & {%- endfor -%} {%- endif -%} {%- endif -%} -{% endblock %} \ No newline at end of file +{% endblock %}