Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 : #ifndef INCLUDED_IDLC_INC_IDLC_IDLC_HXX
20 : #define INCLUDED_IDLC_INC_IDLC_IDLC_HXX
21 :
22 : #include <idlc/idlctypes.hxx>
23 : #include <idlc/aststack.hxx>
24 : #include <idlc/options.hxx>
25 :
26 : #ifdef SAL_UNX
27 : #define SEPARATOR '/'
28 : #define PATH_SEPARATOR "/"
29 : #else
30 : #define SEPARATOR '\\'
31 : #define PATH_SEPARATOR "\\"
32 : #endif
33 :
34 : class AstInterface;
35 : class AstModule;
36 : class AstType;
37 : class Options;
38 : class ErrorHandler;
39 :
40 : class Idlc
41 : {
42 : public:
43 : Idlc(Options* pOptions);
44 : virtual ~Idlc();
45 :
46 : void init();
47 :
48 : bool dumpDeps(OString const& rDepFile,
49 : OString const& rTarget);
50 :
51 1600 : Options* getOptions()
52 1600 : { return m_pOptions; }
53 9704 : AstStack* scopes()
54 9704 : { return m_pScopes; }
55 288 : AstModule* getRoot()
56 288 : { return m_pRoot; }
57 1494 : ErrorHandler* error()
58 1494 : { return m_pErrorHandler; }
59 31004 : const OString& getFileName()
60 31004 : { return m_fileName; }
61 1316 : void setFileName(const OString& fileName)
62 1316 : { m_fileName = fileName; addInclude(fileName); }
63 30018 : const OString& getMainFileName()
64 30018 : { return m_mainFileName; }
65 658 : void setMainFileName(const OString& mainFileName)
66 658 : { m_mainFileName = mainFileName; }
67 30676 : const OString& getRealFileName()
68 30676 : { return m_realFileName; }
69 658 : void setRealFileName(const OString& realFileName)
70 658 : { m_realFileName = realFileName; }
71 202 : const OString& getDocumentation()
72 : {
73 202 : m_bIsDocValid = false;
74 202 : return m_documentation;
75 : }
76 0 : void setDocumentation(const OString& documentation)
77 : {
78 0 : m_documentation = documentation;
79 0 : m_bIsDocValid = true;
80 0 : }
81 : OUString processDocumentation();
82 214 : bool isInMainFile()
83 214 : { return m_bIsInMainfile; }
84 658 : void setInMainfile(bool bInMainfile)
85 658 : { m_bIsInMainfile = bInMainfile; }
86 658 : sal_uInt32 getErrorCount()
87 658 : { return m_errorCount; }
88 : void setErrorCount(sal_uInt32 errorCount)
89 : { m_errorCount = errorCount; }
90 478 : void incErrorCount()
91 478 : { m_errorCount++; }
92 658 : sal_uInt32 getWarningCount()
93 658 : { return m_warningCount; }
94 : void setWarningCount(sal_uInt32 warningCount)
95 : { m_warningCount = warningCount; }
96 0 : void incWarningCount()
97 0 : { m_warningCount++; }
98 806 : sal_uInt32 getLineNumber()
99 806 : { return m_lineNumber; }
100 478 : sal_uInt32 getOffsetStart()
101 478 : { return m_offsetStart; }
102 478 : sal_uInt32 getOffsetEnd()
103 478 : { return m_offsetEnd; }
104 27540 : void setOffset( sal_uInt32 start, sal_uInt32 end)
105 27540 : { m_offsetStart = start; m_offsetEnd = end; }
106 658 : void setLineNumber(sal_uInt32 lineNumber)
107 658 : { m_lineNumber = lineNumber; }
108 4142 : void incLineNumber()
109 4142 : { m_lineNumber++; }
110 136 : ParseState getParseState()
111 136 : { return m_parseState; }
112 17228 : void setParseState(ParseState parseState)
113 17228 : { m_parseState = parseState; }
114 :
115 1316 : void addInclude(const OString& inc)
116 1316 : { m_includes.insert(inc); }
117 : StringSet& getIncludes()
118 : { return m_includes; }
119 :
120 1510 : void setPublished(bool published) { m_published = published; }
121 30628 : bool isPublished() const { return m_published; }
122 :
123 : void reset();
124 : private:
125 : Options* m_pOptions;
126 : AstStack* m_pScopes;
127 : AstModule* m_pRoot;
128 : ErrorHandler* m_pErrorHandler;
129 : OString m_fileName;
130 : OString m_mainFileName;
131 : OString m_realFileName;
132 : OString m_documentation;
133 : bool m_bIsDocValid;
134 : bool m_bGenerateDoc;
135 : bool m_bIsInMainfile;
136 : bool m_published;
137 : sal_uInt32 m_errorCount;
138 : sal_uInt32 m_warningCount;
139 : sal_uInt32 m_lineNumber;
140 : sal_uInt32 m_offsetStart;
141 : sal_uInt32 m_offsetEnd;
142 : ParseState m_parseState;
143 : StringSet m_includes;
144 : };
145 :
146 :
147 : typedef ::std::pair< OString, OString > sPair_t;
148 : sal_Int32 compileFile(const OString * pathname);
149 : // a null pathname means stdin
150 : sal_Int32 produceFile(const OString& filenameBase,
151 : sPair_t const*const pDepFile);
152 : // filenameBase is filename without ".idl"
153 : void removeIfExists(const OString& pathname);
154 :
155 : OString makeTempName(const OString& prefix, const OString& postfix);
156 : bool copyFile(const OString* source, const OString& target);
157 : // a null source means stdin
158 :
159 : bool isFileUrl(const OString& fileName);
160 : OString convertToAbsoluteSystemPath(const OString& fileName);
161 : OString convertToFileUrl(const OString& fileName);
162 :
163 : Idlc* SAL_CALL idlc();
164 : Idlc* SAL_CALL setIdlc(Options* pOptions);
165 :
166 : AstDeclaration const * resolveTypedefs(AstDeclaration const * type);
167 :
168 : AstDeclaration const * deconstructAndResolveTypedefs(
169 : AstDeclaration const * type, sal_Int32 * rank);
170 :
171 : AstInterface const * resolveInterfaceTypedefs(AstType const * type);
172 :
173 : #endif // INCLUDED_IDLC_INC_IDLC_IDLC_HXX
174 :
175 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|