kswoll / WootzJs

C# to Javascript Compiler implemented via Roslyn
MIT License
110 stars 21 forks source link

Create Typed Arrays for C# Arrays #11

Closed Danielku15 closed 9 years ago

Danielku15 commented 9 years ago

It would be awesome if WootzJs automatically utilizes typed arrays if you declare C# arrays:

var byteArray = new byte[10];
var shortArray = new short[10];
...

JS:

var byteArray = new Uint8Array(10);
var shortArray = new Int16Array(10);
kswoll commented 9 years ago

I think this is a good idea. Seems like this would only apply to those types for which there are typed arrays:

kswoll commented 9 years ago

Ok, I've implemented all the basic types (ignoring Uint8ClampedArray). Creating new arrays for any of the numeric primitives (except decimal) will result in typed arrays. The built-in typed array javascript types have been instrumented in the same way as normal arrays so C# methods, etc. can be found and invoked.