public override object Call(ExecutionContext GLOBAL, object t, JSObjectBase a, ExecutionContext x) { ExecutionContext newScope = x; newScope.parent = GLOBAL.currentContext; newScope.thisOb = thisOb; GLOBAL.currentContext = newScope; return(f.Call(GLOBAL, t, a, newScope)); }
int IComparer <object> .Compare(object a, object b) { if (a.Equals(b)) { return(0); } JSArray array = new JSArray(GLOBAL, new object[] { a, b }); double number = JSObject.ToNumber(GLOBAL, mSorter.Call(GLOBAL, GLOBAL.currentContext.thisOb, array, GLOBAL.currentContext)); return((int)number); }
public void TriggerEvent(object sender, EventArgs args) { object senderOb = JSObject.ToJS(GLOBAL, sender), argsOb = JSObject.ToJS(GLOBAL, args); JSArray argArray = new JSArray(GLOBAL, new object[] { senderOb, argsOb }); foreach (object ob in mHookedUp) { JSObjectBase obBase = ob as JSObjectBase; if (obBase != null) { obBase.Call(GLOBAL, ob, argArray, GLOBAL.currentContext); } } }
public object GetValue(ExecutionContext GLOBAL) { JSObjectBase getFun = mGetter as JSObjectBase; if (getFun != null) { return(getFun.Call(GLOBAL, mValue, new JSArray(GLOBAL), GLOBAL.currentContext)); } else if (mSetter != null) { return(JSUndefined.Undefined); } else { return(mValue); } }
public void SetValue(ExecutionContext GLOBAL, object value) { JSObjectBase setFun = mSetter as JSObjectBase; Trace.Assert(!(value is Reference)); if (mGetter != null && setFun == null) { return; } else if (setFun != null) { setFun.Call(GLOBAL, mValue, new JSArray(GLOBAL, new object[] { value }), GLOBAL.currentContext); } else if (!ReadOnly) { mValue = value; } }
internal object apply(bool callMe, JSObjectBase f, object t, JSObjectBase args, ExecutionContext x) { // Curse ECMA again! if (t == JSUndefined.Undefined || t == null) { t = x; } if (!(t is JSObjectBase)) { t = JSObject.ToObject(GLOBAL, t); } if (args == JSUndefined.Undefined || args == null) { args = new JSObject(); args.SetItem(GLOBAL, "length", new JSSimpleProperty("length", 0.0, false, false, true)); } else if (args is JSArray) { var vv = new JSObject(); int ii, jj; for (ii = 0, jj = (int)JSObject.ToNumber(GLOBAL, args.GetItem(GLOBAL, "length").GetValue(GLOBAL)); ii < jj; ii++) { vv.SetItem(GLOBAL, ii.ToString(), new JSSimpleProperty(ii.ToString(), args.GetItem(GLOBAL, ii.ToString()).GetValue(GLOBAL), false, false, true)); } vv.SetItem(GLOBAL, "length", new JSSimpleProperty("length", (double)ii, false, false, true)); args = vv; } if (callMe) { return(f.Call(GLOBAL, t, args, x)); } else { return(f.Construct(GLOBAL, args, x)); } }
internal object apply(bool callMe, JSObjectBase f, object t, JSObjectBase args, ExecutionContext x) { // Curse ECMA again! if (t == JSUndefined.Undefined || t == null) t = x; if (!(t is JSObjectBase)) t = JSObject.ToObject(GLOBAL, t); if (args == JSUndefined.Undefined || args == null) { args = new JSObject(); args.SetItem(GLOBAL, "length", new JSSimpleProperty("length", 0.0, false, false, true)); } else if (args is JSArray) { var vv = new JSObject(); int ii, jj; for (ii = 0, jj = (int)JSObject.ToNumber(GLOBAL, args.GetItem(GLOBAL, "length").GetValue(GLOBAL)); ii < jj; ii++) vv.SetItem(GLOBAL, ii.ToString(), new JSSimpleProperty(ii.ToString(), args.GetItem(GLOBAL, ii.ToString()).GetValue(GLOBAL), false, false, true)); vv.SetItem(GLOBAL, "length", new JSSimpleProperty("length", (double)ii, false, false, true)); args = vv; } if (callMe) return f.Call(GLOBAL, t, args, x); else return f.Construct(GLOBAL, args, x); }