GCC Code Coverage Report


Directory: ./
File: src/TraitBackEnd/PythonWrapper/WrapperTraitTypeStream/WrapperTraitTypeStream.cpp
Date: 2025-12-15 11:32:44
Exec Total Coverage
Lines: 42 47 89.4%
Functions: 11 12 91.7%
Branches: 48 63 76.2%

Line Branch Exec Source
1
2 /***************************************
3 Auteur : Pierre Aubert
4 Mail : pierre.aubert@lapp.in2p3.fr
5 Licence : CeCILL-C
6 ****************************************/
7
8 #include "WrapperTraitTypeStream.h"
9
10 ///Consctructor of WrapperTraitTypeStream
11 2 WrapperTraitTypeStream::WrapperTraitTypeStream()
12 2 :PAbstractWrapperTraitBackend()
13 2 {}
14
15 ///Desctructor of WrapperTraitTypeStream
16 4 WrapperTraitTypeStream::~WrapperTraitTypeStream(){}
17
18 ///Add extra include on the header
19 /** @param[out] fs : file to be completed
20 * @param mode : mode of the generator
21 */
22 3 void WrapperTraitTypeStream::headerExtraInclude(std::ofstream & fs, const GeneratorMode & mode) const{
23
1/2
✗ Branch 0 (2→3) not taken.
✓ Branch 1 (2→4) taken 3 times.
3 if(!mode.enableTypeStream){return;}
24 3 fs << "#include \"phoenix_type_stream.h\"" << std::endl;
25 }
26
27 ///Declaration of class method
28 /** @param[out] fs : file to be completed
29 * @param classConfig : PClassConfig to be used
30 * @param mode : mode of the generator
31 */
32 3 void WrapperTraitTypeStream::classMethodDeclaration(std::ofstream & fs, const PClassConfig & classConfig, const GeneratorMode & mode) const{
33
1/2
✗ Branch 0 (2→3) not taken.
✓ Branch 1 (2→4) taken 3 times.
3 if(!mode.enableTypeStream){return;}
34
1/1
✓ Branch 0 (4→5) taken 3 times.
3 PString className(wrapper_getClassName(classConfig));
35
3/3
✓ Branch 0 (5→6) taken 3 times.
✓ Branch 2 (6→7) taken 3 times.
✓ Branch 4 (7→8) taken 3 times.
3 fs << "PyObject * "+className+"_getTypeName(PyObject *self, PyObject *args);\n\n";
36 3 }
37
38 ///Implementation of class method
39 /** @param[out] fs : file to be completed
40 * @param classConfig : PClassConfig to be used
41 * @param mode : mode of the generator
42 */
43 3 void WrapperTraitTypeStream::classMethodImplementation(std::ofstream & fs, const PClassConfig & classConfig, const GeneratorMode & mode) const{
44
1/2
✗ Branch 0 (2→3) not taken.
✓ Branch 1 (2→4) taken 3 times.
3 if(!mode.enableTypeStream){return;}
45
1/1
✓ Branch 0 (4→5) taken 3 times.
3 PString className(wrapper_getClassName(classConfig));
46
3/3
✓ Branch 0 (5→6) taken 3 times.
✓ Branch 2 (6→7) taken 3 times.
✓ Branch 4 (7→8) taken 3 times.
3 fs << "///Get the type name of "<<className<<" for TypeStream compatibility\n";
47
3/3
✓ Branch 0 (8→9) taken 3 times.
✓ Branch 2 (9→10) taken 3 times.
✓ Branch 4 (10→11) taken 3 times.
3 fs << "/**\t@return type name of "<<className<<"\n";
48
1/1
✓ Branch 0 (11→12) taken 3 times.
3 fs << "*/\n";
49
3/3
✓ Branch 0 (12→13) taken 3 times.
✓ Branch 2 (13→14) taken 3 times.
✓ Branch 4 (14→15) taken 3 times.
3 fs << "PyObject * "<<className<<"_getTypeName(PyObject *self, PyObject *args){\n";
50
4/4
✓ Branch 0 (15→16) taken 3 times.
✓ Branch 2 (16→17) taken 3 times.
✓ Branch 4 (17→18) taken 3 times.
✓ Branch 6 (18→19) taken 3 times.
3 fs << "\tstd::string name(\""<<classConfig.getName()<<"\");\n";
51
1/1
✓ Branch 0 (19→20) taken 3 times.
3 fs << "\treturn Py_BuildValue(\"s\", name.c_str());\n";
52
1/1
✓ Branch 0 (20→21) taken 3 times.
3 fs << "}\n\n";
53 3 }
54
55 ///Register class member
56 /** @param[out] fs : file to be completed
57 * @param classConfig : PClassConfig to be used
58 * @param mode : mode of the generator
59 */
60 3 void WrapperTraitTypeStream::registerClassMember(std::ofstream & fs, const PClassConfig & classConfig, const GeneratorMode & mode) const{
61
1/2
✗ Branch 0 (2→3) not taken.
✓ Branch 1 (2→4) taken 3 times.
3 if(!mode.enableTypeStream){return;}
62
63 }
64
65 ///Register class getter and setter
66 /** @param[out] fs : file to be completed
67 * @param classConfig : PClassConfig to be used
68 * @param mode : mode of the generator
69 */
70 3 void WrapperTraitTypeStream::registerClassGetterSetter(std::ofstream & fs, const PClassConfig & classConfig, const GeneratorMode & mode) const{
71
1/2
✗ Branch 0 (2→3) not taken.
✓ Branch 1 (2→4) taken 3 times.
3 if(!mode.enableTypeStream){return;}
72
73 }
74
75 ///Register class method
76 /** @param[out] fs : file to be completed
77 * @param classConfig : PClassConfig to be used
78 * @param mode : mode of the generator
79 */
80 3 void WrapperTraitTypeStream::registerClassMethod(std::ofstream & fs, const PClassConfig & classConfig, const GeneratorMode & mode) const{
81
1/2
✗ Branch 0 (2→3) not taken.
✓ Branch 1 (2→4) taken 3 times.
3 if(!mode.enableTypeStream){return;}
82
1/1
✓ Branch 0 (4→5) taken 3 times.
3 PString className(wrapper_getClassName(classConfig));
83
5/5
✓ Branch 0 (5→6) taken 3 times.
✓ Branch 2 (6→7) taken 3 times.
✓ Branch 4 (7→8) taken 3 times.
✓ Branch 6 (8→9) taken 3 times.
✓ Branch 8 (9→10) taken 3 times.
3 fs << "\t{\"getTypeName\", (PyCFunction)"<<className<<"_getTypeName, METH_NOARGS | METH_STATIC, \"Doc : Get the type name of "<<className<<" for TypeStream compatibility\"},\n";
84 3 }
85
86 ///Implementation of test function
87 /** @param[out] fs : file to be completed
88 * @param classConfig : PClassConfig to be used
89 * @param mode : mode of the generator
90 */
91 5 void WrapperTraitTypeStream::testFunction(std::ofstream & fs, const PClassConfig & classConfig, const GeneratorMode & mode) const{
92
1/2
✗ Branch 0 (2→3) not taken.
✓ Branch 1 (2→4) taken 5 times.
5 if(!mode.enableTypeStream){return;}
93
2/2
✓ Branch 0 (4→5) taken 5 times.
✓ Branch 2 (5→6) taken 5 times.
5 PString className(classConfig.getName());
94
3/3
✓ Branch 0 (6→7) taken 5 times.
✓ Branch 2 (7→8) taken 5 times.
✓ Branch 4 (8→9) taken 5 times.
5 fs << "#Unit Test for TypeStream of the " + className + "\n";
95
3/3
✓ Branch 0 (11→12) taken 5 times.
✓ Branch 2 (12→13) taken 5 times.
✓ Branch 4 (13→14) taken 5 times.
5 fs << "def test_typestream_"+className+"():\n";
96
5/5
✓ Branch 0 (16→17) taken 5 times.
✓ Branch 2 (17→18) taken 5 times.
✓ Branch 4 (18→19) taken 5 times.
✓ Branch 6 (19→20) taken 5 times.
✓ Branch 8 (20→21) taken 5 times.
5 fs << "\tassert "+className+".getTypeName() == \"" + className + "\"\n\n\n";
97 5 }
98
99 ///Call of the test function
100 /** @param[out] fs : file to be completed
101 * @param classConfig : PClassConfig to be used
102 * @param mode : mode of the generator
103 */
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
110 ///Add dependency in the setup.py
111 /** @param[out] fs : file to be completed
112 * @param mode : mode of the generator
113 */
114 2 void WrapperTraitTypeStream::setupAddDependency(std::ofstream & fs, const GeneratorMode & mode) const{
115
1/2
✗ Branch 0 (2→3) not taken.
✓ Branch 1 (2→4) taken 2 times.
2 if(!mode.enableTypeStream){return;}
116 2 fs << "addWrapperDependency(listIncludeDir, listLibDir, listLib, \"phoenixtypestream-config\", [\"phoenix_type_stream\"])" << std::endl;
117 }
118
119
120
121