コード例 #1
0
        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));
        }
コード例 #2
0
ファイル: jsarray.cs プロジェクト: mhoffesommer/pygmalion
            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);
            }
コード例 #3
0
ファイル: jsref.cs プロジェクト: mhoffesommer/pygmalion
        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);
                }
            }
        }
コード例 #4
0
ファイル: jsref.cs プロジェクト: mhoffesommer/pygmalion
        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);
            }
        }
コード例 #5
0
ファイル: jsref.cs プロジェクト: mhoffesommer/pygmalion
        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;
            }
        }
コード例 #6
0
ファイル: jsexec.cs プロジェクト: mhoffesommer/pygmalion
        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));
            }
        }
コード例 #7
0
ファイル: jsexec.cs プロジェクト: prozacchiwawa/pygmalion
        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);
        }