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 #ifndef INCLUDED_BRIDGES_CPP_UNO_SHARED_VTABLES_HXX
25 #define INCLUDED_BRIDGES_CPP_UNO_SHARED_VTABLES_HXX
26 
27 #include "sal/types.h"
28 #include "typelib/typedescription.h"
29 
30 namespace bridges { namespace cpp_uno { namespace shared {
31 
32 /**
33  * Calculate the number of local functions of an interface type.
34  *
35  * <p><em>Local</em> functions are those not inherited from any base types.  The
36  * number of <em>functions</em> is potentially larger than the number of
37  * <em>members</em>, as each read&ndash;write attribute member counts as two
38  * functions.</p>
39  *
40  * @param type a non-null pointer to an interface type description, for which
41  *     <code>typelib_typedescription_complete</code> must already have been
42  *     executed
43  * @return the number of local functions of the given interface type
44  */
45 sal_Int32 getLocalFunctions(typelib_InterfaceTypeDescription const * type);
46 
47 /**
48  * Calculate the number of primary functions of an interface type.
49  *
50  * <p>The number of primary functions of an interface is the number of local
51  * functions of that interface (see <code>getLocalFunctions</code>), plus the
52  * number of primary functions of that interface's first base type (if it has at
53  * least one base type).</p>
54  *
55  * @param type a pointer to an interface type description; may be null
56  * @return the number of primary functions of the given interface type, or zero
57  *     if the given interface type is null
58  */
59 sal_Int32 getPrimaryFunctions(typelib_InterfaceTypeDescription * type);
60 
61 /**
62  * Represents a vtable slot of a C++ class.
63  */
64 struct VtableSlot {
65     /**
66      * The offset of the vtable.
67      *
68      * <p>Multiple-inheritance C++ classes have more than one vtable.  The
69      * offset is logical (<em>not</em> a byte offset), and must be
70      * non-negative.</p>
71      */
72     sal_Int32 offset;
73 
74     /**
75      * The index within the vtable.
76      *
77      * <p>The index is logical (<em>not</em> a byte offset), and must be
78      * non-negative.</p>
79      */
80     sal_Int32 index;
81 };
82 
83 /**
84  * Calculates the vtable slot associated with an interface attribute member.
85  *
86  * @param ifcMember a non-null pointer to an interface attribute member
87  *     description
88  * @return the vtable slot associated with the given interface member
89  */
90 VtableSlot getVtableSlot(
91     typelib_InterfaceAttributeTypeDescription const * ifcMember);
92 
93 /**
94  * Calculates the vtable slot associated with an interface method member.
95  *
96  * @param ifcMember a non-null pointer to an interface method member description
97  * @return the vtable slot associated with the given interface member
98  */
99 VtableSlot getVtableSlot(
100     typelib_InterfaceMethodTypeDescription const * ifcMember);
101 
102 } } }
103 
104 #endif
105