Skip to content

what does glue code do? #26

@JimmyVV

Description

@JimmyVV

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions