| | |
| | | |
| | | static GeneratorConfig() |
| | | { |
| | | foreach(var type in (from type in XLua.Utils.GetAllTypes() |
| | | where type.IsAbstract && type.IsSealed |
| | | select type)) |
| | | foreach (var type in (from type in XLua.Utils.GetAllTypes() |
| | | where type.IsAbstract && type.IsSealed |
| | | select type)) |
| | | { |
| | | foreach (var field in type.GetFields(BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.DeclaredOnly)) |
| | | { |
| | |
| | | |
| | | foreach (var paraminfo in mi.GetParameters()) |
| | | { |
| | | if ((!paraminfo.ParameterType.IsPrimitive ) && (paraminfo.IsIn || !paraminfo.IsOut)) |
| | | if ((!paraminfo.ParameterType.IsPrimitive) && (paraminfo.IsIn || !paraminfo.IsOut)) |
| | | { |
| | | costing++; |
| | | } |
| | |
| | | } |
| | | return from type in type_has_extension_methods |
| | | where type.IsSealed && !type.IsGenericType && !type.IsNested |
| | | from method in type.GetMethods(BindingFlags.Static | BindingFlags.Public) |
| | | where isSupportedExtensionMethod(method, extendedType) |
| | | select method; |
| | | from method in type.GetMethods(BindingFlags.Static | BindingFlags.Public) |
| | | where isSupportedExtensionMethod(method, extendedType) |
| | | select method; |
| | | } |
| | | |
| | | static bool isSupportedExtensionMethod(MethodBase method, Type extendedType) |
| | |
| | | parameters.Set("constructor_def_vals", constructor_def_vals); |
| | | |
| | | List<string> extension_methods_namespace = new List<string>(); |
| | | var extension_methods = type.IsInterface ? new MethodInfo[0]:GetExtensionMethods(type).ToArray(); |
| | | foreach(var extension_method in extension_methods) |
| | | var extension_methods = type.IsInterface ? new MethodInfo[0] : GetExtensionMethods(type).ToArray(); |
| | | foreach (var extension_method in extension_methods) |
| | | { |
| | | if (extension_method.DeclaringType.Namespace != null |
| | | && extension_method.DeclaringType.Namespace != "System.Collections.Generic" |
| | |
| | | |
| | | //warnning: filter all method start with "op_" "add_" "remove_" may filter some ordinary method |
| | | parameters.Set("methods", type.GetMethods(BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static | BindingFlags.IgnoreCase | BindingFlags.DeclaredOnly) |
| | | .Where(method => !isDefined(method, typeof (ExtensionAttribute)) || method.GetParameters()[0].ParameterType.IsInterface || method.DeclaringType != type) |
| | | .Where(method => !method.IsSpecialName |
| | | .Where(method => !isDefined(method, typeof(ExtensionAttribute)) || method.GetParameters()[0].ParameterType.IsInterface || method.DeclaringType != type) |
| | | .Where(method => !method.IsSpecialName |
| | | || ( |
| | | ((method.Name == "get_Item" && method.GetParameters().Length == 1) || (method.Name == "set_Item" && method.GetParameters().Length == 2)) |
| | | ((method.Name == "get_Item" && method.GetParameters().Length == 1) || (method.Name == "set_Item" && method.GetParameters().Length == 2)) |
| | | && method.GetParameters()[0].ParameterType.IsAssignableFrom(typeof(string)) |
| | | ) |
| | | ) |
| | | ) |
| | | .Concat(extension_methods) |
| | | .Where(method => !IsDoNotGen(type, method.Name)) |
| | | .Where(method => !isMethodInBlackList(method) && (!method.IsGenericMethod || extension_methods.Contains(method) || isSupportedGenericMethod(method)) && !isObsolete(method)) |
| | | .GroupBy(method => (method.Name + ((method.IsStatic && (!isDefined(method, typeof (ExtensionAttribute)) || method.GetParameters()[0].ParameterType.IsInterface)) ? "_xlua_st_" : "")), (k, v) => |
| | | { |
| | | var overloads = new List<MethodBase>(); |
| | | List<int> def_vals = new List<int>(); |
| | | bool isOverride = false; |
| | | foreach (var overload in v.Cast<MethodBase>().OrderBy(mb => OverloadCosting(mb))) |
| | | { |
| | | int def_count = 0; |
| | | overloads.Add(overload); |
| | | def_vals.Add(def_count); |
| | | .GroupBy(method => (method.Name + ((method.IsStatic && (!isDefined(method, typeof(ExtensionAttribute)) || method.GetParameters()[0].ParameterType.IsInterface)) ? "_xlua_st_" : "")), (k, v) => |
| | | { |
| | | var overloads = new List<MethodBase>(); |
| | | List<int> def_vals = new List<int>(); |
| | | bool isOverride = false; |
| | | foreach (var overload in v.Cast<MethodBase>().OrderBy(mb => OverloadCosting(mb))) |
| | | { |
| | | int def_count = 0; |
| | | overloads.Add(overload); |
| | | def_vals.Add(def_count); |
| | | |
| | | if (!isOverride) |
| | | { |
| | | isOverride = IsOverride(overload); |
| | | } |
| | | if (!isOverride) |
| | | { |
| | | isOverride = IsOverride(overload); |
| | | } |
| | | |
| | | var ps = overload.GetParameters(); |
| | | for (int i = ps.Length - 1; i >=0; i--) |
| | | { |
| | | if(ps[i].IsOptional || |
| | | (ps[i].IsDefined(typeof(ParamArrayAttribute), false) && i > 0 && ps[i - 1].IsOptional)) |
| | | { |
| | | def_count++; |
| | | overloads.Add(overload); |
| | | def_vals.Add(def_count); |
| | | } |
| | | else |
| | | { |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | var ps = overload.GetParameters(); |
| | | for (int i = ps.Length - 1; i >= 0; i--) |
| | | { |
| | | if (ps[i].IsOptional || |
| | | (ps[i].IsDefined(typeof(ParamArrayAttribute), false) && i > 0 && ps[i - 1].IsOptional)) |
| | | { |
| | | def_count++; |
| | | overloads.Add(overload); |
| | | def_vals.Add(def_count); |
| | | } |
| | | else |
| | | { |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | |
| | | return new { |
| | | Name = k, |
| | | IsStatic = overloads[0].IsStatic && (!isDefined(overloads[0], typeof(ExtensionAttribute)) || overloads[0].GetParameters()[0].ParameterType.IsInterface), |
| | | Overloads = overloads, |
| | | DefaultValues = def_vals |
| | | }; |
| | | }).ToList()); |
| | | return new |
| | | { |
| | | Name = k, |
| | | IsStatic = overloads[0].IsStatic && (!isDefined(overloads[0], typeof(ExtensionAttribute)) || overloads[0].GetParameters()[0].ParameterType.IsInterface), |
| | | Overloads = overloads, |
| | | DefaultValues = def_vals |
| | | }; |
| | | }).ToList()); |
| | | |
| | | parameters.Set("getters", type.GetProperties(BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static | BindingFlags.IgnoreCase | BindingFlags.DeclaredOnly) |
| | | |
| | | .Where(prop => prop.GetIndexParameters().Length == 0 && prop.CanRead && (prop.GetGetMethod() != null) && prop.Name != "Item" && !isObsolete(prop) && !isObsolete(prop.GetGetMethod()) && !isMemberInBlackList(prop) && !isMemberInBlackList(prop.GetGetMethod())).Select(prop => new { prop.Name, IsStatic = prop.GetGetMethod().IsStatic, ReadOnly = false, Type = prop.PropertyType }) |
| | | |
| | | .Where(prop => prop.GetIndexParameters().Length == 0 && prop.CanRead && (prop.GetGetMethod() != null) && prop.Name != "Item" && !isObsolete(prop) && !isObsolete(prop.GetGetMethod()) && !isMemberInBlackList(prop) && !isMemberInBlackList(prop.GetGetMethod())).Select(prop => new { prop.Name, IsStatic = prop.GetGetMethod().IsStatic, ReadOnly = false, Type = prop.PropertyType }) |
| | | .Concat( |
| | | type.GetFields(BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static | BindingFlags.IgnoreCase | BindingFlags.DeclaredOnly) |
| | | .Where(field => !isObsolete(field) && !isMemberInBlackList(field)) |
| | |
| | | .ToList()); |
| | | |
| | | parameters.Set("events", type.GetEvents(BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static | BindingFlags.IgnoreCase | BindingFlags.DeclaredOnly).Where(e => !isObsolete(e) && !isMemberInBlackList(e)) |
| | | .Where(ev=> ev.GetAddMethod() != null || ev.GetRemoveMethod() != null) |
| | | .Where(ev => ev.GetAddMethod() != null || ev.GetRemoveMethod() != null) |
| | | .Where(ev => !IsDoNotGen(type, ev.Name)) |
| | | .Select(ev => new { IsStatic = ev.GetAddMethod() != null? ev.GetAddMethod().IsStatic: ev.GetRemoveMethod().IsStatic, ev.Name, |
| | | CanSet = false, CanAdd = ev.GetRemoveMethod() != null, CanRemove = ev.GetRemoveMethod() != null, Type = ev.EventHandlerType}) |
| | | .Select(ev => new |
| | | { |
| | | IsStatic = ev.GetAddMethod() != null ? ev.GetAddMethod().IsStatic : ev.GetRemoveMethod().IsStatic, |
| | | ev.Name, |
| | | CanSet = false, |
| | | CanAdd = ev.GetRemoveMethod() != null, |
| | | CanRemove = ev.GetRemoveMethod() != null, |
| | | Type = ev.EventHandlerType |
| | | }) |
| | | .ToList()); |
| | | |
| | | |
| | | parameters.Set("lazymembers", lazyMemberInfos); |
| | | foreach (var member in type.GetMembers(BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static | BindingFlags.IgnoreCase | BindingFlags.DeclaredOnly) |
| | | .Where(m => IsDoNotGen(type, m.Name)) |
| | | .GroupBy(m=>m.Name).Select(g => g.First()) |
| | | .GroupBy(m => m.Name).Select(g => g.First()) |
| | | ) |
| | | { |
| | | switch(member.MemberType) |
| | | switch (member.MemberType) |
| | | { |
| | | case MemberTypes.Method: |
| | | MethodBase mb = member as MethodBase; |
| | |
| | | EventInfo ev = member as EventInfo; |
| | | if (ev.GetAddMethod() == null && ev.GetRemoveMethod() == null) break; |
| | | bool eventIsStatic = ev.GetAddMethod() != null ? ev.GetAddMethod().IsStatic : ev.GetRemoveMethod().IsStatic; |
| | | lazyMemberInfos.Add(new LazyMemberInfo { |
| | | lazyMemberInfos.Add(new LazyMemberInfo |
| | | { |
| | | Index = eventIsStatic ? "CLS_IDX" : "METHOD_IDX", |
| | | Name = member.Name, |
| | | MemberType = "LazyMemberTypes.Event", |
| | |
| | | if (mb is FieldInfo && (mb as FieldInfo).FieldType.IsPointer) return true; |
| | | if (mb is PropertyInfo && (mb as PropertyInfo).PropertyType.IsPointer) return true; |
| | | |
| | | foreach(var filter in memberFilters) |
| | | foreach (var filter in memberFilters) |
| | | { |
| | | if (filter(mb)) |
| | | { |
| | |
| | | { |
| | | string filePath = save_path + "EnumWrap.cs"; |
| | | StreamWriter textWriter = new StreamWriter(filePath, false, Encoding.UTF8); |
| | | |
| | | |
| | | GenOne(null, (type, type_info) => |
| | | { |
| | | var type2fields = luaenv.NewTable(); |
| | | foreach(var _type in types) |
| | | foreach (var _type in types) |
| | | type2fields.Set(_type, _type.GetFields(BindingFlags.Public | BindingFlags.Static).Where(x => !isMemberInBlackList(x)).ToArray()); |
| | | type_info.Set("type2fields", type2fields); |
| | | type_info.Set("types", types.ToList()); |
| | |
| | | |
| | | public int HashCode; |
| | | |
| | | public ParameterInfoSimulation[] GetParameters() |
| | | public ParameterInfoSimulation[] GetParameters() |
| | | { |
| | | return ParameterInfos; |
| | | } |
| | |
| | | |
| | | if (!method.IsConstructor && (isNotPublic((method as MethodInfo).ReturnType) || hasGenericParameter((method as MethodInfo).ReturnType))) return true; |
| | | |
| | | if (!method.IsStatic |
| | | &&(((method.DeclaringType.IsValueType && !ignoreValueType) && isNotPublic(method.DeclaringType)) || hasGenericParameter(method.DeclaringType))) |
| | | if (!method.IsStatic |
| | | && (((method.DeclaringType.IsValueType && !ignoreValueType) && isNotPublic(method.DeclaringType)) || hasGenericParameter(method.DeclaringType))) |
| | | { |
| | | return true; |
| | | } |
| | | |
| | | foreach (var param in method.GetParameters()) |
| | | { |
| | | if ((((param.ParameterType.IsValueType && !ignoreValueType) |
| | | || param.ParameterType.IsByRef || param.IsDefined(typeof(System.ParamArrayAttribute), false)) && isNotPublic(param.ParameterType)) |
| | | if ((((param.ParameterType.IsValueType && !ignoreValueType) |
| | | || param.ParameterType.IsByRef || param.IsDefined(typeof(System.ParamArrayAttribute), false)) && isNotPublic(param.ParameterType)) |
| | | || hasGenericParameter(param.ParameterType)) |
| | | return true; |
| | | } |
| | |
| | | .Select(method => makeHotfixMethodInfoSimulation(method, kv.Value))); |
| | | } |
| | | hotfxDelegates = hotfxDelegates.Distinct(comparer).ToList(); |
| | | for(int i = 0; i < hotfxDelegates.Count; i++) |
| | | for (int i = 0; i < hotfxDelegates.Count; i++) |
| | | { |
| | | hotfxDelegates[i].DeclaringTypeName = "__Gen_Hotfix_Delegate" + i; |
| | | } |
| | |
| | | var delegates_groups = types.Select(delegate_type => makeMethodInfoSimulation(delegate_type.GetMethod("Invoke"))) |
| | | .Where(d => d.DeclaringType.FullName != null) |
| | | .Concat(hotfxDelegates) |
| | | .GroupBy(d => d, comparer).Select((group) => new { Key = group.Key, Value = group.ToList()}); |
| | | .GroupBy(d => d, comparer).Select((group) => new { Key = group.Key, Value = group.ToList() }); |
| | | GenOne(typeof(DelegateBridge), (type, type_info) => |
| | | { |
| | | type_info.Set("delegates_groups", delegates_groups.ToList()); |
| | |
| | | { |
| | | type_info.Set("purevaluetypes", types |
| | | .Where(t => t.IsEnum || (!t.IsPrimitive && SizeOf(t) != -1)) |
| | | .Select(t => new { |
| | | .Select(t => new |
| | | { |
| | | Type = t, |
| | | Size = SizeOf(t), |
| | | Flag = t.IsEnum ? OptimizeFlag.Default : OptimizeCfg[t], |
| | |
| | | |
| | | static void GenWrap(IEnumerable<Type> types, string save_path) |
| | | { |
| | | types = types.Where(type=>!type.IsEnum); |
| | | types = types.Where(type => !type.IsEnum); |
| | | |
| | | #if GENERIC_SHARING |
| | | types = types.GroupBy(t => t.IsGenericType ? t.GetGenericTypeDefinition() : t).Select(g => g.Key); |
| | | #endif |
| | | |
| | | var typeMap = types.ToDictionary(type => { |
| | | var typeMap = types.ToDictionary(type => |
| | | { |
| | | //Debug.Log("type:" + type); |
| | | return type.ToString(); |
| | | }); |
| | |
| | | var argumentType = genericArguments[i]; |
| | | var parameterConstraints = argumentType.GetGenericParameterConstraints(); |
| | | Type parameterConstraint = parameterConstraints[0]; |
| | | foreach(var type in argumentType.GetGenericParameterConstraints()) |
| | | foreach (var type in argumentType.GetGenericParameterConstraints()) |
| | | { |
| | | if (parameterConstraint.IsAssignableFrom(type)) |
| | | { |
| | | parameterConstraint = type; |
| | | } |
| | | } |
| | | |
| | | |
| | | constraintedArgumentTypes[i] = parameterConstraint; |
| | | } |
| | | return method.MakeGenericMethod(constraintedArgumentTypes); |
| | |
| | | var lookup = LuaCallCSharp.Distinct().ToDictionary(t => t); |
| | | |
| | | var extension_methods_from_lcs = (from t in LuaCallCSharp |
| | | where isDefined(t, typeof(ExtensionAttribute)) |
| | | from method in t.GetMethods(BindingFlags.Static | BindingFlags.Public) |
| | | where isDefined(method, typeof(ExtensionAttribute)) && !isObsolete(method) |
| | | where !method.ContainsGenericParameters || isSupportedGenericMethod(method) |
| | | select makeGenericMethodIfNeeded(method)) |
| | | where isDefined(t, typeof(ExtensionAttribute)) |
| | | from method in t.GetMethods(BindingFlags.Static | BindingFlags.Public) |
| | | where isDefined(method, typeof(ExtensionAttribute)) && !isObsolete(method) |
| | | where !method.ContainsGenericParameters || isSupportedGenericMethod(method) |
| | | select makeGenericMethodIfNeeded(method)) |
| | | .Where(method => !lookup.ContainsKey(method.GetParameters()[0].ParameterType)); |
| | | |
| | | var extension_methods = (from t in ReflectionUse |
| | |
| | | if (!type.IsPrimitive && type != typeof(decimal)) |
| | | { |
| | | cb(type); |
| | | foreach(var fieldInfo in type.GetFields(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly)) |
| | | foreach (var fieldInfo in type.GetFields(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly)) |
| | | { |
| | | AllSubStruct(fieldInfo.FieldType, cb); |
| | | } |
| | | |
| | | foreach(var propInfo in type.GetProperties(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly)) |
| | | foreach (var propInfo in type.GetProperties(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly)) |
| | | { |
| | | if ((AdditionalProperties.ContainsKey(type) && AdditionalProperties[type].Contains(propInfo.Name)) |
| | | || isDefined(propInfo, typeof(AdditionalPropertiesAttribute))) |
| | |
| | | var fs = t.GetFields(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly) |
| | | .Select(fi => new XluaFieldInfo { Name = fi.Name, Type = fi.FieldType, IsField = true, Size = SizeOf(fi.FieldType) }) |
| | | .Concat(t.GetProperties(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly) |
| | | .Where(prop => { |
| | | .Where(prop => |
| | | { |
| | | return (AdditionalProperties.ContainsKey(t) && AdditionalProperties[t].Contains(prop.Name)) |
| | | || isDefined(prop, typeof(AdditionalPropertiesAttribute)); |
| | | }) |
| | |
| | | var set = types.ToDictionary(type => type); |
| | | List<Type> all_types = new List<Type>(); |
| | | |
| | | foreach(var type in types) |
| | | foreach (var type in types) |
| | | { |
| | | AllSubStruct(type, (t) => |
| | | { |
| | |
| | | } |
| | | else if (obj is IEnumerable<Type>) |
| | | { |
| | | foreach(var type in (obj as IEnumerable<Type>)) |
| | | foreach (var type in (obj as IEnumerable<Type>)) |
| | | { |
| | | OptimizeCfg.Add(type, flag); |
| | | } |
| | |
| | | #endif |
| | | foreach (var type in cfg as IEnumerable<Type>) |
| | | { |
| | | if (!HotfixCfg.ContainsKey(type) && !isObsolete(type) |
| | | if (!HotfixCfg.ContainsKey(type) && !isObsolete(type) |
| | | && !type.IsEnum && !typeof(Delegate).IsAssignableFrom(type) |
| | | && (!type.IsGenericType || type.IsGenericTypeDefinition) |
| | | && (!type.IsGenericType || type.IsGenericTypeDefinition) |
| | | && (type.Namespace == null || (type.Namespace != "XLua" && !type.Namespace.StartsWith("XLua."))) |
| | | && (assemblyList.Contains(type.Module.Assembly.GetName().Name))) |
| | | { |
| | |
| | | new List<string>(){"UnityEngine.Light", "shadowRadius"}, |
| | | new List<string>(){"UnityEngine.Light", "shadowAngle"}, |
| | | new List<string>(){"UnityEngine.Light", "SetLightDirty"}, |
| | | new List<string>(){"UnityEngine.UI.Text", "OnRebuildRequested"}, |
| | | new List<string>(){"UnityEngine.UI.Graphic", "OnRebuildRequested"}, |
| | | new List<string>(){"UnityEngine.AnimatorControllerParameter", "name"}, |
| | | new List<string>(){"UnityEngine.AudioSettings", "GetSpatializerPluginNames"}, |
| | | new List<string>(){"UnityEngine.AudioSettings", "SetSpatializerPluginName", "System.String"}, |
| | | new List<string>(){"UnityEngine.DrivenRectTransformTracker", "StopRecordingUndo"}, |
| | | new List<string>(){"UnityEngine.DrivenRectTransformTracker", "StartRecordingUndo"}, |
| | | new List<string>(){"UnityEngine.Caching", "SetNoBackupFlag", "UnityEngine.CachedAssetBundle"}, |
| | | new List<string>(){"UnityEngine.Caching", "ResetNoBackupFlag", "UnityEngine.CachedAssetBundle"}, |
| | | new List<string>(){"UnityEngine.Caching", "SetNoBackupFlag", "System.String", "UnityEngine.Hash128"}, |
| | | new List<string>(){"UnityEngine.Caching", "ResetNoBackupFlag", "System.String", "UnityEngine.Hash128"}, |
| | | new List<string>(){"UnityEngine.Input", "IsJoystickPreconfigured", "System.String"}, |
| | | new List<string>(){"UnityEngine.LightProbeGroup", "dering"}, |
| | | new List<string>(){"UnityEngine.LightProbeGroup", "probePositions"}, |
| | | new List<string>(){"UnityEngine.Light", "SetLightDirty"}, |
| | | new List<string>(){"UnityEngine.Light", "shadowRadius"}, |
| | | new List<string>(){"UnityEngine.Light", "shadowAngle"}, |
| | | new List<string>(){"UnityEngine.ParticleSystemForceField", "FindAll"}, |
| | | new List<string>(){"UnityEngine.QualitySettings", "streamingMipmapsRenderersPerFrame"}, |
| | | new List<string>(){"UnityEngine.Texture", "imageContentsHash"} |
| | | }; |
| | | |
| | | HotfixCfg = new Dictionary<Type, HotfixFlag>(); |
| | |
| | | } |
| | | } |
| | | LuaCallCSharp = LuaCallCSharp.Distinct() |
| | | .Where(type=> IsPublic(type) && !isObsolete(type) && !type.IsGenericTypeDefinition) |
| | | .Where(type => IsPublic(type) && !isObsolete(type) && !type.IsGenericTypeDefinition) |
| | | .Where(type => !typeof(Delegate).IsAssignableFrom(type)) |
| | | .Where(type => !type.Name.Contains("<")) |
| | | .ToList(); |
| | |
| | | } |
| | | |
| | | int size = 0; |
| | | foreach(var fieldInfo in type.GetFields(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly)) |
| | | foreach (var fieldInfo in type.GetFields(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly)) |
| | | { |
| | | int t_size = SizeOf(fieldInfo.FieldType); |
| | | if (t_size == -1) |
| | |
| | | templateCache.Clear(); |
| | | Directory.CreateDirectory(save_path); |
| | | GenWrap(wraps, save_path); |
| | | GenWrapPusher(gc_optimze_list.Concat(wraps.Where(type=>type.IsEnum)).Distinct(), save_path); |
| | | GenWrapPusher(gc_optimze_list.Concat(wraps.Where(type => type.IsEnum)).Distinct(), save_path); |
| | | GenPackUnpack(gc_optimze_list.Where(type => !type.IsPrimitive && SizeOf(type) != -1), save_path); |
| | | GenInterfaceBridge(itf_bridges, save_path); |
| | | } |
| | |
| | | static void callCustomGen() |
| | | { |
| | | foreach (var method in (from type in XLua.Utils.GetAllTypes() |
| | | from method in type.GetMethods(BindingFlags.Static | BindingFlags.Public) |
| | | where method.IsDefined(typeof(GenCodeMenuAttribute), false) select method)) |
| | | from method in type.GetMethods(BindingFlags.Static | BindingFlags.Public) |
| | | where method.IsDefined(typeof(GenCodeMenuAttribute), false) |
| | | select method)) |
| | | { |
| | | method.Invoke(null, new object[] { }); |
| | | } |
| | |
| | | |
| | | LuaFunction template = XLua.TemplateEngine.LuaTemplate.Compile(luaenv, |
| | | template_src); |
| | | foreach (var gen_task in get_tasks(luaenv, new UserConfig() { |
| | | foreach (var gen_task in get_tasks(luaenv, new UserConfig() |
| | | { |
| | | LuaCallCSharp = LuaCallCSharp, |
| | | CSharpCallLua = CSharpCallLua, |
| | | ReflectionUse = ReflectionUse |
| | |
| | | gen_task.Data.SetMetaTable(meta); |
| | | meta.Dispose(); |
| | | |
| | | try |
| | | try |
| | | { |
| | | string genCode = XLua.TemplateEngine.LuaTemplate.Execute(template, gen_task.Data); |
| | | gen_task.Output.Write(genCode); |
| | |
| | | } |
| | | return _hasGenericParameter; |
| | | } |
| | | private static bool isSupportGenericParameter(Type parameterType,bool checkConstraint, ref bool _hasGenericParameter) |
| | | private static bool isSupportGenericParameter(Type parameterType, bool checkConstraint, ref bool _hasGenericParameter) |
| | | { |
| | | |
| | | if (parameterType.IsGenericParameter) |
| | |
| | | } |
| | | _hasGenericParameter = true; |
| | | } |
| | | else if(parameterType.IsGenericType) |
| | | else if (parameterType.IsGenericType) |
| | | { |
| | | foreach (var argument in parameterType.GetGenericArguments()) |
| | | { |
| | | if (!isSupportGenericParameter(argument,false, ref _hasGenericParameter)) |
| | | if (!isSupportGenericParameter(argument, false, ref _hasGenericParameter)) |
| | | return false; |
| | | } |
| | | } |