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 1, 2024
commit a176ae1ebb8ca8a1c05946211cb06239886d5fb9
16 changes: 15 additions & 1 deletion src/binaryen-embind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,23 @@ EMSCRIPTEN_BINDINGS(Binaryen) {
class_<Function>("Function")
;

class_<NameType>("NameType")
.constructor<Name, Type>()
.property("name", &NameType::name)
.property("type", &NameType::type)
;

register_vector<NameType>("NameTypeVec");

class_<Builder>("Builder")
.constructor<Module&>()
.function("makeFunction", select_overload<std::unique_ptr<Function> (Name, std::vector<NameType>&&, HeapType, std::vector<NameType>&& vars, Expression*)>(&Builder::makeFunction), allow_raw_pointers())
.function("makeFunction",
select_overload<std::unique_ptr<Function> (Name,
std::vector<NameType>&&,
HeapType,
std::vector<NameType>&& vars,
Expression*)
>(&Builder::makeFunction), allow_raw_pointers())

// All Expression classes...
.function("makeNop", &Builder::makeNop, allow_raw_pointers())
Expand Down
4 changes: 3 additions & 1 deletion test/binaryen-embind.js/basics.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const binaryenFactory = require(binaryen_js_path);

binaryenFactory().then((binaryen) => {
// Create a Module.
var module = new binaryen.Module();
const module = new binaryen.Module();

// Check it prints out as empty.
normEqual(binaryen.stringify(module),
Expand All @@ -26,6 +26,8 @@ binaryenFactory().then((binaryen) => {
)
`);

const builder = new binaryen.Builder(module);
const func = builder.makeFunction("foo",
console.log('success.');
});