1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include "sal/config.h"
29 #include "boost/noncopyable.hpp"
30 #include "rtl/alloc.h"
31 #include "rtl/ref.hxx"
32 #include "rtl/ustrbuf.hxx"
33 #include "rtl/ustring.hxx"
34 #include "rtl/strbuf.hxx"
35 #include "unoidl/unoidl.hxx"
37 #include "codemaker/commoncpp.hxx"
38 #include "codemaker/exceptiontree.hxx"
39 #include "codemaker/generatedtypeset.hxx"
40 #include "codemaker/typemanager.hxx"
41 #include "codemaker/unotype.hxx"
43 #include "cpputype.hxx"
44 #include "cppuoptions.hxx"
45 #include "dependencies.hxx"
46 #include "dumputils.hxx"
47 #include "includes.hxx"
51 bool isBootstrapType(OUString
const & name
) {
52 static char const * const names
[] = {
53 "com.sun.star.beans.Property",
54 "com.sun.star.beans.PropertyAttribute",
55 "com.sun.star.beans.PropertyChangeEvent",
56 "com.sun.star.beans.PropertyState",
57 "com.sun.star.beans.PropertyValue",
58 "com.sun.star.beans.XFastPropertySet",
59 "com.sun.star.beans.XMultiPropertySet",
60 "com.sun.star.beans.XPropertiesChangeListener",
61 "com.sun.star.beans.XPropertyAccess",
62 "com.sun.star.beans.XPropertyChangeListener",
63 "com.sun.star.beans.XPropertySet",
64 "com.sun.star.beans.XPropertySetInfo",
65 "com.sun.star.beans.XPropertySetOption",
66 "com.sun.star.beans.XVetoableChangeListener",
67 "com.sun.star.bridge.UnoUrlResolver",
68 "com.sun.star.bridge.XUnoUrlResolver",
69 "com.sun.star.connection.SocketPermission",
70 "com.sun.star.container.XElementAccess",
71 "com.sun.star.container.XEnumeration",
72 "com.sun.star.container.XEnumerationAccess",
73 "com.sun.star.container.XHierarchicalNameAccess",
74 "com.sun.star.container.XNameAccess",
75 "com.sun.star.container.XNameContainer",
76 "com.sun.star.container.XNameReplace",
77 "com.sun.star.container.XSet",
78 "com.sun.star.io.FilePermission",
79 "com.sun.star.io.IOException",
80 "com.sun.star.lang.DisposedException",
81 "com.sun.star.lang.EventObject",
82 "com.sun.star.lang.WrappedTargetRuntimeException",
83 "com.sun.star.lang.XComponent",
84 "com.sun.star.lang.XEventListener",
85 "com.sun.star.lang.XInitialization",
86 "com.sun.star.lang.XMultiComponentFactory",
87 "com.sun.star.lang.XMultiServiceFactory",
88 "com.sun.star.lang.XServiceInfo",
89 "com.sun.star.lang.XSingleComponentFactory",
90 "com.sun.star.lang.XSingleServiceFactory",
91 "com.sun.star.lang.XTypeProvider",
92 "com.sun.star.loader.XImplementationLoader",
93 "com.sun.star.reflection.FieldAccessMode",
94 "com.sun.star.reflection.MethodMode",
95 "com.sun.star.reflection.ParamInfo",
96 "com.sun.star.reflection.ParamMode",
97 "com.sun.star.reflection.TypeDescriptionSearchDepth",
98 "com.sun.star.reflection.XCompoundTypeDescription",
99 "com.sun.star.reflection.XEnumTypeDescription",
100 "com.sun.star.reflection.XIdlArray",
101 "com.sun.star.reflection.XIdlClass",
102 "com.sun.star.reflection.XIdlField",
103 "com.sun.star.reflection.XIdlField2",
104 "com.sun.star.reflection.XIdlMethod",
105 "com.sun.star.reflection.XIdlReflection",
106 "com.sun.star.reflection.XIndirectTypeDescription",
107 "com.sun.star.reflection.XInterfaceAttributeTypeDescription",
108 "com.sun.star.reflection.XInterfaceAttributeTypeDescription2",
109 "com.sun.star.reflection.XInterfaceMemberTypeDescription",
110 "com.sun.star.reflection.XInterfaceMethodTypeDescription",
111 "com.sun.star.reflection.XInterfaceTypeDescription",
112 "com.sun.star.reflection.XInterfaceTypeDescription2",
113 "com.sun.star.reflection.XMethodParameter",
114 "com.sun.star.reflection.XStructTypeDescription",
115 "com.sun.star.reflection.XTypeDescription",
116 "com.sun.star.reflection.XTypeDescriptionEnumeration",
117 "com.sun.star.reflection.XTypeDescriptionEnumerationAccess",
118 "com.sun.star.registry.RegistryKeyType",
119 "com.sun.star.registry.RegistryValueType",
120 "com.sun.star.registry.XImplementationRegistration",
121 "com.sun.star.registry.XRegistryKey",
122 "com.sun.star.registry.XSimpleRegistry",
123 "com.sun.star.security.RuntimePermission",
124 "com.sun.star.security.XAccessControlContext",
125 "com.sun.star.security.XAccessController",
126 "com.sun.star.security.XAction",
127 "com.sun.star.uno.DeploymentException",
128 "com.sun.star.uno.RuntimeException",
129 "com.sun.star.uno.TypeClass",
130 "com.sun.star.uno.Uik",
131 "com.sun.star.uno.XAdapter",
132 "com.sun.star.uno.XAggregation",
133 "com.sun.star.uno.XComponentContext",
134 "com.sun.star.uno.XCurrentContext",
135 "com.sun.star.uno.XInterface",
136 "com.sun.star.uno.XReference",
137 "com.sun.star.uno.XUnloadingPreference",
138 "com.sun.star.uno.XWeak",
139 "com.sun.star.util.XMacroExpander" };
140 // cf. cppuhelper/unotypes/Makefile UNOTYPES (plus missing dependencies)
141 for (std::size_t i
= 0; i
< SAL_N_ELEMENTS(names
); ++i
) {
142 if (name
.equalsAscii(names
[i
])) {
149 class CppuType
: private boost::noncopyable
{
152 OUString
const & name
, rtl::Reference
< TypeManager
> const & typeMgr
);
154 virtual ~CppuType() {}
156 void dump(CppuOptions
const & options
);
159 OUString
const & uri
, OUString
const & name
, bool hpp
,
160 CppuOptions
const & options
);
162 void dumpDependedTypes(
163 codemaker::GeneratedTypeSet
& generated
, CppuOptions
const & options
);
165 virtual void dumpHFile(
166 FileStream
& out
, codemaker::cppumaker::Includes
& includes
)
167 { dumpHFileContent(out
, includes
); }
169 virtual void dumpHxxFile(FileStream
& o
, codemaker::cppumaker::Includes
& includes
) = 0;
171 OUString
dumpHeaderDefine(FileStream
& o
, OUString
const & extension
);
173 void dumpGetCppuType(FileStream
& out
);
175 virtual void dumpLightGetCppuType(FileStream
& out
);
177 virtual void dumpNormalGetCppuType(FileStream
&)
178 { assert(false); } // this cannot happen
180 virtual void dumpComprehensiveGetCppuType(FileStream
&)
181 { assert(false); } // this cannot happen
184 FileStream
& out
, OUString
const & name
, bool isConst
= false,
185 bool isRef
= false, bool native
= false, bool cppuUnoType
= false)
188 OUString
getTypeClass(OUString
const & name
, bool cStyle
= false);
190 void dumpCppuGetType(
191 FileStream
& out
, OUString
const & name
, OUString
const * ownName
= 0);
193 sal_uInt32
getInheritedMemberCount();
195 void inc(sal_Int32 num
=4);
196 void dec(sal_Int32 num
=4);
197 OUString
indent() const;
199 virtual sal_uInt32
checkInheritedMemberCount() const
200 { assert(false); return 0; } // this cannot happen
202 bool passByReference(OUString
const & name
) const;
204 OUString
resolveOuterTypedefs(OUString
const & name
) const;
206 OUString
resolveAllTypedefs(OUString
const & name
) const;
208 codemaker::cpp::IdentifierTranslationMode
isGlobal() const;
210 virtual void dumpDeclaration(FileStream
&)
211 { assert(false); } // this cannot happen
213 virtual void dumpFiles(OUString
const & uri
, CppuOptions
const & options
);
215 virtual void addLightGetCppuTypeIncludes(
216 codemaker::cppumaker::Includes
& includes
) const;
218 virtual void addNormalGetCppuTypeIncludes(
219 codemaker::cppumaker::Includes
& includes
) const;
221 virtual void addComprehensiveGetCppuTypeIncludes(
222 codemaker::cppumaker::Includes
& includes
) const;
224 virtual bool isPolymorphic() const;
226 virtual void dumpTemplateHead(FileStream
&) const {}
228 virtual void dumpTemplateParameters(FileStream
&) const {}
230 void dumpGetCppuTypePreamble(FileStream
& out
);
232 void dumpGetCppuTypePostamble(FileStream
& out
);
234 void addDefaultHIncludes(codemaker::cppumaker::Includes
& includes
) const;
235 void addDefaultHxxIncludes(codemaker::cppumaker::Includes
& includes
) const;
237 void dumpInitializer(
238 FileStream
& out
, bool parameterized
, OUString
const & name
) const;
240 void dumpHFileContent(
241 FileStream
& out
, codemaker::cppumaker::Includes
& includes
);
244 sal_uInt32 m_inheritedMemberCount
;
247 bool m_cppuTypeDynamic
;
248 sal_Int32 m_indentLength
;
251 rtl::Reference
< TypeManager
> m_typeMgr
;
252 codemaker::cppumaker::Dependencies m_dependencies
;
255 void addGetCppuTypeIncludes(codemaker::cppumaker::Includes
& includes
)
260 OUString
const & name
, rtl::Reference
< TypeManager
> const & typeMgr
):
261 m_inheritedMemberCount(0)
262 , m_cppuTypeLeak(false)
263 , m_cppuTypeDynamic(true)
266 , id_(name_
.copy(name_
.lastIndexOf('.') + 1))
268 , m_dependencies(typeMgr
, name_
)
271 void CppuType::addGetCppuTypeIncludes(codemaker::cppumaker::Includes
& includes
)
274 if (name_
== "com.sun.star.uno.XInterface"
275 || name_
== "com.sun.star.uno.Exception")
278 includes
.addCppuUnotypeHxx();
279 includes
.addSalTypesH();
280 includes
.addTypelibTypeclassH();
281 includes
.addTypelibTypedescriptionH();
282 } else if (m_cppuTypeLeak
) {
283 addLightGetCppuTypeIncludes(includes
);
284 } else if (m_cppuTypeDynamic
) {
285 addNormalGetCppuTypeIncludes(includes
);
287 addComprehensiveGetCppuTypeIncludes(includes
);
291 void CppuType::dumpFiles(OUString
const & uri
, CppuOptions
const & options
) {
292 dumpFile(uri
, name_
, false, options
);
293 dumpFile(uri
, name_
, true, options
);
296 void CppuType::addLightGetCppuTypeIncludes(
297 codemaker::cppumaker::Includes
& includes
) const
299 //TODO: Determine what is really needed, instead of relying on
300 // addDefaultHxxIncludes
301 includes
.addCppuUnotypeHxx();
304 void CppuType::addNormalGetCppuTypeIncludes(
305 codemaker::cppumaker::Includes
& includes
) const
307 //TODO: Determine what is really needed, instead of relying on
308 // addDefaultHxxIncludes
309 includes
.addCppuUnotypeHxx();
312 void CppuType::addComprehensiveGetCppuTypeIncludes(
313 codemaker::cppumaker::Includes
& includes
) const
315 //TODO: Determine what is really needed, instead of relying on
316 // addDefaultHxxIncludes
317 includes
.addCppuUnotypeHxx();
320 bool CppuType::isPolymorphic() const { return false; }
322 void CppuType::dumpGetCppuTypePreamble(FileStream
& out
) {
323 if (isPolymorphic()) {
324 out
<< "namespace cppu {\n\n";
325 dumpTemplateHead(out
);
326 out
<< "class UnoType< ";
327 dumpType(out
, name_
);
328 dumpTemplateParameters(out
);
329 out
<< " > {\npublic:\n";
332 << "static inline ::css::uno::Type const & get() {\n";
334 if (codemaker::cppumaker::dumpNamespaceOpen(out
, name_
, false)) {
337 out
<< ("inline ::css::uno::Type const &"
338 " cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ");
339 dumpType(out
, name_
, false, false, true);
340 out
<< " const *) {\n";
345 void CppuType::dumpGetCppuTypePostamble(FileStream
& out
) {
347 if (isPolymorphic()) {
348 out
<< indent() << "}\n\nprivate:\n"
349 << indent() << "UnoType(UnoType &); // not defined\n"
350 << indent() << "~UnoType(); // not defined\n"
352 << "void operator =(UnoType); // not defined\n};\n\n}\n\n";
355 if (codemaker::cppumaker::dumpNamespaceClose(out
, name_
, false)) {
359 dumpTemplateHead(out
);
360 out
<< ("SAL_DEPRECATED(\"use cppu::UnoType\") inline ::css::uno::Type const & SAL_CALL"
361 " getCppuType(SAL_UNUSED_PARAMETER ");
362 dumpType(out
, name_
);
363 dumpTemplateParameters(out
);
364 out
<< " const *) {\n";
366 out
<< indent() << "return ::cppu::UnoType< ";
367 dumpType(out
, name_
);
368 dumpTemplateParameters(out
);
369 out
<< " >::get();\n";
371 out
<< indent() << "}\n";
374 void CppuType::dump(CppuOptions
const & options
) {
375 if (isBootstrapType(name_
)) {
376 m_cppuTypeDynamic
= false;
378 // -CS was used as an undocumented option to generate static getCppuType
379 // functions; since the introduction of cppu::UnoType this no longer is
380 // meaningful (getCppuType is just a forward to cppu::UnoType::get now),
381 // and -CS is handled the same way as -C now:
382 if (options
.isValid("-L"))
383 m_cppuTypeLeak
= true;
384 if (options
.isValid("-C") || options
.isValid("-CS"))
385 m_cppuTypeDynamic
= false;
388 options
.isValid("-O") ? b2u(options
.getOption("-O")) : "", options
);
391 bool CppuType::dumpFile(
392 OUString
const & uri
, OUString
const & name
, bool hpp
,
393 CppuOptions
const & options
)
396 b2u(createFileNameFromType(
397 u2b(uri
), u2b(name
), hpp
? ".hpp" : ".hdl")));
398 if (fileUri
.isEmpty()) {
399 throw CannotDumpException("empty target URI for entity " + name
);
401 bool exists
= fileExists(u2b(fileUri
));
402 if (exists
&& options
.isValid("-G")) {
406 out
.createTempFile(getTempDir(u2b(fileUri
)));
407 OUString
tmpUri(b2u(out
.getName()));
409 throw CannotDumpException("cannot open " + tmpUri
+ " for writing");
411 codemaker::cppumaker::Includes
includes(m_typeMgr
, m_dependencies
, hpp
);
414 addGetCppuTypeIncludes(includes
);
415 dumpHxxFile(out
, includes
);
417 dumpHFile(out
, includes
);
421 // Remove existing type file if something goes wrong to ensure
423 if (fileExists(u2b(fileUri
))) {
424 removeTypeFile(u2b(fileUri
));
426 removeTypeFile(u2b(tmpUri
));
430 return makeValidTypeFile(
431 u2b(fileUri
), u2b(tmpUri
), exists
&& options
.isValid("-Gc"));
434 void CppuType::dumpDependedTypes(
435 codemaker::GeneratedTypeSet
& generated
, CppuOptions
const & options
)
437 if (!options
.isValid("-nD")) {
438 codemaker::cppumaker::Dependencies::Map
const & map
439 = m_dependencies
.getMap();
440 for (codemaker::cppumaker::Dependencies::Map::const_iterator
i(
444 produce(i
->first
, m_typeMgr
, generated
, options
);
449 OUString
CppuType::dumpHeaderDefine(
450 FileStream
& out
, OUString
const & extension
)
453 "INCLUDED_" + name_
.replace('.', '_').toAsciiUpperCase() + "_"
455 out
<< "#ifndef " << def
<< "\n#define " << def
<< "\n";
459 void CppuType::addDefaultHIncludes(codemaker::cppumaker::Includes
& includes
)
462 //TODO: Only include what is really needed
463 includes
.addCppuMacrosHxx();
464 if (m_typeMgr
->getSort(name_
)
465 == codemaker::UnoType::SORT_INTERFACE_TYPE
)
467 includes
.addException();
468 includes
.addReference();
472 void CppuType::addDefaultHxxIncludes(codemaker::cppumaker::Includes
& includes
)
475 //TODO: Only include what is really needed
477 if (m_typeMgr
->getSort(name_
)
478 == codemaker::UnoType::SORT_INTERFACE_TYPE
)
480 includes
.addException();
481 includes
.addReference();
485 void CppuType::dumpInitializer(
486 FileStream
& out
, bool parameterized
, OUString
const & name
) const
489 if (!parameterized
) {
491 std::vector
< OString
> args
;
493 b2u(codemaker::UnoType::decompose(
494 u2b(resolveAllTypedefs(name
)), &k
, &args
)));
496 rtl::Reference
< unoidl::Entity
> ent
;
497 switch (m_typeMgr
->getSort(n
, &ent
)) {
498 case codemaker::UnoType::SORT_BOOLEAN
:
501 case codemaker::UnoType::SORT_BYTE
:
502 case codemaker::UnoType::SORT_SHORT
:
503 case codemaker::UnoType::SORT_UNSIGNED_SHORT
:
504 case codemaker::UnoType::SORT_LONG
:
505 case codemaker::UnoType::SORT_UNSIGNED_LONG
:
506 case codemaker::UnoType::SORT_HYPER
:
507 case codemaker::UnoType::SORT_UNSIGNED_HYPER
:
508 case codemaker::UnoType::SORT_FLOAT
:
509 case codemaker::UnoType::SORT_DOUBLE
:
510 case codemaker::UnoType::SORT_CHAR
:
513 case codemaker::UnoType::SORT_ENUM_TYPE
:
514 out
<< codemaker::cpp::scopedCppName(u2b(n
)) << "_"
515 << (dynamic_cast< unoidl::EnumTypeEntity
* >(ent
.get())->
516 getMembers()[0].name
);
518 case codemaker::UnoType::SORT_STRING
:
519 case codemaker::UnoType::SORT_TYPE
:
520 case codemaker::UnoType::SORT_ANY
:
521 case codemaker::UnoType::SORT_PLAIN_STRUCT_TYPE
:
522 case codemaker::UnoType::SORT_POLYMORPHIC_STRUCT_TYPE_TEMPLATE
:
523 case codemaker::UnoType::SORT_INTERFACE_TYPE
:
526 throw CannotDumpException(
527 "unexpected entity \"" + name
528 + "\" in call to CppuType::dumpInitializer");
535 void CppuType::dumpHFileContent(
536 FileStream
& out
, codemaker::cppumaker::Includes
& includes
)
538 addDefaultHIncludes(includes
);
539 dumpHeaderDefine(out
, "HDL");
541 includes
.dump(out
, 0);
542 out
<< ("\nnamespace com { namespace sun { namespace star { namespace uno"
543 " { class Type; } } } }\n\n");
544 if (codemaker::cppumaker::dumpNamespaceOpen(out
, name_
, false)) {
547 dumpDeclaration(out
);
548 if (!(name_
== "com.sun.star.uno.XInterface"
549 || name_
== "com.sun.star.uno.Exception"
552 out
<< "\n" << indent()
553 << ("inline ::css::uno::Type const &"
554 " cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ");
555 dumpType(out
, name_
, false, false, true);
556 out
<< " const *);\n";
558 if (codemaker::cppumaker::dumpNamespaceClose(out
, name_
, false)) {
562 dumpTemplateHead(out
);
563 out
<< "SAL_DEPRECATED(\"use cppu::UnoType\") inline ::css::uno::Type const & SAL_CALL getCppuType(";
564 dumpType(out
, name_
, true);
565 dumpTemplateParameters(out
);
566 out
<< " *);\n\n#endif\n";
569 void CppuType::dumpGetCppuType(FileStream
& out
) {
570 if (name_
== "com.sun.star.uno.XInterface") {
572 << ("SAL_DEPRECATED(\"use cppu::UnoType\") inline ::css::uno::Type const & SAL_CALL"
573 " getCppuType(SAL_UNUSED_PARAMETER ");
574 dumpType(out
, name_
, true);
578 << ("return ::cppu::UnoType< ::css::uno::XInterface"
581 out
<< indent() << "}\n";
582 } else if (name_
== "com.sun.star.uno.Exception") {
584 << ("SAL_DEPRECATED(\"use cppu::UnoType\") inline ::css::uno::Type const & SAL_CALL"
585 " getCppuType(SAL_UNUSED_PARAMETER ");
586 dumpType(out
, name_
, true);
590 << ("return ::cppu::UnoType< ::css::uno::Exception"
593 out
<< indent() << "}\n";
594 } else if (m_cppuTypeLeak
) {
595 dumpLightGetCppuType(out
);
596 } else if (m_cppuTypeDynamic
) {
597 dumpNormalGetCppuType(out
);
599 dumpComprehensiveGetCppuType(out
);
603 void CppuType::dumpLightGetCppuType(FileStream
& out
) {
604 dumpGetCppuTypePreamble(out
);
606 << "static typelib_TypeDescriptionReference * the_type = 0;\n"
607 << indent() << "if ( !the_type )\n" << indent() << "{\n";
609 out
<< indent() << "typelib_static_type_init( &the_type, "
610 << getTypeClass(name_
, true) << ", \"" << name_
<< "\" );\n";
612 out
<< indent() << "}\n" << indent()
613 << ("return * reinterpret_cast< ::css::uno::Type * >("
615 dumpGetCppuTypePostamble(out
);
618 codemaker::cpp::IdentifierTranslationMode
CppuType::isGlobal() const {
619 return name_
.indexOf('.') == -1
620 ? codemaker::cpp::ITM_GLOBAL
: codemaker::cpp::ITM_NONGLOBAL
;
623 sal_uInt32
CppuType::getInheritedMemberCount()
625 if (m_inheritedMemberCount
== 0)
627 m_inheritedMemberCount
= checkInheritedMemberCount();
630 return m_inheritedMemberCount
;
633 OUString
CppuType::getTypeClass(OUString
const & name
, bool cStyle
) {
634 rtl::Reference
< unoidl::Entity
> ent
;
635 switch (m_typeMgr
->getSort(name
, &ent
)) {
636 case codemaker::UnoType::SORT_VOID
:
638 ? OUString("typelib_TypeClass_VOID")
639 : OUString("::css::uno::TypeClass_VOID");
640 case codemaker::UnoType::SORT_BOOLEAN
:
642 ? OUString("typelib_TypeClass_BOOLEAN")
643 : OUString("::css::uno::TypeClass_BOOLEAN");
644 case codemaker::UnoType::SORT_BYTE
:
646 ? OUString("typelib_TypeClass_BYTE")
647 : OUString("::css::uno::TypeClass_BYTE");
648 case codemaker::UnoType::SORT_SHORT
:
650 ? OUString("typelib_TypeClass_SHORT")
651 : OUString("::css::uno::TypeClass_SHORT");
652 case codemaker::UnoType::SORT_UNSIGNED_SHORT
:
654 ? OUString("typelib_TypeClass_UNSIGNED_SHORT")
655 : OUString("::css::uno::TypeClass_UNSIGNED_SHORT");
656 case codemaker::UnoType::SORT_LONG
:
658 ? OUString("typelib_TypeClass_LONG")
659 : OUString("::css::uno::TypeClass_LONG");
660 case codemaker::UnoType::SORT_UNSIGNED_LONG
:
662 ? OUString("typelib_TypeClass_UNSIGNED_LONG")
663 : OUString("::css::uno::TypeClass_UNSIGNED_LONG");
664 case codemaker::UnoType::SORT_HYPER
:
666 ? OUString("typelib_TypeClass_HYPER")
667 : OUString("::css::uno::TypeClass_HYPER");
668 case codemaker::UnoType::SORT_UNSIGNED_HYPER
:
670 ? OUString("typelib_TypeClass_UNSIGNED_HYPER")
671 : OUString("::css::uno::TypeClass_UNSIGNED_HYPER");
672 case codemaker::UnoType::SORT_FLOAT
:
674 ? OUString("typelib_TypeClass_FLOAT")
675 : OUString("::css::uno::TypeClass_FLOAT");
676 case codemaker::UnoType::SORT_DOUBLE
:
678 ? OUString("typelib_TypeClass_DOUBLE")
679 : OUString("::css::uno::TypeClass_DOUBLE");
680 case codemaker::UnoType::SORT_CHAR
:
682 ? OUString("typelib_TypeClass_CHAR")
683 : OUString("::css::uno::TypeClass_CHAR");
684 case codemaker::UnoType::SORT_STRING
:
686 ? OUString("typelib_TypeClass_STRING")
687 : OUString("::css::uno::TypeClass_STRING");
688 case codemaker::UnoType::SORT_TYPE
:
690 ? OUString("typelib_TypeClass_TYPE")
691 : OUString("::css::uno::TypeClass_TYPE");
692 case codemaker::UnoType::SORT_ANY
:
694 ? OUString("typelib_TypeClass_ANY")
695 : OUString("::css::uno::TypeClass_ANY");
696 case codemaker::UnoType::SORT_SEQUENCE_TYPE
:
698 ? OUString("typelib_TypeClass_SEQUENCE")
699 : OUString("::css::uno::TypeClass_SEQUENCE");
700 case codemaker::UnoType::SORT_ENUM_TYPE
:
702 ? OUString("typelib_TypeClass_ENUM")
703 : OUString("::css::uno::TypeClass_ENUM");
704 case codemaker::UnoType::SORT_PLAIN_STRUCT_TYPE
:
705 case codemaker::UnoType::SORT_POLYMORPHIC_STRUCT_TYPE_TEMPLATE
:
706 case codemaker::UnoType::SORT_INSTANTIATED_POLYMORPHIC_STRUCT_TYPE
:
708 ? OUString("typelib_TypeClass_STRUCT")
709 : OUString("::css::uno::TypeClass_STRUCT");
710 case codemaker::UnoType::SORT_EXCEPTION_TYPE
:
712 ? OUString("typelib_TypeClass_EXCEPTION")
713 : OUString("::css::uno::TypeClass_EXCEPTION");
714 case codemaker::UnoType::SORT_INTERFACE_TYPE
:
716 ? OUString("typelib_TypeClass_INTERFACE")
717 : OUString("::css::uno::TypeClass_INTERFACE");
718 case codemaker::UnoType::SORT_TYPEDEF
:
720 dynamic_cast<unoidl::TypedefEntity
&>(*ent
.get()).getType(),
723 for (;;) { std::abort(); }
727 void CppuType::dumpType(
728 FileStream
& out
, OUString
const & name
, bool isConst
, bool isRef
,
729 bool native
, bool cppuUnoType
) const
732 std::vector
< OString
> args
;
734 b2u(codemaker::UnoType::decompose(
735 u2b(resolveAllTypedefs(name
)), &k
, &args
)));
739 for (sal_Int32 i
= 0; i
!= k
; ++i
) {
741 ? "::cppu::UnoSequenceType" : "::css::uno::Sequence")
744 switch (m_typeMgr
->getSort(n
)) {
745 case codemaker::UnoType::SORT_VOID
:
748 case codemaker::UnoType::SORT_BOOLEAN
:
751 case codemaker::UnoType::SORT_BYTE
:
754 case codemaker::UnoType::SORT_SHORT
:
755 out
<< "::sal_Int16";
757 case codemaker::UnoType::SORT_UNSIGNED_SHORT
:
758 out
<< (cppuUnoType
? "::cppu::UnoUnsignedShortType" : "::sal_uInt16");
760 case codemaker::UnoType::SORT_LONG
:
761 out
<< "::sal_Int32";
763 case codemaker::UnoType::SORT_UNSIGNED_LONG
:
764 out
<< "::sal_uInt32";
766 case codemaker::UnoType::SORT_HYPER
:
767 out
<< "::sal_Int64";
769 case codemaker::UnoType::SORT_UNSIGNED_HYPER
:
770 out
<< "::sal_uInt64";
772 case codemaker::UnoType::SORT_FLOAT
:
775 case codemaker::UnoType::SORT_DOUBLE
:
778 case codemaker::UnoType::SORT_CHAR
:
779 out
<< (cppuUnoType
? "::cppu::UnoCharType" : "::sal_Unicode");
781 case codemaker::UnoType::SORT_STRING
:
782 out
<< "::rtl::OUString";
784 case codemaker::UnoType::SORT_TYPE
:
785 out
<< "::css::uno::Type";
787 case codemaker::UnoType::SORT_ANY
:
788 out
<< "::css::uno::Any";
790 case codemaker::UnoType::SORT_ENUM_TYPE
:
791 case codemaker::UnoType::SORT_PLAIN_STRUCT_TYPE
:
792 case codemaker::UnoType::SORT_EXCEPTION_TYPE
:
793 out
<< codemaker::cpp::scopedCppName(u2b(n
));
795 case codemaker::UnoType::SORT_POLYMORPHIC_STRUCT_TYPE_TEMPLATE
:
796 out
<< codemaker::cpp::scopedCppName(u2b(n
));
799 for (std::vector
< OString
>::iterator
i(args
.begin());
800 i
!= args
.end(); ++i
)
802 if (i
!= args
.begin()) {
805 dumpType(out
, b2u(*i
));
810 case codemaker::UnoType::SORT_INTERFACE_TYPE
:
812 out
<< "::css::uno::Reference< ";
814 out
<< codemaker::cpp::scopedCppName(u2b(n
));
820 throw CannotDumpException(
821 "unexpected entity \"" + name
+ "\" in call to CppuType::dumpType");
823 for (sal_Int32 i
= 0; i
!= k
; ++i
) {
831 void CppuType::dumpCppuGetType(
832 FileStream
& out
, OUString
const & name
, OUString
const * ownName
)
834 //TODO: What are these calls good for?
837 codemaker::UnoType::Sort sort
= m_typeMgr
->decompose(
838 name
, true, &nucleus
, &rank
, 0, 0);
839 switch (rank
== 0 ? sort
: codemaker::UnoType::SORT_SEQUENCE_TYPE
) {
840 case codemaker::UnoType::SORT_VOID
:
841 case codemaker::UnoType::SORT_BOOLEAN
:
842 case codemaker::UnoType::SORT_BYTE
:
843 case codemaker::UnoType::SORT_SHORT
:
844 case codemaker::UnoType::SORT_UNSIGNED_SHORT
:
845 case codemaker::UnoType::SORT_LONG
:
846 case codemaker::UnoType::SORT_UNSIGNED_LONG
:
847 case codemaker::UnoType::SORT_HYPER
:
848 case codemaker::UnoType::SORT_UNSIGNED_HYPER
:
849 case codemaker::UnoType::SORT_FLOAT
:
850 case codemaker::UnoType::SORT_DOUBLE
:
851 case codemaker::UnoType::SORT_CHAR
:
852 case codemaker::UnoType::SORT_STRING
:
853 case codemaker::UnoType::SORT_TYPE
:
854 case codemaker::UnoType::SORT_ANY
:
856 case codemaker::UnoType::SORT_SEQUENCE_TYPE
:
857 case codemaker::UnoType::SORT_ENUM_TYPE
:
858 case codemaker::UnoType::SORT_PLAIN_STRUCT_TYPE
:
859 case codemaker::UnoType::SORT_INSTANTIATED_POLYMORPHIC_STRUCT_TYPE
:
860 case codemaker::UnoType::SORT_EXCEPTION_TYPE
:
861 case codemaker::UnoType::SORT_INTERFACE_TYPE
:
862 // Take care of recursion like struct S { sequence<S> x; }:
863 if (ownName
== 0 || nucleus
!= *ownName
) {
864 out
<< indent() << "::cppu::UnoType< ";
865 dumpType(out
, name
, false, false, false, true);
866 out
<< " >::get();\n";
869 case codemaker::UnoType::SORT_TYPEDEF
:
870 assert(false); // this cannot happen
873 throw CannotDumpException(
874 "unexpected entity \"" + name
875 + "\" in call to CppuType::dumpCppuGetType");
879 bool CppuType::passByReference(OUString
const & name
) const {
880 switch (m_typeMgr
->getSort(resolveOuterTypedefs(name
))) {
881 case codemaker::UnoType::SORT_BOOLEAN
:
882 case codemaker::UnoType::SORT_BYTE
:
883 case codemaker::UnoType::SORT_SHORT
:
884 case codemaker::UnoType::SORT_UNSIGNED_SHORT
:
885 case codemaker::UnoType::SORT_LONG
:
886 case codemaker::UnoType::SORT_UNSIGNED_LONG
:
887 case codemaker::UnoType::SORT_HYPER
:
888 case codemaker::UnoType::SORT_UNSIGNED_HYPER
:
889 case codemaker::UnoType::SORT_FLOAT
:
890 case codemaker::UnoType::SORT_DOUBLE
:
891 case codemaker::UnoType::SORT_CHAR
:
892 case codemaker::UnoType::SORT_ENUM_TYPE
:
894 case codemaker::UnoType::SORT_STRING
:
895 case codemaker::UnoType::SORT_TYPE
:
896 case codemaker::UnoType::SORT_ANY
:
897 case codemaker::UnoType::SORT_SEQUENCE_TYPE
:
898 case codemaker::UnoType::SORT_PLAIN_STRUCT_TYPE
:
899 case codemaker::UnoType::SORT_INSTANTIATED_POLYMORPHIC_STRUCT_TYPE
:
900 case codemaker::UnoType::SORT_INTERFACE_TYPE
:
903 throw CannotDumpException(
904 "unexpected entity \"" + name
905 + "\" in call to CppuType::passByReference");
909 OUString
CppuType::resolveOuterTypedefs(OUString
const & name
) const {
910 for (OUString
n(name
);;) {
911 rtl::Reference
< unoidl::Entity
> ent
;
912 if (m_typeMgr
->getSort(n
, &ent
) != codemaker::UnoType::SORT_TYPEDEF
) {
915 n
= dynamic_cast<unoidl::TypedefEntity
&>(*ent
.get()).getType();
919 OUString
CppuType::resolveAllTypedefs(OUString
const & name
) const {
921 OUString
n(b2u(codemaker::UnoType::decompose(u2b(name
), &k1
)));
923 rtl::Reference
< unoidl::Entity
> ent
;
924 if (m_typeMgr
->getSort(n
, &ent
) != codemaker::UnoType::SORT_TYPEDEF
) {
929 codemaker::UnoType::decompose(
930 u2b(dynamic_cast<unoidl::TypedefEntity
&>(*ent
.get()).
933 k1
+= k2
; //TODO: overflow
936 for (sal_Int32 i
= 0; i
!= k1
; ++i
) {
940 return b
.makeStringAndClear();
943 void CppuType::inc(sal_Int32 num
)
945 m_indentLength
+= num
;
948 void CppuType::dec(sal_Int32 num
)
950 m_indentLength
= std::max
< sal_Int32
>(m_indentLength
- num
, 0);
953 OUString
CppuType::indent() const {
954 OUStringBuffer
buf(m_indentLength
);
955 for (sal_Int32 i
= 0; i
!= m_indentLength
; ++i
) {
958 return buf
.makeStringAndClear();
961 bool isDeprecated(std::vector
< OUString
> const & annotations
) {
962 for (std::vector
< OUString
>::const_iterator
i(annotations
.begin());
963 i
!= annotations
.end(); ++i
)
965 if (*i
== "deprecated") {
972 void dumpDeprecation(FileStream
& out
, bool deprecated
) {
974 out
<< "SAL_DEPRECATED_INTERNAL(\"marked @deprecated in UNOIDL\") ";
978 class BaseOffset
: private boost::noncopyable
{
981 rtl::Reference
< TypeManager
> const & manager
,
982 rtl::Reference
< unoidl::InterfaceTypeEntity
> const & entity
):
983 manager_(manager
), offset_(0) { calculateBases(entity
); }
985 sal_Int32
get() const { return offset_
; }
989 rtl::Reference
< unoidl::InterfaceTypeEntity
> const & entity
);
991 rtl::Reference
< TypeManager
> manager_
;
992 std::set
< OUString
> set_
;
996 void BaseOffset::calculateBases(
997 rtl::Reference
< unoidl::InterfaceTypeEntity
> const & entity
)
1000 for (std::vector
< unoidl::AnnotatedReference
>::const_iterator
i(
1001 entity
->getDirectMandatoryBases().begin());
1002 i
!= entity
->getDirectMandatoryBases().end(); ++i
)
1004 if (set_
.insert(i
->name
).second
) {
1005 rtl::Reference
< unoidl::Entity
> ent
;
1006 codemaker::UnoType::Sort sort
= manager_
->getSort(i
->name
, &ent
);
1007 if (sort
!= codemaker::UnoType::SORT_INTERFACE_TYPE
) {
1008 throw CannotDumpException(
1009 "interface type base " + i
->name
1010 + " is not an interface type");
1012 rtl::Reference
< unoidl::InterfaceTypeEntity
> ent2(
1013 dynamic_cast< unoidl::InterfaceTypeEntity
* >(ent
.get()));
1015 calculateBases(ent2
);
1016 offset_
+= ent2
->getDirectAttributes().size()
1017 + ent2
->getDirectMethods().size(); //TODO: overflow
1022 class InterfaceType
: public CppuType
{
1025 rtl::Reference
< unoidl::InterfaceTypeEntity
> const & entity
,
1026 OUString
const & name
, rtl::Reference
< TypeManager
> const & typeMgr
);
1028 virtual void dumpDeclaration(FileStream
& o
) SAL_OVERRIDE
;
1029 void dumpHxxFile(FileStream
& o
, codemaker::cppumaker::Includes
& includes
) SAL_OVERRIDE
;
1031 void dumpAttributes(FileStream
& o
);
1032 void dumpMethods(FileStream
& o
);
1033 void dumpNormalGetCppuType(FileStream
& o
) SAL_OVERRIDE
;
1034 void dumpComprehensiveGetCppuType(FileStream
& o
) SAL_OVERRIDE
;
1035 void dumpCppuAttributeRefs(FileStream
& o
, sal_uInt32
& index
);
1036 void dumpCppuMethodRefs(FileStream
& o
, sal_uInt32
& index
);
1037 void dumpCppuAttributes(FileStream
& o
, sal_uInt32
& index
);
1038 void dumpCppuMethods(FileStream
& o
, sal_uInt32
& index
);
1039 void dumpAttributesCppuDecl(FileStream
& out
, std::set
< OUString
> * seen
);
1040 void dumpMethodsCppuDecl(FileStream
& out
, std::set
< OUString
> * seen
);
1043 virtual void addComprehensiveGetCppuTypeIncludes(
1044 codemaker::cppumaker::Includes
& includes
) const SAL_OVERRIDE
;
1046 virtual sal_uInt32
checkInheritedMemberCount() const SAL_OVERRIDE
1047 { return BaseOffset(m_typeMgr
, entity_
).get(); }
1049 static void dumpExceptionSpecification(
1050 FileStream
& out
, std::vector
< OUString
> const & exceptions
,
1051 bool runtimeException
);
1053 void dumpExceptionTypeName(
1054 FileStream
& out
, OUString
const & prefix
, sal_uInt32 index
,
1055 OUString
const & name
);
1057 sal_Int32
dumpExceptionTypeNames(
1058 FileStream
& out
, OUString
const & prefix
,
1059 std::vector
< OUString
> const & exceptions
, bool runtimeException
);
1061 rtl::Reference
< unoidl::InterfaceTypeEntity
> entity_
;
1062 bool m_isDeprecated
;
1065 InterfaceType::InterfaceType(
1066 rtl::Reference
< unoidl::InterfaceTypeEntity
> const & entity
,
1067 OUString
const & name
, rtl::Reference
< TypeManager
> const & typeMgr
):
1068 CppuType(name
, typeMgr
), entity_(entity
),
1069 m_isDeprecated(isDeprecated(entity
->getAnnotations()))
1071 assert(entity
.is());
1074 void InterfaceType::dumpDeclaration(FileStream
& out
) {
1075 out
<< "\nclass SAL_NO_VTABLE SAL_DLLPUBLIC_RTTI " << id_
;
1076 for (std::vector
< unoidl::AnnotatedReference
>::const_iterator
i(
1077 entity_
->getDirectMandatoryBases().begin());
1078 i
!= entity_
->getDirectMandatoryBases().end(); ++i
)
1080 out
<< (i
== entity_
->getDirectMandatoryBases().begin() ? " :" : ",")
1081 << " public " << codemaker::cpp::scopedCppName(u2b(i
->name
));
1083 out
<< "\n{\npublic:\n";
1085 dumpAttributes(out
);
1087 out
<< "\n" << indent()
1088 << ("static inline ::css::uno::Type const & SAL_CALL"
1089 " static_type(void * = 0);\n\n");
1091 out
<< "protected:\n";
1093 out
<< indent() << "~" << id_
1094 << ("() throw () {} // avoid warnings about virtual members and"
1095 " non-virtual dtor\n");
1100 void InterfaceType::dumpHxxFile(
1101 FileStream
& out
, codemaker::cppumaker::Includes
& includes
)
1103 OUString
headerDefine(dumpHeaderDefine(out
, "HPP"));
1105 addDefaultHxxIncludes(includes
);
1106 includes
.dump(out
, &name_
);
1108 dumpGetCppuType(out
);
1109 out
<< "\n::css::uno::Type const & "
1110 << codemaker::cpp::scopedCppName(u2b(name_
))
1111 << "::static_type(SAL_UNUSED_PARAMETER void *) {\n";
1113 out
<< indent() << "return ::cppu::UnoType< ";
1114 dumpType(out
, name_
, false, false, true);
1115 out
<< " >::get();\n";
1117 out
<< "}\n\n#endif // "<< headerDefine
<< "\n";
1120 void InterfaceType::dumpAttributes(FileStream
& out
) {
1121 if (!entity_
->getDirectAttributes().empty()) {
1122 out
<< "\n" << indent() << "// Attributes\n";
1124 for (std::vector
< unoidl::InterfaceTypeEntity::Attribute
>::const_iterator
1125 i(entity_
->getDirectAttributes().begin());
1126 i
!= entity_
->getDirectAttributes().end(); ++i
)
1128 bool depr
= m_isDeprecated
|| isDeprecated(i
->annotations
);
1130 dumpDeprecation(out
, depr
);
1132 dumpType(out
, i
->type
);
1133 out
<< " SAL_CALL get" << i
->name
<< "()";
1134 dumpExceptionSpecification(out
, i
->getExceptions
, true);
1137 bool byRef
= passByReference(i
->type
);
1139 dumpDeprecation(out
, depr
);
1140 out
<< "virtual void SAL_CALL set" << i
->name
<< "( ";
1141 dumpType(out
, i
->type
, byRef
, byRef
);
1142 out
<< " _" << i
->name
.toAsciiLowerCase() << " )";
1143 dumpExceptionSpecification(out
, i
->setExceptions
, true);
1149 void InterfaceType::dumpMethods(FileStream
& out
) {
1150 if (!entity_
->getDirectMethods().empty()) {
1151 out
<< "\n" << indent() << "// Methods\n";
1153 for (std::vector
< unoidl::InterfaceTypeEntity::Method
>::const_iterator
i(
1154 entity_
->getDirectMethods().begin());
1155 i
!= entity_
->getDirectMethods().end(); ++i
)
1158 dumpDeprecation(out
, m_isDeprecated
|| isDeprecated(i
->annotations
));
1160 dumpType(out
, i
->returnType
);
1161 out
<< " SAL_CALL " << i
->name
<< "(";
1162 if (i
->parameters
.empty()) {
1166 for (std::vector
< unoidl::InterfaceTypeEntity::Method::Parameter
>::
1167 const_iterator
j(i
->parameters
.begin());
1168 j
!= i
->parameters
.end();)
1173 == (unoidl::InterfaceTypeEntity::Method::Parameter::
1176 isConst
= passByReference(j
->type
);
1182 dumpType(out
, j
->type
, isConst
, isRef
);
1183 out
<< " " << j
->name
;
1185 if (j
!= i
->parameters
.end()) {
1191 dumpExceptionSpecification(
1192 out
, i
->exceptions
, i
->name
!= "acquire" && i
->name
!= "release");
1197 void InterfaceType::dumpNormalGetCppuType(FileStream
& out
) {
1198 dumpGetCppuTypePreamble(out
);
1200 << "static typelib_TypeDescriptionReference * the_type = 0;\n"
1201 << indent() << "if ( !the_type )\n" << indent() << "{\n";
1203 std::vector
< unoidl::AnnotatedReference
>::size_type
bases(
1204 entity_
->getDirectMandatoryBases().size());
1206 && (entity_
->getDirectMandatoryBases()[0].name
1207 == "com.sun.star.uno.XInterface"))
1212 out
<< indent() << "typelib_TypeDescriptionReference * aSuperTypes["
1213 << entity_
->getDirectMandatoryBases().size() << "];\n";
1214 std::vector
< unoidl::AnnotatedReference
>::size_type n
= 0;
1215 for (std::vector
< unoidl::AnnotatedReference
>::const_iterator
i(
1216 entity_
->getDirectMandatoryBases().begin());
1217 i
!= entity_
->getDirectMandatoryBases().end(); ++i
)
1219 out
<< indent() << "aSuperTypes[" << n
++ << "] = ::cppu::UnoType< ";
1220 dumpType(out
, i
->name
, true, false, false, true);
1221 out
<< " >::get().getTypeLibType();\n";
1224 out
<< indent() << "typelib_static_mi_interface_type_init( &the_type, \""
1225 << name_
<< "\", " << bases
<< ", "
1226 << (bases
== 0 ? "0" : "aSuperTypes") << " );\n";
1228 out
<< indent() << "}\n" << indent()
1229 << ("return * reinterpret_cast< ::css::uno::Type * >("
1231 dumpGetCppuTypePostamble(out
);
1234 void InterfaceType::dumpComprehensiveGetCppuType(FileStream
& out
) {
1235 codemaker::cppumaker::dumpNamespaceOpen(out
, name_
, false);
1236 OUString
staticTypeClass("the" + id_
+ "Type");
1237 out
<< " namespace detail {\n\n" << indent() << "struct " << staticTypeClass
1238 << " : public rtl::StaticWithInit< ::css::uno::Type *, "
1239 << staticTypeClass
<< " >\n" << indent() << "{\n";
1241 out
<< indent() << "::css::uno::Type * operator()() const\n"
1242 << indent() << "{\n";
1244 out
<< indent() << "::rtl::OUString sTypeName( \"" << name_
<< "\" );\n\n"
1245 << indent() << "// Start inline typedescription generation\n"
1246 << indent() << "typelib_InterfaceTypeDescription * pTD = 0;\n\n";
1247 out
<< indent() << "typelib_TypeDescriptionReference * aSuperTypes["
1248 << entity_
->getDirectMandatoryBases().size() << "];\n";
1249 std::vector
< unoidl::AnnotatedReference
>::size_type n
= 0;
1250 for (std::vector
< unoidl::AnnotatedReference
>::const_iterator
i(
1251 entity_
->getDirectMandatoryBases().begin());
1252 i
!= entity_
->getDirectMandatoryBases().end(); ++i
)
1254 out
<< indent() << "aSuperTypes[" << n
++ << "] = ::cppu::UnoType< ";
1255 dumpType(out
, i
->name
, false, false, false, true);
1256 out
<< " >::get().getTypeLibType();\n";
1258 std::size_t count
= entity_
->getDirectAttributes().size()
1259 + entity_
->getDirectMethods().size(); //TODO: overflow
1261 out
<< indent() << "typelib_TypeDescriptionReference * pMembers["
1262 << count
<< "] = { ";
1263 for (std::size_t i
= 0; i
!= count
; ++i
) {
1265 if (i
+ 1 != count
) {
1270 sal_uInt32 index
= 0;
1271 dumpCppuAttributeRefs(out
, index
);
1272 dumpCppuMethodRefs(out
, index
);
1274 out
<< "\n" << indent() << "typelib_typedescription_newMIInterface(\n";
1276 out
<< indent() << "&pTD,\n" << indent()
1277 << "sTypeName.pData, 0, 0, 0, 0, 0,\n" << indent()
1278 << entity_
->getDirectMandatoryBases().size() << ", aSuperTypes,\n"
1279 << indent() << count
<< ",\n" << indent()
1280 << (count
== 0 ? "0" : "pMembers") << " );\n\n";
1283 << ("typelib_typedescription_register( (typelib_TypeDescription**)&pTD"
1285 for (std::size_t i
= 0; i
!= count
; ++i
) {
1286 out
<< indent() << "typelib_typedescriptionreference_release( pMembers["
1290 << ("typelib_typedescription_release( (typelib_TypeDescription*)pTD"
1292 << indent() << "return new ::css::uno::Type( "
1293 << getTypeClass(name_
) << ", sTypeName ); // leaked\n";
1295 out
<< indent() << "}\n";
1297 out
<< indent() << "};\n\n";
1298 codemaker::cppumaker::dumpNamespaceClose(out
, name_
, false);
1300 dumpGetCppuTypePreamble(out
);
1301 out
<< indent() << "const ::css::uno::Type &rRet = *detail::"
1302 << staticTypeClass
<< "::get();\n" << indent()
1303 << "// End inline typedescription generation\n" << indent()
1304 << "static bool bInitStarted = false;\n" << indent()
1305 << "if (!bInitStarted)\n" << indent() << "{\n";
1308 << "::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );\n"
1309 << indent() << "if (!bInitStarted)\n" << indent() << "{\n";
1311 out
<< indent() << "OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER();\n"
1312 << indent() << "bInitStarted = true;\n";
1313 std::set
< OUString
> seen
;
1314 // Type for RuntimeException is always needed:
1315 seen
.insert("com.sun.star.uno.RuntimeException");
1316 dumpCppuGetType(out
, "com.sun.star.uno.RuntimeException");
1317 dumpAttributesCppuDecl(out
, &seen
);
1318 dumpMethodsCppuDecl(out
, &seen
);
1320 sal_uInt32 index
= getInheritedMemberCount();
1321 dumpCppuAttributes(out
, index
);
1322 dumpCppuMethods(out
, index
);
1325 out
<< indent() << "}\n";
1327 out
<< indent() << "}\n" << indent() << "else\n" << indent() << "{\n";
1329 out
<< indent() << "OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER();\n";
1331 out
<< indent() << "}\n" << indent() << "return rRet;\n";
1332 dumpGetCppuTypePostamble(out
);
1335 void InterfaceType::dumpCppuAttributeRefs(FileStream
& out
, sal_uInt32
& index
)
1337 std::vector
< unoidl::InterfaceTypeEntity::Attribute
>::size_type n
= 0;
1338 for (std::vector
< unoidl::InterfaceTypeEntity::Attribute
>::const_iterator
1339 i(entity_
->getDirectAttributes().begin());
1340 i
!= entity_
->getDirectAttributes().end(); ++i
)
1342 out
<< indent() << "::rtl::OUString sAttributeName" << n
<< "( \""
1343 << name_
<< "::" << i
->name
<< "\" );\n" << indent()
1344 << "typelib_typedescriptionreference_new( &pMembers[" << index
++
1348 << ("(typelib_TypeClass)::css::uno::TypeClass_INTERFACE_ATTRIBUTE,\n")
1349 << indent() << "sAttributeName" << n
<< ".pData );\n";
1355 void InterfaceType::dumpCppuMethodRefs(FileStream
& out
, sal_uInt32
& index
) {
1356 std::vector
< unoidl::InterfaceTypeEntity::Method
>::size_type n
= 0;
1357 for (std::vector
< unoidl::InterfaceTypeEntity::Method
>::const_iterator
i(
1358 entity_
->getDirectMethods().begin());
1359 i
!= entity_
->getDirectMethods().end(); ++i
)
1361 out
<< indent() << "::rtl::OUString sMethodName" << n
<< "( \"" << name_
1362 << "::" << i
->name
<< "\" );\n" << indent()
1363 << "typelib_typedescriptionreference_new( &pMembers[" << index
++
1367 << ("(typelib_TypeClass)::css::uno::TypeClass_INTERFACE_METHOD,\n")
1368 << indent() << "sMethodName" << n
<< ".pData );\n";
1374 void InterfaceType::addComprehensiveGetCppuTypeIncludes(
1375 codemaker::cppumaker::Includes
& includes
) const
1377 // The comprehensive getCppuType method always includes a line
1378 // "getCppuType( (const ::css::uno::RuntimeException*)0 );":
1379 includes
.addCppuUnotypeHxx();
1380 includes
.addRtlInstanceHxx(); // using rtl::StaticWithInit
1381 includes
.addOslMutexHxx();
1382 includes
.add("com.sun.star.uno.RuntimeException");
1385 void InterfaceType::dumpCppuAttributes(FileStream
& out
, sal_uInt32
& index
) {
1386 if (!entity_
->getDirectAttributes().empty()) {
1387 out
<< "\n" << indent()
1388 << "typelib_InterfaceAttributeTypeDescription * pAttribute = 0;\n";
1389 std::vector
< unoidl::InterfaceTypeEntity::Attribute
>::size_type n
= 0;
1390 for (std::vector
< unoidl::InterfaceTypeEntity::Attribute
>::
1391 const_iterator
i(entity_
->getDirectAttributes().begin());
1392 i
!= entity_
->getDirectAttributes().end(); ++i
)
1394 OUString
type(resolveAllTypedefs(i
->type
));
1395 out
<< indent() << "{\n";
1397 out
<< indent() << "::rtl::OUString sAttributeType" << n
<< "( \""
1398 << type
<< "\" );\n" << indent()
1399 << "::rtl::OUString sAttributeName" << n
<< "( \"" << name_
1400 << "::" << i
->name
<< "\" );\n";
1401 sal_Int32 getExcn
= dumpExceptionTypeNames(
1402 out
, "get", i
->getExceptions
, false);
1403 sal_Int32 setExcn
= dumpExceptionTypeNames(
1404 out
, "set", i
->setExceptions
, false);
1406 << ("typelib_typedescription_newExtendedInterfaceAttribute("
1409 out
<< indent() << index
++ << ", sAttributeName" << n
1410 << ".pData,\n" << indent() << "(typelib_TypeClass)"
1411 << getTypeClass(type
) << ", sAttributeType" << n
<< ".pData,\n"
1412 << indent() << "sal_" << (i
->readOnly
? "True" : "False")
1413 << ", " << getExcn
<< ", "
1414 << (getExcn
== 0 ? "0" : "the_getExceptions") << ", " << setExcn
1415 << ", " << (setExcn
== 0 ? "0" : "the_setExceptions")
1419 << ("typelib_typedescription_register("
1420 " (typelib_TypeDescription**)&pAttribute );\n");
1422 out
<< indent() << "}\n";
1426 << ("typelib_typedescription_release("
1427 " (typelib_TypeDescription*)pAttribute );\n");
1431 void InterfaceType::dumpCppuMethods(FileStream
& out
, sal_uInt32
& index
) {
1432 if (!entity_
->getDirectMethods().empty()) {
1433 out
<< "\n" << indent()
1434 << "typelib_InterfaceMethodTypeDescription * pMethod = 0;\n";
1435 std::vector
< unoidl::InterfaceTypeEntity::Method
>::size_type n
= 0;
1436 for (std::vector
< unoidl::InterfaceTypeEntity::Method
>::const_iterator
1437 i(entity_
->getDirectMethods().begin());
1438 i
!= entity_
->getDirectMethods().end(); ++i
)
1440 OUString
returnType(resolveAllTypedefs(i
->returnType
));
1441 out
<< indent() << "{\n";
1443 if (!i
->parameters
.empty()) {
1444 out
<< indent() << "typelib_Parameter_Init aParameters["
1445 << i
->parameters
.size() << "];\n";
1447 std::vector
< unoidl::InterfaceTypeEntity::Method::Parameter
>::
1449 for (std::vector
< unoidl::InterfaceTypeEntity::Method::Parameter
>::
1450 const_iterator
j(i
->parameters
.begin());
1451 j
!= i
->parameters
.end(); ++j
)
1453 OUString
type(resolveAllTypedefs(j
->type
));
1454 out
<< indent() << "::rtl::OUString sParamName" << m
<< "( \""
1455 << j
->name
<< "\" );\n" << indent()
1456 << "::rtl::OUString sParamType" << m
<< "( \"" << type
1457 << "\" );\n" << indent() << "aParameters[" << m
1458 << "].pParamName = sParamName" << m
<< ".pData;\n"
1459 << indent() << "aParameters[" << m
1460 << "].eTypeClass = (typelib_TypeClass)"
1461 << getTypeClass(type
) << ";\n" << indent() << "aParameters["
1462 << m
<< "].pTypeName = sParamType" << m
<< ".pData;\n"
1463 << indent() << "aParameters[" << m
<< "].bIn = "
1465 == (unoidl::InterfaceTypeEntity::Method::Parameter::
1467 ? "sal_False" : "sal_True")
1468 << ";\n" << indent() << "aParameters[" << m
<< "].bOut = "
1470 == (unoidl::InterfaceTypeEntity::Method::Parameter::
1472 ? "sal_False" : "sal_True")
1476 sal_Int32 excn
= dumpExceptionTypeNames(
1477 out
, "", i
->exceptions
,
1478 i
->name
!= "acquire" && i
->name
!= "release");
1479 out
<< indent() << "::rtl::OUString sReturnType" << n
<< "( \""
1480 << returnType
<< "\" );\n" << indent()
1481 << "::rtl::OUString sMethodName" << n
<< "( \"" << name_
<< "::"
1482 << i
->name
<< "\" );\n" << indent()
1483 << "typelib_typedescription_newInterfaceMethod( &pMethod,\n";
1485 out
<< indent() << index
++ << ", sal_False,\n" << indent()
1486 << "sMethodName" << n
<< ".pData,\n" << indent()
1487 << "(typelib_TypeClass)" << getTypeClass(returnType
)
1488 << ", sReturnType" << n
<< ".pData,\n" << indent()
1489 << i
->parameters
.size() << ", "
1490 << (i
->parameters
.empty() ? "0" : "aParameters") << ",\n"
1491 << indent() << excn
<< ", "
1492 << (excn
== 0 ? "0" : "the_Exceptions") << " );\n";
1495 << ("typelib_typedescription_register("
1496 " (typelib_TypeDescription**)&pMethod );\n");
1498 out
<< indent() << "}\n";
1502 << ("typelib_typedescription_release("
1503 " (typelib_TypeDescription*)pMethod );\n");
1507 void InterfaceType::dumpAttributesCppuDecl(
1508 FileStream
& out
, std::set
< OUString
> * seen
)
1511 for (std::vector
< unoidl::InterfaceTypeEntity::Attribute
>::const_iterator
1512 i(entity_
->getDirectAttributes().begin());
1513 i
!= entity_
->getDirectAttributes().end(); ++i
)
1515 if (seen
->insert(i
->type
).second
) {
1516 dumpCppuGetType(out
, i
->type
);
1518 for (std::vector
< OUString
>::const_iterator
j(
1519 i
->getExceptions
.begin());
1520 j
!= i
->getExceptions
.end(); ++j
)
1522 if (seen
->insert(*j
).second
) {
1523 dumpCppuGetType(out
, *j
);
1526 for (std::vector
< OUString
>::const_iterator
j(
1527 i
->setExceptions
.begin());
1528 j
!= i
->setExceptions
.end(); ++j
)
1530 if (seen
->insert(*j
).second
) {
1531 dumpCppuGetType(out
, *j
);
1537 void InterfaceType::dumpMethodsCppuDecl(
1538 FileStream
& out
, std::set
< OUString
> * seen
)
1541 for (std::vector
< unoidl::InterfaceTypeEntity::Method
>::const_iterator
i(
1542 entity_
->getDirectMethods().begin());
1543 i
!= entity_
->getDirectMethods().end(); ++i
)
1545 for (std::vector
< OUString
>::const_iterator
j(i
->exceptions
.begin());
1546 j
!= i
->exceptions
.end(); ++j
)
1548 if (seen
->insert(*j
).second
) {
1549 dumpCppuGetType(out
, *j
);
1555 void InterfaceType::dumpExceptionSpecification(
1556 FileStream
& out
, std::vector
< OUString
> const & exceptions
,
1557 bool runtimeException
)
1559 // Exception specifications are undesirable in production code, but make
1560 // for useful assertions in debug builds (on platforms where they are
1561 // enforced at runtime):
1562 #if !defined DBG_UTIL
1567 for (std::vector
< OUString
>::const_iterator
i(exceptions
.begin());
1568 i
!= exceptions
.end(); ++i
)
1570 if (*i
!= "com.sun.star.uno.RuntimeException") {
1574 out
<< codemaker::cpp::scopedCppName(u2b(*i
));
1578 if (runtimeException
) {
1582 out
<< "::css::uno::RuntimeException, ::std::exception";
1585 #if !defined DBG_UTIL
1590 void InterfaceType::dumpExceptionTypeName(
1591 FileStream
& out
, OUString
const & prefix
, sal_uInt32 index
,
1592 OUString
const & name
)
1594 out
<< indent() << "::rtl::OUString the_" << prefix
<< "ExceptionName"
1595 << index
<< "( \"" << name
<< "\" );\n";
1598 sal_Int32
InterfaceType::dumpExceptionTypeNames(
1599 FileStream
& out
, OUString
const & prefix
,
1600 std::vector
< OUString
> const & exceptions
, bool runtimeException
)
1602 sal_Int32 count
= 0;
1603 for (std::vector
< OUString
>::const_iterator
i(exceptions
.begin());
1604 i
!= exceptions
.end(); ++i
)
1606 if (*i
!= "com.sun.star.uno.RuntimeException") {
1607 dumpExceptionTypeName(out
, prefix
, count
++, *i
);
1610 if (runtimeException
) {
1611 dumpExceptionTypeName(
1612 out
, prefix
, count
++, "com.sun.star.uno.RuntimeException");
1615 out
<< indent() << "rtl_uString * the_" << prefix
<< "Exceptions[] = {";
1616 for (sal_Int32 i
= 0; i
!= count
; ++i
) {
1617 out
<< (i
== 0 ? " " : ", ") << "the_" << prefix
<< "ExceptionName"
1625 class ConstantGroup
: public CppuType
{
1628 rtl::Reference
< unoidl::ConstantGroupEntity
> const & entity
,
1629 OUString
const & name
, rtl::Reference
< TypeManager
> const & typeMgr
):
1630 CppuType(name
, typeMgr
), entity_(entity
)
1631 { assert(entity
.is()); }
1633 bool hasConstants() const { return !entity_
->getMembers().empty(); }
1636 virtual void dumpHFile(
1637 FileStream
& out
, codemaker::cppumaker::Includes
& includes
) SAL_OVERRIDE
;
1639 virtual void dumpHxxFile(
1640 FileStream
& out
, codemaker::cppumaker::Includes
& includes
) SAL_OVERRIDE
;
1642 virtual void dumpDeclaration(FileStream
& out
) SAL_OVERRIDE
;
1644 rtl::Reference
< unoidl::ConstantGroupEntity
> entity_
;
1647 void ConstantGroup::dumpHFile(
1648 FileStream
& out
, codemaker::cppumaker::Includes
& includes
)
1650 OUString
headerDefine(dumpHeaderDefine(out
, "HDL"));
1652 addDefaultHIncludes(includes
);
1653 includes
.dump(out
, 0);
1655 if (codemaker::cppumaker::dumpNamespaceOpen(out
, name_
, true)) {
1659 dumpDeclaration(out
);
1661 if (codemaker::cppumaker::dumpNamespaceClose(out
, name_
, true)) {
1664 out
<< "\n#endif // "<< headerDefine
<< "\n";
1667 void ConstantGroup::dumpHxxFile(
1668 FileStream
& out
, codemaker::cppumaker::Includes
&)
1670 OUString
headerDefine(dumpHeaderDefine(out
, "HPP"));
1672 codemaker::cppumaker::Includes::dumpInclude(out
, u2b(name_
), false);
1673 out
<< "\n#endif // "<< headerDefine
<< "\n";
1676 void ConstantGroup::dumpDeclaration(FileStream
& out
) {
1677 for (std::vector
< unoidl::ConstantGroupEntity::Member
>::const_iterator
i(
1678 entity_
->getMembers().begin());
1679 i
!= entity_
->getMembers().end(); ++i
)
1681 out
<< "static const ";
1682 switch (i
->value
.type
) {
1683 case unoidl::ConstantValue::TYPE_BOOLEAN
:
1684 out
<< "::sal_Bool";
1686 case unoidl::ConstantValue::TYPE_BYTE
:
1687 out
<< "::sal_Int8";
1689 case unoidl::ConstantValue::TYPE_SHORT
:
1690 out
<< "::sal_Int16";
1692 case unoidl::ConstantValue::TYPE_UNSIGNED_SHORT
:
1693 out
<< "::sal_uInt16";
1695 case unoidl::ConstantValue::TYPE_LONG
:
1696 out
<< "::sal_Int32";
1698 case unoidl::ConstantValue::TYPE_UNSIGNED_LONG
:
1699 out
<< "::sal_uInt32";
1701 case unoidl::ConstantValue::TYPE_HYPER
:
1702 out
<< "::sal_Int64";
1704 case unoidl::ConstantValue::TYPE_UNSIGNED_HYPER
:
1705 out
<< "::sal_uInt64";
1707 case unoidl::ConstantValue::TYPE_FLOAT
:
1710 case unoidl::ConstantValue::TYPE_DOUBLE
:
1714 out
<< " " << i
->name
<< " = ";
1715 switch (i
->value
.type
) {
1716 case unoidl::ConstantValue::TYPE_BOOLEAN
:
1717 out
<< (i
->value
.booleanValue
? "sal_True" : "sal_False");
1719 case unoidl::ConstantValue::TYPE_BYTE
:
1720 out
<< "(sal_Int8)" << OUString::number(i
->value
.byteValue
);
1722 case unoidl::ConstantValue::TYPE_SHORT
:
1723 out
<< "(sal_Int16)" << OUString::number(i
->value
.shortValue
);
1725 case unoidl::ConstantValue::TYPE_UNSIGNED_SHORT
:
1726 out
<< "(sal_uInt16)"
1727 << OUString::number(i
->value
.unsignedShortValue
);
1729 case unoidl::ConstantValue::TYPE_LONG
:
1730 // Avoid C++ compiler warnings about (un)signedness of literal
1732 if (i
->value
.longValue
== SAL_MIN_INT32
) {
1733 out
<< "SAL_MIN_INT32";
1735 out
<< "(sal_Int32)" << OUString::number(i
->value
.longValue
);
1738 case unoidl::ConstantValue::TYPE_UNSIGNED_LONG
:
1739 out
<< "(sal_uInt32)"
1740 << OUString::number(i
->value
.unsignedLongValue
) << "U";
1742 case unoidl::ConstantValue::TYPE_HYPER
:
1743 // Avoid C++ compiler warnings about (un)signedness of literal
1745 if (i
->value
.hyperValue
== SAL_MIN_INT64
) {
1746 out
<< "SAL_MIN_INT64";
1748 out
<< "(sal_Int64) SAL_CONST_INT64("
1749 << OUString::number(i
->value
.hyperValue
) << ")";
1752 case unoidl::ConstantValue::TYPE_UNSIGNED_HYPER
:
1753 out
<< "SAL_CONST_UINT64("
1754 << OUString::number(i
->value
.unsignedHyperValue
) << ")";
1756 case unoidl::ConstantValue::TYPE_FLOAT
:
1757 out
<< "(float)" << OUString::number(i
->value
.floatValue
);
1759 case unoidl::ConstantValue::TYPE_DOUBLE
:
1760 out
<< "(double)" << OUString::number(i
->value
.doubleValue
);
1767 void dumpTypeParameterName(FileStream
& out
, OUString
const & name
) {
1768 // Prefix all type parameters with "typeparam_" to avoid problems when a
1769 // struct member has the same name as a type parameter, as in
1770 // struct<T> { T T; };
1771 out
<< "typeparam_" << name
;
1774 class PlainStructType
: public CppuType
{
1777 rtl::Reference
< unoidl::PlainStructTypeEntity
> const & entity
,
1778 OUString
const & name
, rtl::Reference
< TypeManager
> const & typeMgr
):
1779 CppuType(name
, typeMgr
), entity_(entity
)
1780 { assert(entity
.is()); }
1783 virtual sal_uInt32
checkInheritedMemberCount() const SAL_OVERRIDE
1784 { return getTotalMemberCount(entity_
->getDirectBase()); }
1786 virtual void dumpDeclaration(FileStream
& o
) SAL_OVERRIDE
;
1788 void dumpHxxFile(FileStream
& o
, codemaker::cppumaker::Includes
& includes
) SAL_OVERRIDE
;
1790 virtual void dumpLightGetCppuType(FileStream
& out
) SAL_OVERRIDE
;
1792 virtual void dumpNormalGetCppuType(FileStream
& out
) SAL_OVERRIDE
;
1794 virtual void dumpComprehensiveGetCppuType(FileStream
& out
) SAL_OVERRIDE
;
1796 virtual void addLightGetCppuTypeIncludes(
1797 codemaker::cppumaker::Includes
& includes
) const SAL_OVERRIDE
;
1799 virtual void addNormalGetCppuTypeIncludes(
1800 codemaker::cppumaker::Includes
& includes
) const SAL_OVERRIDE
;
1802 virtual void addComprehensiveGetCppuTypeIncludes(
1803 codemaker::cppumaker::Includes
& includes
) const SAL_OVERRIDE
;
1805 bool dumpBaseMembers(
1806 FileStream
& out
, OUString
const & base
, bool withType
);
1808 sal_uInt32
getTotalMemberCount(OUString
const & base
) const;
1810 rtl::Reference
< unoidl::PlainStructTypeEntity
> entity_
;
1813 void PlainStructType::dumpDeclaration(FileStream
& out
) {
1814 out
<< "\n#ifdef SAL_W32\n# pragma pack(push, 8)\n#endif\n\n" << indent()
1815 << "struct SAL_DLLPUBLIC_RTTI " << id_
;
1816 OUString
base(entity_
->getDirectBase());
1817 if (!base
.isEmpty()) {
1818 out
<< ": public " << codemaker::cpp::scopedCppName(u2b(base
));
1822 out
<< indent() << "inline " << id_
<< "();\n";
1823 if (!entity_
->getDirectMembers().empty() || getInheritedMemberCount() > 0) {
1824 out
<< "\n" << indent() << "inline " << id_
<< "(";
1825 bool first
= !dumpBaseMembers(out
, base
, true);
1826 for (std::vector
< unoidl::PlainStructTypeEntity::Member
>::
1827 const_iterator
i(entity_
->getDirectMembers().begin());
1828 i
!= entity_
->getDirectMembers().end(); ++i
)
1833 dumpType(out
, i
->type
, true, true);
1834 out
<< " " << i
->name
<< "_";
1839 if (!entity_
->getDirectMembers().empty()) {
1841 for (std::vector
< unoidl::PlainStructTypeEntity::Member
>::
1842 const_iterator
i(entity_
->getDirectMembers().begin());
1843 i
!= entity_
->getDirectMembers().end(); ++i
)
1846 dumpType(out
, i
->type
);
1847 out
<< " " << i
->name
;
1848 if (i
== entity_
->getDirectMembers().begin() && !base
.isEmpty()
1849 && i
->type
!= "hyper" && i
->type
!= "unsigned hyper"
1850 && i
->type
!= "double")
1852 out
<< " CPPU_GCC3_ALIGN("
1853 << codemaker::cpp::scopedCppName(u2b(base
)) << ")";
1859 out
<< "};\n\n#ifdef SAL_W32\n# pragma pack(pop)\n#endif\n\n";
1862 void PlainStructType::dumpHxxFile(
1863 FileStream
& out
, codemaker::cppumaker::Includes
& includes
)
1865 OUString
headerDefine(dumpHeaderDefine(out
, "HPP"));
1867 includes
.dump(out
, &name_
);
1869 if (codemaker::cppumaker::dumpNamespaceOpen(out
, name_
, false)) {
1872 out
<< "\ninline " << id_
<< "::" << id_
<< "()\n";
1874 OUString
base(entity_
->getDirectBase());
1876 if (!base
.isEmpty()) {
1877 out
<< indent() << ": " << codemaker::cpp::scopedCppName(u2b(base
))
1881 for (std::vector
< unoidl::PlainStructTypeEntity::Member
>::const_iterator
i(
1882 entity_
->getDirectMembers().begin());
1883 i
!= entity_
->getDirectMembers().end(); ++i
)
1885 out
<< indent() << (first
? ":" : ",") << " " << i
->name
;
1886 dumpInitializer(out
, false, i
->type
);
1892 if (!entity_
->getDirectMembers().empty() || getInheritedMemberCount() > 0) {
1893 out
<< "inline " << id_
;
1894 out
<< "::" << id_
<< "(";
1895 first
= !dumpBaseMembers(out
, base
, true);
1896 for (std::vector
< unoidl::PlainStructTypeEntity::Member
>::
1897 const_iterator
i(entity_
->getDirectMembers().begin());
1898 i
!= entity_
->getDirectMembers().end(); ++i
)
1903 dumpType(out
, i
->type
, true, true);
1904 out
<< " " << i
->name
<< "_";
1910 if (!base
.isEmpty()) {
1911 out
<< indent() << ": " << codemaker::cpp::scopedCppName(u2b(base
))
1913 dumpBaseMembers(out
, base
, false);
1917 for (std::vector
< unoidl::PlainStructTypeEntity::Member
>::
1918 const_iterator
i(entity_
->getDirectMembers().begin());
1919 i
!= entity_
->getDirectMembers().end(); ++i
)
1921 out
<< indent() << (first
? ":" : ",") << " " << i
->name
<< "("
1922 << i
->name
<< "_)\n";
1928 if (codemaker::cppumaker::dumpNamespaceClose(out
, name_
, false)) {
1932 dumpGetCppuType(out
);
1933 out
<< "\n#endif // "<< headerDefine
<< "\n";
1936 void PlainStructType::dumpLightGetCppuType(FileStream
& out
) {
1937 dumpGetCppuTypePreamble(out
);
1939 << ("//TODO: On certain platforms with weak memory models, the"
1940 " following code can result in some threads observing that the_type"
1941 " points to garbage\n")
1943 << "static ::typelib_TypeDescriptionReference * the_type = 0;\n"
1944 << indent() << "if (the_type == 0) {\n";
1946 out
<< indent() << "::typelib_static_type_init(&the_type, "
1947 << getTypeClass(name_
, true) << ", \"" << name_
<< "\");\n";
1949 out
<< indent() << "}\n" << indent()
1950 << ("return *reinterpret_cast< ::css::uno::Type * >(&the_type);\n");
1951 dumpGetCppuTypePostamble(out
);
1954 void PlainStructType::dumpNormalGetCppuType(FileStream
& out
) {
1955 dumpGetCppuTypePreamble(out
);
1957 << ("//TODO: On certain platforms with weak memory models, the"
1958 " following code can result in some threads observing that the_type"
1959 " points to garbage\n")
1961 << "static ::typelib_TypeDescriptionReference * the_type = 0;\n"
1962 << indent() << "if (the_type == 0) {\n";
1965 << "::typelib_TypeDescriptionReference * the_members[] = {\n";
1967 for (std::vector
< unoidl::PlainStructTypeEntity::Member
>::const_iterator
i(
1968 entity_
->getDirectMembers().begin());
1969 i
!= entity_
->getDirectMembers().end();)
1971 out
<< indent() << "::cppu::UnoType< ";
1972 dumpType(out
, i
->type
, false, false, false, true);
1974 out
<< " >::get().getTypeLibType()"
1975 << (i
== entity_
->getDirectMembers().end() ? " };" : ",") << "\n";
1978 out
<< indent() << "::typelib_static_struct_type_init(&the_type, \""
1980 if (entity_
->getDirectBase().isEmpty()) {
1983 out
<< "::cppu::UnoType< ";
1984 dumpType(out
, entity_
->getDirectBase(), false, false, false, true);
1985 out
<< " >::get().getTypeLibType()";
1987 out
<< ", " << entity_
->getDirectMembers().size() << ", the_members, 0);\n";
1989 out
<< indent() << "}\n" << indent()
1990 << ("return *reinterpret_cast< ::css::uno::Type * >(&the_type);\n");
1991 dumpGetCppuTypePostamble(out
);
1994 void PlainStructType::dumpComprehensiveGetCppuType(FileStream
& out
) {
1995 OUString
staticTypeClass("the" + id_
+ "Type");
1996 codemaker::cppumaker::dumpNamespaceOpen(out
, name_
, false);
1997 out
<< " namespace detail {\n\n" << indent() << "struct "
1999 << " : public rtl::StaticWithInit< ::css::uno::Type *, "
2000 << staticTypeClass
<< " >\n" << indent() << "{\n";
2002 out
<< indent() << "::css::uno::Type * operator()() const\n"
2003 << indent() << "{\n";
2005 out
<< indent() << "::rtl::OUString the_name( \"" << name_
<< "\" );\n";
2006 std::map
< OUString
, sal_uInt32
> types
;
2007 std::vector
< unoidl::PlainStructTypeEntity::Member
>::size_type n
= 0;
2008 for (std::vector
< unoidl::PlainStructTypeEntity::Member
>::const_iterator
i(
2009 entity_
->getDirectMembers().begin());
2010 i
!= entity_
->getDirectMembers().end(); ++i
)
2013 std::map
< OUString
, sal_uInt32
>::value_type(
2014 i
->type
, static_cast< sal_uInt32
>(types
.size()))).
2017 dumpCppuGetType(out
, i
->type
, &name_
);
2018 // For typedefs, use the resolved type name, as there will be no
2019 // information available about the typedef itself at runtime (the
2020 // above getCppuType call will make available information about the
2021 // resolved type); no extra #include for the resolved type is
2022 // needed, as the header for the typedef includes it already:
2023 out
<< indent() << "::rtl::OUString the_tname"
2024 << static_cast< sal_uInt32
>(types
.size() - 1) << "( \""
2025 << resolveAllTypedefs(i
->type
) << "\" );\n";
2027 out
<< indent() << "::rtl::OUString the_name" << n
++ << "( \""
2028 << i
->name
<< "\" );\n";
2030 out
<< indent() << "::typelib_StructMember_Init the_members[] = {\n";
2033 for (std::vector
< unoidl::PlainStructTypeEntity::Member
>::const_iterator
i(
2034 entity_
->getDirectMembers().begin());
2035 i
!= entity_
->getDirectMembers().end();)
2037 out
<< indent() << "{ { " << getTypeClass(i
->type
, true)
2038 << ", the_tname" << types
.find(i
->type
)->second
2039 << ".pData, the_name" << n
++ << ".pData }, false }";
2041 out
<< (i
== entity_
->getDirectMembers().end() ? " };" : ",") << "\n";
2044 out
<< indent() << "::typelib_TypeDescription * the_newType = 0;\n"
2046 << "::typelib_typedescription_newStruct(&the_newType, the_name.pData, ";
2047 if (entity_
->getDirectBase().isEmpty()) {
2050 out
<< "::cppu::UnoType< ";
2051 dumpType(out
, entity_
->getDirectBase(), false, false, false, true);
2052 out
<< " >::get().getTypeLibType()";
2054 out
<< ", " << entity_
->getDirectMembers().size() << ", the_members);\n"
2055 << indent() << "::typelib_typedescription_register(&the_newType);\n"
2056 << indent() << "::typelib_typedescription_release(the_newType);\n"
2057 << indent() << "return new ::css::uno::Type("
2058 << getTypeClass(name_
) << ", the_name); // leaked\n";
2060 out
<< indent() << "}\n";
2062 out
<< indent() << "};\n";
2063 codemaker::cppumaker::dumpNamespaceClose(out
, name_
, false);
2065 dumpGetCppuTypePreamble(out
);
2066 out
<< indent() << "return *detail::" << staticTypeClass
<< "::get();\n";
2067 dumpGetCppuTypePostamble(out
);
2070 bool PlainStructType::dumpBaseMembers(
2071 FileStream
& out
, OUString
const & base
, bool withType
)
2073 bool hasMember
= false;
2074 if (!base
.isEmpty()) {
2075 rtl::Reference
< unoidl::Entity
> ent
;
2076 codemaker::UnoType::Sort sort
= m_typeMgr
->getSort(base
, &ent
);
2077 if (sort
!= codemaker::UnoType::SORT_PLAIN_STRUCT_TYPE
) {
2078 throw CannotDumpException(
2079 "plain struct type base " + base
2080 + " is not a plain struct type");
2082 rtl::Reference
< unoidl::PlainStructTypeEntity
> ent2(
2083 dynamic_cast< unoidl::PlainStructTypeEntity
* >(ent
.get()));
2088 hasMember
= dumpBaseMembers(out
, ent2
->getDirectBase(), withType
);
2089 for (std::vector
< unoidl::PlainStructTypeEntity::Member
>::
2090 const_iterator
i(ent2
->getDirectMembers().begin());
2091 i
!= ent2
->getDirectMembers().end(); ++i
)
2097 dumpType(out
, i
->type
, true, true);
2100 out
<< i
->name
<< "_";
2107 void PlainStructType::addLightGetCppuTypeIncludes(
2108 codemaker::cppumaker::Includes
& includes
) const
2111 includes
.addCppuUnotypeHxx();
2112 includes
.addSalTypesH();
2113 includes
.addTypelibTypeclassH();
2114 includes
.addTypelibTypedescriptionH();
2117 void PlainStructType::addNormalGetCppuTypeIncludes(
2118 codemaker::cppumaker::Includes
& includes
) const
2121 includes
.addCppuUnotypeHxx();
2122 includes
.addSalTypesH();
2123 includes
.addTypelibTypeclassH();
2124 includes
.addTypelibTypedescriptionH();
2127 void PlainStructType::addComprehensiveGetCppuTypeIncludes(
2128 codemaker::cppumaker::Includes
& includes
) const
2131 includes
.addCppuUnotypeHxx();
2132 includes
.addRtlInstanceHxx();
2133 includes
.addRtlUstringH();
2134 includes
.addRtlUstringHxx();
2135 includes
.addSalTypesH();
2136 includes
.addTypelibTypeclassH();
2137 includes
.addTypelibTypedescriptionH();
2140 sal_uInt32
PlainStructType::getTotalMemberCount(OUString
const & base
) const {
2141 if (base
.isEmpty()) {
2144 rtl::Reference
< unoidl::Entity
> ent
;
2145 codemaker::UnoType::Sort sort
= m_typeMgr
->getSort(base
, &ent
);
2146 if (sort
!= codemaker::UnoType::SORT_PLAIN_STRUCT_TYPE
) {
2147 throw CannotDumpException(
2148 "plain struct type base " + base
+ " is not a plain struct type");
2150 rtl::Reference
< unoidl::PlainStructTypeEntity
> ent2(
2151 dynamic_cast< unoidl::PlainStructTypeEntity
* >(ent
.get()));
2156 return getTotalMemberCount(ent2
->getDirectBase())
2157 + ent2
->getDirectMembers().size(); //TODO: overflow
2160 class PolyStructType
: public CppuType
{
2163 rtl::Reference
< unoidl::PolymorphicStructTypeTemplateEntity
> const &
2165 OUString
const & name
, rtl::Reference
< TypeManager
> const & typeMgr
):
2166 CppuType(name
, typeMgr
), entity_(entity
)
2167 { assert(entity
.is()); }
2170 virtual void dumpDeclaration(FileStream
& o
) SAL_OVERRIDE
;
2172 void dumpHxxFile(FileStream
& o
, codemaker::cppumaker::Includes
& includes
) SAL_OVERRIDE
;
2174 virtual void dumpLightGetCppuType(FileStream
& out
) SAL_OVERRIDE
;
2176 virtual void dumpNormalGetCppuType(FileStream
& out
) SAL_OVERRIDE
;
2178 virtual void dumpComprehensiveGetCppuType(FileStream
& out
) SAL_OVERRIDE
;
2180 virtual void addLightGetCppuTypeIncludes(
2181 codemaker::cppumaker::Includes
& includes
) const SAL_OVERRIDE
;
2183 virtual void addNormalGetCppuTypeIncludes(
2184 codemaker::cppumaker::Includes
& includes
) const SAL_OVERRIDE
;
2186 virtual void addComprehensiveGetCppuTypeIncludes(
2187 codemaker::cppumaker::Includes
& includes
) const SAL_OVERRIDE
;
2189 virtual bool isPolymorphic() const SAL_OVERRIDE
{ return true; }
2191 virtual void dumpTemplateHead(FileStream
& out
) const SAL_OVERRIDE
;
2193 virtual void dumpTemplateParameters(FileStream
& out
) const SAL_OVERRIDE
;
2195 rtl::Reference
< unoidl::PolymorphicStructTypeTemplateEntity
> entity_
;
2198 void PolyStructType::dumpDeclaration(FileStream
& out
) {
2199 out
<< "\n#ifdef SAL_W32\n# pragma pack(push, 8)\n#endif\n\n" << indent();
2200 dumpTemplateHead(out
);
2201 out
<< "struct SAL_DLLPUBLIC_RTTI " << id_
<< " {\n";
2203 out
<< indent() << "inline " << id_
<< "();\n";
2204 if (!entity_
->getMembers().empty()) {
2205 out
<< "\n" << indent() << "inline " << id_
<< "(";
2207 unoidl::PolymorphicStructTypeTemplateEntity::Member
>::
2208 const_iterator
i(entity_
->getMembers().begin());
2209 i
!= entity_
->getMembers().end(); ++i
)
2211 if (i
!= entity_
->getMembers().begin()) {
2214 if (i
->parameterized
) {
2215 dumpTypeParameterName(out
, i
->type
);
2218 dumpType(out
, i
->type
, true, true);
2220 out
<< " " << i
->name
<< "_";
2224 unoidl::PolymorphicStructTypeTemplateEntity::Member
>::
2225 const_iterator
i(entity_
->getMembers().begin());
2226 i
!= entity_
->getMembers().end(); ++i
)
2229 if (i
->parameterized
) {
2230 dumpTypeParameterName(out
, i
->type
);
2232 dumpType(out
, i
->type
);
2234 out
<< " " << i
->name
<< ";\n";
2238 out
<< "};\n\n#ifdef SAL_W32\n# pragma pack(pop)\n#endif\n\n";
2241 void PolyStructType::dumpHxxFile(
2242 FileStream
& out
, codemaker::cppumaker::Includes
& includes
)
2244 OUString
headerDefine(dumpHeaderDefine(out
, "HPP"));
2246 includes
.dump(out
, &name_
);
2248 if (codemaker::cppumaker::dumpNamespaceOpen(out
, name_
, false)) {
2252 dumpTemplateHead(out
);
2253 out
<< "inline " << id_
;
2254 dumpTemplateParameters(out
);
2255 out
<< "::" << id_
<< "()\n";
2257 for (std::vector
< unoidl::PolymorphicStructTypeTemplateEntity::Member
>::
2258 const_iterator
i(entity_
->getMembers().begin());
2259 i
!= entity_
->getMembers().end(); ++i
)
2261 out
<< indent() << (i
== entity_
->getMembers().begin() ? ":" : ",")
2263 dumpInitializer(out
, i
->parameterized
, i
->type
);
2268 if (!entity_
->getMembers().empty()) {
2269 dumpTemplateHead(out
);
2270 out
<< "inline " << id_
;
2271 dumpTemplateParameters(out
);
2272 out
<< "::" << id_
<< "(";
2274 unoidl::PolymorphicStructTypeTemplateEntity::Member
>::
2275 const_iterator
i(entity_
->getMembers().begin());
2276 i
!= entity_
->getMembers().end(); ++i
)
2278 if (i
!= entity_
->getMembers().begin()) {
2281 if (i
->parameterized
) {
2282 dumpTypeParameterName(out
, i
->type
);
2285 dumpType(out
, i
->type
, true, true);
2287 out
<< " " << i
->name
<< "_";
2292 unoidl::PolymorphicStructTypeTemplateEntity::Member
>::
2293 const_iterator
i(entity_
->getMembers().begin());
2294 i
!= entity_
->getMembers().end(); ++i
)
2296 out
<< indent() << (i
== entity_
->getMembers().begin() ? ":" : ",")
2297 << " " << i
->name
<< "(" << i
->name
<< "_)\n";
2300 out
<< "{\n}\n\n" << indent();
2301 dumpTemplateHead(out
);
2302 out
<< "\n" << indent() << "inline " << id_
;
2303 dumpTemplateParameters(out
);
2304 out
<< "\n" << indent() << "make_" << id_
<< "(";
2306 unoidl::PolymorphicStructTypeTemplateEntity::Member
>::
2307 const_iterator
i(entity_
->getMembers().begin());
2308 i
!= entity_
->getMembers().end(); ++i
)
2310 if (i
!= entity_
->getMembers().begin()) {
2313 if (i
->parameterized
) {
2314 dumpTypeParameterName(out
, i
->type
);
2317 dumpType(out
, i
->type
, true, true);
2319 out
<< " " << i
->name
<< "_";
2321 out
<< ")\n" << indent() << "{\n";
2323 out
<< indent() << "return " << id_
;
2324 dumpTemplateParameters(out
);
2327 unoidl::PolymorphicStructTypeTemplateEntity::Member
>::
2328 const_iterator
i(entity_
->getMembers().begin());
2329 i
!= entity_
->getMembers().end(); ++i
)
2331 if (i
!= entity_
->getMembers().begin()) {
2334 out
<< i
->name
<< "_";
2338 out
<< indent() << "}\n\n";
2340 if (codemaker::cppumaker::dumpNamespaceClose(out
, name_
, false)) {
2344 dumpGetCppuType(out
);
2345 out
<< "\n#endif // "<< headerDefine
<< "\n";
2348 void PolyStructType::dumpLightGetCppuType(FileStream
& out
) {
2349 dumpGetCppuTypePreamble(out
);
2351 << ("//TODO: On certain platforms with weak memory models, the"
2352 " following code can result in some threads observing that the_type"
2353 " points to garbage\n")
2355 << "static ::typelib_TypeDescriptionReference * the_type = 0;\n"
2356 << indent() << "if (the_type == 0) {\n";
2358 out
<< indent() << "::rtl::OStringBuffer the_buffer(\"" << name_
2360 for (std::vector
< OUString
>::const_iterator
i(
2361 entity_
->getTypeParameters().begin());
2362 i
!= entity_
->getTypeParameters().end();)
2365 << ("the_buffer.append(::rtl::OUStringToOString("
2366 "::cppu::getTypeFavourChar(static_cast< ");
2367 dumpTypeParameterName(out
, *i
);
2368 out
<< " * >(0)).getTypeName(), RTL_TEXTENCODING_UTF8));\n";
2370 if (i
!= entity_
->getTypeParameters().end()) {
2371 out
<< indent() << "the_buffer.append(',');\n";
2374 out
<< indent() << "the_buffer.append('>');\n" << indent()
2375 << "::typelib_static_type_init(&the_type, " << getTypeClass(name_
, true)
2376 << ", the_buffer.getStr());\n";
2378 out
<< indent() << "}\n" << indent()
2379 << ("return *reinterpret_cast< ::css::uno::Type * >(&the_type);\n");
2380 dumpGetCppuTypePostamble(out
);
2383 void PolyStructType::dumpNormalGetCppuType(FileStream
& out
) {
2384 dumpGetCppuTypePreamble(out
);
2386 << ("//TODO: On certain platforms with weak memory models, the"
2387 " following code can result in some threads observing that the_type"
2388 " points to garbage\n")
2390 << "static ::typelib_TypeDescriptionReference * the_type = 0;\n"
2391 << indent() << "if (the_type == 0) {\n";
2393 out
<< indent() << "::rtl::OStringBuffer the_buffer(\"" << name_
2395 for (std::vector
< OUString
>::const_iterator
i(
2396 entity_
->getTypeParameters().begin());
2397 i
!= entity_
->getTypeParameters().end();)
2400 << ("the_buffer.append(::rtl::OUStringToOString("
2401 "::cppu::getTypeFavourChar(static_cast< ");
2402 dumpTypeParameterName(out
, *i
);
2403 out
<< " * >(0)).getTypeName(), RTL_TEXTENCODING_UTF8));\n";
2405 if (i
!= entity_
->getTypeParameters().end()) {
2406 out
<< indent() << "the_buffer.append(',');\n";
2409 out
<< indent() << "the_buffer.append('>');\n" << indent()
2410 << "::typelib_TypeDescriptionReference * the_members[] = {\n";
2412 for (std::vector
< unoidl::PolymorphicStructTypeTemplateEntity::Member
>::
2413 const_iterator
i(entity_
->getMembers().begin());
2414 i
!= entity_
->getMembers().end();)
2417 if (i
->parameterized
) {
2418 out
<< "::cppu::getTypeFavourChar(static_cast< ";
2419 dumpTypeParameterName(out
, i
->type
);
2422 out
<< "::cppu::UnoType< ";
2423 dumpType(out
, i
->type
, false, false, false, true);
2427 out
<< ".getTypeLibType()"
2428 << (i
== entity_
->getMembers().end() ? " };" : ",") << "\n";
2431 out
<< indent() << "static ::sal_Bool const the_parameterizedTypes[] = { ";
2432 for (std::vector
< unoidl::PolymorphicStructTypeTemplateEntity::Member
>::
2433 const_iterator
i(entity_
->getMembers().begin());
2434 i
!= entity_
->getMembers().end(); ++i
)
2436 if (i
!= entity_
->getMembers().begin()) {
2439 out
<< (i
->parameterized
? "true" : "false");
2441 out
<< " };\n" << indent()
2442 << ("::typelib_static_struct_type_init(&the_type, the_buffer.getStr(),"
2444 << entity_
->getMembers().size()
2445 << ", the_members, the_parameterizedTypes);\n";
2447 out
<< indent() << "}\n" << indent()
2448 << ("return *reinterpret_cast< ::css::uno::Type * >("
2450 dumpGetCppuTypePostamble(out
);
2453 void PolyStructType::dumpComprehensiveGetCppuType(FileStream
& out
) {
2454 out
<< "namespace cppu { namespace detail {\n\n" << indent();
2455 dumpTemplateHead(out
);
2456 OUString
staticTypeClass("the" + id_
+ "Type");
2457 out
<< "struct " << staticTypeClass
2458 << " : public rtl::StaticWithInit< ::css::uno::Type *, "
2460 dumpTemplateParameters(out
);
2461 out
<< " >\n" << indent() << "{\n";
2463 out
<< indent() << "::css::uno::Type * operator()() const\n"
2464 << indent() << "{\n";
2466 out
<< indent() << "::rtl::OUStringBuffer the_buffer;\n" << indent()
2467 << "the_buffer.append(\"" << name_
<< "<\");\n";
2468 for (std::vector
< OUString
>::const_iterator
i(
2469 entity_
->getTypeParameters().begin());
2470 i
!= entity_
->getTypeParameters().end();)
2473 << "the_buffer.append(::cppu::getTypeFavourChar(static_cast< ";
2474 dumpTypeParameterName(out
, *i
);
2475 out
<< " * >(0)).getTypeName());\n";
2477 if (i
!= entity_
->getTypeParameters().end()) {
2479 << ("the_buffer.append("
2480 "static_cast< ::sal_Unicode >(','));\n");
2483 out
<< indent() << "the_buffer.append(static_cast< ::sal_Unicode >('>'));\n"
2485 << "::rtl::OUString the_name(the_buffer.makeStringAndClear());\n";
2486 std::map
< OUString
, sal_uInt32
> parameters
;
2487 std::map
< OUString
, sal_uInt32
> types
;
2488 std::vector
< unoidl::PolymorphicStructTypeTemplateEntity::Member
>::
2490 for (std::vector
< unoidl::PolymorphicStructTypeTemplateEntity::Member
>::
2491 const_iterator
i(entity_
->getMembers().begin());
2492 i
!= entity_
->getMembers().end(); ++i
)
2494 if (i
->parameterized
) {
2495 if (parameters
.insert(
2496 std::map
< OUString
, sal_uInt32
>::value_type(
2497 i
->type
, static_cast< sal_uInt32
>(parameters
.size()))).
2500 sal_uInt32 k
= static_cast< sal_uInt32
>(parameters
.size() - 1);
2502 << "::css::uno::Type const & the_ptype" << k
2503 << " = ::cppu::getTypeFavourChar(static_cast< ";
2504 dumpTypeParameterName(out
, i
->type
);
2505 out
<< " * >(0));\n" << indent()
2506 << "::typelib_TypeClass the_pclass" << k
2507 << " = (::typelib_TypeClass) the_ptype" << k
2508 << ".getTypeClass();\n" << indent()
2509 << "::rtl::OUString the_pname" << k
<< "(the_ptype" << k
2510 << ".getTypeName());\n";
2512 } else if (types
.insert(
2513 std::map
< OUString
, sal_uInt32
>::value_type(
2514 i
->type
, static_cast< sal_uInt32
>(types
.size()))).
2517 dumpCppuGetType(out
, i
->type
, &name_
);
2518 // For typedefs, use the resolved type name, as there will be no
2519 // information available about the typedef itself at runtime (the
2520 // above getCppuType call will make available information about the
2521 // resolved type); no extra #include for the resolved type is
2522 // needed, as the header for the typedef includes it already:
2523 out
<< indent() << "::rtl::OUString the_tname"
2524 << static_cast< sal_uInt32
>(types
.size() - 1) << "( \""
2525 << resolveAllTypedefs(i
->type
) << "\" );\n";
2527 out
<< indent() << "::rtl::OUString the_name" << n
++ << "( \""
2528 << i
->name
<< "\" );\n";
2530 out
<< indent() << "::typelib_StructMember_Init the_members[] = {\n";
2533 for (std::vector
< unoidl::PolymorphicStructTypeTemplateEntity::Member
>::
2534 const_iterator
i(entity_
->getMembers().begin());
2535 i
!= entity_
->getMembers().end();)
2537 out
<< indent() << "{ { ";
2538 if (i
->parameterized
) {
2539 sal_uInt32 k
= parameters
.find(i
->type
)->second
;
2540 out
<< "the_pclass" << k
<< ", the_pname" << k
<< ".pData";
2542 out
<< getTypeClass(i
->type
, true) << ", the_tname"
2543 << types
.find(i
->type
)->second
<< ".pData";
2545 out
<< ", the_name" << n
++ << ".pData }, "
2546 << (i
->parameterized
? "true" : "false") << " }";
2548 out
<< (i
== entity_
->getMembers().end() ? " };" : ",") << "\n";
2551 out
<< indent() << "::typelib_TypeDescription * the_newType = 0;\n";
2553 << ("::typelib_typedescription_newStruct(&the_newType, the_name.pData,"
2555 << entity_
->getMembers().size() << ", the_members);\n" << indent()
2556 << "::typelib_typedescription_register(&the_newType);\n" << indent()
2557 << "::typelib_typedescription_release(the_newType);\n" << indent()
2558 << "return new ::css::uno::Type(" << getTypeClass(name_
)
2559 << ", the_name); // leaked\n";
2561 out
<< indent() << "}\n";
2563 out
<< indent() << "};\n } }\n\n";
2564 dumpGetCppuTypePreamble(out
);
2565 out
<< indent() << "return *detail::" << staticTypeClass
;
2566 dumpTemplateParameters(out
);
2567 out
<< "::get();\n";
2568 dumpGetCppuTypePostamble(out
);
2571 void PolyStructType::addLightGetCppuTypeIncludes(
2572 codemaker::cppumaker::Includes
& includes
) const
2575 includes
.addCppuUnotypeHxx();
2576 includes
.addSalTypesH();
2577 includes
.addTypelibTypeclassH();
2578 includes
.addTypelibTypedescriptionH();
2579 includes
.addRtlStrbufHxx();
2580 includes
.addRtlTextencH();
2581 includes
.addRtlUstringHxx();
2584 void PolyStructType::addNormalGetCppuTypeIncludes(
2585 codemaker::cppumaker::Includes
& includes
) const
2588 includes
.addCppuUnotypeHxx();
2589 includes
.addSalTypesH();
2590 includes
.addTypelibTypeclassH();
2591 includes
.addTypelibTypedescriptionH();
2592 includes
.addRtlStrbufHxx();
2593 includes
.addRtlTextencH();
2594 includes
.addRtlUstringHxx();
2597 void PolyStructType::addComprehensiveGetCppuTypeIncludes(
2598 codemaker::cppumaker::Includes
& includes
) const
2601 includes
.addCppuUnotypeHxx();
2602 includes
.addRtlInstanceHxx();
2603 includes
.addRtlUstringH();
2604 includes
.addRtlUstringHxx();
2605 includes
.addSalTypesH();
2606 includes
.addTypelibTypeclassH();
2607 includes
.addTypelibTypedescriptionH();
2608 includes
.addRtlStringH();
2609 includes
.addRtlUstrbufHxx();
2612 void PolyStructType::dumpTemplateHead(FileStream
& out
) const {
2613 out
<< "template< ";
2614 for (std::vector
< OUString
>::const_iterator
i(
2615 entity_
->getTypeParameters().begin());
2616 i
!= entity_
->getTypeParameters().end(); ++i
)
2618 if (i
!= entity_
->getTypeParameters().begin()) {
2622 dumpTypeParameterName(out
, *i
);
2627 void PolyStructType::dumpTemplateParameters(FileStream
& out
) const {
2629 for (std::vector
< OUString
>::const_iterator
i(
2630 entity_
->getTypeParameters().begin());
2631 i
!= entity_
->getTypeParameters().end(); ++i
)
2633 if (i
!= entity_
->getTypeParameters().begin()) {
2636 dumpTypeParameterName(out
, *i
);
2641 OUString
typeToIdentifier(OUString
const & name
) {
2643 OUString
n(b2u(codemaker::UnoType::decompose(u2b(name
), &k
)));
2645 for (sal_Int32 i
= 0; i
!= k
; ++i
) {
2649 b
.replace(' ', '_');
2650 b
.replace(',', '_');
2651 b
.replace('.', '_');
2652 b
.replace('<', '_');
2653 b
.replace('>', '_');
2654 return b
.makeStringAndClear();
2657 class ExceptionType
: public CppuType
{
2660 rtl::Reference
< unoidl::ExceptionTypeEntity
> const & entity
,
2661 OUString
const & name
, rtl::Reference
< TypeManager
> const & typeMgr
):
2662 CppuType(name
, typeMgr
), entity_(entity
)
2663 { assert(entity
.is()); }
2666 virtual void dumpHxxFile(
2667 FileStream
& out
, codemaker::cppumaker::Includes
& includes
) SAL_OVERRIDE
;
2669 virtual void addComprehensiveGetCppuTypeIncludes(
2670 codemaker::cppumaker::Includes
& includes
) const SAL_OVERRIDE
;
2672 virtual void dumpLightGetCppuType(FileStream
& out
) SAL_OVERRIDE
;
2674 virtual void dumpNormalGetCppuType(FileStream
& out
) SAL_OVERRIDE
;
2676 virtual void dumpComprehensiveGetCppuType(FileStream
& out
) SAL_OVERRIDE
;
2678 virtual sal_uInt32
checkInheritedMemberCount() const SAL_OVERRIDE
2679 { return getTotalMemberCount(entity_
->getDirectBase()); }
2681 virtual void dumpDeclaration(FileStream
& out
) SAL_OVERRIDE
;
2683 bool dumpBaseMembers(
2684 FileStream
& out
, OUString
const & base
, bool withType
,
2685 bool eligibleForDefaults
);
2687 sal_uInt32
getTotalMemberCount(OUString
const & base
) const;
2689 rtl::Reference
< unoidl::ExceptionTypeEntity
> entity_
;
2692 void ExceptionType::addComprehensiveGetCppuTypeIncludes(
2693 codemaker::cppumaker::Includes
& includes
) const
2695 includes
.addCppuUnotypeHxx();
2696 includes
.addRtlInstanceHxx(); // using rtl::StaticWithInit
2699 void ExceptionType::dumpHxxFile(
2700 FileStream
& out
, codemaker::cppumaker::Includes
& includes
)
2702 OUString
headerDefine(dumpHeaderDefine(out
, "HPP"));
2704 addDefaultHxxIncludes(includes
);
2705 includes
.dump(out
, &name_
);
2707 if (codemaker::cppumaker::dumpNamespaceOpen(out
, name_
, false)) {
2710 out
<< "\ninline " << id_
<< "::" << id_
<< "()\n";
2712 OUString
base(entity_
->getDirectBase());
2714 if (!base
.isEmpty()) {
2715 out
<< indent() << ": " << codemaker::cpp::scopedCppName(u2b(base
))
2719 for (std::vector
< unoidl::ExceptionTypeEntity::Member
>::const_iterator
i(
2720 entity_
->getDirectMembers().begin());
2721 i
!= entity_
->getDirectMembers().end(); ++i
)
2723 out
<< indent() << (first
? ":" : ",") << " ";
2725 dumpInitializer(out
, false, i
->type
);
2731 if (!m_cppuTypeDynamic
) {
2734 dumpCppuGetType(out
, name_
);
2740 if (!entity_
->getDirectMembers().empty() || getInheritedMemberCount() > 0) {
2741 out
<< indent() << "inline " << id_
<< "::" << id_
<< "(";
2742 first
= !dumpBaseMembers(out
, base
, true, false);
2743 for (std::vector
< unoidl::ExceptionTypeEntity::Member
>::const_iterator
2744 i(entity_
->getDirectMembers().begin());
2745 i
!= entity_
->getDirectMembers().end(); ++i
)
2750 dumpType(out
, i
->type
, true, true);
2751 out
<< " " << i
->name
<< "_";
2757 if (!base
.isEmpty()) {
2758 out
<< indent() << ": " << codemaker::cpp::scopedCppName(u2b(base
))
2760 dumpBaseMembers(out
, base
, false, false);
2764 for (std::vector
< unoidl::ExceptionTypeEntity::Member
>::const_iterator
2765 i(entity_
->getDirectMembers().begin());
2766 i
!= entity_
->getDirectMembers().end(); ++i
)
2768 out
<< indent() << (first
? ":" : ",") << " " << i
->name
<< "("
2769 << i
->name
<< "_)\n";
2774 if (!m_cppuTypeDynamic
) {
2777 dumpCppuGetType(out
, name_
);
2784 out
<< indent() << id_
<< "::" << id_
<< "(" << id_
2785 << " const & the_other)";
2787 if (!base
.isEmpty()) {
2788 out
<< ": " << codemaker::cpp::scopedCppName(u2b(base
))
2792 for (std::vector
< unoidl::ExceptionTypeEntity::Member
>::const_iterator
i(
2793 entity_
->getDirectMembers().begin());
2794 i
!= entity_
->getDirectMembers().end(); ++i
)
2796 out
<< (first
? ":" : ",") << " " << i
->name
<< "(the_other." << i
->name
2800 out
<< indent() << " {}\n\n" << indent() << id_
<< "::~" << id_
2801 << "() {}\n\n" << indent() << id_
<< " & " << id_
<< "::operator =("
2802 << id_
<< " const & the_other) {\n";
2805 << ("//TODO: Just like its implicitly-defined counterpart, this"
2806 " function definition is not exception-safe\n");
2807 if (!base
.isEmpty()) {
2808 out
<< indent() << codemaker::cpp::scopedCppName(u2b(base
))
2809 << "::operator =(the_other);\n";
2811 for (std::vector
< unoidl::ExceptionTypeEntity::Member
>::const_iterator
i(
2812 entity_
->getDirectMembers().begin());
2813 i
!= entity_
->getDirectMembers().end(); ++i
)
2815 out
<< indent() << i
->name
<< " = the_other." << i
->name
<< ";\n";
2817 out
<< indent() << "return *this;\n";
2819 out
<< indent() << "}\n\n";
2820 if (codemaker::cppumaker::dumpNamespaceClose(out
, name_
, false)) {
2824 dumpGetCppuType(out
);
2825 out
<< "\n#endif // "<< headerDefine
<< "\n";
2828 void ExceptionType::dumpLightGetCppuType(FileStream
& out
) {
2829 dumpGetCppuTypePreamble(out
);
2831 << "static typelib_TypeDescriptionReference * the_type = 0;\n"
2832 << indent() << "if ( !the_type )\n" << indent() << "{\n";
2834 out
<< indent() << "typelib_static_type_init( &the_type, "
2835 << getTypeClass(name_
, true) << ", \"" << name_
<< "\" );\n";
2837 out
<< indent() << "}\n" << indent()
2838 << ("return * reinterpret_cast< ::css::uno::Type * >("
2840 dumpGetCppuTypePostamble(out
);
2843 void ExceptionType::dumpNormalGetCppuType(FileStream
& out
) {
2844 dumpGetCppuTypePreamble(out
);
2846 << "static typelib_TypeDescriptionReference * the_type = 0;\n"
2847 << indent() << "if ( !the_type )\n" << indent() << "{\n";
2849 OUString
base(entity_
->getDirectBase());
2850 bool baseException
= false;
2851 if (!base
.isEmpty()) {
2852 if (base
== "com.sun.star.uno.Exception") {
2853 baseException
= true;
2856 << ("const ::css::uno::Type& rBaseType ="
2857 " ::cppu::UnoType< ");
2858 dumpType(out
, base
, true, false, false, true);
2859 out
<< " >::get();\n\n";
2862 if (!entity_
->getDirectMembers().empty()) {
2863 out
<< indent() << "typelib_TypeDescriptionReference * aMemberRefs["
2864 << entity_
->getDirectMembers().size() << "];\n";
2865 std::set
< OUString
> seen
;
2866 std::vector
< unoidl::ExceptionTypeEntity::Member
>::size_type n
= 0;
2867 for (std::vector
< unoidl::ExceptionTypeEntity::Member
>::const_iterator
2868 i(entity_
->getDirectMembers().begin());
2869 i
!= entity_
->getDirectMembers().end(); ++i
)
2871 OUString
type(resolveAllTypedefs(i
->type
));
2872 OUString
modType(typeToIdentifier(type
));
2873 if (seen
.insert(type
).second
) {
2875 << "const ::css::uno::Type& rMemberType_"
2876 << modType
<< " = ::cppu::UnoType< ";
2877 dumpType(out
, type
, false, false, false, true);
2878 out
<< " >::get();\n";
2880 out
<< indent() << "aMemberRefs[" << n
++ << "] = rMemberType_"
2881 << modType
<< ".getTypeLibType();\n";
2885 out
<< indent() << "typelib_static_compound_type_init( &the_type, "
2886 << getTypeClass(name_
, true) << ", \"" << name_
<< "\", ";
2887 if (baseException
) {
2888 out
<< ("* ::typelib_static_type_getByTypeClass("
2889 " typelib_TypeClass_EXCEPTION )");
2890 } else if (base
.isEmpty()) {
2893 out
<< "rBaseType.getTypeLibType()";
2895 out
<< ", " << entity_
->getDirectMembers().size() << ", "
2896 << (entity_
->getDirectMembers().empty() ? "0" : "aMemberRefs")
2899 out
<< indent() << "}\n" << indent()
2900 << ("return * reinterpret_cast< const ::css::uno::Type * >("
2902 dumpGetCppuTypePostamble(out
);
2905 void ExceptionType::dumpComprehensiveGetCppuType(FileStream
& out
) {
2906 codemaker::cppumaker::dumpNamespaceOpen(out
, name_
, false);
2907 out
<< " namespace detail {\n\n";
2908 OUString
staticTypeClass("the" + id_
+ "Type");
2909 out
<< indent() << "struct " << staticTypeClass
2910 << " : public rtl::StaticWithInit< ::css::uno::Type *, "
2911 << staticTypeClass
<< " >\n" << indent() << "{\n";
2913 out
<< indent() << "::css::uno::Type * operator()() const\n"
2914 << indent() << "{\n";
2916 out
<< indent() << "::rtl::OUString sTypeName( \"" << name_
<< "\" );\n\n"
2917 << indent() << "// Start inline typedescription generation\n"
2918 << indent() << "typelib_TypeDescription * pTD = 0;\n";
2919 OUString
base(entity_
->getDirectBase());
2920 if (!base
.isEmpty()) {
2922 << ("const ::css::uno::Type& rSuperType ="
2923 " ::cppu::UnoType< ");
2924 dumpType(out
, base
, false, false, false, true);
2925 out
<< " >::get();\n";
2927 std::set
< OUString
> seen
;
2928 for (std::vector
< unoidl::ExceptionTypeEntity::Member
>::const_iterator
i(
2929 entity_
->getDirectMembers().begin());
2930 i
!= entity_
->getDirectMembers().end(); ++i
)
2932 if (seen
.insert(i
->type
).second
) {
2933 dumpCppuGetType(out
, i
->type
);
2936 if (!entity_
->getDirectMembers().empty()) {
2937 out
<< "\n" << indent() << "typelib_CompoundMember_Init aMembers["
2938 << entity_
->getDirectMembers().size() << "];\n";
2939 std::vector
< unoidl::ExceptionTypeEntity::Member
>::size_type n
= 0;
2940 for (std::vector
< unoidl::ExceptionTypeEntity::Member
>::const_iterator
2941 i(entity_
->getDirectMembers().begin());
2942 i
!= entity_
->getDirectMembers().end(); ++i
)
2944 OUString
type(resolveAllTypedefs(i
->type
));
2945 out
<< indent() << "::rtl::OUString sMemberType" << n
<< "( \""
2946 << type
<< "\" );\n" << indent()
2947 << "::rtl::OUString sMemberName" << n
<< "( \"" << i
->name
2948 << "\" );\n" << indent() << "aMembers[" << n
2949 << "].eTypeClass = (typelib_TypeClass)" << getTypeClass(type
)
2950 << ";\n" << indent() << "aMembers[" << n
2951 << "].pTypeName = sMemberType" << n
<< ".pData;\n" << indent()
2952 << "aMembers[" << n
<< "].pMemberName = sMemberName" << n
2957 out
<< "\n" << indent() << "typelib_typedescription_new(\n";
2959 out
<< indent() << "&pTD,\n" << indent() << "(typelib_TypeClass)"
2960 << getTypeClass(name_
) << ", sTypeName.pData,\n" << indent()
2961 << (base
.isEmpty() ? "0" : "rSuperType.getTypeLibType()") << ",\n"
2962 << indent() << entity_
->getDirectMembers().size() << ",\n" << indent()
2963 << (entity_
->getDirectMembers().empty() ? "0" : "aMembers")
2967 << ("typelib_typedescription_register( (typelib_TypeDescription**)&pTD"
2969 << indent() << "typelib_typedescription_release( pTD );\n" << indent()
2970 << "// End inline typedescription generation\n\n" << indent()
2971 << "return new ::css::uno::Type( " << getTypeClass(name_
)
2972 << ", sTypeName ); // leaked\n";
2974 out
<< indent() << "}\n";
2976 out
<< indent() << "};\n\n";
2977 codemaker::cppumaker::dumpNamespaceClose(out
, name_
, false);
2979 dumpGetCppuTypePreamble(out
);
2980 out
<< indent() << "return *detail::" << staticTypeClass
<< "::get();\n";
2981 dumpGetCppuTypePostamble(out
);
2984 void ExceptionType::dumpDeclaration(FileStream
& out
) {
2985 out
<< "\nclass CPPU_GCC_DLLPUBLIC_EXPORT " << id_
;
2986 OUString
base(entity_
->getDirectBase());
2987 if (!base
.isEmpty()) {
2988 out
<< " : public " << codemaker::cpp::scopedCppName(u2b(base
));
2990 out
<< "\n{\npublic:\n";
2992 out
<< indent() << "inline CPPU_GCC_DLLPRIVATE " << id_
2994 if (!entity_
->getDirectMembers().empty() || getInheritedMemberCount() > 0) {
2995 out
<< indent() << "inline CPPU_GCC_DLLPRIVATE " << id_
<< "(";
2996 bool eligibleForDefaults
= entity_
->getDirectMembers().empty();
2997 bool first
= !dumpBaseMembers(out
, base
, true, eligibleForDefaults
);
2998 for (std::vector
< unoidl::ExceptionTypeEntity::Member
>::const_iterator
2999 i(entity_
->getDirectMembers().begin());
3000 i
!= entity_
->getDirectMembers().end(); ++i
)
3005 dumpType(out
, i
->type
, true, true);
3006 out
<< " " << i
->name
<< "_";
3011 out
<< indent() << "inline CPPU_GCC_DLLPRIVATE " << id_
<< "(" << id_
3012 << " const &);\n\n" << indent() << "inline CPPU_GCC_DLLPRIVATE ~"
3013 << id_
<< "();\n\n" << indent() << "inline CPPU_GCC_DLLPRIVATE " << id_
3014 << " & operator =(" << id_
<< " const &);\n\n";
3015 for (std::vector
< unoidl::ExceptionTypeEntity::Member
>::const_iterator
i(
3016 entity_
->getDirectMembers().begin());
3017 i
!= entity_
->getDirectMembers().end(); ++i
)
3020 dumpType(out
, i
->type
);
3021 out
<< " " << i
->name
;
3022 if (i
== entity_
->getDirectMembers().begin() && !base
.isEmpty()
3023 && i
->type
!= "hyper" && i
->type
!= "unsigned hyper"
3024 && i
->type
!= "double")
3026 out
<< " CPPU_GCC3_ALIGN( "
3027 << codemaker::cpp::scopedCppName(u2b(base
)) << " )";
3035 bool ExceptionType::dumpBaseMembers(
3036 FileStream
& out
, OUString
const & base
, bool withType
, bool eligibleForDefaults
)
3038 bool hasMember
= false;
3039 if (!base
.isEmpty()) {
3040 rtl::Reference
< unoidl::Entity
> ent
;
3041 codemaker::UnoType::Sort sort
= m_typeMgr
->getSort(base
, &ent
);
3042 if (sort
!= codemaker::UnoType::SORT_EXCEPTION_TYPE
) {
3043 throw CannotDumpException(
3044 "exception type base " + base
+ " is not an exception type");
3046 rtl::Reference
< unoidl::ExceptionTypeEntity
> ent2(
3047 dynamic_cast< unoidl::ExceptionTypeEntity
* >(ent
.get()));
3052 hasMember
= dumpBaseMembers( out
, ent2
->getDirectBase(), withType
,
3053 eligibleForDefaults
&& ent2
->getDirectMembers().empty() );
3054 int memberCount
= 0;
3055 for (std::vector
< unoidl::ExceptionTypeEntity::Member
>::const_iterator
3056 i(ent2
->getDirectMembers().begin());
3057 i
!= ent2
->getDirectMembers().end(); ++i
, ++memberCount
)
3063 dumpType(out
, i
->type
, true, true);
3066 out
<< i
->name
<< "_";
3067 // We want to provide a default parameter value for uno::Exception subtype
3068 // constructors, since most of the time we don't pass a Context object in to the exception
3070 if (eligibleForDefaults
3071 && base
== "com.sun.star.uno.Exception"
3073 && i
->name
== "Context"
3074 && i
->type
== "com.sun.star.uno.XInterface") {
3075 out
<< " = ::css::uno::Reference< ::css::uno::XInterface >()";
3083 sal_uInt32
ExceptionType::getTotalMemberCount(OUString
const & base
) const {
3084 if (base
.isEmpty()) {
3087 rtl::Reference
< unoidl::Entity
> ent
;
3088 codemaker::UnoType::Sort sort
= m_typeMgr
->getSort(base
, &ent
);
3089 if (sort
!= codemaker::UnoType::SORT_EXCEPTION_TYPE
) {
3090 throw CannotDumpException(
3091 "exception type base " + base
+ " is not an exception type");
3093 unoidl::ExceptionTypeEntity
& ent2(
3094 dynamic_cast< unoidl::ExceptionTypeEntity
&>(*ent
.get()));
3095 return getTotalMemberCount(ent2
.getDirectBase())
3096 + ent2
.getDirectMembers().size(); //TODO: overflow
3099 class EnumType
: public CppuType
{
3102 rtl::Reference
< unoidl::EnumTypeEntity
> const & entity
,
3103 OUString
const & name
, rtl::Reference
< TypeManager
> const & typeMgr
):
3104 CppuType(name
, typeMgr
), entity_(entity
)
3105 { assert(entity
.is()); }
3108 virtual void dumpDeclaration(FileStream
& o
) SAL_OVERRIDE
;
3110 virtual void addComprehensiveGetCppuTypeIncludes(
3111 codemaker::cppumaker::Includes
& includes
) const SAL_OVERRIDE
;
3113 void dumpHxxFile(FileStream
& o
, codemaker::cppumaker::Includes
& includes
) SAL_OVERRIDE
;
3115 void dumpNormalGetCppuType(FileStream
& o
) SAL_OVERRIDE
;
3116 void dumpComprehensiveGetCppuType(FileStream
& o
) SAL_OVERRIDE
;
3118 rtl::Reference
< unoidl::EnumTypeEntity
> entity_
;
3121 void EnumType::addComprehensiveGetCppuTypeIncludes(
3122 codemaker::cppumaker::Includes
& includes
) const
3124 includes
.addCppuUnotypeHxx();
3125 includes
.addRtlInstanceHxx(); // using rtl::StaticWithInit
3128 void EnumType::dumpDeclaration(FileStream
& o
)
3130 o
<< "\nenum SAL_DLLPUBLIC_RTTI " << id_
<< "\n{\n";
3133 for (std::vector
< unoidl::EnumTypeEntity::Member
>::const_iterator
i(
3134 entity_
->getMembers().begin());
3135 i
!= entity_
->getMembers().end(); ++i
)
3137 o
<< indent() << id_
<< "_" << u2b(i
->name
) << " = " << i
->value
3141 o
<< indent() << id_
<< "_MAKE_FIXED_SIZE = SAL_MAX_ENUM\n";
3147 void EnumType::dumpHxxFile(
3148 FileStream
& o
, codemaker::cppumaker::Includes
& includes
)
3150 OUString
headerDefine(dumpHeaderDefine(o
, "HPP"));
3153 addDefaultHxxIncludes(includes
);
3154 includes
.dump(o
, &name_
);
3159 o
<< "\n#endif // "<< headerDefine
<< "\n";
3162 void EnumType::dumpNormalGetCppuType(FileStream
& o
)
3164 dumpGetCppuTypePreamble(o
);
3167 << "static typelib_TypeDescriptionReference * the_type = 0;\n";
3169 o
<< indent() << "if ( !the_type )\n" << indent() << "{\n";
3172 o
<< indent() << "typelib_static_enum_type_init( &the_type,\n";
3174 o
<< indent() << "\"" << name_
<< "\",\n"
3175 << indent() << codemaker::cpp::scopedCppName(u2b(name_
)) << "_"
3176 << u2b(entity_
->getMembers()[0].name
) << " );\n";
3179 o
<< indent() << "}\n";
3181 << ("return * reinterpret_cast< ::css::uno::Type * >("
3183 dumpGetCppuTypePostamble(o
);
3186 void EnumType::dumpComprehensiveGetCppuType(FileStream
& o
)
3188 if (!isPolymorphic())
3189 codemaker::cppumaker::dumpNamespaceOpen(o
, name_
, false);
3191 o
<< "namespace cppu { ";
3192 o
<< " namespace detail {\n\n";
3194 OUString
sStaticTypeClass("the" + id_
+ "Type");
3195 o
<< indent() << "struct " << sStaticTypeClass
<< " : public rtl::StaticWithInit< ::css::uno::Type *, " << sStaticTypeClass
<< " >\n";
3196 o
<< indent() << "{\n";
3198 o
<< indent() << "::css::uno::Type * operator()() const\n";
3199 o
<< indent() << "{\n";
3202 o
<< indent() << "::rtl::OUString sTypeName( \"" << name_
3205 o
<< indent() << "// Start inline typedescription generation\n"
3206 << indent() << "typelib_TypeDescription * pTD = 0;\n\n";
3208 o
<< indent() << "rtl_uString* enumValueNames["
3209 << entity_
->getMembers().size() << "];\n";
3210 std::vector
< unoidl::EnumTypeEntity::Member
>::size_type n
= 0;
3211 for (std::vector
< unoidl::EnumTypeEntity::Member
>::const_iterator
i(
3212 entity_
->getMembers().begin());
3213 i
!= entity_
->getMembers().end(); ++i
)
3215 o
<< indent() << "::rtl::OUString sEnumValue" << n
<< "( \""
3216 << u2b(i
->name
) << "\" );\n";
3217 o
<< indent() << "enumValueNames[" << n
<< "] = sEnumValue" << n
3222 o
<< "\n" << indent() << "sal_Int32 enumValues["
3223 << entity_
->getMembers().size() << "];\n";
3225 for (std::vector
< unoidl::EnumTypeEntity::Member
>::const_iterator
i(
3226 entity_
->getMembers().begin());
3227 i
!= entity_
->getMembers().end(); ++i
)
3229 o
<< indent() << "enumValues[" << n
++ << "] = " << i
->value
<< ";\n";
3232 o
<< "\n" << indent() << "typelib_typedescription_newEnum( &pTD,\n";
3234 o
<< indent() << "sTypeName.pData,\n"
3235 << indent() << "(sal_Int32)"
3236 << codemaker::cpp::scopedCppName(u2b(name_
), false) << "_"
3237 << u2b(entity_
->getMembers()[0].name
) << ",\n"
3238 << indent() << entity_
->getMembers().size()
3239 << ", enumValueNames, enumValues );\n\n";
3243 << ("typelib_typedescription_register( (typelib_TypeDescription**)&pTD"
3245 o
<< indent() << "typelib_typedescription_release( pTD );\n"
3246 << indent() << "// End inline typedescription generation\n\n";
3248 o
<< indent() << "return new ::css::uno::Type( "
3249 << getTypeClass(name_
) << ", sTypeName ); // leaked\n";
3252 o
<< indent() << "}\n";
3254 o
<< indent() << "};\n\n";
3256 if (!isPolymorphic())
3257 codemaker::cppumaker::dumpNamespaceClose(o
, name_
, false);
3262 dumpGetCppuTypePreamble(o
);
3263 o
<< indent() << "return *detail::" << sStaticTypeClass
<< "::get();\n";
3264 dumpGetCppuTypePostamble(o
);
3267 class Typedef
: public CppuType
{
3270 rtl::Reference
< unoidl::TypedefEntity
> const & entity
,
3271 OUString
const & name
, rtl::Reference
< TypeManager
> const & typeMgr
):
3272 CppuType(name
, typeMgr
), entity_(entity
)
3273 { assert(entity
.is()); }
3276 virtual void dumpDeclaration(FileStream
& o
) SAL_OVERRIDE
;
3278 void dumpHFile(FileStream
& o
, codemaker::cppumaker::Includes
& includes
) SAL_OVERRIDE
;
3280 void dumpHxxFile(FileStream
& o
, codemaker::cppumaker::Includes
& includes
) SAL_OVERRIDE
;
3282 rtl::Reference
< unoidl::TypedefEntity
> entity_
;
3285 void Typedef::dumpHFile(
3286 FileStream
& o
, codemaker::cppumaker::Includes
& includes
)
3288 OUString
headerDefine(dumpHeaderDefine(o
, "HDL"));
3291 addDefaultHIncludes(includes
);
3292 includes
.dump(o
, 0);
3295 if (codemaker::cppumaker::dumpNamespaceOpen(o
, name_
, false)) {
3301 if (codemaker::cppumaker::dumpNamespaceClose(o
, name_
, false)) {
3305 o
<< "#endif // "<< headerDefine
<< "\n";
3308 void Typedef::dumpDeclaration(FileStream
& o
)
3311 dumpType(o
, entity_
->getType());
3312 o
<< " " << id_
<< ";\n\n";
3315 void Typedef::dumpHxxFile(
3316 FileStream
& o
, codemaker::cppumaker::Includes
& includes
)
3318 OUString
headerDefine(dumpHeaderDefine(o
, "HPP"));
3321 addDefaultHxxIncludes(includes
);
3322 includes
.dump(o
, &name_
);
3325 o
<< "\n#endif // "<< headerDefine
<< "\n";
3328 class ConstructiveType
: public CppuType
{
3331 OUString
const & name
, rtl::Reference
< TypeManager
> const & manager
):
3332 CppuType(name
, manager
) {}
3335 virtual void dumpHFile(FileStream
&, codemaker::cppumaker::Includes
&) SAL_OVERRIDE
3336 { assert(false); } // this cannot happen
3338 virtual void dumpFiles(OUString
const & uri
, CppuOptions
const & options
) SAL_OVERRIDE
3339 { dumpFile(uri
, name_
, true, options
); }
3342 bool hasRestParameter(
3343 unoidl::SingleInterfaceBasedServiceEntity::Constructor
const & constructor
)
3345 return !constructor
.parameters
.empty()
3346 && constructor
.parameters
.back().rest
;
3349 void includeExceptions(
3350 codemaker::cppumaker::Includes
& includes
,
3351 codemaker::ExceptionTreeNode
const * node
)
3353 if (node
->present
) {
3354 includes
.add(node
->name
);
3356 for (codemaker::ExceptionTreeNode::Children::const_iterator
i(
3357 node
->children
.begin());
3358 i
!= node
->children
.end(); ++i
)
3360 includeExceptions(includes
, *i
);
3365 class ServiceType
: public ConstructiveType
{
3368 rtl::Reference
< unoidl::SingleInterfaceBasedServiceEntity
> const &
3370 OUString
const & name
, rtl::Reference
< TypeManager
> const & manager
):
3371 ConstructiveType(name
, manager
), entity_(entity
)
3372 { assert(entity
.is()); }
3375 virtual void dumpHxxFile(
3376 FileStream
& o
, codemaker::cppumaker::Includes
& includes
) SAL_OVERRIDE
;
3378 void dumpCatchClauses(
3379 FileStream
& out
, codemaker::ExceptionTreeNode
const * node
);
3381 rtl::Reference
< unoidl::SingleInterfaceBasedServiceEntity
> entity_
;
3384 static OUString
failsToSupply(const OUString
& name_
, const OString
& baseName
)
3388 "#if OSL_DEBUG_LEVEL > 0\n"
3389 " ::rtl::OUString(\"component context fails to supply service '" + name_
+ "' of type '" + OStringToOUString(baseName
, RTL_TEXTENCODING_UTF8
) + "'\")\n"
3391 " ::rtl::OUString(\"service not supplied\")\n"
3395 void ServiceType::dumpHxxFile(
3396 FileStream
& o
, codemaker::cppumaker::Includes
& includes
)
3398 if (!entity_
->getConstructors().empty()) {
3399 //TODO: Decide whether the types added to includes should rather be
3400 // added to m_dependencies (and thus be generated during
3401 // dumpDependedTypes):
3402 includes
.addCassert();
3403 includes
.addReference();
3404 includes
.addRtlUstringH();
3405 includes
.addRtlUstringHxx();
3406 includes
.add("com.sun.star.uno.DeploymentException");
3407 includes
.add("com.sun.star.uno.XComponentContext");
3409 unoidl::SingleInterfaceBasedServiceEntity::Constructor
>::
3410 const_iterator
i(entity_
->getConstructors().begin());
3411 i
!= entity_
->getConstructors().end(); ++i
)
3413 if (i
->defaultConstructor
) {
3414 includes
.add("com.sun.star.uno.Exception");
3415 includes
.add("com.sun.star.uno.RuntimeException");
3417 if (!hasRestParameter(*i
)) {
3419 includes
.addSequence();
3421 unoidl::SingleInterfaceBasedServiceEntity::
3422 Constructor::Parameter
>::const_iterator
j(
3423 i
->parameters
.begin());
3424 j
!= i
->parameters
.end(); ++j
)
3426 if (m_typeMgr
->getSort(
3427 b2u(codemaker::UnoType::decompose(
3428 u2b(j
->type
), 0, 0)))
3429 == codemaker::UnoType::SORT_CHAR
)
3431 includes
.addCppuUnotypeHxx();
3436 codemaker::ExceptionTree tree
;
3437 for (std::vector
< OUString
>::const_iterator
j(
3438 i
->exceptions
.begin());
3439 j
!= i
->exceptions
.end(); ++j
)
3441 tree
.add(u2b(*j
), m_typeMgr
);
3443 if (!tree
.getRoot().present
) {
3444 includes
.add("com.sun.star.uno.Exception");
3445 includes
.add("com.sun.star.uno.RuntimeException");
3446 includeExceptions(includes
, &tree
.getRoot());
3452 codemaker::cpp::translateUnoToCppIdentifier(
3453 u2b(id_
), "service", isGlobal()));
3454 OUString
headerDefine(dumpHeaderDefine(o
, "HPP"));
3456 includes
.dump(o
, 0);
3457 if (!entity_
->getConstructors().empty()) {
3458 o
<< ("\n#if defined ANDROID || defined IOS //TODO\n"
3459 "#include <com/sun/star/lang/XInitialization.hpp>\n"
3460 "#include <osl/detail/component-defines.h>\n#endif\n\n"
3461 "#if defined LO_URE_CURRENT_ENV && defined LO_URE_CTOR_ENV_")
3462 << name_
.replaceAll(".", "_dot_")
3463 << " && (LO_URE_CURRENT_ENV) == (LO_URE_CTOR_ENV_"
3464 << name_
.replaceAll(".", "_dot_") << ") && defined LO_URE_CTOR_FUN_"
3465 << name_
.replaceAll(".", "_dot_")
3466 << "\nextern \"C\" ::css::uno::XInterface * SAL_CALL LO_URE_CTOR_FUN_"
3467 << name_
.replaceAll(".", "_dot_")
3468 << "(::css::uno::XComponentContext *, ::css::uno::Sequence< "
3469 "::css::uno::Any > const &);\n#endif\n";
3472 if (codemaker::cppumaker::dumpNamespaceOpen(o
, name_
, false)) {
3475 o
<< "\nclass " << cppName
<< " {\n";
3477 if (!entity_
->getConstructors().empty()) {
3478 OString
baseName(u2b(entity_
->getBase()));
3479 OString
scopedBaseName(codemaker::cpp::scopedCppName(baseName
));
3482 unoidl::SingleInterfaceBasedServiceEntity::Constructor
>::
3483 const_iterator
i(entity_
->getConstructors().begin());
3484 i
!= entity_
->getConstructors().end(); ++i
)
3486 if (i
->defaultConstructor
) {
3487 o
<< indent() << "static ::css::uno::Reference< "
3488 << scopedBaseName
<< " > "
3489 << codemaker::cpp::translateUnoToCppIdentifier(
3490 "create", "method", codemaker::cpp::ITM_NONGLOBAL
,
3492 << ("(::css::uno::Reference< ::css::uno::XComponentContext > const &"
3493 " the_context) {\n");
3495 o
<< indent() << "assert(the_context.is());\n" << indent()
3496 << "::css::uno::Reference< " << scopedBaseName
3497 << " > the_instance;\n" << indent() << "try {\n";
3499 o
<< ("#if defined LO_URE_CURRENT_ENV && defined "
3501 << name_
.replaceAll(".", "_dot_")
3502 << " && (LO_URE_CURRENT_ENV) == (LO_URE_CTOR_ENV_"
3503 << name_
.replaceAll(".", "_dot_")
3504 << ") && defined LO_URE_CTOR_FUN_"
3505 << name_
.replaceAll(".", "_dot_") << "\n" << indent()
3506 << "the_instance = ::css::uno::Reference< " << scopedBaseName
3507 << (" >(::css::uno::Reference< ::css::uno::XInterface >("
3508 "static_cast< ::css::uno::XInterface * >((*"
3510 << name_
.replaceAll(".", "_dot_")
3511 << (")(the_context.get(), ::css::uno::Sequence<"
3512 " ::css::uno::Any >())), ::SAL_NO_ACQUIRE),"
3513 " ::css::uno::UNO_QUERY);\n#else\n")
3514 << indent() << "the_instance = ::css::uno::Reference< "
3516 << (" >(the_context->getServiceManager()->"
3517 "createInstanceWithContext(::rtl::OUString("
3520 << "\" ), the_context), ::css::uno::UNO_QUERY);\n#endif\n";
3523 << "} catch (const ::css::uno::RuntimeException &) {\n";
3525 o
<< indent() << "throw;\n";
3528 << ("} catch (const ::css::uno::Exception & the_exception) {\n");
3531 << "throw ::css::uno::DeploymentException("
3532 << failsToSupply(name_
, baseName
)
3533 << " + \": \" + the_exception.Message, the_context);\n";
3535 o
<< indent() << "}\n" << indent()
3536 << "if (!the_instance.is()) {\n";
3539 << "throw ::css::uno::DeploymentException("
3540 << failsToSupply(name_
, baseName
)
3541 << ", the_context);\n";
3543 o
<< indent() << "}\n" << indent() << "return the_instance;\n";
3545 o
<< indent() << "}\n\n";
3547 o
<< indent() << "static ::css::uno::Reference< "
3548 << scopedBaseName
<< " > "
3549 << codemaker::cpp::translateUnoToCppIdentifier(
3550 u2b(i
->name
), "method", codemaker::cpp::ITM_NONGLOBAL
,
3552 << ("(::css::uno::Reference< ::css::uno::XComponentContext > const &"
3554 bool rest
= hasRestParameter(*i
);
3556 unoidl::SingleInterfaceBasedServiceEntity::Constructor::
3557 Parameter
>::const_iterator
j(i
->parameters
.begin());
3558 j
!= i
->parameters
.end(); ++j
)
3565 buf
.append(j
->type
);
3566 OUString
type(buf
.makeStringAndClear());
3567 bool byRef
= passByReference(type
);
3568 dumpType(o
, type
, byRef
, byRef
);
3570 << codemaker::cpp::translateUnoToCppIdentifier(
3571 u2b(j
->name
), "param", codemaker::cpp::ITM_NONGLOBAL
);
3575 o
<< indent() << "assert(the_context.is());\n";
3576 if (!rest
&& !i
->parameters
.empty()) {
3578 << ("::css::uno::Sequence< ::css::uno::Any > the_arguments(")
3579 << i
->parameters
.size() << ");\n";
3581 unoidl::SingleInterfaceBasedServiceEntity::Constructor::
3582 Parameter
>::size_type n
= 0;
3584 unoidl::SingleInterfaceBasedServiceEntity::
3585 Constructor::Parameter
>::const_iterator
j(
3586 i
->parameters
.begin());
3587 j
!= i
->parameters
.end(); ++j
)
3589 o
<< indent() << "the_arguments[" << n
++ << "] ";
3591 codemaker::cpp::translateUnoToCppIdentifier(
3592 u2b(j
->name
), "param",
3593 codemaker::cpp::ITM_NONGLOBAL
));
3595 if (m_typeMgr
->getSort(
3596 b2u(codemaker::UnoType::decompose(
3597 u2b(j
->type
), &rank
, 0)))
3598 == codemaker::UnoType::SORT_CHAR
)
3600 o
<< "= ::css::uno::Any(&" << param
3601 << ", ::cppu::UnoType< ";
3602 for (sal_Int32 k
= 0; k
< rank
; ++k
) {
3603 o
<< "::cppu::UnoSequenceType< ";
3605 o
<< "::cppu::UnoCharType";
3606 for (sal_Int32 k
= 0; k
< rank
; ++k
) {
3611 o
<< "<<= " << param
;
3616 o
<< indent() << "::css::uno::Reference< "
3617 << scopedBaseName
<< " > the_instance;\n";
3618 codemaker::ExceptionTree tree
;
3619 for (std::vector
< OUString
>::const_iterator
j(
3620 i
->exceptions
.begin());
3621 j
!= i
->exceptions
.end(); ++j
)
3623 tree
.add(u2b(*j
), m_typeMgr
);
3625 if (!tree
.getRoot().present
) {
3626 o
<< indent() << "try {\n";
3629 o
<< ("#if defined LO_URE_CURRENT_ENV && defined "
3631 << name_
.replaceAll(".", "_dot_")
3632 << " && (LO_URE_CURRENT_ENV) == (LO_URE_CTOR_ENV_"
3633 << name_
.replaceAll(".", "_dot_")
3634 << ") && defined LO_URE_CTOR_FUN_"
3635 << name_
.replaceAll(".", "_dot_") << "\n" << indent()
3636 << "the_instance = ::css::uno::Reference< " << scopedBaseName
3637 << (" >(::css::uno::Reference< ::css::uno::XInterface >("
3638 "static_cast< ::css::uno::XInterface * >((*"
3640 << name_
.replaceAll(".", "_dot_")
3641 << ")(the_context.get(), ";
3643 o
<< codemaker::cpp::translateUnoToCppIdentifier(
3644 u2b(i
->parameters
.back().name
), "param",
3645 codemaker::cpp::ITM_NONGLOBAL
);
3646 } else if (i
->parameters
.empty()) {
3647 o
<< "::css::uno::Sequence< ::css::uno::Any >()";
3649 o
<< "the_arguments";
3651 o
<< ")), ::SAL_NO_ACQUIRE), ::css::uno::UNO_QUERY);\n" << indent()
3652 << ("::css::uno::Reference< ::css::lang::XInitialization > "
3653 "init(the_instance, ::css::uno::UNO_QUERY);\n")
3654 << indent() << "if (init.is()) {\n"
3655 << indent() << " init->initialize(";
3656 if (i
->parameters
.empty()) {
3657 o
<< "::css::uno::Sequence< ::css::uno::Any >()";
3659 o
<< "the_arguments";
3661 o
<< ");\n" << indent() << "}\n";
3663 << indent() << "the_instance = ::css::uno::Reference< "
3665 << (" >(the_context->getServiceManager()->"
3666 "createInstanceWithArgumentsAndContext(::rtl::OUString("
3668 << name_
<< "\" ), ";
3670 o
<< codemaker::cpp::translateUnoToCppIdentifier(
3671 u2b(i
->parameters
.back().name
), "param",
3672 codemaker::cpp::ITM_NONGLOBAL
);
3673 } else if (i
->parameters
.empty()) {
3674 o
<< ("::css::uno::Sequence< ::css::uno::Any >()");
3676 o
<< "the_arguments";
3678 o
<< ", the_context), ::css::uno::UNO_QUERY);\n#endif\n";
3679 if (!tree
.getRoot().present
) {
3682 << ("} catch (const ::css::uno::RuntimeException &) {\n");
3684 o
<< indent() << "throw;\n";
3686 dumpCatchClauses(o
, &tree
.getRoot());
3688 << ("} catch (const ::css::uno::Exception &"
3689 " the_exception) {\n");
3692 << "throw ::css::uno::DeploymentException("
3693 << failsToSupply(name_
, baseName
)
3694 << " + \": \" + the_exception.Message, the_context);\n";
3696 o
<< indent() << "}\n";
3698 o
<< indent() << "if (!the_instance.is()) {\n";
3701 << "throw ::css::uno::DeploymentException("
3702 << failsToSupply(name_
, baseName
)
3703 << ", the_context);\n";
3705 o
<< indent() << "}\n" << indent() << "return the_instance;\n";
3707 o
<< indent() << "}\n\n";
3712 o
<< indent() << cppName
<< "(); // not implemented\n"
3713 << indent() << cppName
<< "(" << cppName
<< " &); // not implemented\n"
3714 << indent() << "~" << cppName
<< "(); // not implemented\n"
3715 << indent() << "void operator =(" << cppName
<< "); // not implemented\n";
3718 if (codemaker::cppumaker::dumpNamespaceClose(o
, name_
, false)) {
3721 o
<< "\n#endif // "<< headerDefine
<< "\n";
3724 void ServiceType::dumpCatchClauses(
3725 FileStream
& out
, codemaker::ExceptionTreeNode
const * node
)
3727 if (node
->present
) {
3728 out
<< indent() << "} catch (const ";
3729 dumpType(out
, b2u(node
->name
));
3732 out
<< indent() << "throw;\n";
3735 for (codemaker::ExceptionTreeNode::Children::const_iterator
i(
3736 node
->children
.begin());
3737 i
!= node
->children
.end(); ++i
)
3739 dumpCatchClauses(out
, *i
);
3744 class SingletonType
: public ConstructiveType
{
3747 rtl::Reference
< unoidl::InterfaceBasedSingletonEntity
> const & entity
,
3748 OUString
const & name
, rtl::Reference
< TypeManager
> const & manager
):
3749 ConstructiveType(name
, manager
), entity_(entity
)
3750 { assert(entity
.is()); }
3753 virtual void dumpHxxFile(
3754 FileStream
& o
, codemaker::cppumaker::Includes
& includes
) SAL_OVERRIDE
;
3756 rtl::Reference
< unoidl::InterfaceBasedSingletonEntity
> entity_
;
3759 void SingletonType::dumpHxxFile(
3760 FileStream
& o
, codemaker::cppumaker::Includes
& includes
)
3763 codemaker::cpp::translateUnoToCppIdentifier(
3764 u2b(id_
), "singleton", isGlobal()));
3765 OString
baseName(u2b(entity_
->getBase()));
3766 OString
scopedBaseName(codemaker::cpp::scopedCppName(baseName
));
3767 OUString
headerDefine(dumpHeaderDefine(o
, "HPP"));
3769 //TODO: Decide whether the types added to includes should rather be added to
3770 // m_dependencies (and thus be generated during dumpDependedTypes):
3771 includes
.add("com.sun.star.uno.DeploymentException");
3772 includes
.add("com.sun.star.uno.XComponentContext");
3773 includes
.addCassert();
3775 includes
.addReference();
3776 includes
.addRtlUstringH();
3777 includes
.addRtlUstringHxx();
3778 includes
.dump(o
, 0);
3779 o
<< ("\n#if defined ANDROID || defined IOS //TODO\n"
3780 "#include <com/sun/star/lang/XInitialization.hpp>\n"
3781 "#include <osl/detail/component-defines.h>\n#endif\n\n"
3782 "#if defined LO_URE_CURRENT_ENV && defined LO_URE_CTOR_ENV_")
3783 << name_
.replaceAll(".", "_dot_")
3784 << " && (LO_URE_CURRENT_ENV) == (LO_URE_CTOR_ENV_"
3785 << name_
.replaceAll(".", "_dot_") << ") && defined LO_URE_CTOR_FUN_"
3786 << name_
.replaceAll(".", "_dot_")
3787 << "\nextern \"C\" ::css::uno::XInterface * SAL_CALL LO_URE_CTOR_FUN_"
3788 << name_
.replaceAll(".", "_dot_")
3789 << "(::css::uno::XComponentContext *, ::css::uno::Sequence< "
3790 "::css::uno::Any > const &);\n#endif\n";
3792 if (codemaker::cppumaker::dumpNamespaceOpen(o
, name_
, false)) {
3795 o
<< "\nclass " << cppName
<< " {\npublic:\n";
3797 o
<< indent() << "static ::css::uno::Reference< "
3798 << scopedBaseName
<< " > "
3799 << codemaker::cpp::translateUnoToCppIdentifier(
3800 "get", "method", codemaker::cpp::ITM_NONGLOBAL
, &cppName
)
3801 << ("(::css::uno::Reference<"
3802 " ::css::uno::XComponentContext > const & the_context)"
3805 o
<< indent() << "assert(the_context.is());\n" << indent()
3806 << "::css::uno::Reference< " << scopedBaseName
3807 << (" > instance;\n#if defined LO_URE_CURRENT_ENV && defined "
3809 << name_
.replaceAll(".", "_dot_")
3810 << " && (LO_URE_CURRENT_ENV) == (LO_URE_CTOR_ENV_"
3811 << name_
.replaceAll(".", "_dot_")
3812 << ") && defined LO_URE_CTOR_FUN_"
3813 << name_
.replaceAll(".", "_dot_") << "\n" << indent()
3814 << "instance = ::css::uno::Reference< " << scopedBaseName
3815 << (" >(::css::uno::Reference< ::css::uno::XInterface >("
3816 "static_cast< ::css::uno::XInterface * >((*"
3818 << name_
.replaceAll(".", "_dot_")
3819 << (")(the_context.get(), ::css::uno::Sequence<"
3820 " ::css::uno::Any >())), ::SAL_NO_ACQUIRE),"
3821 " ::css::uno::UNO_QUERY);\n#else\n")
3822 << indent() << ("the_context->getValueByName("
3823 "::rtl::OUString( \"/singletons/")
3824 << name_
<< "\" )) >>= instance;\n#endif\n"
3825 << indent() << "if (!instance.is()) {\n";
3828 << ("throw ::css::uno::DeploymentException("
3829 "::rtl::OUString( \"component context"
3830 " fails to supply singleton ")
3831 << name_
<< " of type " << baseName
<< "\" ), the_context);\n";
3833 o
<< indent() << "}\n" << indent() << "return instance;\n";
3835 o
<< indent() << "}\n\n";
3837 o
<< indent() << cppName
<< "(); // not implemented\n"
3838 << indent() << cppName
<< "(" << cppName
<< " &); // not implemented\n"
3839 << indent() << "~" << cppName
<< "(); // not implemented\n"
3840 << indent() << "void operator =(" << cppName
<< "); // not implemented\n";
3843 if (codemaker::cppumaker::dumpNamespaceClose(o
, name_
, false)) {
3846 o
<< "\n#endif // "<< headerDefine
<< "\n";
3852 OUString
const & name
, rtl::Reference
< TypeManager
> const & manager
,
3853 codemaker::GeneratedTypeSet
& generated
, CppuOptions
const & options
)
3855 if (generated
.contains(u2b(name
))) {
3858 generated
.add(u2b(name
));
3859 if (!manager
->foundAtPrimaryProvider(name
)) {
3862 rtl::Reference
< unoidl::Entity
> ent
;
3863 rtl::Reference
< unoidl::MapCursor
> cur
;
3864 switch (manager
->getSort(name
, &ent
, &cur
)) {
3865 case codemaker::UnoType::SORT_MODULE
:
3868 if (!name
.isEmpty()) {
3869 prefix
= name
+ ".";
3873 if (!cur
->getNext(&mem
).is()) {
3876 produce(prefix
+ mem
, manager
, generated
, options
);
3880 case codemaker::UnoType::SORT_ENUM_TYPE
:
3883 dynamic_cast< unoidl::EnumTypeEntity
* >(ent
.get()), name
,
3886 t
.dumpDependedTypes(generated
, options
);
3889 case codemaker::UnoType::SORT_PLAIN_STRUCT_TYPE
:
3892 dynamic_cast< unoidl::PlainStructTypeEntity
* >(ent
.get()),
3895 t
.dumpDependedTypes(generated
, options
);
3898 case codemaker::UnoType::SORT_POLYMORPHIC_STRUCT_TYPE_TEMPLATE
:
3901 dynamic_cast< unoidl::PolymorphicStructTypeTemplateEntity
* >(
3905 t
.dumpDependedTypes(generated
, options
);
3908 case codemaker::UnoType::SORT_EXCEPTION_TYPE
:
3911 dynamic_cast< unoidl::ExceptionTypeEntity
* >(ent
.get()), name
,
3914 t
.dumpDependedTypes(generated
, options
);
3917 case codemaker::UnoType::SORT_INTERFACE_TYPE
:
3920 dynamic_cast< unoidl::InterfaceTypeEntity
* >(ent
.get()), name
,
3923 t
.dumpDependedTypes(generated
, options
);
3926 case codemaker::UnoType::SORT_TYPEDEF
:
3929 dynamic_cast< unoidl::TypedefEntity
* >(ent
.get()), name
,
3932 t
.dumpDependedTypes(generated
, options
);
3935 case codemaker::UnoType::SORT_CONSTANT_GROUP
:
3938 dynamic_cast< unoidl::ConstantGroupEntity
* >(ent
.get()), name
,
3940 if (t
.hasConstants()) {
3945 case codemaker::UnoType::SORT_SINGLE_INTERFACE_BASED_SERVICE
:
3948 dynamic_cast< unoidl::SingleInterfaceBasedServiceEntity
* >(
3952 t
.dumpDependedTypes(generated
, options
);
3955 case codemaker::UnoType::SORT_INTERFACE_BASED_SINGLETON
:
3958 dynamic_cast< unoidl::InterfaceBasedSingletonEntity
* >(
3962 t
.dumpDependedTypes(generated
, options
);
3965 case codemaker::UnoType::SORT_ACCUMULATION_BASED_SERVICE
:
3966 case codemaker::UnoType::SORT_SERVICE_BASED_SINGLETON
:
3969 throw CannotDumpException(
3970 "unexpected entity \"" + name
+ "\" in call to produce");
3974 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */