NativeScript / android

NativeScript for Android using v8
https://docs.nativescript.org/guide/android-marshalling
Apache License 2.0
523 stars 134 forks source link

feat: support passing typedArrays as nio buffers #1678

Closed triniwiz closed 2 years ago

triniwiz commented 2 years ago

We can now pass a typedarray over to the platform w/o recreating the data these are passed as directBuffers ..... so 🤷🏽‍♂️

.eg

const myData = new Float32Array(4);
console.log(Array.from(myData)); /// quick way to the values; prints [0,0,0,0]
io.github.triniwiz.buffer.Buffer.update(myData);
console.log(Array.from(myData)); /// quick way to the values; prints [1,2,3,4];
package io.github.triniwiz.buffer;
import java.nio.FloatBuffer;
public class Buffer {
 public static void update(FloatBuffer buffer){
  buffer.put(new float[]{1,2,3,4});
 }
}