コード例 #1
0
 public JSDelegateWrapper(DeligateType Delegate) : this(Delegate, 0)
 {
 }
コード例 #2
0
 public JSDelegateWrapper(DeligateType Delegate)
     : this(Delegate, 0)
 {
 }
コード例 #3
0
 public JSDelegateWrapper(MethodInfo mi)
 {
     this.paramlist = new ParameterList();
     DynamicMethod method = new DynamicMethod("TestMethod", typeof(JSValue), new Type[] { typeof(JSContext), typeof(JSValue), typeof(JSArgs), typeof(bool) }, typeof(JSDelegateWrapper), true);
     ILGenerator gen = method.GetILGenerator();
     gen.Emit(OpCodes.Ldarg_1);
     gen.Emit(OpCodes.Castclass, typeof(JSExternWrapper));
     gen.EmitCallV( mi_get_Wrapped);
     gen.Emit(OpCodes.Castclass, mi.DeclaringType);
     int i = 0;
     foreach (ParameterInfo p in mi.GetParameters())
     {
         gen.Emit(OpCodes.Ldarg_2);
         gen.Emit(OpCodes.Ldc_I4, i);
         gen.EmitCallV( mi_get_Item);
         if (p.ParameterType == typeof(JSValue)) { /* do nothing */ }
         else if (p.ParameterType == typeof(string))
         {
             gen.EmitCallV( CompileContext.mi_JSValue_StringValue);
         }
         else if (p.ParameterType == typeof(double))
         {
             gen.EmitCallV( CompileContext.mi_JSValue_NumberValue);
         }
         else if (p.ParameterType == typeof(float))
         {
             gen.EmitCallV( CompileContext.mi_JSValue_NumberValue);
             gen.Emit(OpCodes.Conv_R4);
         }
         else if (p.ParameterType == typeof(int))
         {
             gen.EmitCallV( CompileContext.mi_JSValue_NumberValue);
             gen.Emit(OpCodes.Conv_I4);
         }
         else if (p.ParameterType == typeof(bool))
             gen.EmitCallV( CompileContext.mi_JSValue_BoolValue);
         else
             throw new Exception();
         gen.EmitCallV( mi);
         i++;
     }
     gen.Emit(OpCodes.Ldsfld, fi_undef_ref);
     gen.Emit(OpCodes.Ret);
     this._delegate = (DeligateType) method.CreateDelegate(typeof(DeligateType));
 }
コード例 #4
0
 public JSDelegateWrapper(DeligateType Delegate, int length)
 {
     this._delegate = Delegate;
     base.SetDataProp("length", (double) length, false, false, false);
 }