PhoenixGenerator
2.8.0
Set of tools to generate code
Toggle main menu visibility
Loading...
Searching...
No Matches
WrapperTraitTypeStream.cpp
Go to the documentation of this file.
1
2
/***************************************
3
Auteur : Pierre Aubert
4
Mail : pierre.aubert@lapp.in2p3.fr
5
Licence : CeCILL-C
6
****************************************/
7
8
#include "
WrapperTraitTypeStream.h
"
9
11
WrapperTraitTypeStream::WrapperTraitTypeStream
()
12
:
PAbstractWrapperTraitBackend
()
13
{}
14
16
WrapperTraitTypeStream::~WrapperTraitTypeStream
(){}
17
19
22
void
WrapperTraitTypeStream::headerExtraInclude
(std::ofstream & fs,
const
GeneratorMode
& mode)
const
{
23
if
(!mode.
enableTypeStream
){
return
;}
24
fs <<
"#include \"phoenix_type_stream.h\""
<< std::endl;
25
}
26
28
32
void
WrapperTraitTypeStream::classMethodDeclaration
(std::ofstream & fs,
const
PClassConfig
& classConfig,
const
GeneratorMode
& mode)
const
{
33
if
(!mode.
enableTypeStream
){
return
;}
34
PString className(
wrapper_getClassName
(classConfig));
35
fs <<
"PyObject * "
+className+
"_getTypeName(PyObject *self, PyObject *args);\n\n"
;
36
}
37
39
43
void
WrapperTraitTypeStream::classMethodImplementation
(std::ofstream & fs,
const
PClassConfig
& classConfig,
const
GeneratorMode
& mode)
const
{
44
if
(!mode.
enableTypeStream
){
return
;}
45
PString className(
wrapper_getClassName
(classConfig));
46
fs <<
"///Get the type name of "
<<className<<
" for TypeStream compatibility\n"
;
47
fs <<
"/**\t@return type name of "
<<className<<
"\n"
;
48
fs <<
"*/\n"
;
49
fs <<
"PyObject * "
<<className<<
"_getTypeName(PyObject *self, PyObject *args){\n"
;
50
fs <<
"\tstd::string name(\""
<<classConfig.
getName
()<<
"\");\n"
;
51
fs <<
"\treturn Py_BuildValue(\"s\", name.c_str());\n"
;
52
fs <<
"}\n\n"
;
53
}
54
56
60
void
WrapperTraitTypeStream::registerClassMember
(std::ofstream & fs,
const
PClassConfig
& classConfig,
const
GeneratorMode
& mode)
const
{
61
if
(!mode.
enableTypeStream
){
return
;}
62
63
}
64
66
70
void
WrapperTraitTypeStream::registerClassGetterSetter
(std::ofstream & fs,
const
PClassConfig
& classConfig,
const
GeneratorMode
& mode)
const
{
71
if
(!mode.
enableTypeStream
){
return
;}
72
73
}
74
76
80
void
WrapperTraitTypeStream::registerClassMethod
(std::ofstream & fs,
const
PClassConfig
& classConfig,
const
GeneratorMode
& mode)
const
{
81
if
(!mode.
enableTypeStream
){
return
;}
82
PString className(
wrapper_getClassName
(classConfig));
83
fs <<
"\t{\"getTypeName\", (PyCFunction)"
<<className<<
"_getTypeName, METH_NOARGS | METH_STATIC, \"Doc : Get the type name of "
<<className<<
" for TypeStream compatibility\"},\n"
;
84
}
85
87
91
void
WrapperTraitTypeStream::testFunction
(std::ofstream & fs,
const
PClassConfig
& classConfig,
const
GeneratorMode
& mode)
const
{
92
if
(!mode.
enableTypeStream
){
return
;}
93
PString className(classConfig.
getName
());
94
fs <<
"#Unit Test for TypeStream of the "
+ className +
"\n"
;
95
fs <<
"def test_typestream_"
+className+
"():\n"
;
96
fs <<
"\tassert "
+className+
".getTypeName() == \""
+ className +
"\"\n\n\n"
;
97
}
98
100
104
void
WrapperTraitTypeStream::testCallFunction
(std::ofstream & fs,
const
PClassConfig
& classConfig,
const
GeneratorMode
& mode)
const
{
105
if
(!mode.
enableTypeStream
){
return
;}
106
PString className(classConfig.
getName
());
107
fs <<
"\ttest_typestream_"
+className+
"():\n"
;
108
}
109
111
114
void
WrapperTraitTypeStream::setupAddDependency
(std::ofstream & fs,
const
GeneratorMode
& mode)
const
{
115
if
(!mode.
enableTypeStream
){
return
;}
116
fs <<
"addWrapperDependency(listIncludeDir, listLibDir, listLib, \"phoenixtypestream-config\", [\"phoenix_type_stream\"])"
<< std::endl;
117
}
118
119
120
WrapperTraitTypeStream.h
PAbstractWrapperTraitBackend::PAbstractWrapperTraitBackend
PAbstractWrapperTraitBackend()
Definition
PAbstractTraitBackend.h:45
PClassConfig
Class to describe a basic class.
Definition
PClassConfig.h:14
PClassConfig::getName
const PString & getName() const
Returns the class name.
Definition
PClassConfig.cpp:129
WrapperTraitTypeStream::headerExtraInclude
virtual void headerExtraInclude(std::ofstream &fs, const GeneratorMode &mode) const
Add extra include on the header.
Definition
WrapperTraitTypeStream.cpp:22
WrapperTraitTypeStream::registerClassMethod
virtual void registerClassMethod(std::ofstream &fs, const PClassConfig &classConfig, const GeneratorMode &mode) const
Register class method.
Definition
WrapperTraitTypeStream.cpp:80
WrapperTraitTypeStream::classMethodImplementation
virtual void classMethodImplementation(std::ofstream &fs, const PClassConfig &classConfig, const GeneratorMode &mode) const
Implementation of class method.
Definition
WrapperTraitTypeStream.cpp:43
WrapperTraitTypeStream::testFunction
virtual void testFunction(std::ofstream &fs, const PClassConfig &classConfig, const GeneratorMode &mode) const
Implementation of test function.
Definition
WrapperTraitTypeStream.cpp:91
WrapperTraitTypeStream::setupAddDependency
virtual void setupAddDependency(std::ofstream &fs, const GeneratorMode &mode) const
Add dependency in the setup.py.
Definition
WrapperTraitTypeStream.cpp:114
WrapperTraitTypeStream::testCallFunction
virtual void testCallFunction(std::ofstream &fs, const PClassConfig &classConfig, const GeneratorMode &mode) const
Call of the test function.
Definition
WrapperTraitTypeStream.cpp:104
WrapperTraitTypeStream::classMethodDeclaration
virtual void classMethodDeclaration(std::ofstream &fs, const PClassConfig &classConfig, const GeneratorMode &mode) const
Declaration of class method.
Definition
WrapperTraitTypeStream.cpp:32
WrapperTraitTypeStream::registerClassGetterSetter
virtual void registerClassGetterSetter(std::ofstream &fs, const PClassConfig &classConfig, const GeneratorMode &mode) const
Register class getter and setter.
Definition
WrapperTraitTypeStream.cpp:70
WrapperTraitTypeStream::~WrapperTraitTypeStream
virtual ~WrapperTraitTypeStream()
Desctructor of WrapperTraitTypeStream.
Definition
WrapperTraitTypeStream.cpp:16
WrapperTraitTypeStream::WrapperTraitTypeStream
WrapperTraitTypeStream()
Consctructor of WrapperTraitTypeStream.
Definition
WrapperTraitTypeStream.cpp:11
WrapperTraitTypeStream::registerClassMember
virtual void registerClassMember(std::ofstream &fs, const PClassConfig &classConfig, const GeneratorMode &mode) const
Register class member.
Definition
WrapperTraitTypeStream.cpp:60
GeneratorMode
All the genertor modes.
Definition
GeneratorMode.h:27
GeneratorMode::enableTypeStream
bool enableTypeStream
True to enable type stream interface generator.
Definition
GeneratorMode.h:31
wrapper_getClassName
PString wrapper_getClassName(const PClassConfig &classConfig)
Get the corresponding wrapper class name.
Definition
wrapper_utils.cpp:70
src
TraitBackEnd
PythonWrapper
WrapperTraitTypeStream
WrapperTraitTypeStream.cpp
Generated by
1.17.0