From de96479d800c99eb04ae490c0fe0044fa8f2152f Mon Sep 17 00:00:00 2001 From: Philippe Teuwen Date: Tue, 29 Oct 2024 21:12:20 +0100 Subject: [PATCH] pm3_console() in Python/Lua/C: replace passthru by capture and quiet --- CHANGELOG.md | 1 + .../01make_client_cmake.sh | 1 + .../01make_client_makefile.sh | 8 +- .../testembedded.lua | 2 +- .../testembedded.py | 2 +- client/experimental_lib/example_c/test.c | 2 +- client/experimental_lib/example_c/test_grab.c | 2 +- client/experimental_lib/example_lua/test.lua | 2 +- client/experimental_lib/example_py/test.py | 2 +- client/include/pm3.h | 2 +- client/pyscripts/fm11rf08s_recovery.py | 2 +- client/pyscripts/pm3.py | 4 +- client/src/pm3.c | 6 +- client/src/pm3.i | 9 +- client/src/pm3_luawrap.c | 3741 ++++++------- client/src/pm3_pywrap.c | 4830 +++++++++-------- 16 files changed, 4382 insertions(+), 4234 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4cb3f8449b..bf1cb7cfe7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ All notable changes to this project will be documented in this file. This project uses the changelog in accordance with [keepchangelog](http://keepachangelog.com/). Please use this to write notable changes, which is not the same as git commit log... ## [unreleased][unreleased] +- Changed `pm3_console()` - Python/Lua/C: replace `passthru` by `capture` and `quiet` (@doegox) - Fixed `hf iclass list` - annotation crc handled better (@iceman1001) - Fixed `hf_mf_uscuid_prog.lua` - bad divisions and code style fixes (@iceman1001) - Changed `hf iclass info` - now checks for cards silicon version (@antiklesys) diff --git a/client/experimental_client_with_swig/01make_client_cmake.sh b/client/experimental_client_with_swig/01make_client_cmake.sh index 456227a7a9..e85171d00a 100755 --- a/client/experimental_client_with_swig/01make_client_cmake.sh +++ b/client/experimental_client_with_swig/01make_client_cmake.sh @@ -13,3 +13,4 @@ ln -s build/proxmark3 . ) ln -s ../pyscripts/pm3.py +ln -s ../lualibs/dkjson.lua diff --git a/client/experimental_client_with_swig/01make_client_makefile.sh b/client/experimental_client_with_swig/01make_client_makefile.sh index 93ab04ca23..0ebb2953f4 100755 --- a/client/experimental_client_with_swig/01make_client_makefile.sh +++ b/client/experimental_client_with_swig/01make_client_makefile.sh @@ -1,4 +1,8 @@ #!/bin/bash -cd .. -make -j +( + cd .. + make -j +) +ln -s ../pyscripts/pm3.py +ln -s ../lualibs/dkjson.lua diff --git a/client/experimental_client_with_swig/testembedded.lua b/client/experimental_client_with_swig/testembedded.lua index 5ed3a8ac04..4857a53727 100755 --- a/client/experimental_client_with_swig/testembedded.lua +++ b/client/experimental_client_with_swig/testembedded.lua @@ -10,7 +10,7 @@ for line in p.grabbed_output:gmatch("[^\r\n]+") do end print("Device:", p.name) -p:console("Rem passthru remark! :coffee:", true) +p:console("Rem passthru remark! :coffee:", false, false) local json = require("dkjson") print("Fetching prefs:") diff --git a/client/experimental_client_with_swig/testembedded.py b/client/experimental_client_with_swig/testembedded.py index 6bf5331bf3..78564a3145 100755 --- a/client/experimental_client_with_swig/testembedded.py +++ b/client/experimental_client_with_swig/testembedded.py @@ -11,7 +11,7 @@ if "uC:" in line: print(line) print("Device:", p.name) -p.console("Rem passthru remark! :coffee:", True) +p.console("Rem passthru remark! :coffee:", capture=False, quiet=False) import json print("Fetching prefs:") diff --git a/client/experimental_lib/example_c/test.c b/client/experimental_lib/example_c/test.c index bd19001548..6debb332cc 100644 --- a/client/experimental_lib/example_c/test.c +++ b/client/experimental_lib/example_c/test.c @@ -9,6 +9,6 @@ int main(int argc, char *argv[]) { } pm3 *p; p = pm3_open(argv[1]); - pm3_console(p, "hw status", true); + pm3_console(p, "hw status", false, false); pm3_close(p); } diff --git a/client/experimental_lib/example_c/test_grab.c b/client/experimental_lib/example_c/test_grab.c index 69b2b7ebf4..ee573fc31f 100644 --- a/client/experimental_lib/example_c/test_grab.c +++ b/client/experimental_lib/example_c/test_grab.c @@ -18,7 +18,7 @@ int main(int argc, char *argv[]) { p = pm3_open(argv[1]); // Execute the command - pm3_console(p, "hw status", false); + pm3_console(p, "hw status", true, true); const char *buf = pm3_grabbed_output_get(p); const char *line_start = buf; diff --git a/client/experimental_lib/example_lua/test.lua b/client/experimental_lib/example_lua/test.lua index d7a165c494..03c0dc149e 100755 --- a/client/experimental_lib/example_lua/test.lua +++ b/client/experimental_lib/example_lua/test.lua @@ -12,7 +12,7 @@ for line in p.grabbed_output:gmatch("[^\r\n]+") do end print("Device:", p.name) -p:console("Rem passthru remark! :coffee:", true) +p:console("Rem passthru remark! :coffee:", false, false) local json = require("dkjson") print("Fetching prefs:") diff --git a/client/experimental_lib/example_py/test.py b/client/experimental_lib/example_py/test.py index 99e104b8ff..fc932b7e57 100755 --- a/client/experimental_lib/example_py/test.py +++ b/client/experimental_lib/example_py/test.py @@ -11,7 +11,7 @@ if "uC:" in line: print(line) print("Device:", p.name) -p.console("Rem passthru remark! :coffee:", True) +p.console("Rem passthru remark! :coffee:", capture=False, quiet=False) import json print("Fetching prefs:") diff --git a/client/include/pm3.h b/client/include/pm3.h index b19fe71740..92e99bacd7 100644 --- a/client/include/pm3.h +++ b/client/include/pm3.h @@ -21,7 +21,7 @@ typedef struct pm3_device pm3; pm3 *pm3_open(const char *port); -int pm3_console(pm3 *dev, const char *cmd, bool passthru); +int pm3_console(pm3 *dev, const char *cmd, bool capture, bool quiet); const char *pm3_grabbed_output_get(pm3 *dev); const char *pm3_name_get(pm3 *dev); void pm3_close(pm3 *dev); diff --git a/client/pyscripts/fm11rf08s_recovery.py b/client/pyscripts/fm11rf08s_recovery.py index 71f785111b..1803ea1c1d 100755 --- a/client/pyscripts/fm11rf08s_recovery.py +++ b/client/pyscripts/fm11rf08s_recovery.py @@ -538,7 +538,7 @@ def print_key(sec, key_type, key): cmd = f"hf mf fchk -f keys_{uid:08x}.dic --no-default --dump" if args.debug: print(cmd) - p.console(cmd, passthru=True) + p.console(cmd, capture=False, quiet=False) else: print() print(plus + color("found keys:", fg="green")) diff --git a/client/pyscripts/pm3.py b/client/pyscripts/pm3.py index ead49777a2..26e90a774b 100644 --- a/client/pyscripts/pm3.py +++ b/client/pyscripts/pm3.py @@ -66,8 +66,8 @@ def __init__(self, *args): _pm3.pm3_swiginit(self, _pm3.new_pm3(*args)) __swig_destroy__ = _pm3.delete_pm3 - def console(self, cmd, passthru=False): - return _pm3.pm3_console(self, cmd, passthru) + def console(self, cmd, capture=True, quiet=True): + return _pm3.pm3_console(self, cmd, capture, quiet) name = property(_pm3.pm3_name_get) grabbed_output = property(_pm3.pm3_grabbed_output_get) diff --git a/client/src/pm3.c b/client/src/pm3.c index 600fd07caf..ff08c8b949 100644 --- a/client/src/pm3.c +++ b/client/src/pm3.c @@ -58,12 +58,14 @@ void pm3_close(pm3_device_t *dev) { free_grabber(); } -int pm3_console(pm3_device_t *dev, const char *cmd, bool passthru) { +int pm3_console(pm3_device_t *dev, const char *cmd, bool capture, bool quiet) { // For now, there is no real device context: (void) dev; uint8_t prev_printAndLog = g_printAndLog; - if (! passthru) { + if (capture) { g_printAndLog |= PRINTANDLOG_GRAB; + } + if (quiet) { g_printAndLog &= ~PRINTANDLOG_PRINT; } int ret = CommandReceived(cmd); diff --git a/client/src/pm3.i b/client/src/pm3.i index 810f5eb229..f7923323cc 100644 --- a/client/src/pm3.i +++ b/client/src/pm3.i @@ -11,8 +11,11 @@ #ifdef PYWRAP #include - %typemap(default) bool passthru { - $1 = Py_False; + %typemap(default) bool capture { + $1 = Py_True; + } + %typemap(default) bool quiet { + $1 = Py_True; } #endif typedef struct { @@ -37,7 +40,7 @@ typedef struct { pm3_close($self); } } - int console(char *cmd, bool passthru = false); + int console(char *cmd, bool capture = true, bool quiet = true); char const * const name; char const * const grabbed_output; } diff --git a/client/src/pm3_luawrap.c b/client/src/pm3_luawrap.c index c880d09fd4..87dec2a1eb 100644 --- a/client/src/pm3_luawrap.c +++ b/client/src/pm3_luawrap.c @@ -140,7 +140,7 @@ # define SWIG_NULLPTR nullptr #else # define SWIG_NULLPTR NULL -#endif +#endif /* ----------------------------------------------------------------------------- * swigcompat.swg @@ -339,10 +339,10 @@ # define SWIG_CASTRANKMASK ((SWIG_CASTRANKLIMIT) -1) # define SWIG_CastRank(r) (r & SWIG_CASTRANKMASK) SWIGINTERNINLINE int SWIG_AddCast(int r) { - return SWIG_IsOK(r) ? ((SWIG_CastRank(r) < SWIG_MAXCASTRANK) ? (r + 1) : SWIG_ERROR) : r; + return SWIG_IsOK(r) ? ((SWIG_CastRank(r) < SWIG_MAXCASTRANK) ? (r + 1) : SWIG_ERROR) : r; } SWIGINTERNINLINE int SWIG_CheckState(int r) { - return SWIG_IsOK(r) ? SWIG_CastRank(r) + 1 : 0; + return SWIG_IsOK(r) ? SWIG_CastRank(r) + 1 : 0; } #else /* no cast-rank mode */ # define SWIG_AddCast(r) (r) @@ -361,32 +361,32 @@ typedef struct swig_type_info *(*swig_dycast_func)(void **); /* Structure to store information on one type */ typedef struct swig_type_info { - const char *name; /* mangled name of this type */ - const char *str; /* human readable name of this type */ - swig_dycast_func dcast; /* dynamic cast function down a hierarchy */ - struct swig_cast_info *cast; /* linked list of types that can cast into this type */ - void *clientdata; /* language specific type data */ - int owndata; /* flag if the structure owns the clientdata */ + const char *name; /* mangled name of this type */ + const char *str; /* human readable name of this type */ + swig_dycast_func dcast; /* dynamic cast function down a hierarchy */ + struct swig_cast_info *cast; /* linked list of types that can cast into this type */ + void *clientdata; /* language specific type data */ + int owndata; /* flag if the structure owns the clientdata */ } swig_type_info; /* Structure to store a type and conversion function used for casting */ typedef struct swig_cast_info { - swig_type_info *type; /* pointer to type that is equivalent to this type */ - swig_converter_func converter; /* function to cast the void pointers */ - struct swig_cast_info *next; /* pointer to next cast in linked list */ - struct swig_cast_info *prev; /* pointer to the previous cast */ + swig_type_info *type; /* pointer to type that is equivalent to this type */ + swig_converter_func converter; /* function to cast the void pointers */ + struct swig_cast_info *next; /* pointer to next cast in linked list */ + struct swig_cast_info *prev; /* pointer to the previous cast */ } swig_cast_info; /* Structure used to store module information * Each module generates one structure like this, and the runtime collects * all of these structures and stores them in a circularly linked list.*/ typedef struct swig_module_info { - swig_type_info **types; /* Array of pointers to swig_type_info structures that are in this module */ - size_t size; /* Number of types in this module */ - struct swig_module_info *next; /* Pointer to next element in circularly linked list */ - swig_type_info **type_initial; /* Array of initially generated type structures */ - swig_cast_info **cast_initial; /* Array of initially generated casting structures */ - void *clientdata; /* Language specific module data */ + swig_type_info **types; /* Array of pointers to swig_type_info structures that are in this module */ + size_t size; /* Number of types in this module */ + struct swig_module_info *next; /* Pointer to next element in circularly linked list */ + swig_type_info **type_initial; /* Array of initially generated type structures */ + swig_cast_info **cast_initial; /* Array of initially generated casting structures */ + void *clientdata; /* Language specific module data */ } swig_module_info; /* @@ -398,13 +398,13 @@ typedef struct swig_module_info { */ SWIGRUNTIME int SWIG_TypeNameComp(const char *f1, const char *l1, - const char *f2, const char *l2) { - for (; (f1 != l1) && (f2 != l2); ++f1, ++f2) { - while ((*f1 == ' ') && (f1 != l1)) ++f1; - while ((*f2 == ' ') && (f2 != l2)) ++f2; - if (*f1 != *f2) return (*f1 > *f2) ? 1 : -1; - } - return (int)((l1 - f1) - (l2 - f2)); + const char *f2, const char *l2) { + for (;(f1 != l1) && (f2 != l2); ++f1, ++f2) { + while ((*f1 == ' ') && (f1 != l1)) ++f1; + while ((*f2 == ' ') && (f2 != l2)) ++f2; + if (*f1 != *f2) return (*f1 > *f2) ? 1 : -1; + } + return (int)((l1 - f1) - (l2 - f2)); } /* @@ -413,17 +413,17 @@ SWIG_TypeNameComp(const char *f1, const char *l1, */ SWIGRUNTIME int SWIG_TypeCmp(const char *nb, const char *tb) { - int equiv = 1; - const char *te = tb + strlen(tb); - const char *ne = nb; - while (equiv != 0 && *ne) { - for (nb = ne; *ne; ++ne) { - if (*ne == '|') break; - } - equiv = SWIG_TypeNameComp(nb, ne, tb, te); - if (*ne) ++ne; + int equiv = 1; + const char* te = tb + strlen(tb); + const char* ne = nb; + while (equiv != 0 && *ne) { + for (nb = ne; *ne; ++ne) { + if (*ne == '|') break; } - return equiv; + equiv = SWIG_TypeNameComp(nb, ne, tb, te); + if (*ne) ++ne; + } + return equiv; } /* @@ -432,7 +432,7 @@ SWIG_TypeCmp(const char *nb, const char *tb) { */ SWIGRUNTIME int SWIG_TypeEquiv(const char *nb, const char *tb) { - return SWIG_TypeCmp(nb, tb) == 0 ? 1 : 0; + return SWIG_TypeCmp(nb, tb) == 0 ? 1 : 0; } /* @@ -440,26 +440,26 @@ SWIG_TypeEquiv(const char *nb, const char *tb) { */ SWIGRUNTIME swig_cast_info * SWIG_TypeCheck(const char *c, swig_type_info *ty) { - if (ty) { - swig_cast_info *iter = ty->cast; - while (iter) { - if (strcmp(iter->type->name, c) == 0) { - if (iter == ty->cast) - return iter; - /* Move iter to the top of the linked list */ - iter->prev->next = iter->next; - if (iter->next) - iter->next->prev = iter->prev; - iter->next = ty->cast; - iter->prev = 0; - if (ty->cast) ty->cast->prev = iter; - ty->cast = iter; - return iter; - } - iter = iter->next; - } + if (ty) { + swig_cast_info *iter = ty->cast; + while (iter) { + if (strcmp(iter->type->name, c) == 0) { + if (iter == ty->cast) + return iter; + /* Move iter to the top of the linked list */ + iter->prev->next = iter->next; + if (iter->next) + iter->next->prev = iter->prev; + iter->next = ty->cast; + iter->prev = 0; + if (ty->cast) ty->cast->prev = iter; + ty->cast = iter; + return iter; + } + iter = iter->next; } - return 0; + } + return 0; } /* @@ -467,26 +467,26 @@ SWIG_TypeCheck(const char *c, swig_type_info *ty) { */ SWIGRUNTIME swig_cast_info * SWIG_TypeCheckStruct(const swig_type_info *from, swig_type_info *ty) { - if (ty) { - swig_cast_info *iter = ty->cast; - while (iter) { - if (iter->type == from) { - if (iter == ty->cast) - return iter; - /* Move iter to the top of the linked list */ - iter->prev->next = iter->next; - if (iter->next) - iter->next->prev = iter->prev; - iter->next = ty->cast; - iter->prev = 0; - if (ty->cast) ty->cast->prev = iter; - ty->cast = iter; - return iter; - } - iter = iter->next; - } + if (ty) { + swig_cast_info *iter = ty->cast; + while (iter) { + if (iter->type == from) { + if (iter == ty->cast) + return iter; + /* Move iter to the top of the linked list */ + iter->prev->next = iter->next; + if (iter->next) + iter->next->prev = iter->prev; + iter->next = ty->cast; + iter->prev = 0; + if (ty->cast) ty->cast->prev = iter; + ty->cast = iter; + return iter; + } + iter = iter->next; } - return 0; + } + return 0; } /* @@ -494,7 +494,7 @@ SWIG_TypeCheckStruct(const swig_type_info *from, swig_type_info *ty) { */ SWIGRUNTIMEINLINE void * SWIG_TypeCast(swig_cast_info *ty, void *ptr, int *newmemory) { - return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr, newmemory); + return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr, newmemory); } /* @@ -502,13 +502,13 @@ SWIG_TypeCast(swig_cast_info *ty, void *ptr, int *newmemory) { */ SWIGRUNTIME swig_type_info * SWIG_TypeDynamicCast(swig_type_info *ty, void **ptr) { - swig_type_info *lastty = ty; - if (!ty || !ty->dcast) return ty; - while (ty && (ty->dcast)) { - ty = (*ty->dcast)(ptr); - if (ty) lastty = ty; - } - return lastty; + swig_type_info *lastty = ty; + if (!ty || !ty->dcast) return ty; + while (ty && (ty->dcast)) { + ty = (*ty->dcast)(ptr); + if (ty) lastty = ty; + } + return lastty; } /* @@ -516,7 +516,7 @@ SWIG_TypeDynamicCast(swig_type_info *ty, void **ptr) { */ SWIGRUNTIMEINLINE const char * SWIG_TypeName(const swig_type_info *ty) { - return ty->name; + return ty->name; } /* @@ -525,19 +525,20 @@ SWIG_TypeName(const swig_type_info *ty) { */ SWIGRUNTIME const char * SWIG_TypePrettyName(const swig_type_info *type) { - /* The "str" field contains the equivalent pretty names of the - type, separated by vertical-bar characters. Choose the last - name. It should be the most specific; a fully resolved name - but not necessarily with default template parameters expanded. */ - if (!type) return NULL; - if (type->str != NULL) { - const char *last_name = type->str; - const char *s; - for (s = type->str; *s; s++) - if (*s == '|') last_name = s + 1; - return last_name; - } else - return type->name; + /* The "str" field contains the equivalent pretty names of the + type, separated by vertical-bar characters. Choose the last + name. It should be the most specific; a fully resolved name + but not necessarily with default template parameters expanded. */ + if (!type) return NULL; + if (type->str != NULL) { + const char *last_name = type->str; + const char *s; + for (s = type->str; *s; s++) + if (*s == '|') last_name = s+1; + return last_name; + } + else + return type->name; } /* @@ -545,24 +546,24 @@ SWIG_TypePrettyName(const swig_type_info *type) { */ SWIGRUNTIME void SWIG_TypeClientData(swig_type_info *ti, void *clientdata) { - swig_cast_info *cast = ti->cast; - /* if (ti->clientdata == clientdata) return; */ - ti->clientdata = clientdata; - - while (cast) { - if (!cast->converter) { - swig_type_info *tc = cast->type; - if (!tc->clientdata) { - SWIG_TypeClientData(tc, clientdata); - } - } - cast = cast->next; + swig_cast_info *cast = ti->cast; + /* if (ti->clientdata == clientdata) return; */ + ti->clientdata = clientdata; + + while (cast) { + if (!cast->converter) { + swig_type_info *tc = cast->type; + if (!tc->clientdata) { + SWIG_TypeClientData(tc, clientdata); + } } + cast = cast->next; + } } SWIGRUNTIME void SWIG_TypeNewClientData(swig_type_info *ti, void *clientdata) { - SWIG_TypeClientData(ti, clientdata); - ti->owndata = 1; + SWIG_TypeClientData(ti, clientdata); + ti->owndata = 1; } /* @@ -576,37 +577,37 @@ SWIG_TypeNewClientData(swig_type_info *ti, void *clientdata) { SWIGRUNTIME swig_type_info * SWIG_MangledTypeQueryModule(swig_module_info *start, swig_module_info *end, - const char *name) { - swig_module_info *iter = start; - do { - if (iter->size) { - size_t l = 0; - size_t r = iter->size - 1; - do { - /* since l+r >= 0, we can (>> 1) instead (/ 2) */ - size_t i = (l + r) >> 1; - const char *iname = iter->types[i]->name; - if (iname) { - int compare = strcmp(name, iname); - if (compare == 0) { - return iter->types[i]; - } else if (compare < 0) { - if (i) { - r = i - 1; - } else { - break; - } - } else if (compare > 0) { - l = i + 1; - } - } else { - break; /* should never happen */ - } - } while (l <= r); - } - iter = iter->next; - } while (iter != end); - return 0; + const char *name) { + swig_module_info *iter = start; + do { + if (iter->size) { + size_t l = 0; + size_t r = iter->size - 1; + do { + /* since l+r >= 0, we can (>> 1) instead (/ 2) */ + size_t i = (l + r) >> 1; + const char *iname = iter->types[i]->name; + if (iname) { + int compare = strcmp(name, iname); + if (compare == 0) { + return iter->types[i]; + } else if (compare < 0) { + if (i) { + r = i - 1; + } else { + break; + } + } else if (compare > 0) { + l = i + 1; + } + } else { + break; /* should never happen */ + } + } while (l <= r); + } + iter = iter->next; + } while (iter != end); + return 0; } /* @@ -621,27 +622,27 @@ SWIG_MangledTypeQueryModule(swig_module_info *start, SWIGRUNTIME swig_type_info * SWIG_TypeQueryModule(swig_module_info *start, swig_module_info *end, - const char *name) { - /* STEP 1: Search the name field using binary search */ - swig_type_info *ret = SWIG_MangledTypeQueryModule(start, end, name); - if (ret) { - return ret; - } else { - /* STEP 2: If the type hasn't been found, do a complete search - of the str field (the human readable name) */ - swig_module_info *iter = start; - do { - size_t i = 0; - for (; i < iter->size; ++i) { - if (iter->types[i]->str && (SWIG_TypeEquiv(iter->types[i]->str, name))) - return iter->types[i]; - } - iter = iter->next; - } while (iter != end); - } + const char *name) { + /* STEP 1: Search the name field using binary search */ + swig_type_info *ret = SWIG_MangledTypeQueryModule(start, end, name); + if (ret) { + return ret; + } else { + /* STEP 2: If the type hasn't been found, do a complete search + of the str field (the human readable name) */ + swig_module_info *iter = start; + do { + size_t i = 0; + for (; i < iter->size; ++i) { + if (iter->types[i]->str && (SWIG_TypeEquiv(iter->types[i]->str, name))) + return iter->types[i]; + } + iter = iter->next; + } while (iter != end); + } - /* neither found a match */ - return 0; + /* neither found a match */ + return 0; } /* @@ -649,15 +650,15 @@ SWIG_TypeQueryModule(swig_module_info *start, */ SWIGRUNTIME char * SWIG_PackData(char *c, void *ptr, size_t sz) { - static const char hex[17] = "0123456789abcdef"; - const unsigned char *u = (unsigned char *) ptr; - const unsigned char *eu = u + sz; - for (; u != eu; ++u) { - unsigned char uu = *u; - *(c++) = hex[(uu & 0xf0) >> 4]; - *(c++) = hex[uu & 0xf]; - } - return c; + static const char hex[17] = "0123456789abcdef"; + const unsigned char *u = (unsigned char *) ptr; + const unsigned char *eu = u + sz; + for (; u != eu; ++u) { + unsigned char uu = *u; + *(c++) = hex[(uu & 0xf0) >> 4]; + *(c++) = hex[uu & 0xf]; + } + return c; } /* @@ -665,27 +666,27 @@ SWIG_PackData(char *c, void *ptr, size_t sz) { */ SWIGRUNTIME const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) { - unsigned char *u = (unsigned char *) ptr; - const unsigned char *eu = u + sz; - for (; u != eu; ++u) { - char d = *(c++); - unsigned char uu; - if ((d >= '0') && (d <= '9')) - uu = (unsigned char)((d - '0') << 4); - else if ((d >= 'a') && (d <= 'f')) - uu = (unsigned char)((d - ('a' - 10)) << 4); - else - return (char *) 0; - d = *(c++); - if ((d >= '0') && (d <= '9')) - uu |= (unsigned char)(d - '0'); - else if ((d >= 'a') && (d <= 'f')) - uu |= (unsigned char)(d - ('a' - 10)); - else - return (char *) 0; - *u = uu; - } - return c; + unsigned char *u = (unsigned char *) ptr; + const unsigned char *eu = u + sz; + for (; u != eu; ++u) { + char d = *(c++); + unsigned char uu; + if ((d >= '0') && (d <= '9')) + uu = (unsigned char)((d - '0') << 4); + else if ((d >= 'a') && (d <= 'f')) + uu = (unsigned char)((d - ('a'-10)) << 4); + else + return (char *) 0; + d = *(c++); + if ((d >= '0') && (d <= '9')) + uu |= (unsigned char)(d - '0'); + else if ((d >= 'a') && (d <= 'f')) + uu |= (unsigned char)(d - ('a'-10)); + else + return (char *) 0; + *u = uu; + } + return c; } /* @@ -693,54 +694,54 @@ SWIG_UnpackData(const char *c, void *ptr, size_t sz) { */ SWIGRUNTIME char * SWIG_PackVoidPtr(char *buff, void *ptr, const char *name, size_t bsz) { - char *r = buff; - if ((2 * sizeof(void *) + 2) > bsz) return 0; - *(r++) = '_'; - r = SWIG_PackData(r, &ptr, sizeof(void *)); - if (strlen(name) + 1 > (bsz - (r - buff))) return 0; - strcpy(r, name); - return buff; + char *r = buff; + if ((2*sizeof(void *) + 2) > bsz) return 0; + *(r++) = '_'; + r = SWIG_PackData(r,&ptr,sizeof(void *)); + if (strlen(name) + 1 > (bsz - (r - buff))) return 0; + strcpy(r,name); + return buff; } SWIGRUNTIME const char * SWIG_UnpackVoidPtr(const char *c, void **ptr, const char *name) { - if (*c != '_') { - if (strcmp(c, "NULL") == 0) { - *ptr = (void *) 0; - return name; - } else { - return 0; - } + if (*c != '_') { + if (strcmp(c,"NULL") == 0) { + *ptr = (void *) 0; + return name; + } else { + return 0; } - return SWIG_UnpackData(++c, ptr, sizeof(void *)); + } + return SWIG_UnpackData(++c,ptr,sizeof(void *)); } SWIGRUNTIME char * SWIG_PackDataName(char *buff, void *ptr, size_t sz, const char *name, size_t bsz) { - char *r = buff; - size_t lname = (name ? strlen(name) : 0); - if ((2 * sz + 2 + lname) > bsz) return 0; - *(r++) = '_'; - r = SWIG_PackData(r, ptr, sz); - if (lname) { - strncpy(r, name, lname + 1); - } else { - *r = 0; - } - return buff; + char *r = buff; + size_t lname = (name ? strlen(name) : 0); + if ((2*sz + 2 + lname) > bsz) return 0; + *(r++) = '_'; + r = SWIG_PackData(r,ptr,sz); + if (lname) { + strncpy(r,name,lname+1); + } else { + *r = 0; + } + return buff; } SWIGRUNTIME const char * SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) { - if (*c != '_') { - if (strcmp(c, "NULL") == 0) { - memset(ptr, 0, sz); - return name; - } else { - return 0; - } + if (*c != '_') { + if (strcmp(c,"NULL") == 0) { + memset(ptr,0,sz); + return name; + } else { + return 0; } - return SWIG_UnpackData(++c, ptr, sz); + } + return SWIG_UnpackData(++c,ptr,sz); } #ifdef __cplusplus @@ -797,32 +798,32 @@ extern "C" { struct swig_elua_entry; typedef struct swig_elua_key { - int type; - union { - const char *strkey; - lua_Number numkey; - } key; + int type; + union { + const char* strkey; + lua_Number numkey; + } key; } swig_elua_key; typedef struct swig_elua_val { - int type; - union { - lua_Number number; - const struct swig_elua_entry *table; - const char *string; - lua_CFunction function; - struct { - char member; - long lvalue; - void *pvalue; - swig_type_info **ptype; - } userdata; - } value; + int type; + union { + lua_Number number; + const struct swig_elua_entry *table; + const char *string; + lua_CFunction function; + struct { + char member; + long lvalue; + void *pvalue; + swig_type_info **ptype; + } userdata; + } value; } swig_elua_val; typedef struct swig_elua_entry { - swig_elua_key key; - swig_elua_val value; + swig_elua_key key; + swig_elua_val value; } swig_elua_entry; #define LSTRKEY(x) {LUA_TSTRING, {.strkey = x} } @@ -856,7 +857,7 @@ typedef struct swig_elua_entry { # define SWIG_LUA_CONSTTAB_FLOAT(B, C) LSTRKEY(B), LNUMVAL(C) # define SWIG_LUA_CONSTTAB_STRING(B, C) LSTRKEY(B), LSTRVAL(C) # define SWIG_LUA_CONSTTAB_CHAR(B, C) LSTRKEY(B), LNUMVAL(C) -/* Those two types of constants are not supported in elua */ + /* Those two types of constants are not supported in elua */ #ifndef SWIG_LUA_CONSTTAB_POINTER #warning eLua does not support pointers as constants. By default, nil will be used as value @@ -920,11 +921,11 @@ typedef struct swig_elua_entry { we provide a compatibility implementation for Lua 5.0. */ #if !defined(LUA_VERSION_NUM) || LUA_VERSION_NUM < 501 static const char *(lua_tolstring)(lua_State *L, int idx, size_t *len) { - /* Call lua_tostring() first as it may convert the value from number to - string. */ - const char *result = lua_tostring(L, idx); - if (len) *len = lua_strlen(L, idx); - return result; + /* Call lua_tostring() first as it may convert the value from number to + string. */ + const char *result = lua_tostring(L, idx); + if (len) *len = lua_strlen(L, idx); + return result; } #endif @@ -962,23 +963,25 @@ static const char *(lua_tolstring)(lua_State *L, int idx, size_t *len) { prefixed with the location of the innermost Lua call-point (as formatted by luaL_where). */ SWIGRUNTIME void -SWIG_Lua_pusherrstring(lua_State *L, const char *str) { - luaL_where(L, 1); - lua_pushstring(L, str); - lua_concat(L, 2); +SWIG_Lua_pusherrstring (lua_State *L, const char *str) +{ + luaL_where (L, 1); + lua_pushstring (L, str); + lua_concat (L, 2); } /* Push a formatted string generated from FMT and following args on the Lua stack, like lua_pushfstring, but prefixed with the location of the innermost Lua call-point (as formatted by luaL_where). */ SWIGRUNTIME void -SWIG_Lua_pushferrstring(lua_State *L, const char *fmt, ...) { - va_list argp; - va_start(argp, fmt); - luaL_where(L, 1); - lua_pushvfstring(L, fmt, argp); - va_end(argp); - lua_concat(L, 2); +SWIG_Lua_pushferrstring (lua_State *L, const char *fmt, ...) +{ + va_list argp; + va_start(argp, fmt); + luaL_where(L, 1); + lua_pushvfstring(L, fmt, argp); + va_end(argp); + lua_concat(L, 2); } @@ -995,9 +998,9 @@ SWIG_Lua_pushferrstring(lua_State *L, const char *fmt, ...) { /* Structure for variable linking table */ typedef struct { - const char *name; - lua_CFunction get; - lua_CFunction set; + const char *name; + lua_CFunction get; + lua_CFunction set; } swig_lua_var_info; #if (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUA) || (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUAC) @@ -1019,43 +1022,43 @@ typedef struct { #endif typedef struct { - const char *name; - lua_CFunction getmethod; - lua_CFunction setmethod; + const char *name; + lua_CFunction getmethod; + lua_CFunction setmethod; } swig_lua_attribute; struct swig_lua_class; /* Can be used to create namespaces. Currently used to wrap class static methods/variables/constants */ typedef struct swig_lua_namespace { - const char *name; - swig_lua_method *ns_methods; - swig_lua_attribute *ns_attributes; - swig_lua_const_info *ns_constants; - struct swig_lua_class **ns_classes; - struct swig_lua_namespace **ns_namespaces; + const char *name; + swig_lua_method *ns_methods; + swig_lua_attribute *ns_attributes; + swig_lua_const_info *ns_constants; + struct swig_lua_class **ns_classes; + struct swig_lua_namespace **ns_namespaces; } swig_lua_namespace; typedef struct swig_lua_class { - const char *name; /* Name that this class has in Lua */ - const char *fqname; /* Fully qualified name - Scope + class name */ - swig_type_info **type; - lua_CFunction constructor; - void (*destructor)(void *); - swig_lua_method *methods; - swig_lua_attribute *attributes; - swig_lua_namespace *cls_static; - swig_lua_method *metatable; /* 0 for -eluac */ - struct swig_lua_class **bases; - const char **base_names; + const char *name; /* Name that this class has in Lua */ + const char *fqname; /* Fully qualified name - Scope + class name */ + swig_type_info **type; + lua_CFunction constructor; + void (*destructor)(void *); + swig_lua_method *methods; + swig_lua_attribute *attributes; + swig_lua_namespace *cls_static; + swig_lua_method *metatable; /* 0 for -eluac */ + struct swig_lua_class **bases; + const char **base_names; } swig_lua_class; /* this is the struct for wrapping all pointers in SwigLua */ typedef struct { - swig_type_info *type; - int own; /* 1 if owned & must be destroyed */ - void *ptr; + swig_type_info *type; + int own; /* 1 if owned & must be destroyed */ + void *ptr; } swig_lua_userdata; /* this is the struct for wrapping arbitrary packed binary data @@ -1064,9 +1067,9 @@ the data ordering is similar to swig_lua_userdata, but it is currently not possi to tell the two structures apart within SWIG, other than by looking at the type */ typedef struct { - swig_type_info *type; - int own; /* 1 if owned & must be destroyed */ - char data[1]; /* arbitrary amount of data */ + swig_type_info *type; + int own; /* 1 if owned & must be destroyed */ + char data[1]; /* arbitrary amount of data */ } swig_lua_rawdata; /* Common SWIG API */ @@ -1126,21 +1129,21 @@ it gets the address, casts it, then dereferences it */ /* storing/access of swig_module_info */ SWIGRUNTIME swig_module_info * SWIG_Lua_GetModule(lua_State *L) { - swig_module_info *ret = 0; - lua_pushstring(L, "swig_runtime_data_type_pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME); - lua_rawget(L, LUA_REGISTRYINDEX); - if (lua_islightuserdata(L, -1)) - ret = (swig_module_info *)lua_touserdata(L, -1); - lua_pop(L, 1); /* tidy */ - return ret; + swig_module_info *ret = 0; + lua_pushstring(L,"swig_runtime_data_type_pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME); + lua_rawget(L,LUA_REGISTRYINDEX); + if (lua_islightuserdata(L,-1)) + ret=(swig_module_info*)lua_touserdata(L,-1); + lua_pop(L,1); /* tidy */ + return ret; } SWIGRUNTIME void SWIG_Lua_SetModule(lua_State *L, swig_module_info *module) { - /* add this all into the Lua registry: */ - lua_pushstring(L, "swig_runtime_data_type_pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME); - lua_pushlightuserdata(L, (void *)module); - lua_rawset(L, LUA_REGISTRYINDEX); + /* add this all into the Lua registry: */ + lua_pushstring(L,"swig_runtime_data_type_pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME); + lua_pushlightuserdata(L,(void*)module); + lua_rawset(L,LUA_REGISTRYINDEX); } /* ----------------------------------------------------------------------------- @@ -1150,147 +1153,153 @@ SWIG_Lua_SetModule(lua_State *L, swig_module_info *module) { /* this function is called when trying to set an immutable. default action is to print an error. This can removed with a compile flag SWIGLUA_IGNORE_SET_IMMUTABLE */ -SWIGINTERN int SWIG_Lua_set_immutable(lua_State *L) { - /* there should be 1 param passed in: the new value */ +SWIGINTERN int SWIG_Lua_set_immutable(lua_State *L) +{ +/* there should be 1 param passed in: the new value */ #ifndef SWIGLUA_IGNORE_SET_IMMUTABLE - lua_pop(L, 1); /* remove it */ - luaL_error(L, "This variable is immutable"); + lua_pop(L,1); /* remove it */ + luaL_error(L,"This variable is immutable"); #endif return 0; /* should not return anything */ } #ifdef SWIG_LUA_ELUA_EMULATE -SWIGRUNTIME void SWIG_Lua_NewPointerObj(lua_State *L, void *ptr, swig_type_info *type, int own); -SWIGRUNTIME void SWIG_Lua_NewPackedObj(lua_State *L, void *ptr, size_t size, swig_type_info *type); +SWIGRUNTIME void SWIG_Lua_NewPointerObj(lua_State *L,void *ptr,swig_type_info *type, int own); +SWIGRUNTIME void SWIG_Lua_NewPackedObj(lua_State *L,void *ptr,size_t size,swig_type_info *type); static int swig_lua_elua_emulate_unique_key; /* This function emulates eLua rotables behaviour. It loads a rotable definition into the usual lua table. */ -SWIGINTERN void SWIG_Lua_elua_emulate_register(lua_State *L, const swig_elua_entry *table) { - int i, table_parsed, parsed_tables_array, target_table; - assert(lua_istable(L, -1)); - target_table = lua_gettop(L); - /* Get the registry where we put all parsed tables to avoid loops */ - lua_rawgetp(L, LUA_REGISTRYINDEX, &swig_lua_elua_emulate_unique_key); - if (lua_isnil(L, -1)) { - lua_pop(L, 1); - lua_newtable(L); - lua_pushvalue(L, -1); - lua_rawsetp(L, LUA_REGISTRYINDEX, (void *)(&swig_lua_elua_emulate_unique_key)); - } - parsed_tables_array = lua_gettop(L); - lua_pushvalue(L, target_table); - lua_rawsetp(L, parsed_tables_array, table); - table_parsed = 0; - const int SWIGUNUSED pairs_start = lua_gettop(L); - for (i = 0; table[i].key.type != LUA_TNIL || table[i].value.type != LUA_TNIL; i++) { - const swig_elua_entry *entry = table + i; - int is_metatable = 0; - switch (entry->key.type) { - case LUA_TSTRING: - lua_pushstring(L, entry->key.key.strkey); - if (strcmp(entry->key.key.strkey, SWIG_LUA_ELUA_EMUL_METATABLE_KEY) == 0) - is_metatable = 1; - break; - case LUA_TNUMBER: - lua_pushnumber(L, entry->key.key.numkey); - break; - case LUA_TNIL: - lua_pushnil(L); - break; - default: - assert(0); +SWIGINTERN void SWIG_Lua_elua_emulate_register(lua_State *L, const swig_elua_entry *table) +{ + int i, table_parsed, parsed_tables_array, target_table; + assert(lua_istable(L,-1)); + target_table = lua_gettop(L); + /* Get the registry where we put all parsed tables to avoid loops */ + lua_rawgetp(L, LUA_REGISTRYINDEX, &swig_lua_elua_emulate_unique_key); + if(lua_isnil(L,-1)) { + lua_pop(L,1); + lua_newtable(L); + lua_pushvalue(L,-1); + lua_rawsetp(L,LUA_REGISTRYINDEX,(void*)(&swig_lua_elua_emulate_unique_key)); + } + parsed_tables_array = lua_gettop(L); + lua_pushvalue(L,target_table); + lua_rawsetp(L, parsed_tables_array, table); + table_parsed = 0; + const int SWIGUNUSED pairs_start = lua_gettop(L); + for(i = 0;table[i].key.type != LUA_TNIL || table[i].value.type != LUA_TNIL;i++) + { + const swig_elua_entry *entry = table + i; + int is_metatable = 0; + switch(entry->key.type) { + case LUA_TSTRING: + lua_pushstring(L,entry->key.key.strkey); + if(strcmp(entry->key.key.strkey, SWIG_LUA_ELUA_EMUL_METATABLE_KEY) == 0) + is_metatable = 1; + break; + case LUA_TNUMBER: + lua_pushnumber(L,entry->key.key.numkey); + break; + case LUA_TNIL: + lua_pushnil(L); + break; + default: + assert(0); + } + switch(entry->value.type) { + case LUA_TSTRING: + lua_pushstring(L,entry->value.value.string); + break; + case LUA_TNUMBER: + lua_pushnumber(L,entry->value.value.number); + break; + case LUA_TFUNCTION: + lua_pushcfunction(L,entry->value.value.function); + break; + case LUA_TTABLE: + lua_rawgetp(L,parsed_tables_array, entry->value.value.table); + table_parsed = !lua_isnil(L,-1); + if(!table_parsed) { + lua_pop(L,1); /*remove nil */ + lua_newtable(L); + SWIG_Lua_elua_emulate_register(L,entry->value.value.table); } - switch (entry->value.type) { - case LUA_TSTRING: - lua_pushstring(L, entry->value.value.string); - break; - case LUA_TNUMBER: - lua_pushnumber(L, entry->value.value.number); - break; - case LUA_TFUNCTION: - lua_pushcfunction(L, entry->value.value.function); - break; - case LUA_TTABLE: - lua_rawgetp(L, parsed_tables_array, entry->value.value.table); - table_parsed = !lua_isnil(L, -1); - if (!table_parsed) { - lua_pop(L, 1); /*remove nil */ - lua_newtable(L); - SWIG_Lua_elua_emulate_register(L, entry->value.value.table); - } - if (is_metatable) { - assert(lua_istable(L, -1)); - lua_pushvalue(L, -1); - lua_setmetatable(L, target_table); - } - - break; - case LUA_TUSERDATA: - if (entry->value.value.userdata.member) - SWIG_NewMemberObj(L, entry->value.value.userdata.pvalue, - entry->value.value.userdata.lvalue, - *(entry->value.value.userdata.ptype)); - else - SWIG_NewPointerObj(L, entry->value.value.userdata.pvalue, - *(entry->value.value.userdata.ptype), 0); - break; - case LUA_TNIL: - lua_pushnil(L); - break; - default: - assert(0); + if(is_metatable) { + assert(lua_istable(L,-1)); + lua_pushvalue(L,-1); + lua_setmetatable(L,target_table); } - assert(lua_gettop(L) == pairs_start + 2); - lua_rawset(L, target_table); + + break; + case LUA_TUSERDATA: + if(entry->value.value.userdata.member) + SWIG_NewMemberObj(L,entry->value.value.userdata.pvalue, + entry->value.value.userdata.lvalue, + *(entry->value.value.userdata.ptype)); + else + SWIG_NewPointerObj(L,entry->value.value.userdata.pvalue, + *(entry->value.value.userdata.ptype),0); + break; + case LUA_TNIL: + lua_pushnil(L); + break; + default: + assert(0); } - lua_pop(L, 1); /* Removing parsed tables storage */ - assert(lua_gettop(L) == target_table); + assert(lua_gettop(L) == pairs_start + 2); + lua_rawset(L,target_table); + } + lua_pop(L,1); /* Removing parsed tables storage */ + assert(lua_gettop(L) == target_table); } -SWIGINTERN void SWIG_Lua_elua_emulate_register_clear(lua_State *L) { - lua_pushnil(L); - lua_rawsetp(L, LUA_REGISTRYINDEX, &swig_lua_elua_emulate_unique_key); +SWIGINTERN void SWIG_Lua_elua_emulate_register_clear(lua_State *L) +{ + lua_pushnil(L); + lua_rawsetp(L, LUA_REGISTRYINDEX, &swig_lua_elua_emulate_unique_key); } SWIGINTERN void SWIG_Lua_get_class_registry(lua_State *L); -SWIGINTERN int SWIG_Lua_emulate_elua_getmetatable(lua_State *L) { - SWIG_check_num_args("getmetatable(SWIG eLua emulation)", 1, 1); - SWIG_Lua_get_class_registry(L); - lua_getfield(L, -1, "lua_getmetatable"); - lua_remove(L, -2); /* remove the registry*/ - assert(!lua_isnil(L, -1)); - lua_pushvalue(L, 1); - assert(lua_gettop(L) == 3); /* object | function | object again */ - lua_call(L, 1, 1); - if (!lua_isnil(L, -1)) /*There is an ordinary metatable */ - return 1; - /*if it is a table, then emulate elua behaviour - check for __metatable attribute of a table*/ - assert(lua_gettop(L) == 2); - if (lua_istable(L, -2)) { - lua_pop(L, 1); /*remove the nil*/ - lua_getfield(L, -1, SWIG_LUA_ELUA_EMUL_METATABLE_KEY); - } - assert(lua_gettop(L) == 2); +SWIGINTERN int SWIG_Lua_emulate_elua_getmetatable(lua_State *L) +{ + SWIG_check_num_args("getmetatable(SWIG eLua emulation)", 1, 1); + SWIG_Lua_get_class_registry(L); + lua_getfield(L,-1,"lua_getmetatable"); + lua_remove(L,-2); /* remove the registry*/ + assert(!lua_isnil(L,-1)); + lua_pushvalue(L,1); + assert(lua_gettop(L) == 3); /* object | function | object again */ + lua_call(L,1,1); + if(!lua_isnil(L,-1)) /*There is an ordinary metatable */ return 1; + /*if it is a table, then emulate elua behaviour - check for __metatable attribute of a table*/ + assert(lua_gettop(L) == 2); + if(lua_istable(L,-2)) { + lua_pop(L,1); /*remove the nil*/ + lua_getfield(L,-1, SWIG_LUA_ELUA_EMUL_METATABLE_KEY); + } + assert(lua_gettop(L) == 2); + return 1; fail: - lua_error(L); - return 0; + lua_error(L); + return 0; } -SWIGINTERN void SWIG_Lua_emulate_elua_swap_getmetatable(lua_State *L) { - SWIG_Lua_get_class_registry(L); - lua_pushglobaltable(L); - lua_pushstring(L, "lua_getmetatable"); - lua_getfield(L, -2, "getmetatable"); - assert(!lua_isnil(L, -1)); - lua_rawset(L, -4); - lua_pushstring(L, "getmetatable"); - lua_pushcfunction(L, SWIG_Lua_emulate_elua_getmetatable); - lua_rawset(L, -3); - lua_pop(L, 2); +SWIGINTERN void SWIG_Lua_emulate_elua_swap_getmetatable(lua_State *L) +{ + SWIG_Lua_get_class_registry(L); + lua_pushglobaltable(L); + lua_pushstring(L,"lua_getmetatable"); + lua_getfield(L,-2,"getmetatable"); + assert(!lua_isnil(L,-1)); + lua_rawset(L,-4); + lua_pushstring(L, "getmetatable"); + lua_pushcfunction(L, SWIG_Lua_emulate_elua_getmetatable); + lua_rawset(L,-3); + lua_pop(L,2); } /* END OF REMOVE */ @@ -1300,115 +1309,120 @@ SWIGINTERN void SWIG_Lua_emulate_elua_swap_getmetatable(lua_State *L) { * global variable support code: namespaces and modules (which are the same thing) * ----------------------------------------------------------------------------- */ -SWIGINTERN int SWIG_Lua_namespace_get(lua_State *L) { - /* there should be 2 params passed in - (1) table (not the meta table) - (2) string name of the attribute - */ - assert(lua_istable(L, -2)); /* just in case */ - lua_getmetatable(L, -2); - assert(lua_istable(L, -1)); - SWIG_Lua_get_table(L, ".get"); /* find the .get table */ - assert(lua_istable(L, -1)); - /* look for the key in the .get table */ - lua_pushvalue(L, 2); /* key */ - lua_rawget(L, -2); - lua_remove(L, -2); /* stack tidy, remove .get table */ - if (lua_iscfunction(L, -1)) { - /* found it so call the fn & return its value */ - lua_call(L, 0, 1); /* 1 value in (userdata),1 out (result) */ - lua_remove(L, -2); /* stack tidy, remove metatable */ - return 1; - } - lua_pop(L, 1); /* remove whatever was there */ - /* ok, so try the .fn table */ - SWIG_Lua_get_table(L, ".fn"); /* find the .get table */ - assert(lua_istable(L, -1)); /* just in case */ - lua_pushvalue(L, 2); /* key */ - lua_rawget(L, -2); /* look for the fn */ - lua_remove(L, -2); /* stack tidy, remove .fn table */ - if (lua_isfunction(L, -1)) { /* note: whether it's a C function or lua function */ - /* found it so return the fn & let lua call it */ - lua_remove(L, -2); /* stack tidy, remove metatable */ - return 1; - } - lua_pop(L, 1); /* remove whatever was there */ - return 0; +SWIGINTERN int SWIG_Lua_namespace_get(lua_State *L) +{ +/* there should be 2 params passed in + (1) table (not the meta table) + (2) string name of the attribute +*/ + assert(lua_istable(L,-2)); /* just in case */ + lua_getmetatable(L,-2); + assert(lua_istable(L,-1)); + SWIG_Lua_get_table(L,".get"); /* find the .get table */ + assert(lua_istable(L,-1)); + /* look for the key in the .get table */ + lua_pushvalue(L,2); /* key */ + lua_rawget(L,-2); + lua_remove(L,-2); /* stack tidy, remove .get table */ + if (lua_iscfunction(L,-1)) + { /* found it so call the fn & return its value */ + lua_call(L,0,1); /* 1 value in (userdata),1 out (result) */ + lua_remove(L,-2); /* stack tidy, remove metatable */ + return 1; + } + lua_pop(L,1); /* remove whatever was there */ + /* ok, so try the .fn table */ + SWIG_Lua_get_table(L,".fn"); /* find the .get table */ + assert(lua_istable(L,-1)); /* just in case */ + lua_pushvalue(L,2); /* key */ + lua_rawget(L,-2); /* look for the fn */ + lua_remove(L,-2); /* stack tidy, remove .fn table */ + if (lua_isfunction(L,-1)) /* note: whether it's a C function or lua function */ + { /* found it so return the fn & let lua call it */ + lua_remove(L,-2); /* stack tidy, remove metatable */ + return 1; + } + lua_pop(L,1); /* remove whatever was there */ + return 0; } -SWIGINTERN int SWIG_Lua_namespace_set(lua_State *L) { - /* there should be 3 params passed in - (1) table (not the meta table) - (2) string name of the attribute - (3) any for the new value - */ +SWIGINTERN int SWIG_Lua_namespace_set(lua_State *L) +{ +/* there should be 3 params passed in + (1) table (not the meta table) + (2) string name of the attribute + (3) any for the new value +*/ - assert(lua_istable(L, 1)); - lua_getmetatable(L, 1); /* get the meta table */ - assert(lua_istable(L, -1)); - - SWIG_Lua_get_table(L, ".set"); /* find the .set table */ - if (lua_istable(L, -1)) { - /* look for the key in the .set table */ - lua_pushvalue(L, 2); /* key */ - lua_rawget(L, -2); - if (lua_iscfunction(L, -1)) { - /* found it so call the fn & return its value */ - lua_pushvalue(L, 3); /* value */ - lua_call(L, 1, 0); - return 0; - } - lua_pop(L, 1); /* remove the value */ - } - lua_pop(L, 1); /* remove the value .set table */ - lua_pop(L, 1); /* remote metatable */ - lua_rawset(L, -3); - return 0; + assert(lua_istable(L,1)); + lua_getmetatable(L,1); /* get the meta table */ + assert(lua_istable(L,-1)); + + SWIG_Lua_get_table(L,".set"); /* find the .set table */ + if (lua_istable(L,-1)) + { + /* look for the key in the .set table */ + lua_pushvalue(L,2); /* key */ + lua_rawget(L,-2); + if (lua_iscfunction(L,-1)) + { /* found it so call the fn & return its value */ + lua_pushvalue(L,3); /* value */ + lua_call(L,1,0); + return 0; + } + lua_pop(L,1); /* remove the value */ + } + lua_pop(L,1); /* remove the value .set table */ + lua_pop(L,1); /* remote metatable */ + lua_rawset(L,-3); + return 0; } #if (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_LUA) /* In elua this is useless */ SWIGINTERN void SWIG_Lua_InstallConstants(lua_State *L, swig_lua_const_info constants[]); /* forward declaration */ -SWIGINTERN void SWIG_Lua_add_variable(lua_State *L, const char *name, lua_CFunction getFn, lua_CFunction setFn); /* forward declaration */ -SWIGINTERN void SWIG_Lua_class_register(lua_State *L, swig_lua_class *clss); +SWIGINTERN void SWIG_Lua_add_variable(lua_State *L,const char *name,lua_CFunction getFn,lua_CFunction setFn); /* forward declaration */ +SWIGINTERN void SWIG_Lua_class_register(lua_State *L,swig_lua_class *clss); /* helper function - register namespace methods and attributes into namespace */ -SWIGINTERN int SWIG_Lua_add_namespace_details(lua_State *L, swig_lua_namespace *ns) { - int i; - /* There must be namespace table (not metatable) at the top of the stack */ - assert(lua_istable(L, -1)); - SWIG_Lua_InstallConstants(L, ns->ns_constants); - - /* add methods to the namespace/module table */ - for (i = 0; ns->ns_methods[i].name; i++) { - SWIG_Lua_add_function(L, ns->ns_methods[i].name, ns->ns_methods[i].func); - } - lua_getmetatable(L, -1); +SWIGINTERN int SWIG_Lua_add_namespace_details(lua_State *L, swig_lua_namespace *ns) +{ + int i; + /* There must be namespace table (not metatable) at the top of the stack */ + assert(lua_istable(L,-1)); + SWIG_Lua_InstallConstants(L, ns->ns_constants); - /* add fns */ - for (i = 0; ns->ns_attributes[i].name; i++) { - SWIG_Lua_add_variable(L, ns->ns_attributes[i].name, ns->ns_attributes[i].getmethod, ns->ns_attributes[i].setmethod); - } + /* add methods to the namespace/module table */ + for(i=0;ns->ns_methods[i].name;i++){ + SWIG_Lua_add_function(L,ns->ns_methods[i].name,ns->ns_methods[i].func); + } + lua_getmetatable(L,-1); - /* clear stack - remove metatble */ - lua_pop(L, 1); - return 0; + /* add fns */ + for(i=0;ns->ns_attributes[i].name;i++){ + SWIG_Lua_add_variable(L,ns->ns_attributes[i].name,ns->ns_attributes[i].getmethod,ns->ns_attributes[i].setmethod); + } + + /* clear stack - remove metatble */ + lua_pop(L,1); + return 0; } /* Register all classes in the namespace */ -SWIGINTERN void SWIG_Lua_add_namespace_classes(lua_State *L, swig_lua_namespace *ns) { - swig_lua_class **classes; +SWIGINTERN void SWIG_Lua_add_namespace_classes(lua_State *L, swig_lua_namespace *ns) +{ + swig_lua_class **classes; - /* There must be a module/namespace table at the top of the stack */ - assert(lua_istable(L, -1)); + /* There must be a module/namespace table at the top of the stack */ + assert(lua_istable(L,-1)); - classes = ns->ns_classes; + classes = ns->ns_classes; - if (classes != 0) { - while (*classes != 0) { - SWIG_Lua_class_register(L, *classes); - classes++; - } + if( classes != 0 ) { + while(*classes != 0) { + SWIG_Lua_class_register(L, *classes); + classes++; } + } } /* Helper function. Creates namespace table and adds it to module table @@ -1416,54 +1430,55 @@ SWIGINTERN void SWIG_Lua_add_namespace_classes(lua_State *L, swig_lua_namespace when function is called). Function always returns newly registered table on top of the stack. */ -SWIGINTERN void SWIG_Lua_namespace_register(lua_State *L, swig_lua_namespace *ns, int reg) { - swig_lua_namespace **sub_namespace; - /* 1 argument - table on the top of the stack */ - const int SWIGUNUSED begin = lua_gettop(L); - assert(lua_istable(L, -1)); /* just in case. This is supposed to be module table or parent namespace table */ - lua_checkstack(L, 5); - lua_newtable(L); /* namespace itself */ - lua_newtable(L); /* metatable for namespace */ - - /* add a table called ".get" */ - lua_pushstring(L, ".get"); - lua_newtable(L); - lua_rawset(L, -3); - /* add a table called ".set" */ - lua_pushstring(L, ".set"); - lua_newtable(L); - lua_rawset(L, -3); - /* add a table called ".fn" */ - lua_pushstring(L, ".fn"); - lua_newtable(L); - lua_rawset(L, -3); - - /* add accessor fns for using the .get,.set&.fn */ - SWIG_Lua_add_function(L, "__index", SWIG_Lua_namespace_get); - SWIG_Lua_add_function(L, "__newindex", SWIG_Lua_namespace_set); - - lua_setmetatable(L, -2); /* set metatable */ - - /* Register all functions, variables etc */ - SWIG_Lua_add_namespace_details(L, ns); - /* Register classes */ - SWIG_Lua_add_namespace_classes(L, ns); - - sub_namespace = ns->ns_namespaces; - if (sub_namespace != 0) { - while (*sub_namespace != 0) { - SWIG_Lua_namespace_register(L, *sub_namespace, 1); - lua_pop(L, 1); /* removing sub-namespace table */ - sub_namespace++; - } - } - - if (reg) { - lua_pushstring(L, ns->name); - lua_pushvalue(L, -2); - lua_rawset(L, -4); /* add namespace to module table */ - } - assert(lua_gettop(L) == begin + 1); +SWIGINTERN void SWIG_Lua_namespace_register(lua_State *L, swig_lua_namespace *ns, int reg) +{ + swig_lua_namespace **sub_namespace; + /* 1 argument - table on the top of the stack */ + const int SWIGUNUSED begin = lua_gettop(L); + assert(lua_istable(L,-1)); /* just in case. This is supposed to be module table or parent namespace table */ + lua_checkstack(L,5); + lua_newtable(L); /* namespace itself */ + lua_newtable(L); /* metatable for namespace */ + + /* add a table called ".get" */ + lua_pushstring(L,".get"); + lua_newtable(L); + lua_rawset(L,-3); + /* add a table called ".set" */ + lua_pushstring(L,".set"); + lua_newtable(L); + lua_rawset(L,-3); + /* add a table called ".fn" */ + lua_pushstring(L,".fn"); + lua_newtable(L); + lua_rawset(L,-3); + + /* add accessor fns for using the .get,.set&.fn */ + SWIG_Lua_add_function(L,"__index",SWIG_Lua_namespace_get); + SWIG_Lua_add_function(L,"__newindex",SWIG_Lua_namespace_set); + + lua_setmetatable(L,-2); /* set metatable */ + + /* Register all functions, variables etc */ + SWIG_Lua_add_namespace_details(L,ns); + /* Register classes */ + SWIG_Lua_add_namespace_classes(L,ns); + + sub_namespace = ns->ns_namespaces; + if( sub_namespace != 0) { + while(*sub_namespace != 0) { + SWIG_Lua_namespace_register(L, *sub_namespace, 1); + lua_pop(L,1); /* removing sub-namespace table */ + sub_namespace++; + } + } + + if (reg) { + lua_pushstring(L,ns->name); + lua_pushvalue(L,-2); + lua_rawset(L,-4); /* add namespace to module table */ + } + assert(lua_gettop(L) == begin+1); } #endif /* SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_LUA */ @@ -1471,12 +1486,13 @@ SWIGINTERN void SWIG_Lua_namespace_register(lua_State *L, swig_lua_namespace *ns * global variable support code: classes * ----------------------------------------------------------------------------- */ -SWIGINTERN void SWIG_Lua_get_class_metatable(lua_State *L, const char *cname); +SWIGINTERN void SWIG_Lua_get_class_metatable(lua_State *L,const char *cname); -typedef int (*swig_lua_base_iterator_func)(lua_State *, swig_type_info *, int, int *ret); +typedef int (*swig_lua_base_iterator_func)(lua_State*,swig_type_info*, int, int *ret); -SWIGINTERN int SWIG_Lua_iterate_bases(lua_State *L, swig_type_info *SWIGUNUSED swig_type, - int first_arg, swig_lua_base_iterator_func func, int *const ret) { +SWIGINTERN int SWIG_Lua_iterate_bases(lua_State *L, swig_type_info * SWIGUNUSED swig_type, + int first_arg, swig_lua_base_iterator_func func, int *const ret) +{ /* first_arg - position of the object in stack. Everything that is above are arguments * and is passed to every evocation of the func */ int last_arg = lua_gettop(L);/* position of last argument */ @@ -1485,87 +1501,88 @@ SWIGINTERN int SWIG_Lua_iterate_bases(lua_State *L, swig_type_info *SWIGUNUSED s int result = SWIG_ERROR; int bases_table; (void)swig_type; - lua_getmetatable(L, first_arg); + lua_getmetatable(L,first_arg); /* initialise base search */ #if (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_LUA) - SWIG_Lua_get_table(L, ".bases"); - assert(lua_istable(L, -1)); - bases_count = lua_rawlen(L, -1); + SWIG_Lua_get_table(L,".bases"); + assert(lua_istable(L,-1)); + bases_count = lua_rawlen(L,-1); bases_table = lua_gettop(L); #else /* In elua .bases table doesn't exist. Use table from swig_lua_class */ (void)bases_table; - assert(swig_type != 0); - swig_module_info *module = SWIG_GetModule(L); - swig_lua_class **bases = ((swig_lua_class *)(swig_type->clientdata))->bases; - const char **base_names = ((swig_lua_class *)(swig_type->clientdata))->base_names; + assert(swig_type!=0); + swig_module_info *module=SWIG_GetModule(L); + swig_lua_class **bases= ((swig_lua_class*)(swig_type->clientdata))->bases; + const char **base_names= ((swig_lua_class*)(swig_type->clientdata))->base_names; bases_count = 0; - for (; base_names[bases_count]; - bases_count++);/* get length of bases */ -#endif - - if (ret) - *ret = 0; - if (bases_count > 0) { - int to_remove; - size_t i; - int j; - int subcall_last_arg; - int subcall_first_arg = lua_gettop(L) + 1;/* Here a copy of first_arg and arguments begin */ - int valid = 1; - swig_type_info *base_swig_type = 0; - for (j = first_arg; j <= last_arg; j++) - lua_pushvalue(L, j); - subcall_last_arg = lua_gettop(L); - - /* Trick: temporarily replacing original metatable with metatable for base class and call getter */ - for (i = 0; i < bases_count; i++) { - /* Iteration through class bases */ + for(;base_names[bases_count]; + bases_count++);/* get length of bases */ +#endif + + if(ret) + *ret = 0; + if(bases_count>0) + { + int to_remove; + size_t i; + int j; + int subcall_last_arg; + int subcall_first_arg = lua_gettop(L) + 1;/* Here a copy of first_arg and arguments begin */ + int valid = 1; + swig_type_info *base_swig_type = 0; + for(j=first_arg;j<=last_arg;j++) + lua_pushvalue(L,j); + subcall_last_arg = lua_gettop(L); + + /* Trick: temporarily replacing original metatable with metatable for base class and call getter */ + for(i=0;ifqname); - base_swig_type = SWIG_TypeQueryModule(module, module, base_names[i]); - assert(base_swig_type != 0); - } + swig_lua_class *base_class = bases[i]; + if(!base_class) { + valid = 0; + } else { + valid = 1; + SWIG_Lua_get_class_metatable(L,base_class->fqname); + base_swig_type = SWIG_TypeQueryModule(module,module,base_names[i]); + assert(base_swig_type != 0); + } #endif - if (!valid) - continue; - assert(lua_isuserdata(L, subcall_first_arg)); - assert(lua_istable(L, -1)); - lua_setmetatable(L, subcall_first_arg); /* Set new metatable */ - assert(lua_gettop(L) == subcall_last_arg); - result = func(L, base_swig_type, subcall_first_arg, ret); /* Forward call */ - if (result != SWIG_ERROR) { - break; - } + if(!valid) + continue; + assert(lua_isuserdata(L, subcall_first_arg)); + assert(lua_istable(L,-1)); + lua_setmetatable(L,subcall_first_arg); /* Set new metatable */ + assert(lua_gettop(L) == subcall_last_arg); + result = func(L, base_swig_type,subcall_first_arg, ret); /* Forward call */ + if(result != SWIG_ERROR) { + break; } - /* Restore original metatable */ - lua_pushvalue(L, original_metatable); - lua_setmetatable(L, first_arg); - /* Clear - remove everything between last_arg and subcall_last_arg including */ - to_remove = subcall_last_arg - last_arg; - for (j = 0; j < to_remove; j++) - lua_remove(L, last_arg + 1); + } + /* Restore original metatable */ + lua_pushvalue(L,original_metatable); + lua_setmetatable(L,first_arg); + /* Clear - remove everything between last_arg and subcall_last_arg including */ + to_remove = subcall_last_arg - last_arg; + for(j=0;jtype; - result = SWIG_Lua_class_do_get(L, type, 1, &ret); - if (result == SWIG_OK) - return ret; +SWIGINTERN int SWIG_Lua_class_get(lua_State *L) +{ +/* there should be 2 params passed in + (1) userdata (not the meta table) + (2) string name of the attribute +*/ + int result; + swig_lua_userdata *usr; + swig_type_info *type; + int ret = 0; + assert(lua_isuserdata(L,1)); + usr=(swig_lua_userdata*)lua_touserdata(L,1); /* get data */ + type = usr->type; + result = SWIG_Lua_class_do_get(L,type,1,&ret); + if(result == SWIG_OK) + return ret; - result = SWIG_Lua_class_do_get_item(L, type, 1, &ret); - if (result == SWIG_OK) - return ret; + result = SWIG_Lua_class_do_get_item(L,type,1,&ret); + if(result == SWIG_OK) + return ret; - return 0; + return 0; } /* helper for the class.set method, performs the lookup of class attributes * It returns error code. Number of function return values is passed inside 'ret' */ -SWIGINTERN int SWIG_Lua_class_do_set(lua_State *L, swig_type_info *type, int first_arg, int *ret) { - /* there should be 3 params passed in - (1) table (not the meta table) - (2) string name of the attribute - (3) any for the new value - */ - - int bases_search_result; - int substack_start = lua_gettop(L) - 3; - lua_checkstack(L, 5); - assert(lua_isuserdata(L, substack_start + 1)); /* just in case */ - lua_getmetatable(L, substack_start + 1); /* get the meta table */ - assert(lua_istable(L, -1)); /* just in case */ - if (ret) - *ret = 0; /* it is setter - number of return values is always 0 */ - - SWIG_Lua_get_table(L, ".set"); /* find the .set table */ - if (lua_istable(L, -1)) { - /* look for the key in the .set table */ - lua_pushvalue(L, substack_start + 2); /* key */ - lua_rawget(L, -2); - lua_remove(L, -2); /* tidy stack, remove .set table */ - if (lua_iscfunction(L, -1)) { - /* found it so call the fn & return its value */ - lua_pushvalue(L, substack_start + 1); /* userdata */ - lua_pushvalue(L, substack_start + 3); /* value */ - lua_call(L, 2, 0); - lua_remove(L, substack_start + 4); /*remove metatable*/ - return SWIG_OK; - } - lua_pop(L, 1); /* remove the value */ - } else { - lua_pop(L, 1); /* remove the answer for .set table request*/ - } - /* NEW: looks for the __setitem() fn - this is a user provided set fn */ - SWIG_Lua_get_table(L, "__setitem"); /* find the fn */ - if (lua_iscfunction(L, -1)) { /* if it's there */ - /* found it so call the fn & return its value */ - lua_pushvalue(L, substack_start + 1); /* the userdata */ - lua_pushvalue(L, substack_start + 2); /* the parameter */ - lua_pushvalue(L, substack_start + 3); /* the value */ - lua_call(L, 3, 0); /* 3 values in ,0 out */ - lua_remove(L, -2); /* stack tidy, remove metatable */ - return SWIG_OK; - } - lua_pop(L, 1); /* remove value */ - - lua_pop(L, 1); /* remove metatable */ - /* Search among bases */ - bases_search_result = SWIG_Lua_iterate_bases(L, type, first_arg, SWIG_Lua_class_do_set, ret); - if (ret) - assert(*ret == 0); - assert(lua_gettop(L) == substack_start + 3); - return bases_search_result; +SWIGINTERN int SWIG_Lua_class_do_set(lua_State *L, swig_type_info *type, int first_arg, int *ret) +{ +/* there should be 3 params passed in + (1) table (not the meta table) + (2) string name of the attribute + (3) any for the new value + */ + + int bases_search_result; + int substack_start = lua_gettop(L) - 3; + lua_checkstack(L,5); + assert(lua_isuserdata(L,substack_start+1)); /* just in case */ + lua_getmetatable(L,substack_start+1); /* get the meta table */ + assert(lua_istable(L,-1)); /* just in case */ + if(ret) + *ret = 0; /* it is setter - number of return values is always 0 */ + + SWIG_Lua_get_table(L,".set"); /* find the .set table */ + if (lua_istable(L,-1)) + { + /* look for the key in the .set table */ + lua_pushvalue(L,substack_start+2); /* key */ + lua_rawget(L,-2); + lua_remove(L,-2); /* tidy stack, remove .set table */ + if (lua_iscfunction(L,-1)) + { /* found it so call the fn & return its value */ + lua_pushvalue(L,substack_start+1); /* userdata */ + lua_pushvalue(L,substack_start+3); /* value */ + lua_call(L,2,0); + lua_remove(L,substack_start+4); /*remove metatable*/ + return SWIG_OK; + } + lua_pop(L,1); /* remove the value */ + } else { + lua_pop(L,1); /* remove the answer for .set table request*/ + } + /* NEW: looks for the __setitem() fn + this is a user provided set fn */ + SWIG_Lua_get_table(L,"__setitem"); /* find the fn */ + if (lua_iscfunction(L,-1)) /* if it's there */ + { /* found it so call the fn & return its value */ + lua_pushvalue(L,substack_start+1); /* the userdata */ + lua_pushvalue(L,substack_start+2); /* the parameter */ + lua_pushvalue(L,substack_start+3); /* the value */ + lua_call(L,3,0); /* 3 values in ,0 out */ + lua_remove(L,-2); /* stack tidy, remove metatable */ + return SWIG_OK; + } + lua_pop(L,1); /* remove value */ + + lua_pop(L,1); /* remove metatable */ + /* Search among bases */ + bases_search_result = SWIG_Lua_iterate_bases(L,type,first_arg,SWIG_Lua_class_do_set,ret); + if(ret) + assert(*ret == 0); + assert(lua_gettop(L) == substack_start + 3); + return bases_search_result; } /* This is the actual method exported to Lua. It calls SWIG_Lua_class_do_set and correctly * handles return values. */ -SWIGINTERN int SWIG_Lua_class_set(lua_State *L) { - /* There should be 3 params passed in - (1) table (not the meta table) - (2) string name of the attribute - (3) any for the new value - */ - int ret = 0; - int result; - swig_lua_userdata *usr; - swig_type_info *type; - assert(lua_isuserdata(L, 1)); - usr = (swig_lua_userdata *)lua_touserdata(L, 1); /* get data */ - type = usr->type; - result = SWIG_Lua_class_do_set(L, type, 1, &ret); - if (result != SWIG_OK) { - SWIG_Lua_pushferrstring(L, "Assignment not possible. No setter/member with this name. For custom assignments implement __setitem method."); - lua_error(L); - } else { - assert(ret == 0); - } - return 0; +SWIGINTERN int SWIG_Lua_class_set(lua_State *L) +{ +/* There should be 3 params passed in + (1) table (not the meta table) + (2) string name of the attribute + (3) any for the new value + */ + int ret = 0; + int result; + swig_lua_userdata *usr; + swig_type_info *type; + assert(lua_isuserdata(L,1)); + usr=(swig_lua_userdata*)lua_touserdata(L,1); /* get data */ + type = usr->type; + result = SWIG_Lua_class_do_set(L,type,1,&ret); + if(result != SWIG_OK) { + SWIG_Lua_pushferrstring(L,"Assignment not possible. No setter/member with this name. For custom assignments implement __setitem method."); + lua_error(L); + } else { + assert(ret==0); + } + return 0; } /* the class.destruct method called by the interpreter */ -SWIGINTERN int SWIG_Lua_class_destruct(lua_State *L) { - /* there should be 1 params passed in - (1) userdata (not the meta table) */ - swig_lua_userdata *usr; - swig_lua_class *clss; - assert(lua_isuserdata(L, -1)); /* just in case */ - usr = (swig_lua_userdata *)lua_touserdata(L, -1); /* get it */ - /* if must be destroyed & has a destructor */ - if (usr->own) { /* if must be destroyed */ - clss = (swig_lua_class *)usr->type->clientdata; /* get the class */ - if (clss && clss->destructor) { /* there is a destroy fn */ - clss->destructor(usr->ptr); /* bye bye */ - } +SWIGINTERN int SWIG_Lua_class_destruct(lua_State *L) +{ +/* there should be 1 params passed in + (1) userdata (not the meta table) */ + swig_lua_userdata *usr; + swig_lua_class *clss; + assert(lua_isuserdata(L,-1)); /* just in case */ + usr=(swig_lua_userdata*)lua_touserdata(L,-1); /* get it */ + /* if must be destroyed & has a destructor */ + if (usr->own) /* if must be destroyed */ + { + clss=(swig_lua_class*)usr->type->clientdata; /* get the class */ + if (clss && clss->destructor) /* there is a destroy fn */ + { + clss->destructor(usr->ptr); /* bye bye */ } - return 0; + } + return 0; } /* the class.__tostring method called by the interpreter and print */ -SWIGINTERN int SWIG_Lua_class_tostring(lua_State *L) { - /* there should be 1 param passed in - (1) userdata (not the metatable) */ - swig_lua_userdata *userData; - assert(lua_isuserdata(L, 1)); /* just in case */ - userData = (swig_lua_userdata *)lua_touserdata(L, 1); /* get the userdata address */ - - lua_pushfstring(L, "", userData->type->str, userData->ptr); - return 1; +SWIGINTERN int SWIG_Lua_class_tostring(lua_State *L) +{ +/* there should be 1 param passed in + (1) userdata (not the metatable) */ + swig_lua_userdata* userData; + assert(lua_isuserdata(L,1)); /* just in case */ + userData = (swig_lua_userdata*)lua_touserdata(L,1); /* get the userdata address */ + + lua_pushfstring(L, "", userData->type->str, userData->ptr); + return 1; } /* to manually disown some userdata */ -SWIGINTERN int SWIG_Lua_class_disown(lua_State *L) { - /* there should be 1 params passed in - (1) userdata (not the meta table) */ - swig_lua_userdata *usr; - assert(lua_isuserdata(L, -1)); /* just in case */ - usr = (swig_lua_userdata *)lua_touserdata(L, -1); /* get it */ +SWIGINTERN int SWIG_Lua_class_disown(lua_State *L) +{ +/* there should be 1 params passed in + (1) userdata (not the meta table) */ + swig_lua_userdata *usr; + assert(lua_isuserdata(L,-1)); /* just in case */ + usr=(swig_lua_userdata*)lua_touserdata(L,-1); /* get it */ - usr->own = 0; /* clear our ownership */ - return 0; + usr->own = 0; /* clear our ownership */ + return 0; } /* lua callable function to compare userdata's value the issue is that two userdata may point to the same thing but to lua, they are different objects */ -SWIGRUNTIME int SWIG_Lua_class_equal(lua_State *L) { - int result; - swig_lua_userdata *usr1, *usr2; - if (!lua_isuserdata(L, 1) || !lua_isuserdata(L, 2)) /* just in case */ - return 0; /* nil reply */ - usr1 = (swig_lua_userdata *)lua_touserdata(L, 1); /* get data */ - usr2 = (swig_lua_userdata *)lua_touserdata(L, 2); /* get data */ - /*result=(usr1->ptr==usr2->ptr && usr1->type==usr2->type); only works if type is the same*/ - result = (usr1->ptr == usr2->ptr); - lua_pushboolean(L, result); - return 1; +SWIGRUNTIME int SWIG_Lua_class_equal(lua_State *L) +{ + int result; + swig_lua_userdata *usr1,*usr2; + if (!lua_isuserdata(L,1) || !lua_isuserdata(L,2)) /* just in case */ + return 0; /* nil reply */ + usr1=(swig_lua_userdata*)lua_touserdata(L,1); /* get data */ + usr2=(swig_lua_userdata*)lua_touserdata(L,2); /* get data */ + /*result=(usr1->ptr==usr2->ptr && usr1->type==usr2->type); only works if type is the same*/ + result=(usr1->ptr==usr2->ptr); + lua_pushboolean(L,result); + return 1; } /* populate table at the top of the stack with metamethods that ought to be inherited */ -SWIGINTERN void SWIG_Lua_populate_inheritable_metamethods(lua_State *L) { - SWIG_Lua_add_boolean(L, "__add", 1); - SWIG_Lua_add_boolean(L, "__sub", 1); - SWIG_Lua_add_boolean(L, "__mul", 1); - SWIG_Lua_add_boolean(L, "__div", 1); - SWIG_Lua_add_boolean(L, "__mod", 1); - SWIG_Lua_add_boolean(L, "__pow", 1); - SWIG_Lua_add_boolean(L, "__unm", 1); - SWIG_Lua_add_boolean(L, "__len", 1); - SWIG_Lua_add_boolean(L, "__concat", 1); - SWIG_Lua_add_boolean(L, "__eq", 1); - SWIG_Lua_add_boolean(L, "__lt", 1); - SWIG_Lua_add_boolean(L, "__le", 1); - SWIG_Lua_add_boolean(L, "__call", 1); - SWIG_Lua_add_boolean(L, "__tostring", 1); - SWIG_Lua_add_boolean(L, "__gc", 0); +SWIGINTERN void SWIG_Lua_populate_inheritable_metamethods(lua_State *L) +{ + SWIG_Lua_add_boolean(L, "__add", 1); + SWIG_Lua_add_boolean(L, "__sub", 1); + SWIG_Lua_add_boolean(L, "__mul", 1); + SWIG_Lua_add_boolean(L, "__div", 1); + SWIG_Lua_add_boolean(L, "__mod", 1); + SWIG_Lua_add_boolean(L, "__pow", 1); + SWIG_Lua_add_boolean(L, "__unm", 1); + SWIG_Lua_add_boolean(L, "__len", 1 ); + SWIG_Lua_add_boolean(L, "__concat", 1 ); + SWIG_Lua_add_boolean(L, "__eq", 1); + SWIG_Lua_add_boolean(L, "__lt", 1); + SWIG_Lua_add_boolean(L, "__le", 1); + SWIG_Lua_add_boolean(L, "__call", 1); + SWIG_Lua_add_boolean(L, "__tostring", 1); + SWIG_Lua_add_boolean(L, "__gc", 0); } /* creates the swig registry */ -SWIGINTERN void SWIG_Lua_create_class_registry(lua_State *L) { - /* create main SWIG registry table */ - lua_pushstring(L, "SWIG"); - lua_newtable(L); - /* populate it with some predefined data */ - - /* .library table. Placeholder */ - lua_pushstring(L, ".library"); +SWIGINTERN void SWIG_Lua_create_class_registry(lua_State *L) +{ + /* create main SWIG registry table */ + lua_pushstring(L,"SWIG"); + lua_newtable(L); + /* populate it with some predefined data */ + + /* .library table. Placeholder */ + lua_pushstring(L,".library"); + lua_newtable(L); + { + /* list of metamethods that class inherits from its bases */ + lua_pushstring(L,"inheritable_metamethods"); lua_newtable(L); - { - /* list of metamethods that class inherits from its bases */ - lua_pushstring(L, "inheritable_metamethods"); - lua_newtable(L); - /* populate with list of metamethods */ - SWIG_Lua_populate_inheritable_metamethods(L); - lua_rawset(L, -3); - } - lua_rawset(L, -3); + /* populate with list of metamethods */ + SWIG_Lua_populate_inheritable_metamethods(L); + lua_rawset(L,-3); + } + lua_rawset(L,-3); - lua_rawset(L, LUA_REGISTRYINDEX); + lua_rawset(L,LUA_REGISTRYINDEX); } /* gets the swig registry (or creates it) */ -SWIGINTERN void SWIG_Lua_get_class_registry(lua_State *L) { - /* add this all into the swig registry: */ - lua_pushstring(L, "SWIG"); - lua_rawget(L, LUA_REGISTRYINDEX); /* get the registry */ - if (!lua_istable(L, -1)) { /* not there */ - /* must be first time, so add it */ - lua_pop(L, 1); /* remove the result */ - SWIG_Lua_create_class_registry(L); - /* then get it */ - lua_pushstring(L, "SWIG"); - lua_rawget(L, LUA_REGISTRYINDEX); - } -} - -SWIGINTERN void SWIG_Lua_get_inheritable_metamethods(lua_State *L) { - SWIG_Lua_get_class_registry(L); - lua_pushstring(L, ".library"); - lua_rawget(L, -2); - assert(!lua_isnil(L, -1)); - lua_pushstring(L, "inheritable_metamethods"); - lua_rawget(L, -2); +SWIGINTERN void SWIG_Lua_get_class_registry(lua_State *L) +{ + /* add this all into the swig registry: */ + lua_pushstring(L,"SWIG"); + lua_rawget(L,LUA_REGISTRYINDEX); /* get the registry */ + if (!lua_istable(L,-1)) /* not there */ + { /* must be first time, so add it */ + lua_pop(L,1); /* remove the result */ + SWIG_Lua_create_class_registry(L); + /* then get it */ + lua_pushstring(L,"SWIG"); + lua_rawget(L,LUA_REGISTRYINDEX); + } +} + +SWIGINTERN void SWIG_Lua_get_inheritable_metamethods(lua_State *L) +{ + SWIG_Lua_get_class_registry(L); + lua_pushstring(L, ".library"); + lua_rawget(L,-2); + assert( !lua_isnil(L,-1) ); + lua_pushstring(L, "inheritable_metamethods"); + lua_rawget(L,-2); - /* Remove class registry and library table */ - lua_remove(L, -2); - lua_remove(L, -2); + /* Remove class registry and library table */ + lua_remove(L,-2); + lua_remove(L,-2); } /* Helper function to get the classes metatable from the register */ -SWIGINTERN void SWIG_Lua_get_class_metatable(lua_State *L, const char *cname) { - SWIG_Lua_get_class_registry(L); /* get the registry */ - lua_pushstring(L, cname); /* get the name */ - lua_rawget(L, -2); /* get it */ - lua_remove(L, -2); /* tidy up (remove registry) */ +SWIGINTERN void SWIG_Lua_get_class_metatable(lua_State *L,const char *cname) +{ + SWIG_Lua_get_class_registry(L); /* get the registry */ + lua_pushstring(L,cname); /* get the name */ + lua_rawget(L,-2); /* get it */ + lua_remove(L,-2); /* tidy up (remove registry) */ } /* Set up the base classes pointers. @@ -1915,151 +1949,165 @@ It cannot be done at compile time, as this will not work with hireachies spread over more than one swig file. Therefore it must be done at runtime, querying the SWIG type system. */ -SWIGINTERN void SWIG_Lua_init_base_class(lua_State *L, swig_lua_class *clss) { - int i = 0; - swig_module_info *module = SWIG_GetModule(L); - for (i = 0; clss->base_names[i]; i++) { - if (clss->bases[i] == 0) { /* not found yet */ - /* lookup and cache the base class */ - swig_type_info *info = SWIG_TypeQueryModule(module, module, clss->base_names[i]); - if (info) clss->bases[i] = (swig_lua_class *) info->clientdata; - } +SWIGINTERN void SWIG_Lua_init_base_class(lua_State *L,swig_lua_class *clss) +{ + int i=0; + swig_module_info *module=SWIG_GetModule(L); + for(i=0;clss->base_names[i];i++) + { + if (clss->bases[i]==0) /* not found yet */ + { + /* lookup and cache the base class */ + swig_type_info *info = SWIG_TypeQueryModule(module,module,clss->base_names[i]); + if (info) clss->bases[i] = (swig_lua_class *) info->clientdata; } + } } #if defined(SWIG_LUA_SQUASH_BASES) && (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_LUA) /* Merges two tables */ -SWIGINTERN void SWIG_Lua_merge_tables_by_index(lua_State *L, int target, int source) { - /* iterating */ - lua_pushnil(L); - while (lua_next(L, source) != 0) { - /* -1 - value, -2 - index */ - /* have to copy to assign */ - lua_pushvalue(L, -2); /* copy of index */ - lua_pushvalue(L, -2); /* copy of value */ - lua_rawset(L, target); - lua_pop(L, 1); - /* only key is left */ - } +SWIGINTERN void SWIG_Lua_merge_tables_by_index(lua_State *L, int target, int source) +{ + /* iterating */ + lua_pushnil(L); + while (lua_next(L,source) != 0) { + /* -1 - value, -2 - index */ + /* have to copy to assign */ + lua_pushvalue(L,-2); /* copy of index */ + lua_pushvalue(L,-2); /* copy of value */ + lua_rawset(L, target); + lua_pop(L,1); + /* only key is left */ + } } /* Merges two tables with given name. original - index of target metatable, base - index of source metatable */ -SWIGINTERN void SWIG_Lua_merge_tables(lua_State *L, const char *name, int original, int base) { - /* push original[name], then base[name] */ - lua_pushstring(L, name); - lua_rawget(L, original); - int original_table = lua_gettop(L); - lua_pushstring(L, name); - lua_rawget(L, base); - int base_table = lua_gettop(L); - SWIG_Lua_merge_tables_by_index(L, original_table, base_table); - /* clearing stack */ - lua_pop(L, 2); +SWIGINTERN void SWIG_Lua_merge_tables(lua_State *L, const char* name, int original, int base) +{ + /* push original[name], then base[name] */ + lua_pushstring(L,name); + lua_rawget(L,original); + int original_table = lua_gettop(L); + lua_pushstring(L,name); + lua_rawget(L,base); + int base_table = lua_gettop(L); + SWIG_Lua_merge_tables_by_index(L, original_table, base_table); + /* clearing stack */ + lua_pop(L,2); } /* Function takes all symbols from base and adds it to derived class. It's just a helper. */ -SWIGINTERN void SWIG_Lua_class_squash_base(lua_State *L, swig_lua_class *base_cls) { - /* There is one parameter - original, i.e. 'derived' class metatable */ - assert(lua_istable(L, -1)); - int original = lua_gettop(L); - SWIG_Lua_get_class_metatable(L, base_cls->fqname); - int base = lua_gettop(L); - SWIG_Lua_merge_tables(L, ".fn", original, base); - SWIG_Lua_merge_tables(L, ".set", original, base); - SWIG_Lua_merge_tables(L, ".get", original, base); - lua_pop(L, 1); +SWIGINTERN void SWIG_Lua_class_squash_base(lua_State *L, swig_lua_class *base_cls) +{ + /* There is one parameter - original, i.e. 'derived' class metatable */ + assert(lua_istable(L,-1)); + int original = lua_gettop(L); + SWIG_Lua_get_class_metatable(L,base_cls->fqname); + int base = lua_gettop(L); + SWIG_Lua_merge_tables(L, ".fn", original, base ); + SWIG_Lua_merge_tables(L, ".set", original, base ); + SWIG_Lua_merge_tables(L, ".get", original, base ); + lua_pop(L,1); } /* Function squashes all symbols from 'clss' bases into itself */ -SWIGINTERN void SWIG_Lua_class_squash_bases(lua_State *L, swig_lua_class *clss) { - int i; - SWIG_Lua_get_class_metatable(L, clss->fqname); - for (i = 0; clss->base_names[i]; i++) { - if (clss->bases[i] == 0) /* Somehow it's not found. Skip it */ - continue; - /* Thing is: all bases are already registered. Thus they have already executed - * this function. So we just need to squash them into us, because their bases - * are already squashed into them. No need for recursion here! - */ - SWIG_Lua_class_squash_base(L, clss->bases[i]); - } - lua_pop(L, 1); /*tidy stack*/ +SWIGINTERN void SWIG_Lua_class_squash_bases(lua_State *L, swig_lua_class *clss) +{ + int i; + SWIG_Lua_get_class_metatable(L,clss->fqname); + for(i=0;clss->base_names[i];i++) + { + if (clss->bases[i]==0) /* Somehow it's not found. Skip it */ + continue; + /* Thing is: all bases are already registered. Thus they have already executed + * this function. So we just need to squash them into us, because their bases + * are already squashed into them. No need for recursion here! + */ + SWIG_Lua_class_squash_base(L, clss->bases[i]); + } + lua_pop(L,1); /*tidy stack*/ } #endif #if (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_LUA) /* In elua this is useless */ /* helper add a variable to a registered class */ -SWIGINTERN void SWIG_Lua_add_variable(lua_State *L, const char *name, lua_CFunction getFn, lua_CFunction setFn) { - assert(lua_istable(L, -1)); /* just in case */ - SWIG_Lua_get_table(L, ".get"); /* find the .get table */ - assert(lua_istable(L, -1)); /* just in case */ - SWIG_Lua_add_function(L, name, getFn); - lua_pop(L, 1); /* tidy stack (remove table) */ - if (setFn) { - SWIG_Lua_get_table(L, ".set"); /* find the .set table */ - assert(lua_istable(L, -1)); /* just in case */ - SWIG_Lua_add_function(L, name, setFn); - lua_pop(L, 1); /* tidy stack (remove table) */ - } +SWIGINTERN void SWIG_Lua_add_variable(lua_State *L,const char *name,lua_CFunction getFn,lua_CFunction setFn) +{ + assert(lua_istable(L,-1)); /* just in case */ + SWIG_Lua_get_table(L,".get"); /* find the .get table */ + assert(lua_istable(L,-1)); /* just in case */ + SWIG_Lua_add_function(L,name,getFn); + lua_pop(L,1); /* tidy stack (remove table) */ + if (setFn) + { + SWIG_Lua_get_table(L,".set"); /* find the .set table */ + assert(lua_istable(L,-1)); /* just in case */ + SWIG_Lua_add_function(L,name,setFn); + lua_pop(L,1); /* tidy stack (remove table) */ + } } /* helper to recursively add class static details (static attributes, operations and constants) */ -SWIGINTERN void SWIG_Lua_add_class_static_details(lua_State *L, swig_lua_class *clss) { - int i = 0; - /* The class namespace table must be on the top of the stack */ - assert(lua_istable(L, -1)); - /* call all the base classes first: we can then override these later: */ - for (i = 0; clss->bases[i]; i++) { - SWIG_Lua_add_class_static_details(L, clss->bases[i]); - } +SWIGINTERN void SWIG_Lua_add_class_static_details(lua_State *L, swig_lua_class *clss) +{ + int i = 0; + /* The class namespace table must be on the top of the stack */ + assert(lua_istable(L,-1)); + /* call all the base classes first: we can then override these later: */ + for(i=0;clss->bases[i];i++) + { + SWIG_Lua_add_class_static_details(L,clss->bases[i]); + } - SWIG_Lua_add_namespace_details(L, clss->cls_static); + SWIG_Lua_add_namespace_details(L, clss->cls_static); } SWIGINTERN void SWIG_Lua_add_class_user_metamethods(lua_State *L, swig_lua_class *clss); /* forward declaration */ /* helper to recursively add class details (attributes & operations) */ -SWIGINTERN void SWIG_Lua_add_class_instance_details(lua_State *L, swig_lua_class *clss) { - int i; - size_t bases_count = 0; - /* Add bases to .bases table */ - SWIG_Lua_get_table(L, ".bases"); - assert(lua_istable(L, -1)); /* just in case */ - for (i = 0; clss->bases[i]; i++) { - SWIG_Lua_get_class_metatable(L, clss->bases[i]->fqname); - /* Base class must be already registered */ - assert(lua_istable(L, -1)); - lua_rawseti(L, -2, i + 1); /* In lua indexing starts from 1 */ - bases_count++; - } - assert(lua_rawlen(L, -1) == bases_count); - lua_pop(L, 1); /* remove .bases table */ - /* add attributes */ - for (i = 0; clss->attributes[i].name; i++) { - SWIG_Lua_add_variable(L, clss->attributes[i].name, clss->attributes[i].getmethod, clss->attributes[i].setmethod); - } - /* add methods to the metatable */ - SWIG_Lua_get_table(L, ".fn"); /* find the .fn table */ - assert(lua_istable(L, -1)); /* just in case */ - for (i = 0; clss->methods[i].name; i++) { - SWIG_Lua_add_function(L, clss->methods[i].name, clss->methods[i].func); - } - lua_pop(L, 1); /* tidy stack (remove table) */ - /* add operator overloads - This adds methods from metatable array to metatable. Can mess up garbage - collectind if someone defines __gc method - */ - if (clss->metatable) { - for (i = 0; clss->metatable[i].name; i++) { - SWIG_Lua_add_function(L, clss->metatable[i].name, clss->metatable[i].func); - } +SWIGINTERN void SWIG_Lua_add_class_instance_details(lua_State *L, swig_lua_class *clss) +{ + int i; + size_t bases_count = 0; + /* Add bases to .bases table */ + SWIG_Lua_get_table(L,".bases"); + assert(lua_istable(L,-1)); /* just in case */ + for(i=0;clss->bases[i];i++) + { + SWIG_Lua_get_class_metatable(L,clss->bases[i]->fqname); + /* Base class must be already registered */ + assert(lua_istable(L,-1)); + lua_rawseti(L,-2,i+1); /* In lua indexing starts from 1 */ + bases_count++; + } + assert(lua_rawlen(L,-1) == bases_count); + lua_pop(L,1); /* remove .bases table */ + /* add attributes */ + for(i=0;clss->attributes[i].name;i++){ + SWIG_Lua_add_variable(L,clss->attributes[i].name,clss->attributes[i].getmethod,clss->attributes[i].setmethod); + } + /* add methods to the metatable */ + SWIG_Lua_get_table(L,".fn"); /* find the .fn table */ + assert(lua_istable(L,-1)); /* just in case */ + for(i=0;clss->methods[i].name;i++){ + SWIG_Lua_add_function(L,clss->methods[i].name,clss->methods[i].func); + } + lua_pop(L,1); /* tidy stack (remove table) */ + /* add operator overloads + This adds methods from metatable array to metatable. Can mess up garbage + collectind if someone defines __gc method + */ + if(clss->metatable) { + for(i=0;clss->metatable[i].name;i++) { + SWIG_Lua_add_function(L,clss->metatable[i].name,clss->metatable[i].func); } + } #if !defined(SWIG_LUA_SQUASH_BASES) - /* Adding metamethods that are defined in base classes. If bases were squashed - * then it is obviously unnecessary - */ - SWIG_Lua_add_class_user_metamethods(L, clss); + /* Adding metamethods that are defined in base classes. If bases were squashed + * then it is obviously unnecessary + */ + SWIG_Lua_add_class_user_metamethods(L, clss); #endif } @@ -2089,67 +2137,70 @@ SWIGRUNTIME int SWIG_Lua_resolve_metamethod(lua_State *L); /*forward declaration * SWIG_Lua_resolve_metamethod * */ SWIGINTERN int SWIG_Lua_do_resolve_metamethod(lua_State *L, const swig_lua_class *clss, int metamethod_name_idx, - int skip_check) { - /* This function is called recursively */ - int result = 0; - int i = 0; - - if (!skip_check) { - SWIG_Lua_get_class_metatable(L, clss->fqname); - lua_pushvalue(L, metamethod_name_idx); - lua_rawget(L, -2); - /* If this is cfunction and it is equal to SWIG_Lua_resolve_metamethod then - * this isn't the function we are looking for :) - * lua_tocfunction will return NULL if not cfunction - */ - if (!lua_isnil(L, -1) && lua_tocfunction(L, -1) != SWIG_Lua_resolve_metamethod) { - lua_remove(L, -2); /* removing class metatable */ - return 1; - } - lua_pop(L, 2); /* remove class metatable and query result */ - } + int skip_check) +{ + /* This function is called recursively */ + int result = 0; + int i = 0; - /* Forwarding calls to bases */ - for (i = 0; clss->bases[i]; i++) { - result = SWIG_Lua_do_resolve_metamethod(L, clss->bases[i], metamethod_name_idx, 0); - if (result) - break; + if (!skip_check) { + SWIG_Lua_get_class_metatable(L, clss->fqname); + lua_pushvalue(L, metamethod_name_idx); + lua_rawget(L,-2); + /* If this is cfunction and it is equal to SWIG_Lua_resolve_metamethod then + * this isn't the function we are looking for :) + * lua_tocfunction will return NULL if not cfunction + */ + if (!lua_isnil(L,-1) && lua_tocfunction(L,-1) != SWIG_Lua_resolve_metamethod ) { + lua_remove(L,-2); /* removing class metatable */ + return 1; } + lua_pop(L,2); /* remove class metatable and query result */ + } - return result; + /* Forwarding calls to bases */ + for(i=0;clss->bases[i];i++) + { + result = SWIG_Lua_do_resolve_metamethod(L, clss->bases[i], metamethod_name_idx, 0); + if (result) + break; + } + + return result; } /* The proxy function for metamethod. All parameters are passed as cclosure. Searches for actual method * and calls it */ -SWIGRUNTIME int SWIG_Lua_resolve_metamethod(lua_State *L) { - int numargs; - int metamethod_name_idx; - const swig_lua_class *clss; - int result; - - lua_checkstack(L, 5); - numargs = lua_gettop(L); /* number of arguments to pass to actual metamethod */ - - /* Get upvalues from closure */ - lua_pushvalue(L, lua_upvalueindex(1)); /*Get function name*/ - metamethod_name_idx = lua_gettop(L); - - lua_pushvalue(L, lua_upvalueindex(2)); - clss = (const swig_lua_class *)(lua_touserdata(L, -1)); - lua_pop(L, 1); /* remove lightuserdata with clss from stack */ - - /* Actual work */ - result = SWIG_Lua_do_resolve_metamethod(L, clss, metamethod_name_idx, 1); - if (!result) { - SWIG_Lua_pushferrstring(L, "The metamethod proxy is set, but it failed to find actual metamethod. Memory corruption is most likely explanation."); - lua_error(L); - return 0; - } +SWIGRUNTIME int SWIG_Lua_resolve_metamethod(lua_State *L) +{ + int numargs; + int metamethod_name_idx; + const swig_lua_class* clss; + int result; + + lua_checkstack(L,5); + numargs = lua_gettop(L); /* number of arguments to pass to actual metamethod */ - lua_remove(L, -2); /* remove metamethod key */ - lua_insert(L, 1); /* move function to correct position */ - lua_call(L, numargs, LUA_MULTRET); - return lua_gettop(L); /* return all results */ + /* Get upvalues from closure */ + lua_pushvalue(L, lua_upvalueindex(1)); /*Get function name*/ + metamethod_name_idx = lua_gettop(L); + + lua_pushvalue(L, lua_upvalueindex(2)); + clss = (const swig_lua_class*)(lua_touserdata(L,-1)); + lua_pop(L,1); /* remove lightuserdata with clss from stack */ + + /* Actual work */ + result = SWIG_Lua_do_resolve_metamethod(L, clss, metamethod_name_idx, 1); + if (!result) { + SWIG_Lua_pushferrstring(L,"The metamethod proxy is set, but it failed to find actual metamethod. Memory corruption is most likely explanation."); + lua_error(L); + return 0; + } + + lua_remove(L,-2); /* remove metamethod key */ + lua_insert(L,1); /* move function to correct position */ + lua_call(L, numargs, LUA_MULTRET); + return lua_gettop(L); /* return all results */ } @@ -2157,281 +2208,292 @@ SWIGRUNTIME int SWIG_Lua_resolve_metamethod(lua_State *L) { * Returns 1 if successfully added, 0 if not added because no base class has it, -1 * if method is defined in the class metatable itself */ -SWIGINTERN int SWIG_Lua_add_class_user_metamethod(lua_State *L, swig_lua_class *clss, const int metatable_index) { - int key_index; - int success = 0; - int i = 0; - - /* metamethod name - on the top of the stack */ - assert(lua_isstring(L, -1)); - - key_index = lua_gettop(L); - - /* Check whether method is already defined in metatable */ - lua_pushvalue(L, key_index); /* copy of the key */ - lua_gettable(L, metatable_index); - if (!lua_isnil(L, -1)) { - lua_pop(L, 1); - return -1; - } - lua_pop(L, 1); - - /* Iterating over immediate bases */ - for (i = 0; clss->bases[i]; i++) { - const swig_lua_class *base = clss->bases[i]; - SWIG_Lua_get_class_metatable(L, base->fqname); - lua_pushvalue(L, key_index); - lua_rawget(L, -2); - if (!lua_isnil(L, -1)) { - lua_pushvalue(L, key_index); - - /* Add proxy function */ - lua_pushvalue(L, key_index); /* first closure value is function name */ - lua_pushlightuserdata(L, clss); /* second closure value is swig_lua_class structure */ - lua_pushcclosure(L, SWIG_Lua_resolve_metamethod, 2); - - lua_rawset(L, metatable_index); - success = 1; - } - lua_pop(L, 1); /* remove function or nil */ - lua_pop(L, 1); /* remove base class metatable */ +SWIGINTERN int SWIG_Lua_add_class_user_metamethod(lua_State *L, swig_lua_class *clss, const int metatable_index) +{ + int key_index; + int success = 0; + int i = 0; + + /* metamethod name - on the top of the stack */ + assert(lua_isstring(L,-1)); + + key_index = lua_gettop(L); + + /* Check whether method is already defined in metatable */ + lua_pushvalue(L,key_index); /* copy of the key */ + lua_gettable(L,metatable_index); + if( !lua_isnil(L,-1) ) { + lua_pop(L,1); + return -1; + } + lua_pop(L,1); + + /* Iterating over immediate bases */ + for(i=0;clss->bases[i];i++) + { + const swig_lua_class *base = clss->bases[i]; + SWIG_Lua_get_class_metatable(L, base->fqname); + lua_pushvalue(L, key_index); + lua_rawget(L, -2); + if( !lua_isnil(L,-1) ) { + lua_pushvalue(L, key_index); + + /* Add proxy function */ + lua_pushvalue(L, key_index); /* first closure value is function name */ + lua_pushlightuserdata(L, clss); /* second closure value is swig_lua_class structure */ + lua_pushcclosure(L, SWIG_Lua_resolve_metamethod, 2); - if (success) - break; + lua_rawset(L, metatable_index); + success = 1; } + lua_pop(L,1); /* remove function or nil */ + lua_pop(L,1); /* remove base class metatable */ + + if( success ) + break; + } - return success; + return success; } -SWIGINTERN void SWIG_Lua_add_class_user_metamethods(lua_State *L, swig_lua_class *clss) { - int metatable_index; - int metamethods_info_index; - int tostring_undefined; - int eq_undefined = 0; +SWIGINTERN void SWIG_Lua_add_class_user_metamethods(lua_State *L, swig_lua_class *clss) +{ + int metatable_index; + int metamethods_info_index; + int tostring_undefined; + int eq_undefined = 0; + + SWIG_Lua_get_class_metatable(L, clss->fqname); + metatable_index = lua_gettop(L); + SWIG_Lua_get_inheritable_metamethods(L); + assert(lua_istable(L,-1)); + metamethods_info_index = lua_gettop(L); + lua_pushnil(L); /* first key */ + while(lua_next(L, metamethods_info_index) != 0 ) { + /* key at index -2, value at index -1 */ + const int is_inheritable = lua_toboolean(L,-2); + lua_pop(L,1); /* remove value - we don't need it anymore */ + + if(is_inheritable) { /* if metamethod is inheritable */ + SWIG_Lua_add_class_user_metamethod(L,clss,metatable_index); + } + } + + lua_pop(L,1); /* remove inheritable metamethods table */ + + /* Special handling for __tostring method */ + lua_pushstring(L, "__tostring"); + lua_pushvalue(L,-1); + lua_rawget(L,metatable_index); + tostring_undefined = lua_isnil(L,-1); + lua_pop(L,1); + if( tostring_undefined ) { + lua_pushcfunction(L, SWIG_Lua_class_tostring); + lua_rawset(L, metatable_index); + } else { + lua_pop(L,1); /* remove copy of the key */ + } + + /* Special handling for __eq method */ + lua_pushstring(L, "__eq"); + lua_pushvalue(L,-1); + lua_rawget(L,metatable_index); + eq_undefined = lua_isnil(L,-1); + lua_pop(L,1); + if( eq_undefined ) { + lua_pushcfunction(L, SWIG_Lua_class_equal); + lua_rawset(L, metatable_index); + } else { + lua_pop(L,1); /* remove copy of the key */ + } + /* Warning: __index and __newindex are SWIG-defined. For user-defined operator[] + * a __getitem/__setitem method should be defined + */ + lua_pop(L,1); /* pop class metatable */ +} - SWIG_Lua_get_class_metatable(L, clss->fqname); - metatable_index = lua_gettop(L); - SWIG_Lua_get_inheritable_metamethods(L); - assert(lua_istable(L, -1)); - metamethods_info_index = lua_gettop(L); - lua_pushnil(L); /* first key */ - while (lua_next(L, metamethods_info_index) != 0) { - /* key at index -2, value at index -1 */ - const int is_inheritable = lua_toboolean(L, -2); - lua_pop(L, 1); /* remove value - we don't need it anymore */ - - if (is_inheritable) { /* if metamethod is inheritable */ - SWIG_Lua_add_class_user_metamethod(L, clss, metatable_index); - } - } +/* Register class static methods,attributes etc as well as constructor proxy */ +SWIGINTERN void SWIG_Lua_class_register_static(lua_State *L, swig_lua_class *clss) +{ + const int SWIGUNUSED begin = lua_gettop(L); + lua_checkstack(L,5); /* just in case */ + assert(lua_istable(L,-1)); /* just in case */ + assert(strcmp(clss->name, clss->cls_static->name) == 0); /* in class those 2 must be equal */ - lua_pop(L, 1); /* remove inheritable metamethods table */ - - /* Special handling for __tostring method */ - lua_pushstring(L, "__tostring"); - lua_pushvalue(L, -1); - lua_rawget(L, metatable_index); - tostring_undefined = lua_isnil(L, -1); - lua_pop(L, 1); - if (tostring_undefined) { - lua_pushcfunction(L, SWIG_Lua_class_tostring); - lua_rawset(L, metatable_index); - } else { - lua_pop(L, 1); /* remove copy of the key */ - } + SWIG_Lua_namespace_register(L,clss->cls_static, 1); - /* Special handling for __eq method */ - lua_pushstring(L, "__eq"); - lua_pushvalue(L, -1); - lua_rawget(L, metatable_index); - eq_undefined = lua_isnil(L, -1); - lua_pop(L, 1); - if (eq_undefined) { - lua_pushcfunction(L, SWIG_Lua_class_equal); - lua_rawset(L, metatable_index); - } else { - lua_pop(L, 1); /* remove copy of the key */ - } - /* Warning: __index and __newindex are SWIG-defined. For user-defined operator[] - * a __getitem/__setitem method should be defined - */ - lua_pop(L, 1); /* pop class metatable */ -} + assert(lua_istable(L,-1)); /* just in case */ -/* Register class static methods,attributes etc as well as constructor proxy */ -SWIGINTERN void SWIG_Lua_class_register_static(lua_State *L, swig_lua_class *clss) { - const int SWIGUNUSED begin = lua_gettop(L); - lua_checkstack(L, 5); /* just in case */ - assert(lua_istable(L, -1)); /* just in case */ - assert(strcmp(clss->name, clss->cls_static->name) == 0); /* in class those 2 must be equal */ - - SWIG_Lua_namespace_register(L, clss->cls_static, 1); - - assert(lua_istable(L, -1)); /* just in case */ - - /* add its constructor to module with the name of the class - so you can do MyClass(...) as well as new_MyClass(...) - BUT only if a constructor is defined - (this overcomes the problem of pure virtual classes without constructors)*/ - if (clss->constructor) { - lua_getmetatable(L, -1); - assert(lua_istable(L, -1)); /* just in case */ - SWIG_Lua_add_function(L, "__call", clss->constructor); - lua_pop(L, 1); - } + /* add its constructor to module with the name of the class + so you can do MyClass(...) as well as new_MyClass(...) + BUT only if a constructor is defined + (this overcomes the problem of pure virtual classes without constructors)*/ + if (clss->constructor) + { + lua_getmetatable(L,-1); + assert(lua_istable(L,-1)); /* just in case */ + SWIG_Lua_add_function(L,"__call", clss->constructor); + lua_pop(L,1); + } - assert(lua_istable(L, -1)); /* just in case */ - SWIG_Lua_add_class_static_details(L, clss); + assert(lua_istable(L,-1)); /* just in case */ + SWIG_Lua_add_class_static_details(L, clss); - /* clear stack */ - lua_pop(L, 1); - assert(lua_gettop(L) == begin); + /* clear stack */ + lua_pop(L,1); + assert( lua_gettop(L) == begin ); } /* Performs the instance (non-static) class registration process. Metatable for class is created * and added to the class registry. */ -SWIGINTERN void SWIG_Lua_class_register_instance(lua_State *L, swig_lua_class *clss) { - const int SWIGUNUSED begin = lua_gettop(L); - int i; - /* if name already there (class is already registered) then do nothing */ - SWIG_Lua_get_class_registry(L); /* get the registry */ - lua_pushstring(L, clss->fqname); /* get the name */ - lua_rawget(L, -2); - if (!lua_isnil(L, -1)) { - lua_pop(L, 2); - assert(lua_gettop(L) == begin); - return; - } - lua_pop(L, 2); /* tidy stack */ - /* Recursively initialize all bases */ - for (i = 0; clss->bases[i]; i++) { - SWIG_Lua_class_register_instance(L, clss->bases[i]); - } - /* Again, get registry and push name */ - SWIG_Lua_get_class_registry(L); /* get the registry */ - lua_pushstring(L, clss->fqname); /* get the name */ - lua_newtable(L); /* create the metatable */ +SWIGINTERN void SWIG_Lua_class_register_instance(lua_State *L,swig_lua_class *clss) +{ + const int SWIGUNUSED begin = lua_gettop(L); + int i; + /* if name already there (class is already registered) then do nothing */ + SWIG_Lua_get_class_registry(L); /* get the registry */ + lua_pushstring(L,clss->fqname); /* get the name */ + lua_rawget(L,-2); + if(!lua_isnil(L,-1)) { + lua_pop(L,2); + assert(lua_gettop(L)==begin); + return; + } + lua_pop(L,2); /* tidy stack */ + /* Recursively initialize all bases */ + for(i=0;clss->bases[i];i++) + { + SWIG_Lua_class_register_instance(L,clss->bases[i]); + } + /* Again, get registry and push name */ + SWIG_Lua_get_class_registry(L); /* get the registry */ + lua_pushstring(L,clss->fqname); /* get the name */ + lua_newtable(L); /* create the metatable */ #if defined(SWIG_LUA_SQUASH_BASES) && (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_LUA) - /* If squashing is requested, then merges all bases metatable into this one. - * It would get us all special methods: __getitem, __add etc. - * This would set .fn, .type, and other .xxx incorrectly, but we will overwrite it right away - */ + /* If squashing is requested, then merges all bases metatable into this one. + * It would get us all special methods: __getitem, __add etc. + * This would set .fn, .type, and other .xxx incorrectly, but we will overwrite it right away + */ + { + int new_metatable_index = lua_absindex(L,-1); + for(i=0;clss->bases[i];i++) { - int new_metatable_index = lua_absindex(L, -1); - for (i = 0; clss->bases[i]; i++) { - int base_metatable; - SWIG_Lua_get_class_metatable(L, clss->bases[i]->fqname); - base_metatable = lua_absindex(L, -1); - SWIG_Lua_merge_tables_by_index(L, new_metatable_index, base_metatable); - lua_pop(L, 1); - } - } - /* And now we will overwrite all incorrectly set data */ -#endif - /* add string of class name called ".type" */ - lua_pushstring(L, ".type"); - lua_pushstring(L, clss->fqname); - lua_rawset(L, -3); - /* add a table called bases */ - lua_pushstring(L, ".bases"); - lua_newtable(L); - lua_rawset(L, -3); - /* add a table called ".get" */ - lua_pushstring(L, ".get"); - lua_newtable(L); - lua_rawset(L, -3); - /* add a table called ".set" */ - lua_pushstring(L, ".set"); - lua_newtable(L); - lua_rawset(L, -3); - /* add a table called ".fn" */ - lua_pushstring(L, ".fn"); - lua_newtable(L); - /* add manual disown method */ - SWIG_Lua_add_function(L, "__disown", SWIG_Lua_class_disown); - lua_rawset(L, -3); - /* add accessor fns for using the .get,.set&.fn */ - SWIG_Lua_add_function(L, "__index", SWIG_Lua_class_get); - SWIG_Lua_add_function(L, "__newindex", SWIG_Lua_class_set); - SWIG_Lua_add_function(L, "__gc", SWIG_Lua_class_destruct); - /* add it */ - lua_rawset(L, -3); /* metatable into registry */ - lua_pop(L, 1); /* tidy stack (remove registry) */ - assert(lua_gettop(L) == begin); + int base_metatable; + SWIG_Lua_get_class_metatable(L,clss->bases[i]->fqname); + base_metatable = lua_absindex(L,-1); + SWIG_Lua_merge_tables_by_index(L,new_metatable_index, base_metatable); + lua_pop(L,1); + } + } + /* And now we will overwrite all incorrectly set data */ +#endif + /* add string of class name called ".type" */ + lua_pushstring(L,".type"); + lua_pushstring(L,clss->fqname); + lua_rawset(L,-3); + /* add a table called bases */ + lua_pushstring(L,".bases"); + lua_newtable(L); + lua_rawset(L,-3); + /* add a table called ".get" */ + lua_pushstring(L,".get"); + lua_newtable(L); + lua_rawset(L,-3); + /* add a table called ".set" */ + lua_pushstring(L,".set"); + lua_newtable(L); + lua_rawset(L,-3); + /* add a table called ".fn" */ + lua_pushstring(L,".fn"); + lua_newtable(L); + /* add manual disown method */ + SWIG_Lua_add_function(L,"__disown",SWIG_Lua_class_disown); + lua_rawset(L,-3); + /* add accessor fns for using the .get,.set&.fn */ + SWIG_Lua_add_function(L,"__index",SWIG_Lua_class_get); + SWIG_Lua_add_function(L,"__newindex",SWIG_Lua_class_set); + SWIG_Lua_add_function(L,"__gc",SWIG_Lua_class_destruct); + /* add it */ + lua_rawset(L,-3); /* metatable into registry */ + lua_pop(L,1); /* tidy stack (remove registry) */ + assert(lua_gettop(L) == begin); #if defined(SWIG_LUA_SQUASH_BASES) && (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_LUA) - /* Now merge all symbols from .fn, .set, .get etc from bases to our tables */ - SWIG_Lua_class_squash_bases(L, clss); + /* Now merge all symbols from .fn, .set, .get etc from bases to our tables */ + SWIG_Lua_class_squash_bases(L,clss); #endif - SWIG_Lua_get_class_metatable(L, clss->fqname); - SWIG_Lua_add_class_instance_details(L, clss); /* recursive adding of details (atts & ops) */ - lua_pop(L, 1); /* tidy stack (remove class metatable) */ - assert(lua_gettop(L) == begin); -} - -SWIGINTERN void SWIG_Lua_class_register(lua_State *L, swig_lua_class *clss) { - int SWIGUNUSED begin; - assert(lua_istable(L, -1)); /* This is a table (module or namespace) where classes will be added */ - SWIG_Lua_class_register_instance(L, clss); - SWIG_Lua_class_register_static(L, clss); - - /* Add links from static part to instance part and vice versa */ - /* [SWIG registry] [Module] - * "MyClass" ----> [MyClass metatable] <===== "MyClass" -+> [static part] - * ".get" ----> ... | | getmetatable()----| - * ".set" ----> ... | | | - * ".static" --------------)----------------/ [static part metatable] - * | ".get" --> ... - * | ".set" --> .... - * |=============================== ".instance" - */ - begin = lua_gettop(L); - lua_pushstring(L, clss->cls_static->name); - lua_rawget(L, -2); /* get class static table */ - assert(lua_istable(L, -1)); - lua_getmetatable(L, -1); - assert(lua_istable(L, -1)); /* get class static metatable */ - lua_pushstring(L, ".instance"); /* prepare key */ - - SWIG_Lua_get_class_metatable(L, clss->fqname); /* get class metatable */ - assert(lua_istable(L, -1)); - lua_pushstring(L, ".static"); /* prepare key */ - lua_pushvalue(L, -4); /* push static class TABLE */ - assert(lua_istable(L, -1)); - lua_rawset(L, -3); /* assign static class table(!NOT metatable) as ".static" member of class metatable */ - lua_rawset(L, -3); /* assign class metatable as ".instance" member of class static METATABLE */ - lua_pop(L, 2); - assert(lua_gettop(L) == begin); + SWIG_Lua_get_class_metatable(L,clss->fqname); + SWIG_Lua_add_class_instance_details(L,clss); /* recursive adding of details (atts & ops) */ + lua_pop(L,1); /* tidy stack (remove class metatable) */ + assert( lua_gettop(L) == begin ); +} + +SWIGINTERN void SWIG_Lua_class_register(lua_State *L,swig_lua_class *clss) +{ + int SWIGUNUSED begin; + assert(lua_istable(L,-1)); /* This is a table (module or namespace) where classes will be added */ + SWIG_Lua_class_register_instance(L,clss); + SWIG_Lua_class_register_static(L,clss); + + /* Add links from static part to instance part and vice versa */ + /* [SWIG registry] [Module] + * "MyClass" ----> [MyClass metatable] <===== "MyClass" -+> [static part] + * ".get" ----> ... | | getmetatable()----| + * ".set" ----> ... | | | + * ".static" --------------)----------------/ [static part metatable] + * | ".get" --> ... + * | ".set" --> .... + * |=============================== ".instance" + */ + begin = lua_gettop(L); + lua_pushstring(L,clss->cls_static->name); + lua_rawget(L,-2); /* get class static table */ + assert(lua_istable(L,-1)); + lua_getmetatable(L,-1); + assert(lua_istable(L,-1)); /* get class static metatable */ + lua_pushstring(L,".instance"); /* prepare key */ + + SWIG_Lua_get_class_metatable(L,clss->fqname); /* get class metatable */ + assert(lua_istable(L,-1)); + lua_pushstring(L,".static"); /* prepare key */ + lua_pushvalue(L, -4); /* push static class TABLE */ + assert(lua_istable(L,-1)); + lua_rawset(L,-3); /* assign static class table(!NOT metatable) as ".static" member of class metatable */ + lua_rawset(L,-3); /* assign class metatable as ".instance" member of class static METATABLE */ + lua_pop(L,2); + assert(lua_gettop(L) == begin); } #endif /* SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_LUA */ #if (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUA) || (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUAC) -SWIGINTERN void SWIG_Lua_elua_class_register_instance(lua_State *L, swig_lua_class *clss) { - const int SWIGUNUSED begin = lua_gettop(L); - int i; - /* if name already there (class is already registered) then do nothing */ - SWIG_Lua_get_class_registry(L); /* get the registry */ - lua_pushstring(L, clss->fqname); /* get the name */ - lua_rawget(L, -2); - if (!lua_isnil(L, -1)) { - lua_pop(L, 2); - assert(lua_gettop(L) == begin); - return; - } - lua_pop(L, 2); /* tidy stack */ - /* Recursively initialize all bases */ - for (i = 0; clss->bases[i]; i++) { - SWIG_Lua_elua_class_register_instance(L, clss->bases[i]); - } - /* Again, get registry and push name */ - SWIG_Lua_get_class_registry(L); /* get the registry */ - lua_pushstring(L, clss->fqname); /* get the name */ - assert(clss->metatable); - lua_pushrotable(L, (void *)(clss->metatable)); /* create the metatable */ - lua_rawset(L, -3); - lua_pop(L, 1); - assert(lua_gettop(L) == begin); +SWIGINTERN void SWIG_Lua_elua_class_register_instance(lua_State *L, swig_lua_class *clss) +{ + const int SWIGUNUSED begin = lua_gettop(L); + int i; + /* if name already there (class is already registered) then do nothing */ + SWIG_Lua_get_class_registry(L); /* get the registry */ + lua_pushstring(L,clss->fqname); /* get the name */ + lua_rawget(L,-2); + if(!lua_isnil(L,-1)) { + lua_pop(L,2); + assert(lua_gettop(L)==begin); + return; + } + lua_pop(L,2); /* tidy stack */ + /* Recursively initialize all bases */ + for(i=0;clss->bases[i];i++) + { + SWIG_Lua_elua_class_register_instance(L,clss->bases[i]); + } + /* Again, get registry and push name */ + SWIG_Lua_get_class_registry(L); /* get the registry */ + lua_pushstring(L,clss->fqname); /* get the name */ + assert(clss->metatable); + lua_pushrotable(L, (void*)(clss->metatable)); /* create the metatable */ + lua_rawset(L,-3); + lua_pop(L,1); + assert(lua_gettop(L) == begin); } #endif /* elua && eluac */ @@ -2440,124 +2502,147 @@ SWIGINTERN void SWIG_Lua_elua_class_register_instance(lua_State *L, swig_lua_cla * ----------------------------------------------------------------------------- */ /* helper to add metatable to new lua object */ -SWIGINTERN void SWIG_Lua_AddMetatable(lua_State *L, swig_type_info *type) { - if (type->clientdata) { /* there is clientdata: so add the metatable */ - SWIG_Lua_get_class_metatable(L, ((swig_lua_class *)(type->clientdata))->fqname); - if (lua_istable(L, -1)) { - lua_setmetatable(L, -2); - } else { - lua_pop(L, 1); - } +SWIGINTERN void SWIG_Lua_AddMetatable(lua_State *L,swig_type_info *type) +{ + if (type->clientdata) /* there is clientdata: so add the metatable */ + { + SWIG_Lua_get_class_metatable(L,((swig_lua_class*)(type->clientdata))->fqname); + if (lua_istable(L,-1)) + { + lua_setmetatable(L,-2); + } + else + { + lua_pop(L,1); } + } } /* pushes a new object into the lua stack */ -SWIGRUNTIME void SWIG_Lua_NewPointerObj(lua_State *L, void *ptr, swig_type_info *type, int own) { - swig_lua_userdata *usr; - if (!ptr) { - lua_pushnil(L); - return; - } - usr = (swig_lua_userdata *)lua_newuserdata(L, sizeof(swig_lua_userdata)); /* get data */ - usr->ptr = ptr; /* set the ptr */ - usr->type = type; - usr->own = own; +SWIGRUNTIME void SWIG_Lua_NewPointerObj(lua_State *L,void *ptr,swig_type_info *type, int own) +{ + swig_lua_userdata *usr; + if (!ptr){ + lua_pushnil(L); + return; + } + usr=(swig_lua_userdata*)lua_newuserdata(L,sizeof(swig_lua_userdata)); /* get data */ + usr->ptr=ptr; /* set the ptr */ + usr->type=type; + usr->own=own; #if (SWIG_LUA_TARGET != SWIG_LUA_FLAVOR_ELUAC) - SWIG_Lua_AddMetatable(L, type); /* add metatable */ + SWIG_Lua_AddMetatable(L,type); /* add metatable */ #endif } /* takes a object from the lua stack & converts it into an object of the correct type (if possible) */ -SWIGRUNTIME int SWIG_Lua_ConvertPtr(lua_State *L, int index, void **ptr, swig_type_info *type, int flags) { - int ret = SWIG_ERROR; - swig_lua_userdata *usr; - swig_cast_info *cast; - /* special case: lua nil => NULL pointer */ - if (lua_isnil(L, index)) { - *ptr = 0; - return (flags & SWIG_POINTER_NO_NULL) ? SWIG_NullReferenceError : SWIG_OK; +SWIGRUNTIME int SWIG_Lua_ConvertPtr(lua_State *L,int index,void **ptr,swig_type_info *type,int flags) +{ + int ret = SWIG_ERROR; + swig_lua_userdata *usr; + swig_cast_info *cast; + /* special case: lua nil => NULL pointer */ + if (lua_isnil(L,index)) + { + *ptr=0; + return (flags & SWIG_POINTER_NO_NULL) ? SWIG_NullReferenceError : SWIG_OK; + } + if (lua_islightuserdata(L,index)) + { + *ptr=lua_touserdata(L,index); + return (flags & SWIG_POINTER_NO_NULL) ? SWIG_NullReferenceError : SWIG_OK; + } + usr=(swig_lua_userdata*)lua_touserdata(L,index); /* get data */ + if (usr) + { + if (((flags & SWIG_POINTER_RELEASE) == SWIG_POINTER_RELEASE) && !usr->own) + { + return SWIG_ERROR_RELEASE_NOT_OWNED; } - if (lua_islightuserdata(L, index)) { - *ptr = lua_touserdata(L, index); - return (flags & SWIG_POINTER_NO_NULL) ? SWIG_NullReferenceError : SWIG_OK; + if (flags & SWIG_POINTER_DISOWN) /* must disown the object */ + { + usr->own = 0; } - usr = (swig_lua_userdata *)lua_touserdata(L, index); /* get data */ - if (usr) { - if (((flags & SWIG_POINTER_RELEASE) == SWIG_POINTER_RELEASE) && !usr->own) { - return SWIG_ERROR_RELEASE_NOT_OWNED; - } - if (flags & SWIG_POINTER_DISOWN) { /* must disown the object */ - usr->own = 0; - } - if (!type) { /* special cast void*, no casting fn */ - *ptr = usr->ptr; - ret = SWIG_OK; - } else { - cast = SWIG_TypeCheck(usr->type->name, type); /* performs normal type checking */ - if (cast) { - int newmemory = 0; - *ptr = SWIG_TypeCast(cast, usr->ptr, &newmemory); - assert(!newmemory); /* newmemory handling not yet implemented */ - ret = SWIG_OK; - } - } - if ((ret == SWIG_OK) && (flags & SWIG_POINTER_CLEAR)) { - usr->ptr = 0; - } + if (!type) /* special cast void*, no casting fn */ + { + *ptr=usr->ptr; + ret = SWIG_OK; } - return ret; + else + { + cast=SWIG_TypeCheck(usr->type->name,type); /* performs normal type checking */ + if (cast) + { + int newmemory = 0; + *ptr=SWIG_TypeCast(cast,usr->ptr,&newmemory); + assert(!newmemory); /* newmemory handling not yet implemented */ + ret = SWIG_OK; + } + } + if ((ret == SWIG_OK) && (flags & SWIG_POINTER_CLEAR)) + { + usr->ptr = 0; + } + } + return ret; } -SWIGRUNTIME void *SWIG_Lua_MustGetPtr(lua_State *L, int index, swig_type_info *type, int flags, - int argnum, const char *func_name) { - void *result = 0; - if (!SWIG_IsOK(SWIG_ConvertPtr(L, index, &result, type, flags))) { - luaL_error(L, "Error in %s, expected a %s at argument number %d\n", - func_name, (type && type->str) ? type->str : "void*", argnum); - } - return result; +SWIGRUNTIME void* SWIG_Lua_MustGetPtr(lua_State *L,int index,swig_type_info *type,int flags, + int argnum,const char *func_name){ + void *result = 0; + if (!SWIG_IsOK(SWIG_ConvertPtr(L,index,&result,type,flags))){ + luaL_error (L,"Error in %s, expected a %s at argument number %d\n", + func_name,(type && type->str)?type->str:"void*",argnum); + } + return result; } /* pushes a packed userdata. user for member fn pointers only */ -SWIGRUNTIME void SWIG_Lua_NewPackedObj(lua_State *L, void *ptr, size_t size, swig_type_info *type) { - swig_lua_rawdata *raw; - assert(ptr); /* not acceptable to pass in a NULL value */ - raw = (swig_lua_rawdata *)lua_newuserdata(L, sizeof(swig_lua_rawdata) - 1 + size); /* alloc data */ - raw->type = type; - raw->own = 0; - memcpy(raw->data, ptr, size); /* copy the data */ - SWIG_Lua_AddMetatable(L, type); /* add metatable */ +SWIGRUNTIME void SWIG_Lua_NewPackedObj(lua_State *L,void *ptr,size_t size,swig_type_info *type) +{ + swig_lua_rawdata *raw; + assert(ptr); /* not acceptable to pass in a NULL value */ + raw=(swig_lua_rawdata*)lua_newuserdata(L,sizeof(swig_lua_rawdata)-1+size); /* alloc data */ + raw->type=type; + raw->own=0; + memcpy(raw->data,ptr,size); /* copy the data */ + SWIG_Lua_AddMetatable(L,type); /* add metatable */ } /* converts a packed userdata. user for member fn pointers only */ -SWIGRUNTIME int SWIG_Lua_ConvertPacked(lua_State *L, int index, void *ptr, size_t size, swig_type_info *type) { - swig_lua_rawdata *raw; - raw = (swig_lua_rawdata *)lua_touserdata(L, index); /* get data */ - if (!raw) return SWIG_ERROR; /* error */ - if (type == 0 || type == raw->type) { /* void* or identical type */ - memcpy(ptr, raw->data, size); /* copy it */ - return SWIG_OK; /* ok */ - } - return SWIG_ERROR; /* error */ +SWIGRUNTIME int SWIG_Lua_ConvertPacked(lua_State *L,int index,void *ptr,size_t size,swig_type_info *type) +{ + swig_lua_rawdata *raw; + raw=(swig_lua_rawdata*)lua_touserdata(L,index); /* get data */ + if (!raw) return SWIG_ERROR; /* error */ + if (type==0 || type==raw->type) /* void* or identical type */ + { + memcpy(ptr,raw->data,size); /* copy it */ + return SWIG_OK; /* ok */ + } + return SWIG_ERROR; /* error */ } /* a function to get the typestring of a piece of data */ -SWIGRUNTIME const char *SWIG_Lua_typename(lua_State *L, int tp) { - swig_lua_userdata *usr; - if (lua_isuserdata(L, tp)) { - usr = (swig_lua_userdata *)lua_touserdata(L, tp); /* get data */ - if (usr && usr->type && usr->type->str) - return usr->type->str; - return "userdata (unknown type)"; - } - return lua_typename(L, lua_type(L, tp)); +SWIGRUNTIME const char *SWIG_Lua_typename(lua_State *L, int tp) +{ + swig_lua_userdata *usr; + if (lua_isuserdata(L,tp)) + { + usr=(swig_lua_userdata*)lua_touserdata(L,tp); /* get data */ + if (usr && usr->type && usr->type->str) + return usr->type->str; + return "userdata (unknown type)"; + } + return lua_typename(L,lua_type(L,tp)); } /* lua callable function to get the userdata's type */ -SWIGRUNTIME int SWIG_Lua_type(lua_State *L) { - lua_pushstring(L, SWIG_Lua_typename(L, 1)); - return 1; +SWIGRUNTIME int SWIG_Lua_type(lua_State *L) +{ + lua_pushstring(L,SWIG_Lua_typename(L,1)); + return 1; } /* ----------------------------------------------------------------------------- @@ -2568,46 +2653,46 @@ SWIGRUNTIME int SWIG_Lua_type(lua_State *L) { /* Install Constants */ SWIGINTERN void SWIG_Lua_InstallConstants(lua_State *L, swig_lua_const_info constants[]) { - int i; - for (i = 0; constants[i].type; i++) { - switch (constants[i].type) { - case SWIG_LUA_INT: - lua_pushstring(L, constants[i].name); - lua_pushinteger(L, (lua_Integer)constants[i].lvalue); - lua_rawset(L, -3); - break; - case SWIG_LUA_FLOAT: - lua_pushstring(L, constants[i].name); - lua_pushnumber(L, (lua_Number)constants[i].dvalue); - lua_rawset(L, -3); - break; - case SWIG_LUA_CHAR: - lua_pushstring(L, constants[i].name); - { - char c = (char)constants[i].lvalue; - lua_pushlstring(L, &c, 1); - } - lua_rawset(L, -3); - break; - case SWIG_LUA_STRING: - lua_pushstring(L, constants[i].name); - lua_pushstring(L, (char *) constants[i].pvalue); - lua_rawset(L, -3); - break; - case SWIG_LUA_POINTER: - lua_pushstring(L, constants[i].name); - SWIG_NewPointerObj(L, constants[i].pvalue, *(constants[i]).ptype, 0); - lua_rawset(L, -3); - break; - case SWIG_LUA_BINARY: - lua_pushstring(L, constants[i].name); - SWIG_NewMemberObj(L, constants[i].pvalue, constants[i].lvalue, *(constants[i]).ptype); - lua_rawset(L, -3); - break; - default: - break; - } - } + int i; + for (i = 0; constants[i].type; i++) { + switch(constants[i].type) { + case SWIG_LUA_INT: + lua_pushstring(L,constants[i].name); + lua_pushinteger(L,(lua_Integer)constants[i].lvalue); + lua_rawset(L,-3); + break; + case SWIG_LUA_FLOAT: + lua_pushstring(L,constants[i].name); + lua_pushnumber(L,(lua_Number)constants[i].dvalue); + lua_rawset(L,-3); + break; + case SWIG_LUA_CHAR: + lua_pushstring(L,constants[i].name); + { + char c = (char)constants[i].lvalue; + lua_pushlstring(L,&c,1); + } + lua_rawset(L,-3); + break; + case SWIG_LUA_STRING: + lua_pushstring(L,constants[i].name); + lua_pushstring(L,(char *) constants[i].pvalue); + lua_rawset(L,-3); + break; + case SWIG_LUA_POINTER: + lua_pushstring(L,constants[i].name); + SWIG_NewPointerObj(L,constants[i].pvalue, *(constants[i]).ptype,0); + lua_rawset(L,-3); + break; + case SWIG_LUA_BINARY: + lua_pushstring(L,constants[i].name); + SWIG_NewMemberObj(L,constants[i].pvalue,constants[i].lvalue,*(constants[i]).ptype); + lua_rawset(L,-3); + break; + default: + break; + } + } } #endif @@ -2625,19 +2710,19 @@ In lua 5.1.X it's luaL_dostring() */ SWIGINTERN int SWIG_Lua_dostring(lua_State *L, const char *str) { - int ok, top; - if (str == 0 || str[0] == 0) return 0; /* nothing to do */ - top = lua_gettop(L); /* save stack */ + int ok,top; + if (str==0 || str[0]==0) return 0; /* nothing to do */ + top=lua_gettop(L); /* save stack */ #if (defined(LUA_VERSION_NUM) && (LUA_VERSION_NUM>=501)) - ok = luaL_dostring(L, str); /* looks like this is lua 5.1.X or later, good */ + ok=luaL_dostring(L,str); /* looks like this is lua 5.1.X or later, good */ #else - ok = lua_dostring(L, str); /* might be lua 5.0.x, using lua_dostring */ + ok=lua_dostring(L,str); /* might be lua 5.0.x, using lua_dostring */ #endif - if (ok != 0) { - SWIG_DOSTRING_FAIL(lua_tostring(L, -1)); - } - lua_settop(L, top); /* restore the stack */ - return ok; + if (ok!=0) { + SWIG_DOSTRING_FAIL(lua_tostring(L,-1)); + } + lua_settop(L,top); /* restore the stack */ + return ok; } #ifdef __cplusplus @@ -2667,218 +2752,212 @@ static swig_module_info swig_module = {swig_types, 1, 0, 0, 0, 0}; #include "pm3.h" #include "comms.h" -SWIGINTERN pm3 *new_pm3__SWIG_0(void) { +SWIGINTERN pm3 *new_pm3__SWIG_0(void){ // printf("SWIG pm3 constructor, get current pm3\n"); - pm3_device_t *p = pm3_get_current_dev(); - p->script_embedded = 1; - return p; -} + pm3_device_t * p = pm3_get_current_dev(); + p->script_embedded = 1; + return p; + } SWIGINTERN int SWIG_lua_isnilstring(lua_State *L, int idx) { - int ret = lua_isstring(L, idx); - if (!ret) - ret = lua_isnil(L, idx); - return ret; + int ret = lua_isstring(L, idx); + if (!ret) + ret = lua_isnil(L, idx); + return ret; } -SWIGINTERN pm3 *new_pm3__SWIG_1(char *port) { +SWIGINTERN pm3 *new_pm3__SWIG_1(char *port){ // printf("SWIG pm3 constructor with port, open pm3\n"); - pm3_device_t *p = pm3_open(port); - p->script_embedded = 0; - return p; -} -SWIGINTERN void delete_pm3(pm3 *self) { - if (self->script_embedded) { + pm3_device_t * p = pm3_open(port); + p->script_embedded = 0; + return p; + } +SWIGINTERN void delete_pm3(pm3 *self){ + if (self->script_embedded) { // printf("SWIG pm3 destructor, nothing to do\n"); - } else { + } else { // printf("SWIG pm3 destructor, close pm3\n"); - pm3_close(self); - } -} + pm3_close(self); + } + } #ifdef __cplusplus extern "C" { #endif -static int _wrap_new_pm3__SWIG_0(lua_State *L) { - int SWIG_arg = 0; - pm3 *result = 0 ; - - SWIG_check_num_args("pm3::pm3", 0, 0) - result = (pm3 *)new_pm3__SWIG_0(); - SWIG_NewPointerObj(L, result, SWIGTYPE_p_pm3, 1); - SWIG_arg++; - return SWIG_arg; - -fail: - SWIGUNUSED; - lua_error(L); - return 0; -} - - -static int _wrap_new_pm3__SWIG_1(lua_State *L) { - int SWIG_arg = 0; - char *arg1 = (char *) 0 ; - pm3 *result = 0 ; - - SWIG_check_num_args("pm3::pm3", 1, 1) - if (!SWIG_lua_isnilstring(L, 1)) SWIG_fail_arg("pm3::pm3", 1, "char *"); - arg1 = (char *)lua_tostring(L, 1); - result = (pm3 *)new_pm3__SWIG_1(arg1); - SWIG_NewPointerObj(L, result, SWIGTYPE_p_pm3, 1); - SWIG_arg++; - return SWIG_arg; - -fail: - SWIGUNUSED; - lua_error(L); - return 0; -} - - -static int _wrap_new_pm3(lua_State *L) { - int argc; - int argv[2] = { - 1, 2 - }; - - argc = lua_gettop(L); - if (argc == 0) { - return _wrap_new_pm3__SWIG_0(L); - } - if (argc == 1) { - int _v = 0; - { - _v = SWIG_lua_isnilstring(L, argv[0]); - } - if (_v) { - return _wrap_new_pm3__SWIG_1(L); - } - } - - SWIG_Lua_pusherrstring(L, "Wrong arguments for overloaded function 'new_pm3'\n" - " Possible C/C++ prototypes are:\n" - " pm3::pm3()\n" - " pm3::pm3(char *)\n"); - lua_error(L); - return 0; -} - - -static int _wrap_pm3_console(lua_State *L) { - int SWIG_arg = 0; - pm3 *arg1 = (pm3 *) 0 ; - char *arg2 = (char *) 0 ; - bool arg3 = (bool) false ; - int result; - - SWIG_check_num_args("pm3::console", 2, 3) - if (!SWIG_isptrtype(L, 1)) SWIG_fail_arg("pm3::console", 1, "pm3 *"); - if (!SWIG_lua_isnilstring(L, 2)) SWIG_fail_arg("pm3::console", 2, "char *"); - if (lua_gettop(L) >= 3 && !lua_isboolean(L, 3)) SWIG_fail_arg("pm3::console", 3, "bool"); - - if (!SWIG_IsOK(SWIG_ConvertPtr(L, 1, (void **)&arg1, SWIGTYPE_p_pm3, 0))) { - SWIG_fail_ptr("pm3_console", 1, SWIGTYPE_p_pm3); - } - - arg2 = (char *)lua_tostring(L, 2); - if (lua_gettop(L) >= 3) { - arg3 = (lua_toboolean(L, 3) != 0); - } - result = (int)pm3_console(arg1, arg2, arg3); - lua_pushnumber(L, (lua_Number) result); - SWIG_arg++; - return SWIG_arg; - -fail: - SWIGUNUSED; - lua_error(L); - return 0; -} - - -static int _wrap_pm3_name_get(lua_State *L) { - int SWIG_arg = 0; - pm3 *arg1 = (pm3 *) 0 ; - char *result = 0 ; - - SWIG_check_num_args("pm3::name", 1, 1) - if (!SWIG_isptrtype(L, 1)) SWIG_fail_arg("pm3::name", 1, "pm3 *"); - - if (!SWIG_IsOK(SWIG_ConvertPtr(L, 1, (void **)&arg1, SWIGTYPE_p_pm3, 0))) { - SWIG_fail_ptr("pm3_name_get", 1, SWIGTYPE_p_pm3); - } - - result = (char *)pm3_name_get(arg1); - lua_pushstring(L, (const char *)result); - SWIG_arg++; - return SWIG_arg; - -fail: - SWIGUNUSED; - lua_error(L); - return 0; -} - - -static int _wrap_pm3_grabbed_output_get(lua_State *L) { - int SWIG_arg = 0; - pm3 *arg1 = (pm3 *) 0 ; - char *result = 0 ; - - SWIG_check_num_args("pm3::grabbed_output", 1, 1) - if (!SWIG_isptrtype(L, 1)) SWIG_fail_arg("pm3::grabbed_output", 1, "pm3 *"); - - if (!SWIG_IsOK(SWIG_ConvertPtr(L, 1, (void **)&arg1, SWIGTYPE_p_pm3, 0))) { - SWIG_fail_ptr("pm3_grabbed_output_get", 1, SWIGTYPE_p_pm3); - } - - result = (char *)pm3_grabbed_output_get(arg1); - lua_pushstring(L, (const char *)result); - SWIG_arg++; - return SWIG_arg; - -fail: - SWIGUNUSED; - lua_error(L); - return 0; +static int _wrap_new_pm3__SWIG_0(lua_State* L) { + int SWIG_arg = 0; + pm3 *result = 0 ; + + SWIG_check_num_args("pm3::pm3",0,0) + result = (pm3 *)new_pm3__SWIG_0(); + SWIG_NewPointerObj(L,result,SWIGTYPE_p_pm3,1); SWIG_arg++; + return SWIG_arg; + + fail: SWIGUNUSED; + lua_error(L); + return 0; +} + + +static int _wrap_new_pm3__SWIG_1(lua_State* L) { + int SWIG_arg = 0; + char *arg1 = (char *) 0 ; + pm3 *result = 0 ; + + SWIG_check_num_args("pm3::pm3",1,1) + if(!SWIG_lua_isnilstring(L,1)) SWIG_fail_arg("pm3::pm3",1,"char *"); + arg1 = (char *)lua_tostring(L, 1); + result = (pm3 *)new_pm3__SWIG_1(arg1); + SWIG_NewPointerObj(L,result,SWIGTYPE_p_pm3,1); SWIG_arg++; + return SWIG_arg; + + fail: SWIGUNUSED; + lua_error(L); + return 0; +} + + +static int _wrap_new_pm3(lua_State* L) { + int argc; + int argv[2]={ + 1,2 + }; + + argc = lua_gettop(L); + if (argc == 0) { + return _wrap_new_pm3__SWIG_0(L); + } + if (argc == 1) { + int _v = 0; + { + _v = SWIG_lua_isnilstring(L,argv[0]); + } + if (_v) { + return _wrap_new_pm3__SWIG_1(L); + } + } + + SWIG_Lua_pusherrstring(L,"Wrong arguments for overloaded function 'new_pm3'\n" + " Possible C/C++ prototypes are:\n" + " pm3::pm3()\n" + " pm3::pm3(char *)\n"); + lua_error(L);return 0; +} + + +static int _wrap_pm3_console(lua_State* L) { + int SWIG_arg = 0; + pm3 *arg1 = (pm3 *) 0 ; + char *arg2 = (char *) 0 ; + bool arg3 = (bool) true ; + bool arg4 = (bool) true ; + int result; + + SWIG_check_num_args("pm3::console",2,4) + if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("pm3::console",1,"pm3 *"); + if(!SWIG_lua_isnilstring(L,2)) SWIG_fail_arg("pm3::console",2,"char *"); + if(lua_gettop(L)>=3 && !lua_isboolean(L,3)) SWIG_fail_arg("pm3::console",3,"bool"); + if(lua_gettop(L)>=4 && !lua_isboolean(L,4)) SWIG_fail_arg("pm3::console",4,"bool"); + + if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_pm3,0))){ + SWIG_fail_ptr("pm3_console",1,SWIGTYPE_p_pm3); + } + + arg2 = (char *)lua_tostring(L, 2); + if(lua_gettop(L)>=3){ + arg3 = (lua_toboolean(L, 3)!=0); + } + if(lua_gettop(L)>=4){ + arg4 = (lua_toboolean(L, 4)!=0); + } + result = (int)pm3_console(arg1,arg2,arg3,arg4); + lua_pushnumber(L, (lua_Number) result); SWIG_arg++; + return SWIG_arg; + + fail: SWIGUNUSED; + lua_error(L); + return 0; +} + + +static int _wrap_pm3_name_get(lua_State* L) { + int SWIG_arg = 0; + pm3 *arg1 = (pm3 *) 0 ; + char *result = 0 ; + + SWIG_check_num_args("pm3::name",1,1) + if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("pm3::name",1,"pm3 *"); + + if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_pm3,0))){ + SWIG_fail_ptr("pm3_name_get",1,SWIGTYPE_p_pm3); + } + + result = (char *)pm3_name_get(arg1); + lua_pushstring(L,(const char *)result); SWIG_arg++; + return SWIG_arg; + + fail: SWIGUNUSED; + lua_error(L); + return 0; +} + + +static int _wrap_pm3_grabbed_output_get(lua_State* L) { + int SWIG_arg = 0; + pm3 *arg1 = (pm3 *) 0 ; + char *result = 0 ; + + SWIG_check_num_args("pm3::grabbed_output",1,1) + if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("pm3::grabbed_output",1,"pm3 *"); + + if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_pm3,0))){ + SWIG_fail_ptr("pm3_grabbed_output_get",1,SWIGTYPE_p_pm3); + } + + result = (char *)pm3_grabbed_output_get(arg1); + lua_pushstring(L,(const char *)result); SWIG_arg++; + return SWIG_arg; + + fail: SWIGUNUSED; + lua_error(L); + return 0; } static void swig_delete_pm3(void *obj) { - pm3 *arg1 = (pm3 *) obj; - delete_pm3(arg1); +pm3 *arg1 = (pm3 *) obj; +delete_pm3(arg1); } static int _proxy__wrap_new_pm3(lua_State *L) { - assert(lua_istable(L, 1)); - lua_pushcfunction(L, _wrap_new_pm3); - assert(!lua_isnil(L, -1)); - lua_replace(L, 1); /* replace our table with real constructor */ - lua_call(L, lua_gettop(L) - 1, 1); + assert(lua_istable(L,1)); + lua_pushcfunction(L,_wrap_new_pm3); + assert(!lua_isnil(L,-1)); + lua_replace(L,1); /* replace our table with real constructor */ + lua_call(L,lua_gettop(L)-1,1); return 1; } static swig_lua_attribute swig_pm3_attributes[] = { { "name", _wrap_pm3_name_get, SWIG_Lua_set_immutable }, { "grabbed_output", _wrap_pm3_grabbed_output_get, SWIG_Lua_set_immutable }, - {0, 0, 0} + {0,0,0} }; -static swig_lua_method swig_pm3_methods[] = { +static swig_lua_method swig_pm3_methods[]= { { "console", _wrap_pm3_console}, - {0, 0} + {0,0} }; static swig_lua_method swig_pm3_meta[] = { - {0, 0} + {0,0} }; static swig_lua_attribute swig_pm3_Sf_SwigStatic_attributes[] = { - {0, 0, 0} + {0,0,0} }; -static swig_lua_const_info swig_pm3_Sf_SwigStatic_constants[] = { - {0, 0, 0, 0, 0, 0} +static swig_lua_const_info swig_pm3_Sf_SwigStatic_constants[]= { + {0,0,0,0,0,0} }; -static swig_lua_method swig_pm3_Sf_SwigStatic_methods[] = { - {0, 0} +static swig_lua_method swig_pm3_Sf_SwigStatic_methods[]= { + {0,0} }; -static swig_lua_class *swig_pm3_Sf_SwigStatic_classes[] = { +static swig_lua_class* swig_pm3_Sf_SwigStatic_classes[]= { 0 }; @@ -2892,22 +2971,22 @@ static swig_lua_namespace swig_pm3_Sf_SwigStatic = { }; static swig_lua_class *swig_pm3_bases[] = {0}; static const char *swig_pm3_base_names[] = {0}; -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 }; +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 }; static swig_lua_attribute swig_SwigModule_attributes[] = { - {0, 0, 0} + {0,0,0} }; -static swig_lua_const_info swig_SwigModule_constants[] = { - {0, 0, 0, 0, 0, 0} +static swig_lua_const_info swig_SwigModule_constants[]= { + {0,0,0,0,0,0} }; -static swig_lua_method swig_SwigModule_methods[] = { - {0, 0} +static swig_lua_method swig_SwigModule_methods[]= { + {0,0} }; -static swig_lua_class *swig_SwigModule_classes[] = { - &_wrap_class_pm3, +static swig_lua_class* swig_SwigModule_classes[]= { +&_wrap_class_pm3, 0 }; -static swig_lua_namespace *swig_SwigModule_namespaces[] = { +static swig_lua_namespace* swig_SwigModule_namespaces[] = { 0 }; @@ -2925,16 +3004,16 @@ static swig_lua_namespace swig_SwigModule = { /* -------- TYPE CONVERSION AND EQUIVALENCE RULES (BEGIN) -------- */ -static swig_type_info _swigt__p_pm3 = {"_p_pm3", "pm3 *", 0, 0, (void *) &_wrap_class_pm3, 0}; +static swig_type_info _swigt__p_pm3 = {"_p_pm3", "pm3 *", 0, 0, (void*)&_wrap_class_pm3, 0}; static swig_type_info *swig_type_initial[] = { - &_swigt__p_pm3, + &_swigt__p_pm3, }; -static swig_cast_info _swigc__p_pm3[] = { {&_swigt__p_pm3, 0, 0, 0}, {0, 0, 0, 0}}; +static swig_cast_info _swigc__p_pm3[] = { {&_swigt__p_pm3, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info *swig_cast_initial[] = { - _swigc__p_pm3, + _swigc__p_pm3, }; @@ -2998,144 +3077,144 @@ extern "C" { SWIGRUNTIME void SWIG_InitializeModule(SWIG_INIT_CLIENT_DATA_TYPE clientdata) { - size_t i; - swig_module_info *module_head, *iter; - int init; - - /* check to see if the circular list has been setup, if not, set it up */ - if (swig_module.next == 0) { - /* Initialize the swig_module */ - swig_module.type_initial = swig_type_initial; - swig_module.cast_initial = swig_cast_initial; - swig_module.next = &swig_module; - init = 1; - } else { - init = 0; - } + size_t i; + swig_module_info *module_head, *iter; + int init; + + /* check to see if the circular list has been setup, if not, set it up */ + if (swig_module.next==0) { + /* Initialize the swig_module */ + swig_module.type_initial = swig_type_initial; + swig_module.cast_initial = swig_cast_initial; + swig_module.next = &swig_module; + init = 1; + } else { + init = 0; + } + + /* Try and load any already created modules */ + module_head = SWIG_GetModule(clientdata); + if (!module_head) { + /* This is the first module loaded for this interpreter */ + /* so set the swig module into the interpreter */ + SWIG_SetModule(clientdata, &swig_module); + } else { + /* the interpreter has loaded a SWIG module, but has it loaded this one? */ + iter=module_head; + do { + if (iter==&swig_module) { + /* Our module is already in the list, so there's nothing more to do. */ + return; + } + iter=iter->next; + } while (iter!= module_head); - /* Try and load any already created modules */ - module_head = SWIG_GetModule(clientdata); - if (!module_head) { - /* This is the first module loaded for this interpreter */ - /* so set the swig module into the interpreter */ - SWIG_SetModule(clientdata, &swig_module); - } else { - /* the interpreter has loaded a SWIG module, but has it loaded this one? */ - iter = module_head; - do { - if (iter == &swig_module) { - /* Our module is already in the list, so there's nothing more to do. */ - return; - } - iter = iter->next; - } while (iter != module_head); + /* otherwise we must add our module into the list */ + swig_module.next = module_head->next; + module_head->next = &swig_module; + } - /* otherwise we must add our module into the list */ - swig_module.next = module_head->next; - module_head->next = &swig_module; - } + /* When multiple interpreters are used, a module could have already been initialized in + a different interpreter, but not yet have a pointer in this interpreter. + In this case, we do not want to continue adding types... everything should be + set up already */ + if (init == 0) return; - /* When multiple interpreters are used, a module could have already been initialized in - a different interpreter, but not yet have a pointer in this interpreter. - In this case, we do not want to continue adding types... everything should be - set up already */ - if (init == 0) return; - - /* Now work on filling in swig_module.types */ + /* Now work on filling in swig_module.types */ #ifdef SWIGRUNTIME_DEBUG - printf("SWIG_InitializeModule: size %lu\n", (unsigned long)swig_module.size); + printf("SWIG_InitializeModule: size %lu\n", (unsigned long)swig_module.size); #endif - for (i = 0; i < swig_module.size; ++i) { - swig_type_info *type = 0; - swig_type_info *ret; - swig_cast_info *cast; + for (i = 0; i < swig_module.size; ++i) { + swig_type_info *type = 0; + swig_type_info *ret; + swig_cast_info *cast; #ifdef SWIGRUNTIME_DEBUG - printf("SWIG_InitializeModule: type %lu %s\n", (unsigned long)i, swig_module.type_initial[i]->name); + printf("SWIG_InitializeModule: type %lu %s\n", (unsigned long)i, swig_module.type_initial[i]->name); #endif - /* if there is another module already loaded */ - if (swig_module.next != &swig_module) { - type = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, swig_module.type_initial[i]->name); - } - if (type) { - /* Overwrite clientdata field */ + /* if there is another module already loaded */ + if (swig_module.next != &swig_module) { + type = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, swig_module.type_initial[i]->name); + } + if (type) { + /* Overwrite clientdata field */ #ifdef SWIGRUNTIME_DEBUG - printf("SWIG_InitializeModule: found type %s\n", type->name); + printf("SWIG_InitializeModule: found type %s\n", type->name); #endif - if (swig_module.type_initial[i]->clientdata) { - type->clientdata = swig_module.type_initial[i]->clientdata; + if (swig_module.type_initial[i]->clientdata) { + type->clientdata = swig_module.type_initial[i]->clientdata; #ifdef SWIGRUNTIME_DEBUG - printf("SWIG_InitializeModule: found and overwrite type %s \n", type->name); + printf("SWIG_InitializeModule: found and overwrite type %s \n", type->name); #endif - } - } else { - type = swig_module.type_initial[i]; - } + } + } else { + type = swig_module.type_initial[i]; + } - /* Insert casting types */ - cast = swig_module.cast_initial[i]; - while (cast->type) { + /* Insert casting types */ + cast = swig_module.cast_initial[i]; + while (cast->type) { - /* Don't need to add information already in the list */ - ret = 0; + /* Don't need to add information already in the list */ + ret = 0; #ifdef SWIGRUNTIME_DEBUG - printf("SWIG_InitializeModule: look cast %s\n", cast->type->name); + printf("SWIG_InitializeModule: look cast %s\n", cast->type->name); #endif - if (swig_module.next != &swig_module) { - ret = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, cast->type->name); + if (swig_module.next != &swig_module) { + ret = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, cast->type->name); #ifdef SWIGRUNTIME_DEBUG - if (ret) printf("SWIG_InitializeModule: found cast %s\n", ret->name); + if (ret) printf("SWIG_InitializeModule: found cast %s\n", ret->name); #endif - } - if (ret) { - if (type == swig_module.type_initial[i]) { + } + if (ret) { + if (type == swig_module.type_initial[i]) { #ifdef SWIGRUNTIME_DEBUG - printf("SWIG_InitializeModule: skip old type %s\n", ret->name); + printf("SWIG_InitializeModule: skip old type %s\n", ret->name); #endif - cast->type = ret; - ret = 0; - } else { - /* Check for casting already in the list */ - swig_cast_info *ocast = SWIG_TypeCheck(ret->name, type); + cast->type = ret; + ret = 0; + } else { + /* Check for casting already in the list */ + swig_cast_info *ocast = SWIG_TypeCheck(ret->name, type); #ifdef SWIGRUNTIME_DEBUG - if (ocast) printf("SWIG_InitializeModule: skip old cast %s\n", ret->name); + if (ocast) printf("SWIG_InitializeModule: skip old cast %s\n", ret->name); #endif - if (!ocast) ret = 0; - } - } + if (!ocast) ret = 0; + } + } - if (!ret) { + if (!ret) { #ifdef SWIGRUNTIME_DEBUG - printf("SWIG_InitializeModule: adding cast %s\n", cast->type->name); + printf("SWIG_InitializeModule: adding cast %s\n", cast->type->name); #endif - if (type->cast) { - type->cast->prev = cast; - cast->next = type->cast; - } - type->cast = cast; - } - cast++; + if (type->cast) { + type->cast->prev = cast; + cast->next = type->cast; } - /* Set entry in modules->types array equal to the type */ - swig_module.types[i] = type; + type->cast = cast; + } + cast++; } - swig_module.types[i] = 0; + /* Set entry in modules->types array equal to the type */ + swig_module.types[i] = type; + } + swig_module.types[i] = 0; #ifdef SWIGRUNTIME_DEBUG - printf("**** SWIG_InitializeModule: Cast List ******\n"); - for (i = 0; i < swig_module.size; ++i) { - int j = 0; - swig_cast_info *cast = swig_module.cast_initial[i]; - printf("SWIG_InitializeModule: type %lu %s\n", (unsigned long)i, swig_module.type_initial[i]->name); - while (cast->type) { - printf("SWIG_InitializeModule: cast type %s\n", cast->type->name); - cast++; - ++j; - } - printf("---- Total casts: %d\n", j); + printf("**** SWIG_InitializeModule: Cast List ******\n"); + for (i = 0; i < swig_module.size; ++i) { + int j = 0; + swig_cast_info *cast = swig_module.cast_initial[i]; + printf("SWIG_InitializeModule: type %lu %s\n", (unsigned long)i, swig_module.type_initial[i]->name); + while (cast->type) { + printf("SWIG_InitializeModule: cast type %s\n", cast->type->name); + cast++; + ++j; } - printf("**** SWIG_InitializeModule: Cast List ******\n"); + printf("---- Total casts: %d\n",j); + } + printf("**** SWIG_InitializeModule: Cast List ******\n"); #endif } @@ -3146,31 +3225,30 @@ SWIG_InitializeModule(SWIG_INIT_CLIENT_DATA_TYPE clientdata) { */ SWIGRUNTIME void SWIG_PropagateClientData(void) { - size_t i; - swig_cast_info *equiv; - static int init_run = 0; - - if (init_run) return; - init_run = 1; - - for (i = 0; i < swig_module.size; i++) { - if (swig_module.types[i]->clientdata) { - equiv = swig_module.types[i]->cast; - while (equiv) { - if (!equiv->converter) { - if (equiv->type && !equiv->type->clientdata) - SWIG_TypeClientData(equiv->type, swig_module.types[i]->clientdata); - } - equiv = equiv->next; - } + size_t i; + swig_cast_info *equiv; + static int init_run = 0; + + if (init_run) return; + init_run = 1; + + for (i = 0; i < swig_module.size; i++) { + if (swig_module.types[i]->clientdata) { + equiv = swig_module.types[i]->cast; + while (equiv) { + if (!equiv->converter) { + if (equiv->type && !equiv->type->clientdata) + SWIG_TypeClientData(equiv->type, swig_module.types[i]->clientdata); } + equiv = equiv->next; + } } + } } #ifdef __cplusplus #if 0 -{ - /* c-mode */ +{ /* c-mode */ #endif } #endif @@ -3178,8 +3256,8 @@ SWIG_PropagateClientData(void) { /* Forward declaration of where the user's %init{} gets inserted */ -void SWIG_init_user(lua_State *L); - +void SWIG_init_user(lua_State* L ); + #ifdef __cplusplus extern "C" { #endif @@ -3188,74 +3266,74 @@ extern "C" { the function is always called SWIG_init, but an earlier #define will rename it */ #if ((SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUA) || (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUAC)) -LUALIB_API int SWIG_init(lua_State *L) +LUALIB_API int SWIG_init(lua_State* L) #else -SWIGEXPORT int SWIG_init(lua_State *L) /* default Lua action */ +SWIGEXPORT int SWIG_init(lua_State* L) /* default Lua action */ #endif { #if (SWIG_LUA_TARGET != SWIG_LUA_FLAVOR_ELUAC) /* valid for both Lua and eLua */ - int i; - int globalRegister = 0; - /* start with global table */ - lua_pushglobaltable(L); - /* SWIG's internal initialisation */ - SWIG_InitializeModule((void *)L); - SWIG_PropagateClientData(); + int i; + int globalRegister = 0; + /* start with global table */ + lua_pushglobaltable (L); + /* SWIG's internal initialisation */ + SWIG_InitializeModule((void*)L); + SWIG_PropagateClientData(); #endif #if ((SWIG_LUA_TARGET != SWIG_LUA_FLAVOR_ELUA) && (SWIG_LUA_TARGET != SWIG_LUA_FLAVOR_ELUAC)) || defined(SWIG_LUA_ELUA_EMULATE) - /* add a global fn */ - SWIG_Lua_add_function(L, "swig_type", SWIG_Lua_type); - SWIG_Lua_add_function(L, "swig_equals", SWIG_Lua_class_equal); + /* add a global fn */ + SWIG_Lua_add_function(L,"swig_type",SWIG_Lua_type); + SWIG_Lua_add_function(L,"swig_equals",SWIG_Lua_class_equal); #endif #if (SWIG_LUA_TARGET != SWIG_LUA_FLAVOR_ELUAC) - /* set up base class pointers (the hierarchy) */ - for (i = 0; swig_types[i]; i++) { - if (swig_types[i]->clientdata) { - SWIG_Lua_init_base_class(L, (swig_lua_class *)(swig_types[i]->clientdata)); - } + /* set up base class pointers (the hierarchy) */ + for (i = 0; swig_types[i]; i++){ + if (swig_types[i]->clientdata){ + SWIG_Lua_init_base_class(L,(swig_lua_class*)(swig_types[i]->clientdata)); } + } #ifdef SWIG_LUA_MODULE_GLOBAL - globalRegister = 1; + globalRegister = 1; #endif #if (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_LUA) - SWIG_Lua_namespace_register(L, &swig_SwigModule, globalRegister); + SWIG_Lua_namespace_register(L,&swig_SwigModule, globalRegister); #endif #if (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUA) || (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUAC) - for (i = 0; swig_types[i]; i++) { - if (swig_types[i]->clientdata) { - SWIG_Lua_elua_class_register_instance(L, (swig_lua_class *)(swig_types[i]->clientdata)); - } + for (i = 0; swig_types[i]; i++){ + if (swig_types[i]->clientdata){ + SWIG_Lua_elua_class_register_instance(L,(swig_lua_class*)(swig_types[i]->clientdata)); } + } #endif #if defined(SWIG_LUA_ELUA_EMULATE) - lua_newtable(L); - SWIG_Lua_elua_emulate_register(L, swig_SwigModule.ns_methods); - SWIG_Lua_elua_emulate_register_clear(L); - if (globalRegister) { - lua_pushstring(L, swig_SwigModule.name); - lua_pushvalue(L, -2); - lua_rawset(L, -4); - } + lua_newtable(L); + SWIG_Lua_elua_emulate_register(L,swig_SwigModule.ns_methods); + SWIG_Lua_elua_emulate_register_clear(L); + if(globalRegister) { + lua_pushstring(L,swig_SwigModule.name); + lua_pushvalue(L,-2); + lua_rawset(L,-4); + } #endif #endif #if (SWIG_LUA_TARGET != SWIG_LUA_FLAVOR_ELUAC) - /* invoke user-specific initialization */ - SWIG_init_user(L); - /* end module */ - /* Note: We do not clean up the stack here (Lua will do this for us). At this - point, we have the globals table and out module table on the stack. Returning - one value makes the module table the result of the require command. */ - return 1; + /* invoke user-specific initialization */ + SWIG_init_user(L); + /* end module */ + /* Note: We do not clean up the stack here (Lua will do this for us). At this + point, we have the globals table and out module table on the stack. Returning + one value makes the module table the result of the require command. */ + return 1; #else - return 0; + return 0; #endif } @@ -3264,11 +3342,12 @@ SWIGEXPORT int SWIG_init(lua_State *L) /* default Lua action */ #endif -const char *SWIG_LUACODE = - ""; +const char* SWIG_LUACODE= + ""; -void SWIG_init_user(lua_State *L) { - /* exec Lua code if applicable */ - SWIG_Lua_dostring(L, SWIG_LUACODE); +void SWIG_init_user(lua_State* L) +{ + /* exec Lua code if applicable */ + SWIG_Lua_dostring(L,SWIG_LUACODE); } diff --git a/client/src/pm3_pywrap.c b/client/src/pm3_pywrap.c index 93a26e2d07..6180a87710 100644 --- a/client/src/pm3_pywrap.c +++ b/client/src/pm3_pywrap.c @@ -139,7 +139,7 @@ # define SWIG_NULLPTR nullptr #else # define SWIG_NULLPTR NULL -#endif +#endif /* ----------------------------------------------------------------------------- * swigcompat.swg @@ -377,10 +377,10 @@ # define SWIG_CASTRANKMASK ((SWIG_CASTRANKLIMIT) -1) # define SWIG_CastRank(r) (r & SWIG_CASTRANKMASK) SWIGINTERNINLINE int SWIG_AddCast(int r) { - return SWIG_IsOK(r) ? ((SWIG_CastRank(r) < SWIG_MAXCASTRANK) ? (r + 1) : SWIG_ERROR) : r; + return SWIG_IsOK(r) ? ((SWIG_CastRank(r) < SWIG_MAXCASTRANK) ? (r + 1) : SWIG_ERROR) : r; } SWIGINTERNINLINE int SWIG_CheckState(int r) { - return SWIG_IsOK(r) ? SWIG_CastRank(r) + 1 : 0; + return SWIG_IsOK(r) ? SWIG_CastRank(r) + 1 : 0; } #else /* no cast-rank mode */ # define SWIG_AddCast(r) (r) @@ -399,32 +399,32 @@ typedef struct swig_type_info *(*swig_dycast_func)(void **); /* Structure to store information on one type */ typedef struct swig_type_info { - const char *name; /* mangled name of this type */ - const char *str; /* human readable name of this type */ - swig_dycast_func dcast; /* dynamic cast function down a hierarchy */ - struct swig_cast_info *cast; /* linked list of types that can cast into this type */ - void *clientdata; /* language specific type data */ - int owndata; /* flag if the structure owns the clientdata */ + const char *name; /* mangled name of this type */ + const char *str; /* human readable name of this type */ + swig_dycast_func dcast; /* dynamic cast function down a hierarchy */ + struct swig_cast_info *cast; /* linked list of types that can cast into this type */ + void *clientdata; /* language specific type data */ + int owndata; /* flag if the structure owns the clientdata */ } swig_type_info; /* Structure to store a type and conversion function used for casting */ typedef struct swig_cast_info { - swig_type_info *type; /* pointer to type that is equivalent to this type */ - swig_converter_func converter; /* function to cast the void pointers */ - struct swig_cast_info *next; /* pointer to next cast in linked list */ - struct swig_cast_info *prev; /* pointer to the previous cast */ + swig_type_info *type; /* pointer to type that is equivalent to this type */ + swig_converter_func converter; /* function to cast the void pointers */ + struct swig_cast_info *next; /* pointer to next cast in linked list */ + struct swig_cast_info *prev; /* pointer to the previous cast */ } swig_cast_info; /* Structure used to store module information * Each module generates one structure like this, and the runtime collects * all of these structures and stores them in a circularly linked list.*/ typedef struct swig_module_info { - swig_type_info **types; /* Array of pointers to swig_type_info structures that are in this module */ - size_t size; /* Number of types in this module */ - struct swig_module_info *next; /* Pointer to next element in circularly linked list */ - swig_type_info **type_initial; /* Array of initially generated type structures */ - swig_cast_info **cast_initial; /* Array of initially generated casting structures */ - void *clientdata; /* Language specific module data */ + swig_type_info **types; /* Array of pointers to swig_type_info structures that are in this module */ + size_t size; /* Number of types in this module */ + struct swig_module_info *next; /* Pointer to next element in circularly linked list */ + swig_type_info **type_initial; /* Array of initially generated type structures */ + swig_cast_info **cast_initial; /* Array of initially generated casting structures */ + void *clientdata; /* Language specific module data */ } swig_module_info; /* @@ -436,13 +436,13 @@ typedef struct swig_module_info { */ SWIGRUNTIME int SWIG_TypeNameComp(const char *f1, const char *l1, - const char *f2, const char *l2) { - for (; (f1 != l1) && (f2 != l2); ++f1, ++f2) { - while ((*f1 == ' ') && (f1 != l1)) ++f1; - while ((*f2 == ' ') && (f2 != l2)) ++f2; - if (*f1 != *f2) return (*f1 > *f2) ? 1 : -1; - } - return (int)((l1 - f1) - (l2 - f2)); + const char *f2, const char *l2) { + for (;(f1 != l1) && (f2 != l2); ++f1, ++f2) { + while ((*f1 == ' ') && (f1 != l1)) ++f1; + while ((*f2 == ' ') && (f2 != l2)) ++f2; + if (*f1 != *f2) return (*f1 > *f2) ? 1 : -1; + } + return (int)((l1 - f1) - (l2 - f2)); } /* @@ -451,17 +451,17 @@ SWIG_TypeNameComp(const char *f1, const char *l1, */ SWIGRUNTIME int SWIG_TypeCmp(const char *nb, const char *tb) { - int equiv = 1; - const char *te = tb + strlen(tb); - const char *ne = nb; - while (equiv != 0 && *ne) { - for (nb = ne; *ne; ++ne) { - if (*ne == '|') break; - } - equiv = SWIG_TypeNameComp(nb, ne, tb, te); - if (*ne) ++ne; + int equiv = 1; + const char* te = tb + strlen(tb); + const char* ne = nb; + while (equiv != 0 && *ne) { + for (nb = ne; *ne; ++ne) { + if (*ne == '|') break; } - return equiv; + equiv = SWIG_TypeNameComp(nb, ne, tb, te); + if (*ne) ++ne; + } + return equiv; } /* @@ -470,7 +470,7 @@ SWIG_TypeCmp(const char *nb, const char *tb) { */ SWIGRUNTIME int SWIG_TypeEquiv(const char *nb, const char *tb) { - return SWIG_TypeCmp(nb, tb) == 0 ? 1 : 0; + return SWIG_TypeCmp(nb, tb) == 0 ? 1 : 0; } /* @@ -478,26 +478,26 @@ SWIG_TypeEquiv(const char *nb, const char *tb) { */ SWIGRUNTIME swig_cast_info * SWIG_TypeCheck(const char *c, swig_type_info *ty) { - if (ty) { - swig_cast_info *iter = ty->cast; - while (iter) { - if (strcmp(iter->type->name, c) == 0) { - if (iter == ty->cast) - return iter; - /* Move iter to the top of the linked list */ - iter->prev->next = iter->next; - if (iter->next) - iter->next->prev = iter->prev; - iter->next = ty->cast; - iter->prev = 0; - if (ty->cast) ty->cast->prev = iter; - ty->cast = iter; - return iter; - } - iter = iter->next; - } + if (ty) { + swig_cast_info *iter = ty->cast; + while (iter) { + if (strcmp(iter->type->name, c) == 0) { + if (iter == ty->cast) + return iter; + /* Move iter to the top of the linked list */ + iter->prev->next = iter->next; + if (iter->next) + iter->next->prev = iter->prev; + iter->next = ty->cast; + iter->prev = 0; + if (ty->cast) ty->cast->prev = iter; + ty->cast = iter; + return iter; + } + iter = iter->next; } - return 0; + } + return 0; } /* @@ -505,26 +505,26 @@ SWIG_TypeCheck(const char *c, swig_type_info *ty) { */ SWIGRUNTIME swig_cast_info * SWIG_TypeCheckStruct(const swig_type_info *from, swig_type_info *ty) { - if (ty) { - swig_cast_info *iter = ty->cast; - while (iter) { - if (iter->type == from) { - if (iter == ty->cast) - return iter; - /* Move iter to the top of the linked list */ - iter->prev->next = iter->next; - if (iter->next) - iter->next->prev = iter->prev; - iter->next = ty->cast; - iter->prev = 0; - if (ty->cast) ty->cast->prev = iter; - ty->cast = iter; - return iter; - } - iter = iter->next; - } + if (ty) { + swig_cast_info *iter = ty->cast; + while (iter) { + if (iter->type == from) { + if (iter == ty->cast) + return iter; + /* Move iter to the top of the linked list */ + iter->prev->next = iter->next; + if (iter->next) + iter->next->prev = iter->prev; + iter->next = ty->cast; + iter->prev = 0; + if (ty->cast) ty->cast->prev = iter; + ty->cast = iter; + return iter; + } + iter = iter->next; } - return 0; + } + return 0; } /* @@ -532,7 +532,7 @@ SWIG_TypeCheckStruct(const swig_type_info *from, swig_type_info *ty) { */ SWIGRUNTIMEINLINE void * SWIG_TypeCast(swig_cast_info *ty, void *ptr, int *newmemory) { - return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr, newmemory); + return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr, newmemory); } /* @@ -540,13 +540,13 @@ SWIG_TypeCast(swig_cast_info *ty, void *ptr, int *newmemory) { */ SWIGRUNTIME swig_type_info * SWIG_TypeDynamicCast(swig_type_info *ty, void **ptr) { - swig_type_info *lastty = ty; - if (!ty || !ty->dcast) return ty; - while (ty && (ty->dcast)) { - ty = (*ty->dcast)(ptr); - if (ty) lastty = ty; - } - return lastty; + swig_type_info *lastty = ty; + if (!ty || !ty->dcast) return ty; + while (ty && (ty->dcast)) { + ty = (*ty->dcast)(ptr); + if (ty) lastty = ty; + } + return lastty; } /* @@ -554,7 +554,7 @@ SWIG_TypeDynamicCast(swig_type_info *ty, void **ptr) { */ SWIGRUNTIMEINLINE const char * SWIG_TypeName(const swig_type_info *ty) { - return ty->name; + return ty->name; } /* @@ -563,19 +563,20 @@ SWIG_TypeName(const swig_type_info *ty) { */ SWIGRUNTIME const char * SWIG_TypePrettyName(const swig_type_info *type) { - /* The "str" field contains the equivalent pretty names of the - type, separated by vertical-bar characters. Choose the last - name. It should be the most specific; a fully resolved name - but not necessarily with default template parameters expanded. */ - if (!type) return NULL; - if (type->str != NULL) { - const char *last_name = type->str; - const char *s; - for (s = type->str; *s; s++) - if (*s == '|') last_name = s + 1; - return last_name; - } else - return type->name; + /* The "str" field contains the equivalent pretty names of the + type, separated by vertical-bar characters. Choose the last + name. It should be the most specific; a fully resolved name + but not necessarily with default template parameters expanded. */ + if (!type) return NULL; + if (type->str != NULL) { + const char *last_name = type->str; + const char *s; + for (s = type->str; *s; s++) + if (*s == '|') last_name = s+1; + return last_name; + } + else + return type->name; } /* @@ -583,24 +584,24 @@ SWIG_TypePrettyName(const swig_type_info *type) { */ SWIGRUNTIME void SWIG_TypeClientData(swig_type_info *ti, void *clientdata) { - swig_cast_info *cast = ti->cast; - /* if (ti->clientdata == clientdata) return; */ - ti->clientdata = clientdata; - - while (cast) { - if (!cast->converter) { - swig_type_info *tc = cast->type; - if (!tc->clientdata) { - SWIG_TypeClientData(tc, clientdata); - } - } - cast = cast->next; + swig_cast_info *cast = ti->cast; + /* if (ti->clientdata == clientdata) return; */ + ti->clientdata = clientdata; + + while (cast) { + if (!cast->converter) { + swig_type_info *tc = cast->type; + if (!tc->clientdata) { + SWIG_TypeClientData(tc, clientdata); + } } + cast = cast->next; + } } SWIGRUNTIME void SWIG_TypeNewClientData(swig_type_info *ti, void *clientdata) { - SWIG_TypeClientData(ti, clientdata); - ti->owndata = 1; + SWIG_TypeClientData(ti, clientdata); + ti->owndata = 1; } /* @@ -614,37 +615,37 @@ SWIG_TypeNewClientData(swig_type_info *ti, void *clientdata) { SWIGRUNTIME swig_type_info * SWIG_MangledTypeQueryModule(swig_module_info *start, swig_module_info *end, - const char *name) { - swig_module_info *iter = start; - do { - if (iter->size) { - size_t l = 0; - size_t r = iter->size - 1; - do { - /* since l+r >= 0, we can (>> 1) instead (/ 2) */ - size_t i = (l + r) >> 1; - const char *iname = iter->types[i]->name; - if (iname) { - int compare = strcmp(name, iname); - if (compare == 0) { - return iter->types[i]; - } else if (compare < 0) { - if (i) { - r = i - 1; - } else { - break; - } - } else if (compare > 0) { - l = i + 1; - } - } else { - break; /* should never happen */ - } - } while (l <= r); - } - iter = iter->next; - } while (iter != end); - return 0; + const char *name) { + swig_module_info *iter = start; + do { + if (iter->size) { + size_t l = 0; + size_t r = iter->size - 1; + do { + /* since l+r >= 0, we can (>> 1) instead (/ 2) */ + size_t i = (l + r) >> 1; + const char *iname = iter->types[i]->name; + if (iname) { + int compare = strcmp(name, iname); + if (compare == 0) { + return iter->types[i]; + } else if (compare < 0) { + if (i) { + r = i - 1; + } else { + break; + } + } else if (compare > 0) { + l = i + 1; + } + } else { + break; /* should never happen */ + } + } while (l <= r); + } + iter = iter->next; + } while (iter != end); + return 0; } /* @@ -659,27 +660,27 @@ SWIG_MangledTypeQueryModule(swig_module_info *start, SWIGRUNTIME swig_type_info * SWIG_TypeQueryModule(swig_module_info *start, swig_module_info *end, - const char *name) { - /* STEP 1: Search the name field using binary search */ - swig_type_info *ret = SWIG_MangledTypeQueryModule(start, end, name); - if (ret) { - return ret; - } else { - /* STEP 2: If the type hasn't been found, do a complete search - of the str field (the human readable name) */ - swig_module_info *iter = start; - do { - size_t i = 0; - for (; i < iter->size; ++i) { - if (iter->types[i]->str && (SWIG_TypeEquiv(iter->types[i]->str, name))) - return iter->types[i]; - } - iter = iter->next; - } while (iter != end); - } + const char *name) { + /* STEP 1: Search the name field using binary search */ + swig_type_info *ret = SWIG_MangledTypeQueryModule(start, end, name); + if (ret) { + return ret; + } else { + /* STEP 2: If the type hasn't been found, do a complete search + of the str field (the human readable name) */ + swig_module_info *iter = start; + do { + size_t i = 0; + for (; i < iter->size; ++i) { + if (iter->types[i]->str && (SWIG_TypeEquiv(iter->types[i]->str, name))) + return iter->types[i]; + } + iter = iter->next; + } while (iter != end); + } - /* neither found a match */ - return 0; + /* neither found a match */ + return 0; } /* @@ -687,15 +688,15 @@ SWIG_TypeQueryModule(swig_module_info *start, */ SWIGRUNTIME char * SWIG_PackData(char *c, void *ptr, size_t sz) { - static const char hex[17] = "0123456789abcdef"; - const unsigned char *u = (unsigned char *) ptr; - const unsigned char *eu = u + sz; - for (; u != eu; ++u) { - unsigned char uu = *u; - *(c++) = hex[(uu & 0xf0) >> 4]; - *(c++) = hex[uu & 0xf]; - } - return c; + static const char hex[17] = "0123456789abcdef"; + const unsigned char *u = (unsigned char *) ptr; + const unsigned char *eu = u + sz; + for (; u != eu; ++u) { + unsigned char uu = *u; + *(c++) = hex[(uu & 0xf0) >> 4]; + *(c++) = hex[uu & 0xf]; + } + return c; } /* @@ -703,27 +704,27 @@ SWIG_PackData(char *c, void *ptr, size_t sz) { */ SWIGRUNTIME const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) { - unsigned char *u = (unsigned char *) ptr; - const unsigned char *eu = u + sz; - for (; u != eu; ++u) { - char d = *(c++); - unsigned char uu; - if ((d >= '0') && (d <= '9')) - uu = (unsigned char)((d - '0') << 4); - else if ((d >= 'a') && (d <= 'f')) - uu = (unsigned char)((d - ('a' - 10)) << 4); - else - return (char *) 0; - d = *(c++); - if ((d >= '0') && (d <= '9')) - uu |= (unsigned char)(d - '0'); - else if ((d >= 'a') && (d <= 'f')) - uu |= (unsigned char)(d - ('a' - 10)); - else - return (char *) 0; - *u = uu; - } - return c; + unsigned char *u = (unsigned char *) ptr; + const unsigned char *eu = u + sz; + for (; u != eu; ++u) { + char d = *(c++); + unsigned char uu; + if ((d >= '0') && (d <= '9')) + uu = (unsigned char)((d - '0') << 4); + else if ((d >= 'a') && (d <= 'f')) + uu = (unsigned char)((d - ('a'-10)) << 4); + else + return (char *) 0; + d = *(c++); + if ((d >= '0') && (d <= '9')) + uu |= (unsigned char)(d - '0'); + else if ((d >= 'a') && (d <= 'f')) + uu |= (unsigned char)(d - ('a'-10)); + else + return (char *) 0; + *u = uu; + } + return c; } /* @@ -731,54 +732,54 @@ SWIG_UnpackData(const char *c, void *ptr, size_t sz) { */ SWIGRUNTIME char * SWIG_PackVoidPtr(char *buff, void *ptr, const char *name, size_t bsz) { - char *r = buff; - if ((2 * sizeof(void *) + 2) > bsz) return 0; - *(r++) = '_'; - r = SWIG_PackData(r, &ptr, sizeof(void *)); - if (strlen(name) + 1 > (bsz - (r - buff))) return 0; - strcpy(r, name); - return buff; + char *r = buff; + if ((2*sizeof(void *) + 2) > bsz) return 0; + *(r++) = '_'; + r = SWIG_PackData(r,&ptr,sizeof(void *)); + if (strlen(name) + 1 > (bsz - (r - buff))) return 0; + strcpy(r,name); + return buff; } SWIGRUNTIME const char * SWIG_UnpackVoidPtr(const char *c, void **ptr, const char *name) { - if (*c != '_') { - if (strcmp(c, "NULL") == 0) { - *ptr = (void *) 0; - return name; - } else { - return 0; - } + if (*c != '_') { + if (strcmp(c,"NULL") == 0) { + *ptr = (void *) 0; + return name; + } else { + return 0; } - return SWIG_UnpackData(++c, ptr, sizeof(void *)); + } + return SWIG_UnpackData(++c,ptr,sizeof(void *)); } SWIGRUNTIME char * SWIG_PackDataName(char *buff, void *ptr, size_t sz, const char *name, size_t bsz) { - char *r = buff; - size_t lname = (name ? strlen(name) : 0); - if ((2 * sz + 2 + lname) > bsz) return 0; - *(r++) = '_'; - r = SWIG_PackData(r, ptr, sz); - if (lname) { - strncpy(r, name, lname + 1); - } else { - *r = 0; - } - return buff; + char *r = buff; + size_t lname = (name ? strlen(name) : 0); + if ((2*sz + 2 + lname) > bsz) return 0; + *(r++) = '_'; + r = SWIG_PackData(r,ptr,sz); + if (lname) { + strncpy(r,name,lname+1); + } else { + *r = 0; + } + return buff; } SWIGRUNTIME const char * SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) { - if (*c != '_') { - if (strcmp(c, "NULL") == 0) { - memset(ptr, 0, sz); - return name; - } else { - return 0; - } + if (*c != '_') { + if (strcmp(c,"NULL") == 0) { + memset(ptr,0,sz); + return name; + } else { + return 0; } - return SWIG_UnpackData(++c, ptr, sz); + } + return SWIG_UnpackData(++c,ptr,sz); } #ifdef __cplusplus @@ -813,7 +814,7 @@ SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) { #define PyString_FromString(x) PyUnicode_FromString(x) #define PyString_Format(fmt, args) PyUnicode_Format(fmt, args) #define PyString_AsString(str) PyBytes_AsString(str) -#define PyString_Size(str) PyBytes_Size(str) +#define PyString_Size(str) PyBytes_Size(str) #define PyString_InternFromString(key) PyUnicode_InternFromString(key) #define Py_TPFLAGS_HAVE_CLASS Py_TPFLAGS_BASETYPE #define _PyLong_FromSsize_t(x) PyLong_FromSsize_t(x) @@ -835,32 +836,34 @@ SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) { /* Wrapper around PyUnicode_AsUTF8AndSize - call Py_XDECREF on the returned pbytes when finished with the returned string */ SWIGINTERN const char * -SWIG_PyUnicode_AsUTF8AndSize(PyObject *str, Py_ssize_t *psize, PyObject **pbytes) { +SWIG_PyUnicode_AsUTF8AndSize(PyObject *str, Py_ssize_t *psize, PyObject **pbytes) +{ #if PY_VERSION_HEX >= 0x03030000 # if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030A0000 - *pbytes = NULL; - return PyUnicode_AsUTF8AndSize(str, psize); + *pbytes = NULL; + return PyUnicode_AsUTF8AndSize(str, psize); # else - *pbytes = PyUnicode_AsUTF8String(str); - const char *chars = *pbytes ? PyBytes_AsString(*pbytes) : NULL; - if (chars && psize) - *psize = PyBytes_Size(*pbytes); - return chars; + *pbytes = PyUnicode_AsUTF8String(str); + const char *chars = *pbytes ? PyBytes_AsString(*pbytes) : NULL; + if (chars && psize) + *psize = PyBytes_Size(*pbytes); + return chars; # endif #else - char *chars = NULL; - *pbytes = NULL; - PyString_AsStringAndSize(str, &chars, psize); - return chars; + char *chars = NULL; + *pbytes = NULL; + PyString_AsStringAndSize(str, &chars, psize); + return chars; #endif } -SWIGINTERN PyObject * -SWIG_Python_str_FromChar(const char *c) { +SWIGINTERN PyObject* +SWIG_Python_str_FromChar(const char *c) +{ #if PY_VERSION_HEX >= 0x03000000 - return PyUnicode_FromString(c); + return PyUnicode_FromString(c); #else - return PyString_FromString(c); + return PyString_FromString(c); #endif } @@ -901,107 +904,110 @@ SWIG_Python_str_FromChar(const char *c) { * error manipulation * ----------------------------------------------------------------------------- */ -SWIGRUNTIME PyObject * +SWIGRUNTIME PyObject* SWIG_Python_ErrorType(int code) { - PyObject *type = 0; - switch (code) { - case SWIG_MemoryError: - type = PyExc_MemoryError; - break; - case SWIG_IOError: - type = PyExc_IOError; - break; - case SWIG_RuntimeError: - type = PyExc_RuntimeError; - break; - case SWIG_IndexError: - type = PyExc_IndexError; - break; - case SWIG_TypeError: - type = PyExc_TypeError; - break; - case SWIG_DivisionByZero: - type = PyExc_ZeroDivisionError; - break; - case SWIG_OverflowError: - type = PyExc_OverflowError; - break; - case SWIG_SyntaxError: - type = PyExc_SyntaxError; - break; - case SWIG_ValueError: - type = PyExc_ValueError; - break; - case SWIG_SystemError: - type = PyExc_SystemError; - break; - case SWIG_AttributeError: - type = PyExc_AttributeError; - break; - default: - type = PyExc_RuntimeError; - } - return type; + PyObject* type = 0; + switch(code) { + case SWIG_MemoryError: + type = PyExc_MemoryError; + break; + case SWIG_IOError: + type = PyExc_IOError; + break; + case SWIG_RuntimeError: + type = PyExc_RuntimeError; + break; + case SWIG_IndexError: + type = PyExc_IndexError; + break; + case SWIG_TypeError: + type = PyExc_TypeError; + break; + case SWIG_DivisionByZero: + type = PyExc_ZeroDivisionError; + break; + case SWIG_OverflowError: + type = PyExc_OverflowError; + break; + case SWIG_SyntaxError: + type = PyExc_SyntaxError; + break; + case SWIG_ValueError: + type = PyExc_ValueError; + break; + case SWIG_SystemError: + type = PyExc_SystemError; + break; + case SWIG_AttributeError: + type = PyExc_AttributeError; + break; + default: + type = PyExc_RuntimeError; + } + return type; } SWIGRUNTIME void -SWIG_Python_AddErrorMsg(const char *mesg) { - PyObject *type = 0; - PyObject *value = 0; - PyObject *traceback = 0; - - if (PyErr_Occurred()) - PyErr_Fetch(&type, &value, &traceback); - if (value) { - PyObject *old_str = PyObject_Str(value); - PyObject *bytes = NULL; - const char *tmp = SWIG_PyUnicode_AsUTF8AndSize(old_str, NULL, &bytes); - PyErr_Clear(); - Py_XINCREF(type); - if (tmp) - PyErr_Format(type, "%s %s", tmp, mesg); - else - PyErr_Format(type, "%s", mesg); - Py_XDECREF(bytes); - Py_DECREF(old_str); - Py_DECREF(value); - } else { - PyErr_SetString(PyExc_RuntimeError, mesg); - } +SWIG_Python_AddErrorMsg(const char* mesg) +{ + PyObject *type = 0; + PyObject *value = 0; + PyObject *traceback = 0; + + if (PyErr_Occurred()) + PyErr_Fetch(&type, &value, &traceback); + if (value) { + PyObject *old_str = PyObject_Str(value); + PyObject *bytes = NULL; + const char *tmp = SWIG_PyUnicode_AsUTF8AndSize(old_str, NULL, &bytes); + PyErr_Clear(); + Py_XINCREF(type); + if (tmp) + PyErr_Format(type, "%s %s", tmp, mesg); + else + PyErr_Format(type, "%s", mesg); + Py_XDECREF(bytes); + Py_DECREF(old_str); + Py_DECREF(value); + } else { + PyErr_SetString(PyExc_RuntimeError, mesg); + } } SWIGRUNTIME int -SWIG_Python_TypeErrorOccurred(PyObject *obj) { - PyObject *error; - if (obj) - return 0; - error = PyErr_Occurred(); - return error && PyErr_GivenExceptionMatches(error, PyExc_TypeError); +SWIG_Python_TypeErrorOccurred(PyObject *obj) +{ + PyObject *error; + if (obj) + return 0; + error = PyErr_Occurred(); + return error && PyErr_GivenExceptionMatches(error, PyExc_TypeError); } SWIGRUNTIME void -SWIG_Python_RaiseOrModifyTypeError(const char *message) { - if (SWIG_Python_TypeErrorOccurred(NULL)) { - /* Use existing TypeError to preserve stacktrace and enhance with given message */ - PyObject *newvalue; - PyObject *type = NULL, *value = NULL, *traceback = NULL; - PyErr_Fetch(&type, &value, &traceback); +SWIG_Python_RaiseOrModifyTypeError(const char *message) +{ + if (SWIG_Python_TypeErrorOccurred(NULL)) { + /* Use existing TypeError to preserve stacktrace and enhance with given message */ + PyObject *newvalue; + PyObject *type = NULL, *value = NULL, *traceback = NULL; + PyErr_Fetch(&type, &value, &traceback); #if PY_VERSION_HEX >= 0x03000000 - newvalue = PyUnicode_FromFormat("%S\nAdditional information:\n%s", value, message); + newvalue = PyUnicode_FromFormat("%S\nAdditional information:\n%s", value, message); #else - newvalue = PyString_FromFormat("%s\nAdditional information:\n%s", PyString_AsString(value), message); + newvalue = PyString_FromFormat("%s\nAdditional information:\n%s", PyString_AsString(value), message); #endif - if (newvalue) { - Py_XDECREF(value); - PyErr_Restore(type, newvalue, traceback); - } else { - PyErr_Restore(type, value, traceback); - } + if (newvalue) { + Py_XDECREF(value); + PyErr_Restore(type, newvalue, traceback); } else { - /* Raise TypeError using given message */ - PyErr_SetString(PyExc_TypeError, message); + PyErr_Restore(type, value, traceback); } + } else { + /* Raise TypeError using given message */ + PyErr_SetString(PyExc_TypeError, message); + } } #if defined(SWIG_PYTHON_NO_THREADS) @@ -1022,22 +1028,22 @@ SWIG_Python_RaiseOrModifyTypeError(const char *message) { # endif # endif # ifdef __cplusplus /* C++ code */ -class SWIG_Python_Thread_Block { - bool status; - PyGILState_STATE state; - public: - void end() { if (status) { PyGILState_Release(state); status = false;} } - SWIG_Python_Thread_Block() : status(true), state(PyGILState_Ensure()) {} - ~SWIG_Python_Thread_Block() { end(); } -}; -class SWIG_Python_Thread_Allow { - bool status; - PyThreadState *save; - public: - void end() { if (status) { status = false; PyEval_RestoreThread(save); }} - SWIG_Python_Thread_Allow() : status(true), save(PyEval_SaveThread()) {} - ~SWIG_Python_Thread_Allow() { end(); } -}; + class SWIG_Python_Thread_Block { + bool status; + PyGILState_STATE state; + public: + void end() { if (status) { PyGILState_Release(state); status = false;} } + SWIG_Python_Thread_Block() : status(true), state(PyGILState_Ensure()) {} + ~SWIG_Python_Thread_Block() { end(); } + }; + class SWIG_Python_Thread_Allow { + bool status; + PyThreadState *save; + public: + void end() { if (status) { status = false; PyEval_RestoreThread(save); }} + SWIG_Python_Thread_Allow() : status(true), save(PyEval_SaveThread()) {} + ~SWIG_Python_Thread_Allow() { end(); } + }; # define SWIG_PYTHON_THREAD_BEGIN_BLOCK SWIG_Python_Thread_Block _swig_thread_block # define SWIG_PYTHON_THREAD_END_BLOCK _swig_thread_block.end() # define SWIG_PYTHON_THREAD_BEGIN_ALLOW SWIG_Python_Thread_Allow _swig_thread_allow @@ -1091,12 +1097,12 @@ extern "C" { /* Constant information structure */ typedef struct swig_const_info { - int type; - const char *name; - long lvalue; - double dvalue; - void *pvalue; - swig_type_info **ptype; + int type; + const char *name; + long lvalue; + double dvalue; + void *pvalue; + swig_type_info **ptype; } swig_const_info; #ifdef __cplusplus @@ -1136,7 +1142,7 @@ typedef struct swig_const_info { #define SWIG_InternalNewPointerObj(ptr, type, flags) SWIG_Python_NewPointerObj(NULL, ptr, type, flags) -#define SWIG_CheckImplicit(ty) SWIG_Python_CheckImplicit(ty) +#define SWIG_CheckImplicit(ty) SWIG_Python_CheckImplicit(ty) #define SWIG_AcquirePtr(ptr, src) SWIG_Python_AcquirePtr(ptr, src) #define swig_owntype int @@ -1163,30 +1169,30 @@ typedef struct swig_const_info { #define SWIG_SetModule(clientdata, pointer) SWIG_Python_SetModule(pointer) #define SWIG_NewClientData(obj) SwigPyClientData_New(obj) -#define SWIG_SetErrorObj SWIG_Python_SetErrorObj -#define SWIG_SetErrorMsg SWIG_Python_SetErrorMsg -#define SWIG_ErrorType(code) SWIG_Python_ErrorType(code) -#define SWIG_Error(code, msg) SWIG_Python_SetErrorMsg(SWIG_ErrorType(code), msg) -#define SWIG_fail goto fail +#define SWIG_SetErrorObj SWIG_Python_SetErrorObj +#define SWIG_SetErrorMsg SWIG_Python_SetErrorMsg +#define SWIG_ErrorType(code) SWIG_Python_ErrorType(code) +#define SWIG_Error(code, msg) SWIG_Python_SetErrorMsg(SWIG_ErrorType(code), msg) +#define SWIG_fail goto fail /* Runtime API implementation */ /* Error manipulation */ -SWIGINTERN void +SWIGINTERN void SWIG_Python_SetErrorObj(PyObject *errtype, PyObject *obj) { - SWIG_PYTHON_THREAD_BEGIN_BLOCK; - PyErr_SetObject(errtype, obj); - Py_DECREF(obj); - SWIG_PYTHON_THREAD_END_BLOCK; + SWIG_PYTHON_THREAD_BEGIN_BLOCK; + PyErr_SetObject(errtype, obj); + Py_DECREF(obj); + SWIG_PYTHON_THREAD_END_BLOCK; } -SWIGINTERN void +SWIGINTERN void SWIG_Python_SetErrorMsg(PyObject *errtype, const char *msg) { - SWIG_PYTHON_THREAD_BEGIN_BLOCK; - PyErr_SetString(errtype, msg); - SWIG_PYTHON_THREAD_END_BLOCK; + SWIG_PYTHON_THREAD_BEGIN_BLOCK; + PyErr_SetString(errtype, msg); + SWIG_PYTHON_THREAD_END_BLOCK; } #define SWIG_Python_Raise(obj, type, desc) SWIG_Python_SetErrorObj(SWIG_Python_ExceptionType(desc), obj) @@ -1197,113 +1203,114 @@ SWIG_Python_SetErrorMsg(PyObject *errtype, const char *msg) { SWIGINTERN void SwigPyBuiltin_AddPublicSymbol(PyObject *seq, const char *key) { - PyObject *s = PyString_InternFromString(key); - PyList_Append(seq, s); - Py_DECREF(s); + PyObject *s = PyString_InternFromString(key); + PyList_Append(seq, s); + Py_DECREF(s); } SWIGINTERN void -SWIG_Python_SetConstant(PyObject *d, PyObject *public_interface, const char *name, PyObject *obj) { - PyDict_SetItemString(d, name, obj); - Py_DECREF(obj); - if (public_interface) - SwigPyBuiltin_AddPublicSymbol(public_interface, name); +SWIG_Python_SetConstant(PyObject *d, PyObject *public_interface, const char *name, PyObject *obj) { + PyDict_SetItemString(d, name, obj); + Py_DECREF(obj); + if (public_interface) + SwigPyBuiltin_AddPublicSymbol(public_interface, name); } #else SWIGINTERN void -SWIG_Python_SetConstant(PyObject *d, const char *name, PyObject *obj) { - PyDict_SetItemString(d, name, obj); - Py_DECREF(obj); +SWIG_Python_SetConstant(PyObject *d, const char *name, PyObject *obj) { + PyDict_SetItemString(d, name, obj); + Py_DECREF(obj); } #endif /* Append a value to the result obj */ -SWIGINTERN PyObject * -SWIG_Python_AppendOutput(PyObject *result, PyObject *obj) { - if (!result) { - result = obj; - } else if (result == Py_None) { - Py_DECREF(result); - result = obj; - } else { - if (!PyList_Check(result)) { - PyObject *o2 = result; - result = PyList_New(1); - if (result) { - PyList_SET_ITEM(result, 0, o2); - } else { - Py_DECREF(obj); - return o2; - } - } - PyList_Append(result, obj); +SWIGINTERN PyObject* +SWIG_Python_AppendOutput(PyObject* result, PyObject* obj) { + if (!result) { + result = obj; + } else if (result == Py_None) { + Py_DECREF(result); + result = obj; + } else { + if (!PyList_Check(result)) { + PyObject *o2 = result; + result = PyList_New(1); + if (result) { + PyList_SET_ITEM(result, 0, o2); + } else { Py_DECREF(obj); + return o2; + } } - return result; + PyList_Append(result,obj); + Py_DECREF(obj); + } + return result; } /* Unpack the argument tuple */ SWIGINTERN Py_ssize_t -SWIG_Python_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssize_t max, PyObject **objs) { - if (!args) { - if (!min && !max) { - return 1; - } else { - PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got none", - name, (min == max ? "" : "at least "), (int)min); - return 0; - } - } - if (!PyTuple_Check(args)) { - if (min <= 1 && max >= 1) { - Py_ssize_t i; - objs[0] = args; - for (i = 1; i < max; ++i) { - objs[i] = 0; - } - return 2; - } - PyErr_SetString(PyExc_SystemError, "UnpackTuple() argument list is not a tuple"); - return 0; +SWIG_Python_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssize_t max, PyObject **objs) +{ + if (!args) { + if (!min && !max) { + return 1; } else { - Py_ssize_t l = PyTuple_GET_SIZE(args); - if (l < min) { - PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got %d", - name, (min == max ? "" : "at least "), (int)min, (int)l); - return 0; - } else if (l > max) { - PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got %d", - name, (min == max ? "" : "at most "), (int)max, (int)l); - return 0; - } else { - Py_ssize_t i; - for (i = 0; i < l; ++i) { - objs[i] = PyTuple_GET_ITEM(args, i); - } - for (; l < max; ++l) { - objs[l] = 0; - } - return i + 1; - } + PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got none", + name, (min == max ? "" : "at least "), (int)min); + return 0; + } + } + if (!PyTuple_Check(args)) { + if (min <= 1 && max >= 1) { + Py_ssize_t i; + objs[0] = args; + for (i = 1; i < max; ++i) { + objs[i] = 0; + } + return 2; } + PyErr_SetString(PyExc_SystemError, "UnpackTuple() argument list is not a tuple"); + return 0; + } else { + Py_ssize_t l = PyTuple_GET_SIZE(args); + if (l < min) { + PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got %d", + name, (min == max ? "" : "at least "), (int)min, (int)l); + return 0; + } else if (l > max) { + PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got %d", + name, (min == max ? "" : "at most "), (int)max, (int)l); + return 0; + } else { + Py_ssize_t i; + for (i = 0; i < l; ++i) { + objs[i] = PyTuple_GET_ITEM(args, i); + } + for (; l < max; ++l) { + objs[l] = 0; + } + return i + 1; + } + } } SWIGINTERN int SWIG_Python_CheckNoKeywords(PyObject *kwargs, const char *name) { - int no_kwargs = 1; - if (kwargs) { - assert(PyDict_Check(kwargs)); - if (PyDict_Size(kwargs) > 0) { - PyErr_Format(PyExc_TypeError, "%s() does not take keyword arguments", name); - no_kwargs = 0; - } + int no_kwargs = 1; + if (kwargs) { + assert(PyDict_Check(kwargs)); + if (PyDict_Size(kwargs) > 0) { + PyErr_Format(PyExc_TypeError, "%s() does not take keyword arguments", name); + no_kwargs = 0; } - return no_kwargs; + } + return no_kwargs; } /* A functor is a function object with one single object argument */ @@ -1327,247 +1334,247 @@ extern "C" { #define SWIG_newvarlink() SWIG_Python_newvarlink() #define SWIG_addvarlink(p, name, get_attr, set_attr) SWIG_Python_addvarlink(p, name, get_attr, set_attr) #define SWIG_InstallConstants(d, constants) SWIG_Python_InstallConstants(d, constants) - + /* ----------------------------------------------------------------------------- * global variable support code. * ----------------------------------------------------------------------------- */ - -typedef struct swig_globalvar { - char *name; /* Name of global variable */ - PyObject *(*get_attr)(void); /* Return the current value */ - int (*set_attr)(PyObject *); /* Set the value */ - struct swig_globalvar *next; + +typedef struct swig_globalvar { + char *name; /* Name of global variable */ + PyObject *(*get_attr)(void); /* Return the current value */ + int (*set_attr)(PyObject *); /* Set the value */ + struct swig_globalvar *next; } swig_globalvar; typedef struct swig_varlinkobject { - PyObject_HEAD - swig_globalvar *vars; + PyObject_HEAD + swig_globalvar *vars; } swig_varlinkobject; SWIGINTERN PyObject * swig_varlink_repr(PyObject *SWIGUNUSEDPARM(v)) { #if PY_VERSION_HEX >= 0x03000000 - return PyUnicode_InternFromString(""); + return PyUnicode_InternFromString(""); #else - return PyString_FromString(""); + return PyString_FromString(""); #endif } SWIGINTERN PyObject * swig_varlink_str(PyObject *o) { - swig_varlinkobject *v = (swig_varlinkobject *) o; + swig_varlinkobject *v = (swig_varlinkobject *) o; #if PY_VERSION_HEX >= 0x03000000 - PyObject *str = PyUnicode_InternFromString("("); - PyObject *tail; - PyObject *joined; - swig_globalvar *var; - for (var = v->vars; var; var = var->next) { - tail = PyUnicode_FromString(var->name); + PyObject *str = PyUnicode_InternFromString("("); + PyObject *tail; + PyObject *joined; + swig_globalvar *var; + for (var = v->vars; var; var=var->next) { + tail = PyUnicode_FromString(var->name); + joined = PyUnicode_Concat(str, tail); + Py_DecRef(str); + Py_DecRef(tail); + str = joined; + if (var->next) { + tail = PyUnicode_InternFromString(", "); joined = PyUnicode_Concat(str, tail); Py_DecRef(str); Py_DecRef(tail); str = joined; - if (var->next) { - tail = PyUnicode_InternFromString(", "); - joined = PyUnicode_Concat(str, tail); - Py_DecRef(str); - Py_DecRef(tail); - str = joined; - } } - tail = PyUnicode_InternFromString(")"); - joined = PyUnicode_Concat(str, tail); - Py_DecRef(str); - Py_DecRef(tail); - str = joined; + } + tail = PyUnicode_InternFromString(")"); + joined = PyUnicode_Concat(str, tail); + Py_DecRef(str); + Py_DecRef(tail); + str = joined; #else - PyObject *str = PyString_FromString("("); - swig_globalvar *var; - for (var = v->vars; var; var = var->next) { - PyString_ConcatAndDel(&str, PyString_FromString(var->name)); - if (var->next) PyString_ConcatAndDel(&str, PyString_FromString(", ")); - } - PyString_ConcatAndDel(&str, PyString_FromString(")")); + PyObject *str = PyString_FromString("("); + swig_globalvar *var; + for (var = v->vars; var; var=var->next) { + PyString_ConcatAndDel(&str,PyString_FromString(var->name)); + if (var->next) PyString_ConcatAndDel(&str,PyString_FromString(", ")); + } + PyString_ConcatAndDel(&str,PyString_FromString(")")); #endif - return str; + return str; } SWIGINTERN void swig_varlink_dealloc(PyObject *o) { - swig_varlinkobject *v = (swig_varlinkobject *) o; - swig_globalvar *var = v->vars; - while (var) { - swig_globalvar *n = var->next; - free(var->name); - free(var); - var = n; - } + swig_varlinkobject *v = (swig_varlinkobject *) o; + swig_globalvar *var = v->vars; + while (var) { + swig_globalvar *n = var->next; + free(var->name); + free(var); + var = n; + } } SWIGINTERN PyObject * swig_varlink_getattr(PyObject *o, char *n) { - swig_varlinkobject *v = (swig_varlinkobject *) o; - PyObject *res = NULL; - swig_globalvar *var = v->vars; - while (var) { - if (strcmp(var->name, n) == 0) { - res = (*var->get_attr)(); - break; - } - var = var->next; + swig_varlinkobject *v = (swig_varlinkobject *) o; + PyObject *res = NULL; + swig_globalvar *var = v->vars; + while (var) { + if (strcmp(var->name,n) == 0) { + res = (*var->get_attr)(); + break; } - if (res == NULL && !PyErr_Occurred()) { - PyErr_Format(PyExc_AttributeError, "Unknown C global variable '%s'", n); - } - return res; + var = var->next; + } + if (res == NULL && !PyErr_Occurred()) { + PyErr_Format(PyExc_AttributeError, "Unknown C global variable '%s'", n); + } + return res; } SWIGINTERN int swig_varlink_setattr(PyObject *o, char *n, PyObject *p) { - swig_varlinkobject *v = (swig_varlinkobject *) o; - int res = 1; - swig_globalvar *var = v->vars; - while (var) { - if (strcmp(var->name, n) == 0) { - res = (*var->set_attr)(p); - break; - } - var = var->next; - } - if (res == 1 && !PyErr_Occurred()) { - PyErr_Format(PyExc_AttributeError, "Unknown C global variable '%s'", n); + swig_varlinkobject *v = (swig_varlinkobject *) o; + int res = 1; + swig_globalvar *var = v->vars; + while (var) { + if (strcmp(var->name,n) == 0) { + res = (*var->set_attr)(p); + break; } - return res; + var = var->next; + } + if (res == 1 && !PyErr_Occurred()) { + PyErr_Format(PyExc_AttributeError, "Unknown C global variable '%s'", n); + } + return res; } -SWIGINTERN PyTypeObject * +SWIGINTERN PyTypeObject* swig_varlink_type(void) { - static char varlink__doc__[] = "Swig var link object"; + static char varlink__doc__[] = "Swig var link object"; #ifndef Py_LIMITED_API - static PyTypeObject varlink_type; - static int type_init = 0; - if (!type_init) { - const PyTypeObject tmp = { + static PyTypeObject varlink_type; + static int type_init = 0; + if (!type_init) { + const PyTypeObject tmp = { #if PY_VERSION_HEX >= 0x03000000 - PyVarObject_HEAD_INIT(NULL, 0) + PyVarObject_HEAD_INIT(NULL, 0) #else - PyObject_HEAD_INIT(NULL) - 0, /* ob_size */ + PyObject_HEAD_INIT(NULL) + 0, /* ob_size */ #endif - "swigvarlink", /* tp_name */ - sizeof(swig_varlinkobject), /* tp_basicsize */ - 0, /* tp_itemsize */ - (destructor) swig_varlink_dealloc, /* tp_dealloc */ + "swigvarlink", /* tp_name */ + sizeof(swig_varlinkobject), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor) swig_varlink_dealloc, /* tp_dealloc */ #if PY_VERSION_HEX < 0x030800b4 - (printfunc)0, /*tp_print*/ + (printfunc)0, /*tp_print*/ #else - (Py_ssize_t)0, /*tp_vectorcall_offset*/ -#endif - (getattrfunc) swig_varlink_getattr, /* tp_getattr */ - (setattrfunc) swig_varlink_setattr, /* tp_setattr */ - 0, /* tp_compare */ - (reprfunc) swig_varlink_repr, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - (reprfunc) swig_varlink_str, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - 0, /* tp_flags */ - varlink__doc__, /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* tp_iter -> tp_weaklist */ - 0, /* tp_del */ - 0, /* tp_version_tag */ + (Py_ssize_t)0, /*tp_vectorcall_offset*/ +#endif + (getattrfunc) swig_varlink_getattr, /* tp_getattr */ + (setattrfunc) swig_varlink_setattr, /* tp_setattr */ + 0, /* tp_compare */ + (reprfunc) swig_varlink_repr, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + (reprfunc) swig_varlink_str, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + 0, /* tp_flags */ + varlink__doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* tp_iter -> tp_weaklist */ + 0, /* tp_del */ + 0, /* tp_version_tag */ #if PY_VERSION_HEX >= 0x03040000 - 0, /* tp_finalize */ + 0, /* tp_finalize */ #endif #if PY_VERSION_HEX >= 0x03080000 - 0, /* tp_vectorcall */ + 0, /* tp_vectorcall */ #endif #if (PY_VERSION_HEX >= 0x03080000) && (PY_VERSION_HEX < 0x03090000) - 0, /* tp_print */ + 0, /* tp_print */ #endif #if PY_VERSION_HEX >= 0x030C0000 - 0, /* tp_watched */ + 0, /* tp_watched */ #endif #ifdef COUNT_ALLOCS - 0, /* tp_allocs */ - 0, /* tp_frees */ - 0, /* tp_maxalloc */ - 0, /* tp_prev */ - 0 /* tp_next */ -#endif - }; - varlink_type = tmp; - type_init = 1; - if (PyType_Ready(&varlink_type) < 0) - return NULL; - } - return &varlink_type; -#else - PyType_Slot slots[] = { - { Py_tp_dealloc, (void *)swig_varlink_dealloc }, - { Py_tp_repr, (void *)swig_varlink_repr }, - { Py_tp_getattr, (void *)swig_varlink_getattr }, - { Py_tp_setattr, (void *)swig_varlink_setattr }, - { Py_tp_str, (void *)swig_varlink_str }, - { Py_tp_doc, (void *)varlink__doc__ }, - { 0, NULL } - }; - PyType_Spec spec = { - "swigvarlink", - sizeof(swig_varlinkobject), - 0, - Py_TPFLAGS_DEFAULT, - slots + 0, /* tp_allocs */ + 0, /* tp_frees */ + 0, /* tp_maxalloc */ + 0, /* tp_prev */ + 0 /* tp_next */ +#endif }; - return (PyTypeObject *)PyType_FromSpec(&spec); + varlink_type = tmp; + type_init = 1; + if (PyType_Ready(&varlink_type) < 0) + return NULL; + } + return &varlink_type; +#else + PyType_Slot slots[] = { + { Py_tp_dealloc, (void *)swig_varlink_dealloc }, + { Py_tp_repr, (void *)swig_varlink_repr }, + { Py_tp_getattr, (void *)swig_varlink_getattr }, + { Py_tp_setattr, (void *)swig_varlink_setattr }, + { Py_tp_str, (void *)swig_varlink_str }, + { Py_tp_doc, (void *)varlink__doc__ }, + { 0, NULL } + }; + PyType_Spec spec = { + "swigvarlink", + sizeof(swig_varlinkobject), + 0, + Py_TPFLAGS_DEFAULT, + slots + }; + return (PyTypeObject *)PyType_FromSpec(&spec); #endif } /* Create a variable linking object for use later */ SWIGINTERN PyObject * SWIG_Python_newvarlink(void) { - swig_varlinkobject *result = PyObject_New(swig_varlinkobject, swig_varlink_type()); - if (result) { - result->vars = 0; - } - return ((PyObject *) result); -} - -SWIGINTERN void -SWIG_Python_addvarlink(PyObject *p, const char *name, PyObject * (*get_attr)(void), int (*set_attr)(PyObject *p)) { - swig_varlinkobject *v = (swig_varlinkobject *) p; - swig_globalvar *gv = (swig_globalvar *) malloc(sizeof(swig_globalvar)); - if (gv) { - size_t size = strlen(name) + 1; - gv->name = (char *)malloc(size); - if (gv->name) { - memcpy(gv->name, name, size); - gv->get_attr = get_attr; - gv->set_attr = set_attr; - gv->next = v->vars; - } + swig_varlinkobject *result = PyObject_New(swig_varlinkobject, swig_varlink_type()); + if (result) { + result->vars = 0; + } + return ((PyObject*) result); +} + +SWIGINTERN void +SWIG_Python_addvarlink(PyObject *p, const char *name, PyObject *(*get_attr)(void), int (*set_attr)(PyObject *p)) { + swig_varlinkobject *v = (swig_varlinkobject *) p; + swig_globalvar *gv = (swig_globalvar *) malloc(sizeof(swig_globalvar)); + if (gv) { + size_t size = strlen(name)+1; + gv->name = (char *)malloc(size); + if (gv->name) { + memcpy(gv->name, name, size); + gv->get_attr = get_attr; + gv->set_attr = set_attr; + gv->next = v->vars; } - v->vars = gv; + } + v->vars = gv; } static PyObject *Swig_Globals_global = NULL; - + SWIGINTERN PyObject * SWIG_globals(void) { - if (Swig_Globals_global == NULL) { - Swig_Globals_global = SWIG_newvarlink(); - } - return Swig_Globals_global; + if (Swig_Globals_global == NULL) { + Swig_Globals_global = SWIG_newvarlink(); + } + return Swig_Globals_global; } #ifdef __cplusplus @@ -1593,110 +1600,114 @@ extern "C" { /* The python void return value */ -SWIGRUNTIMEINLINE PyObject * -SWIG_Py_Void(void) { - PyObject *none = Py_None; - Py_INCREF(none); - return none; +SWIGRUNTIMEINLINE PyObject * +SWIG_Py_Void(void) +{ + PyObject *none = Py_None; + Py_INCREF(none); + return none; } /* SwigPyClientData */ typedef struct { - PyObject *klass; - PyObject *newraw; - PyObject *newargs; - PyObject *destroy; - int delargs; - int implicitconv; - PyTypeObject *pytype; + PyObject *klass; + PyObject *newraw; + PyObject *newargs; + PyObject *destroy; + int delargs; + int implicitconv; + PyTypeObject *pytype; } SwigPyClientData; -SWIGRUNTIMEINLINE int -SWIG_Python_CheckImplicit(swig_type_info *ty) { - SwigPyClientData *data = (SwigPyClientData *)ty->clientdata; - int fail = data ? data->implicitconv : 0; - if (fail) - PyErr_SetString(PyExc_TypeError, "Implicit conversion is prohibited for explicit constructors."); - return fail; +SWIGRUNTIMEINLINE int +SWIG_Python_CheckImplicit(swig_type_info *ty) +{ + SwigPyClientData *data = (SwigPyClientData *)ty->clientdata; + int fail = data ? data->implicitconv : 0; + if (fail) + PyErr_SetString(PyExc_TypeError, "Implicit conversion is prohibited for explicit constructors."); + return fail; } SWIGRUNTIMEINLINE PyObject * SWIG_Python_ExceptionType(swig_type_info *desc) { - SwigPyClientData *data = desc ? (SwigPyClientData *) desc->clientdata : 0; - PyObject *klass = data ? data->klass : 0; - return (klass ? klass : PyExc_RuntimeError); + SwigPyClientData *data = desc ? (SwigPyClientData *) desc->clientdata : 0; + PyObject *klass = data ? data->klass : 0; + return (klass ? klass : PyExc_RuntimeError); } -SWIGRUNTIME SwigPyClientData * -SwigPyClientData_New(PyObject *obj) { - if (!obj) { - return 0; +SWIGRUNTIME SwigPyClientData * +SwigPyClientData_New(PyObject* obj) +{ + if (!obj) { + return 0; + } else { + SwigPyClientData *data = (SwigPyClientData *)malloc(sizeof(SwigPyClientData)); + /* the klass element */ + data->klass = obj; + Py_INCREF(data->klass); + /* the newraw method and newargs arguments used to create a new raw instance */ + if (PyClass_Check(obj)) { + data->newraw = 0; + Py_INCREF(obj); + data->newargs = obj; } else { - SwigPyClientData *data = (SwigPyClientData *)malloc(sizeof(SwigPyClientData)); - /* the klass element */ - data->klass = obj; - Py_INCREF(data->klass); - /* the newraw method and newargs arguments used to create a new raw instance */ - if (PyClass_Check(obj)) { - data->newraw = 0; - Py_INCREF(obj); - data->newargs = obj; - } else { - data->newraw = PyObject_GetAttrString(data->klass, "__new__"); - if (data->newraw) { - data->newargs = PyTuple_New(1); - if (data->newargs) { - Py_INCREF(obj); - PyTuple_SET_ITEM(data->newargs, 0, obj); - } else { - Py_DECREF(data->newraw); - Py_DECREF(data->klass); - free(data); - return 0; - } - } else { - Py_INCREF(obj); - data->newargs = obj; - } - } - /* the destroy method, aka as the C++ delete method */ - data->destroy = PyObject_GetAttrString(data->klass, "__swig_destroy__"); - if (PyErr_Occurred()) { - PyErr_Clear(); - data->destroy = 0; - } - if (data->destroy) { - data->delargs = !(PyCFunction_GET_FLAGS(data->destroy) & METH_O); + data->newraw = PyObject_GetAttrString(data->klass, "__new__"); + if (data->newraw) { + data->newargs = PyTuple_New(1); + if (data->newargs) { + Py_INCREF(obj); + PyTuple_SET_ITEM(data->newargs, 0, obj); } else { - data->delargs = 0; + Py_DECREF(data->newraw); + Py_DECREF(data->klass); + free(data); + return 0; } - data->implicitconv = 0; - data->pytype = 0; - return data; + } else { + Py_INCREF(obj); + data->newargs = obj; + } } + /* the destroy method, aka as the C++ delete method */ + data->destroy = PyObject_GetAttrString(data->klass, "__swig_destroy__"); + if (PyErr_Occurred()) { + PyErr_Clear(); + data->destroy = 0; + } + if (data->destroy) { + data->delargs = !(PyCFunction_GET_FLAGS(data->destroy) & METH_O); + } else { + data->delargs = 0; + } + data->implicitconv = 0; + data->pytype = 0; + return data; + } } -SWIGRUNTIME void -SwigPyClientData_Del(SwigPyClientData *data) { - Py_XDECREF(data->klass); - Py_XDECREF(data->newraw); - Py_XDECREF(data->newargs); - Py_XDECREF(data->destroy); - free(data); +SWIGRUNTIME void +SwigPyClientData_Del(SwigPyClientData *data) +{ + Py_XDECREF(data->klass); + Py_XDECREF(data->newraw); + Py_XDECREF(data->newargs); + Py_XDECREF(data->destroy); + free(data); } /* =============== SwigPyObject =====================*/ typedef struct { - PyObject_HEAD - void *ptr; - swig_type_info *ty; - int own; - PyObject *next; + PyObject_HEAD + void *ptr; + swig_type_info *ty; + int own; + PyObject *next; #ifdef SWIGPYTHON_BUILTIN - PyObject *dict; + PyObject *dict; #endif } SwigPyObject; @@ -1704,151 +1715,160 @@ typedef struct { #ifdef SWIGPYTHON_BUILTIN SWIGRUNTIME PyObject * -SwigPyObject_get___dict__(PyObject *v, PyObject *SWIGUNUSEDPARM(args)) { - SwigPyObject *sobj = (SwigPyObject *)v; +SwigPyObject_get___dict__(PyObject *v, PyObject *SWIGUNUSEDPARM(args)) +{ + SwigPyObject *sobj = (SwigPyObject *)v; - if (!sobj->dict) - sobj->dict = PyDict_New(); + if (!sobj->dict) + sobj->dict = PyDict_New(); - Py_XINCREF(sobj->dict); - return sobj->dict; + Py_XINCREF(sobj->dict); + return sobj->dict; } #endif SWIGRUNTIME PyObject * -SwigPyObject_long(SwigPyObject *v) { - return PyLong_FromVoidPtr(v->ptr); +SwigPyObject_long(SwigPyObject *v) +{ + return PyLong_FromVoidPtr(v->ptr); } SWIGRUNTIME PyObject * -SwigPyObject_format(const char *fmt, SwigPyObject *v) { - PyObject *res = NULL; - PyObject *args = PyTuple_New(1); - if (args) { - PyObject *val = SwigPyObject_long(v); - if (val) { - PyObject *ofmt; - PyTuple_SET_ITEM(args, 0, val); - ofmt = SWIG_Python_str_FromChar(fmt); - if (ofmt) { +SwigPyObject_format(const char* fmt, SwigPyObject *v) +{ + PyObject *res = NULL; + PyObject *args = PyTuple_New(1); + if (args) { + PyObject *val = SwigPyObject_long(v); + if (val) { + PyObject *ofmt; + PyTuple_SET_ITEM(args, 0, val); + ofmt = SWIG_Python_str_FromChar(fmt); + if (ofmt) { #if PY_VERSION_HEX >= 0x03000000 - res = PyUnicode_Format(ofmt, args); + res = PyUnicode_Format(ofmt,args); #else - res = PyString_Format(ofmt, args); + res = PyString_Format(ofmt,args); #endif - Py_DECREF(ofmt); - } - } - Py_DECREF(args); + Py_DECREF(ofmt); + } } - return res; + Py_DECREF(args); + } + return res; } SWIGRUNTIME PyObject * -SwigPyObject_oct(SwigPyObject *v) { - return SwigPyObject_format("%o", v); +SwigPyObject_oct(SwigPyObject *v) +{ + return SwigPyObject_format("%o",v); } SWIGRUNTIME PyObject * -SwigPyObject_hex(SwigPyObject *v) { - return SwigPyObject_format("%x", v); +SwigPyObject_hex(SwigPyObject *v) +{ + return SwigPyObject_format("%x",v); } SWIGRUNTIME PyObject * -SwigPyObject_repr(SwigPyObject *v) { - const char *name = SWIG_TypePrettyName(v->ty); - PyObject *repr = SWIG_Python_str_FromFormat("", (name ? name : "unknown"), (void *)v); - if (repr && v->next) { - PyObject *nrep = SwigPyObject_repr((SwigPyObject *)v->next); - if (nrep) { +SwigPyObject_repr(SwigPyObject *v) +{ + const char *name = SWIG_TypePrettyName(v->ty); + PyObject *repr = SWIG_Python_str_FromFormat("", (name ? name : "unknown"), (void *)v); + if (repr && v->next) { + PyObject *nrep = SwigPyObject_repr((SwigPyObject *)v->next); + if (nrep) { # if PY_VERSION_HEX >= 0x03000000 - PyObject *joined = PyUnicode_Concat(repr, nrep); - Py_DecRef(repr); - Py_DecRef(nrep); - repr = joined; + PyObject *joined = PyUnicode_Concat(repr, nrep); + Py_DecRef(repr); + Py_DecRef(nrep); + repr = joined; # else - PyString_ConcatAndDel(&repr, nrep); + PyString_ConcatAndDel(&repr,nrep); # endif - } else { - Py_DecRef(repr); - repr = NULL; - } + } else { + Py_DecRef(repr); + repr = NULL; } - return repr; + } + return repr; } /* We need a version taking two PyObject* parameters so it's a valid * PyCFunction to use in swigobject_methods[]. */ SWIGRUNTIME PyObject * -SwigPyObject_repr2(PyObject *v, PyObject *SWIGUNUSEDPARM(args)) { - return SwigPyObject_repr((SwigPyObject *)v); +SwigPyObject_repr2(PyObject *v, PyObject *SWIGUNUSEDPARM(args)) +{ + return SwigPyObject_repr((SwigPyObject*)v); } SWIGRUNTIME int -SwigPyObject_compare(SwigPyObject *v, SwigPyObject *w) { - void *i = v->ptr; - void *j = w->ptr; - return (i < j) ? -1 : ((i > j) ? 1 : 0); +SwigPyObject_compare(SwigPyObject *v, SwigPyObject *w) +{ + void *i = v->ptr; + void *j = w->ptr; + return (i < j) ? -1 : ((i > j) ? 1 : 0); } /* Added for Python 3.x, would it also be useful for Python 2.x? */ -SWIGRUNTIME PyObject * -SwigPyObject_richcompare(SwigPyObject *v, SwigPyObject *w, int op) { - PyObject *res = NULL; - if (!PyErr_Occurred()) { - if (op != Py_EQ && op != Py_NE) { - Py_INCREF(Py_NotImplemented); - return Py_NotImplemented; - } - res = PyBool_FromLong((SwigPyObject_compare(v, w) == 0) == (op == Py_EQ) ? 1 : 0); +SWIGRUNTIME PyObject* +SwigPyObject_richcompare(SwigPyObject *v, SwigPyObject *w, int op) +{ + PyObject* res = NULL; + if (!PyErr_Occurred()) { + if (op != Py_EQ && op != Py_NE) { + Py_INCREF(Py_NotImplemented); + return Py_NotImplemented; } - return res; + res = PyBool_FromLong( (SwigPyObject_compare(v, w)==0) == (op == Py_EQ) ? 1 : 0); + } + return res; } -SWIGRUNTIME PyTypeObject *SwigPyObject_TypeOnce(void); +SWIGRUNTIME PyTypeObject* SwigPyObject_TypeOnce(void); #ifdef SWIGPYTHON_BUILTIN static swig_type_info *SwigPyObject_stype = 0; -SWIGRUNTIME PyTypeObject * +SWIGRUNTIME PyTypeObject* SwigPyObject_type(void) { SwigPyClientData *cd; assert(SwigPyObject_stype); - cd = (SwigPyClientData *) SwigPyObject_stype->clientdata; + cd = (SwigPyClientData*) SwigPyObject_stype->clientdata; assert(cd); assert(cd->pytype); return cd->pytype; } #else -SWIGRUNTIME PyTypeObject * +SWIGRUNTIME PyTypeObject* SwigPyObject_type(void) { - static PyTypeObject *SWIG_STATIC_POINTER(type) = SwigPyObject_TypeOnce(); - return type; + static PyTypeObject *SWIG_STATIC_POINTER(type) = SwigPyObject_TypeOnce(); + return type; } #endif SWIGRUNTIMEINLINE int SwigPyObject_Check(PyObject *op) { - PyTypeObject *target_tp = SwigPyObject_type(); - PyTypeObject *op_type = Py_TYPE(op); + PyTypeObject *target_tp = SwigPyObject_type(); + PyTypeObject *op_type = Py_TYPE(op); #ifdef SWIGPYTHON_BUILTIN - if (PyType_IsSubtype(op_type, target_tp)) - return 1; - return (strcmp(op_type->tp_name, "SwigPyObject") == 0); + if (PyType_IsSubtype(op_type, target_tp)) + return 1; + return (strcmp(op_type->tp_name, "SwigPyObject") == 0); #else - if (op_type == target_tp) - return 1; + if (op_type == target_tp) + return 1; # ifdef Py_LIMITED_API - int cmp; - PyObject *tp_name = PyObject_GetAttrString((PyObject *)op_type, "__name__"); - if (!tp_name) - return 0; - cmp = PyUnicode_CompareWithASCIIString(tp_name, "SwigPyObject"); - Py_DECREF(tp_name); - return cmp == 0; + int cmp; + PyObject *tp_name = PyObject_GetAttrString((PyObject *)op_type, "__name__"); + if (!tp_name) + return 0; + cmp = PyUnicode_CompareWithASCIIString(tp_name, "SwigPyObject"); + Py_DECREF(tp_name); + return cmp == 0; # else - return (strcmp(op_type->tp_name, "SwigPyObject") == 0); + return (strcmp(op_type->tp_name, "SwigPyObject") == 0); # endif #endif } @@ -1856,313 +1876,320 @@ SwigPyObject_Check(PyObject *op) { SWIGRUNTIME PyObject * SwigPyObject_New(void *ptr, swig_type_info *ty, int own); -static PyObject *Swig_Capsule_global = NULL; +static PyObject* Swig_Capsule_global = NULL; SWIGRUNTIME void -SwigPyObject_dealloc(PyObject *v) { - SwigPyObject *sobj = (SwigPyObject *) v; - PyObject *next = sobj->next; - if (sobj->own == SWIG_POINTER_OWN) { - swig_type_info *ty = sobj->ty; - SwigPyClientData *data = ty ? (SwigPyClientData *) ty->clientdata : 0; - PyObject *destroy = data ? data->destroy : 0; - if (destroy) { - /* destroy is always a VARARGS method */ - PyObject *res; - - /* PyObject_CallFunction() has the potential to silently drop - the active exception. In cases of unnamed temporary - variable or where we just finished iterating over a generator - StopIteration will be active right now, and this needs to - remain true upon return from SwigPyObject_dealloc. So save - and restore. */ - - PyObject *type = NULL, *value = NULL, *traceback = NULL; - PyErr_Fetch(&type, &value, &traceback); - - if (data->delargs) { - /* we need to create a temporary object to carry the destroy operation */ - PyObject *tmp = SwigPyObject_New(sobj->ptr, ty, 0); - if (tmp) { - res = SWIG_Python_CallFunctor(destroy, tmp); - } else { - res = 0; - } - Py_XDECREF(tmp); - } else { - PyCFunction meth = PyCFunction_GET_FUNCTION(destroy); - PyObject *mself = PyCFunction_GET_SELF(destroy); - res = ((*meth)(mself, v)); - } - if (!res) - PyErr_WriteUnraisable(destroy); +SwigPyObject_dealloc(PyObject *v) +{ + SwigPyObject *sobj = (SwigPyObject *) v; + PyObject *next = sobj->next; + if (sobj->own == SWIG_POINTER_OWN) { + swig_type_info *ty = sobj->ty; + SwigPyClientData *data = ty ? (SwigPyClientData *) ty->clientdata : 0; + PyObject *destroy = data ? data->destroy : 0; + if (destroy) { + /* destroy is always a VARARGS method */ + PyObject *res; + + /* PyObject_CallFunction() has the potential to silently drop + the active exception. In cases of unnamed temporary + variable or where we just finished iterating over a generator + StopIteration will be active right now, and this needs to + remain true upon return from SwigPyObject_dealloc. So save + and restore. */ + + PyObject *type = NULL, *value = NULL, *traceback = NULL; + PyErr_Fetch(&type, &value, &traceback); + + if (data->delargs) { + /* we need to create a temporary object to carry the destroy operation */ + PyObject *tmp = SwigPyObject_New(sobj->ptr, ty, 0); + if (tmp) { + res = SWIG_Python_CallFunctor(destroy, tmp); + } else { + res = 0; + } + Py_XDECREF(tmp); + } else { + PyCFunction meth = PyCFunction_GET_FUNCTION(destroy); + PyObject *mself = PyCFunction_GET_SELF(destroy); + res = ((*meth)(mself, v)); + } + if (!res) + PyErr_WriteUnraisable(destroy); - PyErr_Restore(type, value, traceback); + PyErr_Restore(type, value, traceback); - Py_XDECREF(res); - } + Py_XDECREF(res); + } #if !defined(SWIG_PYTHON_SILENT_MEMLEAK) - else { - const char *name = SWIG_TypePrettyName(ty); - printf("swig/python detected a memory leak of type '%s', no destructor found.\n", (name ? name : "unknown")); - } -#endif - Py_XDECREF(Swig_Capsule_global); + else { + const char *name = SWIG_TypePrettyName(ty); + printf("swig/python detected a memory leak of type '%s', no destructor found.\n", (name ? name : "unknown")); } - Py_XDECREF(next); +#endif + Py_XDECREF(Swig_Capsule_global); + } + Py_XDECREF(next); #ifdef SWIGPYTHON_BUILTIN - Py_XDECREF(sobj->dict); + Py_XDECREF(sobj->dict); #endif - PyObject_DEL(v); + PyObject_DEL(v); } -SWIGRUNTIME PyObject * -SwigPyObject_append(PyObject *v, PyObject *next) { - SwigPyObject *sobj = (SwigPyObject *) v; - if (!SwigPyObject_Check(next)) { - PyErr_SetString(PyExc_TypeError, "Attempt to append a non SwigPyObject"); - return NULL; - } - ((SwigPyObject *)next)->next = sobj->next; - sobj->next = next; - Py_INCREF(next); - return SWIG_Py_Void(); +SWIGRUNTIME PyObject* +SwigPyObject_append(PyObject* v, PyObject* next) +{ + SwigPyObject *sobj = (SwigPyObject *) v; + if (!SwigPyObject_Check(next)) { + PyErr_SetString(PyExc_TypeError, "Attempt to append a non SwigPyObject"); + return NULL; + } + ((SwigPyObject *)next)->next = sobj->next; + sobj->next = next; + Py_INCREF(next); + return SWIG_Py_Void(); } -SWIGRUNTIME PyObject * -SwigPyObject_next(PyObject *v, PyObject *SWIGUNUSEDPARM(args)) { - SwigPyObject *sobj = (SwigPyObject *) v; - if (sobj->next) { - Py_INCREF(sobj->next); - return sobj->next; - } else { - return SWIG_Py_Void(); - } +SWIGRUNTIME PyObject* +SwigPyObject_next(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) +{ + SwigPyObject *sobj = (SwigPyObject *) v; + if (sobj->next) { + Py_INCREF(sobj->next); + return sobj->next; + } else { + return SWIG_Py_Void(); + } } -SWIGINTERN PyObject * -SwigPyObject_disown(PyObject *v, PyObject *SWIGUNUSEDPARM(args)) { - SwigPyObject *sobj = (SwigPyObject *)v; - sobj->own = 0; - return SWIG_Py_Void(); +SWIGINTERN PyObject* +SwigPyObject_disown(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) +{ + SwigPyObject *sobj = (SwigPyObject *)v; + sobj->own = 0; + return SWIG_Py_Void(); } -SWIGINTERN PyObject * -SwigPyObject_acquire(PyObject *v, PyObject *SWIGUNUSEDPARM(args)) { - SwigPyObject *sobj = (SwigPyObject *)v; - sobj->own = SWIG_POINTER_OWN; - return SWIG_Py_Void(); +SWIGINTERN PyObject* +SwigPyObject_acquire(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) +{ + SwigPyObject *sobj = (SwigPyObject *)v; + sobj->own = SWIG_POINTER_OWN; + return SWIG_Py_Void(); } -SWIGINTERN PyObject * -SwigPyObject_own(PyObject *v, PyObject *args) { - PyObject *val = 0; - if (!PyArg_UnpackTuple(args, "own", 0, 1, &val)) { - return NULL; - } else { - SwigPyObject *sobj = (SwigPyObject *)v; - PyObject *obj = PyBool_FromLong(sobj->own); - if (val) { - if (PyObject_IsTrue(val)) { - Py_DECREF(SwigPyObject_acquire(v, args)); - } else { - Py_DECREF(SwigPyObject_disown(v, args)); - } - } - return obj; - } +SWIGINTERN PyObject* +SwigPyObject_own(PyObject *v, PyObject *args) +{ + PyObject *val = 0; + if (!PyArg_UnpackTuple(args, "own", 0, 1, &val)) { + return NULL; + } else { + SwigPyObject *sobj = (SwigPyObject *)v; + PyObject *obj = PyBool_FromLong(sobj->own); + if (val) { + if (PyObject_IsTrue(val)) { + Py_DECREF(SwigPyObject_acquire(v,args)); + } else { + Py_DECREF(SwigPyObject_disown(v,args)); + } + } + return obj; + } } static PyMethodDef swigobject_methods[] = { - {"disown", SwigPyObject_disown, METH_NOARGS, "releases ownership of the pointer"}, - {"acquire", SwigPyObject_acquire, METH_NOARGS, "acquires ownership of the pointer"}, - {"own", SwigPyObject_own, METH_VARARGS, "returns/sets ownership of the pointer"}, - {"append", SwigPyObject_append, METH_O, "appends another 'this' object"}, - {"next", SwigPyObject_next, METH_NOARGS, "returns the next 'this' object"}, - {"__repr__", SwigPyObject_repr2, METH_NOARGS, "returns object representation"}, - {0, 0, 0, 0} + {"disown", SwigPyObject_disown, METH_NOARGS, "releases ownership of the pointer"}, + {"acquire", SwigPyObject_acquire, METH_NOARGS, "acquires ownership of the pointer"}, + {"own", SwigPyObject_own, METH_VARARGS, "returns/sets ownership of the pointer"}, + {"append", SwigPyObject_append, METH_O, "appends another 'this' object"}, + {"next", SwigPyObject_next, METH_NOARGS, "returns the next 'this' object"}, + {"__repr__",SwigPyObject_repr2, METH_NOARGS, "returns object representation"}, + {0, 0, 0, 0} }; -SWIGRUNTIME PyTypeObject * +SWIGRUNTIME PyTypeObject* SwigPyObject_TypeOnce(void) { - static char swigobject_doc[] = "Swig object carries a C/C++ instance pointer"; + static char swigobject_doc[] = "Swig object carries a C/C++ instance pointer"; #ifndef Py_LIMITED_API - static PyNumberMethods SwigPyObject_as_number = { - (binaryfunc)0, /*nb_add*/ - (binaryfunc)0, /*nb_subtract*/ - (binaryfunc)0, /*nb_multiply*/ - /* nb_divide removed in Python 3 */ + static PyNumberMethods SwigPyObject_as_number = { + (binaryfunc)0, /*nb_add*/ + (binaryfunc)0, /*nb_subtract*/ + (binaryfunc)0, /*nb_multiply*/ + /* nb_divide removed in Python 3 */ #if PY_VERSION_HEX < 0x03000000 - (binaryfunc)0, /*nb_divide*/ -#endif - (binaryfunc)0, /*nb_remainder*/ - (binaryfunc)0, /*nb_divmod*/ - (ternaryfunc)0,/*nb_power*/ - (unaryfunc)0, /*nb_negative*/ - (unaryfunc)0, /*nb_positive*/ - (unaryfunc)0, /*nb_absolute*/ - (inquiry)0, /*nb_nonzero*/ - 0, /*nb_invert*/ - 0, /*nb_lshift*/ - 0, /*nb_rshift*/ - 0, /*nb_and*/ - 0, /*nb_xor*/ - 0, /*nb_or*/ + (binaryfunc)0, /*nb_divide*/ +#endif + (binaryfunc)0, /*nb_remainder*/ + (binaryfunc)0, /*nb_divmod*/ + (ternaryfunc)0,/*nb_power*/ + (unaryfunc)0, /*nb_negative*/ + (unaryfunc)0, /*nb_positive*/ + (unaryfunc)0, /*nb_absolute*/ + (inquiry)0, /*nb_nonzero*/ + 0, /*nb_invert*/ + 0, /*nb_lshift*/ + 0, /*nb_rshift*/ + 0, /*nb_and*/ + 0, /*nb_xor*/ + 0, /*nb_or*/ #if PY_VERSION_HEX < 0x03000000 - 0, /*nb_coerce*/ + 0, /*nb_coerce*/ #endif - (unaryfunc)SwigPyObject_long, /*nb_int*/ + (unaryfunc)SwigPyObject_long, /*nb_int*/ #if PY_VERSION_HEX < 0x03000000 - (unaryfunc)SwigPyObject_long, /*nb_long*/ + (unaryfunc)SwigPyObject_long, /*nb_long*/ #else - 0, /*nb_reserved*/ + 0, /*nb_reserved*/ #endif - (unaryfunc)0, /*nb_float*/ + (unaryfunc)0, /*nb_float*/ #if PY_VERSION_HEX < 0x03000000 - (unaryfunc)SwigPyObject_oct, /*nb_oct*/ - (unaryfunc)SwigPyObject_hex, /*nb_hex*/ + (unaryfunc)SwigPyObject_oct, /*nb_oct*/ + (unaryfunc)SwigPyObject_hex, /*nb_hex*/ #endif #if PY_VERSION_HEX >= 0x03050000 /* 3.5 */ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 /* nb_inplace_add -> nb_inplace_matrix_multiply */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_matrix_multiply */ #elif PY_VERSION_HEX >= 0x03000000 /* 3.0 */ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 /* nb_inplace_add -> nb_index, nb_inplace_divide removed */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_index, nb_inplace_divide removed */ #else - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 /* nb_inplace_add -> nb_index */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_index */ #endif - }; + }; - static PyTypeObject swigpyobject_type; - static int type_init = 0; - if (!type_init) { - const PyTypeObject tmp = { + static PyTypeObject swigpyobject_type; + static int type_init = 0; + if (!type_init) { + const PyTypeObject tmp = { #if PY_VERSION_HEX >= 0x03000000 - PyVarObject_HEAD_INIT(NULL, 0) + PyVarObject_HEAD_INIT(NULL, 0) #else - PyObject_HEAD_INIT(NULL) - 0, /* ob_size */ + PyObject_HEAD_INIT(NULL) + 0, /* ob_size */ #endif - "SwigPyObject", /* tp_name */ - sizeof(SwigPyObject), /* tp_basicsize */ - 0, /* tp_itemsize */ - (destructor)SwigPyObject_dealloc, /* tp_dealloc */ + "SwigPyObject", /* tp_name */ + sizeof(SwigPyObject), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor)SwigPyObject_dealloc, /* tp_dealloc */ #if PY_VERSION_HEX < 0x030800b4 - (printfunc)0, /*tp_print*/ + (printfunc)0, /*tp_print*/ #else - (Py_ssize_t)0, /*tp_vectorcall_offset*/ + (Py_ssize_t)0, /*tp_vectorcall_offset*/ #endif - (getattrfunc)0, /* tp_getattr */ - (setattrfunc)0, /* tp_setattr */ + (getattrfunc)0, /* tp_getattr */ + (setattrfunc)0, /* tp_setattr */ #if PY_VERSION_HEX >= 0x03000000 - 0, /* tp_reserved in 3.0.1, tp_compare in 3.0.0 but not used */ + 0, /* tp_reserved in 3.0.1, tp_compare in 3.0.0 but not used */ #else - (cmpfunc)SwigPyObject_compare, /* tp_compare */ -#endif - (reprfunc)SwigPyObject_repr, /* tp_repr */ - &SwigPyObject_as_number, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - (hashfunc)0, /* tp_hash */ - (ternaryfunc)0, /* tp_call */ - 0, /* tp_str */ - PyObject_GenericGetAttr, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - swigobject_doc, /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - (richcmpfunc)SwigPyObject_richcompare,/* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - swigobject_methods, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - 0, /* tp_new */ - 0, /* tp_free */ - 0, /* tp_is_gc */ - 0, /* tp_bases */ - 0, /* tp_mro */ - 0, /* tp_cache */ - 0, /* tp_subclasses */ - 0, /* tp_weaklist */ - 0, /* tp_del */ - 0, /* tp_version_tag */ + (cmpfunc)SwigPyObject_compare, /* tp_compare */ +#endif + (reprfunc)SwigPyObject_repr, /* tp_repr */ + &SwigPyObject_as_number, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + (hashfunc)0, /* tp_hash */ + (ternaryfunc)0, /* tp_call */ + 0, /* tp_str */ + PyObject_GenericGetAttr, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + swigobject_doc, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + (richcmpfunc)SwigPyObject_richcompare,/* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + swigobject_methods, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ + 0, /* tp_free */ + 0, /* tp_is_gc */ + 0, /* tp_bases */ + 0, /* tp_mro */ + 0, /* tp_cache */ + 0, /* tp_subclasses */ + 0, /* tp_weaklist */ + 0, /* tp_del */ + 0, /* tp_version_tag */ #if PY_VERSION_HEX >= 0x03040000 - 0, /* tp_finalize */ + 0, /* tp_finalize */ #endif #if PY_VERSION_HEX >= 0x03080000 - 0, /* tp_vectorcall */ + 0, /* tp_vectorcall */ #endif #if (PY_VERSION_HEX >= 0x03080000) && (PY_VERSION_HEX < 0x03090000) - 0, /* tp_print */ + 0, /* tp_print */ #endif #if PY_VERSION_HEX >= 0x030C0000 - 0, /* tp_watched */ + 0, /* tp_watched */ #endif #ifdef COUNT_ALLOCS - 0, /* tp_allocs */ - 0, /* tp_frees */ - 0, /* tp_maxalloc */ - 0, /* tp_prev */ - 0 /* tp_next */ -#endif - }; - swigpyobject_type = tmp; - type_init = 1; - if (PyType_Ready(&swigpyobject_type) != 0) - return NULL; - } - return &swigpyobject_type; -#else - PyType_Slot slots[] = { - { Py_tp_dealloc, (void *)SwigPyObject_dealloc }, - { Py_tp_repr, (void *)SwigPyObject_repr }, - { Py_tp_getattro, (void *)PyObject_GenericGetAttr }, - { Py_tp_doc, (void *)swigobject_doc }, - { Py_tp_richcompare, (void *)SwigPyObject_richcompare }, - { Py_tp_methods, (void *)swigobject_methods }, - { Py_nb_int, (void *)SwigPyObject_long }, - { 0, NULL } - }; - PyType_Spec spec = { - "SwigPyObject", - sizeof(SwigPyObject), - 0, - Py_TPFLAGS_DEFAULT, - slots + 0, /* tp_allocs */ + 0, /* tp_frees */ + 0, /* tp_maxalloc */ + 0, /* tp_prev */ + 0 /* tp_next */ +#endif }; - return (PyTypeObject *)PyType_FromSpec(&spec); + swigpyobject_type = tmp; + type_init = 1; + if (PyType_Ready(&swigpyobject_type) != 0) + return NULL; + } + return &swigpyobject_type; +#else + PyType_Slot slots[] = { + { Py_tp_dealloc, (void *)SwigPyObject_dealloc }, + { Py_tp_repr, (void *)SwigPyObject_repr }, + { Py_tp_getattro, (void *)PyObject_GenericGetAttr }, + { Py_tp_doc, (void *)swigobject_doc }, + { Py_tp_richcompare, (void *)SwigPyObject_richcompare }, + { Py_tp_methods, (void *)swigobject_methods }, + { Py_nb_int, (void *)SwigPyObject_long }, + { 0, NULL } + }; + PyType_Spec spec = { + "SwigPyObject", + sizeof(SwigPyObject), + 0, + Py_TPFLAGS_DEFAULT, + slots + }; + return (PyTypeObject *)PyType_FromSpec(&spec); #endif } SWIGRUNTIME PyObject * -SwigPyObject_New(void *ptr, swig_type_info *ty, int own) { - SwigPyObject *sobj = PyObject_New(SwigPyObject, SwigPyObject_type()); - if (sobj) { - sobj->ptr = ptr; - sobj->ty = ty; - sobj->own = own; - sobj->next = 0; +SwigPyObject_New(void *ptr, swig_type_info *ty, int own) +{ + SwigPyObject *sobj = PyObject_New(SwigPyObject, SwigPyObject_type()); + if (sobj) { + sobj->ptr = ptr; + sobj->ty = ty; + sobj->own = own; + sobj->next = 0; #ifdef SWIGPYTHON_BUILTIN - sobj->dict = 0; + sobj->dict = 0; #endif - if (own == SWIG_POINTER_OWN) { - /* Obtain a reference to the Python capsule wrapping the module information, so that the - * module information is correctly destroyed after all SWIG python objects have been freed - * by the GC (and corresponding destructors invoked) */ - Py_XINCREF(Swig_Capsule_global); - } + if (own == SWIG_POINTER_OWN) { + /* Obtain a reference to the Python capsule wrapping the module information, so that the + * module information is correctly destroyed after all SWIG python objects have been freed + * by the GC (and corresponding destructors invoked) */ + Py_XINCREF(Swig_Capsule_global); } - return (PyObject *)sobj; + } + return (PyObject *)sobj; } /* ----------------------------------------------------------------------------- @@ -2170,217 +2197,223 @@ SwigPyObject_New(void *ptr, swig_type_info *ty, int own) { * ----------------------------------------------------------------------------- */ typedef struct { - PyObject_HEAD - void *pack; - swig_type_info *ty; - size_t size; + PyObject_HEAD + void *pack; + swig_type_info *ty; + size_t size; } SwigPyPacked; SWIGRUNTIME PyObject * -SwigPyPacked_repr(SwigPyPacked *v) { - char result[SWIG_BUFFER_SIZE]; - if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))) { - return SWIG_Python_str_FromFormat("", result, v->ty->name); - } else { - return SWIG_Python_str_FromFormat("", v->ty->name); - } +SwigPyPacked_repr(SwigPyPacked *v) +{ + char result[SWIG_BUFFER_SIZE]; + if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))) { + return SWIG_Python_str_FromFormat("", result, v->ty->name); + } else { + return SWIG_Python_str_FromFormat("", v->ty->name); + } } SWIGRUNTIME PyObject * -SwigPyPacked_str(SwigPyPacked *v) { - char result[SWIG_BUFFER_SIZE]; - if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))) { - return SWIG_Python_str_FromFormat("%s%s", result, v->ty->name); - } else { - return SWIG_Python_str_FromChar(v->ty->name); - } +SwigPyPacked_str(SwigPyPacked *v) +{ + char result[SWIG_BUFFER_SIZE]; + if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))){ + return SWIG_Python_str_FromFormat("%s%s", result, v->ty->name); + } else { + return SWIG_Python_str_FromChar(v->ty->name); + } } SWIGRUNTIME int -SwigPyPacked_compare(SwigPyPacked *v, SwigPyPacked *w) { - size_t i = v->size; - size_t j = w->size; - int s = (i < j) ? -1 : ((i > j) ? 1 : 0); - return s ? s : strncmp((const char *)v->pack, (const char *)w->pack, 2 * v->size); +SwigPyPacked_compare(SwigPyPacked *v, SwigPyPacked *w) +{ + size_t i = v->size; + size_t j = w->size; + int s = (i < j) ? -1 : ((i > j) ? 1 : 0); + return s ? s : strncmp((const char *)v->pack, (const char *)w->pack, 2*v->size); } -SWIGRUNTIME PyTypeObject *SwigPyPacked_TypeOnce(void); +SWIGRUNTIME PyTypeObject* SwigPyPacked_TypeOnce(void); -SWIGRUNTIME PyTypeObject * +SWIGRUNTIME PyTypeObject* SwigPyPacked_type(void) { - static PyTypeObject *SWIG_STATIC_POINTER(type) = SwigPyPacked_TypeOnce(); - return type; + static PyTypeObject *SWIG_STATIC_POINTER(type) = SwigPyPacked_TypeOnce(); + return type; } SWIGRUNTIMEINLINE int SwigPyPacked_Check(PyObject *op) { - PyTypeObject *op_type = Py_TYPE(op); - if (op_type == SwigPyPacked_TypeOnce()) - return 1; + PyTypeObject* op_type = Py_TYPE(op); + if (op_type == SwigPyPacked_TypeOnce()) + return 1; #ifdef Py_LIMITED_API - int cmp; - PyObject *tp_name = PyObject_GetAttrString((PyObject *)op_type, "__name__"); - if (!tp_name) - return 0; - cmp = PyUnicode_CompareWithASCIIString(tp_name, "SwigPyPacked"); - Py_DECREF(tp_name); - return cmp == 0; + int cmp; + PyObject *tp_name = PyObject_GetAttrString((PyObject *)op_type, "__name__"); + if (!tp_name) + return 0; + cmp = PyUnicode_CompareWithASCIIString(tp_name, "SwigPyPacked"); + Py_DECREF(tp_name); + return cmp == 0; #else - return (strcmp(op_type->tp_name, "SwigPyPacked") == 0); + return (strcmp(op_type->tp_name, "SwigPyPacked") == 0); #endif } SWIGRUNTIME void -SwigPyPacked_dealloc(PyObject *v) { - if (SwigPyPacked_Check(v)) { - SwigPyPacked *sobj = (SwigPyPacked *) v; - free(sobj->pack); - } - PyObject_DEL(v); +SwigPyPacked_dealloc(PyObject *v) +{ + if (SwigPyPacked_Check(v)) { + SwigPyPacked *sobj = (SwigPyPacked *) v; + free(sobj->pack); + } + PyObject_DEL(v); } -SWIGRUNTIME PyTypeObject * +SWIGRUNTIME PyTypeObject* SwigPyPacked_TypeOnce(void) { - static char swigpacked_doc[] = "Swig object carries a C/C++ instance pointer"; + static char swigpacked_doc[] = "Swig object carries a C/C++ instance pointer"; #ifndef Py_LIMITED_API - static PyTypeObject swigpypacked_type; - static int type_init = 0; - if (!type_init) { - const PyTypeObject tmp = { + static PyTypeObject swigpypacked_type; + static int type_init = 0; + if (!type_init) { + const PyTypeObject tmp = { #if PY_VERSION_HEX>=0x03000000 - PyVarObject_HEAD_INIT(NULL, 0) + PyVarObject_HEAD_INIT(NULL, 0) #else - PyObject_HEAD_INIT(NULL) - 0, /* ob_size */ + PyObject_HEAD_INIT(NULL) + 0, /* ob_size */ #endif - "SwigPyPacked", /* tp_name */ - sizeof(SwigPyPacked), /* tp_basicsize */ - 0, /* tp_itemsize */ - (destructor)SwigPyPacked_dealloc, /* tp_dealloc */ + "SwigPyPacked", /* tp_name */ + sizeof(SwigPyPacked), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor)SwigPyPacked_dealloc, /* tp_dealloc */ #if PY_VERSION_HEX < 0x030800b4 - (printfunc)0, /*tp_print*/ + (printfunc)0, /*tp_print*/ #else - (Py_ssize_t)0, /*tp_vectorcall_offset*/ + (Py_ssize_t)0, /*tp_vectorcall_offset*/ #endif - (getattrfunc)0, /* tp_getattr */ - (setattrfunc)0, /* tp_setattr */ + (getattrfunc)0, /* tp_getattr */ + (setattrfunc)0, /* tp_setattr */ #if PY_VERSION_HEX>=0x03000000 - 0, /* tp_reserved in 3.0.1 */ + 0, /* tp_reserved in 3.0.1 */ #else - (cmpfunc)SwigPyPacked_compare, /* tp_compare */ -#endif - (reprfunc)SwigPyPacked_repr, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - (hashfunc)0, /* tp_hash */ - (ternaryfunc)0, /* tp_call */ - (reprfunc)SwigPyPacked_str, /* tp_str */ - PyObject_GenericGetAttr, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - swigpacked_doc, /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - 0, /* tp_new */ - 0, /* tp_free */ - 0, /* tp_is_gc */ - 0, /* tp_bases */ - 0, /* tp_mro */ - 0, /* tp_cache */ - 0, /* tp_subclasses */ - 0, /* tp_weaklist */ - 0, /* tp_del */ - 0, /* tp_version_tag */ + (cmpfunc)SwigPyPacked_compare, /* tp_compare */ +#endif + (reprfunc)SwigPyPacked_repr, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + (hashfunc)0, /* tp_hash */ + (ternaryfunc)0, /* tp_call */ + (reprfunc)SwigPyPacked_str, /* tp_str */ + PyObject_GenericGetAttr, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + swigpacked_doc, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ + 0, /* tp_free */ + 0, /* tp_is_gc */ + 0, /* tp_bases */ + 0, /* tp_mro */ + 0, /* tp_cache */ + 0, /* tp_subclasses */ + 0, /* tp_weaklist */ + 0, /* tp_del */ + 0, /* tp_version_tag */ #if PY_VERSION_HEX >= 0x03040000 - 0, /* tp_finalize */ + 0, /* tp_finalize */ #endif #if PY_VERSION_HEX >= 0x03080000 - 0, /* tp_vectorcall */ + 0, /* tp_vectorcall */ #endif #if (PY_VERSION_HEX >= 0x03080000) && (PY_VERSION_HEX < 0x03090000) - 0, /* tp_print */ + 0, /* tp_print */ #endif #if PY_VERSION_HEX >= 0x030C0000 - 0, /* tp_watched */ + 0, /* tp_watched */ #endif #ifdef COUNT_ALLOCS - 0, /* tp_allocs */ - 0, /* tp_frees */ - 0, /* tp_maxalloc */ - 0, /* tp_prev */ - 0 /* tp_next */ -#endif - }; - swigpypacked_type = tmp; - type_init = 1; - if (PyType_Ready(&swigpypacked_type) != 0) - return NULL; - } - return &swigpypacked_type; -#else - PyType_Slot slots[] = { - { Py_tp_dealloc, (void *)SwigPyPacked_dealloc }, - { Py_tp_repr, (void *)SwigPyPacked_repr }, - { Py_tp_str, (void *)SwigPyPacked_str }, - { Py_tp_getattro, (void *)PyObject_GenericGetAttr }, - { Py_tp_doc, (void *)swigpacked_doc }, - { 0, NULL } - }; - PyType_Spec spec = { - "SwigPyPacked", - sizeof(SwigPyPacked), - 0, - Py_TPFLAGS_DEFAULT, - slots + 0, /* tp_allocs */ + 0, /* tp_frees */ + 0, /* tp_maxalloc */ + 0, /* tp_prev */ + 0 /* tp_next */ +#endif }; - return (PyTypeObject *)PyType_FromSpec(&spec); + swigpypacked_type = tmp; + type_init = 1; + if (PyType_Ready(&swigpypacked_type) != 0) + return NULL; + } + return &swigpypacked_type; +#else + PyType_Slot slots[] = { + { Py_tp_dealloc, (void *)SwigPyPacked_dealloc }, + { Py_tp_repr, (void *)SwigPyPacked_repr }, + { Py_tp_str, (void *)SwigPyPacked_str }, + { Py_tp_getattro, (void *)PyObject_GenericGetAttr }, + { Py_tp_doc, (void *)swigpacked_doc }, + { 0, NULL } + }; + PyType_Spec spec = { + "SwigPyPacked", + sizeof(SwigPyPacked), + 0, + Py_TPFLAGS_DEFAULT, + slots + }; + return (PyTypeObject *)PyType_FromSpec(&spec); #endif } SWIGRUNTIME PyObject * -SwigPyPacked_New(void *ptr, size_t size, swig_type_info *ty) { - SwigPyPacked *sobj = PyObject_New(SwigPyPacked, SwigPyPacked_type()); - if (sobj) { - void *pack = malloc(size); - if (pack) { - memcpy(pack, ptr, size); - sobj->pack = pack; - sobj->ty = ty; - sobj->size = size; - } else { - PyObject_DEL((PyObject *) sobj); - sobj = 0; - } +SwigPyPacked_New(void *ptr, size_t size, swig_type_info *ty) +{ + SwigPyPacked *sobj = PyObject_New(SwigPyPacked, SwigPyPacked_type()); + if (sobj) { + void *pack = malloc(size); + if (pack) { + memcpy(pack, ptr, size); + sobj->pack = pack; + sobj->ty = ty; + sobj->size = size; + } else { + PyObject_DEL((PyObject *) sobj); + sobj = 0; } - return (PyObject *) sobj; + } + return (PyObject *) sobj; } SWIGRUNTIME swig_type_info * -SwigPyPacked_UnpackData(PyObject *obj, void *ptr, size_t size) { - if (SwigPyPacked_Check(obj)) { - SwigPyPacked *sobj = (SwigPyPacked *)obj; - if (sobj->size != size) return 0; - memcpy(ptr, sobj->pack, size); - return sobj->ty; - } else { - return 0; - } +SwigPyPacked_UnpackData(PyObject *obj, void *ptr, size_t size) +{ + if (SwigPyPacked_Check(obj)) { + SwigPyPacked *sobj = (SwigPyPacked *)obj; + if (sobj->size != size) return 0; + memcpy(ptr, sobj->pack, size); + return sobj->ty; + } else { + return 0; + } } /* ----------------------------------------------------------------------------- @@ -2390,79 +2423,81 @@ SwigPyPacked_UnpackData(PyObject *obj, void *ptr, size_t size) { static PyObject *Swig_This_global = NULL; SWIGRUNTIME PyObject * -SWIG_This(void) { - if (Swig_This_global == NULL) - Swig_This_global = SWIG_Python_str_FromChar("this"); - return Swig_This_global; +SWIG_This(void) +{ + if (Swig_This_global == NULL) + Swig_This_global = SWIG_Python_str_FromChar("this"); + return Swig_This_global; } /* #define SWIG_PYTHON_SLOW_GETSET_THIS */ /* TODO: I don't know how to implement the fast getset in Python 3 right now */ #if PY_VERSION_HEX>=0x03000000 -#define SWIG_PYTHON_SLOW_GETSET_THIS +#define SWIG_PYTHON_SLOW_GETSET_THIS #endif SWIGRUNTIME SwigPyObject * -SWIG_Python_GetSwigThis(PyObject *pyobj) { - PyObject *obj; +SWIG_Python_GetSwigThis(PyObject *pyobj) +{ + PyObject *obj; - if (SwigPyObject_Check(pyobj)) - return (SwigPyObject *) pyobj; + if (SwigPyObject_Check(pyobj)) + return (SwigPyObject *) pyobj; #ifdef SWIGPYTHON_BUILTIN - (void)obj; + (void)obj; # ifdef PyWeakref_CheckProxy - if (PyWeakref_CheckProxy(pyobj)) { - pyobj = PyWeakref_GET_OBJECT(pyobj); - if (pyobj && SwigPyObject_Check(pyobj)) - return (SwigPyObject *) pyobj; - } + if (PyWeakref_CheckProxy(pyobj)) { + pyobj = PyWeakref_GET_OBJECT(pyobj); + if (pyobj && SwigPyObject_Check(pyobj)) + return (SwigPyObject*) pyobj; + } # endif - return NULL; + return NULL; #else - obj = 0; + obj = 0; #if !defined(SWIG_PYTHON_SLOW_GETSET_THIS) - if (PyInstance_Check(pyobj)) { - obj = _PyInstance_Lookup(pyobj, SWIG_This()); + if (PyInstance_Check(pyobj)) { + obj = _PyInstance_Lookup(pyobj, SWIG_This()); + } else { + PyObject **dictptr = _PyObject_GetDictPtr(pyobj); + if (dictptr != NULL) { + PyObject *dict = *dictptr; + obj = dict ? PyDict_GetItem(dict, SWIG_This()) : 0; } else { - PyObject **dictptr = _PyObject_GetDictPtr(pyobj); - if (dictptr != NULL) { - PyObject *dict = *dictptr; - obj = dict ? PyDict_GetItem(dict, SWIG_This()) : 0; - } else { #ifdef PyWeakref_CheckProxy - if (PyWeakref_CheckProxy(pyobj)) { - PyObject *wobj = PyWeakref_GET_OBJECT(pyobj); - return wobj ? SWIG_Python_GetSwigThis(wobj) : 0; - } + if (PyWeakref_CheckProxy(pyobj)) { + PyObject *wobj = PyWeakref_GET_OBJECT(pyobj); + return wobj ? SWIG_Python_GetSwigThis(wobj) : 0; + } #endif - obj = PyObject_GetAttr(pyobj, SWIG_This()); - if (obj) { - Py_DECREF(obj); - } else { - if (PyErr_Occurred()) PyErr_Clear(); - return 0; - } - } + obj = PyObject_GetAttr(pyobj,SWIG_This()); + if (obj) { + Py_DECREF(obj); + } else { + if (PyErr_Occurred()) PyErr_Clear(); + return 0; + } } + } #else - obj = PyObject_GetAttr(pyobj, SWIG_This()); - if (obj) { - Py_DECREF(obj); - } else { - if (PyErr_Occurred()) PyErr_Clear(); - return 0; - } + obj = PyObject_GetAttr(pyobj,SWIG_This()); + if (obj) { + Py_DECREF(obj); + } else { + if (PyErr_Occurred()) PyErr_Clear(); + return 0; + } #endif - if (obj && !SwigPyObject_Check(obj)) { - /* a PyObject is called 'this', try to get the 'real this' - SwigPyObject from it */ - return SWIG_Python_GetSwigThis(obj); - } - return (SwigPyObject *)obj; + if (obj && !SwigPyObject_Check(obj)) { + /* a PyObject is called 'this', try to get the 'real this' + SwigPyObject from it */ + return SWIG_Python_GetSwigThis(obj); + } + return (SwigPyObject *)obj; #endif } @@ -2470,183 +2505,183 @@ SWIG_Python_GetSwigThis(PyObject *pyobj) { SWIGRUNTIME int SWIG_Python_AcquirePtr(PyObject *obj, int own) { - if (own == SWIG_POINTER_OWN) { - SwigPyObject *sobj = SWIG_Python_GetSwigThis(obj); - if (sobj) { - int oldown = sobj->own; - sobj->own = own; - return oldown; - } + if (own == SWIG_POINTER_OWN) { + SwigPyObject *sobj = SWIG_Python_GetSwigThis(obj); + if (sobj) { + int oldown = sobj->own; + sobj->own = own; + return oldown; } - return 0; + } + return 0; } /* Convert a pointer value */ SWIGRUNTIME int SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int flags, int *own) { - int res; - SwigPyObject *sobj; - int implicit_conv = (flags & SWIG_POINTER_IMPLICIT_CONV) != 0; - - if (!obj) - return SWIG_ERROR; - if (obj == Py_None && !implicit_conv) { - if (ptr) - *ptr = 0; - return (flags & SWIG_POINTER_NO_NULL) ? SWIG_NullReferenceError : SWIG_OK; - } - - res = SWIG_ERROR; - - sobj = SWIG_Python_GetSwigThis(obj); - if (own) - *own = 0; - while (sobj) { - void *vptr = sobj->ptr; - if (ty) { - swig_type_info *to = sobj->ty; - if (to == ty) { - /* no type cast needed */ - if (ptr) *ptr = vptr; - break; - } else { - swig_cast_info *tc = SWIG_TypeCheck(to->name, ty); - if (!tc) { - sobj = (SwigPyObject *)sobj->next; - } else { - if (ptr) { - int newmemory = 0; - *ptr = SWIG_TypeCast(tc, vptr, &newmemory); - if (newmemory == SWIG_CAST_NEW_MEMORY) { - assert(own); /* badly formed typemap which will lead to a memory leak - it must set and use own to delete *ptr */ - if (own) - *own = *own | SWIG_CAST_NEW_MEMORY; - } - } - break; - } - } - } else { - if (ptr) *ptr = vptr; - break; - } - } - if (sobj) { - if (((flags & SWIG_POINTER_RELEASE) == SWIG_POINTER_RELEASE) && !sobj->own) { - res = SWIG_ERROR_RELEASE_NOT_OWNED; + int res; + SwigPyObject *sobj; + int implicit_conv = (flags & SWIG_POINTER_IMPLICIT_CONV) != 0; + + if (!obj) + return SWIG_ERROR; + if (obj == Py_None && !implicit_conv) { + if (ptr) + *ptr = 0; + return (flags & SWIG_POINTER_NO_NULL) ? SWIG_NullReferenceError : SWIG_OK; + } + + res = SWIG_ERROR; + + sobj = SWIG_Python_GetSwigThis(obj); + if (own) + *own = 0; + while (sobj) { + void *vptr = sobj->ptr; + if (ty) { + swig_type_info *to = sobj->ty; + if (to == ty) { + /* no type cast needed */ + if (ptr) *ptr = vptr; + break; + } else { + swig_cast_info *tc = SWIG_TypeCheck(to->name,ty); + if (!tc) { + sobj = (SwigPyObject *)sobj->next; } else { - if (own) - *own = *own | sobj->own; - if (flags & SWIG_POINTER_DISOWN) { - sobj->own = 0; - } - if (flags & SWIG_POINTER_CLEAR) { - sobj->ptr = 0; + if (ptr) { + int newmemory = 0; + *ptr = SWIG_TypeCast(tc,vptr,&newmemory); + if (newmemory == SWIG_CAST_NEW_MEMORY) { + assert(own); /* badly formed typemap which will lead to a memory leak - it must set and use own to delete *ptr */ + if (own) + *own = *own | SWIG_CAST_NEW_MEMORY; } - res = SWIG_OK; + } + break; } + } } else { - if (implicit_conv) { - SwigPyClientData *data = ty ? (SwigPyClientData *) ty->clientdata : 0; - if (data && !data->implicitconv) { - PyObject *klass = data->klass; - if (klass) { - PyObject *impconv; - data->implicitconv = 1; /* avoid recursion and call 'explicit' constructors*/ - impconv = SWIG_Python_CallFunctor(klass, obj); - data->implicitconv = 0; - if (PyErr_Occurred()) { - PyErr_Clear(); - impconv = 0; - } - if (impconv) { - SwigPyObject *iobj = SWIG_Python_GetSwigThis(impconv); - if (iobj) { - void *vptr; - res = SWIG_Python_ConvertPtrAndOwn((PyObject *)iobj, &vptr, ty, 0, 0); - if (SWIG_IsOK(res)) { - if (ptr) { - *ptr = vptr; - /* transfer the ownership to 'ptr' */ - iobj->own = 0; - res = SWIG_AddCast(res); - res = SWIG_AddNewMask(res); - } else { - res = SWIG_AddCast(res); - } - } - } - Py_DECREF(impconv); - } + if (ptr) *ptr = vptr; + break; + } + } + if (sobj) { + if (((flags & SWIG_POINTER_RELEASE) == SWIG_POINTER_RELEASE) && !sobj->own) { + res = SWIG_ERROR_RELEASE_NOT_OWNED; + } else { + if (own) + *own = *own | sobj->own; + if (flags & SWIG_POINTER_DISOWN) { + sobj->own = 0; + } + if (flags & SWIG_POINTER_CLEAR) { + sobj->ptr = 0; + } + res = SWIG_OK; + } + } else { + if (implicit_conv) { + SwigPyClientData *data = ty ? (SwigPyClientData *) ty->clientdata : 0; + if (data && !data->implicitconv) { + PyObject *klass = data->klass; + if (klass) { + PyObject *impconv; + data->implicitconv = 1; /* avoid recursion and call 'explicit' constructors*/ + impconv = SWIG_Python_CallFunctor(klass, obj); + data->implicitconv = 0; + if (PyErr_Occurred()) { + PyErr_Clear(); + impconv = 0; + } + if (impconv) { + SwigPyObject *iobj = SWIG_Python_GetSwigThis(impconv); + if (iobj) { + void *vptr; + res = SWIG_Python_ConvertPtrAndOwn((PyObject*)iobj, &vptr, ty, 0, 0); + if (SWIG_IsOK(res)) { + if (ptr) { + *ptr = vptr; + /* transfer the ownership to 'ptr' */ + iobj->own = 0; + res = SWIG_AddCast(res); + res = SWIG_AddNewMask(res); + } else { + res = SWIG_AddCast(res); } + } } - if (!SWIG_IsOK(res) && obj == Py_None) { - if (ptr) - *ptr = 0; - if (PyErr_Occurred()) - PyErr_Clear(); - res = SWIG_OK; - } + Py_DECREF(impconv); + } } + } + if (!SWIG_IsOK(res) && obj == Py_None) { + if (ptr) + *ptr = 0; + if (PyErr_Occurred()) + PyErr_Clear(); + res = SWIG_OK; + } } - return res; + } + return res; } /* Convert a function ptr value */ SWIGRUNTIME int SWIG_Python_ConvertFunctionPtr(PyObject *obj, void **ptr, swig_type_info *ty) { - if (!PyCFunction_Check(obj)) { - return SWIG_ConvertPtr(obj, ptr, ty, 0); - } else { - void *vptr = 0; - swig_cast_info *tc; + if (!PyCFunction_Check(obj)) { + return SWIG_ConvertPtr(obj, ptr, ty, 0); + } else { + void *vptr = 0; + swig_cast_info *tc; - /* here we get the method pointer for callbacks */ + /* here we get the method pointer for callbacks */ #ifndef Py_LIMITED_API - const char *doc = (((PyCFunctionObject *)obj) -> m_ml -> ml_doc); + const char *doc = (((PyCFunctionObject *)obj) -> m_ml -> ml_doc); #else - PyObject *pystr_doc = PyObject_GetAttrString(obj, "__doc__"); - PyObject *bytes = NULL; - const char *doc = pystr_doc ? SWIG_PyUnicode_AsUTF8AndSize(pystr_doc, NULL, &bytes) : 0; + PyObject* pystr_doc = PyObject_GetAttrString(obj, "__doc__"); + PyObject *bytes = NULL; + const char *doc = pystr_doc ? SWIG_PyUnicode_AsUTF8AndSize(pystr_doc, NULL, &bytes) : 0; #endif - const char *desc = doc ? strstr(doc, "swig_ptr: ") : 0; - if (desc) - desc = ty ? SWIG_UnpackVoidPtr(desc + 10, &vptr, ty->name) : 0; + const char *desc = doc ? strstr(doc, "swig_ptr: ") : 0; + if (desc) + desc = ty ? SWIG_UnpackVoidPtr(desc + 10, &vptr, ty->name) : 0; #ifdef Py_LIMITED_API - Py_XDECREF(bytes); - Py_XDECREF(pystr_doc); -#endif - if (!desc) - return SWIG_ERROR; - tc = SWIG_TypeCheck(desc, ty); - if (tc) { - int newmemory = 0; - *ptr = SWIG_TypeCast(tc, vptr, &newmemory); - assert(!newmemory); /* newmemory handling not yet implemented */ - } else { - return SWIG_ERROR; - } - return SWIG_OK; + Py_XDECREF(bytes); + Py_XDECREF(pystr_doc); +#endif + if (!desc) + return SWIG_ERROR; + tc = SWIG_TypeCheck(desc,ty); + if (tc) { + int newmemory = 0; + *ptr = SWIG_TypeCast(tc,vptr,&newmemory); + assert(!newmemory); /* newmemory handling not yet implemented */ + } else { + return SWIG_ERROR; } + return SWIG_OK; + } } /* Convert a packed pointer value */ SWIGRUNTIME int SWIG_Python_ConvertPacked(PyObject *obj, void *ptr, size_t sz, swig_type_info *ty) { - swig_type_info *to = SwigPyPacked_UnpackData(obj, ptr, sz); - if (!to) return SWIG_ERROR; - if (ty) { - if (to != ty) { - /* check type cast? */ - swig_cast_info *tc = SWIG_TypeCheck(to->name, ty); - if (!tc) return SWIG_ERROR; - } + swig_type_info *to = SwigPyPacked_UnpackData(obj, ptr, sz); + if (!to) return SWIG_ERROR; + if (ty) { + if (to != ty) { + /* check type cast? */ + swig_cast_info *tc = SWIG_TypeCheck(to->name,ty); + if (!tc) return SWIG_ERROR; } - return SWIG_OK; -} + } + return SWIG_OK; +} /* ----------------------------------------------------------------------------- * Create a new pointer object @@ -2657,179 +2692,181 @@ SWIG_Python_ConvertPacked(PyObject *obj, void *ptr, size_t sz, swig_type_info *t 'this' attribute. */ -SWIGRUNTIME PyObject * -SWIG_Python_NewShadowInstance(SwigPyClientData *data, PyObject *swig_this) { - PyObject *inst = 0; - PyObject *newraw = data->newraw; - if (newraw) { - inst = PyObject_Call(newraw, data->newargs, NULL); - if (inst) { +SWIGRUNTIME PyObject* +SWIG_Python_NewShadowInstance(SwigPyClientData *data, PyObject *swig_this) +{ + PyObject *inst = 0; + PyObject *newraw = data->newraw; + if (newraw) { + inst = PyObject_Call(newraw, data->newargs, NULL); + if (inst) { #if !defined(SWIG_PYTHON_SLOW_GETSET_THIS) - PyObject **dictptr = _PyObject_GetDictPtr(inst); - if (dictptr != NULL) { - PyObject *dict = *dictptr; - if (dict == NULL) { - dict = PyDict_New(); - *dictptr = dict; - } - if (dict) { - PyDict_SetItem(dict, SWIG_This(), swig_this); - } else { - Py_DECREF(inst); - inst = 0; - } - } + PyObject **dictptr = _PyObject_GetDictPtr(inst); + if (dictptr != NULL) { + PyObject *dict = *dictptr; + if (dict == NULL) { + dict = PyDict_New(); + *dictptr = dict; + } + if (dict) { + PyDict_SetItem(dict, SWIG_This(), swig_this); + } else{ + Py_DECREF(inst); + inst = 0; + } + } #else - if (PyObject_SetAttr(inst, SWIG_This(), swig_this) == -1) { - Py_DECREF(inst); - inst = 0; - } + if (PyObject_SetAttr(inst, SWIG_This(), swig_this) == -1) { + Py_DECREF(inst); + inst = 0; + } #endif - } - } else { + } + } else { #if PY_VERSION_HEX >= 0x03000000 - PyObject *empty_args = PyTuple_New(0); - if (empty_args) { - PyObject *empty_kwargs = PyDict_New(); - if (empty_kwargs) { + PyObject *empty_args = PyTuple_New(0); + if (empty_args) { + PyObject *empty_kwargs = PyDict_New(); + if (empty_kwargs) { #ifndef Py_LIMITED_API - newfunc newfn = ((PyTypeObject *)data->newargs)->tp_new; + newfunc newfn = ((PyTypeObject *)data->newargs)->tp_new; #else - newfunc newfn = (newfunc)PyType_GetSlot((PyTypeObject *)data->newargs, Py_tp_new); -#endif - inst = newfn((PyTypeObject *)data->newargs, empty_args, empty_kwargs); - Py_DECREF(empty_kwargs); - if (inst) { - if (PyObject_SetAttr(inst, SWIG_This(), swig_this) == -1) { - Py_DECREF(inst); - inst = 0; - } else { - PyType_Modified(Py_TYPE(inst)); - } - } - } - Py_DECREF(empty_args); + newfunc newfn = (newfunc)PyType_GetSlot((PyTypeObject *)data->newargs, Py_tp_new); +#endif + inst = newfn((PyTypeObject *)data->newargs, empty_args, empty_kwargs); + Py_DECREF(empty_kwargs); + if (inst) { + if (PyObject_SetAttr(inst, SWIG_This(), swig_this) == -1) { + Py_DECREF(inst); + inst = 0; + } else { + PyType_Modified(Py_TYPE(inst)); + } } + } + Py_DECREF(empty_args); + } #else - PyObject *dict = PyDict_New(); - if (dict) { - PyDict_SetItem(dict, SWIG_This(), swig_this); - inst = PyInstance_NewRaw(data->newargs, dict); - Py_DECREF(dict); - } -#endif + PyObject *dict = PyDict_New(); + if (dict) { + PyDict_SetItem(dict, SWIG_This(), swig_this); + inst = PyInstance_NewRaw(data->newargs, dict); + Py_DECREF(dict); } - return inst; +#endif + } + return inst; } SWIGRUNTIME int -SWIG_Python_SetSwigThis(PyObject *inst, PyObject *swig_this) { +SWIG_Python_SetSwigThis(PyObject *inst, PyObject *swig_this) +{ #if !defined(SWIG_PYTHON_SLOW_GETSET_THIS) - PyObject **dictptr = _PyObject_GetDictPtr(inst); - if (dictptr != NULL) { - PyObject *dict = *dictptr; - if (dict == NULL) { - dict = PyDict_New(); - *dictptr = dict; - } - if (dict) { - return PyDict_SetItem(dict, SWIG_This(), swig_this); - } else { - return -1; - } + PyObject **dictptr = _PyObject_GetDictPtr(inst); + if (dictptr != NULL) { + PyObject *dict = *dictptr; + if (dict == NULL) { + dict = PyDict_New(); + *dictptr = dict; } + if (dict) { + return PyDict_SetItem(dict, SWIG_This(), swig_this); + } else{ + return -1; + } + } #endif - return PyObject_SetAttr(inst, SWIG_This(), swig_this); -} + return PyObject_SetAttr(inst, SWIG_This(), swig_this); +} SWIGINTERN PyObject * SWIG_Python_InitShadowInstance(PyObject *args) { - PyObject *obj[2]; - if (!SWIG_Python_UnpackTuple(args, "swiginit", 2, 2, obj)) { - return NULL; + PyObject *obj[2]; + if (!SWIG_Python_UnpackTuple(args, "swiginit", 2, 2, obj)) { + return NULL; + } else { + SwigPyObject *sthis = SWIG_Python_GetSwigThis(obj[0]); + if (sthis) { + Py_DECREF(SwigPyObject_append((PyObject*) sthis, obj[1])); } else { - SwigPyObject *sthis = SWIG_Python_GetSwigThis(obj[0]); - if (sthis) { - Py_DECREF(SwigPyObject_append((PyObject *) sthis, obj[1])); - } else { - if (SWIG_Python_SetSwigThis(obj[0], obj[1]) != 0) - return NULL; - } - return SWIG_Py_Void(); + if (SWIG_Python_SetSwigThis(obj[0], obj[1]) != 0) + return NULL; } + return SWIG_Py_Void(); + } } /* Create a new pointer object */ SWIGRUNTIME PyObject * SWIG_Python_NewPointerObj(PyObject *self, void *ptr, swig_type_info *type, int flags) { - SwigPyClientData *clientdata; - PyObject *robj; - int own; - - if (!ptr) - return SWIG_Py_Void(); - - clientdata = type ? (SwigPyClientData *)(type->clientdata) : 0; - own = (flags & SWIG_POINTER_OWN) ? SWIG_POINTER_OWN : 0; - if (clientdata && clientdata->pytype) { - SwigPyObject *newobj; - if (flags & SWIG_BUILTIN_TP_INIT) { - newobj = (SwigPyObject *) self; - if (newobj->ptr) { + SwigPyClientData *clientdata; + PyObject * robj; + int own; + + if (!ptr) + return SWIG_Py_Void(); + + clientdata = type ? (SwigPyClientData *)(type->clientdata) : 0; + own = (flags & SWIG_POINTER_OWN) ? SWIG_POINTER_OWN : 0; + if (clientdata && clientdata->pytype) { + SwigPyObject *newobj; + if (flags & SWIG_BUILTIN_TP_INIT) { + newobj = (SwigPyObject*) self; + if (newobj->ptr) { #ifndef Py_LIMITED_API - allocfunc alloc = clientdata->pytype->tp_alloc; + allocfunc alloc = clientdata->pytype->tp_alloc; #else - allocfunc alloc = (allocfunc)PyType_GetSlot(clientdata->pytype, Py_tp_alloc); + allocfunc alloc = (allocfunc)PyType_GetSlot(clientdata->pytype, Py_tp_alloc); #endif - PyObject *next_self = alloc(clientdata->pytype, 0); - while (newobj->next) - newobj = (SwigPyObject *) newobj->next; - newobj->next = next_self; - newobj = (SwigPyObject *)next_self; + PyObject *next_self = alloc(clientdata->pytype, 0); + while (newobj->next) + newobj = (SwigPyObject *) newobj->next; + newobj->next = next_self; + newobj = (SwigPyObject *)next_self; #ifdef SWIGPYTHON_BUILTIN - newobj->dict = 0; + newobj->dict = 0; #endif - } - } else { - newobj = PyObject_New(SwigPyObject, clientdata->pytype); + } + } else { + newobj = PyObject_New(SwigPyObject, clientdata->pytype); #ifdef SWIGPYTHON_BUILTIN - if (newobj) { - newobj->dict = 0; - } + if (newobj) { + newobj->dict = 0; + } #endif - } - if (newobj) { - newobj->ptr = ptr; - newobj->ty = type; - newobj->own = own; - newobj->next = 0; - return (PyObject *) newobj; - } - return SWIG_Py_Void(); } + if (newobj) { + newobj->ptr = ptr; + newobj->ty = type; + newobj->own = own; + newobj->next = 0; + return (PyObject*) newobj; + } + return SWIG_Py_Void(); + } - assert(!(flags & SWIG_BUILTIN_TP_INIT)); + assert(!(flags & SWIG_BUILTIN_TP_INIT)); - robj = SwigPyObject_New(ptr, type, own); - if (robj && clientdata && !(flags & SWIG_POINTER_NOSHADOW)) { - PyObject *inst = SWIG_Python_NewShadowInstance(clientdata, robj); - Py_DECREF(robj); - robj = inst; - } - return robj; + robj = SwigPyObject_New(ptr, type, own); + if (robj && clientdata && !(flags & SWIG_POINTER_NOSHADOW)) { + PyObject *inst = SWIG_Python_NewShadowInstance(clientdata, robj); + Py_DECREF(robj); + robj = inst; + } + return robj; } /* Create a new packed object */ SWIGRUNTIMEINLINE PyObject * SWIG_Python_NewPackedObj(void *ptr, size_t sz, swig_type_info *type) { - return ptr ? SwigPyPacked_New((void *) ptr, sz, type) : SWIG_Py_Void(); + return ptr ? SwigPyPacked_New((void *) ptr, sz, type) : SWIG_Py_Void(); } /* -----------------------------------------------------------------------------* - * Get type list + * Get type list * -----------------------------------------------------------------------------*/ #ifdef SWIG_LINK_RUNTIME @@ -2841,103 +2878,105 @@ static PyObject *Swig_TypeCache_global = NULL; /* The python cached type query */ SWIGRUNTIME PyObject * SWIG_Python_TypeCache(void) { - if (Swig_TypeCache_global == NULL) { - Swig_TypeCache_global = PyDict_New(); - } - return Swig_TypeCache_global; + if (Swig_TypeCache_global == NULL) { + Swig_TypeCache_global = PyDict_New(); + } + return Swig_TypeCache_global; } SWIGRUNTIME swig_module_info * SWIG_Python_GetModule(void *SWIGUNUSEDPARM(clientdata)) { #ifdef SWIG_LINK_RUNTIME - static void *type_pointer = (void *)0; - /* first check if module already created */ - if (!type_pointer) { - type_pointer = SWIG_ReturnGlobalTypeList((void *)0); - } + static void *type_pointer = (void *)0; + /* first check if module already created */ + if (!type_pointer) { + type_pointer = SWIG_ReturnGlobalTypeList((void *)0); + } #else - void *type_pointer = PyCapsule_Import(SWIGPY_CAPSULE_NAME, 0); - if (PyErr_Occurred()) { - PyErr_Clear(); - type_pointer = (void *)0; - } + void *type_pointer = PyCapsule_Import(SWIGPY_CAPSULE_NAME, 0); + if (PyErr_Occurred()) { + PyErr_Clear(); + type_pointer = (void *)0; + } #endif - return (swig_module_info *) type_pointer; + return (swig_module_info *) type_pointer; } static int interpreter_counter = 0; /* how many (sub-)interpreters are using swig_module's types */ SWIGRUNTIME void -SWIG_Python_DestroyModule(PyObject *obj) { - swig_module_info *swig_module = (swig_module_info *) PyCapsule_GetPointer(obj, SWIGPY_CAPSULE_NAME); - swig_type_info **types = swig_module->types; - size_t i; - if (--interpreter_counter != 0) /* another sub-interpreter may still be using the swig_module's types */ - return; - for (i = 0; i < swig_module->size; ++i) { - swig_type_info *ty = types[i]; - if (ty->owndata) { - SwigPyClientData *data = (SwigPyClientData *) ty->clientdata; - ty->clientdata = 0; - if (data) SwigPyClientData_Del(data); - } +SWIG_Python_DestroyModule(PyObject *obj) +{ + swig_module_info *swig_module = (swig_module_info *) PyCapsule_GetPointer(obj, SWIGPY_CAPSULE_NAME); + swig_type_info **types = swig_module->types; + size_t i; + if (--interpreter_counter != 0) /* another sub-interpreter may still be using the swig_module's types */ + return; + for (i =0; i < swig_module->size; ++i) { + swig_type_info *ty = types[i]; + if (ty->owndata) { + SwigPyClientData *data = (SwigPyClientData *) ty->clientdata; + ty->clientdata = 0; + if (data) SwigPyClientData_Del(data); } - Py_DECREF(SWIG_This()); - Swig_This_global = NULL; - Py_DECREF(SWIG_globals()); - Swig_Globals_global = NULL; - Py_DECREF(SWIG_Python_TypeCache()); - Swig_TypeCache_global = NULL; - Swig_Capsule_global = NULL; + } + Py_DECREF(SWIG_This()); + Swig_This_global = NULL; + Py_DECREF(SWIG_globals()); + Swig_Globals_global = NULL; + Py_DECREF(SWIG_Python_TypeCache()); + Swig_TypeCache_global = NULL; + Swig_Capsule_global = NULL; } SWIGRUNTIME void SWIG_Python_SetModule(swig_module_info *swig_module) { #if PY_VERSION_HEX >= 0x03000000 - /* Add a dummy module object into sys.modules */ - PyObject *module = PyImport_AddModule("swig_runtime_data" SWIG_RUNTIME_VERSION); + /* Add a dummy module object into sys.modules */ + PyObject *module = PyImport_AddModule("swig_runtime_data" SWIG_RUNTIME_VERSION); #else - static PyMethodDef swig_empty_runtime_method_table[] = { {NULL, NULL, 0, NULL} }; /* Sentinel */ - PyObject *module = Py_InitModule("swig_runtime_data" SWIG_RUNTIME_VERSION, swig_empty_runtime_method_table); -#endif - PyObject *pointer = PyCapsule_New((void *) swig_module, SWIGPY_CAPSULE_NAME, SWIG_Python_DestroyModule); - if (pointer && module) { - if (PyModule_AddObject(module, SWIGPY_CAPSULE_ATTR_NAME, pointer) == 0) { - ++interpreter_counter; - Swig_Capsule_global = pointer; - } else { - Py_DECREF(pointer); - } + static PyMethodDef swig_empty_runtime_method_table[] = { {NULL, NULL, 0, NULL} }; /* Sentinel */ + PyObject *module = Py_InitModule("swig_runtime_data" SWIG_RUNTIME_VERSION, swig_empty_runtime_method_table); +#endif + PyObject *pointer = PyCapsule_New((void *) swig_module, SWIGPY_CAPSULE_NAME, SWIG_Python_DestroyModule); + if (pointer && module) { + if (PyModule_AddObject(module, SWIGPY_CAPSULE_ATTR_NAME, pointer) == 0) { + ++interpreter_counter; + Swig_Capsule_global = pointer; } else { - Py_XDECREF(pointer); + Py_DECREF(pointer); } + } else { + Py_XDECREF(pointer); + } } SWIGRUNTIME swig_type_info * -SWIG_Python_TypeQuery(const char *type) { - PyObject *cache = SWIG_Python_TypeCache(); - PyObject *key = SWIG_Python_str_FromChar(type); - PyObject *obj = PyDict_GetItem(cache, key); - swig_type_info *descriptor; - if (obj) { - descriptor = (swig_type_info *) PyCapsule_GetPointer(obj, NULL); - } else { - swig_module_info *swig_module = SWIG_GetModule(0); - descriptor = SWIG_TypeQueryModule(swig_module, swig_module, type); - if (descriptor) { - obj = PyCapsule_New((void *) descriptor, NULL, NULL); - if (obj) { - PyDict_SetItem(cache, key, obj); - Py_DECREF(obj); - } - } +SWIG_Python_TypeQuery(const char *type) +{ + PyObject *cache = SWIG_Python_TypeCache(); + PyObject *key = SWIG_Python_str_FromChar(type); + PyObject *obj = PyDict_GetItem(cache, key); + swig_type_info *descriptor; + if (obj) { + descriptor = (swig_type_info *) PyCapsule_GetPointer(obj, NULL); + } else { + swig_module_info *swig_module = SWIG_GetModule(0); + descriptor = SWIG_TypeQueryModule(swig_module, swig_module, type); + if (descriptor) { + obj = PyCapsule_New((void*) descriptor, NULL, NULL); + if (obj) { + PyDict_SetItem(cache, key, obj); + Py_DECREF(obj); + } } - Py_DECREF(key); - return descriptor; + } + Py_DECREF(key); + return descriptor; } -/* +/* For backward compatibility only */ #define SWIG_POINTER_EXCEPTION 0 @@ -2945,155 +2984,159 @@ SWIG_Python_TypeQuery(const char *type) { #define SWIG_MustGetPtr(p, type, argnum, flags) SWIG_Python_MustGetPtr(p, type, argnum, flags) SWIGRUNTIME int -SWIG_Python_AddErrMesg(const char *mesg, int infront) { - if (PyErr_Occurred()) { - PyObject *type = 0; - PyObject *value = 0; - PyObject *traceback = 0; - PyErr_Fetch(&type, &value, &traceback); - if (value) { - PyObject *old_str = PyObject_Str(value); - PyObject *bytes = NULL; - const char *tmp = SWIG_PyUnicode_AsUTF8AndSize(old_str, NULL, &bytes); - const char *errmesg = tmp ? tmp : "Invalid error message"; - Py_XINCREF(type); - PyErr_Clear(); - if (infront) { - PyErr_Format(type, "%s %s", mesg, errmesg); - } else { - PyErr_Format(type, "%s %s", errmesg, mesg); - } - Py_XDECREF(bytes); - Py_DECREF(old_str); - } - return 1; - } else { - return 0; +SWIG_Python_AddErrMesg(const char* mesg, int infront) +{ + if (PyErr_Occurred()) { + PyObject *type = 0; + PyObject *value = 0; + PyObject *traceback = 0; + PyErr_Fetch(&type, &value, &traceback); + if (value) { + PyObject *old_str = PyObject_Str(value); + PyObject *bytes = NULL; + const char *tmp = SWIG_PyUnicode_AsUTF8AndSize(old_str, NULL, &bytes); + const char *errmesg = tmp ? tmp : "Invalid error message"; + Py_XINCREF(type); + PyErr_Clear(); + if (infront) { + PyErr_Format(type, "%s %s", mesg, errmesg); + } else { + PyErr_Format(type, "%s %s", errmesg, mesg); + } + Py_XDECREF(bytes); + Py_DECREF(old_str); } + return 1; + } else { + return 0; + } } - + SWIGRUNTIME int -SWIG_Python_ArgFail(int argnum) { - if (PyErr_Occurred()) { - /* add information about failing argument */ - char mesg[256]; - PyOS_snprintf(mesg, sizeof(mesg), "argument number %d:", argnum); - return SWIG_Python_AddErrMesg(mesg, 1); - } else { - return 0; - } +SWIG_Python_ArgFail(int argnum) +{ + if (PyErr_Occurred()) { + /* add information about failing argument */ + char mesg[256]; + PyOS_snprintf(mesg, sizeof(mesg), "argument number %d:", argnum); + return SWIG_Python_AddErrMesg(mesg, 1); + } else { + return 0; + } } SWIGRUNTIMEINLINE const char * -SwigPyObject_GetDesc(PyObject *self) { - SwigPyObject *v = (SwigPyObject *)self; - swig_type_info *ty = v ? v->ty : 0; - return ty ? ty->str : ""; +SwigPyObject_GetDesc(PyObject *self) +{ + SwigPyObject *v = (SwigPyObject *)self; + swig_type_info *ty = v ? v->ty : 0; + return ty ? ty->str : ""; } SWIGRUNTIME void -SWIG_Python_TypeError(const char *type, PyObject *obj) { - if (type) { +SWIG_Python_TypeError(const char *type, PyObject *obj) +{ + if (type) { #if defined(SWIG_COBJECT_TYPES) - if (obj && SwigPyObject_Check(obj)) { - const char *otype = (const char *) SwigPyObject_GetDesc(obj); - if (otype) { - PyErr_Format(PyExc_TypeError, "a '%s' is expected, 'SwigPyObject(%s)' is received", - type, otype); - return; - } - } else -#endif - { + if (obj && SwigPyObject_Check(obj)) { + const char *otype = (const char *) SwigPyObject_GetDesc(obj); + if (otype) { + PyErr_Format(PyExc_TypeError, "a '%s' is expected, 'SwigPyObject(%s)' is received", + type, otype); + return; + } + } else +#endif + { #ifndef Py_LIMITED_API - /* tp_name is not accessible */ - const char *otype = (obj ? obj->ob_type->tp_name : 0); - if (otype) { - PyObject *str = PyObject_Str(obj); - PyObject *bytes = NULL; - const char *cstr = str ? SWIG_PyUnicode_AsUTF8AndSize(str, NULL, &bytes) : 0; - if (cstr) { - PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s(%s)' is received", - type, otype, cstr); - } else { - PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s' is received", - type, otype); - } - Py_XDECREF(bytes); - Py_XDECREF(str); - return; - } + /* tp_name is not accessible */ + const char *otype = (obj ? obj->ob_type->tp_name : 0); + if (otype) { + PyObject *str = PyObject_Str(obj); + PyObject *bytes = NULL; + const char *cstr = str ? SWIG_PyUnicode_AsUTF8AndSize(str, NULL, &bytes) : 0; + if (cstr) { + PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s(%s)' is received", + type, otype, cstr); + } else { + PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s' is received", + type, otype); + } + Py_XDECREF(bytes); + Py_XDECREF(str); + return; + } #endif - } - PyErr_Format(PyExc_TypeError, "a '%s' is expected", type); - } else { - PyErr_Format(PyExc_TypeError, "unexpected type is received"); - } + } + PyErr_Format(PyExc_TypeError, "a '%s' is expected", type); + } else { + PyErr_Format(PyExc_TypeError, "unexpected type is received"); + } } /* Convert a pointer value, signal an exception on a type mismatch */ SWIGRUNTIME void * SWIG_Python_MustGetPtr(PyObject *obj, swig_type_info *ty, int SWIGUNUSEDPARM(argnum), int flags) { - void *result; - if (SWIG_Python_ConvertPtr(obj, &result, ty, flags) == -1) { - PyErr_Clear(); - } - return result; + void *result; + if (SWIG_Python_ConvertPtr(obj, &result, ty, flags) == -1) { + PyErr_Clear(); + } + return result; } #ifdef SWIGPYTHON_BUILTIN SWIGRUNTIME int SWIG_Python_NonDynamicSetAttr(PyObject *obj, PyObject *name, PyObject *value) { - PyTypeObject *tp = obj->ob_type; - PyObject *descr; - PyObject *encoded_name; - descrsetfunc f; - int res = -1; + PyTypeObject *tp = obj->ob_type; + PyObject *descr; + PyObject *encoded_name; + descrsetfunc f; + int res = -1; # ifdef Py_USING_UNICODE - if (PyString_Check(name)) { - name = PyUnicode_Decode(PyString_AsString(name), PyString_Size(name), NULL, NULL); - if (!name) - return -1; - } else if (!PyUnicode_Check(name)) + if (PyString_Check(name)) { + name = PyUnicode_Decode(PyString_AsString(name), PyString_Size(name), NULL, NULL); + if (!name) + return -1; + } else if (!PyUnicode_Check(name)) # else - if (!PyString_Check(name)) + if (!PyString_Check(name)) # endif - { - PyErr_Format(PyExc_TypeError, "attribute name must be string, not '%.200s'", name->ob_type->tp_name); - return -1; - } else { - Py_INCREF(name); - } - - if (!tp->tp_dict) { - if (PyType_Ready(tp) != 0) - goto done; - } - - descr = _PyType_Lookup(tp, name); - f = NULL; - if (descr != NULL) - f = descr->ob_type->tp_descr_set; - if (!f) { - if (PyString_Check(name)) { - encoded_name = name; - Py_INCREF(name); - } else { - encoded_name = PyUnicode_AsUTF8String(name); - if (!encoded_name) - goto done; - } - PyErr_Format(PyExc_AttributeError, "'%.100s' object has no attribute '%.200s'", tp->tp_name, PyString_AsString(encoded_name)); - Py_DECREF(encoded_name); + { + PyErr_Format(PyExc_TypeError, "attribute name must be string, not '%.200s'", name->ob_type->tp_name); + return -1; + } else { + Py_INCREF(name); + } + + if (!tp->tp_dict) { + if (PyType_Ready(tp) != 0) + goto done; + } + + descr = _PyType_Lookup(tp, name); + f = NULL; + if (descr != NULL) + f = descr->ob_type->tp_descr_set; + if (!f) { + if (PyString_Check(name)) { + encoded_name = name; + Py_INCREF(name); } else { - res = f(descr, obj, value); + encoded_name = PyUnicode_AsUTF8String(name); + if (!encoded_name) + goto done; } - -done: - Py_DECREF(name); - return res; + PyErr_Format(PyExc_AttributeError, "'%.100s' object has no attribute '%.200s'", tp->tp_name, PyString_AsString(encoded_name)); + Py_DECREF(encoded_name); + } else { + res = f(descr, obj, value); + } + + done: + Py_DECREF(name); + return res; } #endif @@ -3104,9 +3147,9 @@ SWIG_Python_NonDynamicSetAttr(PyObject *obj, PyObject *name, PyObject *value) { -#define SWIG_exception_fail(code, msg) do { SWIG_Error(code, msg); SWIG_fail; } while(0) +#define SWIG_exception_fail(code, msg) do { SWIG_Error(code, msg); SWIG_fail; } while(0) -#define SWIG_contract_assert(expr, msg) do { if (!(expr)) { SWIG_Error(SWIG_RuntimeError, msg); SWIG_fail; } } while (0) +#define SWIG_contract_assert(expr, msg) do { if (!(expr)) { SWIG_Error(SWIG_RuntimeError, msg); SWIG_fail; } } while (0) @@ -3138,180 +3181,181 @@ static swig_module_info swig_module = {swig_types, 2, 0, 0, 0, 0}; #endif #define SWIG_name "_pm3" -#define SWIG_as_voidptr(a) (void *)((const void *)(a)) -#define SWIG_as_voidptrptr(a) ((void)SWIG_as_voidptr(*a),(void**)(a)) +#define SWIG_as_voidptr(a) (void *)((const void *)(a)) +#define SWIG_as_voidptrptr(a) ((void)SWIG_as_voidptr(*a),(void**)(a)) /* Include the header in the wrapper code */ #include "pm3.h" #include "comms.h" -SWIGINTERN pm3 *new_pm3__SWIG_0(void) { +SWIGINTERN pm3 *new_pm3__SWIG_0(void){ // printf("SWIG pm3 constructor, get current pm3\n"); - pm3_device_t *p = pm3_get_current_dev(); - p->script_embedded = 1; - return p; -} + pm3_device_t * p = pm3_get_current_dev(); + p->script_embedded = 1; + return p; + } -SWIGINTERN swig_type_info * -SWIG_pchar_descriptor(void) { - static int init = 0; - static swig_type_info *info = 0; - if (!init) { - info = SWIG_TypeQuery("_p_char"); - init = 1; - } - return info; +SWIGINTERN swig_type_info* +SWIG_pchar_descriptor(void) +{ + static int init = 0; + static swig_type_info* info = 0; + if (!init) { + info = SWIG_TypeQuery("_p_char"); + init = 1; + } + return info; } /* Return string from Python obj. NOTE: obj must remain in scope in order to use the returned cptr (but only when alloc is set to SWIG_OLDOBJ) */ SWIGINTERN int -SWIG_AsCharPtrAndSize(PyObject *obj, char **cptr, size_t *psize, int *alloc) { +SWIG_AsCharPtrAndSize(PyObject *obj, char **cptr, size_t *psize, int *alloc) +{ #if PY_VERSION_HEX>=0x03000000 #if defined(SWIG_PYTHON_STRICT_BYTE_CHAR) - if (PyBytes_Check(obj)) + if (PyBytes_Check(obj)) #else - if (PyUnicode_Check(obj)) + if (PyUnicode_Check(obj)) #endif -#else - if (PyString_Check(obj)) +#else + if (PyString_Check(obj)) #endif - { - char *cstr; - Py_ssize_t len; - PyObject *bytes = NULL; - int ret = SWIG_OK; - if (alloc) - *alloc = SWIG_OLDOBJ; + { + char *cstr; Py_ssize_t len; + PyObject *bytes = NULL; + int ret = SWIG_OK; + if (alloc) + *alloc = SWIG_OLDOBJ; #if PY_VERSION_HEX>=0x03000000 && defined(SWIG_PYTHON_STRICT_BYTE_CHAR) - if (PyBytes_AsStringAndSize(obj, &cstr, &len) == -1) - return SWIG_TypeError; + if (PyBytes_AsStringAndSize(obj, &cstr, &len) == -1) + return SWIG_TypeError; #else - cstr = (char *)SWIG_PyUnicode_AsUTF8AndSize(obj, &len, &bytes); - if (!cstr) - return SWIG_TypeError; - /* The returned string is only duplicated if the char * returned is not owned and memory managed by obj */ - if (bytes && cptr) { - if (alloc) { - cstr = (char *)memcpy(malloc((len + 1) * sizeof(char)), cstr, sizeof(char) * (len + 1)); - *alloc = SWIG_NEWOBJ; - } else { - /* alloc must be set in order to clean up allocated memory */ - return SWIG_RuntimeError; - } - } + cstr = (char *)SWIG_PyUnicode_AsUTF8AndSize(obj, &len, &bytes); + if (!cstr) + return SWIG_TypeError; + /* The returned string is only duplicated if the char * returned is not owned and memory managed by obj */ + if (bytes && cptr) { + if (alloc) { + cstr = (char *)memcpy(malloc((len + 1)*sizeof(char)), cstr, sizeof(char)*(len + 1)); + *alloc = SWIG_NEWOBJ; + } else { + /* alloc must be set in order to clean up allocated memory */ + return SWIG_RuntimeError; + } + } #endif - if (cptr) *cptr = cstr; - if (psize) *psize = len + 1; - Py_XDECREF(bytes); - return ret; - } else { + if (cptr) *cptr = cstr; + if (psize) *psize = len + 1; + Py_XDECREF(bytes); + return ret; + } else { #if defined(SWIG_PYTHON_2_UNICODE) #if defined(SWIG_PYTHON_STRICT_BYTE_CHAR) #error "Cannot use both SWIG_PYTHON_2_UNICODE and SWIG_PYTHON_STRICT_BYTE_CHAR at once" #endif #if PY_VERSION_HEX<0x03000000 - if (PyUnicode_Check(obj)) { - char *cstr; - Py_ssize_t len; - if (!alloc && cptr) { - return SWIG_RuntimeError; - } - obj = PyUnicode_AsUTF8String(obj); - if (!obj) - return SWIG_TypeError; - if (PyString_AsStringAndSize(obj, &cstr, &len) != -1) { - if (cptr) { - if (alloc) *alloc = SWIG_NEWOBJ; - *cptr = (char *)memcpy(malloc((len + 1) * sizeof(char)), cstr, sizeof(char) * (len + 1)); - } - if (psize) *psize = len + 1; - - Py_XDECREF(obj); - return SWIG_OK; - } else { - Py_XDECREF(obj); - } + if (PyUnicode_Check(obj)) { + char *cstr; Py_ssize_t len; + if (!alloc && cptr) { + return SWIG_RuntimeError; + } + obj = PyUnicode_AsUTF8String(obj); + if (!obj) + return SWIG_TypeError; + if (PyString_AsStringAndSize(obj, &cstr, &len) != -1) { + if (cptr) { + if (alloc) *alloc = SWIG_NEWOBJ; + *cptr = (char *)memcpy(malloc((len + 1)*sizeof(char)), cstr, sizeof(char)*(len + 1)); } + if (psize) *psize = len + 1; + + Py_XDECREF(obj); + return SWIG_OK; + } else { + Py_XDECREF(obj); + } + } #endif #endif - swig_type_info *pchar_descriptor = SWIG_pchar_descriptor(); - if (pchar_descriptor) { - void *vptr = 0; - if (SWIG_ConvertPtr(obj, &vptr, pchar_descriptor, 0) == SWIG_OK) { - if (cptr) *cptr = (char *) vptr; - if (psize) *psize = vptr ? (strlen((char *)vptr) + 1) : 0; - if (alloc) *alloc = SWIG_OLDOBJ; - return SWIG_OK; - } - } + swig_type_info* pchar_descriptor = SWIG_pchar_descriptor(); + if (pchar_descriptor) { + void* vptr = 0; + if (SWIG_ConvertPtr(obj, &vptr, pchar_descriptor, 0) == SWIG_OK) { + if (cptr) *cptr = (char *) vptr; + if (psize) *psize = vptr ? (strlen((char *)vptr) + 1) : 0; + if (alloc) *alloc = SWIG_OLDOBJ; + return SWIG_OK; + } } - return SWIG_TypeError; + } + return SWIG_TypeError; } -SWIGINTERN pm3 *new_pm3__SWIG_1(char *port) { +SWIGINTERN pm3 *new_pm3__SWIG_1(char *port){ // printf("SWIG pm3 constructor with port, open pm3\n"); - pm3_device_t *p = pm3_open(port); - p->script_embedded = 0; - return p; -} -SWIGINTERN void delete_pm3(pm3 *self) { - if (self->script_embedded) { + pm3_device_t * p = pm3_open(port); + p->script_embedded = 0; + return p; + } +SWIGINTERN void delete_pm3(pm3 *self){ + if (self->script_embedded) { // printf("SWIG pm3 destructor, nothing to do\n"); - } else { + } else { // printf("SWIG pm3 destructor, close pm3\n"); - pm3_close(self); - } -} + pm3_close(self); + } + } SWIGINTERN int -SWIG_AsVal_double(PyObject *obj, double *val) { - int res = SWIG_TypeError; - if (PyFloat_Check(obj)) { - if (val) *val = PyFloat_AsDouble(obj); - return SWIG_OK; +SWIG_AsVal_double (PyObject *obj, double *val) +{ + int res = SWIG_TypeError; + if (PyFloat_Check(obj)) { + if (val) *val = PyFloat_AsDouble(obj); + return SWIG_OK; #if PY_VERSION_HEX < 0x03000000 - } else if (PyInt_Check(obj)) { - if (val) *val = (double) PyInt_AsLong(obj); - return SWIG_OK; + } else if (PyInt_Check(obj)) { + if (val) *val = (double) PyInt_AsLong(obj); + return SWIG_OK; #endif - } else if (PyLong_Check(obj)) { - double v = PyLong_AsDouble(obj); - if (!PyErr_Occurred()) { - if (val) *val = v; - return SWIG_OK; - } else { - PyErr_Clear(); - } + } else if (PyLong_Check(obj)) { + double v = PyLong_AsDouble(obj); + if (!PyErr_Occurred()) { + if (val) *val = v; + return SWIG_OK; + } else { + PyErr_Clear(); } + } #ifdef SWIG_PYTHON_CAST_MODE - { - int dispatch = 0; - double d = PyFloat_AsDouble(obj); - if (!PyErr_Occurred()) { - if (val) *val = d; - return SWIG_AddCast(SWIG_OK); - } else { - PyErr_Clear(); - } - if (!dispatch) { - long v = PyLong_AsLong(obj); - if (!PyErr_Occurred()) { - if (val) *val = v; - return SWIG_AddCast(SWIG_AddCast(SWIG_OK)); - } else { - PyErr_Clear(); - } - } + { + int dispatch = 0; + double d = PyFloat_AsDouble(obj); + if (!PyErr_Occurred()) { + if (val) *val = d; + return SWIG_AddCast(SWIG_OK); + } else { + PyErr_Clear(); } + if (!dispatch) { + long v = PyLong_AsLong(obj); + if (!PyErr_Occurred()) { + if (val) *val = v; + return SWIG_AddCast(SWIG_AddCast(SWIG_OK)); + } else { + PyErr_Clear(); + } + } + } #endif - return res; + return res; } @@ -3323,364 +3367,378 @@ SWIG_AsVal_double(PyObject *obj, double *val) { SWIGINTERNINLINE int SWIG_CanCastAsInteger(double *d, double min, double max) { - double x = *d; - if ((min <= x && x <= max)) { - double fx, cx, rd; - errno = 0; - fx = floor(x); - cx = ceil(x); - rd = ((x - fx) < 0.5) ? fx : cx; /* simple rint */ - if ((errno == EDOM) || (errno == ERANGE)) { - errno = 0; - } else { - double summ, reps, diff; - if (rd < x) { - diff = x - rd; - } else if (rd > x) { - diff = rd - x; - } else { - return 1; - } - summ = rd + x; - reps = diff / summ; - if (reps < 8 * DBL_EPSILON) { - *d = rd; - return 1; - } - } - } - return 0; + double x = *d; + if ((min <= x && x <= max)) { + double fx, cx, rd; + errno = 0; + fx = floor(x); + cx = ceil(x); + rd = ((x - fx) < 0.5) ? fx : cx; /* simple rint */ + if ((errno == EDOM) || (errno == ERANGE)) { + errno = 0; + } else { + double summ, reps, diff; + if (rd < x) { + diff = x - rd; + } else if (rd > x) { + diff = rd - x; + } else { + return 1; + } + summ = rd + x; + reps = diff/summ; + if (reps < 8*DBL_EPSILON) { + *d = rd; + return 1; + } + } + } + return 0; } SWIGINTERN int -SWIG_AsVal_long(PyObject *obj, long *val) { +SWIG_AsVal_long (PyObject *obj, long* val) +{ #if PY_VERSION_HEX < 0x03000000 - if (PyInt_Check(obj)) { - if (val) *val = PyInt_AsLong(obj); - return SWIG_OK; - } else + if (PyInt_Check(obj)) { + if (val) *val = PyInt_AsLong(obj); + return SWIG_OK; + } else #endif - if (PyLong_Check(obj)) { - long v = PyLong_AsLong(obj); - if (!PyErr_Occurred()) { - if (val) *val = v; - return SWIG_OK; - } else { - PyErr_Clear(); - return SWIG_OverflowError; - } - } + if (PyLong_Check(obj)) { + long v = PyLong_AsLong(obj); + if (!PyErr_Occurred()) { + if (val) *val = v; + return SWIG_OK; + } else { + PyErr_Clear(); + return SWIG_OverflowError; + } + } #ifdef SWIG_PYTHON_CAST_MODE - { - int dispatch = 0; - long v = PyInt_AsLong(obj); - if (!PyErr_Occurred()) { - if (val) *val = v; - return SWIG_AddCast(SWIG_OK); - } else { - PyErr_Clear(); - } - if (!dispatch) { - double d; - int res = SWIG_AddCast(SWIG_AsVal_double(obj, &d)); - // Largest double not larger than LONG_MAX (not portably calculated easily) - // Note that double(LONG_MAX) is stored in a double rounded up by one (for 64-bit long) - // 0x7ffffffffffffc00LL == (int64_t)std::nextafter(double(__uint128_t(LONG_MAX)+1), double(0)) - const double long_max = sizeof(long) == 8 ? 0x7ffffffffffffc00LL : LONG_MAX; - // No equivalent needed for 64-bit double(LONG_MIN) is exactly LONG_MIN - if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, LONG_MIN, long_max)) { - if (val) *val = (long)(d); - return res; - } - } + { + int dispatch = 0; + long v = PyInt_AsLong(obj); + if (!PyErr_Occurred()) { + if (val) *val = v; + return SWIG_AddCast(SWIG_OK); + } else { + PyErr_Clear(); } + if (!dispatch) { + double d; + int res = SWIG_AddCast(SWIG_AsVal_double (obj,&d)); + // Largest double not larger than LONG_MAX (not portably calculated easily) + // Note that double(LONG_MAX) is stored in a double rounded up by one (for 64-bit long) + // 0x7ffffffffffffc00LL == (int64_t)std::nextafter(double(__uint128_t(LONG_MAX)+1), double(0)) + const double long_max = sizeof(long) == 8 ? 0x7ffffffffffffc00LL : LONG_MAX; + // No equivalent needed for 64-bit double(LONG_MIN) is exactly LONG_MIN + if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, LONG_MIN, long_max)) { + if (val) *val = (long)(d); + return res; + } + } + } #endif - return SWIG_TypeError; + return SWIG_TypeError; } SWIGINTERN int -SWIG_AsVal_bool(PyObject *obj, bool *val) { - int r; - if (!PyBool_Check(obj)) - return SWIG_ERROR; - r = PyObject_IsTrue(obj); - if (r == -1) - return SWIG_ERROR; - if (val) *val = r ? true : false; - return SWIG_OK; +SWIG_AsVal_bool (PyObject *obj, bool *val) +{ + int r; + if (!PyBool_Check(obj)) + return SWIG_ERROR; + r = PyObject_IsTrue(obj); + if (r == -1) + return SWIG_ERROR; + if (val) *val = r ? true : false; + return SWIG_OK; } -SWIGINTERNINLINE PyObject * -SWIG_From_int(int value) { - return PyInt_FromLong((long) value); +SWIGINTERNINLINE PyObject* + SWIG_From_int (int value) +{ + return PyInt_FromLong((long) value); } SWIGINTERNINLINE PyObject * -SWIG_FromCharPtrAndSize(const char *carray, size_t size) { - if (carray) { - if (size > INT_MAX) { - swig_type_info *pchar_descriptor = SWIG_pchar_descriptor(); - return pchar_descriptor ? - SWIG_InternalNewPointerObj((char *)(carray), pchar_descriptor, 0) : SWIG_Py_Void(); - } else { +SWIG_FromCharPtrAndSize(const char* carray, size_t size) +{ + if (carray) { + if (size > INT_MAX) { + swig_type_info* pchar_descriptor = SWIG_pchar_descriptor(); + return pchar_descriptor ? + SWIG_InternalNewPointerObj((char *)(carray), pchar_descriptor, 0) : SWIG_Py_Void(); + } else { #if PY_VERSION_HEX >= 0x03000000 #if defined(SWIG_PYTHON_STRICT_BYTE_CHAR) - return PyBytes_FromStringAndSize(carray, (Py_ssize_t)(size)); + return PyBytes_FromStringAndSize(carray, (Py_ssize_t)(size)); #else - return PyUnicode_DecodeUTF8(carray, (Py_ssize_t)(size), "surrogateescape"); + return PyUnicode_DecodeUTF8(carray, (Py_ssize_t)(size), "surrogateescape"); #endif #else - return PyString_FromStringAndSize(carray, (Py_ssize_t)(size)); + return PyString_FromStringAndSize(carray, (Py_ssize_t)(size)); #endif - } - } else { - return SWIG_Py_Void(); } + } else { + return SWIG_Py_Void(); + } } -SWIGINTERNINLINE PyObject * -SWIG_FromCharPtr(const char *cptr) { - return SWIG_FromCharPtrAndSize(cptr, (cptr ? strlen(cptr) : 0)); +SWIGINTERNINLINE PyObject * +SWIG_FromCharPtr(const char *cptr) +{ + return SWIG_FromCharPtrAndSize(cptr, (cptr ? strlen(cptr) : 0)); } #ifdef __cplusplus extern "C" { #endif SWIGINTERN PyObject *_wrap_new_pm3__SWIG_0(PyObject *self, Py_ssize_t nobjs, PyObject **SWIGUNUSEDPARM(swig_obj)) { - PyObject *resultobj = 0; - pm3 *result = 0 ; - - (void)self; - if ((nobjs < 0) || (nobjs > 0)) SWIG_fail; - result = (pm3 *)new_pm3__SWIG_0(); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_pm3, SWIG_POINTER_NEW | 0); - return resultobj; + PyObject *resultobj = 0; + pm3 *result = 0 ; + + (void)self; + if ((nobjs < 0) || (nobjs > 0)) SWIG_fail; + result = (pm3 *)new_pm3__SWIG_0(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_pm3, SWIG_POINTER_NEW | 0 ); + return resultobj; fail: - return NULL; + return NULL; } SWIGINTERN PyObject *_wrap_new_pm3__SWIG_1(PyObject *self, Py_ssize_t nobjs, PyObject **swig_obj) { - PyObject *resultobj = 0; - char *arg1 = (char *) 0 ; - int res1 ; - char *buf1 = 0 ; - int alloc1 = 0 ; - pm3 *result = 0 ; - - (void)self; - if ((nobjs < 1) || (nobjs > 1)) SWIG_fail; - res1 = SWIG_AsCharPtrAndSize(swig_obj[0], &buf1, NULL, &alloc1); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_pm3" "', argument " "1"" of type '" "char *""'"); - } - arg1 = (char *)(buf1); - result = (pm3 *)new_pm3__SWIG_1(arg1); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_pm3, SWIG_POINTER_NEW | 0); - if (alloc1 == SWIG_NEWOBJ) free((char *)buf1); - return resultobj; + PyObject *resultobj = 0; + char *arg1 = (char *) 0 ; + int res1 ; + char *buf1 = 0 ; + int alloc1 = 0 ; + pm3 *result = 0 ; + + (void)self; + if ((nobjs < 1) || (nobjs > 1)) SWIG_fail; + res1 = SWIG_AsCharPtrAndSize(swig_obj[0], &buf1, NULL, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_pm3" "', argument " "1"" of type '" "char *""'"); + } + arg1 = (char *)(buf1); + result = (pm3 *)new_pm3__SWIG_1(arg1); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_pm3, SWIG_POINTER_NEW | 0 ); + if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); + return resultobj; fail: - if (alloc1 == SWIG_NEWOBJ) free((char *)buf1); - return NULL; + if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); + return NULL; } SWIGINTERN PyObject *_wrap_new_pm3(PyObject *self, PyObject *args) { - Py_ssize_t argc; - PyObject *argv[2] = { - 0 - }; - - if (!(argc = SWIG_Python_UnpackTuple(args, "new_pm3", 0, 1, argv))) SWIG_fail; - --argc; - if (argc == 0) { - return _wrap_new_pm3__SWIG_0(self, argc, argv); - } - if (argc == 1) { - int _v = 0; - int res = SWIG_AsCharPtrAndSize(argv[0], 0, NULL, 0); - _v = SWIG_CheckState(res); - if (_v) { - return _wrap_new_pm3__SWIG_1(self, argc, argv); - } + Py_ssize_t argc; + PyObject *argv[2] = { + 0 + }; + + if (!(argc = SWIG_Python_UnpackTuple(args, "new_pm3", 0, 1, argv))) SWIG_fail; + --argc; + if (argc == 0) { + return _wrap_new_pm3__SWIG_0(self, argc, argv); + } + if (argc == 1) { + int _v = 0; + int res = SWIG_AsCharPtrAndSize(argv[0], 0, NULL, 0); + _v = SWIG_CheckState(res); + if (_v) { + return _wrap_new_pm3__SWIG_1(self, argc, argv); } - + } + fail: - SWIG_Python_RaiseOrModifyTypeError("Wrong number or type of arguments for overloaded function 'new_pm3'.\n" - " Possible C/C++ prototypes are:\n" - " pm3::pm3()\n" - " pm3::pm3(char *)\n"); - return 0; + SWIG_Python_RaiseOrModifyTypeError("Wrong number or type of arguments for overloaded function 'new_pm3'.\n" + " Possible C/C++ prototypes are:\n" + " pm3::pm3()\n" + " pm3::pm3(char *)\n"); + return 0; } SWIGINTERN PyObject *_wrap_delete_pm3(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - pm3 *arg1 = (pm3 *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - - (void)self; - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1, SWIGTYPE_p_pm3, SWIG_POINTER_DISOWN | 0); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_pm3" "', argument " "1"" of type '" "pm3 *""'"); - } - arg1 = (pm3 *)(argp1); - delete_pm3(arg1); - resultobj = SWIG_Py_Void(); - return resultobj; + PyObject *resultobj = 0; + pm3 *arg1 = (pm3 *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + + (void)self; + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_pm3, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_pm3" "', argument " "1"" of type '" "pm3 *""'"); + } + arg1 = (pm3 *)(argp1); + delete_pm3(arg1); + resultobj = SWIG_Py_Void(); + return resultobj; fail: - return NULL; + return NULL; } SWIGINTERN PyObject *_wrap_pm3_console(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - pm3 *arg1 = (pm3 *) 0 ; - char *arg2 = (char *) 0 ; - bool arg3 = (bool) false ; - void *argp1 = 0 ; - int res1 = 0 ; - int res2 ; - char *buf2 = 0 ; - int alloc2 = 0 ; - bool val3 ; - int ecode3 = 0 ; - PyObject *swig_obj[3] ; - int result; - - (void)self; - if (!SWIG_Python_UnpackTuple(args, "pm3_console", 2, 3, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1, SWIGTYPE_p_pm3, 0 | 0); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "pm3_console" "', argument " "1"" of type '" "pm3 *""'"); - } - arg1 = (pm3 *)(argp1); - res2 = SWIG_AsCharPtrAndSize(swig_obj[1], &buf2, NULL, &alloc2); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "pm3_console" "', argument " "2"" of type '" "char *""'"); - } - arg2 = (char *)(buf2); - if (swig_obj[2]) { - ecode3 = SWIG_AsVal_bool(swig_obj[2], &val3); - if (!SWIG_IsOK(ecode3)) { - SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "pm3_console" "', argument " "3"" of type '" "bool""'"); - } - arg3 = (bool)(val3); - } - result = (int)pm3_console(arg1, arg2, arg3); - resultobj = SWIG_From_int((int)(result)); - if (alloc2 == SWIG_NEWOBJ) free((char *)buf2); - return resultobj; + PyObject *resultobj = 0; + pm3 *arg1 = (pm3 *) 0 ; + char *arg2 = (char *) 0 ; + bool arg3 = (bool) true ; + bool arg4 = (bool) true ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + bool val3 ; + int ecode3 = 0 ; + bool val4 ; + int ecode4 = 0 ; + PyObject *swig_obj[4] ; + int result; + + (void)self; + if (!SWIG_Python_UnpackTuple(args, "pm3_console", 2, 4, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_pm3, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "pm3_console" "', argument " "1"" of type '" "pm3 *""'"); + } + arg1 = (pm3 *)(argp1); + res2 = SWIG_AsCharPtrAndSize(swig_obj[1], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "pm3_console" "', argument " "2"" of type '" "char *""'"); + } + arg2 = (char *)(buf2); + if (swig_obj[2]) { + ecode3 = SWIG_AsVal_bool(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "pm3_console" "', argument " "3"" of type '" "bool""'"); + } + arg3 = (bool)(val3); + } + if (swig_obj[3]) { + ecode4 = SWIG_AsVal_bool(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "pm3_console" "', argument " "4"" of type '" "bool""'"); + } + arg4 = (bool)(val4); + } + result = (int)pm3_console(arg1,arg2,arg3,arg4); + resultobj = SWIG_From_int((int)(result)); + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + return resultobj; fail: - if (alloc2 == SWIG_NEWOBJ) free((char *)buf2); - return NULL; + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + return NULL; } SWIGINTERN PyObject *_wrap_pm3_name_get(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - pm3 *arg1 = (pm3 *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - char *result = 0 ; - - (void)self; - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1, SWIGTYPE_p_pm3, 0 | 0); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "pm3_name_get" "', argument " "1"" of type '" "pm3 *""'"); - } - arg1 = (pm3 *)(argp1); - result = (char *)pm3_name_get(arg1); - resultobj = SWIG_FromCharPtr((const char *)result); - return resultobj; + PyObject *resultobj = 0; + pm3 *arg1 = (pm3 *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + char *result = 0 ; + + (void)self; + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_pm3, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "pm3_name_get" "', argument " "1"" of type '" "pm3 *""'"); + } + arg1 = (pm3 *)(argp1); + result = (char *)pm3_name_get(arg1); + resultobj = SWIG_FromCharPtr((const char *)result); + return resultobj; fail: - return NULL; + return NULL; } SWIGINTERN PyObject *_wrap_pm3_grabbed_output_get(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - pm3 *arg1 = (pm3 *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - char *result = 0 ; - - (void)self; - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1, SWIGTYPE_p_pm3, 0 | 0); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "pm3_grabbed_output_get" "', argument " "1"" of type '" "pm3 *""'"); - } - arg1 = (pm3 *)(argp1); - result = (char *)pm3_grabbed_output_get(arg1); - resultobj = SWIG_FromCharPtr((const char *)result); - return resultobj; + PyObject *resultobj = 0; + pm3 *arg1 = (pm3 *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + char *result = 0 ; + + (void)self; + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_pm3, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "pm3_grabbed_output_get" "', argument " "1"" of type '" "pm3 *""'"); + } + arg1 = (pm3 *)(argp1); + result = (char *)pm3_grabbed_output_get(arg1); + resultobj = SWIG_FromCharPtr((const char *)result); + return resultobj; fail: - return NULL; + return NULL; } SWIGINTERN PyObject *pm3_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *obj; - if (!SWIG_Python_UnpackTuple(args, "swigregister", 1, 1, &obj)) return NULL; - SWIG_TypeNewClientData(SWIGTYPE_p_pm3, SWIG_NewClientData(obj)); - return SWIG_Py_Void(); + PyObject *obj; + if (!SWIG_Python_UnpackTuple(args, "swigregister", 1, 1, &obj)) return NULL; + SWIG_TypeNewClientData(SWIGTYPE_p_pm3, SWIG_NewClientData(obj)); + return SWIG_Py_Void(); } SWIGINTERN PyObject *pm3_swiginit(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - return SWIG_Python_InitShadowInstance(args); + return SWIG_Python_InitShadowInstance(args); } static PyMethodDef SwigMethods[] = { - { "new_pm3", _wrap_new_pm3, METH_VARARGS, NULL}, - { "delete_pm3", _wrap_delete_pm3, METH_O, NULL}, - { "pm3_console", _wrap_pm3_console, METH_VARARGS, NULL}, - { "pm3_name_get", _wrap_pm3_name_get, METH_O, NULL}, - { "pm3_grabbed_output_get", _wrap_pm3_grabbed_output_get, METH_O, NULL}, - { "pm3_swigregister", pm3_swigregister, METH_O, NULL}, - { "pm3_swiginit", pm3_swiginit, METH_VARARGS, NULL}, - { NULL, NULL, 0, NULL } + { "new_pm3", _wrap_new_pm3, METH_VARARGS, NULL}, + { "delete_pm3", _wrap_delete_pm3, METH_O, NULL}, + { "pm3_console", _wrap_pm3_console, METH_VARARGS, NULL}, + { "pm3_name_get", _wrap_pm3_name_get, METH_O, NULL}, + { "pm3_grabbed_output_get", _wrap_pm3_grabbed_output_get, METH_O, NULL}, + { "pm3_swigregister", pm3_swigregister, METH_O, NULL}, + { "pm3_swiginit", pm3_swiginit, METH_VARARGS, NULL}, + { NULL, NULL, 0, NULL } }; /* -------- TYPE CONVERSION AND EQUIVALENCE RULES (BEGIN) -------- */ -static swig_type_info _swigt__p_char = {"_p_char", "char *", 0, 0, (void *)0, 0}; -static swig_type_info _swigt__p_pm3 = {"_p_pm3", "pm3 *", 0, 0, (void *)0, 0}; +static swig_type_info _swigt__p_char = {"_p_char", "char *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_pm3 = {"_p_pm3", "pm3 *", 0, 0, (void*)0, 0}; static swig_type_info *swig_type_initial[] = { - &_swigt__p_char, - &_swigt__p_pm3, + &_swigt__p_char, + &_swigt__p_pm3, }; -static swig_cast_info _swigc__p_char[] = { {&_swigt__p_char, 0, 0, 0}, {0, 0, 0, 0}}; -static swig_cast_info _swigc__p_pm3[] = { {&_swigt__p_pm3, 0, 0, 0}, {0, 0, 0, 0}}; +static swig_cast_info _swigc__p_char[] = { {&_swigt__p_char, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_pm3[] = { {&_swigt__p_pm3, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info *swig_cast_initial[] = { - _swigc__p_char, - _swigc__p_pm3, + _swigc__p_char, + _swigc__p_pm3, }; /* -------- TYPE CONVERSION AND EQUIVALENCE RULES (END) -------- */ static swig_const_info swig_const_table[] = { - {0, 0, 0, 0.0, 0, 0} -}; +{0, 0, 0, 0.0, 0, 0}}; #ifdef __cplusplus } @@ -3743,143 +3801,143 @@ extern "C" { SWIGRUNTIME void SWIG_InitializeModule(SWIG_INIT_CLIENT_DATA_TYPE clientdata) { - size_t i; - swig_module_info *module_head, *iter; - int init; - - /* check to see if the circular list has been setup, if not, set it up */ - if (swig_module.next == 0) { - /* Initialize the swig_module */ - swig_module.type_initial = swig_type_initial; - swig_module.cast_initial = swig_cast_initial; - swig_module.next = &swig_module; - init = 1; - } else { - init = 0; - } - - /* Try and load any already created modules */ - module_head = SWIG_GetModule(clientdata); - if (!module_head) { - /* This is the first module loaded for this interpreter */ - /* so set the swig module into the interpreter */ - SWIG_SetModule(clientdata, &swig_module); - } else { - /* the interpreter has loaded a SWIG module, but has it loaded this one? */ - iter = module_head; - do { - if (iter == &swig_module) { - /* Our module is already in the list, so there's nothing more to do. */ - return; - } - iter = iter->next; - } while (iter != module_head); - - /* otherwise we must add our module into the list */ - swig_module.next = module_head->next; - module_head->next = &swig_module; - } - - /* When multiple interpreters are used, a module could have already been initialized in - a different interpreter, but not yet have a pointer in this interpreter. - In this case, we do not want to continue adding types... everything should be - set up already */ - if (init == 0) return; - - /* Now work on filling in swig_module.types */ + size_t i; + swig_module_info *module_head, *iter; + int init; + + /* check to see if the circular list has been setup, if not, set it up */ + if (swig_module.next==0) { + /* Initialize the swig_module */ + swig_module.type_initial = swig_type_initial; + swig_module.cast_initial = swig_cast_initial; + swig_module.next = &swig_module; + init = 1; + } else { + init = 0; + } + + /* Try and load any already created modules */ + module_head = SWIG_GetModule(clientdata); + if (!module_head) { + /* This is the first module loaded for this interpreter */ + /* so set the swig module into the interpreter */ + SWIG_SetModule(clientdata, &swig_module); + } else { + /* the interpreter has loaded a SWIG module, but has it loaded this one? */ + iter=module_head; + do { + if (iter==&swig_module) { + /* Our module is already in the list, so there's nothing more to do. */ + return; + } + iter=iter->next; + } while (iter!= module_head); + + /* otherwise we must add our module into the list */ + swig_module.next = module_head->next; + module_head->next = &swig_module; + } + + /* When multiple interpreters are used, a module could have already been initialized in + a different interpreter, but not yet have a pointer in this interpreter. + In this case, we do not want to continue adding types... everything should be + set up already */ + if (init == 0) return; + + /* Now work on filling in swig_module.types */ #ifdef SWIGRUNTIME_DEBUG - printf("SWIG_InitializeModule: size %lu\n", (unsigned long)swig_module.size); + printf("SWIG_InitializeModule: size %lu\n", (unsigned long)swig_module.size); #endif - for (i = 0; i < swig_module.size; ++i) { - swig_type_info *type = 0; - swig_type_info *ret; - swig_cast_info *cast; - + for (i = 0; i < swig_module.size; ++i) { + swig_type_info *type = 0; + swig_type_info *ret; + swig_cast_info *cast; + #ifdef SWIGRUNTIME_DEBUG - printf("SWIG_InitializeModule: type %lu %s\n", (unsigned long)i, swig_module.type_initial[i]->name); + printf("SWIG_InitializeModule: type %lu %s\n", (unsigned long)i, swig_module.type_initial[i]->name); #endif - - /* if there is another module already loaded */ - if (swig_module.next != &swig_module) { - type = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, swig_module.type_initial[i]->name); - } - if (type) { - /* Overwrite clientdata field */ + + /* if there is another module already loaded */ + if (swig_module.next != &swig_module) { + type = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, swig_module.type_initial[i]->name); + } + if (type) { + /* Overwrite clientdata field */ #ifdef SWIGRUNTIME_DEBUG - printf("SWIG_InitializeModule: found type %s\n", type->name); + printf("SWIG_InitializeModule: found type %s\n", type->name); #endif - if (swig_module.type_initial[i]->clientdata) { - type->clientdata = swig_module.type_initial[i]->clientdata; + if (swig_module.type_initial[i]->clientdata) { + type->clientdata = swig_module.type_initial[i]->clientdata; #ifdef SWIGRUNTIME_DEBUG - printf("SWIG_InitializeModule: found and overwrite type %s \n", type->name); + printf("SWIG_InitializeModule: found and overwrite type %s \n", type->name); #endif - } - } else { - type = swig_module.type_initial[i]; - } - - /* Insert casting types */ - cast = swig_module.cast_initial[i]; - while (cast->type) { - /* Don't need to add information already in the list */ - ret = 0; + } + } else { + type = swig_module.type_initial[i]; + } + + /* Insert casting types */ + cast = swig_module.cast_initial[i]; + while (cast->type) { + /* Don't need to add information already in the list */ + ret = 0; #ifdef SWIGRUNTIME_DEBUG - printf("SWIG_InitializeModule: look cast %s\n", cast->type->name); + printf("SWIG_InitializeModule: look cast %s\n", cast->type->name); #endif - if (swig_module.next != &swig_module) { - ret = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, cast->type->name); + if (swig_module.next != &swig_module) { + ret = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, cast->type->name); #ifdef SWIGRUNTIME_DEBUG - if (ret) printf("SWIG_InitializeModule: found cast %s\n", ret->name); + if (ret) printf("SWIG_InitializeModule: found cast %s\n", ret->name); #endif - } - if (ret) { - if (type == swig_module.type_initial[i]) { + } + if (ret) { + if (type == swig_module.type_initial[i]) { #ifdef SWIGRUNTIME_DEBUG - printf("SWIG_InitializeModule: skip old type %s\n", ret->name); + printf("SWIG_InitializeModule: skip old type %s\n", ret->name); #endif - cast->type = ret; - ret = 0; - } else { - /* Check for casting already in the list */ - swig_cast_info *ocast = SWIG_TypeCheck(ret->name, type); + cast->type = ret; + ret = 0; + } else { + /* Check for casting already in the list */ + swig_cast_info *ocast = SWIG_TypeCheck(ret->name, type); #ifdef SWIGRUNTIME_DEBUG - if (ocast) printf("SWIG_InitializeModule: skip old cast %s\n", ret->name); + if (ocast) printf("SWIG_InitializeModule: skip old cast %s\n", ret->name); #endif - if (!ocast) ret = 0; - } - } - - if (!ret) { + if (!ocast) ret = 0; + } + } + + if (!ret) { #ifdef SWIGRUNTIME_DEBUG - printf("SWIG_InitializeModule: adding cast %s\n", cast->type->name); + printf("SWIG_InitializeModule: adding cast %s\n", cast->type->name); #endif - if (type->cast) { - type->cast->prev = cast; - cast->next = type->cast; - } - type->cast = cast; - } - cast++; + if (type->cast) { + type->cast->prev = cast; + cast->next = type->cast; } - /* Set entry in modules->types array equal to the type */ - swig_module.types[i] = type; + type->cast = cast; + } + cast++; } - swig_module.types[i] = 0; - + /* Set entry in modules->types array equal to the type */ + swig_module.types[i] = type; + } + swig_module.types[i] = 0; + #ifdef SWIGRUNTIME_DEBUG - printf("**** SWIG_InitializeModule: Cast List ******\n"); - for (i = 0; i < swig_module.size; ++i) { - int j = 0; - swig_cast_info *cast = swig_module.cast_initial[i]; - printf("SWIG_InitializeModule: type %lu %s\n", (unsigned long)i, swig_module.type_initial[i]->name); - while (cast->type) { - printf("SWIG_InitializeModule: cast type %s\n", cast->type->name); - cast++; - ++j; - } - printf("---- Total casts: %d\n", j); + printf("**** SWIG_InitializeModule: Cast List ******\n"); + for (i = 0; i < swig_module.size; ++i) { + int j = 0; + swig_cast_info *cast = swig_module.cast_initial[i]; + printf("SWIG_InitializeModule: type %lu %s\n", (unsigned long)i, swig_module.type_initial[i]->name); + while (cast->type) { + printf("SWIG_InitializeModule: cast type %s\n", cast->type->name); + cast++; + ++j; } - printf("**** SWIG_InitializeModule: Cast List ******\n"); + printf("---- Total casts: %d\n",j); + } + printf("**** SWIG_InitializeModule: Cast List ******\n"); #endif } @@ -3890,31 +3948,31 @@ SWIG_InitializeModule(SWIG_INIT_CLIENT_DATA_TYPE clientdata) { */ SWIGRUNTIME void SWIG_PropagateClientData(void) { - size_t i; - swig_cast_info *equiv; - static int init_run = 0; - - if (init_run) return; - init_run = 1; - - for (i = 0; i < swig_module.size; i++) { - if (swig_module.types[i]->clientdata) { - equiv = swig_module.types[i]->cast; - while (equiv) { - if (!equiv->converter) { - if (equiv->type && !equiv->type->clientdata) - SWIG_TypeClientData(equiv->type, swig_module.types[i]->clientdata); - } - equiv = equiv->next; - } + size_t i; + swig_cast_info *equiv; + static int init_run = 0; + + if (init_run) return; + init_run = 1; + + for (i = 0; i < swig_module.size; i++) { + if (swig_module.types[i]->clientdata) { + equiv = swig_module.types[i]->cast; + while (equiv) { + if (!equiv->converter) { + if (equiv->type && !equiv->type->clientdata) + SWIG_TypeClientData(equiv->type, swig_module.types[i]->clientdata); } + equiv = equiv->next; + } } + } } #ifdef __cplusplus #if 0 { - /* c-mode */ + /* c-mode */ #endif } #endif @@ -3924,80 +3982,80 @@ SWIG_PropagateClientData(void) { #ifdef __cplusplus extern "C" { #endif - -/* ----------------------------------------------------------------------------- - * constants/methods manipulation - * ----------------------------------------------------------------------------- */ - -/* Install Constants */ -SWIGINTERN void -SWIG_Python_InstallConstants(PyObject *d, swig_const_info constants[]) { + + /* ----------------------------------------------------------------------------- + * constants/methods manipulation + * ----------------------------------------------------------------------------- */ + + /* Install Constants */ + SWIGINTERN void + SWIG_Python_InstallConstants(PyObject *d, swig_const_info constants[]) { PyObject *obj = 0; size_t i; for (i = 0; constants[i].type; ++i) { - switch (constants[i].type) { - case SWIG_PY_POINTER: - obj = SWIG_InternalNewPointerObj(constants[i].pvalue, *(constants[i]).ptype, 0); - break; - case SWIG_PY_BINARY: - obj = SWIG_NewPackedObj(constants[i].pvalue, constants[i].lvalue, *(constants[i].ptype)); - break; - default: - obj = 0; - break; - } - if (obj) { - PyDict_SetItemString(d, constants[i].name, obj); - Py_DECREF(obj); - } + switch(constants[i].type) { + case SWIG_PY_POINTER: + obj = SWIG_InternalNewPointerObj(constants[i].pvalue, *(constants[i]).ptype,0); + break; + case SWIG_PY_BINARY: + obj = SWIG_NewPackedObj(constants[i].pvalue, constants[i].lvalue, *(constants[i].ptype)); + break; + default: + obj = 0; + break; + } + if (obj) { + PyDict_SetItemString(d, constants[i].name, obj); + Py_DECREF(obj); + } } -} - -/* ----------------------------------------------------------------------------- - * Patch %callback methods' docstrings to hold the callback ptrs - * -----------------------------------------------------------------------------*/ - -SWIGINTERN void -SWIG_Python_FixMethods(PyMethodDef *methods, const swig_const_info *const_table, swig_type_info **types, swig_type_info **types_initial) { + } + + /* ----------------------------------------------------------------------------- + * Patch %callback methods' docstrings to hold the callback ptrs + * -----------------------------------------------------------------------------*/ + + SWIGINTERN void + SWIG_Python_FixMethods(PyMethodDef *methods, const swig_const_info *const_table, swig_type_info **types, swig_type_info **types_initial) { size_t i; for (i = 0; methods[i].ml_name; ++i) { - const char *c = methods[i].ml_doc; - if (!c) continue; - c = strstr(c, "swig_ptr: "); - if (c) { - int j; - const swig_const_info *ci = 0; - const char *name = c + 10; - for (j = 0; const_table[j].type; ++j) { - if (strncmp(const_table[j].name, name, - strlen(const_table[j].name)) == 0) { - ci = &(const_table[j]); - break; - } - } - if (ci) { - void *ptr = (ci->type == SWIG_PY_POINTER) ? ci->pvalue : 0; - if (ptr) { - size_t shift = (ci->ptype) - types; - swig_type_info *ty = types_initial[shift]; - size_t ldoc = (c - methods[i].ml_doc); - size_t lptr = strlen(ty->name) + 2 * sizeof(void *) +2; - char *ndoc = (char *)malloc(ldoc + lptr + 10); - if (ndoc) { - char *buff = ndoc; - memcpy(buff, methods[i].ml_doc, ldoc); - buff += ldoc; - memcpy(buff, "swig_ptr: ", 10); - buff += 10; - SWIG_PackVoidPtr(buff, ptr, ty->name, lptr); - methods[i].ml_doc = ndoc; - } - } + const char *c = methods[i].ml_doc; + if (!c) continue; + c = strstr(c, "swig_ptr: "); + if (c) { + int j; + const swig_const_info *ci = 0; + const char *name = c + 10; + for (j = 0; const_table[j].type; ++j) { + if (strncmp(const_table[j].name, name, + strlen(const_table[j].name)) == 0) { + ci = &(const_table[j]); + break; + } + } + if (ci) { + void *ptr = (ci->type == SWIG_PY_POINTER) ? ci->pvalue : 0; + if (ptr) { + size_t shift = (ci->ptype) - types; + swig_type_info *ty = types_initial[shift]; + size_t ldoc = (c - methods[i].ml_doc); + size_t lptr = strlen(ty->name)+2*sizeof(void*)+2; + char *ndoc = (char*)malloc(ldoc + lptr + 10); + if (ndoc) { + char *buff = ndoc; + memcpy(buff, methods[i].ml_doc, ldoc); + buff += ldoc; + memcpy(buff, "swig_ptr: ", 10); + buff += 10; + SWIG_PackVoidPtr(buff, ptr, ty->name, lptr); + methods[i].ml_doc = ndoc; } + } } + } } -} - + } + #ifdef __cplusplus } #endif @@ -4013,137 +4071,137 @@ SWIG_Python_FixMethods(PyMethodDef *methods, const swig_const_info *const_table, extern "C" #endif -SWIGEXPORT +SWIGEXPORT #if PY_VERSION_HEX >= 0x03000000 -PyObject * +PyObject* #else void #endif SWIG_init(void) { - PyObject *m, *d, *md, *globals; - + PyObject *m, *d, *md, *globals; + #if PY_VERSION_HEX >= 0x03000000 - static struct PyModuleDef SWIG_module = { - PyModuleDef_HEAD_INIT, - SWIG_name, - NULL, - -1, - SwigMethods, - NULL, - NULL, - NULL, - NULL - }; -#endif - + static struct PyModuleDef SWIG_module = { + PyModuleDef_HEAD_INIT, + SWIG_name, + NULL, + -1, + SwigMethods, + NULL, + NULL, + NULL, + NULL + }; +#endif + #if defined(SWIGPYTHON_BUILTIN) - static SwigPyClientData SwigPyObject_clientdata = { - 0, 0, 0, 0, 0, 0, 0 - }; - static PyGetSetDef this_getset_def = { - (char *)"this", &SwigPyBuiltin_ThisClosure, NULL, NULL, NULL - }; - static SwigPyGetSet thisown_getset_closure = { - SwigPyObject_own, - SwigPyObject_own - }; - static PyGetSetDef thisown_getset_def = { - (char *)"thisown", SwigPyBuiltin_GetterClosure, SwigPyBuiltin_SetterClosure, NULL, &thisown_getset_closure - }; - PyTypeObject *builtin_pytype; - int builtin_base_count; - swig_type_info *builtin_basetype; - PyObject *tuple; - PyGetSetDescrObject *static_getset; - PyTypeObject *metatype; - PyTypeObject *swigpyobject; - SwigPyClientData *cd; - PyObject *public_interface, *public_symbol; - PyObject *this_descr; - PyObject *thisown_descr; - PyObject *self = 0; - int i; - - (void)builtin_pytype; - (void)builtin_base_count; - (void)builtin_basetype; - (void)tuple; - (void)static_getset; - (void)self; - - /* Metaclass is used to implement static member variables */ - metatype = SwigPyObjectType(); - assert(metatype); -#endif - - (void)globals; - - /* Create singletons now to avoid potential deadlocks with multi-threaded usage after module initialization */ - SWIG_This(); - SWIG_Python_TypeCache(); - SwigPyPacked_type(); + static SwigPyClientData SwigPyObject_clientdata = { + 0, 0, 0, 0, 0, 0, 0 + }; + static PyGetSetDef this_getset_def = { + (char *)"this", &SwigPyBuiltin_ThisClosure, NULL, NULL, NULL + }; + static SwigPyGetSet thisown_getset_closure = { + SwigPyObject_own, + SwigPyObject_own + }; + static PyGetSetDef thisown_getset_def = { + (char *)"thisown", SwigPyBuiltin_GetterClosure, SwigPyBuiltin_SetterClosure, NULL, &thisown_getset_closure + }; + PyTypeObject *builtin_pytype; + int builtin_base_count; + swig_type_info *builtin_basetype; + PyObject *tuple; + PyGetSetDescrObject *static_getset; + PyTypeObject *metatype; + PyTypeObject *swigpyobject; + SwigPyClientData *cd; + PyObject *public_interface, *public_symbol; + PyObject *this_descr; + PyObject *thisown_descr; + PyObject *self = 0; + int i; + + (void)builtin_pytype; + (void)builtin_base_count; + (void)builtin_basetype; + (void)tuple; + (void)static_getset; + (void)self; + + /* Metaclass is used to implement static member variables */ + metatype = SwigPyObjectType(); + assert(metatype); +#endif + + (void)globals; + + /* Create singletons now to avoid potential deadlocks with multi-threaded usage after module initialization */ + SWIG_This(); + SWIG_Python_TypeCache(); + SwigPyPacked_type(); #ifndef SWIGPYTHON_BUILTIN - SwigPyObject_type(); + SwigPyObject_type(); #endif - - /* Fix SwigMethods to carry the callback ptrs when needed */ - SWIG_Python_FixMethods(SwigMethods, swig_const_table, swig_types, swig_type_initial); - + + /* Fix SwigMethods to carry the callback ptrs when needed */ + SWIG_Python_FixMethods(SwigMethods, swig_const_table, swig_types, swig_type_initial); + #if PY_VERSION_HEX >= 0x03000000 - m = PyModule_Create(&SWIG_module); + m = PyModule_Create(&SWIG_module); #else - m = Py_InitModule(SWIG_name, SwigMethods); -#endif - - md = d = PyModule_GetDict(m); - (void)md; - - SWIG_InitializeModule(0); - + m = Py_InitModule(SWIG_name, SwigMethods); +#endif + + md = d = PyModule_GetDict(m); + (void)md; + + SWIG_InitializeModule(0); + #ifdef SWIGPYTHON_BUILTIN - swigpyobject = SwigPyObject_TypeOnce(); - - SwigPyObject_stype = SWIG_MangledTypeQuery("_p_SwigPyObject"); - assert(SwigPyObject_stype); - cd = (SwigPyClientData *) SwigPyObject_stype->clientdata; - if (!cd) { - SwigPyObject_stype->clientdata = &SwigPyObject_clientdata; - SwigPyObject_clientdata.pytype = swigpyobject; - } else if (swigpyobject->tp_basicsize != cd->pytype->tp_basicsize) { - PyErr_SetString(PyExc_RuntimeError, "Import error: attempted to load two incompatible swig-generated modules."); + swigpyobject = SwigPyObject_TypeOnce(); + + SwigPyObject_stype = SWIG_MangledTypeQuery("_p_SwigPyObject"); + assert(SwigPyObject_stype); + cd = (SwigPyClientData*) SwigPyObject_stype->clientdata; + if (!cd) { + SwigPyObject_stype->clientdata = &SwigPyObject_clientdata; + SwigPyObject_clientdata.pytype = swigpyobject; + } else if (swigpyobject->tp_basicsize != cd->pytype->tp_basicsize) { + PyErr_SetString(PyExc_RuntimeError, "Import error: attempted to load two incompatible swig-generated modules."); # if PY_VERSION_HEX >= 0x03000000 - return NULL; + return NULL; # else - return; + return; # endif - } - - /* All objects have a 'this' attribute */ - this_descr = PyDescr_NewGetSet(SwigPyObject_type(), &this_getset_def); - (void)this_descr; - - /* All objects have a 'thisown' attribute */ - thisown_descr = PyDescr_NewGetSet(SwigPyObject_type(), &thisown_getset_def); - (void)thisown_descr; - - public_interface = PyList_New(0); - public_symbol = 0; - (void)public_symbol; - - PyDict_SetItemString(md, "__all__", public_interface); - Py_DECREF(public_interface); - for (i = 0; SwigMethods[i].ml_name != NULL; ++i) - SwigPyBuiltin_AddPublicSymbol(public_interface, SwigMethods[i].ml_name); - for (i = 0; swig_const_table[i].name != 0; ++i) - SwigPyBuiltin_AddPublicSymbol(public_interface, swig_const_table[i].name); -#endif - - SWIG_InstallConstants(d, swig_const_table); - + } + + /* All objects have a 'this' attribute */ + this_descr = PyDescr_NewGetSet(SwigPyObject_type(), &this_getset_def); + (void)this_descr; + + /* All objects have a 'thisown' attribute */ + thisown_descr = PyDescr_NewGetSet(SwigPyObject_type(), &thisown_getset_def); + (void)thisown_descr; + + public_interface = PyList_New(0); + public_symbol = 0; + (void)public_symbol; + + PyDict_SetItemString(md, "__all__", public_interface); + Py_DECREF(public_interface); + for (i = 0; SwigMethods[i].ml_name != NULL; ++i) + SwigPyBuiltin_AddPublicSymbol(public_interface, SwigMethods[i].ml_name); + for (i = 0; swig_const_table[i].name != 0; ++i) + SwigPyBuiltin_AddPublicSymbol(public_interface, swig_const_table[i].name); +#endif + + SWIG_InstallConstants(d,swig_const_table); + #if PY_VERSION_HEX >= 0x03000000 - return m; + return m; #else - return; + return; #endif }