Branch data 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(::rtl::OString const& rDepFile,
49 : : ::rtl::OString const& rTarget);
50 : :
51 : 14408 : Options* getOptions()
52 : 14408 : { return m_pOptions; }
53 : 2741429 : AstStack* scopes()
54 : 2741429 : { return m_pScopes; }
55 : 5978 : AstModule* getRoot()
56 : 5978 : { return m_pRoot; }
57 : 188864 : ErrorHandler* error()
58 : 188864 : { return m_pErrorHandler; }
59 : 1819228 : const ::rtl::OString& getFileName()
60 : 1819228 : { return m_fileName; }
61 : 137932 : void setFileName(const ::rtl::OString& fileName)
62 : 137932 : { m_fileName = fileName; addInclude(fileName); }
63 : 174379 : const ::rtl::OString& getMainFileName()
64 : 174379 : { return m_mainFileName; }
65 : 5978 : void setMainFileName(const ::rtl::OString& mainFileName)
66 : 5978 : { m_mainFileName = mainFileName; }
67 : 1021965 : const ::rtl::OString& getRealFileName()
68 : 1021965 : { return m_realFileName; }
69 : 5978 : void setRealFileName(const ::rtl::OString& realFileName)
70 : 5978 : { m_realFileName = realFileName; }
71 : 4087 : const ::rtl::OString& getDocumentation()
72 : : {
73 : 4087 : m_bIsDocValid = sal_False;
74 : 4087 : return m_documentation;
75 : : }
76 : 358049 : void setDocumentation(const ::rtl::OString& documentation)
77 : : {
78 : 358049 : m_documentation = documentation;
79 : 358049 : m_bIsDocValid = sal_True;
80 : 358049 : }
81 : : sal_Bool isDocValid();
82 : 239003 : sal_Bool isInMainFile()
83 : 239003 : { return m_bIsInMainfile; }
84 : 131954 : void setInMainfile(sal_Bool bInMainfile)
85 : 131954 : { m_bIsInMainfile = bInMainfile; }
86 : 5978 : sal_uInt32 getErrorCount()
87 : 5978 : { return m_errorCount; }
88 : : void setErrorCount(sal_uInt32 errorCount)
89 : : { m_errorCount = errorCount; }
90 : 0 : void incErrorCount()
91 : 0 : { m_errorCount++; }
92 : 6054 : sal_uInt32 getWarningCount()
93 : 6054 : { return m_warningCount; }
94 : : void setWarningCount(sal_uInt32 warningCount)
95 : : { m_warningCount = warningCount; }
96 : 762 : void incWarningCount()
97 : 762 : { m_warningCount++; }
98 : 2046037 : sal_uInt32 getLineNumber()
99 : 2046037 : { return m_lineNumber; }
100 : 0 : sal_uInt32 getOffsetStart()
101 : 0 : { return m_offsetStart; }
102 : 0 : sal_uInt32 getOffsetEnd()
103 : 0 : { return m_offsetEnd; }
104 : 16403983 : void setOffset( sal_uInt32 start, sal_uInt32 end)
105 : 16403983 : { m_offsetStart = start; m_offsetEnd = end; }
106 : 2084406 : void setLineNumber(sal_uInt32 lineNumber)
107 : 2084406 : { m_lineNumber = lineNumber; }
108 : 2660142 : void incLineNumber()
109 : 2660142 : { m_lineNumber++; }
110 : 0 : ParseState getParseState()
111 : 0 : { return m_parseState; }
112 : 4704561 : void setParseState(ParseState parseState)
113 : 4704561 : { m_parseState = parseState; }
114 : :
115 : 137932 : void addInclude(const ::rtl::OString& inc)
116 : 137932 : { m_includes.insert(inc); }
117 : : StringSet* getIncludes()
118 : : { return &m_includes; }
119 : :
120 : 357545 : void setPublished(bool published) { m_published = published; }
121 : 1072136 : 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 : : ::rtl::OString m_fileName;
130 : : ::rtl::OString m_mainFileName;
131 : : ::rtl::OString m_realFileName;
132 : : ::rtl::OString m_documentation;
133 : : sal_Bool m_bIsDocValid;
134 : : sal_Bool m_bGenerateDoc;
135 : : sal_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< ::rtl::OString, ::rtl::OString > sPair_t;
148 : : sal_Int32 compileFile(const ::rtl::OString * pathname);
149 : : // a null pathname means stdin
150 : : sal_Int32 produceFile(const ::rtl::OString& filenameBase,
151 : : sPair_t const*const pDepFile);
152 : : // filenameBase is filename without ".idl"
153 : : void removeIfExists(const ::rtl::OString& pathname);
154 : :
155 : : ::rtl::OString makeTempName(const ::rtl::OString& prefix, const ::rtl::OString& postfix);
156 : : sal_Bool copyFile(const ::rtl::OString* source, const ::rtl::OString& target);
157 : : // a null source means stdin
158 : :
159 : : sal_Bool isFileUrl(const ::rtl::OString& fileName);
160 : : ::rtl::OString convertToAbsoluteSystemPath(const ::rtl::OString& fileName);
161 : : ::rtl::OString convertToFileUrl(const ::rtl::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: */
|