Better SWIG integration: autogen func & attributes

This commit is contained in:
slurdge 2020-06-14 11:32:37 +02:00 committed by Philippe Teuwen
parent 756b624668
commit 538ee4dabb
12 changed files with 887 additions and 1037 deletions

View file

@ -1,4 +1,4 @@
#!/bin/bash #!/bin/bash
swig -lua -o ../src/pm3_luawrap.c ../include/pm3.h swig -lua -o ../src/pm3_luawrap.c ../include/pm3.i
swig -python -o ../src/pm3_pywrap.c ../include/pm3.h swig -python -o ../src/pm3_pywrap.c ../include/pm3.i

View file

@ -1,4 +1,4 @@
local pm3 = require("pm3") local pm3 = require("pm3")
p=pm3.device() p=pm3.device()
--p.console("hw status") ?? p:console("hw status")
p.console(p, "hw status") print(p.name)

View file

@ -3,4 +3,4 @@
import pm3 import pm3
p=pm3.device() p=pm3.device()
p.console("hw status") p.console("hw status")
print("Device:", p.get_name()) print("Device:", p.name)

View file

@ -1,56 +1,11 @@
#ifndef LIBPM3_H #ifndef LIBPM3_H
#define 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; typedef struct pm3_device pm3_device;
pm3_device* pm3_open(char *port); pm3_device* pm3_open(char *port);
int pm3_console(pm3_device* dev, char *cmd); int pm3_device_console(pm3_device* dev, char *cmd);
char *pm3_get_name(pm3_device* dev); char *pm3_device_name_get(pm3_device* dev);
void pm3_close(pm3_device* dev); void pm3_device_close(pm3_device* dev);
pm3_device* pm3_get_current_dev(void); pm3_device* pm3_device_get_current_dev(void);
#endif // LIBPM3_H #endif // LIBPM3_H

39
client/include/pm3.i Normal file
View file

@ -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 */

View file

@ -2,5 +2,5 @@
local pm3 = require("pm3") local pm3 = require("pm3")
p=pm3.device("/dev/ttyACM0") p=pm3.device("/dev/ttyACM0")
--p.console("hw status") ?? p:console("hw status")
p.console(p, "hw status") print(p.name)

View file

@ -3,4 +3,4 @@
import pm3 import pm3
p=pm3.device("/dev/ttyACM0") p=pm3.device("/dev/ttyACM0")
p.console("hw status") p.console("hw status")
print("Device:", p.get_name()) print("Device:", p.name)

View file

@ -68,6 +68,7 @@ extern communication_arg_t conn;
typedef struct pm3_device pm3_device; typedef struct pm3_device pm3_device;
struct pm3_device { struct pm3_device {
communication_arg_t *conn; communication_arg_t *conn;
int script_embedded;
}; };
void *uart_receiver(void *targ); void *uart_receiver(void *targ);

View file

@ -1,24 +1,85 @@
# This file was automatically generated by SWIG (http://www.swig.org). # 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 # Do not make changes to this file unless you know what you are doing--modify
# the SWIG interface file instead. # the SWIG interface file instead.
from sys import version_info as _swig_python_version_info from sys import version_info as _swig_python_version_info
if _swig_python_version_info < (2, 7, 0): if _swig_python_version_info >= (2, 7, 0):
raise RuntimeError("Python 2.7 or later required") def swig_import_helper():
import importlib
# Import the low-level C/C++ module pkg = __name__.rpartition('.')[0]
if __package__ or "." in __name__: mname = '.'.join((pkg, '_pm3')).lstrip('.')
from . import _pm3 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: else:
import _pm3 import _pm3
del _swig_python_version_info
try:
_swig_property = property
except NameError:
pass # Python < 2.2 doesn't have 'property'.
try: try:
import builtins as __builtin__ import builtins as __builtin__
except ImportError: except ImportError:
import __builtin__ 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): def _swig_repr(self):
try: try:
strthis = "proxy of " + self.this.__repr__() strthis = "proxy of " + self.this.__repr__()
@ -26,73 +87,38 @@ def _swig_repr(self):
strthis = "" strthis = ""
return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, 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): class device(_object):
def set_instance_attr(self, name, value): __swig_setmethods__ = {}
if name == "thisown": __setattr__ = lambda self, name, value: _swig_setattr(self, device, name, value)
self.this.own(value) __swig_getmethods__ = {}
elif name == "this": __getattr__ = lambda self, name: _swig_getattr(self, device, name)
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")
__repr__ = _swig_repr __repr__ = _swig_repr
def __init__(self, *args): 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 __swig_destroy__ = _pm3.delete_device
__del__ = lambda self: None
def console(self, cmd): def console(self, cmd):
return _pm3.device_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): # This file is compatible with both classic and new-style classes.
return _pm3.device_get_name(self)
# Register device in _pm3:
_pm3.device_swigregister(device)
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

View file

@ -1,6 +1,6 @@
/* ---------------------------------------------------------------------------- /* ----------------------------------------------------------------------------
* This file was automatically generated by SWIG (http://www.swig.org). * 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 * 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 * coding conventions designed to improve portability and efficiency. Do not make
@ -185,7 +185,6 @@
/* Flags for pointer conversions */ /* Flags for pointer conversions */
#define SWIG_POINTER_DISOWN 0x1 #define SWIG_POINTER_DISOWN 0x1
#define SWIG_CAST_NEW_MEMORY 0x2 #define SWIG_CAST_NEW_MEMORY 0x2
#define SWIG_POINTER_NO_NULL 0x4
/* Flags for new pointer objects */ /* Flags for new pointer objects */
#define SWIG_POINTER_OWN 0x1 #define SWIG_POINTER_OWN 0x1
@ -714,23 +713,6 @@ SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) {
} }
#endif #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 * luarun.swg
* *
@ -913,8 +895,8 @@ typedef struct swig_elua_entry {
* -------------------------------------------------------------------------- */ * -------------------------------------------------------------------------- */
/* Push the string STR on the Lua stack, like lua_pushstring, but /* Push the string STR on the Lua stack, like lua_pushstring, but
prefixed with the location of the innermost Lua call-point prefixed with the the location of the innermost Lua call-point
(as formatted by luaL_where). */ (as formated by luaL_where). */
SWIGRUNTIME void SWIGRUNTIME void
SWIG_Lua_pusherrstring (lua_State *L, const char *str) 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 /* Push a formatted string generated from FMT and following args on
the Lua stack, like lua_pushfstring, but prefixed with the the Lua stack, like lua_pushfstring, but prefixed with the the
location of the innermost Lua call-point (as formatted by luaL_where). */ location of the innermost Lua call-point (as formated by luaL_where). */
SWIGRUNTIME void SWIGRUNTIME void
SWIG_Lua_pushferrstring (lua_State *L, const char *fmt, ...) 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 { typedef struct {
swig_type_info *type; swig_type_info *type;
int own; /* 1 if owned & must be destroyed */ 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; } swig_lua_rawdata;
/* Common SWIG API */ /* Common SWIG API */
@ -1772,11 +1754,17 @@ SWIGINTERN int SWIG_Lua_class_tostring(lua_State *L)
{ {
/* there should be 1 param passed in /* there should be 1 param passed in
(1) userdata (not the metatable) */ (1) userdata (not the metatable) */
swig_lua_userdata* userData; const char *className;
void* userData;
assert(lua_isuserdata(L,1)); /* just in case */ 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 of type '%s' at %p>", 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; return 1;
} }
@ -2492,12 +2480,7 @@ SWIGRUNTIME int SWIG_Lua_ConvertPtr(lua_State *L,int index,void **ptr,swig_type
{ {
swig_lua_userdata *usr; swig_lua_userdata *usr;
swig_cast_info *cast; swig_cast_info *cast;
/* special case: lua nil => NULL pointer */ if (lua_isnil(L,index)){*ptr=0; return SWIG_OK;} /* special case: lua nil => NULL pointer */
if (lua_isnil(L,index))
{
*ptr=0;
return (flags & SWIG_POINTER_NO_NULL) ? SWIG_NullReferenceError : SWIG_OK;
}
usr=(swig_lua_userdata*)lua_touserdata(L,index); /* get data */ usr=(swig_lua_userdata*)lua_touserdata(L,index); /* get data */
if (usr) if (usr)
{ {
@ -2592,7 +2575,7 @@ SWIG_Lua_InstallConstants(lua_State *L, swig_lua_const_info constants[]) {
switch(constants[i].type) { switch(constants[i].type) {
case SWIG_LUA_INT: case SWIG_LUA_INT:
lua_pushstring(L,constants[i].name); 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); lua_rawset(L,-3);
break; break;
case SWIG_LUA_FLOAT: case SWIG_LUA_FLOAT:
@ -2603,7 +2586,7 @@ SWIG_Lua_InstallConstants(lua_State *L, swig_lua_const_info constants[]) {
case SWIG_LUA_CHAR: case SWIG_LUA_CHAR:
lua_pushstring(L,constants[i].name); lua_pushstring(L,constants[i].name);
{ {
char c = (char)constants[i].lvalue; char c = constants[i].lvalue;
lua_pushlstring(L,&c,1); lua_pushlstring(L,&c,1);
} }
lua_rawset(L,-3); lua_rawset(L,-3);
@ -2684,11 +2667,13 @@ static swig_module_info swig_module = {swig_types, 1, 0, 0, 0, 0};
/* Include the header in the wrapper code */ /* Include the header in the wrapper code */
#include "pm3.h" #include "pm3.h"
#include "comms.h"
SWIGINTERN struct pm3_device *new_pm3_device__SWIG_0(void){ SWIGINTERN pm3_device *new_pm3_device__SWIG_0(void){
printf("SWIG pm3_device constructor, get current pm3\n"); printf("SWIG pm3_device constructor, get current pm3\n");
_embedded = 1; pm3_device * p = pm3_device_get_current_dev();
return pm3_get_current_dev(); p->script_embedded = 1;
return p;
} }
SWIGINTERN int SWIG_lua_isnilstring(lua_State *L, int idx) { SWIGINTERN int SWIG_lua_isnilstring(lua_State *L, int idx) {
@ -2698,34 +2683,29 @@ SWIGINTERN int SWIG_lua_isnilstring(lua_State *L, int idx) {
return ret; return ret;
} }
SWIGINTERN struct pm3_device *new_pm3_device__SWIG_1(char *port){ SWIGINTERN pm3_device *new_pm3_device__SWIG_1(char *port){
printf("SWIG pm3_device constructor with port, open pm3\n"); printf("SWIG pm3_device constructor with port, open pm3\n");
_embedded = 0; pm3_device * p = pm3_open(port);
return pm3_open(port); p->script_embedded = 1;
return p;
} }
SWIGINTERN void delete_pm3_device(struct pm3_device *self){ SWIGINTERN void delete_pm3_device(pm3_device *self){
if (_embedded) { if (self->script_embedded) {
printf("SWIG pm3_device destructor, nothing to do\n"); printf("SWIG pm3_device destructor, nothing to do\n");
} else { } else {
printf("SWIG pm3_device destructor, close pm3\n"); printf("SWIG pm3_device destructor, close pm3\n");
pm3_close(self); 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 #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
static int _wrap_new_device__SWIG_0(lua_State* L) { static int _wrap_new_device__SWIG_0(lua_State* L) {
int SWIG_arg = 0; int SWIG_arg = 0;
struct pm3_device *result = 0 ; pm3_device *result = 0 ;
SWIG_check_num_args("pm3_device::pm3_device",0,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++; SWIG_NewPointerObj(L,result,SWIGTYPE_p_pm3_device,1); SWIG_arg++;
return SWIG_arg; return SWIG_arg;
@ -2740,12 +2720,12 @@ fail:
static int _wrap_new_device__SWIG_1(lua_State* L) { static int _wrap_new_device__SWIG_1(lua_State* L) {
int SWIG_arg = 0; int SWIG_arg = 0;
char *arg1 = (char *) 0 ; char *arg1 = (char *) 0 ;
struct pm3_device *result = 0 ; pm3_device *result = 0 ;
SWIG_check_num_args("pm3_device::pm3_device",1,1) 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 *"); if(!SWIG_lua_isnilstring(L,1)) SWIG_fail_arg("pm3_device::pm3_device",1,"char *");
arg1 = (char *)lua_tostring(L, 1); 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++; SWIG_NewPointerObj(L,result,SWIGTYPE_p_pm3_device,1); SWIG_arg++;
return 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) { static int _wrap_device_console(lua_State* L) {
int SWIG_arg = 0; int SWIG_arg = 0;
struct pm3_device *arg1 = (struct pm3_device *) 0 ; pm3_device *arg1 = (pm3_device *) 0 ;
char *arg2 = (char *) 0 ; char *arg2 = (char *) 0 ;
int result; int result;
SWIG_check_num_args("pm3_device::console",2,2) 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_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))){ 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; int SWIG_arg = 0;
struct pm3_device *arg1 = (struct pm3_device *) 0 ; pm3_device *arg1 = (pm3_device *) 0 ;
char *result = 0 ; char *result = 0 ;
SWIG_check_num_args("pm3_device::get_name",1,1) SWIG_check_num_args("pm3_device::name",1,1)
if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("pm3_device::get_name",1,"struct pm3_device *"); 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))){ 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++; lua_pushstring(L,(const char *)result); SWIG_arg++;
return SWIG_arg; return SWIG_arg;
@ -2837,7 +2817,7 @@ fail:
static void swig_delete_device(void *obj) { 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); delete_pm3_device(arg1);
} }
static int _proxy__wrap_new_device(lua_State *L) { static int _proxy__wrap_new_device(lua_State *L) {
@ -2849,11 +2829,11 @@ static int _proxy__wrap_new_device(lua_State *L) {
return 1; return 1;
} }
static swig_lua_attribute swig_device_attributes[] = { static swig_lua_attribute swig_device_attributes[] = {
{ "name", _wrap_device_name_get, SWIG_Lua_set_immutable },
{0,0,0} {0,0,0}
}; };
static swig_lua_method swig_device_methods[]= { static swig_lua_method swig_device_methods[]= {
{ "console", _wrap_device_console}, { "console", _wrap_device_console},
{ "get_name", _wrap_device_get_name},
{0,0} {0,0}
}; };
static swig_lua_method swig_device_meta[] = { 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 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 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[] = { static swig_lua_attribute swig_SwigModule_attributes[] = {
{ "_embedded", _wrap__embedded_get, _wrap__embedded_set },
{0,0,0} {0,0,0}
}; };
static swig_lua_const_info swig_SwigModule_constants[]= { static swig_lua_const_info swig_SwigModule_constants[]= {
{0,0,0,0,0,0} {0,0,0,0,0,0}
}; };
static swig_lua_method swig_SwigModule_methods[]= { 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} {0,0}
}; };
static swig_lua_class* swig_SwigModule_classes[]= { static swig_lua_class* swig_SwigModule_classes[]= {
@ -3069,7 +2896,7 @@ static swig_lua_namespace swig_SwigModule = {
/* -------- TYPE CONVERSION AND EQUIVALENCE RULES (BEGIN) -------- */ /* -------- 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[] = { static swig_type_info *swig_type_initial[] = {
&_swigt__p_pm3_device, &_swigt__p_pm3_device,
@ -3184,7 +3011,7 @@ SWIG_InitializeModule(void *clientdata) {
/* Now work on filling in swig_module.types */ /* Now work on filling in swig_module.types */
#ifdef SWIGRUNTIME_DEBUG #ifdef SWIGRUNTIME_DEBUG
printf("SWIG_InitializeModule: size %lu\n", (unsigned long)swig_module.size); printf("SWIG_InitializeModule: size %d\n", swig_module.size);
#endif #endif
for (i = 0; i < swig_module.size; ++i) { for (i = 0; i < swig_module.size; ++i) {
swig_type_info *type = 0; swig_type_info *type = 0;
@ -3192,7 +3019,7 @@ SWIG_InitializeModule(void *clientdata) {
swig_cast_info *cast; swig_cast_info *cast;
#ifdef SWIGRUNTIME_DEBUG #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 #endif
/* if there is another module already loaded */ /* if there is another module already loaded */
@ -3268,7 +3095,7 @@ SWIG_InitializeModule(void *clientdata) {
for (i = 0; i < swig_module.size; ++i) { for (i = 0; i < swig_module.size; ++i) {
int j = 0; int j = 0;
swig_cast_info *cast = swig_module.cast_initial[i]; 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) { while (cast->type) {
printf("SWIG_InitializeModule: cast type %s\n", cast->type->name); printf("SWIG_InitializeModule: cast type %s\n", cast->type->name);
cast++; cast++;

File diff suppressed because it is too large Load diff

View file

@ -727,7 +727,7 @@ pm3_device* pm3_open(char *port) {
return session.current_device; 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: // For now, there is no real device context:
(void) dev; (void) dev;
// Clean up the port // 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: // For now, there is no real device context:
(void) dev; (void) dev;
return CommandReceived(Cmd); 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; 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; return session.current_device;
} }
/* ======================================================= */ /* ======================================================= */