예제 #1
0
        public BoolObject(ExecutionContext GLOBAL, bool val)
        {
            mValue = val;
            BooleanFun StaticBooleanFun = (BooleanFun)jsexec.GlobalOrNull(GLOBAL, "StaticBooleanFun");

            this.DefProp(GLOBAL, "prototype", StaticBooleanFun != null ? StaticBooleanFun.GetItem(GLOBAL, "prototype").GetValue(GLOBAL) : null, false, false, false);
            DefProp(GLOBAL, "constructor", StaticBooleanFun, false, false, false, true);
        }
예제 #2
0
        public jsexec()
        {
            GLOBAL.jobject = new JSObject();
            GLOBAL.jobject = GLOBAL.thisOb = new JSObject();

            StaticObjectFun = new ObjectFun(GLOBAL);
            GLOBAL.jobject.SetItem(GLOBAL, "StaticObjectFun", new JSSimpleProperty("StaticObjectFun", StaticObjectFun));
            StaticStringFun = new StringFun(GLOBAL);
            GLOBAL.jobject.SetItem(GLOBAL, "StaticStringFun", new JSSimpleProperty("StaticStringFun", StaticStringFun));
            StaticBooleanFun = new BooleanFun(GLOBAL);
            GLOBAL.jobject.SetItem(GLOBAL, "StaticBooleanFun", new JSSimpleProperty("StaticBooleanFun", StaticBooleanFun));
            StaticArrayFun = new ArrayFun(GLOBAL);
            GLOBAL.jobject.SetItem(GLOBAL, "StaticArrayFun", new JSSimpleProperty("StaticArrayFun", StaticArrayFun));
            StaticNumberFun = new NumberFun(GLOBAL);
            GLOBAL.jobject.SetItem(GLOBAL, "StaticNumberFun", new JSSimpleProperty("StaticNumberFun", StaticNumberFun));
            StaticFunctionFun = new FunctionFun(GLOBAL);
            GLOBAL.jobject.SetItem(GLOBAL, "StaticFunctionFun", new JSSimpleProperty("StaticFunctionFun", StaticFunctionFun));
            //StaticNumberObject = new NumberObject(GLOBAL, 0.0);
#if !JS_SLIM
            DatePrototype = new JSDate(GLOBAL);
            GLOBAL.jobject.SetItem(GLOBAL, "DatePrototype", new JSSimpleProperty("DatePrototype", DatePrototype));
            JSDate.SetupPrototype(GLOBAL, DatePrototype);
#endif

            GLOBAL.jobject.SetItem(GLOBAL, "toString", new JSNativeMethod(typeof(JSObject), "StaticToString"));

            /* Core types */
            JSObject thisOb = (JSObject)GLOBAL.thisOb;
            thisOb.DefProp(GLOBAL, "Object", StaticObjectFun);
            thisOb.DefProp(GLOBAL, "Function", StaticFunctionFun);
            thisOb.DefProp(GLOBAL, "Boolean", StaticBooleanFun);
            thisOb.DefProp(GLOBAL, "Number", StaticNumberFun);
            thisOb.DefProp(GLOBAL, "String", StaticStringFun);
            thisOb.DefProp(GLOBAL, "Array", StaticArrayFun);

            /* Types that work like classes */
#if !JS_SLIM
            thisOb.DefProp(GLOBAL, "Math", JSClassWrapper.RegisterClass(GLOBAL, typeof(pygmalion.JSMath)));
            thisOb.DefProp(GLOBAL, "Date", JSClassWrapper.RegisterClass(GLOBAL, typeof(pygmalion.JSDate)));
            thisOb.DefProp(GLOBAL, "Error", JSClassWrapper.RegisterClass(GLOBAL, typeof(pygmalion.JSError)));

            /* Standard library */
            thisOb.DefProp(GLOBAL, "decodeURI", new DecodeURIFun());
            thisOb.DefProp(GLOBAL, "decodeURIComponent", new DecodeURIComponentFun());
            thisOb.DefProp(GLOBAL, "encodeURI", new EncodeURIFun());
            thisOb.DefProp(GLOBAL, "encodeURIComponent", new EncodeURIComponentFun());
            thisOb.DefProp(GLOBAL, "escape", new EscapeFun());
#endif
            thisOb.DefProp(GLOBAL, "eval", new EvalFun());
            thisOb.DefProp(GLOBAL, "gc", new GcFun());
            thisOb.DefProp(GLOBAL, "Infinity", double.PositiveInfinity, false, false, false);
            thisOb.DefProp(GLOBAL, "isFinite", new isFiniteFun());
            thisOb.SetItem(GLOBAL, "isNaN", new JSNativeMethod(typeof(Double), "IsNaN"));
            thisOb.DefProp(GLOBAL, "parseFloat", new ParseFloat(), false, false, false);
            thisOb.DefProp(GLOBAL, "parseInt", new ParseInt(), false, false, false);
            thisOb.DefProp(GLOBAL, "NaN", double.NaN, false, false, false);
            thisOb.DefProp(GLOBAL, "unescape", new UnescapeFun());
            thisOb.DefProp(GLOBAL, "version", new VersionFun());

            GLOBAL.jobject.SetItem(GLOBAL, "JSExec", new JSSimpleProperty("JSExec", this));
            GLOBAL.thisOb         = GLOBAL.jobject;
            GLOBAL.currentContext = new ExecutionContext(GLOBAL);
            GLOBAL.scope          = GLOBAL.currentContext;
        }
예제 #3
0
        public jsexec()
        {
            GLOBAL.jobject = new JSObject();
            GLOBAL.jobject = GLOBAL.thisOb = new JSObject();

            StaticObjectFun = new ObjectFun(GLOBAL);
            GLOBAL.jobject.SetItem(GLOBAL, "StaticObjectFun", new JSSimpleProperty("StaticObjectFun", StaticObjectFun));
            StaticStringFun = new StringFun(GLOBAL);
            GLOBAL.jobject.SetItem(GLOBAL, "StaticStringFun", new JSSimpleProperty("StaticStringFun", StaticStringFun));
            StaticBooleanFun = new BooleanFun(GLOBAL);
            GLOBAL.jobject.SetItem(GLOBAL, "StaticBooleanFun", new JSSimpleProperty("StaticBooleanFun", StaticBooleanFun));
            StaticArrayFun = new ArrayFun(GLOBAL);
            GLOBAL.jobject.SetItem(GLOBAL, "StaticArrayFun", new JSSimpleProperty("StaticArrayFun", StaticArrayFun));
            StaticNumberFun = new NumberFun(GLOBAL);
            GLOBAL.jobject.SetItem(GLOBAL, "StaticNumberFun", new JSSimpleProperty("StaticNumberFun", StaticNumberFun));
            StaticFunctionFun = new FunctionFun(GLOBAL);
            GLOBAL.jobject.SetItem(GLOBAL, "StaticFunctionFun", new JSSimpleProperty("StaticFunctionFun", StaticFunctionFun));
            StaticNumberObject = new NumberObject(GLOBAL, 0.0);
            DatePrototype = new JSDate(GLOBAL);
            GLOBAL.jobject.SetItem(GLOBAL, "DatePrototype", new JSSimpleProperty("DatePrototype", DatePrototype));
            JSDate.SetupPrototype(GLOBAL, DatePrototype);

            GLOBAL.jobject.SetItem(GLOBAL, "toString", new JSNativeMethod(typeof(JSObject), "StaticToString"));

            /* Core types */
            JSObject thisOb = (JSObject)GLOBAL.thisOb;
            thisOb.DefProp(GLOBAL, "Object", StaticObjectFun);
            thisOb.DefProp(GLOBAL, "Function", StaticFunctionFun);
            thisOb.DefProp(GLOBAL, "Boolean", StaticBooleanFun);
            thisOb.DefProp(GLOBAL, "Number", StaticNumberFun);
            thisOb.DefProp(GLOBAL, "String", StaticStringFun);
            thisOb.DefProp(GLOBAL, "Array", StaticArrayFun);

            /* Types that work like classes */
            thisOb.DefProp(GLOBAL, "Math", JSClassWrapper.RegisterClass(GLOBAL, typeof(pygmalion.JSMath)));
            thisOb.DefProp(GLOBAL, "Date", JSClassWrapper.RegisterClass(GLOBAL, typeof(pygmalion.JSDate)));

            /* Standard library */
            thisOb.DefProp(GLOBAL, "decodeURI", new DecodeURIFun());
            thisOb.DefProp(GLOBAL, "decodeURIComponent", new DecodeURIComponentFun());
            thisOb.DefProp(GLOBAL, "encodeURI", new EncodeURIFun());
            thisOb.DefProp(GLOBAL, "encodeURIComponent", new EncodeURIComponentFun());
            thisOb.DefProp(GLOBAL, "escape", new EscapeFun());
            thisOb.DefProp(GLOBAL, "eval", new EvalFun());
            thisOb.DefProp(GLOBAL, "gc", new GcFun());
            thisOb.DefProp(GLOBAL, "Infinity", double.PositiveInfinity, false, false, false);
            thisOb.DefProp(GLOBAL, "isFinite", new isFiniteFun());
            thisOb.SetItem(GLOBAL, "isNaN", new JSNativeMethod(typeof(Double), "IsNaN"));
            thisOb.DefProp(GLOBAL, "parseFloat", new ParseFloat(), false, false, false);
            thisOb.DefProp(GLOBAL, "parseInt", new ParseInt(), false, false, false);
            thisOb.DefProp(GLOBAL, "NaN", double.NaN, false, false, false);
            thisOb.DefProp(GLOBAL, "unescape", new UnescapeFun());
            thisOb.DefProp(GLOBAL, "version", new VersionFun());

            GLOBAL.jobject.SetItem(GLOBAL, "JSExec", new JSSimpleProperty("JSExec", this));
            GLOBAL.thisOb = GLOBAL.jobject;
            GLOBAL.currentContext = new ExecutionContext(GLOBAL);
            GLOBAL.scope = GLOBAL.currentContext;
        }