6
6
7
7
namespace CppSharp . Generators . Registrable . Lua . Sol
8
8
{
9
- public class LuaSolSources : CodeGenerator
9
+ public class LuaSolSources : RegistrableSources < LuaSolGenerator >
10
10
{
11
- protected LuaSolGenerator Generator { get ; }
12
11
protected LuaSolGenerationContext GenerationContext { get ; }
13
12
protected LuaSolNamingStrategy NamingStrategy => Generator . GeneratorOptions . NamingStrategy ;
14
13
15
14
public LuaSolSources ( LuaSolGenerator generator , IEnumerable < TranslationUnit > units )
16
- : base ( generator . Context , units )
15
+ : base ( generator , units )
17
16
{
18
- Generator = generator ;
19
17
GenerationContext = new LuaSolGenerationContext ( ) ;
20
18
}
21
19
@@ -72,13 +70,12 @@ public virtual void GenerateDeclarationContainerList(DeclarationContext declarat
72
70
73
71
#region TranslationUnit
74
72
75
- public virtual string GetTranslationUnitRegistrationFunctionSignature ( TranslationUnit translationUnit )
73
+ public virtual void GenerateTranslationUnitRegistrationFunctionSignature ( TranslationUnit translationUnit )
76
74
{
77
- StringBuilder builder = new StringBuilder ( ) ;
78
- builder . Append ( "void " ) ;
79
- builder . Append ( Generator . GeneratorOptions . NamingStrategy . GetRegistrationFunctionName ( translationUnit ) ) ;
80
- builder . Append ( "(::sol::state_view& state) {" ) ;
81
- return builder . ToString ( ) ;
75
+ var generatorOptions = Generator . GeneratorOptions ;
76
+ Write ( "void " ) ;
77
+ Write ( generatorOptions . NamingStrategy . GetRegistrationFunctionName ( translationUnit ) ) ;
78
+ Write ( $ "({ generatorOptions . RootContextType } { generatorOptions . RootContextName } )") ;
82
79
}
83
80
84
81
public virtual void GenerateTranslationUnitNamespaceBegin ( TranslationUnit translationUnit )
@@ -97,7 +94,8 @@ public virtual void GenerateTranslationUnitRegistrationFunctionBegin(Translation
97
94
{
98
95
PushBlock ( BlockKind . Function ) ;
99
96
NewLine ( ) ;
100
- WriteLine ( GetTranslationUnitRegistrationFunctionSignature ( translationUnit ) ) ;
97
+ GenerateTranslationUnitRegistrationFunctionSignature ( translationUnit ) ;
98
+ WriteLine ( " {" ) ;
101
99
Indent ( ) ;
102
100
}
103
101
@@ -1194,7 +1192,7 @@ public virtual void GenerateMethod(Class @class, Method method)
1194
1192
Write ( "static_cast<" ) ;
1195
1193
Write ( method . ReturnType . Visit ( new CppTypePrinter ( Context ) ) ) ;
1196
1194
Write ( "(" ) ;
1197
- Write ( " *)") ;
1195
+ Write ( $ " { NamingStrategy . GetMembershipScopeName ( method , GenerationContext ) } *)") ;
1198
1196
Write ( "(" ) ;
1199
1197
var needsComma = false ;
1200
1198
foreach ( var parameter in method . Parameters )
@@ -1259,7 +1257,7 @@ public virtual void GenerateTypedefNameDecl(TypedefNameDecl typedef)
1259
1257
string typedefBindingContext = NamingStrategy . GetBindingContext ( typedef , GenerationContext ) ;
1260
1258
string typedefRootContextName = NamingStrategy . GetRootContextName ( GenerationContext ) ;
1261
1259
1262
- WriteLine ( $ "global{ typedefRegistrationFunctionName } {{}}({ typedefRootContextName } , { typedefBindingContext } , { typedefNameQuoted } ); /* directly */") ;
1260
+ WriteLine ( $ "//TODO: global{ typedefRegistrationFunctionName } {{}}({ typedefRootContextName } , { typedefBindingContext } , { typedefNameQuoted } ); /* directly */") ;
1263
1261
}
1264
1262
}
1265
1263
0 commit comments