1 /* ----------------------------------------------------------------------------
2 * This file was automatically generated by SWIG (https://www.swig.org).
5 * Do not make changes to this file unless you know what you are doing - modify
6 * the SWIG interface file instead.
7 * ----------------------------------------------------------------------------- */
10 #define SWIG_VERSION 0x040201
12 #define SWIG_LUA_TARGET SWIG_LUA_FLAVOR_LUA
13 #define SWIG_LUA_MODULE_GLOBAL
15 /* -----------------------------------------------------------------------------
16 * This section contains generic SWIG labels for method/variable
17 * declarations/attributes, and other compiler dependent labels.
18 * ----------------------------------------------------------------------------- */
20 /* template workaround for compilers that cannot correctly implement the C++ standard */
21 #ifndef SWIGTEMPLATEDISAMBIGUATOR
22 # if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x560)
23 # define SWIGTEMPLATEDISAMBIGUATOR template
24 # elif defined(__HP_aCC)
25 /* Needed even with `aCC -AA' when `aCC -V' reports HP ANSI C++ B3910B A.03.55 */
26 /* If we find a maximum version that requires this, the test would be __HP_aCC <= 35500 for A.03.55 */
27 # define SWIGTEMPLATEDISAMBIGUATOR template
29 # define SWIGTEMPLATEDISAMBIGUATOR
33 /* inline attribute */
35 # if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__))
36 # define SWIGINLINE inline
42 /* attribute recognised by some compilers to avoid 'unused' warnings */
44 # if defined(__GNUC__)
45 # if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
46 # define SWIGUNUSED __attribute__ ((__unused__))
51 # define SWIGUNUSED __attribute__ ((__unused__))
57 #ifndef SWIG_MSC_UNSUPPRESS_4505
58 # if defined(_MSC_VER)
59 # pragma warning(disable : 4505) /* unreferenced local function has been removed */
63 #ifndef SWIGUNUSEDPARM
65 # define SWIGUNUSEDPARM(p)
67 # define SWIGUNUSEDPARM(p) p SWIGUNUSED
71 /* internal SWIG method */
73 # define SWIGINTERN static SWIGUNUSED
76 /* internal inline SWIG method */
77 #ifndef SWIGINTERNINLINE
78 # define SWIGINTERNINLINE SWIGINTERN SWIGINLINE
81 /* exporting methods */
83 # if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
84 # ifndef GCC_HASCLASSVISIBILITY
85 # define GCC_HASCLASSVISIBILITY
91 # if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
92 # if defined(STATIC_LINKED)
95 # define SWIGEXPORT __declspec(dllexport)
98 # if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY)
99 # define SWIGEXPORT __attribute__ ((visibility("default")))
106 /* calling conventions for Windows */
108 # if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
109 # define SWIGSTDCALL __stdcall
115 /* Deal with Microsoft's attempt at deprecating C standard runtime functions */
116 #if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE)
117 # define _CRT_SECURE_NO_DEPRECATE
120 /* Deal with Microsoft's attempt at deprecating methods in the standard C++ library */
121 #if !defined(SWIG_NO_SCL_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_SCL_SECURE_NO_DEPRECATE)
122 # define _SCL_SECURE_NO_DEPRECATE
125 /* Deal with Apple's deprecated 'AssertMacros.h' from Carbon-framework */
126 #if defined(__APPLE__) && !defined(__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES)
127 # define __ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES 0
130 /* Intel's compiler complains if a variable which was never initialised is
131 * cast to void, which is a common idiom which we use to indicate that we
132 * are aware a variable isn't used. So we just silence that warning.
133 * See: https://github.com/swig/swig/issues/192 for more discussion.
135 #ifdef __INTEL_COMPILER
136 # pragma warning disable 592
139 #if defined(__cplusplus) && __cplusplus >=201103L
140 # define SWIG_NULLPTR nullptr
142 # define SWIG_NULLPTR NULL
145 /* -----------------------------------------------------------------------------
148 * Macros to provide support compatibility with older C and C++ standards.
149 * ----------------------------------------------------------------------------- */
151 /* C99 and C++11 should provide snprintf, but define SWIG_NO_SNPRINTF
152 * if you're missing it.
154 #if ((defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L) || \
155 (defined __cplusplus && __cplusplus >= 201103L) || \
156 defined SWIG_HAVE_SNPRINTF) && \
157 !defined SWIG_NO_SNPRINTF
158 # define SWIG_snprintf(O,S,F,A) snprintf(O,S,F,A)
159 # define SWIG_snprintf2(O,S,F,A,B) snprintf(O,S,F,A,B)
161 /* Fallback versions ignore the buffer size, but most of our uses either have a
162 * fixed maximum possible size or dynamically allocate a buffer that's large
165 # define SWIG_snprintf(O,S,F,A) sprintf(O,F,A)
166 # define SWIG_snprintf2(O,S,F,A,B) sprintf(O,F,A,B)
169 /* -----------------------------------------------------------------------------
172 * This file contains generic C API SWIG runtime support for pointer
174 * ----------------------------------------------------------------------------- */
176 /* This should only be incremented when either the layout of swig_type_info changes,
177 or for whatever reason, the runtime changes incompatibly */
178 #define SWIG_RUNTIME_VERSION "4"
180 /* define SWIG_TYPE_TABLE_NAME as "SWIG_TYPE_TABLE" */
181 #ifdef SWIG_TYPE_TABLE
182 # define SWIG_QUOTE_STRING(x) #x
183 # define SWIG_EXPAND_AND_QUOTE_STRING(x) SWIG_QUOTE_STRING(x)
184 # define SWIG_TYPE_TABLE_NAME SWIG_EXPAND_AND_QUOTE_STRING(SWIG_TYPE_TABLE)
186 # define SWIG_TYPE_TABLE_NAME
190 You can use the SWIGRUNTIME and SWIGRUNTIMEINLINE macros for
191 creating a static or dynamic library from the SWIG runtime code.
192 In 99.9% of the cases, SWIG just needs to declare them as 'static'.
194 But only do this if strictly necessary, ie, if you have problems
195 with your compiler or suchlike.
199 # define SWIGRUNTIME SWIGINTERN
202 #ifndef SWIGRUNTIMEINLINE
203 # define SWIGRUNTIMEINLINE SWIGRUNTIME SWIGINLINE
206 /* Generic buffer size */
207 #ifndef SWIG_BUFFER_SIZE
208 # define SWIG_BUFFER_SIZE 1024
211 /* Flags for pointer conversions */
212 #define SWIG_POINTER_DISOWN 0x1
213 #define SWIG_CAST_NEW_MEMORY 0x2
214 #define SWIG_POINTER_NO_NULL 0x4
215 #define SWIG_POINTER_CLEAR 0x8
216 #define SWIG_POINTER_RELEASE (SWIG_POINTER_CLEAR | SWIG_POINTER_DISOWN)
218 /* Flags for new pointer objects */
219 #define SWIG_POINTER_OWN 0x1
223 Flags/methods for returning states.
225 The SWIG conversion methods, as ConvertPtr, return an integer
226 that tells if the conversion was successful or not. And if not,
227 an error code can be returned (see swigerrors.swg for the codes).
229 Use the following macros/flags to set or process the returning
232 In old versions of SWIG, code such as the following was usually written:
234 if (SWIG_ConvertPtr(obj,vptr,ty.flags) != -1) {
240 Now you can be more explicit:
242 int res = SWIG_ConvertPtr(obj,vptr,ty.flags);
243 if (SWIG_IsOK(res)) {
249 which is the same really, but now you can also do
252 int res = SWIG_ConvertPtr(obj,(void **)(&ptr),ty.flags);
253 if (SWIG_IsOK(res)) {
255 if (SWIG_IsNewObj(res) {
265 I.e., now SWIG_ConvertPtr can return new objects and you can
266 identify the case and take care of the deallocation. Of course that
267 also requires SWIG_ConvertPtr to return new result values, such as
269 int SWIG_ConvertPtr(obj, ptr,...) {
271 if (<need new object>) {
272 *ptr = <ptr to new allocated object>;
275 *ptr = <ptr to old object>;
283 Of course, returning the plain '0(success)/-1(fail)' still works, but you can be
284 more explicit by returning SWIG_BADOBJ, SWIG_ERROR or any of the
287 Finally, if the SWIG_CASTRANK_MODE is enabled, the result code
288 allows returning the 'cast rank', for example, if you have this
295 food(1) // cast rank '1' (1 -> 1.0)
296 fooi(1) // cast rank '0'
298 just use the SWIG_AddCast()/SWIG_CheckState()
302 /* Runtime errors are < 0 */
303 #define SWIG_ERROR (-1)
304 /* Errors in range -1 to -99 are in swigerrors.swg (errors for all languages including those not using the runtime) */
305 /* Errors in range -100 to -199 are language specific errors defined in *errors.swg */
306 /* Errors < -200 are generic runtime specific errors */
307 #define SWIG_ERROR_RELEASE_NOT_OWNED (-200)
309 #define SWIG_IsOK(r) (r >= 0)
310 #define SWIG_ArgError(r) ((r != SWIG_ERROR) ? r : SWIG_TypeError)
312 /* The CastRankLimit says how many bits are used for the cast rank */
313 #define SWIG_CASTRANKLIMIT (1 << 8)
314 /* The NewMask denotes the object was created (using new/malloc) */
315 #define SWIG_NEWOBJMASK (SWIG_CASTRANKLIMIT << 1)
316 /* The TmpMask is for in/out typemaps that use temporary objects */
317 #define SWIG_TMPOBJMASK (SWIG_NEWOBJMASK << 1)
318 /* Simple returning values */
319 #define SWIG_BADOBJ (SWIG_ERROR)
320 #define SWIG_OLDOBJ (SWIG_OK)
321 #define SWIG_NEWOBJ (SWIG_OK | SWIG_NEWOBJMASK)
322 #define SWIG_TMPOBJ (SWIG_OK | SWIG_TMPOBJMASK)
323 /* Check, add and del object mask methods */
324 #define SWIG_AddNewMask(r) (SWIG_IsOK(r) ? (r | SWIG_NEWOBJMASK) : r)
325 #define SWIG_DelNewMask(r) (SWIG_IsOK(r) ? (r & ~SWIG_NEWOBJMASK) : r)
326 #define SWIG_IsNewObj(r) (SWIG_IsOK(r) && (r & SWIG_NEWOBJMASK))
327 #define SWIG_AddTmpMask(r) (SWIG_IsOK(r) ? (r | SWIG_TMPOBJMASK) : r)
328 #define SWIG_DelTmpMask(r) (SWIG_IsOK(r) ? (r & ~SWIG_TMPOBJMASK) : r)
329 #define SWIG_IsTmpObj(r) (SWIG_IsOK(r) && (r & SWIG_TMPOBJMASK))
332 #if defined(SWIG_CASTRANK_MODE)
333 # ifndef SWIG_TypeRank
334 # define SWIG_TypeRank unsigned long
336 # ifndef SWIG_MAXCASTRANK /* Default cast allowed */
337 # define SWIG_MAXCASTRANK (2)
339 # define SWIG_CASTRANKMASK ((SWIG_CASTRANKLIMIT) -1)
340 # define SWIG_CastRank(r) (r & SWIG_CASTRANKMASK)
341 SWIGINTERNINLINE
int SWIG_AddCast(int r
) {
342 return SWIG_IsOK(r
) ? ((SWIG_CastRank(r
) < SWIG_MAXCASTRANK
) ? (r
+ 1) : SWIG_ERROR
) : r
;
344 SWIGINTERNINLINE
int SWIG_CheckState(int r
) {
345 return SWIG_IsOK(r
) ? SWIG_CastRank(r
) + 1 : 0;
347 #else /* no cast-rank mode */
348 # define SWIG_AddCast(r) (r)
349 # define SWIG_CheckState(r) (SWIG_IsOK(r) ? 1 : 0)
359 typedef void *(*swig_converter_func
)(void *, int *);
360 typedef struct swig_type_info
*(*swig_dycast_func
)(void **);
362 /* Structure to store information on one type */
363 typedef struct swig_type_info
{
364 const char *name
; /* mangled name of this type */
365 const char *str
; /* human readable name of this type */
366 swig_dycast_func dcast
; /* dynamic cast function down a hierarchy */
367 struct swig_cast_info
*cast
; /* linked list of types that can cast into this type */
368 void *clientdata
; /* language specific type data */
369 int owndata
; /* flag if the structure owns the clientdata */
372 /* Structure to store a type and conversion function used for casting */
373 typedef struct swig_cast_info
{
374 swig_type_info
*type
; /* pointer to type that is equivalent to this type */
375 swig_converter_func converter
; /* function to cast the void pointers */
376 struct swig_cast_info
*next
; /* pointer to next cast in linked list */
377 struct swig_cast_info
*prev
; /* pointer to the previous cast */
380 /* Structure used to store module information
381 * Each module generates one structure like this, and the runtime collects
382 * all of these structures and stores them in a circularly linked list.*/
383 typedef struct swig_module_info
{
384 swig_type_info
**types
; /* Array of pointers to swig_type_info structures that are in this module */
385 size_t size
; /* Number of types in this module */
386 struct swig_module_info
*next
; /* Pointer to next element in circularly linked list */
387 swig_type_info
**type_initial
; /* Array of initially generated type structures */
388 swig_cast_info
**cast_initial
; /* Array of initially generated casting structures */
389 void *clientdata
; /* Language specific module data */
393 Compare two type names skipping the space characters, therefore
394 "char*" == "char *" and "Class<int>" == "Class<int >", etc.
396 Return 0 when the two name types are equivalent, as in
397 strncmp, but skipping ' '.
400 SWIG_TypeNameComp(const char *f1
, const char *l1
,
401 const char *f2
, const char *l2
) {
402 for (; (f1
!= l1
) && (f2
!= l2
); ++f1
, ++f2
) {
403 while ((*f1
== ' ') && (f1
!= l1
)) ++f1
;
404 while ((*f2
== ' ') && (f2
!= l2
)) ++f2
;
405 if (*f1
!= *f2
) return (*f1
> *f2
) ? 1 : -1;
407 return (int)((l1
- f1
) - (l2
- f2
));
411 Check type equivalence in a name list like <name1>|<name2>|...
412 Return 0 if equal, -1 if nb < tb, 1 if nb > tb
415 SWIG_TypeCmp(const char *nb
, const char *tb
) {
417 const char *te
= tb
+ strlen(tb
);
419 while (equiv
!= 0 && *ne
) {
420 for (nb
= ne
; *ne
; ++ne
) {
421 if (*ne
== '|') break;
423 equiv
= SWIG_TypeNameComp(nb
, ne
, tb
, te
);
430 Check type equivalence in a name list like <name1>|<name2>|...
431 Return 0 if not equal, 1 if equal
434 SWIG_TypeEquiv(const char *nb
, const char *tb
) {
435 return SWIG_TypeCmp(nb
, tb
) == 0 ? 1 : 0;
441 SWIGRUNTIME swig_cast_info
*
442 SWIG_TypeCheck(const char *c
, swig_type_info
*ty
) {
444 swig_cast_info
*iter
= ty
->cast
;
446 if (strcmp(iter
->type
->name
, c
) == 0) {
447 if (iter
== ty
->cast
)
449 /* Move iter to the top of the linked list */
450 iter
->prev
->next
= iter
->next
;
452 iter
->next
->prev
= iter
->prev
;
453 iter
->next
= ty
->cast
;
455 if (ty
->cast
) ty
->cast
->prev
= iter
;
466 Identical to SWIG_TypeCheck, except strcmp is replaced with a pointer comparison
468 SWIGRUNTIME swig_cast_info
*
469 SWIG_TypeCheckStruct(const swig_type_info
*from
, swig_type_info
*ty
) {
471 swig_cast_info
*iter
= ty
->cast
;
473 if (iter
->type
== from
) {
474 if (iter
== ty
->cast
)
476 /* Move iter to the top of the linked list */
477 iter
->prev
->next
= iter
->next
;
479 iter
->next
->prev
= iter
->prev
;
480 iter
->next
= ty
->cast
;
482 if (ty
->cast
) ty
->cast
->prev
= iter
;
493 Cast a pointer up an inheritance hierarchy
495 SWIGRUNTIMEINLINE
void *
496 SWIG_TypeCast(swig_cast_info
*ty
, void *ptr
, int *newmemory
) {
497 return ((!ty
) || (!ty
->converter
)) ? ptr
: (*ty
->converter
)(ptr
, newmemory
);
501 Dynamic pointer casting. Down an inheritance hierarchy
503 SWIGRUNTIME swig_type_info
*
504 SWIG_TypeDynamicCast(swig_type_info
*ty
, void **ptr
) {
505 swig_type_info
*lastty
= ty
;
506 if (!ty
|| !ty
->dcast
) return ty
;
507 while (ty
&& (ty
->dcast
)) {
508 ty
= (*ty
->dcast
)(ptr
);
515 Return the name associated with this type
517 SWIGRUNTIMEINLINE
const char *
518 SWIG_TypeName(const swig_type_info
*ty
) {
523 Return the pretty name associated with this type,
524 that is an unmangled type name in a form presentable to the user.
526 SWIGRUNTIME
const char *
527 SWIG_TypePrettyName(const swig_type_info
*type
) {
528 /* The "str" field contains the equivalent pretty names of the
529 type, separated by vertical-bar characters. Choose the last
530 name. It should be the most specific; a fully resolved name
531 but not necessarily with default template parameters expanded. */
532 if (!type
) return NULL
;
533 if (type
->str
!= NULL
) {
534 const char *last_name
= type
->str
;
536 for (s
= type
->str
; *s
; s
++)
537 if (*s
== '|') last_name
= s
+ 1;
544 Set the clientdata field for a type
547 SWIG_TypeClientData(swig_type_info
*ti
, void *clientdata
) {
548 swig_cast_info
*cast
= ti
->cast
;
549 /* if (ti->clientdata == clientdata) return; */
550 ti
->clientdata
= clientdata
;
553 if (!cast
->converter
) {
554 swig_type_info
*tc
= cast
->type
;
555 if (!tc
->clientdata
) {
556 SWIG_TypeClientData(tc
, clientdata
);
563 SWIG_TypeNewClientData(swig_type_info
*ti
, void *clientdata
) {
564 SWIG_TypeClientData(ti
, clientdata
);
569 Search for a swig_type_info structure only by mangled name
570 Search is a O(log #types)
572 We start searching at module start, and finish searching when start == end.
573 Note: if start == end at the beginning of the function, we go all the way around
576 SWIGRUNTIME swig_type_info
*
577 SWIG_MangledTypeQueryModule(swig_module_info
*start
,
578 swig_module_info
*end
,
580 swig_module_info
*iter
= start
;
584 size_t r
= iter
->size
- 1;
586 /* since l+r >= 0, we can (>> 1) instead (/ 2) */
587 size_t i
= (l
+ r
) >> 1;
588 const char *iname
= iter
->types
[i
]->name
;
590 int compare
= strcmp(name
, iname
);
592 return iter
->types
[i
];
593 } else if (compare
< 0) {
599 } else if (compare
> 0) {
603 break; /* should never happen */
608 } while (iter
!= end
);
613 Search for a swig_type_info structure for either a mangled name or a human readable name.
614 It first searches the mangled names of the types, which is a O(log #types)
615 If a type is not found it then searches the human readable names, which is O(#types).
617 We start searching at module start, and finish searching when start == end.
618 Note: if start == end at the beginning of the function, we go all the way around
621 SWIGRUNTIME swig_type_info
*
622 SWIG_TypeQueryModule(swig_module_info
*start
,
623 swig_module_info
*end
,
625 /* STEP 1: Search the name field using binary search */
626 swig_type_info
*ret
= SWIG_MangledTypeQueryModule(start
, end
, name
);
630 /* STEP 2: If the type hasn't been found, do a complete search
631 of the str field (the human readable name) */
632 swig_module_info
*iter
= start
;
635 for (; i
< iter
->size
; ++i
) {
636 if (iter
->types
[i
]->str
&& (SWIG_TypeEquiv(iter
->types
[i
]->str
, name
)))
637 return iter
->types
[i
];
640 } while (iter
!= end
);
643 /* neither found a match */
648 Pack binary data into a string
651 SWIG_PackData(char *c
, void *ptr
, size_t sz
) {
652 static const char hex
[17] = "0123456789abcdef";
653 const unsigned char *u
= (unsigned char *) ptr
;
654 const unsigned char *eu
= u
+ sz
;
655 for (; u
!= eu
; ++u
) {
656 unsigned char uu
= *u
;
657 *(c
++) = hex
[(uu
& 0xf0) >> 4];
658 *(c
++) = hex
[uu
& 0xf];
664 Unpack binary data from a string
666 SWIGRUNTIME
const char *
667 SWIG_UnpackData(const char *c
, void *ptr
, size_t sz
) {
668 unsigned char *u
= (unsigned char *) ptr
;
669 const unsigned char *eu
= u
+ sz
;
670 for (; u
!= eu
; ++u
) {
673 if ((d
>= '0') && (d
<= '9'))
674 uu
= (unsigned char)((d
- '0') << 4);
675 else if ((d
>= 'a') && (d
<= 'f'))
676 uu
= (unsigned char)((d
- ('a' - 10)) << 4);
680 if ((d
>= '0') && (d
<= '9'))
681 uu
|= (unsigned char)(d
- '0');
682 else if ((d
>= 'a') && (d
<= 'f'))
683 uu
|= (unsigned char)(d
- ('a' - 10));
692 Pack 'void *' into a string buffer.
695 SWIG_PackVoidPtr(char *buff
, void *ptr
, const char *name
, size_t bsz
) {
697 if ((2 * sizeof(void *) + 2) > bsz
) return 0;
699 r
= SWIG_PackData(r
, &ptr
, sizeof(void *));
700 if (strlen(name
) + 1 > (bsz
- (r
- buff
))) return 0;
705 SWIGRUNTIME
const char *
706 SWIG_UnpackVoidPtr(const char *c
, void **ptr
, const char *name
) {
708 if (strcmp(c
, "NULL") == 0) {
715 return SWIG_UnpackData(++c
, ptr
, sizeof(void *));
719 SWIG_PackDataName(char *buff
, void *ptr
, size_t sz
, const char *name
, size_t bsz
) {
721 size_t lname
= (name
? strlen(name
) : 0);
722 if ((2 * sz
+ 2 + lname
) > bsz
) return 0;
724 r
= SWIG_PackData(r
, ptr
, sz
);
726 strncpy(r
, name
, lname
+ 1);
733 SWIGRUNTIME
const char *
734 SWIG_UnpackDataName(const char *c
, void *ptr
, size_t sz
, const char *name
) {
736 if (strcmp(c
, "NULL") == 0) {
743 return SWIG_UnpackData(++c
, ptr
, sz
);
750 /* SWIG Errors applicable to all language modules, values are reserved from -1 to -99 */
751 #define SWIG_UnknownError -1
752 #define SWIG_IOError -2
753 #define SWIG_RuntimeError -3
754 #define SWIG_IndexError -4
755 #define SWIG_TypeError -5
756 #define SWIG_DivisionByZero -6
757 #define SWIG_OverflowError -7
758 #define SWIG_SyntaxError -8
759 #define SWIG_ValueError -9
760 #define SWIG_SystemError -10
761 #define SWIG_AttributeError -11
762 #define SWIG_MemoryError -12
763 #define SWIG_NullReferenceError -13
766 /* -----------------------------------------------------------------------------
769 * This file contains the runtime support for Lua modules
770 * and includes code for managing global variables and pointer
772 * ----------------------------------------------------------------------------- */
780 #include <stdlib.h> /* for malloc */
781 #include <assert.h> /* for a few sanity tests */
783 /* -----------------------------------------------------------------------------
785 * ----------------------------------------------------------------------------- */
787 #define SWIG_LUA_FLAVOR_LUA 1
788 #define SWIG_LUA_FLAVOR_ELUA 2
789 #define SWIG_LUA_FLAVOR_ELUAC 3
791 #if !defined(SWIG_LUA_TARGET)
792 # error SWIG_LUA_TARGET not defined
795 #if defined(SWIG_LUA_ELUA_EMULATE)
797 struct swig_elua_entry
;
799 typedef struct swig_elua_key
{
807 typedef struct swig_elua_val
{
811 const struct swig_elua_entry
*table
;
813 lua_CFunction function
;
818 swig_type_info
**ptype
;
823 typedef struct swig_elua_entry
{
828 #define LSTRKEY(x) {LUA_TSTRING, {.strkey = x} }
829 #define LNUMKEY(x) {LUA_TNUMBER, {.numkey = x} }
830 #define LNILKEY {LUA_TNIL, {.strkey = 0} }
832 #define LNUMVAL(x) {LUA_TNUMBER, {.number = x} }
833 #define LFUNCVAL(x) {LUA_TFUNCTION, {.function = x} }
834 #define LROVAL(x) {LUA_TTABLE, {.table = x} }
835 #define LNILVAL {LUA_TNIL, {.string = 0} }
836 #define LSTRVAL(x) {LUA_TSTRING, {.string = x} }
838 #define LUA_REG_TYPE swig_elua_entry
840 #define SWIG_LUA_ELUA_EMUL_METATABLE_KEY "__metatable"
842 #define lua_pushrotable(L,p)\
845 SWIG_Lua_elua_emulate_register(L,(swig_elua_entry*)(p));
847 #define SWIG_LUA_CONSTTAB_POINTER(B,C,D)\
848 LSTRKEY(B), {LUA_TUSERDATA, { .userdata={0,0,(void*)(C),&D} } }
850 #define SWIG_LUA_CONSTTAB_BINARY(B,S,C,D)\
851 LSTRKEY(B), {LUA_TUSERDATA, { .userdata={1,S,(void*)(C),&D} } }
854 #if (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUA) || (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUAC)
855 # define SWIG_LUA_CONSTTAB_INT(B, C) LSTRKEY(B), LNUMVAL(C)
856 # define SWIG_LUA_CONSTTAB_FLOAT(B, C) LSTRKEY(B), LNUMVAL(C)
857 # define SWIG_LUA_CONSTTAB_STRING(B, C) LSTRKEY(B), LSTRVAL(C)
858 # define SWIG_LUA_CONSTTAB_CHAR(B, C) LSTRKEY(B), LNUMVAL(C)
859 /* Those two types of constants are not supported in elua */
861 #ifndef SWIG_LUA_CONSTTAB_POINTER
862 #warning eLua does not support pointers as constants. By default, nil will be used as value
863 #define SWIG_LUA_CONSTTAB_POINTER(B,C,D) LSTRKEY(B), LNILVAL
866 #ifndef SWIG_LUA_CONSTTAB_BINARY
867 #warning eLua does not support pointers to member as constants. By default, nil will be used as value
868 #define SWIG_LUA_CONSTTAB_BINARY(B, S, C, D) LSTRKEY(B), LNILVAL
870 #else /* SWIG_LUA_FLAVOR_LUA */
871 # define SWIG_LUA_CONSTTAB_INT(B, C) SWIG_LUA_INT, (char *)B, (long)C, 0, 0, 0
872 # define SWIG_LUA_CONSTTAB_FLOAT(B, C) SWIG_LUA_FLOAT, (char *)B, 0, (double)C, 0, 0
873 # define SWIG_LUA_CONSTTAB_STRING(B, C) SWIG_LUA_STRING, (char *)B, 0, 0, (void *)C, 0
874 # define SWIG_LUA_CONSTTAB_CHAR(B, C) SWIG_LUA_CHAR, (char *)B, (long)C, 0, 0, 0
875 # define SWIG_LUA_CONSTTAB_POINTER(B,C,D)\
876 SWIG_LUA_POINTER, (char *)B, 0, 0, (void *)C, &D
877 # define SWIG_LUA_CONSTTAB_BINARY(B, S, C, D)\
878 SWIG_LUA_BINARY, (char *)B, S, 0, (void *)C, &D
881 #ifndef SWIG_LUA_ELUA_EMULATE
882 #if (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUA) || (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUAC)
883 # define LRO_STRVAL(v) {{.p = (char *) v}, LUA_TSTRING}
884 # define LSTRVAL LRO_STRVAL
886 #endif /* SWIG_LUA_ELUA_EMULATE*/
888 #ifndef SWIG_LUA_ELUA_EMULATE
889 #if (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUA) || (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUAC)
891 #ifndef MIN_OPT_LEVEL
892 #define MIN_OPT_LEVEL 2
896 #include "lrotable.h"
898 #endif /* SWIG_LUA_ELUA_EMULATE*/
899 /* -----------------------------------------------------------------------------
900 * compatibility defines
901 * ----------------------------------------------------------------------------- */
903 /* History of Lua C API length functions: In Lua 5.0 (and before?)
904 there was "lua_strlen". In Lua 5.1, this was renamed "lua_objlen",
905 but a compatibility define of "lua_strlen" was added. In Lua 5.2,
906 this function was again renamed, to "lua_rawlen" (to emphasize that
907 it doesn't call the "__len" metamethod), and the compatibility
908 define of lua_strlen was removed. All SWIG uses have been updated
909 to "lua_rawlen", and we add our own defines of that here for older
911 #if !defined(LUA_VERSION_NUM) || LUA_VERSION_NUM < 501
912 # define lua_rawlen lua_strlen
913 #elif LUA_VERSION_NUM == 501
914 # define lua_rawlen lua_objlen
917 /* lua_tolstring() was added in Lua 5.1. It should be a little more
918 efficient than making two separate calls and it avoids problems with order
919 of evaluation so SWIG calls lua_tolstring() when it wants the length and
920 we provide a compatibility implementation for Lua 5.0. */
921 #if !defined(LUA_VERSION_NUM) || LUA_VERSION_NUM < 501
922 static const char *(lua_tolstring
)(lua_State
*L
, int idx
, size_t *len
) {
923 /* Call lua_tostring() first as it may convert the value from number to
925 const char *result
= lua_tostring(L
, idx
);
926 if (len
) *len
= lua_strlen(L
, idx
);
932 /* lua_pushglobaltable is the recommended "future-proof" way to get
933 the global table for Lua 5.2 and later. Here we define
934 lua_pushglobaltable ourselves for Lua versions before 5.2. */
935 #if !defined(LUA_VERSION_NUM) || LUA_VERSION_NUM < 502
936 # define lua_pushglobaltable(L) lua_pushvalue(L, LUA_GLOBALSINDEX)
939 /* lua_absindex was introduced in Lua 5.2 */
940 #if !defined(LUA_VERSION_NUM) || LUA_VERSION_NUM < 502
941 # define lua_absindex(L,i) ((i)>0 || (i) <= LUA_REGISTRYINDEX ? (i) : lua_gettop(L) + (i) + 1)
944 /* lua_rawsetp was introduced in Lua 5.2 */
945 #if !defined(LUA_VERSION_NUM) || LUA_VERSION_NUM < 502
946 #define lua_rawsetp(L,index,ptr)\
947 lua_pushlightuserdata(L,(void*)(ptr));\
951 #define lua_rawgetp(L,index,ptr)\
952 lua_pushlightuserdata(L,(void*)(ptr));\
957 /* --------------------------------------------------------------------------
958 * Helper functions for error handling
959 * -------------------------------------------------------------------------- */
961 /* Push the string STR on the Lua stack, like lua_pushstring, but
962 prefixed with the location of the innermost Lua call-point
963 (as formatted by luaL_where). */
965 SWIG_Lua_pusherrstring(lua_State
*L
, const char *str
) {
967 lua_pushstring(L
, str
);
971 /* Push a formatted string generated from FMT and following args on
972 the Lua stack, like lua_pushfstring, but prefixed with the
973 location of the innermost Lua call-point (as formatted by luaL_where). */
975 SWIG_Lua_pushferrstring(lua_State
*L
, const char *fmt
, ...) {
979 lua_pushvfstring(L
, fmt
, argp
);
985 /* -----------------------------------------------------------------------------
987 * ----------------------------------------------------------------------------- */
989 #define SWIG_LUA_INT 1
990 #define SWIG_LUA_FLOAT 2
991 #define SWIG_LUA_STRING 3
992 #define SWIG_LUA_POINTER 4
993 #define SWIG_LUA_BINARY 5
994 #define SWIG_LUA_CHAR 6
996 /* Structure for variable linking table */
1001 } swig_lua_var_info
;
1003 #if (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUA) || (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUAC)
1004 typedef const LUA_REG_TYPE swig_lua_method
;
1005 typedef const LUA_REG_TYPE swig_lua_const_info
;
1006 #else /* Normal lua */
1007 typedef luaL_Reg swig_lua_method
;
1009 /* Constant information structure */
1016 swig_type_info
**ptype
;
1017 } swig_lua_const_info
;
1023 lua_CFunction getmethod
;
1024 lua_CFunction setmethod
;
1025 } swig_lua_attribute
;
1028 struct swig_lua_class
;
1029 /* Can be used to create namespaces. Currently used to wrap class static methods/variables/constants */
1030 typedef struct swig_lua_namespace
{
1032 swig_lua_method
*ns_methods
;
1033 swig_lua_attribute
*ns_attributes
;
1034 swig_lua_const_info
*ns_constants
;
1035 struct swig_lua_class
**ns_classes
;
1036 struct swig_lua_namespace
**ns_namespaces
;
1037 } swig_lua_namespace
;
1039 typedef struct swig_lua_class
{
1040 const char *name
; /* Name that this class has in Lua */
1041 const char *fqname
; /* Fully qualified name - Scope + class name */
1042 swig_type_info
**type
;
1043 lua_CFunction constructor
;
1044 void (*destructor
)(void *);
1045 swig_lua_method
*methods
;
1046 swig_lua_attribute
*attributes
;
1047 swig_lua_namespace
*cls_static
;
1048 swig_lua_method
*metatable
; /* 0 for -eluac */
1049 struct swig_lua_class
**bases
;
1050 const char **base_names
;
1053 /* this is the struct for wrapping all pointers in SwigLua
1056 swig_type_info
*type
;
1057 int own
; /* 1 if owned & must be destroyed */
1059 } swig_lua_userdata
;
1061 /* this is the struct for wrapping arbitrary packed binary data
1062 (currently it is only used for member function pointers)
1063 the data ordering is similar to swig_lua_userdata, but it is currently not possible
1064 to tell the two structures apart within SWIG, other than by looking at the type
1067 swig_type_info
*type
;
1068 int own
; /* 1 if owned & must be destroyed */
1069 char data
[1]; /* arbitrary amount of data */
1072 /* Common SWIG API */
1073 #define SWIG_NewPointerObj(L, ptr, type, owner) SWIG_Lua_NewPointerObj(L, (void *)ptr, type, owner)
1074 #define SWIG_ConvertPtr(L,idx, ptr, type, flags) SWIG_Lua_ConvertPtr(L,idx,ptr,type,flags)
1075 #define SWIG_MustGetPtr(L,idx, type,flags, argnum,fnname) SWIG_Lua_MustGetPtr(L,idx, type,flags, argnum,fnname)
1076 /* for C++ member pointers, ie, member methods */
1077 #define SWIG_ConvertMember(L, idx, ptr, sz, ty) SWIG_Lua_ConvertPacked(L, idx, ptr, sz, ty)
1078 #define SWIG_NewMemberObj(L, ptr, sz, type) SWIG_Lua_NewPackedObj(L, ptr, sz, type)
1081 #define SWIG_GetModule(clientdata) SWIG_Lua_GetModule((lua_State*)(clientdata))
1082 #define SWIG_SetModule(clientdata, pointer) SWIG_Lua_SetModule((lua_State*) (clientdata), pointer)
1083 #define SWIG_MODULE_CLIENTDATA_TYPE lua_State*
1085 /* Contract support */
1086 #define SWIG_contract_assert(expr, msg) \
1087 do { if (!(expr)) { SWIG_Lua_pusherrstring(L, (char *) msg); goto fail; } } while (0)
1090 /* helper #defines */
1091 #define SWIG_fail {goto fail;}
1092 #define SWIG_fail_arg(func_name,argnum,type) \
1093 {SWIG_Lua_pushferrstring(L,"Error in %s (arg %d), expected '%s' got '%s'",\
1094 func_name,argnum,type,SWIG_Lua_typename(L,argnum));\
1096 #define SWIG_fail_ptr(func_name,argnum,type) \
1097 SWIG_fail_arg(func_name,argnum,(type && type->str)?type->str:"void*")
1098 #define SWIG_check_num_args(func_name,a,b) \
1099 if (lua_gettop(L)<a || lua_gettop(L)>b) \
1100 {SWIG_Lua_pushferrstring(L,"Error in %s expected %d..%d args, got %d",func_name,a,b,lua_gettop(L));\
1104 #define SWIG_Lua_get_table(L,n) \
1105 (lua_pushstring(L, n), lua_rawget(L,-2))
1107 #define SWIG_Lua_add_function(L,n,f) \
1108 (lua_pushstring(L, n), \
1109 lua_pushcfunction(L, f), \
1112 #define SWIG_Lua_add_boolean(L,n,b) \
1113 (lua_pushstring(L, n), \
1114 lua_pushboolean(L, b), \
1117 /* special helper for allowing 'nil' for usertypes */
1118 #define SWIG_isptrtype(L,I) (lua_isuserdata(L,I) || lua_isnil(L,I))
1121 /* Special helper for member function pointers
1122 it gets the address, casts it, then dereferences it */
1123 /*#define SWIG_mem_fn_as_voidptr(a) (*((char**)&(a))) */
1126 /* storing/access of swig_module_info */
1127 SWIGRUNTIME swig_module_info
*
1128 SWIG_Lua_GetModule(lua_State
*L
) {
1129 swig_module_info
*ret
= 0;
1130 lua_pushstring(L
, "swig_runtime_data_type_pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME
);
1131 lua_rawget(L
, LUA_REGISTRYINDEX
);
1132 if (lua_islightuserdata(L
, -1))
1133 ret
= (swig_module_info
*)lua_touserdata(L
, -1);
1134 lua_pop(L
, 1); /* tidy */
1139 SWIG_Lua_SetModule(lua_State
*L
, swig_module_info
*module
) {
1140 /* add this all into the Lua registry: */
1141 lua_pushstring(L
, "swig_runtime_data_type_pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME
);
1142 lua_pushlightuserdata(L
, (void *)module
);
1143 lua_rawset(L
, LUA_REGISTRYINDEX
);
1146 /* -----------------------------------------------------------------------------
1147 * global variable support code: modules
1148 * ----------------------------------------------------------------------------- */
1150 /* this function is called when trying to set an immutable.
1151 default action is to print an error.
1152 This can removed with a compile flag SWIGLUA_IGNORE_SET_IMMUTABLE */
1153 SWIGINTERN
int SWIG_Lua_set_immutable(lua_State
*L
) {
1154 /* there should be 1 param passed in: the new value */
1155 #ifndef SWIGLUA_IGNORE_SET_IMMUTABLE
1156 lua_pop(L
, 1); /* remove it */
1157 luaL_error(L
, "This variable is immutable");
1159 return 0; /* should not return anything */
1162 #ifdef SWIG_LUA_ELUA_EMULATE
1164 SWIGRUNTIME
void SWIG_Lua_NewPointerObj(lua_State
*L
, void *ptr
, swig_type_info
*type
, int own
);
1165 SWIGRUNTIME
void SWIG_Lua_NewPackedObj(lua_State
*L
, void *ptr
, size_t size
, swig_type_info
*type
);
1166 static int swig_lua_elua_emulate_unique_key
;
1168 /* This function emulates eLua rotables behaviour. It loads a rotable definition into the usual lua table. */
1169 SWIGINTERN
void SWIG_Lua_elua_emulate_register(lua_State
*L
, const swig_elua_entry
*table
) {
1170 int i
, table_parsed
, parsed_tables_array
, target_table
;
1171 assert(lua_istable(L
, -1));
1172 target_table
= lua_gettop(L
);
1173 /* Get the registry where we put all parsed tables to avoid loops */
1174 lua_rawgetp(L
, LUA_REGISTRYINDEX
, &swig_lua_elua_emulate_unique_key
);
1175 if (lua_isnil(L
, -1)) {
1178 lua_pushvalue(L
, -1);
1179 lua_rawsetp(L
, LUA_REGISTRYINDEX
, (void *)(&swig_lua_elua_emulate_unique_key
));
1181 parsed_tables_array
= lua_gettop(L
);
1182 lua_pushvalue(L
, target_table
);
1183 lua_rawsetp(L
, parsed_tables_array
, table
);
1185 const int SWIGUNUSED pairs_start
= lua_gettop(L
);
1186 for (i
= 0; table
[i
].key
.type
!= LUA_TNIL
|| table
[i
].value
.type
!= LUA_TNIL
; i
++) {
1187 const swig_elua_entry
*entry
= table
+ i
;
1188 int is_metatable
= 0;
1189 switch (entry
->key
.type
) {
1191 lua_pushstring(L
, entry
->key
.key
.strkey
);
1192 if (strcmp(entry
->key
.key
.strkey
, SWIG_LUA_ELUA_EMUL_METATABLE_KEY
) == 0)
1196 lua_pushnumber(L
, entry
->key
.key
.numkey
);
1204 switch (entry
->value
.type
) {
1206 lua_pushstring(L
, entry
->value
.value
.string
);
1209 lua_pushnumber(L
, entry
->value
.value
.number
);
1212 lua_pushcfunction(L
, entry
->value
.value
.function
);
1215 lua_rawgetp(L
, parsed_tables_array
, entry
->value
.value
.table
);
1216 table_parsed
= !lua_isnil(L
, -1);
1217 if (!table_parsed
) {
1218 lua_pop(L
, 1); /*remove nil */
1220 SWIG_Lua_elua_emulate_register(L
, entry
->value
.value
.table
);
1223 assert(lua_istable(L
, -1));
1224 lua_pushvalue(L
, -1);
1225 lua_setmetatable(L
, target_table
);
1230 if (entry
->value
.value
.userdata
.member
)
1231 SWIG_NewMemberObj(L
, entry
->value
.value
.userdata
.pvalue
,
1232 entry
->value
.value
.userdata
.lvalue
,
1233 *(entry
->value
.value
.userdata
.ptype
));
1235 SWIG_NewPointerObj(L
, entry
->value
.value
.userdata
.pvalue
,
1236 *(entry
->value
.value
.userdata
.ptype
), 0);
1244 assert(lua_gettop(L
) == pairs_start
+ 2);
1245 lua_rawset(L
, target_table
);
1247 lua_pop(L
, 1); /* Removing parsed tables storage */
1248 assert(lua_gettop(L
) == target_table
);
1251 SWIGINTERN
void SWIG_Lua_elua_emulate_register_clear(lua_State
*L
) {
1253 lua_rawsetp(L
, LUA_REGISTRYINDEX
, &swig_lua_elua_emulate_unique_key
);
1256 SWIGINTERN
void SWIG_Lua_get_class_registry(lua_State
*L
);
1258 SWIGINTERN
int SWIG_Lua_emulate_elua_getmetatable(lua_State
*L
) {
1259 SWIG_check_num_args("getmetatable(SWIG eLua emulation)", 1, 1);
1260 SWIG_Lua_get_class_registry(L
);
1261 lua_getfield(L
, -1, "lua_getmetatable");
1262 lua_remove(L
, -2); /* remove the registry*/
1263 assert(!lua_isnil(L
, -1));
1264 lua_pushvalue(L
, 1);
1265 assert(lua_gettop(L
) == 3); /* object | function | object again */
1267 if (!lua_isnil(L
, -1)) /*There is an ordinary metatable */
1269 /*if it is a table, then emulate elua behaviour - check for __metatable attribute of a table*/
1270 assert(lua_gettop(L
) == 2);
1271 if (lua_istable(L
, -2)) {
1272 lua_pop(L
, 1); /*remove the nil*/
1273 lua_getfield(L
, -1, SWIG_LUA_ELUA_EMUL_METATABLE_KEY
);
1275 assert(lua_gettop(L
) == 2);
1283 SWIGINTERN
void SWIG_Lua_emulate_elua_swap_getmetatable(lua_State
*L
) {
1284 SWIG_Lua_get_class_registry(L
);
1285 lua_pushglobaltable(L
);
1286 lua_pushstring(L
, "lua_getmetatable");
1287 lua_getfield(L
, -2, "getmetatable");
1288 assert(!lua_isnil(L
, -1));
1290 lua_pushstring(L
, "getmetatable");
1291 lua_pushcfunction(L
, SWIG_Lua_emulate_elua_getmetatable
);
1299 /* -----------------------------------------------------------------------------
1300 * global variable support code: namespaces and modules (which are the same thing)
1301 * ----------------------------------------------------------------------------- */
1303 SWIGINTERN
int SWIG_Lua_namespace_get(lua_State
*L
) {
1304 /* there should be 2 params passed in
1305 (1) table (not the meta table)
1306 (2) string name of the attribute
1308 assert(lua_istable(L
, -2)); /* just in case */
1309 lua_getmetatable(L
, -2);
1310 assert(lua_istable(L
, -1));
1311 SWIG_Lua_get_table(L
, ".get"); /* find the .get table */
1312 assert(lua_istable(L
, -1));
1313 /* look for the key in the .get table */
1314 lua_pushvalue(L
, 2); /* key */
1316 lua_remove(L
, -2); /* stack tidy, remove .get table */
1317 if (lua_iscfunction(L
, -1)) {
1318 /* found it so call the fn & return its value */
1319 lua_call(L
, 0, 1); /* 1 value in (userdata),1 out (result) */
1320 lua_remove(L
, -2); /* stack tidy, remove metatable */
1323 lua_pop(L
, 1); /* remove whatever was there */
1324 /* ok, so try the .fn table */
1325 SWIG_Lua_get_table(L
, ".fn"); /* find the .get table */
1326 assert(lua_istable(L
, -1)); /* just in case */
1327 lua_pushvalue(L
, 2); /* key */
1328 lua_rawget(L
, -2); /* look for the fn */
1329 lua_remove(L
, -2); /* stack tidy, remove .fn table */
1330 if (lua_isfunction(L
, -1)) { /* note: whether it's a C function or lua function */
1331 /* found it so return the fn & let lua call it */
1332 lua_remove(L
, -2); /* stack tidy, remove metatable */
1335 lua_pop(L
, 1); /* remove whatever was there */
1339 SWIGINTERN
int SWIG_Lua_namespace_set(lua_State
*L
) {
1340 /* there should be 3 params passed in
1341 (1) table (not the meta table)
1342 (2) string name of the attribute
1343 (3) any for the new value
1346 assert(lua_istable(L
, 1));
1347 lua_getmetatable(L
, 1); /* get the meta table */
1348 assert(lua_istable(L
, -1));
1350 SWIG_Lua_get_table(L
, ".set"); /* find the .set table */
1351 if (lua_istable(L
, -1)) {
1352 /* look for the key in the .set table */
1353 lua_pushvalue(L
, 2); /* key */
1355 if (lua_iscfunction(L
, -1)) {
1356 /* found it so call the fn & return its value */
1357 lua_pushvalue(L
, 3); /* value */
1361 lua_pop(L
, 1); /* remove the value */
1363 lua_pop(L
, 1); /* remove the value .set table */
1364 lua_pop(L
, 1); /* remote metatable */
1369 #if (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_LUA) /* In elua this is useless */
1370 SWIGINTERN
void SWIG_Lua_InstallConstants(lua_State
*L
, swig_lua_const_info constants
[]); /* forward declaration */
1371 SWIGINTERN
void SWIG_Lua_add_variable(lua_State
*L
, const char *name
, lua_CFunction getFn
, lua_CFunction setFn
); /* forward declaration */
1372 SWIGINTERN
void SWIG_Lua_class_register(lua_State
*L
, swig_lua_class
*clss
);
1374 /* helper function - register namespace methods and attributes into namespace */
1375 SWIGINTERN
int SWIG_Lua_add_namespace_details(lua_State
*L
, swig_lua_namespace
*ns
) {
1377 /* There must be namespace table (not metatable) at the top of the stack */
1378 assert(lua_istable(L
, -1));
1379 SWIG_Lua_InstallConstants(L
, ns
->ns_constants
);
1381 /* add methods to the namespace/module table */
1382 for (i
= 0; ns
->ns_methods
[i
].name
; i
++) {
1383 SWIG_Lua_add_function(L
, ns
->ns_methods
[i
].name
, ns
->ns_methods
[i
].func
);
1385 lua_getmetatable(L
, -1);
1388 for (i
= 0; ns
->ns_attributes
[i
].name
; i
++) {
1389 SWIG_Lua_add_variable(L
, ns
->ns_attributes
[i
].name
, ns
->ns_attributes
[i
].getmethod
, ns
->ns_attributes
[i
].setmethod
);
1392 /* clear stack - remove metatble */
1397 /* Register all classes in the namespace */
1398 SWIGINTERN
void SWIG_Lua_add_namespace_classes(lua_State
*L
, swig_lua_namespace
*ns
) {
1399 swig_lua_class
**classes
;
1401 /* There must be a module/namespace table at the top of the stack */
1402 assert(lua_istable(L
, -1));
1404 classes
= ns
->ns_classes
;
1407 while (*classes
!= 0) {
1408 SWIG_Lua_class_register(L
, *classes
);
1414 /* Helper function. Creates namespace table and adds it to module table
1415 if 'reg' is true, then will register namespace table to parent one (must be on top of the stack
1416 when function is called).
1417 Function always returns newly registered table on top of the stack.
1419 SWIGINTERN
void SWIG_Lua_namespace_register(lua_State
*L
, swig_lua_namespace
*ns
, int reg
) {
1420 swig_lua_namespace
**sub_namespace
;
1421 /* 1 argument - table on the top of the stack */
1422 const int SWIGUNUSED begin
= lua_gettop(L
);
1423 assert(lua_istable(L
, -1)); /* just in case. This is supposed to be module table or parent namespace table */
1424 lua_checkstack(L
, 5);
1425 lua_newtable(L
); /* namespace itself */
1426 lua_newtable(L
); /* metatable for namespace */
1428 /* add a table called ".get" */
1429 lua_pushstring(L
, ".get");
1432 /* add a table called ".set" */
1433 lua_pushstring(L
, ".set");
1436 /* add a table called ".fn" */
1437 lua_pushstring(L
, ".fn");
1441 /* add accessor fns for using the .get,.set&.fn */
1442 SWIG_Lua_add_function(L
, "__index", SWIG_Lua_namespace_get
);
1443 SWIG_Lua_add_function(L
, "__newindex", SWIG_Lua_namespace_set
);
1445 lua_setmetatable(L
, -2); /* set metatable */
1447 /* Register all functions, variables etc */
1448 SWIG_Lua_add_namespace_details(L
, ns
);
1449 /* Register classes */
1450 SWIG_Lua_add_namespace_classes(L
, ns
);
1452 sub_namespace
= ns
->ns_namespaces
;
1453 if (sub_namespace
!= 0) {
1454 while (*sub_namespace
!= 0) {
1455 SWIG_Lua_namespace_register(L
, *sub_namespace
, 1);
1456 lua_pop(L
, 1); /* removing sub-namespace table */
1462 lua_pushstring(L
, ns
->name
);
1463 lua_pushvalue(L
, -2);
1464 lua_rawset(L
, -4); /* add namespace to module table */
1466 assert(lua_gettop(L
) == begin
+ 1);
1468 #endif /* SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_LUA */
1470 /* -----------------------------------------------------------------------------
1471 * global variable support code: classes
1472 * ----------------------------------------------------------------------------- */
1474 SWIGINTERN
void SWIG_Lua_get_class_metatable(lua_State
*L
, const char *cname
);
1476 typedef int (*swig_lua_base_iterator_func
)(lua_State
*, swig_type_info
*, int, int *ret
);
1478 SWIGINTERN
int SWIG_Lua_iterate_bases(lua_State
*L
, swig_type_info
*SWIGUNUSED swig_type
,
1479 int first_arg
, swig_lua_base_iterator_func func
, int *const ret
) {
1480 /* first_arg - position of the object in stack. Everything that is above are arguments
1481 * and is passed to every evocation of the func */
1482 int last_arg
= lua_gettop(L
);/* position of last argument */
1483 int original_metatable
= last_arg
+ 1;
1485 int result
= SWIG_ERROR
;
1488 lua_getmetatable(L
, first_arg
);
1490 /* initialise base search */
1491 #if (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_LUA)
1492 SWIG_Lua_get_table(L
, ".bases");
1493 assert(lua_istable(L
, -1));
1494 bases_count
= lua_rawlen(L
, -1);
1495 bases_table
= lua_gettop(L
);
1497 /* In elua .bases table doesn't exist. Use table from swig_lua_class */
1499 assert(swig_type
!= 0);
1500 swig_module_info
*module
= SWIG_GetModule(L
);
1501 swig_lua_class
**bases
= ((swig_lua_class
*)(swig_type
->clientdata
))->bases
;
1502 const char **base_names
= ((swig_lua_class
*)(swig_type
->clientdata
))->base_names
;
1504 for (; base_names
[bases_count
];
1505 bases_count
++);/* get length of bases */
1510 if (bases_count
> 0) {
1514 int subcall_last_arg
;
1515 int subcall_first_arg
= lua_gettop(L
) + 1;/* Here a copy of first_arg and arguments begin */
1517 swig_type_info
*base_swig_type
= 0;
1518 for (j
= first_arg
; j
<= last_arg
; j
++)
1519 lua_pushvalue(L
, j
);
1520 subcall_last_arg
= lua_gettop(L
);
1522 /* Trick: temporarily replacing original metatable with metatable for base class and call getter */
1523 for (i
= 0; i
< bases_count
; i
++) {
1524 /* Iteration through class bases */
1525 #if (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_LUA)
1526 lua_rawgeti(L
, bases_table
, i
+ 1);
1528 if (lua_isnil(L
, -1)) {
1534 #else /* In elua .bases table doesn't exist. Use table from swig_lua_class */
1535 swig_lua_class
*base_class
= bases
[i
];
1540 SWIG_Lua_get_class_metatable(L
, base_class
->fqname
);
1541 base_swig_type
= SWIG_TypeQueryModule(module
, module
, base_names
[i
]);
1542 assert(base_swig_type
!= 0);
1548 assert(lua_isuserdata(L
, subcall_first_arg
));
1549 assert(lua_istable(L
, -1));
1550 lua_setmetatable(L
, subcall_first_arg
); /* Set new metatable */
1551 assert(lua_gettop(L
) == subcall_last_arg
);
1552 result
= func(L
, base_swig_type
, subcall_first_arg
, ret
); /* Forward call */
1553 if (result
!= SWIG_ERROR
) {
1557 /* Restore original metatable */
1558 lua_pushvalue(L
, original_metatable
);
1559 lua_setmetatable(L
, first_arg
);
1560 /* Clear - remove everything between last_arg and subcall_last_arg including */
1561 to_remove
= subcall_last_arg
- last_arg
;
1562 for (j
= 0; j
< to_remove
; j
++)
1563 lua_remove(L
, last_arg
+ 1);
1565 /* Remove everything after last_arg */
1566 lua_pop(L
, lua_gettop(L
) - last_arg
);
1568 if (ret
) assert(lua_gettop(L
) == last_arg
+ *ret
);
1572 /* The class.get method helper, performs the lookup of class attributes.
1573 * It returns an error code. Number of function return values is passed inside 'ret'.
1574 * first_arg is not used in this function because function always has 2 arguments.
1576 SWIGINTERN
int SWIG_Lua_class_do_get_item(lua_State
*L
, swig_type_info
*type
, int SWIGUNUSED first_arg
, int *ret
) {
1577 /* there should be 2 params passed in
1578 (1) userdata (not the meta table)
1579 (2) string name of the attribute
1581 int bases_search_result
;
1582 int substack_start
= lua_gettop(L
) - 2;
1583 assert(first_arg
== substack_start
+ 1);
1585 lua_checkstack(L
, 5);
1586 assert(lua_isuserdata(L
, -2)); /* just in case */
1587 lua_getmetatable(L
, -2); /* get the meta table */
1588 assert(lua_istable(L
, -1)); /* just in case */
1589 /* NEW: looks for the __getitem() fn
1590 this is a user provided get fn */
1591 SWIG_Lua_get_table(L
, "__getitem"); /* find the __getitem fn */
1592 if (lua_iscfunction(L
, -1)) { /* if it's there */
1593 /* found it so call the fn & return its value */
1594 lua_pushvalue(L
, substack_start
+ 1); /* the userdata */
1595 lua_pushvalue(L
, substack_start
+ 2); /* the parameter */
1596 lua_call(L
, 2, 1); /* 2 value in (userdata),1 out (result) */
1597 lua_remove(L
, -2); /* stack tidy, remove metatable */
1602 /* Remove the metatable */
1604 /* Search in base classes */
1605 bases_search_result
= SWIG_Lua_iterate_bases(L
, type
, substack_start
+ 1, SWIG_Lua_class_do_get_item
, ret
);
1606 return bases_search_result
; /* sorry not known */
1610 /* The class.get method helper, performs the lookup of class attributes.
1611 * It returns an error code. Number of function return values is passed inside 'ret'.
1612 * first_arg is not used in this function because function always has 2 arguments.
1614 SWIGINTERN
int SWIG_Lua_class_do_get(lua_State
*L
, swig_type_info
*type
, int SWIGUNUSED first_arg
, int *ret
) {
1615 /* there should be 2 params passed in
1616 (1) userdata (not the meta table)
1617 (2) string name of the attribute
1619 int bases_search_result
;
1620 int substack_start
= lua_gettop(L
) - 2;
1621 assert(first_arg
== substack_start
+ 1);
1623 lua_checkstack(L
, 5);
1624 assert(lua_isuserdata(L
, -2)); /* just in case */
1625 lua_getmetatable(L
, -2); /* get the meta table */
1626 assert(lua_istable(L
, -1)); /* just in case */
1627 SWIG_Lua_get_table(L
, ".get"); /* find the .get table */
1628 assert(lua_istable(L
, -1)); /* just in case */
1629 /* look for the key in the .get table */
1630 lua_pushvalue(L
, substack_start
+ 2); /* key */
1632 lua_remove(L
, -2); /* stack tidy, remove .get table */
1633 if (lua_iscfunction(L
, -1)) {
1634 /* found it so call the fn & return its value */
1635 lua_pushvalue(L
, substack_start
+ 1); /* the userdata */
1636 lua_call(L
, 1, 1); /* 1 value in (userdata),1 out (result) */
1637 lua_remove(L
, -2); /* stack tidy, remove metatable */
1642 lua_pop(L
, 1); /* remove whatever was there */
1643 /* ok, so try the .fn table */
1644 SWIG_Lua_get_table(L
, ".fn"); /* find the .fn table */
1645 assert(lua_istable(L
, -1)); /* just in case */
1646 lua_pushvalue(L
, substack_start
+ 2); /* key */
1647 lua_rawget(L
, -2); /* look for the fn */
1648 lua_remove(L
, -2); /* stack tidy, remove .fn table */
1649 if (lua_isfunction(L
, -1)) { /* note: if it's a C function or lua function */
1650 /* found it so return the fn & let lua call it */
1651 lua_remove(L
, -2); /* stack tidy, remove metatable */
1656 lua_pop(L
, 1); /* remove whatever was there */
1657 /* Remove the metatable */
1659 /* Search in base classes */
1660 bases_search_result
= SWIG_Lua_iterate_bases(L
, type
, substack_start
+ 1, SWIG_Lua_class_do_get
, ret
);
1661 return bases_search_result
; /* sorry not known */
1664 /* the class.get method, performs the lookup of class attributes
1666 SWIGINTERN
int SWIG_Lua_class_get(lua_State
*L
) {
1667 /* there should be 2 params passed in
1668 (1) userdata (not the meta table)
1669 (2) string name of the attribute
1672 swig_lua_userdata
*usr
;
1673 swig_type_info
*type
;
1675 assert(lua_isuserdata(L
, 1));
1676 usr
= (swig_lua_userdata
*)lua_touserdata(L
, 1); /* get data */
1678 result
= SWIG_Lua_class_do_get(L
, type
, 1, &ret
);
1679 if (result
== SWIG_OK
)
1682 result
= SWIG_Lua_class_do_get_item(L
, type
, 1, &ret
);
1683 if (result
== SWIG_OK
)
1689 /* helper for the class.set method, performs the lookup of class attributes
1690 * It returns error code. Number of function return values is passed inside 'ret'
1692 SWIGINTERN
int SWIG_Lua_class_do_set(lua_State
*L
, swig_type_info
*type
, int first_arg
, int *ret
) {
1693 /* there should be 3 params passed in
1694 (1) table (not the meta table)
1695 (2) string name of the attribute
1696 (3) any for the new value
1699 int bases_search_result
;
1700 int substack_start
= lua_gettop(L
) - 3;
1701 lua_checkstack(L
, 5);
1702 assert(lua_isuserdata(L
, substack_start
+ 1)); /* just in case */
1703 lua_getmetatable(L
, substack_start
+ 1); /* get the meta table */
1704 assert(lua_istable(L
, -1)); /* just in case */
1706 *ret
= 0; /* it is setter - number of return values is always 0 */
1708 SWIG_Lua_get_table(L
, ".set"); /* find the .set table */
1709 if (lua_istable(L
, -1)) {
1710 /* look for the key in the .set table */
1711 lua_pushvalue(L
, substack_start
+ 2); /* key */
1713 lua_remove(L
, -2); /* tidy stack, remove .set table */
1714 if (lua_iscfunction(L
, -1)) {
1715 /* found it so call the fn & return its value */
1716 lua_pushvalue(L
, substack_start
+ 1); /* userdata */
1717 lua_pushvalue(L
, substack_start
+ 3); /* value */
1719 lua_remove(L
, substack_start
+ 4); /*remove metatable*/
1722 lua_pop(L
, 1); /* remove the value */
1724 lua_pop(L
, 1); /* remove the answer for .set table request*/
1726 /* NEW: looks for the __setitem() fn
1727 this is a user provided set fn */
1728 SWIG_Lua_get_table(L
, "__setitem"); /* find the fn */
1729 if (lua_iscfunction(L
, -1)) { /* if it's there */
1730 /* found it so call the fn & return its value */
1731 lua_pushvalue(L
, substack_start
+ 1); /* the userdata */
1732 lua_pushvalue(L
, substack_start
+ 2); /* the parameter */
1733 lua_pushvalue(L
, substack_start
+ 3); /* the value */
1734 lua_call(L
, 3, 0); /* 3 values in ,0 out */
1735 lua_remove(L
, -2); /* stack tidy, remove metatable */
1738 lua_pop(L
, 1); /* remove value */
1740 lua_pop(L
, 1); /* remove metatable */
1741 /* Search among bases */
1742 bases_search_result
= SWIG_Lua_iterate_bases(L
, type
, first_arg
, SWIG_Lua_class_do_set
, ret
);
1745 assert(lua_gettop(L
) == substack_start
+ 3);
1746 return bases_search_result
;
1749 /* This is the actual method exported to Lua. It calls SWIG_Lua_class_do_set and correctly
1750 * handles return values.
1752 SWIGINTERN
int SWIG_Lua_class_set(lua_State
*L
) {
1753 /* There should be 3 params passed in
1754 (1) table (not the meta table)
1755 (2) string name of the attribute
1756 (3) any for the new value
1760 swig_lua_userdata
*usr
;
1761 swig_type_info
*type
;
1762 assert(lua_isuserdata(L
, 1));
1763 usr
= (swig_lua_userdata
*)lua_touserdata(L
, 1); /* get data */
1765 result
= SWIG_Lua_class_do_set(L
, type
, 1, &ret
);
1766 if (result
!= SWIG_OK
) {
1767 SWIG_Lua_pushferrstring(L
, "Assignment not possible. No setter/member with this name. For custom assignments implement __setitem method.");
1775 /* the class.destruct method called by the interpreter */
1776 SWIGINTERN
int SWIG_Lua_class_destruct(lua_State
*L
) {
1777 /* there should be 1 params passed in
1778 (1) userdata (not the meta table) */
1779 swig_lua_userdata
*usr
;
1780 swig_lua_class
*clss
;
1781 assert(lua_isuserdata(L
, -1)); /* just in case */
1782 usr
= (swig_lua_userdata
*)lua_touserdata(L
, -1); /* get it */
1783 /* if must be destroyed & has a destructor */
1784 if (usr
->own
) { /* if must be destroyed */
1785 clss
= (swig_lua_class
*)usr
->type
->clientdata
; /* get the class */
1786 if (clss
&& clss
->destructor
) { /* there is a destroy fn */
1787 clss
->destructor(usr
->ptr
); /* bye bye */
1793 /* the class.__tostring method called by the interpreter and print */
1794 SWIGINTERN
int SWIG_Lua_class_tostring(lua_State
*L
) {
1795 /* there should be 1 param passed in
1796 (1) userdata (not the metatable) */
1797 swig_lua_userdata
*userData
;
1798 assert(lua_isuserdata(L
, 1)); /* just in case */
1799 userData
= (swig_lua_userdata
*)lua_touserdata(L
, 1); /* get the userdata address */
1801 lua_pushfstring(L
, "<userdata of type '%s' at %p>", userData
->type
->str
, userData
->ptr
);
1805 /* to manually disown some userdata */
1806 SWIGINTERN
int SWIG_Lua_class_disown(lua_State
*L
) {
1807 /* there should be 1 params passed in
1808 (1) userdata (not the meta table) */
1809 swig_lua_userdata
*usr
;
1810 assert(lua_isuserdata(L
, -1)); /* just in case */
1811 usr
= (swig_lua_userdata
*)lua_touserdata(L
, -1); /* get it */
1813 usr
->own
= 0; /* clear our ownership */
1817 /* lua callable function to compare userdata's value
1818 the issue is that two userdata may point to the same thing
1819 but to lua, they are different objects */
1820 SWIGRUNTIME
int SWIG_Lua_class_equal(lua_State
*L
) {
1822 swig_lua_userdata
*usr1
, *usr2
;
1823 if (!lua_isuserdata(L
, 1) || !lua_isuserdata(L
, 2)) /* just in case */
1824 return 0; /* nil reply */
1825 usr1
= (swig_lua_userdata
*)lua_touserdata(L
, 1); /* get data */
1826 usr2
= (swig_lua_userdata
*)lua_touserdata(L
, 2); /* get data */
1827 /*result=(usr1->ptr==usr2->ptr && usr1->type==usr2->type); only works if type is the same*/
1828 result
= (usr1
->ptr
== usr2
->ptr
);
1829 lua_pushboolean(L
, result
);
1833 /* populate table at the top of the stack with metamethods that ought to be inherited */
1834 SWIGINTERN
void SWIG_Lua_populate_inheritable_metamethods(lua_State
*L
) {
1835 SWIG_Lua_add_boolean(L
, "__add", 1);
1836 SWIG_Lua_add_boolean(L
, "__sub", 1);
1837 SWIG_Lua_add_boolean(L
, "__mul", 1);
1838 SWIG_Lua_add_boolean(L
, "__div", 1);
1839 SWIG_Lua_add_boolean(L
, "__mod", 1);
1840 SWIG_Lua_add_boolean(L
, "__pow", 1);
1841 SWIG_Lua_add_boolean(L
, "__unm", 1);
1842 SWIG_Lua_add_boolean(L
, "__len", 1);
1843 SWIG_Lua_add_boolean(L
, "__concat", 1);
1844 SWIG_Lua_add_boolean(L
, "__eq", 1);
1845 SWIG_Lua_add_boolean(L
, "__lt", 1);
1846 SWIG_Lua_add_boolean(L
, "__le", 1);
1847 SWIG_Lua_add_boolean(L
, "__call", 1);
1848 SWIG_Lua_add_boolean(L
, "__tostring", 1);
1849 SWIG_Lua_add_boolean(L
, "__gc", 0);
1852 /* creates the swig registry */
1853 SWIGINTERN
void SWIG_Lua_create_class_registry(lua_State
*L
) {
1854 /* create main SWIG registry table */
1855 lua_pushstring(L
, "SWIG");
1857 /* populate it with some predefined data */
1859 /* .library table. Placeholder */
1860 lua_pushstring(L
, ".library");
1863 /* list of metamethods that class inherits from its bases */
1864 lua_pushstring(L
, "inheritable_metamethods");
1866 /* populate with list of metamethods */
1867 SWIG_Lua_populate_inheritable_metamethods(L
);
1872 lua_rawset(L
, LUA_REGISTRYINDEX
);
1875 /* gets the swig registry (or creates it) */
1876 SWIGINTERN
void SWIG_Lua_get_class_registry(lua_State
*L
) {
1877 /* add this all into the swig registry: */
1878 lua_pushstring(L
, "SWIG");
1879 lua_rawget(L
, LUA_REGISTRYINDEX
); /* get the registry */
1880 if (!lua_istable(L
, -1)) { /* not there */
1881 /* must be first time, so add it */
1882 lua_pop(L
, 1); /* remove the result */
1883 SWIG_Lua_create_class_registry(L
);
1885 lua_pushstring(L
, "SWIG");
1886 lua_rawget(L
, LUA_REGISTRYINDEX
);
1890 SWIGINTERN
void SWIG_Lua_get_inheritable_metamethods(lua_State
*L
) {
1891 SWIG_Lua_get_class_registry(L
);
1892 lua_pushstring(L
, ".library");
1894 assert(!lua_isnil(L
, -1));
1895 lua_pushstring(L
, "inheritable_metamethods");
1898 /* Remove class registry and library table */
1903 /* Helper function to get the classes metatable from the register */
1904 SWIGINTERN
void SWIG_Lua_get_class_metatable(lua_State
*L
, const char *cname
) {
1905 SWIG_Lua_get_class_registry(L
); /* get the registry */
1906 lua_pushstring(L
, cname
); /* get the name */
1907 lua_rawget(L
, -2); /* get it */
1908 lua_remove(L
, -2); /* tidy up (remove registry) */
1911 /* Set up the base classes pointers.
1912 Each class structure has a list of pointers to the base class structures.
1913 This function fills them.
1914 It cannot be done at compile time, as this will not work with hireachies
1915 spread over more than one swig file.
1916 Therefore it must be done at runtime, querying the SWIG type system.
1918 SWIGINTERN
void SWIG_Lua_init_base_class(lua_State
*L
, swig_lua_class
*clss
) {
1920 swig_module_info
*module
= SWIG_GetModule(L
);
1921 for (i
= 0; clss
->base_names
[i
]; i
++) {
1922 if (clss
->bases
[i
] == 0) { /* not found yet */
1923 /* lookup and cache the base class */
1924 swig_type_info
*info
= SWIG_TypeQueryModule(module
, module
, clss
->base_names
[i
]);
1925 if (info
) clss
->bases
[i
] = (swig_lua_class
*) info
->clientdata
;
1930 #if defined(SWIG_LUA_SQUASH_BASES) && (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_LUA)
1931 /* Merges two tables */
1932 SWIGINTERN
void SWIG_Lua_merge_tables_by_index(lua_State
*L
, int target
, int source
) {
1935 while (lua_next(L
, source
) != 0) {
1936 /* -1 - value, -2 - index */
1937 /* have to copy to assign */
1938 lua_pushvalue(L
, -2); /* copy of index */
1939 lua_pushvalue(L
, -2); /* copy of value */
1940 lua_rawset(L
, target
);
1942 /* only key is left */
1946 /* Merges two tables with given name. original - index of target metatable, base - index of source metatable */
1947 SWIGINTERN
void SWIG_Lua_merge_tables(lua_State
*L
, const char *name
, int original
, int base
) {
1948 /* push original[name], then base[name] */
1949 lua_pushstring(L
, name
);
1950 lua_rawget(L
, original
);
1951 int original_table
= lua_gettop(L
);
1952 lua_pushstring(L
, name
);
1953 lua_rawget(L
, base
);
1954 int base_table
= lua_gettop(L
);
1955 SWIG_Lua_merge_tables_by_index(L
, original_table
, base_table
);
1956 /* clearing stack */
1960 /* Function takes all symbols from base and adds it to derived class. It's just a helper. */
1961 SWIGINTERN
void SWIG_Lua_class_squash_base(lua_State
*L
, swig_lua_class
*base_cls
) {
1962 /* There is one parameter - original, i.e. 'derived' class metatable */
1963 assert(lua_istable(L
, -1));
1964 int original
= lua_gettop(L
);
1965 SWIG_Lua_get_class_metatable(L
, base_cls
->fqname
);
1966 int base
= lua_gettop(L
);
1967 SWIG_Lua_merge_tables(L
, ".fn", original
, base
);
1968 SWIG_Lua_merge_tables(L
, ".set", original
, base
);
1969 SWIG_Lua_merge_tables(L
, ".get", original
, base
);
1973 /* Function squashes all symbols from 'clss' bases into itself */
1974 SWIGINTERN
void SWIG_Lua_class_squash_bases(lua_State
*L
, swig_lua_class
*clss
) {
1976 SWIG_Lua_get_class_metatable(L
, clss
->fqname
);
1977 for (i
= 0; clss
->base_names
[i
]; i
++) {
1978 if (clss
->bases
[i
] == 0) /* Somehow it's not found. Skip it */
1980 /* Thing is: all bases are already registered. Thus they have already executed
1981 * this function. So we just need to squash them into us, because their bases
1982 * are already squashed into them. No need for recursion here!
1984 SWIG_Lua_class_squash_base(L
, clss
->bases
[i
]);
1986 lua_pop(L
, 1); /*tidy stack*/
1990 #if (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_LUA) /* In elua this is useless */
1991 /* helper add a variable to a registered class */
1992 SWIGINTERN
void SWIG_Lua_add_variable(lua_State
*L
, const char *name
, lua_CFunction getFn
, lua_CFunction setFn
) {
1993 assert(lua_istable(L
, -1)); /* just in case */
1994 SWIG_Lua_get_table(L
, ".get"); /* find the .get table */
1995 assert(lua_istable(L
, -1)); /* just in case */
1996 SWIG_Lua_add_function(L
, name
, getFn
);
1997 lua_pop(L
, 1); /* tidy stack (remove table) */
1999 SWIG_Lua_get_table(L
, ".set"); /* find the .set table */
2000 assert(lua_istable(L
, -1)); /* just in case */
2001 SWIG_Lua_add_function(L
, name
, setFn
);
2002 lua_pop(L
, 1); /* tidy stack (remove table) */
2006 /* helper to recursively add class static details (static attributes, operations and constants) */
2007 SWIGINTERN
void SWIG_Lua_add_class_static_details(lua_State
*L
, swig_lua_class
*clss
) {
2009 /* The class namespace table must be on the top of the stack */
2010 assert(lua_istable(L
, -1));
2011 /* call all the base classes first: we can then override these later: */
2012 for (i
= 0; clss
->bases
[i
]; i
++) {
2013 SWIG_Lua_add_class_static_details(L
, clss
->bases
[i
]);
2016 SWIG_Lua_add_namespace_details(L
, clss
->cls_static
);
2019 SWIGINTERN
void SWIG_Lua_add_class_user_metamethods(lua_State
*L
, swig_lua_class
*clss
); /* forward declaration */
2021 /* helper to recursively add class details (attributes & operations) */
2022 SWIGINTERN
void SWIG_Lua_add_class_instance_details(lua_State
*L
, swig_lua_class
*clss
) {
2024 size_t bases_count
= 0;
2025 /* Add bases to .bases table */
2026 SWIG_Lua_get_table(L
, ".bases");
2027 assert(lua_istable(L
, -1)); /* just in case */
2028 for (i
= 0; clss
->bases
[i
]; i
++) {
2029 SWIG_Lua_get_class_metatable(L
, clss
->bases
[i
]->fqname
);
2030 /* Base class must be already registered */
2031 assert(lua_istable(L
, -1));
2032 lua_rawseti(L
, -2, i
+ 1); /* In lua indexing starts from 1 */
2035 assert(lua_rawlen(L
, -1) == bases_count
);
2036 lua_pop(L
, 1); /* remove .bases table */
2037 /* add attributes */
2038 for (i
= 0; clss
->attributes
[i
].name
; i
++) {
2039 SWIG_Lua_add_variable(L
, clss
->attributes
[i
].name
, clss
->attributes
[i
].getmethod
, clss
->attributes
[i
].setmethod
);
2041 /* add methods to the metatable */
2042 SWIG_Lua_get_table(L
, ".fn"); /* find the .fn table */
2043 assert(lua_istable(L
, -1)); /* just in case */
2044 for (i
= 0; clss
->methods
[i
].name
; i
++) {
2045 SWIG_Lua_add_function(L
, clss
->methods
[i
].name
, clss
->methods
[i
].func
);
2047 lua_pop(L
, 1); /* tidy stack (remove table) */
2048 /* add operator overloads
2049 This adds methods from metatable array to metatable. Can mess up garbage
2050 collectind if someone defines __gc method
2052 if (clss
->metatable
) {
2053 for (i
= 0; clss
->metatable
[i
].name
; i
++) {
2054 SWIG_Lua_add_function(L
, clss
->metatable
[i
].name
, clss
->metatable
[i
].func
);
2058 #if !defined(SWIG_LUA_SQUASH_BASES)
2059 /* Adding metamethods that are defined in base classes. If bases were squashed
2060 * then it is obviously unnecessary
2062 SWIG_Lua_add_class_user_metamethods(L
, clss
);
2066 /* Helpers to add user defined class metamedhods - __add, __sub etc. The helpers are needed
2067 for the following issue: Lua runtime checks for metamethod existence with rawget function
2068 ignoring our SWIG-provided __index and __newindex functions. Thus our inheritance-aware method
2069 search algorithm doesn't work in such case. (Not to say that Lua runtime queries metamethod directly
2070 in metatable and not in object).
2071 Current solution is this: if somewhere in hierarchy metamethod __x is defined, then all descendants
2072 are automatically given a special proxy __x that calls the real __x method.
2073 Obvious idea - to copy __x instead of creating __x-proxy is wrong because if someone changes __x in runtime,
2074 those changes must be reflected in all descendants.
2077 SWIGRUNTIME
int SWIG_Lua_resolve_metamethod(lua_State
*L
); /*forward declaration*/
2079 /* The real function that resolves a metamethod.
2080 * Function searches given class and all its bases (recursively) for first instance of something that is
2081 * not equal to SWIG_Lua_resolve_metamethod. (Almost always this 'something' is actual metamethod implementation
2082 * and it is a SWIG-generated C function.). It returns value on the top of the L and there is no garbage below the
2084 * Returns 1 if found, 0 otherwise.
2085 * clss is class which metatable we will search for method
2086 * metamethod_name_idx is index in L where metamethod name (as string) lies
2087 * skip_check allows skipping searching metamethod in the given class and immediately going to searching in bases. skip_check
2088 * is not carried to subsequent recursive calls - false is always passed. It is set to true only at first call from
2089 * SWIG_Lua_resolve_metamethod
2091 SWIGINTERN
int SWIG_Lua_do_resolve_metamethod(lua_State
*L
, const swig_lua_class
*clss
, int metamethod_name_idx
,
2093 /* This function is called recursively */
2098 SWIG_Lua_get_class_metatable(L
, clss
->fqname
);
2099 lua_pushvalue(L
, metamethod_name_idx
);
2101 /* If this is cfunction and it is equal to SWIG_Lua_resolve_metamethod then
2102 * this isn't the function we are looking for :)
2103 * lua_tocfunction will return NULL if not cfunction
2105 if (!lua_isnil(L
, -1) && lua_tocfunction(L
, -1) != SWIG_Lua_resolve_metamethod
) {
2106 lua_remove(L
, -2); /* removing class metatable */
2109 lua_pop(L
, 2); /* remove class metatable and query result */
2112 /* Forwarding calls to bases */
2113 for (i
= 0; clss
->bases
[i
]; i
++) {
2114 result
= SWIG_Lua_do_resolve_metamethod(L
, clss
->bases
[i
], metamethod_name_idx
, 0);
2122 /* The proxy function for metamethod. All parameters are passed as cclosure. Searches for actual method
2124 SWIGRUNTIME
int SWIG_Lua_resolve_metamethod(lua_State
*L
) {
2126 int metamethod_name_idx
;
2127 const swig_lua_class
*clss
;
2130 lua_checkstack(L
, 5);
2131 numargs
= lua_gettop(L
); /* number of arguments to pass to actual metamethod */
2133 /* Get upvalues from closure */
2134 lua_pushvalue(L
, lua_upvalueindex(1)); /*Get function name*/
2135 metamethod_name_idx
= lua_gettop(L
);
2137 lua_pushvalue(L
, lua_upvalueindex(2));
2138 clss
= (const swig_lua_class
*)(lua_touserdata(L
, -1));
2139 lua_pop(L
, 1); /* remove lightuserdata with clss from stack */
2142 result
= SWIG_Lua_do_resolve_metamethod(L
, clss
, metamethod_name_idx
, 1);
2144 SWIG_Lua_pushferrstring(L
, "The metamethod proxy is set, but it failed to find actual metamethod. Memory corruption is most likely explanation.");
2149 lua_remove(L
, -2); /* remove metamethod key */
2150 lua_insert(L
, 1); /* move function to correct position */
2151 lua_call(L
, numargs
, LUA_MULTRET
);
2152 return lua_gettop(L
); /* return all results */
2156 /* If given metamethod must be present in given class, then creates appropriate proxy
2157 * Returns 1 if successfully added, 0 if not added because no base class has it, -1
2158 * if method is defined in the class metatable itself
2160 SWIGINTERN
int SWIG_Lua_add_class_user_metamethod(lua_State
*L
, swig_lua_class
*clss
, const int metatable_index
) {
2165 /* metamethod name - on the top of the stack */
2166 assert(lua_isstring(L
, -1));
2168 key_index
= lua_gettop(L
);
2170 /* Check whether method is already defined in metatable */
2171 lua_pushvalue(L
, key_index
); /* copy of the key */
2172 lua_gettable(L
, metatable_index
);
2173 if (!lua_isnil(L
, -1)) {
2179 /* Iterating over immediate bases */
2180 for (i
= 0; clss
->bases
[i
]; i
++) {
2181 const swig_lua_class
*base
= clss
->bases
[i
];
2182 SWIG_Lua_get_class_metatable(L
, base
->fqname
);
2183 lua_pushvalue(L
, key_index
);
2185 if (!lua_isnil(L
, -1)) {
2186 lua_pushvalue(L
, key_index
);
2188 /* Add proxy function */
2189 lua_pushvalue(L
, key_index
); /* first closure value is function name */
2190 lua_pushlightuserdata(L
, clss
); /* second closure value is swig_lua_class structure */
2191 lua_pushcclosure(L
, SWIG_Lua_resolve_metamethod
, 2);
2193 lua_rawset(L
, metatable_index
);
2196 lua_pop(L
, 1); /* remove function or nil */
2197 lua_pop(L
, 1); /* remove base class metatable */
2206 SWIGINTERN
void SWIG_Lua_add_class_user_metamethods(lua_State
*L
, swig_lua_class
*clss
) {
2207 int metatable_index
;
2208 int metamethods_info_index
;
2209 int tostring_undefined
;
2210 int eq_undefined
= 0;
2212 SWIG_Lua_get_class_metatable(L
, clss
->fqname
);
2213 metatable_index
= lua_gettop(L
);
2214 SWIG_Lua_get_inheritable_metamethods(L
);
2215 assert(lua_istable(L
, -1));
2216 metamethods_info_index
= lua_gettop(L
);
2217 lua_pushnil(L
); /* first key */
2218 while (lua_next(L
, metamethods_info_index
) != 0) {
2219 /* key at index -2, value at index -1 */
2220 const int is_inheritable
= lua_toboolean(L
, -2);
2221 lua_pop(L
, 1); /* remove value - we don't need it anymore */
2223 if (is_inheritable
) { /* if metamethod is inheritable */
2224 SWIG_Lua_add_class_user_metamethod(L
, clss
, metatable_index
);
2228 lua_pop(L
, 1); /* remove inheritable metamethods table */
2230 /* Special handling for __tostring method */
2231 lua_pushstring(L
, "__tostring");
2232 lua_pushvalue(L
, -1);
2233 lua_rawget(L
, metatable_index
);
2234 tostring_undefined
= lua_isnil(L
, -1);
2236 if (tostring_undefined
) {
2237 lua_pushcfunction(L
, SWIG_Lua_class_tostring
);
2238 lua_rawset(L
, metatable_index
);
2240 lua_pop(L
, 1); /* remove copy of the key */
2243 /* Special handling for __eq method */
2244 lua_pushstring(L
, "__eq");
2245 lua_pushvalue(L
, -1);
2246 lua_rawget(L
, metatable_index
);
2247 eq_undefined
= lua_isnil(L
, -1);
2250 lua_pushcfunction(L
, SWIG_Lua_class_equal
);
2251 lua_rawset(L
, metatable_index
);
2253 lua_pop(L
, 1); /* remove copy of the key */
2255 /* Warning: __index and __newindex are SWIG-defined. For user-defined operator[]
2256 * a __getitem/__setitem method should be defined
2258 lua_pop(L
, 1); /* pop class metatable */
2261 /* Register class static methods,attributes etc as well as constructor proxy */
2262 SWIGINTERN
void SWIG_Lua_class_register_static(lua_State
*L
, swig_lua_class
*clss
) {
2263 const int SWIGUNUSED begin
= lua_gettop(L
);
2264 lua_checkstack(L
, 5); /* just in case */
2265 assert(lua_istable(L
, -1)); /* just in case */
2266 assert(strcmp(clss
->name
, clss
->cls_static
->name
) == 0); /* in class those 2 must be equal */
2268 SWIG_Lua_namespace_register(L
, clss
->cls_static
, 1);
2270 assert(lua_istable(L
, -1)); /* just in case */
2272 /* add its constructor to module with the name of the class
2273 so you can do MyClass(...) as well as new_MyClass(...)
2274 BUT only if a constructor is defined
2275 (this overcomes the problem of pure virtual classes without constructors)*/
2276 if (clss
->constructor
) {
2277 lua_getmetatable(L
, -1);
2278 assert(lua_istable(L
, -1)); /* just in case */
2279 SWIG_Lua_add_function(L
, "__call", clss
->constructor
);
2283 assert(lua_istable(L
, -1)); /* just in case */
2284 SWIG_Lua_add_class_static_details(L
, clss
);
2288 assert(lua_gettop(L
) == begin
);
2291 /* Performs the instance (non-static) class registration process. Metatable for class is created
2292 * and added to the class registry.
2294 SWIGINTERN
void SWIG_Lua_class_register_instance(lua_State
*L
, swig_lua_class
*clss
) {
2295 const int SWIGUNUSED begin
= lua_gettop(L
);
2297 /* if name already there (class is already registered) then do nothing */
2298 SWIG_Lua_get_class_registry(L
); /* get the registry */
2299 lua_pushstring(L
, clss
->fqname
); /* get the name */
2301 if (!lua_isnil(L
, -1)) {
2303 assert(lua_gettop(L
) == begin
);
2306 lua_pop(L
, 2); /* tidy stack */
2307 /* Recursively initialize all bases */
2308 for (i
= 0; clss
->bases
[i
]; i
++) {
2309 SWIG_Lua_class_register_instance(L
, clss
->bases
[i
]);
2311 /* Again, get registry and push name */
2312 SWIG_Lua_get_class_registry(L
); /* get the registry */
2313 lua_pushstring(L
, clss
->fqname
); /* get the name */
2314 lua_newtable(L
); /* create the metatable */
2315 #if defined(SWIG_LUA_SQUASH_BASES) && (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_LUA)
2316 /* If squashing is requested, then merges all bases metatable into this one.
2317 * It would get us all special methods: __getitem, __add etc.
2318 * This would set .fn, .type, and other .xxx incorrectly, but we will overwrite it right away
2321 int new_metatable_index
= lua_absindex(L
, -1);
2322 for (i
= 0; clss
->bases
[i
]; i
++) {
2324 SWIG_Lua_get_class_metatable(L
, clss
->bases
[i
]->fqname
);
2325 base_metatable
= lua_absindex(L
, -1);
2326 SWIG_Lua_merge_tables_by_index(L
, new_metatable_index
, base_metatable
);
2330 /* And now we will overwrite all incorrectly set data */
2332 /* add string of class name called ".type" */
2333 lua_pushstring(L
, ".type");
2334 lua_pushstring(L
, clss
->fqname
);
2336 /* add a table called bases */
2337 lua_pushstring(L
, ".bases");
2340 /* add a table called ".get" */
2341 lua_pushstring(L
, ".get");
2344 /* add a table called ".set" */
2345 lua_pushstring(L
, ".set");
2348 /* add a table called ".fn" */
2349 lua_pushstring(L
, ".fn");
2351 /* add manual disown method */
2352 SWIG_Lua_add_function(L
, "__disown", SWIG_Lua_class_disown
);
2354 /* add accessor fns for using the .get,.set&.fn */
2355 SWIG_Lua_add_function(L
, "__index", SWIG_Lua_class_get
);
2356 SWIG_Lua_add_function(L
, "__newindex", SWIG_Lua_class_set
);
2357 SWIG_Lua_add_function(L
, "__gc", SWIG_Lua_class_destruct
);
2359 lua_rawset(L
, -3); /* metatable into registry */
2360 lua_pop(L
, 1); /* tidy stack (remove registry) */
2361 assert(lua_gettop(L
) == begin
);
2363 #if defined(SWIG_LUA_SQUASH_BASES) && (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_LUA)
2364 /* Now merge all symbols from .fn, .set, .get etc from bases to our tables */
2365 SWIG_Lua_class_squash_bases(L
, clss
);
2367 SWIG_Lua_get_class_metatable(L
, clss
->fqname
);
2368 SWIG_Lua_add_class_instance_details(L
, clss
); /* recursive adding of details (atts & ops) */
2369 lua_pop(L
, 1); /* tidy stack (remove class metatable) */
2370 assert(lua_gettop(L
) == begin
);
2373 SWIGINTERN
void SWIG_Lua_class_register(lua_State
*L
, swig_lua_class
*clss
) {
2374 int SWIGUNUSED begin
;
2375 assert(lua_istable(L
, -1)); /* This is a table (module or namespace) where classes will be added */
2376 SWIG_Lua_class_register_instance(L
, clss
);
2377 SWIG_Lua_class_register_static(L
, clss
);
2379 /* Add links from static part to instance part and vice versa */
2380 /* [SWIG registry] [Module]
2381 * "MyClass" ----> [MyClass metatable] <===== "MyClass" -+> [static part]
2382 * ".get" ----> ... | | getmetatable()----|
2383 * ".set" ----> ... | | |
2384 * ".static" --------------)----------------/ [static part metatable]
2387 * |=============================== ".instance"
2389 begin
= lua_gettop(L
);
2390 lua_pushstring(L
, clss
->cls_static
->name
);
2391 lua_rawget(L
, -2); /* get class static table */
2392 assert(lua_istable(L
, -1));
2393 lua_getmetatable(L
, -1);
2394 assert(lua_istable(L
, -1)); /* get class static metatable */
2395 lua_pushstring(L
, ".instance"); /* prepare key */
2397 SWIG_Lua_get_class_metatable(L
, clss
->fqname
); /* get class metatable */
2398 assert(lua_istable(L
, -1));
2399 lua_pushstring(L
, ".static"); /* prepare key */
2400 lua_pushvalue(L
, -4); /* push static class TABLE */
2401 assert(lua_istable(L
, -1));
2402 lua_rawset(L
, -3); /* assign static class table(!NOT metatable) as ".static" member of class metatable */
2403 lua_rawset(L
, -3); /* assign class metatable as ".instance" member of class static METATABLE */
2405 assert(lua_gettop(L
) == begin
);
2407 #endif /* SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_LUA */
2409 #if (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUA) || (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUAC)
2410 SWIGINTERN
void SWIG_Lua_elua_class_register_instance(lua_State
*L
, swig_lua_class
*clss
) {
2411 const int SWIGUNUSED begin
= lua_gettop(L
);
2413 /* if name already there (class is already registered) then do nothing */
2414 SWIG_Lua_get_class_registry(L
); /* get the registry */
2415 lua_pushstring(L
, clss
->fqname
); /* get the name */
2417 if (!lua_isnil(L
, -1)) {
2419 assert(lua_gettop(L
) == begin
);
2422 lua_pop(L
, 2); /* tidy stack */
2423 /* Recursively initialize all bases */
2424 for (i
= 0; clss
->bases
[i
]; i
++) {
2425 SWIG_Lua_elua_class_register_instance(L
, clss
->bases
[i
]);
2427 /* Again, get registry and push name */
2428 SWIG_Lua_get_class_registry(L
); /* get the registry */
2429 lua_pushstring(L
, clss
->fqname
); /* get the name */
2430 assert(clss
->metatable
);
2431 lua_pushrotable(L
, (void *)(clss
->metatable
)); /* create the metatable */
2434 assert(lua_gettop(L
) == begin
);
2436 #endif /* elua && eluac */
2438 /* -----------------------------------------------------------------------------
2439 * Class/structure conversion fns
2440 * ----------------------------------------------------------------------------- */
2442 /* helper to add metatable to new lua object */
2443 SWIGINTERN
void SWIG_Lua_AddMetatable(lua_State
*L
, swig_type_info
*type
) {
2444 if (type
->clientdata
) { /* there is clientdata: so add the metatable */
2445 SWIG_Lua_get_class_metatable(L
, ((swig_lua_class
*)(type
->clientdata
))->fqname
);
2446 if (lua_istable(L
, -1)) {
2447 lua_setmetatable(L
, -2);
2454 /* pushes a new object into the lua stack */
2455 SWIGRUNTIME
void SWIG_Lua_NewPointerObj(lua_State
*L
, void *ptr
, swig_type_info
*type
, int own
) {
2456 swig_lua_userdata
*usr
;
2461 usr
= (swig_lua_userdata
*)lua_newuserdata(L
, sizeof(swig_lua_userdata
)); /* get data */
2462 usr
->ptr
= ptr
; /* set the ptr */
2465 #if (SWIG_LUA_TARGET != SWIG_LUA_FLAVOR_ELUAC)
2466 SWIG_Lua_AddMetatable(L
, type
); /* add metatable */
2470 /* takes a object from the lua stack & converts it into an object of the correct type
2472 SWIGRUNTIME
int SWIG_Lua_ConvertPtr(lua_State
*L
, int index
, void **ptr
, swig_type_info
*type
, int flags
) {
2473 int ret
= SWIG_ERROR
;
2474 swig_lua_userdata
*usr
;
2475 swig_cast_info
*cast
;
2476 /* special case: lua nil => NULL pointer */
2477 if (lua_isnil(L
, index
)) {
2479 return (flags
& SWIG_POINTER_NO_NULL
) ? SWIG_NullReferenceError
: SWIG_OK
;
2481 if (lua_islightuserdata(L
, index
)) {
2482 *ptr
= lua_touserdata(L
, index
);
2483 return (flags
& SWIG_POINTER_NO_NULL
) ? SWIG_NullReferenceError
: SWIG_OK
;
2485 usr
= (swig_lua_userdata
*)lua_touserdata(L
, index
); /* get data */
2487 if (((flags
& SWIG_POINTER_RELEASE
) == SWIG_POINTER_RELEASE
) && !usr
->own
) {
2488 return SWIG_ERROR_RELEASE_NOT_OWNED
;
2490 if (flags
& SWIG_POINTER_DISOWN
) { /* must disown the object */
2493 if (!type
) { /* special cast void*, no casting fn */
2497 cast
= SWIG_TypeCheck(usr
->type
->name
, type
); /* performs normal type checking */
2500 *ptr
= SWIG_TypeCast(cast
, usr
->ptr
, &newmemory
);
2501 assert(!newmemory
); /* newmemory handling not yet implemented */
2505 if ((ret
== SWIG_OK
) && (flags
& SWIG_POINTER_CLEAR
)) {
2512 SWIGRUNTIME
void *SWIG_Lua_MustGetPtr(lua_State
*L
, int index
, swig_type_info
*type
, int flags
,
2513 int argnum
, const char *func_name
) {
2515 if (!SWIG_IsOK(SWIG_ConvertPtr(L
, index
, &result
, type
, flags
))) {
2516 luaL_error(L
, "Error in %s, expected a %s at argument number %d\n",
2517 func_name
, (type
&& type
->str
) ? type
->str
: "void*", argnum
);
2522 /* pushes a packed userdata. user for member fn pointers only */
2523 SWIGRUNTIME
void SWIG_Lua_NewPackedObj(lua_State
*L
, void *ptr
, size_t size
, swig_type_info
*type
) {
2524 swig_lua_rawdata
*raw
;
2525 assert(ptr
); /* not acceptable to pass in a NULL value */
2526 raw
= (swig_lua_rawdata
*)lua_newuserdata(L
, sizeof(swig_lua_rawdata
) - 1 + size
); /* alloc data */
2529 memcpy(raw
->data
, ptr
, size
); /* copy the data */
2530 SWIG_Lua_AddMetatable(L
, type
); /* add metatable */
2533 /* converts a packed userdata. user for member fn pointers only */
2534 SWIGRUNTIME
int SWIG_Lua_ConvertPacked(lua_State
*L
, int index
, void *ptr
, size_t size
, swig_type_info
*type
) {
2535 swig_lua_rawdata
*raw
;
2536 raw
= (swig_lua_rawdata
*)lua_touserdata(L
, index
); /* get data */
2537 if (!raw
) return SWIG_ERROR
; /* error */
2538 if (type
== 0 || type
== raw
->type
) { /* void* or identical type */
2539 memcpy(ptr
, raw
->data
, size
); /* copy it */
2540 return SWIG_OK
; /* ok */
2542 return SWIG_ERROR
; /* error */
2545 /* a function to get the typestring of a piece of data */
2546 SWIGRUNTIME
const char *SWIG_Lua_typename(lua_State
*L
, int tp
) {
2547 swig_lua_userdata
*usr
;
2548 if (lua_isuserdata(L
, tp
)) {
2549 usr
= (swig_lua_userdata
*)lua_touserdata(L
, tp
); /* get data */
2550 if (usr
&& usr
->type
&& usr
->type
->str
)
2551 return usr
->type
->str
;
2552 return "userdata (unknown type)";
2554 return lua_typename(L
, lua_type(L
, tp
));
2557 /* lua callable function to get the userdata's type */
2558 SWIGRUNTIME
int SWIG_Lua_type(lua_State
*L
) {
2559 lua_pushstring(L
, SWIG_Lua_typename(L
, 1));
2563 /* -----------------------------------------------------------------------------
2564 * global variable support code: class/struct typemap functions
2565 * ----------------------------------------------------------------------------- */
2567 #if ((SWIG_LUA_TARGET != SWIG_LUA_FLAVOR_ELUA) && (SWIG_LUA_TARGET != SWIG_LUA_FLAVOR_ELUAC))
2568 /* Install Constants */
2570 SWIG_Lua_InstallConstants(lua_State
*L
, swig_lua_const_info constants
[]) {
2572 for (i
= 0; constants
[i
].type
; i
++) {
2573 switch (constants
[i
].type
) {
2575 lua_pushstring(L
, constants
[i
].name
);
2576 lua_pushinteger(L
, (lua_Integer
)constants
[i
].lvalue
);
2579 case SWIG_LUA_FLOAT
:
2580 lua_pushstring(L
, constants
[i
].name
);
2581 lua_pushnumber(L
, (lua_Number
)constants
[i
].dvalue
);
2585 lua_pushstring(L
, constants
[i
].name
);
2587 char c
= (char)constants
[i
].lvalue
;
2588 lua_pushlstring(L
, &c
, 1);
2592 case SWIG_LUA_STRING
:
2593 lua_pushstring(L
, constants
[i
].name
);
2594 lua_pushstring(L
, (char *) constants
[i
].pvalue
);
2597 case SWIG_LUA_POINTER
:
2598 lua_pushstring(L
, constants
[i
].name
);
2599 SWIG_NewPointerObj(L
, constants
[i
].pvalue
, *(constants
[i
]).ptype
, 0);
2602 case SWIG_LUA_BINARY
:
2603 lua_pushstring(L
, constants
[i
].name
);
2604 SWIG_NewMemberObj(L
, constants
[i
].pvalue
, constants
[i
].lvalue
, *(constants
[i
]).ptype
);
2614 /* -----------------------------------------------------------------------------
2615 * executing lua code from within the wrapper
2616 * ----------------------------------------------------------------------------- */
2618 #ifndef SWIG_DOSTRING_FAIL /* Allows redefining of error function */
2619 #define SWIG_DOSTRING_FAIL(S) fprintf(stderr,"%s\n",S)
2621 /* Executes a C string in Lua which is a really simple way of calling lua from C
2622 Unfortunately lua keeps changing its APIs, so we need a conditional compile
2623 In lua 5.0.X it's lua_dostring()
2624 In lua 5.1.X it's luaL_dostring()
2627 SWIG_Lua_dostring(lua_State
*L
, const char *str
) {
2629 if (str
== 0 || str
[0] == 0) return 0; /* nothing to do */
2630 top
= lua_gettop(L
); /* save stack */
2631 #if (defined(LUA_VERSION_NUM) && (LUA_VERSION_NUM>=501))
2632 ok
= luaL_dostring(L
, str
); /* looks like this is lua 5.1.X or later, good */
2634 ok
= lua_dostring(L
, str
); /* might be lua 5.0.x, using lua_dostring */
2637 SWIG_DOSTRING_FAIL(lua_tostring(L
, -1));
2639 lua_settop(L
, top
); /* restore the stack */
2647 /* ------------------------------ end luarun.swg ------------------------------ */
2650 /* -------- TYPES TABLE (BEGIN) -------- */
2652 #define SWIGTYPE_p_pm3 swig_types[0]
2653 static swig_type_info
*swig_types
[2];
2654 static swig_module_info swig_module
= {swig_types
, 1, 0, 0, 0, 0};
2655 #define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&swig_module, &swig_module, name)
2656 #define SWIG_MangledTypeQuery(name) SWIG_MangledTypeQueryModule(&swig_module, &swig_module, name)
2658 /* -------- TYPES TABLE (END) -------- */
2660 #define SWIG_name "pm3"
2661 #define SWIG_init luaopen_pm3
2662 #define SWIG_init_user luaopen_pm3_user
2664 #define SWIG_LUACODE luaopen_pm3_luacode
2666 /* Include the header in the wrapper code */
2670 SWIGINTERN pm3
*new_pm3__SWIG_0(void) {
2671 // printf("SWIG pm3 constructor, get current pm3\n");
2672 pm3_device_t
*p
= pm3_get_current_dev();
2673 p
->script_embedded
= 1;
2677 SWIGINTERN
int SWIG_lua_isnilstring(lua_State
*L
, int idx
) {
2678 int ret
= lua_isstring(L
, idx
);
2680 ret
= lua_isnil(L
, idx
);
2684 SWIGINTERN pm3
*new_pm3__SWIG_1(char *port
) {
2685 // printf("SWIG pm3 constructor with port, open pm3\n");
2686 pm3_device_t
*p
= pm3_open(port
);
2687 p
->script_embedded
= 0;
2690 SWIGINTERN
void delete_pm3(pm3
*self
) {
2691 if (self
->script_embedded
) {
2692 // printf("SWIG pm3 destructor, nothing to do\n");
2694 // printf("SWIG pm3 destructor, close pm3\n");
2701 static int _wrap_new_pm3__SWIG_0(lua_State
*L
) {
2705 SWIG_check_num_args("pm3::pm3", 0, 0)
2706 result
= (pm3
*)new_pm3__SWIG_0();
2707 SWIG_NewPointerObj(L
, result
, SWIGTYPE_p_pm3
, 1);
2718 static int _wrap_new_pm3__SWIG_1(lua_State
*L
) {
2720 char *arg1
= (char *) 0 ;
2723 SWIG_check_num_args("pm3::pm3", 1, 1)
2724 if (!SWIG_lua_isnilstring(L
, 1)) SWIG_fail_arg("pm3::pm3", 1, "char *");
2725 arg1
= (char *)lua_tostring(L
, 1);
2726 result
= (pm3
*)new_pm3__SWIG_1(arg1
);
2727 SWIG_NewPointerObj(L
, result
, SWIGTYPE_p_pm3
, 1);
2738 static int _wrap_new_pm3(lua_State
*L
) {
2744 argc
= lua_gettop(L
);
2746 return _wrap_new_pm3__SWIG_0(L
);
2751 _v
= SWIG_lua_isnilstring(L
, argv
[0]);
2754 return _wrap_new_pm3__SWIG_1(L
);
2758 SWIG_Lua_pusherrstring(L
, "Wrong arguments for overloaded function 'new_pm3'\n"
2759 " Possible C/C++ prototypes are:\n"
2761 " pm3::pm3(char *)\n");
2767 static int _wrap_pm3_console(lua_State
*L
) {
2769 pm3
*arg1
= (pm3
*) 0 ;
2770 char *arg2
= (char *) 0 ;
2771 bool arg3
= (bool) false ;
2774 SWIG_check_num_args("pm3::console", 2, 3)
2775 if (!SWIG_isptrtype(L
, 1)) SWIG_fail_arg("pm3::console", 1, "pm3 *");
2776 if (!SWIG_lua_isnilstring(L
, 2)) SWIG_fail_arg("pm3::console", 2, "char *");
2777 if (lua_gettop(L
) >= 3 && !lua_isboolean(L
, 3)) SWIG_fail_arg("pm3::console", 3, "bool");
2779 if (!SWIG_IsOK(SWIG_ConvertPtr(L
, 1, (void **)&arg1
, SWIGTYPE_p_pm3
, 0))) {
2780 SWIG_fail_ptr("pm3_console", 1, SWIGTYPE_p_pm3
);
2783 arg2
= (char *)lua_tostring(L
, 2);
2784 if (lua_gettop(L
) >= 3) {
2785 arg3
= (lua_toboolean(L
, 3) != 0);
2787 result
= (int)pm3_console(arg1
, arg2
, arg3
);
2788 lua_pushnumber(L
, (lua_Number
) result
);
2799 static int _wrap_pm3_name_get(lua_State
*L
) {
2801 pm3
*arg1
= (pm3
*) 0 ;
2804 SWIG_check_num_args("pm3::name", 1, 1)
2805 if (!SWIG_isptrtype(L
, 1)) SWIG_fail_arg("pm3::name", 1, "pm3 *");
2807 if (!SWIG_IsOK(SWIG_ConvertPtr(L
, 1, (void **)&arg1
, SWIGTYPE_p_pm3
, 0))) {
2808 SWIG_fail_ptr("pm3_name_get", 1, SWIGTYPE_p_pm3
);
2811 result
= (char *)pm3_name_get(arg1
);
2812 lua_pushstring(L
, (const char *)result
);
2823 static int _wrap_pm3_grabbed_output_get(lua_State
*L
) {
2825 pm3
*arg1
= (pm3
*) 0 ;
2828 SWIG_check_num_args("pm3::grabbed_output", 1, 1)
2829 if (!SWIG_isptrtype(L
, 1)) SWIG_fail_arg("pm3::grabbed_output", 1, "pm3 *");
2831 if (!SWIG_IsOK(SWIG_ConvertPtr(L
, 1, (void **)&arg1
, SWIGTYPE_p_pm3
, 0))) {
2832 SWIG_fail_ptr("pm3_grabbed_output_get", 1, SWIGTYPE_p_pm3
);
2835 result
= (char *)pm3_grabbed_output_get(arg1
);
2836 lua_pushstring(L
, (const char *)result
);
2847 static void swig_delete_pm3(void *obj
) {
2848 pm3
*arg1
= (pm3
*) obj
;
2851 static int _proxy__wrap_new_pm3(lua_State
*L
) {
2852 assert(lua_istable(L
, 1));
2853 lua_pushcfunction(L
, _wrap_new_pm3
);
2854 assert(!lua_isnil(L
, -1));
2855 lua_replace(L
, 1); /* replace our table with real constructor */
2856 lua_call(L
, lua_gettop(L
) - 1, 1);
2859 static swig_lua_attribute swig_pm3_attributes
[] = {
2860 { "name", _wrap_pm3_name_get
, SWIG_Lua_set_immutable
},
2861 { "grabbed_output", _wrap_pm3_grabbed_output_get
, SWIG_Lua_set_immutable
},
2864 static swig_lua_method swig_pm3_methods
[] = {
2865 { "console", _wrap_pm3_console
},
2868 static swig_lua_method swig_pm3_meta
[] = {
2872 static swig_lua_attribute swig_pm3_Sf_SwigStatic_attributes
[] = {
2875 static swig_lua_const_info swig_pm3_Sf_SwigStatic_constants
[] = {
2878 static swig_lua_method swig_pm3_Sf_SwigStatic_methods
[] = {
2881 static swig_lua_class
*swig_pm3_Sf_SwigStatic_classes
[] = {
2885 static swig_lua_namespace swig_pm3_Sf_SwigStatic
= {
2887 swig_pm3_Sf_SwigStatic_methods
,
2888 swig_pm3_Sf_SwigStatic_attributes
,
2889 swig_pm3_Sf_SwigStatic_constants
,
2890 swig_pm3_Sf_SwigStatic_classes
,
2893 static swig_lua_class
*swig_pm3_bases
[] = {0};
2894 static const char *swig_pm3_base_names
[] = {0};
2895 static swig_lua_class _wrap_class_pm3
= { "pm3", "pm3", &SWIGTYPE_p_pm3
, _proxy__wrap_new_pm3
, swig_delete_pm3
, swig_pm3_methods
, swig_pm3_attributes
, &swig_pm3_Sf_SwigStatic
, swig_pm3_meta
, swig_pm3_bases
, swig_pm3_base_names
};
2897 static swig_lua_attribute swig_SwigModule_attributes
[] = {
2900 static swig_lua_const_info swig_SwigModule_constants
[] = {
2903 static swig_lua_method swig_SwigModule_methods
[] = {
2906 static swig_lua_class
*swig_SwigModule_classes
[] = {
2910 static swig_lua_namespace
*swig_SwigModule_namespaces
[] = {
2914 static swig_lua_namespace swig_SwigModule
= {
2916 swig_SwigModule_methods
,
2917 swig_SwigModule_attributes
,
2918 swig_SwigModule_constants
,
2919 swig_SwigModule_classes
,
2920 swig_SwigModule_namespaces
2926 /* -------- TYPE CONVERSION AND EQUIVALENCE RULES (BEGIN) -------- */
2928 static swig_type_info _swigt__p_pm3
= {"_p_pm3", "pm3 *", 0, 0, (void *) &_wrap_class_pm3
, 0};
2930 static swig_type_info
*swig_type_initial
[] = {
2934 static swig_cast_info _swigc__p_pm3
[] = { {&_swigt__p_pm3
, 0, 0, 0}, {0, 0, 0, 0}};
2936 static swig_cast_info
*swig_cast_initial
[] = {
2941 /* -------- TYPE CONVERSION AND EQUIVALENCE RULES (END) -------- */
2943 /* -----------------------------------------------------------------------------
2944 * Type initialization:
2945 * This problem is tough by the requirement that no dynamic
2946 * memory is used. Also, since swig_type_info structures store pointers to
2947 * swig_cast_info structures and swig_cast_info structures store pointers back
2948 * to swig_type_info structures, we need some lookup code at initialization.
2949 * The idea is that swig generates all the structures that are needed.
2950 * The runtime then collects these partially filled structures.
2951 * The SWIG_InitializeModule function takes these initial arrays out of
2952 * swig_module, and does all the lookup, filling in the swig_module.types
2953 * array with the correct data and linking the correct swig_cast_info
2954 * structures together.
2956 * The generated swig_type_info structures are assigned statically to an initial
2957 * array. We just loop through that array, and handle each type individually.
2958 * First we lookup if this type has been already loaded, and if so, use the
2959 * loaded structure instead of the generated one. Then we have to fill in the
2960 * cast linked list. The cast data is initially stored in something like a
2961 * two-dimensional array. Each row corresponds to a type (there are the same
2962 * number of rows as there are in the swig_type_initial array). Each entry in
2963 * a column is one of the swig_cast_info structures for that type.
2964 * The cast_initial array is actually an array of arrays, because each row has
2965 * a variable number of columns. So to actually build the cast linked list,
2966 * we find the array of casts associated with the type, and loop through it
2967 * adding the casts to the list. The one last trick we need to do is making
2968 * sure the type pointer in the swig_cast_info struct is correct.
2970 * First off, we lookup the cast->type name to see if it is already loaded.
2971 * There are three cases to handle:
2972 * 1) If the cast->type has already been loaded AND the type we are adding
2973 * casting info to has not been loaded (it is in this module), THEN we
2974 * replace the cast->type pointer with the type pointer that has already
2976 * 2) If BOTH types (the one we are adding casting info to, and the
2977 * cast->type) are loaded, THEN the cast info has already been loaded by
2978 * the previous module so we just ignore it.
2979 * 3) Finally, if cast->type has not already been loaded, then we add that
2980 * swig_cast_info to the linked list (because the cast->type) pointer will
2982 * ----------------------------------------------------------------------------- */
2992 #define SWIGRUNTIME_DEBUG
2995 #ifndef SWIG_INIT_CLIENT_DATA_TYPE
2996 #define SWIG_INIT_CLIENT_DATA_TYPE void *
3000 SWIG_InitializeModule(SWIG_INIT_CLIENT_DATA_TYPE clientdata
) {
3002 swig_module_info
*module_head
, *iter
;
3005 /* check to see if the circular list has been setup, if not, set it up */
3006 if (swig_module
.next
== 0) {
3007 /* Initialize the swig_module */
3008 swig_module
.type_initial
= swig_type_initial
;
3009 swig_module
.cast_initial
= swig_cast_initial
;
3010 swig_module
.next
= &swig_module
;
3016 /* Try and load any already created modules */
3017 module_head
= SWIG_GetModule(clientdata
);
3019 /* This is the first module loaded for this interpreter */
3020 /* so set the swig module into the interpreter */
3021 SWIG_SetModule(clientdata
, &swig_module
);
3023 /* the interpreter has loaded a SWIG module, but has it loaded this one? */
3026 if (iter
== &swig_module
) {
3027 /* Our module is already in the list, so there's nothing more to do. */
3031 } while (iter
!= module_head
);
3033 /* otherwise we must add our module into the list */
3034 swig_module
.next
= module_head
->next
;
3035 module_head
->next
= &swig_module
;
3038 /* When multiple interpreters are used, a module could have already been initialized in
3039 a different interpreter, but not yet have a pointer in this interpreter.
3040 In this case, we do not want to continue adding types... everything should be
3042 if (init
== 0) return;
3044 /* Now work on filling in swig_module.types */
3045 #ifdef SWIGRUNTIME_DEBUG
3046 printf("SWIG_InitializeModule: size %lu\n", (unsigned long)swig_module
.size
);
3048 for (i
= 0; i
< swig_module
.size
; ++i
) {
3049 swig_type_info
*type
= 0;
3050 swig_type_info
*ret
;
3051 swig_cast_info
*cast
;
3053 #ifdef SWIGRUNTIME_DEBUG
3054 printf("SWIG_InitializeModule: type %lu %s\n", (unsigned long)i
, swig_module
.type_initial
[i
]->name
);
3057 /* if there is another module already loaded */
3058 if (swig_module
.next
!= &swig_module
) {
3059 type
= SWIG_MangledTypeQueryModule(swig_module
.next
, &swig_module
, swig_module
.type_initial
[i
]->name
);
3062 /* Overwrite clientdata field */
3063 #ifdef SWIGRUNTIME_DEBUG
3064 printf("SWIG_InitializeModule: found type %s\n", type
->name
);
3066 if (swig_module
.type_initial
[i
]->clientdata
) {
3067 type
->clientdata
= swig_module
.type_initial
[i
]->clientdata
;
3068 #ifdef SWIGRUNTIME_DEBUG
3069 printf("SWIG_InitializeModule: found and overwrite type %s \n", type
->name
);
3073 type
= swig_module
.type_initial
[i
];
3076 /* Insert casting types */
3077 cast
= swig_module
.cast_initial
[i
];
3078 while (cast
->type
) {
3080 /* Don't need to add information already in the list */
3082 #ifdef SWIGRUNTIME_DEBUG
3083 printf("SWIG_InitializeModule: look cast %s\n", cast
->type
->name
);
3085 if (swig_module
.next
!= &swig_module
) {
3086 ret
= SWIG_MangledTypeQueryModule(swig_module
.next
, &swig_module
, cast
->type
->name
);
3087 #ifdef SWIGRUNTIME_DEBUG
3088 if (ret
) printf("SWIG_InitializeModule: found cast %s\n", ret
->name
);
3092 if (type
== swig_module
.type_initial
[i
]) {
3093 #ifdef SWIGRUNTIME_DEBUG
3094 printf("SWIG_InitializeModule: skip old type %s\n", ret
->name
);
3099 /* Check for casting already in the list */
3100 swig_cast_info
*ocast
= SWIG_TypeCheck(ret
->name
, type
);
3101 #ifdef SWIGRUNTIME_DEBUG
3102 if (ocast
) printf("SWIG_InitializeModule: skip old cast %s\n", ret
->name
);
3104 if (!ocast
) ret
= 0;
3109 #ifdef SWIGRUNTIME_DEBUG
3110 printf("SWIG_InitializeModule: adding cast %s\n", cast
->type
->name
);
3113 type
->cast
->prev
= cast
;
3114 cast
->next
= type
->cast
;
3120 /* Set entry in modules->types array equal to the type */
3121 swig_module
.types
[i
] = type
;
3123 swig_module
.types
[i
] = 0;
3125 #ifdef SWIGRUNTIME_DEBUG
3126 printf("**** SWIG_InitializeModule: Cast List ******\n");
3127 for (i
= 0; i
< swig_module
.size
; ++i
) {
3129 swig_cast_info
*cast
= swig_module
.cast_initial
[i
];
3130 printf("SWIG_InitializeModule: type %lu %s\n", (unsigned long)i
, swig_module
.type_initial
[i
]->name
);
3131 while (cast
->type
) {
3132 printf("SWIG_InitializeModule: cast type %s\n", cast
->type
->name
);
3136 printf("---- Total casts: %d\n", j
);
3138 printf("**** SWIG_InitializeModule: Cast List ******\n");
3142 /* This function will propagate the clientdata field of type to
3143 * any new swig_type_info structures that have been added into the list
3144 * of equivalent types. It is like calling
3145 * SWIG_TypeClientData(type, clientdata) a second time.
3148 SWIG_PropagateClientData(void) {
3150 swig_cast_info
*equiv
;
3151 static int init_run
= 0;
3153 if (init_run
) return;
3156 for (i
= 0; i
< swig_module
.size
; i
++) {
3157 if (swig_module
.types
[i
]->clientdata
) {
3158 equiv
= swig_module
.types
[i
]->cast
;
3160 if (!equiv
->converter
) {
3161 if (equiv
->type
&& !equiv
->type
->clientdata
)
3162 SWIG_TypeClientData(equiv
->type
, swig_module
.types
[i
]->clientdata
);
3164 equiv
= equiv
->next
;
3180 /* Forward declaration of where the user's %init{} gets inserted */
3181 void SWIG_init_user(lua_State
*L
);
3186 /* this is the initialization function
3187 added at the very end of the code
3188 the function is always called SWIG_init, but an earlier #define will rename it
3190 #if ((SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUA) || (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUAC))
3191 LUALIB_API
int SWIG_init(lua_State
*L
)
3193 SWIGEXPORT
int SWIG_init(lua_State
*L
) /* default Lua action */
3196 #if (SWIG_LUA_TARGET != SWIG_LUA_FLAVOR_ELUAC) /* valid for both Lua and eLua */
3198 int globalRegister
= 0;
3199 /* start with global table */
3200 lua_pushglobaltable(L
);
3201 /* SWIG's internal initialisation */
3202 SWIG_InitializeModule((void *)L
);
3203 SWIG_PropagateClientData();
3206 #if ((SWIG_LUA_TARGET != SWIG_LUA_FLAVOR_ELUA) && (SWIG_LUA_TARGET != SWIG_LUA_FLAVOR_ELUAC)) || defined(SWIG_LUA_ELUA_EMULATE)
3207 /* add a global fn */
3208 SWIG_Lua_add_function(L
, "swig_type", SWIG_Lua_type
);
3209 SWIG_Lua_add_function(L
, "swig_equals", SWIG_Lua_class_equal
);
3212 #if (SWIG_LUA_TARGET != SWIG_LUA_FLAVOR_ELUAC)
3213 /* set up base class pointers (the hierarchy) */
3214 for (i
= 0; swig_types
[i
]; i
++) {
3215 if (swig_types
[i
]->clientdata
) {
3216 SWIG_Lua_init_base_class(L
, (swig_lua_class
*)(swig_types
[i
]->clientdata
));
3219 #ifdef SWIG_LUA_MODULE_GLOBAL
3224 #if (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_LUA)
3225 SWIG_Lua_namespace_register(L
, &swig_SwigModule
, globalRegister
);
3228 #if (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUA) || (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUAC)
3229 for (i
= 0; swig_types
[i
]; i
++) {
3230 if (swig_types
[i
]->clientdata
) {
3231 SWIG_Lua_elua_class_register_instance(L
, (swig_lua_class
*)(swig_types
[i
]->clientdata
));
3236 #if defined(SWIG_LUA_ELUA_EMULATE)
3238 SWIG_Lua_elua_emulate_register(L
, swig_SwigModule
.ns_methods
);
3239 SWIG_Lua_elua_emulate_register_clear(L
);
3240 if (globalRegister
) {
3241 lua_pushstring(L
, swig_SwigModule
.name
);
3242 lua_pushvalue(L
, -2);
3249 #if (SWIG_LUA_TARGET != SWIG_LUA_FLAVOR_ELUAC)
3250 /* invoke user-specific initialization */
3253 /* Note: We do not clean up the stack here (Lua will do this for us). At this
3254 point, we have the globals table and out module table on the stack. Returning
3255 one value makes the module table the result of the require command. */
3267 const char *SWIG_LUACODE
=
3270 void SWIG_init_user(lua_State
*L
) {
3271 /* exec Lua code if applicable */
3272 SWIG_Lua_dostring(L
, SWIG_LUACODE
);