How to use shared-ptr when bind?

10 views
Skip to first unread message

Paulo Coutinho

unread,
Dec 25, 2022, 10:25:02 AM12/25/22
to emscripten-discuss
Hi,

Im trying create a new class in Javascript and pass it to a function that receive a shared-ptr, but im getting this error:

BindingError {name: 'BindingError', message: 'Cannot pass "[object Object]" as a PlatformProxy'}

The line with problem is here:


CODE:
"wm.module.PlatformProxy.create(new XWebPlatformClient());"

That is a bind from here:


CODE:
EMSCRIPTEN_BINDINGS(xplpc_proxy_platform_proxy)
{
    em::class_<xplpc::proxy::PlatformProxy>("PlatformProxy")
        .smart_ptr<std::shared_ptr<xplpc::proxy::PlatformProxy>>("PlatformProxy")
        .class_function("shared", &xplpc::proxy::PlatformProxy::shared)
        .class_function("createDefault", &xplpc::proxy::PlatformProxy::createDefault)
        .class_function("create", &xplpc::proxy::PlatformProxy::create)
        .class_function("hasProxy", &xplpc::proxy::PlatformProxy::hasProxy)
        .function("initialize", &xplpc::proxy::PlatformProxy::initialize)
        .function("call", &xplpc::proxy::PlatformProxy::call);
}


After search a lot, i don't know understand what is wrong and what i need pass to "create" function that receive a shared-ptr.

Thanks for any help.

Reply all
Reply to author
Forward
0 new messages