Comments (6)
As for why const std::shared_ptr
works, that will be a const reference which has a helper static WireType toWireType(const T& v) {
for sending it to JS so it works.
from emscripten.
Embind generally doesn't like raw pointers being sent across since it unclear who owns the object. Can you instead use a std::shared_ptr
?
from emscripten.
Embind generally doesn't like raw pointers being sent across since it unclear who owns the object. Can you instead use a
std::shared_ptr
?
Thank you @brendandahl. I'm also bothered by this issue. When I tried to change the function to void passConstObj(const std::shared_ptr<PolyDerived> o)
, the problem was solved.
But I have a question, ignoring the question of whether embind likes the original pointer preference (because it doesn't affect the compilation of PolyDerived*
type arguments), why const PolyDerived*
can't compile the same const argument, but const std::shared_ptr<PolyDerived>
can
from emscripten.
I misremembered, I thought val::call
had the same restrictions as bind.h function
bindings where you must explicitly pass allow_raw_pointers
if you want to use pointers as arguments. val::call
doesn't appear to have that restriction, so yes it is strange that const
pointers don't work. I'm not the original author of this code so I'm not sure what the intent was there or if it was just an oversight.
It seems reasonable to automatically remove the const in the val.h code.
from emscripten.
There was a relevant discussion previously #7292 but nothing ever came of it.
from emscripten.
Thanks @brendandahl again. Although I didn't figure it out thoroughly, at least there was a solution.
from emscripten.
Related Issues (20)
- No transitive dependency with emscripten ports HOT 6
- Template Instantiation Error in system/lib/libcxx/include/__memory/pointer_traits.h HOT 1
- File-related syscalls, like readdir, can not handle empty directories properly HOT 2
- C++ exceptions caught in JavaScript leak stack memory even when documented instructions are followed HOT 4
- WASM_WORKERS=2 documentation HOT 14
- typedef redefinition with different types HOT 6
- [embind] Using `EMSCRIPTEN_HAS_UNBOUND_TYPE_NAMES=0` fails with polymorphic types HOT 4
- It could help to always use JS for memsets during startup / that are always large HOT 6
- Weird --embind-emit-tsd output HOT 1
- how to generated only one file *.js if i use pthread HOT 2
- [embind] Automatic downcasting doesn't work for address over 2gb
- scorecards action seems broken. HOT 3
- --embind-emit-tsd may cause "ReferenceError: assert is not defined"
- embind d.ts defintion for std::string
- Any example to compile a project via emscripten and use it in wasmtime? HOT 10
- In `-sMODULARIZE` mode the `moduleArg` should not be modified in place
- Bind error of getting a pointer property in class
- Make mimalloc headers accessible HOT 2
- lto2.test_embind_i64_val is failing
- evaluation of std::sin in C++ is slower than in JS directly HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from emscripten.