Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

embind - Disable wasm2js when emitting types. #21333

Merged
merged 1 commit into from
Feb 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
112 changes: 112 additions & 0 deletions test/other/embind_tsgen_ignore_3.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
// TypeScript bindings for emscripten-generated code. Automatically generated at compile time.
interface WasmModule {
_main(_0: number, _1: number): number;
}

export interface Test {
x: number;
readonly y: number;
functionOne(_0: number, _1: number): number;
functionTwo(_0: number, _1: number): number;
functionFour(_0: boolean): number;
functionFive(x: number, y: number): number;
constFn(): number;
longFn(_0: number): number;
functionThree(_0: ArrayBuffer|Uint8Array|Uint8ClampedArray|Int8Array|string): number;
functionSix(str: ArrayBuffer|Uint8Array|Uint8ClampedArray|Int8Array|string): number;
delete(): void;
}

export interface BarValue<T extends number> {
value: T;
}
export type Bar = BarValue<0>|BarValue<1>|BarValue<2>;

export interface EmptyEnumValue<T extends number> {
value: T;
}
export type EmptyEnum = never/* Empty Enumerator */;

export type ValArrIx = [ Bar, Bar, Bar, Bar ];

export interface IntVec {
push_back(_0: number): void;
resize(_0: number, _1: number): void;
size(): number;
get(_0: number): number | undefined;
set(_0: number, _1: number): boolean;
delete(): void;
}

export interface MapIntInt {
keys(): IntVec;
get(_0: number): number | undefined;
set(_0: number, _1: number): void;
size(): number;
delete(): void;
}

export interface Foo {
process(_0: Test): void;
delete(): void;
}

export type ValObj = {
foo: Foo,
bar: Bar
};

export interface ClassWithConstructor {
fn(_0: number): number;
delete(): void;
}

export interface ClassWithTwoConstructors {
delete(): void;
}

export interface ClassWithSmartPtrConstructor {
fn(_0: number): number;
delete(): void;
}

export interface BaseClass {
fn(_0: number): number;
delete(): void;
}

export interface DerivedClass extends BaseClass {
fn2(_0: number): number;
delete(): void;
}

export type ValArr = [ number, number, number ];

interface EmbindModule {
Test: {staticFunction(_0: number): number; staticFunctionWithParam(x: number): number; staticProperty: number};
class_returning_fn(): Test;
class_unique_ptr_returning_fn(): Test;
a_class_instance: Test;
an_enum: Bar;
Bar: {valueOne: BarValue<0>, valueTwo: BarValue<1>, valueThree: BarValue<2>};
EmptyEnum: {};
enum_returning_fn(): Bar;
IntVec: {new(): IntVec};
MapIntInt: {new(): MapIntInt};
Foo: {};
ClassWithConstructor: {new(_0: number, _1: ValArr): ClassWithConstructor};
ClassWithTwoConstructors: {new(): ClassWithTwoConstructors; new(_0: number): ClassWithTwoConstructors};
ClassWithSmartPtrConstructor: {new(_0: number, _1: ValArr): ClassWithSmartPtrConstructor};
BaseClass: {};
DerivedClass: {};
a_bool: boolean;
an_int: number;
optional_test(_0: Foo | undefined): number | undefined;
global_fn(_0: number, _1: number): number;
smart_ptr_function(_0: ClassWithSmartPtrConstructor): number;
smart_ptr_function_with_params(foo: ClassWithSmartPtrConstructor): number;
function_with_callback_param(_0: (message: string) => void): number;
string_test(_0: ArrayBuffer|Uint8Array|Uint8ClampedArray|Int8Array|string): string;
wstring_test(_0: string): string;
}
export type MainModule = WasmModule & EmbindModule;
4 changes: 4 additions & 0 deletions test/test_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -3143,6 +3143,10 @@ def test_embind_tsgen_ignore(self):
'-sEXPORT_ES6=1']
self.emcc(test_file('other/embind_tsgen.cpp'), extra_args)
self.assertFileContents(test_file('other/embind_tsgen_ignore_2.d.ts'), read_file('embind_tsgen.d.ts'))
# Also test this separately since it conflicts with other settings.
extra_args = ['-sWASM=0']
self.emcc(test_file('other/embind_tsgen.cpp'), extra_args)
self.assertFileContents(test_file('other/embind_tsgen_ignore_3.d.ts'), read_file('embind_tsgen.d.ts'))

def test_embind_tsgen_test_embind(self):
self.run_process([EMXX, test_file('embind/embind_test.cpp'),
Expand Down
2 changes: 2 additions & 0 deletions tools/link.py
Original file line number Diff line number Diff line change
Expand Up @@ -1904,6 +1904,8 @@ def run_embind_gen(wasm_target, js_syms, extra_settings):
# Disable proxying and thread pooling so a worker is not automatically created.
settings.PROXY_TO_PTHREAD = False
settings.PTHREAD_POOL_SIZE = 0
# Assume wasm support at binding generation time
settings.WASM2JS = 0
# Disable minify since the binaryen pass has not been run yet to change the
# import names.
settings.MINIFY_WASM_IMPORTED_MODULES = False
Expand Down
Loading