Can the JS equality operators (like ===) work with embind types?

Viewed 112

Suppose I have some Emscripten bindings like so:

class_<MyNode>("MyNode")
    .constructor<>()
    .function("getParentNode", &MyNode::parentNode, allow_raw_pointers());

When I run the following code in JS, I get false, but I want it to be true:

node.getParentNode() === node.getParentNode()

I'm guessing this is because Emscripten is wrapping the result of each function call in a new JS object, even though the JS objects point to the same underlying C++ object.

That is, is there some trick in Emscripten for JS === or == to return true with bound types that have the same underlying raw pointer values?

1 Answers
Related