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
wprk
  • Loading branch information
kripken committed Apr 2, 2024
commit 4c84f27083f8d040508263cddc8a92cdb1d086c3
74 changes: 40 additions & 34 deletions src/binaryen-embind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,7 @@ EMSCRIPTEN_BINDINGS(Binaryen) {
class_<Expression>("Expression")
.property("type", &Expression::type);

class_<Nop, base<Expression>>("Nop");


#if 0
// Expression types, autogenerated.

#define DELEGATE_ID id

Expand All @@ -91,40 +88,49 @@ EMSCRIPTEN_BINDINGS(Binaryen) {
#define DELEGATE_END(id) std::cout << '\n';

#define DELEGATE_FIELD_CHILD(id, field) \
std::cout << "BINARYEN_API BinaryenExpressionRef Binaryen" << #id << "Get" \
<< #field << "(BinaryenExpressionRef expr);\n";

.property(#field, &id::field);
#define DELEGATE_FIELD_CHILD_VECTOR(id, field) \
std::cout << "BINARYEN_API BinaryenExpressionRef Binaryen" << #id << "Get" \
<< #field \
<< "At(BinaryenExpressionRef expr, BinaryenIndex index);\n";

// TODO
#define DELEGATE_FIELD_TYPE(id, field)
#define DELEGATE_FIELD_HEAPTYPE(id, field)
#define DELEGATE_FIELD_OPTIONAL_CHILD(id, field)
#define DELEGATE_FIELD_INT(id, field)
#define DELEGATE_FIELD_LITERAL(id, field)
#define DELEGATE_FIELD_NAME(id, field)
#define DELEGATE_FIELD_SCOPE_NAME_DEF(id, field)
#define DELEGATE_FIELD_SCOPE_NAME_USE(id, field)
#define DELEGATE_FIELD_ADDRESS(id, field)
#define DELEGATE_FIELD_INT_ARRAY(id, field)
#define DELEGATE_FIELD_INT_VECTOR(id, field)
#define DELEGATE_FIELD_NAME_VECTOR(id, field)
#define DELEGATE_FIELD_SCOPE_NAME_USE_VECTOR(id, field)
#define DELEGATE_FIELD_TYPE_VECTOR(id, field)

#define DELEGATE(clazz) \
class_<clazz, base<Expression>>(#clazz)
#include "wasm-delegations-fields.def"
.property(#field, &id::field);
#define DELEGATE_FIELD_TYPE(id, field) \
.property(#field, &id::field);
#define DELEGATE_FIELD_HEAPTYPE(id, field) \
.property(#field, &id::field);
#define DELEGATE_FIELD_OPTIONAL_CHILD(id, field) \
.property(#field, &id::field);
#define DELEGATE_FIELD_INT(id, field) \
.property(#field, &id::field);
#define DELEGATE_FIELD_LITERAL(id, field) \
.property(#field, &id::field);
#define DELEGATE_FIELD_NAME(id, field) \
.property(#field, &id::field);
#define DELEGATE_FIELD_SCOPE_NAME_DEF(id, field) \
.property(#field, &id::field);
#define DELEGATE_FIELD_SCOPE_NAME_USE(id, field) \
.property(#field, &id::field);
#define DELEGATE_FIELD_ADDRESS(id, field) \
.property(#field, &id::field);
#define DELEGATE_FIELD_INT_ARRAY(id, field) \
.property(#field, &id::field);
#define DELEGATE_FIELD_INT_VECTOR(id, field) \
.property(#field, &id::field);
#define DELEGATE_FIELD_NAME_VECTOR(id, field) \
.property(#field, &id::field);
#define DELEGATE_FIELD_SCOPE_NAME_USE_VECTOR(id, field) \
.property(#field, &id::field);
#define DELEGATE_FIELD_TYPE_VECTOR(id, field) \
.property(#field, &id::field);

#define DELEGATE_FIELD_MAIN_START

#define DELEGATE_FIELD_CASE_START(id) \
class_<id, base<Expression>>(#id)

#define DELEGATE_FIELD_CASE_END(id) \
;

#include "wasm-delegations.def"
#endif


#define DELEGATE_FIELD_MAIN_END

#include "wasm-delegations-fields.def"

// Module-level constructs.

Expand Down
11 changes: 6 additions & 5 deletions src/wasm-delegations-fields.def
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@

// By default we emit a switch and cases, but that can be customized using the
// following:

#ifndef DELEGATE_FIELD_MAIN_START
#define DELEGATE_FIELD_MAIN_START \
switch (DELEGATE_ID) { \
Expand All @@ -239,11 +240,6 @@ switch (DELEGATE_ID) { \
}
#endif

#ifndef DELEGATE_FIELD_MAIN_END
#define DELEGATE_FIELD_MAIN_END \
}
#endif

#ifndef DELEGATE_FIELD_CASE_START
#define DELEGATE_FIELD_CASE_START(id) \
case Expression::Id::id##Id: { \
Expand All @@ -257,6 +253,11 @@ switch (DELEGATE_ID) { \
}
#endif

#ifndef DELEGATE_FIELD_MAIN_END
#define DELEGATE_FIELD_MAIN_END \
}
#endif

DELEGATE_FIELD_MAIN_START

DELEGATE_FIELD_CASE_START(Block)
Expand Down