Coverage Report

Created: 2025-07-07 10:01

/src/libreoffice/unoidl/source/sourceprovider-parser-requires.hxx
Line
Count
Source (jump to first uncovered line)
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
#pragma once
11
12
#include <sal/config.h>
13
14
#include <utility>
15
#include <vector>
16
17
#include <rtl/ustring.hxx>
18
#include <sal/types.h>
19
20
0
#define YYLTYPE int
21
22
typedef void * yyscan_t;
23
24
namespace unoidl::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 {
38
0
    static SourceProviderExpr Bool(bool v) {
39
0
        SourceProviderExpr e;
40
0
        e.type = TYPE_BOOL;
41
0
        e.bval = v;
42
0
        return e;
43
0
    }
44
45
0
    static SourceProviderExpr Int(sal_Int64 v) {
46
0
        SourceProviderExpr e;
47
0
        e.type = TYPE_INT;
48
0
        e.ival = v;
49
0
        return e;
50
0
    }
51
52
0
    static SourceProviderExpr Uint(sal_uInt64 v) {
53
0
        SourceProviderExpr e;
54
0
        e.type = TYPE_UINT;
55
0
        e.uval = v;
56
0
        return e;
57
0
    }
58
59
0
    static SourceProviderExpr Float(double v) {
60
0
        SourceProviderExpr e;
61
0
        e.type = TYPE_FLOAT;
62
0
        e.fval = v;
63
0
        return e;
64
0
    }
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
86
    SourceProviderType():
87
        type(), entity() // avoid false warnings about uninitialized members
88
0
    {}
89
90
    explicit SourceProviderType(Type theType):
91
0
        type(theType),
92
        entity() // avoid false warnings about uninitialized member
93
0
    { assert(theType <= TYPE_ANY); }
94
95
    explicit SourceProviderType(SourceProviderType const * componentType):
96
0
        type(TYPE_SEQUENCE),
97
        entity() // avoid false warnings about uninitialized member
98
0
    { assert(componentType != nullptr); subtypes.push_back(*componentType); }
99
100
    SourceProviderType(
101
        Type theType, OUString theName,
102
        SourceProviderEntity const * theEntity):
103
0
        type(theType), name(std::move(theName)), entity(theEntity)
104
0
    {
105
0
        assert(theType >= TYPE_ENUM && theType <= TYPE_INTERFACE);
106
0
        assert(theEntity != nullptr);
107
0
    }
108
109
    SourceProviderType(
110
        OUString polymorphicStructTypeTemplateName,
111
        SourceProviderEntity const * theEntity,
112
        std::vector<SourceProviderType>&& typeArguments):
113
0
        type(TYPE_INSTANTIATED_POLYMORPHIC_STRUCT),
114
0
        name(std::move(polymorphicStructTypeTemplateName)), entity(theEntity),
115
0
        subtypes(std::move(typeArguments))
116
0
    { assert(theEntity != nullptr); }
117
118
    explicit SourceProviderType(OUString identifier):
119
0
        type(TYPE_PARAMETER), name(std::move(identifier)),
120
        entity() // avoid false warnings about uninitialized member
121
0
    {}
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_POLYMORPHIC_STRUCT
131
    std::vector<SourceProviderType> subtypes;
132
        // TYPE_SEQUENCE, TYPE_INSTANTIATED_POLYMORPHIC_STRUCT
133
    OUString typedefName;
134
};
135
136
}
137
138
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */