Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

runtime: Add a native length property on AS3 Object and override it i…

…n subclasses.

This fixes code such as "Array.prototype.push.call({length: 3}, 2)" where the length property needs to be reflected to the underlying object length so that the JS native push function works.
  • Loading branch information...
commit 4d2482a90e4fb9b314620855e97f4021dd0b84c1 1 parent 66bf401
@mbebenita mbebenita authored
View
4 src/avm2/generated/builtin/Array.as
@@ -49,8 +49,8 @@ package
public static const NUMERIC:uint = 16;
// E262 {DontEnum, DontDelete}
- public native function get length():uint;
- public native function set length(newLength:uint);
+ public override native function get length():uint;
+ public override native function set length(newLength:uint);
[compat]
private function set_length(newLength:*, altLength:uint) {}
View
4 src/avm2/generated/builtin/ByteArray.as
@@ -105,8 +105,8 @@ package flash.utils
public native function readUTF():String;
public native function readUTFBytes(length:uint):String;
- public native function get length():uint;
- public native function set length(value:uint):void;
+ public override native function get length():uint;
+ public override native function set length(value:uint);
public native function writeObject(object:*):void;
public native function readObject():*;
View
2  src/avm2/generated/builtin/Function.as
@@ -51,7 +51,7 @@ package
public native function set prototype(p);
// E262 {DontEnum, DontDelete, ReadOnly}
- public native function get length():int;
+ public override native function get length():uint;
//[API(CONFIG::VM_INTERNAL)]
[compat]
View
4 src/avm2/generated/builtin/Object.as
@@ -43,6 +43,10 @@ package
[native(cls="ObjectClass")]
public dynamic class Object
{
+
+ public native function get length():uint;
+ public native function set length(newLength:uint);
+
// Object.length = 1 per ES3
// E262 {ReadOnly, DontDelete, DontEnum }
public static const length:int = 1;
View
2  src/avm2/generated/builtin/String.as
@@ -49,7 +49,7 @@ package
String.fromCharCode = unsafeJSNative("String.fromCharCode");
// E262 {DontEnum, DontDelete, ReadOnly}
- public native function get length():int;
+ public override native function get length():uint;
[compat]
private native function _indexOf(s:String, i:int=0):int;
View
4 src/avm2/generated/builtin/VectorImpl.as
@@ -38,8 +38,8 @@
// This file is the implementation of the common vector methods for each of the different vector classes.
// It is included in the body of the class of each of the different vector types.
-public native function get length():uint;
-public native function set length(value:uint);
+public override native function get length():uint;
+public override native function set length(value:uint);
public native function set fixed(f:Boolean);
public native function get fixed():Boolean;
View
BIN  src/avm2/generated/builtin/builtin.abc
Binary file not shown
View
3  src/avm2/native.js
@@ -164,6 +164,9 @@ const natives = (function () {
}
};
+ defineNonEnumerableProperty(Object.prototype, "get length", function() { return this.length; });
+ defineNonEnumerableProperty(Object.prototype, "set length", function(l) { this.length = l; });
+
c.dynamicPrototype = Object.prototype;
c.defaultValue = null;
return c;
Please sign in to comment.
Something went wrong with that request. Please try again.