To send a value into inline code, use the EM_ASM_* macros, see
emscripten.h. For example, here you would use

int size = 111;
EM_ASM_INT({
  Module['size'] = $0;
}, size);

- Alon



On Sat, Feb 22, 2014 at 9:04 AM, Nickolay Sukhanov
<[email protected]>wrote:

> I want to ask, what should i do if i want write smth like:
>
> int size = 111;
> EM_ASM(
>     Module['size'] = size;
> );
> I didn't understand it(
>
> On Tuesday, November 19, 2013 4:39:30 AM UTC+4, Alon Zakai wrote:
>>
>> We have had partial support for
>>
>> asm(" .. some js ..")
>>
>> for a while, but it's always been tricky to use because of gnu asm syntax
>> (comments, etc. are all different than JS). We have also had EM_ASM which
>> is simpler,
>>
>> EM_ASM(
>>   ..some js..
>> )
>>
>> but it did not support input and output arguments. There are now versions
>> that do support input and output,
>>
>> int x = EM_ASM_INT({ .. some js .. })
>>
>> and arbitrary numbers of input arguments work too (called $x in the code,
>> starting from $0)
>>
>> int y = EM_ASM_INT({ ..use $0, $1 .. }, arg1, arg2);
>>
>> and also a version EM_ASM_DOUBLE which returns a double value. For more
>> details see emscripten.h.
>>
>> Note that this does not get expanded out inline directly. Instead we
>> store the code as a string on the heap, and call a C method to execute it.
>> The reason for that is to keep the compiled code guaranteed to validate as
>> asm.js for performance. But there is some call overhead, so in an inner
>> loop there might be a cost. Otherwise you don't need to be aware of that
>> implementation detail.
>>
>> Hopefully this will provide most of what people need in terms in inline
>> js. Thoughts, feedback are welcome.
>>
>> - Alon
>>
>>  --
> 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].
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
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].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to