1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 #ifndef _IDLC_IDLC_HXX_ 24 #define _IDLC_IDLC_HXX_ 25 26 #include <idlc/idlctypes.hxx> 27 #include <idlc/aststack.hxx> 28 #include <idlc/options.hxx> 29 30 #ifdef SAL_UNX 31 #define SEPARATOR '/' 32 #define PATH_SEPARATOR "/" 33 #else 34 #define SEPARATOR '\\' 35 #define PATH_SEPARATOR "\\" 36 #endif 37 38 class AstInterface; 39 class AstModule; 40 class AstType; 41 class Options; 42 class ErrorHandler; 43 44 class Idlc 45 { 46 public: 47 Idlc(Options* pOptions); 48 virtual ~Idlc(); 49 50 void init(); 51 getOptions()52 Options* getOptions() 53 { return m_pOptions; } scopes()54 AstStack* scopes() 55 { return m_pScopes; } getRoot()56 AstModule* getRoot() 57 { return m_pRoot; } error()58 ErrorHandler* error() 59 { return m_pErrorHandler; } getFileName()60 const ::rtl::OString& getFileName() 61 { return m_fileName; } setFileName(const::rtl::OString & fileName)62 void setFileName(const ::rtl::OString& fileName) 63 { m_fileName = fileName; } getMainFileName()64 const ::rtl::OString& getMainFileName() 65 { return m_mainFileName; } setMainFileName(const::rtl::OString & mainFileName)66 void setMainFileName(const ::rtl::OString& mainFileName) 67 { m_mainFileName = mainFileName; } getRealFileName()68 const ::rtl::OString& getRealFileName() 69 { return m_realFileName; } setRealFileName(const::rtl::OString & realFileName)70 void setRealFileName(const ::rtl::OString& realFileName) 71 { m_realFileName = realFileName; } getDocumentation()72 const ::rtl::OString& getDocumentation() 73 { 74 m_bIsDocValid = sal_False; 75 return m_documentation; 76 } setDocumentation(const::rtl::OString & documentation)77 void setDocumentation(const ::rtl::OString& documentation) 78 { 79 m_documentation = documentation; 80 m_bIsDocValid = sal_True; 81 } 82 sal_Bool isDocValid(); isInMainFile()83 sal_Bool isInMainFile() 84 { return m_bIsInMainfile; } setInMainfile(sal_Bool bInMainfile)85 void setInMainfile(sal_Bool bInMainfile) 86 { m_bIsInMainfile = bInMainfile; } getErrorCount()87 sal_uInt32 getErrorCount() 88 { return m_errorCount; } setErrorCount(sal_uInt32 errorCount)89 void setErrorCount(sal_uInt32 errorCount) 90 { m_errorCount = errorCount; } incErrorCount()91 void incErrorCount() 92 { m_errorCount++; } getWarningCount()93 sal_uInt32 getWarningCount() 94 { return m_warningCount; } setWarningCount(sal_uInt32 warningCount)95 void setWarningCount(sal_uInt32 warningCount) 96 { m_warningCount = warningCount; } incWarningCount()97 void incWarningCount() 98 { m_warningCount++; } getLineNumber()99 sal_uInt32 getLineNumber() 100 { return m_lineNumber; } setLineNumber(sal_uInt32 lineNumber)101 void setLineNumber(sal_uInt32 lineNumber) 102 { m_lineNumber = lineNumber; } incLineNumber()103 void incLineNumber() 104 { m_lineNumber++; } getParseState()105 ParseState getParseState() 106 { return m_parseState; } setParseState(ParseState parseState)107 void setParseState(ParseState parseState) 108 { m_parseState = parseState; } 109 insertInclude(const::rtl::OString & inc)110 void insertInclude(const ::rtl::OString& inc) 111 { m_includes.insert(inc); } getIncludes()112 StringSet* getIncludes() 113 { return &m_includes; } 114 setPublished(bool published)115 void setPublished(bool published) { m_published = published; } isPublished() const116 bool isPublished() const { return m_published; } 117 118 void reset(); 119 private: 120 Options* m_pOptions; 121 AstStack* m_pScopes; 122 AstModule* m_pRoot; 123 ErrorHandler* m_pErrorHandler; 124 ::rtl::OString m_fileName; 125 ::rtl::OString m_mainFileName; 126 ::rtl::OString m_realFileName; 127 ::rtl::OString m_documentation; 128 sal_Bool m_bIsDocValid; 129 sal_Bool m_bGenerateDoc; 130 sal_Bool m_bIsInMainfile; 131 bool m_published; 132 sal_uInt32 m_errorCount; 133 sal_uInt32 m_warningCount; 134 sal_uInt32 m_lineNumber; 135 ParseState m_parseState; 136 StringSet m_includes; 137 }; 138 139 sal_Int32 compileFile(const ::rtl::OString * pathname); 140 // a null pathname means stdin 141 sal_Int32 produceFile(const ::rtl::OString& filenameBase); 142 // filenameBase is filename without ".idl" 143 void removeIfExists(const ::rtl::OString& pathname); 144 145 ::rtl::OString makeTempName(const ::rtl::OString& prefix, const ::rtl::OString& postfix); 146 sal_Bool copyFile(const ::rtl::OString* source, const ::rtl::OString& target); 147 // a null source means stdin 148 149 sal_Bool isFileUrl(const ::rtl::OString& fileName); 150 ::rtl::OString convertToAbsoluteSystemPath(const ::rtl::OString& fileName); 151 ::rtl::OString convertToFileUrl(const ::rtl::OString& fileName); 152 153 Idlc* SAL_CALL idlc(); 154 Idlc* SAL_CALL setIdlc(Options* pOptions); 155 156 AstDeclaration const * resolveTypedefs(AstDeclaration const * type); 157 158 AstDeclaration const * deconstructAndResolveTypedefs( 159 AstDeclaration const * type, sal_Int32 * rank); 160 161 AstInterface const * resolveInterfaceTypedefs(AstType const * type); 162 163 #endif // _IDLC_IDLC_HXX_ 164 165