Re: Strings

I think it may be more appropriate, and you may get a better response, if you post the issue here: https://github.com/WebAssembly/wabt/issues

 

-Sam

 

From: Borut Jegrisnik <borut@medianova.hr>
Date: Tuesday, May 30, 2017 at 4:20 PM
To: <public-webassembly@w3.org>
Subject: Strings
Resent-From: <public-webassembly@w3.org>
Resent-Date: Tue, 30 May 2017 21:22:52 +0000

 

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:35:51 UTC