Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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
28namespace clang {
29 class CompilerInstance;
30 class SourceManager;
31}
32
33namespace 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
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char filename
Option_t Option_t TPoint TPoint const char text
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,...
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 # undef FOO #endif
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 # define FOO=bar #endif
This file contains a specialised ROOT message handler to test for diagnostic in unit tests.