Bump for 3.6-28
[LibreOffice.git] / unodevtools / source / skeletonmaker / javatypemaker.cxx
blob51b52e51b047816943735ceaa98344ecd32a9d19
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 #include "codemaker/commonjava.hxx"
31 #include "ostringostreaminserter.hxx"
32 #include "skeletoncommon.hxx"
33 #include "skeletonjava.hxx"
35 using namespace ::rtl;
37 namespace skeletonmaker { namespace java {
39 void printType(std::ostream & o,
40 ProgramOptions const & options, TypeManager const & manager,
41 OString const & type, bool referenceType,
42 bool defaultvalue);
44 void printType(std::ostream & o,
45 ProgramOptions const & options, TypeManager const & manager,
46 codemaker::UnoType::Sort sort, RTTypeClass typeClass,
47 OString const & name, sal_Int32 rank,
48 std::vector< OString > const & arguments, bool referenceType,
49 bool defaultvalue)
51 if ( defaultvalue && rank == 0 && sort <= codemaker::UnoType::SORT_CHAR ) {
52 switch (sort)
54 case codemaker::UnoType::SORT_BOOLEAN:
55 o << "false";
56 return;
57 case codemaker::UnoType::SORT_CHAR:
58 case codemaker::UnoType::SORT_BYTE:
59 case codemaker::UnoType::SORT_SHORT:
60 case codemaker::UnoType::SORT_UNSIGNED_SHORT:
61 case codemaker::UnoType::SORT_LONG:
62 case codemaker::UnoType::SORT_UNSIGNED_LONG:
63 case codemaker::UnoType::SORT_HYPER:
64 case codemaker::UnoType::SORT_UNSIGNED_HYPER:
65 case codemaker::UnoType::SORT_FLOAT:
66 case codemaker::UnoType::SORT_DOUBLE:
67 o << "0";
68 return;
69 case codemaker::UnoType::SORT_VOID:
70 case codemaker::UnoType::SORT_STRING:
71 case codemaker::UnoType::SORT_TYPE:
72 case codemaker::UnoType::SORT_ANY:
73 case codemaker::UnoType::SORT_COMPLEX:
74 break;
78 if ( defaultvalue ) {
79 if ( sort == codemaker::UnoType::SORT_COMPLEX &&
80 typeClass == RT_TYPE_INTERFACE ) {
81 o << "null";
82 return;
83 } else if ( sort == codemaker::UnoType::SORT_ANY && rank==0 ) {
84 o << "com.sun.star.uno.Any.VOID";
85 return;
86 } else if ( sort == codemaker::UnoType::SORT_TYPE && rank==0 ) {
87 o << "com.sun.star.uno.Type.VOID";
88 return;
89 } else
90 if ( typeClass != RT_TYPE_ENUM || rank > 0 )
91 o << "new ";
94 OString sType(codemaker::java::translateUnoToJavaType(
95 sort, typeClass, name, referenceType && rank==0).replace('/', '.'));
96 if ( sType.indexOf("java.lang.") == 0 )
97 sType = sType.copy(10);
98 o << sType.getStr();
99 if ( !arguments.empty() && options.java5 ) {
100 o << '<';
101 for ( std::vector< OString >::const_iterator i(arguments.begin());
102 i != arguments.end(); ++i )
104 if ( i != arguments.begin() ) {
105 o << ", ";
108 printType(o, options, manager, *i, true, false);
110 o << '>';
112 for ( sal_Int32 i = 0; i < rank; ++i ) {
113 if ( defaultvalue )
114 o << "[0]";
115 else
116 o << "[]";
119 if ( defaultvalue && sort > codemaker::UnoType::SORT_CHAR && rank == 0 ) {
120 if ( typeClass == RT_TYPE_ENUM )
121 o << ".getDefault()";
122 else
123 o << "()";
127 void printType(std::ostream & o,
128 ProgramOptions const & options, TypeManager const & manager,
129 OString const & type, bool referenceType, bool defaultvalue)
131 RTTypeClass typeClass;
132 OString name;
133 sal_Int32 rank;
134 std::vector< OString > arguments;
135 codemaker::UnoType::Sort sort = codemaker::decomposeAndResolve(
136 manager, type, true, true, true, &typeClass, &name, &rank, &arguments);
137 printType(o,
138 options, manager, sort, typeClass, name, rank, arguments,
139 referenceType, defaultvalue);
142 bool printConstructorParameters(std::ostream & o,
143 ProgramOptions const & options, TypeManager const & manager,
144 typereg::Reader const & reader, typereg::Reader const & outerReader,
145 std::vector< OString > const & arguments)
147 bool previous = false;
148 if ( reader.getSuperTypeCount() != 0 ) {
149 OString super(
150 codemaker::convertString(reader.getSuperTypeName(0)));
151 typereg::Reader superReader(manager.getTypeReader(super));
152 if ( !superReader.isValid() ) {
153 throw CannotDumpException("Bad type library entity " + super);
155 previous = printConstructorParameters(o,
156 options, manager, superReader, outerReader, arguments);
158 for ( sal_uInt16 i = 0; i < reader.getFieldCount(); ++i ) {
159 if ( previous ) {
160 o << ", ";
162 previous = true;
163 if ( (reader.getFieldFlags(i) & RT_ACCESS_PARAMETERIZED_TYPE) == 0 ) {
164 printType(o,
165 options, manager,
166 codemaker::convertString(reader.getFieldTypeName(i)),
167 false);
168 } else if ( arguments.empty() ) {
169 o << "java.lang.Object";
170 } else {
171 sal_uInt16 tparam = 0;
172 while ( outerReader.getReferenceTypeName(tparam)
173 != reader.getFieldTypeName(i) )
175 ++tparam;
176 OSL_ASSERT(tparam < outerReader.getReferenceCount());
178 // assume std::vector< OString >::size_type is at least as
179 // large as sal_uInt16:
180 printType(o, options, manager, arguments[tparam], true);
183 << ' '
184 << (codemaker::java::translateUnoToJavaIdentifier(
185 codemaker::convertString(reader.getFieldName(i)),
186 "param").
187 getStr());
189 return previous;
192 void printConstructor(std::ostream & o,
193 ProgramOptions const & options, TypeManager const & manager,
194 typereg::Reader const & reader,
195 std::vector< OString > const & arguments)
197 OString type(codemaker::convertString(reader.getTypeName()));
198 o << "public " << type.copy(type.lastIndexOf('/') + 1) << '(';
199 printConstructorParameters(o, options, manager, reader, reader, arguments);
200 o << ");\n";
203 void printMethodParameters(std::ostream & o,
204 ProgramOptions const & options, TypeManager const & manager,
205 typereg::Reader const & reader, sal_uInt16 method, bool previous,
206 bool withtype)
208 for ( sal_uInt16 i = 0; i < reader.getMethodParameterCount(method); ++i ) {
209 if ( previous )
210 o << ", ";
211 else
212 previous = true;
214 if ( withtype ) {
215 printType(o, options, manager,
216 codemaker::convertString(
217 reader.getMethodParameterTypeName(method, i)),
218 false);
219 if ( reader.getMethodParameterFlags(method, i) == RT_PARAM_OUT
220 || reader.getMethodParameterFlags(method, i) == RT_PARAM_INOUT )
222 o << "[]";
223 } else if ( (reader.getMethodParameterFlags(method, i) & RT_PARAM_REST )
224 != 0)
226 o << (options.java5 ? "..." : "[]");
228 o << ' ';
230 o << (codemaker::java::translateUnoToJavaIdentifier(
231 codemaker::convertString(
232 reader.getMethodParameterName(method, i)),
233 "param").
234 getStr());
238 void printExceptionSpecification(std::ostream & o,
239 ProgramOptions const & options, TypeManager const & manager,
240 typereg::Reader const & reader, sal_uInt16 method)
242 if ( reader.getMethodExceptionCount(method) > 0 ) {
243 o << " throws ";
244 for ( sal_uInt16 i = 0; i < reader.getMethodExceptionCount(method); ++i )
246 if ( i != 0 ) {
247 o << ", ";
249 printType(o,
250 options, manager,
251 codemaker::convertString(
252 reader.getMethodExceptionTypeName(method, i)),
253 false);
259 void printSetPropertyMixinBody(std::ostream & o,
260 typereg::Reader const & reader,
261 sal_uInt16 field,
262 sal_uInt16 method,
263 OString const & indentation)
265 RTFieldAccess propFlags = checkAdditionalPropertyFlags(reader, field, method);
266 OString fieldname = codemaker::convertString(reader.getFieldName(field));
267 bool bound = (reader.getFieldFlags(field) & RT_ACCESS_BOUND ? true : false);
269 o << "\n" << indentation << "{\n";
271 if ( bound ) {
272 o << indentation << " PropertySetMixin.BoundListeners l = "
273 "new PropertySetMixin.BoundListeners();\n\n";
276 o << indentation << " m_prophlp.prepareSet(\""
277 << fieldname << "\", ";
278 if ( propFlags & RT_ACCESS_CONSTRAINED ) {
279 OString fieldtype = codemaker::convertString(reader.getFieldTypeName(field));
281 sal_Int32 index = fieldtype.lastIndexOf('<');
282 sal_Int32 nPos=0;
283 bool single = true;
284 bool optional = false;
285 OStringBuffer buffer1(64);
286 OStringBuffer buffer2(64);
289 OString s(fieldtype.getToken(0, '<', nPos));
290 OStringBuffer buffer(16);
291 buffer.append("((");
292 buffer.append(s.copy(s.lastIndexOf('/')+1));
293 buffer.append(')');
294 OString t = buffer.makeStringAndClear();
296 if ( t.equals("((Optional)") ) {
297 optional=true;
298 if (single) {
299 single=false;
300 buffer1.append("the_value.IsPresent");
301 buffer2.append("the_value.Value");
302 } else {
303 buffer1.insert(0, t);
304 buffer1.append(").IsPresent");
305 buffer2.insert(0, t);
306 buffer2.append(").Value");
308 } else {
309 if ( single ) {
310 single=false;
311 if ( !optional ) {
312 buffer1.append("the_value.Value");
314 buffer2.append("the_value.Value");
315 } else {
316 if ( !optional ) {
317 buffer1.insert(0, t);
318 buffer1.append(").Value");
320 buffer2.insert(0, t);
321 buffer2.append(").Value");
324 } while( nPos <= index );
326 o << "Any.VOID,\n" << indentation << " ";
327 if ( optional )
328 o << "(";
329 o << buffer1.makeStringAndClear();
330 if ( optional )
331 o << ") ? " << buffer2.makeStringAndClear() << " : Any.VOID,\n"
332 << indentation << " ";
333 else
334 o << ", ";
337 if ( bound )
338 o << "l";
339 else
340 o << "null";
341 o << ");\n";
343 o << indentation << " synchronized (this) {\n"
344 << indentation << " m_" << fieldname
345 << " = the_value;\n" << indentation << " }\n";
347 if ( bound ) {
348 o << indentation << " l.notifyListeners();\n";
350 o << indentation << "}\n\n";
353 void generateXPropertySetBodies(std::ostream& o);
354 void generateXFastPropertySetBodies(std::ostream& o);
355 void generateXPropertyAccessBodies(std::ostream& o);
357 void printMethods(std::ostream & o,
358 ProgramOptions const & options, TypeManager const & manager,
359 typereg::Reader const & reader,
360 codemaker::GeneratedTypeSet & generated,
361 OString const & delegate, OString const & indentation,
362 bool defaultvalue, bool usepropertymixin)
364 OString type(codemaker::convertString(reader.getTypeName()));
365 if ( generated.contains(type) || type == "com/sun/star/uno/XInterface" ||
366 ( defaultvalue &&
367 ( type.equals("com/sun/star/lang/XComponent") ||
368 type.equals("com/sun/star/lang/XTypeProvider") ||
369 type.equals("com/sun/star/uno/XWeak") ) ) ) {
370 return;
373 if ( usepropertymixin ) {
374 if ( type.equals("com/sun/star/beans/XPropertySet") ) {
375 generated.add(type);
376 generateXPropertySetBodies(o);
377 return;
378 } else if ( type.equals("com/sun/star/beans/XFastPropertySet") ) {
379 generated.add(type);
380 generateXFastPropertySetBodies(o);
381 return;
382 } else if ( type.equals("com/sun/star/beans/XPropertyAccess") ) {
383 generated.add(type);
384 generateXPropertyAccessBodies(o);
385 return;
389 static OString sd(RTL_CONSTASCII_STRINGPARAM("_"));
390 bool body = !delegate.isEmpty();
391 bool defaultbody = ((delegate.equals(sd)) ? true : false);
393 generated.add(type);
394 if ( options.all || defaultvalue ) {
395 for (sal_uInt16 i = 0; i < reader.getSuperTypeCount(); ++i) {
396 typereg::Reader super(
397 manager.getTypeReader(
398 codemaker::convertString(
399 reader.getSuperTypeName(i))));
400 if ( !super.isValid() ) {
401 throw CannotDumpException(
402 "Bad type library entity "
403 + codemaker::convertString(
404 reader.getSuperTypeName(i)));
406 printMethods(o, options, manager, super, generated, delegate,
407 indentation, defaultvalue, usepropertymixin);
409 if ( reader.getFieldCount() > 0 || reader.getMethodCount() > 0 ) {
410 o << indentation << "// ";
411 printType(o, options, manager, type, false);
412 o << ":\n";
415 sal_uInt16 method = 0;
416 for ( sal_uInt16 i = 0; i < reader.getFieldCount(); ++i ) {
417 // OString fieldName(
418 // codemaker::convertString(reader.getFieldName(i)).
419 // replace('/', '.'));
420 // OString fieldType(
421 // codemaker::convertString(reader.getFieldTypeName(i)).
422 // replace('/', '.'));
423 // attributes.insert(StringPairHashMap::value_type(fieldName,
424 // std::pair<OString, sal_Int16>(
425 // fieldType, reader.getFieldFlags(i))));
427 o << indentation << "public ";
428 printType(o,
429 options, manager,
430 codemaker::convertString(reader.getFieldTypeName(i)), false);
431 o << " get"
432 << codemaker::convertString(reader.getFieldName(i)).getStr()
433 << "()";
435 OUString mn = reader.getMethodName(method);
436 OUString fn = reader.getFieldName(i);
438 if ( method < reader.getMethodCount()
439 && reader.getMethodFlags(method) == RT_MODE_ATTRIBUTE_GET
440 && reader.getMethodName(method) == reader.getFieldName(i) )
442 printExceptionSpecification(o, options, manager, reader, method++);
444 if ( body ) {
445 if ( defaultbody ) {
446 if ( usepropertymixin ) {
447 o << "\n" << indentation << "{\n" << indentation
448 << " return m_"
449 << codemaker::convertString(reader.getFieldName(i)).getStr()
450 << ";\n" << indentation << "}\n\n";
451 } else {
452 o << "\n" << indentation << "{\n" << indentation
453 << " return ";
454 printType(o,
455 options, manager,
456 codemaker::convertString(reader.getFieldTypeName(i)),
457 false, true);
458 o << ";\n" << indentation << "}\n\n";
460 } else {
461 o << "\n" << indentation << "{\n" << indentation <<
462 " return "
463 << delegate.getStr() << "get"
464 << codemaker::convertString(reader.getFieldName(i)).getStr()
465 << "();\n" << indentation << "}\n\n";
467 } else {
468 o << ";\n";
471 // REMOVE next line
472 OUString tmp = reader.getFieldName(i);
473 bool setAttrMethod = false;
474 if ( (reader.getFieldFlags(i) & RT_ACCESS_READONLY) == 0 ) {
475 o << indentation << "public void set"
476 << (codemaker::convertString(reader.getFieldName(i)).
477 getStr())
478 << '(';
479 printType(o,
480 options, manager,
481 codemaker::convertString(reader.getFieldTypeName(i)),
482 false);
483 o << " the_value)";
484 if ( method < reader.getMethodCount()
485 && reader.getMethodFlags(method) == RT_MODE_ATTRIBUTE_SET
486 && reader.getMethodName(method) == reader.getFieldName(i) )
488 setAttrMethod=true;
489 printExceptionSpecification(o, options, manager, reader, method);
491 if ( body ) {
492 if ( defaultbody ) {
493 if ( usepropertymixin ) {
494 printSetPropertyMixinBody(o, reader, i, method,
495 indentation);
496 } else {
497 o << "\n" << indentation << "{\n\n" << indentation
498 << "}\n\n";
500 } else {
501 o << "\n" << indentation << "{\n" << indentation
502 << " " << delegate.getStr() << "set"
503 << codemaker::convertString(reader.getFieldName(i)).getStr()
504 << "(the_value);\n" << indentation << "}\n\n";
506 } else {
507 o << ";\n";
509 if (setAttrMethod) ++method;
512 for ( ; method < reader.getMethodCount(); ++method ) {
513 o << indentation << "public ";
514 printType(o,
515 options, manager,
516 codemaker::convertString(
517 reader.getMethodReturnTypeName(method)),
518 false);
520 const OString methodName(codemaker::convertString(reader.getMethodName(method)));
522 o << ' ' << methodName.getStr() << '(';
523 printMethodParameters(o, options, manager, reader, method, false, true);
524 o << ')';
525 printExceptionSpecification(o, options, manager, reader, method);
526 if ( body ) {
527 static OUString s(RTL_CONSTASCII_USTRINGPARAM("void"));
528 if ( defaultbody ) {
529 o << "\n" << indentation << "{\n";
530 if ( !reader.getMethodReturnTypeName(method).equals(s) ) {
531 o << indentation << " // TODO: Exchange the default return "
532 << "implementation for \"" << methodName << "\" !!!\n";
533 o << indentation << " // NOTE: "
534 "Default initialized polymorphic structs can cause problems"
535 "\n" << indentation << " // because of missing default "
536 "initialization of primitive types of\n" << indentation
537 << " // some C++ compilers or different Any initialization"
538 " in Java and C++\n" << indentation
539 << " // polymorphic structs.\n" << indentation
540 << " return ";
541 printType(o,
542 options, manager,
543 codemaker::convertString(
544 reader.getMethodReturnTypeName(method)),
545 false, true);
546 o << ";";
547 } else {
548 o << indentation << " // TODO: Insert your implementation for \""
549 << methodName << "\" here.";
551 o << "\n" << indentation << "}\n\n";
552 } else {
553 o << "\n" << indentation << "{\n" << indentation << " ";
554 if ( !reader.getMethodReturnTypeName(method).equals(s) )
555 o << "return ";
556 o << delegate.getStr()
557 << (codemaker::convertString(
558 reader.getMethodName(method)).getStr())
559 << '(';
560 printMethodParameters(o, options, manager, reader, method,
561 false, false);
562 o << ");\n" << indentation << "}\n\n";
564 } else {
565 o << ";\n";
570 void printConstructionMethods(std::ostream & o,
571 ProgramOptions const & options, TypeManager const & manager,
572 typereg::Reader const & reader)
574 for ( sal_uInt16 i = 0; i < reader.getMethodCount(); ++i ) {
575 o << "public static ";
576 printType(o,
577 options, manager,
578 codemaker::convertString(reader.getSuperTypeName(0)), false);
579 o << ' ';
580 if ( reader.getMethodName(i).isEmpty() ) {
581 o << "create";
582 } else {
583 o << (codemaker::java::translateUnoToJavaIdentifier(
584 codemaker::convertString(reader.getMethodName(i)),
585 "method").getStr());
587 o << "(com.sun.star.uno.XComponentContext the_context";
588 printMethodParameters(o, options, manager, reader, i, true, true);
589 o << ')';
590 printExceptionSpecification(o, options, manager, reader, i);
591 o << ";\n";
595 void generateDocumentation(std::ostream & o,
596 ProgramOptions const & options, TypeManager const & manager,
597 OString const & type);
599 void printServiceMembers(std::ostream & o,
600 ProgramOptions const & options, TypeManager const & manager,
601 typereg::Reader const & reader, OString const & type,
602 OString const & delegate)
604 for ( sal_uInt16 i = 0; i < reader.getReferenceCount(); ++i ) {
605 OString referenceType(
606 codemaker::convertString(
607 reader.getReferenceTypeName(i)).replace('/', '.'));
609 if ( reader.getReferenceSort(i) == RT_REF_SUPPORTS ) {
610 o << "\n// supported interface " << referenceType.getStr() << "\n";
611 generateDocumentation(o, options, manager, referenceType, delegate);
612 } else if ( reader.getReferenceSort(i) == RT_REF_EXPORTS ) {
613 o << "\n// exported service " << referenceType.getStr() << "\n";
614 generateDocumentation(o, options, manager, referenceType, delegate);
618 o << "\n// properties of service \""<< type.getStr() << "\"\n";
619 for ( sal_uInt16 i = 0; i < reader.getFieldCount(); ++i ) {
620 OString fieldName(
621 codemaker::convertString(reader.getFieldName(i)));
622 OString fieldType(
623 codemaker::convertString(reader.getFieldTypeName(i)));
625 o << "// private ";
626 printType(o, options, manager, fieldType, false);
627 o << " "
628 << codemaker::java::translateUnoToJavaIdentifier(
629 fieldName, "property").getStr()
630 << ";\n";
634 void printMapsToJavaType(std::ostream & o,
635 ProgramOptions const & options, TypeManager const & manager,
636 codemaker::UnoType::Sort sort, RTTypeClass typeClass,
637 OString const & name, sal_Int32 rank,
638 std::vector< OString > const & arguments, const char * javaTypeSort)
640 o << "maps to Java " << (options.java5 ? "1.5" : "1.4") << " ";
641 if ( javaTypeSort != 0 ) {
642 o << javaTypeSort << ' ';
644 o << "type \"";
645 if ( rank == 0 && name == "com/sun/star/uno/XInterface" ) {
646 o << "com.sun.star.uno.XInterface";
647 } else {
648 printType(o,
649 options, manager, sort, typeClass, name, rank, arguments, false);
651 o << '"';
654 void generateDocumentation(std::ostream & o,
655 ProgramOptions const & options, TypeManager const & manager,
656 OString const & type, OString const & delegate)
658 if ( type.indexOf('/') >= 0 ) {
659 throw CannotDumpException("Illegal type name " + type);
661 OString binType(type.replace('.', '/'));
662 RTTypeClass typeClass;
663 OString name;
664 sal_Int32 rank;
665 std::vector< OString > arguments;
666 codemaker::UnoType::Sort sort = decomposeResolveAndCheck(
667 manager, binType, false, true, true, &typeClass, &name, &rank,
668 &arguments);
670 bool comment=true;
671 if ( !delegate.isEmpty() ) {
672 if ( typeClass != RT_TYPE_INTERFACE && typeClass != RT_TYPE_SERVICE )
673 return;
675 comment=false;
678 if ( comment ) {
679 o << "\n// UNO";
680 if ( rank > 0 ) {
681 o << " sequence type";
682 } else if ( sort != codemaker::UnoType::SORT_COMPLEX ) {
683 o << " simple type";
684 } else {
685 typereg::Reader reader(manager.getTypeReader(name));
686 if ( !reader.isValid() ) {
687 throw CannotDumpException("Bad type library entity " + name);
689 switch ( typeClass ) {
690 case RT_TYPE_INTERFACE:
691 o << " interface type";
692 break;
694 case RT_TYPE_MODULE:
695 o << "IDL module";
696 break;
698 case RT_TYPE_STRUCT:
699 if ( reader.getReferenceCount() == 0 ) {
700 o << " simple struct type";
701 } else if ( arguments.empty() ) {
702 o << " polymorphic struct type template";
703 } else {
704 o << " instantiated polymorphic struct type";
706 break;
708 case RT_TYPE_ENUM:
709 o << " enum type";
710 break;
712 case RT_TYPE_EXCEPTION:
713 o << " exception type";
714 break;
716 case RT_TYPE_TYPEDEF:
717 o << "IDL typedef";
718 break;
720 case RT_TYPE_SERVICE:
721 if ( reader.getSuperTypeCount() > 0 ) {
722 o << " single-inheritance--based service";
723 } else {
724 o << "IDL accumulation-based service";
726 break;
728 case RT_TYPE_SINGLETON:
729 if ( (manager.getTypeReader(
730 codemaker::convertString(
731 reader.getSuperTypeName(0))).getTypeClass())
732 == RT_TYPE_INTERFACE )
734 o << " inheritance-based singleton";
735 } else {
736 o << "IDL service-based singleton";
738 break;
740 case RT_TYPE_CONSTANTS:
741 o << "IDL constant group";
742 break;
744 default:
745 OSL_ASSERT(false);
746 break;
749 o << " \"" << type.getStr() << "\" ";
751 sort = codemaker::decomposeAndResolve(
752 manager, binType, true, true, true, &typeClass, &name, &rank,
753 &arguments);
754 if ( rank > 0 ) {
755 printMapsToJavaType(o,
756 options, manager, sort, typeClass, name, rank, arguments, "array");
757 o << '\n';
758 } else if ( sort != codemaker::UnoType::SORT_COMPLEX ) {
759 printMapsToJavaType(o,
760 options, manager, sort, typeClass, name, rank, arguments, 0);
761 o << '\n';
762 } else {
763 typereg::Reader reader(manager.getTypeReader(name));
764 if ( !reader.isValid() ) {
765 throw CannotDumpException("Bad type library entity " + name);
767 switch ( typeClass ) {
768 case RT_TYPE_INTERFACE:
769 printMapsToJavaType(o,
770 options, manager, sort, typeClass, name, rank, arguments,
771 "interface");
772 if ( name == "com/sun/star/uno/XInterface" ) {
773 o << '\n';
774 } else {
776 << "; " << (options.all ? "all" : "direct")
777 << " methods:\n";
778 codemaker::GeneratedTypeSet generated;
779 printMethods(o, options, manager, reader, generated,
780 delegate, "");
782 break;
784 case RT_TYPE_MODULE:
785 printMapsToJavaType(o,
786 options, manager, sort, typeClass, name, rank, arguments,
787 "package");
788 o << '\n';
789 break;
791 case RT_TYPE_STRUCT:
792 if ( reader.getReferenceCount() == 0 ) {
793 printMapsToJavaType(o,
794 options, manager, sort, typeClass, name, rank, arguments,
795 "class");
796 } else if ( arguments.empty() ) {
797 printMapsToJavaType(o,
798 options, manager, sort, typeClass, name, rank, arguments,
799 options.java5 ? "generic class" : "class");
800 } else {
801 printMapsToJavaType(o,
802 options, manager, sort, typeClass, name, rank, arguments,
803 options.java5 ? "generic class instantiation" : "class");
805 o << "; full constructor:\n";
806 printConstructor(o, options, manager, reader, arguments);
807 break;
809 case RT_TYPE_ENUM:
810 case RT_TYPE_CONSTANTS:
811 printMapsToJavaType(o,
812 options, manager, sort, typeClass, name, rank, arguments,
813 "class");
814 o << '\n';
815 break;
817 case RT_TYPE_EXCEPTION:
818 printMapsToJavaType(o,
819 options, manager, sort, typeClass, name, rank, arguments,
820 "exception class");
821 o << "; full constructor:\n";
822 printConstructor(o, options, manager, reader, arguments);
823 break;
825 case RT_TYPE_SERVICE:
826 if ( reader.getSuperTypeCount() > 0 ) {
827 printMapsToJavaType(o,
828 options, manager, sort, typeClass, name, rank, arguments,
829 "class");
830 o << "; construction methods:\n";
831 printConstructionMethods(o, options, manager, reader);
833 OString super(
834 codemaker::convertString(
835 reader.getSuperTypeName(0)).replace('/', '.'));
837 generateDocumentation(o, options, manager, super, delegate);
838 } else {
839 o << ("does not map to Java\n"
840 "// the service members are generated instead\n");
841 printServiceMembers(o, options, manager, reader, type, delegate);
843 break;
845 case RT_TYPE_SINGLETON:
846 if ( reader.getSuperTypeCount() > 0 &&
847 ((manager.getTypeReader(
848 codemaker::convertString(
849 reader.getSuperTypeName(0))).getTypeClass())
850 == RT_TYPE_INTERFACE) ) {
851 printMapsToJavaType(o, options, manager, sort, typeClass,
852 name, rank, arguments, "class");
853 o << "; get method:\npublic static ";
854 printType(o, options, manager,
855 codemaker::convertString(reader.getSuperTypeName(0)),
856 false);
858 << " get(com.sun.star.uno.XComponentContext context);\n";
859 } else {
860 o << "does not map to Java\n";
862 break;
864 default:
865 OSL_ASSERT(false);
866 break;
874 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */