// Helper method for "TestArgIteratorGetType".
	private void TestTypes(String testNum, Type[] types, __arglist)
			{
				ArgIterator iter = new ArgIterator(__arglist);
				int count = iter.GetRemainingCount();
				AssertEquals("Length " + testNum, types.Length, count);
				while(count > 0)
				{
					Type type = Type.GetTypeFromHandle
						(iter.GetNextArgType());
					AssertEquals("TypeCheck " + testNum,
								 types[types.Length - count], type);
					AssertEquals("Remaining " + testNum,
								 count, iter.GetRemainingCount());
					iter.GetNextArg();
					--count;
				}
				try
				{
					iter.GetNextArgType();
					Fail("EndCheck " + testNum);
				}
				catch(InvalidOperationException)
				{
					// We expect this exception at the end of the list.
				}
				AssertEquals("Remaining " + testNum, 0,
							 iter.GetRemainingCount());
			}
示例#2
0
        public static void argit0(__arglist)
        {
            ArgIterator args   = new ArgIterator(__arglist);
            int         iCount = args.GetRemainingCount();

            for (int i = 0; i < iCount + 15; i++)
            {
                try
                {
                    TypedReference trTypRef = args.GetNextArg();
                    if (args.GetRemainingCount() != (iCount - i - 1))
                    {
                        throw new Exception("ExcErr5  ,Should have had remaining count " + (iCount - i - 1) + " but had remaining count " + args.GetRemainingCount());
                    }
                }
                catch (Exception ex)
                {
                    if (i < iCount)
                    {
                        Console.WriteLine(i);
                        throw ex;
                    }
                    int iRemCount = args.GetRemainingCount();
                    if (iRemCount != 0)
                    {
                        throw new Exception("ExcErr3  ,Should have had remaining count 0 but had remaining count " + iRemCount);
                    }
                }
            }
            if (args.GetRemainingCount() != 0)
            {
                throw new Exception("ExcErr4  ,Should have had remaining count 0");
            }
        }
示例#3
0
            public override object Invoke(__arglist)
            {
                ArgIterator ai = new ArgIterator(__arglist);

                ObjectTypeHandle[] args = new ObjectTypeHandle[ai.GetRemainingCount()];
                while (ai.GetRemainingCount() > 0)
                {
                    int    idx = args.Length - ai.GetRemainingCount();
                    object arg = TypedReference.ToObject(ai.GetNextArg());
                    args[idx] = AdapterTools.Marshal(arg);
                }
                var res = Delegate.InvokeMember("Invoke", ref args, new bool[args.Length]);

                ai = new ArgIterator(__arglist);
                while (ai.GetRemainingCount() > 0)
                {
                    int          idx = args.Length - ai.GetRemainingCount();
                    ObjectHandle arg = args[idx];
                    var          tr  = ai.GetNextArg();
                    if (__reftype(tr).IsByRef)
                    {
                        tr.SetValue(arg.Unwrap());
                    }
                }
                if (res != null)
                {
                    return(res.Unwrap());
                }
                else
                {
                    return(null);
                }
            }
示例#4
0
        internal static void dummy(string servername, string eventname, __arglist)
        {
            ArgIterator lIterator = new ArgIterator(__arglist);

            object[] args = new object[lIterator.GetRemainingCount()];
            int      i    = 0;

            while (lIterator.GetRemainingCount() > 0)
            {
                TypedReference r = lIterator.GetNextArg();
                args[i++] = TypedReference.ToObject(r);
            }

            foreach (var e in eventinvlist)
            {
                string server_event = servername + "/" + eventname + "/";
                if (e.Contains(server_event))
                {
                    string server    = e.Split('/')[2];
                    var    baseproxy = new SimpleIPC.NamedObject.SIPCProxy(server);
                    if (baseproxy.IsServerAlive())
                    {
                        var proxy = new GenericProxy <IEventCaller>(baseproxy);
                        try
                        {
                            proxy.Proxy.calleventhandlers(eventname, e.Split('/')[3], args);
                        }
                        catch
                        {
                        }
                        proxy.Dispose();
                    }
                }
            }
        }
示例#5
0
    // Helper method for "TestArgIteratorGetType".
    private void TestTypes(String testNum, Type[] types, __arglist)
    {
        ArgIterator iter  = new ArgIterator(__arglist);
        int         count = iter.GetRemainingCount();

        AssertEquals("Length " + testNum, types.Length, count);
        while (count > 0)
        {
            Type type = Type.GetTypeFromHandle
                            (iter.GetNextArgType());
            AssertEquals("TypeCheck " + testNum,
                         types[types.Length - count], type);
            AssertEquals("Remaining " + testNum,
                         count, iter.GetRemainingCount());
            iter.GetNextArg();
            --count;
        }
        try
        {
            iter.GetNextArgType();
            Fail("EndCheck " + testNum);
        }
        catch (InvalidOperationException)
        {
            // We expect this exception at the end of the list.
        }
        AssertEquals("Remaining " + testNum, 0,
                     iter.GetRemainingCount());
    }
    public static int Sum(int a, double b, int c, float d, __arglist)
    {
        ArgIterator args = new ArgIterator(__arglist);
        int         S    = a + (int)b + c + (int)d;

        while (args.GetRemainingCount() > 0)
        {
            if (args.GetNextArgType().Equals(typeof(int).TypeHandle))
            {
                int N = __refvalue(args.GetNextArg(), int);
                Console.WriteLine("int value is " + N);
                S = S + N;
            }
            else if (args.GetNextArgType().Equals(typeof(string).TypeHandle))
            {
                string s = __refvalue(args.GetNextArg(), string);
                Console.WriteLine("string value is " + s);
            }
            else if (args.GetNextArgType().Equals(typeof(MyStruct).TypeHandle))
            {
                MyStruct st = __refvalue(args.GetNextArg(), MyStruct);
                Console.WriteLine("MyStruct value is " + st.x + " " + st.y);
                S = S + 2 * st.x + 3 * st.y;
            }
            else
            {
                return(-1);
            }
        }
        return(S);
    }
    public static long EnumTest(__arglist)
    {
        ArgIterator args = new ArgIterator(__arglist);
        long        S    = 0;

        while (args.GetRemainingCount() > 0)
        {
            if (args.GetNextArgType().Equals(typeof(Enum1).TypeHandle))
            {
                Enum1 e = __refvalue(args.GetNextArg(), Enum1);
                Console.WriteLine("Got Enum1, value = " + e + " = " + (long)e);
                S += (long)e;
            }
            if (args.GetNextArgType().Equals(typeof(Enum8).TypeHandle))
            {
                Enum8 e = __refvalue(args.GetNextArg(), Enum8);
                Console.WriteLine("Got Enum8, value = " + e + " = " + (long)e);
                S += (long)e;
            }
            if (args.GetNextArgType().Equals(typeof(Enum16).TypeHandle))
            {
                Enum16 e = __refvalue(args.GetNextArg(), Enum16);
                Console.WriteLine("Got Enum16, value = " + e + " = " + (long)e);
                S += (long)e;
            }
            if (args.GetNextArgType().Equals(typeof(Enuml).TypeHandle))
            {
                Enuml e = __refvalue(args.GetNextArg(), Enuml);
                Console.WriteLine("Got Enuml, value = " + e + " = " + (long)e);
                S += (long)e;
            }
        }
        return(S);
    }
示例#8
0
 public static int Sum(int a, double b, int c, float d, __arglist)
 {
    ArgIterator args = new ArgIterator(__arglist);
    int S = a + (int)b + c + (int)d;
    while(args.GetRemainingCount() > 0)
      {
        if (args.GetNextArgType().Equals(typeof(int).TypeHandle))
        {
            int N = __refvalue(args.GetNextArg(), int);
            Console.WriteLine("int value is "+N);
            S = S + N;
        }
        else if (args.GetNextArgType().Equals(typeof(string).TypeHandle))
        {
            string s = __refvalue(args.GetNextArg(), string);
            Console.WriteLine("string value is "+s);
        }
        else if (args.GetNextArgType().Equals(typeof(MyStruct).TypeHandle))
        {
            MyStruct st = __refvalue(args.GetNextArg(), MyStruct);
            Console.WriteLine("MyStruct value is "+st.x+" "+st.y);
            S = S + 2*st.x + 3*st.y;
        }
        else
           return -1;
      }
    return S;
 }
示例#9
0
        private static void testArglist(__arglist)
        {
            const int    newint    = 10;
            const double newdouble = 0.1;
            ArgIterator  iter      = new ArgIterator(__arglist);
            int          length    = iter.GetRemainingCount();

            for (int i = 0; i < length; i++)
            {
                Type type = Type.GetTypeFromHandle(iter.GetNextArgType());
                if (type == typeof(int))
                {
                    int v = __refvalue(iter.GetNextArg(), int);
                    Debug.WriteLine("Found int with value:{0}", v);
                    v = newint;
                    continue;
                }
                if (type == typeof(double))
                {
                    double v = __refvalue(iter.GetNextArg(), double);
                    Debug.WriteLine("Found double with value:{0}", v);
                    v = newdouble;
                    continue;
                }
                Debug.WriteLine("Missing object:{0}", TypedReference.ToObject(iter.GetNextArg()));
            }
        }
 public static long EnumTest(__arglist)
 {
     ArgIterator args = new ArgIterator(__arglist);
     long S = 0;
     while (args.GetRemainingCount() > 0)
     {
         if (args.GetNextArgType().Equals(typeof(Enum1).TypeHandle))
         {
             Enum1 e = __refvalue(args.GetNextArg(), Enum1);
             Console.WriteLine("Got Enum1, value = " + e + " = " + (long)e);
             S += (long)e;
         }
         if (args.GetNextArgType().Equals(typeof(Enum8).TypeHandle))
         {
             Enum8 e = __refvalue(args.GetNextArg(), Enum8);
             Console.WriteLine("Got Enum8, value = " + e + " = " + (long)e);
             S += (long)e;
         }
         if (args.GetNextArgType().Equals(typeof(Enum16).TypeHandle))
         {
             Enum16 e = __refvalue(args.GetNextArg(), Enum16);
             Console.WriteLine("Got Enum16, value = " + e + " = " + (long)e);
             S += (long)e;
         }
         if (args.GetNextArgType().Equals(typeof(Enuml).TypeHandle))
         {
             Enuml e = __refvalue(args.GetNextArg(), Enuml);
             Console.WriteLine("Got Enuml, value = " + e + " = " + (long)e);
             S += (long)e;
         }
     }
     return S;
 }
示例#11
0
        public static void Write(string format, object arg0, object arg1, object arg2, object arg3, __arglist)
        {
            ArgIterator iter     = new ArgIterator(__arglist);
            int         argCount = iter.GetRemainingCount();
#endif

            object[] args = new object[argCount + 4];
            args[0] = arg0;
            args[1] = arg1;
            args[2] = arg2;
            args[3] = arg3;
#if NETCF
            for (int i = 0; i < argCount; i++)
            {
                args[i + 4] = arglist[i];
#else
            for (int i = 0; i < argCount; i++)
            {
                TypedReference typedRef = iter.GetNextArg();
                args[i + 4] = TypedReference.ToObject(typedRef);
#endif
            }

            stdout.Write(String.Format(format, args));
        }
示例#12
0
 public void TestArgIteratorUninitialized()
 {
     AssertEquals("Remaining", 0,
                  emptyIterator.GetRemainingCount());
     try
     {
         emptyIterator.GetNextArg();
         Fail("EndCheck");
     }
     catch (InvalidOperationException)
     {
         // We expect this exception at the end of the list.
     }
     try
     {
         emptyIterator.GetNextArgType();
         Fail("EndCheck 2");
     }
     catch (InvalidOperationException)
     {
         // We expect this exception at the end of the list.
     }
     try
     {
         emptyIterator.GetNextArg(typeof(int).TypeHandle);
         Fail("EndCheck 3");
     }
     catch (InvalidOperationException)
     {
         // We expect this exception at the end of the list.
     }
 }
示例#13
0
    static void X(__arglist) // 仮引数のところに __arglist を書く
    {
        // 中身のとりだしには ArgIterator 構造体を使う
        ArgIterator argumentIterator = new ArgIterator(__arglist);

        while (argumentIterator.GetRemainingCount() > 0)
        {
            object value = null;

            var r = argumentIterator.GetNextArg(); // 可変個引数の1個1個は TypedReference になっている
            var t = __reftype(r);                  // TypedReference から、元の型を取得

            // 型で分岐して、__refvalue で値の取り出し
            if (t == typeof(int))
            {
                value = __refvalue(r, int);
            }
            else if (t == typeof(char))
            {
                value = __refvalue(r, char);
            }
            else if (t == typeof(double))
            {
                value = __refvalue(r, double);
            }
            else
            {
                value = __refvalue(r, string);
            }

            Console.WriteLine(t.Name + ": " + value);
        }
    }
示例#14
0
   public static void argit1( __arglist )
     {
     ArgIterator args = new ArgIterator( __arglist );
     try
       {
       int argCount = args.GetRemainingCount();
       for (int i = 0; i < argCount; i++) 
	 {
	 TypedReference trTypRef =  args.GetNextArg();
	 }
       }
     catch(Exception ex)
       {
       throw new Exception( "ExcErr001  ," + ex.ToString() );
       }
     for ( int j = 0; j < 5; j++ )
       {
       try
	 {
	 TypedReference trTypRef = args.GetNextArg();
	 throw new Exception( "ExcErr002  , Last call should have thrown." );
	 }
       catch (InvalidOperationException)
	 {}
       }
     }
示例#15
0
        public static void argit3(__arglist)
        {
            ArgIterator args = new ArgIterator(__arglist);

            try
            {
                int argCount = args.GetRemainingCount();
                for (int i = 0; i < argCount; i++)
                {
                    TypedReference trTypRef = args.GetNextArg();
                }
            }
            catch (Exception ex)
            {
                throw new Exception("ExcErr007  ," + ex.ToString());
            }
            for (int j = 0; j < 5; j++)
            {
                try
                {
                    RuntimeTypeHandle rthRunTypHan = args.GetNextArgType();
                    throw new Exception("ExcErr006  , Last call should have thrown.");
                }
                catch (InvalidOperationException)
                {}
            }
        }
示例#16
0
    /// <summary>
    /// 副列表&物品添加到字典再将该字典保存到list中,设置相关属性
    /// </summary>
    /// <param name="__arglist">可变参数</param>
    /// <param name="enumType">枚举名</param>
    /// <param name="originalItemName">item原来名字</param>
    /// <param name="currentViceItemName">item当前名字</param>
    /// <param name="chName">Toggle中文名字</param>
    /// <param name="index">Toggle在当前Group中的index</param>
    Dictionary <object, GameObject> AddPreObjToDic(__arglist)
    {
        object      enumType = null;
        string      currentViceItemName = null, chName = null;
        int         index = 0;
        string      imageName = null;
        GameObject  viceOrItem;
        ArgIterator args = new ArgIterator(__arglist);
        //print(args.GetRemainingCount());
        Dictionary <object, GameObject> toggleDicDetial = new Dictionary <object, GameObject>();

        if (4 == args.GetRemainingCount())
        {
            enumType            = TypedReference.ToObject(args.GetNextArg());
            currentViceItemName = TypedReference.ToObject(args.GetNextArg()).ToString();
            chName = TypedReference.ToObject(args.GetNextArg()).ToString();
            index  = int.Parse(TypedReference.ToObject(args.GetNextArg()).ToString());
            //print(enumType + " "+ currentViceItemName+" "+chName+ " "+ index);
            viceOrItem = UIManager.Instance.GetUIPrefabInstance(ConstDates.UIStoreViceItem, currentViceItemName);

            //副列表属性设置
            viceOrItem.transform.SetParent(viceToggleParent.transform);//设置父层级
            viceOrItem.transform.Find("Label").GetComponent <Text>().text = chName;
            Toggle tgTemp = viceOrItem.GetComponent <Toggle>();
            if (0 == index)   //将Group组中的第一个Toggle激活
            {
                tgTemp.isOn = true;
            }
            tgTemp.group = viceToggleGroup; //给每个Toggle设置ToggleGroup
        }
        else if (2 == args.GetRemainingCount())
        {
            enumType  = TypedReference.ToObject(args.GetNextArg());
            imageName = TypedReference.ToObject(args.GetNextArg()).ToString();
            //print(enumType+" "+imageName);
            viceOrItem = UIManager.Instance.GetUIPrefabInstance(ConstDates.UIStoreItem);

            //物品属性等设置
            SetItemProperty(viceOrItem, imageName);
        }
        else
        {
            throw new Exception("参数错误!");
        }
        toggleDicDetial.Add(enumType, viceOrItem);
        return(toggleDicDetial);
    }
示例#17
0
文件: test-811.cs 项目: nobled/mono
	static void TestRefValue (__arglist)
	{
		ArgIterator args = new ArgIterator (__arglist);

		var o = __refvalue ( args.GetNextArg (),int);
		for (int i = 0; i < args.GetRemainingCount (); i++) {
			Console.WriteLine (__refvalue (args.GetNextArg (), int));
		}
	}
示例#18
0
        private static void ArglistMethod(__arglist)
        {
            var iter = new ArgIterator(__arglist);

            for (int n = iter.GetRemainingCount(); n > 0; n--)
            {
                Console.WriteLine(TypedReference.ToObject(iter.GetNextArg()));
            }
        }
示例#19
0
        public void VariableArguments(__arglist)
        {
            ArgIterator argumentIterator = new ArgIterator(__arglist);

            for (int i = 0; i < argumentIterator.GetRemainingCount(); i++)
            {
                Console.WriteLine(
                    __refvalue(argumentIterator.GetNextArg(), string));
            }
        }
示例#20
0
        public void Bar3(int val, string name, __arglist) // Noncompliant
        {
            ArgIterator argumentIterator = new ArgIterator(__arglist);

            for (int i = 0; i < argumentIterator.GetRemainingCount(); i++)
            {
                Console.WriteLine(
                    __refvalue(argumentIterator.GetNextArg(), string));
            }
        }
    public static void VarArgs(int normalArg, __arglist)
    {
        ArgIterator argIterator = new ArgIterator(__arglist);

        Console.WriteLine("Called with {0} arguments", argIterator.GetRemainingCount());
        int pos = 0;

        while (argIterator.GetRemainingCount() > 0)
        {
            TypedReference tr = argIterator.GetNextArg();
            object         val;
            try {
                val = __refvalue(tr, object);
            } catch (Exception ex) {
                val = ex.GetType().Name;
            }
            Console.WriteLine("{0} : {1} = {2}", pos++, __reftype(tr).Name, val);
        }
    }
示例#22
0
        public static void DisplayNumbersOnConsole(__arglist)
        {
            ArgIterator ai = new ArgIterator(__arglist);

            while (ai.GetRemainingCount() > 0)
            {
                TypedReference tr = ai.GetNextArg();
                Console.WriteLine(TypedReference.ToObject(tr));
            }
        }
示例#23
0
            public void Bar4(__arglist) // Compliant - private method
            {
                ArgIterator argumentIterator = new ArgIterator(__arglist);

                for (int i = 0; i < argumentIterator.GetRemainingCount(); i++)
                {
                    Console.WriteLine(
                        __refvalue(argumentIterator.GetNextArg(), string));
                }
            }
示例#24
0
	    public void Foo(__arglist)
	    {
		    var iterator = new ArgIterator(__arglist);
		    while (iterator.GetRemainingCount() > 0)
		    {
			    TypedReference typedReference = iterator.GetNextArg();
			    Console.WriteLine("{0} / {1}",
				    TypedReference.ToObject(typedReference),
				    TypedReference.GetTargetType(typedReference));
		    }
	    }
示例#25
0
        private static void Foo(__arglist)
        {
            var iterator = new ArgIterator(__arglist);

            while (iterator.GetRemainingCount() > 0)
            {
                var typedReference = iterator.GetNextArg();
                Console.WriteLine($"{TypedReference.ToObject(typedReference)} " +
                                  $"/ {TypedReference.GetTargetType(typedReference)}");
            }
        }
示例#26
0
        public static void VarargMethod(string headline, __arglist)
        {
            ArgIterator ai = new ArgIterator(__arglist);

            Console.Write(headline);
            while (ai.GetRemainingCount() > 0)
            {
                Console.Write(TypedReference.ToObject(ai.GetNextArg()));
            }
            Console.WriteLine();
        }
示例#27
0
        /*
         * static public TType Cast<TType>(object Value)
         * {
         *      if (typeof(TType) == typeof(int)) return (TType)(dynamic)Convert.ToInt32(Value);
         *      if (typeof(TType) == typeof(uint)) return (TType)(dynamic)Convert.ToUInt32(Value);
         *
         *      if (Value.GetType() == typeof(int)) return (TType)(dynamic)(int)Value;
         *      if (Value.GetType() == typeof(uint)) return (TType)(dynamic)(uint)Value;
         *      return (TType)(dynamic)Value;
         * }
         */

        static public object[] GetObjectsFromArgsIterator(ArgIterator ArgIterator)
        {
            var Params = new object[ArgIterator.GetRemainingCount()];

            for (int n = 0; n < Params.Length; n++)
            {
                Params[n] = TypedReference.ToObject(ArgIterator.GetNextArg());
            }
            ArgIterator.End();
            return(Params);
        }
示例#28
0
    static void TestRefValue(__arglist)
    {
        ArgIterator args = new ArgIterator(__arglist);

        var o = __refvalue(args.GetNextArg(), int);

        for (int i = 0; i < args.GetRemainingCount(); i++)
        {
            Console.WriteLine(__refvalue(args.GetNextArg(), int));
        }
    }
示例#29
0
        public object[] ArgTest(__arglist)
        {
            var args   = new ArgIterator(__arglist);
            var result = new object[] { args.GetRemainingCount() };

            for (int i = 0; i < result.Length; i++)
            {
                result[i] = TypedReference.ToObject(args.GetNextArg());
            }
            return(result);
        }
示例#30
0
        public void Bar(__arglist) // Noncompliant {{Use the 'params' keyword instead of '__arglist'.}}
//                  ^^^
        {
            ArgIterator argumentIterator = new ArgIterator(__arglist);

            for (int i = 0; i < argumentIterator.GetRemainingCount(); i++)
            {
                Console.WriteLine(
                    __refvalue(argumentIterator.GetNextArg(), string));
            }
        }
示例#31
0
    // Helper method for "TestArgIteratorGetValueByType".
    private void TestByType(String testNum, Type[] types, __arglist)
    {
        ArgIterator iter  = new ArgIterator(__arglist);
        int         count = iter.GetRemainingCount();

        AssertEquals("Length " + testNum, types.Length, count);
        while (count > 0)
        {
            Type   type  = types[types.Length - count];
            Object value = TypedReference.ToObject
                               (iter.GetNextArg(type.TypeHandle));
            Type valueType = value.GetType();
            AssertEquals("TypeCheck " + testNum, type, valueType);
            --count;
            AssertEquals("Remaining " + testNum,
                         count, iter.GetRemainingCount());
        }
        try
        {
            iter.GetNextArg(typeof(double).TypeHandle);
            Fail("EndCheck " + testNum);
        }
        catch (InvalidOperationException)
        {
            // We expect this exception at the end of the list.
        }
        AssertEquals("Remaining " + testNum, 0,
                     iter.GetRemainingCount());

        // Reset the list and check for the wrong type.
        iter = new ArgIterator(__arglist);
        try
        {
            iter.GetNextArg(typeof(long).TypeHandle);
            Fail("TypeCheck 2 " + testNum);
        }
        catch (InvalidOperationException)
        {
            // This is what we expected.
        }
    }
    private static void Bar(__arglist)
    {
        ArgIterator argIterator = new ArgIterator(__arglist);

        while (argIterator.GetRemainingCount() > 0)
        {
            HiddenFeatureserence HiddenFeatureserence = argIterator.GetNextArg();
            object obj = HiddenFeatureserence.ToObject(HiddenFeatureserence);
            //Console.Out.WriteLine(obj);
            printf("%s\n", __arglist(obj.ToString()));
        }
    }
示例#33
0
        // special case, this return false for HasParameters
        private void ShowItems_NoParameter(__arglist)
        {
            ArgIterator args = new ArgIterator(__arglist);

            for (int i = 0; i < args.GetRemainingCount(); i++)
            {
// gmcs cannot compile __refvalue correctly - bnc 569539
#if !__MonoCS__
                Console.WriteLine(__refvalue(args.GetNextArg(), string));
#endif
            }
        }
示例#34
0
        private static int[] VarArgMethod(int count, __arglist)
        {
            var it     = new ArgIterator(__arglist);
            var result = new int[count];

            for (var i = 0; i < count; ++i)
            {
                result[i] = it.GetRemainingCount() > 0 ? __refvalue(it.GetNextArg(), int) : 0;
            }

            return(result);
        }
示例#35
0
    public static void Play(GameObject g, float volume, __arglist)
    {
        ArgIterator   args   = new ArgIterator(__arglist);
        List <String> sounds = new List <String> ();

        while (args.GetRemainingCount() > 0)
        {
            sounds.Add((string)TypedReference.ToObject(args.GetNextArg()));
        }
        String[] soundsName = sounds.ToArray();
        SoundEffectFunction.Play(g, soundsName, volume);
    }
示例#36
0
 public static void argit1( __arglist )
   {
   ArgIterator args = new ArgIterator( __arglist );
   int iCount = args.GetRemainingCount();
   for ( int i = 0; i < iCount + 15; i++ ){
   try	{
   try {
   TypedReference trTypRef =  args.GetNextArg();
   }
   catch (InvalidOperationException){}
   if (args.GetRemainingCount()!=0)
     if ( args.GetRemainingCount() != (iCount - i - 1) ){
     throw new Exception( "ExcErr5  ,Should have had remaining count " + (iCount - i - 1) + " but had remaining count " + args.GetRemainingCount() );
     }
   }
   catch(Exception ex){			
   if ( i < iCount )
     Console.WriteLine( "Err_argit4_00: Loop has not gone through only " + i + " arguments" );
   int iRemCount = args.GetRemainingCount();
   if ( iRemCount != 0 ){
   Console.WriteLine( "Err_argit4_01: Should have had remaining count 0 but had remaining count " + iRemCount );
   }
   throw ex;
   }
   }
   if ( args.GetRemainingCount() != 0 ){
   throw new Exception( "ExcErr4  ,Should have had remaining count 0");
   }
   }
示例#37
0
//Test 1
	// check whether GetHashCode returns the same value
	// check to see if we can use ArgIterators on any class
	// check ArgIterators on Arrays
	// test arg iterators with instance methods on normal classes
	public TestStruct argit1( Object[] objExpectedArr, __arglist )
	{
		ArgIterator args = new ArgIterator( __arglist );
		int hashcode = args.GetHashCode();
		
		int iCount = args.GetRemainingCount();
                Console.WriteLine( "Found  "+ iCount +" arguments. " );  
		Object[] objArr = new Object[iCount];

		for ( int i = 0; i < iCount; i++ ){
			objArr[i] = TypedReference.ToObject(args.GetNextArg());
                        Console.WriteLine( "Object  " + i + ": " + objArr[i] + " Expected: " + objExpectedArr[i] );  
			if ( objExpectedArr[i] == null ){
				if ( objArr[i] != null ){
					throw new Exception( "argit1 - 1, __arglist[i] was null but it did not equal to objExpectedArr[i]" );
				}
			}
			
			else if ( ! objArr[i].Equals( objExpectedArr[i] ) ) {
				throw new Exception( "argit1 - 2, __arglist[i] was null but it did not equal to objExpectedArr[i]" );
			}
		}		

		//repeating the code above __arglist should be valid in method scope
		ArgIterator args2 = new ArgIterator( __arglist );
		int iCount2 = args2.GetRemainingCount();
		Object[] objArr2 = new Object[iCount];

		for ( int i = 0; i < iCount2; i++ ){
			objArr2[i] = TypedReference.ToObject(args2.GetNextArg());
                        Console.WriteLine( "Object  " + i + ": " + objArr2[i] + " Expected: " + objExpectedArr[i] );
			if ( objExpectedArr[i] == null ){
				if ( objArr2[i] != null ){
					throw new Exception( "argit1 - 3, __arglist[i] was null but it did not equal to objExpectedArr[i]" );
				}
			}
			
			else if ( ! objArr2[i].Equals( objExpectedArr[i] ) ) {
				throw new Exception( "argit1 - 4, __arglist[i] was null but it did not equal to objExpectedArr[i]" );
			}
		}				
		int hashcodecompare= args.GetHashCode();
		if (! hashcode.Equals(hashcodecompare))
			{
				throw new Exception( "argit1 - 5, hashcode changed" );
			}
                TestStruct Bar = new TestStruct();
                Bar.foo1 = 1;
                Bar.foo2 = 2;
                return Bar;
	}
示例#38
0
    static void X(__arglist) // 仮引数のところに __arglist を書く
    {
        // 中身のとりだしには ArgIterator 構造体を使う
        ArgIterator argumentIterator = new ArgIterator(__arglist);
        while (argumentIterator.GetRemainingCount() > 0)
        {
            object value = null;

            var r = argumentIterator.GetNextArg(); // 可変個引数の1個1個は TypedReference になっている
            var t = __reftype(r); // TypedReference から、元の型を取得

            // 型で分岐して、__refvalue で値の取り出し
            if (t == typeof(int)) value = __refvalue(r, int);
            else if (t == typeof(char)) value = __refvalue(r, char);
            else if (t == typeof(double)) value = __refvalue(r, double);
            else value = __refvalue(r, string);

            Console.WriteLine(t.Name + ": " + value);
        }
    }
示例#39
0
 public void argit1( Object[] objExpectedArr, __arglist )
   {
   ArgIterator args = new ArgIterator( __arglist );
   int hashcode = args.GetHashCode();
   int iCount = args.GetRemainingCount();
   Object[] objArr = new Object[iCount];
   for ( int i = 0; i < iCount; i++ ){
   objArr[i] = TypedReference.ToObject(args.GetNextArg());
   if ( objExpectedArr[i] == null ){
   if ( objArr[i] != null ){
   throw new Exception( "argit1 - 1, __arglist[i] was null but it did not equal to objExpectedArr[i]" );
   }
   }
   else if ( ! objArr[i].Equals( objExpectedArr[i] ) ) {
   throw new Exception( "argit1 - 2, __arglist[i] was null but it did not equal to objExpectedArr[i]" );
   }
   }		
   ArgIterator args2 = new ArgIterator( __arglist );
   int iCount2 = args2.GetRemainingCount();
   Object[] objArr2 = new Object[iCount];
   for ( int i = 0; i < iCount2; i++ ){
   objArr2[i] = TypedReference.ToObject(args2.GetNextArg());
   if ( objExpectedArr[i] == null ){
   if ( objArr2[i] != null ){
   throw new Exception( "argit1 - 3, __arglist[i] was null but it did not equal to objExpectedArr[i]" );
   }
   }
   else if ( ! objArr2[i].Equals( objExpectedArr[i] ) ) {
   throw new Exception( "argit1 - 4, __arglist[i] was null but it did not equal to objExpectedArr[i]" );
   }
   }				
   int hashcodecompare= args.GetHashCode();
   if (! hashcode.Equals(hashcodecompare))
     {
     throw new Exception( "argit1 - 5, hashcode changed" );
     }
   }
示例#40
0
   public static void argit0( __arglist )
     {
     ArgIterator args = new ArgIterator( __arglist );
     int iCount = args.GetRemainingCount();
     for ( int i = 0; i < iCount + 15; i++ )
       {
       try
	 {
	 TypedReference trTypRef =  args.GetNextArg();
	 if ( args.GetRemainingCount() != (iCount - i - 1) )
	   {
	   throw new Exception( "ExcErr5  ,Should have had remaining count " + (iCount - i - 1) + " but had remaining count " + args.GetRemainingCount() );
	   }
	 }
       catch(Exception ex)
	 {			
	 if ( i < iCount )
	   {
	   Console.WriteLine( i );
	   throw ex;
	   }
	 int iRemCount = args.GetRemainingCount();
	 if ( iRemCount != 0 )
	   {
	   throw new Exception( "ExcErr3  ,Should have had remaining count 0 but had remaining count " + iRemCount );
	   }
	 }
       }
     if ( args.GetRemainingCount() != 0 )
       {
       throw new Exception( "ExcErr4  ,Should have had remaining count 0");
       }
     }
	// Helper method for "TestArgIteratorGetValue".
	private void TestValues(String testNum, Object[] values, __arglist)
			{
				Object expected, actual;
				ArgIterator iter = new ArgIterator(__arglist);
				int count = iter.GetRemainingCount();
				AssertEquals("Length " + testNum, values.Length, count);
				while(count > 0)
				{
					expected = values[values.Length - count];
					actual = TypedReference.ToObject(iter.GetNextArg());
					if(expected == null)
					{
						AssertNull("ValueCheck " + testNum, actual);
					}
					else
					{
						Assert("ValueCheck " + testNum,
							   expected.Equals(actual));
					}
					--count;
					AssertEquals("Remaining " + testNum,
								 count, iter.GetRemainingCount());
				}
				try
				{
					iter.GetNextArg();
					Fail("EndCheck " + testNum);
				}
				catch(InvalidOperationException)
				{
					// We expect this exception at the end of the list.
				}
				AssertEquals("Remaining " + testNum, 0,
							 iter.GetRemainingCount());

				// Restart and run the test again to make sure that
				// the first iteration did not modify the vararg values.
				iter = new ArgIterator(__arglist);
				count = iter.GetRemainingCount();
				AssertEquals("Length " + testNum, values.Length, count);
				while(count > 0)
				{
					expected = values[values.Length - count];
					actual = TypedReference.ToObject(iter.GetNextArg());
					if(expected == null)
					{
						AssertNull("ValueCheck " + testNum, actual);
					}
					else
					{
						Assert("ValueCheck " + testNum,
							   expected.Equals(actual));
					}
					--count;
					AssertEquals("Remaining " + testNum,
								 count, iter.GetRemainingCount());
				}
				try
				{
					iter.GetNextArg();
					Fail("EndCheck " + testNum);
				}
				catch(InvalidOperationException)
				{
					// We expect this exception at the end of the list.
				}
				AssertEquals("Remaining " + testNum, 0,
							 iter.GetRemainingCount());
			}
示例#42
0
 public Type[] argit7( __arglist )
   {
   Console.WriteLine( 1 );
   ArgIterator args = new ArgIterator( __arglist );
   int iCount = args.GetRemainingCount();
   Type[] typArr = new Type[iCount];
   for ( int i = 0; i < iCount; i++ )
     {
     Console.WriteLine( "       -> " + typeof( System.TypedReference ).TypeHandle.Value );
     Console.WriteLine( "       => " + args.GetNextArgType() );
     }
   return typArr;
   }
   public MyStruct SumAndCount(int a, int b, __arglist)
   {
     Console.WriteLine("This type: " + this.GetType().ToString());
     MyStruct t = new MyStruct();
     
    ArgIterator args = new ArgIterator(__arglist);     
    t.x += (a + b);
    t.y += args.GetRemainingCount();

    while(args.GetRemainingCount() > 0)
    {
        if (args.GetNextArgType().Equals(typeof(int).TypeHandle))
        {
            int N = __refvalue(args.GetNextArg(), int);
            Console.WriteLine("int value is "+N);
            t.x = t.x + N;
        }
        else
        if (args.GetNextArgType().Equals(typeof(byte).TypeHandle))
        {
            byte N = __refvalue(args.GetNextArg(), byte);
            Console.WriteLine("byte value is "+N);
            t.x = t.x + N;
        }
        else
        if (args.GetNextArgType().Equals(typeof(short).TypeHandle))
        {
            short N = __refvalue(args.GetNextArg(), short);
            Console.WriteLine("short value is "+N);
            t.x = t.x + N;
        }
        else
        if (args.GetNextArgType().Equals(typeof(long).TypeHandle))
        {
            TypedReference tr = args.GetNextArg();
            Interlocked.Increment(ref __refvalue(tr, long));
            long N = __refvalue(tr, long);
            Console.WriteLine("long value is "+N);
            t.x = t.x + (int)(N % 57);
        }
        else
        if (args.GetNextArgType().Equals(typeof(float).TypeHandle))
        {
            float N = __refvalue(args.GetNextArg(), float);
            Console.WriteLine("float value is "+N);
            t.x = t.x + (int)N;
        }
        else
        if (args.GetNextArgType().Equals(typeof(double).TypeHandle))
        {
            double N = __refvalue(args.GetNextArg(), double);
            Console.WriteLine("double value is "+N);
            t.x = t.x + (int)N;
        }                            
        else
        if (args.GetNextArgType().Equals(typeof(Struct1).TypeHandle))
        {
            Struct1 N = __refvalue(args.GetNextArg(), Struct1);
            Console.WriteLine("Struct1 value is "+N.x);
            t.x = t.x + N.x;
        }                            
        else
            throw new Exception();
     }
     
     return t;
   }
	public static int GetArgCount(__arglist)
	{
		ArgIterator argIterator = new ArgIterator(__arglist);
		return argIterator.GetRemainingCount();
	}
示例#45
0
   public Object[] argit6( Object[] objExpectedArr, __arglist )
     {
     ArgIterator args = new ArgIterator( __arglist );
     int iCount = args.GetRemainingCount();
     Object[] objArr = new Object[iCount];
     for ( int i = 0; i < iCount; i++ )
       {
       objArr[i] = TypedReference.ToObject(args.GetNextArg());
       if ( objExpectedArr[i] == null )
	 {
	 if ( objArr[i] != null )
	   {
	   throw new Exception( "argit6 - 1, __arglist[i] was null but it did not equal to objExpectedArr[i]" );
	   }
	 }
       else if ( ! objExpectedArr[i].Equals( objExpectedArr[i] ) )
	 {
	 throw new Exception( "argit6 - 2, __arglist[i] was null but it did not equal to objExpectedArr[i]" );
	 }
       }
     return objArr;
     }
	// Helper method for "TestArgIteratorGetValueByType".
	private void TestByType(String testNum, Type[] types, __arglist)
			{
				ArgIterator iter = new ArgIterator(__arglist);
				int count = iter.GetRemainingCount();
				AssertEquals("Length " + testNum, types.Length, count);
				while(count > 0)
				{
					Type type = types[types.Length - count];
					Object value = TypedReference.ToObject
						(iter.GetNextArg(type.TypeHandle));
					Type valueType = value.GetType();
					AssertEquals("TypeCheck " + testNum, type, valueType);
					--count;
					AssertEquals("Remaining " + testNum,
								 count, iter.GetRemainingCount());
				}
				try
				{
					iter.GetNextArg(typeof(double).TypeHandle);
					Fail("EndCheck " + testNum);
				}
				catch(InvalidOperationException)
				{
					// We expect this exception at the end of the list.
				}
				AssertEquals("Remaining " + testNum, 0,
							 iter.GetRemainingCount());

				// Reset the list and check for the wrong type.
				iter = new ArgIterator(__arglist);
				try
				{
					iter.GetNextArg(typeof(long).TypeHandle);
					Fail("TypeCheck 2 " + testNum);
				}
				catch(InvalidOperationException)
				{
					// This is what we expected.
				}
			}
	// Helper method for "TestArgIteratorEnd".
	private void TestEnd(String testNum, __arglist)
			{
				ArgIterator iter = new ArgIterator(__arglist);
				iter.End();
				AssertEquals("Remaining " + testNum, 0,
							 iter.GetRemainingCount());
				try
				{
					iter.GetNextArg();
					Fail("EndCheck " + testNum);
				}
				catch(InvalidOperationException)
				{
					// We expect this exception at the end of the list.
				}
			}