PhoenixGenerator  2.8.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 if(classConfig.getIsEnum()){
22 name = name + "::" + name;
23 }
24 fs << std::endl << std::endl << "\t\t///Get the name of the class " << name;
25 fs << std::endl << "\t\t.def_static(\"phoenix_get_type_name\", []() {";
26 fs << std::endl << "\t\t\treturn phoenix_getTypeName<" << name << ">();}, ";
27 fs << std::endl << "\t\t\t\"Return the type name of " << name << "\")";
28}
29
31void NanobindTraitTypeStream::testFunction(std::ofstream & fs, const PClassConfig & classConfig, const GeneratorMode & mode, const PString & baseFileName) const{
32 if(!mode.enableTypeStream){return;}
33 PString name(classConfig.getName());
34 PString moduleName = baseFileName.toLower();
35 fs << "#Test Phoenix type name retrieval for " << name << std::endl;
36 fs << "def test_phoenix_type_name():" << std::endl;
37 fs << "\t\"\"\"Test Phoenix type name retrieval\"\"\"" << std::endl;
38 fs << "\ttype_name = " << moduleName << "." << name << ".phoenix_get_type_name()" << std::endl;
39 if(classConfig.getIsEnum()){
40 name = name + "::" + name;
41 }
42 fs << "\tassert type_name == \"" << name << "\"" << std::endl << std::endl;
43}
44
46void NanobindTraitTypeStream::testCallFunction(std::ofstream & fs, const PClassConfig & classConfig, const GeneratorMode & mode) const{
47 if(!mode.enableTypeStream){return;}
48 fs << "\ttest_phoenix_type_name()" << std::endl;
49}
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.
bool getIsEnum() const
Say if the current PClassConfig is an enum.
All the genertor modes.
bool enableTypeStream
True to enable type stream interface generator.