emscripten read javascript arrayBuffer in C -


this code incorrect tells trying do

char* p = em_asm(     var = new arraybuffer(8);     return a; ); 

what correct way of getting c pointer of javascript arraybuffer?
want read arraybuffer not write

as far i'm aware, there's no direct way of returning array inline javascript (although there way of returning read-only arrays javascript wrapped c functions, see this answer). can instead malloc space array in c function, pass address inline emscripten, , use emscripten javascript function writearraytomemory copy javascript array malloced memory. this...

char *a = malloc(4);  em_asm_int({     var v1 = new uint8array([2,4,6,8]);      writearraytomemory(v1, $0)     }, a);  printf("the array [%d, %d, %d, %d]\n", a[0], a[1], a[2], a[3]); 

Comments

Popular posts from this blog

javascript - Thinglink image not visible until browser resize -

firebird - Error "invalid transaction handle (expecting explicit transaction start)" executing script from Delphi -

mongodb - How to keep track of users making Stripe Payments -