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
weird
  • Loading branch information
kripken committed Apr 1, 2024
commit 63b05706a06d1e9ca5fe80538ae00b9ffc539d5e
5 changes: 3 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ if(EMSCRIPTEN)
add_link_flag("-sNODERAWFS")
endif()
# in opt builds, LTO helps so much (>20%) it's worth slow compile times
add_nondebug_compile_flag("-flto")
#add_nondebug_compile_flag("-flto")
add_compile_flag("-DEMSCRIPTEN_HAS_UNBOUND_TYPE_NAMES=0") # XXX - ?
endif()

Expand Down Expand Up @@ -561,7 +561,8 @@ if(EMSCRIPTEN)
#target_link_libraries(binaryen_embind_wasm optimized "--closure=1")
# TODO: Fix closure warnings! (#5062)
target_link_libraries(binaryen_embind_wasm optimized "-Wno-error=closure")
target_link_libraries(binaryen_embind_wasm optimized "-flto")
#target_link_libraries(binaryen_embind_wasm optimized "-flto")
target_link_libraries(binaryen_embind_wasm optimized "--profiling") # XXX
target_link_libraries(binaryen_embind_wasm debug "--profiling")
install(TARGETS binaryen_embind_wasm DESTINATION ${CMAKE_INSTALL_BINDIR})
endif()
Expand Down
34 changes: 33 additions & 1 deletion src/binaryen-embind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,39 @@
using namespace wasm;
using namespace emscripten;

Function* (Module::*Module_addFunction)(Function*) = &Module::addFunction; // XXX work around overloaded name

EMSCRIPTEN_BINDINGS(Binaryen) {

class_<Type>("Type")
.function("isTuple", &Type::isTuple)
.function("isRef", &Type::isRef)
.function("isFunction", &Type::isFunction)
.function("isData", &Type::isData)
.function("isNullable", &Type::isNullable)
.function("isNonNullable", &Type::isNonNullable)
.function("isNull", &Type::isNull)
.function("isSignature", &Type::isSignature)
.function("isStruct", &Type::isStruct)
.function("isArray", &Type::isArray)
.function("isException", &Type::isException)
.function("isString", &Type::isString)
.function("isDefaultable", &Type::isDefaultable);

class_<Name>("Name")
.constructor<const std::string&>();

class_<Expression>("Expression")
.function("finalize", &Expression::finalize);
.property("type", &Expression::type);

class_<Function>("Function")
;

class_<Module>("Module")
.property("start", &Module::start)
.function("getFunction", &Module::getFunction, allow_raw_pointers())
.function("getFunctionOrNull", &Module::getFunctionOrNull, allow_raw_pointers())
.function("addFunction", Module_addFunction, allow_raw_pointers()) // XXX
;

}