Replies: 2 comments
-
Beta Was this translation helpful? Give feedback.
0 replies
-
There's not an official/documented way to do this currently. You could set up your own conversion, but this may break in the future. namespace emscripten {
namespace internal {
template <>
struct BindingType<your_type> {
using ValBinding = BindingType<val>;
using WireType = ValBinding::WireType;
static WireType toWireType(const your_type& yourObj) {
val obj = val::object();
// ... copy data from yourObj
return ValBinding::toWireType(obj);
}
static your_type fromWireType(WireType value) {
val val = ValBinding::fromWireType(value);
your_type mine;
mine.set(val);
return mine;
}
};
template <typename T>
struct TypeID<T,
typename std::enable_if_t<
std::is_same<typename Canonicalized<T>::type, your_type>::value>> {
static constexpr TYPEID get() { return TypeID<val>::get(); }
};
}} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi!
Is it possible to hook into embind, such that I can specify conversion from/to
emscripten::val
for C++ types? For example, I would like to mapEigen
types to correspondingThree.js
ones, for whichvalue_object
might not be sufficient, as I need the whole JS object at once to set up the type on the C++ side.Or phrased differently. Can a
value_object
have a constructor takingemscripten::val
and can I provide lambdas forvalue_object
members, that take a reference to the underlying object as argument?Like
Thanks and greetings from Berlin.
Beta Was this translation helpful? Give feedback.
All reactions