Bump version to 24.04.3.4
[LibreOffice.git] / unodevtools / source / skeletonmaker / javatypemaker.cxx
blob803090ab2249e4f55d41c33fc0e8d1d9b06f9c1b
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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>
22 #include <algorithm>
23 #include <cstring>
24 #include <string_view>
26 #include <codemaker/codemaker.hxx>
27 #include <codemaker/commonjava.hxx>
28 #include <codemaker/global.hxx>
30 #include "skeletoncommon.hxx"
31 #include "skeletonjava.hxx"
33 namespace skeletonmaker::java {
35 static void printType(
36 std::ostream & o, ProgramOptions const & options,
37 rtl::Reference< TypeManager > const & manager,
38 codemaker::UnoType::Sort sort, std::u16string_view nucleus, sal_Int32 rank,
39 std::vector< OUString > const & arguments, bool referenceType,
40 bool defaultvalue)
42 if (defaultvalue && rank == 0 && sort <= codemaker::UnoType::Sort::Char) {
43 switch (sort) {
44 case codemaker::UnoType::Sort::Boolean:
45 o << "false";
46 return;
47 case codemaker::UnoType::Sort::Char:
48 case codemaker::UnoType::Sort::Byte:
49 case codemaker::UnoType::Sort::Short:
50 case codemaker::UnoType::Sort::UnsignedShort:
51 case codemaker::UnoType::Sort::Long:
52 case codemaker::UnoType::Sort::UnsignedLong:
53 case codemaker::UnoType::Sort::Hyper:
54 case codemaker::UnoType::Sort::UnsignedHyper:
55 case codemaker::UnoType::Sort::Float:
56 case codemaker::UnoType::Sort::Double:
57 o << "0";
58 return;
59 default:
60 break;
64 if (defaultvalue) {
65 if (sort == codemaker::UnoType::Sort::Interface) {
66 o << "null";
67 return;
68 } else if (sort == codemaker::UnoType::Sort::Any && rank == 0) {
69 o << "com.sun.star.uno.Any.VOID";
70 return;
71 } else if (sort == codemaker::UnoType::Sort::Type && rank == 0) {
72 o << "com.sun.star.uno.Type.VOID";
73 return;
74 } else if (sort != codemaker::UnoType::Sort::Enum || rank != 0) {
75 o << "new ";
79 OString sType(
80 codemaker::java::translateUnoToJavaType(
81 sort, u2b(nucleus), referenceType && rank == 0));
82 if (sType.startsWith("java.lang.")) {
83 sType = sType.copy(std::strlen("java.lang."));
85 o << sType;
86 if (!arguments.empty()) {
87 o << '<';
88 for (std::vector< OUString >::const_iterator i(arguments.begin());
89 i != arguments.end(); ++i)
91 if (i != arguments.begin()) {
92 o << ", ";
94 printType(o, options, manager, *i, true);
96 o << '>';
98 for (sal_Int32 i = 0; i != rank; ++i) {
99 if (defaultvalue)
100 o << "[0]";
101 else
102 o << "[]";
105 if (defaultvalue && sort > codemaker::UnoType::Sort::Char && rank == 0) {
106 if (sort == codemaker::UnoType::Sort::Enum)
107 o << ".getDefault()";
108 else
109 o << "()";
113 void printType(
114 std::ostream & o, ProgramOptions const & options,
115 rtl::Reference< TypeManager > const & manager, std::u16string_view name,
116 bool referenceType, bool defaultvalue)
118 OUString nucleus;
119 sal_Int32 rank;
120 std::vector< OUString > arguments;
121 codemaker::UnoType::Sort sort = manager->decompose(
122 name, true, &nucleus, &rank, &arguments, nullptr);
123 printType(
124 o, options, manager, sort, nucleus, rank, arguments, referenceType,
125 defaultvalue);
128 static bool printConstructorParameters(
129 std::ostream & o, ProgramOptions const & options,
130 rtl::Reference< TypeManager > const & manager,
131 codemaker::UnoType::Sort sort,
132 rtl::Reference< unoidl::Entity > const & entity, std::u16string_view name,
133 std::vector< OUString > const & arguments)
135 bool previous = false;
136 switch (sort) {
137 case codemaker::UnoType::Sort::PlainStruct:
139 rtl::Reference< unoidl::PlainStructTypeEntity > ent2(
140 dynamic_cast< unoidl::PlainStructTypeEntity * >(entity.get()));
141 assert(ent2.is());
142 if (!ent2->getDirectBase().isEmpty()) {
143 rtl::Reference< unoidl::Entity > baseEnt;
144 codemaker::UnoType::Sort baseSort = manager->getSort(
145 ent2->getDirectBase(), &baseEnt);
146 previous = printConstructorParameters(
147 o, options, manager, baseSort, baseEnt,
148 ent2->getDirectBase(), std::vector< OUString >());
150 for (const auto& rMember : ent2->getDirectMembers())
152 if (previous) {
153 o << ", ";
155 previous = true;
156 printType(o, options, manager, rMember.type, false);
157 o << ' '
158 << codemaker::java::translateUnoToJavaIdentifier(
159 u2b(rMember.name), "param");
161 break;
163 case codemaker::UnoType::Sort::PolymorphicStructTemplate:
165 rtl::Reference< unoidl::PolymorphicStructTypeTemplateEntity > ent2(
166 dynamic_cast< unoidl::PolymorphicStructTypeTemplateEntity * >(
167 entity.get()));
168 assert(ent2.is());
169 for (const auto& rMember : ent2->getMembers())
171 if (previous) {
172 o << ", ";
174 previous = true;
175 if (rMember.parameterized) {
176 o << rMember.type;
177 } else {
178 printType(o, options, manager, rMember.type, false);
180 o << ' '
181 << codemaker::java::translateUnoToJavaIdentifier(
182 u2b(rMember.name), "param");
184 break;
186 case codemaker::UnoType::Sort::InstantiatedPolymorphicStruct:
188 rtl::Reference< unoidl::PolymorphicStructTypeTemplateEntity > ent2(
189 dynamic_cast< unoidl::PolymorphicStructTypeTemplateEntity * >(
190 entity.get()));
191 assert(ent2.is());
192 for (const auto& rMember : ent2->getMembers())
194 if (previous) {
195 o << ", ";
197 previous = true;
198 if (rMember.parameterized) {
199 auto j = std::find(ent2->getTypeParameters().begin(),
200 ent2->getTypeParameters().end(), rMember.type);
201 if (j != ent2->getTypeParameters().end()) {
202 o << arguments[j - ent2->getTypeParameters().begin()];
204 } else {
205 printType(o, options, manager, rMember.type, false);
207 o << ' '
208 << codemaker::java::translateUnoToJavaIdentifier(
209 u2b(rMember.name), "param");
211 break;
213 case codemaker::UnoType::Sort::Exception:
215 rtl::Reference< unoidl::ExceptionTypeEntity > ent2(
216 dynamic_cast< unoidl::ExceptionTypeEntity * >(entity.get()));
217 assert(ent2.is());
218 if (!ent2->getDirectBase().isEmpty()) {
219 rtl::Reference< unoidl::Entity > baseEnt;
220 codemaker::UnoType::Sort baseSort = manager->getSort(
221 ent2->getDirectBase(), &baseEnt);
222 previous = printConstructorParameters(
223 o, options, manager, baseSort, baseEnt,
224 ent2->getDirectBase(), std::vector< OUString >());
226 for (const auto& rMember : ent2->getDirectMembers())
228 if (previous) {
229 o << ", ";
231 previous = true;
232 printType(o, options, manager, rMember.type, false);
233 o << ' '
234 << codemaker::java::translateUnoToJavaIdentifier(
235 u2b(rMember.name), "param");
237 break;
239 default:
240 throw CannotDumpException(
241 OUString::Concat("unexpected entity \"") + name
242 + "\" in call to skeletonmaker::cpp::printConstructorParameters");
244 return previous;
247 static void printConstructor(
248 std::ostream & o, ProgramOptions const & options,
249 rtl::Reference< TypeManager > const & manager,
250 codemaker::UnoType::Sort sort,
251 rtl::Reference< unoidl::Entity > const & entity, std::u16string_view name,
252 std::vector< OUString > const & arguments)
254 o << "public " << OUString(name.substr(name.rfind('.') + 1)) << '(';
255 printConstructorParameters(
256 o, options, manager, sort, entity, name, arguments);
257 o << ");\n";
260 static void printMethodParameters(
261 std::ostream & o, ProgramOptions const & options,
262 rtl::Reference< TypeManager > const & manager,
263 std::vector< unoidl::InterfaceTypeEntity::Method::Parameter > const &
264 parameters,
265 bool withType)
267 for (std::vector< unoidl::InterfaceTypeEntity::Method::Parameter >::
268 const_iterator i(parameters.begin());
269 i != parameters.end(); ++i)
271 if (i != parameters.begin()) {
272 o << ", ";
274 if (withType) {
275 printType(o, options, manager, i->type, false);
276 if (i->direction
277 != unoidl::InterfaceTypeEntity::Method::Parameter::DIRECTION_IN)
279 o << "[]";
281 o << ' ';
283 o << codemaker::java::translateUnoToJavaIdentifier(
284 u2b(i->name), "param");
288 static void printExceptionSpecification(
289 std::ostream & o, ProgramOptions const & options,
290 rtl::Reference< TypeManager > const & manager,
291 std::vector< OUString > const & exceptions)
293 if (!exceptions.empty()) {
294 o << " throws ";
295 for (std::vector< OUString >::const_iterator i(exceptions.begin());
296 i != exceptions.end(); ++i)
298 if (i !=exceptions.begin() ) {
299 o << ", ";
301 printType(o, options, manager, *i, false);
307 static void printSetPropertyMixinBody(
308 std::ostream & o, unoidl::InterfaceTypeEntity::Attribute const & attribute,
309 OString const & indentation)
311 unoidl::AccumulationBasedServiceEntity::Property::Attributes propFlags
312 = checkAdditionalPropertyFlags(attribute);
314 o << "\n" << indentation << "{\n";
316 if ( attribute.bound ) {
317 o << indentation << " PropertySetMixin.BoundListeners l = "
318 "new PropertySetMixin.BoundListeners();\n\n";
321 o << indentation << " m_prophlp.prepareSet(\""
322 << attribute.name << "\", ";
323 if ( propFlags & unoidl::AccumulationBasedServiceEntity::Property::ATTRIBUTE_CONSTRAINED ) {
324 OString fieldtype = codemaker::convertString(attribute.type);
326 sal_Int32 index = fieldtype.lastIndexOf('<');
327 sal_Int32 nPos=0;
328 bool single = true;
329 bool optional = false;
330 OStringBuffer buffer1(64);
331 OStringBuffer buffer2(64);
334 OString s(fieldtype.getToken(0, '<', nPos));
335 OString t{ OString::Concat("((") + s.subView(s.lastIndexOf('/')+1) + ")" };
337 if ( t == "((Optional)" ) {
338 optional=true;
339 if (single) {
340 single=false;
341 buffer1.append("the_value.IsPresent");
342 buffer2.append("the_value.Value");
343 } else {
344 buffer1.insert(0, t);
345 buffer1.append(").IsPresent");
346 buffer2.insert(0, t);
347 buffer2.append(").Value");
349 } else {
350 if ( single ) {
351 single=false;
352 if ( !optional ) {
353 buffer1.append("the_value.Value");
355 buffer2.append("the_value.Value");
356 } else {
357 if ( !optional ) {
358 buffer1.insert(0, t);
359 buffer1.append(").Value");
361 buffer2.insert(0, t);
362 buffer2.append(").Value");
365 } while( nPos <= index );
367 o << "Any.VOID,\n" << indentation << " ";
368 if ( optional )
369 o << "(";
370 o << buffer1.makeStringAndClear();
371 if ( optional )
372 o << ") ? " << buffer2.makeStringAndClear() << " : Any.VOID,\n"
373 << indentation << " ";
374 else
375 o << ", ";
378 if ( attribute.bound )
379 o << "l";
380 else
381 o << "null";
382 o << ");\n";
384 o << indentation << " synchronized (this) {\n"
385 << indentation << " m_" << attribute.name
386 << " = the_value;\n" << indentation << " }\n";
388 if ( attribute.bound ) {
389 o << indentation << " l.notifyListeners();\n";
391 o << indentation << "}\n\n";
394 void printMethods(std::ostream & o,
395 ProgramOptions const & options, rtl::Reference< TypeManager > const & manager,
396 OUString const & name,
397 codemaker::GeneratedTypeSet & generated,
398 OString const & delegate, OString const & indentation,
399 bool defaultvalue, bool usepropertymixin)
401 if ( generated.contains(u2b(name)) || name == "com.sun.star.uno.XInterface" ||
402 ( defaultvalue &&
403 ( name == "com.sun.star.lang.XComponent" ||
404 name == "com.sun.star.lang.XTypeProvider" ||
405 name == "com.sun.star.uno.XWeak" ) ) ) {
406 return;
409 if ( usepropertymixin ) {
410 if (name == "com.sun.star.beans.XPropertySet") {
411 generated.add(u2b(name));
412 generateXPropertySetBodies(o);
413 return;
414 } else if (name == "com.sun.star.beans.XFastPropertySet") {
415 generated.add(u2b(name));
416 generateXFastPropertySetBodies(o);
417 return;
418 } else if (name == "com.sun.star.beans.XPropertyAccess") {
419 generated.add(u2b(name));
420 generateXPropertyAccessBodies(o);
421 return;
425 static OString sd("_"_ostr);
426 bool body = !delegate.isEmpty();
427 bool defaultbody = delegate == sd;
429 generated.add(u2b(name));
430 rtl::Reference< unoidl::Entity > ent;
431 if (manager->getSort(name, &ent) != codemaker::UnoType::Sort::Interface)
433 throw CannotDumpException(
434 "unexpected entity \"" + name
435 + "\" in call to skeletonmaker::java::printMethods");
437 rtl::Reference< unoidl::InterfaceTypeEntity > ent2(
438 dynamic_cast< unoidl::InterfaceTypeEntity * >(ent.get()));
439 assert(ent2.is());
440 if ( options.all || defaultvalue ) {
441 for (const auto& rBase : ent2->getDirectMandatoryBases())
443 printMethods(
444 o, options, manager, rBase.name, generated, delegate, indentation,
445 defaultvalue, usepropertymixin);
447 if (!(ent2->getDirectAttributes().empty()
448 && ent2->getDirectMethods().empty()))
450 o << indentation << "// ";
451 printType(o, options, manager, name, false);
452 o << ":\n";
455 for (const auto& rAttr : ent2->getDirectAttributes())
457 o << indentation << "public ";
458 printType(o, options, manager, rAttr.type, false);
459 o << " get" << rAttr.name << "()";
460 printExceptionSpecification(o, options, manager, rAttr.getExceptions);
461 if ( body ) {
462 if ( defaultbody ) {
463 if ( usepropertymixin ) {
464 o << "\n" << indentation << "{\n" << indentation
465 << " return m_" << rAttr.name << ";\n" << indentation
466 << "}\n\n";
467 } else {
468 o << "\n" << indentation << "{\n" << indentation
469 << " return ";
470 printType(o, options, manager, rAttr.type, false, true);
471 o << ";\n" << indentation << "}\n\n";
473 } else {
474 o << "\n" << indentation << "{\n" << indentation
475 << " return " << delegate << "get" << rAttr.name
476 << "();\n" << indentation << "}\n\n";
478 } else {
479 o << ";\n";
482 // REMOVE next line
483 if (!rAttr.readOnly) {
484 o << indentation << "public void set" << rAttr.name << '(';
485 printType(o, options, manager, rAttr.type, false);
486 o << " the_value)";
487 printExceptionSpecification(o, options, manager, rAttr.setExceptions);
488 if ( body ) {
489 if ( defaultbody ) {
490 if ( usepropertymixin ) {
491 printSetPropertyMixinBody(o, rAttr, indentation);
492 } else {
493 o << "\n" << indentation << "{\n\n" << indentation
494 << "}\n\n";
496 } else {
497 o << "\n" << indentation << "{\n" << indentation
498 << " " << delegate << "set" << rAttr.name
499 << "(the_value);\n" << indentation << "}\n\n";
501 } else {
502 o << ";\n";
506 for (const auto& rMethod : ent2->getDirectMethods())
508 o << indentation << "public ";
509 printType(o, options, manager, rMethod.returnType, false);
510 o << ' ' << rMethod.name << '(';
511 printMethodParameters(o, options, manager, rMethod.parameters, true);
512 o << ')';
513 printExceptionSpecification(o, options, manager, rMethod.exceptions);
514 if ( body ) {
515 if ( defaultbody ) {
516 o << "\n" << indentation << "{\n";
517 if (rMethod.returnType != "void") {
518 o << indentation << " // TODO: Exchange the default return implementation for \"" << rMethod.name << "\" !!!\n";
519 o << indentation << " // NOTE: "
520 "Default initialized polymorphic structs can cause problems"
521 "\n" << indentation << " // because of missing default "
522 "initialization of primitive types of\n" << indentation
523 << " // some C++ compilers or different Any initialization"
524 " in Java and C++\n" << indentation
525 << " // polymorphic structs.\n" << indentation
526 << " return ";
527 printType(o, options, manager, rMethod.returnType, false, true);
528 o << ";";
529 } else {
530 o << indentation << " // TODO: Insert your implementation for \""
531 << rMethod.name << "\" here.";
533 o << "\n" << indentation << "}\n\n";
534 } else {
535 o << "\n" << indentation << "{\n" << indentation << " ";
536 if (rMethod.returnType != "void") {
537 o << "return ";
539 o << delegate << rMethod.name << '(';
540 printMethodParameters(
541 o, options, manager, rMethod.parameters, false);
542 o << ");\n" << indentation << "}\n\n";
544 } else {
545 o << ";\n";
550 static void printConstructors(
551 std::ostream & o, ProgramOptions const & options,
552 rtl::Reference< TypeManager > const & manager, OUString const & name)
554 rtl::Reference< unoidl::Entity > ent;
555 if (manager->getSort(name, &ent)
556 != codemaker::UnoType::Sort::SingleInterfaceBasedService)
558 throw CannotDumpException(
559 "unexpected entity \"" + name
560 + "\" in call to skeletonmaker::java::printConstructors");
562 rtl::Reference< unoidl::SingleInterfaceBasedServiceEntity > ent2(
563 dynamic_cast< unoidl::SingleInterfaceBasedServiceEntity * >(ent.get()));
564 assert(ent2.is());
565 for (const auto& rConstructor : ent2->getConstructors())
567 o << "public static ";
568 printType(o, options, manager, ent2->getBase(), false);
569 o << ' ';
570 if (rConstructor.defaultConstructor) {
571 o << "create";
572 } else {
573 o << codemaker::java::translateUnoToJavaIdentifier(
574 u2b(rConstructor.name), "method");
576 o << "(com.sun.star.uno.XComponentContext the_context";
577 for (const auto& rParam : rConstructor.parameters)
579 o << ", ";
580 printType(o, options, manager, rParam.type, false);
581 if (rParam.rest) {
582 o << "...";
584 o << ' '
585 << codemaker::java::translateUnoToJavaIdentifier(
586 u2b(rParam.name), "param");
588 o << ')';
589 printExceptionSpecification(o, options, manager, rConstructor.exceptions);
590 o << ";\n";
594 static void printServiceMembers(
595 std::ostream & o, ProgramOptions const & options,
596 rtl::Reference< TypeManager > const & manager,
597 OUString const & name,
598 rtl::Reference< unoidl::AccumulationBasedServiceEntity > const & entity,
599 OString const & delegate)
601 assert(entity.is());
602 for (const auto& rService : entity->getDirectMandatoryBaseServices())
604 o << "\n// exported service " << rService.name << "\n";
605 generateDocumentation(o, options, manager, u2b(rService.name), delegate);
607 for (const auto& rIface : entity->getDirectMandatoryBaseInterfaces())
609 o << "\n// supported interface " << rIface.name << "\n";
610 generateDocumentation(o, options, manager, u2b(rIface.name), delegate);
612 o << "\n// properties of service \""<< name << "\"\n";
613 for (const auto& rProp : entity->getDirectProperties())
615 o << "// private ";
616 printType(o, options, manager, rProp.type, false);
617 o << " "
618 << codemaker::java::translateUnoToJavaIdentifier(
619 u2b(rProp.name), "property")
620 << ";\n";
624 static void printMapsToJavaType(
625 std::ostream & o, ProgramOptions const & options,
626 rtl::Reference< TypeManager > const & manager,
627 codemaker::UnoType::Sort sort, std::u16string_view nucleus, sal_Int32 rank,
628 std::vector< OUString > const & arguments, const char * javaTypeSort)
630 o << "maps to Java 1.5 ";
631 if (javaTypeSort != nullptr) {
632 o << javaTypeSort << ' ';
634 o << "type \"";
635 if (rank == 0 && nucleus == u"com.sun.star.uno.XInterface") {
636 o << "com.sun.star.uno.XInterface";
637 } else {
638 printType(
639 o, options, manager, sort, nucleus, rank, arguments, false, false);
641 o << '"';
644 void generateDocumentation(std::ostream & o,
645 ProgramOptions const & options, rtl::Reference< TypeManager > const & manager,
646 OString const & type, OString const & delegate)
648 OUString nucleus;
649 sal_Int32 rank;
650 codemaker::UnoType::Sort sort = manager->decompose(
651 b2u(type), false, &nucleus, &rank, nullptr, nullptr);
653 bool comment = true;
654 if (!delegate.isEmpty()) {
655 if (sort != codemaker::UnoType::Sort::Interface &&
656 sort != codemaker::UnoType::Sort::SingleInterfaceBasedService &&
657 sort != codemaker::UnoType::Sort::AccumulationBasedService )
659 return;
661 comment = false;
664 if (comment) {
665 o << "\n// UNO";
666 if (rank != 0) {
667 o << " sequence type";
668 } else if (sort <= codemaker::UnoType::Sort::Any) {
669 o << " simple type";
670 } else {
671 switch (sort) {
672 case codemaker::UnoType::Sort::Interface:
673 o << " interface type";
674 break;
676 case codemaker::UnoType::Sort::Module:
677 o << "IDL module";
678 break;
680 case codemaker::UnoType::Sort::PlainStruct:
681 o << " simple struct type";
682 break;
684 case codemaker::UnoType::Sort::PolymorphicStructTemplate:
685 o << " polymorphic struct type template";
686 break;
688 case codemaker::UnoType::Sort::InstantiatedPolymorphicStruct:
689 o << " instantiated polymorphic struct type";
690 break;
692 case codemaker::UnoType::Sort::Enum:
693 o << " enum type";
694 break;
696 case codemaker::UnoType::Sort::Exception:
697 o << " exception type";
698 break;
700 case codemaker::UnoType::Sort::Typedef:
701 o << "IDL typedef";
702 break;
704 case codemaker::UnoType::Sort::SingleInterfaceBasedService:
705 o << " single-inheritance--based service";
706 break;
708 case codemaker::UnoType::Sort::AccumulationBasedService:
709 o << "IDL accumulation-based service";
710 break;
712 case codemaker::UnoType::Sort::InterfaceBasedSingleton:
713 o << " inheritance-based singleton";
714 break;
716 case codemaker::UnoType::Sort::ServiceBasedSingleton:
717 o << "IDL service-based singleton";
718 break;
720 case codemaker::UnoType::Sort::ConstantGroup:
721 o << "IDL constant group";
722 break;
724 default:
725 OSL_ASSERT(false);
726 break;
729 o << " \"" << type << "\" ";
731 std::vector< OUString > arguments;
732 rtl::Reference< unoidl::Entity > entity;
733 sort = manager->decompose(
734 b2u(type), true, &nucleus, &rank, &arguments, &entity);
735 if (rank != 0) {
736 printMapsToJavaType(
737 o, options, manager, sort, nucleus, rank, arguments, "array");
738 o << '\n';
739 } else if (sort <= codemaker::UnoType::Sort::Any) {
740 printMapsToJavaType(
741 o, options, manager, sort, nucleus, rank, arguments, nullptr);
742 o << '\n';
743 } else {
744 switch (sort) {
745 case codemaker::UnoType::Sort::Interface:
746 printMapsToJavaType(
747 o, options, manager, sort, nucleus, rank, arguments,
748 "interface");
749 if (nucleus == "com.sun.star.uno.XInterface") {
750 o << '\n';
751 } else {
752 o << "; " << (options.all ? "all" : "direct") << " methods:\n";
753 codemaker::GeneratedTypeSet generated;
754 printMethods(
755 o, options, manager, nucleus, generated, delegate, ""_ostr);
757 break;
759 case codemaker::UnoType::Sort::Module:
760 printMapsToJavaType(
761 o, options, manager, sort, nucleus, rank, arguments, "package");
762 o << '\n';
763 break;
765 case codemaker::UnoType::Sort::PlainStruct:
766 printMapsToJavaType(
767 o, options, manager, sort, nucleus, rank, arguments, "class");
768 o << "; full constructor:\n";
769 printConstructor(
770 o, options, manager, codemaker::UnoType::Sort::PlainStruct,
771 entity, nucleus, arguments);
772 break;
774 case codemaker::UnoType::Sort::PolymorphicStructTemplate:
775 printMapsToJavaType(
776 o, options, manager, sort, nucleus, rank, arguments,
777 "generic class");
778 o << "; full constructor:\n";
779 printConstructor(
780 o, options, manager,
781 codemaker::UnoType::Sort::PolymorphicStructTemplate,
782 entity, nucleus, arguments);
783 break;
785 case codemaker::UnoType::Sort::InstantiatedPolymorphicStruct:
786 printMapsToJavaType(
787 o, options, manager, sort, nucleus, rank, arguments,
788 "generic class instantiation");
789 o << "; full constructor:\n";
790 printConstructor(
791 o, options, manager,
792 codemaker::UnoType::Sort::InstantiatedPolymorphicStruct,
793 entity, nucleus, arguments);
794 break;
796 case codemaker::UnoType::Sort::Enum:
797 case codemaker::UnoType::Sort::ConstantGroup:
798 printMapsToJavaType(
799 o, options, manager, sort, nucleus, rank, arguments, "class");
800 o << '\n';
801 break;
803 case codemaker::UnoType::Sort::Exception:
804 printMapsToJavaType(
805 o, options, manager, sort, nucleus, rank, arguments,
806 "exception class");
807 o << "; full constructor:\n";
808 printConstructor(
809 o, options, manager, codemaker::UnoType::Sort::Exception,
810 entity, nucleus, arguments);
811 break;
813 case codemaker::UnoType::Sort::SingleInterfaceBasedService:
814 printMapsToJavaType(
815 o, options, manager, sort, nucleus, rank, arguments, "class");
816 o << "; construction methods:\n";
817 printConstructors(o, options, manager, nucleus);
818 generateDocumentation(
819 o, options, manager,
820 u2b(dynamic_cast< unoidl::SingleInterfaceBasedServiceEntity & >(
821 *entity).getBase()),
822 delegate);
823 break;
825 case codemaker::UnoType::Sort::AccumulationBasedService:
826 o << ("does not map to Java\n"
827 "// the service members are generated instead\n");
828 printServiceMembers(
829 o, options, manager, nucleus,
830 dynamic_cast< unoidl::AccumulationBasedServiceEntity * >(
831 entity.get()),
832 delegate);
833 break;
835 case codemaker::UnoType::Sort::InterfaceBasedSingleton:
836 printMapsToJavaType(
837 o, options, manager, sort, nucleus, rank, arguments, "class");
838 o << "; get method:\npublic static ";
839 printType(
840 o, options, manager,
841 dynamic_cast< unoidl::InterfaceBasedSingletonEntity & >(
842 *entity).getBase(),
843 false);
844 o << " get(com.sun.star.uno.XComponentContext context);\n";
845 break;
847 case codemaker::UnoType::Sort::ServiceBasedSingleton:
848 o << "does not map to Java\n";
849 break;
851 default:
852 OSL_ASSERT(false);
853 break;
861 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */