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 24 #ifndef INCLUDED_CODEMAKER_SOURCE_IDLMAKER_IDLTYPE_HXX 25 #define INCLUDED_CODEMAKER_SOURCE_IDLMAKER_IDLTYPE_HXX 26 27 #include <codemaker/typemanager.hxx> 28 #include <codemaker/dependency.hxx> 29 30 enum BASETYPE 31 { 32 BT_INVALID, 33 BT_VOID, 34 BT_ANY, 35 BT_TYPE, 36 BT_BOOLEAN, 37 BT_CHAR, 38 BT_STRING, 39 BT_FLOAT, 40 BT_DOUBLE, 41 BT_OCTET, 42 BT_BYTE, 43 BT_SHORT, 44 BT_LONG, 45 BT_HYPER, 46 BT_UNSIGNED_SHORT, 47 BT_UNSIGNED_LONG, 48 BT_UNSIGNED_HYPER 49 }; 50 51 52 enum IdlTypeDecl 53 { 54 CPPUTYPEDECL_ALLTYPES, 55 CPPUTYPEDECL_NOINTERFACES, 56 CPPUTYPEDECL_ONLYINTERFACES 57 }; 58 59 class IdlOptions; 60 class FileStream; 61 62 class IdlType 63 { 64 public: 65 IdlType(TypeReader& typeReader, 66 const ::rtl::OString& typeName, 67 const TypeManager& typeMgr, 68 const TypeDependency& typeDependencies); 69 70 virtual ~IdlType(); 71 72 virtual sal_Bool dump(IdlOptions* pOptions); 73 virtual sal_Bool dumpDependedTypes(IdlOptions* pOptions); 74 virtual sal_Bool dumpHFile(FileStream& o) = 0; 75 76 virtual ::rtl::OString dumpHeaderDefine(FileStream& o, sal_Char* prefix ); 77 virtual void dumpDefaultHIncludes(FileStream& o); 78 virtual void dumpInclude(FileStream& o, const ::rtl::OString& genTypeName, const ::rtl::OString& typeName, sal_Char* prefix ); 79 80 virtual void dumpDepIncludes(FileStream& o, const ::rtl::OString& typeName, sal_Char* prefix); 81 82 virtual void dumpNameSpace(FileStream& o, sal_Bool bOpen = sal_True, sal_Bool bFull = sal_False, const ::rtl::OString& type=""); 83 84 virtual void dumpType(FileStream& o, const ::rtl::OString& type); 85 ::rtl::OString getBaseType(const ::rtl::OString& type); 86 void dumpIdlGetType(FileStream& o, const ::rtl::OString& type, sal_Bool bDecl=sal_False, IdlTypeDecl eDeclFlag=CPPUTYPEDECL_ALLTYPES); 87 BASETYPE isBaseType(const ::rtl::OString& type); 88 89 void dumpConstantValue(FileStream& o, sal_uInt16 index); 90 91 virtual sal_uInt32 getMemberCount(); 92 virtual sal_uInt32 getInheritedMemberCount(); 93 94 void inc(sal_uInt32 num=4); 95 void dec(sal_uInt32 num=4); 96 ::rtl::OString indent(); 97 ::rtl::OString indent(sal_uInt32 num); 98 protected: 99 virtual sal_uInt32 checkInheritedMemberCount(const TypeReader* pReader); 100 101 ::rtl::OString checkSpecialIdlType(const ::rtl::OString& type); 102 ::rtl::OString checkRealBaseType(const ::rtl::OString& type, sal_Bool bResolveTypeOnly = sal_False); 103 104 protected: 105 sal_uInt32 m_inheritedMemberCount; 106 107 sal_uInt32 m_indentLength; 108 ::rtl::OString m_typeName; 109 ::rtl::OString m_name; 110 TypeReader m_reader; 111 TypeManager& m_typeMgr; 112 TypeDependency m_dependencies; 113 }; 114 115 class InterfaceType : public IdlType 116 { 117 public: 118 InterfaceType(TypeReader& typeReader, 119 const ::rtl::OString& typeName, 120 const TypeManager& typeMgr, 121 const TypeDependency& typeDependencies); 122 123 virtual ~InterfaceType(); 124 125 sal_Bool dumpHFile(FileStream& o); 126 127 void dumpAttributes(FileStream& o); 128 void dumpMethods(FileStream& o); 129 130 sal_uInt32 getMemberCount(); 131 sal_uInt32 getInheritedMemberCount(); 132 133 protected: 134 sal_uInt32 checkInheritedMemberCount(const TypeReader* pReader); 135 136 protected: 137 sal_uInt32 m_inheritedMemberCount; 138 sal_Bool m_hasAttributes; 139 sal_Bool m_hasMethods; 140 }; 141 142 class ModuleType : public IdlType 143 { 144 public: 145 ModuleType(TypeReader& typeReader, 146 const ::rtl::OString& typeName, 147 const TypeManager& typeMgr, 148 const TypeDependency& typeDependencies); 149 150 virtual ~ModuleType(); 151 152 virtual sal_Bool dump(IdlOptions* pOptions); 153 sal_Bool dumpHFile(FileStream& o); 154 sal_Bool hasConstants(); 155 }; 156 157 class ConstantsType : public ModuleType 158 { 159 public: 160 ConstantsType(TypeReader& typeReader, 161 const ::rtl::OString& typeName, 162 const TypeManager& typeMgr, 163 const TypeDependency& typeDependencies); 164 165 virtual ~ConstantsType(); 166 167 virtual sal_Bool dump(IdlOptions* pOptions); 168 }; 169 170 class StructureType : public IdlType 171 { 172 public: 173 StructureType(TypeReader& typeReader, 174 const ::rtl::OString& typeName, 175 const TypeManager& typeMgr, 176 const TypeDependency& typeDependencies); 177 178 virtual ~StructureType(); 179 180 sal_Bool dumpHFile(FileStream& o); 181 182 void dumpSuperMember(FileStream& o, const ::rtl::OString& super); 183 }; 184 185 class ExceptionType : public IdlType 186 { 187 public: 188 ExceptionType(TypeReader& typeReader, 189 const ::rtl::OString& typeName, 190 const TypeManager& typeMgr, 191 const TypeDependency& typeDependencies); 192 193 virtual ~ExceptionType(); 194 195 sal_Bool dumpHFile(FileStream& o); 196 197 void dumpSuperMember(FileStream& o, const ::rtl::OString& super); 198 }; 199 200 class EnumType : public IdlType 201 { 202 public: 203 EnumType(TypeReader& typeReader, 204 const ::rtl::OString& typeName, 205 const TypeManager& typeMgr, 206 const TypeDependency& typeDependencies); 207 208 virtual ~EnumType(); 209 210 sal_Bool dumpHFile(FileStream& o); 211 }; 212 213 class TypeDefType : public IdlType 214 { 215 public: 216 TypeDefType(TypeReader& typeReader, 217 const ::rtl::OString& typeName, 218 const TypeManager& typeMgr, 219 const TypeDependency& typeDependencies); 220 221 virtual ~TypeDefType(); 222 223 sal_Bool dumpHFile(FileStream& o); 224 }; 225 226 227 sal_Bool produceType(const ::rtl::OString& typeName, 228 TypeManager& typeMgr, 229 TypeDependency& typeDependencies, 230 IdlOptions* pOptions); 231 232 /** 233 * This function returns a C++ scoped name, represents the namespace 234 * scoping of this type, e.g. com:.sun::star::uno::XInterface. If the scope of 235 * the type is equal scope, the relativ name will be used. 236 */ 237 ::rtl::OString scopedName(const ::rtl::OString& scope, const ::rtl::OString& type, sal_Bool bNoNameSpace = sal_False ); 238 239 ::rtl::OString scope(const ::rtl::OString& scope, const ::rtl::OString& type ); 240 241 242 #endif // INCLUDED_CODEMAKER_SOURCE_IDLMAKER_IDLTYPE_HXX 243