I had successfuly, built a 3rd party library in webasm and I am trying to
test it.
however I am stuck on how to proceed as I cant find documentation or
tutorial related to it.
the library I ported is initialized by calling a Create() function and
returns a struct pointer like a context, and this struct pointer is passed
everytime a function on that libraryy is called.
I am confuse on how to handle this in webasm as the returning struct
pointer is neither used outside of the library but just recieved and passed
thru.
I have tried settingthe return value as 'number' in the call to initialize
method and just pass back these number to the next method but to no lock.
here is a sample mini code I made
C++
void* EMSCRIPTEN_KEEPALIVE InitializeLibrary(){
SomeStruct s;
s.k = 18;
s.t = 21;
return (void*)&s;
}
int EMSCRIPTEN_KEEPALIVE Add(void* b) {
SomeStruct* bg = (SomeStruct*)b;
return bg->k + bg->t;
}
and in Javascript/nodejs side
const ptr = Module.ccall("InitializeLibrary", 'number', null);
const result = Module.ccall("Add", 'number', ['number'],[ptr]);
console.log(result);
to no avail,
How to effectively approach this?
I have yet to try (and will try next), creating a C/C++ adapter that will
serve as the middleman between the library and JS instead and keep the
pointer/context in there, but im not sure if its possible.
Any help is appreaciated.
--
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].
To view this discussion on the web visit
https://groups.google.com/d/msgid/emscripten-discuss/c69d8ea3-a4df-4462-94e3-0711878099d7n%40googlegroups.com.