← Back to team overview

leaningtech-dev team mailing list archive

Re: [Question #249804]: How to operate on TypedArray in C++

 

Question #249804 on Duetto changed:
https://answers.launchpad.net/duetto/+question/249804

    Status: Open => Answered

Alessandro Pignotti proposed the following answer:
Hi Ben,

there is no specific API at the moment to do a copy-less conversion,
although we have plan to add it soon. In duetto 0.9.6 and the upcoming
1.0 release you can use the following hack to access a typed array like
a plain pointer:

        Int8Array* ar=new Int8Array(4);
        char* volatile c=(char*)(Array*)ar;
        c[2] = 42;

Please be careful in using the right C data type for any given typed
array to guarantee correct results. The apparently useless double cast
is necessary. Again, we plan to add a cleaner solution in future, but
this should work and no copy is made.

-- 
You received this question notification because you are a member of
Leaningtech Team, which is an answer contact for Duetto.