-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathluna.h
647 lines (578 loc) · 19.5 KB
/
luna.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
#ifndef _LUNA_H_TAESOO_MOD
#define _LUNA_H_TAESOO_MOD
// an optimized version of luna by Taesoo Kwon.
// This luna class is faster than the original luna, lunar. (Faster than OOLUA and luabind too.)
extern "C" {
#include "lua.h"
#include "lauxlib.h"
}
#include <stdio.h>
#include <string.h>
#include <string>
#include <iostream>
#include <sstream>
struct luna_eqstr{
bool operator()(const char* s1, const char* s2) const {
return strcmp(s1,s2)==0;
}
};
typedef int (*luna_mfp)(lua_State *L);
#if (defined(_MSC_VER)&& _MSC_VER<1700) || (!defined(_MSC_VER) &&__cplusplus < 201103L)
#define OLD_COMPILERS
#endif
#ifdef OLD_COMPILERS
#ifdef NO_HASH_MAP
#include <map>
struct luna_ltsz: std::binary_function<char* const &, char* const &, bool>
{
bool operator()(const char* _X, const char* _Y) const
{
return strcmp(_X, _Y)<0;
}
};
typedef std::map<const char*, luna_mfp, luna_ltsz> luna__hashmap;
#else // not defined NO_HASH_MAP
#ifdef _MSC_VER
#include <hash_map> // VC2010
class luna_stringhasher : public stdext::hash_compare <const char*>
{
public:
size_t operator() (const char* in) const
{
size_t h = 0;
const char* p;
for(p = in; *p != 0; ++p)
h = 31 * h + (*p);
return h;
}
bool operator() (const char* s1, const char* s2) const
{
return strcmp(s1, s2)<0;
}
};
typedef stdext::hash_map<const char*, luna_mfp, luna_stringhasher> luna__hashmap;
#else // UNIX
#ifndef CXX_ENABLED
#include <ext/hash_map>
typedef __gnu_cxx::hash<const char*> luna_hash_t;
typedef __gnu_cxx::hash_map<const char*, luna_mfp, luna_hash_t, luna_eqstr> luna__hashmap;
#endif
#endif // UNIX
#endif // not NO_HASH_MAP
#else // not OLD_COMPILERS
#include <unordered_map>
#ifdef _MSC_VER
class luna_hash_t
{
public:
size_t operator() (const char* in) const
{
size_t h = 0;
const char* p;
for(p = in; *p != 0; ++p)
h = 31 * h + (*p);
return h;
}
bool operator() (const char* s1, const char* s2) const
{
return strcmp(s1, s2)<0;
}
};
#else
typedef std::hash<const char*> luna_hash_t;
#endif
typedef std::unordered_map<std::string, luna_mfp> luna__hashmap;
#endif
typedef struct { const char *name; luna_mfp mfunc; } luna_RegType;
template <typename T_interface> class LunaModule {
public:
static void Register(lua_State* L)
{
// T_interface::className is namespace rather than class here. (no constructor, destructor, userdata)
int methods;
luaL_dostring(L, "if not __luna then __luna={} end");
std::string temp;
temp="if not __luna.";
temp+= T_interface::moduleName;
temp+=" then __luna.";
temp+=T_interface::moduleName;
temp+=" ={} end";
luaL_dostring(L,temp.c_str());
lua_pushstring(L, "__luna");
lua_gettable(L, LUA_GLOBALSINDEX);
int __luna= lua_gettop(L);
lua_pushstring(L, T_interface::moduleName);
lua_gettable(L, __luna);
methods= lua_gettop(L);
// fill method table
for (const luna_RegType *l = T_interface::methods; l->name; l++)
{
lua_pushstring(L, l->name);
lua_pushcfunction(L, l->mfunc);
lua_settable(L, methods);
}
lua_pop(L, 2); // drop methods and __luna
}
};
void luna_printStack(lua_State* L, bool compact=false);
void luna_dostring(lua_State* L, const char* luacode);
template <typename T> class Luna;
template <typename T>
class LunaTraits
{
public:
typedef Luna<T > luna_t;
static const char className[]; // 1051
static const int uniqueID; // 1052
};
template <typename T>
class impl_LunaTraits
{
public:
};
template <typename T> class Luna {
typedef LunaTraits<T > T_interface;
public:
typedef struct {int uniqueID; T *pT; bool gc; bool has_env;} userdataType;
inline static void set(lua_State *L, int table_index, const char *key) {
lua_pushstring(L, key);
lua_insert(L, -2); // swap value and key
lua_settable(L, table_index);
}
static void Register(lua_State *L) {
int methods;
lua_newtable(L);
methods = lua_gettop(L);
#define METHOD_TABLE_IS_METATABLE // luna_gen.lua is written assuming this is defined.
#ifdef METHOD_TABLE_IS_METATABLE
// use a single table
// sometimes more convenient
int metatable=methods;
#else // use two seperate tables
luaL_newmetatable(L, T_interface::className);
int metatable=lua_gettop(L);
#endif
luaL_dostring(L, "if not __luna then __luna={} end");
lua_pushstring(L, "__luna");
lua_gettable(L, LUA_GLOBALSINDEX);
// unlike original luna class, this class uses the same table for methods and metatable
// store methods table in __luna global table so that
// scripts can add functions written in Lua.
lua_pushstring(L, T_interface::className);
lua_pushvalue(L, methods);
lua_settable(L, -3); // __luna[className]=methods because __luna:-3, className:-2, methods:-1
lua_pushliteral(L, "__index");
lua_pushvalue(L, methods);
lua_settable(L, metatable); // metatable.__index=methods
/* lua_pushliteral(L, "__tostring"); */
/* lua_pushcfunction(L, tostring_T); */
/* lua_settable(L, metatable);// metatable.__tostring=tostring_T */
lua_pushliteral(L, "__gc");
lua_pushcfunction(L, gc_T);
lua_settable(L, metatable);
if (0)
{
// ctor supports only classname:new
lua_pushliteral(L, "new");
lua_pushcfunction(L, new_T);
lua_settable(L, methods); // add new_T to metatable table
}
else
{
// ctor supports both classname:new(...) and classname(...)
// very slight memory and performance overhead, so
// no reason to support only one
lua_newtable(L); // mt for method table
{
lua_pushcfunction(L, new_T);
lua_pushvalue(L, -1); // dup new_T function
set(L, methods, "new"); // add new_T to method table
}
set(L, -3, "__call"); // mt.__call = new_T
lua_setmetatable(L, methods);
}
// fill method table with metatable from class T
for (const luna_RegType *l = T_interface::methods; l->name; l++) {
lua_pushstring(L, l->name);
lua_pushcclosure(L, l->mfunc, 0);
lua_settable(L, methods);
}
lua_pop(L, 2); // drop methods and __luna
}
inline static int get_uniqueid(lua_State *L, int narg) {
userdataType* ud=static_cast<userdataType*>(lua_touserdata(L,narg));
if (!ud ) return -1;
return ud->uniqueID;
}
inline static userdataType* checkRaw(lua_State *L, int narg){
userdataType* ud=static_cast<userdataType*>(lua_touserdata(L,narg));
if(!ud) { printf("checkRaw: ud==nil\n"); luaL_typerror(L, narg, T_interface::className); }
if(ud->uniqueID !=T_interface::uniqueID) // type checking with almost no overhead
{
printf("ud->uid: %d != interface::uid : %d\n", ud->uniqueID, T_interface::uniqueID);
luaL_typerror(L, narg, T_interface::className);
}
return ud; // pointer to T object
}
// get userdata from Lua stack and return pointer to T object
inline static T *check(lua_State *L, int narg) {
return checkRaw(L, narg)->pT;
}
// use lunaStack::push or luna_push<T>(L,obj, gc) if possible.
inline static void push(lua_State *L, const T* obj, bool gc, const char* metatable=T_interface::className)
{
#if defined(METHOD_TABLE_IS_METATABLE)
lua_pushstring(L,"__luna");
lua_gettable(L, LUA_GLOBALSINDEX);
int __luna= lua_gettop(L);
userdataType *ud =
static_cast<userdataType*>(lua_newuserdata(L, sizeof(userdataType)));
ud->pT = (T*)obj; // store pointer to object in userdata
ud->gc=gc; // collect garbage by default
ud->has_env=false; // does this userdata has a table attached to it?
ud->uniqueID=T_interface::uniqueID;
lua_pushstring(L, metatable);
lua_gettable(L, __luna);
lua_setmetatable(L, -2);
//luna_printStack(L);
lua_insert(L, -2); // swap __luna and userdata
lua_pop(L,1);
#else
luaL_getmetatable(L, T_interface::className); // lookup metatable in Lua registry
if (lua_isnil(L, -1)) luaL_error(L, "%s missing metatable", T_interface::className);
int mt = lua_gettop(L);
userdataType *ud =
static_cast<userdataType*>(lua_newuserdata(L, sizeof(userdataType)));
ud->pT = obj; // store pointer to object in userdata
ud->gc=gc;
ud->has_env=false;
ud->uniqueID=T_interface::uniqueID;
lua_pushvalue(L, mt);
lua_setmetatable(L, -2);
#endif
}
static int new_modified_T(lua_State *L);
private:
Luna(); // hide default constructor
// create a new T object and
// push onto the Lua stack a userdata containing a pointer to T object
static int new_T(lua_State *L) {
lua_remove(L, 1); // use classname:new(), instead of classname.new()
T *obj = T_interface::_bind_ctor(L); // call constructor for T objects
push(L,obj,true);
return 1; // userdata containing pointer to T object
}
// garbage collection metamethod
static int gc_T(lua_State *L) {
userdataType *ud = static_cast<userdataType*>(lua_touserdata(L, 1));
T *obj = ud->pT;
if (ud->gc)
{
T_interface::_bind_dtor(obj); // call constructor for T objects
}
return 0;
}
static int tostring_T (lua_State *L) {
char buff[32];
userdataType *ud = static_cast<userdataType*>(lua_touserdata(L, 1));
T *obj = ud->pT;
sprintf(buff, "%p", obj);
lua_pushfstring(L, "%s (%s)", T_interface::className, buff);
return 1;
}
};
// helper class for easy use.
// wraps lua-stack and/or lua-environment
class lunaStack
{
public:
lua_State* L;
int currArg;
int delta;
lunaStack():L(NULL){} // setCheck is necessary before use.
lunaStack(lua_State* l, bool upward=true):L(l){
if (upward){
// useful for retrieving function argument. Retreieving (operator>>) doesn't remove elements from stack
setCheckFromBottom();
} else {
// Retrieving (operator>>) pops elements from stack
setCheckFromTop();
}
}
~lunaStack();
inline void setCheckFromTop() { delta=0; currArg=-1;}// gettop();}
inline void setPop() { setCheckFromTop();}
inline void setCheckFromBottom() { delta=1; currArg=1;}
inline void printStack(bool compact=true)
{
luna_printStack(L,compact);
}
// check
inline int gettop() { return lua_gettop(L);}
inline double tonumber(int i) { return luaL_checknumber(L, i);}
inline const char* tostring(int i) { return luaL_checkstring(L, i);}
inline bool toboolean(int i) { return lua_toboolean(L, i)==1;}
template <class T> T* topointer(int i) { return (T*)Luna<typename LunaTraits<T>::base_t>::check(L,i);}
inline void _incr(){
currArg+=delta;
if (delta==0) lua_pop(L,1);
}
// for variable number of arguments:
// while(l.currArg<=l.numArg()) l>>res;
// or without changing currArg:
// for (int i=l.currArg; i<=l.numArg(); i++)
// printf("%d ", l.luaType(i));
inline int numArg() { return gettop();}
// check type before pop. LUA_NUMBER, LUA_STRING
int luaType() { return lua_type(L, currArg); }
int luaType(int i) { return lua_type(L, i); }
// "number", "string", .. or luna types such as "vector3",...
std::string lunaType(int i);
std::string lunaType() { return lunaType(currArg);}
// retrieve (or pop)
friend lunaStack& operator>>( lunaStack& os, double& a)
{ a=os.tonumber(os.currArg); os._incr(); return os;}
friend lunaStack& operator>>( lunaStack& os, std::string& a)
{ a=os.tostring(os.currArg); os._incr(); return os;}
friend lunaStack& operator>>( lunaStack& os, bool& a)
{ a=os.toboolean(os.currArg); os._incr(); return os;}
friend lunaStack& operator>>( lunaStack& os, int& a)
{ a=(int)os.tonumber(os.currArg); os._incr(); return os;}
// check and pop
template <class T> T* check() {
T* a=topointer<T>(currArg);_incr(); return a;}
inline void pop() { lua_pop(L,1);}
friend lunaStack& operator<<( lunaStack& os, double a) { lua_pushnumber(os.L, a); return os;}
friend lunaStack& operator<<( lunaStack& os, bool a) { lua_pushboolean(os.L, a); return os;}
friend lunaStack& operator<<( lunaStack& os, std::string const &a) { lua_pushstring(os.L,a.c_str()); return os;}
// set garbageCollection=true when lua environment needs to adopt the object.
// e.g. push<OBJ>(new OBJ(), true);
// push<OBJ>(pointerToExistingOBJmanagedInsideCpp, false);
template <class T> void push(T const* c,bool garbageCollection=false) { Luna<typename LunaTraits<T>::base_t>::push(L,(typename LunaTraits<T>::base_t*)c,garbageCollection, LunaTraits<T>::className);}
template <class T> void push(T const& c) { Luna<typename LunaTraits<T>::base_t>::push(L,(typename LunaTraits<T>::base_t*)&c,false, LunaTraits<T>::className);}
// stack[top]=stack[tblindex][index]
inline void gettable(int tblindex, int index)
{
lua_pushnumber(L, index);
lua_gettable(L, tblindex);
}
// stack[top]=stack[tblindex][key]
inline void gettable(int tblindex, const char* key)
{
lua_pushstring(L, key);
lua_gettable(L, tblindex);
}
// stack[top]=_G[key]
inline void getglobal(const char* key){
lua_pushstring(L, key);
lua_gettable(L,LUA_GLOBALSINDEX); // stack top becomes _G[key]
}
// For example,
// to access a vector3 object "mRetarget.testSkel[2].vec3" without affecting stack,
// l.getglobal('mRetarget','testSkel');
// l.replaceTop(2);
// l.replaceTop('vec3');
// result=l.topointer<vector3>(-1);
// l.pop();
//
// stack[top]=_G[key1][key2]
inline void getglobal(const char* key1, const char* key2){
getglobal(key1);
replaceTop(key2);
}
// stack[top]=_G[key1][key2][key3]
inline void getglobal(const char* key1, const char* key2, const char* key3){
getglobal(key1);
replaceTop(key2);
replaceTop(key3);
}
inline void getglobal(const char* key1, const char* key2, const char* key3, const char* key4){
getglobal(key1);
replaceTop(key2);
replaceTop(key3);
replaceTop(key4);
}
inline void popSecondLast()
{
lua_insert(L, -2); // swap table and value
lua_pop(L,1); // pop-out prev table
}
// stack[top]=stack[top][key]
inline void replaceTop(const char* key){
if (!lua_istable(L,-1)) luaL_error(L, "Luna<>::replaceTop: non-table object cannot be accessed");
lua_pushstring(L, key);
lua_gettable(L, -2);
popSecondLast();
}
// stack[top]=stack[top][index]
inline void replaceTop(int index){
if (!lua_istable(L,-1)) luaL_error(L, "Luna<>::replaceTop: non-table object cannot be accessed");
lua_pushnumber(L, index);
lua_gettable(L, -2);
popSecondLast();
}
inline void replaceTopLUD(void* key){
if (!lua_istable(L,-1)) luaL_error(L, "Luna<>::replaceTop: non-table object cannot be accessed");
lua_pushlightuserdata(L, key);
lua_gettable(L, -2);
popSecondLast();
}
// what this does is
// local a={}
// stack[top][key]=a followed by a replaceTop operation:
// stack[top]=a
inline void replaceTop_newTable(const char* key)
{
lua_pushstring(L,key);
lua_newtable(L);
//luna_printStack(L);
lua_settable(L,-3);
//printf("asdf "); luna_printStack(L);
lua_pushstring(L,key);
lua_gettable(L,-2);
popSecondLast();
//luna_printStack(L);
}
// function call example 1 :
// lua: ret1, ret2=functionName(param1, param2, param3)
// cpp:
// l.getglobal("functionName")
// l << param1 << param2 << param3;
// l.call(3, 2);
// l >> ret2 >> ret1;
// assuming stack[-1-numIn]==function. (stack: function -> arg1 -> arg2 -> arg_numIn )
inline void call(int numIn, int numOut){
lua_call(L, numIn, numOut);
// prepare to read-out results in reverse order
setCheckFromTop(); // this is not the default mode, but it is okay to leave it that way.
}
// function call example 2 (which is identical to the example 1):
// l.getglobal("functionName")
// l << param1 << param2 << param3;
// int numOut=l.beginCall(3);
// l >> ret1 >> ret2; // note the order here.
// l.endCall(numOut); // cleans the stack
int beginCall(int numIn);
int beginPcall(int numIn, int errorFunc);
void endCall(int numOut);
template <class T> T* get(const char* key, int table_index=LUA_GLOBALSINDEX){
//luna_printStack(L);
lua_pushstring(L, key);
lua_gettable(L, table_index);
T* ptr= topointer<T>(gettop());
lua_pop(L,1);
//luna_printStack(L);
return ptr;
}
template <class T> void set(const char* key, T* ptr, int table_index=LUA_GLOBALSINDEX, bool garbageCollection=false) {
push<T>(ptr,garbageCollection);
lua_pushstring(L, key);
lua_insert(L, -2); // swap value and key
lua_settable(L, table_index);
//printf("%x %x\n", (unsigned int)ptr,(unsigned int) get<T>(key));
}
inline void settable(int table_index=LUA_GLOBALSINDEX){
lua_settable(L, table_index);
}
// linear search. returns #tbl
int arraySize(int tblindex);
// a={{"a","b"}, "c"} -> treeSize of (a)=5 : ( Root, LeftInternalNode, "a", "b", "c")
// where Root=a, LeftInternalNode={"a","b"}
int treeSize(int tblindex);
};
class luna_wrap_object // inherit this object to enable inheritance from lua
{
public:
luna_wrap_object(){}
std::string _custumMT; // custum metatable
lua_State* _L;
void setCustumMT(lua_State* L, const char* mt) { _L=L; _custumMT=mt;}
// push a member function (__luna[_custumMT][funcName]) and self object to stack
template <class T>
bool pushMemberFunc(lunaStack & l, const char* funcName )
{
/* easy to read but slower version
l.getglobal("__luna", _custumMT.c_str(), funcName);
if(!lua_isnil(l.L,-1)){
l.getglobal("__luna",_custumMT.c_str(), "aUserdata");
l.replaceTopLUD((void*)(static_cast<typename LunaTraits<T>::base_t*>(this)));
return true;
}
lua_pop(l.L,1);
return false;
*/
lua_State* L=l.L;
l.getglobal("__luna", _custumMT.c_str()); // get metatable
lua_pushstring(L, funcName);
lua_gettable(L,-2);
if(lua_isnil(L,-1)){
lua_pop(L,2);
return false;
}
lua_pushstring(L, "aUserdata");
lua_gettable(L,-3);
l.replaceTopLUD((void*)(static_cast<typename LunaTraits<T>::base_t*>((T*)this)));
lua_remove(L,-3); // pop-out metatable
return true;
}
};
class luna_derived_object // inherit this object to derive a lua class in cpp. See test_inheritance_from_lua.lua.
{
protected:
int _uniqueID;
lunaStack _l;
public:
luna_derived_object(lua_State* l):_l(l){}
luna_derived_object(lua_State* l, int uniqueID):_l(l), _uniqueID(uniqueID){}
luna_derived_object(){_l=NULL;}
virtual ~luna_derived_object();
void call_ctor(int numArg);
// push a member function and the self object.
void pushMemberAndSelf(const char* funcName);
// push only a member function
void pushMemberOnly(const char* funcName);
inline void pushSelf() { push(*this);}
void push(luna_derived_object const& o);
int _storeNewObject(); // returns a unique ID.
};
template <class T>
int Luna<T>::new_modified_T(lua_State *L) {
//luna_printStack(L);
std::string metatable=lua_tostring(L,2);
lua_remove(L, 1); // use classname:new(), instead of classname.new()
lua_remove(L, 1);
T *obj = T_interface::_bind_ctor(L); // call constructor for T objects
obj->setCustumMT(L, metatable.c_str());
//push(L,obj,true, metatable.c_str());
Luna<typename LunaTraits<T>::base_t>::push(L,(typename LunaTraits<T>::base_t*)obj,true, metatable.c_str());
lunaStack l(L);
//luna_printStack(L);
l.getglobal("__luna", metatable.c_str(), "aUserdata");
if(lua_isnil(L,-1))
{
lua_pop(L,1);
l.getglobal("__luna", metatable.c_str());
//printf("getglobal"); luna_printStack(L);
l.replaceTop_newTable("aUserdata");
}
//printf("kk ");luna_printStack(L);
// aUserdata[obj]=userdata
lua_pushlightuserdata(L, (void*)obj);
lua_pushvalue(L, -3); // dup userdata
//luna_printStack(L);
lua_settable(L, -3);
lua_pop(L,1);
//luna_printStack(L);
return 1; // userdata containing pointer to T object
}
class lunaState
{
lua_State* L;
public:
lunaState(lua_State* l):L(l){}
lua_State* ptr() const {return L;}
inline operator lua_State*() const {return L;}
void print() const { printf("%lx\n", (unsigned long) L);}
};
template <class T> void luna_push(lua_State *L, T const* c,bool garbageCollection=false) { Luna<typename LunaTraits<T>::base_t>::push(L,(typename LunaTraits<T>::base_t*)c,garbageCollection, LunaTraits<T>::className);}
#endif