Logo ROOT  
Reference Guide
TModuleGenerator.h
Go to the documentation of this file.
1// @(#)root/utils:$Id$
2// Author: Axel Naumann, 2-13-07-02
3
4/*************************************************************************
5 * Copyright (C) 1995-2013, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11
12////////////////////////////////////////////////////////////////////////////////
13//
14// PCM writer.
15//
16////////////////////////////////////////////////////////////////////////////////
17
18#ifndef ROOT_TModuleGenerator
19#define ROOT_TModuleGenerator
20
21#include <ostream>
22#include <sstream>
23#include <fstream>
24#include <string>
25#include <vector>
26
27namespace clang {
28 class CompilerInstance;
29 class SourceManager;
30}
31
32namespace ROOT {
33
34//______________________________________________________________________________
36 public:
42 };
43
44 TModuleGenerator(clang::CompilerInstance *CI,
45 bool inlineHeader,
46 const std::string &shLibFileName,
47 bool isInPCH);
49
50 // FIXME: remove once PCH is gone.
51 bool IsPCH() const {
52 return fIsPCH;
53 }
54 void ParseArgs(const std::vector<std::string> &args);
55
56 const std::string &GetDictionaryName() const {
57 return fDictionaryName;
58 }
59
60 const std::string &GetDemangledDictionaryName() const {
62 }
63
64 const std::string &GetModuleFileName() const {
65 return fModuleFileName;
66 }
67 const std::string &GetModuleDirName() const {
68 return fModuleDirName;
69 }
70
71 int GetErrorCount() const {
72 return fErrorCount;
73 }
74
75 const std::string &GetUmbrellaName() const {
76 return fUmbrellaName;
77 }
78 const std::string &GetContentName() const {
79 return fContentName;
80 }
81
82 const std::vector<std::string> &GetHeaders() const {
83 return fHeaders;
84 }
85
86 const std::vector<std::string> &GetIncludePaths() const {
87 return fCompI;
88 }
89
90 std::ostream &WritePPDefines(std::ostream &out) const;
91 std::ostream &WritePPUndefines(std::ostream &out) const;
92
93 void WriteRegistrationSource(std::ostream &out, const std::string &fwdDeclnArgsToKeepString,
94 const std::string &headersClassesMapString, const std::string &fwdDeclsString,
95 const std::string &extraIncludes, bool hasCxxModule) const;
96 void WriteContentHeader(std::ostream &out) const;
97 void WriteUmbrellaHeader(std::ostream &out) const;
98
99 private:
100 void WriteRegistrationSourceImpl(std::ostream& out,
101 const std::string &dictName,
102 const std::string &demangledDictName,
103 const std::vector<std::string> &headerArray,
104 const std::vector<std::string> &includePathArray,
105 const std::string &fwdDeclStringRAW,
106 const std::string &fwdDeclnArgsToKeepString,
107 const std::string &payloadCodeWrapped,
108 const std::string &headersClassesMapString,
109 const std::string &extraIncludes,
110 bool hasCxxModule) const;
111
112 void ConvertToCppString(std::string &text) const;
113
114 std::ostream &WritePPIncludes(std::ostream &out) const;
115
116 std::ostream &WritePPCode(std::ostream &out) const {
117 // Write defines, undefiles, includes, corrsponding to a rootcling
118 // invocation with -c -DFOO -UBAR header.h.
119 WritePPDefines(out);
120 WritePPUndefines(out);
121 return WritePPIncludes(out);
122 }
123
124 std::ostream &WriteHeaderArray(std::ostream &out) const {
125 // Write "header1.h",\n"header2.h",\n0\n
126 return WriteStringVec(fHeaders, out);
127 }
128 std::ostream &WriteIncludePathArray(std::ostream &out) const {
129 // Write "./include",\n"/usr/include",\n0\n
130 return WriteStringVec(fCompI, out);
131 }
132 std::ostream &WriteDefinesArray(std::ostream &out) const {
133 // Write "DEFINED",\n"NAME=\"VALUE\"",\n0\n
134 return WriteStringPairVec(fCompD, out);
135 }
136 std::ostream &WriteUndefinesArray(std::ostream &out) const {
137 // Write "UNDEFINED",\n"NAME",\n0\n
138 return WriteStringVec(fCompU, out);
139 }
140
141 bool FindHeader(const std::string& hdrName, std::string& hdrFullPath) const;
142
143 typedef std::vector<std::pair<std::string, std::string> > StringPairVec_t;
144
145 ESourceFileKind GetSourceFileKind(const char *filename) const;
146 std::ostream &WriteStringVec(const std::vector<std::string> &vec,
147 std::ostream &out) const;
148 std::ostream &WriteStringPairVec(const StringPairVec_t &vecP,
149 std::ostream &out) const;
150
151 clang::CompilerInstance *fCI;
152 bool fIsPCH;
153 bool fIsInPCH; // whether the headers of this module are part of the PCH.
155
156 std::string fDictionaryName; // Name of the dictionary, e.g. "Base"
157 std::string fDemangledDictionaryName; // Demangled name of the dictionary
158 std::string fModuleFileName; // PCM file name
159 std::string fModuleDirName; // PCM output directory
160 std::string fUmbrellaName; // name of umbrella header in PCM
161 std::string fContentName; // name of content description header in PCM
162
163 std::vector<std::string> fHeaders; // exported headers in PCM
164 std::string fLinkDefFile; // The name of the linkdef file
165 std::vector<std::string> fCompI; // -I; needed only for ACLiC without PCMs
166
167 StringPairVec_t fCompD; // -Dfirst=second
168 std::vector<std::string> fCompU; // -Ufirst
169 mutable int fErrorCount;
170 };
171
172} // namespace ROOT
173
174#endif // ROOT_TModuleGenerator
std::vector< std::string > fCompU
void WriteUmbrellaHeader(std::ostream &out) const
Write a header file pulling in the content of this module through a series of #defined,...
std::ostream & WriteHeaderArray(std::ostream &out) const
std::vector< std::pair< std::string, std::string > > StringPairVec_t
std::ostream & WriteStringVec(const std::vector< std::string > &vec, std::ostream &out) const
std::ostream & WriteStringPairVec(const StringPairVec_t &vecP, std::ostream &out) const
const std::string & GetUmbrellaName() const
const std::vector< std::string > & GetIncludePaths() const
void WriteRegistrationSource(std::ostream &out, const std::string &fwdDeclnArgsToKeepString, const std::string &headersClassesMapString, const std::string &fwdDeclsString, const std::string &extraIncludes, bool hasCxxModule) const
ESourceFileKind GetSourceFileKind(const char *filename) const
Check whether the file's extension is compatible with C or C++.
std::ostream & WritePPIncludes(std::ostream &out) const
Write #include "header1.h" #include "header2.h" or, if inlining of headers is requested,...
TModuleGenerator(clang::CompilerInstance *CI, bool inlineHeader, const std::string &shLibFileName, bool isInPCH)
void ConvertToCppString(std::string &text) const
std::ostream & WriteIncludePathArray(std::ostream &out) const
const std::vector< std::string > & GetHeaders() const
void WriteContentHeader(std::ostream &out) const
Write a header file describing the content of this module through a series of variables inside the na...
std::vector< std::string > fCompI
std::vector< std::string > fHeaders
const std::string & GetModuleFileName() const
std::ostream & WritePPUndefines(std::ostream &out) const
Write #ifdef FOO.
void WriteRegistrationSourceImpl(std::ostream &out, const std::string &dictName, const std::string &demangledDictName, const std::vector< std::string > &headerArray, const std::vector< std::string > &includePathArray, const std::string &fwdDeclStringRAW, const std::string &fwdDeclnArgsToKeepString, const std::string &payloadCodeWrapped, const std::string &headersClassesMapString, const std::string &extraIncludes, bool hasCxxModule) const
std::ostream & WritePPCode(std::ostream &out) const
const std::string & GetDictionaryName() const
std::string fDemangledDictionaryName
clang::CompilerInstance * fCI
std::ostream & WriteDefinesArray(std::ostream &out) const
bool FindHeader(const std::string &hdrName, std::string &hdrFullPath) const
Return true if the header is found in the include paths in this case also fill the full path variable...
std::ostream & WriteUndefinesArray(std::ostream &out) const
const std::string & GetDemangledDictionaryName() const
void ParseArgs(const std::vector< std::string > &args)
Parse -I -D -U headers.h SomethingLinkdef.h.
const std::string & GetContentName() const
const std::string & GetModuleDirName() const
std::ostream & WritePPDefines(std::ostream &out) const
Write #ifndef FOO.
TText * text
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...
Definition: StringConv.hxx:21