Example #1
0
 /// <summary> Create an array with a specified initial length.
 /// <p>
 /// </summary>
 /// <param name="scope">the scope to create the object in
 /// </param>
 /// <param name="length">the initial length (JavaScript arrays may have
 /// additional properties added dynamically).
 /// </param>
 /// <returns> the new array object
 /// </returns>
 public IScriptable NewArray(IScriptable scope, int length)
 {
     BuiltinArray result = new BuiltinArray (length);
     ScriptRuntime.setObjectProtoAndParent (result, scope);
     return result;
 }
Example #2
0
 /// <summary> Create an array with a set of initial elements.
 /// 
 /// </summary>
 /// <param name="scope">the scope to create the object in.
 /// </param>
 /// <param name="elements">the initial elements. Each object in this array
 /// must be an acceptable JavaScript type and type
 /// of array should be exactly Object[], not
 /// SomeObjectSubclass[].
 /// </param>
 /// <returns> the new array object.
 /// </returns>
 public IScriptable NewArray(IScriptable scope, object [] elements)
 {
     Type elementType = elements.GetType ().GetElementType ();
     if (elementType != typeof (object))
         throw new ArgumentException ();
     BuiltinArray result = new BuiltinArray (elements);
     ScriptRuntime.setObjectProtoAndParent (result, scope);
     return result;
 }
 internal static void Init (IScriptable scope, bool zealed)
 {
     BuiltinArray obj = new BuiltinArray ();
     obj.ExportAsJSClass (MAX_PROTOTYPE_ID, scope, zealed
         ,ScriptableObject.DONTENUM | ScriptableObject.READONLY | ScriptableObject.PERMANENT);
 }