1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* This file is part of OpenOffice.org.
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* OpenOffice.org is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
*
************************************************************************/
#ifndef INCLUDED_CODEMAKER_SOURCE_CPPUMAKER_CPPUTYPE_HXX
#define INCLUDED_CODEMAKER_SOURCE_CPPUMAKER_CPPUTYPE_HXX
#include "codemaker/dependencies.hxx"
#include "codemaker/options.hxx"
#include "codemaker/typemanager.hxx"
#include "codemaker/commoncpp.hxx"
#include "registry/reader.hxx"
#include "registry/types.h"
#include "rtl/string.hxx"
namespace rtl { class OUString; }
namespace codemaker {
namespace cppumaker { class Includes; }
struct ExceptionTreeNode;
class GeneratedTypeSet;
}
enum CppuTypeDecl
{
CPPUTYPEDECL_ALLTYPES,
CPPUTYPEDECL_NOINTERFACES,
CPPUTYPEDECL_ONLYINTERFACES
};
class CppuOptions;
class FileStream;
class CppuType
{
public:
CppuType(typereg::Reader& typeReader,
const ::rtl::OString& typeName,
const TypeManager& typeMgr);
virtual ~CppuType();
virtual sal_Bool dump(CppuOptions* pOptions) throw( CannotDumpException );
sal_Bool dumpFile(CppuOptions* pOptions,
const ::rtl::OString& sExtension,
const ::rtl::OString& sName,
const ::rtl::OString& sOutPath )
throw( CannotDumpException );
void dumpDependedTypes(
codemaker::GeneratedTypeSet & generated, CppuOptions * options);
virtual sal_Bool dumpHFile(FileStream& o, codemaker::cppumaker::Includes & includes) throw( CannotDumpException ) = 0;
virtual sal_Bool dumpHxxFile(FileStream& o, codemaker::cppumaker::Includes & includes) throw( CannotDumpException ) = 0;
::rtl::OString dumpHeaderDefine(
FileStream& o, char const * prefix, sal_Bool bExtended=sal_False);
void dumpGetCppuType(FileStream & out);
virtual void dumpLightGetCppuType(FileStream& o);
virtual void dumpNormalGetCppuType(FileStream& o);
virtual void dumpComprehensiveGetCppuType(FileStream& o);
virtual void dumpType(FileStream& o, const ::rtl::OString& type, bool bConst=false,
bool bRef=false, bool bNative=false, bool cppuUnoType=false)
const throw( CannotDumpException );
::rtl::OString getTypeClass(const ::rtl::OString& type="", sal_Bool bCStyle=sal_False);
void dumpCppuGetType(FileStream& o, const ::rtl::OString& type, sal_Bool bDecl=sal_False, CppuTypeDecl eDeclFlag=CPPUTYPEDECL_ALLTYPES);
::rtl::OString typeToIdentifier(const ::rtl::OString& type);
void dumpConstantValue(FileStream& o, sal_uInt16 index);
virtual sal_uInt32 getMemberCount();
virtual sal_uInt32 getInheritedMemberCount();
void inc(sal_Int32 num=4);
void dec(sal_Int32 num=4);
::rtl::OString indent() const;
protected:
virtual sal_uInt32 checkInheritedMemberCount(
const typereg::Reader* pReader);
bool passByReference(rtl::OString const & unoType);
::rtl::OString resolveTypedefs(const ::rtl::OString& type) const;
::rtl::OString checkRealBaseType(const ::rtl::OString& type, sal_Bool bResolveTypeOnly = sal_False) const;
void dumpCppuGetTypeMemberDecl(FileStream& o, CppuTypeDecl eDeclFlag);
codemaker::cpp::IdentifierTranslationMode isGlobal() const;
virtual void dumpDeclaration(FileStream & out) throw (CannotDumpException);
virtual void addSpecialDependencies() {}
virtual bool dumpFiles(CppuOptions * options, rtl::OString const & outPath);
virtual void addLightGetCppuTypeIncludes(
codemaker::cppumaker::Includes & includes) const;
virtual void addNormalGetCppuTypeIncludes(
codemaker::cppumaker::Includes & includes) const;
virtual void addComprehensiveGetCppuTypeIncludes(
codemaker::cppumaker::Includes & includes) const;
virtual bool isPolymorphic() const;
virtual void dumpTemplateHead(FileStream & out) const;
virtual void dumpTemplateParameters(FileStream & out) const;
void dumpGetCppuTypePreamble(FileStream & out);
void dumpGetCppuTypePostamble(FileStream & out);
void addDefaultHIncludes(codemaker::cppumaker::Includes & includes) const;
void addDefaultHxxIncludes(codemaker::cppumaker::Includes & includes) const;
void dumpInitializer(
FileStream & out, bool parameterized, rtl::OUString const & type) const;
void dumpHFileContent(
FileStream & out, codemaker::cppumaker::Includes & includes);
protected:
sal_uInt32 m_inheritedMemberCount;
sal_Bool m_cppuTypeLeak;
sal_Bool m_cppuTypeDynamic;
sal_Int32 m_indentLength;
::rtl::OString m_typeName;
::rtl::OString m_name;
typereg::Reader m_reader;
TypeManager const & m_typeMgr;
codemaker::Dependencies m_dependencies;
private:
void addGetCppuTypeIncludes(codemaker::cppumaker::Includes & includes)
const;
};
class InterfaceType : public CppuType
{
public:
InterfaceType(typereg::Reader& typeReader,
const ::rtl::OString& typeName,
const TypeManager& typeMgr);
virtual ~InterfaceType();
virtual void dumpDeclaration(FileStream& o) throw( CannotDumpException );
sal_Bool dumpHFile(FileStream& o, codemaker::cppumaker::Includes & includes) throw( CannotDumpException );
sal_Bool dumpHxxFile(FileStream& o, codemaker::cppumaker::Includes & includes) throw( CannotDumpException );
void dumpAttributes(FileStream& o);
void dumpMethods(FileStream& o);
void dumpNormalGetCppuType(FileStream& o);
void dumpComprehensiveGetCppuType(FileStream& o);
void dumpCppuAttributeRefs(FileStream& o, sal_uInt32& index);
void dumpCppuMethodRefs(FileStream& o, sal_uInt32& index);
void dumpCppuAttributes(FileStream& o, sal_uInt32& index);
void dumpCppuMethods(FileStream& o, sal_uInt32& index);
void dumpAttributesCppuDecl(FileStream& o, StringSet* pFinishedTypes, CppuTypeDecl eDeclFlag);
void dumpMethodsCppuDecl(FileStream& o, StringSet* pFinishedTypes, CppuTypeDecl eDeclFlag );
sal_uInt32 getMemberCount();
sal_uInt32 getInheritedMemberCount();
protected:
virtual void addSpecialDependencies();
virtual void addComprehensiveGetCppuTypeIncludes(
codemaker::cppumaker::Includes & includes) const;
sal_uInt32 checkInheritedMemberCount(const typereg::Reader* pReader);
protected:
sal_uInt32 m_inheritedMemberCount;
sal_Bool m_hasAttributes;
sal_Bool m_hasMethods;
private:
void dumpExceptionSpecification(
FileStream & out, sal_uInt32 methodIndex, bool runtimeException);
void dumpAttributeExceptionSpecification(
FileStream & out, rtl::OUString const & name, RTMethodMode sort);
void dumpExceptionTypeName(
FileStream & out, char const * prefix, sal_uInt32 index,
rtl::OUString name);
sal_Int32 dumpExceptionTypeNames(
FileStream & out, char const * prefix, sal_uInt16 methodIndex,
bool runtimeException);
sal_Int32 dumpAttributeExceptionTypeNames(
FileStream & out, char const * prefix, rtl::OUString const & name,
RTMethodMode sort);
};
class ConstantsType : public CppuType
{
public:
ConstantsType(typereg::Reader& typeReader,
const ::rtl::OString& typeName,
const TypeManager& typeMgr);
virtual ~ConstantsType();
virtual sal_Bool dump(CppuOptions* pOptions) throw( CannotDumpException );
virtual void dumpDeclaration(FileStream& o) throw( CannotDumpException );
sal_Bool dumpHFile(FileStream& o, codemaker::cppumaker::Includes & includes) throw( CannotDumpException );
sal_Bool dumpHxxFile(FileStream& o, codemaker::cppumaker::Includes & includes) throw( CannotDumpException );
sal_Bool hasConstants();
};
class ModuleType : public ConstantsType
{
public:
ModuleType(typereg::Reader& typeReader,
const ::rtl::OString& typeName,
const TypeManager& typeMgr);
virtual ~ModuleType();
protected:
virtual bool dumpFiles(CppuOptions * options, rtl::OString const & outPath);
};
class StructureType : public CppuType
{
public:
StructureType(typereg::Reader& typeReader,
const ::rtl::OString& typeName,
const TypeManager& typeMgr);
virtual ~StructureType();
virtual void dumpDeclaration(FileStream& o) throw( CannotDumpException );
sal_Bool dumpHFile(FileStream& o, codemaker::cppumaker::Includes & includes) throw( CannotDumpException );
sal_Bool dumpHxxFile(FileStream& o, codemaker::cppumaker::Includes & includes) throw( CannotDumpException );
virtual void dumpLightGetCppuType(FileStream & out);
virtual void dumpNormalGetCppuType(FileStream & out);
virtual void dumpComprehensiveGetCppuType(FileStream & out);
sal_Bool dumpSuperMember(FileStream& o, const ::rtl::OString& super, sal_Bool bWithType);
protected:
virtual void addLightGetCppuTypeIncludes(
codemaker::cppumaker::Includes & includes) const;
virtual void addNormalGetCppuTypeIncludes(
codemaker::cppumaker::Includes & includes) const;
virtual void addComprehensiveGetCppuTypeIncludes(
codemaker::cppumaker::Includes & includes) const;
virtual bool isPolymorphic() const;
virtual void dumpTemplateHead(FileStream & out) const;
virtual void dumpTemplateParameters(FileStream & out) const;
};
class ExceptionType : public CppuType
{
public:
ExceptionType(typereg::Reader& typeReader,
const ::rtl::OString& typeName,
const TypeManager& typeMgr);
virtual ~ExceptionType();
virtual void dumpDeclaration(FileStream& o) throw( CannotDumpException );
sal_Bool dumpHFile(FileStream& o, codemaker::cppumaker::Includes & includes) throw( CannotDumpException );
sal_Bool dumpHxxFile(FileStream& o, codemaker::cppumaker::Includes & includes) throw( CannotDumpException );
sal_Bool dumpSuperMember(FileStream& o, const ::rtl::OString& super, sal_Bool bWithType);
};
class EnumType : public CppuType
{
public:
EnumType(typereg::Reader& typeReader,
const ::rtl::OString& typeName,
const TypeManager& typeMgr);
virtual ~EnumType();
virtual void dumpDeclaration(FileStream& o) throw( CannotDumpException );
sal_Bool dumpHFile(FileStream& o, codemaker::cppumaker::Includes & includes) throw( CannotDumpException );
sal_Bool dumpHxxFile(FileStream& o, codemaker::cppumaker::Includes & includes) throw( CannotDumpException );
void dumpNormalGetCppuType(FileStream& o);
void dumpComprehensiveGetCppuType(FileStream& o);
};
class TypeDefType : public CppuType
{
public:
TypeDefType(typereg::Reader& typeReader,
const ::rtl::OString& typeName,
const TypeManager& typeMgr);
virtual ~TypeDefType();
virtual void dumpDeclaration(FileStream& o) throw( CannotDumpException );
sal_Bool dumpHFile(FileStream& o, codemaker::cppumaker::Includes & includes) throw( CannotDumpException );
sal_Bool dumpHxxFile(FileStream& o, codemaker::cppumaker::Includes & includes) throw( CannotDumpException );
};
class ConstructiveType: public CppuType {
public:
ConstructiveType(
typereg::Reader & reader, rtl::OString const & name,
TypeManager const & manager):
CppuType(reader, name, manager) {}
virtual sal_Bool dumpHFile(
FileStream & o, codemaker::cppumaker::Includes & includes)
throw (CannotDumpException);
protected:
virtual bool dumpFiles(CppuOptions * options, rtl::OString const & outPath);
};
class ServiceType: public ConstructiveType {
public:
ServiceType(
typereg::Reader & reader, rtl::OString const & name,
TypeManager const & manager):
ConstructiveType(reader, name, manager) {}
bool isSingleInterfaceBased();
virtual sal_Bool dumpHxxFile(
FileStream & o, codemaker::cppumaker::Includes & includes)
throw (CannotDumpException);
private:
virtual void addSpecialDependencies();
bool isDefaultConstructor(sal_uInt16 ctorIndex) const;
bool hasRestParameter(sal_uInt16 ctorIndex) const;
void dumpCatchClauses(
FileStream & out, codemaker::ExceptionTreeNode const * node);
};
class SingletonType: public ConstructiveType {
public:
SingletonType(
typereg::Reader & reader, rtl::OString const & name,
TypeManager const & manager):
ConstructiveType(reader, name, manager) {}
bool isInterfaceBased();
virtual sal_Bool dumpHxxFile(
FileStream & o, codemaker::cppumaker::Includes & includes)
throw (CannotDumpException);
};
bool produceType(const ::rtl::OString& typeName,
TypeManager const & typeMgr,
codemaker::GeneratedTypeSet & generated,
CppuOptions* pOptions)
throw( CannotDumpException );
bool produceType(RegistryKey& typeName, bool bIsExtraType,
TypeManager const & typeMgr,
codemaker::GeneratedTypeSet & generated,
CppuOptions* pOptions)
throw( CannotDumpException );
/**
* This function returns a C++ scoped name, represents the namespace
* scoping of this type, e.g. com:.sun::star::uno::XInterface.
*/
// ::rtl::OString scopedName(const ::rtl::OString& scope, const ::rtl::OString& type,
// sal_Bool bNoNameSpace=sal_False);
#endif // INCLUDED_CODEMAKER_SOURCE_CPPUMAKER_CPPUTYPE_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|