@@ -214,10 +214,11 @@ static class Lua final :
214
214
iMembers = 0 , // Number of static functions used
215
215
iMethods = 0 , // Number of class methods used
216
216
iTables = 0 , // Number of tables used
217
- iTotalStatics = 0 , // Number of static vars registered
217
+ iStatics = 0 , // Number of static vars registered
218
218
iTotalMembers = 0 , // Number of static functions in total
219
219
iTotalMethods = 0 , // Number of class methods in total
220
- iTotalTables = 0 ; // Number of tables in total
220
+ iTotalTables = 0 , // Number of tables in total
221
+ iTotalStatics = 0 ; // Number of static vars in total
221
222
// Init core libraries
222
223
for (const LuaLibStatic &llRef : llsaAPI)
223
224
{ // Increment total statistics
@@ -226,8 +227,20 @@ static class Lua final :
226
227
iTotalTables += llRef.iLLKICount ;
227
228
++iTotal;
228
229
// Ignore if this API is not allowed in the current operation mode
229
- if (!cSystem->IsCoreFlagsHave (llRef.cfcRequired )) continue ;
230
- // Increment used statistics
230
+ if (!cSystem->IsCoreFlagsHave (llRef.cfcRequired ))
231
+ { // If we have consts list?
232
+ if (llRef.lkiList )
233
+ { // Number of static vars registered in this namespace
234
+ int iStaticsNS = 0 ;
235
+ // Walk through the table
236
+ for (const LuaTable *ltPtr = llRef.lkiList ; ltPtr->cpName ; ++ltPtr)
237
+ // Add to total static variables registered for this namespace
238
+ iStaticsNS += ltPtr->iCount ;
239
+ // Add to total static variables registered
240
+ iTotalStatics += iStaticsNS;
241
+ } // Next namespace
242
+ continue ;
243
+ } // Increment used statistics
231
244
iMembers += llRef.iLLCount ;
232
245
iMethods += llRef.iLLMFCount ;
233
246
iTables += llRef.iLLKICount ;
@@ -236,8 +249,8 @@ static class Lua final :
236
249
LuaUtilPushTable (GetState (), 0 ,
237
250
llRef.iLLCount + llRef.iLLMFCount + llRef.iLLKICount );
238
251
luaL_setfuncs (GetState (), llRef.libList , 0 );
239
- // Number of static vars registered
240
- int iStatics = 0 ;
252
+ // Number of static vars registered in this namespace
253
+ int iStaticsNS = 0 ;
241
254
// If we have consts list?
242
255
if (llRef.lkiList )
243
256
{ // Walk through the table
@@ -256,16 +269,17 @@ static class Lua final :
256
269
} // Set field name and finalise const table
257
270
lua_setfield (GetState (), -2 , ltRef.cpName );
258
271
// Add to total static variables registered for this namespace
259
- iStatics += ltRef.iCount ;
272
+ iStaticsNS += ltRef.iCount ;
260
273
} // Add to total static variables registered
261
- iTotalStatics += iStatics;
274
+ iStatics += iStaticsNS;
275
+ iTotalStatics += iStaticsNS;
262
276
} // If we have don't have member functions?
263
277
if (!llRef.libmfList )
264
278
{ // Set this current list to global
265
279
lua_setglobal (GetState (), llRef.strvName .data ());
266
280
// Log progress
267
281
cLog->LogDebugExSafe (" - $ ($ members, $ tables, $ statics)." ,
268
- llRef.strvName , llRef.iLLCount , llRef.iLLKICount , iStatics );
282
+ llRef.strvName , llRef.iLLCount , llRef.iLLKICount , iStaticsNS );
269
283
// Continue
270
284
continue ;
271
285
} // Load members into this namespace too for possible aliasing.
@@ -276,7 +290,7 @@ static class Lua final :
276
290
// all threads of the same lua state share a single registry so this is
277
291
// very safe. Start by creating a new metadata table for 4 entries.
278
292
LuaUtilPushTable (GetState (), 0 , 4 );
279
- // Push the name of the metatable
293
+ // Push the name of the meta table
280
294
LuaUtilPushStrView (GetState (), llRef.strvName );
281
295
lua_setfield (GetState (), -2 , " __name" );
282
296
// Set methods so var:func() works
@@ -298,7 +312,7 @@ static class Lua final :
298
312
// Log progress
299
313
cLog->LogDebugExSafe (
300
314
" - $ ($ members, $ tables, $ statics and $ methods)." ,
301
- llRef.strvName , llRef.iLLCount , llRef.iLLKICount , iStatics ,
315
+ llRef.strvName , llRef.iLLCount , llRef.iLLKICount , iStaticsNS ,
302
316
llRef.iLLMFCount );
303
317
// For some reason, I cannot specify a __gc member for the garbage
304
318
// collector in this metadata part above because LUA seems to remove
@@ -307,17 +321,20 @@ static class Lua final :
307
321
} // Count libraries and report them
308
322
cLog->LogDebugExSafe (
309
323
" Lua registered $ of $ global namespaces...\n "
310
- " - $ of $ const tables are registered with $ statics.\n "
324
+ " - $ of $ const tables are registered.\n "
325
+ " - $ of $ static variables are registered.\n "
311
326
" - $ of $ member functions are registered.\n "
312
327
" - $ of $ method functions are registered.\n "
313
328
" - $ of $ functions are registered in total.\n "
314
- " - $ variables are registered in total." ,
329
+ " - $ of $ variables are registered in total." ,
315
330
iCount, iTotal,
316
- iTables, iTotalTables, iTotalStatics,
331
+ iTables, iTotalTables,
332
+ iStatics, iTotalStatics,
317
333
iMembers, iTotalMembers,
318
334
iMethods, iTotalMethods,
319
335
iMembers+iMethods, iTotalMembers+iTotalMethods,
320
- iMembers+iMethods+iTables+iTotalStatics);
336
+ iMembers+iMethods+iTables+iStatics,
337
+ iTotalMembers+iTotalMethods+iTotalTables+iTotalStatics);
321
338
} // Init enviornment variables?
322
339
if (FlagIsSet (LF_CORE))
323
340
{ // Log progress
0 commit comments