1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/.
10 /*TODO: check Exception, RuntimeException, XInterface defns */
17 #include <sal/config.h>
19 #include <o3tl/unreachable.hxx>
20 #include <o3tl/string_view.hxx>
21 #include <rtl/ustrbuf.hxx>
22 #include <unoidl/unoidl.hxx>
34 #include "sourceprovider-parser-requires.hxx"
44 std
::vector
<OUString
> * excns
;
45 unoidl
::detail
::SourceProviderAccessDecls decls
;
46 unoidl
::InterfaceTypeEntity
::Method
::Parameter
::Direction dir
;
47 unoidl
::detail
::SourceProviderFlags flags
;
48 unoidl
::detail
::SourceProviderExpr expr
;
49 unoidl
::detail
::SourceProviderType
* type
;
50 std
::vector
<unoidl
::detail
::SourceProviderType
> * types
;
53 /* TODO: %destructor { delete $$; } <sval> <excns> <type> <types> */
55 %lex
-param
{yyscan_t yyscanner
}
56 %parse
-param
{yyscan_t yyscanner
}
61 #include <osl/thread.h>
62 #include <sal/log.hxx>
64 #include "sourceprovider-scanner.hxx"
66 #define YYLLOC_DEFAULT(Current, Rhs, N) \
67 do
{ (Current
) = YYRHSLOC
((Rhs
), (N
) ?
1 : 0); } while
(0)
69 static void yyerror(YYLTYPE * locp
, yyscan_t yyscanner
, char const * msg
) {
70 assert
(locp
!= nullptr
);
71 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
72 data
->errorLine
= *locp
;
73 data
->parserError
= OString
(msg
);
78 void error(YYLTYPE location
, yyscan_t yyscanner
, OUString
const & message
) {
79 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
80 data
->errorLine
= location
;
81 data
->errorMessage
= message
;
84 OUString flagName
(unoidl
::detail
::SourceProviderFlags flag
) {
86 case unoidl
::detail
::FLAG_ATTRIBUTE
:
87 return u
"attribute"_ustr
;
88 case unoidl
::detail
::FLAG_BOUND
:
90 case unoidl
::detail
::FLAG_CONSTRAINED
:
91 return u
"constrained"_ustr
;
92 case unoidl
::detail
::FLAG_MAYBEAMBIGUOUS
:
93 return u
"maybeambiguous"_ustr
;
94 case unoidl
::detail
::FLAG_MAYBEDEFAULT
:
95 return u
"maybedefault"_ustr
;
96 case unoidl
::detail
::FLAG_MAYBEVOID
:
97 return u
"maybevoid"_ustr
;
98 case unoidl
::detail
::FLAG_OPTIONAL
:
99 return u
"optional"_ustr
;
100 case unoidl
::detail
::FLAG_PROPERTY
:
101 return u
"property"_ustr
;
102 case unoidl
::detail
::FLAG_READONLY
:
103 return u
"readonly"_ustr
;
104 case unoidl
::detail
::FLAG_REMOVABLE
:
105 return u
"removable"_ustr
;
106 case unoidl
::detail
::FLAG_TRANSIENT
:
107 return u
"transient"_ustr
;
109 assert
(false
&& "this cannot happen"); for
(;;) { std
::abort
(); }
113 OUString convertName
(OString
const * name
) {
114 assert
(name
!= nullptr
);
115 OUString s
(OStringToOUString
(*name
, RTL_TEXTENCODING_ASCII_US
));
120 OUString convertToFullName
(
121 unoidl
::detail
::SourceProviderScannerData
const * data
,
122 OString
const * identifier
)
124 assert
(data
!= nullptr
);
126 if
(!data
->modules.empty
()) {
127 pref
= data
->modules.back
() + ".";
129 return pref
+ convertName
(identifier
);
132 void convertToCurrentName
(
133 unoidl
::detail
::SourceProviderScannerData
* data
,
134 OString
const * identifier
)
136 assert
(data
!= nullptr
);
137 assert
(data
->currentName.isEmpty
());
138 data
->currentName
= convertToFullName
(data
, identifier
);
139 assert
(!data
->currentName.isEmpty
());
142 void clearCurrentState
(unoidl
::detail
::SourceProviderScannerData
* data
) {
143 assert
(data
!= nullptr
);
144 data
->currentName.clear
();
145 data
->publishedContext
= false
;
148 unoidl::detail
::SourceProviderEntity
* getCurrentEntity
(
149 unoidl
::detail
::SourceProviderScannerData
* data
)
151 assert
(data
!= nullptr
);
152 assert
(!data
->currentName.isEmpty
());
153 std
::map
<OUString
, unoidl
::detail
::SourceProviderEntity
>::iterator i
(
154 data
->entities.find
(data
->currentName
));
155 assert
(i
!= data
->entities.end
());
156 assert
(i
->second.kind
== unoidl
::detail
::SourceProviderEntity
::KIND_LOCAL
);
157 assert
(i
->second.pad.is
());
161 template
<typename T
> rtl
::Reference
<T
> getCurrentPad
(
162 unoidl
::detail
::SourceProviderScannerData
* data
)
164 rtl
::Reference
<T
> pad
(dynamic_cast
<T
*>(getCurrentEntity
(data
)->pad.get
()));
169 bool nameHasSameIdentifierAs
(std
::u16string_view name
, std
::u16string_view identifier
)
171 std
::u16string_view
::size_type pos
= name.rfind
('.');
172 size_t i
= (pos
!= std
::u16string_view
::npos
) ? pos
+ 1 : 0;
173 return identifier.size
() == name.size
() - i
174 && o3tl
::starts_with
(name.substr
(i
), identifier
);
178 YYLTYPE location
, yyscan_t yyscanner
,
179 unoidl
::detail
::SourceProviderExpr
* lhs
,
180 unoidl
::detail
::SourceProviderExpr
* rhs
)
182 assert
(lhs
!= nullptr
);
183 assert
(rhs
!= nullptr
);
184 bool ok
= bool(); // avoid warnings
186 case unoidl
::detail
::SourceProviderExpr
::TYPE_BOOL
:
187 ok
= rhs
->type
!= unoidl
::detail
::SourceProviderExpr
::TYPE_BOOL
;
189 case unoidl
::detail
::SourceProviderExpr
::TYPE_INT
:
191 case unoidl
::detail
::SourceProviderExpr
::TYPE_BOOL
:
194 case unoidl
::detail
::SourceProviderExpr
::TYPE_INT
:
197 case unoidl
::detail
::SourceProviderExpr
::TYPE_UINT
:
198 if
(lhs
->ival
>= 0) {
199 lhs
->type
= unoidl
::detail
::SourceProviderExpr
::TYPE_UINT
;
201 } else if
(rhs
->uval
<= SAL_MAX_INT64
) {
202 rhs
->type
= unoidl
::detail
::SourceProviderExpr
::TYPE_INT
;
208 case unoidl
::detail
::SourceProviderExpr
::TYPE_FLOAT
:
210 auto tmp
= lhs
->ival
;
217 case unoidl
::detail
::SourceProviderExpr
::TYPE_UINT
:
219 case unoidl
::detail
::SourceProviderExpr
::TYPE_BOOL
:
222 case unoidl
::detail
::SourceProviderExpr
::TYPE_INT
:
223 if
(rhs
->ival
>= 0) {
224 rhs
->type
= unoidl
::detail
::SourceProviderExpr
::TYPE_UINT
;
226 } else if
(lhs
->uval
<= SAL_MAX_INT64
) {
227 lhs
->type
= unoidl
::detail
::SourceProviderExpr
::TYPE_INT
;
233 case unoidl
::detail
::SourceProviderExpr
::TYPE_UINT
:
236 case unoidl
::detail
::SourceProviderExpr
::TYPE_FLOAT
:
238 auto nTmp
= lhs
->uval
;
245 case unoidl
::detail
::SourceProviderExpr
::TYPE_FLOAT
:
247 case unoidl
::detail
::SourceProviderExpr
::TYPE_BOOL
:
250 case unoidl
::detail
::SourceProviderExpr
::TYPE_INT
:
252 auto tmp
= rhs
->ival
;
257 case unoidl
::detail
::SourceProviderExpr
::TYPE_UINT
:
259 auto tmp
= rhs
->uval
;
264 case unoidl
::detail
::SourceProviderExpr
::TYPE_FLOAT
:
271 error(location
, yyscanner
, u
"cannot coerce binary expression arguments"_ustr
);
276 unoidl::detail
::SourceProviderEntity
* findEntity_
(
277 unoidl
::detail
::SourceProviderScannerData
* data
, OUString
* name
)
279 assert
(data
!= nullptr
);
280 assert
(name
!= nullptr
);
282 if
(!name
->startsWith
(".", &n
)) {
283 for
(auto i
(data
->modules.rbegin
()); i
!= data
->modules.rend
(); ++i
) {
284 n
= *i
+ "." + *name
;
285 std
::map
<OUString
, unoidl
::detail
::SourceProviderEntity
>::iterator j
(
286 data
->entities.find
(n
));
287 if
(j
!= data
->entities.end
()) {
291 rtl
::Reference
<unoidl
::Entity
> ent
(data
->manager
->findEntity
(n
));
293 std
::map
<OUString
, unoidl
::detail
::SourceProviderEntity
>::iterator
294 k
(data
->entities.emplace
(
296 unoidl
::detail
::SourceProviderEntity
(
297 unoidl
::detail
::SourceProviderEntity
::KIND_EXTERNAL
,
306 std
::map
<OUString
, unoidl
::detail
::SourceProviderEntity
>::iterator i
(
307 data
->entities.find
(n
));
308 if
(i
!= data
->entities.end
()) {
312 rtl
::Reference
<unoidl
::Entity
> ent
(data
->manager
->findEntity
(n
));
314 std
::map
<OUString
, unoidl
::detail
::SourceProviderEntity
>::iterator
315 j
(data
->entities.emplace
(
317 unoidl
::detail
::SourceProviderEntity
(
318 unoidl
::detail
::SourceProviderEntity
::KIND_EXTERNAL
,
327 enum Found
{ FOUND_ERROR
, FOUND_TYPE
, FOUND_ENTITY
};
330 YYLTYPE location
, yyscan_t yyscanner
,
331 unoidl
::detail
::SourceProviderScannerData
* data
,
332 bool resolveInterfaceDefinitions
, OUString
* name
,
333 unoidl
::detail
::SourceProviderEntity
const ** entity
, bool * typedefed
,
334 unoidl
::detail
::SourceProviderType
* typedefedType
)
336 //TODO: avoid recursion
337 assert
(data
!= nullptr
);
338 assert
(name
!= nullptr
);
339 assert
(entity
!= nullptr
);
340 unoidl
::detail
::SourceProviderEntity
* e
= findEntity_
(data
, name
);
342 OUString typeNucleus
;
343 std
::size_t rank
= 0;
344 std
::vector
<unoidl
::detail
::SourceProviderType
> args
;
348 case unoidl
::detail
::SourceProviderEntity
::KIND_LOCAL
:
352 assert
(e
->entity.is
());
354 case unoidl
::detail
::SourceProviderEntity
::KIND_EXTERNAL
:
355 if
(e
->entity
->getSort
() == unoidl
::Entity
::SORT_TYPEDEF
) {
356 if
(typedefed
!= nullptr
) {
359 if
(data
->publishedContext
360 && !static_cast
<unoidl
::TypedefEntity
*>(
361 e
->entity.get
())->isPublished
())
365 ("type " + *name
+ " based on unpublished typedef "
366 + n
+ " used in published context"));
370 static_cast
<unoidl
::TypedefEntity
*>(e
->entity.get
())
373 while
(typeNucleus.startsWith
("[]", &typeNucleus
)) {
377 ("inconsistent type manager: bad type " + *name
378 + (" based on instantiated polymorphic struct"
379 " type based on sequence type named ")
383 if
(rank
== std
::numeric_limits
<std
::size_t>::max
()) {
387 + " based on sequence type of too high rank"));
392 sal_Int32 i
= typeNucleus.indexOf
('<');
397 ("inconsistent type manager: bad type " + *name
398 + (" based on instantiated polymorphic struct"
399 " type based on instantiated polymorphic"
400 " struct type named ")
404 std
::u16string_view tmpl
(typeNucleus.subView
(0, i
));
406 ++i
; // skip '<' or ','
408 for
(sal_Int32 level
= 0;
409 j
!= typeNucleus.getLength
(); ++j
)
411 sal_Unicode c
= typeNucleus
[j
];
416 } else if
(c
== '<') {
418 } else if
(c
== '>') {
425 if
(j
!= typeNucleus.getLength
()) {
426 OUString argName
(typeNucleus.copy
(i
, j
- i
));
427 unoidl
::detail
::SourceProviderEntity
const *
429 unoidl
::detail
::SourceProviderType argType
;
432 location
, yyscanner
, data
, false
,
433 &argName
, &argEnt
, nullptr
, &argType
))
440 if
(argEnt
== nullptr
) {
443 (("inconsistent type manager: bad"
444 " instantiated polymorphic struct"
445 " type template type argument ")
449 unoidl
::detail
::SourceProviderType
::Type
451 = unoidl
::detail
::SourceProviderType
::Type
();
453 switch
(argEnt
->kind
) {
454 case unoidl
::detail
::SourceProviderEntity
::KIND_LOCAL
:
458 (("inconsistent type"
461 " polymorphic struct type"
467 assert
(e
->entity.is
());
469 case unoidl
::detail
::SourceProviderEntity
::KIND_EXTERNAL
:
470 switch
(e
->entity
->getSort
()) {
471 case unoidl
::Entity
::SORT_ENUM_TYPE
:
472 argT
= unoidl
::detail
::SourceProviderType
::TYPE_ENUM
;
474 case unoidl
::Entity
::SORT_PLAIN_STRUCT_TYPE
:
475 argT
= unoidl
::detail
::SourceProviderType
::TYPE_PLAIN_STRUCT
;
477 case unoidl
::Entity
::SORT_INTERFACE_TYPE
:
478 argT
= unoidl
::detail
::SourceProviderType
::TYPE_INTERFACE
;
483 (("inconsistent type"
486 " polymorphic struct type"
493 case unoidl
::detail
::SourceProviderEntity
::KIND_INTERFACE_DECL
:
494 case unoidl
::detail
::SourceProviderEntity
::KIND_PUBLISHED_INTERFACE_DECL
:
495 argT
= unoidl
::detail
::SourceProviderType
::TYPE_INTERFACE
;
497 case unoidl
::detail
::SourceProviderEntity
::KIND_MODULE
:
498 assert
(false
&& "this cannot happen");
501 = unoidl
::detail
::SourceProviderType
(
502 argT
, argName
, argEnt
);
506 args.push_back
(argType
);
509 } while
(i
!= typeNucleus.getLength
()
510 && typeNucleus
[i
] != '>');
511 if
(i
!= typeNucleus.getLength
() - 1
512 || typeNucleus
[i
] != '>')
516 ("inconsistent type manager: bad type name \""
520 assert
(!args.empty
());
523 if
(typeNucleus.isEmpty
()) {
526 ("inconsistent type manager: bad type name \"" + t
530 if
(typeNucleus
== "void") {
533 ("inconsistent type manager: bad type " + *name
534 + " based on void"));
537 if
(typeNucleus
== "boolean" || typeNucleus
== "byte"
538 || typeNucleus
== "short"
539 || typeNucleus
== "unsigned short"
540 || typeNucleus
== "long"
541 || typeNucleus
== "unsigned long"
542 || typeNucleus
== "hyper"
543 || typeNucleus
== "unsigned hyper"
544 || typeNucleus
== "float" || typeNucleus
== "double"
545 || typeNucleus
== "char" || typeNucleus
== "string"
546 || typeNucleus
== "type" || typeNucleus
== "any")
551 ("inconsistent type manager: bad type " + *name
552 + (" based on instantiated polymorphic struct"
559 n
= "." + typeNucleus
;
561 e
= findEntity_
(data
, &n
);
565 case unoidl
::detail
::SourceProviderEntity
::KIND_INTERFACE_DECL
:
566 case unoidl
::detail
::SourceProviderEntity
::KIND_PUBLISHED_INTERFACE_DECL
:
567 if
(resolveInterfaceDefinitions
) {
568 rtl
::Reference
<unoidl
::Entity
> ent
(
569 data
->manager
->findEntity
(n
));
570 // Do not allow ent to be of SORT_TYPEDEF:
573 != unoidl
::Entity
::SORT_INTERFACE_TYPE
))
577 (*name
+ " is based on interface declaration " + n
578 + " that is not an interface type entity"));
582 = unoidl
::detail
::SourceProviderEntity
::KIND_EXTERNAL
;
583 e
->entity
= std
::move
(ent
);
586 case unoidl
::detail
::SourceProviderEntity
::KIND_MODULE
:
589 *name
+ " is based on module entity " + n
);
593 if
(!typeNucleus.isEmpty
() || rank
!= 0 ||
!args.empty
()) {
594 if
(typeNucleus.isEmpty
() && e
== nullptr
) {
595 // Found a type name based on an unknown entity:
599 unoidl
::detail
::SourceProviderType t
;
601 if
(typeNucleus
== "boolean") {
602 t
= unoidl
::detail
::SourceProviderType
(
603 unoidl
::detail
::SourceProviderType
::TYPE_BOOLEAN
);
604 } else if
(typeNucleus
== "byte") {
605 t
= unoidl
::detail
::SourceProviderType
(
606 unoidl
::detail
::SourceProviderType
::TYPE_BYTE
);
607 } else if
(typeNucleus
== "short") {
608 t
= unoidl
::detail
::SourceProviderType
(
609 unoidl
::detail
::SourceProviderType
::TYPE_SHORT
);
610 } else if
(typeNucleus
== "unsigned short") {
611 t
= unoidl
::detail
::SourceProviderType
(
612 unoidl
::detail
::SourceProviderType
::TYPE_UNSIGNED_SHORT
);
613 } else if
(typeNucleus
== "long") {
614 t
= unoidl
::detail
::SourceProviderType
(
615 unoidl
::detail
::SourceProviderType
::TYPE_LONG
);
616 } else if
(typeNucleus
== "unsigned long") {
617 t
= unoidl
::detail
::SourceProviderType
(
618 unoidl
::detail
::SourceProviderType
::TYPE_UNSIGNED_LONG
);
619 } else if
(typeNucleus
== "hyper") {
620 t
= unoidl
::detail
::SourceProviderType
(
621 unoidl
::detail
::SourceProviderType
::TYPE_HYPER
);
622 } else if
(typeNucleus
== "unsigned hyper") {
623 t
= unoidl
::detail
::SourceProviderType
(
624 unoidl
::detail
::SourceProviderType
::TYPE_UNSIGNED_HYPER
);
625 } else if
(typeNucleus
== "float") {
626 t
= unoidl
::detail
::SourceProviderType
(
627 unoidl
::detail
::SourceProviderType
::TYPE_FLOAT
);
628 } else if
(typeNucleus
== "double") {
629 t
= unoidl
::detail
::SourceProviderType
(
630 unoidl
::detail
::SourceProviderType
::TYPE_DOUBLE
);
631 } else if
(typeNucleus
== "char") {
632 t
= unoidl
::detail
::SourceProviderType
(
633 unoidl
::detail
::SourceProviderType
::TYPE_CHAR
);
634 } else if
(typeNucleus
== "string") {
635 t
= unoidl
::detail
::SourceProviderType
(
636 unoidl
::detail
::SourceProviderType
::TYPE_STRING
);
637 } else if
(typeNucleus
== "type") {
638 t
= unoidl
::detail
::SourceProviderType
(
639 unoidl
::detail
::SourceProviderType
::TYPE_TYPE
);
640 } else if
(typeNucleus
== "any") {
641 t
= unoidl
::detail
::SourceProviderType
(
642 unoidl
::detail
::SourceProviderType
::TYPE_ANY
);
644 assert
(typeNucleus.isEmpty
());
645 assert
(e
!= nullptr
);
647 case unoidl
::detail
::SourceProviderEntity
::KIND_LOCAL
:
649 if
(dynamic_cast
<unoidl
::detail
::SourceProviderEnumTypeEntityPad
*>(
653 t
= unoidl
::detail
::SourceProviderType
(
654 unoidl
::detail
::SourceProviderType
::TYPE_ENUM
,
656 } else if
(dynamic_cast
<unoidl
::detail
::SourceProviderPlainStructTypeEntityPad
*>(
660 t
= unoidl
::detail
::SourceProviderType
(
661 unoidl
::detail
::SourceProviderType
::TYPE_PLAIN_STRUCT
,
663 } else if
(dynamic_cast
<unoidl
::detail
::SourceProviderPolymorphicStructTypeTemplateEntityPad
*>(
670 + (" based on recursive reference to"
671 " polymorphic struct type template ")
674 } else if
(dynamic_cast
<unoidl
::detail
::SourceProviderExceptionTypeEntityPad
*>(
678 t
= unoidl
::detail
::SourceProviderType
(
679 unoidl
::detail
::SourceProviderType
::TYPE_EXCEPTION
,
681 } else if
(dynamic_cast
<unoidl
::detail
::SourceProviderInterfaceTypeEntityPad
*>(
685 t
= unoidl
::detail
::SourceProviderType
(
686 unoidl
::detail
::SourceProviderType
::TYPE_INTERFACE
,
692 + " based on non-type entity " + n
));
697 assert
(e
->entity.is
());
699 case unoidl
::detail
::SourceProviderEntity
::KIND_EXTERNAL
:
700 switch
(e
->entity
->getSort
()) {
701 case unoidl
::Entity
::SORT_ENUM_TYPE
:
702 t
= unoidl
::detail
::SourceProviderType
(
703 unoidl
::detail
::SourceProviderType
::TYPE_ENUM
,
706 case unoidl
::Entity
::SORT_PLAIN_STRUCT_TYPE
:
707 t
= unoidl
::detail
::SourceProviderType
(
708 unoidl
::detail
::SourceProviderType
::TYPE_PLAIN_STRUCT
,
711 case unoidl
::Entity
::SORT_POLYMORPHIC_STRUCT_TYPE_TEMPLATE
:
715 + " based on polymorphic struct type template "
716 + n
+ " without type arguments"));
718 case unoidl
::Entity
::SORT_EXCEPTION_TYPE
:
719 t
= unoidl
::detail
::SourceProviderType
(
720 unoidl
::detail
::SourceProviderType
::TYPE_EXCEPTION
,
723 case unoidl
::Entity
::SORT_INTERFACE_TYPE
:
724 t
= unoidl
::detail
::SourceProviderType
(
725 unoidl
::detail
::SourceProviderType
::TYPE_INTERFACE
,
732 + " based on non-type entity " + n
));
736 case unoidl
::detail
::SourceProviderEntity
::KIND_INTERFACE_DECL
:
737 case unoidl
::detail
::SourceProviderEntity
::KIND_PUBLISHED_INTERFACE_DECL
:
738 t
= unoidl
::detail
::SourceProviderType
(
739 unoidl
::detail
::SourceProviderType
::TYPE_INTERFACE
,
742 case unoidl
::detail
::SourceProviderEntity
::KIND_MODULE
:
743 assert
(false
&& "this cannot happen");
747 assert
(typeNucleus.isEmpty
());
748 assert
(e
!= nullptr
);
750 case unoidl
::detail
::SourceProviderEntity
::KIND_LOCAL
:
755 + (" based on instantiated polymorphic struct type"
758 + (" that is either not a polymorphic struct type"
759 " template or a recursive reference to a"
760 " polymorphic struct type template")));
763 assert
(e
->entity.is
());
765 case unoidl
::detail
::SourceProviderEntity
::KIND_EXTERNAL
:
766 if
(e
->entity
->getSort
()
767 == unoidl
::Entity
::SORT_POLYMORPHIC_STRUCT_TYPE_TEMPLATE
)
771 unoidl
::PolymorphicStructTypeTemplateEntity
*>(
773 ->getTypeParameters
().size
()))
778 + (" based on instantiated polymorphic struct"
780 + OUString
::number
(args.size
())
781 + (" type arguments based on polymorphic"
782 " struct type template ")
786 unoidl
::PolymorphicStructTypeTemplateEntity
*>(
788 ->getTypeParameters
().size
())
789 + " type parameters"));
792 t
= unoidl
::detail
::SourceProviderType
(n
, e
, std
::move
(args
));
796 case unoidl
::detail
::SourceProviderEntity
::KIND_INTERFACE_DECL
:
797 case unoidl
::detail
::SourceProviderEntity
::KIND_PUBLISHED_INTERFACE_DECL
:
801 + (" based on instantiated polymorphic struct type"
804 + " that is not a polymorphic struct type template"));
806 case unoidl
::detail
::SourceProviderEntity
::KIND_MODULE
:
807 assert
(false
&& "this cannot happen");
810 if
(typedefedType
!= nullptr
) {
811 for
(std
::size_t i
= 0; i
!= rank
; ++i
) {
812 t
= unoidl
::detail
::SourceProviderType
(&t
);
814 *typedefedType
= std
::move
(t
);
815 typedefedType
->typedefName
= *name
;
826 bool checkTypeArgument
(
827 YYLTYPE location
, yyscan_t yyscanner
,
828 unoidl
::detail
::SourceProviderType
const & type
)
831 case unoidl
::detail
::SourceProviderType
::TYPE_VOID
:
832 case unoidl
::detail
::SourceProviderType
::TYPE_UNSIGNED_SHORT
:
833 case unoidl
::detail
::SourceProviderType
::TYPE_UNSIGNED_LONG
:
834 case unoidl
::detail
::SourceProviderType
::TYPE_UNSIGNED_HYPER
:
835 case unoidl
::detail
::SourceProviderType
::TYPE_EXCEPTION
:
836 case unoidl
::detail
::SourceProviderType
::TYPE_PARAMETER
: //TODO?
839 u
"bad instantiated polymorphic struct type argument"_ustr
);
841 case unoidl
::detail
::SourceProviderType
::TYPE_SEQUENCE
:
842 return checkTypeArgument
(location
, yyscanner
, type.subtypes.front
());
848 bool checkInstantiatedPolymorphicStructTypeArgument
(
849 unoidl
::detail
::SourceProviderType
const & type
, OUString
const & name
)
852 == unoidl
::detail
::SourceProviderType
::TYPE_INSTANTIATED_POLYMORPHIC_STRUCT
)
854 for
(auto
& i
: type.subtypes
) {
855 if
(checkInstantiatedPolymorphicStructTypeArgument
(i
, name
)
856 || i.getName
() == name
) // no need to worry about typedef
865 std::vector
<OUString
> annotations
(bool deprecated
) {
866 std
::vector
<OUString
> ann
;
868 ann.push_back
(u
"deprecated"_ustr
);
880 %token TOK_RIGHTSHIFT
892 %token TOK_CONSTRAINED
903 %token TOK_MAYBEAMBIGUOUS
904 %token TOK_MAYBEDEFAULT
927 %token
<sval
> TOK_IDENTIFIER
928 %token
<ival
> TOK_INTEGER
929 %token
<fval
> TOK_FLOATING
931 %token TOK_DEPRECATED
935 %type
<sval
> identifier name singleInheritance singleInheritance_opt
936 %type
<bval
> ctors_opt deprecated_opt ellipsis_opt published_opt
937 %type
<decls
> attributeAccessDecl attributeAccessDecls
939 %type
<excns
> exceptionSpec exceptionSpec_opt exceptions
940 %type
<flags
> flag flagSection flagSection_opt flags
941 %type
<expr
> addExpr andExpr expr multExpr orExpr primaryExpr shiftExpr unaryExpr
944 %type
<types
> typeArguments
946 %initial
-action
{ yylloc = 1; }
951 definitions definition
959 | polymorphicStructTemplateDefn
964 | singleInterfaceBasedServiceDefn
965 | accumulationBasedServiceDefn
966 | interfaceBasedSingletonDefn
967 | serviceBasedSingletonDefn
972 TOK_MODULE identifier
974 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
975 OUString name
(convertToFullName
(data
, $2));
976 data
->modules.push_back
(name
);
977 std
::pair
<std
::map
<OUString
, unoidl
::detail
::SourceProviderEntity
>::iterator
, bool> p
(
978 data
->entities.emplace
(
980 unoidl
::detail
::SourceProviderEntity
(
981 unoidl
::detail
::SourceProviderEntity
::KIND_MODULE
)));
983 && (p.first
->second.kind
984 != unoidl
::detail
::SourceProviderEntity
::KIND_MODULE
))
986 error(@
2, yyscanner
, "multiple entities named " + name
);
990 '{' definitions
'}' ';' { yyget_extra
(yyscanner
)->modules.pop_back
(); }
994 deprecated_opt published_opt TOK_ENUM identifier
996 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
997 data
->publishedContext
= $2;
998 convertToCurrentName
(data
, $4);
999 if
(!data
->entities.emplace
(
1001 unoidl
::detail
::SourceProviderEntity
(
1002 new unoidl
::detail
::SourceProviderEnumTypeEntityPad
(
1006 error(@
4, yyscanner
, "multiple entities named " + data
->currentName
);
1010 '{' enumMembers
'}' ';'
1012 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
1013 unoidl
::detail
::SourceProviderEntity
* ent
= getCurrentEntity
(data
);
1014 unoidl
::detail
::SourceProviderEnumTypeEntityPad
* pad
=
1015 dynamic_cast
<unoidl
::detail
::SourceProviderEnumTypeEntityPad
*>(
1017 assert
(pad
!= nullptr
);
1018 ent
->entity
= new unoidl
::EnumTypeEntity
(
1019 pad
->isPublished
(), std
::move
(pad
->members
), annotations
($1));
1021 clearCurrentState
(data
);
1026 | enumMembers
',' enumMember
1031 deprecated_opt identifier
1033 OUString id
(convertName
($2));
1034 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
1035 rtl
::Reference
<unoidl
::detail
::SourceProviderEnumTypeEntityPad
> pad
(
1036 getCurrentPad
<unoidl
::detail
::SourceProviderEnumTypeEntityPad
>(data
));
1038 if
(pad
->members.empty
()) {
1041 v
= pad
->members.back
().value
;
1042 if
(v
== SAL_MAX_INT32
) {
1045 ("enum " + data
->currentName
+ " member " + id
1046 + " would have out-of-range value 2^31"));
1051 pad
->members.emplace_back
(id
, v
, annotations
($1));
1053 | deprecated_opt identifier
'=' expr
1055 OUString id
(convertName
($2));
1056 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
1057 rtl
::Reference
<unoidl
::detail
::SourceProviderEnumTypeEntityPad
> pad
(
1058 getCurrentPad
<unoidl
::detail
::SourceProviderEnumTypeEntityPad
>(data
));
1061 case unoidl
::detail
::SourceProviderExpr
::TYPE_INT
:
1062 if
($4.ival
< SAL_MIN_INT32 ||
$4.ival
> SAL_MAX_INT32
) {
1065 ("out-of-range enum " + data
->currentName
+ " member " + id
1066 + " value " + OUString
::number
($4.ival
)));
1069 v
= static_cast
<sal_Int32
>($4.ival
);
1071 case unoidl
::detail
::SourceProviderExpr
::TYPE_UINT
:
1072 if
($4.uval
> SAL_MAX_INT32
) {
1075 ("out-of-range enum " + data
->currentName
+ " member " + id
1076 + " value " + OUString
::number
($4.uval
)));
1079 v
= static_cast
<sal_Int32
>($4.uval
);
1084 ("non-integer enum " + data
->currentName
+ " member " + id
1089 pad
->members.emplace_back
(id
, v
, annotations
($1));
1094 deprecated_opt published_opt TOK_STRUCT identifier singleInheritance_opt
1096 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
1097 data
->publishedContext
= $2;
1098 convertToCurrentName
(data
, $4);
1100 rtl
::Reference
<unoidl
::PlainStructTypeEntity
> baseEnt
;
1101 if
($5 != nullptr
) {
1102 baseName
= convertName
($5);
1103 unoidl
::detail
::SourceProviderEntity
const * p
;
1105 @
5, yyscanner
, data
, false
, &baseName
, &p
, nullptr
, nullptr
)
1110 if
(p
== nullptr ||
!p
->entity.is
()
1111 || p
->entity
->getSort
() != unoidl
::Entity
::SORT_PLAIN_STRUCT_TYPE
)
1115 ("plain struct type " + data
->currentName
+ " base "
1117 + " does not resolve to an existing plain struct type"));
1120 baseEnt
= static_cast
<unoidl
::PlainStructTypeEntity
*>(
1122 if
($2 && !baseEnt
->isPublished
()) {
1125 ("published plain struct type " + data
->currentName
+ " base "
1126 + baseName
+ " is unpublished"));
1130 if
(!data
->entities.emplace
(
1132 unoidl
::detail
::SourceProviderEntity
(
1133 new unoidl
::detail
::SourceProviderPlainStructTypeEntityPad
(
1134 $2, baseName
, baseEnt
))).
1137 error(@
4, yyscanner
, "multiple entities named " + data
->currentName
);
1141 '{' structMembers
'}' ';'
1143 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
1144 unoidl
::detail
::SourceProviderEntity
* ent
= getCurrentEntity
(data
);
1145 unoidl
::detail
::SourceProviderPlainStructTypeEntityPad
* pad
=
1147 unoidl
::detail
::SourceProviderPlainStructTypeEntityPad
*>(
1149 assert
(pad
!= nullptr
);
1150 ent
->entity
= new unoidl
::PlainStructTypeEntity
(
1151 pad
->isPublished
(), pad
->baseName
, std
::move
(pad
->members
), annotations
($1));
1153 clearCurrentState
(data
);
1157 polymorphicStructTemplateDefn:
1158 deprecated_opt published_opt TOK_STRUCT identifier
'<'
1160 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
1161 data
->publishedContext
= $2;
1162 convertToCurrentName
(data
, $4);
1163 if
(!data
->entities.emplace
(
1165 unoidl
::detail
::SourceProviderEntity
(
1166 new unoidl
::detail
::SourceProviderPolymorphicStructTypeTemplateEntityPad
(
1170 error(@
4, yyscanner
, "multiple entities named " + data
->currentName
);
1174 typeParameters
'>' '{' structMembers
'}' ';'
1176 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
1177 unoidl
::detail
::SourceProviderEntity
* ent
= getCurrentEntity
(data
);
1178 unoidl
::detail
::SourceProviderPolymorphicStructTypeTemplateEntityPad
*
1180 unoidl
::detail
::SourceProviderPolymorphicStructTypeTemplateEntityPad
*>(
1182 assert
(pad
!= nullptr
);
1183 ent
->entity
= new unoidl
::PolymorphicStructTypeTemplateEntity
(
1184 pad
->isPublished
(), std
::move
(pad
->typeParameters
), std
::move
(pad
->members
),
1187 clearCurrentState
(data
);
1192 typeParameters
',' identifier
1194 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
1195 rtl
::Reference
<unoidl
::detail
::SourceProviderPolymorphicStructTypeTemplateEntityPad
>
1196 pad
(getCurrentPad
<unoidl
::detail
::SourceProviderPolymorphicStructTypeTemplateEntityPad
>(
1198 OUString id
(convertName
($3));
1199 if
(std
::find
(pad
->typeParameters.begin
(), pad
->typeParameters.end
(), id
)
1200 != pad
->typeParameters.end
())
1204 ("polymorphic struct type template " + data
->currentName
1205 + " type parameter " + id
1206 + " has same identifier as another type parameter"));
1209 pad
->typeParameters.push_back
(id
);
1213 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
1214 rtl
::Reference
<unoidl
::detail
::SourceProviderPolymorphicStructTypeTemplateEntityPad
>
1215 pad
(getCurrentPad
<unoidl
::detail
::SourceProviderPolymorphicStructTypeTemplateEntityPad
>(
1217 OUString id
(convertName
($1));
1218 assert
(pad
->typeParameters.empty
());
1219 pad
->typeParameters.push_back
(id
);
1224 deprecated_opt published_opt TOK_EXCEPTION identifier singleInheritance_opt
1226 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
1227 data
->publishedContext
= $2;
1228 convertToCurrentName
(data
, $4);
1230 rtl
::Reference
<unoidl
::ExceptionTypeEntity
> baseEnt
;
1231 if
($5 != nullptr
) {
1232 baseName
= convertName
($5);
1233 unoidl
::detail
::SourceProviderEntity
const * p
;
1235 @
5, yyscanner
, data
, false
, &baseName
, &p
, nullptr
, nullptr
)
1240 if
(p
== nullptr ||
!p
->entity.is
()
1241 || p
->entity
->getSort
() != unoidl
::Entity
::SORT_EXCEPTION_TYPE
)
1245 ("exception type " + data
->currentName
+ " base " + baseName
1246 + " does not resolve to an existing exception type"));
1249 baseEnt
= static_cast
<unoidl
::ExceptionTypeEntity
*>(
1251 if
($2 && !baseEnt
->isPublished
()) {
1254 ("published exception type " + data
->currentName
+ " base "
1255 + baseName
+ " is unpublished"));
1259 if
(!data
->entities.emplace
(
1261 unoidl
::detail
::SourceProviderEntity
(
1262 new unoidl
::detail
::SourceProviderExceptionTypeEntityPad
(
1263 $2, baseName
, baseEnt
))).
1266 error(@
4, yyscanner
, "multiple entities named " + data
->currentName
);
1270 '{' structMembers
'}' ';'
1272 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
1273 unoidl
::detail
::SourceProviderEntity
* ent
= getCurrentEntity
(data
);
1274 unoidl
::detail
::SourceProviderExceptionTypeEntityPad
* pad
=
1275 dynamic_cast
<unoidl
::detail
::SourceProviderExceptionTypeEntityPad
*>(
1277 assert
(pad
!= nullptr
);
1278 ent
->entity
= new unoidl
::ExceptionTypeEntity
(
1279 pad
->isPublished
(), pad
->baseName
, std
::move
(pad
->members
), annotations
($1));
1281 clearCurrentState
(data
);
1286 structMembers structMember
1291 deprecated_opt type identifier
';'
1293 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
1294 unoidl
::detail
::SourceProviderType t
(*$2);
1296 OUString id
(convertName
($3));
1298 case unoidl
::detail
::SourceProviderType
::TYPE_VOID
:
1299 case unoidl
::detail
::SourceProviderType
::TYPE_EXCEPTION
:
1302 ("illegal struct/exception type " + data
->currentName
1303 + " direct member " + id
+ " type"));
1309 if
(t.type
!= unoidl
::detail
::SourceProviderType
::TYPE_PARAMETER
1310 && t.getName
() == data
->currentName
) // no need to worry about typedef
1314 ("struct/exception type " + data
->currentName
+ " direct member "
1315 + id
+ " has same type as the type itself"));
1318 if
(checkInstantiatedPolymorphicStructTypeArgument
(t
, data
->currentName
))
1322 ("struct/exception type " + data
->currentName
+ " direct member "
1324 + (" has instantiated polymorphic struct type that uses the type"
1325 " itself as an argument")));
1328 if
(nameHasSameIdentifierAs
(data
->currentName
, id
)) {
1331 ("struct/exception type " + data
->currentName
+ " direct member "
1332 + id
+ " has same unqualified identifier as the type itself"));
1335 unoidl
::detail
::SourceProviderEntity
* ent
= getCurrentEntity
(data
);
1336 unoidl
::detail
::SourceProviderPlainStructTypeEntityPad
* p1
=
1337 dynamic_cast
<unoidl
::detail
::SourceProviderPlainStructTypeEntityPad
*>(
1339 if
(p1
!= nullptr
) {
1340 for
(const auto
& i
: p1
->members
) {
1344 ("plain struct type " + data
->currentName
1345 + " direct member " + id
1346 + " has same identifier as another direct member"));
1350 if
(p1
->baseEntity.is
()) {
1351 OUString baseName
(p1
->baseName
);
1352 for
(auto baseEnt
(p1
->baseEntity
);;) {
1353 if
(nameHasSameIdentifierAs
(baseName
, id
)) {
1356 ("plain struct type " + data
->currentName
1357 + " direct member " + id
1358 + " has same unqalified identifier as base "
1362 for
(auto
& i
: baseEnt
->getDirectMembers
()) {
1366 ("plain struct type " + data
->currentName
1367 + " direct member " + id
1368 + " has same identifier as a member of base "
1373 baseName
= baseEnt
->getDirectBase
();
1374 if
(baseName.isEmpty
()) {
1377 unoidl
::detail
::SourceProviderEntity
const * p
;
1379 @
2, yyscanner
, data
, false
, &baseName
, &p
, nullptr
,
1385 if
(p
== nullptr ||
!p
->entity.is
()
1386 ||
(p
->entity
->getSort
()
1387 != unoidl
::Entity
::SORT_PLAIN_STRUCT_TYPE
))
1391 ("inconsistent type manager: plain struct type "
1392 + data
->currentName
+ " base " + baseName
1393 + (" does not resolve to an existing plain struct"
1397 baseEnt
= static_cast
<unoidl
::PlainStructTypeEntity
*>(
1401 p1
->members.emplace_back
(id
, t.getName
(), annotations
($1));
1403 unoidl
::detail
::SourceProviderPolymorphicStructTypeTemplateEntityPad
*
1404 p2
= dynamic_cast
<unoidl
::detail
::SourceProviderPolymorphicStructTypeTemplateEntityPad
*>(
1406 if
(p2
!= nullptr
) {
1407 for
(const auto
& i
: p2
->members
) {
1411 ("polymorphic struct type template "
1412 + data
->currentName
+ " direct member " + id
1413 + " has same identifier as another direct member"));
1417 p2
->members.emplace_back
(
1419 t.type
== unoidl
::detail
::SourceProviderType
::TYPE_PARAMETER
,
1422 unoidl
::detail
::SourceProviderExceptionTypeEntityPad
* p3
1423 = dynamic_cast
<unoidl
::detail
::SourceProviderExceptionTypeEntityPad
*>(
1425 assert
(p3
!= nullptr
);
1426 for
(const auto
& i
: p3
->members
) {
1430 ("exception type " + data
->currentName
1431 + " direct member " + id
1432 + " has same identifier as another direct member"));
1436 if
(p3
->baseEntity.is
()) {
1437 OUString baseName
(p3
->baseName
);
1438 for
(auto baseEnt
(p3
->baseEntity
);;) {
1439 if
(nameHasSameIdentifierAs
(baseName
, id
)) {
1442 ("exception type " + data
->currentName
1443 + " direct member " + id
1444 + " has same unqalified identifier as base "
1448 for
(auto
& i
: baseEnt
->getDirectMembers
()) {
1452 ("exception type " + data
->currentName
1453 + " direct member " + id
1454 + " has same identifier as a member of base "
1459 baseName
= baseEnt
->getDirectBase
();
1460 if
(baseName.isEmpty
()) {
1463 unoidl
::detail
::SourceProviderEntity
const * p
;
1465 @
2, yyscanner
, data
, false
, &baseName
, &p
,
1471 if
(p
== nullptr ||
!p
->entity.is
()
1472 ||
(p
->entity
->getSort
()
1473 != unoidl
::Entity
::SORT_EXCEPTION_TYPE
))
1477 ("inconsistent type manager: exception type "
1478 + data
->currentName
+ " base " + baseName
1479 + (" does not resolve to an existing exception"
1483 baseEnt
= static_cast
<unoidl
::ExceptionTypeEntity
*>(
1487 p3
->members.emplace_back
(id
, t.getName
(), annotations
($1));
1494 deprecated_opt published_opt TOK_INTERFACE identifier singleInheritance_opt
1496 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
1497 data
->publishedContext
= $2;
1498 convertToCurrentName
(data
, $4);
1500 rtl
::Reference
<unoidl
::InterfaceTypeEntity
> baseEnt
;
1501 if
($5 != nullptr
) {
1502 baseName
= convertName
($5);
1503 unoidl
::detail
::SourceProviderEntity
const * p
;
1505 @
5, yyscanner
, data
, true
, &baseName
, &p
, nullptr
, nullptr
)
1510 if
(p
== nullptr ||
!p
->entity.is
()
1511 || p
->entity
->getSort
() != unoidl
::Entity
::SORT_INTERFACE_TYPE
)
1515 ("interface type " + data
->currentName
+ " direct base "
1517 + " does not resolve to an existing interface type"));
1520 baseEnt
= static_cast
<unoidl
::InterfaceTypeEntity
*>(p
->entity.get
());
1521 if
($2 && !baseEnt
->isPublished
()) {
1524 ("published interface type " + data
->currentName
1525 + " direct base " + baseName
+ " is unpublished"));
1529 std
::map
<OUString
, unoidl
::detail
::SourceProviderEntity
>::iterator i
(
1530 data
->entities.find
(data
->currentName
));
1531 if
(i
!= data
->entities.end
()) {
1532 switch
(i
->second.kind
) {
1533 case unoidl
::detail
::SourceProviderEntity
::KIND_INTERFACE_DECL
:
1535 case unoidl
::detail
::SourceProviderEntity
::KIND_PUBLISHED_INTERFACE_DECL
:
1539 ("unpublished interface type " + data
->currentName
1540 + " has been declared published"));
1547 "multiple entities named " + data
->currentName
);
1552 rtl
::Reference
<unoidl
::detail
::SourceProviderInterfaceTypeEntityPad
> pad
(
1553 new unoidl
::detail
::SourceProviderInterfaceTypeEntityPad
(
1556 && !pad
->addDirectBase
(
1557 @
4, yyscanner
, data
,
1558 unoidl
::detail
::SourceProviderInterfaceTypeEntityPad
::DirectBase
(
1559 baseName
, baseEnt
, std
::vector
<OUString
>()),
1564 data
->entities
[data
->currentName
] = unoidl
::detail
::SourceProviderEntity
(
1567 '{' interfaceMembers
'}' ';'
1569 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
1570 unoidl
::detail
::SourceProviderEntity
* ent
= getCurrentEntity
(data
);
1571 unoidl
::detail
::SourceProviderInterfaceTypeEntityPad
* pad
=
1572 dynamic_cast
<unoidl
::detail
::SourceProviderInterfaceTypeEntityPad
*>(
1574 assert
(pad
!= nullptr
);
1575 if
(pad
->directMandatoryBases.empty
()
1576 && data
->currentName
!= "com.sun.star.uno.XInterface")
1578 OUString base
(u
".com.sun.star.uno.XInterface"_ustr
);
1579 unoidl
::detail
::SourceProviderEntity
const * p
;
1580 if
(findEntity
(@
4, yyscanner
, data
, true
, &base
, &p
, nullptr
, nullptr
)
1585 if
(p
== nullptr ||
!p
->entity.is
()
1586 || p
->entity
->getSort
() != unoidl
::Entity
::SORT_INTERFACE_TYPE
)
1590 ("interface type " + data
->currentName
1591 + " implicit direct base " + base
1592 + " does not resolve to an existing interface type"));
1595 if
(!pad
->addDirectBase
(
1596 @
3, yyscanner
, data
,
1597 unoidl
::detail
::SourceProviderInterfaceTypeEntityPad
::DirectBase
(
1599 static_cast
<unoidl
::InterfaceTypeEntity
*>(
1601 std
::vector
<OUString
>()),
1607 std
::vector
<unoidl
::AnnotatedReference
> mbases
;
1608 for
(auto
& i
: pad
->directMandatoryBases
) {
1609 mbases.emplace_back
(i.name
, std
::move
(i.annotations
));
1611 std
::vector
<unoidl
::AnnotatedReference
> obases
;
1612 for
(auto
& i
: pad
->directOptionalBases
) {
1613 obases.emplace_back
(i.name
, std
::move
(i.annotations
));
1615 ent
->entity
= new unoidl
::InterfaceTypeEntity
(
1616 pad
->isPublished
(), std
::move
(mbases
), std
::move
(obases
), std
::move
(pad
->directAttributes
),
1617 std
::move
(pad
->directMethods
), annotations
($1));
1619 clearCurrentState
(data
);
1624 interfaceMembers interfaceMember
1630 | interfaceAttribute
1635 deprecated_opt flagSection_opt TOK_INTERFACE name
';'
1637 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
1638 OUString name
(convertName
($4));
1639 rtl
::Reference
<unoidl
::detail
::SourceProviderInterfaceTypeEntityPad
> pad
(
1640 getCurrentPad
<unoidl
::detail
::SourceProviderInterfaceTypeEntityPad
>(
1642 if
(pad
->singleBase
) {
1645 u
"single-inheritance interface cannot have additional bases"_ustr
);
1648 if
(($2 & ~unoidl
::detail
::FLAG_OPTIONAL
) != 0) {
1651 u
"interface base can only be flagged as [optional]"_ustr
);
1654 bool opt
= ($2 & unoidl
::detail
::FLAG_OPTIONAL
) != 0;
1655 OUString orgName
(name
);
1656 unoidl
::detail
::SourceProviderEntity
const * p
;
1657 bool typedefed
= false
;
1658 if
(findEntity
(@
4, yyscanner
, data
, true
, &name
, &p
, &typedefed
, nullptr
)
1663 if
(p
== nullptr ||
!p
->entity.is
()
1664 || p
->entity
->getSort
() != unoidl
::Entity
::SORT_INTERFACE_TYPE
)
1668 ("interface type " + data
->currentName
+ " direct base " + name
1669 + " does not resolve to an existing interface type"));
1675 ("interface type " + data
->currentName
+ " direct base " + orgName
1676 + " is a typedef"));
1679 rtl
::Reference
<unoidl
::InterfaceTypeEntity
> ent
(
1680 static_cast
<unoidl
::InterfaceTypeEntity
*>(p
->entity.get
()));
1681 if
(data
->publishedContext
&& !ent
->isPublished
()) {
1684 ("published interface type " + data
->currentName
+ " direct base "
1685 + name
+ " is unpublished"));
1688 if
(!pad
->addDirectBase
(
1689 @
4, yyscanner
, data
,
1690 unoidl
::detail
::SourceProviderInterfaceTypeEntityPad
::DirectBase
(
1691 name
, ent
, annotations
($1)),
1700 deprecated_opt flagSection type identifier
1702 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
1703 unoidl
::detail
::SourceProviderType t
(*$3);
1705 OUString id
(convertName
($4));
1706 if
(($2 & unoidl
::detail
::FLAG_ATTRIBUTE
) == 0) {
1709 u
"interface attribute must be flagged as [attribute]"_ustr
);
1713 & ~
(unoidl
::detail
::FLAG_ATTRIBUTE | unoidl
::detail
::FLAG_BOUND
1714 | unoidl
::detail
::FLAG_READONLY
))
1719 (u
"interface attribute can only be flagged as [attribute,"
1720 " bound, readonly]"_ustr
));
1724 case unoidl
::detail
::SourceProviderType
::TYPE_VOID
:
1725 case unoidl
::detail
::SourceProviderType
::TYPE_EXCEPTION
:
1728 ("illegal interface type " + data
->currentName
1729 + " direct attribute " + id
+ " type"));
1735 rtl
::Reference
<unoidl
::detail
::SourceProviderInterfaceTypeEntityPad
> pad
(
1736 getCurrentPad
<unoidl
::detail
::SourceProviderInterfaceTypeEntityPad
>(
1738 if
(!pad
->addDirectMember
(@
4, yyscanner
, data
, id
)) {
1741 pad
->directAttributes.emplace_back
(
1742 id
, t.getName
(), ($2 & unoidl
::detail
::FLAG_BOUND
) != 0,
1743 ($2 & unoidl
::detail
::FLAG_READONLY
) != 0,
1744 std
::vector
<OUString
>(), std
::vector
<OUString
>(), annotations
($1));
1746 attributeAccessDecls_opt
';'
1749 attributeAccessDecls_opt:
1750 '{' attributeAccessDecls
'}'
1754 attributeAccessDecls:
1755 attributeAccessDecls attributeAccessDecl
1757 if
(($1 & $2) != 0) {
1759 @
2, yyscanner
, u
"duplicate get/set attribute access declaration"_ustr
);
1762 $$
= unoidl
::detail
::SourceProviderAccessDecls
($1 |
$2);
1764 |
/* empty */ { $$
= unoidl
::detail
::SourceProviderAccessDecls
(0); }
1767 attributeAccessDecl:
1768 TOK_GET exceptionSpec
';'
1770 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
1771 rtl
::Reference
<unoidl
::detail
::SourceProviderInterfaceTypeEntityPad
>
1772 pad
(getCurrentPad
<unoidl
::detail
::SourceProviderInterfaceTypeEntityPad
>(
1774 assert
(!pad
->directAttributes.empty
());
1775 pad
->directAttributes.back
().getExceptions
= *$2;
1777 $$
= unoidl
::detail
::ACCESS_DECL_GET
;
1779 | TOK_SET exceptionSpec
';'
1781 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
1782 rtl
::Reference
<unoidl
::detail
::SourceProviderInterfaceTypeEntityPad
>
1783 pad
(getCurrentPad
<unoidl
::detail
::SourceProviderInterfaceTypeEntityPad
>(
1785 assert
(!pad
->directAttributes.empty
());
1786 pad
->directAttributes.back
().setExceptions
= *$2;
1788 if
(pad
->directAttributes.back
().readOnly
) {
1791 ("interface type " + data
->currentName
1792 + " direct read-only attribute "
1793 + pad
->directAttributes.back
().name
1794 + " cannot have set access declaration"));
1797 $$
= unoidl
::detail
::ACCESS_DECL_SET
;
1802 deprecated_opt type identifier
1804 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
1805 unoidl
::detail
::SourceProviderType t
(*$2);
1807 OUString id
(convertName
($3));
1808 if
(t.type
== unoidl
::detail
::SourceProviderType
::TYPE_EXCEPTION
) {
1811 ("illegal interface type " + data
->currentName
1812 + " direct method " + id
+ " return type"));
1815 rtl
::Reference
<unoidl
::detail
::SourceProviderInterfaceTypeEntityPad
> pad
(
1816 getCurrentPad
<unoidl
::detail
::SourceProviderInterfaceTypeEntityPad
>(
1818 if
(!pad
->addDirectMember
(@
3, yyscanner
, data
, id
)) {
1821 pad
->directMethods.emplace_back
(
1823 std
::vector
<unoidl
::InterfaceTypeEntity
::Method
::Parameter
>(),
1824 std
::vector
<OUString
>(), annotations
($1));
1826 '(' methodParams_opt
')' exceptionSpec_opt
';'
1828 if
($8 != nullptr
) {
1829 unoidl
::detail
::SourceProviderScannerData
* data
1830 = yyget_extra
(yyscanner
);
1831 rtl
::Reference
<unoidl
::detail
::SourceProviderInterfaceTypeEntityPad
>
1832 pad
(getCurrentPad
<unoidl
::detail
::SourceProviderInterfaceTypeEntityPad
>(
1834 assert
(!pad
->directMethods.empty
());
1835 pad
->directMethods.back
().exceptions
= *$8;
1847 methodParams
',' methodParam
1852 '[' direction
']' type identifier
1854 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
1855 unoidl
::detail
::SourceProviderType t
(*$4);
1857 OUString id
(convertName
($5));
1858 rtl
::Reference
<unoidl
::detail
::SourceProviderInterfaceTypeEntityPad
>
1859 pad
(getCurrentPad
<unoidl
::detail
::SourceProviderInterfaceTypeEntityPad
>(
1861 assert
(!pad
->directMethods.empty
());
1863 case unoidl
::detail
::SourceProviderType
::TYPE_VOID
:
1864 case unoidl
::detail
::SourceProviderType
::TYPE_EXCEPTION
:
1867 ("illegal interface type " + data
->currentName
1868 + " direct method " + pad
->directMethods.back
().name
1869 + " parameter " + id
+ " type"));
1875 for
(const auto
& i
: pad
->directMethods.back
().parameters
) {
1879 ("interface type " + data
->currentName
+ " direct method "
1880 + pad
->directMethods.back
().name
+ " parameter " + id
1881 + " has same identifier as another parameter"));
1885 pad
->directMethods.back
().parameters.emplace_back
(id
, t.getName
(), $2);
1890 TOK_IN
{ $$
= unoidl
::InterfaceTypeEntity
::Method
::Parameter
::DIRECTION_IN
; }
1892 { $$
= unoidl
::InterfaceTypeEntity
::Method
::Parameter
::DIRECTION_OUT
; }
1894 { $$
= unoidl
::InterfaceTypeEntity
::Method
::Parameter
::DIRECTION_IN_OUT
; }
1898 deprecated_opt published_opt TOK_TYPEDEF type identifier
';'
1900 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
1901 data
->publishedContext
= $2;
1902 unoidl
::detail
::SourceProviderType t
(*$4);
1904 OUString name
(convertToFullName
(data
, $5));
1905 // There is no good reason to forbid typedefs to VOID, to instantiated
1906 // polymorphic struct types, and to exception types, but some old client
1907 // code of registry data expects this typedef restriction (like the
1908 // assert(false) default in handleTypedef in
1909 // codemaker/source/javamaker/javatype.cxx), so forbid them for now:
1911 case unoidl
::detail
::SourceProviderType
::TYPE_VOID
:
1912 case unoidl
::detail
::SourceProviderType
::TYPE_EXCEPTION
:
1913 case unoidl
::detail
::SourceProviderType
::TYPE_INSTANTIATED_POLYMORPHIC_STRUCT
:
1914 error(@
4, yyscanner
, u
"bad typedef type"_ustr
);
1917 case unoidl
::detail
::SourceProviderType
::TYPE_ENUM
:
1918 case unoidl
::detail
::SourceProviderType
::TYPE_PLAIN_STRUCT
:
1919 case unoidl
::detail
::SourceProviderType
::TYPE_INTERFACE
:
1922 switch
(t.entity
->kind
) {
1923 case unoidl
::detail
::SourceProviderEntity
::KIND_INTERFACE_DECL
:
1926 case unoidl
::detail
::SourceProviderEntity
::KIND_PUBLISHED_INTERFACE_DECL
:
1928 case unoidl
::detail
::SourceProviderEntity
::KIND_MODULE
:
1931 assert
(t.entity
->entity.is
() || t.entity
->pad.is
());
1933 = !(t.entity
->entity.is
()
1934 ? static_cast
<unoidl
::PublishableEntity
*>(
1935 t.entity
->entity.get
())->isPublished
()
1936 : t.entity
->pad
->isPublished
());
1942 "published typedef " + name
+ " type is unpublished");
1947 case unoidl
::detail
::SourceProviderType
::TYPE_PARAMETER
:
1952 if
(!data
->entities.emplace
(
1954 unoidl
::detail
::SourceProviderEntity
(
1955 unoidl
::detail
::SourceProviderEntity
::KIND_LOCAL
,
1956 new unoidl
::TypedefEntity
(
1957 $2, t.getName
(), annotations
($1)))).
1960 error(@
5, yyscanner
, "multiple entities named " + name
);
1963 clearCurrentState
(data
);
1968 deprecated_opt published_opt TOK_CONSTANTS identifier
1970 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
1971 data
->publishedContext
= $2;
1972 convertToCurrentName
(data
, $4);
1973 if
(!data
->entities.emplace
(
1975 unoidl
::detail
::SourceProviderEntity
(
1976 new unoidl
::detail
::SourceProviderConstantGroupEntityPad
(
1980 error(@
4, yyscanner
, "multiple entities named " + data
->currentName
);
1984 '{' constants
'}' ';'
1986 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
1987 unoidl
::detail
::SourceProviderEntity
* ent
= getCurrentEntity
(data
);
1988 unoidl
::detail
::SourceProviderConstantGroupEntityPad
* pad
=
1989 dynamic_cast
<unoidl
::detail
::SourceProviderConstantGroupEntityPad
*>(
1991 assert
(pad
!= nullptr
);
1992 ent
->entity
= new unoidl
::ConstantGroupEntity
(
1993 pad
->isPublished
(), std
::move
(pad
->members
), annotations
($1));
1995 clearCurrentState
(data
);
2005 deprecated_opt TOK_CONST type identifier
'=' expr
';'
2007 OUString id
(convertName
($4));
2008 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
2009 rtl
::Reference
<unoidl
::detail
::SourceProviderConstantGroupEntityPad
> pad
(
2010 getCurrentPad
<unoidl
::detail
::SourceProviderConstantGroupEntityPad
>(
2012 unoidl
::detail
::SourceProviderType t
(*$3);
2014 unoidl
::ConstantValue v
(false
); // dummy value
2016 case unoidl
::detail
::SourceProviderType
::TYPE_BOOLEAN
:
2017 if
($6.type
!= unoidl
::detail
::SourceProviderExpr
::TYPE_BOOL
) {
2020 ("bad value of boolean-typed constant " + data
->currentName
2024 v
= unoidl
::ConstantValue
($6.bval
);
2026 case unoidl
::detail
::SourceProviderType
::TYPE_BYTE
:
2028 case unoidl
::detail
::SourceProviderExpr
::TYPE_INT
:
2029 if
($6.ival
< SAL_MIN_INT8 ||
$6.ival
> SAL_MAX_INT8
) {
2032 ("out-of-range byte-typed constant " + data
->currentName
2033 + "." + id
+ " value " + OUString
::number
($6.ival
)));
2036 v
= unoidl
::ConstantValue
(static_cast
<sal_Int8
>($6.ival
));
2038 case unoidl
::detail
::SourceProviderExpr
::TYPE_UINT
:
2039 if
($6.uval
> SAL_MAX_INT8
) {
2042 ("out-of-range byte-typed constant " + data
->currentName
2043 + "." + id
+ " value " + OUString
::number
($6.uval
)));
2046 v
= unoidl
::ConstantValue
(static_cast
<sal_Int8
>($6.uval
));
2051 ("bad value of byte-typed constant " + data
->currentName
+ "."
2057 case unoidl
::detail
::SourceProviderType
::TYPE_SHORT
:
2059 case unoidl
::detail
::SourceProviderExpr
::TYPE_INT
:
2060 if
($6.ival
< SAL_MIN_INT16 ||
$6.ival
> SAL_MAX_INT16
) {
2063 ("out-of-range short-typed constant " + data
->currentName
2064 + "." + id
+ " value " + OUString
::number
($6.ival
)));
2067 v
= unoidl
::ConstantValue
(static_cast
<sal_Int16
>($6.ival
));
2069 case unoidl
::detail
::SourceProviderExpr
::TYPE_UINT
:
2070 if
($6.uval
> SAL_MAX_INT16
) {
2073 ("out-of-range short-typed constant " + data
->currentName
2074 + "." + id
+ " value " + OUString
::number
($6.uval
)));
2077 v
= unoidl
::ConstantValue
(static_cast
<sal_Int16
>($6.uval
));
2082 ("bad value of short-typed constant " + data
->currentName
2088 case unoidl
::detail
::SourceProviderType
::TYPE_UNSIGNED_SHORT
:
2090 case unoidl
::detail
::SourceProviderExpr
::TYPE_INT
:
2091 if
($6.ival
< 0 ||
$6.ival
> SAL_MAX_UINT16
) {
2094 ("out-of-range unsigned-short-typed constant "
2095 + data
->currentName
+ "." + id
+ " value "
2096 + OUString
::number
($6.ival
)));
2099 v
= unoidl
::ConstantValue
(static_cast
<sal_uInt16
>($6.ival
));
2101 case unoidl
::detail
::SourceProviderExpr
::TYPE_UINT
:
2102 if
($6.uval
> SAL_MAX_UINT16
) {
2105 ("out-of-range unsigned-short-typed constant "
2106 + data
->currentName
+ "." + id
+ " value "
2107 + OUString
::number
($6.uval
)));
2110 v
= unoidl
::ConstantValue
(static_cast
<sal_uInt16
>($6.uval
));
2115 ("bad value of unsigned-short-typed constant "
2116 + data
->currentName
+ "." + id
));
2121 case unoidl
::detail
::SourceProviderType
::TYPE_LONG
:
2123 case unoidl
::detail
::SourceProviderExpr
::TYPE_INT
:
2124 if
($6.ival
< SAL_MIN_INT32 ||
$6.ival
> SAL_MAX_INT32
) {
2127 ("out-of-range long-typed constant " + data
->currentName
2128 + "." + id
+ " value " + OUString
::number
($6.ival
)));
2131 v
= unoidl
::ConstantValue
(static_cast
<sal_Int32
>($6.ival
));
2133 case unoidl
::detail
::SourceProviderExpr
::TYPE_UINT
:
2134 if
($6.uval
> SAL_MAX_INT32
) {
2137 ("out-of-range long-typed constant " + data
->currentName
2138 + "." + id
+ " value " + OUString
::number
($6.uval
)));
2141 v
= unoidl
::ConstantValue
(static_cast
<sal_Int32
>($6.uval
));
2146 ("bad value of long-typed constant " + data
->currentName
2152 case unoidl
::detail
::SourceProviderType
::TYPE_UNSIGNED_LONG
:
2154 case unoidl
::detail
::SourceProviderExpr
::TYPE_INT
:
2155 if
($6.ival
< 0 ||
$6.ival
> SAL_MAX_UINT32
) {
2158 ("out-of-range unsigned-long-typed constant "
2159 + data
->currentName
+ "." + id
+ " value "
2160 + OUString
::number
($6.ival
)));
2163 v
= unoidl
::ConstantValue
(static_cast
<sal_uInt32
>($6.ival
));
2165 case unoidl
::detail
::SourceProviderExpr
::TYPE_UINT
:
2166 if
($6.uval
> SAL_MAX_UINT32
) {
2169 ("out-of-range unsigned-long-typed constant "
2170 + data
->currentName
+ "." + id
+ " value "
2171 + OUString
::number
($6.uval
)));
2174 v
= unoidl
::ConstantValue
(static_cast
<sal_uInt32
>($6.uval
));
2179 ("bad value of unsigned-long-typed constant "
2180 + data
->currentName
+ "." + id
));
2185 case unoidl
::detail
::SourceProviderType
::TYPE_HYPER
:
2187 case unoidl
::detail
::SourceProviderExpr
::TYPE_INT
:
2188 v
= unoidl
::ConstantValue
($6.ival
);
2190 case unoidl
::detail
::SourceProviderExpr
::TYPE_UINT
:
2191 if
($6.uval
> SAL_MAX_INT64
) {
2194 ("out-of-range hyper-typed constant " + data
->currentName
2195 + "." + id
+ " value " + OUString
::number
($6.uval
)));
2198 v
= unoidl
::ConstantValue
(static_cast
<sal_Int64
>($6.uval
));
2203 ("bad value of hyper-typed constant " + data
->currentName
2209 case unoidl
::detail
::SourceProviderType
::TYPE_UNSIGNED_HYPER
:
2211 case unoidl
::detail
::SourceProviderExpr
::TYPE_INT
:
2215 ("out-of-range unsigned-hyper-typed constant "
2216 + data
->currentName
+ "." + id
+ " value "
2217 + OUString
::number
($6.ival
)));
2220 v
= unoidl
::ConstantValue
(static_cast
<sal_uInt64
>($6.ival
));
2222 case unoidl
::detail
::SourceProviderExpr
::TYPE_UINT
:
2223 v
= unoidl
::ConstantValue
($6.uval
);
2228 ("bad value of unsigned-hyper-typed constant "
2229 + data
->currentName
+ "." + id
));
2234 case unoidl
::detail
::SourceProviderType
::TYPE_FLOAT
:
2236 case unoidl
::detail
::SourceProviderExpr
::TYPE_BOOL
:
2239 ("bad boolean value of float-typed constant "
2240 + data
->currentName
+ "." + id
));
2243 case unoidl
::detail
::SourceProviderExpr
::TYPE_INT
:
2244 v
= unoidl
::ConstantValue
(static_cast
<float>($6.ival
));
2246 case unoidl
::detail
::SourceProviderExpr
::TYPE_UINT
:
2247 v
= unoidl
::ConstantValue
(static_cast
<float>($6.uval
));
2249 case unoidl
::detail
::SourceProviderExpr
::TYPE_FLOAT
:
2250 v
= unoidl
::ConstantValue
(static_cast
<float>($6.fval
));
2254 case unoidl
::detail
::SourceProviderType
::TYPE_DOUBLE
:
2256 case unoidl
::detail
::SourceProviderExpr
::TYPE_BOOL
:
2259 ("bad boolean value of double-typed constant "
2260 + data
->currentName
+ "." + id
));
2263 case unoidl
::detail
::SourceProviderExpr
::TYPE_INT
:
2264 v
= unoidl
::ConstantValue
(static_cast
<double>($6.ival
));
2266 case unoidl
::detail
::SourceProviderExpr
::TYPE_UINT
:
2267 v
= unoidl
::ConstantValue
(static_cast
<double>($6.uval
));
2269 case unoidl
::detail
::SourceProviderExpr
::TYPE_FLOAT
:
2270 v
= unoidl
::ConstantValue
($6.fval
);
2277 "bad type for constant " + data
->currentName
+ "." + id
);
2281 pad
->members.emplace_back
(id
, v
, annotations
($1));
2285 singleInterfaceBasedServiceDefn:
2286 deprecated_opt published_opt TOK_SERVICE identifier singleInheritance
2288 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
2289 data
->publishedContext
= $2;
2290 convertToCurrentName
(data
, $4);
2291 OUString base
(convertName
($5));
2292 unoidl
::detail
::SourceProviderEntity
const * p
;
2293 if
(findEntity
(@
5, yyscanner
, data
, false
, &base
, &p
, nullptr
, nullptr
)
2298 bool ifcBase
= false
;
2299 bool pubBase
= false
;
2302 case unoidl
::detail
::SourceProviderEntity
::KIND_INTERFACE_DECL
:
2306 case unoidl
::detail
::SourceProviderEntity
::KIND_PUBLISHED_INTERFACE_DECL
:
2312 && (p
->entity
->getSort
()
2313 == unoidl
::Entity
::SORT_INTERFACE_TYPE
))
2316 pubBase
= static_cast
<unoidl
::InterfaceTypeEntity
*>(
2317 p
->entity.get
())->isPublished
();
2325 ("single-interface--based service " + data
->currentName
+ " base "
2326 + base
+ " does not resolve to an interface type"));
2329 if
($2 && !pubBase
) {
2332 ("published single-interface--based service " + data
->currentName
2333 + " base " + base
+ " is unpublished"));
2336 if
(!data
->entities.emplace
(
2338 unoidl
::detail
::SourceProviderEntity
(
2339 new unoidl
::detail
::SourceProviderSingleInterfaceBasedServiceEntityPad
(
2343 error(@
4, yyscanner
, "multiple entities named " + data
->currentName
);
2349 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
2350 unoidl
::detail
::SourceProviderEntity
* ent
= getCurrentEntity
(data
);
2351 unoidl
::detail
::SourceProviderSingleInterfaceBasedServiceEntityPad
* pad
=
2352 dynamic_cast
<unoidl
::detail
::SourceProviderSingleInterfaceBasedServiceEntityPad
*>(
2354 assert
(pad
!= nullptr
);
2355 std
::vector
<unoidl
::SingleInterfaceBasedServiceEntity
::Constructor
> ctors
;
2357 for
(const auto
& i
: pad
->constructors
) {
2358 std
::vector
<unoidl
::SingleInterfaceBasedServiceEntity
::Constructor
::Parameter
> parms
;
2359 for
(auto
& j
: i.parameters
) {
2360 parms.emplace_back
(j.name
, j.type.getName
(), j.rest
);
2363 unoidl
::SingleInterfaceBasedServiceEntity
::Constructor
(
2364 i.name
, std
::move
(parms
), std
::vector
(i.exceptions
), std
::vector
(i.annotations
)));
2367 assert
(pad
->constructors.empty
());
2369 unoidl
::SingleInterfaceBasedServiceEntity
::Constructor
());
2371 ent
->entity
= new unoidl
::SingleInterfaceBasedServiceEntity
(
2372 pad
->isPublished
(), pad
->base
, std
::move
(ctors
), annotations
($1));
2374 clearCurrentState
(data
);
2379 '{' ctors
'}' { $$
= true
; }
2380 |
/* empty */ { $$
= false
; }
2389 deprecated_opt identifier
2391 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
2392 OUString id
(convertName
($2));
2393 rtl
::Reference
<unoidl
::detail
::SourceProviderSingleInterfaceBasedServiceEntityPad
>
2394 pad
(getCurrentPad
<unoidl
::detail
::SourceProviderSingleInterfaceBasedServiceEntityPad
>(
2396 for
(const auto
& i
: pad
->constructors
) {
2400 ("single-interface--based service " + data
->currentName
2401 + " constructor " + id
2402 + " has same identifier as another constructor"));
2406 pad
->constructors.push_back
(
2407 unoidl
::detail
::SourceProviderSingleInterfaceBasedServiceEntityPad
::Constructor
(
2408 id
, annotations
($1)));
2410 '(' ctorParams_opt
')' exceptionSpec_opt
';'
2412 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
2413 rtl
::Reference
<unoidl
::detail
::SourceProviderSingleInterfaceBasedServiceEntityPad
>
2414 pad
(getCurrentPad
<unoidl
::detail
::SourceProviderSingleInterfaceBasedServiceEntityPad
>(
2416 assert
(!pad
->constructors.empty
());
2417 if
($7 != nullptr
) {
2418 pad
->constructors.back
().exceptions
= *$7;
2421 for
(auto i
(pad
->constructors.begin
()); i
!= pad
->constructors.end
() - 1;
2424 if
(i
->parameters.size
()
2425 == pad
->constructors.back
().parameters.size
())
2429 j
(i
->parameters.begin
()),
2430 k
(pad
->constructors.back
().parameters.begin
());
2431 j
!= i
->parameters.end
(); ++j
, ++k
)
2433 if
(!j
->type.equals
(k
->type
) || j
->rest
!= k
->rest
) {
2441 ("single-interface--based service " + data
->currentName
2442 + " constructor " + pad
->constructors.back
().name
2443 + " has similar parameter list to constructor "
2458 ctorParams
',' ctorParam
2463 '[' direction
']' type ellipsis_opt identifier
2465 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
2466 unoidl
::detail
::SourceProviderType t
(*$4);
2468 OUString id
(convertName
($6));
2469 rtl
::Reference
<unoidl
::detail
::SourceProviderSingleInterfaceBasedServiceEntityPad
>
2470 pad
(getCurrentPad
<unoidl
::detail
::SourceProviderSingleInterfaceBasedServiceEntityPad
>(
2472 assert
(!pad
->constructors.empty
());
2473 if
($2 != unoidl
::InterfaceTypeEntity
::Method
::Parameter
::DIRECTION_IN
) {
2476 ("single-interface--based service " + data
->currentName
2477 + " constructor " + pad
->constructors.back
().name
+ " parameter "
2478 + id
+ " direction must be [in]"));
2482 case unoidl
::detail
::SourceProviderType
::TYPE_VOID
:
2483 case unoidl
::detail
::SourceProviderType
::TYPE_EXCEPTION
:
2486 ("illegal single-interface--based service " + data
->currentName
2487 + " constructor " + pad
->constructors.back
().name
+ " parameter "
2495 if
(t.type
!= unoidl
::detail
::SourceProviderType
::TYPE_ANY
) {
2498 ("illegal single-interface--based service "
2499 + data
->currentName
+ " constructor "
2500 + pad
->constructors.back
().name
+ " rest parameter " + id
2501 + " non-any type"));
2504 if
(!pad
->constructors.back
().parameters.empty
()) {
2507 ("single-interface--based service " + data
->currentName
2508 + " constructor " + pad
->constructors.back
().name
2509 + " rest parameter " + id
+ " must be first parameter"));
2512 } else if
(!pad
->constructors.back
().parameters.empty
()
2513 && pad
->constructors.back
().parameters.back
().rest
)
2517 ("single-interface--based service " + data
->currentName
2518 + " constructor " + pad
->constructors.back
().name
2519 + " rest parameter must be last parameter"));
2522 for
(const auto
& i
: pad
->constructors.back
().parameters
) {
2526 ("single-interface--based service " + data
->currentName
2527 + " constructor " + pad
->constructors.back
().name
2528 + " parameter " + id
2529 + " has same identifier as another parameter"));
2533 pad
->constructors.back
().parameters.push_back
(
2534 unoidl
::detail
::SourceProviderSingleInterfaceBasedServiceEntityPad
::Constructor
::Parameter
(
2535 id
, std
::move
(t
), $5));
2540 TOK_ELLIPSIS
{ $$
= true
; }
2541 |
/* empty */ { $$
= false
; }
2543 accumulationBasedServiceDefn:
2544 deprecated_opt published_opt TOK_SERVICE identifier
2546 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
2547 data
->publishedContext
= $2;
2548 convertToCurrentName
(data
, $4);
2549 if
(!data
->entities.emplace
(
2551 unoidl
::detail
::SourceProviderEntity
(
2552 new unoidl
::detail
::SourceProviderAccumulationBasedServiceEntityPad
(
2556 error(@
4, yyscanner
, "multiple entities named " + data
->currentName
);
2560 '{' serviceMembers
'}' ';'
2562 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
2563 unoidl
::detail
::SourceProviderEntity
* ent
= getCurrentEntity
(data
);
2564 unoidl
::detail
::SourceProviderAccumulationBasedServiceEntityPad
* pad
=
2565 dynamic_cast
<unoidl
::detail
::SourceProviderAccumulationBasedServiceEntityPad
*>(
2567 assert
(pad
!= nullptr
);
2568 ent
->entity
= new unoidl
::AccumulationBasedServiceEntity
(
2569 pad
->isPublished
(), std
::move
(pad
->directMandatoryBaseServices
),
2570 std
::move
(pad
->directOptionalBaseServices
), std
::move
(pad
->directMandatoryBaseInterfaces
),
2571 std
::move
(pad
->directOptionalBaseInterfaces
), std
::move
(pad
->directProperties
),
2574 clearCurrentState
(data
);
2579 serviceMembers serviceMember
2585 | serviceInterfaceBase
2590 deprecated_opt flagSection_opt TOK_SERVICE name
';'
2592 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
2593 OUString name
(convertName
($4));
2594 rtl
::Reference
<unoidl
::detail
::SourceProviderAccumulationBasedServiceEntityPad
> pad
(
2595 getCurrentPad
<unoidl
::detail
::SourceProviderAccumulationBasedServiceEntityPad
>(
2597 if
(($2 & ~unoidl
::detail
::FLAG_OPTIONAL
) != 0) {
2600 u
"service base can only be flagged as [optional]"_ustr
);
2603 bool opt
= ($2 & unoidl
::detail
::FLAG_OPTIONAL
) != 0;
2604 unoidl
::detail
::SourceProviderEntity
const * p
;
2605 if
(findEntity
(@
4, yyscanner
, data
, false
, &name
, &p
, nullptr
, nullptr
)
2610 if
(p
== nullptr ||
!p
->entity.is
()
2611 ||
(p
->entity
->getSort
()
2612 != unoidl
::Entity
::SORT_ACCUMULATION_BASED_SERVICE
))
2616 ("accumulation-based service " + data
->currentName
2617 + " direct base service " + name
2618 + " does not resolve to an accumulation-based service"));
2621 if
(data
->publishedContext
2622 && !static_cast
<unoidl
::AccumulationBasedServiceEntity
*>(
2623 p
->entity.get
())->isPublished
())
2627 ("published accumulation-based service " + data
->currentName
2628 + " direct base service " + name
+ " is unpublished"));
2631 std
::vector
<unoidl
::AnnotatedReference
> & v
(
2633 ? pad
->directOptionalBaseServices
: pad
->directMandatoryBaseServices
);
2634 for
(const auto
& i
: v
) {
2635 if
(name
== i.name
) {
2638 ("accumulation-based service " + data
->currentName
2639 + " duplicate direct base service " + name
));
2643 v.emplace_back
(name
, annotations
($1));
2647 serviceInterfaceBase:
2648 deprecated_opt flagSection_opt TOK_INTERFACE name
';'
2650 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
2651 OUString name
(convertName
($4));
2652 rtl
::Reference
<unoidl
::detail
::SourceProviderAccumulationBasedServiceEntityPad
> pad
(
2653 getCurrentPad
<unoidl
::detail
::SourceProviderAccumulationBasedServiceEntityPad
>(
2655 if
(($2 & ~unoidl
::detail
::FLAG_OPTIONAL
) != 0) {
2658 u
"interface base can only be flagged as [optional]"_ustr
);
2661 bool opt
= ($2 & unoidl
::detail
::FLAG_OPTIONAL
) != 0;
2662 unoidl
::detail
::SourceProviderEntity
const * p
;
2663 if
(findEntity
(@
4, yyscanner
, data
, false
, &name
, &p
, nullptr
, nullptr
)
2668 bool ifcBase
= false
;
2669 bool pubBase
= false
;
2672 case unoidl
::detail
::SourceProviderEntity
::KIND_INTERFACE_DECL
:
2676 case unoidl
::detail
::SourceProviderEntity
::KIND_PUBLISHED_INTERFACE_DECL
:
2682 && (p
->entity
->getSort
()
2683 == unoidl
::Entity
::SORT_INTERFACE_TYPE
))
2686 pubBase
= static_cast
<unoidl
::InterfaceTypeEntity
*>(
2687 p
->entity.get
())->isPublished
();
2695 ("accumulation-based service " + data
->currentName
2696 + " direct base interface " + name
2697 + " does not resolve to an interface type"));
2700 if
(data
->publishedContext
&& !opt
&& !pubBase
) {
2703 ("published accumulation-based service " + data
->currentName
2704 + " direct base interface " + name
+ " is unpublished"));
2707 std
::vector
<unoidl
::AnnotatedReference
> & v
(
2709 ? pad
->directOptionalBaseInterfaces
2710 : pad
->directMandatoryBaseInterfaces
);
2711 for
(const auto
& i
: v
) {
2712 if
(name
== i.name
) {
2715 ("accumulation-based service " + data
->currentName
2716 + " duplicate direct base interface " + name
));
2720 v.emplace_back
(name
, annotations
($1));
2725 deprecated_opt flagSection type identifier
';'
2727 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
2728 unoidl
::detail
::SourceProviderType t
(*$3);
2730 OUString id
(convertName
($4));
2731 if
(($2 & unoidl
::detail
::FLAG_PROPERTY
) == 0) {
2734 (u
"accumulation-based service property must be flagged as"
2735 " [property]"_ustr
));
2739 & ~
(unoidl
::detail
::FLAG_BOUND | unoidl
::detail
::FLAG_CONSTRAINED
2740 | unoidl
::detail
::FLAG_MAYBEAMBIGUOUS
2741 | unoidl
::detail
::FLAG_MAYBEDEFAULT
2742 | unoidl
::detail
::FLAG_MAYBEVOID | unoidl
::detail
::FLAG_OPTIONAL
2743 | unoidl
::detail
::FLAG_PROPERTY | unoidl
::detail
::FLAG_READONLY
2744 | unoidl
::detail
::FLAG_REMOVABLE
2745 | unoidl
::detail
::FLAG_TRANSIENT
))
2750 (u
"accumulation-based service property can only be flagged as"
2751 " [property, bound, constrained, maybeambiguous, maybedefault,"
2752 " maybevoid, optional, readonly, removable, transient]"_ustr
));
2756 if
(($2 & unoidl
::detail
::FLAG_BOUND
) != 0) {
2757 att |
= unoidl
::AccumulationBasedServiceEntity
::Property
::ATTRIBUTE_BOUND
;
2759 if
(($2 & unoidl
::detail
::FLAG_CONSTRAINED
) != 0) {
2760 att |
= unoidl
::AccumulationBasedServiceEntity
::Property
::ATTRIBUTE_CONSTRAINED
;
2762 if
(($2 & unoidl
::detail
::FLAG_MAYBEAMBIGUOUS
) != 0) {
2763 att |
= unoidl
::AccumulationBasedServiceEntity
::Property
::ATTRIBUTE_MAYBE_AMBIGUOUS
;
2765 if
(($2 & unoidl
::detail
::FLAG_MAYBEDEFAULT
) != 0) {
2766 att |
= unoidl
::AccumulationBasedServiceEntity
::Property
::ATTRIBUTE_MAYBE_DEFAULT
;
2768 if
(($2 & unoidl
::detail
::FLAG_MAYBEVOID
) != 0) {
2769 att |
= unoidl
::AccumulationBasedServiceEntity
::Property
::ATTRIBUTE_MAYBE_VOID
;
2771 if
(($2 & unoidl
::detail
::FLAG_OPTIONAL
) != 0) {
2772 att |
= unoidl
::AccumulationBasedServiceEntity
::Property
::ATTRIBUTE_OPTIONAL
;
2774 if
(($2 & unoidl
::detail
::FLAG_READONLY
) != 0) {
2775 att |
= unoidl
::AccumulationBasedServiceEntity
::Property
::ATTRIBUTE_READ_ONLY
;
2777 if
(($2 & unoidl
::detail
::FLAG_REMOVABLE
) != 0) {
2778 att |
= unoidl
::AccumulationBasedServiceEntity
::Property
::ATTRIBUTE_REMOVABLE
;
2780 if
(($2 & unoidl
::detail
::FLAG_TRANSIENT
) != 0) {
2781 att |
= unoidl
::AccumulationBasedServiceEntity
::Property
::ATTRIBUTE_TRANSIENT
;
2784 case unoidl
::detail
::SourceProviderType
::TYPE_VOID
:
2785 case unoidl
::detail
::SourceProviderType
::TYPE_EXCEPTION
:
2788 ("illegal accumulation-based service " + data
->currentName
2789 + " direct property " + id
+ " type"));
2795 rtl
::Reference
<unoidl
::detail
::SourceProviderAccumulationBasedServiceEntityPad
>
2796 pad
(getCurrentPad
<unoidl
::detail
::SourceProviderAccumulationBasedServiceEntityPad
>(
2798 for
(const auto
& i
: pad
->directProperties
) {
2802 ("accumulation-based service " + data
->currentName
2803 + " duplicate direct property " + id
));
2807 pad
->directProperties.emplace_back
(
2809 unoidl
::AccumulationBasedServiceEntity
::Property
::Attributes
(att
),
2814 interfaceBasedSingletonDefn:
2815 deprecated_opt published_opt TOK_SINGLETON identifier singleInheritance
';'
2817 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
2818 data
->publishedContext
= $2;
2819 OUString name
(convertToFullName
(data
, $4));
2820 OUString base
(convertName
($5));
2821 unoidl
::detail
::SourceProviderEntity
const * p
;
2822 if
(findEntity
(@
5, yyscanner
, data
, false
, &base
, &p
, nullptr
, nullptr
)
2827 bool ifcBase
= false
;
2828 bool pubBase
= false
;
2831 case unoidl
::detail
::SourceProviderEntity
::KIND_INTERFACE_DECL
:
2835 case unoidl
::detail
::SourceProviderEntity
::KIND_PUBLISHED_INTERFACE_DECL
:
2841 && (p
->entity
->getSort
()
2842 == unoidl
::Entity
::SORT_INTERFACE_TYPE
))
2845 pubBase
= static_cast
<unoidl
::InterfaceTypeEntity
*>(
2846 p
->entity.get
())->isPublished
();
2854 ("interface-based singleton " + name
+ " base " + base
2855 + " does not resolve to an interface type"));
2858 if
($2 && !pubBase
) {
2861 ("published interface-based singleton " + name
+ " base " + base
2862 + " is unpublished"));
2865 if
(!data
->entities.emplace
(
2867 unoidl
::detail
::SourceProviderEntity
(
2868 unoidl
::detail
::SourceProviderEntity
::KIND_LOCAL
,
2869 new unoidl
::InterfaceBasedSingletonEntity
(
2870 $2, base
, annotations
($1)))).
2873 error(@
4, yyscanner
, "multiple entities named " + name
);
2876 clearCurrentState
(data
);
2880 serviceBasedSingletonDefn:
2881 deprecated_opt published_opt TOK_SINGLETON identifier
'{' TOK_SERVICE name
';'
2884 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
2885 data
->publishedContext
= $2;
2886 OUString name
(convertToFullName
(data
, $4));
2887 OUString base
(convertName
($7));
2888 unoidl
::detail
::SourceProviderEntity
const * p
;
2889 if
(findEntity
(@
7, yyscanner
, data
, false
, &base
, &p
, nullptr
, nullptr
)
2896 ||
(p
->entity
->getSort
()
2897 != unoidl
::Entity
::SORT_ACCUMULATION_BASED_SERVICE
))
2901 ("service-based singleton " + name
+ " base " + base
2902 + " does not resolve to an accumulation-based service"));
2906 && !static_cast
<unoidl
::AccumulationBasedServiceEntity
*>(
2907 p
->entity.get
())->isPublished
())
2911 ("published service-based singleton " + name
+ " base " + base
2912 + " is unpublished"));
2915 if
(!data
->entities.emplace
(
2917 unoidl
::detail
::SourceProviderEntity
(
2918 unoidl
::detail
::SourceProviderEntity
::KIND_LOCAL
,
2919 new unoidl
::ServiceBasedSingletonEntity
(
2920 $2, base
, annotations
($1)))).
2923 error(@
4, yyscanner
, "multiple entities named " + name
);
2926 clearCurrentState
(data
);
2930 singleInheritance_opt:
2932 |
/* empty */ { $$
= nullptr
; }
2935 singleInheritance: ':' name
{ $$
= $2; }
2940 |
/* empty */ { $$
= nullptr
; }
2943 exceptionSpec: TOK_RAISES
'(' exceptions
')' { $$
= $3; }
2949 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
2950 OUString name
(convertName
($3));
2951 unoidl
::detail
::SourceProviderEntity
const * p
;
2952 if
(findEntity
(@
3, yyscanner
, data
, false
, &name
, &p
, nullptr
, nullptr
)
2955 delete
$1; /* see commented-out %destructor above */
2960 ||
(p
->entity
->getSort
() != unoidl
::Entity
::SORT_EXCEPTION_TYPE
))
2962 delete
$1; /* see commented-out %destructor above */
2965 ("exception " + name
+ " does not resolve to an exception type"));
2968 if
(data
->publishedContext
2969 && !(static_cast
<unoidl
::ExceptionTypeEntity
*>(p
->entity.get
())
2972 delete
$1; /* see commented-out %destructor above */
2975 ("unpublished exception " + name
+ " used in published context"));
2978 if
(std
::find
($1->begin
(), $1->end
(), name
) != $1->end
()) {
2979 delete
$1; /* see commented-out %destructor above */
2981 @
3, yyscanner
, ("exception " + name
+ " listed more than once"));
2984 $1->push_back
(name
);
2989 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
2990 OUString name
(convertName
($1));
2991 unoidl
::detail
::SourceProviderEntity
const * p
;
2992 if
(findEntity
(@
1, yyscanner
, data
, false
, &name
, &p
, nullptr
, nullptr
)
2999 ||
(p
->entity
->getSort
() != unoidl
::Entity
::SORT_EXCEPTION_TYPE
))
3003 ("exception " + name
+ " does not resolve to an exception type"));
3006 if
(data
->publishedContext
3007 && !(static_cast
<unoidl
::ExceptionTypeEntity
*>(p
->entity.get
())
3012 ("unpublished exception " + name
+ " used in published context"));
3015 $$
= new std
::vector
<OUString
>; $$
->push_back
(name
);
3020 deprecated_opt
/*ignored*/ published_opt TOK_INTERFACE identifier
';'
3022 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
3023 data
->publishedContext
= $2;
3024 OUString name
(convertToFullName
(data
, $4));
3025 std
::pair
<std
::map
<OUString
, unoidl
::detail
::SourceProviderEntity
>::iterator
, bool> p
(
3026 data
->entities.emplace
(
3028 unoidl
::detail
::SourceProviderEntity
(
3030 ? unoidl
::detail
::SourceProviderEntity
::KIND_PUBLISHED_INTERFACE_DECL
3031 : unoidl
::detail
::SourceProviderEntity
::KIND_INTERFACE_DECL
)));
3033 switch
(p.first
->second.kind
) {
3034 case unoidl
::detail
::SourceProviderEntity
::KIND_INTERFACE_DECL
:
3036 p.first
->second.kind
3037 = unoidl
::detail
::SourceProviderEntity
::KIND_PUBLISHED_INTERFACE_DECL
;
3040 case unoidl
::detail
::SourceProviderEntity
::KIND_PUBLISHED_INTERFACE_DECL
:
3043 assert
(p.first
->second.entity.is
());
3044 if
(p.first
->second.entity
->getSort
()
3045 != unoidl
::Entity
::SORT_INTERFACE_TYPE
)
3049 "multiple entities named " + data
->currentName
);
3053 && !static_cast
<unoidl
::InterfaceTypeEntity
*>(
3054 p.first
->second.entity.get
())->isPublished
())
3058 ("published interface type declaration "
3059 + data
->currentName
+ " has been defined unpublished"));
3064 clearCurrentState
(data
);
3069 TOK_PUBLISHED
{ $$
= true
; }
3070 |
/* empty */ { $$
= false
; }
3075 |
/* empty */ { $$
= unoidl
::detail
::SourceProviderFlags
(0); }
3078 flagSection: '[' flags
']' { $$
= $2; }
3084 if
(($1 & $3) != 0) {
3085 error(@
3, yyscanner
, "duplicate flag " + flagName
($3));
3088 $$
= unoidl
::detail
::SourceProviderFlags
($1 |
$3);
3094 TOK_ATTRIBUTE
{ $$
= unoidl
::detail
::FLAG_ATTRIBUTE
; }
3095 | TOK_BOUND
{ $$
= unoidl
::detail
::FLAG_BOUND
; }
3096 | TOK_CONSTRAINED
{ $$
= unoidl
::detail
::FLAG_CONSTRAINED
; }
3097 | TOK_MAYBEAMBIGUOUS
{ $$
= unoidl
::detail
::FLAG_MAYBEAMBIGUOUS
; }
3098 | TOK_MAYBEDEFAULT
{ $$
= unoidl
::detail
::FLAG_MAYBEDEFAULT
; }
3099 | TOK_MAYBEVOID
{ $$
= unoidl
::detail
::FLAG_MAYBEVOID
; }
3100 | TOK_OPTIONAL
{ $$
= unoidl
::detail
::FLAG_OPTIONAL
; }
3101 | TOK_PROPERTY
{ $$
= unoidl
::detail
::FLAG_PROPERTY
; }
3102 | TOK_READONLY
{ $$
= unoidl
::detail
::FLAG_READONLY
; }
3103 | TOK_REMOVABLE
{ $$
= unoidl
::detail
::FLAG_REMOVABLE
; }
3104 | TOK_TRANSIENT
{ $$
= unoidl
::detail
::FLAG_TRANSIENT
; }
3113 if
(!coerce
(@
1, yyscanner
, &$1, &$3)) {
3117 case unoidl
::detail
::SourceProviderExpr
::TYPE_INT
:
3118 $$
= unoidl
::detail
::SourceProviderExpr
::Int
($1.ival |
$3.ival
);
3120 case unoidl
::detail
::SourceProviderExpr
::TYPE_UINT
:
3121 $$
= unoidl
::detail
::SourceProviderExpr
::Uint
($1.uval |
$3.uval
);
3124 error(@
1, yyscanner
, u
"arguments of non-integer type to \"|\""_ustr
);
3135 if
(!coerce
(@
1, yyscanner
, &$1, &$3)) {
3139 case unoidl
::detail
::SourceProviderExpr
::TYPE_INT
:
3140 $$
= unoidl
::detail
::SourceProviderExpr
::Int
($1.ival ^
$3.ival
);
3142 case unoidl
::detail
::SourceProviderExpr
::TYPE_UINT
:
3143 $$
= unoidl
::detail
::SourceProviderExpr
::Uint
($1.uval ^
$3.uval
);
3146 error(@
1, yyscanner
, u
"arguments of non-integer type to \"^\""_ustr
);
3155 andExpr
'&' shiftExpr
3157 if
(!coerce
(@
1, yyscanner
, &$1, &$3)) {
3161 case unoidl
::detail
::SourceProviderExpr
::TYPE_INT
:
3162 $$
= unoidl
::detail
::SourceProviderExpr
::Int
($1.ival
& $3.ival
);
3164 case unoidl
::detail
::SourceProviderExpr
::TYPE_UINT
:
3165 $$
= unoidl
::detail
::SourceProviderExpr
::Uint
($1.uval
& $3.uval
);
3168 error(@
1, yyscanner
, u
"arguments of non-integer type to \"&\""_ustr
);
3177 shiftExpr TOK_LEFTSHIFT addExpr
3181 case unoidl
::detail
::SourceProviderExpr
::TYPE_INT
:
3182 if
($3.ival
< 0 ||
$3.ival
> 63) {
3185 ("out-of-range shift argument " + OUString
::number
($3.ival
)
3189 n
= static_cast
<int>($3.ival
);
3191 case unoidl
::detail
::SourceProviderExpr
::TYPE_UINT
:
3195 ("out-of-range shift argument " + OUString
::number
($3.uval
)
3199 n
= static_cast
<int>($3.uval
);
3202 error(@
3, yyscanner
, u
"right argument of non-integer type to \"<<\""_ustr
);
3206 case unoidl
::detail
::SourceProviderExpr
::TYPE_INT
:
3210 ("cannot left-shift negative argument "
3211 + OUString
::number
($1.ival
)));
3214 $$
= unoidl
::detail
::SourceProviderExpr
::Int
($1.ival
<< n
);
3216 case unoidl
::detail
::SourceProviderExpr
::TYPE_UINT
:
3217 $$
= unoidl
::detail
::SourceProviderExpr
::Uint
($1.uval
<< n
);
3220 error(@
1, yyscanner
, u
"left argument of non-integer type to \"<<\""_ustr
);
3225 | shiftExpr TOK_RIGHTSHIFT addExpr
3229 case unoidl
::detail
::SourceProviderExpr
::TYPE_INT
:
3230 if
($3.ival
< 0 ||
$3.ival
> 63) {
3233 ("out-of-range shift argument " + OUString
::number
($3.ival
)
3237 n
= static_cast
<int>($3.ival
);
3239 case unoidl
::detail
::SourceProviderExpr
::TYPE_UINT
:
3243 ("out-of-range shift argument " + OUString
::number
($3.uval
)
3247 n
= static_cast
<int>($3.uval
);
3250 error(@
3, yyscanner
, u
"right argument of non-integer type to \">>\""_ustr
);
3255 case unoidl
::detail
::SourceProviderExpr
::TYPE_INT
:
3256 $$
= unoidl
::detail
::SourceProviderExpr
::Int
($1.ival
>> n
);
3258 case unoidl
::detail
::SourceProviderExpr
::TYPE_UINT
:
3259 $$
= unoidl
::detail
::SourceProviderExpr
::Uint
($1.uval
>> n
);
3262 error(@
1, yyscanner
, u
"left argument of non-integer type to \">>\""_ustr
);
3271 addExpr
'+' multExpr
3273 if
(!coerce
(@
1, yyscanner
, &$1, &$3)) {
3277 case unoidl
::detail
::SourceProviderExpr
::TYPE_BOOL
:
3278 error(@
1, yyscanner
, u
"arguments of boolean type to binary \"+\""_ustr
);
3281 case unoidl
::detail
::SourceProviderExpr
::TYPE_INT
:
3282 $$
= unoidl
::detail
::SourceProviderExpr
::Int
($1.ival
+ $3.ival
); //TODO: overflow
3284 case unoidl
::detail
::SourceProviderExpr
::TYPE_UINT
:
3285 $$
= unoidl
::detail
::SourceProviderExpr
::Uint
($1.uval
+ $3.uval
); //TODO: overflow
3287 case unoidl
::detail
::SourceProviderExpr
::TYPE_FLOAT
:
3288 $$
= unoidl
::detail
::SourceProviderExpr
::Float
($1.fval
+ $3.fval
);
3292 | addExpr
'-' multExpr
3294 if
(!coerce
(@
1, yyscanner
, &$1, &$3)) {
3298 case unoidl
::detail
::SourceProviderExpr
::TYPE_BOOL
:
3299 error(@
1, yyscanner
, u
"arguments of boolean type to binary \"-\""_ustr
);
3302 case unoidl
::detail
::SourceProviderExpr
::TYPE_INT
:
3303 $$
= unoidl
::detail
::SourceProviderExpr
::Int
($1.ival
- $3.ival
); //TODO: overflow
3305 case unoidl
::detail
::SourceProviderExpr
::TYPE_UINT
:
3306 $$
= unoidl
::detail
::SourceProviderExpr
::Uint
($1.uval
- $3.uval
); //TODO: overflow
3308 case unoidl
::detail
::SourceProviderExpr
::TYPE_FLOAT
:
3309 $$
= unoidl
::detail
::SourceProviderExpr
::Float
($1.fval
- $3.fval
);
3317 multExpr
'*' unaryExpr
3319 if
(!coerce
(@
1, yyscanner
, &$1, &$3)) {
3323 case unoidl
::detail
::SourceProviderExpr
::TYPE_BOOL
:
3324 error(@
1, yyscanner
, u
"arguments of boolean type to \"*\""_ustr
);
3327 case unoidl
::detail
::SourceProviderExpr
::TYPE_INT
:
3328 $$
= unoidl
::detail
::SourceProviderExpr
::Int
($1.ival
* $3.ival
); //TODO: overflow
3330 case unoidl
::detail
::SourceProviderExpr
::TYPE_UINT
:
3331 $$
= unoidl
::detail
::SourceProviderExpr
::Uint
($1.uval
* $3.uval
); //TODO: overflow
3333 case unoidl
::detail
::SourceProviderExpr
::TYPE_FLOAT
:
3334 $$
= unoidl
::detail
::SourceProviderExpr
::Float
($1.fval
* $3.fval
);
3338 | multExpr
'/' unaryExpr
3340 if
(!coerce
(@
1, yyscanner
, &$1, &$3)) {
3344 case unoidl
::detail
::SourceProviderExpr
::TYPE_BOOL
:
3345 error(@
1, yyscanner
, u
"arguments of boolean type to \"/\""_ustr
);
3348 case unoidl
::detail
::SourceProviderExpr
::TYPE_INT
:
3350 error(@
3, yyscanner
, u
"cannot divide by zero"_ustr
);
3353 $$
= unoidl
::detail
::SourceProviderExpr
::Int
($1.ival
/ $3.ival
);
3355 case unoidl
::detail
::SourceProviderExpr
::TYPE_UINT
:
3357 error(@
3, yyscanner
, u
"cannot divide by zero"_ustr
);
3360 $$
= unoidl
::detail
::SourceProviderExpr
::Uint
($1.uval
/ $3.uval
);
3362 case unoidl
::detail
::SourceProviderExpr
::TYPE_FLOAT
:
3364 error(@
3, yyscanner
, u
"cannot divide by zero"_ustr
);
3367 $$
= unoidl
::detail
::SourceProviderExpr
::Float
($1.fval
- $3.fval
);
3371 | multExpr
'%' unaryExpr
3373 if
(!coerce
(@
1, yyscanner
, &$1, &$3)) {
3377 case unoidl
::detail
::SourceProviderExpr
::TYPE_INT
:
3379 error(@
3, yyscanner
, u
"cannot divide by zero"_ustr
);
3382 $$
= unoidl
::detail
::SourceProviderExpr
::Int
($1.ival %
$3.ival
);
3384 case unoidl
::detail
::SourceProviderExpr
::TYPE_UINT
:
3386 error(@
3, yyscanner
, u
"cannot divide by zero"_ustr
);
3389 $$
= unoidl
::detail
::SourceProviderExpr
::Uint
($1.uval %
$3.uval
);
3392 error(@
1, yyscanner
, u
"arguments of non-integer type to \"%\""_ustr
);
3403 if
($2.type
== unoidl
::detail
::SourceProviderExpr
::TYPE_BOOL
) {
3404 error(@
2, yyscanner
, u
"argument of boolean type to unary \"+\""_ustr
);
3412 case unoidl
::detail
::SourceProviderExpr
::TYPE_BOOL
:
3413 error(@
2, yyscanner
, u
"argument of boolean type to unary \"-\""_ustr
);
3416 case unoidl
::detail
::SourceProviderExpr
::TYPE_INT
:
3417 if
($2.ival
== SAL_MIN_INT64
) {
3418 error(@
2, yyscanner
, u
"cannot negate -2^63"_ustr
);
3421 $$
= unoidl
::detail
::SourceProviderExpr
::Int
(-$2.ival
);
3423 case unoidl
::detail
::SourceProviderExpr
::TYPE_UINT
:
3424 if
($2.uval
== SAL_CONST_UINT64
(0x8000000000000000)) {
3425 $$
= unoidl
::detail
::SourceProviderExpr
::Int
(SAL_MIN_INT64
);
3427 if
($2.uval
> SAL_MAX_INT64
) {
3430 ("cannot negate out-of-range value "
3431 + OUString
::number
($2.uval
)));
3434 $$
= unoidl
::detail
::SourceProviderExpr
::Int
(
3435 -static_cast
<sal_Int64
>($2.uval
));
3438 case unoidl
::detail
::SourceProviderExpr
::TYPE_FLOAT
:
3439 $$
= unoidl
::detail
::SourceProviderExpr
::Float
(-$2.fval
);
3446 case unoidl
::detail
::SourceProviderExpr
::TYPE_INT
:
3447 $$
= unoidl
::detail
::SourceProviderExpr
::Int
(~
$2.ival
);
3449 case unoidl
::detail
::SourceProviderExpr
::TYPE_UINT
:
3450 $$
= unoidl
::detail
::SourceProviderExpr
::Uint
(~
$2.uval
);
3453 error(@
2, yyscanner
, u
"argument of non-integer type to \"~\""_ustr
);
3462 '(' expr
')' { $$
= $2; }
3463 | TOK_FALSE
{ $$
= unoidl
::detail
::SourceProviderExpr
::Bool
(false
); }
3464 | TOK_TRUE
{ $$
= unoidl
::detail
::SourceProviderExpr
::Bool
(true
); }
3465 | TOK_INTEGER
{ $$
= unoidl
::detail
::SourceProviderExpr
::Uint
($1); }
3466 | TOK_FLOATING
{ $$
= unoidl
::detail
::SourceProviderExpr
::Float
($1); }
3469 OUString name
(convertName
($1));
3470 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
3471 unoidl
::ConstantValue v
(false
); // dummy value
3474 sal_Int32 i
= name.lastIndexOf
('.');
3476 rtl
::Reference
<unoidl
::detail
::SourceProviderEntityPad
> pad
(
3477 getCurrentEntity
(data
)->pad
);
3478 unoidl
::detail
::SourceProviderEnumTypeEntityPad
* p1
= dynamic_cast
<
3479 unoidl
::detail
::SourceProviderEnumTypeEntityPad
*>(pad.get
());
3480 if
(p1
!= nullptr
) {
3481 for
(const auto
& j
: p1
->members
) {
3482 if
(j.name
== name
) {
3483 v
= unoidl
::ConstantValue
(j.value
);
3489 unoidl
::detail
::SourceProviderConstantGroupEntityPad
* p2
3491 unoidl
::detail
::SourceProviderConstantGroupEntityPad
*>(
3493 if
(p2
!= nullptr
) {
3494 for
(const auto
& j
: p2
->members
) {
3495 if
(j.name
== name
) {
3504 OUString scope
(name.copy
(0, i
));
3505 unoidl
::detail
::SourceProviderEntity
const * ent
;
3507 @
1, yyscanner
, data
, false
, &scope
, &ent
, nullptr
, nullptr
)
3512 if
(ent
!= nullptr
) {
3513 std
::u16string_view id
(name.subView
(i
+ 1));
3514 // No need to check for enum members here, as they cannot be
3515 // referenced in expressions by qualified name (TODO: is that true?):
3516 if
(ent
->entity.is
()) {
3517 if
(ent
->entity
->getSort
()
3518 == unoidl
::Entity
::SORT_CONSTANT_GROUP
)
3520 std
::vector
<unoidl
::ConstantGroupEntity
::Member
> const &
3522 static_cast
<unoidl
::ConstantGroupEntity
*>(
3523 ent
->entity.get
())->
3525 for
(auto
& j
: mems
) {
3530 = !static_cast
<unoidl
::ConstantGroupEntity
*>(
3531 ent
->entity.get
())->isPublished
();
3536 } else if
(ent
->pad.is
()) {
3537 unoidl
::detail
::SourceProviderConstantGroupEntityPad
* pad
3539 unoidl
::detail
::SourceProviderConstantGroupEntityPad
*>(
3541 if
(pad
!= nullptr
) {
3542 for
(const auto
& j
: pad
->members
) {
3546 unpub
= !ent
->pad
->isPublished
();
3558 + (" does not resolve to neither a constant nor an unqualified"
3562 if
(data
->publishedContext
&& unpub
) {
3565 "unpublished value " + name
+ " used in published context");
3569 case unoidl
::ConstantValue
::TYPE_BOOLEAN
:
3570 $$
= unoidl
::detail
::SourceProviderExpr
::Bool
(v.booleanValue
);
3572 case unoidl
::ConstantValue
::TYPE_BYTE
:
3573 $$
= unoidl
::detail
::SourceProviderExpr
::Int
(v.byteValue
);
3575 case unoidl
::ConstantValue
::TYPE_SHORT
:
3576 $$
= unoidl
::detail
::SourceProviderExpr
::Int
(v.shortValue
);
3578 case unoidl
::ConstantValue
::TYPE_UNSIGNED_SHORT
:
3579 $$
= unoidl
::detail
::SourceProviderExpr
::Uint
(v.unsignedShortValue
);
3581 case unoidl
::ConstantValue
::TYPE_LONG
:
3582 $$
= unoidl
::detail
::SourceProviderExpr
::Int
(v.longValue
);
3584 case unoidl
::ConstantValue
::TYPE_UNSIGNED_LONG
:
3585 $$
= unoidl
::detail
::SourceProviderExpr
::Uint
(v.unsignedLongValue
);
3587 case unoidl
::ConstantValue
::TYPE_HYPER
:
3588 $$
= unoidl
::detail
::SourceProviderExpr
::Int
(v.hyperValue
);
3590 case unoidl
::ConstantValue
::TYPE_UNSIGNED_HYPER
:
3591 $$
= unoidl
::detail
::SourceProviderExpr
::Uint
(v.unsignedHyperValue
);
3593 case unoidl
::ConstantValue
::TYPE_FLOAT
:
3594 $$
= unoidl
::detail
::SourceProviderExpr
::Float
(v.floatValue
);
3596 case unoidl
::ConstantValue
::TYPE_DOUBLE
:
3597 $$
= unoidl
::detail
::SourceProviderExpr
::Float
(v.doubleValue
);
3604 typeArguments
',' type
3606 unoidl
::detail
::SourceProviderType t
(*$3);
3608 if
(!checkTypeArgument
(@
3, yyscanner
, t
)) {
3609 delete
$1; /* see commented-out %destructor above */
3617 unoidl
::detail
::SourceProviderType t
(*$1);
3619 if
(!checkTypeArgument
(@
1, yyscanner
, t
)) {
3622 $$
= new std
::vector
<unoidl
::detail
::SourceProviderType
>;
3630 $$
= new unoidl
::detail
::SourceProviderType
(
3631 unoidl
::detail
::SourceProviderType
::TYPE_VOID
);
3635 $$
= new unoidl
::detail
::SourceProviderType
(
3636 unoidl
::detail
::SourceProviderType
::TYPE_BOOLEAN
);
3640 $$
= new unoidl
::detail
::SourceProviderType
(
3641 unoidl
::detail
::SourceProviderType
::TYPE_BYTE
);
3645 $$
= new unoidl
::detail
::SourceProviderType
(
3646 unoidl
::detail
::SourceProviderType
::TYPE_SHORT
);
3648 | TOK_UNSIGNED TOK_SHORT
3650 $$
= new unoidl
::detail
::SourceProviderType
(
3651 unoidl
::detail
::SourceProviderType
::TYPE_UNSIGNED_SHORT
);
3655 $$
= new unoidl
::detail
::SourceProviderType
(
3656 unoidl
::detail
::SourceProviderType
::TYPE_LONG
);
3658 | TOK_UNSIGNED TOK_LONG
3660 $$
= new unoidl
::detail
::SourceProviderType
(
3661 unoidl
::detail
::SourceProviderType
::TYPE_UNSIGNED_LONG
);
3665 $$
= new unoidl
::detail
::SourceProviderType
(
3666 unoidl
::detail
::SourceProviderType
::TYPE_HYPER
);
3668 | TOK_UNSIGNED TOK_HYPER
3670 $$
= new unoidl
::detail
::SourceProviderType
(
3671 unoidl
::detail
::SourceProviderType
::TYPE_UNSIGNED_HYPER
);
3675 $$
= new unoidl
::detail
::SourceProviderType
(
3676 unoidl
::detail
::SourceProviderType
::TYPE_FLOAT
);
3680 $$
= new unoidl
::detail
::SourceProviderType
(
3681 unoidl
::detail
::SourceProviderType
::TYPE_DOUBLE
);
3685 $$
= new unoidl
::detail
::SourceProviderType
(
3686 unoidl
::detail
::SourceProviderType
::TYPE_CHAR
);
3690 $$
= new unoidl
::detail
::SourceProviderType
(
3691 unoidl
::detail
::SourceProviderType
::TYPE_STRING
);
3695 $$
= new unoidl
::detail
::SourceProviderType
(
3696 unoidl
::detail
::SourceProviderType
::TYPE_TYPE
);
3700 $$
= new unoidl
::detail
::SourceProviderType
(
3701 unoidl
::detail
::SourceProviderType
::TYPE_ANY
);
3703 | TOK_SEQUENCE
'<' type
'>'
3706 case unoidl
::detail
::SourceProviderType
::TYPE_VOID
:
3707 case unoidl
::detail
::SourceProviderType
::TYPE_EXCEPTION
:
3708 case unoidl
::detail
::SourceProviderType
::TYPE_PARAMETER
: //TODO?
3709 error(@
3, yyscanner
, u
"illegal sequence type component type"_ustr
);
3715 $$
= new unoidl
::detail
::SourceProviderType
($3);
3720 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
3721 OUString name
(convertName
($1));
3723 if
(name.indexOf
('.') == -1 && !data
->currentName.isEmpty
()) {
3724 unoidl
::detail
::SourceProviderEntity
* ent
= getCurrentEntity
(data
);
3725 unoidl
::detail
::SourceProviderPolymorphicStructTypeTemplateEntityPad
*
3727 unoidl
::detail
::SourceProviderPolymorphicStructTypeTemplateEntityPad
*>(
3731 pad
->typeParameters.begin
(), pad
->typeParameters.end
(),
3733 != pad
->typeParameters.end
()))
3735 $$
= new unoidl
::detail
::SourceProviderType
(name
);
3740 unoidl
::detail
::SourceProviderEntity
const * ent
;
3741 unoidl
::detail
::SourceProviderType t
;
3743 @
1, yyscanner
, data
, false
, &name
, &ent
, nullptr
, &t
))
3749 $$
= new unoidl
::detail
::SourceProviderType
(t
);
3752 if
(ent
== nullptr
) {
3753 error(@
1, yyscanner
, "unknown entity " + name
);
3757 switch
(ent
->kind
) {
3758 case unoidl
::detail
::SourceProviderEntity
::KIND_LOCAL
:
3759 if
(ent
->pad.is
()) {
3760 if
(data
->publishedContext
&& !ent
->pad
->isPublished
()) {
3763 ("unpublished entity " + name
3764 + " used in published context"));
3767 if
(dynamic_cast
<unoidl
::detail
::SourceProviderEnumTypeEntityPad
*>(
3771 $$
= new unoidl
::detail
::SourceProviderType
(
3772 unoidl
::detail
::SourceProviderType
::TYPE_ENUM
,
3775 } else if
(dynamic_cast
<unoidl
::detail
::SourceProviderPlainStructTypeEntityPad
*>(
3779 $$
= new unoidl
::detail
::SourceProviderType
(
3780 unoidl
::detail
::SourceProviderType
::TYPE_PLAIN_STRUCT
,
3783 } else if
(dynamic_cast
<unoidl
::detail
::SourceProviderPolymorphicStructTypeTemplateEntityPad
*>(
3789 (("recursive reference to polymorphic struct type"
3793 } else if
(dynamic_cast
<unoidl
::detail
::SourceProviderExceptionTypeEntityPad
*>(
3797 $$
= new unoidl
::detail
::SourceProviderType
(
3798 unoidl
::detail
::SourceProviderType
::TYPE_EXCEPTION
,
3801 } else if
(dynamic_cast
<unoidl
::detail
::SourceProviderInterfaceTypeEntityPad
*>(
3805 $$
= new unoidl
::detail
::SourceProviderType
(
3806 unoidl
::detail
::SourceProviderType
::TYPE_INTERFACE
,
3812 assert
(ent
->entity.is
());
3814 case unoidl
::detail
::SourceProviderEntity
::KIND_EXTERNAL
:
3815 if
(data
->publishedContext
3816 && ent
->entity
->getSort
() != unoidl
::Entity
::SORT_MODULE
3817 && !static_cast
<unoidl
::PublishableEntity
*>(
3818 ent
->entity.get
())->isPublished
())
3822 ("unpublished entity " + name
3823 + " used in published context"));
3826 switch
(ent
->entity
->getSort
()) {
3827 case unoidl
::Entity
::SORT_ENUM_TYPE
:
3828 $$
= new unoidl
::detail
::SourceProviderType
(
3829 unoidl
::detail
::SourceProviderType
::TYPE_ENUM
, name
,
3833 case unoidl
::Entity
::SORT_PLAIN_STRUCT_TYPE
:
3834 $$
= new unoidl
::detail
::SourceProviderType
(
3835 unoidl
::detail
::SourceProviderType
::TYPE_PLAIN_STRUCT
,
3839 case unoidl
::Entity
::SORT_POLYMORPHIC_STRUCT_TYPE_TEMPLATE
:
3842 ("polymorphic struct type template " + name
3843 + " without type arguments"));
3846 case unoidl
::Entity
::SORT_EXCEPTION_TYPE
:
3847 $$
= new unoidl
::detail
::SourceProviderType
(
3848 unoidl
::detail
::SourceProviderType
::TYPE_EXCEPTION
,
3852 case unoidl
::Entity
::SORT_INTERFACE_TYPE
:
3853 $$
= new unoidl
::detail
::SourceProviderType
(
3854 unoidl
::detail
::SourceProviderType
::TYPE_INTERFACE
,
3858 case unoidl
::Entity
::SORT_TYPEDEF
:
3864 case unoidl
::detail
::SourceProviderEntity
::KIND_INTERFACE_DECL
:
3865 if
(data
->publishedContext
) {
3868 ("unpublished entity " + name
3869 + " used in published context"));
3873 case unoidl
::detail
::SourceProviderEntity
::KIND_PUBLISHED_INTERFACE_DECL
:
3874 $$
= new unoidl
::detail
::SourceProviderType
(
3875 unoidl
::detail
::SourceProviderType
::TYPE_INTERFACE
, name
,
3879 case unoidl
::detail
::SourceProviderEntity
::KIND_MODULE
:
3880 assert
(false
&& "this cannot happen");
3883 error(@
1, yyscanner
, "non-type entity " + name
);
3890 | name
'<' typeArguments
'>'
3892 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
3893 OUString name
(convertName
($1));
3894 std
::vector
<unoidl
::detail
::SourceProviderType
> args
(*$3);
3896 unoidl
::detail
::SourceProviderEntity
const * ent
;
3897 if
(findEntity
(@
1, yyscanner
, data
, false
, &name
, &ent
, nullptr
, nullptr
)
3902 if
(ent
== nullptr
) {
3903 error(@
1, yyscanner
, "unknown entity " + name
);
3907 switch
(ent
->kind
) {
3908 case unoidl
::detail
::SourceProviderEntity
::KIND_LOCAL
:
3909 if
(ent
->pad.is
()) {
3910 if
(dynamic_cast
<unoidl
::detail
::SourceProviderPolymorphicStructTypeTemplateEntityPad
*>(
3916 (("recursive reference to polymorphic struct type"
3923 assert
(ent
->entity.is
());
3925 case unoidl
::detail
::SourceProviderEntity
::KIND_EXTERNAL
:
3926 if
(ent
->entity
->getSort
()
3927 == unoidl
::Entity
::SORT_POLYMORPHIC_STRUCT_TYPE_TEMPLATE
)
3929 rtl
::Reference
<unoidl
::PolymorphicStructTypeTemplateEntity
> e
(
3930 static_cast
<unoidl
::PolymorphicStructTypeTemplateEntity
*>(
3931 ent
->entity.get
()));
3932 if
(args.size
() != e
->getTypeParameters
().size
()) {
3935 ("bad number of polymorphic struct type template " + name
3936 + " type arguments"));
3939 if
(data
->publishedContext
&& !e
->isPublished
()) {
3942 ("unpublished polymorphic struct type template " + name
3943 + " used in published context"));
3946 $$
= new unoidl
::detail
::SourceProviderType
(name
, ent
, std
::move
(args
));
3950 case unoidl
::detail
::SourceProviderEntity
::KIND_INTERFACE_DECL
:
3951 case unoidl
::detail
::SourceProviderEntity
::KIND_PUBLISHED_INTERFACE_DECL
:
3953 case unoidl
::detail
::SourceProviderEntity
::KIND_MODULE
:
3954 assert
(false
&& "this cannot happen");
3957 error(@
1, yyscanner
, "non-type entity " + name
);
3964 name TOK_COLONS identifier
{ *$1 += "." + *$3; delete
$3; $$
= $1; }
3965 | TOK_COLONS identifier
{ *$2 = "." + *$2; $$
= $2; }
3971 | TOK_GET
{ $$
= new OString
("get"_ostr
); }
3972 | TOK_PUBLISHED
{ $$
= new OString
("published"_ostr
); }
3973 | TOK_SET
{ $$
= new OString
("set"_ostr
); }
3977 TOK_DEPRECATED
{ $$
= true
; }
3978 |
/* empty */ { $$
= false
; }
3983 namespace unoidl
::detail
{
3985 OUString SourceProviderType
::getName
() const {
3986 if
(!typedefName.isEmpty
()) {
3990 case unoidl
::detail
::SourceProviderType
::TYPE_VOID
:
3991 return u
"void"_ustr
;
3992 case unoidl
::detail
::SourceProviderType
::TYPE_BOOLEAN
:
3993 return u
"boolean"_ustr
;
3994 case unoidl
::detail
::SourceProviderType
::TYPE_BYTE
:
3995 return u
"byte"_ustr
;
3996 case unoidl
::detail
::SourceProviderType
::TYPE_SHORT
:
3997 return u
"short"_ustr
;
3998 case unoidl
::detail
::SourceProviderType
::TYPE_UNSIGNED_SHORT
:
3999 return u
"unsigned short"_ustr
;
4000 case unoidl
::detail
::SourceProviderType
::TYPE_LONG
:
4001 return u
"long"_ustr
;
4002 case unoidl
::detail
::SourceProviderType
::TYPE_UNSIGNED_LONG
:
4003 return u
"unsigned long"_ustr
;
4004 case unoidl
::detail
::SourceProviderType
::TYPE_HYPER
:
4005 return u
"hyper"_ustr
;
4006 case unoidl
::detail
::SourceProviderType
::TYPE_UNSIGNED_HYPER
:
4007 return u
"unsigned hyper"_ustr
;
4008 case unoidl
::detail
::SourceProviderType
::TYPE_FLOAT
:
4009 return u
"float"_ustr
;
4010 case unoidl
::detail
::SourceProviderType
::TYPE_DOUBLE
:
4011 return u
"double"_ustr
;
4012 case unoidl
::detail
::SourceProviderType
::TYPE_CHAR
:
4013 return u
"char"_ustr
;
4014 case unoidl
::detail
::SourceProviderType
::TYPE_STRING
:
4015 return u
"string"_ustr
;
4016 case unoidl
::detail
::SourceProviderType
::TYPE_TYPE
:
4017 return u
"type"_ustr
;
4018 case unoidl
::detail
::SourceProviderType
::TYPE_ANY
:
4020 case unoidl
::detail
::SourceProviderType
::TYPE_SEQUENCE
:
4021 assert
(subtypes.size
() == 1);
4022 return
"[]" + subtypes.front
().getName
();
4023 case unoidl
::detail
::SourceProviderType
::TYPE_ENUM
:
4024 case unoidl
::detail
::SourceProviderType
::TYPE_PLAIN_STRUCT
:
4025 case unoidl
::detail
::SourceProviderType
::TYPE_EXCEPTION
:
4026 case unoidl
::detail
::SourceProviderType
::TYPE_INTERFACE
:
4027 case unoidl
::detail
::SourceProviderType
::TYPE_PARAMETER
:
4029 case unoidl
::detail
::SourceProviderType
::TYPE_INSTANTIATED_POLYMORPHIC_STRUCT
:
4031 OUStringBuffer n
(512);
4032 n.append
(name
+ "<");
4033 for
(auto i
(subtypes.begin
()); i
!= subtypes.end
(); ++i
) {
4034 if
(i
!= subtypes.begin
()) {
4037 n.append
(i
->getName
());
4039 return n.append
(">").makeStringAndClear
();
4042 assert
(false
&& "this cannot happen"); for
(;;) { std
::abort
(); }
4046 bool SourceProviderType
::equals
(SourceProviderType
const & other
) const {
4047 if
(type
!= other.type || name
!= other.name
4048 || subtypes.size
() != other.subtypes.size
())
4052 for
(auto i
(subtypes.begin
()), j
(other.subtypes.begin
());
4053 i
!= subtypes.end
(); ++i
, ++j
)
4055 if
(!i
->equals
(*j
)) {
4062 bool SourceProviderInterfaceTypeEntityPad
::addDirectBase
(
4063 YYLTYPE location
, yyscan_t yyscanner
, SourceProviderScannerData
* data
,
4064 DirectBase
const & base
, bool optional
)
4066 std
::set
<OUString
> seen
;
4067 if
(!(checkBaseClashes
(
4068 location
, yyscanner
, data
, base.name
, base.entity
, true
, optional
,
4071 location
, yyscanner
, data
, base.name
, base.name
, base.entity
,
4077 addOptionalBaseMembers
(
4078 location
, yyscanner
, data
, base.name
, base.entity
);
4080 (optional ? directOptionalBases
: directMandatoryBases
).push_back
(base
);
4084 bool SourceProviderInterfaceTypeEntityPad
::addDirectMember
(
4085 YYLTYPE location
, yyscan_t yyscanner
, SourceProviderScannerData
* data
,
4086 OUString
const & name
)
4088 assert
(data
!= nullptr
);
4089 if
(!checkMemberClashes
(location
, yyscanner
, data
, u
"", name
, true
)) {
4092 allMembers.emplace
(name
, Member
(data
->currentName
));
4096 bool SourceProviderInterfaceTypeEntityPad
::checkBaseClashes
(
4097 YYLTYPE location
, yyscan_t yyscanner
, SourceProviderScannerData
* data
,
4098 OUString
const & name
,
4099 rtl
::Reference
<unoidl
::InterfaceTypeEntity
> const & entity
, bool direct
,
4100 bool optional
, bool outerOptional
, std
::set
<OUString
> * seen
) const
4102 assert
(data
!= nullptr
);
4103 assert
(entity.is
());
4104 assert
(seen
!= nullptr
);
4105 if
(direct || optional || seen
->insert
(name
).second
) {
4106 std
::map
<OUString
, BaseKind
>::const_iterator i
(allBases.find
(name
));
4107 if
(i
!= allBases.end
()) {
4108 switch
(i
->second
) {
4109 case BASE_INDIRECT_OPTIONAL
:
4110 if
(direct
&& optional
) {
4112 location
, yyscanner
,
4113 ("interface type " + data
->currentName
4114 + " duplicate base " + name
));
4118 case BASE_DIRECT_OPTIONAL
:
4119 if
(direct ||
!outerOptional
) {
4121 location
, yyscanner
,
4122 ("interface type " + data
->currentName
4123 + " duplicate base " + name
));
4127 case BASE_INDIRECT_MANDATORY
:
4130 location
, yyscanner
,
4131 ("interface type " + data
->currentName
4132 + " duplicate base " + name
));
4136 case BASE_DIRECT_MANDATORY
:
4137 if
(direct ||
(!optional
&& !outerOptional
)) {
4139 location
, yyscanner
,
4140 ("interface type " + data
->currentName
4141 + " duplicate base " + name
));
4147 if
(direct ||
!optional
) {
4148 for
(auto
& j
: entity
->getDirectMandatoryBases
()) {
4149 OUString n
("." + j.name
);
4150 unoidl
::detail
::SourceProviderEntity
const * p
;
4152 location
, yyscanner
, data
, true
, &n
, &p
, nullptr
,
4158 if
(p
== nullptr ||
!p
->entity.is
()
4159 ||
(p
->entity
->getSort
()
4160 != unoidl
::Entity
::SORT_INTERFACE_TYPE
))
4163 location
, yyscanner
,
4164 ("inconsistent type manager: interface type "
4165 + data
->currentName
+ " base " + n
4166 + " does not resolve to an existing interface type"));
4169 if
(!checkBaseClashes
(
4170 location
, yyscanner
, data
, n
,
4171 static_cast
<unoidl
::InterfaceTypeEntity
*>(
4173 false
, false
, outerOptional
, seen
))
4178 for
(auto
& j
: entity
->getDirectOptionalBases
()) {
4179 OUString n
("." + j.name
);
4180 unoidl
::detail
::SourceProviderEntity
const * p
;
4182 location
, yyscanner
, data
, true
, &n
, &p
, nullptr
,
4188 if
(p
== nullptr ||
!p
->entity.is
()
4189 ||
(p
->entity
->getSort
()
4190 != unoidl
::Entity
::SORT_INTERFACE_TYPE
))
4193 location
, yyscanner
,
4194 ("inconsistent type manager: interface type "
4195 + data
->currentName
+ " base " + n
4196 + " does not resolve to an existing interface type"));
4199 if
(!checkBaseClashes
(
4200 location
, yyscanner
, data
, n
,
4201 static_cast
<unoidl
::InterfaceTypeEntity
*>(
4203 false
, true
, outerOptional
, seen
))
4208 for
(auto
& j
: entity
->getDirectAttributes
()) {
4209 if
(!checkMemberClashes
(
4210 location
, yyscanner
, data
, name
, j.name
,
4216 for
(auto
& j
: entity
->getDirectMethods
()) {
4217 if
(!checkMemberClashes
(
4218 location
, yyscanner
, data
, name
, j.name
,
4229 bool SourceProviderInterfaceTypeEntityPad
::checkMemberClashes
(
4230 YYLTYPE location
, yyscan_t yyscanner
, SourceProviderScannerData
* data
,
4231 std
::u16string_view interfaceName
, OUString
const & memberName
,
4232 bool checkOptional
) const
4234 std
::map
<OUString
, Member
>::const_iterator i
(allMembers.find
(memberName
));
4235 if
(i
!= allMembers.end
()) {
4236 if
(!i
->second.mandatory.isEmpty
()) {
4237 // For a direct member, interfaceName will be empty, so this will
4238 // catch two direct members with the same name:
4239 if
(i
->second.mandatory
!= interfaceName
) {
4241 location
, yyscanner
,
4242 ("interface type " + data
->currentName
4243 + " duplicate member " + memberName
));
4246 } else if
(checkOptional
) {
4247 for
(auto
& j
: i
->second.optional
) {
4248 if
(j
!= interfaceName
) {
4250 location
, yyscanner
,
4251 ("interface type " + data
->currentName
4252 + " duplicate member " + memberName
));
4261 bool SourceProviderInterfaceTypeEntityPad
::addBase
(
4262 YYLTYPE location
, yyscan_t yyscanner
, SourceProviderScannerData
* data
,
4263 OUString
const & directBaseName
, OUString
const & name
,
4264 rtl
::Reference
<unoidl
::InterfaceTypeEntity
> const & entity
, bool direct
,
4267 assert
(data
!= nullptr
);
4268 assert
(entity.is
());
4269 BaseKind kind
= optional
4270 ? direct ? BASE_DIRECT_OPTIONAL
: BASE_INDIRECT_OPTIONAL
4271 : direct ? BASE_DIRECT_MANDATORY
: BASE_INDIRECT_MANDATORY
;
4272 std
::pair
<std
::map
<OUString
, BaseKind
>::iterator
, bool> p
(
4273 allBases.emplace
(name
, kind
));
4274 bool seen
= !p.second
&& p.first
->second
>= BASE_INDIRECT_MANDATORY
;
4275 if
(!p.second
&& kind
> p.first
->second
) {
4276 p.first
->second
= kind
;
4278 if
(!optional
&& !seen
) {
4279 for
(auto
& i
: entity
->getDirectMandatoryBases
()) {
4280 OUString n
("." + i.name
);
4281 unoidl
::detail
::SourceProviderEntity
const * q
;
4283 location
, yyscanner
, data
, true
, &n
, &q
, nullptr
, nullptr
)
4288 if
(q
== nullptr ||
!q
->entity.is
()
4289 || q
->entity
->getSort
() != unoidl
::Entity
::SORT_INTERFACE_TYPE
)
4292 location
, yyscanner
,
4293 ("inconsistent type manager: interface type "
4294 + data
->currentName
+ " base " + n
4295 + " does not resolve to an existing interface type"));
4299 location
, yyscanner
, data
, directBaseName
, n
,
4300 static_cast
<unoidl
::InterfaceTypeEntity
*>(q
->entity.get
()),
4306 for
(auto
& i
: entity
->getDirectOptionalBases
())
4308 OUString n
("." + i.name
);
4309 unoidl
::detail
::SourceProviderEntity
const * q
;
4311 location
, yyscanner
, data
, true
, &n
, &q
, nullptr
, nullptr
)
4316 if
(q
== nullptr ||
!q
->entity.is
()
4317 || q
->entity
->getSort
() != unoidl
::Entity
::SORT_INTERFACE_TYPE
)
4320 location
, yyscanner
,
4321 ("inconsistent type manager: interface type "
4322 + data
->currentName
+ " base " + n
4323 + " does not resolve to an existing interface type"));
4327 location
, yyscanner
, data
, directBaseName
, n
,
4328 static_cast
<unoidl
::InterfaceTypeEntity
*>(q
->entity.get
()),
4334 for
(auto
& i
: entity
->getDirectAttributes
()) {
4335 allMembers.emplace
(i.name
, Member
(name
));
4337 for
(auto
& i
: entity
->getDirectMethods
()) {
4338 allMembers.emplace
(i.name
, Member
(name
));
4344 bool SourceProviderInterfaceTypeEntityPad
::addOptionalBaseMembers
(
4345 YYLTYPE location
, yyscan_t yyscanner
, SourceProviderScannerData
* data
,
4346 OUString
const & name
,
4347 rtl
::Reference
<unoidl
::InterfaceTypeEntity
> const & entity
)
4349 assert
(entity.is
());
4350 for
(auto
& i
: entity
->getDirectMandatoryBases
()) {
4351 OUString n
("." + i.name
);
4352 unoidl
::detail
::SourceProviderEntity
const * p
;
4354 location
, yyscanner
, data
, true
, &n
, &p
, nullptr
, nullptr
)
4359 if
(p
== nullptr ||
!p
->entity.is
()
4360 || p
->entity
->getSort
() != unoidl
::Entity
::SORT_INTERFACE_TYPE
)
4363 location
, yyscanner
,
4364 ("inconsistent type manager: interface type "
4365 + data
->currentName
+ " base " + n
4366 + " does not resolve to an existing interface type"));
4369 if
(!addOptionalBaseMembers
(
4370 location
, yyscanner
, data
, n
,
4371 static_cast
<unoidl
::InterfaceTypeEntity
*>(p
->entity.get
())))
4376 for
(auto
& i
: entity
->getDirectAttributes
()) {
4378 allMembers.emplace
(i.name
, Member
(u
""_ustr
))
4380 if
(m.mandatory.isEmpty
()) {
4381 m.optional.insert
(name
);
4384 for
(auto
& i
: entity
->getDirectMethods
()) {
4386 allMembers.emplace
(i.name
, Member
(u
""_ustr
))
4388 if
(m.mandatory.isEmpty
()) {
4389 m.optional.insert
(name
);
4395 bool parse
(OUString
const & uri
, SourceProviderScannerData
* data
) {
4396 assert
(data
!= nullptr
);
4397 oslFileHandle handle
;
4398 oslFileError e
= osl_openFile
(uri.pData
, &handle
, osl_File_OpenFlag_Read
);
4400 case osl_File_E_None
:
4402 case osl_File_E_NOENT
:
4405 throw FileFormatException
(uri
, "cannot open: " + OUString
::number
(e
));
4408 e
= osl_getFileSize
(handle
, &size
);
4409 if
(e
!= osl_File_E_None
) {
4410 oslFileError e2
= osl_closeFile
(handle
);
4412 e2
!= osl_File_E_None
, "unoidl",
4413 "cannot close " << uri
<< ": " << +e2
);
4414 throw FileFormatException
(
4415 uri
, "cannot get size: " + OUString
::number
(e
));
4418 e
= osl_mapFile
(handle
, &address
, size
, 0, osl_File_MapFlag_RandomAccess
);
4419 if
(e
!= osl_File_E_None
) {
4420 oslFileError e2
= osl_closeFile
(handle
);
4422 e2
!= osl_File_E_None
, "unoidl",
4423 "cannot close " << uri
<< ": " << +e2
);
4424 throw FileFormatException
(uri
, "cannot mmap: " + OUString
::number
(e
));
4427 data
->setSource
(address
, size
);
4429 if
(yylex_init_extra
(data
, &yyscanner
) != 0) {
4430 // Checking errno for the specific EINVAL, ENOMEM documented for
4431 // yylex_init_extra would not work as those values are not defined
4432 // by the C++ Standard:
4434 throw FileFormatException
(
4436 "yylex_init_extra failed with errno " + OUString
::number
(e2
));
4438 int e2
= yyparse(yyscanner
);
4439 yylex_destroy
(yyscanner
);
4446 throw FileFormatException
(
4449 + (data
->errorLine
== 0
4450 ? OUString
() : " line " + OUString
::number
(data
->errorLine
))
4451 + (data
->parserError.isEmpty
()
4454 + OStringToOUString
(
4455 data
->parserError
, osl_getThreadTextEncoding
())))
4456 + (data
->errorMessage.isEmpty
()
4457 ? OUString
() : ": \"" + data
->errorMessage
+ "\"")));
4459 throw std
::bad_alloc
();
4462 e
= osl_unmapMappedFile
(handle
, address
, size
);
4463 SAL_WARN_IF
(e
!= osl_File_E_None
, "unoidl", "cannot unmap: " << +e
);
4464 e
= osl_closeFile
(handle
);
4465 SAL_WARN_IF
(e
!= osl_File_E_None
, "unoidl", "cannot close: " << +e
);
4468 e
= osl_unmapMappedFile
(handle
, address
, size
);
4469 SAL_WARN_IF
(e
!= osl_File_E_None
, "unoidl", "cannot unmap: " << +e
);
4470 e
= osl_closeFile
(handle
);
4471 SAL_WARN_IF
(e
!= osl_File_E_None
, "unoidl", "cannot close: " << +e
);
4477 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */