36#include <rtl/ustrbuf.hxx>
37#include <rtl/ustring.hxx>
38#include <rtl/strbuf.hxx>
56bool isBootstrapType(OUString
const & name)
58 static char const *
const names[] = {
59 "com.sun.star.beans.Property",
60 "com.sun.star.beans.PropertyAttribute",
61 "com.sun.star.beans.PropertyChangeEvent",
62 "com.sun.star.beans.PropertyState",
63 "com.sun.star.beans.PropertyValue",
64 "com.sun.star.beans.XFastPropertySet",
65 "com.sun.star.beans.XMultiPropertySet",
66 "com.sun.star.beans.XPropertiesChangeListener",
67 "com.sun.star.beans.XPropertyAccess",
68 "com.sun.star.beans.XPropertyChangeListener",
69 "com.sun.star.beans.XPropertySet",
70 "com.sun.star.beans.XPropertySetInfo",
71 "com.sun.star.beans.XPropertySetOption",
72 "com.sun.star.beans.XVetoableChangeListener",
73 "com.sun.star.bridge.UnoUrlResolver",
74 "com.sun.star.bridge.XUnoUrlResolver",
75 "com.sun.star.connection.SocketPermission",
76 "com.sun.star.container.XElementAccess",
77 "com.sun.star.container.XEnumeration",
78 "com.sun.star.container.XEnumerationAccess",
79 "com.sun.star.container.XHierarchicalNameAccess",
80 "com.sun.star.container.XNameAccess",
81 "com.sun.star.container.XNameContainer",
82 "com.sun.star.container.XNameReplace",
83 "com.sun.star.container.XSet",
84 "com.sun.star.io.FilePermission",
85 "com.sun.star.io.IOException",
86 "com.sun.star.lang.DisposedException",
87 "com.sun.star.lang.EventObject",
88 "com.sun.star.lang.WrappedTargetRuntimeException",
89 "com.sun.star.lang.XComponent",
90 "com.sun.star.lang.XEventListener",
91 "com.sun.star.lang.XInitialization",
92 "com.sun.star.lang.XMultiComponentFactory",
93 "com.sun.star.lang.XMultiServiceFactory",
94 "com.sun.star.lang.XServiceInfo",
95 "com.sun.star.lang.XSingleComponentFactory",
96 "com.sun.star.lang.XSingleServiceFactory",
97 "com.sun.star.lang.XTypeProvider",
98 "com.sun.star.loader.XImplementationLoader",
99 "com.sun.star.reflection.FieldAccessMode",
100 "com.sun.star.reflection.MethodMode",
101 "com.sun.star.reflection.ParamInfo",
102 "com.sun.star.reflection.ParamMode",
103 "com.sun.star.reflection.TypeDescriptionSearchDepth",
104 "com.sun.star.reflection.XCompoundTypeDescription",
105 "com.sun.star.reflection.XEnumTypeDescription",
106 "com.sun.star.reflection.XIdlArray",
107 "com.sun.star.reflection.XIdlClass",
108 "com.sun.star.reflection.XIdlField",
109 "com.sun.star.reflection.XIdlField2",
110 "com.sun.star.reflection.XIdlMethod",
111 "com.sun.star.reflection.XIdlReflection",
112 "com.sun.star.reflection.XIndirectTypeDescription",
113 "com.sun.star.reflection.XInterfaceAttributeTypeDescription",
114 "com.sun.star.reflection.XInterfaceAttributeTypeDescription2",
115 "com.sun.star.reflection.XInterfaceMemberTypeDescription",
116 "com.sun.star.reflection.XInterfaceMethodTypeDescription",
117 "com.sun.star.reflection.XInterfaceTypeDescription",
118 "com.sun.star.reflection.XInterfaceTypeDescription2",
119 "com.sun.star.reflection.XMethodParameter",
120 "com.sun.star.reflection.XStructTypeDescription",
121 "com.sun.star.reflection.XTypeDescription",
122 "com.sun.star.reflection.XTypeDescriptionEnumeration",
123 "com.sun.star.reflection.XTypeDescriptionEnumerationAccess",
124 "com.sun.star.registry.RegistryKeyType",
125 "com.sun.star.registry.RegistryValueType",
126 "com.sun.star.registry.XImplementationRegistration",
127 "com.sun.star.registry.XRegistryKey",
128 "com.sun.star.registry.XSimpleRegistry",
129 "com.sun.star.security.RuntimePermission",
130 "com.sun.star.security.XAccessControlContext",
131 "com.sun.star.security.XAccessController",
132 "com.sun.star.security.XAction",
133 "com.sun.star.uno.DeploymentException",
134 "com.sun.star.uno.RuntimeException",
135 "com.sun.star.uno.TypeClass",
136 "com.sun.star.uno.Uik",
137 "com.sun.star.uno.XAdapter",
138 "com.sun.star.uno.XAggregation",
139 "com.sun.star.uno.XComponentContext",
140 "com.sun.star.uno.XCurrentContext",
141 "com.sun.star.uno.XInterface",
142 "com.sun.star.uno.XReference",
143 "com.sun.star.uno.XUnloadingPreference",
144 "com.sun.star.uno.XWeak",
145 "com.sun.star.util.XMacroExpander" };
147 auto const pred = [&
name](
const char*
aName) {
148 return name.equalsAscii(aName);
150 return std::any_of(std::begin(names), std::end(names), pred);
158 virtual ~CppuType() {}
160 CppuType(
const CppuType&) =
delete;
161 const CppuType& operator=(
const CppuType&) =
delete;
166 std::u16string_view uri, std::u16string_view name,
bool hpp,
169 void dumpDependedTypes(
172 virtual void dumpHdlFile(
174 dumpHFileContent(out, includes);
179 OUString dumpHeaderDefine(
FileStream& o, std::u16string_view extension)
const;
183 virtual void dumpLightGetCppuType(
FileStream & out);
185 virtual void dumpNormalGetCppuType(
FileStream &) {
189 virtual void dumpComprehensiveGetCppuType(
FileStream &) {
194 FileStream & out, std::u16string_view name,
bool isConst =
false,
195 bool isRef =
false,
bool native =
false,
bool cppuUnoType =
false)
198 OUString
getTypeClass(OUString
const & name,
bool cStyle =
false);
200 void dumpCppuGetType(
201 FileStream & out, std::u16string_view name, OUString
const * ownName =
nullptr)
const;
203 sal_uInt32 getInheritedMemberCount();
205 void inc(sal_Int32 num=4);
206 void dec(sal_Int32 num=4);
207 OUString indent()
const;
209 virtual sal_uInt32 checkInheritedMemberCount()
const {
214 bool passByReference(OUString
const & name)
const;
216 bool canBeWarnUnused(OUString
const & name)
const;
217 bool canBeWarnUnused(OUString
const & name,
int depth)
const;
219 OUString resolveOuterTypedefs(OUString
const & name)
const;
221 OUString resolveAllTypedefs(std::u16string_view name)
const;
229 virtual void dumpFiles(OUString
const & uri,
CppuOptions const & options);
231 virtual void addLightGetCppuTypeIncludes(
234 virtual void addNormalGetCppuTypeIncludes(
237 virtual void addComprehensiveGetCppuTypeIncludes(
240 virtual bool isPolymorphic()
const;
242 virtual void dumpTemplateHead(
FileStream &)
const {}
244 virtual void dumpTemplateParameters(
FileStream &)
const {}
246 void dumpGetCppuTypePreamble(
FileStream & out);
248 void dumpGetCppuTypePostamble(
FileStream & out);
253 void dumpInitializer(
254 FileStream & out,
bool parameterized, std::u16string_view name)
const;
256 void dumpHFileContent(
260 sal_uInt32 m_inheritedMemberCount;
263 bool m_cppuTypeDynamic;
264 sal_Int32 m_indentLength;
277 m_inheritedMemberCount(0)
278 , m_cppuTypeLeak(false)
279 , m_cppuTypeDynamic(true)
284 , m_dependencies(typeMgr,
name_)
290 if (name_ ==
"com.sun.star.uno.XInterface"
291 || name_ ==
"com.sun.star.uno.Exception") {
297 }
else if (m_cppuTypeLeak) {
298 addLightGetCppuTypeIncludes(includes);
299 }
else if (m_cppuTypeDynamic) {
300 addNormalGetCppuTypeIncludes(includes);
302 addComprehensiveGetCppuTypeIncludes(includes);
306void CppuType::dumpFiles(OUString
const & uri,
CppuOptions const & options)
308 dumpFile(uri, name_,
false, options);
309 dumpFile(uri, name_,
true, options);
312void CppuType::addLightGetCppuTypeIncludes(
320void CppuType::addNormalGetCppuTypeIncludes(
328void CppuType::addComprehensiveGetCppuTypeIncludes(
336bool CppuType::isPolymorphic()
const
341void CppuType::dumpGetCppuTypePreamble(
FileStream & out)
343 if (isPolymorphic()) {
344 out <<
"namespace cppu {\n\n";
345 dumpTemplateHead(out);
346 out <<
"class UnoType< ";
347 dumpType(out, name_);
348 dumpTemplateParameters(out);
349 out <<
" > {\npublic:\n";
352 <<
"static inline ::css::uno::Type const & get() {\n";
357 out << (
"inline ::css::uno::Type const &"
358 " cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ");
359 dumpType(out, name_,
false,
false,
true);
360 out <<
" const *) {\n";
365void CppuType::dumpGetCppuTypePostamble(
FileStream & out)
368 if (isPolymorphic()) {
369 out << indent() <<
"}\n\nprivate:\n"
370 << indent() <<
"UnoType(UnoType &); // not defined\n"
371 << indent() <<
"~UnoType(); // not defined\n"
373 <<
"void operator =(UnoType); // not defined\n};\n\n}\n\n";
380 dumpTemplateHead(out);
381 out << (
"SAL_DEPRECATED(\"use cppu::UnoType\") inline ::css::uno::Type const & SAL_CALL"
382 " getCppuType(SAL_UNUSED_PARAMETER ");
383 dumpType(out, name_);
384 dumpTemplateParameters(out);
385 out <<
" const *) {\n";
387 out << indent() <<
"return ::cppu::UnoType< ";
388 dumpType(out, name_);
389 dumpTemplateParameters(out);
390 out <<
" >::get();\n";
392 out << indent() <<
"}\n";
397 if (isBootstrapType(name_)) {
398 m_cppuTypeDynamic =
false;
405 m_cppuTypeLeak =
true;
407 m_cppuTypeDynamic =
false;
413void CppuType::dumpFile(
414 std::u16string_view uri, std::u16string_view name,
bool hpp,
419 u2b(uri),
u2b(name), hpp ?
".hpp" :
".hdl")));
420 if (fileUri.isEmpty()) {
424 if (exists && options.
isValid(
"-G")) {
429 OUString tmpUri(
b2u(out.getName()));
436 addGetCppuTypeIncludes(includes);
437 dumpHppFile(out, includes);
439 dumpHdlFile(out, includes);
453 u2b(fileUri),
u2b(tmpUri), exists && options.
isValid(
"-Gc"));
456void CppuType::dumpDependedTypes(
461 = m_dependencies.getMap();
462 for (
const auto& entry : map) {
463 produce(entry.first, m_typeMgr, generated, options);
468OUString CppuType::dumpHeaderDefine(
469 FileStream & out, std::u16string_view extension)
const
472 "INCLUDED_" +
name_.replace(
'.',
'_').toAsciiUpperCase() +
"_"
474 out <<
"#ifndef " << def <<
"\n#define " << def <<
"\n";
483 if (m_typeMgr->getSort(name_)
494 if (m_typeMgr->getSort(name_)
500void CppuType::dumpInitializer(
501 FileStream & out,
bool parameterized, std::u16string_view name)
const
504 if (!parameterized) {
506 std::vector< OString >
args;
509 u2b(resolveAllTypedefs(name)), &k, &args)));
512 switch (m_typeMgr->getSort(n, &ent)) {
531 getMembers()[0].name);
542 OUString::Concat(
"unexpected entity \"") + name
543 +
"\" in call to CppuType::dumpInitializer");
550void CppuType::dumpHFileContent(
553 addDefaultHIncludes(includes);
554 dumpHeaderDefine(out, u
"HDL");
556 includes.
dump(out,
nullptr,
false);
559 out << (
"\nnamespace com { namespace sun { namespace star { namespace uno"
560 " { class Type; } } } }\n\n");
564 dumpDeclaration(out);
565 if (!(name_ ==
"com.sun.star.uno.XInterface"
566 || name_ ==
"com.sun.star.uno.Exception"
567 || isPolymorphic())) {
568 out <<
"\n" << indent()
569 << (
"inline ::css::uno::Type const &"
570 " cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ");
571 dumpType(out, name_,
false,
false,
true);
572 out <<
" const *);\n";
578 dumpTemplateHead(out);
579 out <<
"SAL_DEPRECATED(\"use cppu::UnoType\") inline ::css::uno::Type const & SAL_CALL getCppuType(";
580 dumpType(out, name_,
true);
581 dumpTemplateParameters(out);
582 out <<
" *);\n\n#endif\n";
585void CppuType::dumpGetCppuType(
FileStream & out)
587 if (name_ ==
"com.sun.star.uno.XInterface") {
589 << (
"SAL_DEPRECATED(\"use cppu::UnoType\") inline ::css::uno::Type const & SAL_CALL"
590 " getCppuType(SAL_UNUSED_PARAMETER ");
591 dumpType(out, name_,
true);
595 << (
"return ::cppu::UnoType< ::css::uno::XInterface"
598 out << indent() <<
"}\n";
599 }
else if (name_ ==
"com.sun.star.uno.Exception") {
601 << (
"SAL_DEPRECATED(\"use cppu::UnoType\") inline ::css::uno::Type const & SAL_CALL"
602 " getCppuType(SAL_UNUSED_PARAMETER ");
603 dumpType(out, name_,
true);
607 << (
"return ::cppu::UnoType< ::css::uno::Exception"
610 out << indent() <<
"}\n";
611 }
else if (m_cppuTypeLeak) {
612 dumpLightGetCppuType(out);
613 }
else if (m_cppuTypeDynamic) {
614 dumpNormalGetCppuType(out);
616 dumpComprehensiveGetCppuType(out);
620void CppuType::dumpLightGetCppuType(
FileStream & out)
622 dumpGetCppuTypePreamble(out);
624 <<
"static typelib_TypeDescriptionReference * the_type = 0;\n"
625 << indent() <<
"if ( !the_type )\n" << indent() <<
"{\n";
627 out << indent() <<
"typelib_static_type_init( &the_type, "
630 out << indent() <<
"}\n" << indent()
631 << (
"return * reinterpret_cast< ::css::uno::Type * >("
633 dumpGetCppuTypePostamble(out);
638 return name_.indexOf(
'.') == -1
642sal_uInt32 CppuType::getInheritedMemberCount()
644 if (m_inheritedMemberCount == 0) {
645 m_inheritedMemberCount = checkInheritedMemberCount();
648 return m_inheritedMemberCount;
651OUString CppuType::getTypeClass(OUString
const & name,
bool cStyle)
654 switch (m_typeMgr->getSort(name, &ent)) {
657 ? OUString(
"typelib_TypeClass_VOID")
658 : OUString(
"::css::uno::TypeClass_VOID");
661 ? OUString(
"typelib_TypeClass_BOOLEAN")
662 : OUString(
"::css::uno::TypeClass_BOOLEAN");
665 ? OUString(
"typelib_TypeClass_BYTE")
666 : OUString(
"::css::uno::TypeClass_BYTE");
669 ? OUString(
"typelib_TypeClass_SHORT")
670 : OUString(
"::css::uno::TypeClass_SHORT");
673 ? OUString(
"typelib_TypeClass_UNSIGNED_SHORT")
674 : OUString(
"::css::uno::TypeClass_UNSIGNED_SHORT");
677 ? OUString(
"typelib_TypeClass_LONG")
678 : OUString(
"::css::uno::TypeClass_LONG");
681 ? OUString(
"typelib_TypeClass_UNSIGNED_LONG")
682 : OUString(
"::css::uno::TypeClass_UNSIGNED_LONG");
685 ? OUString(
"typelib_TypeClass_HYPER")
686 : OUString(
"::css::uno::TypeClass_HYPER");
689 ? OUString(
"typelib_TypeClass_UNSIGNED_HYPER")
690 : OUString(
"::css::uno::TypeClass_UNSIGNED_HYPER");
693 ? OUString(
"typelib_TypeClass_FLOAT")
694 : OUString(
"::css::uno::TypeClass_FLOAT");
697 ? OUString(
"typelib_TypeClass_DOUBLE")
698 : OUString(
"::css::uno::TypeClass_DOUBLE");
701 ? OUString(
"typelib_TypeClass_CHAR")
702 : OUString(
"::css::uno::TypeClass_CHAR");
705 ? OUString(
"typelib_TypeClass_STRING")
706 : OUString(
"::css::uno::TypeClass_STRING");
709 ? OUString(
"typelib_TypeClass_TYPE")
710 : OUString(
"::css::uno::TypeClass_TYPE");
713 ? OUString(
"typelib_TypeClass_ANY")
714 : OUString(
"::css::uno::TypeClass_ANY");
717 ? OUString(
"typelib_TypeClass_SEQUENCE")
718 : OUString(
"::css::uno::TypeClass_SEQUENCE");
721 ? OUString(
"typelib_TypeClass_ENUM")
722 : OUString(
"::css::uno::TypeClass_ENUM");
727 ? OUString(
"typelib_TypeClass_STRUCT")
728 : OUString(
"::css::uno::TypeClass_STRUCT");
731 ? OUString(
"typelib_TypeClass_EXCEPTION")
732 : OUString(
"::css::uno::TypeClass_EXCEPTION");
735 ? OUString(
"typelib_TypeClass_INTERFACE")
736 : OUString(
"::css::uno::TypeClass_INTERFACE");
746void CppuType::dumpType(
747 FileStream & out, std::u16string_view name,
bool isConst,
bool isRef,
748 bool native,
bool cppuUnoType)
const
751 std::vector< OString >
args;
754 u2b(resolveAllTypedefs(name)), &k, &args)));
758 for (sal_Int32 i = 0;
i != k; ++
i) {
760 ?
"::cppu::UnoSequenceType" :
"::css::uno::Sequence")
763 switch (m_typeMgr->getSort(n)) {
774 out <<
"::sal_Int16";
777 out << (cppuUnoType ?
"::cppu::UnoUnsignedShortType" :
"::sal_uInt16");
780 out <<
"::sal_Int32";
783 out <<
"::sal_uInt32";
786 out <<
"::sal_Int64";
789 out <<
"::sal_uInt64";
798 out << (cppuUnoType ?
"::cppu::UnoCharType" :
"::sal_Unicode");
801 out <<
"::rtl::OUString";
804 out <<
"::css::uno::Type";
807 out <<
"::css::uno::Any";
818 for (std::vector< OString >::iterator
i(
args.begin());
819 i !=
args.end(); ++i) {
820 if (i !=
args.begin()) {
823 dumpType(out,
b2u(*i));
830 out <<
"::css::uno::Reference< ";
839 OUString::Concat(
"unexpected entity \"") + name +
"\" in call to CppuType::dumpType");
841 for (sal_Int32 i = 0;
i != k; ++
i) {
849void CppuType::dumpCppuGetType(
850 FileStream & out, std::u16string_view name, OUString
const * ownName)
const
856 name,
true, &nucleus, &rank,
nullptr,
nullptr);
881 if (ownName ==
nullptr || nucleus != *ownName) {
882 out << indent() <<
"::cppu::UnoType< ";
883 dumpType(out, name,
false,
false,
false,
true);
884 out <<
" >::get();\n";
888 for (;;) std::abort();
891 OUString::Concat(
"unexpected entity \"") + name
892 +
"\" in call to CppuType::dumpCppuGetType");
896bool CppuType::passByReference(OUString
const & name)
const
898 switch (m_typeMgr->getSort(resolveOuterTypedefs(name))) {
922 "unexpected entity \"" + name
923 +
"\" in call to CppuType::passByReference");
927bool CppuType::canBeWarnUnused(OUString
const & name)
const
929 return canBeWarnUnused(name, 0);
931bool CppuType::canBeWarnUnused(OUString
const & name,
int depth)
const
936 OUString aResolvedName = resolveOuterTypedefs(name);
937 switch (m_typeMgr->getSort(aResolvedName)) {
955 m_typeMgr->getSort(aResolvedName, &ent);
958 if (!ent2->getDirectBase().isEmpty() && !canBeWarnUnused(ent2->getDirectBase(), depth+1))
961 if (!canBeWarnUnused(rMember.type, depth+1))
967 OUString aInnerType = aResolvedName.copy(2);
968 return canBeWarnUnused(aInnerType, depth+1);
976 "unexpected entity \"" + name
977 +
"\" in call to CppuType::canBeWarnUnused");
981OUString CppuType::resolveOuterTypedefs(OUString
const & name)
const
983 for (OUString
n(name);;) {
992OUString CppuType::resolveAllTypedefs(std::u16string_view name)
const
1006 OUStringBuffer b(k1*2 +
n.getLength());
1007 for (sal_Int32 i = 0;
i != k1; ++
i) {
1011 return b.makeStringAndClear();
1014void CppuType::inc(sal_Int32 num)
1016 m_indentLength += num;
1019void CppuType::dec(sal_Int32 num)
1021 m_indentLength = std::max< sal_Int32 >(m_indentLength - num, 0);
1024OUString CppuType::indent()
const
1026 OUStringBuffer buf(m_indentLength);
1027 for (sal_Int32 i = 0;
i != m_indentLength; ++
i) {
1030 return buf.makeStringAndClear();
1033bool isDeprecated(std::vector< OUString >
const & annotations)
1035 for (
const OUString& r : annotations) {
1036 if (r ==
"deprecated") {
1043void dumpDeprecation(
FileStream & out,
bool deprecated)
1046 out <<
"SAL_DEPRECATED_INTERNAL(\"marked @deprecated in UNOIDL\") ";
1057 calculateBases(entity);
1059 BaseOffset(
const BaseOffset&) =
delete;
1060 const BaseOffset& operator=(
const BaseOffset&) =
delete;
1062 sal_Int32
get()
const {
1067 void calculateBases(
1071 std::set< OUString > set_;
1075void BaseOffset::calculateBases(
1078 assert(entity.is());
1080 if (set_.insert(ar.name).second) {
1085 "interface type base " + ar.name
1086 +
" is not an interface type");
1091 calculateBases(ent2);
1092 offset_ += ent2->getDirectAttributes().size()
1093 + ent2->getDirectMethods().size();
1098class InterfaceType:
public CppuType
1105 virtual void dumpDeclaration(
FileStream& o)
override;
1110 void dumpNormalGetCppuType(
FileStream& o)
override;
1111 void dumpComprehensiveGetCppuType(
FileStream& o)
override;
1112 void dumpCppuAttributeRefs(
FileStream& o, sal_uInt32& index);
1113 void dumpCppuMethodRefs(
FileStream& o, sal_uInt32& index);
1114 void dumpCppuAttributes(
FileStream& o, sal_uInt32& index);
1115 void dumpCppuMethods(
FileStream& o, sal_uInt32& index);
1116 void dumpAttributesCppuDecl(
FileStream & out, std::set< OUString > * seen)
const;
1117 void dumpMethodsCppuDecl(
FileStream & out, std::set< OUString > * seen)
const;
1120 virtual void addComprehensiveGetCppuTypeIncludes(
1123 virtual sal_uInt32 checkInheritedMemberCount()
const override {
1124 return BaseOffset(m_typeMgr, entity_).get();
1127 void dumpExceptionTypeName(
1128 FileStream & out, std::u16string_view prefix, sal_uInt32 index,
1129 std::u16string_view name)
const;
1131 sal_Int32 dumpExceptionTypeNames(
1132 FileStream & out, std::u16string_view prefix,
1133 std::vector< OUString >
const & exceptions,
bool runtimeException)
const;
1136 bool m_isDeprecated;
1139InterfaceType::InterfaceType(
1142 CppuType(
name, typeMgr), entity_(entity),
1143 m_isDeprecated(isDeprecated(entity->getAnnotations()))
1145 assert(entity.is());
1148void InterfaceType::dumpDeclaration(
FileStream & out)
1150 out <<
"\nclass SAL_NO_VTABLE SAL_DLLPUBLIC_RTTI " << id_;
1151 for (std::vector< unoidl::AnnotatedReference >::const_iterator
i(
1152 entity_->getDirectMandatoryBases().begin());
1153 i != entity_->getDirectMandatoryBases().end(); ++i) {
1154 out << (
i == entity_->getDirectMandatoryBases().begin() ?
" :" :
",")
1157 out <<
"\n{\npublic:\n";
1159 out <<
"#if defined LIBO_INTERNAL_ONLY\n"
1160 << indent() << id_ <<
"() = default;\n"
1161 << indent() << id_ <<
"(" << id_ <<
" const &) = default;\n"
1162 << indent() << id_ <<
"(" << id_ <<
" &&) = default;\n"
1163 << indent() << id_ <<
" & operator =(" << id_ <<
" const &) = default;\n"
1164 << indent() << id_ <<
" & operator =(" << id_ <<
" &&) = default;\n#endif\n\n";
1165 dumpAttributes(out);
1167 out <<
"\n" << indent()
1168 << (
"static inline ::css::uno::Type const & SAL_CALL"
1169 " static_type(void * = 0);\n\n");
1171 out <<
"protected:\n";
1173 out << indent() <<
"~" << id_
1174 << (
"() SAL_NOEXCEPT {} // avoid warnings about virtual members and"
1175 " non-virtual dtor\n");
1180void InterfaceType::dumpHppFile(
1183 OUString headerDefine(dumpHeaderDefine(out, u
"HPP"));
1185 addDefaultHxxIncludes(includes);
1186 includes.
dump(out, &name_, !(m_cppuTypeLeak || m_cppuTypeDynamic));
1187 out <<
"\n#if defined LIBO_INTERNAL_ONLY\n#include <type_traits>\n#endif\n\n";
1188 dumpGetCppuType(out);
1189 out <<
"\n::css::uno::Type const & "
1191 <<
"::static_type(SAL_UNUSED_PARAMETER void *) {\n";
1193 out << indent() <<
"return ::cppu::UnoType< ";
1194 dumpType(out, name_,
false,
false,
true);
1195 out <<
" >::get();\n";
1197 out <<
"}\n\n#if defined LIBO_INTERNAL_ONLY\nnamespace cppu::detail {\n";
1198 if (name_ ==
"com.sun.star.uno.XInterface") {
1199 out <<
"template<typename> struct IsUnoInterfaceType: ::std::false_type {};\n"
1200 "template<typename T> inline constexpr auto isUnoInterfaceType ="
1201 " sizeof (T) && IsUnoInterfaceType<T>::value;\n";
1203 out <<
"template<> struct IsUnoInterfaceType<";
1204 dumpType(out, name_,
false,
false,
true);
1205 out <<
">: ::std::true_type {};\n}\n#endif\n\n#endif // "<< headerDefine <<
"\n";
1208void InterfaceType::dumpAttributes(
FileStream & out)
const
1210 if (!entity_->getDirectAttributes().empty()) {
1211 out <<
"\n" << indent() <<
"// Attributes\n";
1214 bool depr = m_isDeprecated || isDeprecated(attr.annotations);
1216 dumpDeprecation(out, depr);
1218 dumpType(out, attr.type);
1219 out <<
" SAL_CALL get" << attr.name <<
"() = 0;\n";
1220 if (!attr.readOnly) {
1221 bool byRef = passByReference(attr.type);
1223 dumpDeprecation(out, depr);
1224 out <<
"virtual void SAL_CALL set" << attr.name <<
"( ";
1225 dumpType(out, attr.type, byRef, byRef);
1226 out <<
" _" << attr.name.toAsciiLowerCase() <<
" ) = 0;\n";
1231void InterfaceType::dumpMethods(
FileStream & out)
const
1233 if (!entity_->getDirectMethods().empty()) {
1234 out <<
"\n" << indent() <<
"// Methods\n";
1238 dumpDeprecation(out, m_isDeprecated || isDeprecated(method.annotations));
1240 dumpType(out, method.returnType);
1241 out <<
" SAL_CALL " << method.name <<
"(";
1242 if (!method.parameters.empty()) {
1244 for (std::vector< unoidl::InterfaceTypeEntity::Method::Parameter >::
1245 const_iterator j(method.parameters.begin());
1246 j != method.parameters.end();) {
1252 isConst = passByReference(j->type);
1258 dumpType(out, j->type, isConst, isRef);
1259 out <<
" " << j->name;
1261 if (j != method.parameters.end()) {
1271void InterfaceType::dumpNormalGetCppuType(
FileStream & out)
1273 dumpGetCppuTypePreamble(out);
1275 <<
"static typelib_TypeDescriptionReference * the_type = 0;\n"
1276 << indent() <<
"if ( !the_type )\n" << indent() <<
"{\n";
1278 std::vector< unoidl::AnnotatedReference >::size_type bases(
1279 entity_->getDirectMandatoryBases().size());
1281 && (entity_->getDirectMandatoryBases()[0].name
1282 ==
"com.sun.star.uno.XInterface")) {
1286 out << indent() <<
"typelib_TypeDescriptionReference * aSuperTypes["
1287 << entity_->getDirectMandatoryBases().size() <<
"];\n";
1288 std::vector< unoidl::AnnotatedReference >::size_type
n = 0;
1290 out << indent() <<
"aSuperTypes[" <<
n++ <<
"] = ::cppu::UnoType< ";
1291 dumpType(out, ar.name,
true,
false,
false,
true);
1292 out <<
" >::get().getTypeLibType();\n";
1295 out << indent() <<
"typelib_static_mi_interface_type_init( &the_type, \""
1296 <<
name_ <<
"\", " << bases <<
", "
1297 << (bases == 0 ?
"0" :
"aSuperTypes") <<
" );\n";
1299 out << indent() <<
"}\n" << indent()
1300 << (
"return * reinterpret_cast< ::css::uno::Type * >("
1302 dumpGetCppuTypePostamble(out);
1305void InterfaceType::dumpComprehensiveGetCppuType(
FileStream & out)
1308 OUString staticTypeClass(
"the" + id_ +
"Type");
1309 out <<
" namespace detail {\n\n" << indent() <<
"struct " << staticTypeClass
1310 <<
" : public rtl::StaticWithInit< ::css::uno::Type *, "
1311 << staticTypeClass <<
" >\n" << indent() <<
"{\n";
1313 out << indent() <<
"::css::uno::Type * operator()() const\n"
1314 << indent() <<
"{\n";
1316 out << indent() <<
"::rtl::OUString sTypeName( \"" <<
name_ <<
"\" );\n\n"
1317 << indent() <<
"// Start inline typedescription generation\n"
1318 << indent() <<
"typelib_InterfaceTypeDescription * pTD = 0;\n\n";
1319 out << indent() <<
"typelib_TypeDescriptionReference * aSuperTypes["
1320 << entity_->getDirectMandatoryBases().size() <<
"];\n";
1321 std::vector< unoidl::AnnotatedReference >::size_type
n = 0;
1323 out << indent() <<
"aSuperTypes[" <<
n++ <<
"] = ::cppu::UnoType< ";
1324 dumpType(out, ar.name,
false,
false,
false,
true);
1325 out <<
" >::get().getTypeLibType();\n";
1327 std::size_t
count = entity_->getDirectAttributes().size()
1328 + entity_->getDirectMethods().size();
1330 out << indent() <<
"typelib_TypeDescriptionReference * pMembers["
1331 <<
count <<
"] = { ";
1332 for (std::size_t i = 0;
i !=
count; ++
i) {
1334 if (i + 1 != count) {
1339 sal_uInt32
index = 0;
1340 dumpCppuAttributeRefs(out, index);
1341 dumpCppuMethodRefs(out, index);
1343 out <<
"\n" << indent() <<
"typelib_typedescription_newMIInterface(\n";
1345 out << indent() <<
"&pTD,\n" << indent()
1346 <<
"sTypeName.pData, 0, 0, 0, 0, 0,\n" << indent()
1347 << entity_->getDirectMandatoryBases().size() <<
", aSuperTypes,\n"
1348 << indent() <<
count <<
",\n" << indent()
1349 << (
count == 0 ?
"0" :
"pMembers") <<
" );\n\n";
1352 << (
"typelib_typedescription_register( (typelib_TypeDescription**)&pTD"
1354 for (std::size_t i = 0;
i !=
count; ++
i) {
1355 out << indent() <<
"typelib_typedescriptionreference_release( pMembers["
1359 << (
"typelib_typedescription_release( (typelib_TypeDescription*)pTD"
1361 << indent() <<
"return new ::css::uno::Type( "
1362 <<
getTypeClass(name_) <<
", sTypeName ); // leaked\n";
1364 out << indent() <<
"}\n";
1366 out << indent() <<
"};\n\n";
1369 dumpGetCppuTypePreamble(out);
1370 out << indent() <<
"const ::css::uno::Type &rRet = *detail::"
1371 << staticTypeClass <<
"::get();\n" << indent()
1372 <<
"// End inline typedescription generation\n" << indent()
1373 <<
"static bool bInitStarted = false;\n" << indent()
1374 <<
"if (!bInitStarted)\n" << indent() <<
"{\n";
1377 <<
"::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );\n"
1378 << indent() <<
"if (!bInitStarted)\n" << indent() <<
"{\n";
1380 out << indent() <<
"OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER();\n"
1381 << indent() <<
"bInitStarted = true;\n";
1382 std::set< OUString > seen;
1384 seen.insert(
"com.sun.star.uno.RuntimeException");
1385 dumpCppuGetType(out, u
"com.sun.star.uno.RuntimeException");
1386 dumpAttributesCppuDecl(out, &seen);
1387 dumpMethodsCppuDecl(out, &seen);
1389 sal_uInt32
index = getInheritedMemberCount();
1390 dumpCppuAttributes(out, index);
1391 dumpCppuMethods(out, index);
1394 out << indent() <<
"}\n";
1396 out << indent() <<
"}\n" << indent() <<
"else\n" << indent() <<
"{\n";
1398 out << indent() <<
"OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER();\n";
1400 out << indent() <<
"}\n" << indent() <<
"return rRet;\n";
1401 dumpGetCppuTypePostamble(out);
1404void InterfaceType::dumpCppuAttributeRefs(
FileStream & out, sal_uInt32 & index)
1406 std::vector< unoidl::InterfaceTypeEntity::Attribute >::size_type
n = 0;
1408 out << indent() <<
"::rtl::OUString sAttributeName" <<
n <<
"( \""
1409 <<
name_ <<
"::" << attr.name <<
"\" );\n" << indent()
1410 <<
"typelib_typedescriptionreference_new( &pMembers[" <<
index++
1414 <<
"(typelib_TypeClass)::css::uno::TypeClass_INTERFACE_ATTRIBUTE,\n"
1415 << indent() <<
"sAttributeName" <<
n <<
".pData );\n";
1421void InterfaceType::dumpCppuMethodRefs(
FileStream & out, sal_uInt32 & index)
1423 std::vector< unoidl::InterfaceTypeEntity::Method >::size_type
n = 0;
1425 out << indent() <<
"::rtl::OUString sMethodName" <<
n <<
"( \"" <<
name_
1426 <<
"::" << method.name <<
"\" );\n" << indent()
1427 <<
"typelib_typedescriptionreference_new( &pMembers[" <<
index++
1431 <<
"(typelib_TypeClass)::css::uno::TypeClass_INTERFACE_METHOD,\n"
1432 << indent() <<
"sMethodName" <<
n <<
".pData );\n";
1438void InterfaceType::addComprehensiveGetCppuTypeIncludes(
1446 includes.
add(
"com.sun.star.uno.RuntimeException");
1449void InterfaceType::dumpCppuAttributes(
FileStream & out, sal_uInt32 & index)
1451 if (entity_->getDirectAttributes().empty())
1454 out <<
"\n" << indent()
1455 <<
"typelib_InterfaceAttributeTypeDescription * pAttribute = 0;\n";
1456 std::vector< unoidl::InterfaceTypeEntity::Attribute >::size_type
n = 0;
1458 OUString
type(resolveAllTypedefs(attr.type));
1459 out << indent() <<
"{\n";
1461 out << indent() <<
"::rtl::OUString sAttributeType" <<
n <<
"( \""
1462 <<
type <<
"\" );\n" << indent()
1463 <<
"::rtl::OUString sAttributeName" <<
n <<
"( \"" <<
name_
1464 <<
"::" << attr.name <<
"\" );\n";
1465 sal_Int32 getExcn = dumpExceptionTypeNames(
1466 out, u
"get", attr.getExceptions,
false);
1467 sal_Int32 setExcn = dumpExceptionTypeNames(
1468 out, u
"set", attr.setExceptions,
false);
1470 << (
"typelib_typedescription_newExtendedInterfaceAttribute("
1473 out << indent() <<
index++ <<
", sAttributeName" <<
n
1474 <<
".pData,\n" << indent() <<
"(typelib_TypeClass)"
1475 <<
getTypeClass(type) <<
", sAttributeType" <<
n <<
".pData,\n"
1476 << indent() <<
"sal_" << (attr.readOnly ?
"True" :
"False")
1477 <<
", " << getExcn <<
", "
1478 << (getExcn == 0 ?
"0" :
"the_getExceptions") <<
", " << setExcn
1479 <<
", " << (setExcn == 0 ?
"0" :
"the_setExceptions")
1483 << (
"typelib_typedescription_register("
1484 " (typelib_TypeDescription**)&pAttribute );\n");
1486 out << indent() <<
"}\n";
1490 << (
"typelib_typedescription_release("
1491 " (typelib_TypeDescription*)pAttribute );\n");
1494void InterfaceType::dumpCppuMethods(
FileStream & out, sal_uInt32 & index)
1496 if (entity_->getDirectMethods().empty())
1499 out <<
"\n" << indent()
1500 <<
"typelib_InterfaceMethodTypeDescription * pMethod = 0;\n";
1501 std::vector< unoidl::InterfaceTypeEntity::Method >::size_type
n = 0;
1503 OUString returnType(resolveAllTypedefs(method.returnType));
1504 out << indent() <<
"{\n";
1506 if (!method.parameters.empty()) {
1507 out << indent() <<
"typelib_Parameter_Init aParameters["
1508 << method.parameters.size() <<
"];\n";
1510 std::vector< unoidl::InterfaceTypeEntity::Method::Parameter >::
1513 OUString
type(resolveAllTypedefs(param.
type));
1514 out << indent() <<
"::rtl::OUString sParamName" <<
m <<
"( \""
1515 << param.
name <<
"\" );\n" << indent()
1516 <<
"::rtl::OUString sParamType" <<
m <<
"( \"" <<
type
1517 <<
"\" );\n" << indent() <<
"aParameters[" <<
m
1518 <<
"].pParamName = sParamName" <<
m <<
".pData;\n"
1519 << indent() <<
"aParameters[" <<
m
1520 <<
"].eTypeClass = (typelib_TypeClass)"
1521 <<
getTypeClass(type) <<
";\n" << indent() <<
"aParameters["
1522 <<
m <<
"].pTypeName = sParamType" <<
m <<
".pData;\n"
1523 << indent() <<
"aParameters[" <<
m <<
"].bIn = "
1526 ?
"sal_False" :
"sal_True")
1527 <<
";\n" << indent() <<
"aParameters[" <<
m <<
"].bOut = "
1530 ?
"sal_False" :
"sal_True")
1534 sal_Int32 excn = dumpExceptionTypeNames(
1535 out, u
"", method.exceptions,
1536 method.name !=
"acquire" && method.name !=
"release");
1537 out << indent() <<
"::rtl::OUString sReturnType" <<
n <<
"( \""
1538 << returnType <<
"\" );\n" << indent()
1539 <<
"::rtl::OUString sMethodName" <<
n <<
"( \"" <<
name_ <<
"::"
1540 << method.name <<
"\" );\n" << indent()
1541 <<
"typelib_typedescription_newInterfaceMethod( &pMethod,\n";
1543 out << indent() <<
index++ <<
", sal_False,\n" << indent()
1544 <<
"sMethodName" <<
n <<
".pData,\n" << indent()
1546 <<
", sReturnType" <<
n <<
".pData,\n" << indent()
1547 << method.parameters.size() <<
", "
1548 << (method.parameters.empty() ?
"0" :
"aParameters") <<
",\n"
1549 << indent() << excn <<
", "
1550 << (excn == 0 ?
"0" :
"the_Exceptions") <<
" );\n";
1553 << (
"typelib_typedescription_register("
1554 " (typelib_TypeDescription**)&pMethod );\n");
1556 out << indent() <<
"}\n";
1560 << (
"typelib_typedescription_release("
1561 " (typelib_TypeDescription*)pMethod );\n");
1564void InterfaceType::dumpAttributesCppuDecl(
1565 FileStream & out, std::set< OUString > * seen)
const
1567 assert(seen !=
nullptr);
1569 if (seen->insert(attr.type).second) {
1570 dumpCppuGetType(out, attr.type);
1572 for (
const OUString& exc : attr.getExceptions) {
1573 if (seen->insert(exc).second) {
1574 dumpCppuGetType(out, exc);
1577 for (
const OUString& exc : attr.setExceptions) {
1578 if (seen->insert(exc).second) {
1579 dumpCppuGetType(out, exc);
1585void InterfaceType::dumpMethodsCppuDecl(
1586 FileStream & out, std::set< OUString > * seen)
const
1588 assert(seen !=
nullptr);
1590 for (
const OUString& ex : method.exceptions) {
1591 if (seen->insert(ex).second) {
1592 dumpCppuGetType(out, ex);
1598void InterfaceType::dumpExceptionTypeName(
1599 FileStream & out, std::u16string_view prefix, sal_uInt32 index,
1600 std::u16string_view name)
const
1602 out << indent() <<
"::rtl::OUString the_" <<
prefix <<
"ExceptionName"
1603 <<
index <<
"( \"" <<
name <<
"\" );\n";
1606sal_Int32 InterfaceType::dumpExceptionTypeNames(
1607 FileStream & out, std::u16string_view prefix,
1608 std::vector< OUString >
const & exceptions,
bool runtimeException)
const
1610 sal_Int32
count = 0;
1611 for (
const OUString& ex : exceptions) {
1612 if (ex !=
"com.sun.star.uno.RuntimeException") {
1613 dumpExceptionTypeName(out, prefix, count++, ex);
1616 if (runtimeException) {
1617 dumpExceptionTypeName(
1618 out, prefix, count++, u
"com.sun.star.uno.RuntimeException");
1621 out << indent() <<
"rtl_uString * the_" <<
prefix <<
"Exceptions[] = {";
1622 for (sal_Int32 i = 0;
i !=
count; ++
i) {
1623 out << (
i == 0 ?
" " :
", ") <<
"the_" << prefix <<
"ExceptionName"
1637 CppuType(
name, typeMgr), entity_(entity) {
1638 assert(entity.is());
1641 bool hasConstants()
const {
1642 return !entity_->getMembers().empty();
1646 virtual void dumpHdlFile(
1649 virtual void dumpHppFile(
1652 virtual void dumpDeclaration(
FileStream & out)
override;
1657void ConstantGroup::dumpHdlFile(
1660 OUString headerDefine(dumpHeaderDefine(out, u
"HDL"));
1662 addDefaultHIncludes(includes);
1663 includes.
dump(out,
nullptr,
true);
1669 dumpDeclaration(out);
1674 out <<
"\n#endif // "<< headerDefine <<
"\n";
1677void ConstantGroup::dumpHppFile(
1680 OUString headerDefine(dumpHeaderDefine(out, u
"HPP"));
1683 out <<
"\n#endif // "<< headerDefine <<
"\n";
1686void ConstantGroup::dumpDeclaration(
FileStream & out)
1689 out <<
"static const ";
1690 switch (member.value.type) {
1692 out <<
"::sal_Bool";
1695 out <<
"::sal_Int8";
1698 out <<
"::sal_Int16";
1701 out <<
"::sal_uInt16";
1704 out <<
"::sal_Int32";
1707 out <<
"::sal_uInt32";
1710 out <<
"::sal_Int64";
1713 out <<
"::sal_uInt64";
1722 out <<
" " << member.name <<
" = ";
1723 switch (member.value.type) {
1725 out << (member.value.booleanValue ?
"sal_True" :
"sal_False");
1728 out <<
"(sal_Int8)" << OUString::number(member.value.byteValue);
1731 out <<
"(sal_Int16)" << OUString::number(member.value.shortValue);
1734 out <<
"(sal_uInt16)"
1735 << OUString::number(member.value.unsignedShortValue);
1740 if (member.value.longValue == SAL_MIN_INT32) {
1741 out <<
"SAL_MIN_INT32";
1743 out <<
"(sal_Int32)" << OUString::number(member.value.longValue);
1747 out <<
"(sal_uInt32)"
1748 << OUString::number(member.value.unsignedLongValue) <<
"U";
1753 if (member.value.hyperValue == SAL_MIN_INT64) {
1754 out <<
"SAL_MIN_INT64";
1756 out <<
"(sal_Int64) SAL_CONST_INT64("
1757 << OUString::number(member.value.hyperValue) <<
")";
1761 out <<
"SAL_CONST_UINT64("
1762 << OUString::number(member.value.unsignedHyperValue) <<
")";
1765 out <<
"(float)" << OUString::number(member.value.floatValue);
1768 out <<
"(double)" << OUString::number(member.value.doubleValue);
1775void dumpTypeParameterName(
FileStream & out, std::u16string_view name)
1780 out <<
"typeparam_" <<
name;
1783class PlainStructType:
public CppuType
1789 CppuType(
name, typeMgr), entity_(entity) {
1790 assert(entity.is());
1794 virtual sal_uInt32 checkInheritedMemberCount()
const override {
1795 return getTotalMemberCount(entity_->getDirectBase());
1798 virtual void dumpDeclaration(
FileStream& o)
override;
1802 virtual void dumpLightGetCppuType(
FileStream & out)
override;
1804 virtual void dumpNormalGetCppuType(
FileStream & out)
override;
1806 virtual void dumpComprehensiveGetCppuType(
FileStream & out)
override;
1808 virtual void addLightGetCppuTypeIncludes(
1811 virtual void addNormalGetCppuTypeIncludes(
1814 virtual void addComprehensiveGetCppuTypeIncludes(
1817 bool dumpBaseMembers(
1818 FileStream & out, OUString
const & base,
bool withType);
1820 sal_uInt32 getTotalMemberCount(OUString
const & base)
const;
1825void PlainStructType::dumpDeclaration(
FileStream & out)
1827 out <<
"\n#ifdef _WIN32\n# pragma pack(push, 8)\n#endif\n\n" << indent();
1828 out <<
"struct SAL_DLLPUBLIC_RTTI ";
1829 if (canBeWarnUnused(name_))
1830 out <<
"SAL_WARN_UNUSED ";
1832 OUString
base(entity_->getDirectBase());
1833 if (!
base.isEmpty()) {
1838 out << indent() <<
"inline " << id_ <<
"();\n";
1839 if (!entity_->getDirectMembers().empty() || getInheritedMemberCount() > 0) {
1840 out <<
"\n" << indent() <<
"inline " << id_ <<
"(";
1841 bool bFirst = !dumpBaseMembers(out, base,
true);
1846 dumpType(out, member.type,
true,
true);
1847 out <<
" " << member.name <<
"_";
1852 if (!entity_->getDirectMembers().empty()) {
1854 for (std::vector< unoidl::PlainStructTypeEntity::Member >::
1855 const_iterator
i(entity_->getDirectMembers().begin());
1856 i != entity_->getDirectMembers().end(); ++i) {
1858 dumpType(out,
i->type);
1859 out <<
" " <<
i->name;
1860 if (i == entity_->getDirectMembers().begin() && !
base.isEmpty()
1861 &&
i->type !=
"hyper" &&
i->type !=
"unsigned hyper"
1862 &&
i->type !=
"double") {
1863 out <<
" CPPU_GCC3_ALIGN("
1870 out <<
"};\n\n#ifdef _WIN32\n# pragma pack(pop)\n#endif\n\n";
1873void PlainStructType::dumpHppFile(
1876 OUString headerDefine(dumpHeaderDefine(out, u
"HPP"));
1878 includes.
dump(out, &name_,
true);
1883 out <<
"\ninline " << id_ <<
"::" << id_ <<
"()\n";
1885 OUString
base(entity_->getDirectBase());
1887 if (!
base.isEmpty()) {
1893 out << indent() << (bFirst ?
":" :
",") <<
" " << member.name;
1894 dumpInitializer(out,
false, member.type);
1900 if (!entity_->getDirectMembers().empty() || getInheritedMemberCount() > 0) {
1901 out <<
"inline " << id_;
1902 out <<
"::" << id_ <<
"(";
1903 bFirst = !dumpBaseMembers(out, base,
true);
1908 dumpType(out, member.type,
true,
true);
1909 out <<
" " << member.name <<
"_";
1915 if (!
base.isEmpty()) {
1918 dumpBaseMembers(out, base,
false);
1923 out << indent() << (bFirst ?
":" :
",") <<
" " << member.name <<
"("
1924 << member.name <<
"_)\n";
1931 out <<
"\ninline bool operator==(const " << id_ <<
"& the_lhs, const " << id_ <<
"& the_rhs)\n";
1934 out << indent() <<
"return ";
1936 if (!
base.isEmpty()) {
1943 out <<
"\n" << indent() << indent() <<
"&& ";
1944 out <<
"the_lhs." << member.name <<
" == the_rhs." << member.name;
1951 out <<
"\ninline bool operator!=(const " << id_ <<
"& the_lhs, const " << id_ <<
"& the_rhs)\n";
1953 out << indent() <<
"return !operator==(the_lhs, the_rhs);\n";
1960 dumpGetCppuType(out);
1961 out <<
"\n#endif // "<< headerDefine <<
"\n";
1964void PlainStructType::dumpLightGetCppuType(
FileStream & out)
1966 dumpGetCppuTypePreamble(out);
1968 << (
"//TODO: On certain platforms with weak memory models, the"
1969 " following code can result in some threads observing that the_type"
1970 " points to garbage\n")
1972 <<
"static ::typelib_TypeDescriptionReference * the_type = 0;\n"
1973 << indent() <<
"if (the_type == 0) {\n";
1975 out << indent() <<
"::typelib_static_type_init(&the_type, "
1978 out << indent() <<
"}\n" << indent()
1979 <<
"return *reinterpret_cast< ::css::uno::Type * >(&the_type);\n";
1980 dumpGetCppuTypePostamble(out);
1983void PlainStructType::dumpNormalGetCppuType(
FileStream & out)
1985 dumpGetCppuTypePreamble(out);
1987 << (
"//TODO: On certain platforms with weak memory models, the"
1988 " following code can result in some threads observing that the_type"
1989 " points to garbage\n")
1991 <<
"static ::typelib_TypeDescriptionReference * the_type = 0;\n"
1992 << indent() <<
"if (the_type == 0) {\n";
1995 <<
"::typelib_TypeDescriptionReference * the_members[] = {\n";
1997 for (std::vector< unoidl::PlainStructTypeEntity::Member >::const_iterator
i(
1998 entity_->getDirectMembers().begin());
1999 i != entity_->getDirectMembers().end();) {
2000 out << indent() <<
"::cppu::UnoType< ";
2001 dumpType(out,
i->type,
false,
false,
false,
true);
2003 out <<
" >::get().getTypeLibType()"
2004 << (
i == entity_->getDirectMembers().end() ?
" };" :
",") <<
"\n";
2007 out << indent() <<
"::typelib_static_struct_type_init(&the_type, \""
2009 if (entity_->getDirectBase().isEmpty()) {
2012 out <<
"::cppu::UnoType< ";
2013 dumpType(out, entity_->getDirectBase(),
false,
false,
false,
true);
2014 out <<
" >::get().getTypeLibType()";
2016 out <<
", " << entity_->getDirectMembers().size() <<
", the_members, 0);\n";
2018 out << indent() <<
"}\n" << indent()
2019 <<
"return *reinterpret_cast< ::css::uno::Type * >(&the_type);\n";
2020 dumpGetCppuTypePostamble(out);
2023void PlainStructType::dumpComprehensiveGetCppuType(
FileStream & out)
2025 OUString staticTypeClass(
"the" + id_ +
"Type");
2027 out <<
" namespace detail {\n\n" << indent() <<
"struct "
2029 <<
" : public rtl::StaticWithInit< ::css::uno::Type *, "
2030 << staticTypeClass <<
" >\n" << indent() <<
"{\n";
2032 out << indent() <<
"::css::uno::Type * operator()() const\n"
2033 << indent() <<
"{\n";
2035 out << indent() <<
"::rtl::OUString the_name( \"" <<
name_ <<
"\" );\n";
2036 std::map< OUString, sal_uInt32 > types;
2037 std::vector< unoidl::PlainStructTypeEntity::Member >::size_type
n = 0;
2040 member.type,
static_cast< sal_uInt32
>(types.size())).
2042 dumpCppuGetType(out, member.type, &name_);
2048 out << indent() <<
"::rtl::OUString the_tname"
2049 <<
static_cast< sal_uInt32
>(types.size() - 1) <<
"( \""
2050 << resolveAllTypedefs(member.type) <<
"\" );\n";
2052 out << indent() <<
"::rtl::OUString the_name" <<
n++ <<
"( \""
2053 << member.name <<
"\" );\n";
2055 out << indent() <<
"::typelib_StructMember_Init the_members[] = {\n";
2058 for (std::vector< unoidl::PlainStructTypeEntity::Member >::const_iterator
i(
2059 entity_->getDirectMembers().begin());
2060 i != entity_->getDirectMembers().end();) {
2062 <<
", the_tname" << types.find(
i->type)->second
2063 <<
".pData, the_name" <<
n++ <<
".pData }, false }";
2065 out << (
i == entity_->getDirectMembers().end() ?
" };" :
",") <<
"\n";
2068 out << indent() <<
"::typelib_TypeDescription * the_newType = 0;\n"
2070 <<
"::typelib_typedescription_newStruct(&the_newType, the_name.pData, ";
2071 if (entity_->getDirectBase().isEmpty()) {
2074 out <<
"::cppu::UnoType< ";
2075 dumpType(out, entity_->getDirectBase(),
false,
false,
false,
true);
2076 out <<
" >::get().getTypeLibType()";
2078 out <<
", " << entity_->getDirectMembers().size() <<
", the_members);\n"
2079 << indent() <<
"::typelib_typedescription_register(&the_newType);\n"
2080 << indent() <<
"::typelib_typedescription_release(the_newType);\n"
2081 << indent() <<
"return new ::css::uno::Type("
2084 out << indent() <<
"}\n";
2086 out << indent() <<
"};\n";
2089 dumpGetCppuTypePreamble(out);
2090 out << indent() <<
"return *detail::" << staticTypeClass <<
"::get();\n";
2091 dumpGetCppuTypePostamble(out);
2094bool PlainStructType::dumpBaseMembers(
2095 FileStream & out, OUString
const & base,
bool withType)
2104 "plain struct type base " + base
2105 +
" is not a plain struct type");
2113 bool hasMember = dumpBaseMembers(out, ent2->getDirectBase(), withType);
2119 dumpType(out, member.type,
true,
true);
2122 out << member.name <<
"_";
2128void PlainStructType::addLightGetCppuTypeIncludes(
2138void PlainStructType::addNormalGetCppuTypeIncludes(
2148void PlainStructType::addComprehensiveGetCppuTypeIncludes(
2161sal_uInt32 PlainStructType::getTotalMemberCount(OUString
const & base)
const
2163 if (
base.isEmpty()) {
2170 "plain struct type base " + base +
" is not a plain struct type");
2178 return getTotalMemberCount(ent2->getDirectBase())
2179 + ent2->getDirectMembers().size();
2182class PolyStructType:
public CppuType
2189 CppuType(
name, typeMgr), entity_(entity) {
2190 assert(entity.is());
2194 virtual void dumpDeclaration(
FileStream& o)
override;
2198 virtual void dumpLightGetCppuType(
FileStream & out)
override;
2200 virtual void dumpNormalGetCppuType(
FileStream & out)
override;
2202 virtual void dumpComprehensiveGetCppuType(
FileStream & out)
override;
2204 virtual void addLightGetCppuTypeIncludes(
2207 virtual void addNormalGetCppuTypeIncludes(
2210 virtual void addComprehensiveGetCppuTypeIncludes(
2213 virtual bool isPolymorphic()
const override {
2217 virtual void dumpTemplateHead(
FileStream & out)
const override;
2219 virtual void dumpTemplateParameters(
FileStream & out)
const override;
2224void PolyStructType::dumpDeclaration(
FileStream & out)
2226 out <<
"\n#ifdef _WIN32\n# pragma pack(push, 8)\n#endif\n\n" << indent();
2227 dumpTemplateHead(out);
2228 out <<
"struct SAL_DLLPUBLIC_RTTI " << id_ <<
" {\n";
2230 out << indent() <<
"inline " << id_ <<
"();\n";
2231 if (!entity_->getMembers().empty()) {
2232 out <<
"\n" << indent() <<
"inline " << id_ <<
"(";
2235 const_iterator
i(entity_->getMembers().begin());
2236 i != entity_->getMembers().end(); ++i) {
2237 if (i != entity_->getMembers().begin()) {
2240 if (
i->parameterized) {
2241 dumpTypeParameterName(out,
i->type);
2244 dumpType(out,
i->type,
true,
true);
2246 out <<
" " <<
i->name <<
"_";
2251 entity_->getMembers()) {
2253 if (member.parameterized) {
2254 dumpTypeParameterName(out, member.type);
2256 dumpType(out, member.type);
2258 out <<
" " << member.name <<
";\n";
2262 out <<
"};\n\n#ifdef _WIN32\n# pragma pack(pop)\n#endif\n\n";
2265void PolyStructType::dumpHppFile(
2268 OUString headerDefine(dumpHeaderDefine(out, u
"HPP"));
2270 includes.
dump(out, &name_,
true);
2277 dumpTemplateHead(out);
2278 out <<
"inline " << id_;
2279 dumpTemplateParameters(out);
2280 out <<
"::" << id_ <<
"()\n";
2282 for (std::vector< unoidl::PolymorphicStructTypeTemplateEntity::Member >::
2283 const_iterator
i(entity_->getMembers().begin());
2284 i != entity_->getMembers().end(); ++i) {
2285 out << indent() << (
i == entity_->getMembers().begin() ?
":" :
",")
2287 dumpInitializer(out,
i->parameterized,
i->type);
2292 if (!entity_->getMembers().empty()) {
2294 dumpTemplateHead(out);
2295 out <<
"inline " << id_;
2296 dumpTemplateParameters(out);
2297 out <<
"::" << id_ <<
"(";
2300 const_iterator
i(entity_->getMembers().begin());
2301 i != entity_->getMembers().end(); ++i) {
2302 if (i != entity_->getMembers().begin()) {
2305 if (
i->parameterized) {
2306 dumpTypeParameterName(out,
i->type);
2309 dumpType(out,
i->type,
true,
true);
2311 out <<
" " <<
i->name <<
"_";
2317 const_iterator
i(entity_->getMembers().begin());
2318 i != entity_->getMembers().end(); ++i) {
2319 out << indent() << (
i == entity_->getMembers().begin() ?
":" :
",")
2320 <<
" " <<
i->name <<
"(" <<
i->name <<
"_)\n";
2323 out <<
"{\n}\n\n" << indent();
2325 dumpTemplateHead(out);
2326 out <<
"\n" << indent() <<
"inline " << id_;
2327 dumpTemplateParameters(out);
2328 out <<
"\n" << indent() <<
"make_" << id_ <<
"(";
2331 const_iterator
i(entity_->getMembers().begin());
2332 i != entity_->getMembers().end(); ++i) {
2333 if (i != entity_->getMembers().begin()) {
2336 if (
i->parameterized) {
2337 dumpTypeParameterName(out,
i->type);
2340 dumpType(out,
i->type,
true,
true);
2342 out <<
" " <<
i->name <<
"_";
2344 out <<
")\n" << indent() <<
"{\n";
2346 out << indent() <<
"return " << id_;
2347 dumpTemplateParameters(out);
2351 const_iterator
i(entity_->getMembers().begin());
2352 i != entity_->getMembers().end(); ++i) {
2353 if (i != entity_->getMembers().begin()) {
2356 out <<
i->name <<
"_";
2360 out << indent() <<
"}\n\n";
2363 dumpTemplateHead(out);
2364 out <<
" inline bool operator==(const " << id_;
2365 dumpTemplateParameters(out);
2366 out <<
"& the_lhs, const " << id_;
2367 dumpTemplateParameters(out);
2368 out <<
"& the_rhs)\n";
2371 out << indent() <<
"return ";
2375 out <<
"\n" << indent() << indent() <<
"&& ";
2376 out <<
"the_lhs." << member.name <<
" == the_rhs." << member.name;
2383 dumpTemplateHead(out);
2384 out <<
" inline bool operator!=(const " << id_;
2385 dumpTemplateParameters(out);
2386 out <<
"& the_lhs, const " << id_;
2387 dumpTemplateParameters(out);
2388 out <<
"& the_rhs)\n";
2390 out << indent() <<
"return !operator==(the_lhs, the_rhs);\n";
2397 dumpGetCppuType(out);
2398 out <<
"\n#endif // "<< headerDefine <<
"\n";
2401void PolyStructType::dumpLightGetCppuType(
FileStream & out)
2403 dumpGetCppuTypePreamble(out);
2405 << (
"//TODO: On certain platforms with weak memory models, the"
2406 " following code can result in some threads observing that the_type"
2407 " points to garbage\n")
2409 <<
"static ::typelib_TypeDescriptionReference * the_type = 0;\n"
2410 << indent() <<
"if (the_type == 0) {\n";
2413 out <<
"#ifdef LIBO_INTERNAL_ONLY\n";
2415 out << indent() <<
"::rtl::OString the_buffer = \"" <<
name_
2417 for (std::vector< OUString >::const_iterator
i(
2418 entity_->getTypeParameters().begin());
2419 i != entity_->getTypeParameters().end();) {
2421 << (
"::rtl::OUStringToOString("
2422 "::cppu::getTypeFavourChar(static_cast< ");
2423 dumpTypeParameterName(out, *i);
2424 out <<
" * >(0)).getTypeName(), RTL_TEXTENCODING_UTF8) +\n";
2426 if (i != entity_->getTypeParameters().end()) {
2427 out << indent() <<
"\",\" +\n";
2430 out << indent() <<
"\">\";\n";
2434 out << indent() <<
"::rtl::OStringBuffer the_buffer(\"" <<
name_
2436 for (std::vector< OUString >::const_iterator
i(
2437 entity_->getTypeParameters().begin());
2438 i != entity_->getTypeParameters().end();) {
2440 << (
"the_buffer.append(::rtl::OUStringToOString("
2441 "::cppu::getTypeFavourChar(static_cast< ");
2442 dumpTypeParameterName(out, *i);
2443 out <<
" * >(0)).getTypeName(), RTL_TEXTENCODING_UTF8));\n";
2445 if (i != entity_->getTypeParameters().end()) {
2446 out << indent() <<
"the_buffer.append(',');\n";
2449 out << indent() <<
"the_buffer.append('>');\n";
2454 <<
"::typelib_static_type_init(&the_type, " <<
getTypeClass(name_,
true)
2455 <<
", the_buffer.getStr());\n";
2458 out << indent() <<
"}\n" << indent()
2459 <<
"return *reinterpret_cast< ::css::uno::Type * >(&the_type);\n";
2460 dumpGetCppuTypePostamble(out);
2463void PolyStructType::dumpNormalGetCppuType(
FileStream & out)
2465 dumpGetCppuTypePreamble(out);
2467 << (
"//TODO: On certain platforms with weak memory models, the"
2468 " following code can result in some threads observing that the_type"
2469 " points to garbage\n")
2471 <<
"static ::typelib_TypeDescriptionReference * the_type = 0;\n"
2472 << indent() <<
"if (the_type == 0) {\n";
2474 out << indent() <<
"::rtl::OStringBuffer the_buffer(\"" <<
name_
2476 for (std::vector< OUString >::const_iterator
i(
2477 entity_->getTypeParameters().begin());
2478 i != entity_->getTypeParameters().end();) {
2480 << (
"the_buffer.append(::rtl::OUStringToOString("
2481 "::cppu::getTypeFavourChar(static_cast< ");
2482 dumpTypeParameterName(out, *i);
2483 out <<
" * >(0)).getTypeName(), RTL_TEXTENCODING_UTF8));\n";
2485 if (i != entity_->getTypeParameters().end()) {
2486 out << indent() <<
"the_buffer.append(',');\n";
2489 out << indent() <<
"the_buffer.append('>');\n" << indent()
2490 <<
"::typelib_TypeDescriptionReference * the_members[] = {\n";
2492 for (std::vector< unoidl::PolymorphicStructTypeTemplateEntity::Member >::
2493 const_iterator
i(entity_->getMembers().begin());
2494 i != entity_->getMembers().end();) {
2496 if (
i->parameterized) {
2497 out <<
"::cppu::getTypeFavourChar(static_cast< ";
2498 dumpTypeParameterName(out,
i->type);
2501 out <<
"::cppu::UnoType< ";
2502 dumpType(out,
i->type,
false,
false,
false,
true);
2506 out <<
".getTypeLibType()"
2507 << (
i == entity_->getMembers().end() ?
" };" :
",") <<
"\n";
2510 out << indent() <<
"static ::sal_Bool const the_parameterizedTypes[] = { ";
2511 for (std::vector< unoidl::PolymorphicStructTypeTemplateEntity::Member >::
2512 const_iterator
i(entity_->getMembers().begin());
2513 i != entity_->getMembers().end(); ++i) {
2514 if (i != entity_->getMembers().begin()) {
2517 out << (
i->parameterized ?
"true" :
"false");
2519 out <<
" };\n" << indent()
2520 << (
"::typelib_static_struct_type_init(&the_type, the_buffer.getStr(),"
2522 << entity_->getMembers().size()
2523 <<
", the_members, the_parameterizedTypes);\n";
2525 out << indent() <<
"}\n" << indent()
2526 << (
"return *reinterpret_cast< ::css::uno::Type * >("
2528 dumpGetCppuTypePostamble(out);
2531void PolyStructType::dumpComprehensiveGetCppuType(
FileStream & out)
2533 out <<
"namespace cppu { namespace detail {\n\n" << indent();
2534 dumpTemplateHead(out);
2535 OUString staticTypeClass(
"the" + id_ +
"Type");
2536 out <<
"struct " << staticTypeClass
2537 <<
" : public rtl::StaticWithInit< ::css::uno::Type *, "
2539 dumpTemplateParameters(out);
2540 out <<
" >\n" << indent() <<
"{\n";
2542 out << indent() <<
"::css::uno::Type * operator()() const\n"
2543 << indent() <<
"{\n";
2546 out <<
"#ifdef LIBO_INTERNAL_ONLY\n";
2548 <<
"::rtl::OUString the_name =\n";
2549 out << indent() <<
"\"" <<
name_ <<
"<\" +\n";
2550 for (std::vector< OUString >::const_iterator
i(
2551 entity_->getTypeParameters().begin());
2552 i != entity_->getTypeParameters().end();) {
2554 <<
"::cppu::getTypeFavourChar(static_cast< ";
2555 dumpTypeParameterName(out, *i);
2556 out <<
" * >(0)).getTypeName() +\n";
2558 if (i != entity_->getTypeParameters().end()) {
2566 out << indent() <<
"::rtl::OUStringBuffer the_buffer;\n" << indent()
2567 <<
"the_buffer.append(\"" <<
name_ <<
"<\");\n";
2568 for (std::vector< OUString >::const_iterator
i(
2569 entity_->getTypeParameters().begin());
2570 i != entity_->getTypeParameters().end();) {
2572 <<
"the_buffer.append(::cppu::getTypeFavourChar(static_cast< ";
2573 dumpTypeParameterName(out, *i);
2574 out <<
" * >(0)).getTypeName());\n";
2576 if (i != entity_->getTypeParameters().end()) {
2578 << (
"the_buffer.append("
2579 "static_cast< ::sal_Unicode >(','));\n");
2582 out << indent() <<
"the_buffer.append(static_cast< ::sal_Unicode >('>'));\n";
2584 <<
"::rtl::OUString the_name(the_buffer.makeStringAndClear());\n";
2586 std::map< OUString, sal_uInt32 > parameters;
2587 std::map< OUString, sal_uInt32 > types;
2588 std::vector< unoidl::PolymorphicStructTypeTemplateEntity::Member >::
2591 if (member.parameterized) {
2592 if (parameters.emplace(
2593 member.type,
static_cast< sal_uInt32
>(parameters.size())).
2595 sal_uInt32 k =
static_cast< sal_uInt32
>(parameters.size() - 1);
2597 <<
"::css::uno::Type const & the_ptype" << k
2598 <<
" = ::cppu::getTypeFavourChar(static_cast< ";
2599 dumpTypeParameterName(out, member.type);
2600 out <<
" * >(0));\n" << indent()
2601 <<
"::typelib_TypeClass the_pclass" << k
2602 <<
" = (::typelib_TypeClass) the_ptype" << k
2603 <<
".getTypeClass();\n" << indent()
2604 <<
"::rtl::OUString the_pname" << k <<
"(the_ptype" << k
2605 <<
".getTypeName());\n";
2607 }
else if (types.emplace(member.type,
static_cast< sal_uInt32
>(types.size())).
2609 dumpCppuGetType(out, member.type, &name_);
2615 out << indent() <<
"::rtl::OUString the_tname"
2616 <<
static_cast< sal_uInt32
>(types.size() - 1) <<
"( \""
2617 << resolveAllTypedefs(member.type) <<
"\" );\n";
2619 out << indent() <<
"::rtl::OUString the_name" <<
n++ <<
"( \""
2620 << member.name <<
"\" );\n";
2622 out << indent() <<
"::typelib_StructMember_Init the_members[] = {\n";
2625 for (std::vector< unoidl::PolymorphicStructTypeTemplateEntity::Member >::
2626 const_iterator
i(entity_->getMembers().begin());
2627 i != entity_->getMembers().end();) {
2628 out << indent() <<
"{ { ";
2629 if (
i->parameterized) {
2630 sal_uInt32 k = parameters.find(
i->type)->second;
2631 out <<
"the_pclass" << k <<
", the_pname" << k <<
".pData";
2634 << types.find(
i->type)->second <<
".pData";
2636 out <<
", the_name" <<
n++ <<
".pData }, "
2637 << (
i->parameterized ?
"true" :
"false") <<
" }";
2639 out << (
i == entity_->getMembers().end() ?
" };" :
",") <<
"\n";
2642 out << indent() <<
"::typelib_TypeDescription * the_newType = 0;\n";
2644 << (
"::typelib_typedescription_newStruct(&the_newType, the_name.pData,"
2646 << entity_->getMembers().size() <<
", the_members);\n" << indent()
2647 <<
"::typelib_typedescription_register(&the_newType);\n" << indent()
2648 <<
"::typelib_typedescription_release(the_newType);\n" << indent()
2649 <<
"return new ::css::uno::Type(" <<
getTypeClass(name_)
2650 <<
", the_name); // leaked\n";
2652 out << indent() <<
"}\n";
2654 out << indent() <<
"};\n } }\n\n";
2655 dumpGetCppuTypePreamble(out);
2656 out << indent() <<
"return *detail::" << staticTypeClass;
2657 dumpTemplateParameters(out);
2658 out <<
"::get();\n";
2659 dumpGetCppuTypePostamble(out);
2662void PolyStructType::addLightGetCppuTypeIncludes(
2675void PolyStructType::addNormalGetCppuTypeIncludes(
2688void PolyStructType::addComprehensiveGetCppuTypeIncludes(
2703void PolyStructType::dumpTemplateHead(
FileStream & out)
const
2705 out <<
"template< ";
2706 for (std::vector< OUString >::const_iterator
i(
2707 entity_->getTypeParameters().begin());
2708 i != entity_->getTypeParameters().end(); ++i) {
2709 if (i != entity_->getTypeParameters().begin()) {
2713 dumpTypeParameterName(out, *i);
2718void PolyStructType::dumpTemplateParameters(
FileStream & out)
const
2721 for (std::vector< OUString >::const_iterator
i(
2722 entity_->getTypeParameters().begin());
2723 i != entity_->getTypeParameters().end(); ++i) {
2724 if (i != entity_->getTypeParameters().begin()) {
2727 dumpTypeParameterName(out, *i);
2732OUString typeToIdentifier(std::u16string_view name)
2736 OUStringBuffer b(4*k +
n.getLength());
2737 for (sal_Int32 i = 0;
i != k; ++
i) {
2741 b.replace(
' ',
'_');
2742 b.replace(
',',
'_');
2743 b.replace(
'.',
'_');
2744 b.replace(
'<',
'_');
2745 b.replace(
'>',
'_');
2746 return b.makeStringAndClear();
2755 CppuType(
name, typeMgr), entity_(entity) {
2756 assert(entity.is());
2760 virtual void dumpHdlFile(
2763 virtual void dumpHppFile(
2766 virtual void addComprehensiveGetCppuTypeIncludes(
2769 virtual void dumpLightGetCppuType(
FileStream & out)
override;
2771 virtual void dumpNormalGetCppuType(
FileStream & out)
override;
2773 virtual void dumpComprehensiveGetCppuType(
FileStream & out)
override;
2775 virtual sal_uInt32 checkInheritedMemberCount()
const override {
2776 return getTotalMemberCount(entity_->getDirectBase());
2779 virtual void dumpDeclaration(
FileStream & out)
override;
2781 bool dumpBaseMembers(
2782 FileStream & out, OUString
const & base,
bool withType,
2783 bool eligibleForDefaults);
2785 sal_uInt32 getTotalMemberCount(OUString
const & base)
const;
2790void ExceptionType::dumpHdlFile(
2793 if (name_ ==
"com.sun.star.uno.Exception")
2799 includes.
addCustom(
"#if defined LIBO_INTERNAL_ONLY && ((defined __GNUC__ && !defined __clang__) || (defined __clang__ && __clang_major__ >= 9)) && __has_include(<experimental/source_location>)");
2800 includes.
addCustom(
"#define LIBO_USE_SOURCE_LOCATION");
2802 includes.
addCustom(
"#if defined LIBO_USE_SOURCE_LOCATION");
2803 includes.
addCustom(
"#include <experimental/source_location>");
2804 includes.
addCustom(
"#include <o3tl/runtimetooustring.hxx>");
2807 dumpHFileContent(out, includes);
2810void ExceptionType::addComprehensiveGetCppuTypeIncludes(
2817void ExceptionType::dumpHppFile(
2820 OUString headerDefine(dumpHeaderDefine(out, u
"HPP"));
2822 addDefaultHxxIncludes(includes);
2823 includes.
dump(out, &name_,
true);
2826 if (name_ ==
"com.sun.star.uno.Exception")
2828 out <<
"#if defined LIBO_INTERNAL_ONLY\n";
2829 out <<
"#include <ostream>\n";
2830 out <<
"#include <typeinfo>\n";
2841 out <<
"\ninline " << id_ <<
"::" << id_ <<
"(\n";
2842 out <<
"#if defined LIBO_USE_SOURCE_LOCATION\n";
2843 out <<
" std::experimental::source_location location\n";
2847 OUString
base(entity_->getDirectBase());
2849 if (!
base.isEmpty()) {
2852 out <<
"#if defined LIBO_USE_SOURCE_LOCATION\n";
2853 out <<
" location\n";
2859 out << indent() << (bFirst ?
":" :
",") <<
" ";
2861 dumpInitializer(out,
false, member.type);
2867 if (!m_cppuTypeDynamic) {
2870 dumpCppuGetType(out, name_);
2875 if (name_ ==
"com.sun.star.uno.Exception")
2877 out <<
"\n#if defined LIBO_USE_SOURCE_LOCATION\n";
2878 out <<
" if (!Message.isEmpty())\n";
2879 out <<
" Message += \" \";\n";
2880 out <<
" Message += \"at \" + o3tl::runtimeToOUString(location.file_name()) + \":\" + OUString::number(location.line());\n";
2886 if (!entity_->getDirectMembers().empty() || getInheritedMemberCount() > 0) {
2887 out << indent() <<
"inline " << id_ <<
"::" << id_ <<
"(";
2888 bFirst = !dumpBaseMembers(out, base,
true,
false);
2893 dumpType(out, member.type,
true,
true);
2894 out <<
" " << member.name <<
"_";
2897 out <<
"\n#if defined LIBO_USE_SOURCE_LOCATION\n";
2898 out <<
" " << (bFirst ?
"" :
", ") <<
"std::experimental::source_location location\n";
2903 if (!
base.isEmpty()) {
2906 dumpBaseMembers(out, base,
false,
false);
2907 out <<
"\n#if defined LIBO_USE_SOURCE_LOCATION\n";
2908 out <<
" , location\n";
2914 out << indent() << (bFirst ?
":" :
",") <<
" " << member.name <<
"("
2915 << member.name <<
"_)\n";
2920 if (!m_cppuTypeDynamic) {
2923 dumpCppuGetType(out, name_);
2928 if (name_ ==
"com.sun.star.uno.Exception")
2930 out <<
"\n#if defined LIBO_USE_SOURCE_LOCATION\n";
2931 out <<
" if (!Message.isEmpty())\n";
2932 out <<
" Message += \" \";\n";
2933 out <<
" Message += \"at \" + o3tl::runtimeToOUString(location.file_name()) + \":\" + OUString::number(location.line());\n";
2938 out <<
"#if !defined LIBO_INTERNAL_ONLY\n" << indent() << id_ <<
"::" << id_
2939 <<
"(" << id_ <<
" const & the_other)";
2941 if (!
base.isEmpty()) {
2947 out << (bFirst ?
":" :
",") <<
" " << member.name <<
"(the_other." << member.name
2951 out << indent() <<
" {}\n\n" << indent() << id_ <<
"::~" << id_
2952 <<
"() {}\n\n" << indent() << id_ <<
" & " << id_ <<
"::operator =("
2953 << id_ <<
" const & the_other) {\n";
2956 << (
"//TODO: Just like its implicitly-defined counterpart, this"
2957 " function definition is not exception-safe\n");
2958 if (!
base.isEmpty()) {
2960 <<
"::operator =(the_other);\n";
2963 out << indent() << member.name <<
" = the_other." << member.name <<
";\n";
2965 out << indent() <<
"return *this;\n";
2967 out << indent() <<
"}\n#endif\n\n";
2970 if (name_ ==
"com.sun.star.uno.Exception")
2972 out <<
"#if defined LIBO_INTERNAL_ONLY\n";
2973 out <<
"template< typename charT, typename traits >\n";
2974 out <<
"inline ::std::basic_ostream<charT, traits> & operator<<(\n";
2975 out <<
" ::std::basic_ostream<charT, traits> & os, ::com::sun::star::uno::Exception const & exception)\n";
2977 out <<
" // the class name is useful because exception throwing code does not always pass in a useful message\n";
2978 out <<
" os << typeid(exception).name();\n";
2979 out <<
" if (!exception.Message.isEmpty())\n";
2980 out <<
" os << \" msg: \" << exception.Message;\n";
2981 out <<
" return os;\n";
2992 dumpGetCppuType(out);
2993 out <<
"\n#endif // "<< headerDefine <<
"\n";
2996void ExceptionType::dumpLightGetCppuType(
FileStream & out)
2998 dumpGetCppuTypePreamble(out);
3000 <<
"static typelib_TypeDescriptionReference * the_type = 0;\n"
3001 << indent() <<
"if ( !the_type )\n" << indent() <<
"{\n";
3003 out << indent() <<
"typelib_static_type_init( &the_type, "
3006 out << indent() <<
"}\n" << indent()
3007 << (
"return * reinterpret_cast< ::css::uno::Type * >("
3009 dumpGetCppuTypePostamble(out);
3012void ExceptionType::dumpNormalGetCppuType(
FileStream & out)
3014 dumpGetCppuTypePreamble(out);
3016 <<
"static typelib_TypeDescriptionReference * the_type = 0;\n"
3017 << indent() <<
"if ( !the_type )\n" << indent() <<
"{\n";
3019 OUString
base(entity_->getDirectBase());
3020 bool baseException =
false;
3021 if (!
base.isEmpty()) {
3022 if (base ==
"com.sun.star.uno.Exception") {
3023 baseException =
true;
3026 << (
"const ::css::uno::Type& rBaseType ="
3027 " ::cppu::UnoType< ");
3028 dumpType(out, base,
true,
false,
false,
true);
3029 out <<
" >::get();\n\n";
3032 if (!entity_->getDirectMembers().empty()) {
3033 out << indent() <<
"typelib_TypeDescriptionReference * aMemberRefs["
3034 << entity_->getDirectMembers().size() <<
"];\n";
3035 std::set< OUString > seen;
3036 std::vector< unoidl::ExceptionTypeEntity::Member >::size_type
n = 0;
3038 OUString
type(resolveAllTypedefs(member.type));
3039 OUString modType(typeToIdentifier(type));
3040 if (seen.insert(type).second) {
3042 <<
"const ::css::uno::Type& rMemberType_"
3043 << modType <<
" = ::cppu::UnoType< ";
3044 dumpType(out, type,
false,
false,
false,
true);
3045 out <<
" >::get();\n";
3047 out << indent() <<
"aMemberRefs[" <<
n++ <<
"] = rMemberType_"
3048 << modType <<
".getTypeLibType();\n";
3052 out << indent() <<
"typelib_static_compound_type_init( &the_type, "
3054 if (baseException) {
3055 out << (
"* ::typelib_static_type_getByTypeClass("
3056 " typelib_TypeClass_EXCEPTION )");
3057 }
else if (
base.isEmpty()) {
3060 out <<
"rBaseType.getTypeLibType()";
3062 out <<
", " << entity_->getDirectMembers().size() <<
", "
3063 << (entity_->getDirectMembers().empty() ?
"0" :
"aMemberRefs")
3066 out << indent() <<
"}\n" << indent()
3067 << (
"return * reinterpret_cast< const ::css::uno::Type * >("
3069 dumpGetCppuTypePostamble(out);
3072void ExceptionType::dumpComprehensiveGetCppuType(
FileStream & out)
3075 out <<
" namespace detail {\n\n";
3076 OUString staticTypeClass(
"the" + id_ +
"Type");
3077 out << indent() <<
"struct " << staticTypeClass
3078 <<
" : public rtl::StaticWithInit< ::css::uno::Type *, "
3079 << staticTypeClass <<
" >\n" << indent() <<
"{\n";
3081 out << indent() <<
"::css::uno::Type * operator()() const\n"
3082 << indent() <<
"{\n";
3084 out << indent() <<
"::rtl::OUString sTypeName( \"" <<
name_ <<
"\" );\n\n"
3085 << indent() <<
"// Start inline typedescription generation\n"
3086 << indent() <<
"typelib_TypeDescription * pTD = 0;\n";
3087 OUString
base(entity_->getDirectBase());
3088 if (!
base.isEmpty()) {
3090 << (
"const ::css::uno::Type& rSuperType ="
3091 " ::cppu::UnoType< ");
3092 dumpType(out, base,
false,
false,
false,
true);
3093 out <<
" >::get();\n";
3095 std::set< OUString > seen;
3097 if (seen.insert(member.type).second) {
3098 dumpCppuGetType(out, member.type);
3101 if (!entity_->getDirectMembers().empty()) {
3102 out <<
"\n" << indent() <<
"typelib_CompoundMember_Init aMembers["
3103 << entity_->getDirectMembers().size() <<
"];\n";
3104 std::vector< unoidl::ExceptionTypeEntity::Member >::size_type
n = 0;
3106 OUString
type(resolveAllTypedefs(member.type));
3107 out << indent() <<
"::rtl::OUString sMemberType" <<
n <<
"( \""
3108 <<
type <<
"\" );\n" << indent()
3109 <<
"::rtl::OUString sMemberName" <<
n <<
"( \"" << member.name
3110 <<
"\" );\n" << indent() <<
"aMembers[" <<
n
3111 <<
"].eTypeClass = (typelib_TypeClass)" <<
getTypeClass(type)
3112 <<
";\n" << indent() <<
"aMembers[" <<
n
3113 <<
"].pTypeName = sMemberType" <<
n <<
".pData;\n" << indent()
3114 <<
"aMembers[" <<
n <<
"].pMemberName = sMemberName" <<
n
3119 out <<
"\n" << indent() <<
"typelib_typedescription_new(\n";
3121 out << indent() <<
"&pTD,\n" << indent() <<
"(typelib_TypeClass)"
3122 <<
getTypeClass(name_) <<
", sTypeName.pData,\n" << indent()
3123 << (
base.isEmpty() ?
"0" :
"rSuperType.getTypeLibType()") <<
",\n"
3124 << indent() << entity_->getDirectMembers().size() <<
",\n" << indent()
3125 << (entity_->getDirectMembers().empty() ?
"0" :
"aMembers")
3129 << (
"typelib_typedescription_register( (typelib_TypeDescription**)&pTD"
3131 << indent() <<
"typelib_typedescription_release( pTD );\n" << indent()
3132 <<
"// End inline typedescription generation\n\n" << indent()
3133 <<
"return new ::css::uno::Type( " <<
getTypeClass(name_)
3134 <<
", sTypeName ); // leaked\n";
3136 out << indent() <<
"}\n";
3138 out << indent() <<
"};\n\n";
3141 dumpGetCppuTypePreamble(out);
3142 out << indent() <<
"return *detail::" << staticTypeClass <<
"::get();\n";
3143 dumpGetCppuTypePostamble(out);
3146void ExceptionType::dumpDeclaration(
FileStream & out)
3148 out <<
"\nclass CPPU_GCC_DLLPUBLIC_EXPORT SAL_WARN_UNUSED " << id_;
3149 OUString
base(entity_->getDirectBase());
3150 if (!
base.isEmpty()) {
3153 out <<
"\n{\npublic:\n";
3157 out << indent() <<
"inline CPPU_GCC_DLLPRIVATE " << id_ <<
"(\n";
3158 out <<
"#if defined LIBO_USE_SOURCE_LOCATION\n";
3159 out <<
" std::experimental::source_location location = std::experimental::source_location::current()\n";
3160 out <<
"#endif\n\n";
3164 if (!entity_->getDirectMembers().empty() || getInheritedMemberCount() > 0) {
3165 out << indent() <<
"inline CPPU_GCC_DLLPRIVATE " << id_ <<
"(";
3166 bool eligibleForDefaults = entity_->getDirectMembers().empty();
3167 bool bFirst = !dumpBaseMembers(out, base,
true, eligibleForDefaults);
3172 dumpType(out, member.type,
true,
true);
3173 out <<
" " << member.name <<
"_";
3176 out <<
"\n#if defined LIBO_USE_SOURCE_LOCATION\n";
3177 out <<
", std::experimental::source_location location = std::experimental::source_location::current()\n";
3181 out <<
"#if !defined LIBO_INTERNAL_ONLY\n" << indent()
3182 <<
"inline CPPU_GCC_DLLPRIVATE " << id_ <<
"(" << id_
3183 <<
" const &);\n\n" << indent() <<
"inline CPPU_GCC_DLLPRIVATE ~"
3184 << id_ <<
"();\n\n" << indent() <<
"inline CPPU_GCC_DLLPRIVATE " << id_
3185 <<
" & operator =(" << id_ <<
" const &);\n#endif\n\n";
3186 for (std::vector< unoidl::ExceptionTypeEntity::Member >::const_iterator
i(
3187 entity_->getDirectMembers().begin());
3188 i != entity_->getDirectMembers().end(); ++i) {
3190 dumpType(out,
i->type);
3191 out <<
" " <<
i->name;
3192 if (i == entity_->getDirectMembers().begin() && !
base.isEmpty()
3193 &&
i->type !=
"hyper" &&
i->type !=
"unsigned hyper"
3194 &&
i->type !=
"double") {
3195 out <<
" CPPU_GCC3_ALIGN( "
3204bool ExceptionType::dumpBaseMembers(
3205 FileStream & out, OUString
const & base,
bool withType,
bool eligibleForDefaults)
3210 bool hasMember =
false;
3215 "exception type base " + base +
" is not an exception type");
3223 hasMember = dumpBaseMembers( out, ent2->getDirectBase(), withType,
3224 eligibleForDefaults && ent2->getDirectMembers().empty() );
3225 int memberCount = 0;
3231 dumpType(out, member.type,
true,
true);
3234 out << member.name <<
"_";
3238 if (eligibleForDefaults
3239 && base ==
"com.sun.star.uno.Exception"
3241 && member.name ==
"Context"
3242 && member.type ==
"com.sun.star.uno.XInterface") {
3243 out <<
" = ::css::uno::Reference< ::css::uno::XInterface >()";
3251sal_uInt32 ExceptionType::getTotalMemberCount(OUString
const & base)
const
3253 if (
base.isEmpty()) {
3260 "exception type base " + base +
" is not an exception type");
3263 return getTotalMemberCount(ent2.getDirectBase())
3264 + ent2.getDirectMembers().size();
3267class EnumType:
public CppuType
3273 CppuType(
name, typeMgr), entity_(entity) {
3274 assert(entity.is());
3278 virtual void dumpDeclaration(
FileStream& o)
override;
3280 virtual void addComprehensiveGetCppuTypeIncludes(
3285 void dumpNormalGetCppuType(
FileStream& o)
override;
3286 void dumpComprehensiveGetCppuType(
FileStream& o)
override;
3291void EnumType::addComprehensiveGetCppuTypeIncludes(
3300 o <<
"\n#if defined LIBO_INTERNAL_ONLY\n";
3301 o <<
"\nenum class SAL_DLLPUBLIC_RTTI " << id_ <<
"\n{\n";
3303 o <<
"\nenum SAL_DLLPUBLIC_RTTI " << id_ <<
"\n{\n";
3308 o << indent() << id_ <<
"_" <<
u2b(member.name) <<
" = " << member.value
3312 o << indent() << id_ <<
"_MAKE_FIXED_SIZE = SAL_MAX_ENUM\n";
3318 o <<
"#if defined LIBO_INTERNAL_ONLY\n";
3320 o <<
"constexpr auto " << id_ <<
"_" <<
u2b(member.name)
3322 << id_ <<
"::" << id_ <<
"_" <<
u2b(member.name)
3328void EnumType::dumpHppFile(
3331 OUString headerDefine(dumpHeaderDefine(o, u
"HPP"));
3334 addDefaultHxxIncludes(includes);
3335 includes.
dump(o, &name_,
true);
3340 o <<
"\n#endif // "<< headerDefine <<
"\n";
3343void EnumType::dumpNormalGetCppuType(
FileStream& o)
3345 dumpGetCppuTypePreamble(o);
3348 <<
"static typelib_TypeDescriptionReference * the_type = 0;\n";
3350 o << indent() <<
"if ( !the_type )\n" << indent() <<
"{\n";
3353 o << indent() <<
"typelib_static_enum_type_init( &the_type,\n";
3355 o << indent() <<
"\"" <<
name_ <<
"\",\n"
3357 <<
u2b(entity_->getMembers()[0].name) <<
" );\n";
3360 o << indent() <<
"}\n";
3362 << (
"return * reinterpret_cast< ::css::uno::Type * >("
3364 dumpGetCppuTypePostamble(o);
3367void EnumType::dumpComprehensiveGetCppuType(
FileStream& o)
3369 if (!isPolymorphic())
3372 o <<
"namespace cppu { ";
3373 o <<
" namespace detail {\n\n";
3375 OUString sStaticTypeClass(
"the" + id_ +
"Type");
3376 o << indent() <<
"struct " << sStaticTypeClass <<
" : public rtl::StaticWithInit< ::css::uno::Type *, " << sStaticTypeClass <<
" >\n";
3377 o << indent() <<
"{\n";
3379 o << indent() <<
"::css::uno::Type * operator()() const\n";
3380 o << indent() <<
"{\n";
3383 o << indent() <<
"::rtl::OUString sTypeName( \"" <<
name_
3386 o << indent() <<
"// Start inline typedescription generation\n"
3387 << indent() <<
"typelib_TypeDescription * pTD = 0;\n\n";
3389 o << indent() <<
"rtl_uString* enumValueNames["
3390 << entity_->getMembers().size() <<
"];\n";
3391 std::vector< unoidl::EnumTypeEntity::Member >::size_type
n = 0;
3393 o << indent() <<
"::rtl::OUString sEnumValue" <<
n <<
"( \""
3394 <<
u2b(member.name) <<
"\" );\n";
3395 o << indent() <<
"enumValueNames[" <<
n <<
"] = sEnumValue" <<
n
3400 o <<
"\n" << indent() <<
"sal_Int32 enumValues["
3401 << entity_->getMembers().size() <<
"];\n";
3404 o << indent() <<
"enumValues[" <<
n++ <<
"] = " << member.value <<
";\n";
3407 o <<
"\n" << indent() <<
"typelib_typedescription_newEnum( &pTD,\n";
3409 o << indent() <<
"sTypeName.pData,\n"
3410 << indent() <<
"(sal_Int32)"
3412 <<
u2b(entity_->getMembers()[0].name) <<
",\n"
3413 << indent() << entity_->getMembers().size()
3414 <<
", enumValueNames, enumValues );\n\n";
3418 << (
"typelib_typedescription_register( (typelib_TypeDescription**)&pTD"
3420 o << indent() <<
"typelib_typedescription_release( pTD );\n"
3421 << indent() <<
"// End inline typedescription generation\n\n";
3423 o << indent() <<
"return new ::css::uno::Type( "
3424 <<
getTypeClass(name_) <<
", sTypeName ); // leaked\n";
3427 o << indent() <<
"}\n";
3429 o << indent() <<
"};\n\n";
3431 if (!isPolymorphic())
3437 dumpGetCppuTypePreamble(o);
3438 o << indent() <<
"return *detail::" << sStaticTypeClass <<
"::get();\n";
3439 dumpGetCppuTypePostamble(o);
3448 CppuType(
name, typeMgr), entity_(entity) {
3449 assert(entity.is());
3453 virtual void dumpDeclaration(
FileStream& o)
override;
3462void Typedef::dumpHdlFile(
3465 OUString headerDefine(dumpHeaderDefine(o, u
"HDL"));
3468 addDefaultHIncludes(includes);
3469 includes.
dump(o,
nullptr,
true);
3482 o <<
"#endif // "<< headerDefine <<
"\n";
3488 dumpType(o, entity_->getType());
3489 o <<
" " << id_ <<
";\n\n";
3492void Typedef::dumpHppFile(
3495 OUString headerDefine(dumpHeaderDefine(o, u
"HPP"));
3498 addDefaultHxxIncludes(includes);
3499 includes.
dump(o, &name_,
true);
3502 o <<
"\n#endif // "<< headerDefine <<
"\n";
3505class ConstructiveType:
public CppuType
3517 virtual void dumpFiles(OUString
const & uri,
CppuOptions const & options)
override {
3518 dumpFile(uri, name_,
true, options);
3522bool hasRestParameter(
3529void includeExceptions(
3536 for (std::unique_ptr<codemaker::ExceptionTreeNode>
const & pChild : node->
children) {
3537 includeExceptions(includes, pChild.get());
3542class ServiceType:
public ConstructiveType
3549 ConstructiveType(
name,
manager), entity_(entity) {
3550 assert(entity.is());
3554 virtual void dumpHppFile(
3557 void dumpCatchClauses(
3564 FileStream & o, std::u16string_view service, OString
const & type)
3566 o <<
"::rtl::OUString(\"component context fails to supply service \") + \""
3567 << service <<
"\" + \" of type \" + \"" <<
type <<
"\"";
3570void ServiceType::dumpHppFile(
3573 if (!entity_->getConstructors().empty()) {
3581 includes.
add(
"com.sun.star.uno.DeploymentException");
3582 includes.
add(
"com.sun.star.uno.XComponentContext");
3584 if (cons.defaultConstructor) {
3585 includes.
add(
"com.sun.star.uno.Exception");
3586 includes.
add(
"com.sun.star.uno.RuntimeException");
3588 if (!hasRestParameter(cons)) {
3593 if (m_typeMgr->getSort(
3603 for (
const OUString& ex : cons.exceptions) {
3604 tree.
add(
u2b(ex), m_typeMgr);
3607 includes.
add(
"com.sun.star.uno.Exception");
3608 includes.
add(
"com.sun.star.uno.RuntimeException");
3609 includeExceptions(includes, &tree.
getRoot());
3616 u2b(id_),
"service", isGlobal()));
3617 OUString headerDefine(dumpHeaderDefine(o, u
"HPP"));
3619 includes.
dump(o,
nullptr,
true);
3620 if (!entity_->getConstructors().empty()) {
3621 o << (
"\n#if defined ANDROID || defined IOS //TODO\n"
3622 "#include <com/sun/star/lang/XInitialization.hpp>\n"
3623 "#include <osl/detail/component-defines.h>\n#endif\n\n"
3624 "#if defined LO_URE_CURRENT_ENV && defined LO_URE_CTOR_ENV_")
3625 <<
name_.replaceAll(
".",
"_dot_")
3626 <<
" && (LO_URE_CURRENT_ENV) == (LO_URE_CTOR_ENV_"
3627 <<
name_.replaceAll(
".",
"_dot_") <<
") && defined LO_URE_CTOR_FUN_"
3628 <<
name_.replaceAll(
".",
"_dot_")
3629 <<
"\nextern \"C\" ::css::uno::XInterface * SAL_CALL LO_URE_CTOR_FUN_"
3630 <<
name_.replaceAll(
".",
"_dot_")
3631 <<
"(::css::uno::XComponentContext *, ::css::uno::Sequence< "
3632 "::css::uno::Any > const &);\n#endif\n";
3638 o <<
"\nclass " << cppName <<
" {\n";
3640 if (!entity_->getConstructors().empty()) {
3641 OString baseName(
u2b(entity_->getBase()));
3645 entity_->getConstructors()) {
3646 if (cons.defaultConstructor) {
3647 o << indent() <<
"static ::css::uno::Reference< "
3648 << scopedBaseName <<
" > "
3652 << (
"(::css::uno::Reference< ::css::uno::XComponentContext > const &"
3653 " the_context) {\n");
3655 o << indent() <<
"assert(the_context.is());\n" << indent()
3656 <<
"::css::uno::Reference< " << scopedBaseName
3657 <<
" > the_instance;\n" << indent() <<
"try {\n";
3659 o << (
"#if defined LO_URE_CURRENT_ENV && defined "
3661 <<
name_.replaceAll(
".",
"_dot_")
3662 <<
" && (LO_URE_CURRENT_ENV) == (LO_URE_CTOR_ENV_"
3663 <<
name_.replaceAll(
".",
"_dot_")
3664 <<
") && defined LO_URE_CTOR_FUN_"
3665 <<
name_.replaceAll(
".",
"_dot_") <<
"\n" << indent()
3666 <<
"the_instance = ::css::uno::Reference< " << scopedBaseName
3667 << (
" >(::css::uno::Reference< ::css::uno::XInterface >("
3668 "static_cast< ::css::uno::XInterface * >((*"
3670 <<
name_.replaceAll(
".",
"_dot_")
3671 << (
")(the_context.get(), ::css::uno::Sequence<"
3672 " ::css::uno::Any >())), ::SAL_NO_ACQUIRE),"
3673 " ::css::uno::UNO_QUERY);\n#else\n")
3674 << indent() <<
"the_instance = ::css::uno::Reference< "
3676 << (
" >(the_context->getServiceManager()->"
3677 "createInstanceWithContext("
3680 <<
"\", the_context), ::css::uno::UNO_QUERY);\n#endif\n";
3683 <<
"} catch (const ::css::uno::RuntimeException &) {\n";
3685 o << indent() <<
"throw;\n";
3688 <<
"} catch (const ::css::uno::Exception & the_exception) {\n";
3690 o << indent() <<
"throw ::css::uno::DeploymentException(";
3691 failsToSupply(o, name_, baseName);
3692 o <<
" + \": \" + the_exception.Message, the_context);\n";
3694 o << indent() <<
"}\n" << indent()
3695 <<
"if (!the_instance.is()) {\n";
3697 o << indent() <<
"throw ::css::uno::DeploymentException(";
3698 failsToSupply(o, name_, baseName);
3699 o <<
", the_context);\n";
3701 o << indent() <<
"}\n" << indent() <<
"return the_instance;\n";
3703 o << indent() <<
"}\n\n";
3705 o << indent() <<
"static ::css::uno::Reference< "
3706 << scopedBaseName <<
" > "
3710 << (
"(::css::uno::Reference< ::css::uno::XComponentContext > const &"
3712 bool rest = hasRestParameter(cons);
3716 OUStringBuffer buf(2 + param.
type.getLength());
3720 buf.append(param.
type);
3721 OUString
type(buf.makeStringAndClear());
3722 bool byRef = passByReference(type);
3723 dumpType(o, type, byRef, byRef);
3730 o << indent() <<
"assert(the_context.is());\n";
3731 if (!rest && !cons.parameters.empty()) {
3733 <<
"::css::uno::Sequence< ::css::uno::Any > the_arguments("
3734 << cons.parameters.size() <<
");\n";
3736 <<
"::css::uno::Any* the_arguments_array = the_arguments.getArray();\n";
3739 unoidl::SingleInterfaceBasedServiceEntity::Constructor::
3740 Parameter >::size_type
n = 0;
3743 o << indent() <<
"the_arguments_array[" <<
n++ <<
"] ";
3749 if (resolveOuterTypedefs(j.
type) ==
"any") {
3751 }
else if (m_typeMgr->getSort(
3755 o <<
"= ::css::uno::Any(&" << param
3756 <<
", ::cppu::UnoType< ";
3757 for (sal_Int32 k = 0; k < rank; ++k) {
3758 o <<
"::cppu::UnoSequenceType< ";
3760 o <<
"::cppu::UnoCharType";
3761 for (sal_Int32 k = 0; k < rank; ++k) {
3766 o <<
"<<= " << param;
3771 o << indent() <<
"::css::uno::Reference< "
3772 << scopedBaseName <<
" > the_instance;\n";
3774 for (
const OUString& ex : cons.exceptions) {
3775 tree.
add(
u2b(ex), m_typeMgr);
3778 o << indent() <<
"try {\n";
3781 o << (
"#if defined LO_URE_CURRENT_ENV && defined "
3783 <<
name_.replaceAll(
".",
"_dot_")
3784 <<
" && (LO_URE_CURRENT_ENV) == (LO_URE_CTOR_ENV_"
3785 <<
name_.replaceAll(
".",
"_dot_")
3786 <<
") && defined LO_URE_CTOR_FUN_"
3787 <<
name_.replaceAll(
".",
"_dot_") <<
"\n" << indent()
3788 <<
"the_instance = ::css::uno::Reference< " << scopedBaseName
3789 << (
" >(::css::uno::Reference< ::css::uno::XInterface >("
3790 "static_cast< ::css::uno::XInterface * >((*"
3792 <<
name_.replaceAll(
".",
"_dot_")
3793 <<
")(the_context.get(), ";
3796 u2b(cons.parameters.back().name),
"param",
3798 }
else if (cons.parameters.empty()) {
3799 o <<
"::css::uno::Sequence< ::css::uno::Any >()";
3801 o <<
"the_arguments";
3803 o <<
")), ::SAL_NO_ACQUIRE), ::css::uno::UNO_QUERY);\n" << indent()
3804 << (
"::css::uno::Reference< ::css::lang::XInitialization > "
3805 "init(the_instance, ::css::uno::UNO_QUERY);\n")
3806 << indent() <<
"if (init.is()) {\n"
3807 << indent() <<
" init->initialize(";
3808 if (cons.parameters.empty()) {
3809 o <<
"::css::uno::Sequence< ::css::uno::Any >()";
3811 o <<
"the_arguments";
3813 o <<
");\n" << indent() <<
"}\n";
3815 << indent() <<
"the_instance = ::css::uno::Reference< "
3817 << (
" >(the_context->getServiceManager()->"
3818 "createInstanceWithArgumentsAndContext("
3823 u2b(cons.parameters.back().name),
"param",
3825 }
else if (cons.parameters.empty()) {
3826 o <<
"::css::uno::Sequence< ::css::uno::Any >()";
3828 o <<
"the_arguments";
3830 o <<
", the_context), ::css::uno::UNO_QUERY);\n#endif\n";
3834 <<
"} catch (const ::css::uno::RuntimeException &) {\n";
3836 o << indent() <<
"throw;\n";
3838 dumpCatchClauses(o, &tree.
getRoot());
3840 << (
"} catch (const ::css::uno::Exception &"
3841 " the_exception) {\n");
3843 o << indent() <<
"throw ::css::uno::DeploymentException(";
3844 failsToSupply(o, name_, baseName);
3845 o <<
" + \": \" + the_exception.Message, the_context);\n";
3847 o << indent() <<
"}\n";
3849 o << indent() <<
"if (!the_instance.is()) {\n";
3851 o << indent() <<
"throw ::css::uno::DeploymentException(";
3852 failsToSupply(o, name_, baseName);
3853 o <<
", the_context);\n";
3855 o << indent() <<
"}\n" << indent() <<
"return the_instance;\n";
3857 o << indent() <<
"}\n\n";
3862 o << indent() << cppName <<
"(); // not implemented\n"
3863 << indent() << cppName <<
"(" << cppName <<
" &); // not implemented\n"
3864 << indent() <<
"~" << cppName <<
"(); // not implemented\n"
3865 << indent() <<
"void operator =(" << cppName <<
"); // not implemented\n";
3871 o <<
"\n#endif // "<< headerDefine <<
"\n";
3874void ServiceType::dumpCatchClauses(
3878 out << indent() <<
"} catch (const ";
3879 dumpType(out,
b2u(node->
name));
3882 out << indent() <<
"throw;\n";
3885 for (std::unique_ptr<codemaker::ExceptionTreeNode>
const & pChild : node->
children) {
3886 dumpCatchClauses(out, pChild.get());
3891class SingletonType:
public ConstructiveType
3897 ConstructiveType(
name,
manager), entity_(entity) {
3898 assert(entity.is());
3902 virtual void dumpHppFile(
3908void SingletonType::dumpHppFile(
3913 u2b(id_),
"singleton", isGlobal()));
3914 OString baseName(
u2b(entity_->getBase()));
3916 OUString headerDefine(dumpHeaderDefine(o, u
"HPP"));
3920 includes.
add(
"com.sun.star.uno.DeploymentException");
3921 includes.
add(
"com.sun.star.uno.XComponentContext");
3927 includes.
dump(o,
nullptr,
true);
3928 o << (
"\n#if defined ANDROID || defined IOS //TODO\n"
3929 "#include <com/sun/star/lang/XInitialization.hpp>\n"
3930 "#include <osl/detail/component-defines.h>\n#endif\n\n"
3931 "#if defined LO_URE_CURRENT_ENV && defined LO_URE_CTOR_ENV_")
3932 <<
name_.replaceAll(
".",
"_dot_")
3933 <<
" && (LO_URE_CURRENT_ENV) == (LO_URE_CTOR_ENV_"
3934 <<
name_.replaceAll(
".",
"_dot_") <<
") && defined LO_URE_CTOR_FUN_"
3935 <<
name_.replaceAll(
".",
"_dot_")
3936 <<
"\nextern \"C\" ::css::uno::XInterface * SAL_CALL LO_URE_CTOR_FUN_"
3937 <<
name_.replaceAll(
".",
"_dot_")
3938 <<
"(::css::uno::XComponentContext *, ::css::uno::Sequence< "
3939 "::css::uno::Any > const &);\n#endif\n";
3944 o <<
"\nclass " << cppName <<
" {\npublic:\n";
3946 o << indent() <<
"static ::css::uno::Reference< "
3947 << scopedBaseName <<
" > "
3950 << (
"(::css::uno::Reference<"
3951 " ::css::uno::XComponentContext > const & the_context)"
3954 o << indent() <<
"assert(the_context.is());\n" << indent()
3955 <<
"::css::uno::Reference< " << scopedBaseName
3956 << (
" > instance;\n#if defined LO_URE_CURRENT_ENV && defined "
3958 <<
name_.replaceAll(
".",
"_dot_")
3959 <<
" && (LO_URE_CURRENT_ENV) == (LO_URE_CTOR_ENV_"
3960 <<
name_.replaceAll(
".",
"_dot_")
3961 <<
") && defined LO_URE_CTOR_FUN_"
3962 <<
name_.replaceAll(
".",
"_dot_") <<
"\n" << indent()
3963 <<
"instance = ::css::uno::Reference< " << scopedBaseName
3964 << (
" >(::css::uno::Reference< ::css::uno::XInterface >("
3965 "static_cast< ::css::uno::XInterface * >((*"
3967 <<
name_.replaceAll(
".",
"_dot_")
3968 << (
")(the_context.get(), ::css::uno::Sequence<"
3969 " ::css::uno::Any >())), ::SAL_NO_ACQUIRE),"
3970 " ::css::uno::UNO_QUERY);\n#else\n")
3971 << indent() << (
"the_context->getValueByName("
3972 "::rtl::OUString( \"/singletons/")
3973 << name_ <<
"\" )) >>= instance;\n#endif\n"
3974 << indent() <<
"if (!instance.is()) {\n";
3977 << (
"throw ::css::uno::DeploymentException("
3978 "::rtl::OUString( \"component context"
3979 " fails to supply singleton ")
3980 << name_ <<
" of type " << baseName <<
"\" ), the_context);\n";
3982 o << indent() <<
"}\n" << indent() <<
"return instance;\n";
3984 o << indent() <<
"}\n\n";
3986 o << indent() << cppName <<
"(); // not implemented\n"
3987 << indent() << cppName <<
"(" << cppName <<
" &); // not implemented\n"
3988 << indent() <<
"~" << cppName <<
"(); // not implemented\n"
3989 << indent() <<
"void operator =(" << cppName <<
"); // not implemented\n";
3995 o <<
"\n#endif // "<< headerDefine <<
"\n";
4016 if (!
name.isEmpty()) {
4021 if (!cur->getNext(&mem).is()) {
4033 t.dumpDependedTypes(generated, options);
4041 t.dumpDependedTypes(generated, options);
4050 t.dumpDependedTypes(generated, options);
4058 t.dumpDependedTypes(generated, options);
4066 t.dumpDependedTypes(generated, options);
4074 t.dumpDependedTypes(generated, options);
4081 if (
t.hasConstants()) {
4092 t.dumpDependedTypes(generated, options);
4101 t.dumpDependedTypes(generated, options);
4109 "unexpected entity \"" +
name +
"\" in call to produce");
bool isValid(const ::rtl::OString &option) const
const OString & getOption(const ::rtl::OString &option) const
Represents the hierarchy formed by a set of UNO exception types.
void add(rtl::OString const &name, rtl::Reference< TypeManager > const &manager)
Builds the exception hierarchy, by adding one exception type at a time.
ExceptionTreeNode const & getRoot() const
Gives access to the resultant exception hierarchy.
A simple class to track which types have already been processed by a code maker.
bool contains(OString const &type) const
Checks whether a given type has already been generated.
void add(OString const &type)
Add a type to the set of generated types.
A simple class to track which other entities a given entity depends on.
std::map< OUString, Kind > Map
void add(OString const &entityName)
void addTypelibTypedescriptionH()
static void dumpInclude(FileStream &out, OString const &entityName, bool hpp)
void dump(FileStream &out, OUString const *companionHdl, bool exceptions)
void addTypelibTypeclassH()
void addCustom(const OUString &s)
const OUString & getType() const
rtl::Reference< ParseManager > manager
void produce(OUString const &name, rtl::Reference< TypeManager > const &manager, codemaker::GeneratedTypeSet &generated, CppuOptions const &options)
OString getTempDir(const OString &sFileName)
bool removeTypeFile(const OString &fileName)
OString createFileNameFromType(const OString &destination, const OString &typeName, const OString &postfix)
bool fileExists(const OString &fileName)
bool makeValidTypeFile(const OString &targetFileName, const OString &tmpFileName, bool bFileCheck)
rtl::Reference< Manager > manager_
bool SC_DLLPUBLIC isRef(const ScTokenRef &pToken)
VCL_DLLPUBLIC void dump(const SkBitmap &bitmap, const char *file)
Sort
An enumeration of all the sorts of relevant UNOIDL entities.
@ InstantiatedPolymorphicStruct
@ InterfaceBasedSingleton
@ SingleInterfaceBasedService
@ PolymorphicStructTemplate
@ AccumulationBasedService
rtl::OString decompose(rtl::OString const &type, sal_Int32 *rank=nullptr, std::vector< rtl::OString > *arguments=nullptr)
Decomposes a UNO type name or UNO type registry name.
IdentifierTranslationMode
OString translateUnoToCppIdentifier(OString const &unoIdentifier, std::string_view prefix, IdentifierTranslationMode transmode, OString const *forbidden)
OString scopedCppName(OString const &type, bool ns_alias)
bool dumpNamespaceClose(FileStream &out, std::u16string_view entityName, bool fullModuleType)
bool dumpNamespaceOpen(FileStream &out, std::u16string_view entityName, bool fullModuleType)
void copy(const fs::path &src, const fs::path &dest)
PyRef getTypeClass(const Runtime &)
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
std::map< OUString, rtl::Reference< Entity > > map
ExceptionType(unsigned char *pCode, sal_uInt64 pCodeBase, typelib_TypeDescription *pTD) noexcept
Represents a node of the hierarchy from the ExceptionTree class.
std::vector< Parameter > parameters
OUString b2u(std::string_view s)
OString u2b(std::u16string_view s)