Hi,

I have a problem with smart-pointer. When i pass it for a JS function, the 
PTR is undefined and COUNT is undefined.

https://user-images.githubusercontent.com/395096/211975635-50b02139-b9ea-4130-995d-dcbf3ea1da44.png

The class that receive the smart-ptr is OK, but the method that receive a 
smart-ptr is wrong.

The bind code is:









*```EMSCRIPTEN_BINDINGS(xplpc_proxy_platform_proxy_callback){    
em::class_<xplpc::proxy::PlatformProxyCallback>("PlatformProxyCallback")    
    .constructor<const std::function<void(const std::string &)> &&>()      
  
.smart_ptr<std::shared_ptr<xplpc::proxy::PlatformProxyCallback>>("shared_ptr<PlatformProxyCallback>")
  
      .function("call", &xplpc::proxy::PlatformProxyCallback::call);}```*

File: 
https://github.com/xplpc/xplpc/blob/wasm-mapping/wasm/lib/src/bind.cpp#L33-L39

The javascript function is:






*```onRemoteProxyCallAsync: function (data: string, callback: 
XWebPlatformProxyCallback) {    console.log("[XWebPlatformProxy : 
onRemoteProxyCallAsync] This: ", this);    console.log("[XWebPlatformProxy 
: onRemoteProxyCallAsync] Callback: ", callback);}```*

File: 
https://github.com/xplpc/xplpc/blob/wasm-mapping/wasm/sample/src/xplpc/proxy/platform-proxy.ts#L31-L33

The C++ code that call the JS function is:











*```void callProxyAsync(const std::string &data, 
std::shared_ptr<xplpc::proxy::PlatformProxyCallback> callback){    // the 
count is 2    spdlog::info("[callProxyAsync 1] Callback Smart Ptr Count: 
{}", callback.use_count());    call<void>("onRemoteProxyCallAsync", data, 
callback);    spdlog::info("[callProxyAsync 2]");}```*

What im doing wrong? Thanks.

-- 
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 emscripten-discuss+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/emscripten-discuss/eac4fefe-d1c4-4a07-be40-1a76d0a66922n%40googlegroups.com.

Reply via email to