1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 // MARKER(update_precomp.py): autogen include statement, do not remove 25 #include "precompiled_bridges.hxx" 26 27 #include "bridges/cpp_uno/shared/types.hxx" 28 #define INCLUDED_BRIDGES_CPP_UNO_SHARED_VTABLES_HXX 29 30 #include "typelib/typeclass.h" 31 #include "typelib/typedescription.h" 32 33 namespace bridges { namespace cpp_uno { namespace shared { 34 isSimpleType(typelib_TypeClass typeClass)35bool isSimpleType(typelib_TypeClass typeClass) { 36 return typeClass <= typelib_TypeClass_DOUBLE 37 || typeClass == typelib_TypeClass_ENUM; 38 } 39 isSimpleType(typelib_TypeDescriptionReference const * type)40bool isSimpleType(typelib_TypeDescriptionReference const * type) { 41 return isSimpleType(type->eTypeClass); 42 } 43 isSimpleType(typelib_TypeDescription const * type)44bool isSimpleType(typelib_TypeDescription const * type) { 45 return isSimpleType(type->eTypeClass); 46 } 47 relatesToInterfaceType(typelib_TypeDescription const * type)48bool relatesToInterfaceType(typelib_TypeDescription const * type) { 49 switch (type->eTypeClass) { 50 case typelib_TypeClass_ANY: 51 case typelib_TypeClass_INTERFACE: 52 return true; 53 54 case typelib_TypeClass_STRUCT: 55 case typelib_TypeClass_EXCEPTION: 56 { 57 typelib_CompoundTypeDescription const * p 58 = reinterpret_cast< typelib_CompoundTypeDescription const * >( 59 type); 60 for (sal_Int32 i = 0; i < p->nMembers; ++i) { 61 switch (p->ppTypeRefs[i]->eTypeClass) { 62 case typelib_TypeClass_ANY: 63 case typelib_TypeClass_INTERFACE: 64 return true; 65 66 case typelib_TypeClass_STRUCT: 67 case typelib_TypeClass_EXCEPTION: 68 case typelib_TypeClass_SEQUENCE: 69 { 70 typelib_TypeDescription * t = 0; 71 TYPELIB_DANGER_GET(&t, p->ppTypeRefs[i]); 72 bool b = relatesToInterfaceType(t); 73 TYPELIB_DANGER_RELEASE(t); 74 if (b) { 75 return true; 76 } 77 } 78 break; 79 80 default: 81 break; 82 } 83 } 84 if (p->pBaseTypeDescription != 0) { 85 return relatesToInterfaceType(&p->pBaseTypeDescription->aBase); 86 } 87 } 88 break; 89 90 case typelib_TypeClass_SEQUENCE: 91 switch (reinterpret_cast< typelib_IndirectTypeDescription const * >( 92 type)->pType->eTypeClass) { 93 case typelib_TypeClass_ANY: 94 case typelib_TypeClass_INTERFACE: 95 return true; 96 97 case typelib_TypeClass_STRUCT: 98 case typelib_TypeClass_EXCEPTION: 99 case typelib_TypeClass_SEQUENCE: 100 { 101 typelib_TypeDescription * t = 0; 102 TYPELIB_DANGER_GET( 103 &t, 104 reinterpret_cast< typelib_IndirectTypeDescription const * >( 105 type)->pType); 106 bool b = relatesToInterfaceType(t); 107 TYPELIB_DANGER_RELEASE(t); 108 return b; 109 } 110 111 default: 112 break; 113 } 114 break; 115 116 default: 117 break; 118 } 119 return false; 120 } 121 122 } } } 123