LibreOffice Module bridges (master)  1
types.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
20 
21 #include <types.hxx>
22 
23 #include <typelib/typeclass.h>
24 #include <typelib/typedescription.h>
25 
26 namespace bridges::cpp_uno::shared {
27 
28 bool isSimpleType(typelib_TypeClass typeClass) {
29  return typeClass <= typelib_TypeClass_DOUBLE
30  || typeClass == typelib_TypeClass_ENUM;
31 }
32 
33 bool isSimpleType(typelib_TypeDescriptionReference const * type) {
34  return isSimpleType(type->eTypeClass);
35 }
36 
38  return isSimpleType(type->eTypeClass);
39 }
40 
42  switch (type->eTypeClass) {
43  case typelib_TypeClass_ANY:
44  case typelib_TypeClass_INTERFACE:
45  return true;
46 
47  case typelib_TypeClass_STRUCT:
48  case typelib_TypeClass_EXCEPTION:
49  {
50  typelib_CompoundTypeDescription const * p
51  = reinterpret_cast< typelib_CompoundTypeDescription const * >(
52  type);
53  for (sal_Int32 i = 0; i < p->nMembers; ++i) {
54  switch (p->ppTypeRefs[i]->eTypeClass) {
55  case typelib_TypeClass_ANY:
56  case typelib_TypeClass_INTERFACE:
57  return true;
58 
59  case typelib_TypeClass_STRUCT:
60  case typelib_TypeClass_EXCEPTION:
61  case typelib_TypeClass_SEQUENCE:
62  {
63  typelib_TypeDescription * t = nullptr;
64  TYPELIB_DANGER_GET(&t, p->ppTypeRefs[i]);
65  bool b = relatesToInterfaceType(t);
66  TYPELIB_DANGER_RELEASE(t);
67  if (b) {
68  return true;
69  }
70  }
71  break;
72 
73  default:
74  break;
75  }
76  }
77  if (p->pBaseTypeDescription != nullptr) {
78  return relatesToInterfaceType(&p->pBaseTypeDescription->aBase);
79  }
80  }
81  break;
82 
83  case typelib_TypeClass_SEQUENCE:
84  switch (reinterpret_cast< typelib_IndirectTypeDescription const * >(
85  type)->pType->eTypeClass) {
86  case typelib_TypeClass_ANY:
87  case typelib_TypeClass_INTERFACE:
88  return true;
89 
90  case typelib_TypeClass_STRUCT:
91  case typelib_TypeClass_EXCEPTION:
92  case typelib_TypeClass_SEQUENCE:
93  {
94  typelib_TypeDescription * t = nullptr;
95  TYPELIB_DANGER_GET(
96  &t,
97  reinterpret_cast< typelib_IndirectTypeDescription const * >(
98  type)->pType);
99  bool b = relatesToInterfaceType(t);
100  TYPELIB_DANGER_RELEASE(t);
101  return b;
102  }
103 
104  default:
105  break;
106  }
107  break;
108 
109  default:
110  break;
111  }
112  return false;
113 }
114 
115 }
116 
117 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool isSimpleType(typelib_TypeClass typeClass)
Determines whether a type is a "simple" type (VOID, BOOLEAN, BYTE, SHORT, UNSIGNED SHORT...
Definition: types.cxx:28
bool relatesToInterfaceType(typelib_TypeDescription const *type)
Determines whether a type relates to an interface type (is itself an interface type, or might contain entities of interface type).
Definition: types.cxx:41
int i
struct _typelib_TypeDescription typelib_TypeDescription
Definition: msvc/except.hxx:52
XPropertyListType t
void * p