通过javaScript土地内置的对象的指针到WebAssembly(C++)函数
我在C ++中具有一个(const char*)
参数。我想通过将其传递给JavaScript中创建的对象的地址,在JavaScript(通过Web Assembly)中调用此函数。这可能吗?
代码就像
// Create an object by loading from url.
const encoder = await loadModel("some_url");
const data = [1,2,3];
Module.onRuntimeInitialized = _ => {
// Call the wasm function with a pointer to the encoder.
Module.encode(&encoder, data);
}
我如何将编码对象的地址传递给函数?
I have a function in C++ that takes a (const char*)
argument. I want to call this function in JavaScript (through Web assembly) by passing to it the address of an object created in JavaScript. Is this possible?
The code is something like
// Create an object by loading from url.
const encoder = await loadModel("some_url");
const data = [1,2,3];
Module.onRuntimeInitialized = _ => {
// Call the wasm function with a pointer to the encoder.
Module.encode(&encoder, data);
}
How can I take the address of the encoder object to pass to the function?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将JavaScript对象序列化为原始字符串以在编程语言之间传递是常见的。
It is common to serialize the JavaScript object to a primitive string to pass between programming languages.