Version 5.2.6.1, tag libreoffice-5.2.6.1
[LibreOffice.git] / unodevtools / source / skeletonmaker / javatypemaker.cxx
blobe097b831be90bc92fc0d96b3b703d10b6b0c27e1
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 <cstring>
24 #include "codemaker/codemaker.hxx"
25 #include "codemaker/commonjava.hxx"
26 #include "codemaker/global.hxx"
28 #include "skeletoncommon.hxx"
29 #include "skeletonjava.hxx"
31 namespace skeletonmaker { namespace java {
33 void printType(
34 std::ostream & o, ProgramOptions const & options,
35 rtl::Reference< TypeManager > const & manager,
36 codemaker::UnoType::Sort sort, OUString const & nucleus, sal_Int32 rank,
37 std::vector< OUString > const & arguments, bool referenceType,
38 bool defaultvalue)
40 if (defaultvalue && rank == 0 && sort <= codemaker::UnoType::Sort::Char) {
41 switch (sort) {
42 case codemaker::UnoType::Sort::Boolean:
43 o << "false";
44 return;
45 case codemaker::UnoType::Sort::Char:
46 case codemaker::UnoType::Sort::Byte:
47 case codemaker::UnoType::Sort::Short:
48 case codemaker::UnoType::Sort::UnsignedShort:
49 case codemaker::UnoType::Sort::Long:
50 case codemaker::UnoType::Sort::UnsignedLong:
51 case codemaker::UnoType::Sort::Hyper:
52 case codemaker::UnoType::Sort::UnsignedHyper:
53 case codemaker::UnoType::Sort::Float:
54 case codemaker::UnoType::Sort::Double:
55 o << "0";
56 return;
57 default:
58 break;
62 if (defaultvalue) {
63 if (sort == codemaker::UnoType::Sort::Interface) {
64 o << "null";
65 return;
66 } else if (sort == codemaker::UnoType::Sort::Any && rank == 0) {
67 o << "com.sun.star.uno.Any.VOID";
68 return;
69 } else if (sort == codemaker::UnoType::Sort::Type && rank == 0) {
70 o << "com.sun.star.uno.Type.VOID";
71 return;
72 } else if (sort != codemaker::UnoType::Sort::Enum || rank != 0) {
73 o << "new ";
77 OString sType(
78 codemaker::java::translateUnoToJavaType(
79 sort, u2b(nucleus), referenceType && rank == 0));
80 if (sType.startsWith("java.lang.")) {
81 sType = sType.copy(std::strlen("java.lang."));
83 o << sType;
84 if (!arguments.empty()) {
85 o << '<';
86 for (std::vector< OUString >::const_iterator i(arguments.begin());
87 i != arguments.end(); ++i)
89 if (i != arguments.begin()) {
90 o << ", ";
92 printType(o, options, manager, *i, true);
94 o << '>';
96 for (sal_Int32 i = 0; i != rank; ++i) {
97 if (defaultvalue)
98 o << "[0]";
99 else
100 o << "[]";
103 if (defaultvalue && sort > codemaker::UnoType::Sort::Char && rank == 0) {
104 if (sort == codemaker::UnoType::Sort::Enum)
105 o << ".getDefault()";
106 else
107 o << "()";
111 void printType(
112 std::ostream & o, ProgramOptions const & options,
113 rtl::Reference< TypeManager > const & manager, OUString const & name,
114 bool referenceType, bool defaultvalue)
116 OUString nucleus;
117 sal_Int32 rank;
118 std::vector< OUString > arguments;
119 codemaker::UnoType::Sort sort = manager->decompose(
120 name, true, &nucleus, &rank, &arguments, nullptr);
121 printType(
122 o, options, manager, sort, nucleus, rank, arguments, referenceType,
123 defaultvalue);
126 bool printConstructorParameters(
127 std::ostream & o, ProgramOptions const & options,
128 rtl::Reference< TypeManager > const & manager,
129 codemaker::UnoType::Sort sort,
130 rtl::Reference< unoidl::Entity > const & entity, OUString const & name,
131 std::vector< OUString > const & arguments)
133 bool previous = false;
134 switch (sort) {
135 case codemaker::UnoType::Sort::PlainStruct:
137 rtl::Reference< unoidl::PlainStructTypeEntity > ent2(
138 dynamic_cast< unoidl::PlainStructTypeEntity * >(entity.get()));
139 assert(ent2.is());
140 if (!ent2->getDirectBase().isEmpty()) {
141 rtl::Reference< unoidl::Entity > baseEnt;
142 codemaker::UnoType::Sort baseSort = manager->getSort(
143 ent2->getDirectBase(), &baseEnt);
144 previous = printConstructorParameters(
145 o, options, manager, baseSort, baseEnt,
146 ent2->getDirectBase(), std::vector< OUString >());
148 for (std::vector< unoidl::PlainStructTypeEntity::Member >::
149 const_iterator i(ent2->getDirectMembers().begin());
150 i != ent2->getDirectMembers().end(); ++i)
152 if (previous) {
153 o << ", ";
155 previous = true;
156 printType(o, options, manager, i->type, false);
157 o << ' '
158 << codemaker::java::translateUnoToJavaIdentifier(
159 u2b(i->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 (std::vector<
170 unoidl::PolymorphicStructTypeTemplateEntity::Member >::
171 const_iterator i(ent2->getMembers().begin());
172 i != ent2->getMembers().end(); ++i)
174 if (previous) {
175 o << ", ";
177 previous = true;
178 if (i->parameterized) {
179 o << i->type;
180 } else {
181 printType(o, options, manager, i->type, false);
183 o << ' '
184 << codemaker::java::translateUnoToJavaIdentifier(
185 u2b(i->name), "param");
187 break;
189 case codemaker::UnoType::Sort::InstantiatedPolymorphicStruct:
191 rtl::Reference< unoidl::PolymorphicStructTypeTemplateEntity > ent2(
192 dynamic_cast< unoidl::PolymorphicStructTypeTemplateEntity * >(
193 entity.get()));
194 assert(ent2.is());
195 for (std::vector<
196 unoidl::PolymorphicStructTypeTemplateEntity::Member >::
197 const_iterator i(ent2->getMembers().begin());
198 i != ent2->getMembers().end(); ++i)
200 if (previous) {
201 o << ", ";
203 previous = true;
204 if (i->parameterized) {
205 for (std::vector< OUString >::const_iterator j(
206 ent2->getTypeParameters().begin());
207 j != ent2->getTypeParameters().end(); ++j)
209 if (i->type == *j) {
210 o << arguments[
211 j - ent2->getTypeParameters().begin()];
212 break;
215 } else {
216 printType(o, options, manager, i->type, false);
218 o << ' '
219 << codemaker::java::translateUnoToJavaIdentifier(
220 u2b(i->name), "param");
222 break;
224 case codemaker::UnoType::Sort::Exception:
226 rtl::Reference< unoidl::ExceptionTypeEntity > ent2(
227 dynamic_cast< unoidl::ExceptionTypeEntity * >(entity.get()));
228 assert(ent2.is());
229 if (!ent2->getDirectBase().isEmpty()) {
230 rtl::Reference< unoidl::Entity > baseEnt;
231 codemaker::UnoType::Sort baseSort = manager->getSort(
232 ent2->getDirectBase(), &baseEnt);
233 previous = printConstructorParameters(
234 o, options, manager, baseSort, baseEnt,
235 ent2->getDirectBase(), std::vector< OUString >());
237 for (std::vector< unoidl::ExceptionTypeEntity::Member >::
238 const_iterator i(ent2->getDirectMembers().begin());
239 i != ent2->getDirectMembers().end(); ++i)
241 if (previous) {
242 o << ", ";
244 previous = true;
245 printType(o, options, manager, i->type, false);
246 o << ' '
247 << codemaker::java::translateUnoToJavaIdentifier(
248 u2b(i->name), "param");
250 break;
252 default:
253 throw CannotDumpException(
254 "unexpected entity \"" + name
255 + "\" in call to skeletonmaker::cpp::printConstructorParameters");
257 return previous;
260 void printConstructor(
261 std::ostream & o, ProgramOptions const & options,
262 rtl::Reference< TypeManager > const & manager,
263 codemaker::UnoType::Sort sort,
264 rtl::Reference< unoidl::Entity > const & entity, OUString const & name,
265 std::vector< OUString > const & arguments)
267 o << "public " << name.copy(name.lastIndexOf('.') + 1) << '(';
268 printConstructorParameters(
269 o, options, manager, sort, entity, name, arguments);
270 o << ");\n";
273 void printMethodParameters(
274 std::ostream & o, ProgramOptions const & options,
275 rtl::Reference< TypeManager > const & manager,
276 std::vector< unoidl::InterfaceTypeEntity::Method::Parameter > const &
277 parameters,
278 bool withType)
280 for (std::vector< unoidl::InterfaceTypeEntity::Method::Parameter >::
281 const_iterator i(parameters.begin());
282 i != parameters.end(); ++i)
284 if (i != parameters.begin()) {
285 o << ", ";
287 if (withType) {
288 printType(o, options, manager, i->type, false);
289 if (i->direction
290 != unoidl::InterfaceTypeEntity::Method::Parameter::DIRECTION_IN)
292 o << "[]";
294 o << ' ';
296 o << codemaker::java::translateUnoToJavaIdentifier(
297 u2b(i->name), "param");
301 void printExceptionSpecification(
302 std::ostream & o, ProgramOptions const & options,
303 rtl::Reference< TypeManager > const & manager,
304 std::vector< OUString > const & exceptions)
306 if (!exceptions.empty()) {
307 o << " throws ";
308 for (std::vector< OUString >::const_iterator i(exceptions.begin());
309 i != exceptions.end(); ++i)
311 if (i !=exceptions.begin() ) {
312 o << ", ";
314 printType(o, options, manager, *i, false);
320 void printSetPropertyMixinBody(
321 std::ostream & o, unoidl::InterfaceTypeEntity::Attribute const & attribute,
322 OString const & indentation)
324 unoidl::AccumulationBasedServiceEntity::Property::Attributes propFlags
325 = checkAdditionalPropertyFlags(attribute);
327 o << "\n" << indentation << "{\n";
329 if ( attribute.bound ) {
330 o << indentation << " PropertySetMixin.BoundListeners l = "
331 "new PropertySetMixin.BoundListeners();\n\n";
334 o << indentation << " m_prophlp.prepareSet(\""
335 << attribute.name << "\", ";
336 if ( propFlags & unoidl::AccumulationBasedServiceEntity::Property::ATTRIBUTE_CONSTRAINED ) {
337 OString fieldtype = codemaker::convertString(attribute.type);
339 sal_Int32 index = fieldtype.lastIndexOf('<');
340 sal_Int32 nPos=0;
341 bool single = true;
342 bool optional = false;
343 OStringBuffer buffer1(64);
344 OStringBuffer buffer2(64);
347 OString s(fieldtype.getToken(0, '<', nPos));
348 OStringBuffer buffer(16);
349 buffer.append("((");
350 buffer.append(s.copy(s.lastIndexOf('/')+1));
351 buffer.append(')');
352 OString t = buffer.makeStringAndClear();
354 if ( t.equals("((Optional)") ) {
355 optional=true;
356 if (single) {
357 single=false;
358 buffer1.append("the_value.IsPresent");
359 buffer2.append("the_value.Value");
360 } else {
361 buffer1.insert(0, t);
362 buffer1.append(").IsPresent");
363 buffer2.insert(0, t);
364 buffer2.append(").Value");
366 } else {
367 if ( single ) {
368 single=false;
369 if ( !optional ) {
370 buffer1.append("the_value.Value");
372 buffer2.append("the_value.Value");
373 } else {
374 if ( !optional ) {
375 buffer1.insert(0, t);
376 buffer1.append(").Value");
378 buffer2.insert(0, t);
379 buffer2.append(").Value");
382 } while( nPos <= index );
384 o << "Any.VOID,\n" << indentation << " ";
385 if ( optional )
386 o << "(";
387 o << buffer1.makeStringAndClear();
388 if ( optional )
389 o << ") ? " << buffer2.makeStringAndClear() << " : Any.VOID,\n"
390 << indentation << " ";
391 else
392 o << ", ";
395 if ( attribute.bound )
396 o << "l";
397 else
398 o << "null";
399 o << ");\n";
401 o << indentation << " synchronized (this) {\n"
402 << indentation << " m_" << attribute.name
403 << " = the_value;\n" << indentation << " }\n";
405 if ( attribute.bound ) {
406 o << indentation << " l.notifyListeners();\n";
408 o << indentation << "}\n\n";
411 void printMethods(std::ostream & o,
412 ProgramOptions const & options, rtl::Reference< TypeManager > const & manager,
413 OUString const & name,
414 codemaker::GeneratedTypeSet & generated,
415 OString const & delegate, OString const & indentation,
416 bool defaultvalue, bool usepropertymixin)
418 if ( generated.contains(u2b(name)) || name == "com.sun.star.uno.XInterface" ||
419 ( defaultvalue &&
420 ( name == "com.sun.star.lang.XComponent" ||
421 name == "com.sun.star.lang.XTypeProvider" ||
422 name == "com.sun.star.uno.XWeak" ) ) ) {
423 return;
426 if ( usepropertymixin ) {
427 if (name == "com.sun.star.beans.XPropertySet") {
428 generated.add(u2b(name));
429 generateXPropertySetBodies(o);
430 return;
431 } else if (name == "com.sun.star.beans.XFastPropertySet") {
432 generated.add(u2b(name));
433 generateXFastPropertySetBodies(o);
434 return;
435 } else if (name == "com.sun.star.beans.XPropertyAccess") {
436 generated.add(u2b(name));
437 generateXPropertyAccessBodies(o);
438 return;
442 static OString sd("_");
443 bool body = !delegate.isEmpty();
444 bool defaultbody = delegate.equals(sd);
446 generated.add(u2b(name));
447 rtl::Reference< unoidl::Entity > ent;
448 if (manager->getSort(name, &ent) != codemaker::UnoType::Sort::Interface)
450 throw CannotDumpException(
451 "unexpected entity \"" + name
452 + "\" in call to skeletonmaker::java::printMethods");
454 rtl::Reference< unoidl::InterfaceTypeEntity > ent2(
455 dynamic_cast< unoidl::InterfaceTypeEntity * >(ent.get()));
456 assert(ent2.is());
457 if ( options.all || defaultvalue ) {
458 for (std::vector< unoidl::AnnotatedReference >::const_iterator i(
459 ent2->getDirectMandatoryBases().begin());
460 i != ent2->getDirectMandatoryBases().end(); ++i)
462 printMethods(
463 o, options, manager, i->name, generated, delegate, indentation,
464 defaultvalue, usepropertymixin);
466 if (!(ent2->getDirectAttributes().empty()
467 && ent2->getDirectMethods().empty()))
469 o << indentation << "// ";
470 printType(o, options, manager, name, false);
471 o << ":\n";
474 for (std::vector< unoidl::InterfaceTypeEntity::Attribute >::const_iterator
475 i(ent2->getDirectAttributes().begin());
476 i != ent2->getDirectAttributes().end(); ++i)
478 o << indentation << "public ";
479 printType(o, options, manager, i->type, false);
480 o << " get" << i->name << "()";
481 printExceptionSpecification(o, options, manager, i->getExceptions);
482 if ( body ) {
483 if ( defaultbody ) {
484 if ( usepropertymixin ) {
485 o << "\n" << indentation << "{\n" << indentation
486 << " return m_" << i->name << ";\n" << indentation
487 << "}\n\n";
488 } else {
489 o << "\n" << indentation << "{\n" << indentation
490 << " return ";
491 printType(o, options, manager, i->type, false, true);
492 o << ";\n" << indentation << "}\n\n";
494 } else {
495 o << "\n" << indentation << "{\n" << indentation
496 << " return " << delegate.getStr() << "get" << i->name
497 << "();\n" << indentation << "}\n\n";
499 } else {
500 o << ";\n";
503 // REMOVE next line
504 if (!i->readOnly) {
505 o << indentation << "public void set" << i->name << '(';
506 printType(o, options, manager, i->type, false);
507 o << " the_value)";
508 printExceptionSpecification(o, options, manager, i->setExceptions);
509 if ( body ) {
510 if ( defaultbody ) {
511 if ( usepropertymixin ) {
512 printSetPropertyMixinBody(o, *i, indentation);
513 } else {
514 o << "\n" << indentation << "{\n\n" << indentation
515 << "}\n\n";
517 } else {
518 o << "\n" << indentation << "{\n" << indentation
519 << " " << delegate.getStr() << "set" << i->name
520 << "(the_value);\n" << indentation << "}\n\n";
522 } else {
523 o << ";\n";
527 for (std::vector< unoidl::InterfaceTypeEntity::Method >::const_iterator i(
528 ent2->getDirectMethods().begin());
529 i != ent2->getDirectMethods().end(); ++i)
531 o << indentation << "public ";
532 printType(o, options, manager, i->returnType, false);
533 o << ' ' << i->name << '(';
534 printMethodParameters(o, options, manager, i->parameters, true);
535 o << ')';
536 printExceptionSpecification(o, options, manager, i->exceptions);
537 if ( body ) {
538 if ( defaultbody ) {
539 o << "\n" << indentation << "{\n";
540 if (i->returnType != "void") {
541 o << indentation << " // TODO: Exchange the default return implementation for \"" << i->name << "\" !!!\n";
542 o << indentation << " // NOTE: "
543 "Default initialized polymorphic structs can cause problems"
544 "\n" << indentation << " // because of missing default "
545 "initialization of primitive types of\n" << indentation
546 << " // some C++ compilers or different Any initialization"
547 " in Java and C++\n" << indentation
548 << " // polymorphic structs.\n" << indentation
549 << " return ";
550 printType(o, options, manager, i->returnType, false, true);
551 o << ";";
552 } else {
553 o << indentation << " // TODO: Insert your implementation for \""
554 << i->name << "\" here.";
556 o << "\n" << indentation << "}\n\n";
557 } else {
558 o << "\n" << indentation << "{\n" << indentation << " ";
559 if (i->returnType != "void") {
560 o << "return ";
562 o << delegate.getStr() << i->name << '(';
563 printMethodParameters(
564 o, options, manager, i->parameters, false);
565 o << ");\n" << indentation << "}\n\n";
567 } else {
568 o << ";\n";
573 void printConstructors(
574 std::ostream & o, ProgramOptions const & options,
575 rtl::Reference< TypeManager > const & manager, OUString const & name)
577 rtl::Reference< unoidl::Entity > ent;
578 if (manager->getSort(name, &ent)
579 != codemaker::UnoType::Sort::SingleInterfaceBasedService)
581 throw CannotDumpException(
582 "unexpected entity \"" + name
583 + "\" in call to skeletonmaker::java::printConstructors");
585 rtl::Reference< unoidl::SingleInterfaceBasedServiceEntity > ent2(
586 dynamic_cast< unoidl::SingleInterfaceBasedServiceEntity * >(ent.get()));
587 assert(ent2.is());
588 for (std::vector< unoidl::SingleInterfaceBasedServiceEntity::Constructor >::
589 const_iterator i(ent2->getConstructors().begin());
590 i != ent2->getConstructors().end(); ++i)
592 o << "public static ";
593 printType(o, options, manager, ent2->getBase(), false);
594 o << ' ';
595 if (i->defaultConstructor) {
596 o << "create";
597 } else {
598 o << codemaker::java::translateUnoToJavaIdentifier(
599 u2b(i->name), "method");
601 o << "(com.sun.star.uno.XComponentContext the_context";
602 for (std::vector<
603 unoidl::SingleInterfaceBasedServiceEntity::Constructor::
604 Parameter >::const_iterator j(i->parameters.begin());
605 j != i->parameters.end(); ++i)
607 o << ", ";
608 printType(o, options, manager, j->type, false);
609 if (j->rest) {
610 o << "...";
612 o << ' '
613 << codemaker::java::translateUnoToJavaIdentifier(
614 u2b(j->name), "param");
616 o << ')';
617 printExceptionSpecification(o, options, manager, i->exceptions);
618 o << ";\n";
622 void printServiceMembers(
623 std::ostream & o, ProgramOptions const & options,
624 rtl::Reference< TypeManager > const & manager,
625 OUString const & name,
626 rtl::Reference< unoidl::AccumulationBasedServiceEntity > const & entity,
627 OString const & delegate)
629 assert(entity.is());
630 for (std::vector< unoidl::AnnotatedReference >::const_iterator i(
631 entity->getDirectMandatoryBaseServices().begin());
632 i != entity->getDirectMandatoryBaseServices().end(); ++i)
634 o << "\n// exported service " << i->name << "\n";
635 generateDocumentation(o, options, manager, u2b(i->name), delegate);
637 for (std::vector< unoidl::AnnotatedReference >::const_iterator i(
638 entity->getDirectMandatoryBaseInterfaces().begin());
639 i != entity->getDirectMandatoryBaseInterfaces().end(); ++i)
641 o << "\n// supported interface " << i->name << "\n";
642 generateDocumentation(o, options, manager, u2b(i->name), delegate);
644 o << "\n// properties of service \""<< name << "\"\n";
645 for (std::vector< unoidl::AccumulationBasedServiceEntity::Property >::
646 const_iterator i(entity->getDirectProperties().begin());
647 i != entity->getDirectProperties().end(); ++i)
649 o << "// private ";
650 printType(o, options, manager, i->type, false);
651 o << " "
652 << codemaker::java::translateUnoToJavaIdentifier(
653 u2b(i->name), "property")
654 << ";\n";
658 void printMapsToJavaType(
659 std::ostream & o, ProgramOptions const & options,
660 rtl::Reference< TypeManager > const & manager,
661 codemaker::UnoType::Sort sort, OUString const & nucleus, sal_Int32 rank,
662 std::vector< OUString > const & arguments, const char * javaTypeSort)
664 o << "maps to Java 1.5 ";
665 if (javaTypeSort != nullptr) {
666 o << javaTypeSort << ' ';
668 o << "type \"";
669 if (rank == 0 && nucleus == "com.sun.star.uno.XInterface") {
670 o << "com.sun.star.uno.XInterface";
671 } else {
672 printType(
673 o, options, manager, sort, nucleus, rank, arguments, false, false);
675 o << '"';
678 void generateDocumentation(std::ostream & o,
679 ProgramOptions const & options, rtl::Reference< TypeManager > const & manager,
680 OString const & type, OString const & delegate)
682 OUString nucleus;
683 sal_Int32 rank;
684 codemaker::UnoType::Sort sort = manager->decompose(
685 b2u(type), false, &nucleus, &rank, nullptr, nullptr);
687 bool comment = true;
688 if (!delegate.isEmpty()) {
689 if (sort != codemaker::UnoType::Sort::Interface &&
690 sort != codemaker::UnoType::Sort::SingleInterfaceBasedService &&
691 sort != codemaker::UnoType::Sort::AccumulationBasedService )
693 return;
695 comment = false;
698 if (comment) {
699 o << "\n// UNO";
700 if (rank != 0) {
701 o << " sequence type";
702 } else if (sort <= codemaker::UnoType::Sort::Any) {
703 o << " simple type";
704 } else {
705 switch (sort) {
706 case codemaker::UnoType::Sort::Interface:
707 o << " interface type";
708 break;
710 case codemaker::UnoType::Sort::Module:
711 o << "IDL module";
712 break;
714 case codemaker::UnoType::Sort::PlainStruct:
715 o << " simple struct type";
716 break;
718 case codemaker::UnoType::Sort::PolymorphicStructTemplate:
719 o << " polymorphic struct type template";
720 break;
722 case codemaker::UnoType::Sort::InstantiatedPolymorphicStruct:
723 o << " instantiated polymorphic struct type";
724 break;
726 case codemaker::UnoType::Sort::Enum:
727 o << " enum type";
728 break;
730 case codemaker::UnoType::Sort::Exception:
731 o << " exception type";
732 break;
734 case codemaker::UnoType::Sort::Typedef:
735 o << "IDL typedef";
736 break;
738 case codemaker::UnoType::Sort::SingleInterfaceBasedService:
739 o << " single-inheritance--based service";
740 break;
742 case codemaker::UnoType::Sort::AccumulationBasedService:
743 o << "IDL accumulation-based service";
744 break;
746 case codemaker::UnoType::Sort::InterfaceBasedSingleton:
747 o << " inheritance-based singleton";
748 break;
750 case codemaker::UnoType::Sort::ServiceBasedSingleton:
751 o << "IDL service-based singleton";
752 break;
754 case codemaker::UnoType::Sort::ConstantGroup:
755 o << "IDL constant group";
756 break;
758 default:
759 OSL_ASSERT(false);
760 break;
763 o << " \"" << type << "\" ";
765 std::vector< OUString > arguments;
766 rtl::Reference< unoidl::Entity > entity;
767 sort = manager->decompose(
768 b2u(type), true, &nucleus, &rank, &arguments, &entity);
769 if (rank != 0) {
770 printMapsToJavaType(
771 o, options, manager, sort, nucleus, rank, arguments, "array");
772 o << '\n';
773 } else if (sort <= codemaker::UnoType::Sort::Any) {
774 printMapsToJavaType(
775 o, options, manager, sort, nucleus, rank, arguments, nullptr);
776 o << '\n';
777 } else {
778 switch (sort) {
779 case codemaker::UnoType::Sort::Interface:
780 printMapsToJavaType(
781 o, options, manager, sort, nucleus, rank, arguments,
782 "interface");
783 if (nucleus == "com.sun.star.uno.XInterface") {
784 o << '\n';
785 } else {
786 o << "; " << (options.all ? "all" : "direct") << " methods:\n";
787 codemaker::GeneratedTypeSet generated;
788 printMethods(
789 o, options, manager, nucleus, generated, delegate, "");
791 break;
793 case codemaker::UnoType::Sort::Module:
794 printMapsToJavaType(
795 o, options, manager, sort, nucleus, rank, arguments, "package");
796 o << '\n';
797 break;
799 case codemaker::UnoType::Sort::PlainStruct:
800 printMapsToJavaType(
801 o, options, manager, sort, nucleus, rank, arguments, "class");
802 o << "; full constructor:\n";
803 printConstructor(
804 o, options, manager, codemaker::UnoType::Sort::PlainStruct,
805 entity, nucleus, arguments);
806 break;
808 case codemaker::UnoType::Sort::PolymorphicStructTemplate:
809 printMapsToJavaType(
810 o, options, manager, sort, nucleus, rank, arguments,
811 "generic class");
812 o << "; full constructor:\n";
813 printConstructor(
814 o, options, manager,
815 codemaker::UnoType::Sort::PolymorphicStructTemplate,
816 entity, nucleus, arguments);
817 break;
819 case codemaker::UnoType::Sort::InstantiatedPolymorphicStruct:
820 printMapsToJavaType(
821 o, options, manager, sort, nucleus, rank, arguments,
822 "generic class instantiation");
823 o << "; full constructor:\n";
824 printConstructor(
825 o, options, manager,
826 codemaker::UnoType::Sort::InstantiatedPolymorphicStruct,
827 entity, nucleus, arguments);
828 break;
830 case codemaker::UnoType::Sort::Enum:
831 case codemaker::UnoType::Sort::ConstantGroup:
832 printMapsToJavaType(
833 o, options, manager, sort, nucleus, rank, arguments, "class");
834 o << '\n';
835 break;
837 case codemaker::UnoType::Sort::Exception:
838 printMapsToJavaType(
839 o, options, manager, sort, nucleus, rank, arguments,
840 "exception class");
841 o << "; full constructor:\n";
842 printConstructor(
843 o, options, manager, codemaker::UnoType::Sort::Exception,
844 entity, nucleus, arguments);
845 break;
847 case codemaker::UnoType::Sort::SingleInterfaceBasedService:
848 printMapsToJavaType(
849 o, options, manager, sort, nucleus, rank, arguments, "class");
850 o << "; construction methods:\n";
851 printConstructors(o, options, manager, nucleus);
852 generateDocumentation(
853 o, options, manager,
854 u2b(dynamic_cast< unoidl::SingleInterfaceBasedServiceEntity * >(
855 entity.get())->getBase()),
856 delegate);
857 break;
859 case codemaker::UnoType::Sort::AccumulationBasedService:
860 o << ("does not map to Java\n"
861 "// the service members are generated instead\n");
862 printServiceMembers(
863 o, options, manager, nucleus,
864 dynamic_cast< unoidl::AccumulationBasedServiceEntity * >(
865 entity.get()),
866 delegate);
867 break;
869 case codemaker::UnoType::Sort::InterfaceBasedSingleton:
870 printMapsToJavaType(
871 o, options, manager, sort, nucleus, rank, arguments, "class");
872 o << "; get method:\npublic static ";
873 printType(
874 o, options, manager,
875 dynamic_cast< unoidl::InterfaceBasedSingletonEntity * >(
876 entity.get())->getBase(),
877 false);
878 o << " get(com.sun.star.uno.XComponentContext context);\n";
879 break;
881 case codemaker::UnoType::Sort::ServiceBasedSingleton:
882 o << "does not map to Java\n";
883 break;
885 default:
886 OSL_ASSERT(false);
887 break;
895 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */