PhoenixGenerator  2.2.0
Set of tools to generate code
Loading...
Searching...
No Matches
NanobindTraitTypeStream.cpp
Go to the documentation of this file.
1/***************************************
2 Auteur : Thibaut Oprinsen
3 Mail : thibaut.oprinsen@lapp.in2p3.fr
4 Licence : CeCILL-C
5****************************************/
6
8
13
16
18void NanobindTraitTypeStream::registerStaticMethod(std::ofstream & fs, const PClassConfig & classConfig, const GeneratorMode & mode) const{
19 if(!mode.enableTypeStream){return;}
20 PString name(classConfig.getName());
21
22 fs << std::endl << std::endl << "\t\t///Get the name of the class " << name;
23 fs << std::endl << "\t\t.def_static(\"phoenix_get_type_name\", []() {";
24 fs << std::endl << "\t\t\treturn phoenix_getTypeName<" << name << ">();}, ";
25 fs << std::endl << "\t\t\t\"Return the type name of " << name << "\")";
26}
27
29void NanobindTraitTypeStream::testFunction(std::ofstream & fs, const PClassConfig & classConfig, const GeneratorMode & mode, const PString & baseFileName) const{
30 if(!mode.enableTypeStream){return;}
31 PString name(classConfig.getName());
32 PString moduleName = baseFileName.toLower() + "_module";
33 fs << "#Test Phoenix type name retrieval for " << name << std::endl;
34 fs << "def test_phoenix_type_name():" << std::endl;
35 fs << "\t\"\"\"Test Phoenix type name retrieval\"\"\"" << std::endl;
36 fs << "type_name = " << moduleName << "." << name << ".phoenix_get_type_name()" << std::endl;
37 fs << "assert type_name == \"" << name << "\"" << std::endl << std::endl;
38}
39
41void NanobindTraitTypeStream::testCallFunction(std::ofstream & fs, const PClassConfig & classConfig, const GeneratorMode & mode) const{
42 if(!mode.enableTypeStream){return;}
43 fs << "\ttest_phoenix_type_name()" << std::endl;
44}
virtual void registerStaticMethod(std::ofstream &fs, const PClassConfig &classConfig, const GeneratorMode &mode) const
Registration of static method.
virtual void testFunction(std::ofstream &fs, const PClassConfig &classConfig, const GeneratorMode &mode, const PString &baseFileName) const
Test function for type stream trait.
virtual void testCallFunction(std::ofstream &fs, const PClassConfig &classConfig, const GeneratorMode &mode) const
call the test function for type stream trait
NanobindTraitTypeStream()
Constructor of NanobindTraitTypeStream.
virtual ~NanobindTraitTypeStream()
Destructor of NanobindTraitTypeStream.
Class to describe a basic class.
const PString & getName() const
Returns the class name.
All the genertor modes.
bool enableTypeStream
True to enable type stream interface generator.