Exemplo n.º 1
0
		internal NativeMethodBuilder (MethodInfo minfo, Type type, ExportAttribute ea) {
			if (ea == null)
				throw new ArgumentException ("MethodInfo does not have a export attribute");

			if (minfo.DeclaringType.IsGenericType)
				throw new ArgumentException ("MethodInfo cannot be in a generic type");

			Parameters = minfo.GetParameters ();

			rettype = ConvertReturnType (minfo.ReturnType);

			// FIXME: We should detect if this is in a bound assembly or not and only alloc if needed
			Selector = new Selector (ea.Selector ?? minfo.Name, true).Handle;
			Signature = string.Format ("{0}@:", TypeConverter.ToNative (rettype));

			ConvertParameters (Parameters, minfo.IsStatic, isstret);
			
			DelegateType = CreateDelegateType (rettype, ParameterTypes);

			this.minfo = minfo;
			this.type = type;
		}
Exemplo n.º 2
0
		public static void ConnectMethod (MethodInfo method, Selector selector) {
			if (method == null)
				throw new ArgumentNullException ("method");
			if (selector == null)
				throw new ArgumentNullException ("selector");
			var type = method.DeclaringType;

			if (!Class.IsCustomType (type))
				throw new ArgumentException ("Cannot late bind methods on core types");

			var ea = new ExportAttribute (selector.Name);
			var klass = new Class (type);

			Class.RegisterMethod (method, ea, type, klass.Handle);
		}
Exemplo n.º 3
0
		internal unsafe static void RegisterMethod (MethodInfo minfo, ExportAttribute ea, Type type, IntPtr handle) {
			NativeMethodBuilder builder = new NativeMethodBuilder (minfo, type, ea);

			class_addMethod (minfo.IsStatic ? ((objc_class *) handle)->isa : handle, builder.Selector, builder.Delegate, builder.Signature);
			method_wrappers.Add (builder.Delegate);
#if DEBUG
			Console.WriteLine ("[METHOD] Registering {0}[0x{1:x}|{2}] on {3} -> ({4})", ea.Selector, (int) builder.Selector, builder.Signature, type, minfo);
#endif
		}