On Mon, Apr 25, 2016 at 9:33 AM, Brion Vibber <[email protected]> wrote:
> On Monday, April 25, 2016, Thomas Fischer <[email protected]> wrote: > >> >> It seems that *value_array* binding doesn't check against nulltptr >> beforehand, when translating it into a JS Array. >> Is it a bug or a feature? Is there anything else I can do instead of >> wrapping the Point2f value to cover the nullptr case? >> > > Value objects/arrays are marshaled through embind by value -- making a > copy of the data into a JS structure -- rather than by reference/pointer, > so I don't think they're really supposed to be handling a pointer return > value like this. > I tried compiling your sample code plus a little extra testing with emscripten 1.36.0; here's the sample project: https://github.com/brion/embind-valuearray-test/ I cannot bind the sample function that returns a Point2f*, as I get a nice error from the embind templates that raw pointers are not allowed here unless whitelisted: $ make em++ -o sample.js --bind sample.cpp In file included from sample.cpp:2: In file included from /Users/brion/src/emsdk_portable/emscripten/master/system/include/emscripten/bind.h:10: In file included from /Users/brion/src/emsdk_portable/emscripten/master/system/include/emscripten/val.h:4: /Users/brion/src/emsdk_portable/emscripten/master/system/include/emscripten/wire.h:86:13: error: static_assert failed "Implicitly binding raw pointers is illegal. Specify allow_raw_pointer<arg<?>>" static_assert(!std::is_pointer<T*>::value, "Implicitly bindi... ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~ /Users/brion/src/emsdk_portable/emscripten/master/system/include/emscripten/wire.h:182:53: note: in instantiation of template class 'emscripten::internal::TypeID<Point2f *>' requested here static constexpr TYPEID types[] = { TypeID<Args>::get()... }; ^ /Users/brion/src/emsdk_portable/emscripten/master/system/include/emscripten/wire.h:205:24: note: in instantiation of member function 'emscripten::internal::ArgArrayGetter<emscripten::internal::TypeList<Point2f *> >::get' requested here >::get(); ^ /Users/brion/src/emsdk_portable/emscripten/master/system/include/emscripten/bind.h:419:18: note: in instantiation of member function 'emscripten::internal::WithPolicies<>::ArgTypeList<Point2f *>::getTypes' requested here args.getTypes(), ^ sample.cpp:31:2: note: in instantiation of function template specialization 'emscripten::function<Point2f *>' requested here function("getPoint2fPtr", &getPoint2fPtr); ^ 1 error generated. ERROR:root:compiler frontend failed to generate LLVM bitcode, halting make: *** [sample.js] Error 1 Can you provide the exact code you're compiling and the emscripten version you're building with? -- brion -- You received this message because you are subscribed to the Google Groups "emscripten-discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
