PhoenixGenerator
2.8.0
Set of tools to generate code
Toggle main menu visibility
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
7
#include "
NanobindTraitTypeStream.h
"
8
10
NanobindTraitTypeStream::NanobindTraitTypeStream
()
11
:
PAbstractNanobindTraitBackend
()
12
{}
13
15
NanobindTraitTypeStream::~NanobindTraitTypeStream
(){}
16
18
void
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
31
void
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
46
void
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
}
NanobindTraitTypeStream.h
NanobindTraitTypeStream::registerStaticMethod
virtual void registerStaticMethod(std::ofstream &fs, const PClassConfig &classConfig, const GeneratorMode &mode) const
Registration of static method.
Definition
NanobindTraitTypeStream.cpp:18
NanobindTraitTypeStream::testFunction
virtual void testFunction(std::ofstream &fs, const PClassConfig &classConfig, const GeneratorMode &mode, const PString &baseFileName) const
Test function for type stream trait.
Definition
NanobindTraitTypeStream.cpp:31
NanobindTraitTypeStream::testCallFunction
virtual void testCallFunction(std::ofstream &fs, const PClassConfig &classConfig, const GeneratorMode &mode) const
call the test function for type stream trait
Definition
NanobindTraitTypeStream.cpp:46
NanobindTraitTypeStream::NanobindTraitTypeStream
NanobindTraitTypeStream()
Constructor of NanobindTraitTypeStream.
Definition
NanobindTraitTypeStream.cpp:10
NanobindTraitTypeStream::~NanobindTraitTypeStream
virtual ~NanobindTraitTypeStream()
Destructor of NanobindTraitTypeStream.
Definition
NanobindTraitTypeStream.cpp:15
PAbstractNanobindTraitBackend::PAbstractNanobindTraitBackend
PAbstractNanobindTraitBackend()
Definition
PAbstractTraitBackend.h:67
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
PClassConfig::getIsEnum
bool getIsEnum() const
Say if the current PClassConfig is an enum.
Definition
PClassConfig.cpp:197
GeneratorMode
All the genertor modes.
Definition
GeneratorMode.h:27
GeneratorMode::enableTypeStream
bool enableTypeStream
True to enable type stream interface generator.
Definition
GeneratorMode.h:31
src
TraitBackEnd
Nanobind
NanobindTraitTypeStream
NanobindTraitTypeStream.cpp
Generated by
1.17.0