fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / cppu / source / uno / constr.hxx
bloba1242da507ce63c021dcf03b8aba8c53e3e141d5
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 #ifndef INCLUDED_CPPU_SOURCE_UNO_CONSTR_HXX
20 #define INCLUDED_CPPU_SOURCE_UNO_CONSTR_HXX
22 #include <string.h>
23 #include "prim.hxx"
25 namespace cppu
29 //#### construction ################################################################################
33 void defaultConstructStruct(
34 void * pMem,
35 typelib_CompoundTypeDescription * pCompType );
37 inline void _defaultConstructStruct(
38 void * pMem,
39 typelib_CompoundTypeDescription * pTypeDescr )
41 if (pTypeDescr->pBaseTypeDescription)
43 defaultConstructStruct( pMem, pTypeDescr->pBaseTypeDescription );
46 typelib_TypeDescriptionReference ** ppTypeRefs = (pTypeDescr)->ppTypeRefs;
47 sal_Int32 * pMemberOffsets = pTypeDescr->pMemberOffsets;
48 sal_Int32 nDescr = pTypeDescr->nMembers;
50 while (nDescr--)
52 ::uno_type_constructData( static_cast<char *>(pMem) + pMemberOffsets[nDescr], ppTypeRefs[nDescr] );
57 inline void _defaultConstructData(
58 void * pMem,
59 typelib_TypeDescriptionReference * pType,
60 typelib_TypeDescription * pTypeDescr )
62 switch (pType->eTypeClass)
64 case typelib_TypeClass_CHAR:
65 *static_cast<sal_Unicode *>(pMem) = '\0';
66 break;
67 case typelib_TypeClass_BOOLEAN:
68 *static_cast<sal_Bool *>(pMem) = sal_False;
69 break;
70 case typelib_TypeClass_BYTE:
71 *static_cast<sal_Int8 *>(pMem) = 0;
72 break;
73 case typelib_TypeClass_SHORT:
74 case typelib_TypeClass_UNSIGNED_SHORT:
75 *static_cast<sal_Int16 *>(pMem) = 0;
76 break;
77 case typelib_TypeClass_LONG:
78 case typelib_TypeClass_UNSIGNED_LONG:
79 *static_cast<sal_Int32 *>(pMem) = 0;
80 break;
81 case typelib_TypeClass_HYPER:
82 case typelib_TypeClass_UNSIGNED_HYPER:
83 *static_cast<sal_Int64 *>(pMem) = 0;
84 break;
85 case typelib_TypeClass_FLOAT:
86 *static_cast<float *>(pMem) = 0.0;
87 break;
88 case typelib_TypeClass_DOUBLE:
89 *static_cast<double *>(pMem) = 0.0;
90 break;
91 case typelib_TypeClass_STRING:
92 *static_cast<rtl_uString **>(pMem) = 0;
93 ::rtl_uString_new( static_cast<rtl_uString **>(pMem) );
94 break;
95 case typelib_TypeClass_TYPE:
96 *static_cast<typelib_TypeDescriptionReference **>(pMem) = _getVoidType();
97 break;
98 case typelib_TypeClass_ANY:
99 CONSTRUCT_EMPTY_ANY( static_cast<uno_Any *>(pMem) );
100 break;
101 case typelib_TypeClass_ENUM:
102 if (pTypeDescr)
104 *static_cast<sal_Int32 *>(pMem) = reinterpret_cast<typelib_EnumTypeDescription *>(pTypeDescr)->nDefaultEnumValue;
106 else
108 TYPELIB_DANGER_GET( &pTypeDescr, pType );
109 *static_cast<sal_Int32 *>(pMem) = reinterpret_cast<typelib_EnumTypeDescription *>(pTypeDescr)->nDefaultEnumValue;
110 TYPELIB_DANGER_RELEASE( pTypeDescr );
112 break;
113 case typelib_TypeClass_STRUCT:
114 case typelib_TypeClass_EXCEPTION:
115 if (pTypeDescr)
117 _defaultConstructStruct( pMem, reinterpret_cast<typelib_CompoundTypeDescription *>(pTypeDescr) );
119 else
121 TYPELIB_DANGER_GET( &pTypeDescr, pType );
122 _defaultConstructStruct( pMem, reinterpret_cast<typelib_CompoundTypeDescription *>(pTypeDescr) );
123 TYPELIB_DANGER_RELEASE( pTypeDescr );
125 break;
126 case typelib_TypeClass_SEQUENCE:
127 *static_cast<uno_Sequence **>(pMem) = createEmptySequence();
128 break;
129 case typelib_TypeClass_INTERFACE:
130 *static_cast<void **>(pMem) = 0; // either cpp or c-uno interface
131 break;
132 default:
133 OSL_ASSERT(false);
134 break;
140 #endif
142 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */