1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #include "precompiled_bridges.hxx" 29 #include "sal/config.h" 30 31 #include <cstddef> 32 33 #include "sal/types.h" 34 #include "typelib/typeclass.h" 35 #include "typelib/typedescription.h" 36 37 #include "isdirectreturntype.hxx" 38 39 namespace { 40 41 bool isPodStruct(typelib_CompoundTypeDescription * type) { 42 for (; type != NULL; type = type->pBaseTypeDescription) { 43 for (sal_Int32 i = 0; i < type->nMembers; ++i) { 44 if (!bridges::cpp_uno::cc5_solaris_sparc64::isDirectReturnType( 45 type->ppTypeRefs[i])) 46 { 47 return false; 48 } 49 } 50 } 51 return true; 52 } 53 54 } 55 56 namespace bridges { namespace cpp_uno { namespace cc5_solaris_sparc64 { 57 58 bool isDirectReturnType(typelib_TypeDescriptionReference * type) { 59 // Is POD of size <= 32 bytes: 60 switch (type->eTypeClass) { 61 default: 62 return true; 63 case typelib_TypeClass_STRING: 64 case typelib_TypeClass_TYPE: 65 case typelib_TypeClass_ANY: 66 case typelib_TypeClass_SEQUENCE: 67 case typelib_TypeClass_INTERFACE: 68 return false; 69 case typelib_TypeClass_STRUCT: 70 { 71 typelib_TypeDescription * t = NULL; 72 TYPELIB_DANGER_GET(&t, type); 73 bool b = t->nSize <= 32 && isPodStruct( 74 reinterpret_cast< typelib_CompoundTypeDescription * >(t)); 75 TYPELIB_DANGER_RELEASE(t); 76 return b; 77 } 78 } 79 } 80 81 } } } 82