@@ -98,7 +98,7 @@ class JsonType
9898 [ Serializable ]
9999 class JsonBaseType
100100 {
101- public JsonGenericParams [ ] GenericParams ;
101+ public string [ ] GenericTypes ;
102102 public int MaxSimultaneous ;
103103 public JsonConstructor [ ] Constructors ;
104104 public JsonMethod [ ] OverrideMethods ;
@@ -521,10 +521,34 @@ static void DoPostCompileWork(bool canRefreshAssetDb)
521521
522522 if ( jsonType . BaseTypes != null )
523523 {
524+ // C++ template declaration if necessary
525+ Type type = GetType (
526+ jsonType . Name ,
527+ assemblies ) ;
528+ Type [ ] genericArgTypes = type . GetGenericArguments ( ) ;
529+ string cppBaseTypeName = "Base" + type . Name ;
530+ if ( ! IsStatic ( type ) )
531+ {
532+ foreach ( JsonBaseType jsonBaseType in jsonType . BaseTypes )
533+ {
534+ if ( jsonBaseType . GenericTypes != null )
535+ {
536+ AppendCppTemplateDeclaration (
537+ cppBaseTypeName ,
538+ type . Namespace ,
539+ genericArgTypes . Length ,
540+ builders . CppTypeDeclarations ) ;
541+ }
542+ }
543+ }
544+
524545 foreach ( JsonBaseType jsonBaseType in jsonType . BaseTypes )
525546 {
526547 AppendBaseType (
548+ type ,
549+ genericArgTypes ,
527550 jsonType . Name ,
551+ cppBaseTypeName ,
528552 jsonBaseType ,
529553 assemblies ,
530554 builders ) ;
@@ -1628,56 +1652,38 @@ static void AppendType(
16281652 }
16291653
16301654 static void AppendBaseType (
1655+ Type type ,
1656+ Type [ ] genericArgTypes ,
16311657 string typeName ,
1658+ string cppBaseTypeName ,
16321659 JsonBaseType jsonBaseType ,
16331660 Assembly [ ] assemblies ,
16341661 StringBuilders builders )
16351662 {
1636- Type type = GetType ( typeName , assemblies ) ;
1637- string cppTypeName = "Base" + type . Name ;
1638- Type [ ] genericArgTypes = type . GetGenericArguments ( ) ;
1639- if ( jsonBaseType . GenericParams != null )
1663+ int ? maxSimultaneous = jsonBaseType . MaxSimultaneous != 0
1664+ ? jsonBaseType . MaxSimultaneous
1665+ : default ( int ? ) ;
1666+ if ( jsonBaseType . GenericTypes != null )
16401667 {
1641- if ( ! IsStatic ( type ) )
1642- {
1643- AppendCppTemplateDeclaration (
1644- cppTypeName ,
1645- type . Namespace ,
1646- genericArgTypes . Length ,
1647- builders . CppTypeDeclarations ) ;
1648- }
1649-
1650- foreach ( JsonGenericParams jsonGenericParams
1651- in jsonBaseType . GenericParams )
1652- {
1653- Type [ ] typeParams = GetTypes (
1654- jsonGenericParams . Types ,
1655- assemblies ) ;
1656- Type genericType = type . MakeGenericType ( typeParams ) ;
1657- int ? maxSimultaneous = jsonGenericParams . MaxSimultaneous != 0
1658- ? jsonGenericParams . MaxSimultaneous
1659- : jsonBaseType . MaxSimultaneous != 0
1660- ? jsonBaseType . MaxSimultaneous
1661- : default ( int ? ) ;
1662- AppendBaseType (
1663- genericType ,
1664- jsonBaseType ,
1665- cppTypeName ,
1666- typeParams ,
1667- maxSimultaneous ,
1668- assemblies ,
1669- builders ) ;
1670- }
1668+ Type [ ] typeParams = GetTypes (
1669+ jsonBaseType . GenericTypes ,
1670+ assemblies ) ;
1671+ Type genericType = type . MakeGenericType ( typeParams ) ;
1672+ AppendBaseType (
1673+ genericType ,
1674+ jsonBaseType ,
1675+ cppBaseTypeName ,
1676+ typeParams ,
1677+ maxSimultaneous ,
1678+ assemblies ,
1679+ builders ) ;
16711680 }
16721681 else
16731682 {
1674- int ? maxSimultaneous = jsonBaseType . MaxSimultaneous != 0
1675- ? jsonBaseType . MaxSimultaneous
1676- : default ( int ? ) ;
16771683 AppendBaseType (
16781684 type ,
16791685 jsonBaseType ,
1680- cppTypeName ,
1686+ cppBaseTypeName ,
16811687 null ,
16821688 maxSimultaneous ,
16831689 assemblies ,
@@ -6381,7 +6387,7 @@ static void AppendDelegate(
63816387 static void AppendBaseType (
63826388 Type type ,
63836389 JsonBaseType jsonBaseType ,
6384- string cppTypeName ,
6390+ string cppBaseTypeName ,
63856391 Type [ ] typeParams ,
63866392 int ? maxSimultaneous ,
63876393 Assembly [ ] assemblies ,
@@ -6410,7 +6416,8 @@ static void AppendBaseType(
64106416 builders . TempStrBuilder [ 0 ] ) ;
64116417 string releaseFuncNameLower = builders . TempStrBuilder . ToString ( ) ;
64126418
6413- // Either use specified constructors or the default constructor
6419+ // Either use specified constructors, the default constructor, or
6420+ // nothing in the case of MonoBehaviour (where you can't call 'new')
64146421 JsonConstructor [ ] jsonConstructors = jsonBaseType . Constructors ;
64156422 if ( jsonConstructors == null )
64166423 {
@@ -6505,7 +6512,7 @@ static void AppendBaseType(
65056512 // C++ type declaration
65066513 int indent = AppendCppTypeDeclaration (
65076514 type . Namespace ,
6508- cppTypeName ,
6515+ cppBaseTypeName ,
65096516 false ,
65106517 typeParams ,
65116518 builders . CppTypeDeclarations ) ;
@@ -6524,21 +6531,21 @@ static void AppendBaseType(
65246531 AppendCppFreeListStateAndFunctions (
65256532 type ,
65266533 typeParams ,
6527- cppTypeName ,
6534+ cppBaseTypeName ,
65286535 bindingTypeName ,
65296536 builders . CppGlobalStateAndFunctions ) ;
65306537
65316538 AppendCppFreeListInit (
65326539 type ,
65336540 typeParams ,
6534- cppTypeName ,
6541+ cppBaseTypeName ,
65356542 maxSimultaneous ,
65366543 bindingTypeName ,
65376544 builders . CppInitBody ) ;
65386545
65396546 // C++ type definition (begin)
65406547 AppendCppTypeDefinitionBegin (
6541- cppTypeName ,
6548+ cppBaseTypeName ,
65426549 type . Namespace ,
65436550 TypeKind . Class ,
65446551 typeParams ,
@@ -6562,7 +6569,7 @@ static void AppendBaseType(
65626569 indent + 1 ,
65636570 builders . CppTypeDefinitions ) ;
65646571 AppendCppMethodDeclaration (
6565- cppTypeName ,
6572+ cppBaseTypeName ,
65666573 false ,
65676574 false ,
65686575 false ,
@@ -6658,7 +6665,7 @@ static void AppendBaseType(
66586665 type . Name ,
66596666 type . Namespace ,
66606667 TypeKind . Class ,
6661- cppTypeName ,
6668+ cppBaseTypeName ,
66626669 type ,
66636670 typeParams ,
66646671 typeParams ,
@@ -6672,7 +6679,7 @@ static void AppendBaseType(
66726679
66736680 AppendCppBaseTypeNullptrConstructor (
66746681 bindingTypeName ,
6675- cppTypeName ,
6682+ cppBaseTypeName ,
66766683 typeParams ,
66776684 type . Name ,
66786685 type . Namespace ,
@@ -6683,7 +6690,7 @@ static void AppendBaseType(
66836690
66846691 AppendCppBaseTypeCopyConstructor (
66856692 bindingTypeName ,
6686- cppTypeName ,
6693+ cppBaseTypeName ,
66876694 typeParams ,
66886695 type . Name ,
66896696 type . Namespace ,
@@ -6693,7 +6700,7 @@ static void AppendBaseType(
66936700 builders . CppMethodDefinitions ) ;
66946701
66956702 AppendCppBaseTypeMoveConstructor (
6696- cppTypeName ,
6703+ cppBaseTypeName ,
66976704 typeParams ,
66986705 type . Name ,
66996706 type . Namespace ,
@@ -6704,18 +6711,18 @@ static void AppendBaseType(
67046711
67056712 AppendCppBaseTypeHandleConstructor (
67066713 bindingTypeName ,
6707- cppTypeName ,
6714+ cppBaseTypeName ,
67086715 typeParams ,
67096716 type . Name ,
67106717 type . Namespace ,
67116718 typeParams ,
67126719 false ,
67136720 cppMethodDefinitionsIndent ,
67146721 builders . CppMethodDefinitions ) ;
6715-
6722+
67166723 AppendCppBaseTypeDestructor (
67176724 bindingTypeName ,
6718- cppTypeName ,
6725+ cppBaseTypeName ,
67196726 typeParams ,
67206727 false ,
67216728 releaseFuncName ,
@@ -6724,14 +6731,14 @@ static void AppendBaseType(
67246731
67256732 AppendCppBaseTypeAssignmentOperatorSameType (
67266733 type ,
6727- cppTypeName ,
6734+ cppBaseTypeName ,
67286735 typeParams ,
67296736 false ,
67306737 cppMethodDefinitionsIndent ,
67316738 builders . CppMethodDefinitions ) ;
67326739
67336740 AppendCppBaseTypeAssignmentOperatorNullptr (
6734- cppTypeName ,
6741+ cppBaseTypeName ,
67356742 typeParams ,
67366743 false ,
67376744 releaseFuncName ,
@@ -6740,21 +6747,21 @@ static void AppendBaseType(
67406747
67416748 AppendCppBaseTypeMoveAssignmentOperator (
67426749 bindingTypeName ,
6743- cppTypeName ,
6750+ cppBaseTypeName ,
67446751 typeParams ,
67456752 false ,
67466753 releaseFuncName ,
67476754 cppMethodDefinitionsIndent ,
67486755 builders . CppMethodDefinitions ) ;
67496756
67506757 AppendCppBaseTypeEqualityOperator (
6751- cppTypeName ,
6758+ cppBaseTypeName ,
67526759 typeParams ,
67536760 cppMethodDefinitionsIndent ,
67546761 builders . CppMethodDefinitions ) ;
67556762
67566763 AppendCppBaseTypeInequalityOperator (
6757- cppTypeName ,
6764+ cppBaseTypeName ,
67586765 typeParams ,
67596766 cppMethodDefinitionsIndent ,
67606767 builders . CppMethodDefinitions ) ;
@@ -6855,7 +6862,7 @@ static void AppendBaseType(
68556862 type ,
68566863 bindingTypeName ,
68576864 typeParams ,
6858- cppTypeName ,
6865+ cppBaseTypeName ,
68596866 methodInfo ,
68606867 indent ,
68616868 builders ) ;
@@ -6876,7 +6883,7 @@ static void AppendBaseType(
68766883 type ,
68776884 bindingTypeName ,
68786885 typeParams ,
6879- cppTypeName ,
6886+ cppBaseTypeName ,
68806887 methodInfo ,
68816888 indent ,
68826889 builders ) ;
@@ -6902,7 +6909,7 @@ static void AppendBaseType(
69026909 type ,
69036910 bindingTypeName ,
69046911 typeParams ,
6905- cppTypeName ,
6912+ cppBaseTypeName ,
69066913 methodInfo ,
69076914 indent ,
69086915 builders ) ;
@@ -6922,7 +6929,7 @@ static void AppendBaseType(
69226929 AppendBaseTypeProperty (
69236930 type ,
69246931 bindingTypeName ,
6925- cppTypeName ,
6932+ cppBaseTypeName ,
69266933 typeParams ,
69276934 propertyInfo ,
69286935 getMethodInfo ,
@@ -6949,7 +6956,7 @@ static void AppendBaseType(
69496956 AppendBaseTypeProperty (
69506957 type ,
69516958 bindingTypeName ,
6952- cppTypeName ,
6959+ cppBaseTypeName ,
69536960 typeParams ,
69546961 propertyInfo ,
69556962 getMethodInfo ,
@@ -7009,7 +7016,7 @@ static void AppendBaseType(
70097016 AppendBaseTypeProperty (
70107017 type ,
70117018 bindingTypeName ,
7012- cppTypeName ,
7019+ cppBaseTypeName ,
70137020 typeParams ,
70147021 propertyInfo ,
70157022 getMethodInfo ,
@@ -7032,7 +7039,7 @@ static void AppendBaseType(
70327039 AppendBaseTypeEvent (
70337040 type ,
70347041 bindingTypeName ,
7035- cppTypeName ,
7042+ cppBaseTypeName ,
70367043 typeParams ,
70377044 eventInfo ,
70387045 addMethodInfo ,
@@ -7058,7 +7065,7 @@ static void AppendBaseType(
70587065 AppendBaseTypeEvent (
70597066 type ,
70607067 bindingTypeName ,
7061- cppTypeName ,
7068+ cppBaseTypeName ,
70627069 typeParams ,
70637070 eventInfo ,
70647071 addMethodInfo ,
@@ -7118,7 +7125,7 @@ static void AppendBaseType(
71187125 AppendBaseTypeEvent (
71197126 type ,
71207127 bindingTypeName ,
7121- cppTypeName ,
7128+ cppBaseTypeName ,
71227129 typeParams ,
71237130 eventInfo ,
71247131 addMethodInfo ,
@@ -8814,7 +8821,7 @@ static void AppendCppBaseTypeHandleConstructor(
88148821 output ) ;
88158822 output . Append ( "\n " ) ;
88168823 }
8817-
8824+
88188825 static void AppendCppBaseTypeMoveConstructor (
88198826 string cppTypeName ,
88208827 Type [ ] typeParams ,
0 commit comments