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 #include <utility>
27 
28 namespace clang {
29  class CompilerInstance;
30  class SourceManager;
31 }
32 
33 namespace ROOT {
34 
35 //______________________________________________________________________________
37  public:
43  };
44 
45  TModuleGenerator(clang::CompilerInstance *CI,
46  bool inlineHeader,
47  const std::string &shLibFileName,
48  bool isInPCH);
50 
51  // FIXME: remove once PCH is gone.
52  bool IsPCH() const {
53  return fIsPCH;
54  }
55  void ParseArgs(const std::vector<std::string> &args);
56 
57  const std::string &GetDictionaryName() const {
58  return fDictionaryName;
59  }
60 
61  const std::string &GetDemangledDictionaryName() const {
63  }
64 
65  const std::string &GetModuleFileName() const {
66  return fModuleFileName;
67  }
68  const std::string &GetModuleDirName() const {
69  return fModuleDirName;
70  }
71 
72  int GetErrorCount() const {
73  return fErrorCount;
74  }
75 
76  const std::string &GetUmbrellaName() const {
77  return fUmbrellaName;
78  }
79  const std::string &GetContentName() const {
80  return fContentName;
81  }
82 
83  const std::vector<std::string> &GetHeaders() const {
84  return fHeaders;
85  }
86 
87  const std::vector<std::string> &GetIncludePaths() const {
88  return fCompI;
89  }
90 
91  std::ostream &WritePPDefines(std::ostream &out) const;
92  std::ostream &WritePPUndefines(std::ostream &out) const;
93 
94  void WriteRegistrationSource(std::ostream &out, const std::string &fwdDeclnArgsToKeepString,
95  const std::string &headersClassesMapString, const std::string &fwdDeclsString,
96  const std::string &extraIncludes, bool hasCxxModule) const;
97  void WriteContentHeader(std::ostream &out) const;
98  void WriteUmbrellaHeader(std::ostream &out) const;
99 
100  private:
101  void WriteRegistrationSourceImpl(std::ostream& out,
102  const std::string &dictName,
103  const std::string &demangledDictName,
104  const std::vector<std::string> &headerArray,
105  const std::vector<std::string> &includePathArray,
106  const std::string &fwdDeclStringRAW,
107  const std::string &fwdDeclnArgsToKeepString,
108  const std::string &payloadCodeWrapped,
109  const std::string &headersClassesMapString,
110  const std::string &extraIncludes,
111  bool hasCxxModule) const;
112 
113  void ConvertToCppString(std::string &text) const;
114 
115  std::ostream &WritePPIncludes(std::ostream &out) const;
116 
117  std::ostream &WritePPCode(std::ostream &out) const {
118  // Write defines, undefiles, includes, corrsponding to a rootcling
119  // invocation with -c -DFOO -UBAR header.h.
120  WritePPDefines(out);
121  WritePPUndefines(out);
122  return WritePPIncludes(out);
123  }
124 
125  std::ostream &WriteHeaderArray(std::ostream &out) const {
126  // Write "header1.h",\n"header2.h",\n0\n
127  return WriteStringVec(fHeaders, out);
128  }
129  std::ostream &WriteIncludePathArray(std::ostream &out) const {
130  // Write "./include",\n"/usr/include",\n0\n
131  return WriteStringVec(fCompI, out);
132  }
133  std::ostream &WriteDefinesArray(std::ostream &out) const {
134  // Write "DEFINED",\n"NAME=\"VALUE\"",\n0\n
135  return WriteStringPairVec(fCompD, out);
136  }
137  std::ostream &WriteUndefinesArray(std::ostream &out) const {
138  // Write "UNDEFINED",\n"NAME",\n0\n
139  return WriteStringVec(fCompU, out);
140  }
141 
142  bool FindHeader(const std::string& hdrName, std::string& hdrFullPath) const;
143 
144  typedef std::vector<std::pair<std::string, std::string> > StringPairVec_t;
145 
146  ESourceFileKind GetSourceFileKind(const char *filename) const;
147  std::ostream &WriteStringVec(const std::vector<std::string> &vec,
148  std::ostream &out) const;
149  std::ostream &WriteStringPairVec(const StringPairVec_t &vecP,
150  std::ostream &out) const;
151 
152  clang::CompilerInstance *fCI;
153  bool fIsPCH;
154  bool fIsInPCH; // whether the headers of this module are part of the PCH.
156 
157  std::string fDictionaryName; // Name of the dictionary, e.g. "Base"
158  std::string fDemangledDictionaryName; // Demangled name of the dictionary
159  std::string fModuleFileName; // PCM file name
160  std::string fModuleDirName; // PCM output directory
161  std::string fUmbrellaName; // name of umbrella header in PCM
162  std::string fContentName; // name of content description header in PCM
163 
164  std::vector<std::string> fHeaders; // exported headers in PCM
165  std::string fLinkDefFile; // The name of the linkdef file
166  std::vector<std::string> fCompI; // -I; needed only for ACLiC without PCMs
167 
168  StringPairVec_t fCompD; // -Dfirst=second
169  std::vector<std::string> fCompU; // -Ufirst
170  mutable int fErrorCount;
171  };
172 
173 } // namespace ROOT
174 
175 #endif // ROOT_TModuleGenerator
ROOT::TModuleGenerator::WriteUmbrellaHeader
void WriteUmbrellaHeader(std::ostream &out) const
Write a header file pulling in the content of this module through a series of #defined,...
Definition: TModuleGenerator.cxx:595
ROOT::TModuleGenerator::ParseArgs
void ParseArgs(const std::vector< std::string > &args)
Parse -I -D -U headers.h SomethingLinkdef.h.
Definition: TModuleGenerator.cxx:173
ROOT::TModuleGenerator::WriteRegistrationSourceImpl
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
Definition: TModuleGenerator.cxx:341
ROOT::TModuleGenerator::GetDemangledDictionaryName
const std::string & GetDemangledDictionaryName() const
Definition: TModuleGenerator.h:61
ROOT::TModuleGenerator::ConvertToCppString
void ConvertToCppString(std::string &text) const
ROOT::TModuleGenerator::WriteContentHeader
void WriteContentHeader(std::ostream &out) const
Write a header file describing the content of this module through a series of variables inside the na...
Definition: TModuleGenerator.cxx:536
ROOT::TModuleGenerator::IsPCH
bool IsPCH() const
Definition: TModuleGenerator.h:52
ROOT::TModuleGenerator::WritePPDefines
std::ostream & WritePPDefines(std::ostream &out) const
Write #ifndef FOO.
Definition: TModuleGenerator.cxx:209
ROOT::TModuleGenerator::WriteIncludePathArray
std::ostream & WriteIncludePathArray(std::ostream &out) const
Definition: TModuleGenerator.h:129
ROOT::TModuleGenerator::kSFKSource
@ kSFKSource
Definition: TModuleGenerator.h:41
ROOT::TModuleGenerator::FindHeader
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...
Definition: TModuleGenerator.cxx:560
ROOT::TModuleGenerator::fModuleDirName
std::string fModuleDirName
Definition: TModuleGenerator.h:160
ROOT::TModuleGenerator::WriteStringPairVec
std::ostream & WriteStringPairVec(const StringPairVec_t &vecP, std::ostream &out) const
Definition: TModuleGenerator.cxx:318
ROOT::TModuleGenerator::WriteRegistrationSource
void WriteRegistrationSource(std::ostream &out, const std::string &fwdDeclnArgsToKeepString, const std::string &headersClassesMapString, const std::string &fwdDeclsString, const std::string &extraIncludes, bool hasCxxModule) const
Definition: TModuleGenerator.cxx:392
ROOT::TModuleGenerator::fDictionaryName
std::string fDictionaryName
Definition: TModuleGenerator.h:157
ROOT::TModuleGenerator::GetSourceFileKind
ESourceFileKind GetSourceFileKind(const char *filename) const
Check whether the file's extension is compatible with C or C++.
Definition: TModuleGenerator.cxx:96
ROOT::TModuleGenerator::GetModuleDirName
const std::string & GetModuleDirName() const
Definition: TModuleGenerator.h:68
ROOT::TModuleGenerator::GetErrorCount
int GetErrorCount() const
Definition: TModuleGenerator.h:72
ROOT::TModuleGenerator::fErrorCount
int fErrorCount
Definition: TModuleGenerator.h:170
ROOT::TModuleGenerator::fCompU
std::vector< std::string > fCompU
Definition: TModuleGenerator.h:169
text
TText * text
Definition: entrylist_figure1.C:10
ROOT::TModuleGenerator::TModuleGenerator
TModuleGenerator(clang::CompilerInstance *CI, bool inlineHeader, const std::string &shLibFileName, bool isInPCH)
Definition: TModuleGenerator.cxx:45
ROOT::TModuleGenerator::StringPairVec_t
std::vector< std::pair< std::string, std::string > > StringPairVec_t
Definition: TModuleGenerator.h:144
ROOT::TModuleGenerator::fUmbrellaName
std::string fUmbrellaName
Definition: TModuleGenerator.h:161
ROOT::TModuleGenerator::fLinkDefFile
std::string fLinkDefFile
Definition: TModuleGenerator.h:165
ROOT::TModuleGenerator::GetUmbrellaName
const std::string & GetUmbrellaName() const
Definition: TModuleGenerator.h:76
ROOT::TModuleGenerator::fDemangledDictionaryName
std::string fDemangledDictionaryName
Definition: TModuleGenerator.h:158
ROOT::TModuleGenerator::WritePPIncludes
std::ostream & WritePPIncludes(std::ostream &out) const
Write #include "header1.h" #include "header2.h" or, if inlining of headers is requested,...
Definition: TModuleGenerator.cxx:281
ROOT::TModuleGenerator::WriteDefinesArray
std::ostream & WriteDefinesArray(std::ostream &out) const
Definition: TModuleGenerator.h:133
ROOT::TModuleGenerator::ESourceFileKind
ESourceFileKind
Definition: TModuleGenerator.h:38
ROOT::TModuleGenerator::GetIncludePaths
const std::vector< std::string > & GetIncludePaths() const
Definition: TModuleGenerator.h:87
ROOT::TModuleGenerator::WriteHeaderArray
std::ostream & WriteHeaderArray(std::ostream &out) const
Definition: TModuleGenerator.h:125
ROOT::TModuleGenerator::kSFKLinkdef
@ kSFKLinkdef
Definition: TModuleGenerator.h:42
ROOT::TModuleGenerator::~TModuleGenerator
~TModuleGenerator()
Definition: TModuleGenerator.cxx:85
ROOT::TModuleGenerator::fIsPCH
bool fIsPCH
Definition: TModuleGenerator.h:153
ROOT::TModuleGenerator
Definition: TModuleGenerator.h:36
ROOT::TModuleGenerator::kSFKNotC
@ kSFKNotC
Definition: TModuleGenerator.h:39
ROOT::TModuleGenerator::GetDictionaryName
const std::string & GetDictionaryName() const
Definition: TModuleGenerator.h:57
ROOT::TModuleGenerator::WriteStringVec
std::ostream & WriteStringVec(const std::vector< std::string > &vec, std::ostream &out) const
Definition: TModuleGenerator.cxx:306
ROOT::TModuleGenerator::WritePPCode
std::ostream & WritePPCode(std::ostream &out) const
Definition: TModuleGenerator.h:117
ROOT::TModuleGenerator::GetHeaders
const std::vector< std::string > & GetHeaders() const
Definition: TModuleGenerator.h:83
clang
Definition: BaseSelectionRule.h:29
ROOT::TModuleGenerator::fCompD
StringPairVec_t fCompD
Definition: TModuleGenerator.h:168
ROOT::TModuleGenerator::WritePPUndefines
std::ostream & WritePPUndefines(std::ostream &out) const
Write #ifdef FOO.
Definition: TModuleGenerator.cxx:231
ROOT::TModuleGenerator::fContentName
std::string fContentName
Definition: TModuleGenerator.h:162
ROOT::TModuleGenerator::GetModuleFileName
const std::string & GetModuleFileName() const
Definition: TModuleGenerator.h:65
ROOT::TModuleGenerator::fIsInPCH
bool fIsInPCH
Definition: TModuleGenerator.h:154
ROOT::TModuleGenerator::fHeaders
std::vector< std::string > fHeaders
Definition: TModuleGenerator.h:164
ROOT::TModuleGenerator::kSFKHeader
@ kSFKHeader
Definition: TModuleGenerator.h:40
ROOT::TModuleGenerator::WriteUndefinesArray
std::ostream & WriteUndefinesArray(std::ostream &out) const
Definition: TModuleGenerator.h:137
ROOT::TModuleGenerator::fModuleFileName
std::string fModuleFileName
Definition: TModuleGenerator.h:159
ROOT
VSD Structures.
Definition: StringConv.hxx:21
ROOT::TModuleGenerator::fCI
clang::CompilerInstance * fCI
Definition: TModuleGenerator.h:152
ROOT::TModuleGenerator::fInlineInputHeaders
bool fInlineInputHeaders
Definition: TModuleGenerator.h:155
ROOT::TModuleGenerator::fCompI
std::vector< std::string > fCompI
Definition: TModuleGenerator.h:166
ROOT::TModuleGenerator::GetContentName
const std::string & GetContentName() const
Definition: TModuleGenerator.h:79