Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

what does glue code do? #26

Open
JimmyVV opened this issue Dec 18, 2017 · 0 comments
Open

what does glue code do? #26

JimmyVV opened this issue Dec 18, 2017 · 0 comments

Comments

@JimmyVV
Copy link

JimmyVV commented Dec 18, 2017

The repo is great, but there some code inside I don't understand.

There is a global variable -- Module. However, the glue code is like a black box, how do i know what .wasm exposed. Yes, I could get some exposed fn using WebAssembly.Module.exports/imports, but in this glue code, I should need to do this by Module.ccall.

so, how can get information from glue code? like:

wam['grayScale'] = function (pixelData) {
              const len = pixelData.length
              const mem = _malloc(len); // get the memory of wasm
              HEAPU8.set(pixelData, mem); // transfer the pixelData
              _grayScale(mem, len); // trigger the grayScale fun
              const filtered = HEAPU8.subarray(mem, mem + len); // get the resulted data
              _free(mem); // release memory
              return filtered; // return buffer
            };

where could I find some explanation of the above code, like HEAPU8, or _free.

I feel a little confused.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant