Permalink
Browse files

Switch back to nme.Vector

The haxe.ds.Vector type has strict size limits, which is not ideal as an enforced type for all places where the Flash API uses Vectors. Instead, we can have a new nme.Vector type, which is lenient (allowing push(), shift(), etc) and can have new conversions to add extra convenience, like automatically converting arrays to vectors, only on Flash
  • Loading branch information...
1 parent ea90fc5 commit c41df3944f24c1fb8aa2d1bd209c36c08b335fea @jgranick jgranick committed Feb 25, 2013
@@ -18,7 +18,7 @@ import browser.geom.Point;
import browser.geom.Rectangle;
import browser.Html5Dom;
import browser.Lib;
-import haxe.ds.Vector;
+import nme.Vector;
class Graphics {
@@ -4,7 +4,7 @@ package browser.display;
import browser.display.IGraphicsData;
import browser.Html5Dom;
-import haxe.ds.Vector;
+import nme.Vector;
class GraphicsPath implements IGraphicsData #if !haxe3 , #end implements IGraphicsPath {
@@ -17,7 +17,7 @@ import browser.ui.Acceleration;
import browser.ui.Keyboard;
import browser.Html5Dom;
import browser.Lib;
-import haxe.ds.Vector;
+import nme.Vector;
#if stage3d
import browser.display.Stage3D;
@@ -16,7 +16,7 @@ import nme.gl.GLFramebuffer;
import nme.gl.GLProgram;
import nme.utils.ByteArray;
import nme.Lib;
-import haxe.ds.Vector;
+import nme.Vector;
class Context3D {
@@ -6,7 +6,7 @@ import nme.gl.GL;
import nme.gl.GLBuffer;
import nme.utils.Int16Array;
import nme.utils.ByteArray;
-import haxe.ds.Vector;
+import nme.Vector;
class IndexBuffer3D {
@@ -7,7 +7,7 @@ import nme.gl.GLBuffer;
import nme.utils.Float32Array;
import nme.utils.Float32Array;
import nme.utils.ByteArray;
-import haxe.ds.Vector;
+import nme.Vector;
class VertexBuffer3D {
@@ -6,7 +6,7 @@ import browser.display.BitmapData;
import browser.geom.Point;
import browser.geom.Rectangle;
import browser.Html5Dom;
-import haxe.ds.Vector;
+import nme.Vector;
class BlurFilter extends BitmapFilter {
@@ -3,7 +3,7 @@ package browser.geom;
import browser.Html5Dom;
-import haxe.ds.Vector;
+import nme.Vector;
class Matrix3D {
@@ -2,7 +2,7 @@ package browser.geom;
#if js
-import haxe.ds.Vector;
+import nme.Vector;
class Utils3D {
@@ -12,12 +12,12 @@ package flash.display;
function curveTo(controlX : Float, controlY : Float, anchorX : Float, anchorY : Float) : Void;
function drawCircle(x : Float, y : Float, radius : Float) : Void;
function drawEllipse(x : Float, y : Float, width : Float, height : Float) : Void;
- @:require(flash10) function drawGraphicsData(graphicsData : haxe.ds.Vector<IGraphicsData>) : Void;
- @:require(flash10) function drawPath(commands : haxe.ds.Vector<Int>, data : haxe.ds.Vector<Float>, ?winding : GraphicsPathWinding) : Void;
+ @:require(flash10) function drawGraphicsData(graphicsData : nme.Vector<IGraphicsData>) : Void;
+ @:require(flash10) function drawPath(commands : nme.Vector<Int>, data : nme.Vector<Float>, ?winding : GraphicsPathWinding) : Void;
function drawRect(x : Float, y : Float, width : Float, height : Float) : Void;
function drawRoundRect(x : Float, y : Float, width : Float, height : Float, ellipseWidth : Float, ?ellipseHeight : Float) : Void;
function drawRoundRectComplex(x : Float, y : Float, width : Float, height : Float, topLeftRadius : Float, topRightRadius : Float, bottomLeftRadius : Float, bottomRightRadius : Float) : Void;
- @:require(flash10) function drawTriangles(vertices : haxe.ds.Vector<Float>, ?indices : haxe.ds.Vector<Int>, ?uvtData : haxe.ds.Vector<Float>, ?culling : TriangleCulling) : Void;
+ @:require(flash10) function drawTriangles(vertices : nme.Vector<Float>, ?indices : nme.Vector<Int>, ?uvtData : nme.Vector<Float>, ?culling : TriangleCulling) : Void;
function endFill() : Void;
@:require(flash10) function lineBitmapStyle(bitmap : BitmapData, ?matrix : flash.geom.Matrix, repeat : Bool = true, smooth : Bool = false) : Void;
function lineGradientStyle(type : GradientType, colors : Array<UInt>, alphas : Array<Dynamic>, ratios : Array<Dynamic>, ?matrix : flash.geom.Matrix, ?spreadMethod : SpreadMethod, ?interpolationMethod : InterpolationMethod, focalPointRatio : Float = 0) : Void;
@@ -22,7 +22,7 @@ import native.Lib;
import native.media.SoundChannel;
import native.net.URLLoader;
import native.Loader;
-import haxe.ds.Vector;
+import nme.Vector;
class Stage extends DisplayObjectContainer
@@ -15,7 +15,7 @@ import nme.gl.GLFramebuffer;
import nme.gl.GLProgram;
import nme.utils.ByteArray;
import nme.Lib;
-import haxe.ds.Vector;
+import nme.Vector;
class Context3D
{
@@ -5,7 +5,7 @@ import nme.gl.GL;
import nme.gl.GLBuffer;
import nme.utils.Int16Array;
import nme.utils.ByteArray;
-import haxe.ds.Vector;
+import nme.Vector;
class IndexBuffer3D
{
@@ -5,7 +5,7 @@ import nme.gl.GL;
import nme.gl.GLBuffer;
import nme.utils.Float32Array;
import nme.utils.ByteArray;
-import haxe.ds.Vector;
+import nme.Vector;
class VertexBuffer3D
{
@@ -1,7 +1,7 @@
package native.geom;
#if (cpp || neko)
-import haxe.ds.Vector;
+import nme.Vector;
class Matrix3D
{
View
@@ -0,0 +1,23 @@
+package nme;
+
+
+#if flash
+private typedef VectorData<T> = flash.Vector<T>;
+#else
+private typedef VectorData<T> = Array<T>;
+#end
+
+
+@:arrayAccess abstract Vector<T>(VectorData<T>) {
+
+ @:from static public inline function fromArray(a:Array<T>) {
+
+ #if flash
+ return new flash.Vector<T> (a);
+ #else
+ return cast a;
+ #end
+
+ }
+
+}
@@ -4,7 +4,7 @@ package nme.display;
import nme.geom.Point;
import nme.geom.Rectangle;
-import haxe.ds.Vector;
+import nme.Vector;
/**
@@ -1,6 +1,6 @@
package nme.display3D.shaders.glsl;
-import haxe.ds.Vector;
+import nme.Vector;
import nme.display3D.textures.Texture;
import nme.geom.Matrix3D;
import nme.display3D.Context3D;
@@ -3,7 +3,7 @@ package nme.display3D.shaders.glsl;
import nme.utils.ByteArray;
import nme.display3D.Program3D;
-import haxe.ds.Vector;
+import nme.Vector;
import nme.display3D.textures.Texture;
import nme.display3D.Context3DVertexBufferFormat;
import nme.display3D.VertexBuffer3D;
@@ -131,11 +131,11 @@ class Sample extends Sprite
?tex:Array<Float>, ?cull:TriangleCulling, ? cols:Array<Int> )
{
#if flash
- var verts_v = new haxe.ds.Vector<Float>(verts.length);
+ var verts_v = new nme.Vector<Float>(verts.length);
for(i in 0...verts.length) verts_v[i] = verts[i];
- var indices_v = new haxe.ds.Vector<Int>(indices.length);
+ var indices_v = new nme.Vector<Int>(indices.length);
for(i in 0...indices.length) indices_v[i] = indices[i];
- var tex_v = new haxe.ds.Vector<Float>(tex.length);
+ var tex_v = new nme.Vector<Float>(tex.length);
for(i in 0...tex.length) tex_v[i] = tex[i];
inGfx.drawTriangles(verts_v, indices_v, tex_v, cull);
@@ -139,7 +139,7 @@ class Sample extends Sprite
// Create a combined array with destination at the bottom, and source at the
// top so with can so a single "select" call.
- var next = new haxe.ds.Vector<Int>();
+ var next = new nme.Vector<Int>();
next[pixels.length-1] = 0;

0 comments on commit c41df39

Please sign in to comment.