예제 #1
0
 private void SetupDefaultPrototype()
 {
     BuiltinObject obj = new BuiltinObject ();
     obj.DefineProperty ("constructor", this, ScriptableObject.DONTENUM);
     // put the prototype property into the object now, then in the
     // wacky case of a user defining a function Object(), we don't
     // get an infinite loop trying to find the prototype.
     prototypeProperty = obj;
     IScriptable proto = GetObjectPrototype (this);
     if (proto != obj) {
         // not the one we just made, it must remain grounded
         obj.SetPrototype (proto);
     }
 }
예제 #2
0
 static void InitItObject(Context cx, ScriptableObject scope)
 {
     BuiltinObject itObj = new BuiltinObject ();
     itObj.SetPrototype (scope);
     itObj.DefineProperty ("color", Undefined.Value, ScriptableObject.PERMANENT);
     itObj.DefineProperty ("height", Undefined.Value, ScriptableObject.PERMANENT);
     itObj.DefineProperty ("width", Undefined.Value, ScriptableObject.PERMANENT);
     itObj.DefineProperty ("funny", Undefined.Value, ScriptableObject.PERMANENT);
     itObj.DefineProperty ("array", Undefined.Value, ScriptableObject.PERMANENT);
     itObj.DefineProperty ("rdonly", Undefined.Value, ScriptableObject.READONLY);
     scope.DefineProperty ("it", itObj, ScriptableObject.PERMANENT);
 }
예제 #3
0
 /// <summary> Creates new script object.
 /// The default implementation of {@link #construct} uses the method to
 /// to get the value for <tt>thisObj</tt> argument when invoking
 /// {@link #call}.
 /// The methos is allowed to return <tt>null</tt> to indicate that
 /// {@link #call} will create a new object itself. In this case
 /// {@link #construct} will set scope and prototype on the result
 /// {@link #call} unless they are already set.
 /// </summary>
 public virtual IScriptable CreateObject(Context cx, IScriptable scope)
 {
     IScriptable newInstance = new BuiltinObject ();
     newInstance.SetPrototype (GetClassPrototype ());
     newInstance.ParentScope = ParentScope;
     return newInstance;
 }