36 for(PVecClassAttribute::const_iterator it(vecAttr.begin()); it != vecAttr.end(); ++it){
39 fs <<
"int "+className+
"_set"+it->getName()+
"("+className+
" * self, PyObject * value, void * closure);\n";
40 fs <<
"PyObject * "+className+
"_get"+it->getName()+
"("+className+
" * self, void * closure);\n";
53 for(PVecClassAttribute::const_iterator it(vecAttr.begin()); it != vecAttr.end(); ++it){
55 PString attrName(it->getName()), attrDoc(it->getDocumentation());
56 fs <<
"///Setter of the "+attrName+
"\n";
57 fs <<
"/**\t@param self : object "+className+
"\n";
58 fs <<
" * \t@param value : "+attrDoc+
"\n";
59 fs <<
" * \t@param closure : object closure for python API (it is a wrapper python grosse bidouille)\n";
60 fs <<
" * \t@return 0 on success, -1 otherwise\n";
62 fs <<
"int "+className+
"_set"+attrName+
"("+className+
" * self, PyObject * value, void * closure){\n";
63 fs <<
"\tif(value == NULL){\n";
64 fs <<
"\t\tPyErr_SetString(PyExc_TypeError, \"Cannot delete the "+className+
"."+attrName+
" attribute\");\n";
65 fs <<
"\t\treturn -1;\n";
67 fs <<
"\tPy_DECREF(self->"+attrName+
");\n";
68 fs <<
"\tPy_INCREF(value);\n";
69 fs <<
"\tself->"+attrName+
" = value;\n";
70 fs <<
"\treturn 0;\n";
73 fs <<
"///Setter of the "+attrName+
"\n";
74 fs <<
"/**\t@param self : object "+className+
"\n";
75 fs <<
" * \t@param closure : object closure for python API (it is a wrapper python grosse bidouille)\n";
76 fs <<
" * \t@return "+attrDoc+
"\n";
78 fs <<
"PyObject * "+className+
"_get"+attrName+
"("+className+
" * self, void * closure){\n";
79 fs <<
"\tPy_INCREF(self->"+attrName+
");\n";
80 fs <<
"\treturn self->"+attrName+
";\n";
95 for(PVecClassAttribute::const_iterator it(vecAttr.begin()); it != vecAttr.end(); ++it){
99 fs <<
"\t{(char*)\""<<it->getName()<<
"\", "+
getPythonStrForPythonApiType(it->getType())<<
", offsetof("<<className<<
", "<<it->getName()<<
"), 0, (char*)\"Doc : "<<it->getDocumentation().replace(
"///",
"")<<
"\"},\n";
112 for(PVecClassAttribute::const_iterator it(vecAttr.begin()); it != vecAttr.end(); ++it){
116 fs <<
"\t{(char*)\""<<it->getName()+
"\", (getter)"<<className+
"_get"<<it->getName()<<
", (setter)"<<className+
"_set"+it->getName()<<
", (char*)\""+it->getDocumentation().replace(
"///",
"")+
"\", NULL},\n";
std::vector< PClassAttribute > PVecClassAttribute
PAbstractWrapperTraitBackend()
Class to describe a basic class.
const std::vector< PClassAttribute > & getListAttribute() const
Returns the list of attributes of the class.
bool getIsEnum() const
Say if the current PClassConfig is an enum.
virtual void classMethodImplementation(std::ofstream &fs, const PClassConfig &classConfig, const GeneratorMode &mode) const
Implementation of class method.
virtual void classMethodDeclaration(std::ofstream &fs, const PClassConfig &classConfig, const GeneratorMode &mode) const
Declaration of class method.
virtual void registerClassGetterSetter(std::ofstream &fs, const PClassConfig &classConfig, const GeneratorMode &mode) const
Register class getter and setter.
virtual void registerClassMethod(std::ofstream &fs, const PClassConfig &classConfig, const GeneratorMode &mode) const
Register class method.
virtual void testFunction(std::ofstream &fs, const PClassConfig &classConfig, const GeneratorMode &mode) const
Implementation of test function.
virtual ~WrapperTraitGetterSetter()
Desctructor of WrapperTraitGetterSetter.
virtual void headerExtraInclude(std::ofstream &fs, const GeneratorMode &mode) const
Add extra include on the header.
virtual void registerClassMember(std::ofstream &fs, const PClassConfig &classConfig, const GeneratorMode &mode) const
Register class member.
virtual void testCallFunction(std::ofstream &fs, const PClassConfig &classConfig, const GeneratorMode &mode) const
Call of the test function.
WrapperTraitGetterSetter()
Consctructor of WrapperTraitGetterSetter.
bool enableGetter
True to enable getters trait generator.
bool enableSetter
True to enable setters trait generator.
bool getIsSimpleType(const PString &varType)
Check if the given type is a simple type.
PString getPythonStrForPythonApiType(const PString &typeStr)
Gets the python API str type of the correcponding numpy C/C++ type.
PString wrapper_getClassName(const PClassConfig &classConfig)
Get the corresponding wrapper class name.