Reflection for RapidJSON
0.0.17
Reflection for serializing/deserializing with RapidJSON
Toggle main menu visibility
Loading...
Searching...
No Matches
codegenerator.cpp
Go to the documentation of this file.
1
#include "
./codegenerator.h
"
2
#include "
./codefactory.h
"
3
4
#include <c++utilities/application/global.h>
5
6
#include <clang/AST/DeclCXX.h>
7
#include <clang/Frontend/CompilerInstance.h>
8
9
using namespace
std;
10
11
namespace
ReflectiveRapidJSON
{
12
13
CodeGenerator::~CodeGenerator
()
14
{
15
}
16
20
void
CodeGenerator::addDeclaration
(clang::Decl *decl)
21
{
22
CPP_UTILITIES_UNUSED(decl)
23
}
24
29
void
CodeGenerator::lazyInitializeSourceManager
()
const
30
{
31
if
(
factory
().compilerInstance()) {
32
m_sourceManager = &
factory
().
compilerInstance
()->getSourceManager();
33
}
34
}
35
39
bool
CodeGenerator::isOnlyIncluded
(
const
clang::Decl *declaration)
const
40
{
41
return
m_sourceManager
42
&& m_sourceManager->getFileID(m_sourceManager->getExpansionLoc(declaration->getSourceRange().getBegin())) != m_sourceManager->getMainFileID();
43
}
44
50
clang::CXXBaseSpecifier *
CodeGenerator::inheritsFromInstantiationOf
(clang::CXXRecordDecl *
const
record,
const
char
*
const
templateClass)
51
{
52
for
(clang::CXXBaseSpecifier &base : record->bases()) {
53
clang::CXXRecordDecl *
const
baseDecl = base.getType()->getAsCXXRecordDecl();
54
if
(baseDecl && baseDecl->getQualifiedNameAsString() == templateClass) {
55
return
&base;
56
}
57
}
58
return
nullptr
;
59
}
60
61
}
// namespace ReflectiveRapidJSON
ReflectiveRapidJSON::CodeFactory::compilerInstance
clang::CompilerInstance * compilerInstance()
Returns the compiler instance.
Definition
codefactory.h:121
ReflectiveRapidJSON::CodeGenerator::inheritsFromInstantiationOf
static clang::CXXBaseSpecifier * inheritsFromInstantiationOf(clang::CXXRecordDecl *record, const char *templateClass)
Returns whether the specified record inherits from an instantiation of the specified templateClass.
Definition
codegenerator.cpp:50
ReflectiveRapidJSON::CodeGenerator::lazyInitializeSourceManager
void lazyInitializeSourceManager() const
Lazy initializes the source manager.
Definition
codegenerator.cpp:29
ReflectiveRapidJSON::CodeGenerator::addDeclaration
virtual void addDeclaration(clang::Decl *decl)
Adds the specified decl to the code generator.
Definition
codegenerator.cpp:20
ReflectiveRapidJSON::CodeGenerator::isOnlyIncluded
bool isOnlyIncluded(const clang::Decl *declaration) const
Returns whether the specified declaration is only included and not part of the actual file.
Definition
codegenerator.cpp:39
ReflectiveRapidJSON::CodeGenerator::factory
CodeFactory & factory() const
Definition
codegenerator.h:49
ReflectiveRapidJSON::CodeGenerator::~CodeGenerator
virtual ~CodeGenerator()
Definition
codegenerator.cpp:13
codefactory.h
codegenerator.h
ReflectiveRapidJSON
Definition
codegenerator.h:15
Generated on
for Reflection for RapidJSON by
1.18.0