SWIG %extend
This commit is contained in:
1 parent
21841cb9d9
commit
47ba4acd02
15 files changed
+790
-39
No files matched your search
+35
-2
@@ -11,13 +11,46 @@
|
||||
/* 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
|
||||
#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);
|
||||
#endif
|
||||
#endif // LIBPM3_H
|
||||
Reference in new issue
Block a user