From 538ee4dabb8087660878981c4b966212482350e6 Mon Sep 17 00:00:00 2001 From: slurdge Date: Sun, 14 Jun 2020 11:32:37 +0200 Subject: [PATCH] Better SWIG integration: autogen func & attributes --- client/client_with_swig/00make_swig.sh | 4 +- client/client_with_swig/testembedded.lua | 4 +- client/client_with_swig/testembedded.py | 2 +- client/include/pm3.h | 55 +- client/include/pm3.i | 39 + client/lib/example_lua/test.lua | 4 +- client/lib/example_py/test.py | 2 +- client/src/comms.h | 1 + client/src/pm3.py | 158 +-- client/src/pm3_luawrap.c | 321 ++---- client/src/pm3_pywrap.c | 1326 +++++++++++----------- client/src/proxmark3.c | 8 +- 12 files changed, 887 insertions(+), 1037 deletions(-) create mode 100644 client/include/pm3.i diff --git a/client/client_with_swig/00make_swig.sh b/client/client_with_swig/00make_swig.sh index 20d1a55b3..8c1adafb3 100755 --- a/client/client_with_swig/00make_swig.sh +++ b/client/client_with_swig/00make_swig.sh @@ -1,4 +1,4 @@ #!/bin/bash -swig -lua -o ../src/pm3_luawrap.c ../include/pm3.h -swig -python -o ../src/pm3_pywrap.c ../include/pm3.h +swig -lua -o ../src/pm3_luawrap.c ../include/pm3.i +swig -python -o ../src/pm3_pywrap.c ../include/pm3.i diff --git a/client/client_with_swig/testembedded.lua b/client/client_with_swig/testembedded.lua index 27361f1d0..e67630e7d 100755 --- a/client/client_with_swig/testembedded.lua +++ b/client/client_with_swig/testembedded.lua @@ -1,4 +1,4 @@ local pm3 = require("pm3") p=pm3.device() ---p.console("hw status") ?? -p.console(p, "hw status") +p:console("hw status") +print(p.name) diff --git a/client/client_with_swig/testembedded.py b/client/client_with_swig/testembedded.py index 5f58c2bb6..6f5afc37e 100755 --- a/client/client_with_swig/testembedded.py +++ b/client/client_with_swig/testembedded.py @@ -3,4 +3,4 @@ import pm3 p=pm3.device() p.console("hw status") -print("Device:", p.get_name()) +print("Device:", p.name) diff --git a/client/include/pm3.h b/client/include/pm3.h index 228a4dcb6..c66f6768a 100644 --- a/client/include/pm3.h +++ b/client/include/pm3.h @@ -1,56 +1,11 @@ #ifndef LIBPM3_H #define LIBPM3_H -#ifdef SWIG -%module pm3 -%{ -/* Include the header in the wrapper code */ -#include "pm3.h" -%} - -/* Strip "pm3_" from API functions for SWIG */ -%rename("%(strip:[pm3_])s") ""; -%feature("immutable","1") pm3_current_dev; -struct pm3_device { }; -%extend pm3_device { - pm3_device() { - printf("SWIG pm3_device constructor, get current pm3\n"); - _embedded = 1; - return pm3_get_current_dev(); - } - pm3_device(char *port) { - printf("SWIG pm3_device constructor with port, open pm3\n"); - _embedded = 0; - return pm3_open(port); - } - ~pm3_device() { - if (_embedded) { - printf("SWIG pm3_device destructor, nothing to do\n"); - } else { - printf("SWIG pm3_device destructor, close pm3\n"); - pm3_close($self); - } - } - int console(char *cmd) { - return pm3_console($self, cmd); - } - char *get_name() { - return pm3_get_name($self); - } -} -//%nodefaultctor pm3_device; -//%nodefaultdtor pm3_device; - -/* Parse the header file to generate wrappers */ -#endif // SWIG - -// TODO better than this global? -int _embedded; - typedef struct pm3_device pm3_device; + pm3_device* pm3_open(char *port); -int pm3_console(pm3_device* dev, char *cmd); -char *pm3_get_name(pm3_device* dev); -void pm3_close(pm3_device* dev); -pm3_device* pm3_get_current_dev(void); +int pm3_device_console(pm3_device* dev, char *cmd); +char *pm3_device_name_get(pm3_device* dev); +void pm3_device_close(pm3_device* dev); +pm3_device* pm3_device_get_current_dev(void); #endif // LIBPM3_H diff --git a/client/include/pm3.i b/client/include/pm3.i new file mode 100644 index 000000000..1350df138 --- /dev/null +++ b/client/include/pm3.i @@ -0,0 +1,39 @@ +%module pm3 +%{ +/* Include the header in the wrapper code */ +#include "pm3.h" +#include "comms.h" +%} + +/* Strip "pm3_" from API functions for SWIG */ +%rename("%(strip:[pm3_])s") ""; +%feature("immutable","1") pm3_current_dev; +typedef struct { + %extend { + pm3_device() { + printf("SWIG pm3_device constructor, get current pm3\n"); + pm3_device * p = pm3_device_get_current_dev(); + p->script_embedded = 1; + return p; + } + pm3_device(char *port) { + printf("SWIG pm3_device constructor with port, open pm3\n"); + pm3_device * p = pm3_open(port); + p->script_embedded = 1; + return p; + } + ~pm3_device() { + if ($self->script_embedded) { + printf("SWIG pm3_device destructor, nothing to do\n"); + } else { + printf("SWIG pm3_device destructor, close pm3\n"); + pm3_device_close($self); + } + } + int console(char *cmd); + char const * const name; + } +} pm3_device; +//%nodefaultctor device; +//%nodefaultdtor device; +/* Parse the header file to generate wrappers */ \ No newline at end of file diff --git a/client/lib/example_lua/test.lua b/client/lib/example_lua/test.lua index 2acd38657..f640d5abf 100755 --- a/client/lib/example_lua/test.lua +++ b/client/lib/example_lua/test.lua @@ -2,5 +2,5 @@ local pm3 = require("pm3") p=pm3.device("/dev/ttyACM0") ---p.console("hw status") ?? -p.console(p, "hw status") +p:console("hw status") +print(p.name) diff --git a/client/lib/example_py/test.py b/client/lib/example_py/test.py index 93154269a..5bdbee089 100755 --- a/client/lib/example_py/test.py +++ b/client/lib/example_py/test.py @@ -3,4 +3,4 @@ import pm3 p=pm3.device("/dev/ttyACM0") p.console("hw status") -print("Device:", p.get_name()) +print("Device:", p.name) diff --git a/client/src/comms.h b/client/src/comms.h index e35183a52..3ee691a30 100644 --- a/client/src/comms.h +++ b/client/src/comms.h @@ -68,6 +68,7 @@ extern communication_arg_t conn; typedef struct pm3_device pm3_device; struct pm3_device { communication_arg_t *conn; + int script_embedded; }; void *uart_receiver(void *targ); diff --git a/client/src/pm3.py b/client/src/pm3.py index 5807bde8a..c59db1811 100644 --- a/client/src/pm3.py +++ b/client/src/pm3.py @@ -1,24 +1,85 @@ # This file was automatically generated by SWIG (http://www.swig.org). -# Version 4.0.1 +# Version 3.0.12 # # Do not make changes to this file unless you know what you are doing--modify # the SWIG interface file instead. from sys import version_info as _swig_python_version_info -if _swig_python_version_info < (2, 7, 0): - raise RuntimeError("Python 2.7 or later required") - -# Import the low-level C/C++ module -if __package__ or "." in __name__: - from . import _pm3 +if _swig_python_version_info >= (2, 7, 0): + def swig_import_helper(): + import importlib + pkg = __name__.rpartition('.')[0] + mname = '.'.join((pkg, '_pm3')).lstrip('.') + try: + return importlib.import_module(mname) + except ImportError: + return importlib.import_module('_pm3') + _pm3 = swig_import_helper() + del swig_import_helper +elif _swig_python_version_info >= (2, 6, 0): + def swig_import_helper(): + from os.path import dirname + import imp + fp = None + try: + fp, pathname, description = imp.find_module('_pm3', [dirname(__file__)]) + except ImportError: + import _pm3 + return _pm3 + try: + _mod = imp.load_module('_pm3', fp, pathname, description) + finally: + if fp is not None: + fp.close() + return _mod + _pm3 = swig_import_helper() + del swig_import_helper else: import _pm3 +del _swig_python_version_info + +try: + _swig_property = property +except NameError: + pass # Python < 2.2 doesn't have 'property'. try: import builtins as __builtin__ except ImportError: import __builtin__ +def _swig_setattr_nondynamic(self, class_type, name, value, static=1): + if (name == "thisown"): + return self.this.own(value) + if (name == "this"): + if type(value).__name__ == 'SwigPyObject': + self.__dict__[name] = value + return + method = class_type.__swig_setmethods__.get(name, None) + if method: + return method(self, value) + if (not static): + if _newclass: + object.__setattr__(self, name, value) + else: + self.__dict__[name] = value + else: + raise AttributeError("You cannot add attributes to %s" % self) + + +def _swig_setattr(self, class_type, name, value): + return _swig_setattr_nondynamic(self, class_type, name, value, 0) + + +def _swig_getattr(self, class_type, name): + if (name == "thisown"): + return self.this.own() + method = class_type.__swig_getmethods__.get(name, None) + if method: + return method(self) + raise AttributeError("'%s' object has no attribute '%s'" % (class_type.__name__, name)) + + def _swig_repr(self): try: strthis = "proxy of " + self.this.__repr__() @@ -26,73 +87,38 @@ def _swig_repr(self): strthis = "" return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,) +try: + _object = object + _newclass = 1 +except __builtin__.Exception: + class _object: + pass + _newclass = 0 -def _swig_setattr_nondynamic_instance_variable(set): - def set_instance_attr(self, name, value): - if name == "thisown": - self.this.own(value) - elif name == "this": - set(self, name, value) - elif hasattr(self, name) and isinstance(getattr(type(self), name), property): - set(self, name, value) - else: - raise AttributeError("You cannot add instance attributes to %s" % self) - return set_instance_attr - - -def _swig_setattr_nondynamic_class_variable(set): - def set_class_attr(cls, name, value): - if hasattr(cls, name) and not isinstance(getattr(cls, name), property): - set(cls, name, value) - else: - raise AttributeError("You cannot add class attributes to %s" % cls) - return set_class_attr - - -def _swig_add_metaclass(metaclass): - """Class decorator for adding a metaclass to a SWIG wrapped class - a slimmed down version of six.add_metaclass""" - def wrapper(cls): - return metaclass(cls.__name__, cls.__bases__, cls.__dict__.copy()) - return wrapper - - -class _SwigNonDynamicMeta(type): - """Meta class to enforce nondynamic attributes (no new attributes) for a class""" - __setattr__ = _swig_setattr_nondynamic_class_variable(type.__setattr__) - - -class device(object): - thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") +class device(_object): + __swig_setmethods__ = {} + __setattr__ = lambda self, name, value: _swig_setattr(self, device, name, value) + __swig_getmethods__ = {} + __getattr__ = lambda self, name: _swig_getattr(self, device, name) __repr__ = _swig_repr def __init__(self, *args): - _pm3.device_swiginit(self, _pm3.new_device(*args)) + this = _pm3.new_device(*args) + try: + self.this.append(this) + except __builtin__.Exception: + self.this = this __swig_destroy__ = _pm3.delete_device + __del__ = lambda self: None def console(self, cmd): return _pm3.device_console(self, cmd) + __swig_getmethods__["name"] = _pm3.device_name_get + if _newclass: + name = _swig_property(_pm3.device_name_get) +device_swigregister = _pm3.device_swigregister +device_swigregister(device) - def get_name(self): - return _pm3.device_get_name(self) - -# Register device in _pm3: -_pm3.device_swigregister(device) +# This file is compatible with both classic and new-style classes. -def open(port): - return _pm3.open(port) - -def console(dev, cmd): - return _pm3.console(dev, cmd) - -def get_name(dev): - return _pm3.get_name(dev) - -def close(dev): - return _pm3.close(dev) - -def get_current_dev(): - return _pm3.get_current_dev() - -cvar = _pm3.cvar - diff --git a/client/src/pm3_luawrap.c b/client/src/pm3_luawrap.c index e87261a6d..12dfa2831 100644 --- a/client/src/pm3_luawrap.c +++ b/client/src/pm3_luawrap.c @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 4.0.1 + * Version 3.0.12 * * This file is not intended to be easily readable and contains a number of * coding conventions designed to improve portability and efficiency. Do not make @@ -185,7 +185,6 @@ /* Flags for pointer conversions */ #define SWIG_POINTER_DISOWN 0x1 #define SWIG_CAST_NEW_MEMORY 0x2 -#define SWIG_POINTER_NO_NULL 0x4 /* Flags for new pointer objects */ #define SWIG_POINTER_OWN 0x1 @@ -714,23 +713,6 @@ SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) { } #endif -/* Errors in SWIG */ -#define SWIG_UnknownError -1 -#define SWIG_IOError -2 -#define SWIG_RuntimeError -3 -#define SWIG_IndexError -4 -#define SWIG_TypeError -5 -#define SWIG_DivisionByZero -6 -#define SWIG_OverflowError -7 -#define SWIG_SyntaxError -8 -#define SWIG_ValueError -9 -#define SWIG_SystemError -10 -#define SWIG_AttributeError -11 -#define SWIG_MemoryError -12 -#define SWIG_NullReferenceError -13 - - - /* ----------------------------------------------------------------------------- * luarun.swg * @@ -913,8 +895,8 @@ typedef struct swig_elua_entry { * -------------------------------------------------------------------------- */ /* Push the string STR on the Lua stack, like lua_pushstring, but - prefixed with the location of the innermost Lua call-point - (as formatted by luaL_where). */ + prefixed with the the location of the innermost Lua call-point + (as formated by luaL_where). */ SWIGRUNTIME void SWIG_Lua_pusherrstring (lua_State *L, const char *str) { @@ -924,8 +906,8 @@ SWIG_Lua_pusherrstring (lua_State *L, const char *str) } /* 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). */ + the Lua stack, like lua_pushfstring, but prefixed with the the + location of the innermost Lua call-point (as formated by luaL_where). */ SWIGRUNTIME void SWIG_Lua_pushferrstring (lua_State *L, const char *fmt, ...) { @@ -1022,7 +1004,7 @@ 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 */ + char data[1]; /* arbitary amount of data */ } swig_lua_rawdata; /* Common SWIG API */ @@ -1074,7 +1056,7 @@ typedef struct { #define SWIG_isptrtype(L,I) (lua_isuserdata(L,I) || lua_isnil(L,I)) #ifdef __cplusplus -/* Special helper for member function pointers +/* Special helper for member function pointers it gets the address, casts it, then dereferences it */ /*#define SWIG_mem_fn_as_voidptr(a) (*((char**)&(a))) */ #endif @@ -1177,7 +1159,7 @@ SWIGINTERN void SWIG_Lua_elua_emulate_register(lua_State *L, const swig_elua_ent 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); @@ -1186,11 +1168,11 @@ SWIGINTERN void SWIG_Lua_elua_emulate_register(lua_State *L, const swig_elua_ent break; case LUA_TUSERDATA: - if(entry->value.value.userdata.member) + 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 + else SWIG_NewPointerObj(L,entry->value.value.userdata.pvalue, *(entry->value.value.userdata.ptype),0); break; @@ -1235,7 +1217,7 @@ SWIGINTERN int SWIG_Lua_emulate_elua_getmetatable(lua_State *L) } assert(lua_gettop(L) == 2); return 1; - + fail: lua_error(L); return 0; @@ -1253,7 +1235,7 @@ SWIGINTERN void SWIG_Lua_emulate_elua_swap_getmetatable(lua_State *L) lua_pushcfunction(L, SWIG_Lua_emulate_elua_getmetatable); lua_rawset(L,-3); lua_pop(L,2); - + } /* END OF REMOVE */ @@ -1772,11 +1754,17 @@ 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; + const char *className; + void* userData; assert(lua_isuserdata(L,1)); /* just in case */ - userData = (swig_lua_userdata*)lua_touserdata(L,1); /* get the userdata address */ + userData = lua_touserdata(L,1); /* get the userdata address for later */ + lua_getmetatable(L,1); /* get the meta table */ + assert(lua_istable(L,-1)); /* just in case */ - lua_pushfstring(L, "", userData->type->str, userData->ptr); + lua_getfield(L, -1, ".type"); + className = lua_tostring(L, -1); + + lua_pushfstring(L, "<%s userdata: %p>", className, userData); return 1; } @@ -1788,7 +1776,7 @@ SWIGINTERN int SWIG_Lua_class_disown(lua_State *L) 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; } @@ -1897,7 +1885,7 @@ SWIGINTERN void SWIG_Lua_get_class_metatable(lua_State *L,const char *cname) Each class structure has a list of pointers to the base class structures. This function fills them. It cannot be done at compile time, as this will not work with hireachies -spread over more than one swig file. +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) @@ -2131,11 +2119,11 @@ SWIGRUNTIME int SWIG_Lua_resolve_metamethod(lua_State *L) 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 */ @@ -2167,7 +2155,7 @@ SWIGINTERN int SWIG_Lua_add_class_user_metamethod(lua_State *L, swig_lua_class * /* 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 */ @@ -2177,7 +2165,7 @@ SWIGINTERN int SWIG_Lua_add_class_user_metamethod(lua_State *L, swig_lua_class * lua_pop(L,1); return -1; } - lua_pop(L,1); + lua_pop(L,1); /* Iterating over immediate bases */ for(i=0;clss->bases[i];i++) @@ -2187,13 +2175,13 @@ SWIGINTERN int SWIG_Lua_add_class_user_metamethod(lua_State *L, swig_lua_class * lua_pushvalue(L, key_index); lua_rawget(L, -2); if( !lua_isnil(L,-1) ) { - lua_pushvalue(L, key_index); + 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; } @@ -2204,7 +2192,7 @@ SWIGINTERN int SWIG_Lua_add_class_user_metamethod(lua_State *L, swig_lua_class * break; } - return success; + return success; } SWIGINTERN void SWIG_Lua_add_class_user_metamethods(lua_State *L, swig_lua_class *clss) @@ -2492,12 +2480,7 @@ SWIGRUNTIME int SWIG_Lua_ConvertPtr(lua_State *L,int index,void **ptr,swig_type { 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_isnil(L,index)){*ptr=0; return SWIG_OK;} /* special case: lua nil => NULL pointer */ usr=(swig_lua_userdata*)lua_touserdata(L,index); /* get data */ if (usr) { @@ -2543,7 +2526,7 @@ SWIGRUNTIME void SWIG_Lua_NewPackedObj(lua_State *L,void *ptr,size_t size,swig_t 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) { @@ -2592,7 +2575,7 @@ SWIG_Lua_InstallConstants(lua_State *L, swig_lua_const_info constants[]) { switch(constants[i].type) { case SWIG_LUA_INT: lua_pushstring(L,constants[i].name); - lua_pushinteger(L,(lua_Integer)constants[i].lvalue); + lua_pushinteger(L,(lua_Number)constants[i].lvalue); lua_rawset(L,-3); break; case SWIG_LUA_FLOAT: @@ -2603,7 +2586,7 @@ SWIG_Lua_InstallConstants(lua_State *L, swig_lua_const_info constants[]) { case SWIG_LUA_CHAR: lua_pushstring(L,constants[i].name); { - char c = (char)constants[i].lvalue; + char c = constants[i].lvalue; lua_pushlstring(L,&c,1); } lua_rawset(L,-3); @@ -2642,7 +2625,7 @@ Unfortunately lua keeps changing its APIs, so we need a conditional compile In lua 5.0.X it's lua_dostring() In lua 5.1.X it's luaL_dostring() */ -SWIGINTERN int +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 */ @@ -2657,7 +2640,7 @@ SWIG_Lua_dostring(lua_State *L, const char *str) { } lua_settop(L,top); /* restore the stack */ return ok; -} +} #ifdef __cplusplus } @@ -2684,12 +2667,14 @@ static swig_module_info swig_module = {swig_types, 1, 0, 0, 0, 0}; /* Include the header in the wrapper code */ #include "pm3.h" +#include "comms.h" -SWIGINTERN struct pm3_device *new_pm3_device__SWIG_0(void){ - printf("SWIG pm3_device constructor, get current pm3\n"); - _embedded = 1; - return pm3_get_current_dev(); - } +SWIGINTERN pm3_device *new_pm3_device__SWIG_0(void){ + printf("SWIG pm3_device constructor, get current pm3\n"); + pm3_device * p = pm3_device_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); @@ -2698,34 +2683,29 @@ SWIGINTERN int SWIG_lua_isnilstring(lua_State *L, int idx) { return ret; } -SWIGINTERN struct pm3_device *new_pm3_device__SWIG_1(char *port){ - printf("SWIG pm3_device constructor with port, open pm3\n"); - _embedded = 0; - return pm3_open(port); - } -SWIGINTERN void delete_pm3_device(struct pm3_device *self){ - if (_embedded) { - printf("SWIG pm3_device destructor, nothing to do\n"); - } else { - printf("SWIG pm3_device destructor, close pm3\n"); - pm3_close(self); +SWIGINTERN pm3_device *new_pm3_device__SWIG_1(char *port){ + printf("SWIG pm3_device constructor with port, open pm3\n"); + pm3_device * p = pm3_open(port); + p->script_embedded = 1; + return p; + } +SWIGINTERN void delete_pm3_device(pm3_device *self){ + if (self->script_embedded) { + printf("SWIG pm3_device destructor, nothing to do\n"); + } else { + printf("SWIG pm3_device destructor, close pm3\n"); + pm3_device_close(self); + } } - } -SWIGINTERN int pm3_device_console(struct pm3_device *self,char *cmd){ - return pm3_console(self, cmd); - } -SWIGINTERN char *pm3_device_get_name(struct pm3_device *self){ - return pm3_get_name(self); - } #ifdef __cplusplus extern "C" { #endif static int _wrap_new_device__SWIG_0(lua_State* L) { int SWIG_arg = 0; - struct pm3_device *result = 0 ; + pm3_device *result = 0 ; SWIG_check_num_args("pm3_device::pm3_device",0,0) - result = (struct pm3_device *)new_pm3_device__SWIG_0(); + result = (pm3_device *)new_pm3_device__SWIG_0(); SWIG_NewPointerObj(L,result,SWIGTYPE_p_pm3_device,1); SWIG_arg++; return SWIG_arg; @@ -2740,12 +2720,12 @@ fail: static int _wrap_new_device__SWIG_1(lua_State* L) { int SWIG_arg = 0; char *arg1 = (char *) 0 ; - struct pm3_device *result = 0 ; + pm3_device *result = 0 ; SWIG_check_num_args("pm3_device::pm3_device",1,1) if(!SWIG_lua_isnilstring(L,1)) SWIG_fail_arg("pm3_device::pm3_device",1,"char *"); arg1 = (char *)lua_tostring(L, 1); - result = (struct pm3_device *)new_pm3_device__SWIG_1(arg1); + result = (pm3_device *)new_pm3_device__SWIG_1(arg1); SWIG_NewPointerObj(L,result,SWIGTYPE_p_pm3_device,1); SWIG_arg++; return SWIG_arg; @@ -2787,12 +2767,12 @@ static int _wrap_new_device(lua_State* L) { static int _wrap_device_console(lua_State* L) { int SWIG_arg = 0; - struct pm3_device *arg1 = (struct pm3_device *) 0 ; + pm3_device *arg1 = (pm3_device *) 0 ; char *arg2 = (char *) 0 ; int result; SWIG_check_num_args("pm3_device::console",2,2) - if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("pm3_device::console",1,"struct pm3_device *"); + if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("pm3_device::console",1,"pm3_device *"); if(!SWIG_lua_isnilstring(L,2)) SWIG_fail_arg("pm3_device::console",2,"char *"); if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_pm3_device,0))){ @@ -2812,19 +2792,19 @@ fail: } -static int _wrap_device_get_name(lua_State* L) { +static int _wrap_device_name_get(lua_State* L) { int SWIG_arg = 0; - struct pm3_device *arg1 = (struct pm3_device *) 0 ; + pm3_device *arg1 = (pm3_device *) 0 ; char *result = 0 ; - SWIG_check_num_args("pm3_device::get_name",1,1) - if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("pm3_device::get_name",1,"struct pm3_device *"); + SWIG_check_num_args("pm3_device::name",1,1) + if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("pm3_device::name",1,"pm3_device *"); if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_pm3_device,0))){ - SWIG_fail_ptr("device_get_name",1,SWIGTYPE_p_pm3_device); + SWIG_fail_ptr("device_name_get",1,SWIGTYPE_p_pm3_device); } - result = (char *)pm3_device_get_name(arg1); + result = (char *)pm3_device_name_get(arg1); lua_pushstring(L,(const char *)result); SWIG_arg++; return SWIG_arg; @@ -2837,7 +2817,7 @@ fail: static void swig_delete_device(void *obj) { -struct pm3_device *arg1 = (struct pm3_device *) obj; +pm3_device *arg1 = (pm3_device *) obj; delete_pm3_device(arg1); } static int _proxy__wrap_new_device(lua_State *L) { @@ -2849,11 +2829,11 @@ static int _proxy__wrap_new_device(lua_State *L) { return 1; } static swig_lua_attribute swig_device_attributes[] = { + { "name", _wrap_device_name_get, SWIG_Lua_set_immutable }, {0,0,0} }; static swig_lua_method swig_device_methods[]= { { "console", _wrap_device_console}, - { "get_name", _wrap_device_get_name}, {0,0} }; static swig_lua_method swig_device_meta[] = { @@ -2885,166 +2865,13 @@ static swig_lua_class *swig_device_bases[] = {0}; static const char *swig_device_base_names[] = {0}; static swig_lua_class _wrap_class_device = { "device", "device", &SWIGTYPE_p_pm3_device,_proxy__wrap_new_device, swig_delete_device, swig_device_methods, swig_device_attributes, &swig_device_Sf_SwigStatic, swig_device_meta, swig_device_bases, swig_device_base_names }; -static int _wrap__embedded_set(lua_State* L) { - int SWIG_arg = 0; - int arg1 ; - - SWIG_check_num_args("_embedded",1,1) - if(!lua_isnumber(L,1)) SWIG_fail_arg("_embedded",1,"int"); - arg1 = (int)lua_tonumber(L, 1); - _embedded = arg1; - - return SWIG_arg; - - if(0) SWIG_fail; - -fail: - lua_error(L); - return SWIG_arg; -} - - -static int _wrap__embedded_get(lua_State* L) { - int SWIG_arg = 0; - int result; - - SWIG_check_num_args("_embedded",0,0) - result = (int)_embedded; - lua_pushnumber(L, (lua_Number) result); SWIG_arg++; - return SWIG_arg; - - if(0) SWIG_fail; - -fail: - lua_error(L); - return SWIG_arg; -} - - -static int _wrap_open(lua_State* L) { - int SWIG_arg = 0; - char *arg1 = (char *) 0 ; - pm3_device *result = 0 ; - - SWIG_check_num_args("pm3_open",1,1) - if(!SWIG_lua_isnilstring(L,1)) SWIG_fail_arg("pm3_open",1,"char *"); - arg1 = (char *)lua_tostring(L, 1); - result = (pm3_device *)pm3_open(arg1); - SWIG_NewPointerObj(L,result,SWIGTYPE_p_pm3_device,0); SWIG_arg++; - return SWIG_arg; - - if(0) SWIG_fail; - -fail: - lua_error(L); - return SWIG_arg; -} - - -static int _wrap_console(lua_State* L) { - int SWIG_arg = 0; - pm3_device *arg1 = (pm3_device *) 0 ; - char *arg2 = (char *) 0 ; - int result; - - SWIG_check_num_args("pm3_console",2,2) - if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("pm3_console",1,"pm3_device *"); - if(!SWIG_lua_isnilstring(L,2)) SWIG_fail_arg("pm3_console",2,"char *"); - - if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_pm3_device,0))){ - SWIG_fail_ptr("console",1,SWIGTYPE_p_pm3_device); - } - - arg2 = (char *)lua_tostring(L, 2); - result = (int)pm3_console(arg1,arg2); - lua_pushnumber(L, (lua_Number) result); SWIG_arg++; - return SWIG_arg; - - if(0) SWIG_fail; - -fail: - lua_error(L); - return SWIG_arg; -} - - -static int _wrap_get_name(lua_State* L) { - int SWIG_arg = 0; - pm3_device *arg1 = (pm3_device *) 0 ; - char *result = 0 ; - - SWIG_check_num_args("pm3_get_name",1,1) - if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("pm3_get_name",1,"pm3_device *"); - - if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_pm3_device,0))){ - SWIG_fail_ptr("get_name",1,SWIGTYPE_p_pm3_device); - } - - result = (char *)pm3_get_name(arg1); - lua_pushstring(L,(const char *)result); SWIG_arg++; - return SWIG_arg; - - if(0) SWIG_fail; - -fail: - lua_error(L); - return SWIG_arg; -} - - -static int _wrap_close(lua_State* L) { - int SWIG_arg = 0; - pm3_device *arg1 = (pm3_device *) 0 ; - - SWIG_check_num_args("pm3_close",1,1) - if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("pm3_close",1,"pm3_device *"); - - if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_pm3_device,0))){ - SWIG_fail_ptr("close",1,SWIGTYPE_p_pm3_device); - } - - pm3_close(arg1); - - return SWIG_arg; - - if(0) SWIG_fail; - -fail: - lua_error(L); - return SWIG_arg; -} - - -static int _wrap_get_current_dev(lua_State* L) { - int SWIG_arg = 0; - pm3_device *result = 0 ; - - SWIG_check_num_args("pm3_get_current_dev",0,0) - result = (pm3_device *)pm3_get_current_dev(); - SWIG_NewPointerObj(L,result,SWIGTYPE_p_pm3_device,0); SWIG_arg++; - return SWIG_arg; - - if(0) SWIG_fail; - -fail: - lua_error(L); - return SWIG_arg; -} - - static swig_lua_attribute swig_SwigModule_attributes[] = { - { "_embedded", _wrap__embedded_get, _wrap__embedded_set }, {0,0,0} }; static swig_lua_const_info swig_SwigModule_constants[]= { {0,0,0,0,0,0} }; static swig_lua_method swig_SwigModule_methods[]= { - { "open", _wrap_open}, - { "console", _wrap_console}, - { "get_name", _wrap_get_name}, - { "close", _wrap_close}, - { "get_current_dev", _wrap_get_current_dev}, {0,0} }; static swig_lua_class* swig_SwigModule_classes[]= { @@ -3069,7 +2896,7 @@ static swig_lua_namespace swig_SwigModule = { /* -------- TYPE CONVERSION AND EQUIVALENCE RULES (BEGIN) -------- */ -static swig_type_info _swigt__p_pm3_device = {"_p_pm3_device", "struct pm3_device *|pm3_device *", 0, 0, (void*)&_wrap_class_device, 0}; +static swig_type_info _swigt__p_pm3_device = {"_p_pm3_device", "pm3_device *", 0, 0, (void*)&_wrap_class_device, 0}; static swig_type_info *swig_type_initial[] = { &_swigt__p_pm3_device, @@ -3184,7 +3011,7 @@ SWIG_InitializeModule(void *clientdata) { /* 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 %d\n", swig_module.size); #endif for (i = 0; i < swig_module.size; ++i) { swig_type_info *type = 0; @@ -3192,7 +3019,7 @@ SWIG_InitializeModule(void *clientdata) { 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 %d %s\n", i, swig_module.type_initial[i]->name); #endif /* if there is another module already loaded */ @@ -3268,7 +3095,7 @@ SWIG_InitializeModule(void *clientdata) { 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); + printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name); while (cast->type) { printf("SWIG_InitializeModule: cast type %s\n", cast->type->name); cast++; diff --git a/client/src/pm3_pywrap.c b/client/src/pm3_pywrap.c index 544850243..f778a3e74 100644 --- a/client/src/pm3_pywrap.c +++ b/client/src/pm3_pywrap.c @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 4.0.1 + * Version 3.0.12 * * This file is not intended to be easily readable and contains a number of * coding conventions designed to improve portability and efficiency. Do not make @@ -140,16 +140,11 @@ #endif -#if defined(__GNUC__) && defined(_WIN32) && !defined(SWIG_PYTHON_NO_HYPOT_WORKAROUND) -/* Workaround for '::hypot' has not been declared', see https://bugs.python.org/issue11566 */ -# include -#endif - #if defined(_DEBUG) && defined(SWIG_PYTHON_INTERPRETER_NO_DEBUG) /* Use debug wrappers with the Python release dll */ # undef _DEBUG # include -# define _DEBUG 1 +# define _DEBUG #else # include #endif @@ -199,7 +194,6 @@ /* Flags for pointer conversions */ #define SWIG_POINTER_DISOWN 0x1 #define SWIG_CAST_NEW_MEMORY 0x2 -#define SWIG_POINTER_NO_NULL 0x4 /* Flags for new pointer objects */ #define SWIG_POINTER_OWN 0x1 @@ -785,16 +779,14 @@ SWIGINTERN char* SWIG_Python_str_AsChar(PyObject *str) { #if PY_VERSION_HEX >= 0x03000000 - char *newstr = 0; + char *cstr; + char *newstr; + Py_ssize_t len; str = PyUnicode_AsUTF8String(str); - if (str) { - char *cstr; - Py_ssize_t len; - PyBytes_AsStringAndSize(str, &cstr, &len); - newstr = (char *) malloc(len+1); - memcpy(newstr, cstr, len+1); - Py_XDECREF(str); - } + PyBytes_AsStringAndSize(str, &cstr, &len); + newstr = (char *) malloc(len+1); + memcpy(newstr, cstr, len+1); + Py_XDECREF(str); return newstr; #else return PyString_AsString(str); @@ -818,14 +810,144 @@ SWIG_Python_str_FromChar(const char *c) #endif } +/* Add PyOS_snprintf for old Pythons */ +#if PY_VERSION_HEX < 0x02020000 +# if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) +# define PyOS_snprintf _snprintf +# else +# define PyOS_snprintf snprintf +# endif +#endif + +/* A crude PyString_FromFormat implementation for old Pythons */ +#if PY_VERSION_HEX < 0x02020000 + +#ifndef SWIG_PYBUFFER_SIZE +# define SWIG_PYBUFFER_SIZE 1024 +#endif + +static PyObject * +PyString_FromFormat(const char *fmt, ...) { + va_list ap; + char buf[SWIG_PYBUFFER_SIZE * 2]; + int res; + va_start(ap, fmt); + res = vsnprintf(buf, sizeof(buf), fmt, ap); + va_end(ap); + return (res < 0 || res >= (int)sizeof(buf)) ? 0 : PyString_FromString(buf); +} +#endif + #ifndef PyObject_DEL # define PyObject_DEL PyObject_Del #endif -// SWIGPY_USE_CAPSULE is no longer used within SWIG itself, but some user -// interface files check for it. +/* A crude PyExc_StopIteration exception for old Pythons */ +#if PY_VERSION_HEX < 0x02020000 +# ifndef PyExc_StopIteration +# define PyExc_StopIteration PyExc_RuntimeError +# endif +# ifndef PyObject_GenericGetAttr +# define PyObject_GenericGetAttr 0 +# endif +#endif + +/* Py_NotImplemented is defined in 2.1 and up. */ +#if PY_VERSION_HEX < 0x02010000 +# ifndef Py_NotImplemented +# define Py_NotImplemented PyExc_RuntimeError +# endif +#endif + +/* A crude PyString_AsStringAndSize implementation for old Pythons */ +#if PY_VERSION_HEX < 0x02010000 +# ifndef PyString_AsStringAndSize +# define PyString_AsStringAndSize(obj, s, len) {*s = PyString_AsString(obj); *len = *s ? strlen(*s) : 0;} +# endif +#endif + +/* PySequence_Size for old Pythons */ +#if PY_VERSION_HEX < 0x02000000 +# ifndef PySequence_Size +# define PySequence_Size PySequence_Length +# endif +#endif + +/* PyBool_FromLong for old Pythons */ +#if PY_VERSION_HEX < 0x02030000 +static +PyObject *PyBool_FromLong(long ok) +{ + PyObject *result = ok ? Py_True : Py_False; + Py_INCREF(result); + return result; +} +#endif + +/* Py_ssize_t for old Pythons */ +/* This code is as recommended by: */ +/* http://www.python.org/dev/peps/pep-0353/#conversion-guidelines */ +#if PY_VERSION_HEX < 0x02050000 && !defined(PY_SSIZE_T_MIN) +typedef int Py_ssize_t; +# define PY_SSIZE_T_MAX INT_MAX +# define PY_SSIZE_T_MIN INT_MIN +typedef inquiry lenfunc; +typedef intargfunc ssizeargfunc; +typedef intintargfunc ssizessizeargfunc; +typedef intobjargproc ssizeobjargproc; +typedef intintobjargproc ssizessizeobjargproc; +typedef getreadbufferproc readbufferproc; +typedef getwritebufferproc writebufferproc; +typedef getsegcountproc segcountproc; +typedef getcharbufferproc charbufferproc; +static long PyNumber_AsSsize_t (PyObject *x, void *SWIGUNUSEDPARM(exc)) +{ + long result = 0; + PyObject *i = PyNumber_Int(x); + if (i) { + result = PyInt_AsLong(i); + Py_DECREF(i); + } + return result; +} +#endif + +#if PY_VERSION_HEX < 0x02050000 +#define PyInt_FromSize_t(x) PyInt_FromLong((long)x) +#endif + +#if PY_VERSION_HEX < 0x02040000 +#define Py_VISIT(op) \ + do { \ + if (op) { \ + int vret = visit((op), arg); \ + if (vret) \ + return vret; \ + } \ + } while (0) +#endif + +#if PY_VERSION_HEX < 0x02030000 +typedef struct { + PyTypeObject type; + PyNumberMethods as_number; + PyMappingMethods as_mapping; + PySequenceMethods as_sequence; + PyBufferProcs as_buffer; + PyObject *name, *slots; +} PyHeapTypeObject; +#endif + +#if PY_VERSION_HEX < 0x02030000 +typedef destructor freefunc; +#endif + +#if ((PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION > 6) || \ + (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION > 0) || \ + (PY_MAJOR_VERSION > 3)) # define SWIGPY_USE_CAPSULE -# define SWIGPY_CAPSULE_NAME ("swig_runtime_data" SWIG_RUNTIME_VERSION ".type_pointer_capsule" SWIG_TYPE_TABLE_NAME) +# define SWIGPY_CAPSULE_NAME ((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION ".type_pointer_capsule" SWIG_TYPE_TABLE_NAME) +#endif #if PY_VERSION_HEX < 0x03020000 #define PyDescr_TYPE(x) (((PyDescrObject *)(x))->d_type) @@ -888,17 +1010,14 @@ SWIG_Python_AddErrorMsg(const char* mesg) PyObject *value = 0; PyObject *traceback = 0; - if (PyErr_Occurred()) - PyErr_Fetch(&type, &value, &traceback); + if (PyErr_Occurred()) PyErr_Fetch(&type, &value, &traceback); if (value) { + char *tmp; PyObject *old_str = PyObject_Str(value); - const char *tmp = SWIG_Python_str_AsChar(old_str); PyErr_Clear(); Py_XINCREF(type); - if (tmp) - PyErr_Format(type, "%s %s", tmp, mesg); - else - PyErr_Format(type, "%s", mesg); + + PyErr_Format(type, "%s %s", tmp = SWIG_Python_str_AsChar(old_str), mesg); SWIG_Python_str_DelForPy3(tmp); Py_DECREF(old_str); Py_DECREF(value); @@ -907,37 +1026,6 @@ SWIG_Python_AddErrorMsg(const char* mesg) } } -SWIGRUNTIME int -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); -#if PY_VERSION_HEX >= 0x03000000 - newvalue = PyUnicode_FromFormat("%S\nAdditional information:\n%s", value, message); -#else - newvalue = PyString_FromFormat("%s\nAdditional information:\n%s", PyString_AsString(value), message); -#endif - Py_XDECREF(value); - PyErr_Restore(type, newvalue, traceback); - } else { - /* Raise TypeError using given message */ - PyErr_SetString(PyExc_TypeError, message); - } -} - #if defined(SWIG_PYTHON_NO_THREADS) # if defined(SWIG_PYTHON_THREADS) # undef SWIG_PYTHON_THREADS @@ -945,7 +1033,9 @@ SWIG_Python_RaiseOrModifyTypeError(const char *message) #endif #if defined(SWIG_PYTHON_THREADS) /* Threading support is enabled */ # if !defined(SWIG_PYTHON_USE_GIL) && !defined(SWIG_PYTHON_NO_USE_GIL) -# define SWIG_PYTHON_USE_GIL +# if (PY_VERSION_HEX >= 0x02030000) /* For 2.3 or later, use the PyGILState calls */ +# define SWIG_PYTHON_USE_GIL +# endif # endif # if defined(SWIG_PYTHON_USE_GIL) /* Use PyGILState threads calls */ # ifndef SWIG_PYTHON_INITIALIZE_THREADS @@ -1022,13 +1112,30 @@ extern "C" { /* Constant information structure */ typedef struct swig_const_info { int type; - const char *name; + char *name; long lvalue; double dvalue; void *pvalue; swig_type_info **ptype; } swig_const_info; + +/* ----------------------------------------------------------------------------- + * Wrapper of PyInstanceMethod_New() used in Python 3 + * It is exported to the generated module, used for -fastproxy + * ----------------------------------------------------------------------------- */ +#if PY_VERSION_HEX >= 0x03000000 +SWIGRUNTIME PyObject* SWIG_PyInstanceMethod_New(PyObject *SWIGUNUSEDPARM(self), PyObject *func) +{ + return PyInstanceMethod_New(func); +} +#else +SWIGRUNTIME PyObject* SWIG_PyInstanceMethod_New(PyObject *SWIGUNUSEDPARM(self), PyObject *SWIGUNUSEDPARM(func)) +{ + return NULL; +} +#endif + #ifdef __cplusplus } #endif @@ -1043,14 +1150,6 @@ typedef struct swig_const_info { * * ----------------------------------------------------------------------------- */ -#if PY_VERSION_HEX < 0x02070000 /* 2.7.0 */ -# error "This version of SWIG only supports Python >= 2.7" -#endif - -#if PY_VERSION_HEX >= 0x03000000 && PY_VERSION_HEX < 0x03020000 -# error "This version of SWIG only supports Python 3 >= 3.2" -#endif - /* Common SWIG API */ /* for raw pointers */ @@ -1134,7 +1233,11 @@ SwigPyBuiltin_AddPublicSymbol(PyObject *seq, const char *key) { SWIGINTERN void SWIG_Python_SetConstant(PyObject *d, PyObject *public_interface, const char *name, PyObject *obj) { +#if PY_VERSION_HEX < 0x02030000 + PyDict_SetItemString(d, (char *)name, obj); +#else PyDict_SetItemString(d, name, obj); +#endif Py_DECREF(obj); if (public_interface) SwigPyBuiltin_AddPublicSymbol(public_interface, name); @@ -1144,7 +1247,11 @@ SWIG_Python_SetConstant(PyObject *d, PyObject *public_interface, const char *nam SWIGINTERN void SWIG_Python_SetConstant(PyObject *d, const char *name, PyObject *obj) { +#if PY_VERSION_HEX < 0x02030000 + PyDict_SetItemString(d, (char *)name, obj); +#else PyDict_SetItemString(d, name, obj); +#endif Py_DECREF(obj); } @@ -1154,6 +1261,7 @@ SWIG_Python_SetConstant(PyObject *d, const char *name, PyObject *obj) { SWIGINTERN PyObject* SWIG_Python_AppendOutput(PyObject* result, PyObject* obj) { +#if !defined(SWIG_PYTHON_OUTPUT_TUPLE) if (!result) { result = obj; } else if (result == Py_None) { @@ -1169,6 +1277,29 @@ SWIG_Python_AppendOutput(PyObject* result, PyObject* obj) { Py_DECREF(obj); } return result; +#else + PyObject* o2; + PyObject* o3; + if (!result) { + result = obj; + } else if (result == Py_None) { + Py_DECREF(result); + result = obj; + } else { + if (!PyTuple_Check(result)) { + o2 = result; + result = PyTuple_New(1); + PyTuple_SET_ITEM(result, 0, o2); + } + o3 = PyTuple_New(1); + PyTuple_SET_ITEM(o3, 0, obj); + o2 = result; + result = PySequence_Concat(o2, o3); + Py_DECREF(o2); + Py_DECREF(o3); + } + return result; +#endif } /* Unpack the argument tuple */ @@ -1220,7 +1351,11 @@ SWIG_Python_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssi } /* A functor is a function object with one single object argument */ +#if PY_VERSION_HEX >= 0x02020000 #define SWIG_Python_CallFunctor(functor, obj) PyObject_CallFunctionObjArgs(functor, obj, NULL); +#else +#define SWIG_Python_CallFunctor(functor, obj) PyObject_CallFunction(functor, "O", obj); +#endif /* Helper for static pointer initialization for both C and C++ code, for example @@ -1249,6 +1384,35 @@ SWIG_Python_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssi extern "C" { #endif +/* How to access Py_None */ +#if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) +# ifndef SWIG_PYTHON_NO_BUILD_NONE +# ifndef SWIG_PYTHON_BUILD_NONE +# define SWIG_PYTHON_BUILD_NONE +# endif +# endif +#endif + +#ifdef SWIG_PYTHON_BUILD_NONE +# ifdef Py_None +# undef Py_None +# define Py_None SWIG_Py_None() +# endif +SWIGRUNTIMEINLINE PyObject * +_SWIG_Py_None(void) +{ + PyObject *none = Py_BuildValue((char*)""); + Py_DECREF(none); + return none; +} +SWIGRUNTIME PyObject * +SWIG_Py_None(void) +{ + static PyObject *SWIG_STATIC_POINTER(none) = _SWIG_Py_None(); + return none; +} +#endif + /* The python void return value */ SWIGRUNTIMEINLINE PyObject * @@ -1275,10 +1439,7 @@ 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; + return data ? data->implicitconv : 0; } SWIGRUNTIMEINLINE PyObject * @@ -1305,7 +1466,11 @@ SwigPyClientData_New(PyObject* obj) data->newargs = obj; Py_INCREF(obj); } else { - data->newraw = PyObject_GetAttrString(data->klass, "__new__"); +#if (PY_VERSION_HEX < 0x02020000) + data->newraw = 0; +#else + data->newraw = PyObject_GetAttrString(data->klass, (char *)"__new__"); +#endif if (data->newraw) { Py_INCREF(data->newraw); data->newargs = PyTuple_New(1); @@ -1316,7 +1481,7 @@ SwigPyClientData_New(PyObject* obj) Py_INCREF(data->newargs); } /* the destroy method, aka as the C++ delete method */ - data->destroy = PyObject_GetAttrString(data->klass, "__swig_destroy__"); + data->destroy = PyObject_GetAttrString(data->klass, (char *)"__swig_destroy__"); if (PyErr_Occurred()) { PyErr_Clear(); data->destroy = 0; @@ -1325,7 +1490,11 @@ SwigPyClientData_New(PyObject* obj) int flags; Py_INCREF(data->destroy); flags = PyCFunction_GET_FLAGS(data->destroy); +#ifdef METH_O data->delargs = !(flags & (METH_O)); +#else + data->delargs = 0; +#endif } else { data->delargs = 0; } @@ -1413,12 +1582,20 @@ SwigPyObject_hex(SwigPyObject *v) } SWIGRUNTIME PyObject * +#ifdef METH_NOARGS SwigPyObject_repr(SwigPyObject *v) +#else +SwigPyObject_repr(SwigPyObject *v, PyObject *args) +#endif { const char *name = SWIG_TypePrettyName(v->ty); PyObject *repr = SWIG_Python_str_FromFormat("", (name ? name : "unknown"), (void *)v); if (v->next) { +# ifdef METH_NOARGS PyObject *nrep = SwigPyObject_repr((SwigPyObject *)v->next); +# else + PyObject *nrep = SwigPyObject_repr((SwigPyObject *)v->next, args); +# endif # if PY_VERSION_HEX >= 0x03000000 PyObject *joined = PyUnicode_Concat(repr, nrep); Py_DecRef(repr); @@ -1431,14 +1608,6 @@ SwigPyObject_repr(SwigPyObject *v) 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); -} - SWIGRUNTIME int SwigPyObject_compare(SwigPyObject *v, SwigPyObject *w) { @@ -1512,14 +1681,14 @@ SwigPyObject_dealloc(PyObject *v) PyObject *res; /* PyObject_CallFunction() has the potential to silently drop - the active exception. In cases of unnamed temporary + the active 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); + PyObject *val = NULL, *type = NULL, *tb = NULL; + PyErr_Fetch(&val, &type, &tb); if (data->delargs) { /* we need to create a temporary object to carry the destroy operation */ @@ -1534,7 +1703,7 @@ SwigPyObject_dealloc(PyObject *v) if (!res) PyErr_WriteUnraisable(destroy); - PyErr_Restore(type, value, traceback); + PyErr_Restore(val, type, tb); Py_XDECREF(res); } @@ -1553,6 +1722,11 @@ SWIGRUNTIME PyObject* SwigPyObject_append(PyObject* v, PyObject* next) { SwigPyObject *sobj = (SwigPyObject *) v; +#ifndef METH_O + PyObject *tmp = 0; + if (!PyArg_ParseTuple(next,(char *)"O:append", &tmp)) return NULL; + next = tmp; +#endif if (!SwigPyObject_Check(next)) { PyErr_SetString(PyExc_TypeError, "Attempt to append a non SwigPyObject"); return NULL; @@ -1563,7 +1737,11 @@ SwigPyObject_append(PyObject* v, PyObject* next) } SWIGRUNTIME PyObject* +#ifdef METH_NOARGS +SwigPyObject_next(PyObject* v) +#else SwigPyObject_next(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) +#endif { SwigPyObject *sobj = (SwigPyObject *) v; if (sobj->next) { @@ -1575,7 +1753,11 @@ SwigPyObject_next(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) } SWIGINTERN PyObject* +#ifdef METH_NOARGS +SwigPyObject_disown(PyObject *v) +#else SwigPyObject_disown(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) +#endif { SwigPyObject *sobj = (SwigPyObject *)v; sobj->own = 0; @@ -1583,7 +1765,11 @@ SwigPyObject_disown(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) } SWIGINTERN PyObject* +#ifdef METH_NOARGS +SwigPyObject_acquire(PyObject *v) +#else SwigPyObject_acquire(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) +#endif { SwigPyObject *sobj = (SwigPyObject *)v; sobj->own = SWIG_POINTER_OWN; @@ -1594,32 +1780,70 @@ 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)) { - SwigPyObject_acquire(v,args); - } else { - SwigPyObject_disown(v,args); - } +#if (PY_VERSION_HEX < 0x02020000) + if (!PyArg_ParseTuple(args,(char *)"|O:own",&val)) +#elif (PY_VERSION_HEX < 0x02050000) + if (!PyArg_UnpackTuple(args, (char *)"own", 0, 1, &val)) +#else + if (!PyArg_UnpackTuple(args, "own", 0, 1, &val)) +#endif + { + return NULL; } - return obj; - } + else + { + SwigPyObject *sobj = (SwigPyObject *)v; + PyObject *obj = PyBool_FromLong(sobj->own); + if (val) { +#ifdef METH_NOARGS + if (PyObject_IsTrue(val)) { + SwigPyObject_acquire(v); + } else { + SwigPyObject_disown(v); + } +#else + if (PyObject_IsTrue(val)) { + SwigPyObject_acquire(v,args); + } else { + SwigPyObject_disown(v,args); + } +#endif + } + return obj; + } } +#ifdef METH_O 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"}, + {(char *)"disown", (PyCFunction)SwigPyObject_disown, METH_NOARGS, (char *)"releases ownership of the pointer"}, + {(char *)"acquire", (PyCFunction)SwigPyObject_acquire, METH_NOARGS, (char *)"acquires ownership of the pointer"}, + {(char *)"own", (PyCFunction)SwigPyObject_own, METH_VARARGS, (char *)"returns/sets ownership of the pointer"}, + {(char *)"append", (PyCFunction)SwigPyObject_append, METH_O, (char *)"appends another 'this' object"}, + {(char *)"next", (PyCFunction)SwigPyObject_next, METH_NOARGS, (char *)"returns the next 'this' object"}, + {(char *)"__repr__",(PyCFunction)SwigPyObject_repr, METH_NOARGS, (char *)"returns object representation"}, {0, 0, 0, 0} }; +#else +static PyMethodDef +swigobject_methods[] = { + {(char *)"disown", (PyCFunction)SwigPyObject_disown, METH_VARARGS, (char *)"releases ownership of the pointer"}, + {(char *)"acquire", (PyCFunction)SwigPyObject_acquire, METH_VARARGS, (char *)"acquires ownership of the pointer"}, + {(char *)"own", (PyCFunction)SwigPyObject_own, METH_VARARGS, (char *)"returns/sets ownership of the pointer"}, + {(char *)"append", (PyCFunction)SwigPyObject_append, METH_VARARGS, (char *)"appends another 'this' object"}, + {(char *)"next", (PyCFunction)SwigPyObject_next, METH_VARARGS, (char *)"returns the next 'this' object"}, + {(char *)"__repr__",(PyCFunction)SwigPyObject_repr, METH_VARARGS, (char *)"returns object representation"}, + {0, 0, 0, 0} +}; +#endif + +#if PY_VERSION_HEX < 0x02020000 +SWIGINTERN PyObject * +SwigPyObject_getattr(SwigPyObject *sobj,char *name) +{ + return Py_FindMethod(swigobject_methods, (PyObject *)sobj, name); +} +#endif SWIGRUNTIME PyTypeObject* SwigPyObject_TypeOnce(void) { @@ -1664,8 +1888,12 @@ SwigPyObject_TypeOnce(void) { 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 */ -#else +#elif PY_VERSION_HEX >= 0x02050000 /* 2.5.0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_index */ +#elif PY_VERSION_HEX >= 0x02020000 /* 2.2.0 */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_true_divide */ +#elif PY_VERSION_HEX >= 0x02000000 /* 2.0.0 */ + 0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_or */ #endif }; @@ -1679,12 +1907,16 @@ SwigPyObject_TypeOnce(void) { PyObject_HEAD_INIT(NULL) 0, /* ob_size */ #endif - "SwigPyObject", /* tp_name */ + (char *)"SwigPyObject", /* tp_name */ sizeof(SwigPyObject), /* tp_basicsize */ 0, /* tp_itemsize */ (destructor)SwigPyObject_dealloc, /* tp_dealloc */ 0, /* tp_print */ +#if PY_VERSION_HEX < 0x02020000 + (getattrfunc)SwigPyObject_getattr, /* tp_getattr */ +#else (getattrfunc)0, /* tp_getattr */ +#endif (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 */ @@ -1707,6 +1939,7 @@ SwigPyObject_TypeOnce(void) { 0, /* tp_clear */ (richcmpfunc)SwigPyObject_richcompare,/* tp_richcompare */ 0, /* tp_weaklistoffset */ +#if PY_VERSION_HEX >= 0x02020000 0, /* tp_iter */ 0, /* tp_iternext */ swigobject_methods, /* tp_methods */ @@ -1727,8 +1960,13 @@ SwigPyObject_TypeOnce(void) { 0, /* tp_cache */ 0, /* tp_subclasses */ 0, /* tp_weaklist */ +#endif +#if PY_VERSION_HEX >= 0x02030000 0, /* tp_del */ +#endif +#if PY_VERSION_HEX >= 0x02060000 0, /* tp_version_tag */ +#endif #if PY_VERSION_HEX >= 0x03040000 0, /* tp_finalize */ #endif @@ -1736,14 +1974,20 @@ SwigPyObject_TypeOnce(void) { 0, /* tp_allocs */ 0, /* tp_frees */ 0, /* tp_maxalloc */ +#if PY_VERSION_HEX >= 0x02050000 0, /* tp_prev */ +#endif 0 /* tp_next */ #endif }; swigpyobject_type = tmp; type_init = 1; +#if PY_VERSION_HEX < 0x02020000 + swigpyobject_type.ob_type = &PyType_Type; +#else if (PyType_Ready(&swigpyobject_type) < 0) return NULL; +#endif } return &swigpyobject_type; } @@ -1772,6 +2016,20 @@ typedef struct { size_t size; } SwigPyPacked; +SWIGRUNTIME int +SwigPyPacked_print(SwigPyPacked *v, FILE *fp, int SWIGUNUSEDPARM(flags)) +{ + char result[SWIG_BUFFER_SIZE]; + fputs("pack, v->size, 0, sizeof(result))) { + fputs("at ", fp); + fputs(result, fp); + } + fputs(v->ty->name,fp); + fputs(">", fp); + return 0; +} + SWIGRUNTIME PyObject * SwigPyPacked_repr(SwigPyPacked *v) { @@ -1800,7 +2058,7 @@ 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); + return s ? s : strncmp((char *)v->pack, (char *)w->pack, 2*v->size); } SWIGRUNTIME PyTypeObject* SwigPyPacked_TypeOnce(void); @@ -1840,11 +2098,11 @@ SwigPyPacked_TypeOnce(void) { PyObject_HEAD_INIT(NULL) 0, /* ob_size */ #endif - "SwigPyPacked", /* tp_name */ + (char *)"SwigPyPacked", /* tp_name */ sizeof(SwigPyPacked), /* tp_basicsize */ 0, /* tp_itemsize */ (destructor)SwigPyPacked_dealloc, /* tp_dealloc */ - 0, /* tp_print */ + (printfunc)SwigPyPacked_print, /* tp_print */ (getattrfunc)0, /* tp_getattr */ (setattrfunc)0, /* tp_setattr */ #if PY_VERSION_HEX>=0x03000000 @@ -1868,6 +2126,7 @@ SwigPyPacked_TypeOnce(void) { 0, /* tp_clear */ 0, /* tp_richcompare */ 0, /* tp_weaklistoffset */ +#if PY_VERSION_HEX >= 0x02020000 0, /* tp_iter */ 0, /* tp_iternext */ 0, /* tp_methods */ @@ -1888,8 +2147,13 @@ SwigPyPacked_TypeOnce(void) { 0, /* tp_cache */ 0, /* tp_subclasses */ 0, /* tp_weaklist */ +#endif +#if PY_VERSION_HEX >= 0x02030000 0, /* tp_del */ +#endif +#if PY_VERSION_HEX >= 0x02060000 0, /* tp_version_tag */ +#endif #if PY_VERSION_HEX >= 0x03040000 0, /* tp_finalize */ #endif @@ -1897,14 +2161,20 @@ SwigPyPacked_TypeOnce(void) { 0, /* tp_allocs */ 0, /* tp_frees */ 0, /* tp_maxalloc */ +#if PY_VERSION_HEX >= 0x02050000 0, /* tp_prev */ +#endif 0 /* tp_next */ #endif }; swigpypacked_type = tmp; type_init = 1; +#if PY_VERSION_HEX < 0x02020000 + swigpypacked_type.ob_type = &PyType_Type; +#else if (PyType_Ready(&swigpypacked_type) < 0) return NULL; +#endif } return &swigpypacked_type; } @@ -1945,14 +2215,20 @@ SwigPyPacked_UnpackData(PyObject *obj, void *ptr, size_t size) * pointers/data manipulation * ----------------------------------------------------------------------------- */ -static PyObject *Swig_This_global = NULL; +SWIGRUNTIMEINLINE PyObject * +_SWIG_This(void) +{ + return SWIG_Python_str_FromChar("this"); +} + +static PyObject *swig_this = NULL; SWIGRUNTIME PyObject * SWIG_This(void) { - if (Swig_This_global == NULL) - Swig_This_global = SWIG_Python_str_FromChar("this"); - return Swig_This_global; + if (swig_this == NULL) + swig_this = _SWIG_This(); + return swig_this; } /* #define SWIG_PYTHON_SLOW_GETSET_THIS */ @@ -1984,7 +2260,7 @@ SWIG_Python_GetSwigThis(PyObject *pyobj) obj = 0; -#if !defined(SWIG_PYTHON_SLOW_GETSET_THIS) +#if (!defined(SWIG_PYTHON_SLOW_GETSET_THIS) && (PY_VERSION_HEX >= 0x02030000)) if (PyInstance_Check(pyobj)) { obj = _PyInstance_Lookup(pyobj, SWIG_This()); } else { @@ -2054,7 +2330,7 @@ SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int if (obj == Py_None && !implicit_conv) { if (ptr) *ptr = 0; - return (flags & SWIG_POINTER_NO_NULL) ? SWIG_NullReferenceError : SWIG_OK; + return SWIG_OK; } res = SWIG_ERROR; @@ -2134,13 +2410,13 @@ SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int } } } - if (!SWIG_IsOK(res) && obj == Py_None) { - if (ptr) - *ptr = 0; - if (PyErr_Occurred()) - PyErr_Clear(); - res = SWIG_OK; - } + } + if (!SWIG_IsOK(res) && obj == Py_None) { + if (ptr) + *ptr = 0; + if (PyErr_Occurred()) + PyErr_Clear(); + res = SWIG_OK; } } return res; @@ -2154,28 +2430,31 @@ SWIG_Python_ConvertFunctionPtr(PyObject *obj, void **ptr, swig_type_info *ty) { return SWIG_ConvertPtr(obj, ptr, ty, 0); } else { void *vptr = 0; - swig_cast_info *tc; - + /* here we get the method pointer for callbacks */ const char *doc = (((PyCFunctionObject *)obj) -> m_ml -> ml_doc); const char *desc = doc ? strstr(doc, "swig_ptr: ") : 0; if (desc) desc = ty ? SWIG_UnpackVoidPtr(desc + 10, &vptr, ty->name) : 0; - if (!desc) + 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 */ + if (ty) { + swig_cast_info *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; + } } else { - return SWIG_ERROR; + *ptr = vptr; } return SWIG_OK; } } -/* Convert a packed pointer value */ +/* Convert a packed value value */ SWIGRUNTIME int SWIG_Python_ConvertPacked(PyObject *obj, void *ptr, size_t sz, swig_type_info *ty) { @@ -2203,6 +2482,7 @@ SWIG_Python_ConvertPacked(PyObject *obj, void *ptr, size_t sz, swig_type_info *t SWIGRUNTIME PyObject* SWIG_Python_NewShadowInstance(SwigPyClientData *data, PyObject *swig_this) { +#if (PY_VERSION_HEX >= 0x02020000) PyObject *inst = 0; PyObject *newraw = data->newraw; if (newraw) { @@ -2225,18 +2505,10 @@ SWIG_Python_NewShadowInstance(SwigPyClientData *data, PyObject *swig_this) } } else { #if PY_VERSION_HEX >= 0x03000000 - PyObject *empty_args = PyTuple_New(0); - if (empty_args) { - PyObject *empty_kwargs = PyDict_New(); - if (empty_kwargs) { - inst = ((PyTypeObject *)data->newargs)->tp_new((PyTypeObject *)data->newargs, empty_args, empty_kwargs); - Py_DECREF(empty_kwargs); - if (inst) { - PyObject_SetAttr(inst, SWIG_This(), swig_this); - Py_TYPE(inst)->tp_flags &= ~Py_TPFLAGS_VALID_VERSION_TAG; - } - } - Py_DECREF(empty_args); + inst = ((PyTypeObject*) data->newargs)->tp_new((PyTypeObject*) data->newargs, Py_None, Py_None); + if (inst) { + PyObject_SetAttr(inst, SWIG_This(), swig_this); + Py_TYPE(inst)->tp_flags &= ~Py_TPFLAGS_VALID_VERSION_TAG; } #else PyObject *dict = PyDict_New(); @@ -2248,13 +2520,45 @@ SWIG_Python_NewShadowInstance(SwigPyClientData *data, PyObject *swig_this) #endif } return inst; +#else +#if (PY_VERSION_HEX >= 0x02010000) + PyObject *inst = 0; + PyObject *dict = PyDict_New(); + if (dict) { + PyDict_SetItem(dict, SWIG_This(), swig_this); + inst = PyInstance_NewRaw(data->newargs, dict); + Py_DECREF(dict); + } + return (PyObject *) inst; +#else + PyInstanceObject *inst = PyObject_NEW(PyInstanceObject, &PyInstance_Type); + if (inst == NULL) { + return NULL; + } + inst->in_class = (PyClassObject *)data->newargs; + Py_INCREF(inst->in_class); + inst->in_dict = PyDict_New(); + if (inst->in_dict == NULL) { + Py_DECREF(inst); + return NULL; + } +#ifdef Py_TPFLAGS_HAVE_WEAKREFS + inst->in_weakreflist = NULL; +#endif +#ifdef Py_TPFLAGS_GC + PyObject_GC_Init(inst); +#endif + PyDict_SetItem(inst->in_dict, SWIG_This(), swig_this); + return (PyObject *) inst; +#endif +#endif } SWIGRUNTIME void SWIG_Python_SetSwigThis(PyObject *inst, PyObject *swig_this) { PyObject *dict; -#if !defined(SWIG_PYTHON_SLOW_GETSET_THIS) +#if (PY_VERSION_HEX >= 0x02020000) && !defined(SWIG_PYTHON_SLOW_GETSET_THIS) PyObject **dictptr = _PyObject_GetDictPtr(inst); if (dictptr != NULL) { dict = *dictptr; @@ -2266,7 +2570,7 @@ SWIG_Python_SetSwigThis(PyObject *inst, PyObject *swig_this) return; } #endif - dict = PyObject_GetAttrString(inst, "__dict__"); + dict = PyObject_GetAttrString(inst, (char*)"__dict__"); PyDict_SetItem(dict, SWIG_This(), swig_this); Py_DECREF(dict); } @@ -2365,7 +2669,12 @@ SWIG_Python_GetModule(void *SWIGUNUSEDPARM(clientdata)) { #ifdef SWIG_LINK_RUNTIME type_pointer = SWIG_ReturnGlobalTypeList((void *)0); #else +# ifdef SWIGPY_USE_CAPSULE type_pointer = PyCapsule_Import(SWIGPY_CAPSULE_NAME, 0); +# else + type_pointer = PyCObject_Import((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION, + (char*)"type_pointer" SWIG_TYPE_TABLE_NAME); +# endif if (PyErr_Occurred()) { PyErr_Clear(); type_pointer = (void *)0; @@ -2375,10 +2684,48 @@ SWIG_Python_GetModule(void *SWIGUNUSEDPARM(clientdata)) { return (swig_module_info *) type_pointer; } -SWIGRUNTIME void -SWIG_Python_DestroyModule(PyObject *obj) +#if PY_MAJOR_VERSION < 2 +/* PyModule_AddObject function was introduced in Python 2.0. The following function + is copied out of Python/modsupport.c in python version 2.3.4 */ +SWIGINTERN int +PyModule_AddObject(PyObject *m, char *name, PyObject *o) { + PyObject *dict; + if (!PyModule_Check(m)) { + PyErr_SetString(PyExc_TypeError, "PyModule_AddObject() needs module as first arg"); + return SWIG_ERROR; + } + if (!o) { + PyErr_SetString(PyExc_TypeError, "PyModule_AddObject() needs non-NULL value"); + return SWIG_ERROR; + } + + dict = PyModule_GetDict(m); + if (dict == NULL) { + /* Internal error -- modules must have a dict! */ + PyErr_Format(PyExc_SystemError, "module '%s' has no __dict__", + PyModule_GetName(m)); + return SWIG_ERROR; + } + if (PyDict_SetItemString(dict, name, o)) + return SWIG_ERROR; + Py_DECREF(o); + return SWIG_OK; +} +#endif + +SWIGRUNTIME void +#ifdef SWIGPY_USE_CAPSULE +SWIG_Python_DestroyModule(PyObject *obj) +#else +SWIG_Python_DestroyModule(void *vptr) +#endif +{ +#ifdef SWIGPY_USE_CAPSULE swig_module_info *swig_module = (swig_module_info *) PyCapsule_GetPointer(obj, SWIGPY_CAPSULE_NAME); +#else + swig_module_info *swig_module = (swig_module_info *) vptr; +#endif swig_type_info **types = swig_module->types; size_t i; for (i =0; i < swig_module->size; ++i) { @@ -2389,24 +2736,33 @@ SWIG_Python_DestroyModule(PyObject *obj) } } Py_DECREF(SWIG_This()); - Swig_This_global = NULL; + swig_this = 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); + PyObject *module = PyImport_AddModule((char*)"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); + PyObject *module = Py_InitModule((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION, swig_empty_runtime_method_table); #endif +#ifdef SWIGPY_USE_CAPSULE PyObject *pointer = PyCapsule_New((void *) swig_module, SWIGPY_CAPSULE_NAME, SWIG_Python_DestroyModule); if (pointer && module) { - PyModule_AddObject(module, "type_pointer_capsule" SWIG_TYPE_TABLE_NAME, pointer); + PyModule_AddObject(module, (char*)"type_pointer_capsule" SWIG_TYPE_TABLE_NAME, pointer); } else { Py_XDECREF(pointer); } +#else + PyObject *pointer = PyCObject_FromVoidPtr((void *) swig_module, SWIG_Python_DestroyModule); + if (pointer && module) { + PyModule_AddObject(module, (char*)"type_pointer" SWIG_TYPE_TABLE_NAME, pointer); + } else { + Py_XDECREF(pointer); + } +#endif } /* The python cached type query */ @@ -2424,12 +2780,20 @@ SWIG_Python_TypeQuery(const char *type) PyObject *obj = PyDict_GetItem(cache, key); swig_type_info *descriptor; if (obj) { +#ifdef SWIGPY_USE_CAPSULE descriptor = (swig_type_info *) PyCapsule_GetPointer(obj, NULL); +#else + descriptor = (swig_type_info *) PyCObject_AsVoidPtr(obj); +#endif } else { swig_module_info *swig_module = SWIG_GetModule(0); descriptor = SWIG_TypeQueryModule(swig_module, swig_module, type); if (descriptor) { +#ifdef SWIGPY_USE_CAPSULE obj = PyCapsule_New((void*) descriptor, NULL, NULL); +#else + obj = PyCObject_FromVoidPtr(descriptor, NULL); +#endif PyDict_SetItem(cache, key, obj); Py_DECREF(obj); } @@ -2454,15 +2818,14 @@ SWIG_Python_AddErrMesg(const char* mesg, int infront) PyObject *traceback = 0; PyErr_Fetch(&type, &value, &traceback); if (value) { + char *tmp; PyObject *old_str = PyObject_Str(value); - const char *tmp = SWIG_Python_str_AsChar(old_str); - const char *errmesg = tmp ? tmp : "Invalid error message"; Py_XINCREF(type); PyErr_Clear(); if (infront) { - PyErr_Format(type, "%s %s", mesg, errmesg); + PyErr_Format(type, "%s %s", mesg, tmp = SWIG_Python_str_AsChar(old_str)); } else { - PyErr_Format(type, "%s %s", errmesg, mesg); + PyErr_Format(type, "%s %s", tmp = SWIG_Python_str_AsChar(old_str), mesg); } SWIG_Python_str_DelForPy3(tmp); Py_DECREF(old_str); @@ -2588,8 +2951,6 @@ SWIG_Python_NonDynamicSetAttr(PyObject *obj, PyObject *name, PyObject *value) { Py_INCREF(name); } else { encoded_name = PyUnicode_AsUTF8String(name); - if (!encoded_name) - return -1; } PyErr_Format(PyExc_AttributeError, "'%.100s' object has no attribute '%.200s'", tp->tp_name, PyString_AsString(encoded_name)); Py_DECREF(encoded_name); @@ -2616,21 +2977,6 @@ SWIG_Python_NonDynamicSetAttr(PyObject *obj, PyObject *name, PyObject *value) { -#ifdef __cplusplus -extern "C" { -#endif - -/* Method creation and docstring support functions */ - -SWIGINTERN PyMethodDef *SWIG_PythonGetProxyDoc(const char *name); -SWIGINTERN PyObject *SWIG_PyInstanceMethod_New(PyObject *SWIGUNUSEDPARM(self), PyObject *func); -SWIGINTERN PyObject *SWIG_PyStaticMethod_New(PyObject *SWIGUNUSEDPARM(self), PyObject *func); - -#ifdef __cplusplus -} -#endif - - /* -------- TYPES TABLE (BEGIN) -------- */ #define SWIGTYPE_p_char swig_types[0] @@ -2642,10 +2988,11 @@ static swig_module_info swig_module = {swig_types, 2, 0, 0, 0, 0}; /* -------- TYPES TABLE (END) -------- */ -#ifdef SWIG_TypeQuery -# undef SWIG_TypeQuery +#if (PY_VERSION_HEX <= 0x02000000) +# if !defined(SWIG_PYTHON_CLASSIC) +# error "This python version requires swig to be run with the '-classic' option" +# endif #endif -#define SWIG_TypeQuery SWIG_Python_TypeQuery /*----------------------------------------------- @(target):= _pm3.so @@ -2659,7 +3006,7 @@ static swig_module_info swig_module = {swig_types, 2, 0, 0, 0, 0}; #endif #define SWIG_name "_pm3" -#define SWIGVERSION 0x040001 +#define SWIGVERSION 0x030012 #define SWIG_VERSION SWIGVERSION @@ -2669,12 +3016,14 @@ static swig_module_info swig_module = {swig_types, 2, 0, 0, 0, 0}; /* Include the header in the wrapper code */ #include "pm3.h" +#include "comms.h" -SWIGINTERN struct pm3_device *new_pm3_device__SWIG_0(void){ - printf("SWIG pm3_device constructor, get current pm3\n"); - _embedded = 1; - return pm3_get_current_dev(); - } +SWIGINTERN pm3_device *new_pm3_device__SWIG_0(void){ + printf("SWIG pm3_device constructor, get current pm3\n"); + pm3_device * p = pm3_device_get_current_dev(); + p->script_embedded = 1; + return p; + } SWIGINTERN swig_type_info* SWIG_pchar_descriptor(void) @@ -2703,7 +3052,6 @@ SWIG_AsCharPtrAndSize(PyObject *obj, char** cptr, size_t* psize, int *alloc) #endif { char *cstr; Py_ssize_t len; - int ret = SWIG_OK; #if PY_VERSION_HEX>=0x03000000 #if !defined(SWIG_PYTHON_STRICT_BYTE_CHAR) if (!alloc && cptr) { @@ -2714,10 +3062,7 @@ SWIG_AsCharPtrAndSize(PyObject *obj, char** cptr, size_t* psize, int *alloc) return SWIG_RuntimeError; } obj = PyUnicode_AsUTF8String(obj); - if (!obj) - return SWIG_TypeError; - if (alloc) - *alloc = SWIG_NEWOBJ; + if(alloc) *alloc = SWIG_NEWOBJ; #endif PyBytes_AsStringAndSize(obj, &cstr, &len); #else @@ -2725,7 +3070,21 @@ SWIG_AsCharPtrAndSize(PyObject *obj, char** cptr, size_t* psize, int *alloc) #endif if (cptr) { if (alloc) { - if (*alloc == SWIG_NEWOBJ) { + /* + In python the user should not be able to modify the inner + string representation. To warranty that, if you define + SWIG_PYTHON_SAFE_CSTRINGS, a new/copy of the python string + buffer is always returned. + + The default behavior is just to return the pointer value, + so, be careful. + */ +#if defined(SWIG_PYTHON_SAFE_CSTRINGS) + if (*alloc != SWIG_OLDOBJ) +#else + if (*alloc == SWIG_NEWOBJ) +#endif + { *cptr = (char *)memcpy(malloc((len + 1)*sizeof(char)), cstr, sizeof(char)*(len + 1)); *alloc = SWIG_NEWOBJ; } else { @@ -2741,8 +3100,6 @@ SWIG_AsCharPtrAndSize(PyObject *obj, char** cptr, size_t* psize, int *alloc) #endif #else *cptr = SWIG_Python_str_AsChar(obj); - if (!*cptr) - ret = SWIG_TypeError; #endif } } @@ -2750,7 +3107,7 @@ SWIG_AsCharPtrAndSize(PyObject *obj, char** cptr, size_t* psize, int *alloc) #if PY_VERSION_HEX>=0x03000000 && !defined(SWIG_PYTHON_STRICT_BYTE_CHAR) Py_XDECREF(obj); #endif - return ret; + return SWIG_OK; } else { #if defined(SWIG_PYTHON_2_UNICODE) #if defined(SWIG_PYTHON_STRICT_BYTE_CHAR) @@ -2763,8 +3120,6 @@ SWIG_AsCharPtrAndSize(PyObject *obj, char** cptr, size_t* psize, int *alloc) 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; @@ -2798,22 +3153,20 @@ SWIG_AsCharPtrAndSize(PyObject *obj, char** cptr, size_t* psize, int *alloc) -SWIGINTERN struct pm3_device *new_pm3_device__SWIG_1(char *port){ - printf("SWIG pm3_device constructor with port, open pm3\n"); - _embedded = 0; - return pm3_open(port); - } -SWIGINTERN void delete_pm3_device(struct pm3_device *self){ - if (_embedded) { - printf("SWIG pm3_device destructor, nothing to do\n"); - } else { - printf("SWIG pm3_device destructor, close pm3\n"); - pm3_close(self); +SWIGINTERN pm3_device *new_pm3_device__SWIG_1(char *port){ + printf("SWIG pm3_device constructor with port, open pm3\n"); + pm3_device * p = pm3_open(port); + p->script_embedded = 1; + return p; + } +SWIGINTERN void delete_pm3_device(pm3_device *self){ + if (self->script_embedded) { + printf("SWIG pm3_device destructor, nothing to do\n"); + } else { + printf("SWIG pm3_device destructor, close pm3\n"); + pm3_device_close(self); + } } - } -SWIGINTERN int pm3_device_console(struct pm3_device *self,char *cmd){ - return pm3_console(self, cmd); - } SWIGINTERNINLINE PyObject* SWIG_From_int (int value) @@ -2821,9 +3174,6 @@ SWIGINTERNINLINE PyObject* return PyInt_FromLong((long) value); } -SWIGINTERN char *pm3_device_get_name(struct pm3_device *self){ - return pm3_get_name(self); - } SWIGINTERNINLINE PyObject * SWIG_FromCharPtrAndSize(const char* carray, size_t size) @@ -2838,7 +3188,11 @@ SWIG_FromCharPtrAndSize(const char* carray, size_t size) #if defined(SWIG_PYTHON_STRICT_BYTE_CHAR) return PyBytes_FromStringAndSize(carray, (Py_ssize_t)(size)); #else +#if PY_VERSION_HEX >= 0x03010000 return PyUnicode_DecodeUTF8(carray, (Py_ssize_t)(size), "surrogateescape"); +#else + return PyUnicode_FromStringAndSize(carray, (Py_ssize_t)(size)); +#endif #endif #else return PyString_FromStringAndSize(carray, (Py_ssize_t)(size)); @@ -2856,166 +3210,15 @@ SWIG_FromCharPtr(const char *cptr) return SWIG_FromCharPtrAndSize(cptr, (cptr ? strlen(cptr) : 0)); } - -#include -#if !defined(SWIG_NO_LLONG_MAX) -# if !defined(LLONG_MAX) && defined(__GNUC__) && defined (__LONG_LONG_MAX__) -# define LLONG_MAX __LONG_LONG_MAX__ -# define LLONG_MIN (-LLONG_MAX - 1LL) -# define ULLONG_MAX (LLONG_MAX * 2ULL + 1ULL) -# endif -#endif - - -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; -#if PY_VERSION_HEX < 0x03000000 - } 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(); - } - } -#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(); - } - } - } -#endif - return res; -} - - -#include - - -#include - - -SWIGINTERNINLINE int -SWIG_CanCastAsInteger(double *d, double min, double max) { - double x = *d; - if ((min <= x && x <= max)) { - double fx = floor(x); - double cx = ceil(x); - double 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) -{ -#if PY_VERSION_HEX < 0x03000000 - 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; - } - } -#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)); - if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, LONG_MIN, LONG_MAX)) { - if (val) *val = (long)(d); - return res; - } - } - } -#endif - return SWIG_TypeError; -} - - -SWIGINTERN int -SWIG_AsVal_int (PyObject * obj, int *val) -{ - long v; - int res = SWIG_AsVal_long (obj, &v); - if (SWIG_IsOK(res)) { - if ((v < INT_MIN || v > INT_MAX)) { - return SWIG_OverflowError; - } else { - if (val) *val = (int)(v); - } - } - return res; -} - #ifdef __cplusplus extern "C" { #endif -SWIGINTERN PyObject *_wrap_new_device__SWIG_0(PyObject *SWIGUNUSEDPARM(self), Py_ssize_t nobjs, PyObject **SWIGUNUSEDPARM(swig_obj)) { +SWIGINTERN PyObject *_wrap_new_device__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; - struct pm3_device *result = 0 ; + pm3_device *result = 0 ; - if ((nobjs < 0) || (nobjs > 0)) SWIG_fail; - result = (struct pm3_device *)new_pm3_device__SWIG_0(); + if (!PyArg_ParseTuple(args,(char *)":new_device")) SWIG_fail; + result = (pm3_device *)new_pm3_device__SWIG_0(); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_pm3_device, SWIG_POINTER_NEW | 0 ); return resultobj; fail: @@ -3023,21 +3226,22 @@ fail: } -SWIGINTERN PyObject *_wrap_new_device__SWIG_1(PyObject *SWIGUNUSEDPARM(self), Py_ssize_t nobjs, PyObject **swig_obj) { +SWIGINTERN PyObject *_wrap_new_device__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; char *arg1 = (char *) 0 ; int res1 ; char *buf1 = 0 ; int alloc1 = 0 ; - struct pm3_device *result = 0 ; + PyObject * obj0 = 0 ; + pm3_device *result = 0 ; - if ((nobjs < 1) || (nobjs > 1)) SWIG_fail; - res1 = SWIG_AsCharPtrAndSize(swig_obj[0], &buf1, NULL, &alloc1); + if (!PyArg_ParseTuple(args,(char *)"O:new_device",&obj0)) SWIG_fail; + res1 = SWIG_AsCharPtrAndSize(obj0, &buf1, NULL, &alloc1); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_device" "', argument " "1"" of type '" "char *""'"); } arg1 = (char *)(buf1); - result = (struct pm3_device *)new_pm3_device__SWIG_1(arg1); + result = (pm3_device *)new_pm3_device__SWIG_1(arg1); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_pm3_device, SWIG_POINTER_NEW | 0 ); if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); return resultobj; @@ -3052,23 +3256,27 @@ SWIGINTERN PyObject *_wrap_new_device(PyObject *self, PyObject *args) { PyObject *argv[2] = { 0 }; + Py_ssize_t ii; - if (!(argc = SWIG_Python_UnpackTuple(args, "new_device", 0, 1, argv))) SWIG_fail; - --argc; + if (!PyTuple_Check(args)) SWIG_fail; + argc = args ? PyObject_Length(args) : 0; + for (ii = 0; (ii < 1) && (ii < argc); ii++) { + argv[ii] = PyTuple_GET_ITEM(args,ii); + } if (argc == 0) { - return _wrap_new_device__SWIG_0(self, argc, argv); + return _wrap_new_device__SWIG_0(self, args); } if (argc == 1) { int _v; int res = SWIG_AsCharPtrAndSize(argv[0], 0, NULL, 0); _v = SWIG_CheckState(res); if (_v) { - return _wrap_new_device__SWIG_1(self, argc, argv); + return _wrap_new_device__SWIG_1(self, args); } } fail: - SWIG_Python_RaiseOrModifyTypeError("Wrong number or type of arguments for overloaded function 'new_device'.\n" + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'new_device'.\n" " Possible C/C++ prototypes are:\n" " pm3_device::pm3_device()\n" " pm3_device::pm3_device(char *)\n"); @@ -3078,18 +3286,17 @@ fail: SWIGINTERN PyObject *_wrap_delete_device(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; - struct pm3_device *arg1 = (struct pm3_device *) 0 ; + pm3_device *arg1 = (pm3_device *) 0 ; void *argp1 = 0 ; int res1 = 0 ; - PyObject *swig_obj[1] ; + PyObject * obj0 = 0 ; - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_pm3_device, SWIG_POINTER_DISOWN | 0 ); + if (!PyArg_ParseTuple(args,(char *)"O:delete_device",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_pm3_device, SWIG_POINTER_DISOWN | 0 ); if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_device" "', argument " "1"" of type '" "struct pm3_device *""'"); + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_device" "', argument " "1"" of type '" "pm3_device *""'"); } - arg1 = (struct pm3_device *)(argp1); + arg1 = (pm3_device *)(argp1); delete_pm3_device(arg1); resultobj = SWIG_Py_Void(); return resultobj; @@ -3100,23 +3307,24 @@ fail: SWIGINTERN PyObject *_wrap_device_console(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; - struct pm3_device *arg1 = (struct pm3_device *) 0 ; + pm3_device *arg1 = (pm3_device *) 0 ; char *arg2 = (char *) 0 ; void *argp1 = 0 ; int res1 = 0 ; int res2 ; char *buf2 = 0 ; int alloc2 = 0 ; - PyObject *swig_obj[2] ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; int result; - if (!SWIG_Python_UnpackTuple(args, "device_console", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_pm3_device, 0 | 0 ); + if (!PyArg_ParseTuple(args,(char *)"OO:device_console",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_pm3_device, 0 | 0 ); if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "device_console" "', argument " "1"" of type '" "struct pm3_device *""'"); + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "device_console" "', argument " "1"" of type '" "pm3_device *""'"); } - arg1 = (struct pm3_device *)(argp1); - res2 = SWIG_AsCharPtrAndSize(swig_obj[1], &buf2, NULL, &alloc2); + arg1 = (pm3_device *)(argp1); + res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "device_console" "', argument " "2"" of type '" "char *""'"); } @@ -3131,22 +3339,21 @@ fail: } -SWIGINTERN PyObject *_wrap_device_get_name(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { +SWIGINTERN PyObject *_wrap_device_name_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; - struct pm3_device *arg1 = (struct pm3_device *) 0 ; + pm3_device *arg1 = (pm3_device *) 0 ; void *argp1 = 0 ; int res1 = 0 ; - PyObject *swig_obj[1] ; + PyObject * obj0 = 0 ; char *result = 0 ; - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_pm3_device, 0 | 0 ); + if (!PyArg_ParseTuple(args,(char *)"O:device_name_get",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_pm3_device, 0 | 0 ); if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "device_get_name" "', argument " "1"" of type '" "struct pm3_device *""'"); + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "device_name_get" "', argument " "1"" of type '" "pm3_device *""'"); } - arg1 = (struct pm3_device *)(argp1); - result = (char *)pm3_device_get_name(arg1); + arg1 = (pm3_device *)(argp1); + result = (char *)pm3_device_name_get(arg1); resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: @@ -3156,172 +3363,18 @@ fail: SWIGINTERN PyObject *device_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *obj; - if (!SWIG_Python_UnpackTuple(args, "swigregister", 1, 1, &obj)) return NULL; + if (!PyArg_ParseTuple(args,(char *)"O:swigregister", &obj)) return NULL; SWIG_TypeNewClientData(SWIGTYPE_p_pm3_device, SWIG_NewClientData(obj)); return SWIG_Py_Void(); } -SWIGINTERN PyObject *device_swiginit(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - return SWIG_Python_InitShadowInstance(args); -} - -SWIGINTERN int Swig_var__embedded_set(PyObject *_val) { - { - int val; - int res = SWIG_AsVal_int(_val, &val); - if (!SWIG_IsOK(res)) { - SWIG_exception_fail(SWIG_ArgError(res), "in variable '""_embedded""' of type '""int""'"); - } - _embedded = (int)(val); - } - return 0; -fail: - return 1; -} - - -SWIGINTERN PyObject *Swig_var__embedded_get(void) { - PyObject *pyobj = 0; - - pyobj = SWIG_From_int((int)(_embedded)); - return pyobj; -} - - -SWIGINTERN PyObject *_wrap_open(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - char *arg1 = (char *) 0 ; - int res1 ; - char *buf1 = 0 ; - int alloc1 = 0 ; - PyObject *swig_obj[1] ; - pm3_device *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_AsCharPtrAndSize(swig_obj[0], &buf1, NULL, &alloc1); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "open" "', argument " "1"" of type '" "char *""'"); - } - arg1 = (char *)(buf1); - result = (pm3_device *)pm3_open(arg1); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_pm3_device, 0 | 0 ); - if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); - return resultobj; -fail: - if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); - return NULL; -} - - -SWIGINTERN PyObject *_wrap_console(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - pm3_device *arg1 = (pm3_device *) 0 ; - char *arg2 = (char *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - int res2 ; - char *buf2 = 0 ; - int alloc2 = 0 ; - PyObject *swig_obj[2] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "console", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_pm3_device, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "console" "', argument " "1"" of type '" "pm3_device *""'"); - } - arg1 = (pm3_device *)(argp1); - res2 = SWIG_AsCharPtrAndSize(swig_obj[1], &buf2, NULL, &alloc2); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "console" "', argument " "2"" of type '" "char *""'"); - } - arg2 = (char *)(buf2); - result = (int)pm3_console(arg1,arg2); - 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; -} - - -SWIGINTERN PyObject *_wrap_get_name(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - pm3_device *arg1 = (pm3_device *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - char *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_pm3_device, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "get_name" "', argument " "1"" of type '" "pm3_device *""'"); - } - arg1 = (pm3_device *)(argp1); - result = (char *)pm3_get_name(arg1); - resultobj = SWIG_FromCharPtr((const char *)result); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_close(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - pm3_device *arg1 = (pm3_device *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_pm3_device, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "close" "', argument " "1"" of type '" "pm3_device *""'"); - } - arg1 = (pm3_device *)(argp1); - pm3_close(arg1); - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_get_current_dev(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - pm3_device *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "get_current_dev", 0, 0, 0)) SWIG_fail; - result = (pm3_device *)pm3_get_current_dev(); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_pm3_device, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - static PyMethodDef SwigMethods[] = { - { "SWIG_PyInstanceMethod_New", SWIG_PyInstanceMethod_New, METH_O, NULL}, - { "new_device", _wrap_new_device, METH_VARARGS, NULL}, - { "delete_device", _wrap_delete_device, METH_O, NULL}, - { "device_console", _wrap_device_console, METH_VARARGS, NULL}, - { "device_get_name", _wrap_device_get_name, METH_O, NULL}, - { "device_swigregister", device_swigregister, METH_O, NULL}, - { "device_swiginit", device_swiginit, METH_VARARGS, NULL}, - { "open", _wrap_open, METH_O, NULL}, - { "console", _wrap_console, METH_VARARGS, NULL}, - { "get_name", _wrap_get_name, METH_O, NULL}, - { "close", _wrap_close, METH_O, NULL}, - { "get_current_dev", _wrap_get_current_dev, METH_NOARGS, NULL}, - { NULL, NULL, 0, NULL } -}; - -static PyMethodDef SwigMethods_proxydocs[] = { + { (char *)"SWIG_PyInstanceMethod_New", (PyCFunction)SWIG_PyInstanceMethod_New, METH_O, NULL}, + { (char *)"new_device", _wrap_new_device, METH_VARARGS, NULL}, + { (char *)"delete_device", _wrap_delete_device, METH_VARARGS, NULL}, + { (char *)"device_console", _wrap_device_console, METH_VARARGS, NULL}, + { (char *)"device_name_get", _wrap_device_name_get, METH_VARARGS, NULL}, + { (char *)"device_swigregister", device_swigregister, METH_VARARGS, NULL}, { NULL, NULL, 0, NULL } }; @@ -3329,7 +3382,7 @@ static PyMethodDef SwigMethods_proxydocs[] = { /* -------- 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_device = {"_p_pm3_device", "struct pm3_device *|pm3_device *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_pm3_device = {"_p_pm3_device", "pm3_device *", 0, 0, (void*)0, 0}; static swig_type_info *swig_type_initial[] = { &_swigt__p_char, @@ -3453,7 +3506,7 @@ SWIG_InitializeModule(void *clientdata) { /* 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 %d\n", swig_module.size); #endif for (i = 0; i < swig_module.size; ++i) { swig_type_info *type = 0; @@ -3461,7 +3514,7 @@ SWIG_InitializeModule(void *clientdata) { 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 %d %s\n", i, swig_module.type_initial[i]->name); #endif /* if there is another module already loaded */ @@ -3536,7 +3589,7 @@ SWIG_InitializeModule(void *clientdata) { 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); + printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name); while (cast->type) { printf("SWIG_InitializeModule: cast type %s\n", cast->type->name); cast++; @@ -3658,6 +3711,17 @@ extern "C" { return str; } + SWIGINTERN int + swig_varlink_print(swig_varlinkobject *v, FILE *fp, int SWIGUNUSEDPARM(flags)) { + char *tmp; + PyObject *str = swig_varlink_str(v); + fprintf(fp,"Swig global variables "); + fprintf(fp,"%s\n", tmp = SWIG_Python_str_AsChar(str)); + SWIG_Python_str_DelForPy3(tmp); + Py_DECREF(str); + return 0; + } + SWIGINTERN void swig_varlink_dealloc(swig_varlinkobject *v) { swig_globalvar *var = v->vars; @@ -3716,11 +3780,11 @@ extern "C" { PyObject_HEAD_INIT(NULL) 0, /* ob_size */ #endif - "swigvarlink", /* tp_name */ + (char *)"swigvarlink", /* tp_name */ sizeof(swig_varlinkobject), /* tp_basicsize */ 0, /* tp_itemsize */ (destructor) swig_varlink_dealloc, /* tp_dealloc */ - 0, /* tp_print */ + (printfunc) swig_varlink_print, /* tp_print */ (getattrfunc) swig_varlink_getattr, /* tp_getattr */ (setattrfunc) swig_varlink_setattr, /* tp_setattr */ 0, /* tp_compare */ @@ -3740,9 +3804,15 @@ extern "C" { 0, /* tp_clear */ 0, /* tp_richcompare */ 0, /* tp_weaklistoffset */ +#if PY_VERSION_HEX >= 0x02020000 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* tp_iter -> tp_weaklist */ +#endif +#if PY_VERSION_HEX >= 0x02030000 0, /* tp_del */ +#endif +#if PY_VERSION_HEX >= 0x02060000 0, /* tp_version_tag */ +#endif #if PY_VERSION_HEX >= 0x03040000 0, /* tp_finalize */ #endif @@ -3750,14 +3820,20 @@ extern "C" { 0, /* tp_allocs */ 0, /* tp_frees */ 0, /* tp_maxalloc */ +#if PY_VERSION_HEX >= 0x02050000 0, /* tp_prev */ +#endif 0 /* tp_next */ #endif }; varlink_type = tmp; type_init = 1; +#if PY_VERSION_HEX < 0x02020000 + varlink_type.ob_type = &PyType_Type; +#else if (PyType_Ready(&varlink_type) < 0) return NULL; +#endif } return &varlink_type; } @@ -3773,14 +3849,14 @@ extern "C" { } SWIGINTERN void - SWIG_Python_addvarlink(PyObject *p, const char *name, PyObject *(*get_attr)(void), int (*set_attr)(PyObject *p)) { + SWIG_Python_addvarlink(PyObject *p, 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); + strncpy(gv->name,name,size); gv->get_attr = get_attr; gv->set_attr = set_attr; gv->next = v->vars; @@ -3791,11 +3867,9 @@ extern "C" { SWIGINTERN PyObject * SWIG_globals(void) { - static PyObject *globals = 0; - if (!globals) { - globals = SWIG_newvarlink(); - } - return globals; + static PyObject *_SWIG_globals = 0; + if (!_SWIG_globals) _SWIG_globals = SWIG_newvarlink(); + return _SWIG_globals; } /* ----------------------------------------------------------------------------- @@ -3861,9 +3935,9 @@ extern "C" { char *ndoc = (char*)malloc(ldoc + lptr + 10); if (ndoc) { char *buff = ndoc; - memcpy(buff, methods[i].ml_doc, ldoc); + strncpy(buff, methods[i].ml_doc, ldoc); buff += ldoc; - memcpy(buff, "swig_ptr: ", 10); + strncpy(buff, "swig_ptr: ", 10); buff += 10; SWIG_PackVoidPtr(buff, ptr, ty->name, lptr); methods[i].ml_doc = ndoc; @@ -3874,64 +3948,6 @@ extern "C" { } } - /* ----------------------------------------------------------------------------- - * Method creation and docstring support functions - * ----------------------------------------------------------------------------- */ - - /* ----------------------------------------------------------------------------- - * Function to find the method definition with the correct docstring for the - * proxy module as opposed to the low-level API - * ----------------------------------------------------------------------------- */ - - SWIGINTERN PyMethodDef *SWIG_PythonGetProxyDoc(const char *name) { - /* Find the function in the modified method table */ - size_t offset = 0; - int found = 0; - while (SwigMethods_proxydocs[offset].ml_meth != NULL) { - if (strcmp(SwigMethods_proxydocs[offset].ml_name, name) == 0) { - found = 1; - break; - } - offset++; - } - /* Use the copy with the modified docstring if available */ - return found ? &SwigMethods_proxydocs[offset] : NULL; - } - - /* ----------------------------------------------------------------------------- - * Wrapper of PyInstanceMethod_New() used in Python 3 - * It is exported to the generated module, used for -fastproxy - * ----------------------------------------------------------------------------- */ - - SWIGINTERN PyObject *SWIG_PyInstanceMethod_New(PyObject *SWIGUNUSEDPARM(self), PyObject *func) { - if (PyCFunction_Check(func)) { - PyCFunctionObject *funcobj = (PyCFunctionObject *)func; - PyMethodDef *ml = SWIG_PythonGetProxyDoc(funcobj->m_ml->ml_name); - if (ml) - func = PyCFunction_NewEx(ml, funcobj->m_self, funcobj->m_module); - } -#if PY_VERSION_HEX >= 0x03000000 - return PyInstanceMethod_New(func); -#else - return PyMethod_New(func, NULL, NULL); -#endif - } - - /* ----------------------------------------------------------------------------- - * Wrapper of PyStaticMethod_New() - * It is exported to the generated module, used for -fastproxy - * ----------------------------------------------------------------------------- */ - - SWIGINTERN PyObject *SWIG_PyStaticMethod_New(PyObject *SWIGUNUSEDPARM(self), PyObject *func) { - if (PyCFunction_Check(func)) { - PyCFunctionObject *funcobj = (PyCFunctionObject *)func; - PyMethodDef *ml = SWIG_PythonGetProxyDoc(funcobj->m_ml->ml_name); - if (ml) - func = PyCFunction_NewEx(ml, funcobj->m_self, funcobj->m_module); - } - return PyStaticMethod_New(func); - } - #ifdef __cplusplus } #endif @@ -3951,12 +3967,20 @@ PyObject* void #endif SWIG_init(void) { - PyObject *m, *d, *md, *globals; - + PyObject *m, *d, *md; #if PY_VERSION_HEX >= 0x03000000 static struct PyModuleDef SWIG_module = { +# if PY_VERSION_HEX >= 0x03020000 PyModuleDef_HEAD_INIT, - SWIG_name, +# else + { + PyObject_HEAD_INIT(NULL) + NULL, /* m_init */ + 0, /* m_index */ + NULL, /* m_copy */ + }, +# endif + (char *) SWIG_name, NULL, -1, SwigMethods, @@ -3975,8 +3999,8 @@ SWIG_init(void) { (char *)"this", &SwigPyBuiltin_ThisClosure, NULL, NULL, NULL }; static SwigPyGetSet thisown_getset_closure = { - SwigPyObject_own, - SwigPyObject_own + (PyCFunction) SwigPyObject_own, + (PyCFunction) SwigPyObject_own }; static PyGetSetDef thisown_getset_def = { (char *)"thisown", SwigPyBuiltin_GetterClosure, SwigPyBuiltin_SetterClosure, NULL, &thisown_getset_closure @@ -4007,23 +4031,13 @@ SWIG_init(void) { 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(); -#endif - /* 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); #else - m = Py_InitModule(SWIG_name, SwigMethods); + m = Py_InitModule((char *) SWIG_name, SwigMethods); #endif md = d = PyModule_GetDict(m); @@ -4071,18 +4085,6 @@ SWIG_init(void) { SWIG_InstallConstants(d,swig_const_table); - globals = SWIG_globals(); - if (!globals) { - PyErr_SetString(PyExc_TypeError, "Failure to create SWIG globals."); -#if PY_VERSION_HEX >= 0x03000000 - return NULL; -#else - return; -#endif - } - PyDict_SetItemString(md, "cvar", globals); - Py_DECREF(globals); - SWIG_addvarlink(globals, "_embedded", Swig_var__embedded_get, Swig_var__embedded_set); #if PY_VERSION_HEX >= 0x03000000 return m; #else diff --git a/client/src/proxmark3.c b/client/src/proxmark3.c index 2b6e4bf8b..cde5b4a0a 100644 --- a/client/src/proxmark3.c +++ b/client/src/proxmark3.c @@ -727,7 +727,7 @@ pm3_device* pm3_open(char *port) { return session.current_device; } -void pm3_close(pm3_device* dev) { +void pm3_device_close(pm3_device* dev) { // For now, there is no real device context: (void) dev; // Clean up the port @@ -739,17 +739,17 @@ void pm3_close(pm3_device* dev) { } } -int pm3_console(pm3_device* dev, char *Cmd) { +int pm3_device_console(pm3_device* dev, char *Cmd) { // For now, there is no real device context: (void) dev; return CommandReceived(Cmd); } -char *pm3_get_name(pm3_device* dev) { +const char *pm3_device_name_get(pm3_device* dev) { return dev->conn->serial_port_name; } -pm3_device* pm3_get_current_dev(void) { +pm3_device* pm3_device_get_current_dev(void) { return session.current_device; } /* ======================================================= */