Exemple #1
0
		// FIXME: This doesn't properly handle virtual properties yet
		private unsafe static void RegisterProperty (PropertyInfo prop, Type type, IntPtr handle) {
			ExportAttribute ea = (ExportAttribute) Attribute.GetCustomAttribute (prop, typeof (ExportAttribute));
			if (ea == null)
				return;
			
			var m = prop.GetGetMethod (true);
			if (m != null)
				RegisterMethod (m, ea.ToGetter (prop), type, handle);
			m = prop.GetSetMethod (true);
			if (m != null)
				RegisterMethod (m, ea.ToSetter (prop), type, handle);
				
			// http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/ObjCRuntimeGuide/Articles/ocrtPropertyIntrospection.html
			int count = 0;
			var props = new objc_attribute_prop [3];
			props [count++] = new objc_attribute_prop { name = "T", value = TypeConverter.ToNative (prop.PropertyType) };
			switch (ea.ArgumentSemantic) {
			case ArgumentSemantic.Copy:
				props [count++] = new objc_attribute_prop { name = "C", value = "" };
				break;
			case ArgumentSemantic.Retain:
				props [count++] = new objc_attribute_prop { name = "&", value = "" };
				break;
			}
			props [count++] = new objc_attribute_prop { name = "V", value = ea.Selector };
			
			class_addProperty (handle, ea.Selector, props, count);
			
		}
Exemple #2
0
		static IntPtr class_addProperty (IntPtr cls, string name, objc_attribute_prop [] attributes, int count)
		{
			if (!addPropertyInitialized) {
				var handle = Dlfcn.dlopen (Constants.ObjectiveCLibrary, 0);
				try {
					var fptr = Dlfcn.dlsym (handle, "class_addProperty");
					if (fptr != IntPtr.Zero)
						addProperty = (addPropertyDelegate) Marshal.GetDelegateForFunctionPointer (fptr, typeof (addPropertyDelegate));
				} finally {
					Dlfcn.dlclose (handle);
				}
				addPropertyInitialized = true;
			}
			if (addProperty == null)
				return IntPtr.Zero;
			return addProperty (cls, name, attributes, count);
		}
Exemple #3
0
		internal extern static bool class_addProperty (IntPtr cls, string name, objc_attribute_prop [] attributes, int count);