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 
10 #ifndef INCLUDED_UNOIDL_SOURCE_SOURCEPROVIDER_PARSER_REQUIRES_HXX
11 #define INCLUDED_UNOIDL_SOURCE_SOURCEPROVIDER_PARSER_REQUIRES_HXX
12 
13 #include <sal/config.h>
14 
15 #include <vector>
16 
17 #include <rtl/ustring.hxx>
18 #include <sal/types.h>
19 
20 #define YYLTYPE int
21 
22 typedef void * yyscan_t;
23 
24 namespace unoidl { namespace detail {
25 
26 struct SourceProviderEntity;
27 
28 enum SourceProviderAccessDecls { ACCESS_DECL_GET = 0x1, ACCESS_DECL_SET = 0x2 };
29 
30 enum SourceProviderFlags {
31     FLAG_ATTRIBUTE = 0x001, FLAG_BOUND = 0x002, FLAG_CONSTRAINED = 0x004,
32     FLAG_MAYBEAMBIGUOUS = 0x008, FLAG_MAYBEDEFAULT = 0x010,
33     FLAG_MAYBEVOID = 0x020, FLAG_OPTIONAL = 0x040, FLAG_PROPERTY = 0x080,
34     FLAG_READONLY = 0x100, FLAG_REMOVABLE = 0x200, FLAG_TRANSIENT = 0x400
35 };
36 
37 struct SourceProviderExpr {
Boolunoidl::detail::SourceProviderExpr38     static SourceProviderExpr Bool(bool v) {
39         SourceProviderExpr e;
40         e.type = TYPE_BOOL;
41         e.bval = v;
42         return e;
43     }
44 
Intunoidl::detail::SourceProviderExpr45     static SourceProviderExpr Int(sal_Int64 v) {
46         SourceProviderExpr e;
47         e.type = TYPE_INT;
48         e.ival = v;
49         return e;
50     }
51 
Uintunoidl::detail::SourceProviderExpr52     static SourceProviderExpr Uint(sal_uInt64 v) {
53         SourceProviderExpr e;
54         e.type = TYPE_UINT;
55         e.uval = v;
56         return e;
57     }
58 
Floatunoidl::detail::SourceProviderExpr59     static SourceProviderExpr Float(double v) {
60         SourceProviderExpr e;
61         e.type = TYPE_FLOAT;
62         e.fval = v;
63         return e;
64     }
65 
66     enum Type { TYPE_BOOL, TYPE_INT, TYPE_UINT, TYPE_FLOAT };
67 
68     Type type;
69     union {
70         bool bval;
71         sal_Int64 ival;
72         sal_uInt64 uval;
73         double fval;
74     };
75 };
76 
77 struct SourceProviderType {
78     enum Type {
79         TYPE_VOID, TYPE_BOOLEAN, TYPE_BYTE, TYPE_SHORT, TYPE_UNSIGNED_SHORT,
80         TYPE_LONG, TYPE_UNSIGNED_LONG, TYPE_HYPER, TYPE_UNSIGNED_HYPER,
81         TYPE_FLOAT, TYPE_DOUBLE, TYPE_CHAR, TYPE_STRING, TYPE_TYPE, TYPE_ANY,
82         TYPE_SEQUENCE, TYPE_ENUM, TYPE_PLAIN_STRUCT, TYPE_EXCEPTION,
83         TYPE_INTERFACE, TYPE_INSTANTIATED_POLYMORPHIC_STRUCT, TYPE_PARAMETER
84     };
85 
SourceProviderTypeunoidl::detail::SourceProviderType86     SourceProviderType():
87         type(), entity() // avoid false warnings about uninitialized members
88     {}
89 
SourceProviderTypeunoidl::detail::SourceProviderType90     explicit SourceProviderType(Type theType):
91         type(theType),
92         entity() // avoid false warnings about uninitialized member
93     { assert(theType <= TYPE_ANY); }
94 
SourceProviderTypeunoidl::detail::SourceProviderType95     explicit SourceProviderType(SourceProviderType const * componentType):
96         type(TYPE_SEQUENCE),
97         entity() // avoid false warnings about uninitialized member
98     { assert(componentType != nullptr); subtypes.push_back(*componentType); }
99 
SourceProviderTypeunoidl::detail::SourceProviderType100     SourceProviderType(
101         Type theType, OUString const & theName,
102         SourceProviderEntity const * theEntity):
103         type(theType), name(theName), entity(theEntity)
104     {
105         assert(theType >= TYPE_ENUM && theType <= TYPE_INTERFACE);
106         assert(theEntity != nullptr);
107     }
108 
SourceProviderTypeunoidl::detail::SourceProviderType109     SourceProviderType(
110         OUString const & polymorphicStructTypeTemplateName,
111         SourceProviderEntity const * theEntity,
112         std::vector<SourceProviderType> const & typeArguments):
113         type(TYPE_INSTANTIATED_POLYMORPHIC_STRUCT),
114         name(polymorphicStructTypeTemplateName), entity(theEntity),
115         subtypes(typeArguments)
116     { assert(theEntity != nullptr); }
117 
SourceProviderTypeunoidl::detail::SourceProviderType118     explicit SourceProviderType(OUString const & identifier):
119         type(TYPE_PARAMETER), name(identifier),
120         entity() // avoid false warnings about uninitialized member
121     {}
122 
123     OUString getName() const;
124 
125     bool equals(SourceProviderType const & other) const;
126 
127     Type type;
128     OUString name; // TYPE_ENUM ... TYPE_PARAMETER
129     SourceProviderEntity const * entity;
130         // TYPE_ENUM ... TYPE_INSTANTIATED_POLYMOPRHIC_STRUCT
131     std::vector<SourceProviderType> subtypes;
132         // TYPE_SEQUENCE, TYPE_INSTANTIATED_POLYMOPRHIC_STRUCT
133     OUString typedefName;
134 };
135 
136 } }
137 
138 #endif
139 
140 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
141