Strings

Hey all,

I'm trying to get this simple scenario working, but I can't understand how
to get the data from Memory:

in hello.cpp:

void EMSCRIPTEN_KEEPALIVE modifyDOM(const char *text, const char *id) {
    printf("modify dom %s with %s\n", id, text);
    EM_ASM_({
        console.log($0);
        console.log($1);
        console.log(arguments);
        const elt = document.getElementById($0);
        elt.innerHTML = $1;
    }, id, text);
}

in hello.html:

document.querySelector('.addDom').addEventListener('click', function(){
    Module.ccall('modifyDOM', null, ['string', 'string'], ['Some fun text',
'textDom']);
});

What I get is that printf outputs correct values (i.e. modify dom textDom
with Some fun text) but the console.log outputs numbers like 6736 and 6672.

I guess that's because inside Javascript world those values are stored like
pointers in memory. If that's the case, what would be the best way to get
those values as strings?

And sub-question, is there a documentation on generated hello.js library?

Many thanks
Borut Jegrisnik

Received on Tuesday, 30 May 2017 21:22:51 UTC