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 _IDLC_IDLC_HXX_
20 : #define _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 800 : Options* getOptions()
52 800 : { return m_pOptions; }
53 4852 : AstStack* scopes()
54 4852 : { return m_pScopes; }
55 144 : AstModule* getRoot()
56 144 : { return m_pRoot; }
57 747 : ErrorHandler* error()
58 747 : { return m_pErrorHandler; }
59 15502 : const OString& getFileName()
60 15502 : { return m_fileName; }
61 658 : void setFileName(const OString& fileName)
62 658 : { m_fileName = fileName; addInclude(fileName); }
63 15009 : const OString& getMainFileName()
64 15009 : { return m_mainFileName; }
65 329 : void setMainFileName(const OString& mainFileName)
66 329 : { m_mainFileName = mainFileName; }
67 15338 : const OString& getRealFileName()
68 15338 : { return m_realFileName; }
69 329 : void setRealFileName(const OString& realFileName)
70 329 : { m_realFileName = realFileName; }
71 101 : const OString& getDocumentation()
72 : {
73 101 : m_bIsDocValid = false;
74 101 : 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 107 : bool isInMainFile()
83 107 : { return m_bIsInMainfile; }
84 329 : void setInMainfile(bool bInMainfile)
85 329 : { m_bIsInMainfile = bInMainfile; }
86 329 : sal_uInt32 getErrorCount()
87 329 : { return m_errorCount; }
88 : void setErrorCount(sal_uInt32 errorCount)
89 : { m_errorCount = errorCount; }
90 239 : void incErrorCount()
91 239 : { m_errorCount++; }
92 329 : sal_uInt32 getWarningCount()
93 329 : { return m_warningCount; }
94 : void setWarningCount(sal_uInt32 warningCount)
95 : { m_warningCount = warningCount; }
96 0 : void incWarningCount()
97 0 : { m_warningCount++; }
98 403 : sal_uInt32 getLineNumber()
99 403 : { return m_lineNumber; }
100 239 : sal_uInt32 getOffsetStart()
101 239 : { return m_offsetStart; }
102 239 : sal_uInt32 getOffsetEnd()
103 239 : { return m_offsetEnd; }
104 13770 : void setOffset( sal_uInt32 start, sal_uInt32 end)
105 13770 : { m_offsetStart = start; m_offsetEnd = end; }
106 329 : void setLineNumber(sal_uInt32 lineNumber)
107 329 : { m_lineNumber = lineNumber; }
108 2071 : void incLineNumber()
109 2071 : { m_lineNumber++; }
110 68 : ParseState getParseState()
111 68 : { return m_parseState; }
112 8614 : void setParseState(ParseState parseState)
113 8614 : { m_parseState = parseState; }
114 :
115 658 : void addInclude(const OString& inc)
116 658 : { m_includes.insert(inc); }
117 : StringSet* getIncludes()
118 : { return &m_includes; }
119 :
120 755 : void setPublished(bool published) { m_published = published; }
121 15314 : 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 // _IDLC_IDLC_HXX_
174 :
175 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|