コード例 #1
0
ファイル: SpObject.cs プロジェクト: ZhHong/sproto-cs
	public void Append (SpObject obj) {
		if (IsTable () == false) {
			mType = ArgType.Table;
			mValue = new Dictionary<object, SpObject> ();
		}
		Insert (AsTable ().Count, obj);
	}
コード例 #2
0
ファイル: NotifyArgs.cs プロジェクト: smartboyathome/Haxxit
 // Constructor
 public NotifyArgs(string newEventItem, object newObjectItem, EventArgs newEventArgsItem, ArgType newArgsType)
 {
     eventItem = newEventItem;
     objectItem = newObjectItem;
     eventArgsItem = newEventArgsItem;
     argsType = newArgsType;
 }
コード例 #3
0
ファイル: SpObject.cs プロジェクト: ZhHong/sproto-cs
	public void Insert (object key, SpObject obj) {
        if (IsTable () == false) {
            mType = ArgType.Table;
			mValue = new Dictionary<object, SpObject> ();
        }
        AsTable ()[key] = obj;
	}
コード例 #4
0
 public Parameter(int lineNum, int colNum, int charIndex, VariableDeclaration varDec, ArgType argType)
     : base(lineNum, colNum, charIndex)
 {
     this.TypeMark = varDec.TypeMark;
     this.VariableName = varDec.VariableName;
     this.ArraySize = varDec.ArraySize;
     Type = argType;
 }
コード例 #5
0
        public void Insert(object key, SpObject obj)
        {
            if (IsTable() == false)
            {
                mType  = ArgType.Table;
                mValue = new Dictionary <object, SpObject>();
            }

            AsTable()[key] = obj;
        }
コード例 #6
0
ファイル: AzmiArgument.cs プロジェクト: mmillerxyz/azmitool
 // constructor NAME + DESCRIPTION
 internal AzmiArgument(string name, [DisallowNull] string description,
                       ArgType type = ArgType.str, bool required = false)
     : this(
         name,
         name[0],
         description,
         required,
         type)
 {
 }
コード例 #7
0
ファイル: AzmiArgument.cs プロジェクト: mmillerxyz/azmitool
 // constructor NAME + ALIAS? + DESCRIPTION
 internal AzmiArgument(string name, char?alias, string description,
                       ArgType type = ArgType.str, bool required = false)
     : this(
         name,
         alias,
         description,
         required,
         type)
 {
 }
コード例 #8
0
ファイル: AzmiArgument.cs プロジェクト: mmillerxyz/azmitool
 // constructor NAME with one string
 internal AzmiArgument(string name,
                       ArgType type = ArgType.str, bool required = false)
     : this(
         name,
         name[0],
         $"Description for {name}",
         required,
         type)
 {
 }
コード例 #9
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = (Key != null ? Key.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (ArgType != null ? ArgType.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ Position;
         return(hashCode);
     }
 }
コード例 #10
0
        public void Append(SpObject obj)
        {
            if (IsTable() == false)
            {
                mType  = ArgType.Table;
                mValue = new Dictionary <object, SpObject>();
            }

            Insert(AsTable().Count, obj);
        }
コード例 #11
0
ファイル: AzmiArgument.cs プロジェクト: urtabajev/azmitool
 // constructor NAME with one string
 internal AzmiArgument(string name,
                       ArgType type = defaultType, bool required = defaultRequired, bool multiValued = defaultMultiValued)
     : this(
         name,
         name[0],
         $"Description for {name}",
         required,
         type,
         multiValued)
 {
 }
コード例 #12
0
ファイル: AzmiArgument.cs プロジェクト: urtabajev/azmitool
 // constructor NAME + ALIAS? + DESCRIPTION
 internal AzmiArgument(string name, char?alias, string description,
                       ArgType type = defaultType, bool required = defaultRequired, bool multiValued = defaultMultiValued)
     : this(
         name,
         alias,
         description,
         required,
         type,
         multiValued)
 {
 }
コード例 #13
0
                                public static @string GoString(this ArgType t)
                                {
                                    var s = t.String();

                                    if (t > 0L && t < TypeLast)
                                    {
                                        return("Type" + s);
                                    }

                                    return(s);
                                }
コード例 #14
0
ファイル: AzmiArgument.cs プロジェクト: urtabajev/azmitool
 // constructor NAME + DESCRIPTION
 internal AzmiArgument(string name, [DisallowNull] string description,
                       ArgType type = defaultType, bool required = defaultRequired, bool multiValued = defaultMultiValued)
     : this(
         name,
         name[0],
         description,
         required,
         type,
         multiValued)
 {
 }
コード例 #15
0
ファイル: Win32API.cs プロジェクト: jschementi/iron
        private Win32API/*!*/ Reinitialize(IntPtr function, ArgType[] signature, ArgType returnType) {
            if (IntPtr.Size != 4) {
                throw new NotSupportedException("Win32API is not supported in 64-bit process");
            }

            Debug.Assert(function != IntPtr.Zero && signature != null);
            _function = function;
            _signature = signature;
            _returnType = returnType;
            _version = Interlocked.Increment(ref _Version);
            return this;
        }
コード例 #16
0
ファイル: Win32API.cs プロジェクト: yyyyj/ironruby
        private static Type /*!*/ ToNativeType(ArgType argType)
        {
            switch (argType)
            {
            case ArgType.Buffer: return(typeof(byte[]));

            case ArgType.Int32: return(typeof(int));

            case ArgType.None: return(typeof(void));
            }
            throw Assert.Unreachable;
        }
コード例 #17
0
        public static object MatchArgToType(Character self, string arg, ArgType type)
        {
            object result;

            int nresult;

            if (type.HasFlag(ArgType.Int) &&
                int.TryParse(arg, out nresult))
            {
                return(nresult);
            }

            if (type.HasFlag(ArgType.String))
            {
                return(arg);
            }

            if (type.HasFlag(ArgType.ObjEq) &&
                (result = self.Eq.Items.ToList().Find(obj => obj.MatchNames(arg))) != null)
            {
                return(result);
            }

            if (type.HasFlag(ArgType.ObjInv) &&
                (result = self.Inventory.Find(obj => obj.MatchNames(arg))) != null)
            {
                return(result);
            }

            if (type.HasFlag(ArgType.ObjRoom) &&
                (result = self.Room.Items.Find(obj => obj.MatchNames(arg))) != null)
            {
                return(result);
            }

            if (type.HasFlag(ArgType.ChRoom) &&
                (result = self.Room.Characters.Find(vch => vch.MatchNames(arg))) != null)
            {
                return(result);
            }

            if (type.HasFlag(ArgType.ExitRoom) &&
                (result = self.Room.Exits[arg]) != null)
            {
                return(result);
            }

            /*if( type.HasFlag( ArgType.ChWorld )
             *  && ( result = World.ActivePlayers.Find(
             *      player => player.Model.ShortDescr.StartsWith( arg, StringComparison.CurrentCultureIgnoreCase ) ) ) != null )
             *  return result;*/// TODO fix
            return(null);
        }
コード例 #18
0
ファイル: NodeWindow.cs プロジェクト: kazu0928/StateEditor
        private void SetArgument(ref Argument sop, ref ArgType argType, ParameterInfo[] infos, int paramNum, int wid)
        {
            //インスタンスがObject型に変換可能であれば引数に代入し、引数のTypeを決める
            if (infos[paramNum].ParameterType.IsSubclassOf(typeof(UnityEngine.Object)))
            {
                GUILayout.Label("Object");
                sop.object_Arg = (UnityEngine.Object)EditorGUILayout.ObjectField(sop.object_Arg, infos[paramNum].ParameterType, true, GUILayout.Width(wid));
                argType        = ArgType.UnityObject;
            }
            //int型
            else if (infos[paramNum].ParameterType == typeof(int))
            {
                GUILayout.Label("int");
                sop.int_Arg = EditorGUILayout.IntField(sop.int_Arg, GUILayout.Width(wid));
                argType     = ArgType.Int;
            }
            //string型
            else if (infos[paramNum].ParameterType == typeof(string))
            {
                GUILayout.Label("string");
                sop.string_Arg = EditorGUILayout.TextField(sop.string_Arg, GUILayout.Width(wid - 20));
                argType        = ArgType.String;
            }
            //float型
            else if (infos[paramNum].ParameterType == typeof(float))
            {
                GUILayout.Label("float");
                sop.float_Arg = EditorGUILayout.FloatField(sop.float_Arg, GUILayout.Width(wid));
                argType       = ArgType.Float;
            }
            //bool型
            else if (infos[paramNum].ParameterType == typeof(bool))
            {
                GUILayout.Label("bool");
                sop.bool_Arg = EditorGUILayout.Toggle(sop.bool_Arg, GUILayout.Width(wid));
                argType      = ArgType.Bool;
            }
            else if (infos[paramNum].ParameterType.IsEnum)
            {
                GUILayout.Label("Enum");

                Enum em = (Enum)infos[paramNum].ParameterType.GetField(Enum.GetName(infos[paramNum].ParameterType, sop.enum_Arg)).GetValue(null);
                em                = EditorGUILayout.EnumPopup(em);
                sop.enum_Arg      = em.GetHashCode();
                sop.enum_Name     = infos[paramNum].ParameterType.FullName;
                sop.assembly_Name = infos[paramNum].ParameterType.Assembly.FullName;
                argType           = ArgType.Enum;
            }
            else
            {
                GUILayout.Label("未対応の引数です、エラーが起こります");
            }
        }
コード例 #19
0
 public CodeArg(string src)
 {
     if (src.StartsWith("\""))
     {
         _ArgType = ArgType.TEXT;
         _Value   = TextUtil.unescapeText(src);
     }
     else
     {
         _ArgType = ArgType.ENUM;
         _Value   = src;
     }
 }
コード例 #20
0
 public Argument(Argument otherArg)
 {
     Type = otherArg.Type;
     Name = otherArg.Name;
     Init();
     if (otherArg.Arguments == null || otherArg.Arguments.Count <= 0)
     {
         return;
     }
     foreach (var arg in otherArg.Arguments)
     {
         Arguments.Add(new Argument(arg));
     }
 }
コード例 #21
0
ファイル: Win32API.cs プロジェクト: yyyyj/ironruby
        private Win32API /*!*/ Reinitialize(IntPtr function, ArgType[] signature, ArgType returnType)
        {
            if (IntPtr.Size != 4)
            {
                throw new NotSupportedException("Win32API is not supported in 64-bit process");
            }

            Debug.Assert(function != IntPtr.Zero && signature != null);
            _function   = function;
            _signature  = signature;
            _returnType = returnType;
            _version    = Interlocked.Increment(ref _Version);
            return(this);
        }
コード例 #22
0
        static void Main(string[] args)
        {
            try
            {
                //assume the first arg to be the input file
                currentArgType = ArgType.Action;

                //then look for other args
                for (int index = 0; index < args.Length; index++)
                {
                    if (args[index].StartsWith("-")) //an attribute
                    {
                        if (args[index] == "--action" || args[index] == "-a")
                        {
                            currentArgType = ArgType.Action;
                        }
                        else if (args[index] == "--data" || args[index] == "-d")
                        {
                            currentArgType = ArgType.Data;
                        }
                    }
                    else //a value
                    {
                        commandLineArgs.Add(currentArgType, args[index]);
                    }
                }

                if (commandLineArgs[ArgType.Action] == "add-activity")
                {
                    AddActivity(commandLineArgs[ArgType.Data]);
                }
                else if (commandLineArgs[ArgType.Action] == "enroll")
                {
                    Enroll(commandLineArgs[ArgType.Data]);
                }
                else if (commandLineArgs[ArgType.Action] == "get")
                {
                    Get(commandLineArgs[ArgType.Data]);
                }
                else if (commandLineArgs[ArgType.Action] == "identify")
                {
                    Identify(commandLineArgs[ArgType.Data]);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine($">> Error : {ex.Message}");
            }
            Console.Read();
        }
コード例 #23
0
ファイル: SpObject.cs プロジェクト: ZhHong/sproto-cs
    public SpObject (ArgType type, params object[] args) {
        mType = ArgType.Null;

		switch (type) {
		case ArgType.Array:
			for (int i = 0; i < args.Length; i++) {
				Insert (i, args[i]);
			}
			break;
		case ArgType.Table:
			for (int i = 0; i < args.Length; i += 2) {
				Insert (args[i], args[i + 1]);
			}
			break;
		}
    }
コード例 #24
0
        public Dictionary <uint, string> GetArgList(ArgType argType, bool IsTran = false)
        {
            if (ArgDic.ContainsKey(argType))
            {
                if (IsTran)
                {
                    return(TranArgDic[argType]);
                }
                else
                {
                    return(ArgDic[argType]);
                }
            }

            return(null);
        }
コード例 #25
0
        private bool TryGetArg(string str, ArgType type, out object arg)
        {
            try
            {
                arg = GetArg(str, type);

                return(true);
            }
            catch
            {
            }

            arg = null;

            return(false);
        }
コード例 #26
0
            /// <summary>
            /// If <see cref="ArgType"/> is not null, returns a new default instance of <see cref="ArgType"/>.
            /// Otherwise, returns null.
            /// </summary>
            public object CreateArguments()
            {
                if (ArgType == null)
                {
                    return(null);
                }

                var ctor = ArgType.GetConstructor(Type.EmptyTypes);

                if (ctor == null)
                {
                    throw Contracts.Except("Loadable class '{0}' has ArgType '{1}', which has no suitable constructor",
                                           UserName, ArgType);
                }

                return(ctor.Invoke(null));
            }
コード例 #27
0
 public CmdArgument(string names, ArgType type,
                    string help             = "",
                    string parameter_help   = "",
                    bool required           = false,
                    bool anonymous          = false,
                    Action <dynamic> assign = default(Action <dynamic>))
 {
     _type           = type;
     _value          = NewArgType(type);
     _names          = names.Split(',');
     _required       = required;
     _assign         = assign;
     _help           = help;
     _parameter_help = parameter_help;
     _matched        = false;
     _anonymous      = anonymous;
 }
コード例 #28
0
    public static Type RealType(ArgType type)
    {
        switch (type)
        {
        case ArgType.Bool:
            return(typeof(bool));

        case ArgType.Int:
            return(typeof(int));

        case ArgType.Float:
            return(typeof(float));

        case ArgType.String:
            return(typeof(string));

        case ArgType.Object:
            return(typeof(Object));

        case ArgType.GameObject:
            return(typeof(GameObject));

        case ArgType.StringVariable:
            return(typeof(StringVariable));

        case ArgType.ScriptableObject:
            return(typeof(ScriptableObject));

        case ArgType.KeyValuePairsArrayVariable:
            return(typeof(KeyValuePairsArrayVariable));

        case ArgType.FloatVariable:
            return(typeof(FloatVariable));

        case ArgType.InputKey:
            return(typeof(AdvancedUnityPlugin.Input.Key));

        case ArgType.AnimationClip:
            return(typeof(AnimationClip));

        default:
            return(null);
        }
    }
コード例 #29
0
    public object GetValue(ArgType type)
    {
        switch (type)
        {
        case ArgType.Bool:
            return(boolValue);

        case ArgType.Int:
            return(intValue);

        case ArgType.Float:
            return(floatValue);

        case ArgType.String:
            return(stringValue);

        case ArgType.Object:
            return(objectValue);

        case ArgType.GameObject:
            return(gameObjectValue);

        case ArgType.StringVariable:
            return(stringVariableValue);

        case ArgType.ScriptableObject:
            return(scriptableObjectValue);

        case ArgType.KeyValuePairsArrayVariable:
            return(keyValuePairsArrayVariable);

        case ArgType.FloatVariable:
            return(floatVariable);

        case ArgType.InputKey:
            return(inputKeyVariable);

        case ArgType.AnimationClip:
            return(clipVariable);

        default:
            return(null);
        }
    }
コード例 #30
0
        // generate a new dynamic object with type suitable for ArgType
        private dynamic NewArgType(ArgType type)
        {
            switch (type)
            {
            case ArgType.Int:
            case ArgType.Counter:
                return(new int());

            case ArgType.Double:
                return(new double());

            case ArgType.String:
                return(String.Empty);

            case ArgType.Flag:
                return(new bool());
            }
            return(null);
        }
コード例 #31
0
        private object GetArg(string str, ArgType type)
        {
            object arg;

            switch (type)
            {
            case ArgType.Int:
                arg = long.Parse(str);

                break;

            default:
                arg = str;

                break;
            }

            return(arg);
        }
コード例 #32
0
        int ReadArg(Track track, ArgType type)
        {
            switch (type)
            {
            case ArgType.Byte:     // GetByte
            {
                return(sseq.Data[track.DataOffset++]);
            }

            case ArgType.Short:     // GetShort
            {
                return(sseq.Data[track.DataOffset++] | (sseq.Data[track.DataOffset++] << 8));
            }

            case ArgType.VarLen:     // GetVariableLengthInt
            {
                int  read = 0, val = 0;
                byte b;
                do
                {
                    b   = sseq.Data[track.DataOffset++];
                    val = (val << 7) | (b & 0x7F);
                    read++;
                }while (read < 4 && (b & 0x80) != 0);
                return(val);
            }

            case ArgType.Rand:     // GetRandomShort
            {
                short min = (short)(sseq.Data[track.DataOffset++] | (sseq.Data[track.DataOffset++] << 8));
                short max = (short)(sseq.Data[track.DataOffset++] | (sseq.Data[track.DataOffset++] << 8));
                return(Utils.RNG.Next(min, max + 1));
            }

            case ArgType.SoundVar:     // GetSoundVarShort
            {
                byte varIndex = sseq.Data[track.DataOffset++];
                return(soundVars[varIndex].Value);
            }

            default: throw new Exception();
            }
        }
コード例 #33
0
ファイル: Command.cs プロジェクト: akinomyoga/mwg
        private Command(Xml::XmlElement elem)
        {
            this.name = elem.GetAttribute("name");
            this.size = int.Parse(elem.GetAttribute("size"));
            this.mask = int.Parse(elem.GetAttribute("mask"));
            this.code = int.Parse(elem.GetAttribute("code"));

            string sbits = elem.GetAttribute("bits");

            if (sbits != "00")
            {
                bits = (Bits)System.Enum.Parse(typeof(Bits), sbits);
            }
            else
            {
                bits = Bits.None;
            }

            this.type = default(CmdType);
            string[] types = elem.GetAttribute("type").Split('|');
            foreach (string stype in types)
            {
                if ('0' <= stype[0] && stype[0] <= '9')
                {
                    this.type |= (CmdType)int.Parse(stype);
                }
                else
                {
                    this.type |= (CmdType)System.Enum.Parse(typeof(CmdType), stype);
                }
            }

            Gen::List <ArgType> list = new System.Collections.Generic.List <ArgType>();

            foreach (Xml::XmlElement earg in elem.SelectNodes("/operand"))
            {
                string  stype = earg.GetAttribute("type");
                ArgType type  = (ArgType)System.Enum.Parse(typeof(ArgType), stype);
                list.Add(type);
            }
            this.args = list.ToArray();
        }
コード例 #34
0
ファイル: NodeWindow.cs プロジェクト: 17cuA/AimRacing11
 private void SetArgument(ref Argument sop, ref ArgType argType, ParameterInfo[] infos, int paramNum, int wid)
 {
     //インスタンスがObject型に変換可能であれば引数に代入し、引数のTypeを決める
     if (infos[paramNum].ParameterType.IsSubclassOf(typeof(UnityEngine.Object)))
     {
         GUILayout.Label("Object");
         sop.object_Arg = (UnityEngine.Object)EditorGUILayout.ObjectField(sop.object_Arg, infos[paramNum].ParameterType, true, GUILayout.Width(wid));
         argType        = ArgType.UnityObject;
     }
     //int型
     else if (infos[paramNum].ParameterType == typeof(int))
     {
         GUILayout.Label("int");
         sop.int_Arg = EditorGUILayout.IntField(sop.int_Arg, GUILayout.Width(wid));
         argType     = ArgType.Int;
     }
     //string型
     else if (infos[paramNum].ParameterType == typeof(string))
     {
         GUILayout.Label("string");
         sop.string_Arg = EditorGUILayout.TextField(sop.string_Arg, GUILayout.Width(wid - 20));
         argType        = ArgType.String;
     }
     //float型
     else if (infos[paramNum].ParameterType == typeof(float))
     {
         GUILayout.Label("float");
         sop.float_Arg = EditorGUILayout.FloatField(sop.float_Arg, GUILayout.Width(wid));
         argType       = ArgType.Float;
     }
     //bool型
     else if (infos[paramNum].ParameterType == typeof(bool))
     {
         GUILayout.Label("bool");
         sop.bool_Arg = EditorGUILayout.Toggle(sop.bool_Arg, GUILayout.Width(wid));
         argType      = ArgType.Bool;
     }
     else
     {
         GUILayout.Label("未対応の引数です、エラーが起こります");
     }
 }
コード例 #35
0
        public System.Type RealType(ArgType type)
        {
            switch (type)
            {
            case ArgType.CurrentGenericParam0:
                return(System.Type.GetType(genericType0));

            case ArgType.CurrentGenericParam1:
                return(System.Type.GetType(genericType1));

            case ArgType.CurrentGenericParam2:
                return(System.Type.GetType(genericType2));

            case ArgType.CurrentGenericParam3:
                return(System.Type.GetType(genericType3));

            default:
                return(null);
            }
        }
コード例 #36
0
ファイル: SpObject.cs プロジェクト: ZhHong/sproto-cs
	public SpObject (object arg) {
        mValue = arg;
        mType = ArgType.Null;

        if (mValue != null) {
            Type t = mValue.GetType ();
            if (t == typeof (long)) {
                mType = ArgType.Long;
            }
            else if (t == typeof (int)) {
                mType = ArgType.Int;
            }
            else if (t == typeof (string)) {
                mType = ArgType.String;
            }
            else if (t == typeof (bool)) {
                mType = ArgType.Boolean;
            }
        }
	}
コード例 #37
0
ファイル: Win32API.cs プロジェクト: yyyyj/ironruby
        private static ArgType[] /*!*/ MakeSignature(int size, Func <int, byte> /*!*/ getByte)
        {
            ArgType[] signature = new ArgType[size];
            int       j         = 0;

            for (int i = 0; i < size; i++)
            {
                var argType = ToArgType(getByte(i));
                if (argType != ArgType.None)
                {
                    signature[j++] = argType;
                }
            }

            if (j != signature.Length)
            {
                Array.Resize(ref signature, j);
            }
            return(signature);
        }
コード例 #38
0
ファイル: Arg.cs プロジェクト: bclymer/AssemblerParent
 public Arg(string arg, bool containsLabel, bool allowSixBit)
 {
     if (arg.Contains('('))
     {
         Type = ArgType.HasParaenthesis;
         var args = arg.Split('(');
         args[0] = args[0].Replace("(", "");
         args[0] = args[0].Replace(")", "");
         args[0] = args[0].Replace("$", "");
         args[1] = args[1].Replace("(", "");
         args[1] = args[1].Replace(")", "");
         args[1] = args[1].Replace("$", "");
         OutsideValue = Int32.Parse(args[0]);
         Value = Int32.Parse(args[1]);
     }
     else if (arg.Contains('$'))
     {
         Type = ArgType.HasDollarSign;
         arg = arg.Replace("$", "");
         Value = Int32.Parse(arg);
     }
     else
     {
         if (!containsLabel)
         {
             Type = ArgType.JustAValue;
             Value = Int32.Parse(arg);
         }
         else
         {
             Label = arg;
             IsLabel = true;
         }
     }
     var maxValue = allowSixBit ? 63 : 7;
     if (!IsLabel && (Value > maxValue || OutsideValue > 63))
     {
         throw new ValueTooLargeException();
     }
 }
コード例 #39
0
 public Argument(string data, ArgType type = ArgType.NONE)
 {
     Name = data.Split(' ')[0];
     Description = data.Substring(data.IndexOf(" ") + 1);
     Type = type;
 }
コード例 #40
0
ファイル: ArgsManager.cs プロジェクト: webba/WurmAssistant2
 public IEnumerable<string> GetArgs(ArgType type)
 {
     return _argDatas[type].Args;
 }
コード例 #41
0
ファイル: ArgsManager.cs プロジェクト: webba/WurmAssistant2
 public string GetArg(ArgType type)
 {
     return _argDatas[type].Args.First();
 }
コード例 #42
0
 private string GetFormattedArg(double argVal, ArgType type)
 {
     // beware, you have to cast to correct type for X to work (it will throw exception on floating types etc)
     switch (type)
     {
         case ArgType.Byte:  return string.Format("0x{0:X2}",    (byte)argVal);
         case ArgType.Word:  return string.Format("0x{0:X4}",    (ushort)argVal);
         case ArgType.Dword: return string.Format("0x{0:X8}",    (uint)argVal);
         case ArgType.Qword: return string.Format("0x{0:X16}",   (ulong)argVal);
         case ArgType.Token: return string.Format("0x{0:X8}",    (uint)argVal);
         // beware: branches use relative logic that is not straightforward to print
         case ArgType.SmallBranch:
             byte b = (byte) argVal;
             if (b <= 127)
                 return string.Format("0x{0:X8}", Offset + 2 + b);
             else
                 return string.Format("0x{0:X8}", Offset + 2 - (0 - b));
         case ArgType.Branch:
             uint dword = (uint) argVal;
             if (dword <= 0x7FFFFFFF)
                 return string.Format("0x{0:X8}", Offset + 5 +dword);
             else
                 return string.Format("0x{0:X8}", Offset + 5 - (0 - dword));
         case ArgType.Char:
         case ArgType.Short:     return string.Format("{0}", (short) argVal);
         case ArgType.UChar:
         case ArgType.UShort:    return string.Format("{0}", (ushort) argVal);
         case ArgType.Int:       return string.Format("{0}", (int) argVal);
         case ArgType.UInt:      return string.Format("{0}", (uint) argVal);
         case ArgType.Int64:     return string.Format("{0}", (ulong) argVal);
         case ArgType.Float:
         case ArgType.Double:    return argVal.ToString("F");
         default:                return string.Empty;
     }
 }
コード例 #43
0
 public Arg(ArgType type, string param)
 {
     Type = type;
     Param = param;
 }
コード例 #44
0
ファイル: Win32API.cs プロジェクト: jschementi/iron
        private static ArgType[]/*!*/ MakeSignature(int size, Func<int, byte>/*!*/ getByte) {
            ArgType[] signature = new ArgType[size];
            int j = 0;
            for (int i = 0; i < size; i++) {
                var argType = ToArgType(getByte(i));
                if (argType != ArgType.None) {
                    signature[j++] = argType;
                }
            }

            if (j != signature.Length) {
                Array.Resize(ref signature, j);
            }
            return signature;
        }
コード例 #45
0
ファイル: SpObject.cs プロジェクト: ZhHong/sproto-cs
	public SpObject () {
		mValue = null;
        mType = ArgType.Null;
	}
コード例 #46
0
ファイル: ScriptUtil.cs プロジェクト: khadoran/reanimator
        private void _PushLocalVar(int byteOffset, ArgType argType)
        {
            String argName = null;
            if (_excelFunction != null)
            {
                argName = (from arg in _excelFunction.Args
                           where arg.ByteOffset == byteOffset
                           select arg.Name).FirstOrDefault();
            }

            if (argName == null)
            {
                StackObject localVar = (from varObj in _vars
                                        where varObj.ByteOffset == byteOffset
                                        select varObj).FirstOrDefault();
                Debug.Assert(localVar != null);

                int index = byteOffset / 4;
                argName = "var" + index;
            }
            Debug.Assert(argName != null);

            _stack.Push(new StackObject { Value = argName, Type = argType });
        }
コード例 #47
0
ファイル: Args.cs プロジェクト: pmprog/OpenXCOM.Tools
		public Args(ArgType type)
		{
			this.type=type;
		}
コード例 #48
0
ファイル: Disassembler.cs プロジェクト: DexterHaslem/doyleil
 private static void SetInstruction(DisassembledInstruction dec, Instruction instr, byte[] chunks, ArgType type)
 {
     dec.Instruction = instr;
     ReadParameter(dec, chunks, type, false);
 }
コード例 #49
0
ファイル: Disassembler.cs プロジェクト: DexterHaslem/doyleil
 private static void SetPrefix(DisassembledInstruction dec, Prefix prefix, byte[] chunks, ArgType type)
 {
     dec.PrefixType  = type;
     dec.Prefix      = prefix;
     ReadParameter(dec, chunks, type, true);
 }
コード例 #50
0
ファイル: Program.cs プロジェクト: walter-artica/r5asm
 public Argument(ArgType type, string str)
 {
     this.type = type;
     this.str = str;
     this.param = null;
 }
コード例 #51
0
ファイル: Win32API.cs プロジェクト: jschementi/iron
 private static Type/*!*/ ToNativeType(ArgType argType) {
     switch (argType) {
         case ArgType.Buffer: return typeof(byte[]);
         case ArgType.Int32: return typeof(int);
         case ArgType.None: return typeof(void);
     }
     throw Assert.Unreachable;
 }
コード例 #52
0
 public RegisterArguments(Type t, ArgType argType)
 {
     this.Type = t;
     this.ArgType = argType;
 }
コード例 #53
0
ファイル: Win32API.cs プロジェクト: jschementi/iron
        private Expression/*!*/ MarshalArgument(MetaObjectBuilder/*!*/ metaBuilder, DynamicMetaObject/*!*/ arg, ArgType parameterType) {
            object value = arg.Value;
            if (value == null) {
                metaBuilder.AddRestriction(Ast.Equal(arg.Expression, AstUtils.Constant(null)));
            } else {
                metaBuilder.AddTypeRestriction(value.GetType(), arg.Expression);
            }

            switch (parameterType) {
                case ArgType.Buffer:
                    if (value == null) {
                        return AstUtils.Constant(null, typeof(byte[]));
                    }

                    if (value is int && (int)value == 0) {
                        metaBuilder.AddRestriction(Ast.Equal(AstUtils.Convert(arg.Expression, typeof(int)), AstUtils.Constant(0)));
                        return AstUtils.Constant(null, typeof(byte[]));
                    }

                    if (value.GetType() == typeof(MutableString)) {
                        return Methods.GetMutableStringBytes.OpCall(
                            AstUtils.Convert(arg.Expression, typeof(MutableString))
                        );
                    } 
                    
                    return Methods.GetMutableStringBytes.OpCall(
                        AstUtils.LightDynamic(ConvertToStrAction.Make(_context), typeof(MutableString), arg.Expression)
                    );

                case ArgType.Int32:
                    if (value is int) {
                        return AstUtils.Convert(arg.Expression, typeof(int));
                    }

                    return Ast.Convert(
                        Ast.Call(
                            AstUtils.LightDynamic(ConvertToIntAction.Make(_context), typeof(IntegerValue), arg.Expression), 
                            Methods.IntegerValue_ToUInt32Unchecked
                        ), 
                        typeof(int)
                    );
            }
            throw Assert.Unreachable;
        }
コード例 #54
0
ファイル: Disassembler.cs プロジェクト: DexterHaslem/doyleil
        private static void ReadParameter(DisassembledInstruction dec, byte[] chunks, ArgType type, bool isPrefixVal)
        {
            if (isPrefixVal)
                dec.PrefixType = type;
            else
                dec.ArgType = type;

            if (type == ArgType.None)
                return;

            int curIdx = dec.RollingByteIndex;
            double? parsedVal = null;

            switch (type)
            {
                case ArgType.SmallBranch:
                case ArgType.Byte:
                case ArgType.Char:
                case ArgType.UChar:
                    if (type != ArgType.UChar)
                        parsedVal = chunks[curIdx];
                    else
                        parsedVal = ((sbyte)chunks[curIdx]);
                    ++curIdx;
                    break;
                case ArgType.Short:
                    if (EnsureRoom(chunks, curIdx, 2))
                    {
                        parsedVal = BitConverter.ToInt16(chunks, curIdx);
                        curIdx += 2;
                    }
                    break;
                case ArgType.UShort:
                    if (EnsureRoom(chunks, curIdx, 2))
                    {
                        parsedVal = BitConverter.ToUInt16(chunks, curIdx);
                        curIdx += 2;
                    }
                    break;
                case ArgType.Token:
                case ArgType.UInt:
                case ArgType.Branch:
                case ArgType.Dword:
                    if (EnsureRoom(chunks, curIdx, 4))
                    {
                        parsedVal = BitConverter.ToUInt32(chunks, curIdx);
                        curIdx += 4;
                    }
                    break;
                case ArgType.Int:
                    if (EnsureRoom(chunks, curIdx, 4))
                    {
                        parsedVal = BitConverter.ToInt32(chunks, curIdx);
                        curIdx += 4;
                    }
                    break;
                case ArgType.Qword:
                    if (EnsureRoom(chunks, curIdx, 8))
                    {
                        parsedVal = BitConverter.ToUInt64(chunks, curIdx);
                        curIdx += 8;
                    }
                    break;
                case ArgType.Int64:
                    if (EnsureRoom(chunks, curIdx, 8))
                    {
                        parsedVal = BitConverter.ToInt64(chunks, curIdx);
                        curIdx += 8;
                    }
                    break;
                case ArgType.Switch:
                    // first uint -> # of uints follow it, its an array of switch offsets
                    // [dword #1] ([dword] [dword] .... ) x #1
                    if (EnsureRoom(chunks, curIdx, 4))
                    {
                        int switchOffsetsCount = BitConverter.ToInt32(chunks, curIdx);
                        curIdx += 4;
                        // TODO: does the array of offsets need to be saved?
                        int switchByteSize = 4 * switchOffsetsCount;
                        if (EnsureRoom(chunks, curIdx, switchByteSize))
                            curIdx += switchByteSize;
                    }
                    break;
            }

            if (parsedVal != null)
            {
                if (isPrefixVal)
                    dec.PrefixValue = parsedVal.Value;
                else
                    dec.ArgValue = parsedVal.Value;
            }
            // dont forget to update this, wups
            dec.RollingByteIndex = curIdx;
        }
コード例 #55
0
ファイル: Primitive.cs プロジェクト: cchayden/SimpleScheme
 /// <summary>
 /// Gets the string associated with the expected argument type. 
 /// </summary>
 /// <param name="argType">The argument type.</param>
 /// <returns>The string describing the argument type.</returns>
 internal static string ValueMessage(ArgType argType)
 {
     return valueMessage[(int)argType];
 }
コード例 #56
0
 public ArgDef(string name, ArgType type)
     : this(name, type, false)
 {
 }
コード例 #57
0
ファイル: CLI.cs プロジェクト: Chieze-Franklin/Quic
        static void Main(string[] args)
        {
            if (!initialized)
            {
                Console.WriteLine("Quic Command Line Interface");
                Console.WriteLine();

                Messenger.Prompted += Messenger_Prompted;
                Messenger.Notified += Messenger_Notified;
                Messenger.NotificationsCleared += Messenger_NotificationsCleared;

                initialized = true;
            }

            try
            {
                //assume the first arg to be the input file
                currentArgType = ArgType.InputFile;

                //then look for other args
                for (int index = 0; index < args.Length; index++)
                {
                    if (args[index].StartsWith("-")) //an attribute
                    {
                        if (args[index] == "--input-file" || args[index] == "-i")
                        {
                            currentArgType = ArgType.InputFile;
                        }
                        else if (args[index] == "--output-dir" || args[index] == "-o")
                        {
                            currentArgType = ArgType.OutputDirectory;
                        }
                        else if (args[index] == "--done" || args[index] == "-d")
                        {
                            currentArgType = ArgType.Done;
                        }
                    }
                    else //a value
                    {
                        commandLineArgs.Add(currentArgType, args[index]);
                    }
                }

                //if there are missing command line args, ask for them
                if (!commandLineArgs.ContainsKey(ArgType.InputFile))
                {
                    Console.WriteLine("Specify the path to the input file:");
                    string inputFile = Console.ReadLine();
                    commandLineArgs.Add(ArgType.InputFile, inputFile);
                }
                if (!commandLineArgs.ContainsKey(ArgType.OutputDirectory))
                {
                    Console.WriteLine("Specify the path to the output directory:");
                    string outputDirectory = Console.ReadLine();
                    commandLineArgs.Add(ArgType.OutputDirectory, outputDirectory);
                }

                string sourceFile = commandLineArgs[ArgType.InputFile];
                string outputDir = commandLineArgs[ArgType.OutputDirectory];

                if (!string.IsNullOrWhiteSpace(sourceFile) && !string.IsNullOrWhiteSpace(outputDir))
                {
                    Messenger.ClearNotifications();
                    QuicDocument doc = QuicDocument.Load(sourceFile);
                    doc.Render(outputDir);

                    //a success notif
                    if (Messenger.Notifications.Length == 0)
                    {
                        Messenger.Notify(
                       new QuicException("Build complete.", sourceFile) { MessageType = MessageType.Success });
                    }

                    if (commandLineArgs.ContainsKey(ArgType.Done))
                    {
                        string done = commandLineArgs[ArgType.Done];
                        if (done.Equals("open-dir", StringComparison.InvariantCultureIgnoreCase))
                        {
                            if (Directory.Exists(outputDir))
                                Process.Start(outputDir);
                        }
                    }
                }
            }
            catch (ArgumentException)
            {
                Messenger.Prompt("A command line option appears more than once.", MessageType.Error);
            }
            catch (QuicException ex)
            {
                Messenger.Notify(ex);
            }
            catch (Exception ex)
            {
                //MessageBox.Show(ex.Message, "Quic");
                Messenger.Prompt(ex.Message, MessageType.Error);
            }

            Console.WriteLine();
            Console.WriteLine("Press Enter to exit");
            Console.Read();
        }
コード例 #58
0
 public ArgDef(string name, ArgType type, bool optional)
 {
     Name = name;
     Type = type;
     Optional = optional;
 }
コード例 #59
0
ファイル: Primitive.cs プロジェクト: cchayden/SimpleScheme
        /// <summary>
        /// Check one of the arguments
        /// </summary>
        /// <param name="arg">An argument passed to the primitive.</param>
        /// <param name="argType">The expected argument type.</param>
        private void CheckArgType(SchemeObject arg, ArgType argType)
        {
            if (ArgTypeTester.Ok(arg, argType))
            {
                return;
            }

            var msg = string.Format(
                @"Primitive ""{0}"" invalid argument ""{1}"". Got type: {2}. Expected type: {3}",
                this.ProcedureName,
                arg.ToString(true),
                arg.GetType().Name,
                ArgTypeTester.ValueMessage(argType));
            ErrorHandlers.SemanticError(msg, arg);
        }
コード例 #60
0
ファイル: Primitive.cs プロジェクト: cchayden/SimpleScheme
 /// <summary>
 /// Tests the argument against the expected argument type.
 /// </summary>
 /// <param name="arg">The actual argument.</param>
 /// <param name="argType">The expected argument type.</param>
 /// <returns>True if OK.</returns>
 internal static bool Ok(SchemeObject arg, ArgType argType)
 {
     return argType <= ArgType.Undefined && argPredicates[(int)argType](arg);
 }