Skip to content

Commit

Permalink
Merge branch 'master' of github.com:Tencent/puerts
Browse files Browse the repository at this point in the history
  • Loading branch information
chexiongsheng committed Jul 27, 2021
2 parents 0342579 + 0b56288 commit ac76fd2
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
17 changes: 17 additions & 0 deletions unity/Assets/Puerts/Src/Editor/Generator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,7 @@ public class TsTypeGenInfo
public TsTypeGenInfo[] interfaces;
public bool IsEnum;
public string EnumKeyValues;
public TsTypeGenInfo DeclaringType;
public TsMethodGenInfo[] ExtensionMethods;
public bool IsCheckOk = false;
public string FullName
Expand Down Expand Up @@ -698,9 +699,15 @@ public static TsTypeGenInfo ToTsTypeGenInfo(Type type, HashSet<Type> genTypeSet)
IsDelegate = (IsDelegate(type) && type != typeof(Delegate)),
IsInterface = type.IsInterface,
Namespace = type.Namespace,
DeclaringType = null,
ExtensionMethods = GetExtensionMethods(type, genTypeSet).Select(m => ToTsMethodGenInfo(m, type.IsGenericTypeDefinition, true)).ToArray()
};

if (type.DeclaringType != null)
{
result.DeclaringType = ToTsTypeGenInfo(type.DeclaringType, genTypeSet);
}

if (result.IsGenericTypeDefinition)
{
result.GenericParameters = type.GetGenericArguments().Select(t => t.ToString()).ToArray();
Expand Down Expand Up @@ -730,8 +737,13 @@ public static TsTypeGenInfo ToTsTypeGenInfo(Type type, HashSet<Type> genTypeSet)
{
Name = interfaces[i].IsGenericType ? GetTsTypeName(interfaces[i]) : interfaces[i].Name.Replace('`', '$'),
Document = DocResolver.GetTsDocument(interfaces[i]),
DeclaringType = null,
Namespace = interfaces[i].Namespace
};
if (interfaces[i].DeclaringType != null)
{
interfaceTypeGenInfo.DeclaringType = ToTsTypeGenInfo(interfaces[i].DeclaringType, genTypeSet);
}
if (interfaces[i].IsGenericType && interfaces[i].Namespace != null)
{
interfaceTypeGenInfo.Name = interfaceTypeGenInfo.Name.Substring(interfaces[i].Namespace.Length + 1);
Expand Down Expand Up @@ -767,8 +779,13 @@ public static TsTypeGenInfo ToTsTypeGenInfo(Type type, HashSet<Type> genTypeSet)
{
Name = type.BaseType.IsGenericType ? GetTsTypeName(type.BaseType) : type.BaseType.Name.Replace('`', '$'),
Document = DocResolver.GetTsDocument(type.BaseType),
DeclaringType = null,
Namespace = type.BaseType.Namespace
};
if (type.BaseType.DeclaringType != null)
{
result.BaseType.DeclaringType = ToTsTypeGenInfo(type.BaseType.DeclaringType, genTypeSet);
}
if (type.BaseType.IsGenericType && type.BaseType.Namespace != null)
{
result.BaseType.Name = result.BaseType.Name.Substring(type.BaseType.Namespace.Length + 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,13 @@ function typeDeclaration(type, level1) {
if (level1 && !type.IsDelegate && !type.IsEnum && interfaces.length) {
result += ((type.IsInterface ? " extends " : " implements ") + interfaces.map(interface=> typeDeclaration(interface)).join(', '))
}
if (!level1 && type.Namespace) {
result = type.Namespace + "." + result;
if (!level1) {
if (type.DeclaringType != null) {
result = typeDeclaration(type.DeclaringType) + "." + result;

} else {
result = type.Namespace + "." + result;
}
}
return result;
}
Expand Down

0 comments on commit ac76fd2

Please sign in to comment.