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 
29 #include "typelib/typeclass.h"
30 #include "typelib/typedescription.h"
31 
32 namespace bridges { namespace cpp_uno { namespace shared {
33 
34 namespace {
isSimpleStruct(typelib_TypeDescription const * type)35 bool isSimpleStruct(typelib_TypeDescription const * type) {
36     switch (type->eTypeClass) {
37     case typelib_TypeClass_STRUCT:
38         {
39             typelib_CompoundTypeDescription const * p
40                 = reinterpret_cast< typelib_CompoundTypeDescription const * >(
41                     type);
42             for (sal_Int32 i = 0; i < p->nMembers; ++i) {
43                 switch (p->ppTypeRefs[i]->eTypeClass) {
44                 case typelib_TypeClass_STRUCT:
45                     {
46                         typelib_TypeDescription * t = 0;
47                         TYPELIB_DANGER_GET(&t, p->ppTypeRefs[i]);
48                         bool b = isSimpleStruct(t);
49                         TYPELIB_DANGER_RELEASE(t);
50                         if (!b) {
51                             return false;
52                         }
53                     }
54                     break;
55 
56                 default:
57                     if (!isSimpleType(p->ppTypeRefs[i]->eTypeClass))
58 			return false;
59 		    break;
60                 }
61             }
62         }
63         return true;
64 
65     default:
66         return false;
67     }
68 }
69 }
70 
isSmallStruct(typelib_TypeDescription const * type)71 bool isSmallStruct(typelib_TypeDescription const * type) {
72 	return (type->nSize <= 8 && isSimpleStruct(type));
73 }
74 
75 } } }
76