[英]Emscripten- retrieving array values set by c function with Module.cwrap
We have a "little c" library compiled to javascript via emscripten. 我们有一个通过emscripten编译为javascript的“小c”库。 Many functions in the c library modify arrays that are passed in. It is not obvious what the mechanism is to access those arrays from the javascript level.
c库中的许多函数都会修改传入的数组。从javascript级别访问这些数组的机制并不明显。
Using Module.cwrap
and calling a function that is correctly exported (eg EXPORTED_FUNCTIONS="['_myFunc']
) is straightforward, but the only access to variables calculated on the c side appears to be in the return from this function. If we return a pointer to an array from the c side, it is not obvious how to access the array from the javascript side. 使用
Module.cwrap
并调用正确导出的函数(例如EXPORTED_FUNCTIONS="['_myFunc']
)很简单,但是对c侧计算的变量的唯一访问似乎是从该函数返回。如果我们返回从c方面指向数组的指针,如何从javascript端访问数组并不明显。
If we indicate that Module.cwrap
has a returnType of array
how would the c function called return an array? 如果我们指出
Module.cwrap
有一个array
的returnType,那么c函数如何调用返回一个数组?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.