Beispiel #1
0
        public CFunc TranslateFunc(IDiaSymbol sym)
        {
            CType retType = Translate(sym.type);
            CFunc res     = new CFunc(retType, TranslateCallConv(sym.callingConvention));

            IDiaEnumSymbols syms;

            sym.findChildren(SymTagEnum.SymTagFunctionArgType, null, 0, out syms);

            if (syms.count == 0)
            {
                res.Add(PrimTypes.VOID);
                return(res);
            }
            else if (syms.count == 1)
            {
                IDiaSymbol only = syms.Item(0).type;
                if ((SymTagEnum)only.symTag == SymTagEnum.SymTagBaseType &&
                    (BaseTypeEnum)only.baseType == BaseTypeEnum.btNoType)
                {
                    return(res);
                }
            }

            foreach (IDiaSymbol argSym in syms)
            {
                CType argType = Translate(argSym.type);
                res.Add(argType);
            }
            return(res);
        }
Beispiel #2
0
        public void RegFunc(CFunc func, string name)
        {
            var nfunc = new SynFunc(name);

            nfunc.RealCode = func;
            RegFunc(nfunc);
        }
Beispiel #3
0
 public void Push(GLua GLua, object obj)
 {
     if (obj is Delegate dele)
     {
         CFunc cfunc = (IntPtr L) => {
             List <object> args = new List <object>();
             foreach (var param in dele.Method.GetParameters())
             {
                 args.Add(GLua.Get(param.ParameterType, param.Position + 1));
             }
             var rtn = dele.DynamicInvoke(args.ToArray());
             if (rtn != null)
             {
                 GLua.Push(rtn, rtn.GetType());
                 return(1);
             }
             return(0);
         };
         GCHandle gch = GCHandle.Alloc(cfunc);
         GLua.AddLuaReference(gch);
         GLua.PushCFunction(cfunc);
     }
     else
     {
         throw new Exception("wrapper func must be castable to delegate");
     }
 }
 /// <summary>
 /// Measuring execution time and returns it in milliseconds
 /// </summary>
 /// <param name="fnc"></param>
 /// <returns></returns>
 public static double DoCheck( CFunc fnc )
 {
     var begin_time = DateTime.Now;
     fnc();
     var delta_time = DateTime.Now - begin_time;
     return delta_time.TotalMilliseconds;
 }
Beispiel #5
0
        private static void TestLIBC()
        {
            string libc = "msvcrt.dll";

            var printf = new CFunc(libc, "printf");

            printf.callInt("via [msvcrt.dll] printf();\r\n");
        }
Beispiel #6
0
        public void VisitFunc(CFunc func)
        {
            string letter = object.ReferenceEquals(func.CallConv, CallConvs.Default)
                ? "f"
                : "F";

            _val = " " + letter + " " + _maker.AddFunc(func) + _val;
        }
Beispiel #7
0
        void Example_Checking_IsDone()
        {
            SetNewTest("This test shows how you can use the IsDone property to check if a coroutine is complete");
            CFunc coroutine = new CFunc(CoroutineWithError());

            StartCoroutine(coroutine);
            _coroutineFunction = coroutine;
        }
 public void ReturnsCoroutineInOrderAdded()
 {
     ICFunc[] cwArray = new CFunc[10];
     for (int i = 0; i < cwArray.Length; i++)
     {
         cwArray[i] = runnerUnderTest.Start(RoutineYieldNull());
     }
     for (int i = 0; i < cwArray.Length; i++)
     {
         Assert.AreSame(cwArray[i], runnerUnderTest[i]);
     }
 }
Beispiel #9
0
        /// <summary>
        /// 绘制砂轮图
        /// </summary>
        public override void Draw(Graphics g, Point p0)
        {
            Console.WriteLine("调用CW3型砂轮绘图。");

            Pen p = new Pen(Color.Black, 1f);

            p.DashStyle = DashStyle.DashDot;

            //CDraw.SetCoordinate(g, p0);                 // 设置坐标

            p.Color     = Color.Blue;
            p.DashStyle = DashStyle.Solid;
            Point p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14;

            p1  = new Point(base.StartPos, (int)radiusS);
            p2  = new Point(base.StartPos, -(int)radiusS);
            p3  = new Point(base.StartPos + (int)mainThickness, (int)(mainThickness * CFunc.Tan(ang) + radiusS));
            p4  = new Point(base.StartPos + (int)mainThickness, -(int)(mainThickness * CFunc.Tan(ang) + radiusS));
            p5  = new Point(p3.X, (int)base.Radius);
            p6  = new Point(p3.X, -(int)base.Radius);
            p7  = new Point(base.StartPos + (int)base.Thickness, (int)base.Radius);
            p8  = new Point(base.StartPos + (int)base.Thickness, -(int)base.Radius);
            p9  = new Point(base.StartPos + (int)edgeThickness, (int)radiusI);
            p10 = new Point(base.StartPos + (int)edgeThickness, -(int)radiusI);
            p11 = new Point(p3.X, (int)((mainThickness - edgeThickness) * CFunc.Tan(ang) + radiusI));
            p12 = new Point(p3.X, -(int)((mainThickness - edgeThickness) * CFunc.Tan(ang) + radiusI));
            p13 = new Point(base.StartPos + (int)base.Thickness, p11.Y);
            p14 = new Point(base.StartPos + (int)base.Thickness, p12.Y);

            EndPos = p13.X;

            g.DrawLine(p, p1, p3);
            g.DrawLine(p, p3, p5);
            g.DrawLine(p, p5, p7);
            //g.DrawLine(p, p5, p11);
            g.DrawLine(p, p7, p13);
            g.DrawLine(p, p11, p13);

            g.DrawLine(p, p2, p4);
            g.DrawLine(p, p4, p6);
            g.DrawLine(p, p6, p8);
            //g.DrawLine(p, p6, p12);
            g.DrawLine(p, p8, p14);
            g.DrawLine(p, p12, p14);

            g.DrawLine(p, p1, p2);
            g.DrawLine(p, p9, p10);
            g.DrawLine(p, p9, p11);
            g.DrawLine(p, p10, p12);
        }
        public void IteratesCoroutinesInOrderAdded()
        {
            ICFunc[] cwArray = new CFunc[10];
            for (int i = 0; i < cwArray.Length; i++)
            {
                cwArray[i] = runnerUnderTest.Start(RoutineYieldNull());
            }
            int index = 0;

            foreach (CFunc cw in runnerUnderTest)
            {
                Assert.AreSame(cwArray[index++], cw);
            }
        }
Beispiel #11
0
    private void Awake()
    {
        // if the singleton hasn't been initialized yet
        if (instance != null && instance != this)
        {
            Destroy(this.gameObject);
        }

        instance = this;
        DontDestroyOnLoad(this.gameObject);

        Reference();
        SymbolLoader.instance.Initialise();
        CFunc.LoadScore();
    }
Beispiel #12
0
        internal int AddFunc(CFunc func)
        {
            int        curNum = ++_funcNum;
            XmlElement entry  = MakeElem("func");

            AddAttr(entry, "id", curNum);
            foreach (CType argType in func.Args)
            {
                XmlElement arg = MakeElem("arg");
                AddTypeBasicAttrs(arg, argType, true);
                AddChild(entry, arg);
            }
            AddChild(_args, entry);
            return(curNum);
        }
Beispiel #13
0
        private string LoadJson()
        {
            try
            {
                StringBuilder sb = new StringBuilder();

                System.Web.Script.Serialization.JavaScriptSerializer js = new System.Web.Script.Serialization.JavaScriptSerializer();

                sb.Append("\"DeleteFlag\":\"" + (DeleteFlag == null ? "" : DeleteFlag.NAME) + "\"");
                sb.Append(",");
                sb.Append("\"IsReadable\":" + IsReadable.ToString().ToLower() + "");
                sb.Append(",");
                sb.Append("\"IsCreatable\":" + IsCreatable.ToString().ToLower() + "");
                sb.Append(",");
                sb.Append("\"IsEditable\":" + IsEditable.ToString().ToLower() + "");
                sb.Append(",");
                sb.Append("\"IsDeletable\":" + IsDeletable.ToString().ToLower() + "");
                sb.Append(",");
                string fEntityKeys = "{" + (FirstEntityKeys.Any() ? FirstEntityKeys.Select(x => "\"" + x.Key + "\":" + js.Serialize(x.Value)).Aggregate((a, b) => a + "," + b) : "") + "}";
                sb.Append("\"FirstEntity\":" + fEntityKeys);

                string baseJson = base.Json;

                baseJson = baseJson.Replace(("\"SecurityZone\":\"" + base.SecurityZone + "\""), ("\"SecurityZone\":\"" + SecurityZone + "\""));

                sb.Append(string.IsNullOrEmpty(baseJson) ? "" : ("," + baseJson));

                sb.Append(",\"AVAILABLE_FORMATS\":[");
                if (AVAILABLE_FORMATS != null && AVAILABLE_FORMATS.Any())
                {
                    sb.Append(AVAILABLE_FORMATS.Select(x => "{" + x.Json + "}").Aggregate((a, b) => a + "," + b));
                }
                sb.Append("]");
                return(sb.ToString());
            }
            catch (Exception e) { WSStatus status = WSStatusBase.NONE.clone(); CFunc.RegError(GetType(), e, ref status); }

            return(string.Empty);
        }
Beispiel #14
0
    IEnumerator CheckSelectedSpin()
    {
        bool tResult = false;

        if (((EUtil.Symbol)randNUmList[currentIndex]).ToString() == popupList.value)
        {
            tResult = true;            //			Debug.Log("SUCCESS");
            CFunc.successCount++;
        }
        else
        {
            tResult = false;             //Debug.Log("FAILED");
            CFunc.failedCount++;
        }


        CFunc.SaveScore();
        yield return(new WaitForSeconds(0.7f));

        UIResult.SetActive(true, tResult);
        UIGame.SetActive(false);
    }
Beispiel #15
0
        public void PushCFunction(CFunc val)
        {
            IntPtr ptr = Marshal.GetFunctionPointerForDelegate(val);

            this.LuaBase.PushCFunction(ptr);
        }
Beispiel #16
0
        public new void ReadXmlAttributes(XmlReader reader)
        {
            base.ReadXmlAttributes(reader);

            #region DeleteFlag
            string _DeleteFlag = reader["deleteFlag"];
            if (!string.IsNullOrEmpty(_DeleteFlag) && GetXParam(_DeleteFlag) != null)
            {
                DeleteFlag = (WSTableParam)GetXParam(_DeleteFlag);
            }
            #endregion

            #region IsReadableBySchema
            string _AttrIsReadableBySchema = reader["readable"];
            if (!string.IsNullOrEmpty(_AttrIsReadableBySchema))
            {
                if (_AttrIsReadableBySchema.IsTrue() || _AttrIsReadableBySchema.IsFalse())
                {
                    _IsReadableBySchema = _AttrIsReadableBySchema.IsTrue();
                }
                else
                {
                    _IsReadableBySchema = true;
                    ReadableFilter      = _AttrIsReadableBySchema.ToJson();
                }
            }
            #endregion

            #region IsCreatableBySchema
            string _AttrIsCreatableBySchema = reader["creatable"];
            if (!string.IsNullOrEmpty(_AttrIsCreatableBySchema))
            {
                if (_AttrIsCreatableBySchema.IsTrue() || _AttrIsCreatableBySchema.IsFalse())
                {
                    _IsCreatableBySchema = _AttrIsCreatableBySchema.IsTrue();
                }
                else
                {
                    _IsCreatableBySchema = true;
                    CreatableFilter      = _AttrIsCreatableBySchema.ToJson();
                }
            }
            #endregion

            #region IsEditableBySchema
            string _AttrIsEditableBySchema = reader["editable"];
            if (!string.IsNullOrEmpty(_AttrIsEditableBySchema))
            {
                if (_AttrIsEditableBySchema.IsTrue() || _AttrIsEditableBySchema.IsFalse())
                {
                    _IsEditableBySchema = _AttrIsEditableBySchema.IsTrue();
                }
                else
                {
                    _IsEditableBySchema = true;
                    EditableFilter      = _AttrIsEditableBySchema.ToJson();
                }
            }
            #endregion

            #region IsDeletableBySchema
            string _AttrIsDeletableBySchema = reader["deletable"];
            if (!string.IsNullOrEmpty(_AttrIsDeletableBySchema))
            {
                if (_AttrIsDeletableBySchema.IsTrue() || _AttrIsDeletableBySchema.IsFalse())
                {
                    _IsDeletableBySchema = _AttrIsDeletableBySchema.IsTrue();
                }
                else
                {
                    _IsDeletableBySchema = true;
                    DeletableFilter      = _AttrIsDeletableBySchema.ToJson();
                }
            }
            #endregion

            #region AllowOwnerAccess
            string  _AllowOwnerAccess  = reader["allowOwnerAccess"];
            dynamic _dAllowOwnerAccess = AllowOwnerAccess;
            if (!string.IsNullOrEmpty(_AllowOwnerAccess) && typeof(bool).Read(_AllowOwnerAccess, out _dAllowOwnerAccess))
            {
                AllowOwnerAccess = _dAllowOwnerAccess;
            }
            #endregion

            #region BaseFilter
            try
            {
                string _BaseFilterValue = reader["baseFilter"];
                if (!string.IsNullOrEmpty(_BaseFilterValue))
                {
                    BaseFilter = _BaseFilterValue.ToJson();
                }
            }
            catch (Exception e) { WSStatus status = WSStatusBase.NONE.clone(); CFunc.RegError(GetType(), e, ref status); }

            #endregion
        }
Beispiel #17
0
        public void RegisterFuncs()
        {
            CFunc cf_printf = (pars) =>
            {
                foreach (var p in pars)
                {
                    Console.WriteLine(p);
                }
                return(null);
            };

            GlobalScope.RegFunc(cf_printf, "printf");


            CFunc cf_playsong = (pars) =>
            {
                Console.WriteLine("Playing song:" + pars[0]);

                Vivid.Audio.Songs.PlaySong(pars[0]);

                return(null);
            };

            GlobalScope.RegFunc(cf_playsong, "playsong");

            CFunc cf_loadImg = (pars) =>
            {
                var img = new Texture.Texture2D(pars[0], Texture.LoadMethod.Single, true);

                return(img);
            };

            GlobalScope.RegFunc(cf_loadImg, "loadImg");

            CFunc cf_drawImg = (pars) =>
            {
                Draw.IntelliDraw.BeginDraw();
                Draw.IntelliDraw.DrawImg(pars[1], pars[2], pars[3], pars[4], pars[0], new OpenTK.Vector4(1, 1, 1, 1));
                Draw.IntelliDraw.EndDraw();
                return(null);
            };

            GlobalScope.RegFunc(cf_drawImg, "drawImg");

            CFunc cf_drawImgCentered = (pars) =>
            {
                int cx = App.AppInfo.RW / 2;
                int cy = App.AppInfo.RH / 2;

                Draw.IntelliDraw.BeginDraw();
                Draw.IntelliDraw.DrawImg(cx - pars[1] / 2, cy - pars[2] / 2, pars[1], pars[2], pars[0], new OpenTK.Vector4(1, 1, 1, pars[3]));
                Draw.IntelliDraw.EndDraw();


                return(null);
            };

            GlobalScope.RegFunc(cf_drawImgCentered, "drawImgCentered");


            CFunc cf_getTicks = (pars) =>
            {
                int tick = Environment.TickCount;
                return(tick);
            };


            GlobalScope.RegFunc(cf_getTicks, "getTicks");

            CFunc cf_rndInt = (pars) =>
            {
                return(rnd.Next(pars[0], pars[1]));
            };

            GlobalScope.RegFunc(cf_rndInt, "rndInt");

            CFunc cf_rnd = (pars) =>
            {
                float rv = (float)rnd.NextDouble();

                float r2 = pars[1] - pars[0];

                r2 = r2 * rv + pars[0];

                return(r2);
            };

            GlobalScope.RegFunc(cf_rnd, "rnd");

            CFunc cf_beginDraw = (pars) =>
            {
                Draw.IntelliDraw.BeginDraw();
                return(null);
            };

            GlobalScope.RegFunc(cf_beginDraw, "beginDraw");

            CFunc cf_endDraw = (pars) =>
            {
                Draw.IntelliDraw.EndDraw();
                return(null);
            };

            GlobalScope.RegFunc(cf_endDraw, "endDraw");

            CFunc cf_drawRect = (pars) =>
            {
                if (whiteTex == null)
                {
                    whiteTex = new Texture.Texture2D("syn/data/whiteTex.png", Texture.LoadMethod.Single, false);
                }



                Draw.IntelliDraw.DrawImg((int)pars[0], (int)pars[1], (int)pars[2], (int)pars[3], whiteTex, new OpenTK.Vector4(1, 1, 1, 1));


                return(null);
            };

            GlobalScope.RegFunc(cf_drawRect, "drawRect");
        }
Beispiel #18
0
 public CFunc(CFunc other)
 {
     _permissionLevel = other._permissionLevel;
     _isCheat         = other._isCheat;
     _isServer        = other._isServer;
 }