Skip to content

Embind port #7239

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

Draft
wants to merge 38 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
work
  • Loading branch information
kripken committed Apr 2, 2024
commit 417f7da8fe03813055fc353230fbe1ebae7b4f86
6 changes: 2 additions & 4 deletions src/binaryen-embind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ EMSCRIPTEN_BINDINGS(Binaryen) {
.function("isDefaultable", &Type::isDefaultable)
.function("getHeapType", &Type::getHeapType)
;

register_vector<Type>("TypeVec");

value_object<Signature>("Signature")
Expand All @@ -81,7 +80,7 @@ EMSCRIPTEN_BINDINGS(Binaryen) {
.property("type", &Expression::type);

// All Expression classes...
class_<Nop>("Nop");
class_<Nop, base<Expression>>("Nop");

// Module-level constructs.

Expand All @@ -101,12 +100,11 @@ EMSCRIPTEN_BINDINGS(Binaryen) {
.property("name", &NameType::name)
.property("type", &NameType::type)
;

register_vector<NameType>("NameTypeVec");

class_<Builder>("Builder")
.constructor<Module&>()
.function("makeFunction",
.class_function("makeFunction",
select_overload<std::unique_ptr<Function> (Name,
HeapType,
std::vector<Type>&& vars,
Expand Down
17 changes: 15 additions & 2 deletions test/binaryen-embind.js/basics.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,25 @@ binaryenFactory().then((binaryen) => {
};
const func_ii = new binaryen.HeapType(sig);
const vars = new binaryen.TypeVec();
const func = builder.makeFunction(
"foo",
const func = binaryen.Builder.makeFunction(
new binaryen.Name("foo"),
func_ii,
vars,
builder.makeNop()
);
module.addFunction(func);

// Check the function prints out ok.
normEqual(binaryen.stringify(module),
`
(module
(type $0 (func (param i32) (result i32)))
(func $foo (param $0 i32) (result i32)
(nop)
)
)
`);

console.log('success.');
});