// Used primarily for reading variant values private object ReadValue(Signature sig) { if (sig.IsPrimitive) { return(ReadValue(sig[0])); } Type t = null; try { t = sig.ToType(); } catch (NotSupportedException e) { // We don't catch other exceptions as they indicate a malformed signature if (Protocol.Verbose) { Console.Error.WriteLine(e.Message); } } /* * if (t == null) { * StepOver (sig); * return null; * } */ if (t == null) { ReadPad(sig.Alignment); int startPos = pos; StepOver(sig); int ln = pos - startPos; DValue dv = new DValue(); dv.endianness = endianness; dv.signature = sig; dv.data = new byte[ln]; Array.Copy(data, startPos, dv.data, 0, ln); return(dv); } return(ReadValue(t)); }
public static MethodBuilder DefineMethod(TypeBuilder typeB, string name, MethodAttributes mattr, Argument[] args, bool isSignal) { // TODO: Share this method for both signals and methods. List <Type> parms = new List <Type> (); if (args != null) { for (int argNum = 0; argNum != args.Length; argNum++) { Argument arg = args[argNum]; Signature sig = new Signature(arg.Type); Type argType = sig.ToType(); if (arg.Direction == Introspection.ArgDirection.@out) { argType = argType.MakeByRefType(); } parms.Add(argType); } } MethodBuilder mb = typeB.DefineMethod(name, mattr, typeof(void), parms.ToArray()); if (args != null) { for (int argNum = 0; argNum != args.Length; argNum++) { Argument arg = args[argNum]; ParameterAttributes pattrs = (arg.Direction == Introspection.ArgDirection.@out) ? ParameterAttributes.Out : ParameterAttributes.In; mb.DefineParameter(argNum + 1, pattrs, arg.Name ?? ("arg" + argNum)); } } return(mb); }
public static MethodBuilder DefineMethod(TypeBuilder typeB, string name, MethodAttributes mattr, Argument[] args, bool isSignal) { // TODO: Share this method for both signals and methods. List<Type> parms = new List<Type> (); if (args != null) for (int argNum = 0; argNum != args.Length; argNum++) { Argument arg = args[argNum]; Signature sig = new Signature (arg.Type); Type argType = sig.ToType (); if (arg.Direction == Introspection.ArgDirection.@out) argType = argType.MakeByRefType (); parms.Add (argType); } MethodBuilder mb = typeB.DefineMethod (name, mattr, typeof (void), parms.ToArray ()); if (args != null) for (int argNum = 0; argNum != args.Length; argNum++) { Argument arg = args[argNum]; ParameterAttributes pattrs = (arg.Direction == Introspection.ArgDirection.@out) ? ParameterAttributes.Out : ParameterAttributes.In; mb.DefineParameter (argNum + 1, pattrs, arg.Name ?? ("arg" + argNum)); } return mb; }
object ReadVariant (Signature sig) { return ReadValue (sig.ToType ()); }
public void GetValue (Signature sig, out object val) { GetValue (sig.ToType (), out val); }
object ReadVariant(Signature sig) { return(ReadValue(sig.ToType())); }
public void GetValue(Signature sig, out object val) { GetValue(sig.ToType(), out val); }