+ base ParameterGrpPy class on PyCXX and fix usage of unsigned values
This commit is contained in:
parent
1a06e50f0e
commit
dec030b34e
|
@ -48,520 +48,397 @@
|
||||||
#include "Exception.h"
|
#include "Exception.h"
|
||||||
#include "Console.h"
|
#include "Console.h"
|
||||||
#include "PyObjectBase.h"
|
#include "PyObjectBase.h"
|
||||||
|
#include <CXX/Extensions.hxx>
|
||||||
|
|
||||||
|
|
||||||
using namespace Base;
|
using namespace Base;
|
||||||
|
|
||||||
//**************************************************************************
|
class ParameterGrpPy : public Py::PythonExtension<ParameterGrpPy>
|
||||||
//**************************************************************************
|
|
||||||
// FCPyParametrGrp
|
|
||||||
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** The ParameterGrp wrapper class
|
|
||||||
*/
|
|
||||||
class ParameterGrpPy :public Base::PyObjectBase
|
|
||||||
{
|
{
|
||||||
/** always start with Py_Header */
|
public:
|
||||||
Py_Header;
|
static void init_type(void); // announce properties and methods
|
||||||
|
|
||||||
protected:
|
ParameterGrpPy(const Base::Reference<ParameterGrp> &rcParamGrp);
|
||||||
/// Destruction
|
|
||||||
~ParameterGrpPy();
|
~ParameterGrpPy();
|
||||||
|
|
||||||
public:
|
Py::Object repr();
|
||||||
|
|
||||||
|
Py::Object getGroup(const Py::Tuple&);
|
||||||
|
Py::Object remGroup(const Py::Tuple&);
|
||||||
|
Py::Object hasGroup(const Py::Tuple&);
|
||||||
|
|
||||||
//---------------------------------------------------------------------
|
Py::Object isEmpty(const Py::Tuple&);
|
||||||
// construction / destruction +++++++++++++++++++++++++++++++++++++++++
|
Py::Object clear(const Py::Tuple&);
|
||||||
//---------------------------------------------------------------------
|
|
||||||
|
|
||||||
/// Constructor
|
Py::Object notify(const Py::Tuple&);
|
||||||
ParameterGrpPy(const Base::Reference<ParameterGrp> &rcParamGrp, PyTypeObject *T = &Type);
|
Py::Object notifyAll(const Py::Tuple&);
|
||||||
/// for Construction in python
|
|
||||||
static PyObject *PyMake(PyObject *, PyObject *);
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------
|
Py::Object setBool(const Py::Tuple&);
|
||||||
// python exports ++++++++++++++++++++++++++++++++++++++++++++++++++++
|
Py::Object getBool(const Py::Tuple&);
|
||||||
//---------------------------------------------------------------------
|
Py::Object remBool(const Py::Tuple&);
|
||||||
|
|
||||||
PyObject *_repr(void);
|
Py::Object setInt(const Py::Tuple&);
|
||||||
PyObject *_getattr(char *attr); // __getattr__ function
|
Py::Object getInt(const Py::Tuple&);
|
||||||
// getter setter
|
Py::Object remInt(const Py::Tuple&);
|
||||||
int _setattr(char *attr, PyObject *value); // __setattr__ function
|
|
||||||
// methods
|
|
||||||
PYFUNCDEF_D (ParameterGrpPy,PyGetGrp);
|
|
||||||
PYFUNCDEF_D (ParameterGrpPy,PyRemGrp);
|
|
||||||
PYFUNCDEF_D (ParameterGrpPy,PyHasGroup);
|
|
||||||
PYFUNCDEF_D (ParameterGrpPy,PyIsEmpty);
|
|
||||||
PYFUNCDEF_D (ParameterGrpPy,PyClear);
|
|
||||||
PYFUNCDEF_D (ParameterGrpPy,PyNotify);
|
|
||||||
PYFUNCDEF_D (ParameterGrpPy,PyNotifyAll);
|
|
||||||
|
|
||||||
PYFUNCDEF_D (ParameterGrpPy,PySetBool);
|
Py::Object setUnsigned(const Py::Tuple&);
|
||||||
PYFUNCDEF_D (ParameterGrpPy,PyGetBool);
|
Py::Object getUnsigned(const Py::Tuple&);
|
||||||
PYFUNCDEF_D (ParameterGrpPy,PyRemBool);
|
Py::Object remUnsigned(const Py::Tuple&);
|
||||||
|
|
||||||
PYFUNCDEF_D (ParameterGrpPy,PySetInt);
|
Py::Object setFloat(const Py::Tuple&);
|
||||||
PYFUNCDEF_D (ParameterGrpPy,PyGetInt);
|
Py::Object getFloat(const Py::Tuple&);
|
||||||
PYFUNCDEF_D (ParameterGrpPy,PyRemInt);
|
Py::Object remFloat(const Py::Tuple&);
|
||||||
|
|
||||||
PYFUNCDEF_D (ParameterGrpPy,PySetUnsigned);
|
Py::Object setString(const Py::Tuple&);
|
||||||
PYFUNCDEF_D (ParameterGrpPy,PyGetUnsigned);
|
Py::Object getString(const Py::Tuple&);
|
||||||
PYFUNCDEF_D (ParameterGrpPy,PyRemUnsigned);
|
Py::Object remString(const Py::Tuple&);
|
||||||
|
|
||||||
PYFUNCDEF_D (ParameterGrpPy,PySetFloat);
|
Py::Object importFrom(const Py::Tuple&);
|
||||||
PYFUNCDEF_D (ParameterGrpPy,PyGetFloat);
|
Py::Object insert(const Py::Tuple&);
|
||||||
PYFUNCDEF_D (ParameterGrpPy,PyRemFloat);
|
Py::Object exportTo(const Py::Tuple&);
|
||||||
|
|
||||||
PYFUNCDEF_D (ParameterGrpPy,PySetString);
|
private:
|
||||||
PYFUNCDEF_D (ParameterGrpPy,PyGetString);
|
|
||||||
PYFUNCDEF_D (ParameterGrpPy,PyRemString);
|
|
||||||
|
|
||||||
PYFUNCDEF_D (ParameterGrpPy,importFrom);
|
|
||||||
PYFUNCDEF_D (ParameterGrpPy,insert);
|
|
||||||
PYFUNCDEF_D (ParameterGrpPy,exportTo);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
Base::Reference<ParameterGrp> _cParamGrp;
|
Base::Reference<ParameterGrp> _cParamGrp;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// ---------------------------------------------------------
|
||||||
|
|
||||||
//--------------------------------------------------------------------------
|
void ParameterGrpPy::init_type()
|
||||||
// Type structure
|
|
||||||
//--------------------------------------------------------------------------
|
|
||||||
|
|
||||||
PyTypeObject ParameterGrpPy::Type = {
|
|
||||||
PyObject_HEAD_INIT(&PyType_Type)
|
|
||||||
0, /*ob_size*/
|
|
||||||
"ParameterGrp", /*tp_name*/
|
|
||||||
sizeof(ParameterGrpPy), /*tp_basicsize*/
|
|
||||||
0, /*tp_itemsize*/
|
|
||||||
/* methods */
|
|
||||||
PyDestructor, /*tp_dealloc*/
|
|
||||||
0, /*tp_print*/
|
|
||||||
__getattr, /*tp_getattr*/
|
|
||||||
__setattr, /*tp_setattr*/
|
|
||||||
0, /*tp_compare*/
|
|
||||||
__repr, /*tp_repr*/
|
|
||||||
0, /*tp_as_number*/
|
|
||||||
0, /*tp_as_sequence*/
|
|
||||||
0, /*tp_as_mapping*/
|
|
||||||
0, /*tp_hash*/
|
|
||||||
0, /*tp_call */
|
|
||||||
0, /*tp_str */
|
|
||||||
0, /*tp_getattro*/
|
|
||||||
0, /*tp_setattro*/
|
|
||||||
/* --- Functions to access object as input/output buffer ---------*/
|
|
||||||
0, /* tp_as_buffer */
|
|
||||||
/* --- Flags to define presence of optional/expanded features */
|
|
||||||
0, /*tp_flags */
|
|
||||||
"Python interface class to set parameters", /*tp_doc */
|
|
||||||
0, /*tp_traverse */
|
|
||||||
0, /*tp_clear */
|
|
||||||
0, /*tp_richcompare */
|
|
||||||
0, /*tp_weaklistoffset */
|
|
||||||
0, /*tp_iter */
|
|
||||||
0, /*tp_iternext */
|
|
||||||
0, /*tp_methods */
|
|
||||||
0, /*tp_members */
|
|
||||||
0, /*tp_getset */
|
|
||||||
0, /*tp_base */
|
|
||||||
0, /*tp_dict */
|
|
||||||
0, /*tp_descr_get */
|
|
||||||
0, /*tp_descr_set */
|
|
||||||
0, /*tp_dictoffset */
|
|
||||||
0, /*tp_init */
|
|
||||||
0, /*tp_alloc */
|
|
||||||
0, /*tp_new */
|
|
||||||
0, /*tp_free Low-level free-memory routine */
|
|
||||||
0, /*tp_is_gc For PyObject_IS_GC */
|
|
||||||
0, /*tp_bases */
|
|
||||||
0, /*tp_mro method resolution order */
|
|
||||||
0, /*tp_cache */
|
|
||||||
0, /*tp_subclasses */
|
|
||||||
0, /*tp_weaklist */
|
|
||||||
0 /*tp_del */
|
|
||||||
};
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------
|
|
||||||
// Methods structure
|
|
||||||
//--------------------------------------------------------------------------
|
|
||||||
PyMethodDef ParameterGrpPy::Methods[] = {
|
|
||||||
{"GetGroup", (PyCFunction) sPyGetGrp, Py_NEWARGS, 0},
|
|
||||||
{"RemGroup", (PyCFunction) sPyRemGrp, Py_NEWARGS, 0},
|
|
||||||
{"HasGroup", (PyCFunction) sPyHasGroup, Py_NEWARGS, 0},
|
|
||||||
{"IsEmpty", (PyCFunction) sPyIsEmpty, Py_NEWARGS, 0},
|
|
||||||
{"Clear", (PyCFunction) sPyClear, Py_NEWARGS, 0},
|
|
||||||
{"Notify", (PyCFunction) sPyNotify, Py_NEWARGS, 0},
|
|
||||||
{"NotifyAll", (PyCFunction) sPyNotifyAll, Py_NEWARGS, 0},
|
|
||||||
|
|
||||||
{"SetBool", (PyCFunction) sPySetBool, Py_NEWARGS, 0},
|
|
||||||
{"GetBool", (PyCFunction) sPyGetBool, Py_NEWARGS, 0},
|
|
||||||
{"RemBool", (PyCFunction) sPyRemBool, Py_NEWARGS, 0},
|
|
||||||
|
|
||||||
{"SetInt", (PyCFunction) sPySetInt, Py_NEWARGS, 0},
|
|
||||||
{"GetInt", (PyCFunction) sPyGetInt, Py_NEWARGS, 0},
|
|
||||||
{"RemInt", (PyCFunction) sPyRemInt, Py_NEWARGS, 0},
|
|
||||||
|
|
||||||
{"SetUnsigned", (PyCFunction) sPySetUnsigned, Py_NEWARGS, 0},
|
|
||||||
{"GetUnsigned", (PyCFunction) sPyGetUnsigned, Py_NEWARGS, 0},
|
|
||||||
{"RemUnsigned", (PyCFunction) sPyRemUnsigned, Py_NEWARGS, 0},
|
|
||||||
|
|
||||||
{"SetFloat", (PyCFunction) sPySetFloat, Py_NEWARGS, 0},
|
|
||||||
{"GetFloat", (PyCFunction) sPyGetFloat, Py_NEWARGS, 0},
|
|
||||||
{"RemFloat", (PyCFunction) sPyRemFloat, Py_NEWARGS, 0},
|
|
||||||
|
|
||||||
{"SetString", (PyCFunction) sPySetString, Py_NEWARGS, 0},
|
|
||||||
{"GetString", (PyCFunction) sPyGetString, Py_NEWARGS, 0},
|
|
||||||
{"RemString", (PyCFunction) sPyRemString, Py_NEWARGS, 0},
|
|
||||||
|
|
||||||
{"Import", (PyCFunction) simportFrom, Py_NEWARGS, 0},
|
|
||||||
{"Insert", (PyCFunction) sinsert, Py_NEWARGS, 0},
|
|
||||||
{"Export", (PyCFunction) sexportTo, Py_NEWARGS, 0},
|
|
||||||
|
|
||||||
{NULL, NULL, 0, NULL} /* Sentinel */
|
|
||||||
};
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------
|
|
||||||
// constructor
|
|
||||||
//--------------------------------------------------------------------------
|
|
||||||
ParameterGrpPy::ParameterGrpPy(const Base::Reference<ParameterGrp> &rcParamGrp, PyTypeObject *T )
|
|
||||||
: PyObjectBase(0, T),_cParamGrp(rcParamGrp)
|
|
||||||
{
|
{
|
||||||
//Console().Log("Create Param Group %p\n",this);
|
behaviors().name("ParameterGrp");
|
||||||
|
behaviors().doc("Python interface class to set parameters");
|
||||||
|
// you must have overwritten the virtual functions
|
||||||
|
behaviors().supportRepr();
|
||||||
|
behaviors().supportGetattr();
|
||||||
|
behaviors().supportSetattr();
|
||||||
|
behaviors().readyType();
|
||||||
|
|
||||||
|
add_varargs_method("GetGroup",&ParameterGrpPy::getGroup,"GetGroup(str)");
|
||||||
|
add_varargs_method("RemGroup",&ParameterGrpPy::remGroup,"RemGroup(str)");
|
||||||
|
add_varargs_method("HasGroup",&ParameterGrpPy::hasGroup,"HasGroup(str)");
|
||||||
|
|
||||||
|
add_varargs_method("IsEmpty",&ParameterGrpPy::isEmpty,"IsEmpty()");
|
||||||
|
add_varargs_method("Clear",&ParameterGrpPy::clear,"Clear()");
|
||||||
|
|
||||||
|
add_varargs_method("Notify",&ParameterGrpPy::notify,"Notify()");
|
||||||
|
add_varargs_method("NotifyAll",&ParameterGrpPy::notifyAll,"NotifyAll()");
|
||||||
|
|
||||||
|
add_varargs_method("SetBool",&ParameterGrpPy::setBool,"SetBool()");
|
||||||
|
add_varargs_method("GetBool",&ParameterGrpPy::getBool,"GetBool()");
|
||||||
|
add_varargs_method("RemBool",&ParameterGrpPy::remBool,"RemBool()");
|
||||||
|
|
||||||
|
add_varargs_method("SetInt",&ParameterGrpPy::setInt,"SetInt()");
|
||||||
|
add_varargs_method("GetInt",&ParameterGrpPy::getInt,"GetInt()");
|
||||||
|
add_varargs_method("RemInt",&ParameterGrpPy::remInt,"RemInt()");
|
||||||
|
|
||||||
|
add_varargs_method("SetUnsigned",&ParameterGrpPy::setUnsigned,"SetUnsigned()");
|
||||||
|
add_varargs_method("GetUnsigned",&ParameterGrpPy::getUnsigned,"GetUnsigned()");
|
||||||
|
add_varargs_method("RemUnsigned",&ParameterGrpPy::remUnsigned,"RemUnsigned()");
|
||||||
|
|
||||||
|
add_varargs_method("SetFloat",&ParameterGrpPy::setFloat,"SetFloat()");
|
||||||
|
add_varargs_method("GetFloat",&ParameterGrpPy::getFloat,"GetFloat()");
|
||||||
|
add_varargs_method("RemFloat",&ParameterGrpPy::remFloat,"RemFloat()");
|
||||||
|
|
||||||
|
add_varargs_method("SetString",&ParameterGrpPy::setString,"SetString()");
|
||||||
|
add_varargs_method("GetString",&ParameterGrpPy::getString,"GetString()");
|
||||||
|
add_varargs_method("RemString",&ParameterGrpPy::remString,"RemString()");
|
||||||
|
|
||||||
|
add_varargs_method("Import",&ParameterGrpPy::importFrom,"Import()");
|
||||||
|
add_varargs_method("Insert",&ParameterGrpPy::insert,"Insert()");
|
||||||
|
add_varargs_method("Export",&ParameterGrpPy::exportTo,"Export()");
|
||||||
}
|
}
|
||||||
|
|
||||||
PyObject *ParameterGrpPy::PyMake(PyObject* /*ignored*/, PyObject* /*args*/) // Python wrapper
|
ParameterGrpPy::ParameterGrpPy(const Base::Reference<ParameterGrp> &rcParamGrp)
|
||||||
|
: _cParamGrp(rcParamGrp)
|
||||||
{
|
{
|
||||||
//return new ParameterGrpPy(); // Make new Python-able object
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------
|
ParameterGrpPy::~ParameterGrpPy()
|
||||||
// FCPyParametrGrp destructor
|
|
||||||
//--------------------------------------------------------------------------
|
|
||||||
ParameterGrpPy::~ParameterGrpPy() // Everything handled in parent
|
|
||||||
{
|
{
|
||||||
//Console().Log("Destroy ParameterGrp %p\n",this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------
|
Py::Object ParameterGrpPy::repr()
|
||||||
// FCPyParametrGrp Attributes
|
|
||||||
//--------------------------------------------------------------------------
|
|
||||||
|
|
||||||
PyObject *ParameterGrpPy::_repr(void)
|
|
||||||
{
|
{
|
||||||
std::stringstream a;
|
std::stringstream s;
|
||||||
a << "<ParameterGrp at " << this << ">";
|
s << "<ParameterGrp at " << this << ">";
|
||||||
return Py_BuildValue("s", a.str().c_str());
|
return Py::String(s.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
PyObject *ParameterGrpPy::_getattr(char *attr) // __getattr__ function: note only need to handle new state
|
Py::Object ParameterGrpPy::importFrom(const Py::Tuple& args)
|
||||||
{
|
|
||||||
_getattr_up(PyObjectBase); // send to parent
|
|
||||||
}
|
|
||||||
|
|
||||||
int ParameterGrpPy::_setattr(char *attr, PyObject *value) // __setattr__ function: note only need to handle new state
|
|
||||||
{
|
|
||||||
return PyObjectBase::_setattr(attr, value); // send up to parent
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------
|
|
||||||
// Python wrappers
|
|
||||||
//--------------------------------------------------------------------------
|
|
||||||
|
|
||||||
PyObject *ParameterGrpPy::importFrom(PyObject *args)
|
|
||||||
{
|
{
|
||||||
char *pstr;
|
char *pstr;
|
||||||
if (!PyArg_ParseTuple(args, "s", &pstr)) // convert args: Python->C
|
if (!PyArg_ParseTuple(args.ptr(), "s", &pstr))
|
||||||
return NULL; // NULL triggers exception
|
throw Py::Exception();
|
||||||
PY_TRY {
|
|
||||||
_cParamGrp->importFrom(pstr);
|
_cParamGrp->importFrom(pstr);
|
||||||
}PY_CATCH;
|
return Py::None();
|
||||||
Py_Return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PyObject *ParameterGrpPy::insert(PyObject *args)
|
Py::Object ParameterGrpPy::insert(const Py::Tuple& args)
|
||||||
{
|
{
|
||||||
char *pstr;
|
char *pstr;
|
||||||
if (!PyArg_ParseTuple(args, "s", &pstr)) // convert args: Python->C
|
if (!PyArg_ParseTuple(args.ptr(), "s", &pstr))
|
||||||
return NULL; // NULL triggers exception
|
throw Py::Exception();
|
||||||
PY_TRY {
|
|
||||||
_cParamGrp->insert(pstr);
|
_cParamGrp->insert(pstr);
|
||||||
}PY_CATCH;
|
return Py::None();
|
||||||
Py_Return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PyObject *ParameterGrpPy::exportTo(PyObject *args)
|
Py::Object ParameterGrpPy::exportTo(const Py::Tuple& args)
|
||||||
{
|
{
|
||||||
char *pstr;
|
char *pstr;
|
||||||
if (!PyArg_ParseTuple(args, "s", &pstr)) // convert args: Python->C
|
if (!PyArg_ParseTuple(args.ptr(), "s", &pstr))
|
||||||
return NULL; // NULL triggers exception
|
throw Py::Exception();
|
||||||
PY_TRY {
|
|
||||||
_cParamGrp->exportTo(pstr);
|
_cParamGrp->exportTo(pstr);
|
||||||
}PY_CATCH;
|
return Py::None();
|
||||||
Py_Return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PyObject *ParameterGrpPy::PyGetGrp(PyObject *args)
|
Py::Object ParameterGrpPy::getGroup(const Py::Tuple& args)
|
||||||
{
|
{
|
||||||
char *pstr;
|
char *pstr;
|
||||||
if (!PyArg_ParseTuple(args, "s", &pstr)) // convert args: Python->C
|
if (!PyArg_ParseTuple(args.ptr(), "s", &pstr))
|
||||||
return NULL; // NULL triggers exception
|
throw Py::Exception();
|
||||||
PY_TRY {
|
|
||||||
// get the Handle of the wanted group
|
// get the Handle of the wanted group
|
||||||
Base::Reference<ParameterGrp> handle = _cParamGrp->GetGroup(pstr);
|
Base::Reference<ParameterGrp> handle = _cParamGrp->GetGroup(pstr);
|
||||||
if(handle.isValid()){
|
if (handle.isValid()) {
|
||||||
// crate a python wrapper class
|
// crate a python wrapper class
|
||||||
ParameterGrpPy *pcParamGrp = new ParameterGrpPy(handle);
|
ParameterGrpPy *pcParamGrp = new ParameterGrpPy(handle);
|
||||||
// increment the reff count
|
// increment the reff count
|
||||||
//pcParamGrp->_INCREF();
|
return Py::asObject(pcParamGrp);
|
||||||
return pcParamGrp;
|
}
|
||||||
}else{
|
else {
|
||||||
PyErr_SetString(PyExc_IOError, "GetGroup failed");
|
throw Py::RuntimeError("GetGroup failed");
|
||||||
return 0L;
|
|
||||||
}
|
}
|
||||||
}PY_CATCH;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PyObject *ParameterGrpPy::PySetBool(PyObject *args)
|
Py::Object ParameterGrpPy::setBool(const Py::Tuple& args)
|
||||||
{
|
{
|
||||||
char *pstr;
|
char *pstr;
|
||||||
int Bool;
|
int Bool;
|
||||||
if (!PyArg_ParseTuple(args, "si", &pstr,&Bool)) // convert args: Python->C
|
if (!PyArg_ParseTuple(args.ptr(), "si", &pstr,&Bool))
|
||||||
return NULL; // NULL triggers exception
|
throw Py::Exception();
|
||||||
PY_TRY {
|
|
||||||
_cParamGrp->SetBool(pstr,Bool!=0);
|
_cParamGrp->SetBool(pstr,Bool!=0);
|
||||||
Py_Return;
|
return Py::None();
|
||||||
}PY_CATCH;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PyObject *ParameterGrpPy::PyGetBool(PyObject *args)
|
Py::Object ParameterGrpPy::getBool(const Py::Tuple& args)
|
||||||
{
|
{
|
||||||
char *pstr;
|
char *pstr;
|
||||||
int Bool=0;
|
int Bool=0;
|
||||||
if (!PyArg_ParseTuple(args, "s|i", &pstr,&Bool)) // convert args: Python->C
|
if (!PyArg_ParseTuple(args.ptr(), "s|i", &pstr,&Bool))
|
||||||
return NULL; // NULL triggers exception
|
throw Py::Exception();
|
||||||
PY_TRY {
|
|
||||||
return Py_BuildValue("i",_cParamGrp->GetBool(pstr,Bool!=0));
|
return Py::Boolean(_cParamGrp->GetBool(pstr,Bool!=0));
|
||||||
}PY_CATCH;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PyObject *ParameterGrpPy::PySetInt(PyObject *args)
|
Py::Object ParameterGrpPy::setInt(const Py::Tuple& args)
|
||||||
{
|
{
|
||||||
char *pstr;
|
char *pstr;
|
||||||
long Int;
|
int Int;
|
||||||
if (!PyArg_ParseTuple(args, "si", &pstr,&Int)) // convert args: Python->C
|
if (!PyArg_ParseTuple(args.ptr(), "si", &pstr,&Int))
|
||||||
return NULL; // NULL triggers exception
|
throw Py::Exception();
|
||||||
PY_TRY {
|
|
||||||
_cParamGrp->SetInt(pstr,Int);
|
_cParamGrp->SetInt(pstr,Int);
|
||||||
Py_Return;
|
return Py::None();
|
||||||
}PY_CATCH;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PyObject *ParameterGrpPy::PyGetInt(PyObject *args)
|
Py::Object ParameterGrpPy::getInt(const Py::Tuple& args)
|
||||||
{
|
{
|
||||||
char *pstr;
|
char *pstr;
|
||||||
long Int=0;
|
int Int=0;
|
||||||
if (!PyArg_ParseTuple(args, "s|i", &pstr,&Int)) // convert args: Python->C
|
if (!PyArg_ParseTuple(args.ptr(), "s|i", &pstr,&Int))
|
||||||
return NULL; // NULL triggers exception
|
throw Py::Exception();
|
||||||
PY_TRY {
|
#if PY_MAJOR_VERSION < 3
|
||||||
return Py_BuildValue("i",_cParamGrp->GetInt(pstr,Int));
|
return Py::Int(_cParamGrp->GetInt(pstr,Int));
|
||||||
}PY_CATCH;
|
#else
|
||||||
|
return Py::Long(_cParamGrp->GetInt(pstr,Int));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
PyObject *ParameterGrpPy::PySetUnsigned(PyObject *args)
|
Py::Object ParameterGrpPy::setUnsigned(const Py::Tuple& args)
|
||||||
{
|
{
|
||||||
char *pstr;
|
char *pstr;
|
||||||
unsigned long UInt;
|
unsigned int UInt;
|
||||||
if (!PyArg_ParseTuple(args, "sI", &pstr,&UInt)) // convert args: Python->C
|
if (!PyArg_ParseTuple(args.ptr(), "sI", &pstr,&UInt))
|
||||||
return NULL; // NULL triggers exception
|
throw Py::Exception();
|
||||||
PY_TRY {
|
|
||||||
_cParamGrp->SetUnsigned(pstr,UInt);
|
_cParamGrp->SetUnsigned(pstr,UInt);
|
||||||
Py_Return;
|
return Py::None();
|
||||||
}PY_CATCH;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PyObject *ParameterGrpPy::PyGetUnsigned(PyObject *args)
|
Py::Object ParameterGrpPy::getUnsigned(const Py::Tuple& args)
|
||||||
{
|
{
|
||||||
char *pstr;
|
char *pstr;
|
||||||
unsigned long UInt=0;
|
unsigned int UInt=0;
|
||||||
if (!PyArg_ParseTuple(args, "s|I", &pstr,&UInt)) // convert args: Python->C
|
if (!PyArg_ParseTuple(args.ptr(), "s|I", &pstr,&UInt))
|
||||||
return NULL; // NULL triggers exception
|
throw Py::Exception();
|
||||||
PY_TRY {
|
#if PY_MAJOR_VERSION < 3
|
||||||
return Py_BuildValue("I",_cParamGrp->GetUnsigned(pstr,UInt));
|
int cropped = _cParamGrp->GetUnsigned(pstr,UInt) & INT_MAX;
|
||||||
}PY_CATCH;
|
return Py::Int(cropped);
|
||||||
|
#else
|
||||||
|
return Py::Long(_cParamGrp->GetUnsigned(pstr,UInt));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
PyObject *ParameterGrpPy::PySetFloat(PyObject *args)
|
Py::Object ParameterGrpPy::setFloat(const Py::Tuple& args)
|
||||||
{
|
{
|
||||||
char *pstr;
|
char *pstr;
|
||||||
double Float;
|
double Float;
|
||||||
if (!PyArg_ParseTuple(args, "sd", &pstr,&Float)) // convert args: Python->C
|
if (!PyArg_ParseTuple(args.ptr(), "sd", &pstr,&Float))
|
||||||
return NULL; // NULL triggers exception
|
throw Py::Exception();
|
||||||
PY_TRY {
|
|
||||||
_cParamGrp->SetFloat(pstr,Float);
|
_cParamGrp->SetFloat(pstr,Float);
|
||||||
Py_Return;
|
return Py::None();
|
||||||
}PY_CATCH;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PyObject *ParameterGrpPy::PyGetFloat(PyObject *args)
|
Py::Object ParameterGrpPy::getFloat(const Py::Tuple& args)
|
||||||
{
|
{
|
||||||
char *pstr;
|
char *pstr;
|
||||||
double Float=0.0;
|
double Float=0.0;
|
||||||
if (!PyArg_ParseTuple(args, "s|d", &pstr,&Float)) // convert args: Python->C
|
if (!PyArg_ParseTuple(args.ptr(), "s|d", &pstr,&Float))
|
||||||
return NULL; // NULL triggers exception
|
throw Py::Exception();
|
||||||
PY_TRY {
|
|
||||||
return Py_BuildValue("d",_cParamGrp->GetFloat(pstr,Float));
|
return Py::Float(_cParamGrp->GetFloat(pstr,Float));
|
||||||
}PY_CATCH;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PyObject *ParameterGrpPy::PySetString(PyObject *args)
|
Py::Object ParameterGrpPy::setString(const Py::Tuple& args)
|
||||||
{
|
{
|
||||||
char *pstr;
|
char *pstr;
|
||||||
char * str;
|
char * str;
|
||||||
if (!PyArg_ParseTuple(args, "ss", &pstr,&str)) // convert args: Python->C
|
if (!PyArg_ParseTuple(args.ptr(), "ss", &pstr,&str))
|
||||||
return NULL; // NULL triggers exception
|
throw Py::Exception();
|
||||||
PY_TRY {
|
|
||||||
_cParamGrp->SetASCII(pstr,str);
|
_cParamGrp->SetASCII(pstr,str);
|
||||||
Py_Return;
|
return Py::None();
|
||||||
}PY_CATCH;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PyObject *ParameterGrpPy::PyGetString(PyObject *args)
|
Py::Object ParameterGrpPy::getString(const Py::Tuple& args)
|
||||||
{
|
{
|
||||||
char *pstr;
|
char *pstr;
|
||||||
char * str="";
|
char * str="";
|
||||||
if (!PyArg_ParseTuple(args, "s|s", &pstr,&str)) // convert args: Python->C
|
if (!PyArg_ParseTuple(args.ptr(), "s|s", &pstr,&str))
|
||||||
return NULL; // NULL triggers exception
|
throw Py::Exception();
|
||||||
PY_TRY {
|
|
||||||
return Py_BuildValue("s",_cParamGrp->GetASCII(pstr,str).c_str());
|
return Py::String(_cParamGrp->GetASCII(pstr,str));
|
||||||
}PY_CATCH;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//----
|
Py::Object ParameterGrpPy::remInt(const Py::Tuple& args)
|
||||||
|
|
||||||
PyObject *ParameterGrpPy::PyRemInt(PyObject *args)
|
|
||||||
{
|
{
|
||||||
char *pstr;
|
char *pstr;
|
||||||
if (!PyArg_ParseTuple(args, "s", &pstr)) // convert args: Python->C
|
if (!PyArg_ParseTuple(args.ptr(), "s", &pstr))
|
||||||
return NULL; // NULL triggers exception
|
throw Py::Exception();
|
||||||
PY_TRY {
|
|
||||||
_cParamGrp->RemoveInt(pstr);
|
_cParamGrp->RemoveInt(pstr);
|
||||||
Py_Return;
|
return Py::None();
|
||||||
}PY_CATCH;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PyObject *ParameterGrpPy::PyRemUnsigned(PyObject *args)
|
Py::Object ParameterGrpPy::remUnsigned(const Py::Tuple& args)
|
||||||
{
|
{
|
||||||
char *pstr;
|
char *pstr;
|
||||||
if (!PyArg_ParseTuple(args, "s", &pstr)) // convert args: Python->C
|
if (!PyArg_ParseTuple(args.ptr(), "s", &pstr))
|
||||||
return NULL; // NULL triggers exception
|
throw Py::Exception();
|
||||||
PY_TRY {
|
|
||||||
_cParamGrp->RemoveUnsigned(pstr);
|
_cParamGrp->RemoveUnsigned(pstr);
|
||||||
Py_Return;
|
return Py::None();
|
||||||
}PY_CATCH;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PyObject *ParameterGrpPy::PyRemBool(PyObject *args)
|
Py::Object ParameterGrpPy::remBool(const Py::Tuple& args)
|
||||||
{
|
{
|
||||||
char *pstr;
|
char *pstr;
|
||||||
if (!PyArg_ParseTuple(args, "s", &pstr)) // convert args: Python->C
|
if (!PyArg_ParseTuple(args.ptr(), "s", &pstr))
|
||||||
return NULL; // NULL triggers exception
|
throw Py::Exception();
|
||||||
PY_TRY {
|
|
||||||
_cParamGrp->RemoveBool(pstr);
|
_cParamGrp->RemoveBool(pstr);
|
||||||
Py_Return;
|
return Py::None();
|
||||||
}PY_CATCH;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PyObject *ParameterGrpPy::PyRemGrp(PyObject *args)
|
Py::Object ParameterGrpPy::remGroup(const Py::Tuple& args)
|
||||||
{
|
{
|
||||||
char *pstr;
|
char *pstr;
|
||||||
if (!PyArg_ParseTuple(args, "s", &pstr)) // convert args: Python->C
|
if (!PyArg_ParseTuple(args.ptr(), "s", &pstr))
|
||||||
return NULL; // NULL triggers exception
|
throw Py::Exception();
|
||||||
PY_TRY {
|
|
||||||
_cParamGrp->RemoveGrp(pstr);
|
_cParamGrp->RemoveGrp(pstr);
|
||||||
Py_Return;
|
return Py::None();
|
||||||
}PY_CATCH;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PyObject *ParameterGrpPy::PyRemFloat(PyObject *args)
|
Py::Object ParameterGrpPy::remFloat(const Py::Tuple& args)
|
||||||
{
|
{
|
||||||
char *pstr;
|
char *pstr;
|
||||||
if (!PyArg_ParseTuple(args, "s", &pstr)) // convert args: Python->C
|
if (!PyArg_ParseTuple(args.ptr(), "s", &pstr))
|
||||||
return NULL; // NULL triggers exception
|
throw Py::Exception();
|
||||||
PY_TRY {
|
|
||||||
_cParamGrp->RemoveFloat(pstr);
|
_cParamGrp->RemoveFloat(pstr);
|
||||||
Py_Return;
|
return Py::None();
|
||||||
}PY_CATCH;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PyObject *ParameterGrpPy::PyRemString(PyObject *args)
|
Py::Object ParameterGrpPy::remString(const Py::Tuple& args)
|
||||||
{
|
{
|
||||||
char *pstr;
|
char *pstr;
|
||||||
if (!PyArg_ParseTuple(args, "s", &pstr)) // convert args: Python->C
|
if (!PyArg_ParseTuple(args.ptr(), "s", &pstr))
|
||||||
return NULL; // NULL triggers exception
|
throw Py::Exception();
|
||||||
PY_TRY {
|
|
||||||
_cParamGrp->RemoveASCII(pstr);
|
_cParamGrp->RemoveASCII(pstr);
|
||||||
Py_Return;
|
return Py::None();
|
||||||
}PY_CATCH;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PyObject *ParameterGrpPy::PyClear(PyObject *args)
|
Py::Object ParameterGrpPy::clear(const Py::Tuple& args)
|
||||||
{
|
{
|
||||||
if (!PyArg_ParseTuple(args, "")) // convert args: Python->C
|
if (!PyArg_ParseTuple(args.ptr(), ""))
|
||||||
return NULL; // NULL triggers exception
|
throw Py::Exception();
|
||||||
PY_TRY {
|
|
||||||
_cParamGrp->Clear();
|
_cParamGrp->Clear();
|
||||||
Py_Return;
|
return Py::None();
|
||||||
}PY_CATCH;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PyObject *ParameterGrpPy::PyIsEmpty(PyObject *args)
|
Py::Object ParameterGrpPy::isEmpty(const Py::Tuple& args)
|
||||||
{
|
{
|
||||||
if (!PyArg_ParseTuple(args, "")) // convert args: Python->C
|
if (!PyArg_ParseTuple(args.ptr(), ""))
|
||||||
return NULL; // NULL triggers exception
|
throw Py::Exception();
|
||||||
PY_TRY {
|
|
||||||
return Py_BuildValue("i",_cParamGrp->IsEmpty());
|
return Py::Boolean(_cParamGrp->IsEmpty());
|
||||||
}PY_CATCH;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PyObject *ParameterGrpPy::PyHasGroup(PyObject *args)
|
Py::Object ParameterGrpPy::hasGroup(const Py::Tuple& args)
|
||||||
{
|
{
|
||||||
char *pstr;
|
char *pstr;
|
||||||
if (!PyArg_ParseTuple(args, "s", &pstr)) // convert args: Python->C
|
if (!PyArg_ParseTuple(args.ptr(), "s", &pstr))
|
||||||
return NULL; // NULL triggers exception
|
throw Py::Exception();
|
||||||
PY_TRY {
|
|
||||||
return Py_BuildValue("i",_cParamGrp->HasGroup(pstr));
|
return Py::Boolean(_cParamGrp->HasGroup(pstr));
|
||||||
}PY_CATCH;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PyObject *ParameterGrpPy::PyNotify(PyObject *args)
|
Py::Object ParameterGrpPy::notify(const Py::Tuple& args)
|
||||||
{
|
{
|
||||||
char *pstr;
|
char *pstr;
|
||||||
if (!PyArg_ParseTuple(args, "s", &pstr)) // convert args: Python->C
|
if (!PyArg_ParseTuple(args.ptr(), "s", &pstr))
|
||||||
return NULL; // NULL triggers exception
|
throw Py::Exception();
|
||||||
PY_TRY {
|
|
||||||
_cParamGrp->Notify(pstr);
|
_cParamGrp->Notify(pstr);
|
||||||
Py_Return;
|
return Py::None();
|
||||||
}PY_CATCH;
|
|
||||||
}
|
}
|
||||||
PyObject *ParameterGrpPy::PyNotifyAll(PyObject *args)
|
|
||||||
{
|
|
||||||
if (!PyArg_ParseTuple(args, "")) // convert args: Python->C
|
|
||||||
return NULL; // NULL triggers exception
|
|
||||||
|
|
||||||
PY_TRY {
|
Py::Object ParameterGrpPy::notifyAll(const Py::Tuple& args)
|
||||||
|
{
|
||||||
|
if (!PyArg_ParseTuple(args.ptr(), ""))
|
||||||
|
throw Py::Exception();
|
||||||
|
|
||||||
_cParamGrp->NotifyAll();
|
_cParamGrp->NotifyAll();
|
||||||
Py_Return;
|
return Py::None();
|
||||||
}PY_CATCH;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** python wrapper function
|
/** python wrapper function
|
||||||
*/
|
*/
|
||||||
PyObject* GetPyObject( const Base::Reference<ParameterGrp> &hcParamGrp)
|
PyObject* GetPyObject(const Base::Reference<ParameterGrp> &hcParamGrp)
|
||||||
{
|
{
|
||||||
|
static bool init = false;
|
||||||
|
if (!init) {
|
||||||
|
init = true;
|
||||||
|
ParameterGrpPy::init_type();
|
||||||
|
}
|
||||||
|
|
||||||
return new ParameterGrpPy(hcParamGrp);
|
return new ParameterGrpPy(hcParamGrp);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user