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 #include "precompiled_bridges.hxx" 25 #include "sal/config.h" 26 27 #include <cstddef> 28 29 #include "sal/types.h" 30 #include "typelib/typeclass.h" 31 #include "typelib/typedescription.h" 32 33 #include "isdirectreturntype.hxx" 34 35 namespace { 36 isPodStruct(typelib_CompoundTypeDescription * type)37bool isPodStruct(typelib_CompoundTypeDescription * type) { 38 for (; type != NULL; type = type->pBaseTypeDescription) { 39 for (sal_Int32 i = 0; i < type->nMembers; ++i) { 40 if (!bridges::cpp_uno::cc5_solaris_sparc64::isDirectReturnType( 41 type->ppTypeRefs[i])) 42 { 43 return false; 44 } 45 } 46 } 47 return true; 48 } 49 50 } 51 52 namespace bridges { namespace cpp_uno { namespace cc5_solaris_sparc64 { 53 isDirectReturnType(typelib_TypeDescriptionReference * type)54bool isDirectReturnType(typelib_TypeDescriptionReference * type) { 55 // Is POD of size <= 32 bytes: 56 switch (type->eTypeClass) { 57 default: 58 return true; 59 case typelib_TypeClass_STRING: 60 case typelib_TypeClass_TYPE: 61 case typelib_TypeClass_ANY: 62 case typelib_TypeClass_SEQUENCE: 63 case typelib_TypeClass_INTERFACE: 64 return false; 65 case typelib_TypeClass_STRUCT: 66 { 67 typelib_TypeDescription * t = NULL; 68 TYPELIB_DANGER_GET(&t, type); 69 bool b = t->nSize <= 32 && isPodStruct( 70 reinterpret_cast< typelib_CompoundTypeDescription * >(t)); 71 TYPELIB_DANGER_RELEASE(t); 72 return b; 73 } 74 } 75 } 76 77 } } } 78