Exemple #1
0
        private static void Test1(DWSContext context)
        {
            var t = new DWSTypeDefinition("TPoint");

            t.Fields.Add(new DWSFieldDefinition("x", "Integer"));
            t.Fields.Add(new DWSFieldDefinition("y", "Integer"));


            var m = new DWSMethodDefinition("ReturnFirstArg", (c, a) =>
            {
                var v = c.CreateTypedValue("TPoint");

                object o = v.Value;
                v["x"]   = 10;
                return(v);
            });

            m.Args.Add(new DWSParameterDefinition("a", "Integer"));
            m.ReturnTypeName = "TPoint";

            context.DefineType(t);
            context.DefineMethod(m);
            string s = context.EvaluateScript("var t : TPoint = ReturnFirstArg(2); ReturnFirstArg(t.x);");

            GC.KeepAlive(m);
        }
Exemple #2
0
        private static void Test3(DWSContext context)
        {
            var a = new DWSArrayDefinition("TIntArray", "Integer");

            context.DefineType(a);
            var method = new DWSMethodDefinition("CreateArrayTest", new NativeAction(CreteArrayTest));

            context.DefineMethod(method);
            context.EvaluateScript("CreateArrayTest();");

            GC.KeepAlive(method);
        }
Exemple #3
0
        private static void Test4(DWSContext context)
        {
            var a = new DWSEnumDefinition("TEnum");

            a.Add("ENUM_VALUE1", 0);
            a.Add("ENUM_VALUE2", 1);
            a.Add("ENUM_VALUE3", 2);
            context.DefineType(a);

            var method = new DWSMethodDefinition("CreateArrayTest", new NativeAction((cx, args) =>
            {
                var v  = new DWSElement(args[0]);
                bool s = false;
            }));

            method.Args.Add(new DWSParameterDefinition("a", "TEnum")
            {
                DefaultValue = "ENUM_VALUE3"
            });
            context.DefineMethod(method);
            context.EvaluateScript("CreateArrayTest();");

            GC.KeepAlive(method);
        }