diff --git a/example/js/lib/api/DataProvider.d.ts b/example/js/lib/api/DataProvider.d.ts index c05589e1b..2e0c0f839 100644 --- a/example/js/lib/api/DataProvider.d.ts +++ b/example/js/lib/api/DataProvider.d.ts @@ -1,17 +1,20 @@ // 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; - + 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 cd03b2142..033b9ac68 100644 --- a/example/js/lib/api/DataProvider.mjs +++ b/example/js/lib/api/DataProvider.mjs @@ -2,16 +2,19 @@ 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; @@ -36,8 +39,8 @@ export class DataProvider { get ffiValue() { return this.#ptr; - } - + } + static newStatic() { const result = wasm.icu4x_DataProvider_new_static_mv1(); @@ -46,8 +49,8 @@ export class DataProvider { } finally {} - } - + } + static returnsResult() { const result = wasm.icu4x_DataProvider_returns_result_mv1(); diff --git a/example/js/lib/api/FixedDecimal.d.ts b/example/js/lib/api/FixedDecimal.d.ts index 4866c24d2..89dcdb8d6 100644 --- a/example/js/lib/api/FixedDecimal.d.ts +++ b/example/js/lib/api/FixedDecimal.d.ts @@ -1,17 +1,28 @@ // 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; - - static new_(v: number): FixedDecimal; - - multiplyPow10(power: number): void; - + get ffiValue(): pointer; + + #defaultConstructor(v: number): FixedDecimal; + + multiplyPow10(power: number): void; + toString(): string | null; + + constructor(v: number) { + if (arguments[0] === diplomatRuntime.internalConstructor) { + this.#internalConstructor(...arguments.slice(1)); + } else { + this.#defaultConstructor(...arguments); + } + } } \ No newline at end of file diff --git a/example/js/lib/api/FixedDecimal.mjs b/example/js/lib/api/FixedDecimal.mjs index 193a2a70d..8969476b7 100644 --- a/example/js/lib/api/FixedDecimal.mjs +++ b/example/js/lib/api/FixedDecimal.mjs @@ -2,14 +2,17 @@ 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; @@ -17,7 +20,7 @@ export class FixedDecimal { // Since JS won't garbage collect until there are no incoming edges. #selfEdge = []; - constructor(symbol, ptr, selfEdge) { + #internalConstructor(symbol, ptr, selfEdge) { if (symbol !== diplomatRuntime.internalConstructor) { console.error("FixedDecimal is an Opaque type. You cannot call its constructor."); return; @@ -34,9 +37,9 @@ export class FixedDecimal { get ffiValue() { return this.#ptr; - } - - static new_(v) { + } + + #defaultConstructor(v) { const result = wasm.icu4x_FixedDecimal_new_mv1(v); try { @@ -44,15 +47,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); @@ -66,4 +69,12 @@ export class FixedDecimal { write.free(); } } + + constructor() { + if (arguments[0] === diplomatRuntime.internalConstructor) { + this.#internalConstructor(...arguments.slice(1)); + } else { + 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 9561d4b46..838687851 100644 --- a/example/js/lib/api/FixedDecimalFormatter.d.ts +++ b/example/js/lib/api/FixedDecimalFormatter.d.ts @@ -6,17 +6,20 @@ 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; - + 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 c424ec42f..7060af87b 100644 --- a/example/js/lib/api/FixedDecimalFormatter.mjs +++ b/example/js/lib/api/FixedDecimalFormatter.mjs @@ -6,16 +6,19 @@ 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; @@ -40,8 +43,8 @@ export class FixedDecimalFormatter { get ffiValue() { return this.#ptr; - } - + } + static tryNew(locale, provider, options) { let functionCleanupArena = new diplomatRuntime.CleanupArena(); @@ -61,8 +64,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); diff --git a/example/js/lib/api/FixedDecimalFormatterOptions.d.ts b/example/js/lib/api/FixedDecimalFormatterOptions.d.ts index 23db17b77..a06f23acd 100644 --- a/example/js/lib/api/FixedDecimalFormatterOptions.d.ts +++ b/example/js/lib/api/FixedDecimalFormatterOptions.d.ts @@ -7,14 +7,28 @@ type FixedDecimalFormatterOptions_obj = { someOtherConfig: boolean; }; -export class FixedDecimalFormatterOptions { + + +export class FixedDecimalFormatterOptions { + get groupingStrategy() : FixedDecimalGroupingStrategy; set groupingStrategy(value: FixedDecimalGroupingStrategy); get someOtherConfig() : boolean; set someOtherConfig(value: boolean); - constructor(structObj : FixedDecimalFormatterOptions_obj); - static default_(): FixedDecimalFormatterOptions; + + #internalConstructor(structObj : FixedDecimalFormatterOptions_obj); + + + #defaultConstructor(): FixedDecimalFormatterOptions; + + constructor() { + if (arguments[0] === diplomatRuntime.internalConstructor) { + this.#internalConstructor(...arguments.slice(1)); + } else { + this.#defaultConstructor(...arguments); + } + } } \ No newline at end of file diff --git a/example/js/lib/api/FixedDecimalFormatterOptions.mjs b/example/js/lib/api/FixedDecimalFormatterOptions.mjs index f601efb19..7273aeb83 100644 --- a/example/js/lib/api/FixedDecimalFormatterOptions.mjs +++ b/example/js/lib/api/FixedDecimalFormatterOptions.mjs @@ -3,7 +3,10 @@ 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; get groupingStrategy() { @@ -20,7 +23,9 @@ export class FixedDecimalFormatterOptions { set someOtherConfig(value) { this.#someOtherConfig = value; } - constructor(structObj) { + + + #internalConstructor(structObj) { if (typeof structObj !== "object") { throw new Error("FixedDecimalFormatterOptions's constructor takes an object of FixedDecimalFormatterOptions's fields."); } @@ -93,8 +98,9 @@ export class FixedDecimalFormatterOptions { return new FixedDecimalFormatterOptions(structObj, internalConstructor); } - - static default_() { + + + #defaultConstructor() { const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 8, 4, false); const result = wasm.icu4x_FixedDecimalFormatterOptions_default_mv1(diplomatReceive.buffer); @@ -107,4 +113,12 @@ export class FixedDecimalFormatterOptions { diplomatReceive.free(); } } + + constructor() { + if (arguments[0] === diplomatRuntime.internalConstructor) { + this.#internalConstructor(...arguments.slice(1)); + } else { + 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 c692e9429..8f2c265a8 100644 --- a/example/js/lib/api/FixedDecimalGroupingStrategy.d.ts +++ b/example/js/lib/api/FixedDecimalGroupingStrategy.d.ts @@ -1,8 +1,10 @@ // generated by diplomat-tool import type { pointer, codepoint } from "./diplomat-runtime.d.ts"; -// Base enumerator definition -export class FixedDecimalGroupingStrategy { + + +export class FixedDecimalGroupingStrategy { + constructor(value : FixedDecimalGroupingStrategy | string); get value() : string; @@ -13,4 +15,5 @@ export class FixedDecimalGroupingStrategy { static Never : FixedDecimalGroupingStrategy; static Always : FixedDecimalGroupingStrategy; static Min2 : FixedDecimalGroupingStrategy; + } \ No newline at end of file diff --git a/example/js/lib/api/FixedDecimalGroupingStrategy.mjs b/example/js/lib/api/FixedDecimalGroupingStrategy.mjs index ba673bd3a..d83e25926 100644 --- a/example/js/lib/api/FixedDecimalGroupingStrategy.mjs +++ b/example/js/lib/api/FixedDecimalGroupingStrategy.mjs @@ -2,8 +2,10 @@ import wasm from "./diplomat-wasm.mjs"; import * as diplomatRuntime from "./diplomat-runtime.mjs"; -// Base enumerator definition -export class FixedDecimalGroupingStrategy { + + +export class FixedDecimalGroupingStrategy { + #value = undefined; static #values = new Map([ @@ -16,7 +18,8 @@ export class FixedDecimalGroupingStrategy { static getAllEntries() { return FixedDecimalGroupingStrategy.#values.entries(); } - + + constructor(value) { if (arguments.length > 1 && arguments[0] === diplomatRuntime.internalConstructor) { // We pass in two internalConstructor arguments to create *new* @@ -60,4 +63,5 @@ export class FixedDecimalGroupingStrategy { static Never = FixedDecimalGroupingStrategy.#objectValues[1]; static Always = FixedDecimalGroupingStrategy.#objectValues[2]; static Min2 = FixedDecimalGroupingStrategy.#objectValues[3]; + } \ 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 df9c2944b..466348576 100644 --- a/example/js/lib/api/Locale.d.ts +++ b/example/js/lib/api/Locale.d.ts @@ -1,15 +1,26 @@ // 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; + get ffiValue(): pointer; + + #defaultConstructor(name: string): Locale; - static new_(name: string): Locale; + constructor(name: string) { + if (arguments[0] === diplomatRuntime.internalConstructor) { + this.#internalConstructor(...arguments.slice(1)); + } else { + this.#defaultConstructor(...arguments); + } + } } \ No newline at end of file diff --git a/example/js/lib/api/Locale.mjs b/example/js/lib/api/Locale.mjs index de94e0f46..c977deec5 100644 --- a/example/js/lib/api/Locale.mjs +++ b/example/js/lib/api/Locale.mjs @@ -2,16 +2,19 @@ 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; @@ -19,7 +22,7 @@ export class Locale { // Since JS won't garbage collect until there are no incoming edges. #selfEdge = []; - constructor(symbol, ptr, selfEdge) { + #internalConstructor(symbol, ptr, selfEdge) { if (symbol !== diplomatRuntime.internalConstructor) { console.error("Locale is an Opaque type. You cannot call its constructor."); return; @@ -36,9 +39,9 @@ export class Locale { get ffiValue() { return this.#ptr; - } - - static new_(name) { + } + + #defaultConstructor(name) { let functionCleanupArena = new diplomatRuntime.CleanupArena(); const nameSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.str8(wasm, name)); @@ -53,4 +56,12 @@ export class Locale { functionCleanupArena.free(); } } + + constructor() { + if (arguments[0] === diplomatRuntime.internalConstructor) { + this.#internalConstructor(...arguments.slice(1)); + } else { + 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 be40b1e74..16723bd7c 100644 --- a/feature_tests/js/api/AttrOpaque1Renamed.d.ts +++ b/feature_tests/js/api/AttrOpaque1Renamed.d.ts @@ -3,18 +3,29 @@ 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; - - static totallyNotNew(): AttrOpaque1Renamed; - - get methodRenamed(): number; - - get abirenamed(): number; - - useUnnamespaced(un: Unnamespaced): void; - + get ffiValue(): pointer; + + #defaultConstructor(): AttrOpaque1Renamed; + + get methodRenamed(): number; + + get abirenamed(): number; + + useUnnamespaced(un: Unnamespaced): void; + useNamespaced(n: RenamedAttrEnum): void; + + constructor() { + if (arguments[0] === diplomatRuntime.internalConstructor) { + this.#internalConstructor(...arguments.slice(1)); + } else { + this.#defaultConstructor(...arguments); + } + } } \ No newline at end of file diff --git a/feature_tests/js/api/AttrOpaque1Renamed.mjs b/feature_tests/js/api/AttrOpaque1Renamed.mjs index 5c550dfc7..cfee14a28 100644 --- a/feature_tests/js/api/AttrOpaque1Renamed.mjs +++ b/feature_tests/js/api/AttrOpaque1Renamed.mjs @@ -8,7 +8,10 @@ const AttrOpaque1Renamed_box_destroy_registry = new FinalizationRegistry((ptr) = wasm.namespace_AttrOpaque1_destroy(ptr); }); -export class AttrOpaque1Renamed { + + +export class AttrOpaque1Renamed { + // Internal ptr reference: #ptr = null; @@ -16,7 +19,7 @@ export class AttrOpaque1Renamed { // Since JS won't garbage collect until there are no incoming edges. #selfEdge = []; - constructor(symbol, ptr, selfEdge) { + #internalConstructor(symbol, ptr, selfEdge) { if (symbol !== diplomatRuntime.internalConstructor) { console.error("AttrOpaque1Renamed is an Opaque type. You cannot call its constructor."); return; @@ -33,9 +36,9 @@ export class AttrOpaque1Renamed { get ffiValue() { return this.#ptr; - } - - static totallyNotNew() { + } + + #defaultConstructor() { const result = wasm.namespace_AttrOpaque1_new(); try { @@ -43,8 +46,8 @@ export class AttrOpaque1Renamed { } finally {} - } - + } + get methodRenamed() { const result = wasm.namespace_AttrOpaque1_method(this.ffiValue); @@ -53,8 +56,8 @@ export class AttrOpaque1Renamed { } finally {} - } - + } + get abirenamed() { const result = wasm.renamed_on_abi_only(this.ffiValue); @@ -63,19 +66,27 @@ 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.internalConstructor) { + this.#internalConstructor(...arguments.slice(1)); + } else { + 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 cec745181..508594208 100644 --- a/feature_tests/js/api/Bar.d.ts +++ b/feature_tests/js/api/Bar.d.ts @@ -2,10 +2,13 @@ import type { Foo } from "./Foo" import type { pointer, codepoint } from "./diplomat-runtime.d.ts"; -export class Bar { + + +export class Bar { + - get ffiValue(): pointer; - + 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 9d7ce6553..8ce70f742 100644 --- a/feature_tests/js/api/Bar.mjs +++ b/feature_tests/js/api/Bar.mjs @@ -7,7 +7,10 @@ const Bar_box_destroy_registry = new FinalizationRegistry((ptr) => { wasm.Bar_destroy(ptr); }); -export class Bar { + + +export class Bar { + // Internal ptr reference: #ptr = null; @@ -40,8 +43,8 @@ export class Bar { get ffiValue() { return this.#ptr; - } - + } + get foo() { // This lifetime edge depends on lifetimes 'b, 'a let bEdges = [this]; diff --git a/feature_tests/js/api/BigStructWithStuff.d.ts b/feature_tests/js/api/BigStructWithStuff.d.ts index add1d37c5..ce7df15ca 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,7 +14,10 @@ type BigStructWithStuff_obj = { fifth: number; }; -export class BigStructWithStuff { + + +export class BigStructWithStuff { + get first() : number; set first(value: number); @@ -30,7 +33,10 @@ export class BigStructWithStuff { get fifth() : number; set fifth(value: number); - constructor(structObj : BigStructWithStuff_obj); + + constructor(structObj : BigStructWithStuff_obj); + + assertValue(extraVal: number): void; } \ No newline at end of file diff --git a/feature_tests/js/api/BigStructWithStuff.mjs b/feature_tests/js/api/BigStructWithStuff.mjs index 1669c9eba..fc1f4d92f 100644 --- a/feature_tests/js/api/BigStructWithStuff.mjs +++ b/feature_tests/js/api/BigStructWithStuff.mjs @@ -3,10 +3,13 @@ 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; get first() { @@ -47,6 +50,8 @@ export class BigStructWithStuff { set fifth(value) { this.#fifth = value; } + + constructor(structObj) { if (typeof structObj !== "object") { throw new Error("BigStructWithStuff's constructor takes an object of BigStructWithStuff's fields."); @@ -142,7 +147,8 @@ export class BigStructWithStuff { return new BigStructWithStuff(structObj, internalConstructor); } - + + assertValue(extraVal) { let functionCleanupArena = new diplomatRuntime.CleanupArena(); wasm.BigStructWithStuff_assert_value(...this._intoFFI(), extraVal); diff --git a/feature_tests/js/api/BorrowedFields.d.ts b/feature_tests/js/api/BorrowedFields.d.ts index 13c15d576..80c1d5234 100644 --- a/feature_tests/js/api/BorrowedFields.d.ts +++ b/feature_tests/js/api/BorrowedFields.d.ts @@ -8,7 +8,10 @@ type BorrowedFields_obj = { c: string; }; -export class BorrowedFields { + + +export class BorrowedFields { + get a() : string; set a(value: string); @@ -18,7 +21,10 @@ export class BorrowedFields { get c() : string; set c(value: string); - constructor(structObj : BorrowedFields_obj); + + constructor(structObj : BorrowedFields_obj); + + static fromBarAndStrings(bar: Bar, dstr16: string, utf8Str: string): BorrowedFields; } \ No newline at end of file diff --git a/feature_tests/js/api/BorrowedFields.mjs b/feature_tests/js/api/BorrowedFields.mjs index b3182c6b7..fd1a08615 100644 --- a/feature_tests/js/api/BorrowedFields.mjs +++ b/feature_tests/js/api/BorrowedFields.mjs @@ -3,7 +3,10 @@ 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; get a() { @@ -28,6 +31,8 @@ export class BorrowedFields { set c(value) { this.#c = value; } + + constructor(structObj) { if (typeof structObj !== "object") { throw new Error("BorrowedFields's constructor takes an object of BorrowedFields's fields."); @@ -112,7 +117,8 @@ export class BorrowedFields { 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)); diff --git a/feature_tests/js/api/BorrowedFieldsReturning.d.ts b/feature_tests/js/api/BorrowedFieldsReturning.d.ts index 609874175..f5abaa5af 100644 --- a/feature_tests/js/api/BorrowedFieldsReturning.d.ts +++ b/feature_tests/js/api/BorrowedFieldsReturning.d.ts @@ -5,9 +5,15 @@ type BorrowedFieldsReturning_obj = { bytes: string; }; -export class BorrowedFieldsReturning { + + +export class BorrowedFieldsReturning { + get bytes() : string; set bytes(value: string); + + 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 ef1cda7b6..6116843bb 100644 --- a/feature_tests/js/api/BorrowedFieldsReturning.mjs +++ b/feature_tests/js/api/BorrowedFieldsReturning.mjs @@ -2,7 +2,10 @@ import wasm from "./diplomat-wasm.mjs"; import * as diplomatRuntime from "./diplomat-runtime.mjs"; -export class BorrowedFieldsReturning { + + +export class BorrowedFieldsReturning { + #bytes; get bytes() { @@ -11,6 +14,8 @@ export class BorrowedFieldsReturning { set bytes(value) { this.#bytes = value; } + + constructor(structObj) { if (typeof structObj !== "object") { throw new Error("BorrowedFieldsReturning's constructor takes an object of BorrowedFieldsReturning's fields."); @@ -77,4 +82,5 @@ export class BorrowedFieldsReturning { get _fieldsForLifetimeA() { return [bytes]; }; + } \ 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 875d7b41f..864e8d001 100644 --- a/feature_tests/js/api/BorrowedFieldsWithBounds.d.ts +++ b/feature_tests/js/api/BorrowedFieldsWithBounds.d.ts @@ -8,7 +8,10 @@ type BorrowedFieldsWithBounds_obj = { fieldC: string; }; -export class BorrowedFieldsWithBounds { + + +export class BorrowedFieldsWithBounds { + get fieldA() : string; set fieldA(value: string); @@ -18,7 +21,10 @@ export class BorrowedFieldsWithBounds { get fieldC() : string; set fieldC(value: string); - constructor(structObj : BorrowedFieldsWithBounds_obj); + + constructor(structObj : BorrowedFieldsWithBounds_obj); + + static fromFooAndStrings(foo: Foo, dstr16X: string, utf8StrZ: string): BorrowedFieldsWithBounds; } \ No newline at end of file diff --git a/feature_tests/js/api/BorrowedFieldsWithBounds.mjs b/feature_tests/js/api/BorrowedFieldsWithBounds.mjs index 91faddaaf..b130a3694 100644 --- a/feature_tests/js/api/BorrowedFieldsWithBounds.mjs +++ b/feature_tests/js/api/BorrowedFieldsWithBounds.mjs @@ -3,7 +3,10 @@ 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; get fieldA() { @@ -28,6 +31,8 @@ export class BorrowedFieldsWithBounds { set fieldC(value) { this.#fieldC = value; } + + constructor(structObj) { if (typeof structObj !== "object") { throw new Error("BorrowedFieldsWithBounds's constructor takes an object of BorrowedFieldsWithBounds's fields."); @@ -132,7 +137,8 @@ export class BorrowedFieldsWithBounds { get _fieldsForLifetimeC() { return [fieldC]; }; - + + static fromFooAndStrings(foo, dstr16X, utf8StrZ) { let functionGarbageCollectorGrip = new diplomatRuntime.GarbageCollectorGrip(); const dstr16XSlice = functionGarbageCollectorGrip.alloc(diplomatRuntime.DiplomatBuf.str16(wasm, dstr16X)); diff --git a/feature_tests/js/api/ContiguousEnum.d.ts b/feature_tests/js/api/ContiguousEnum.d.ts index 851a5430a..472ce12ff 100644 --- a/feature_tests/js/api/ContiguousEnum.d.ts +++ b/feature_tests/js/api/ContiguousEnum.d.ts @@ -1,8 +1,10 @@ // generated by diplomat-tool import type { pointer, codepoint } from "./diplomat-runtime.d.ts"; -// Base enumerator definition -export class ContiguousEnum { + + +export class ContiguousEnum { + constructor(value : ContiguousEnum | string); get value() : string; @@ -13,4 +15,5 @@ export class ContiguousEnum { static D : ContiguousEnum; static E : ContiguousEnum; static F : ContiguousEnum; + } \ No newline at end of file diff --git a/feature_tests/js/api/ContiguousEnum.mjs b/feature_tests/js/api/ContiguousEnum.mjs index 77aeb5bd1..1a23853fd 100644 --- a/feature_tests/js/api/ContiguousEnum.mjs +++ b/feature_tests/js/api/ContiguousEnum.mjs @@ -2,8 +2,10 @@ import wasm from "./diplomat-wasm.mjs"; import * as diplomatRuntime from "./diplomat-runtime.mjs"; -// Base enumerator definition -export class ContiguousEnum { + + +export class ContiguousEnum { + #value = undefined; static #values = new Map([ @@ -16,7 +18,8 @@ export class ContiguousEnum { static getAllEntries() { return ContiguousEnum.#values.entries(); } - + + constructor(value) { if (arguments.length > 1 && arguments[0] === diplomatRuntime.internalConstructor) { // We pass in two internalConstructor arguments to create *new* @@ -60,4 +63,5 @@ export class ContiguousEnum { static D = ContiguousEnum.#objectValues[1]; static E = ContiguousEnum.#objectValues[2]; static F = ContiguousEnum.#objectValues[3]; + } \ 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 d4a4fde52..5160c4655 100644 --- a/feature_tests/js/api/CyclicStructA.d.ts +++ b/feature_tests/js/api/CyclicStructA.d.ts @@ -7,13 +7,19 @@ type CyclicStructA_obj = { a: CyclicStructB_obj; }; -export class CyclicStructA { + + +export class CyclicStructA { + get a() : CyclicStructB; set a(value: CyclicStructB); - constructor(structObj : CyclicStructA_obj); - - static getB(): CyclicStructB; + + constructor(structObj : CyclicStructA_obj); + + + static getB(): CyclicStructB; + cyclicOut(): string; } \ No newline at end of file diff --git a/feature_tests/js/api/CyclicStructA.mjs b/feature_tests/js/api/CyclicStructA.mjs index d9cb148ab..89a9a3941 100644 --- a/feature_tests/js/api/CyclicStructA.mjs +++ b/feature_tests/js/api/CyclicStructA.mjs @@ -3,7 +3,10 @@ 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; get a() { @@ -12,6 +15,8 @@ export class CyclicStructA { set a(value) { this.#a = value; } + + constructor(structObj) { if (typeof structObj !== "object") { throw new Error("CyclicStructA's constructor takes an object of CyclicStructA's fields."); @@ -71,7 +76,8 @@ export class CyclicStructA { return new CyclicStructA(structObj, internalConstructor); } - + + static getB() { const result = wasm.CyclicStructA_get_b(); @@ -80,8 +86,8 @@ export class CyclicStructA { } finally {} - } - + } + cyclicOut() { let functionCleanupArena = new diplomatRuntime.CleanupArena(); diff --git a/feature_tests/js/api/CyclicStructB.d.ts b/feature_tests/js/api/CyclicStructB.d.ts index 74a06af26..48b87be58 100644 --- a/feature_tests/js/api/CyclicStructB.d.ts +++ b/feature_tests/js/api/CyclicStructB.d.ts @@ -6,13 +6,19 @@ type CyclicStructB_obj = { field: number; }; -export class CyclicStructB { + + +export class CyclicStructB { + get field() : number; set field(value: number); - constructor(structObj : CyclicStructB_obj); - - static getA(): CyclicStructA; + + constructor(structObj : CyclicStructB_obj); + + + static getA(): CyclicStructA; + static getAOption(): CyclicStructA | null; } \ No newline at end of file diff --git a/feature_tests/js/api/CyclicStructB.mjs b/feature_tests/js/api/CyclicStructB.mjs index 6f87daf7f..ba1874c7d 100644 --- a/feature_tests/js/api/CyclicStructB.mjs +++ b/feature_tests/js/api/CyclicStructB.mjs @@ -3,7 +3,10 @@ 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; get field() { @@ -12,6 +15,8 @@ export class CyclicStructB { set field(value) { this.#field = value; } + + constructor(structObj) { if (typeof structObj !== "object") { throw new Error("CyclicStructB's constructor takes an object of CyclicStructB's fields."); @@ -71,7 +76,8 @@ export class CyclicStructB { return new CyclicStructB(structObj, internalConstructor); } - + + static getA() { const result = wasm.CyclicStructB_get_a(); @@ -80,8 +86,8 @@ export class CyclicStructB { } finally {} - } - + } + static getAOption() { const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 2, 1, true); diff --git a/feature_tests/js/api/CyclicStructC.d.ts b/feature_tests/js/api/CyclicStructC.d.ts index 0edd8f613..14e8934a2 100644 --- a/feature_tests/js/api/CyclicStructC.d.ts +++ b/feature_tests/js/api/CyclicStructC.d.ts @@ -7,13 +7,19 @@ type CyclicStructC_obj = { a: CyclicStructA_obj; }; -export class CyclicStructC { + + +export class CyclicStructC { + get a() : CyclicStructA; set a(value: CyclicStructA); - constructor(structObj : CyclicStructC_obj); - - static takesNestedParameters(c: CyclicStructC_obj): CyclicStructC; + + constructor(structObj : CyclicStructC_obj); + + + static takesNestedParameters(c: CyclicStructC_obj): CyclicStructC; + cyclicOut(): string; } \ No newline at end of file diff --git a/feature_tests/js/api/CyclicStructC.mjs b/feature_tests/js/api/CyclicStructC.mjs index 221beb115..7925e2991 100644 --- a/feature_tests/js/api/CyclicStructC.mjs +++ b/feature_tests/js/api/CyclicStructC.mjs @@ -3,7 +3,10 @@ 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; get a() { @@ -12,6 +15,8 @@ export class CyclicStructC { set a(value) { this.#a = value; } + + constructor(structObj) { if (typeof structObj !== "object") { throw new Error("CyclicStructC's constructor takes an object of CyclicStructC's fields."); @@ -71,7 +76,8 @@ export class CyclicStructC { return new CyclicStructC(structObj, internalConstructor); } - + + static takesNestedParameters(c) { let functionCleanupArena = new diplomatRuntime.CleanupArena(); @@ -84,8 +90,8 @@ export class CyclicStructC { finally { functionCleanupArena.free(); } - } - + } + cyclicOut() { let functionCleanupArena = new diplomatRuntime.CleanupArena(); diff --git a/feature_tests/js/api/ErrorEnum.d.ts b/feature_tests/js/api/ErrorEnum.d.ts index 802bfd300..df2038bd2 100644 --- a/feature_tests/js/api/ErrorEnum.d.ts +++ b/feature_tests/js/api/ErrorEnum.d.ts @@ -1,8 +1,10 @@ // generated by diplomat-tool import type { pointer, codepoint } from "./diplomat-runtime.d.ts"; -// Base enumerator definition -export class ErrorEnum { + + +export class ErrorEnum { + constructor(value : ErrorEnum | string); get value() : string; @@ -11,4 +13,5 @@ export class ErrorEnum { static Foo : ErrorEnum; static Bar : ErrorEnum; + } \ No newline at end of file diff --git a/feature_tests/js/api/ErrorEnum.mjs b/feature_tests/js/api/ErrorEnum.mjs index cedaf53d2..769d2f56e 100644 --- a/feature_tests/js/api/ErrorEnum.mjs +++ b/feature_tests/js/api/ErrorEnum.mjs @@ -2,8 +2,10 @@ import wasm from "./diplomat-wasm.mjs"; import * as diplomatRuntime from "./diplomat-runtime.mjs"; -// Base enumerator definition -export class ErrorEnum { + + +export class ErrorEnum { + #value = undefined; static #values = new Map([ @@ -14,7 +16,8 @@ export class ErrorEnum { static getAllEntries() { return ErrorEnum.#values.entries(); } - + + constructor(value) { if (arguments.length > 1 && arguments[0] === diplomatRuntime.internalConstructor) { // We pass in two internalConstructor arguments to create *new* @@ -54,4 +57,5 @@ export class ErrorEnum { static Foo = ErrorEnum.#objectValues[0]; static Bar = ErrorEnum.#objectValues[1]; + } \ 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 d7b99d1dc..ce12081a0 100644 --- a/feature_tests/js/api/ErrorStruct.d.ts +++ b/feature_tests/js/api/ErrorStruct.d.ts @@ -6,12 +6,18 @@ type ErrorStruct_obj = { j: number; }; -export class ErrorStruct { + + +export class ErrorStruct { + get i() : number; set i(value: number); get j() : number; set j(value: number); + + 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 d4b05fdf7..4a24451a6 100644 --- a/feature_tests/js/api/ErrorStruct.mjs +++ b/feature_tests/js/api/ErrorStruct.mjs @@ -2,7 +2,10 @@ import wasm from "./diplomat-wasm.mjs"; import * as diplomatRuntime from "./diplomat-runtime.mjs"; -export class ErrorStruct { + + +export class ErrorStruct { + #i; get i() { @@ -19,6 +22,8 @@ export class ErrorStruct { set j(value) { this.#j = value; } + + constructor(structObj) { if (typeof structObj !== "object") { throw new Error("ErrorStruct's constructor takes an object of ErrorStruct's fields."); @@ -87,4 +92,5 @@ export class ErrorStruct { return new ErrorStruct(structObj, internalConstructor); } + } \ 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 714cb07f5..c63514fb7 100644 --- a/feature_tests/js/api/Float64Vec.d.ts +++ b/feature_tests/js/api/Float64Vec.d.ts @@ -1,34 +1,45 @@ // 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; - - static newFromOwned(v: Array): Float64Vec; - - get asSlice(): Array; - - fillSlice(v: Array): void; - - setValue(newSlice: Array): void; - - toString(): string; - - borrow(): 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; + + #defaultConstructor(v: Array): Float64Vec; + + get asSlice(): Array; + + fillSlice(v: Array): void; + + setValue(newSlice: Array): void; + + toString(): string; + + borrow(): Array; + get(i: number): number | null; + + constructor(v: Array) { + if (arguments[0] === diplomatRuntime.internalConstructor) { + this.#internalConstructor(...arguments.slice(1)); + } else { + this.#defaultConstructor(...arguments); + } + } } \ No newline at end of file diff --git a/feature_tests/js/api/Float64Vec.mjs b/feature_tests/js/api/Float64Vec.mjs index bac5ff7e5..9fa8df9ea 100644 --- a/feature_tests/js/api/Float64Vec.mjs +++ b/feature_tests/js/api/Float64Vec.mjs @@ -6,7 +6,10 @@ const Float64Vec_box_destroy_registry = new FinalizationRegistry((ptr) => { wasm.Float64Vec_destroy(ptr); }); -export class Float64Vec { + + +export class Float64Vec { + // Internal ptr reference: #ptr = null; @@ -14,7 +17,7 @@ export class Float64Vec { // Since JS won't garbage collect until there are no incoming edges. #selfEdge = []; - constructor(symbol, ptr, selfEdge) { + #internalConstructor(symbol, ptr, selfEdge) { if (symbol !== diplomatRuntime.internalConstructor) { console.error("Float64Vec is an Opaque type. You cannot call its constructor."); return; @@ -31,8 +34,8 @@ export class Float64Vec { get ffiValue() { return this.#ptr; - } - + } + static newBool(v) { let functionCleanupArena = new diplomatRuntime.CleanupArena(); @@ -47,8 +50,8 @@ export class Float64Vec { finally { functionCleanupArena.free(); } - } - + } + static newI16(v) { let functionCleanupArena = new diplomatRuntime.CleanupArena(); @@ -63,8 +66,8 @@ export class Float64Vec { finally { functionCleanupArena.free(); } - } - + } + static newU16(v) { let functionCleanupArena = new diplomatRuntime.CleanupArena(); @@ -79,8 +82,8 @@ export class Float64Vec { finally { functionCleanupArena.free(); } - } - + } + static newIsize(v) { let functionCleanupArena = new diplomatRuntime.CleanupArena(); @@ -95,8 +98,8 @@ export class Float64Vec { finally { functionCleanupArena.free(); } - } - + } + static newUsize(v) { let functionCleanupArena = new diplomatRuntime.CleanupArena(); @@ -111,8 +114,8 @@ export class Float64Vec { finally { functionCleanupArena.free(); } - } - + } + static newF64BeBytes(v) { let functionCleanupArena = new diplomatRuntime.CleanupArena(); @@ -127,9 +130,9 @@ export class Float64Vec { finally { functionCleanupArena.free(); } - } - - static newFromOwned(v) { + } + + #defaultConstructor(v) { let functionCleanupArena = new diplomatRuntime.CleanupArena(); const vSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.slice(wasm, v, "f64")); @@ -143,8 +146,8 @@ export class Float64Vec { finally { functionCleanupArena.free(); } - } - + } + get asSlice() { const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 8, 4, false); @@ -160,8 +163,8 @@ export class Float64Vec { finally { diplomatReceive.free(); } - } - + } + fillSlice(v) { let functionCleanupArena = new diplomatRuntime.CleanupArena(); @@ -173,8 +176,8 @@ export class Float64Vec { finally { functionCleanupArena.free(); } - } - + } + setValue(newSlice) { let functionCleanupArena = new diplomatRuntime.CleanupArena(); @@ -186,8 +189,8 @@ export class Float64Vec { finally { functionCleanupArena.free(); } - } - + } + toString() { const write = new diplomatRuntime.DiplomatWriteBuf(wasm); wasm.Float64Vec_to_string(this.ffiValue, write.buffer); @@ -199,8 +202,8 @@ export class Float64Vec { finally { write.free(); } - } - + } + borrow() { const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 8, 4, false); @@ -216,8 +219,8 @@ export class Float64Vec { finally { diplomatReceive.free(); } - } - + } + get(i) { const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 9, 8, true); @@ -234,4 +237,12 @@ export class Float64Vec { diplomatReceive.free(); } } + + constructor() { + if (arguments[0] === diplomatRuntime.internalConstructor) { + this.#internalConstructor(...arguments.slice(1)); + } else { + 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 a4f65e6bc..6388d1c06 100644 --- a/feature_tests/js/api/Foo.d.ts +++ b/feature_tests/js/api/Foo.d.ts @@ -7,18 +7,29 @@ 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; - - static new_(x: string): Foo; - - get bar(): Bar; - - asReturning(): BorrowedFieldsReturning; - - static extractFromFields(fields: BorrowedFields_obj): Foo; - + get ffiValue(): pointer; + + #defaultConstructor(x: string): Foo; + + get bar(): Bar; + + asReturning(): BorrowedFieldsReturning; + + static extractFromFields(fields: BorrowedFields_obj): Foo; + static extractFromBounds(bounds: BorrowedFieldsWithBounds_obj, anotherString: string): Foo; + + constructor(x: string) { + if (arguments[0] === diplomatRuntime.internalConstructor) { + this.#internalConstructor(...arguments.slice(1)); + } else { + this.#defaultConstructor(...arguments); + } + } } \ No newline at end of file diff --git a/feature_tests/js/api/Foo.mjs b/feature_tests/js/api/Foo.mjs index 06572b431..aa5f8623b 100644 --- a/feature_tests/js/api/Foo.mjs +++ b/feature_tests/js/api/Foo.mjs @@ -10,7 +10,10 @@ const Foo_box_destroy_registry = new FinalizationRegistry((ptr) => { wasm.Foo_destroy(ptr); }); -export class Foo { + + +export class Foo { + // Internal ptr reference: #ptr = null; @@ -19,7 +22,7 @@ export class Foo { #selfEdge = []; #aEdge = []; - constructor(symbol, ptr, selfEdge, aEdge) { + #internalConstructor(symbol, ptr, selfEdge, aEdge) { if (symbol !== diplomatRuntime.internalConstructor) { console.error("Foo is an Opaque type. You cannot call its constructor."); return; @@ -39,9 +42,9 @@ export class Foo { get ffiValue() { return this.#ptr; - } - - static new_(x) { + } + + #defaultConstructor(x) { let functionGarbageCollectorGrip = new diplomatRuntime.GarbageCollectorGrip(); const xSlice = functionGarbageCollectorGrip.alloc(diplomatRuntime.DiplomatBuf.str8(wasm, x)); @@ -57,8 +60,8 @@ export class Foo { finally { functionGarbageCollectorGrip.releaseToGarbageCollector(); } - } - + } + get bar() { // This lifetime edge depends on lifetimes 'a let aEdges = [this]; @@ -73,8 +76,8 @@ export class Foo { } finally {} - } - + } + asReturning() { const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 8, 4, false); @@ -90,8 +93,8 @@ export class Foo { finally { diplomatReceive.free(); } - } - + } + static extractFromFields(fields) { let functionCleanupArena = new diplomatRuntime.CleanupArena(); @@ -107,8 +110,8 @@ export class Foo { finally { functionCleanupArena.free(); } - } - + } + static extractFromBounds(bounds, anotherString) { let functionCleanupArena = new diplomatRuntime.CleanupArena(); @@ -130,4 +133,12 @@ export class Foo { functionGarbageCollectorGrip.releaseToGarbageCollector(); } } + + constructor() { + if (arguments[0] === diplomatRuntime.internalConstructor) { + this.#internalConstructor(...arguments.slice(1)); + } else { + 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 8e9d1bceb..8712e0b42 100644 --- a/feature_tests/js/api/ImportedStruct.d.ts +++ b/feature_tests/js/api/ImportedStruct.d.ts @@ -7,12 +7,18 @@ type ImportedStruct_obj = { count: number; }; -export class ImportedStruct { + + +export class ImportedStruct { + get foo() : UnimportedEnum; set foo(value: UnimportedEnum); get count() : number; set count(value: number); + + 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 1e1f535b7..9a4fe89b1 100644 --- a/feature_tests/js/api/ImportedStruct.mjs +++ b/feature_tests/js/api/ImportedStruct.mjs @@ -3,7 +3,10 @@ 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; get foo() { @@ -20,6 +23,8 @@ export class ImportedStruct { set count(value) { this.#count = value; } + + constructor(structObj) { if (typeof structObj !== "object") { throw new Error("ImportedStruct's constructor takes an object of ImportedStruct's fields."); @@ -93,4 +98,5 @@ export class ImportedStruct { return new ImportedStruct(structObj, internalConstructor); } + } \ 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 ace176e87..cfb7ff99b 100644 --- a/feature_tests/js/api/MyEnum.d.ts +++ b/feature_tests/js/api/MyEnum.d.ts @@ -1,8 +1,10 @@ // generated by diplomat-tool import type { pointer, codepoint } from "./diplomat-runtime.d.ts"; -// Base enumerator definition -export class MyEnum { + + +export class MyEnum { + constructor(value : MyEnum | string); get value() : string; @@ -19,4 +21,9 @@ export class MyEnum { intoValue(): number; static getA(): MyEnum; + + + intoValue(): number; + + static getA(): MyEnum; } \ No newline at end of file diff --git a/feature_tests/js/api/MyEnum.mjs b/feature_tests/js/api/MyEnum.mjs index 788f7a045..a57a76c29 100644 --- a/feature_tests/js/api/MyEnum.mjs +++ b/feature_tests/js/api/MyEnum.mjs @@ -2,8 +2,10 @@ import wasm from "./diplomat-wasm.mjs"; import * as diplomatRuntime from "./diplomat-runtime.mjs"; -// Base enumerator definition -export class MyEnum { + + +export class MyEnum { + #value = undefined; static #values = new Map([ @@ -18,7 +20,8 @@ export class MyEnum { static getAllEntries() { return MyEnum.#values.entries(); } - + + constructor(value) { if (arguments.length > 1 && arguments[0] === diplomatRuntime.internalConstructor) { // We pass in two internalConstructor arguments to create *new* @@ -90,4 +93,25 @@ export class MyEnum { finally {} } + + + intoValue() { + const result = wasm.MyEnum_into_value(this.ffiValue); + + try { + return result; + } + + finally {} + } + + static getA() { + const result = wasm.MyEnum_get_a(); + + try { + return new MyEnum(diplomatRuntime.internalConstructor, result); + } + + finally {} + } } \ 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 43d7dd7e9..15ca76a7a 100644 --- a/feature_tests/js/api/MyOpaqueEnum.d.ts +++ b/feature_tests/js/api/MyOpaqueEnum.d.ts @@ -1,12 +1,15 @@ // 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; - + 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 ca9ebbc9a..aceddc45b 100644 --- a/feature_tests/js/api/MyOpaqueEnum.mjs +++ b/feature_tests/js/api/MyOpaqueEnum.mjs @@ -6,7 +6,10 @@ const MyOpaqueEnum_box_destroy_registry = new FinalizationRegistry((ptr) => { wasm.MyOpaqueEnum_destroy(ptr); }); -export class MyOpaqueEnum { + + +export class MyOpaqueEnum { + // Internal ptr reference: #ptr = null; @@ -31,8 +34,8 @@ export class MyOpaqueEnum { get ffiValue() { return this.#ptr; - } - + } + static new_() { const result = wasm.MyOpaqueEnum_new(); @@ -41,8 +44,8 @@ export class MyOpaqueEnum { } finally {} - } - + } + toString() { const write = new diplomatRuntime.DiplomatWriteBuf(wasm); wasm.MyOpaqueEnum_to_string(this.ffiValue, write.buffer); diff --git a/feature_tests/js/api/MyString.d.ts b/feature_tests/js/api/MyString.d.ts index e2d9609fb..323f5401f 100644 --- a/feature_tests/js/api/MyString.d.ts +++ b/feature_tests/js/api/MyString.d.ts @@ -1,24 +1,35 @@ // generated by diplomat-tool import type { pointer, codepoint } from "./diplomat-runtime.d.ts"; -export class MyString { + + +export class MyString { + - get ffiValue(): pointer; - - static new_(v: string): MyString; - - 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; - + get ffiValue(): pointer; + + #defaultConstructor(v: string): MyString; + + 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) { + if (arguments[0] === diplomatRuntime.internalConstructor) { + this.#internalConstructor(...arguments.slice(1)); + } else { + this.#defaultConstructor(...arguments); + } + } } \ No newline at end of file diff --git a/feature_tests/js/api/MyString.mjs b/feature_tests/js/api/MyString.mjs index ea01b1c64..bc352a8bc 100644 --- a/feature_tests/js/api/MyString.mjs +++ b/feature_tests/js/api/MyString.mjs @@ -6,7 +6,10 @@ const MyString_box_destroy_registry = new FinalizationRegistry((ptr) => { wasm.MyString_destroy(ptr); }); -export class MyString { + + +export class MyString { + // Internal ptr reference: #ptr = null; @@ -14,7 +17,7 @@ export class MyString { // Since JS won't garbage collect until there are no incoming edges. #selfEdge = []; - constructor(symbol, ptr, selfEdge) { + #internalConstructor(symbol, ptr, selfEdge) { if (symbol !== diplomatRuntime.internalConstructor) { console.error("MyString is an Opaque type. You cannot call its constructor."); return; @@ -31,9 +34,9 @@ export class MyString { get ffiValue() { return this.#ptr; - } - - static new_(v) { + } + + #defaultConstructor(v) { let functionCleanupArena = new diplomatRuntime.CleanupArena(); const vSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.str8(wasm, v)); @@ -47,8 +50,8 @@ export class MyString { finally { functionCleanupArena.free(); } - } - + } + static newUnsafe(v) { let functionCleanupArena = new diplomatRuntime.CleanupArena(); @@ -63,8 +66,8 @@ export class MyString { finally { functionCleanupArena.free(); } - } - + } + static newOwned(v) { let functionCleanupArena = new diplomatRuntime.CleanupArena(); @@ -79,8 +82,8 @@ export class MyString { finally { functionCleanupArena.free(); } - } - + } + static newFromFirst(v) { let functionCleanupArena = new diplomatRuntime.CleanupArena(); @@ -95,8 +98,8 @@ export class MyString { finally { functionCleanupArena.free(); } - } - + } + set str(newStr) { let functionCleanupArena = new diplomatRuntime.CleanupArena(); @@ -108,8 +111,8 @@ export class MyString { finally { functionCleanupArena.free(); } - } - + } + get str() { const write = new diplomatRuntime.DiplomatWriteBuf(wasm); wasm.MyString_get_str(this.ffiValue, write.buffer); @@ -121,8 +124,8 @@ export class MyString { finally { write.free(); } - } - + } + static stringTransform(foo) { let functionCleanupArena = new diplomatRuntime.CleanupArena(); @@ -140,8 +143,8 @@ export class MyString { write.free(); } - } - + } + borrow() { const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 8, 4, false); @@ -158,4 +161,12 @@ export class MyString { diplomatReceive.free(); } } + + constructor() { + if (arguments[0] === diplomatRuntime.internalConstructor) { + this.#internalConstructor(...arguments.slice(1)); + } else { + 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 2f094a099..c624aad03 100644 --- a/feature_tests/js/api/MyStruct.d.ts +++ b/feature_tests/js/api/MyStruct.d.ts @@ -13,7 +13,10 @@ type MyStruct_obj = { g: MyEnum; }; -export class MyStruct { + + +export class MyStruct { + get a() : number; set a(value: number); @@ -35,13 +38,24 @@ export class MyStruct { get g() : MyEnum; set g(value: MyEnum); - constructor(structObj : MyStruct_obj); - - static new_(): MyStruct; - - intoA(): number; - - static returnsZstResult(): void; + + #internalConstructor(structObj : MyStruct_obj); + + + #defaultConstructor(): MyStruct; + + intoA(): number; + + static returnsZstResult(): void; + static failsZstResult(): void; + + constructor() { + if (arguments[0] === diplomatRuntime.internalConstructor) { + this.#internalConstructor(...arguments.slice(1)); + } else { + this.#defaultConstructor(...arguments); + } + } } \ No newline at end of file diff --git a/feature_tests/js/api/MyStruct.mjs b/feature_tests/js/api/MyStruct.mjs index 9c2d2daa4..3bf7fd395 100644 --- a/feature_tests/js/api/MyStruct.mjs +++ b/feature_tests/js/api/MyStruct.mjs @@ -4,7 +4,10 @@ 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; get a() { @@ -61,7 +64,9 @@ export class MyStruct { set g(value) { this.#g = value; } - constructor(structObj) { + + + #internalConstructor(structObj) { if (typeof structObj !== "object") { throw new Error("MyStruct's constructor takes an object of MyStruct's fields."); } @@ -174,8 +179,9 @@ export class MyStruct { return new MyStruct(structObj, internalConstructor); } - - static new_() { + + + #defaultConstructor() { const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 32, 8, false); const result = wasm.MyStruct_new(diplomatReceive.buffer); @@ -187,8 +193,8 @@ export class MyStruct { finally { diplomatReceive.free(); } - } - + } + intoA() { let functionCleanupArena = new diplomatRuntime.CleanupArena(); @@ -201,8 +207,8 @@ export class MyStruct { finally { functionCleanupArena.free(); } - } - + } + static returnsZstResult() { const result = wasm.MyStruct_returns_zst_result(); @@ -215,8 +221,8 @@ export class MyStruct { } finally {} - } - + } + static failsZstResult() { const result = wasm.MyStruct_fails_zst_result(); @@ -230,4 +236,12 @@ export class MyStruct { finally {} } + + constructor() { + if (arguments[0] === diplomatRuntime.internalConstructor) { + this.#internalConstructor(...arguments.slice(1)); + } else { + 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 83ac3785c..867055eb7 100644 --- a/feature_tests/js/api/MyZst.d.ts +++ b/feature_tests/js/api/MyZst.d.ts @@ -4,6 +4,12 @@ import type { pointer, codepoint } from "./diplomat-runtime.d.ts"; type MyZst_obj = { }; -export class MyZst { + + +export class MyZst { + + + 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 6caca21a0..ba6567272 100644 --- a/feature_tests/js/api/MyZst.mjs +++ b/feature_tests/js/api/MyZst.mjs @@ -2,7 +2,12 @@ import wasm from "./diplomat-wasm.mjs"; import * as diplomatRuntime from "./diplomat-runtime.mjs"; -export class MyZst { + + +export class MyZst { + + + constructor(structObj) { if (typeof structObj !== "object") { throw new Error("MyZst's constructor takes an object of MyZst's fields."); @@ -10,4 +15,5 @@ export class MyZst { } + } \ 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 9e49766f9..a35c9b9c6 100644 --- a/feature_tests/js/api/NestedBorrowedFields.d.ts +++ b/feature_tests/js/api/NestedBorrowedFields.d.ts @@ -13,7 +13,10 @@ type NestedBorrowedFields_obj = { bounds2: BorrowedFieldsWithBounds_obj; }; -export class NestedBorrowedFields { + + +export class NestedBorrowedFields { + get fields() : BorrowedFields; set fields(value: BorrowedFields); @@ -23,7 +26,10 @@ export class NestedBorrowedFields { get bounds2() : BorrowedFieldsWithBounds; set bounds2(value: BorrowedFieldsWithBounds); - constructor(structObj : NestedBorrowedFields_obj); + + constructor(structObj : NestedBorrowedFields_obj); + + static fromBarAndFooAndStrings(bar: Bar, foo: Foo, dstr16X: string, dstr16Z: string, utf8StrY: string, utf8StrZ: string): NestedBorrowedFields; } \ No newline at end of file diff --git a/feature_tests/js/api/NestedBorrowedFields.mjs b/feature_tests/js/api/NestedBorrowedFields.mjs index 2f225fabc..ce4e64222 100644 --- a/feature_tests/js/api/NestedBorrowedFields.mjs +++ b/feature_tests/js/api/NestedBorrowedFields.mjs @@ -6,7 +6,10 @@ 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; get fields() { @@ -31,6 +34,8 @@ export class NestedBorrowedFields { set bounds2(value) { this.#bounds2 = value; } + + constructor(structObj) { if (typeof structObj !== "object") { throw new Error("NestedBorrowedFields's constructor takes an object of NestedBorrowedFields's fields."); @@ -135,7 +140,8 @@ export class NestedBorrowedFields { 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)); diff --git a/feature_tests/js/api/One.d.ts b/feature_tests/js/api/One.d.ts index 4b3823995..208f48f6a 100644 --- a/feature_tests/js/api/One.d.ts +++ b/feature_tests/js/api/One.d.ts @@ -2,30 +2,33 @@ 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; - + 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 322273be4..2763c095c 100644 --- a/feature_tests/js/api/One.mjs +++ b/feature_tests/js/api/One.mjs @@ -7,7 +7,10 @@ const One_box_destroy_registry = new FinalizationRegistry((ptr) => { wasm.One_destroy(ptr); }); -export class One { + + +export class One { + // Internal ptr reference: #ptr = null; @@ -36,8 +39,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]; @@ -49,8 +52,8 @@ export class One { } finally {} - } - + } + static cycle(hold, nohold) { // This lifetime edge depends on lifetimes 'a, 'b, 'c let aEdges = [hold]; @@ -62,8 +65,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]; @@ -75,8 +78,8 @@ export class One { } finally {} - } - + } + static returnOutlivesParam(hold, nohold) { // This lifetime edge depends on lifetimes 'long let longEdges = [hold]; @@ -88,8 +91,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]; @@ -101,8 +104,8 @@ export class One { } finally {} - } - + } + static diamondLeft(top, left, right, bottom) { // This lifetime edge depends on lifetimes 'left, 'bottom let leftEdges = [left, bottom]; @@ -114,8 +117,8 @@ export class One { } finally {} - } - + } + static diamondRight(top, left, right, bottom) { // This lifetime edge depends on lifetimes 'right, 'bottom let rightEdges = [right, bottom]; @@ -127,8 +130,8 @@ export class One { } finally {} - } - + } + static diamondBottom(top, left, right, bottom) { // This lifetime edge depends on lifetimes 'bottom let bottomEdges = [bottom]; @@ -140,8 +143,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]; @@ -153,8 +156,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]; @@ -166,8 +169,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]; diff --git a/feature_tests/js/api/Opaque.d.ts b/feature_tests/js/api/Opaque.d.ts index f9bcc0b7e..a8c10fed1 100644 --- a/feature_tests/js/api/Opaque.d.ts +++ b/feature_tests/js/api/Opaque.d.ts @@ -4,24 +4,35 @@ 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 new_(): Opaque; - - static tryFromUtf8(input: string): Opaque | null; - - static fromStr(input: string): Opaque; - - getDebugStr(): string; - - assertStruct(s: MyStruct_obj): void; - - static returnsUsize(): number; - - static returnsImported(): ImportedStruct; - + get ffiValue(): pointer; + + #defaultConstructor(): Opaque; + + 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() { + if (arguments[0] === diplomatRuntime.internalConstructor) { + this.#internalConstructor(...arguments.slice(1)); + } else { + this.#defaultConstructor(...arguments); + } + } } \ No newline at end of file diff --git a/feature_tests/js/api/Opaque.mjs b/feature_tests/js/api/Opaque.mjs index 6518a3a91..49d585344 100644 --- a/feature_tests/js/api/Opaque.mjs +++ b/feature_tests/js/api/Opaque.mjs @@ -8,7 +8,10 @@ const Opaque_box_destroy_registry = new FinalizationRegistry((ptr) => { wasm.Opaque_destroy(ptr); }); -export class Opaque { + + +export class Opaque { + // Internal ptr reference: #ptr = null; @@ -16,7 +19,7 @@ export class Opaque { // Since JS won't garbage collect until there are no incoming edges. #selfEdge = []; - constructor(symbol, ptr, selfEdge) { + #internalConstructor(symbol, ptr, selfEdge) { if (symbol !== diplomatRuntime.internalConstructor) { console.error("Opaque is an Opaque type. You cannot call its constructor."); return; @@ -33,9 +36,9 @@ export class Opaque { get ffiValue() { return this.#ptr; - } - - static new_() { + } + + #defaultConstructor() { const result = wasm.Opaque_new(); try { @@ -43,8 +46,8 @@ export class Opaque { } finally {} - } - + } + static tryFromUtf8(input) { let functionCleanupArena = new diplomatRuntime.CleanupArena(); @@ -59,8 +62,8 @@ export class Opaque { finally { functionCleanupArena.free(); } - } - + } + static fromStr(input) { let functionCleanupArena = new diplomatRuntime.CleanupArena(); @@ -75,8 +78,8 @@ export class Opaque { finally { functionCleanupArena.free(); } - } - + } + getDebugStr() { const write = new diplomatRuntime.DiplomatWriteBuf(wasm); wasm.Opaque_get_debug_str(this.ffiValue, write.buffer); @@ -88,8 +91,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, {})); @@ -99,8 +102,8 @@ export class Opaque { finally { functionCleanupArena.free(); } - } - + } + static returnsUsize() { const result = wasm.Opaque_returns_usize(); @@ -109,8 +112,8 @@ export class Opaque { } finally {} - } - + } + static returnsImported() { const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 8, 4, false); @@ -123,8 +126,8 @@ export class Opaque { finally { diplomatReceive.free(); } - } - + } + static cmp() { const result = wasm.Opaque_cmp(); @@ -134,4 +137,12 @@ export class Opaque { finally {} } + + constructor() { + if (arguments[0] === diplomatRuntime.internalConstructor) { + this.#internalConstructor(...arguments.slice(1)); + } else { + 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 d1989901c..c469b27ab 100644 --- a/feature_tests/js/api/OpaqueMutexedString.d.ts +++ b/feature_tests/js/api/OpaqueMutexedString.d.ts @@ -2,26 +2,29 @@ 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; - + 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 16a0ea5ec..f9f258202 100644 --- a/feature_tests/js/api/OpaqueMutexedString.mjs +++ b/feature_tests/js/api/OpaqueMutexedString.mjs @@ -7,7 +7,10 @@ const OpaqueMutexedString_box_destroy_registry = new FinalizationRegistry((ptr) wasm.OpaqueMutexedString_destroy(ptr); }); -export class OpaqueMutexedString { + + +export class OpaqueMutexedString { + // Internal ptr reference: #ptr = null; @@ -32,8 +35,8 @@ export class OpaqueMutexedString { get ffiValue() { return this.#ptr; - } - + } + static fromUsize(number) { const result = wasm.OpaqueMutexedString_from_usize(number); @@ -42,15 +45,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]; @@ -62,8 +65,8 @@ export class OpaqueMutexedString { } finally {} - } - + } + static borrowOther(other) { // This lifetime edge depends on lifetimes 'a let aEdges = [other]; @@ -75,8 +78,8 @@ export class OpaqueMutexedString { } finally {} - } - + } + borrowSelfOrOther(other) { // This lifetime edge depends on lifetimes 'a let aEdges = [this, other]; @@ -88,8 +91,8 @@ export class OpaqueMutexedString { } finally {} - } - + } + getLenAndAdd(other) { const result = wasm.OpaqueMutexedString_get_len_and_add(this.ffiValue, other); @@ -98,8 +101,8 @@ export class OpaqueMutexedString { } finally {} - } - + } + dummyStr() { const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 8, 4, false); @@ -115,8 +118,8 @@ export class OpaqueMutexedString { finally { diplomatReceive.free(); } - } - + } + wrapper() { const result = wasm.OpaqueMutexedString_wrapper(this.ffiValue); @@ -125,8 +128,8 @@ export class OpaqueMutexedString { } finally {} - } - + } + toUnsignedFromUnsigned(input) { const result = wasm.OpaqueMutexedString_to_unsigned_from_unsigned(this.ffiValue, input); diff --git a/feature_tests/js/api/OptionEnum.d.ts b/feature_tests/js/api/OptionEnum.d.ts index 9c653bb63..677a2ed3d 100644 --- a/feature_tests/js/api/OptionEnum.d.ts +++ b/feature_tests/js/api/OptionEnum.d.ts @@ -1,8 +1,10 @@ // generated by diplomat-tool import type { pointer, codepoint } from "./diplomat-runtime.d.ts"; -// Base enumerator definition -export class OptionEnum { + + +export class OptionEnum { + constructor(value : OptionEnum | string); get value() : string; @@ -11,4 +13,5 @@ export class OptionEnum { static Foo : OptionEnum; static Bar : OptionEnum; + } \ No newline at end of file diff --git a/feature_tests/js/api/OptionEnum.mjs b/feature_tests/js/api/OptionEnum.mjs index 57907e448..f42c10336 100644 --- a/feature_tests/js/api/OptionEnum.mjs +++ b/feature_tests/js/api/OptionEnum.mjs @@ -2,8 +2,10 @@ import wasm from "./diplomat-wasm.mjs"; import * as diplomatRuntime from "./diplomat-runtime.mjs"; -// Base enumerator definition -export class OptionEnum { + + +export class OptionEnum { + #value = undefined; static #values = new Map([ @@ -14,7 +16,8 @@ export class OptionEnum { static getAllEntries() { return OptionEnum.#values.entries(); } - + + constructor(value) { if (arguments.length > 1 && arguments[0] === diplomatRuntime.internalConstructor) { // We pass in two internalConstructor arguments to create *new* @@ -54,4 +57,5 @@ export class OptionEnum { static Foo = OptionEnum.#objectValues[0]; static Bar = OptionEnum.#objectValues[1]; + } \ 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 1548ad8b2..57f193d24 100644 --- a/feature_tests/js/api/OptionInputStruct.d.ts +++ b/feature_tests/js/api/OptionInputStruct.d.ts @@ -8,7 +8,10 @@ type OptionInputStruct_obj = { c?: OptionEnum | null; }; -export class OptionInputStruct { + + +export class OptionInputStruct { + get a() : number | null; set a(value: number | null); @@ -18,5 +21,8 @@ export class OptionInputStruct { get c() : OptionEnum | null; set c(value: OptionEnum | null); + + 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 15012b579..c5ca3cc4b 100644 --- a/feature_tests/js/api/OptionInputStruct.mjs +++ b/feature_tests/js/api/OptionInputStruct.mjs @@ -3,7 +3,10 @@ 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; get a() { @@ -28,6 +31,8 @@ export class OptionInputStruct { set c(value) { this.#c = value; } + + constructor(structObj) { if (typeof structObj !== "object") { throw new Error("OptionInputStruct's constructor takes an object of OptionInputStruct's fields."); @@ -105,4 +110,5 @@ export class OptionInputStruct { return new OptionInputStruct(structObj, internalConstructor); } + } \ 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 587d09ae1..525a3983d 100644 --- a/feature_tests/js/api/OptionOpaque.d.ts +++ b/feature_tests/js/api/OptionOpaque.d.ts @@ -4,38 +4,41 @@ 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; - + 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 2c24e05cb..410a720bf 100644 --- a/feature_tests/js/api/OptionOpaque.mjs +++ b/feature_tests/js/api/OptionOpaque.mjs @@ -9,7 +9,10 @@ const OptionOpaque_box_destroy_registry = new FinalizationRegistry((ptr) => { wasm.OptionOpaque_destroy(ptr); }); -export class OptionOpaque { + + +export class OptionOpaque { + // Internal ptr reference: #ptr = null; @@ -34,8 +37,8 @@ export class OptionOpaque { get ffiValue() { return this.#ptr; - } - + } + static new_(i) { const result = wasm.OptionOpaque_new(i); @@ -44,8 +47,8 @@ export class OptionOpaque { } finally {} - } - + } + static newNone() { const result = wasm.OptionOpaque_new_none(); @@ -54,8 +57,8 @@ export class OptionOpaque { } finally {} - } - + } + static returns() { const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 17, 4, true); @@ -71,8 +74,8 @@ export class OptionOpaque { finally { diplomatReceive.free(); } - } - + } + optionIsize() { const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true); @@ -88,8 +91,8 @@ export class OptionOpaque { finally { diplomatReceive.free(); } - } - + } + optionUsize() { const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true); @@ -105,8 +108,8 @@ export class OptionOpaque { finally { diplomatReceive.free(); } - } - + } + optionI32() { const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true); @@ -122,8 +125,8 @@ export class OptionOpaque { finally { diplomatReceive.free(); } - } - + } + optionU32() { const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true); @@ -139,8 +142,8 @@ export class OptionOpaque { finally { diplomatReceive.free(); } - } - + } + static newStruct() { const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 16, 4, false); @@ -153,8 +156,8 @@ export class OptionOpaque { finally { diplomatReceive.free(); } - } - + } + static newStructNones() { const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 16, 4, false); @@ -167,15 +170,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); @@ -184,8 +187,8 @@ export class OptionOpaque { } finally {} - } - + } + static acceptsOptionU8(arg) { const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 2, 1, true); @@ -201,8 +204,8 @@ export class OptionOpaque { finally { diplomatReceive.free(); } - } - + } + static acceptsOptionEnum(arg) { const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true); @@ -218,8 +221,8 @@ export class OptionOpaque { finally { diplomatReceive.free(); } - } - + } + static acceptsOptionInputStruct(arg) { let functionCleanupArena = new diplomatRuntime.CleanupArena(); @@ -239,8 +242,8 @@ export class OptionOpaque { diplomatReceive.free(); } - } - + } + static returnsOptionInputStruct() { const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 20, 4, false); diff --git a/feature_tests/js/api/OptionOpaqueChar.d.ts b/feature_tests/js/api/OptionOpaqueChar.d.ts index 06ad0f9c0..2b6868d33 100644 --- a/feature_tests/js/api/OptionOpaqueChar.d.ts +++ b/feature_tests/js/api/OptionOpaqueChar.d.ts @@ -1,10 +1,13 @@ // generated by diplomat-tool import type { pointer, codepoint } from "./diplomat-runtime.d.ts"; -export class OptionOpaqueChar { + + +export class OptionOpaqueChar { + - get ffiValue(): pointer; - + 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 b9edc9d20..24b115680 100644 --- a/feature_tests/js/api/OptionOpaqueChar.mjs +++ b/feature_tests/js/api/OptionOpaqueChar.mjs @@ -6,7 +6,10 @@ const OptionOpaqueChar_box_destroy_registry = new FinalizationRegistry((ptr) => wasm.OptionOpaqueChar_destroy(ptr); }); -export class OptionOpaqueChar { + + +export class OptionOpaqueChar { + // Internal ptr reference: #ptr = null; @@ -31,8 +34,8 @@ export class OptionOpaqueChar { get ffiValue() { return this.#ptr; - } - + } + assertChar(ch) {wasm.OptionOpaqueChar_assert_char(this.ffiValue, ch); try {} diff --git a/feature_tests/js/api/OptionString.d.ts b/feature_tests/js/api/OptionString.d.ts index 4ebce0a29..f6fc5cdc6 100644 --- a/feature_tests/js/api/OptionString.d.ts +++ b/feature_tests/js/api/OptionString.d.ts @@ -1,14 +1,17 @@ // 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; - + 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 a3ea4e40a..795468641 100644 --- a/feature_tests/js/api/OptionString.mjs +++ b/feature_tests/js/api/OptionString.mjs @@ -6,7 +6,10 @@ const OptionString_box_destroy_registry = new FinalizationRegistry((ptr) => { wasm.OptionString_destroy(ptr); }); -export class OptionString { + + +export class OptionString { + // Internal ptr reference: #ptr = null; @@ -31,8 +34,8 @@ export class OptionString { get ffiValue() { return this.#ptr; - } - + } + static new_(diplomatStr) { let functionCleanupArena = new diplomatRuntime.CleanupArena(); @@ -47,8 +50,8 @@ export class OptionString { finally { functionCleanupArena.free(); } - } - + } + write() { const write = new diplomatRuntime.DiplomatWriteBuf(wasm); @@ -61,8 +64,8 @@ export class OptionString { finally { write.free(); } - } - + } + borrow() { const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 9, 4, true); diff --git a/feature_tests/js/api/OptionStruct.d.ts b/feature_tests/js/api/OptionStruct.d.ts index 8d65486cd..0d349dd32 100644 --- a/feature_tests/js/api/OptionStruct.d.ts +++ b/feature_tests/js/api/OptionStruct.d.ts @@ -3,7 +3,10 @@ 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; @@ -16,4 +19,7 @@ export class OptionStruct { get d() : OptionOpaque | null; + + + } \ No newline at end of file diff --git a/feature_tests/js/api/OptionStruct.mjs b/feature_tests/js/api/OptionStruct.mjs index d66b22e66..d864f1a0b 100644 --- a/feature_tests/js/api/OptionStruct.mjs +++ b/feature_tests/js/api/OptionStruct.mjs @@ -4,7 +4,10 @@ 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; get a() { @@ -29,6 +32,8 @@ export class OptionStruct { return this.#d; } + + constructor(structObj, internalConstructor) { if (typeof structObj !== "object") { throw new Error("OptionStruct's constructor takes an object of OptionStruct's fields."); @@ -118,4 +123,5 @@ export class OptionStruct { return new OptionStruct(structObj, internalConstructor); } + } \ 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 8eb737974..e7f9fc9be 100644 --- a/feature_tests/js/api/RefList.d.ts +++ b/feature_tests/js/api/RefList.d.ts @@ -2,10 +2,13 @@ import type { RefListParameter } from "./RefListParameter" import type { pointer, codepoint } from "./diplomat-runtime.d.ts"; -export class RefList { + + +export class RefList { + - get ffiValue(): pointer; - + 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 1ccd4444a..38d00bd15 100644 --- a/feature_tests/js/api/RefList.mjs +++ b/feature_tests/js/api/RefList.mjs @@ -7,7 +7,10 @@ const RefList_box_destroy_registry = new FinalizationRegistry((ptr) => { wasm.RefList_destroy(ptr); }); -export class RefList { + + +export class RefList { + // Internal ptr reference: #ptr = null; @@ -36,8 +39,8 @@ export class RefList { get ffiValue() { return this.#ptr; - } - + } + static node(data) { // This lifetime edge depends on lifetimes 'b let bEdges = [data]; diff --git a/feature_tests/js/api/RefListParameter.d.ts b/feature_tests/js/api/RefListParameter.d.ts index 92ec0855f..482c52d08 100644 --- a/feature_tests/js/api/RefListParameter.d.ts +++ b/feature_tests/js/api/RefListParameter.d.ts @@ -1,7 +1,10 @@ // generated by diplomat-tool import type { pointer, codepoint } from "./diplomat-runtime.d.ts"; -export class RefListParameter { + + +export class RefListParameter { + get ffiValue(): pointer; diff --git a/feature_tests/js/api/RefListParameter.mjs b/feature_tests/js/api/RefListParameter.mjs index 1321ae415..c2e8948d6 100644 --- a/feature_tests/js/api/RefListParameter.mjs +++ b/feature_tests/js/api/RefListParameter.mjs @@ -6,7 +6,10 @@ const RefListParameter_box_destroy_registry = new FinalizationRegistry((ptr) => wasm.RefListParameter_destroy(ptr); }); -export class RefListParameter { + + +export class RefListParameter { + // Internal ptr reference: #ptr = null; diff --git a/feature_tests/js/api/RenamedAttrEnum.d.ts b/feature_tests/js/api/RenamedAttrEnum.d.ts index 367a44768..31f396fb4 100644 --- a/feature_tests/js/api/RenamedAttrEnum.d.ts +++ b/feature_tests/js/api/RenamedAttrEnum.d.ts @@ -1,8 +1,10 @@ // generated by diplomat-tool import type { pointer, codepoint } from "./diplomat-runtime.d.ts"; -// Base enumerator definition -export class RenamedAttrEnum { + + +export class RenamedAttrEnum { + constructor(value : RenamedAttrEnum | string); get value() : string; @@ -12,4 +14,5 @@ export class RenamedAttrEnum { static A : RenamedAttrEnum; static B : RenamedAttrEnum; static Renamed : RenamedAttrEnum; + } \ No newline at end of file diff --git a/feature_tests/js/api/RenamedAttrEnum.mjs b/feature_tests/js/api/RenamedAttrEnum.mjs index be4c09515..b9a5411e6 100644 --- a/feature_tests/js/api/RenamedAttrEnum.mjs +++ b/feature_tests/js/api/RenamedAttrEnum.mjs @@ -2,8 +2,10 @@ import wasm from "./diplomat-wasm.mjs"; import * as diplomatRuntime from "./diplomat-runtime.mjs"; -// Base enumerator definition -export class RenamedAttrEnum { + + +export class RenamedAttrEnum { + #value = undefined; static #values = new Map([ @@ -15,7 +17,8 @@ export class RenamedAttrEnum { static getAllEntries() { return RenamedAttrEnum.#values.entries(); } - + + constructor(value) { if (arguments.length > 1 && arguments[0] === diplomatRuntime.internalConstructor) { // We pass in two internalConstructor arguments to create *new* @@ -57,4 +60,5 @@ export class RenamedAttrEnum { static A = RenamedAttrEnum.#objectValues[0]; static B = RenamedAttrEnum.#objectValues[1]; static Renamed = RenamedAttrEnum.#objectValues[2]; + } \ 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 761ee8831..75523e532 100644 --- a/feature_tests/js/api/RenamedAttrOpaque2.d.ts +++ b/feature_tests/js/api/RenamedAttrOpaque2.d.ts @@ -1,7 +1,10 @@ // generated by diplomat-tool import type { pointer, codepoint } from "./diplomat-runtime.d.ts"; -export class RenamedAttrOpaque2 { + + +export class RenamedAttrOpaque2 { + get ffiValue(): pointer; diff --git a/feature_tests/js/api/RenamedAttrOpaque2.mjs b/feature_tests/js/api/RenamedAttrOpaque2.mjs index e2e2da2cc..e49bac154 100644 --- a/feature_tests/js/api/RenamedAttrOpaque2.mjs +++ b/feature_tests/js/api/RenamedAttrOpaque2.mjs @@ -6,7 +6,10 @@ const RenamedAttrOpaque2_box_destroy_registry = new FinalizationRegistry((ptr) = wasm.namespace_AttrOpaque2_destroy(ptr); }); -export class RenamedAttrOpaque2 { + + +export class RenamedAttrOpaque2 { + // Internal ptr reference: #ptr = null; diff --git a/feature_tests/js/api/RenamedMyIterable.d.ts b/feature_tests/js/api/RenamedMyIterable.d.ts index 24bf845ef..a6806e353 100644 --- a/feature_tests/js/api/RenamedMyIterable.d.ts +++ b/feature_tests/js/api/RenamedMyIterable.d.ts @@ -2,12 +2,23 @@ import type { RenamedMyIterator } from "./RenamedMyIterator" import type { pointer, codepoint } from "./diplomat-runtime.d.ts"; -export class RenamedMyIterable { + + +export class RenamedMyIterable { + - get ffiValue(): pointer; - - static new_(x: Array): RenamedMyIterable; - + get ffiValue(): pointer; + + #defaultConstructor(x: Array): RenamedMyIterable; + [Symbol.iterator](): RenamedMyIterator; + + constructor(x: Array) { + if (arguments[0] === diplomatRuntime.internalConstructor) { + this.#internalConstructor(...arguments.slice(1)); + } else { + this.#defaultConstructor(...arguments); + } + } } \ No newline at end of file diff --git a/feature_tests/js/api/RenamedMyIterable.mjs b/feature_tests/js/api/RenamedMyIterable.mjs index fc2133413..17fc30e08 100644 --- a/feature_tests/js/api/RenamedMyIterable.mjs +++ b/feature_tests/js/api/RenamedMyIterable.mjs @@ -7,7 +7,10 @@ const RenamedMyIterable_box_destroy_registry = new FinalizationRegistry((ptr) => wasm.namespace_MyIterable_destroy(ptr); }); -export class RenamedMyIterable { + + +export class RenamedMyIterable { + // Internal ptr reference: #ptr = null; @@ -15,7 +18,7 @@ export class RenamedMyIterable { // Since JS won't garbage collect until there are no incoming edges. #selfEdge = []; - constructor(symbol, ptr, selfEdge) { + #internalConstructor(symbol, ptr, selfEdge) { if (symbol !== diplomatRuntime.internalConstructor) { console.error("RenamedMyIterable is an Opaque type. You cannot call its constructor."); return; @@ -32,9 +35,9 @@ export class RenamedMyIterable { get ffiValue() { return this.#ptr; - } - - static new_(x) { + } + + #defaultConstructor(x) { let functionCleanupArena = new diplomatRuntime.CleanupArena(); const xSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.slice(wasm, x, "u8")); @@ -48,8 +51,8 @@ export class RenamedMyIterable { finally { functionCleanupArena.free(); } - } - + } + [Symbol.iterator]() { // This lifetime edge depends on lifetimes 'a let aEdges = [this]; @@ -62,4 +65,12 @@ export class RenamedMyIterable { finally {} } + + constructor() { + if (arguments[0] === diplomatRuntime.internalConstructor) { + this.#internalConstructor(...arguments.slice(1)); + } else { + 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 0511d5cfc..ec0e1a0e1 100644 --- a/feature_tests/js/api/RenamedMyIterator.d.ts +++ b/feature_tests/js/api/RenamedMyIterator.d.ts @@ -1,11 +1,14 @@ // generated by diplomat-tool import type { pointer, codepoint } from "./diplomat-runtime.d.ts"; -export class RenamedMyIterator { + + +export class RenamedMyIterator { + - get ffiValue(): pointer; - + get ffiValue(): pointer; + #iteratorNext(): number | null; diff --git a/feature_tests/js/api/RenamedMyIterator.mjs b/feature_tests/js/api/RenamedMyIterator.mjs index fc8aaa141..60ca5168b 100644 --- a/feature_tests/js/api/RenamedMyIterator.mjs +++ b/feature_tests/js/api/RenamedMyIterator.mjs @@ -6,7 +6,10 @@ const RenamedMyIterator_box_destroy_registry = new FinalizationRegistry((ptr) => wasm.namespace_MyIterator_destroy(ptr); }); -export class RenamedMyIterator { + + +export class RenamedMyIterator { + // Internal ptr reference: #ptr = null; @@ -35,8 +38,8 @@ export class RenamedMyIterator { get ffiValue() { return this.#ptr; - } - + } + #iteratorNext() { const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 2, 1, true); diff --git a/feature_tests/js/api/RenamedOpaqueIterable.d.ts b/feature_tests/js/api/RenamedOpaqueIterable.d.ts index 5c13881da..c2201fef8 100644 --- a/feature_tests/js/api/RenamedOpaqueIterable.d.ts +++ b/feature_tests/js/api/RenamedOpaqueIterable.d.ts @@ -2,10 +2,13 @@ import type { RenamedOpaqueIterator } from "./RenamedOpaqueIterator" import type { pointer, codepoint } from "./diplomat-runtime.d.ts"; -export class RenamedOpaqueIterable { + + +export class RenamedOpaqueIterable { + - get ffiValue(): pointer; - + 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 b43de5b73..16342690d 100644 --- a/feature_tests/js/api/RenamedOpaqueIterable.mjs +++ b/feature_tests/js/api/RenamedOpaqueIterable.mjs @@ -7,7 +7,10 @@ const RenamedOpaqueIterable_box_destroy_registry = new FinalizationRegistry((ptr wasm.namespace_OpaqueIterable_destroy(ptr); }); -export class RenamedOpaqueIterable { + + +export class RenamedOpaqueIterable { + // Internal ptr reference: #ptr = null; @@ -32,8 +35,8 @@ export class RenamedOpaqueIterable { get ffiValue() { return this.#ptr; - } - + } + [Symbol.iterator]() { // This lifetime edge depends on lifetimes 'a let aEdges = [this]; diff --git a/feature_tests/js/api/RenamedOpaqueIterator.d.ts b/feature_tests/js/api/RenamedOpaqueIterator.d.ts index 448d71ecf..74ae5e14e 100644 --- a/feature_tests/js/api/RenamedOpaqueIterator.d.ts +++ b/feature_tests/js/api/RenamedOpaqueIterator.d.ts @@ -2,11 +2,14 @@ import type { AttrOpaque1Renamed } from "./AttrOpaque1Renamed" import type { pointer, codepoint } from "./diplomat-runtime.d.ts"; -export class RenamedOpaqueIterator { + + +export class RenamedOpaqueIterator { + - get ffiValue(): pointer; - + get ffiValue(): pointer; + #iteratorNext(): AttrOpaque1Renamed | null; diff --git a/feature_tests/js/api/RenamedOpaqueIterator.mjs b/feature_tests/js/api/RenamedOpaqueIterator.mjs index c85ba89bf..bdaa7952a 100644 --- a/feature_tests/js/api/RenamedOpaqueIterator.mjs +++ b/feature_tests/js/api/RenamedOpaqueIterator.mjs @@ -7,7 +7,10 @@ const RenamedOpaqueIterator_box_destroy_registry = new FinalizationRegistry((ptr wasm.namespace_OpaqueIterator_destroy(ptr); }); -export class RenamedOpaqueIterator { + + +export class RenamedOpaqueIterator { + // Internal ptr reference: #ptr = null; @@ -36,8 +39,8 @@ export class RenamedOpaqueIterator { get ffiValue() { return this.#ptr; - } - + } + #iteratorNext() { const result = wasm.namespace_OpaqueIterator_next(this.ffiValue); diff --git a/feature_tests/js/api/ResultOpaque.d.ts b/feature_tests/js/api/ResultOpaque.d.ts index 03344b663..a8028195b 100644 --- a/feature_tests/js/api/ResultOpaque.d.ts +++ b/feature_tests/js/api/ResultOpaque.d.ts @@ -3,26 +3,29 @@ 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 new_(i: number): ResultOpaque; - - 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; - + get ffiValue(): pointer; + + static new_(i: number): ResultOpaque; + + 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; } \ No newline at end of file diff --git a/feature_tests/js/api/ResultOpaque.mjs b/feature_tests/js/api/ResultOpaque.mjs index 0753c6c2a..9c0835ba4 100644 --- a/feature_tests/js/api/ResultOpaque.mjs +++ b/feature_tests/js/api/ResultOpaque.mjs @@ -8,7 +8,10 @@ const ResultOpaque_box_destroy_registry = new FinalizationRegistry((ptr) => { wasm.ResultOpaque_destroy(ptr); }); -export class ResultOpaque { + + +export class ResultOpaque { + // Internal ptr reference: #ptr = null; @@ -33,8 +36,8 @@ export class ResultOpaque { get ffiValue() { return this.#ptr; - } - + } + static new_(i) { const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true); @@ -51,8 +54,8 @@ export class ResultOpaque { finally { diplomatReceive.free(); } - } - + } + static newFailingFoo() { const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true); @@ -69,8 +72,8 @@ export class ResultOpaque { finally { diplomatReceive.free(); } - } - + } + static newFailingBar() { const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true); @@ -87,8 +90,8 @@ export class ResultOpaque { finally { diplomatReceive.free(); } - } - + } + static newFailingUnit() { const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true); @@ -104,8 +107,8 @@ export class ResultOpaque { finally { diplomatReceive.free(); } - } - + } + static newFailingStruct(i) { const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 9, 4, true); @@ -122,8 +125,8 @@ export class ResultOpaque { finally { diplomatReceive.free(); } - } - + } + static newInErr(i) { const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true); @@ -140,8 +143,8 @@ export class ResultOpaque { finally { diplomatReceive.free(); } - } - + } + static newInt(i) { const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true); @@ -157,8 +160,8 @@ export class ResultOpaque { finally { diplomatReceive.free(); } - } - + } + static newInEnumErr(i) { const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true); @@ -175,8 +178,8 @@ export class ResultOpaque { finally { diplomatReceive.free(); } - } - + } + assertInteger(i) {wasm.ResultOpaque_assert_integer(this.ffiValue, i); try {} diff --git a/feature_tests/js/api/ScalarPairWithPadding.d.ts b/feature_tests/js/api/ScalarPairWithPadding.d.ts index 13964fc3c..b4c526e4a 100644 --- a/feature_tests/js/api/ScalarPairWithPadding.d.ts +++ b/feature_tests/js/api/ScalarPairWithPadding.d.ts @@ -1,22 +1,28 @@ // 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); get second() : number; set second(value: number); - constructor(structObj : ScalarPairWithPadding_obj); + + constructor(structObj : ScalarPairWithPadding_obj); + + assertValue(): void; } \ No newline at end of file diff --git a/feature_tests/js/api/ScalarPairWithPadding.mjs b/feature_tests/js/api/ScalarPairWithPadding.mjs index 0ee8b43b5..9009f89a6 100644 --- a/feature_tests/js/api/ScalarPairWithPadding.mjs +++ b/feature_tests/js/api/ScalarPairWithPadding.mjs @@ -2,10 +2,13 @@ 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; get first() { @@ -22,6 +25,8 @@ export class ScalarPairWithPadding { set second(value) { this.#second = value; } + + constructor(structObj) { if (typeof structObj !== "object") { throw new Error("ScalarPairWithPadding's constructor takes an object of ScalarPairWithPadding's fields."); @@ -95,7 +100,8 @@ export class ScalarPairWithPadding { return new ScalarPairWithPadding(structObj, internalConstructor); } - + + assertValue() { let functionCleanupArena = new diplomatRuntime.CleanupArena(); wasm.ScalarPairWithPadding_assert_value(...this._intoFFI()); diff --git a/feature_tests/js/api/Two.d.ts b/feature_tests/js/api/Two.d.ts index 8a06416fb..38082f508 100644 --- a/feature_tests/js/api/Two.d.ts +++ b/feature_tests/js/api/Two.d.ts @@ -1,7 +1,10 @@ // generated by diplomat-tool import type { pointer, codepoint } from "./diplomat-runtime.d.ts"; -export class Two { + + +export class Two { + get ffiValue(): pointer; diff --git a/feature_tests/js/api/Two.mjs b/feature_tests/js/api/Two.mjs index ec2263bbc..0b47e908e 100644 --- a/feature_tests/js/api/Two.mjs +++ b/feature_tests/js/api/Two.mjs @@ -6,7 +6,10 @@ const Two_box_destroy_registry = new FinalizationRegistry((ptr) => { wasm.Two_destroy(ptr); }); -export class Two { + + +export class Two { + // Internal ptr reference: #ptr = null; diff --git a/feature_tests/js/api/UnimportedEnum.d.ts b/feature_tests/js/api/UnimportedEnum.d.ts index 4a3b8ca1a..335434558 100644 --- a/feature_tests/js/api/UnimportedEnum.d.ts +++ b/feature_tests/js/api/UnimportedEnum.d.ts @@ -1,8 +1,10 @@ // generated by diplomat-tool import type { pointer, codepoint } from "./diplomat-runtime.d.ts"; -// Base enumerator definition -export class UnimportedEnum { + + +export class UnimportedEnum { + constructor(value : UnimportedEnum | string); get value() : string; @@ -12,4 +14,5 @@ export class UnimportedEnum { static A : UnimportedEnum; static B : UnimportedEnum; static C : UnimportedEnum; + } \ No newline at end of file diff --git a/feature_tests/js/api/UnimportedEnum.mjs b/feature_tests/js/api/UnimportedEnum.mjs index 273e06e5e..021b99b1b 100644 --- a/feature_tests/js/api/UnimportedEnum.mjs +++ b/feature_tests/js/api/UnimportedEnum.mjs @@ -2,8 +2,10 @@ import wasm from "./diplomat-wasm.mjs"; import * as diplomatRuntime from "./diplomat-runtime.mjs"; -// Base enumerator definition -export class UnimportedEnum { + + +export class UnimportedEnum { + #value = undefined; static #values = new Map([ @@ -15,7 +17,8 @@ export class UnimportedEnum { static getAllEntries() { return UnimportedEnum.#values.entries(); } - + + constructor(value) { if (arguments.length > 1 && arguments[0] === diplomatRuntime.internalConstructor) { // We pass in two internalConstructor arguments to create *new* @@ -57,4 +60,5 @@ export class UnimportedEnum { static A = UnimportedEnum.#objectValues[0]; static B = UnimportedEnum.#objectValues[1]; static C = UnimportedEnum.#objectValues[2]; + } \ 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 6c7301346..adbe09b45 100644 --- a/feature_tests/js/api/Unnamespaced.d.ts +++ b/feature_tests/js/api/Unnamespaced.d.ts @@ -3,12 +3,15 @@ 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; - + 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 50adc186f..0b8438078 100644 --- a/feature_tests/js/api/Unnamespaced.mjs +++ b/feature_tests/js/api/Unnamespaced.mjs @@ -8,7 +8,10 @@ const Unnamespaced_box_destroy_registry = new FinalizationRegistry((ptr) => { wasm.namespace_Unnamespaced_destroy(ptr); }); -export class Unnamespaced { + + +export class Unnamespaced { + // Internal ptr reference: #ptr = null; @@ -33,8 +36,8 @@ export class Unnamespaced { get ffiValue() { return this.#ptr; - } - + } + static make(e) { const result = wasm.namespace_Unnamespaced_make(e.ffiValue); @@ -43,8 +46,8 @@ export class Unnamespaced { } finally {} - } - + } + useNamespaced(n) {wasm.namespace_Unnamespaced_use_namespaced(this.ffiValue, n.ffiValue); try {} diff --git a/feature_tests/js/api/Utf16Wrap.d.ts b/feature_tests/js/api/Utf16Wrap.d.ts index 856a7021b..5eddea9a6 100644 --- a/feature_tests/js/api/Utf16Wrap.d.ts +++ b/feature_tests/js/api/Utf16Wrap.d.ts @@ -1,14 +1,25 @@ // generated by diplomat-tool import type { pointer, codepoint } from "./diplomat-runtime.d.ts"; -export class Utf16Wrap { + + +export class Utf16Wrap { + - get ffiValue(): pointer; - - static fromUtf16(input: string): Utf16Wrap; - - getDebugStr(): string; - + get ffiValue(): pointer; + + #defaultConstructor(input: string): Utf16Wrap; + + getDebugStr(): string; + borrowCont(): string; + + constructor(input: string) { + if (arguments[0] === diplomatRuntime.internalConstructor) { + this.#internalConstructor(...arguments.slice(1)); + } else { + this.#defaultConstructor(...arguments); + } + } } \ No newline at end of file diff --git a/feature_tests/js/api/Utf16Wrap.mjs b/feature_tests/js/api/Utf16Wrap.mjs index 1bb497ea3..0e79abb74 100644 --- a/feature_tests/js/api/Utf16Wrap.mjs +++ b/feature_tests/js/api/Utf16Wrap.mjs @@ -6,7 +6,10 @@ const Utf16Wrap_box_destroy_registry = new FinalizationRegistry((ptr) => { wasm.Utf16Wrap_destroy(ptr); }); -export class Utf16Wrap { + + +export class Utf16Wrap { + // Internal ptr reference: #ptr = null; @@ -14,7 +17,7 @@ export class Utf16Wrap { // Since JS won't garbage collect until there are no incoming edges. #selfEdge = []; - constructor(symbol, ptr, selfEdge) { + #internalConstructor(symbol, ptr, selfEdge) { if (symbol !== diplomatRuntime.internalConstructor) { console.error("Utf16Wrap is an Opaque type. You cannot call its constructor."); return; @@ -31,9 +34,9 @@ export class Utf16Wrap { get ffiValue() { return this.#ptr; - } - - static fromUtf16(input) { + } + + #defaultConstructor(input) { let functionCleanupArena = new diplomatRuntime.CleanupArena(); const inputSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.str16(wasm, input)); @@ -47,8 +50,8 @@ export class Utf16Wrap { finally { functionCleanupArena.free(); } - } - + } + getDebugStr() { const write = new diplomatRuntime.DiplomatWriteBuf(wasm); wasm.Utf16Wrap_get_debug_str(this.ffiValue, write.buffer); @@ -60,8 +63,8 @@ export class Utf16Wrap { finally { write.free(); } - } - + } + borrowCont() { const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 8, 4, false); @@ -78,4 +81,12 @@ export class Utf16Wrap { diplomatReceive.free(); } } + + constructor() { + if (arguments[0] === diplomatRuntime.internalConstructor) { + this.#internalConstructor(...arguments.slice(1)); + } else { + this.#defaultConstructor(...arguments); + } + } } \ No newline at end of file