nss: upgrade to release 3.73
[LibreOffice.git] / bridges / source / cpp_uno / msvc_win32_arm64 / abi.cxx
blobc88873143898e82c6283c92ee5846409a89452c4
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 .
20 #include <sal/config.h>
21 #include <sal/types.h>
23 #include <cassert>
25 #include "abi.hxx"
27 enum StructKind
29 STRUCT_KIND_EMPTY,
30 STRUCT_KIND_FLOAT,
31 STRUCT_KIND_DOUBLE,
32 STRUCT_KIND_POD,
33 STRUCT_KIND_DTOR
36 static StructKind getStructKind(typelib_CompoundTypeDescription const* type)
38 StructKind k = type->pBaseTypeDescription == 0 ? STRUCT_KIND_EMPTY
39 : getStructKind(type->pBaseTypeDescription);
41 for (sal_Int32 i = 0; i != type->nMembers; ++i)
43 StructKind k2 = StructKind();
44 switch (type->ppTypeRefs[i]->eTypeClass)
46 case typelib_TypeClass_BOOLEAN:
47 case typelib_TypeClass_BYTE:
48 case typelib_TypeClass_SHORT:
49 case typelib_TypeClass_UNSIGNED_SHORT:
50 case typelib_TypeClass_LONG:
51 case typelib_TypeClass_UNSIGNED_LONG:
52 case typelib_TypeClass_HYPER:
53 case typelib_TypeClass_UNSIGNED_HYPER:
54 case typelib_TypeClass_CHAR:
55 case typelib_TypeClass_ENUM:
56 k2 = STRUCT_KIND_POD;
57 break;
58 case typelib_TypeClass_FLOAT:
59 k2 = STRUCT_KIND_FLOAT;
60 break;
61 case typelib_TypeClass_DOUBLE:
62 k2 = STRUCT_KIND_DOUBLE;
63 break;
64 case typelib_TypeClass_STRING:
65 case typelib_TypeClass_TYPE:
66 case typelib_TypeClass_ANY:
67 case typelib_TypeClass_SEQUENCE:
68 case typelib_TypeClass_INTERFACE:
69 k2 = STRUCT_KIND_DTOR;
70 break;
71 case typelib_TypeClass_STRUCT:
73 typelib_TypeDescription* td = 0;
74 TYPELIB_DANGER_GET(&td, type->ppTypeRefs[i]);
75 k2 = getStructKind(reinterpret_cast<typelib_CompoundTypeDescription const*>(td));
76 TYPELIB_DANGER_RELEASE(td);
77 break;
79 default:
80 assert(false);
82 switch (k2)
84 case STRUCT_KIND_EMPTY:
85 // this means an empty sub-object, which nevertheless obtains a byte
86 // of storage (TODO: does it?), so the full object cannot be a
87 // homogeneous collection of float or double
88 case STRUCT_KIND_POD:
89 assert(k != STRUCT_KIND_DTOR);
90 k = STRUCT_KIND_POD;
91 break;
92 case STRUCT_KIND_FLOAT:
93 case STRUCT_KIND_DOUBLE:
94 if (k == STRUCT_KIND_EMPTY)
96 k = k2;
98 else if (k != k2)
100 assert(k != STRUCT_KIND_DTOR);
101 k = STRUCT_KIND_POD;
103 break;
104 case STRUCT_KIND_DTOR:
105 return STRUCT_KIND_DTOR;
108 return k;
111 ReturnKind getReturnKind(typelib_TypeDescription const* type)
113 switch (type->eTypeClass)
115 default:
116 assert(false);
117 [[fallthrough]];
118 case typelib_TypeClass_VOID:
119 case typelib_TypeClass_BOOLEAN:
120 case typelib_TypeClass_BYTE:
121 case typelib_TypeClass_SHORT:
122 case typelib_TypeClass_UNSIGNED_SHORT:
123 case typelib_TypeClass_LONG:
124 case typelib_TypeClass_UNSIGNED_LONG:
125 case typelib_TypeClass_HYPER:
126 case typelib_TypeClass_UNSIGNED_HYPER:
127 case typelib_TypeClass_FLOAT:
128 case typelib_TypeClass_DOUBLE:
129 case typelib_TypeClass_CHAR:
130 case typelib_TypeClass_ENUM:
131 assert(type->nSize <= 16);
132 return RETURN_KIND_REG;
133 case typelib_TypeClass_STRING:
134 case typelib_TypeClass_TYPE:
135 case typelib_TypeClass_ANY:
136 case typelib_TypeClass_SEQUENCE:
137 case typelib_TypeClass_INTERFACE:
138 return RETURN_KIND_INDIRECT;
139 case typelib_TypeClass_STRUCT:
140 if (type->nSize > 16)
142 return RETURN_KIND_INDIRECT;
144 switch (getStructKind(reinterpret_cast<typelib_CompoundTypeDescription const*>(type)))
146 case STRUCT_KIND_FLOAT:
147 return RETURN_KIND_HFA_FLOAT;
148 case STRUCT_KIND_DOUBLE:
149 return RETURN_KIND_HFA_DOUBLE;
150 case STRUCT_KIND_DTOR:
151 return RETURN_KIND_INDIRECT;
152 default:
153 return RETURN_KIND_REG;
158 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */