| | |
| | | |
| | | if (!gen_interfaces.Contains(to_be_impl)) |
| | | { |
| | | throw new InvalidCastException("This type must add to CSharpCallLua: " + to_be_impl); |
| | | throw new InvalidCastException("This type must add to CSharpCallLua: " + to_be_impl.GetFriendlyName()); |
| | | } |
| | | |
| | | TypeBuilder impl_type_builder = CodeEmitModule.DefineType("XLuaGenInterfaceImpl" + (genID++), TypeAttributes.Public | TypeAttributes.Class, typeof(LuaBase), new Type[] { to_be_impl}); |
| | |
| | | { |
| | | var getter_buildler = defineImplementMethod(impl_type_builder, property.GetGetMethod(), |
| | | MethodAttributes.Virtual | MethodAttributes.Public | MethodAttributes.SpecialName | MethodAttributes.HideBySig); |
| | | emitEmptyMethod(getter_buildler.GetILGenerator(), property.PropertyType); |
| | | emitMethodImpl(property.GetGetMethod(), getter_buildler.GetILGenerator(), true); |
| | | prop_builder.SetGetMethod(getter_buildler); |
| | | } |
| | | if (property.CanWrite) |
| | | { |
| | | var setter_buildler = defineImplementMethod(impl_type_builder, property.GetSetMethod(), |
| | | MethodAttributes.Virtual | MethodAttributes.Public | MethodAttributes.SpecialName | MethodAttributes.HideBySig); |
| | | emitEmptyMethod(setter_buildler.GetILGenerator(), property.PropertyType); |
| | | emitMethodImpl(property.GetSetMethod(), setter_buildler.GetILGenerator(), true); |
| | | prop_builder.SetSetMethod(setter_buildler); |
| | | } |
| | | continue; |
| | |
| | | { |
| | | var add_buildler = defineImplementMethod(impl_type_builder, event_info.GetAddMethod(), |
| | | MethodAttributes.Virtual | MethodAttributes.Public | MethodAttributes.SpecialName | MethodAttributes.HideBySig); |
| | | emitEmptyMethod(add_buildler.GetILGenerator(), typeof(void)); |
| | | emitMethodImpl(event_info.GetAddMethod(), add_buildler.GetILGenerator(), true); |
| | | event_builder.SetAddOnMethod(add_buildler); |
| | | } |
| | | if (event_info.GetRemoveMethod() != null) |
| | | { |
| | | var remove_buildler = defineImplementMethod(impl_type_builder, event_info.GetRemoveMethod(), |
| | | MethodAttributes.Virtual | MethodAttributes.Public | MethodAttributes.SpecialName | MethodAttributes.HideBySig); |
| | | emitEmptyMethod(remove_buildler.GetILGenerator(), typeof(void)); |
| | | emitMethodImpl(event_info.GetRemoveMethod(), remove_buildler.GetILGenerator(), true); |
| | | event_builder.SetRemoveOnMethod(remove_buildler); |
| | | } |
| | | } |
| | |
| | | var getter = prop.GetGetMethod(); |
| | | if (getter != null && getter.IsPublic) |
| | | { |
| | | if (prop.Name == "Item" && prop.GetIndexParameters().Length > 0) |
| | | if (prop.GetIndexParameters().Length > 0) |
| | | { |
| | | if (!prop.GetIndexParameters()[0].ParameterType.IsAssignableFrom(typeof(string))) |
| | | { |
| | |
| | | var setter = prop.GetSetMethod(); |
| | | if (setter != null && setter.IsPublic) |
| | | { |
| | | if (prop.Name == "Item" && prop.GetIndexParameters().Length > 0) |
| | | if (prop.GetIndexParameters().Length > 0) |
| | | { |
| | | if (!prop.GetIndexParameters()[0].ParameterType.IsAssignableFrom(typeof(string))) |
| | | { |