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
:
88 case unoidl
::detail
::FLAG_BOUND
:
90 case unoidl
::detail
::FLAG_CONSTRAINED
:
92 case unoidl
::detail
::FLAG_MAYBEAMBIGUOUS
:
93 return
"maybeambiguous";
94 case unoidl
::detail
::FLAG_MAYBEDEFAULT
:
95 return
"maybedefault";
96 case unoidl
::detail
::FLAG_MAYBEVOID
:
98 case unoidl
::detail
::FLAG_OPTIONAL
:
100 case unoidl
::detail
::FLAG_PROPERTY
:
102 case unoidl
::detail
::FLAG_READONLY
:
104 case unoidl
::detail
::FLAG_REMOVABLE
:
106 case unoidl
::detail
::FLAG_TRANSIENT
:
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 size_t i
= name.rfind
('.') + 1;
172 return identifier.size
() == name.size
() - i
173 && o3tl
::starts_with
(name.substr
(i
), identifier
);
177 YYLTYPE location
, yyscan_t yyscanner
,
178 unoidl
::detail
::SourceProviderExpr
* lhs
,
179 unoidl
::detail
::SourceProviderExpr
* rhs
)
181 assert
(lhs
!= nullptr
);
182 assert
(rhs
!= nullptr
);
183 bool ok
= bool(); // avoid warnings
185 case unoidl
::detail
::SourceProviderExpr
::TYPE_BOOL
:
186 ok
= rhs
->type
!= unoidl
::detail
::SourceProviderExpr
::TYPE_BOOL
;
188 case unoidl
::detail
::SourceProviderExpr
::TYPE_INT
:
190 case unoidl
::detail
::SourceProviderExpr
::TYPE_BOOL
:
193 case unoidl
::detail
::SourceProviderExpr
::TYPE_INT
:
196 case unoidl
::detail
::SourceProviderExpr
::TYPE_UINT
:
197 if
(lhs
->ival
>= 0) {
198 lhs
->type
= unoidl
::detail
::SourceProviderExpr
::TYPE_UINT
;
200 } else if
(rhs
->uval
<= SAL_MAX_INT64
) {
201 rhs
->type
= unoidl
::detail
::SourceProviderExpr
::TYPE_INT
;
207 case unoidl
::detail
::SourceProviderExpr
::TYPE_FLOAT
:
209 auto tmp
= lhs
->ival
;
216 case unoidl
::detail
::SourceProviderExpr
::TYPE_UINT
:
218 case unoidl
::detail
::SourceProviderExpr
::TYPE_BOOL
:
221 case unoidl
::detail
::SourceProviderExpr
::TYPE_INT
:
222 if
(rhs
->ival
>= 0) {
223 rhs
->type
= unoidl
::detail
::SourceProviderExpr
::TYPE_UINT
;
225 } else if
(lhs
->uval
<= SAL_MAX_INT64
) {
226 lhs
->type
= unoidl
::detail
::SourceProviderExpr
::TYPE_INT
;
232 case unoidl
::detail
::SourceProviderExpr
::TYPE_UINT
:
235 case unoidl
::detail
::SourceProviderExpr
::TYPE_FLOAT
:
237 auto nTmp
= lhs
->uval
;
244 case unoidl
::detail
::SourceProviderExpr
::TYPE_FLOAT
:
246 case unoidl
::detail
::SourceProviderExpr
::TYPE_BOOL
:
249 case unoidl
::detail
::SourceProviderExpr
::TYPE_INT
:
251 auto tmp
= rhs
->ival
;
256 case unoidl
::detail
::SourceProviderExpr
::TYPE_UINT
:
258 auto tmp
= rhs
->uval
;
263 case unoidl
::detail
::SourceProviderExpr
::TYPE_FLOAT
:
270 error(location
, yyscanner
, "cannot coerce binary expression arguments");
275 unoidl::detail
::SourceProviderEntity
* findEntity_
(
276 unoidl
::detail
::SourceProviderScannerData
* data
, OUString
* name
)
278 assert
(data
!= nullptr
);
279 assert
(name
!= nullptr
);
281 if
(!name
->startsWith
(".", &n
)) {
282 for
(auto i
(data
->modules.rbegin
()); i
!= data
->modules.rend
(); ++i
) {
283 n
= *i
+ "." + *name
;
284 std
::map
<OUString
, unoidl
::detail
::SourceProviderEntity
>::iterator j
(
285 data
->entities.find
(n
));
286 if
(j
!= data
->entities.end
()) {
290 rtl
::Reference
<unoidl
::Entity
> ent
(data
->manager
->findEntity
(n
));
292 std
::map
<OUString
, unoidl
::detail
::SourceProviderEntity
>::iterator
293 k
(data
->entities.emplace
(
295 unoidl
::detail
::SourceProviderEntity
(
296 unoidl
::detail
::SourceProviderEntity
::KIND_EXTERNAL
,
305 std
::map
<OUString
, unoidl
::detail
::SourceProviderEntity
>::iterator i
(
306 data
->entities.find
(n
));
307 if
(i
!= data
->entities.end
()) {
311 rtl
::Reference
<unoidl
::Entity
> ent
(data
->manager
->findEntity
(n
));
313 std
::map
<OUString
, unoidl
::detail
::SourceProviderEntity
>::iterator
314 j
(data
->entities.emplace
(
316 unoidl
::detail
::SourceProviderEntity
(
317 unoidl
::detail
::SourceProviderEntity
::KIND_EXTERNAL
,
326 enum Found
{ FOUND_ERROR
, FOUND_TYPE
, FOUND_ENTITY
};
329 YYLTYPE location
, yyscan_t yyscanner
,
330 unoidl
::detail
::SourceProviderScannerData
* data
,
331 bool resolveInterfaceDefinitions
, OUString
* name
,
332 unoidl
::detail
::SourceProviderEntity
const ** entity
, bool * typedefed
,
333 unoidl
::detail
::SourceProviderType
* typedefedType
)
335 //TODO: avoid recursion
336 assert
(data
!= nullptr
);
337 assert
(name
!= nullptr
);
338 assert
(entity
!= nullptr
);
339 unoidl
::detail
::SourceProviderEntity
* e
= findEntity_
(data
, name
);
341 OUString typeNucleus
;
342 std
::size_t rank
= 0;
343 std
::vector
<unoidl
::detail
::SourceProviderType
> args
;
347 case unoidl
::detail
::SourceProviderEntity
::KIND_LOCAL
:
351 assert
(e
->entity.is
());
353 case unoidl
::detail
::SourceProviderEntity
::KIND_EXTERNAL
:
354 if
(e
->entity
->getSort
() == unoidl
::Entity
::SORT_TYPEDEF
) {
355 if
(typedefed
!= nullptr
) {
358 if
(data
->publishedContext
359 && !static_cast
<unoidl
::TypedefEntity
*>(
360 e
->entity.get
())->isPublished
())
364 ("type " + *name
+ " based on unpublished typedef "
365 + n
+ " used in published context"));
369 static_cast
<unoidl
::TypedefEntity
*>(e
->entity.get
())
372 while
(typeNucleus.startsWith
("[]", &typeNucleus
)) {
376 ("inconsistent type manager: bad type " + *name
377 + (" based on instantiated polymorphic struct"
378 " type based on sequence type named ")
382 if
(rank
== std
::numeric_limits
<std
::size_t>::max
()) {
386 + " based on sequence type of too high rank"));
391 sal_Int32 i
= typeNucleus.indexOf
('<');
396 ("inconsistent type manager: bad type " + *name
397 + (" based on instantiated polymorphic struct"
398 " type based on instantiated polymorphic"
399 " struct type named ")
403 std
::u16string_view tmpl
(typeNucleus.subView
(0, i
));
405 ++i
; // skip '<' or ','
407 for
(sal_Int32 level
= 0;
408 j
!= typeNucleus.getLength
(); ++j
)
410 sal_Unicode c
= typeNucleus
[j
];
415 } else if
(c
== '<') {
417 } else if
(c
== '>') {
424 if
(j
!= typeNucleus.getLength
()) {
425 OUString argName
(typeNucleus.copy
(i
, j
- i
));
426 unoidl
::detail
::SourceProviderEntity
const *
428 unoidl
::detail
::SourceProviderType argType
;
431 location
, yyscanner
, data
, false
,
432 &argName
, &argEnt
, nullptr
, &argType
))
439 if
(argEnt
== nullptr
) {
442 (("inconsistent type manager: bad"
443 " instantiated polymorphic struct"
444 " type template type argument ")
448 unoidl
::detail
::SourceProviderType
::Type
450 = unoidl
::detail
::SourceProviderType
::Type
();
452 switch
(argEnt
->kind
) {
453 case unoidl
::detail
::SourceProviderEntity
::KIND_LOCAL
:
457 (("inconsistent type"
460 " polymorphic struct type"
466 assert
(e
->entity.is
());
468 case unoidl
::detail
::SourceProviderEntity
::KIND_EXTERNAL
:
469 switch
(e
->entity
->getSort
()) {
470 case unoidl
::Entity
::SORT_ENUM_TYPE
:
471 argT
= unoidl
::detail
::SourceProviderType
::TYPE_ENUM
;
473 case unoidl
::Entity
::SORT_PLAIN_STRUCT_TYPE
:
474 argT
= unoidl
::detail
::SourceProviderType
::TYPE_PLAIN_STRUCT
;
476 case unoidl
::Entity
::SORT_INTERFACE_TYPE
:
477 argT
= unoidl
::detail
::SourceProviderType
::TYPE_INTERFACE
;
482 (("inconsistent type"
485 " polymorphic struct type"
492 case unoidl
::detail
::SourceProviderEntity
::KIND_INTERFACE_DECL
:
493 case unoidl
::detail
::SourceProviderEntity
::KIND_PUBLISHED_INTERFACE_DECL
:
494 argT
= unoidl
::detail
::SourceProviderType
::TYPE_INTERFACE
;
496 case unoidl
::detail
::SourceProviderEntity
::KIND_MODULE
:
497 assert
(false
&& "this cannot happen");
500 = unoidl
::detail
::SourceProviderType
(
501 argT
, argName
, argEnt
);
505 args.push_back
(argType
);
508 } while
(i
!= typeNucleus.getLength
()
509 && typeNucleus
[i
] != '>');
510 if
(i
!= typeNucleus.getLength
() - 1
511 || typeNucleus
[i
] != '>')
515 ("inconsistent type manager: bad type name \""
519 assert
(!args.empty
());
522 if
(typeNucleus.isEmpty
()) {
525 ("inconsistent type manager: bad type name \"" + t
529 if
(typeNucleus
== "void") {
532 ("inconsistent type manager: bad type " + *name
533 + " based on void"));
536 if
(typeNucleus
== "boolean" || typeNucleus
== "byte"
537 || typeNucleus
== "short"
538 || typeNucleus
== "unsigned short"
539 || typeNucleus
== "long"
540 || typeNucleus
== "unsigned long"
541 || typeNucleus
== "hyper"
542 || typeNucleus
== "unsigned hyper"
543 || typeNucleus
== "float" || typeNucleus
== "double"
544 || typeNucleus
== "char" || typeNucleus
== "string"
545 || typeNucleus
== "type" || typeNucleus
== "any")
550 ("inconsistent type manager: bad type " + *name
551 + (" based on instantiated polymorphic struct"
558 n
= "." + typeNucleus
;
560 e
= findEntity_
(data
, &n
);
564 case unoidl
::detail
::SourceProviderEntity
::KIND_INTERFACE_DECL
:
565 case unoidl
::detail
::SourceProviderEntity
::KIND_PUBLISHED_INTERFACE_DECL
:
566 if
(resolveInterfaceDefinitions
) {
567 rtl
::Reference
<unoidl
::Entity
> ent
(
568 data
->manager
->findEntity
(n
));
569 // Do not allow ent to be of SORT_TYPEDEF:
572 != unoidl
::Entity
::SORT_INTERFACE_TYPE
))
576 (*name
+ " is based on interface declaration " + n
577 + " that is not an interface type entity"));
581 = unoidl
::detail
::SourceProviderEntity
::KIND_EXTERNAL
;
585 case unoidl
::detail
::SourceProviderEntity
::KIND_MODULE
:
588 *name
+ " is based on module entity " + n
);
592 if
(!typeNucleus.isEmpty
() || rank
!= 0 ||
!args.empty
()) {
593 if
(typeNucleus.isEmpty
() && e
== nullptr
) {
594 // Found a type name based on an unknown entity:
598 unoidl
::detail
::SourceProviderType t
;
600 if
(typeNucleus
== "boolean") {
601 t
= unoidl
::detail
::SourceProviderType
(
602 unoidl
::detail
::SourceProviderType
::TYPE_BOOLEAN
);
603 } else if
(typeNucleus
== "byte") {
604 t
= unoidl
::detail
::SourceProviderType
(
605 unoidl
::detail
::SourceProviderType
::TYPE_BYTE
);
606 } else if
(typeNucleus
== "short") {
607 t
= unoidl
::detail
::SourceProviderType
(
608 unoidl
::detail
::SourceProviderType
::TYPE_SHORT
);
609 } else if
(typeNucleus
== "unsigned short") {
610 t
= unoidl
::detail
::SourceProviderType
(
611 unoidl
::detail
::SourceProviderType
::TYPE_UNSIGNED_SHORT
);
612 } else if
(typeNucleus
== "long") {
613 t
= unoidl
::detail
::SourceProviderType
(
614 unoidl
::detail
::SourceProviderType
::TYPE_LONG
);
615 } else if
(typeNucleus
== "unsigned long") {
616 t
= unoidl
::detail
::SourceProviderType
(
617 unoidl
::detail
::SourceProviderType
::TYPE_UNSIGNED_LONG
);
618 } else if
(typeNucleus
== "hyper") {
619 t
= unoidl
::detail
::SourceProviderType
(
620 unoidl
::detail
::SourceProviderType
::TYPE_HYPER
);
621 } else if
(typeNucleus
== "unsigned hyper") {
622 t
= unoidl
::detail
::SourceProviderType
(
623 unoidl
::detail
::SourceProviderType
::TYPE_UNSIGNED_HYPER
);
624 } else if
(typeNucleus
== "float") {
625 t
= unoidl
::detail
::SourceProviderType
(
626 unoidl
::detail
::SourceProviderType
::TYPE_FLOAT
);
627 } else if
(typeNucleus
== "double") {
628 t
= unoidl
::detail
::SourceProviderType
(
629 unoidl
::detail
::SourceProviderType
::TYPE_DOUBLE
);
630 } else if
(typeNucleus
== "char") {
631 t
= unoidl
::detail
::SourceProviderType
(
632 unoidl
::detail
::SourceProviderType
::TYPE_CHAR
);
633 } else if
(typeNucleus
== "string") {
634 t
= unoidl
::detail
::SourceProviderType
(
635 unoidl
::detail
::SourceProviderType
::TYPE_STRING
);
636 } else if
(typeNucleus
== "type") {
637 t
= unoidl
::detail
::SourceProviderType
(
638 unoidl
::detail
::SourceProviderType
::TYPE_TYPE
);
639 } else if
(typeNucleus
== "any") {
640 t
= unoidl
::detail
::SourceProviderType
(
641 unoidl
::detail
::SourceProviderType
::TYPE_ANY
);
643 assert
(typeNucleus.isEmpty
());
644 assert
(e
!= nullptr
);
646 case unoidl
::detail
::SourceProviderEntity
::KIND_LOCAL
:
648 if
(dynamic_cast
<unoidl
::detail
::SourceProviderEnumTypeEntityPad
*>(
652 t
= unoidl
::detail
::SourceProviderType
(
653 unoidl
::detail
::SourceProviderType
::TYPE_ENUM
,
655 } else if
(dynamic_cast
<unoidl
::detail
::SourceProviderPlainStructTypeEntityPad
*>(
659 t
= unoidl
::detail
::SourceProviderType
(
660 unoidl
::detail
::SourceProviderType
::TYPE_PLAIN_STRUCT
,
662 } else if
(dynamic_cast
<unoidl
::detail
::SourceProviderPolymorphicStructTypeTemplateEntityPad
*>(
669 + (" based on recursive reference to"
670 " polymorphic struct type template ")
673 } else if
(dynamic_cast
<unoidl
::detail
::SourceProviderExceptionTypeEntityPad
*>(
677 t
= unoidl
::detail
::SourceProviderType
(
678 unoidl
::detail
::SourceProviderType
::TYPE_EXCEPTION
,
680 } else if
(dynamic_cast
<unoidl
::detail
::SourceProviderInterfaceTypeEntityPad
*>(
684 t
= unoidl
::detail
::SourceProviderType
(
685 unoidl
::detail
::SourceProviderType
::TYPE_INTERFACE
,
691 + " based on non-type entity " + n
));
696 assert
(e
->entity.is
());
698 case unoidl
::detail
::SourceProviderEntity
::KIND_EXTERNAL
:
699 switch
(e
->entity
->getSort
()) {
700 case unoidl
::Entity
::SORT_ENUM_TYPE
:
701 t
= unoidl
::detail
::SourceProviderType
(
702 unoidl
::detail
::SourceProviderType
::TYPE_ENUM
,
705 case unoidl
::Entity
::SORT_PLAIN_STRUCT_TYPE
:
706 t
= unoidl
::detail
::SourceProviderType
(
707 unoidl
::detail
::SourceProviderType
::TYPE_PLAIN_STRUCT
,
710 case unoidl
::Entity
::SORT_POLYMORPHIC_STRUCT_TYPE_TEMPLATE
:
714 + " based on polymorphic struct type template "
715 + n
+ " without type arguments"));
717 case unoidl
::Entity
::SORT_EXCEPTION_TYPE
:
718 t
= unoidl
::detail
::SourceProviderType
(
719 unoidl
::detail
::SourceProviderType
::TYPE_EXCEPTION
,
722 case unoidl
::Entity
::SORT_INTERFACE_TYPE
:
723 t
= unoidl
::detail
::SourceProviderType
(
724 unoidl
::detail
::SourceProviderType
::TYPE_INTERFACE
,
731 + " based on non-type entity " + n
));
735 case unoidl
::detail
::SourceProviderEntity
::KIND_INTERFACE_DECL
:
736 case unoidl
::detail
::SourceProviderEntity
::KIND_PUBLISHED_INTERFACE_DECL
:
737 t
= unoidl
::detail
::SourceProviderType
(
738 unoidl
::detail
::SourceProviderType
::TYPE_INTERFACE
,
741 case unoidl
::detail
::SourceProviderEntity
::KIND_MODULE
:
742 assert
(false
&& "this cannot happen");
746 assert
(typeNucleus.isEmpty
());
747 assert
(e
!= nullptr
);
749 case unoidl
::detail
::SourceProviderEntity
::KIND_LOCAL
:
754 + (" based on instantiated polymorphic struct type"
757 + (" that is either not a polymorphic struct type"
758 " template or a recursive reference to a"
759 " polymorphic struct type template")));
762 assert
(e
->entity.is
());
764 case unoidl
::detail
::SourceProviderEntity
::KIND_EXTERNAL
:
765 if
(e
->entity
->getSort
()
766 == unoidl
::Entity
::SORT_POLYMORPHIC_STRUCT_TYPE_TEMPLATE
)
770 unoidl
::PolymorphicStructTypeTemplateEntity
*>(
772 ->getTypeParameters
().size
()))
777 + (" based on instantiated polymorphic struct"
779 + OUString
::number
(args.size
())
780 + (" type arguments based on polymorphic"
781 " struct type template ")
785 unoidl
::PolymorphicStructTypeTemplateEntity
*>(
787 ->getTypeParameters
().size
())
788 + " type parameters"));
791 t
= unoidl
::detail
::SourceProviderType
(n
, e
, std
::move
(args
));
795 case unoidl
::detail
::SourceProviderEntity
::KIND_INTERFACE_DECL
:
796 case unoidl
::detail
::SourceProviderEntity
::KIND_PUBLISHED_INTERFACE_DECL
:
800 + (" based on instantiated polymorphic struct type"
803 + " that is not a polymorphic struct type template"));
805 case unoidl
::detail
::SourceProviderEntity
::KIND_MODULE
:
806 assert
(false
&& "this cannot happen");
809 if
(typedefedType
!= nullptr
) {
810 for
(std
::size_t i
= 0; i
!= rank
; ++i
) {
811 t
= unoidl
::detail
::SourceProviderType
(&t
);
814 typedefedType
->typedefName
= *name
;
825 bool checkTypeArgument
(
826 YYLTYPE location
, yyscan_t yyscanner
,
827 unoidl
::detail
::SourceProviderType
const & type
)
830 case unoidl
::detail
::SourceProviderType
::TYPE_VOID
:
831 case unoidl
::detail
::SourceProviderType
::TYPE_UNSIGNED_SHORT
:
832 case unoidl
::detail
::SourceProviderType
::TYPE_UNSIGNED_LONG
:
833 case unoidl
::detail
::SourceProviderType
::TYPE_UNSIGNED_HYPER
:
834 case unoidl
::detail
::SourceProviderType
::TYPE_EXCEPTION
:
835 case unoidl
::detail
::SourceProviderType
::TYPE_PARAMETER
: //TODO?
838 "bad instantiated polymorphic struct type argument");
840 case unoidl
::detail
::SourceProviderType
::TYPE_SEQUENCE
:
841 return checkTypeArgument
(location
, yyscanner
, type.subtypes.front
());
847 bool checkInstantiatedPolymorphicStructTypeArgument
(
848 unoidl
::detail
::SourceProviderType
const & type
, OUString
const & name
)
851 == unoidl
::detail
::SourceProviderType
::TYPE_INSTANTIATED_POLYMORPHIC_STRUCT
)
853 for
(auto
& i
: type.subtypes
) {
854 if
(checkInstantiatedPolymorphicStructTypeArgument
(i
, name
)
855 || i.getName
() == name
) // no need to worry about typedef
864 std::vector
<OUString
> annotations
(bool deprecated
) {
865 std
::vector
<OUString
> ann
;
867 ann.push_back
("deprecated");
879 %token TOK_RIGHTSHIFT
891 %token TOK_CONSTRAINED
902 %token TOK_MAYBEAMBIGUOUS
903 %token TOK_MAYBEDEFAULT
926 %token
<sval
> TOK_IDENTIFIER
927 %token
<ival
> TOK_INTEGER
928 %token
<fval
> TOK_FLOATING
930 %token TOK_DEPRECATED
934 %type
<sval
> identifier name singleInheritance singleInheritance_opt
935 %type
<bval
> ctors_opt deprecated_opt ellipsis_opt published_opt
936 %type
<decls
> attributeAccessDecl attributeAccessDecls
938 %type
<excns
> exceptionSpec exceptionSpec_opt exceptions
939 %type
<flags
> flag flagSection flagSection_opt flags
940 %type
<expr
> addExpr andExpr expr multExpr orExpr primaryExpr shiftExpr unaryExpr
943 %type
<types
> typeArguments
945 %initial
-action
{ yylloc = 1; }
950 definitions definition
958 | polymorphicStructTemplateDefn
963 | singleInterfaceBasedServiceDefn
964 | accumulationBasedServiceDefn
965 | interfaceBasedSingletonDefn
966 | serviceBasedSingletonDefn
971 TOK_MODULE identifier
973 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
974 OUString name
(convertToFullName
(data
, $2));
975 data
->modules.push_back
(name
);
976 std
::pair
<std
::map
<OUString
, unoidl
::detail
::SourceProviderEntity
>::iterator
, bool> p
(
977 data
->entities.emplace
(
979 unoidl
::detail
::SourceProviderEntity
(
980 unoidl
::detail
::SourceProviderEntity
::KIND_MODULE
)));
982 && (p.first
->second.kind
983 != unoidl
::detail
::SourceProviderEntity
::KIND_MODULE
))
985 error(@
2, yyscanner
, "multiple entities named " + name
);
989 '{' definitions
'}' ';' { yyget_extra
(yyscanner
)->modules.pop_back
(); }
993 deprecated_opt published_opt TOK_ENUM identifier
995 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
996 data
->publishedContext
= $2;
997 convertToCurrentName
(data
, $4);
998 if
(!data
->entities.emplace
(
1000 unoidl
::detail
::SourceProviderEntity
(
1001 new unoidl
::detail
::SourceProviderEnumTypeEntityPad
(
1005 error(@
4, yyscanner
, "multiple entities named " + data
->currentName
);
1009 '{' enumMembers
'}' ';'
1011 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
1012 unoidl
::detail
::SourceProviderEntity
* ent
= getCurrentEntity
(data
);
1013 unoidl
::detail
::SourceProviderEnumTypeEntityPad
* pad
=
1014 dynamic_cast
<unoidl
::detail
::SourceProviderEnumTypeEntityPad
*>(
1016 assert
(pad
!= nullptr
);
1017 ent
->entity
= new unoidl
::EnumTypeEntity
(
1018 pad
->isPublished
(), std
::move
(pad
->members
), annotations
($1));
1020 clearCurrentState
(data
);
1025 | enumMembers
',' enumMember
1030 deprecated_opt identifier
1032 OUString id
(convertName
($2));
1033 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
1034 rtl
::Reference
<unoidl
::detail
::SourceProviderEnumTypeEntityPad
> pad
(
1035 getCurrentPad
<unoidl
::detail
::SourceProviderEnumTypeEntityPad
>(data
));
1037 if
(pad
->members.empty
()) {
1040 v
= pad
->members.back
().value
;
1041 if
(v
== SAL_MAX_INT32
) {
1044 ("enum " + data
->currentName
+ " member " + id
1045 + " would have out-of-range value 2^31"));
1050 pad
->members.emplace_back
(id
, v
, annotations
($1));
1052 | deprecated_opt identifier
'=' expr
1054 OUString id
(convertName
($2));
1055 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
1056 rtl
::Reference
<unoidl
::detail
::SourceProviderEnumTypeEntityPad
> pad
(
1057 getCurrentPad
<unoidl
::detail
::SourceProviderEnumTypeEntityPad
>(data
));
1060 case unoidl
::detail
::SourceProviderExpr
::TYPE_INT
:
1061 if
($4.ival
< SAL_MIN_INT32 ||
$4.ival
> SAL_MAX_INT32
) {
1064 ("out-of-range enum " + data
->currentName
+ " member " + id
1065 + " value " + OUString
::number
($4.ival
)));
1068 v
= static_cast
<sal_Int32
>($4.ival
);
1070 case unoidl
::detail
::SourceProviderExpr
::TYPE_UINT
:
1071 if
($4.uval
> SAL_MAX_INT32
) {
1074 ("out-of-range enum " + data
->currentName
+ " member " + id
1075 + " value " + OUString
::number
($4.uval
)));
1078 v
= static_cast
<sal_Int32
>($4.uval
);
1083 ("non-integer enum " + data
->currentName
+ " member " + id
1088 pad
->members.emplace_back
(id
, v
, annotations
($1));
1093 deprecated_opt published_opt TOK_STRUCT identifier singleInheritance_opt
1095 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
1096 data
->publishedContext
= $2;
1097 convertToCurrentName
(data
, $4);
1099 rtl
::Reference
<unoidl
::PlainStructTypeEntity
> baseEnt
;
1100 if
($5 != nullptr
) {
1101 baseName
= convertName
($5);
1102 unoidl
::detail
::SourceProviderEntity
const * p
;
1104 @
5, yyscanner
, data
, false
, &baseName
, &p
, nullptr
, nullptr
)
1109 if
(p
== nullptr ||
!p
->entity.is
()
1110 || p
->entity
->getSort
() != unoidl
::Entity
::SORT_PLAIN_STRUCT_TYPE
)
1114 ("plain struct type " + data
->currentName
+ " base "
1116 + " does not resolve to an existing plain struct type"));
1119 baseEnt
= static_cast
<unoidl
::PlainStructTypeEntity
*>(
1121 if
($2 && !baseEnt
->isPublished
()) {
1124 ("published plain struct type " + data
->currentName
+ " base "
1125 + baseName
+ " is unpublished"));
1129 if
(!data
->entities.emplace
(
1131 unoidl
::detail
::SourceProviderEntity
(
1132 new unoidl
::detail
::SourceProviderPlainStructTypeEntityPad
(
1133 $2, baseName
, baseEnt
))).
1136 error(@
4, yyscanner
, "multiple entities named " + data
->currentName
);
1140 '{' structMembers
'}' ';'
1142 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
1143 unoidl
::detail
::SourceProviderEntity
* ent
= getCurrentEntity
(data
);
1144 unoidl
::detail
::SourceProviderPlainStructTypeEntityPad
* pad
=
1146 unoidl
::detail
::SourceProviderPlainStructTypeEntityPad
*>(
1148 assert
(pad
!= nullptr
);
1149 ent
->entity
= new unoidl
::PlainStructTypeEntity
(
1150 pad
->isPublished
(), pad
->baseName
, std
::move
(pad
->members
), annotations
($1));
1152 clearCurrentState
(data
);
1156 polymorphicStructTemplateDefn:
1157 deprecated_opt published_opt TOK_STRUCT identifier
'<'
1159 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
1160 data
->publishedContext
= $2;
1161 convertToCurrentName
(data
, $4);
1162 if
(!data
->entities.emplace
(
1164 unoidl
::detail
::SourceProviderEntity
(
1165 new unoidl
::detail
::SourceProviderPolymorphicStructTypeTemplateEntityPad
(
1169 error(@
4, yyscanner
, "multiple entities named " + data
->currentName
);
1173 typeParameters
'>' '{' structMembers
'}' ';'
1175 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
1176 unoidl
::detail
::SourceProviderEntity
* ent
= getCurrentEntity
(data
);
1177 unoidl
::detail
::SourceProviderPolymorphicStructTypeTemplateEntityPad
*
1179 unoidl
::detail
::SourceProviderPolymorphicStructTypeTemplateEntityPad
*>(
1181 assert
(pad
!= nullptr
);
1182 ent
->entity
= new unoidl
::PolymorphicStructTypeTemplateEntity
(
1183 pad
->isPublished
(), std
::move
(pad
->typeParameters
), std
::move
(pad
->members
),
1186 clearCurrentState
(data
);
1191 typeParameters
',' identifier
1193 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
1194 rtl
::Reference
<unoidl
::detail
::SourceProviderPolymorphicStructTypeTemplateEntityPad
>
1195 pad
(getCurrentPad
<unoidl
::detail
::SourceProviderPolymorphicStructTypeTemplateEntityPad
>(
1197 OUString id
(convertName
($3));
1198 if
(std
::find
(pad
->typeParameters.begin
(), pad
->typeParameters.end
(), id
)
1199 != pad
->typeParameters.end
())
1203 ("polymorphic struct type template " + data
->currentName
1204 + " type parameter " + id
1205 + " has same identifier as another type parameter"));
1208 pad
->typeParameters.push_back
(id
);
1212 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
1213 rtl
::Reference
<unoidl
::detail
::SourceProviderPolymorphicStructTypeTemplateEntityPad
>
1214 pad
(getCurrentPad
<unoidl
::detail
::SourceProviderPolymorphicStructTypeTemplateEntityPad
>(
1216 OUString id
(convertName
($1));
1217 assert
(pad
->typeParameters.empty
());
1218 pad
->typeParameters.push_back
(id
);
1223 deprecated_opt published_opt TOK_EXCEPTION identifier singleInheritance_opt
1225 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
1226 data
->publishedContext
= $2;
1227 convertToCurrentName
(data
, $4);
1229 rtl
::Reference
<unoidl
::ExceptionTypeEntity
> baseEnt
;
1230 if
($5 != nullptr
) {
1231 baseName
= convertName
($5);
1232 unoidl
::detail
::SourceProviderEntity
const * p
;
1234 @
5, yyscanner
, data
, false
, &baseName
, &p
, nullptr
, nullptr
)
1239 if
(p
== nullptr ||
!p
->entity.is
()
1240 || p
->entity
->getSort
() != unoidl
::Entity
::SORT_EXCEPTION_TYPE
)
1244 ("exception type " + data
->currentName
+ " base " + baseName
1245 + " does not resolve to an existing exception type"));
1248 baseEnt
= static_cast
<unoidl
::ExceptionTypeEntity
*>(
1250 if
($2 && !baseEnt
->isPublished
()) {
1253 ("published exception type " + data
->currentName
+ " base "
1254 + baseName
+ " is unpublished"));
1258 if
(!data
->entities.emplace
(
1260 unoidl
::detail
::SourceProviderEntity
(
1261 new unoidl
::detail
::SourceProviderExceptionTypeEntityPad
(
1262 $2, baseName
, baseEnt
))).
1265 error(@
4, yyscanner
, "multiple entities named " + data
->currentName
);
1269 '{' structMembers
'}' ';'
1271 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
1272 unoidl
::detail
::SourceProviderEntity
* ent
= getCurrentEntity
(data
);
1273 unoidl
::detail
::SourceProviderExceptionTypeEntityPad
* pad
=
1274 dynamic_cast
<unoidl
::detail
::SourceProviderExceptionTypeEntityPad
*>(
1276 assert
(pad
!= nullptr
);
1277 ent
->entity
= new unoidl
::ExceptionTypeEntity
(
1278 pad
->isPublished
(), pad
->baseName
, std
::move
(pad
->members
), annotations
($1));
1280 clearCurrentState
(data
);
1285 structMembers structMember
1290 deprecated_opt type identifier
';'
1292 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
1293 unoidl
::detail
::SourceProviderType t
(*$2);
1295 OUString id
(convertName
($3));
1297 case unoidl
::detail
::SourceProviderType
::TYPE_VOID
:
1298 case unoidl
::detail
::SourceProviderType
::TYPE_EXCEPTION
:
1301 ("illegal struct/exception type " + data
->currentName
1302 + " direct member " + id
+ " type"));
1308 if
(t.type
!= unoidl
::detail
::SourceProviderType
::TYPE_PARAMETER
1309 && t.getName
() == data
->currentName
) // no need to worry about typedef
1313 ("struct/exception type " + data
->currentName
+ " direct member "
1314 + id
+ " has same type as the type itself"));
1317 if
(checkInstantiatedPolymorphicStructTypeArgument
(t
, data
->currentName
))
1321 ("struct/exception type " + data
->currentName
+ " direct member "
1323 + (" has instantiated polymorphic struct type that uses the type"
1324 " itself as an argument")));
1327 if
(nameHasSameIdentifierAs
(data
->currentName
, id
)) {
1330 ("struct/exception type " + data
->currentName
+ " direct member "
1331 + id
+ " has same unqualified identifier as the type itself"));
1334 unoidl
::detail
::SourceProviderEntity
* ent
= getCurrentEntity
(data
);
1335 unoidl
::detail
::SourceProviderPlainStructTypeEntityPad
* p1
=
1336 dynamic_cast
<unoidl
::detail
::SourceProviderPlainStructTypeEntityPad
*>(
1338 if
(p1
!= nullptr
) {
1339 for
(const auto
& i
: p1
->members
) {
1343 ("plain struct type " + data
->currentName
1344 + " direct member " + id
1345 + " has same identifier as another direct member"));
1349 if
(p1
->baseEntity.is
()) {
1350 OUString baseName
(p1
->baseName
);
1351 for
(auto baseEnt
(p1
->baseEntity
);;) {
1352 if
(nameHasSameIdentifierAs
(baseName
, id
)) {
1355 ("plain struct type " + data
->currentName
1356 + " direct member " + id
1357 + " has same unqalified identifier as base "
1361 for
(auto
& i
: baseEnt
->getDirectMembers
()) {
1365 ("plain struct type " + data
->currentName
1366 + " direct member " + id
1367 + " has same identifier as a member of base "
1372 baseName
= baseEnt
->getDirectBase
();
1373 if
(baseName.isEmpty
()) {
1376 unoidl
::detail
::SourceProviderEntity
const * p
;
1378 @
2, yyscanner
, data
, false
, &baseName
, &p
, nullptr
,
1384 if
(p
== nullptr ||
!p
->entity.is
()
1385 ||
(p
->entity
->getSort
()
1386 != unoidl
::Entity
::SORT_PLAIN_STRUCT_TYPE
))
1390 ("inconsistent type manager: plain struct type "
1391 + data
->currentName
+ " base " + baseName
1392 + (" does not resolve to an existing plain struct"
1396 baseEnt
= static_cast
<unoidl
::PlainStructTypeEntity
*>(
1400 p1
->members.emplace_back
(id
, t.getName
(), annotations
($1));
1402 unoidl
::detail
::SourceProviderPolymorphicStructTypeTemplateEntityPad
*
1403 p2
= dynamic_cast
<unoidl
::detail
::SourceProviderPolymorphicStructTypeTemplateEntityPad
*>(
1405 if
(p2
!= nullptr
) {
1406 for
(const auto
& i
: p2
->members
) {
1410 ("polymorphic struct type template "
1411 + data
->currentName
+ " direct member " + id
1412 + " has same identifier as another direct member"));
1416 p2
->members.emplace_back
(
1418 t.type
== unoidl
::detail
::SourceProviderType
::TYPE_PARAMETER
,
1421 unoidl
::detail
::SourceProviderExceptionTypeEntityPad
* p3
1422 = dynamic_cast
<unoidl
::detail
::SourceProviderExceptionTypeEntityPad
*>(
1424 assert
(p3
!= nullptr
);
1425 for
(const auto
& i
: p3
->members
) {
1429 ("exception type " + data
->currentName
1430 + " direct member " + id
1431 + " has same identifier as another direct member"));
1435 if
(p3
->baseEntity.is
()) {
1436 OUString baseName
(p3
->baseName
);
1437 for
(auto baseEnt
(p3
->baseEntity
);;) {
1438 if
(nameHasSameIdentifierAs
(baseName
, id
)) {
1441 ("exception type " + data
->currentName
1442 + " direct member " + id
1443 + " has same unqalified identifier as base "
1447 for
(auto
& i
: baseEnt
->getDirectMembers
()) {
1451 ("exception type " + data
->currentName
1452 + " direct member " + id
1453 + " has same identifier as a member of base "
1458 baseName
= baseEnt
->getDirectBase
();
1459 if
(baseName.isEmpty
()) {
1462 unoidl
::detail
::SourceProviderEntity
const * p
;
1464 @
2, yyscanner
, data
, false
, &baseName
, &p
,
1470 if
(p
== nullptr ||
!p
->entity.is
()
1471 ||
(p
->entity
->getSort
()
1472 != unoidl
::Entity
::SORT_EXCEPTION_TYPE
))
1476 ("inconsistent type manager: exception type "
1477 + data
->currentName
+ " base " + baseName
1478 + (" does not resolve to an existing exception"
1482 baseEnt
= static_cast
<unoidl
::ExceptionTypeEntity
*>(
1486 p3
->members.emplace_back
(id
, t.getName
(), annotations
($1));
1493 deprecated_opt published_opt TOK_INTERFACE identifier singleInheritance_opt
1495 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
1496 data
->publishedContext
= $2;
1497 convertToCurrentName
(data
, $4);
1499 rtl
::Reference
<unoidl
::InterfaceTypeEntity
> baseEnt
;
1500 if
($5 != nullptr
) {
1501 baseName
= convertName
($5);
1502 unoidl
::detail
::SourceProviderEntity
const * p
;
1504 @
5, yyscanner
, data
, true
, &baseName
, &p
, nullptr
, nullptr
)
1509 if
(p
== nullptr ||
!p
->entity.is
()
1510 || p
->entity
->getSort
() != unoidl
::Entity
::SORT_INTERFACE_TYPE
)
1514 ("interface type " + data
->currentName
+ " direct base "
1516 + " does not resolve to an existing interface type"));
1519 baseEnt
= static_cast
<unoidl
::InterfaceTypeEntity
*>(p
->entity.get
());
1520 if
($2 && !baseEnt
->isPublished
()) {
1523 ("published interface type " + data
->currentName
1524 + " direct base " + baseName
+ " is unpublished"));
1528 std
::map
<OUString
, unoidl
::detail
::SourceProviderEntity
>::iterator i
(
1529 data
->entities.find
(data
->currentName
));
1530 if
(i
!= data
->entities.end
()) {
1531 switch
(i
->second.kind
) {
1532 case unoidl
::detail
::SourceProviderEntity
::KIND_INTERFACE_DECL
:
1534 case unoidl
::detail
::SourceProviderEntity
::KIND_PUBLISHED_INTERFACE_DECL
:
1538 ("unpublished interface type " + data
->currentName
1539 + " has been declared published"));
1546 "multiple entities named " + data
->currentName
);
1551 rtl
::Reference
<unoidl
::detail
::SourceProviderInterfaceTypeEntityPad
> pad
(
1552 new unoidl
::detail
::SourceProviderInterfaceTypeEntityPad
(
1555 && !pad
->addDirectBase
(
1556 @
4, yyscanner
, data
,
1557 unoidl
::detail
::SourceProviderInterfaceTypeEntityPad
::DirectBase
(
1558 baseName
, baseEnt
, std
::vector
<OUString
>()),
1563 data
->entities
[data
->currentName
] = unoidl
::detail
::SourceProviderEntity
(
1566 '{' interfaceMembers
'}' ';'
1568 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
1569 unoidl
::detail
::SourceProviderEntity
* ent
= getCurrentEntity
(data
);
1570 unoidl
::detail
::SourceProviderInterfaceTypeEntityPad
* pad
=
1571 dynamic_cast
<unoidl
::detail
::SourceProviderInterfaceTypeEntityPad
*>(
1573 assert
(pad
!= nullptr
);
1574 if
(pad
->directMandatoryBases.empty
()
1575 && data
->currentName
!= "com.sun.star.uno.XInterface")
1577 OUString base
(".com.sun.star.uno.XInterface");
1578 unoidl
::detail
::SourceProviderEntity
const * p
;
1579 if
(findEntity
(@
4, yyscanner
, data
, true
, &base
, &p
, nullptr
, nullptr
)
1584 if
(p
== nullptr ||
!p
->entity.is
()
1585 || p
->entity
->getSort
() != unoidl
::Entity
::SORT_INTERFACE_TYPE
)
1589 ("interface type " + data
->currentName
1590 + " implicit direct base " + base
1591 + " does not resolve to an existing interface type"));
1594 if
(!pad
->addDirectBase
(
1595 @
3, yyscanner
, data
,
1596 unoidl
::detail
::SourceProviderInterfaceTypeEntityPad
::DirectBase
(
1598 static_cast
<unoidl
::InterfaceTypeEntity
*>(
1600 std
::vector
<OUString
>()),
1606 std
::vector
<unoidl
::AnnotatedReference
> mbases
;
1607 for
(auto
& i
: pad
->directMandatoryBases
) {
1608 mbases.emplace_back
(i.name
, std
::move
(i.annotations
));
1610 std
::vector
<unoidl
::AnnotatedReference
> obases
;
1611 for
(auto
& i
: pad
->directOptionalBases
) {
1612 obases.emplace_back
(i.name
, std
::move
(i.annotations
));
1614 ent
->entity
= new unoidl
::InterfaceTypeEntity
(
1615 pad
->isPublished
(), std
::move
(mbases
), std
::move
(obases
), std
::move
(pad
->directAttributes
),
1616 std
::move
(pad
->directMethods
), annotations
($1));
1618 clearCurrentState
(data
);
1623 interfaceMembers interfaceMember
1629 | interfaceAttribute
1634 deprecated_opt flagSection_opt TOK_INTERFACE name
';'
1636 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
1637 OUString name
(convertName
($4));
1638 rtl
::Reference
<unoidl
::detail
::SourceProviderInterfaceTypeEntityPad
> pad
(
1639 getCurrentPad
<unoidl
::detail
::SourceProviderInterfaceTypeEntityPad
>(
1641 if
(pad
->singleBase
) {
1644 "single-inheritance interface cannot have additional bases");
1647 if
(($2 & ~unoidl
::detail
::FLAG_OPTIONAL
) != 0) {
1650 "interface base can only be flagged as [optional]");
1653 bool opt
= ($2 & unoidl
::detail
::FLAG_OPTIONAL
) != 0;
1654 OUString orgName
(name
);
1655 unoidl
::detail
::SourceProviderEntity
const * p
;
1656 bool typedefed
= false
;
1657 if
(findEntity
(@
4, yyscanner
, data
, true
, &name
, &p
, &typedefed
, nullptr
)
1662 if
(p
== nullptr ||
!p
->entity.is
()
1663 || p
->entity
->getSort
() != unoidl
::Entity
::SORT_INTERFACE_TYPE
)
1667 ("interface type " + data
->currentName
+ " direct base " + name
1668 + " does not resolve to an existing interface type"));
1674 ("interface type " + data
->currentName
+ " direct base " + orgName
1675 + " is a typedef"));
1678 rtl
::Reference
<unoidl
::InterfaceTypeEntity
> ent
(
1679 static_cast
<unoidl
::InterfaceTypeEntity
*>(p
->entity.get
()));
1680 if
(data
->publishedContext
&& !ent
->isPublished
()) {
1683 ("published interface type " + data
->currentName
+ " direct base "
1684 + name
+ " is unpublished"));
1687 if
(!pad
->addDirectBase
(
1688 @
4, yyscanner
, data
,
1689 unoidl
::detail
::SourceProviderInterfaceTypeEntityPad
::DirectBase
(
1690 name
, ent
, annotations
($1)),
1699 deprecated_opt flagSection type identifier
1701 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
1702 unoidl
::detail
::SourceProviderType t
(*$3);
1704 OUString id
(convertName
($4));
1705 if
(($2 & unoidl
::detail
::FLAG_ATTRIBUTE
) == 0) {
1708 "interface attribute must be flagged as [attribute]");
1712 & ~
(unoidl
::detail
::FLAG_ATTRIBUTE | unoidl
::detail
::FLAG_BOUND
1713 | unoidl
::detail
::FLAG_READONLY
))
1718 ("interface attribute can only be flagged as [attribute,"
1719 " bound, readonly]"));
1723 case unoidl
::detail
::SourceProviderType
::TYPE_VOID
:
1724 case unoidl
::detail
::SourceProviderType
::TYPE_EXCEPTION
:
1727 ("illegal interface type " + data
->currentName
1728 + " direct attribute " + id
+ " type"));
1734 rtl
::Reference
<unoidl
::detail
::SourceProviderInterfaceTypeEntityPad
> pad
(
1735 getCurrentPad
<unoidl
::detail
::SourceProviderInterfaceTypeEntityPad
>(
1737 if
(!pad
->addDirectMember
(@
4, yyscanner
, data
, id
)) {
1740 pad
->directAttributes.emplace_back
(
1741 id
, t.getName
(), ($2 & unoidl
::detail
::FLAG_BOUND
) != 0,
1742 ($2 & unoidl
::detail
::FLAG_READONLY
) != 0,
1743 std
::vector
<OUString
>(), std
::vector
<OUString
>(), annotations
($1));
1745 attributeAccessDecls_opt
';'
1748 attributeAccessDecls_opt:
1749 '{' attributeAccessDecls
'}'
1753 attributeAccessDecls:
1754 attributeAccessDecls attributeAccessDecl
1756 if
(($1 & $2) != 0) {
1758 @
2, yyscanner
, "duplicate get/set attribute access declaration");
1761 $$
= unoidl
::detail
::SourceProviderAccessDecls
($1 |
$2);
1763 |
/* empty */ { $$
= unoidl
::detail
::SourceProviderAccessDecls
(0); }
1766 attributeAccessDecl:
1767 TOK_GET exceptionSpec
';'
1769 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
1770 rtl
::Reference
<unoidl
::detail
::SourceProviderInterfaceTypeEntityPad
>
1771 pad
(getCurrentPad
<unoidl
::detail
::SourceProviderInterfaceTypeEntityPad
>(
1773 assert
(!pad
->directAttributes.empty
());
1774 pad
->directAttributes.back
().getExceptions
= *$2;
1776 $$
= unoidl
::detail
::ACCESS_DECL_GET
;
1778 | TOK_SET exceptionSpec
';'
1780 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
1781 rtl
::Reference
<unoidl
::detail
::SourceProviderInterfaceTypeEntityPad
>
1782 pad
(getCurrentPad
<unoidl
::detail
::SourceProviderInterfaceTypeEntityPad
>(
1784 assert
(!pad
->directAttributes.empty
());
1785 pad
->directAttributes.back
().setExceptions
= *$2;
1787 if
(pad
->directAttributes.back
().readOnly
) {
1790 ("interface type " + data
->currentName
1791 + " direct read-only attribute "
1792 + pad
->directAttributes.back
().name
1793 + " cannot have set access declaration"));
1796 $$
= unoidl
::detail
::ACCESS_DECL_SET
;
1801 deprecated_opt type identifier
1803 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
1804 unoidl
::detail
::SourceProviderType t
(*$2);
1806 OUString id
(convertName
($3));
1807 if
(t.type
== unoidl
::detail
::SourceProviderType
::TYPE_EXCEPTION
) {
1810 ("illegal interface type " + data
->currentName
1811 + " direct method " + id
+ " return type"));
1814 rtl
::Reference
<unoidl
::detail
::SourceProviderInterfaceTypeEntityPad
> pad
(
1815 getCurrentPad
<unoidl
::detail
::SourceProviderInterfaceTypeEntityPad
>(
1817 if
(!pad
->addDirectMember
(@
3, yyscanner
, data
, id
)) {
1820 pad
->directMethods.emplace_back
(
1822 std
::vector
<unoidl
::InterfaceTypeEntity
::Method
::Parameter
>(),
1823 std
::vector
<OUString
>(), annotations
($1));
1825 '(' methodParams_opt
')' exceptionSpec_opt
';'
1827 if
($8 != nullptr
) {
1828 unoidl
::detail
::SourceProviderScannerData
* data
1829 = yyget_extra
(yyscanner
);
1830 rtl
::Reference
<unoidl
::detail
::SourceProviderInterfaceTypeEntityPad
>
1831 pad
(getCurrentPad
<unoidl
::detail
::SourceProviderInterfaceTypeEntityPad
>(
1833 assert
(!pad
->directMethods.empty
());
1834 pad
->directMethods.back
().exceptions
= *$8;
1846 methodParams
',' methodParam
1851 '[' direction
']' type identifier
1853 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
1854 unoidl
::detail
::SourceProviderType t
(*$4);
1856 OUString id
(convertName
($5));
1857 rtl
::Reference
<unoidl
::detail
::SourceProviderInterfaceTypeEntityPad
>
1858 pad
(getCurrentPad
<unoidl
::detail
::SourceProviderInterfaceTypeEntityPad
>(
1860 assert
(!pad
->directMethods.empty
());
1862 case unoidl
::detail
::SourceProviderType
::TYPE_VOID
:
1863 case unoidl
::detail
::SourceProviderType
::TYPE_EXCEPTION
:
1866 ("illegal interface type " + data
->currentName
1867 + " direct method " + pad
->directMethods.back
().name
1868 + " parameter " + id
+ " type"));
1874 for
(const auto
& i
: pad
->directMethods.back
().parameters
) {
1878 ("interface type " + data
->currentName
+ " direct method "
1879 + pad
->directMethods.back
().name
+ " parameter " + id
1880 + " has same identifier as another parameter"));
1884 pad
->directMethods.back
().parameters.emplace_back
(id
, t.getName
(), $2);
1889 TOK_IN
{ $$
= unoidl
::InterfaceTypeEntity
::Method
::Parameter
::DIRECTION_IN
; }
1891 { $$
= unoidl
::InterfaceTypeEntity
::Method
::Parameter
::DIRECTION_OUT
; }
1893 { $$
= unoidl
::InterfaceTypeEntity
::Method
::Parameter
::DIRECTION_IN_OUT
; }
1897 deprecated_opt published_opt TOK_TYPEDEF type identifier
';'
1899 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
1900 data
->publishedContext
= $2;
1901 unoidl
::detail
::SourceProviderType t
(*$4);
1903 OUString name
(convertToFullName
(data
, $5));
1904 // There is no good reason to forbid typedefs to VOID, to instantiated
1905 // polymorphic struct types, and to exception types, but some old client
1906 // code of registry data expects this typedef restriction (like the
1907 // assert(false) default in handleTypedef in
1908 // codemaker/source/javamaker/javatype.cxx), so forbid them for now:
1910 case unoidl
::detail
::SourceProviderType
::TYPE_VOID
:
1911 case unoidl
::detail
::SourceProviderType
::TYPE_EXCEPTION
:
1912 case unoidl
::detail
::SourceProviderType
::TYPE_INSTANTIATED_POLYMORPHIC_STRUCT
:
1913 error(@
4, yyscanner
, "bad typedef type");
1916 case unoidl
::detail
::SourceProviderType
::TYPE_ENUM
:
1917 case unoidl
::detail
::SourceProviderType
::TYPE_PLAIN_STRUCT
:
1918 case unoidl
::detail
::SourceProviderType
::TYPE_INTERFACE
:
1921 switch
(t.entity
->kind
) {
1922 case unoidl
::detail
::SourceProviderEntity
::KIND_INTERFACE_DECL
:
1925 case unoidl
::detail
::SourceProviderEntity
::KIND_PUBLISHED_INTERFACE_DECL
:
1927 case unoidl
::detail
::SourceProviderEntity
::KIND_MODULE
:
1930 assert
(t.entity
->entity.is
() || t.entity
->pad.is
());
1932 = !(t.entity
->entity.is
()
1933 ? static_cast
<unoidl
::PublishableEntity
*>(
1934 t.entity
->entity.get
())->isPublished
()
1935 : t.entity
->pad
->isPublished
());
1941 "published typedef " + name
+ " type is unpublished");
1946 case unoidl
::detail
::SourceProviderType
::TYPE_PARAMETER
:
1951 if
(!data
->entities.emplace
(
1953 unoidl
::detail
::SourceProviderEntity
(
1954 unoidl
::detail
::SourceProviderEntity
::KIND_LOCAL
,
1955 new unoidl
::TypedefEntity
(
1956 $2, t.getName
(), annotations
($1)))).
1959 error(@
5, yyscanner
, "multiple entities named " + name
);
1962 clearCurrentState
(data
);
1967 deprecated_opt published_opt TOK_CONSTANTS identifier
1969 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
1970 data
->publishedContext
= $2;
1971 convertToCurrentName
(data
, $4);
1972 if
(!data
->entities.emplace
(
1974 unoidl
::detail
::SourceProviderEntity
(
1975 new unoidl
::detail
::SourceProviderConstantGroupEntityPad
(
1979 error(@
4, yyscanner
, "multiple entities named " + data
->currentName
);
1983 '{' constants
'}' ';'
1985 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
1986 unoidl
::detail
::SourceProviderEntity
* ent
= getCurrentEntity
(data
);
1987 unoidl
::detail
::SourceProviderConstantGroupEntityPad
* pad
=
1988 dynamic_cast
<unoidl
::detail
::SourceProviderConstantGroupEntityPad
*>(
1990 assert
(pad
!= nullptr
);
1991 ent
->entity
= new unoidl
::ConstantGroupEntity
(
1992 pad
->isPublished
(), std
::move
(pad
->members
), annotations
($1));
1994 clearCurrentState
(data
);
2004 deprecated_opt TOK_CONST type identifier
'=' expr
';'
2006 OUString id
(convertName
($4));
2007 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
2008 rtl
::Reference
<unoidl
::detail
::SourceProviderConstantGroupEntityPad
> pad
(
2009 getCurrentPad
<unoidl
::detail
::SourceProviderConstantGroupEntityPad
>(
2011 unoidl
::detail
::SourceProviderType t
(*$3);
2013 unoidl
::ConstantValue v
(false
); // dummy value
2015 case unoidl
::detail
::SourceProviderType
::TYPE_BOOLEAN
:
2016 if
($6.type
!= unoidl
::detail
::SourceProviderExpr
::TYPE_BOOL
) {
2019 ("bad value of boolean-typed constant " + data
->currentName
2023 v
= unoidl
::ConstantValue
($6.bval
);
2025 case unoidl
::detail
::SourceProviderType
::TYPE_BYTE
:
2027 case unoidl
::detail
::SourceProviderExpr
::TYPE_INT
:
2028 if
($6.ival
< SAL_MIN_INT8 ||
$6.ival
> SAL_MAX_INT8
) {
2031 ("out-of-range byte-typed constant " + data
->currentName
2032 + "." + id
+ " value " + OUString
::number
($6.ival
)));
2035 v
= unoidl
::ConstantValue
(static_cast
<sal_Int8
>($6.ival
));
2037 case unoidl
::detail
::SourceProviderExpr
::TYPE_UINT
:
2038 if
($6.uval
> SAL_MAX_INT8
) {
2041 ("out-of-range byte-typed constant " + data
->currentName
2042 + "." + id
+ " value " + OUString
::number
($6.uval
)));
2045 v
= unoidl
::ConstantValue
(static_cast
<sal_Int8
>($6.uval
));
2050 ("bad value of byte-typed constant " + data
->currentName
+ "."
2056 case unoidl
::detail
::SourceProviderType
::TYPE_SHORT
:
2058 case unoidl
::detail
::SourceProviderExpr
::TYPE_INT
:
2059 if
($6.ival
< SAL_MIN_INT16 ||
$6.ival
> SAL_MAX_INT16
) {
2062 ("out-of-range short-typed constant " + data
->currentName
2063 + "." + id
+ " value " + OUString
::number
($6.ival
)));
2066 v
= unoidl
::ConstantValue
(static_cast
<sal_Int16
>($6.ival
));
2068 case unoidl
::detail
::SourceProviderExpr
::TYPE_UINT
:
2069 if
($6.uval
> SAL_MAX_INT16
) {
2072 ("out-of-range short-typed constant " + data
->currentName
2073 + "." + id
+ " value " + OUString
::number
($6.uval
)));
2076 v
= unoidl
::ConstantValue
(static_cast
<sal_Int16
>($6.uval
));
2081 ("bad value of short-typed constant " + data
->currentName
2087 case unoidl
::detail
::SourceProviderType
::TYPE_UNSIGNED_SHORT
:
2089 case unoidl
::detail
::SourceProviderExpr
::TYPE_INT
:
2090 if
($6.ival
< 0 ||
$6.ival
> SAL_MAX_UINT16
) {
2093 ("out-of-range unsigned-short-typed constant "
2094 + data
->currentName
+ "." + id
+ " value "
2095 + OUString
::number
($6.ival
)));
2098 v
= unoidl
::ConstantValue
(static_cast
<sal_uInt16
>($6.ival
));
2100 case unoidl
::detail
::SourceProviderExpr
::TYPE_UINT
:
2101 if
($6.uval
> SAL_MAX_UINT16
) {
2104 ("out-of-range unsigned-short-typed constant "
2105 + data
->currentName
+ "." + id
+ " value "
2106 + OUString
::number
($6.uval
)));
2109 v
= unoidl
::ConstantValue
(static_cast
<sal_uInt16
>($6.uval
));
2114 ("bad value of unsigned-short-typed constant "
2115 + data
->currentName
+ "." + id
));
2120 case unoidl
::detail
::SourceProviderType
::TYPE_LONG
:
2122 case unoidl
::detail
::SourceProviderExpr
::TYPE_INT
:
2123 if
($6.ival
< SAL_MIN_INT32 ||
$6.ival
> SAL_MAX_INT32
) {
2126 ("out-of-range long-typed constant " + data
->currentName
2127 + "." + id
+ " value " + OUString
::number
($6.ival
)));
2130 v
= unoidl
::ConstantValue
(static_cast
<sal_Int32
>($6.ival
));
2132 case unoidl
::detail
::SourceProviderExpr
::TYPE_UINT
:
2133 if
($6.uval
> SAL_MAX_INT32
) {
2136 ("out-of-range long-typed constant " + data
->currentName
2137 + "." + id
+ " value " + OUString
::number
($6.uval
)));
2140 v
= unoidl
::ConstantValue
(static_cast
<sal_Int32
>($6.uval
));
2145 ("bad value of long-typed constant " + data
->currentName
2151 case unoidl
::detail
::SourceProviderType
::TYPE_UNSIGNED_LONG
:
2153 case unoidl
::detail
::SourceProviderExpr
::TYPE_INT
:
2154 if
($6.ival
< 0 ||
$6.ival
> SAL_MAX_UINT32
) {
2157 ("out-of-range unsigned-long-typed constant "
2158 + data
->currentName
+ "." + id
+ " value "
2159 + OUString
::number
($6.ival
)));
2162 v
= unoidl
::ConstantValue
(static_cast
<sal_uInt32
>($6.ival
));
2164 case unoidl
::detail
::SourceProviderExpr
::TYPE_UINT
:
2165 if
($6.uval
> SAL_MAX_UINT32
) {
2168 ("out-of-range unsigned-long-typed constant "
2169 + data
->currentName
+ "." + id
+ " value "
2170 + OUString
::number
($6.uval
)));
2173 v
= unoidl
::ConstantValue
(static_cast
<sal_uInt32
>($6.uval
));
2178 ("bad value of unsigned-long-typed constant "
2179 + data
->currentName
+ "." + id
));
2184 case unoidl
::detail
::SourceProviderType
::TYPE_HYPER
:
2186 case unoidl
::detail
::SourceProviderExpr
::TYPE_INT
:
2187 v
= unoidl
::ConstantValue
($6.ival
);
2189 case unoidl
::detail
::SourceProviderExpr
::TYPE_UINT
:
2190 if
($6.uval
> SAL_MAX_INT64
) {
2193 ("out-of-range hyper-typed constant " + data
->currentName
2194 + "." + id
+ " value " + OUString
::number
($6.uval
)));
2197 v
= unoidl
::ConstantValue
(static_cast
<sal_Int64
>($6.uval
));
2202 ("bad value of hyper-typed constant " + data
->currentName
2208 case unoidl
::detail
::SourceProviderType
::TYPE_UNSIGNED_HYPER
:
2210 case unoidl
::detail
::SourceProviderExpr
::TYPE_INT
:
2214 ("out-of-range unsigned-hyper-typed constant "
2215 + data
->currentName
+ "." + id
+ " value "
2216 + OUString
::number
($6.ival
)));
2219 v
= unoidl
::ConstantValue
(static_cast
<sal_uInt64
>($6.ival
));
2221 case unoidl
::detail
::SourceProviderExpr
::TYPE_UINT
:
2222 v
= unoidl
::ConstantValue
($6.uval
);
2227 ("bad value of unsigned-hyper-typed constant "
2228 + data
->currentName
+ "." + id
));
2233 case unoidl
::detail
::SourceProviderType
::TYPE_FLOAT
:
2235 case unoidl
::detail
::SourceProviderExpr
::TYPE_BOOL
:
2238 ("bad boolean value of float-typed constant "
2239 + data
->currentName
+ "." + id
));
2242 case unoidl
::detail
::SourceProviderExpr
::TYPE_INT
:
2243 v
= unoidl
::ConstantValue
(static_cast
<float>($6.ival
));
2245 case unoidl
::detail
::SourceProviderExpr
::TYPE_UINT
:
2246 v
= unoidl
::ConstantValue
(static_cast
<float>($6.uval
));
2248 case unoidl
::detail
::SourceProviderExpr
::TYPE_FLOAT
:
2249 v
= unoidl
::ConstantValue
(static_cast
<float>($6.fval
));
2253 case unoidl
::detail
::SourceProviderType
::TYPE_DOUBLE
:
2255 case unoidl
::detail
::SourceProviderExpr
::TYPE_BOOL
:
2258 ("bad boolean value of double-typed constant "
2259 + data
->currentName
+ "." + id
));
2262 case unoidl
::detail
::SourceProviderExpr
::TYPE_INT
:
2263 v
= unoidl
::ConstantValue
(static_cast
<double>($6.ival
));
2265 case unoidl
::detail
::SourceProviderExpr
::TYPE_UINT
:
2266 v
= unoidl
::ConstantValue
(static_cast
<double>($6.uval
));
2268 case unoidl
::detail
::SourceProviderExpr
::TYPE_FLOAT
:
2269 v
= unoidl
::ConstantValue
($6.fval
);
2276 "bad type for constant " + data
->currentName
+ "." + id
);
2280 pad
->members.emplace_back
(id
, v
, annotations
($1));
2284 singleInterfaceBasedServiceDefn:
2285 deprecated_opt published_opt TOK_SERVICE identifier singleInheritance
2287 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
2288 data
->publishedContext
= $2;
2289 convertToCurrentName
(data
, $4);
2290 OUString base
(convertName
($5));
2291 unoidl
::detail
::SourceProviderEntity
const * p
;
2292 if
(findEntity
(@
5, yyscanner
, data
, false
, &base
, &p
, nullptr
, nullptr
)
2297 bool ifcBase
= false
;
2298 bool pubBase
= false
;
2301 case unoidl
::detail
::SourceProviderEntity
::KIND_INTERFACE_DECL
:
2305 case unoidl
::detail
::SourceProviderEntity
::KIND_PUBLISHED_INTERFACE_DECL
:
2311 && (p
->entity
->getSort
()
2312 == unoidl
::Entity
::SORT_INTERFACE_TYPE
))
2315 pubBase
= static_cast
<unoidl
::InterfaceTypeEntity
*>(
2316 p
->entity.get
())->isPublished
();
2324 ("single-interface--based service " + data
->currentName
+ " base "
2325 + base
+ " does not resolve to an interface type"));
2328 if
($2 && !pubBase
) {
2331 ("published single-interface--based service " + data
->currentName
2332 + " base " + base
+ " is unpublished"));
2335 if
(!data
->entities.emplace
(
2337 unoidl
::detail
::SourceProviderEntity
(
2338 new unoidl
::detail
::SourceProviderSingleInterfaceBasedServiceEntityPad
(
2342 error(@
4, yyscanner
, "multiple entities named " + data
->currentName
);
2348 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
2349 unoidl
::detail
::SourceProviderEntity
* ent
= getCurrentEntity
(data
);
2350 unoidl
::detail
::SourceProviderSingleInterfaceBasedServiceEntityPad
* pad
=
2351 dynamic_cast
<unoidl
::detail
::SourceProviderSingleInterfaceBasedServiceEntityPad
*>(
2353 assert
(pad
!= nullptr
);
2354 std
::vector
<unoidl
::SingleInterfaceBasedServiceEntity
::Constructor
> ctors
;
2356 for
(const auto
& i
: pad
->constructors
) {
2357 std
::vector
<unoidl
::SingleInterfaceBasedServiceEntity
::Constructor
::Parameter
> parms
;
2358 for
(auto
& j
: i.parameters
) {
2359 parms.emplace_back
(j.name
, j.type.getName
(), j.rest
);
2362 unoidl
::SingleInterfaceBasedServiceEntity
::Constructor
(
2363 i.name
, std
::vector
(parms
), std
::vector
(i.exceptions
), std
::vector
(i.annotations
)));
2366 assert
(pad
->constructors.empty
());
2368 unoidl
::SingleInterfaceBasedServiceEntity
::Constructor
());
2370 ent
->entity
= new unoidl
::SingleInterfaceBasedServiceEntity
(
2371 pad
->isPublished
(), pad
->base
, std
::move
(ctors
), annotations
($1));
2373 clearCurrentState
(data
);
2378 '{' ctors
'}' { $$
= true
; }
2379 |
/* empty */ { $$
= false
; }
2388 deprecated_opt identifier
2390 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
2391 OUString id
(convertName
($2));
2392 rtl
::Reference
<unoidl
::detail
::SourceProviderSingleInterfaceBasedServiceEntityPad
>
2393 pad
(getCurrentPad
<unoidl
::detail
::SourceProviderSingleInterfaceBasedServiceEntityPad
>(
2395 for
(const auto
& i
: pad
->constructors
) {
2399 ("single-interface--based service " + data
->currentName
2400 + " constructor " + id
2401 + " has same identifier as another constructor"));
2405 pad
->constructors.push_back
(
2406 unoidl
::detail
::SourceProviderSingleInterfaceBasedServiceEntityPad
::Constructor
(
2407 id
, annotations
($1)));
2409 '(' ctorParams_opt
')' exceptionSpec_opt
';'
2411 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
2412 rtl
::Reference
<unoidl
::detail
::SourceProviderSingleInterfaceBasedServiceEntityPad
>
2413 pad
(getCurrentPad
<unoidl
::detail
::SourceProviderSingleInterfaceBasedServiceEntityPad
>(
2415 assert
(!pad
->constructors.empty
());
2416 if
($7 != nullptr
) {
2417 pad
->constructors.back
().exceptions
= *$7;
2420 for
(auto i
(pad
->constructors.begin
()); i
!= pad
->constructors.end
() - 1;
2423 if
(i
->parameters.size
()
2424 == pad
->constructors.back
().parameters.size
())
2428 j
(i
->parameters.begin
()),
2429 k
(pad
->constructors.back
().parameters.begin
());
2430 j
!= i
->parameters.end
(); ++j
, ++k
)
2432 if
(!j
->type.equals
(k
->type
) || j
->rest
!= k
->rest
) {
2440 ("single-interface--based service " + data
->currentName
2441 + " constructor " + pad
->constructors.back
().name
2442 + " has similar paramete list to constructor "
2457 ctorParams
',' ctorParam
2462 '[' direction
']' type ellipsis_opt identifier
2464 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
2465 unoidl
::detail
::SourceProviderType t
(*$4);
2467 OUString id
(convertName
($6));
2468 rtl
::Reference
<unoidl
::detail
::SourceProviderSingleInterfaceBasedServiceEntityPad
>
2469 pad
(getCurrentPad
<unoidl
::detail
::SourceProviderSingleInterfaceBasedServiceEntityPad
>(
2471 assert
(!pad
->constructors.empty
());
2472 if
($2 != unoidl
::InterfaceTypeEntity
::Method
::Parameter
::DIRECTION_IN
) {
2475 ("single-interface--based service " + data
->currentName
2476 + " constructor " + pad
->constructors.back
().name
+ " parameter "
2477 + id
+ " direction must be [in]"));
2481 case unoidl
::detail
::SourceProviderType
::TYPE_VOID
:
2482 case unoidl
::detail
::SourceProviderType
::TYPE_EXCEPTION
:
2485 ("illegal single-interface--based service " + data
->currentName
2486 + " constructor " + pad
->constructors.back
().name
+ " parameter "
2494 if
(t.type
!= unoidl
::detail
::SourceProviderType
::TYPE_ANY
) {
2497 ("illegal single-interface--based service "
2498 + data
->currentName
+ " constructor "
2499 + pad
->constructors.back
().name
+ " rest parameter " + id
2500 + " non-any type"));
2503 if
(!pad
->constructors.back
().parameters.empty
()) {
2506 ("single-interface--based service " + data
->currentName
2507 + " constructor " + pad
->constructors.back
().name
2508 + " rest parameter " + id
+ " must be first parameter"));
2511 } else if
(!pad
->constructors.back
().parameters.empty
()
2512 && pad
->constructors.back
().parameters.back
().rest
)
2516 ("single-interface--based service " + data
->currentName
2517 + " constructor " + pad
->constructors.back
().name
2518 + " rest parameter must be last parameter"));
2521 for
(const auto
& i
: pad
->constructors.back
().parameters
) {
2525 ("single-interface--based service " + data
->currentName
2526 + " constructor " + pad
->constructors.back
().name
2527 + " parameter " + id
2528 + " has same identifier as another parameter"));
2532 pad
->constructors.back
().parameters.push_back
(
2533 unoidl
::detail
::SourceProviderSingleInterfaceBasedServiceEntityPad
::Constructor
::Parameter
(
2534 id
, std
::move
(t
), $5));
2539 TOK_ELLIPSIS
{ $$
= true
; }
2540 |
/* empty */ { $$
= false
; }
2542 accumulationBasedServiceDefn:
2543 deprecated_opt published_opt TOK_SERVICE identifier
2545 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
2546 data
->publishedContext
= $2;
2547 convertToCurrentName
(data
, $4);
2548 if
(!data
->entities.emplace
(
2550 unoidl
::detail
::SourceProviderEntity
(
2551 new unoidl
::detail
::SourceProviderAccumulationBasedServiceEntityPad
(
2555 error(@
4, yyscanner
, "multiple entities named " + data
->currentName
);
2559 '{' serviceMembers
'}' ';'
2561 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
2562 unoidl
::detail
::SourceProviderEntity
* ent
= getCurrentEntity
(data
);
2563 unoidl
::detail
::SourceProviderAccumulationBasedServiceEntityPad
* pad
=
2564 dynamic_cast
<unoidl
::detail
::SourceProviderAccumulationBasedServiceEntityPad
*>(
2566 assert
(pad
!= nullptr
);
2567 ent
->entity
= new unoidl
::AccumulationBasedServiceEntity
(
2568 pad
->isPublished
(), std
::move
(pad
->directMandatoryBaseServices
),
2569 std
::move
(pad
->directOptionalBaseServices
), std
::move
(pad
->directMandatoryBaseInterfaces
),
2570 std
::move
(pad
->directOptionalBaseInterfaces
), std
::move
(pad
->directProperties
),
2573 clearCurrentState
(data
);
2578 serviceMembers serviceMember
2584 | serviceInterfaceBase
2589 deprecated_opt flagSection_opt TOK_SERVICE name
';'
2591 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
2592 OUString name
(convertName
($4));
2593 rtl
::Reference
<unoidl
::detail
::SourceProviderAccumulationBasedServiceEntityPad
> pad
(
2594 getCurrentPad
<unoidl
::detail
::SourceProviderAccumulationBasedServiceEntityPad
>(
2596 if
(($2 & ~unoidl
::detail
::FLAG_OPTIONAL
) != 0) {
2599 "service base can only be flagged as [optional]");
2602 bool opt
= ($2 & unoidl
::detail
::FLAG_OPTIONAL
) != 0;
2603 unoidl
::detail
::SourceProviderEntity
const * p
;
2604 if
(findEntity
(@
4, yyscanner
, data
, false
, &name
, &p
, nullptr
, nullptr
)
2609 if
(p
== nullptr ||
!p
->entity.is
()
2610 ||
(p
->entity
->getSort
()
2611 != unoidl
::Entity
::SORT_ACCUMULATION_BASED_SERVICE
))
2615 ("accumulation-based service " + data
->currentName
2616 + " direct base service " + name
2617 + " does not resolve to an accumulation-based service"));
2620 if
(data
->publishedContext
2621 && !static_cast
<unoidl
::AccumulationBasedServiceEntity
*>(
2622 p
->entity.get
())->isPublished
())
2626 ("published accumulation-based service " + data
->currentName
2627 + " direct base service " + name
+ " is unpublished"));
2630 std
::vector
<unoidl
::AnnotatedReference
> & v
(
2632 ? pad
->directOptionalBaseServices
: pad
->directMandatoryBaseServices
);
2633 for
(const auto
& i
: v
) {
2634 if
(name
== i.name
) {
2637 ("accumulation-based service " + data
->currentName
2638 + " duplicate direct base service " + name
));
2642 v.emplace_back
(name
, annotations
($1));
2646 serviceInterfaceBase:
2647 deprecated_opt flagSection_opt TOK_INTERFACE name
';'
2649 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
2650 OUString name
(convertName
($4));
2651 rtl
::Reference
<unoidl
::detail
::SourceProviderAccumulationBasedServiceEntityPad
> pad
(
2652 getCurrentPad
<unoidl
::detail
::SourceProviderAccumulationBasedServiceEntityPad
>(
2654 if
(($2 & ~unoidl
::detail
::FLAG_OPTIONAL
) != 0) {
2657 "interface base can only be flagged as [optional]");
2660 bool opt
= ($2 & unoidl
::detail
::FLAG_OPTIONAL
) != 0;
2661 unoidl
::detail
::SourceProviderEntity
const * p
;
2662 if
(findEntity
(@
4, yyscanner
, data
, false
, &name
, &p
, nullptr
, nullptr
)
2667 bool ifcBase
= false
;
2668 bool pubBase
= false
;
2671 case unoidl
::detail
::SourceProviderEntity
::KIND_INTERFACE_DECL
:
2675 case unoidl
::detail
::SourceProviderEntity
::KIND_PUBLISHED_INTERFACE_DECL
:
2681 && (p
->entity
->getSort
()
2682 == unoidl
::Entity
::SORT_INTERFACE_TYPE
))
2685 pubBase
= static_cast
<unoidl
::InterfaceTypeEntity
*>(
2686 p
->entity.get
())->isPublished
();
2694 ("accumulation-based service " + data
->currentName
2695 + " direct base interface " + name
2696 + " does not resolve to an interface type"));
2699 if
(data
->publishedContext
&& !opt
&& !pubBase
) {
2702 ("published accumulation-based service " + data
->currentName
2703 + " direct base interface " + name
+ " is unpublished"));
2706 std
::vector
<unoidl
::AnnotatedReference
> & v
(
2708 ? pad
->directOptionalBaseInterfaces
2709 : pad
->directMandatoryBaseInterfaces
);
2710 for
(const auto
& i
: v
) {
2711 if
(name
== i.name
) {
2714 ("accumulation-based service " + data
->currentName
2715 + " duplicate direct base interface " + name
));
2719 v.emplace_back
(name
, annotations
($1));
2724 deprecated_opt flagSection type identifier
';'
2726 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
2727 unoidl
::detail
::SourceProviderType t
(*$3);
2729 OUString id
(convertName
($4));
2730 if
(($2 & unoidl
::detail
::FLAG_PROPERTY
) == 0) {
2733 ("accumulation-based service property must be flagged as"
2738 & ~
(unoidl
::detail
::FLAG_BOUND | unoidl
::detail
::FLAG_CONSTRAINED
2739 | unoidl
::detail
::FLAG_MAYBEAMBIGUOUS
2740 | unoidl
::detail
::FLAG_MAYBEDEFAULT
2741 | unoidl
::detail
::FLAG_MAYBEVOID | unoidl
::detail
::FLAG_OPTIONAL
2742 | unoidl
::detail
::FLAG_PROPERTY | unoidl
::detail
::FLAG_READONLY
2743 | unoidl
::detail
::FLAG_REMOVABLE
2744 | unoidl
::detail
::FLAG_TRANSIENT
))
2749 ("accumulation-based service property can only be flagged as"
2750 " [property, bound, constrained, maybeambiguous, maybedefault,"
2751 " maybevoid, optional, readonly, removable, transient]"));
2755 if
(($2 & unoidl
::detail
::FLAG_BOUND
) != 0) {
2756 att |
= unoidl
::AccumulationBasedServiceEntity
::Property
::ATTRIBUTE_BOUND
;
2758 if
(($2 & unoidl
::detail
::FLAG_CONSTRAINED
) != 0) {
2759 att |
= unoidl
::AccumulationBasedServiceEntity
::Property
::ATTRIBUTE_CONSTRAINED
;
2761 if
(($2 & unoidl
::detail
::FLAG_MAYBEAMBIGUOUS
) != 0) {
2762 att |
= unoidl
::AccumulationBasedServiceEntity
::Property
::ATTRIBUTE_MAYBE_AMBIGUOUS
;
2764 if
(($2 & unoidl
::detail
::FLAG_MAYBEDEFAULT
) != 0) {
2765 att |
= unoidl
::AccumulationBasedServiceEntity
::Property
::ATTRIBUTE_MAYBE_DEFAULT
;
2767 if
(($2 & unoidl
::detail
::FLAG_MAYBEVOID
) != 0) {
2768 att |
= unoidl
::AccumulationBasedServiceEntity
::Property
::ATTRIBUTE_MAYBE_VOID
;
2770 if
(($2 & unoidl
::detail
::FLAG_OPTIONAL
) != 0) {
2771 att |
= unoidl
::AccumulationBasedServiceEntity
::Property
::ATTRIBUTE_OPTIONAL
;
2773 if
(($2 & unoidl
::detail
::FLAG_READONLY
) != 0) {
2774 att |
= unoidl
::AccumulationBasedServiceEntity
::Property
::ATTRIBUTE_READ_ONLY
;
2776 if
(($2 & unoidl
::detail
::FLAG_REMOVABLE
) != 0) {
2777 att |
= unoidl
::AccumulationBasedServiceEntity
::Property
::ATTRIBUTE_REMOVABLE
;
2779 if
(($2 & unoidl
::detail
::FLAG_TRANSIENT
) != 0) {
2780 att |
= unoidl
::AccumulationBasedServiceEntity
::Property
::ATTRIBUTE_TRANSIENT
;
2783 case unoidl
::detail
::SourceProviderType
::TYPE_VOID
:
2784 case unoidl
::detail
::SourceProviderType
::TYPE_EXCEPTION
:
2787 ("illegal accumulation-based service " + data
->currentName
2788 + " direct property " + id
+ " type"));
2794 rtl
::Reference
<unoidl
::detail
::SourceProviderAccumulationBasedServiceEntityPad
>
2795 pad
(getCurrentPad
<unoidl
::detail
::SourceProviderAccumulationBasedServiceEntityPad
>(
2797 for
(const auto
& i
: pad
->directProperties
) {
2801 ("accumulation-based service " + data
->currentName
2802 + " duplicate direct property " + id
));
2806 pad
->directProperties.emplace_back
(
2808 unoidl
::AccumulationBasedServiceEntity
::Property
::Attributes
(att
),
2813 interfaceBasedSingletonDefn:
2814 deprecated_opt published_opt TOK_SINGLETON identifier singleInheritance
';'
2816 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
2817 data
->publishedContext
= $2;
2818 OUString name
(convertToFullName
(data
, $4));
2819 OUString base
(convertName
($5));
2820 unoidl
::detail
::SourceProviderEntity
const * p
;
2821 if
(findEntity
(@
5, yyscanner
, data
, false
, &base
, &p
, nullptr
, nullptr
)
2826 bool ifcBase
= false
;
2827 bool pubBase
= false
;
2830 case unoidl
::detail
::SourceProviderEntity
::KIND_INTERFACE_DECL
:
2834 case unoidl
::detail
::SourceProviderEntity
::KIND_PUBLISHED_INTERFACE_DECL
:
2840 && (p
->entity
->getSort
()
2841 == unoidl
::Entity
::SORT_INTERFACE_TYPE
))
2844 pubBase
= static_cast
<unoidl
::InterfaceTypeEntity
*>(
2845 p
->entity.get
())->isPublished
();
2853 ("interface-based singleton " + name
+ " base " + base
2854 + " does not resolve to an interface type"));
2857 if
($2 && !pubBase
) {
2860 ("published interface-based singleton " + name
+ " base " + base
2861 + " is unpublished"));
2864 if
(!data
->entities.emplace
(
2866 unoidl
::detail
::SourceProviderEntity
(
2867 unoidl
::detail
::SourceProviderEntity
::KIND_LOCAL
,
2868 new unoidl
::InterfaceBasedSingletonEntity
(
2869 $2, base
, annotations
($1)))).
2872 error(@
4, yyscanner
, "multiple entities named " + name
);
2875 clearCurrentState
(data
);
2879 serviceBasedSingletonDefn:
2880 deprecated_opt published_opt TOK_SINGLETON identifier
'{' TOK_SERVICE name
';'
2883 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
2884 data
->publishedContext
= $2;
2885 OUString name
(convertToFullName
(data
, $4));
2886 OUString base
(convertName
($7));
2887 unoidl
::detail
::SourceProviderEntity
const * p
;
2888 if
(findEntity
(@
7, yyscanner
, data
, false
, &base
, &p
, nullptr
, nullptr
)
2895 ||
(p
->entity
->getSort
()
2896 != unoidl
::Entity
::SORT_ACCUMULATION_BASED_SERVICE
))
2900 ("service-based singleton " + name
+ " base " + base
2901 + " does not resolve to an accumulation-based service"));
2905 && !static_cast
<unoidl
::AccumulationBasedServiceEntity
*>(
2906 p
->entity.get
())->isPublished
())
2910 ("published service-based singleton " + name
+ " base " + base
2911 + " is unpublished"));
2914 if
(!data
->entities.emplace
(
2916 unoidl
::detail
::SourceProviderEntity
(
2917 unoidl
::detail
::SourceProviderEntity
::KIND_LOCAL
,
2918 new unoidl
::ServiceBasedSingletonEntity
(
2919 $2, base
, annotations
($1)))).
2922 error(@
4, yyscanner
, "multiple entities named " + name
);
2925 clearCurrentState
(data
);
2929 singleInheritance_opt:
2931 |
/* empty */ { $$
= nullptr
; }
2934 singleInheritance: ':' name
{ $$
= $2; }
2939 |
/* empty */ { $$
= nullptr
; }
2942 exceptionSpec: TOK_RAISES
'(' exceptions
')' { $$
= $3; }
2948 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
2949 OUString name
(convertName
($3));
2950 unoidl
::detail
::SourceProviderEntity
const * p
;
2951 if
(findEntity
(@
3, yyscanner
, data
, false
, &name
, &p
, nullptr
, nullptr
)
2954 delete
$1; /* see commented-out %destructor above */
2959 ||
(p
->entity
->getSort
() != unoidl
::Entity
::SORT_EXCEPTION_TYPE
))
2961 delete
$1; /* see commented-out %destructor above */
2964 ("exception " + name
+ " does not resolve to an exception type"));
2967 if
(data
->publishedContext
2968 && !(static_cast
<unoidl
::ExceptionTypeEntity
*>(p
->entity.get
())
2971 delete
$1; /* see commented-out %destructor above */
2974 ("unpublished exception " + name
+ " used in published context"));
2977 if
(std
::find
($1->begin
(), $1->end
(), name
) != $1->end
()) {
2978 delete
$1; /* see commented-out %destructor above */
2980 @
3, yyscanner
, ("exception " + name
+ " listed more than once"));
2983 $1->push_back
(name
);
2988 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
2989 OUString name
(convertName
($1));
2990 unoidl
::detail
::SourceProviderEntity
const * p
;
2991 if
(findEntity
(@
1, yyscanner
, data
, false
, &name
, &p
, nullptr
, nullptr
)
2998 ||
(p
->entity
->getSort
() != unoidl
::Entity
::SORT_EXCEPTION_TYPE
))
3002 ("exception " + name
+ " does not resolve to an exception type"));
3005 if
(data
->publishedContext
3006 && !(static_cast
<unoidl
::ExceptionTypeEntity
*>(p
->entity.get
())
3011 ("unpublished exception " + name
+ " used in published context"));
3014 $$
= new std
::vector
<OUString
>; $$
->push_back
(name
);
3019 deprecated_opt
/*ignored*/ published_opt TOK_INTERFACE identifier
';'
3021 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
3022 data
->publishedContext
= $2;
3023 OUString name
(convertToFullName
(data
, $4));
3024 std
::pair
<std
::map
<OUString
, unoidl
::detail
::SourceProviderEntity
>::iterator
, bool> p
(
3025 data
->entities.emplace
(
3027 unoidl
::detail
::SourceProviderEntity
(
3029 ? unoidl
::detail
::SourceProviderEntity
::KIND_PUBLISHED_INTERFACE_DECL
3030 : unoidl
::detail
::SourceProviderEntity
::KIND_INTERFACE_DECL
)));
3032 switch
(p.first
->second.kind
) {
3033 case unoidl
::detail
::SourceProviderEntity
::KIND_INTERFACE_DECL
:
3035 p.first
->second.kind
3036 = unoidl
::detail
::SourceProviderEntity
::KIND_PUBLISHED_INTERFACE_DECL
;
3039 case unoidl
::detail
::SourceProviderEntity
::KIND_PUBLISHED_INTERFACE_DECL
:
3042 assert
(p.first
->second.entity.is
());
3043 if
(p.first
->second.entity
->getSort
()
3044 != unoidl
::Entity
::SORT_INTERFACE_TYPE
)
3048 "multiple entities named " + data
->currentName
);
3052 && !static_cast
<unoidl
::InterfaceTypeEntity
*>(
3053 p.first
->second.entity.get
())->isPublished
())
3057 ("published interface type declaration "
3058 + data
->currentName
+ " has been defined unpublished"));
3063 clearCurrentState
(data
);
3068 TOK_PUBLISHED
{ $$
= true
; }
3069 |
/* empty */ { $$
= false
; }
3074 |
/* empty */ { $$
= unoidl
::detail
::SourceProviderFlags
(0); }
3077 flagSection: '[' flags
']' { $$
= $2; }
3083 if
(($1 & $3) != 0) {
3084 error(@
3, yyscanner
, "duplicate flag " + flagName
($3));
3087 $$
= unoidl
::detail
::SourceProviderFlags
($1 |
$3);
3093 TOK_ATTRIBUTE
{ $$
= unoidl
::detail
::FLAG_ATTRIBUTE
; }
3094 | TOK_BOUND
{ $$
= unoidl
::detail
::FLAG_BOUND
; }
3095 | TOK_CONSTRAINED
{ $$
= unoidl
::detail
::FLAG_CONSTRAINED
; }
3096 | TOK_MAYBEAMBIGUOUS
{ $$
= unoidl
::detail
::FLAG_MAYBEAMBIGUOUS
; }
3097 | TOK_MAYBEDEFAULT
{ $$
= unoidl
::detail
::FLAG_MAYBEDEFAULT
; }
3098 | TOK_MAYBEVOID
{ $$
= unoidl
::detail
::FLAG_MAYBEVOID
; }
3099 | TOK_OPTIONAL
{ $$
= unoidl
::detail
::FLAG_OPTIONAL
; }
3100 | TOK_PROPERTY
{ $$
= unoidl
::detail
::FLAG_PROPERTY
; }
3101 | TOK_READONLY
{ $$
= unoidl
::detail
::FLAG_READONLY
; }
3102 | TOK_REMOVABLE
{ $$
= unoidl
::detail
::FLAG_REMOVABLE
; }
3103 | TOK_TRANSIENT
{ $$
= unoidl
::detail
::FLAG_TRANSIENT
; }
3112 if
(!coerce
(@
1, yyscanner
, &$1, &$3)) {
3116 case unoidl
::detail
::SourceProviderExpr
::TYPE_INT
:
3117 $$
= unoidl
::detail
::SourceProviderExpr
::Int
($1.ival |
$3.ival
);
3119 case unoidl
::detail
::SourceProviderExpr
::TYPE_UINT
:
3120 $$
= unoidl
::detail
::SourceProviderExpr
::Uint
($1.uval |
$3.uval
);
3123 error(@
1, yyscanner
, "arguments of non-integer type to \"|\"");
3134 if
(!coerce
(@
1, yyscanner
, &$1, &$3)) {
3138 case unoidl
::detail
::SourceProviderExpr
::TYPE_INT
:
3139 $$
= unoidl
::detail
::SourceProviderExpr
::Int
($1.ival ^
$3.ival
);
3141 case unoidl
::detail
::SourceProviderExpr
::TYPE_UINT
:
3142 $$
= unoidl
::detail
::SourceProviderExpr
::Uint
($1.uval ^
$3.uval
);
3145 error(@
1, yyscanner
, "arguments of non-integer type to \"^\"");
3154 andExpr
'&' shiftExpr
3156 if
(!coerce
(@
1, yyscanner
, &$1, &$3)) {
3160 case unoidl
::detail
::SourceProviderExpr
::TYPE_INT
:
3161 $$
= unoidl
::detail
::SourceProviderExpr
::Int
($1.ival
& $3.ival
);
3163 case unoidl
::detail
::SourceProviderExpr
::TYPE_UINT
:
3164 $$
= unoidl
::detail
::SourceProviderExpr
::Uint
($1.uval
& $3.uval
);
3167 error(@
1, yyscanner
, "arguments of non-integer type to \"&\"");
3176 shiftExpr TOK_LEFTSHIFT addExpr
3180 case unoidl
::detail
::SourceProviderExpr
::TYPE_INT
:
3181 if
($3.ival
< 0 ||
$3.ival
> 63) {
3184 ("out-of-range shift argument " + OUString
::number
($3.ival
)
3188 n
= static_cast
<int>($3.ival
);
3190 case unoidl
::detail
::SourceProviderExpr
::TYPE_UINT
:
3194 ("out-of-range shift argument " + OUString
::number
($3.uval
)
3198 n
= static_cast
<int>($3.uval
);
3201 error(@
3, yyscanner
, "right argument of non-integer type to \"<<\"");
3205 case unoidl
::detail
::SourceProviderExpr
::TYPE_INT
:
3209 ("cannot left-shift negative argument "
3210 + OUString
::number
($1.ival
)));
3213 $$
= unoidl
::detail
::SourceProviderExpr
::Int
($1.ival
<< n
);
3215 case unoidl
::detail
::SourceProviderExpr
::TYPE_UINT
:
3216 $$
= unoidl
::detail
::SourceProviderExpr
::Uint
($1.uval
<< n
);
3219 error(@
1, yyscanner
, "left argument of non-integer type to \"<<\"");
3224 | shiftExpr TOK_RIGHTSHIFT addExpr
3228 case unoidl
::detail
::SourceProviderExpr
::TYPE_INT
:
3229 if
($3.ival
< 0 ||
$3.ival
> 63) {
3232 ("out-of-range shift argument " + OUString
::number
($3.ival
)
3236 n
= static_cast
<int>($3.ival
);
3238 case unoidl
::detail
::SourceProviderExpr
::TYPE_UINT
:
3242 ("out-of-range shift argument " + OUString
::number
($3.uval
)
3246 n
= static_cast
<int>($3.uval
);
3249 error(@
3, yyscanner
, "right argument of non-integer type to \">>\"");
3254 case unoidl
::detail
::SourceProviderExpr
::TYPE_INT
:
3255 $$
= unoidl
::detail
::SourceProviderExpr
::Int
($1.ival
>> n
);
3257 case unoidl
::detail
::SourceProviderExpr
::TYPE_UINT
:
3258 $$
= unoidl
::detail
::SourceProviderExpr
::Uint
($1.uval
>> n
);
3261 error(@
1, yyscanner
, "left argument of non-integer type to \">>\"");
3270 addExpr
'+' multExpr
3272 if
(!coerce
(@
1, yyscanner
, &$1, &$3)) {
3276 case unoidl
::detail
::SourceProviderExpr
::TYPE_BOOL
:
3277 error(@
1, yyscanner
, "arguments of boolean type to binary \"+\"");
3280 case unoidl
::detail
::SourceProviderExpr
::TYPE_INT
:
3281 $$
= unoidl
::detail
::SourceProviderExpr
::Int
($1.ival
+ $3.ival
); //TODO: overflow
3283 case unoidl
::detail
::SourceProviderExpr
::TYPE_UINT
:
3284 $$
= unoidl
::detail
::SourceProviderExpr
::Uint
($1.uval
+ $3.uval
); //TODO: overflow
3286 case unoidl
::detail
::SourceProviderExpr
::TYPE_FLOAT
:
3287 $$
= unoidl
::detail
::SourceProviderExpr
::Float
($1.fval
+ $3.fval
);
3291 | addExpr
'-' multExpr
3293 if
(!coerce
(@
1, yyscanner
, &$1, &$3)) {
3297 case unoidl
::detail
::SourceProviderExpr
::TYPE_BOOL
:
3298 error(@
1, yyscanner
, "arguments of boolean type to binary \"-\"");
3301 case unoidl
::detail
::SourceProviderExpr
::TYPE_INT
:
3302 $$
= unoidl
::detail
::SourceProviderExpr
::Int
($1.ival
- $3.ival
); //TODO: overflow
3304 case unoidl
::detail
::SourceProviderExpr
::TYPE_UINT
:
3305 $$
= unoidl
::detail
::SourceProviderExpr
::Uint
($1.uval
- $3.uval
); //TODO: overflow
3307 case unoidl
::detail
::SourceProviderExpr
::TYPE_FLOAT
:
3308 $$
= unoidl
::detail
::SourceProviderExpr
::Float
($1.fval
- $3.fval
);
3316 multExpr
'*' unaryExpr
3318 if
(!coerce
(@
1, yyscanner
, &$1, &$3)) {
3322 case unoidl
::detail
::SourceProviderExpr
::TYPE_BOOL
:
3323 error(@
1, yyscanner
, "arguments of boolean type to \"*\"");
3326 case unoidl
::detail
::SourceProviderExpr
::TYPE_INT
:
3327 $$
= unoidl
::detail
::SourceProviderExpr
::Int
($1.ival
* $3.ival
); //TODO: overflow
3329 case unoidl
::detail
::SourceProviderExpr
::TYPE_UINT
:
3330 $$
= unoidl
::detail
::SourceProviderExpr
::Uint
($1.uval
* $3.uval
); //TODO: overflow
3332 case unoidl
::detail
::SourceProviderExpr
::TYPE_FLOAT
:
3333 $$
= unoidl
::detail
::SourceProviderExpr
::Float
($1.fval
* $3.fval
);
3337 | multExpr
'/' unaryExpr
3339 if
(!coerce
(@
1, yyscanner
, &$1, &$3)) {
3343 case unoidl
::detail
::SourceProviderExpr
::TYPE_BOOL
:
3344 error(@
1, yyscanner
, "arguments of boolean type to \"/\"");
3347 case unoidl
::detail
::SourceProviderExpr
::TYPE_INT
:
3349 error(@
3, yyscanner
, "cannot divide by zero");
3352 $$
= unoidl
::detail
::SourceProviderExpr
::Int
($1.ival
/ $3.ival
);
3354 case unoidl
::detail
::SourceProviderExpr
::TYPE_UINT
:
3356 error(@
3, yyscanner
, "cannot divide by zero");
3359 $$
= unoidl
::detail
::SourceProviderExpr
::Uint
($1.uval
/ $3.uval
);
3361 case unoidl
::detail
::SourceProviderExpr
::TYPE_FLOAT
:
3363 error(@
3, yyscanner
, "cannot divide by zero");
3366 $$
= unoidl
::detail
::SourceProviderExpr
::Float
($1.fval
- $3.fval
);
3370 | multExpr
'%' unaryExpr
3372 if
(!coerce
(@
1, yyscanner
, &$1, &$3)) {
3376 case unoidl
::detail
::SourceProviderExpr
::TYPE_INT
:
3378 error(@
3, yyscanner
, "cannot divide by zero");
3381 $$
= unoidl
::detail
::SourceProviderExpr
::Int
($1.ival %
$3.ival
);
3383 case unoidl
::detail
::SourceProviderExpr
::TYPE_UINT
:
3385 error(@
3, yyscanner
, "cannot divide by zero");
3388 $$
= unoidl
::detail
::SourceProviderExpr
::Uint
($1.uval %
$3.uval
);
3391 error(@
1, yyscanner
, "arguments of non-integer type to \"%\"");
3402 if
($2.type
== unoidl
::detail
::SourceProviderExpr
::TYPE_BOOL
) {
3403 error(@
2, yyscanner
, "argument of boolean type to unary \"+\"");
3411 case unoidl
::detail
::SourceProviderExpr
::TYPE_BOOL
:
3412 error(@
2, yyscanner
, "argument of boolean type to unary \"-\"");
3415 case unoidl
::detail
::SourceProviderExpr
::TYPE_INT
:
3416 if
($2.ival
== SAL_MIN_INT64
) {
3417 error(@
2, yyscanner
, "cannot negate -2^63");
3420 $$
= unoidl
::detail
::SourceProviderExpr
::Int
(-$2.ival
);
3422 case unoidl
::detail
::SourceProviderExpr
::TYPE_UINT
:
3423 if
($2.uval
== SAL_CONST_UINT64
(0x8000000000000000)) {
3424 $$
= unoidl
::detail
::SourceProviderExpr
::Int
(SAL_MIN_INT64
);
3426 if
($2.uval
> SAL_MAX_INT64
) {
3429 ("cannot negate out-of-range value "
3430 + OUString
::number
($2.uval
)));
3433 $$
= unoidl
::detail
::SourceProviderExpr
::Int
(
3434 -static_cast
<sal_Int64
>($2.uval
));
3437 case unoidl
::detail
::SourceProviderExpr
::TYPE_FLOAT
:
3438 $$
= unoidl
::detail
::SourceProviderExpr
::Float
(-$2.fval
);
3445 case unoidl
::detail
::SourceProviderExpr
::TYPE_INT
:
3446 $$
= unoidl
::detail
::SourceProviderExpr
::Int
(~
$2.ival
);
3448 case unoidl
::detail
::SourceProviderExpr
::TYPE_UINT
:
3449 $$
= unoidl
::detail
::SourceProviderExpr
::Uint
(~
$2.uval
);
3452 error(@
2, yyscanner
, "argument of non-integer type to \"~\"");
3461 '(' expr
')' { $$
= $2; }
3462 | TOK_FALSE
{ $$
= unoidl
::detail
::SourceProviderExpr
::Bool
(false
); }
3463 | TOK_TRUE
{ $$
= unoidl
::detail
::SourceProviderExpr
::Bool
(true
); }
3464 | TOK_INTEGER
{ $$
= unoidl
::detail
::SourceProviderExpr
::Uint
($1); }
3465 | TOK_FLOATING
{ $$
= unoidl
::detail
::SourceProviderExpr
::Float
($1); }
3468 OUString name
(convertName
($1));
3469 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
3470 unoidl
::ConstantValue v
(false
); // dummy value
3473 sal_Int32 i
= name.lastIndexOf
('.');
3475 rtl
::Reference
<unoidl
::detail
::SourceProviderEntityPad
> pad
(
3476 getCurrentEntity
(data
)->pad
);
3477 unoidl
::detail
::SourceProviderEnumTypeEntityPad
* p1
= dynamic_cast
<
3478 unoidl
::detail
::SourceProviderEnumTypeEntityPad
*>(pad.get
());
3479 if
(p1
!= nullptr
) {
3480 for
(const auto
& j
: p1
->members
) {
3481 if
(j.name
== name
) {
3482 v
= unoidl
::ConstantValue
(j.value
);
3488 unoidl
::detail
::SourceProviderConstantGroupEntityPad
* p2
3490 unoidl
::detail
::SourceProviderConstantGroupEntityPad
*>(
3492 if
(p2
!= nullptr
) {
3493 for
(const auto
& j
: p2
->members
) {
3494 if
(j.name
== name
) {
3503 OUString scope
(name.copy
(0, i
));
3504 unoidl
::detail
::SourceProviderEntity
const * ent
;
3506 @
1, yyscanner
, data
, false
, &scope
, &ent
, nullptr
, nullptr
)
3511 if
(ent
!= nullptr
) {
3512 std
::u16string_view id
(name.subView
(i
+ 1));
3513 // No need to check for enum members here, as they cannot be
3514 // referenced in expressions by qualified name (TODO: is that true?):
3515 if
(ent
->entity.is
()) {
3516 if
(ent
->entity
->getSort
()
3517 == unoidl
::Entity
::SORT_CONSTANT_GROUP
)
3519 std
::vector
<unoidl
::ConstantGroupEntity
::Member
> const &
3521 static_cast
<unoidl
::ConstantGroupEntity
*>(
3522 ent
->entity.get
())->
3524 for
(auto
& j
: mems
) {
3529 = !static_cast
<unoidl
::ConstantGroupEntity
*>(
3530 ent
->entity.get
())->isPublished
();
3535 } else if
(ent
->pad.is
()) {
3536 unoidl
::detail
::SourceProviderConstantGroupEntityPad
* pad
3538 unoidl
::detail
::SourceProviderConstantGroupEntityPad
*>(
3540 if
(pad
!= nullptr
) {
3541 for
(const auto
& j
: pad
->members
) {
3545 unpub
= !ent
->pad
->isPublished
();
3557 + (" does not resolve to neither a constant nor an unqualified"
3561 if
(data
->publishedContext
&& unpub
) {
3564 "unpublished value " + name
+ " used in published context");
3568 case unoidl
::ConstantValue
::TYPE_BOOLEAN
:
3569 $$
= unoidl
::detail
::SourceProviderExpr
::Bool
(v.booleanValue
);
3571 case unoidl
::ConstantValue
::TYPE_BYTE
:
3572 $$
= unoidl
::detail
::SourceProviderExpr
::Int
(v.byteValue
);
3574 case unoidl
::ConstantValue
::TYPE_SHORT
:
3575 $$
= unoidl
::detail
::SourceProviderExpr
::Int
(v.shortValue
);
3577 case unoidl
::ConstantValue
::TYPE_UNSIGNED_SHORT
:
3578 $$
= unoidl
::detail
::SourceProviderExpr
::Uint
(v.unsignedShortValue
);
3580 case unoidl
::ConstantValue
::TYPE_LONG
:
3581 $$
= unoidl
::detail
::SourceProviderExpr
::Int
(v.longValue
);
3583 case unoidl
::ConstantValue
::TYPE_UNSIGNED_LONG
:
3584 $$
= unoidl
::detail
::SourceProviderExpr
::Uint
(v.unsignedLongValue
);
3586 case unoidl
::ConstantValue
::TYPE_HYPER
:
3587 $$
= unoidl
::detail
::SourceProviderExpr
::Int
(v.hyperValue
);
3589 case unoidl
::ConstantValue
::TYPE_UNSIGNED_HYPER
:
3590 $$
= unoidl
::detail
::SourceProviderExpr
::Uint
(v.unsignedHyperValue
);
3592 case unoidl
::ConstantValue
::TYPE_FLOAT
:
3593 $$
= unoidl
::detail
::SourceProviderExpr
::Float
(v.floatValue
);
3595 case unoidl
::ConstantValue
::TYPE_DOUBLE
:
3596 $$
= unoidl
::detail
::SourceProviderExpr
::Float
(v.doubleValue
);
3603 typeArguments
',' type
3605 unoidl
::detail
::SourceProviderType t
(*$3);
3607 if
(!checkTypeArgument
(@
3, yyscanner
, t
)) {
3608 delete
$1; /* see commented-out %destructor above */
3616 unoidl
::detail
::SourceProviderType t
(*$1);
3618 if
(!checkTypeArgument
(@
1, yyscanner
, t
)) {
3621 $$
= new std
::vector
<unoidl
::detail
::SourceProviderType
>;
3629 $$
= new unoidl
::detail
::SourceProviderType
(
3630 unoidl
::detail
::SourceProviderType
::TYPE_VOID
);
3634 $$
= new unoidl
::detail
::SourceProviderType
(
3635 unoidl
::detail
::SourceProviderType
::TYPE_BOOLEAN
);
3639 $$
= new unoidl
::detail
::SourceProviderType
(
3640 unoidl
::detail
::SourceProviderType
::TYPE_BYTE
);
3644 $$
= new unoidl
::detail
::SourceProviderType
(
3645 unoidl
::detail
::SourceProviderType
::TYPE_SHORT
);
3647 | TOK_UNSIGNED TOK_SHORT
3649 $$
= new unoidl
::detail
::SourceProviderType
(
3650 unoidl
::detail
::SourceProviderType
::TYPE_UNSIGNED_SHORT
);
3654 $$
= new unoidl
::detail
::SourceProviderType
(
3655 unoidl
::detail
::SourceProviderType
::TYPE_LONG
);
3657 | TOK_UNSIGNED TOK_LONG
3659 $$
= new unoidl
::detail
::SourceProviderType
(
3660 unoidl
::detail
::SourceProviderType
::TYPE_UNSIGNED_LONG
);
3664 $$
= new unoidl
::detail
::SourceProviderType
(
3665 unoidl
::detail
::SourceProviderType
::TYPE_HYPER
);
3667 | TOK_UNSIGNED TOK_HYPER
3669 $$
= new unoidl
::detail
::SourceProviderType
(
3670 unoidl
::detail
::SourceProviderType
::TYPE_UNSIGNED_HYPER
);
3674 $$
= new unoidl
::detail
::SourceProviderType
(
3675 unoidl
::detail
::SourceProviderType
::TYPE_FLOAT
);
3679 $$
= new unoidl
::detail
::SourceProviderType
(
3680 unoidl
::detail
::SourceProviderType
::TYPE_DOUBLE
);
3684 $$
= new unoidl
::detail
::SourceProviderType
(
3685 unoidl
::detail
::SourceProviderType
::TYPE_CHAR
);
3689 $$
= new unoidl
::detail
::SourceProviderType
(
3690 unoidl
::detail
::SourceProviderType
::TYPE_STRING
);
3694 $$
= new unoidl
::detail
::SourceProviderType
(
3695 unoidl
::detail
::SourceProviderType
::TYPE_TYPE
);
3699 $$
= new unoidl
::detail
::SourceProviderType
(
3700 unoidl
::detail
::SourceProviderType
::TYPE_ANY
);
3702 | TOK_SEQUENCE
'<' type
'>'
3705 case unoidl
::detail
::SourceProviderType
::TYPE_VOID
:
3706 case unoidl
::detail
::SourceProviderType
::TYPE_EXCEPTION
:
3707 case unoidl
::detail
::SourceProviderType
::TYPE_PARAMETER
: //TODO?
3708 error(@
3, yyscanner
, "illegal sequence type component type");
3714 $$
= new unoidl
::detail
::SourceProviderType
($3);
3719 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
3720 OUString name
(convertName
($1));
3722 if
(name.indexOf
('.') == -1 && !data
->currentName.isEmpty
()) {
3723 unoidl
::detail
::SourceProviderEntity
* ent
= getCurrentEntity
(data
);
3724 unoidl
::detail
::SourceProviderPolymorphicStructTypeTemplateEntityPad
*
3726 unoidl
::detail
::SourceProviderPolymorphicStructTypeTemplateEntityPad
*>(
3730 pad
->typeParameters.begin
(), pad
->typeParameters.end
(),
3732 != pad
->typeParameters.end
()))
3734 $$
= new unoidl
::detail
::SourceProviderType
(name
);
3739 unoidl
::detail
::SourceProviderEntity
const * ent
;
3740 unoidl
::detail
::SourceProviderType t
;
3742 @
1, yyscanner
, data
, false
, &name
, &ent
, nullptr
, &t
))
3748 $$
= new unoidl
::detail
::SourceProviderType
(t
);
3751 if
(ent
== nullptr
) {
3752 error(@
1, yyscanner
, "unknown entity " + name
);
3756 switch
(ent
->kind
) {
3757 case unoidl
::detail
::SourceProviderEntity
::KIND_LOCAL
:
3758 if
(ent
->pad.is
()) {
3759 if
(data
->publishedContext
&& !ent
->pad
->isPublished
()) {
3762 ("unpublished entity " + name
3763 + " used in published context"));
3766 if
(dynamic_cast
<unoidl
::detail
::SourceProviderEnumTypeEntityPad
*>(
3770 $$
= new unoidl
::detail
::SourceProviderType
(
3771 unoidl
::detail
::SourceProviderType
::TYPE_ENUM
,
3774 } else if
(dynamic_cast
<unoidl
::detail
::SourceProviderPlainStructTypeEntityPad
*>(
3778 $$
= new unoidl
::detail
::SourceProviderType
(
3779 unoidl
::detail
::SourceProviderType
::TYPE_PLAIN_STRUCT
,
3782 } else if
(dynamic_cast
<unoidl
::detail
::SourceProviderPolymorphicStructTypeTemplateEntityPad
*>(
3788 (("recursive reference to polymorphic struct type"
3792 } else if
(dynamic_cast
<unoidl
::detail
::SourceProviderExceptionTypeEntityPad
*>(
3796 $$
= new unoidl
::detail
::SourceProviderType
(
3797 unoidl
::detail
::SourceProviderType
::TYPE_EXCEPTION
,
3800 } else if
(dynamic_cast
<unoidl
::detail
::SourceProviderInterfaceTypeEntityPad
*>(
3804 $$
= new unoidl
::detail
::SourceProviderType
(
3805 unoidl
::detail
::SourceProviderType
::TYPE_INTERFACE
,
3811 assert
(ent
->entity.is
());
3813 case unoidl
::detail
::SourceProviderEntity
::KIND_EXTERNAL
:
3814 if
(data
->publishedContext
3815 && ent
->entity
->getSort
() != unoidl
::Entity
::SORT_MODULE
3816 && !static_cast
<unoidl
::PublishableEntity
*>(
3817 ent
->entity.get
())->isPublished
())
3821 ("unpublished entity " + name
3822 + " used in published context"));
3825 switch
(ent
->entity
->getSort
()) {
3826 case unoidl
::Entity
::SORT_ENUM_TYPE
:
3827 $$
= new unoidl
::detail
::SourceProviderType
(
3828 unoidl
::detail
::SourceProviderType
::TYPE_ENUM
, name
,
3832 case unoidl
::Entity
::SORT_PLAIN_STRUCT_TYPE
:
3833 $$
= new unoidl
::detail
::SourceProviderType
(
3834 unoidl
::detail
::SourceProviderType
::TYPE_PLAIN_STRUCT
,
3838 case unoidl
::Entity
::SORT_POLYMORPHIC_STRUCT_TYPE_TEMPLATE
:
3841 ("polymorphic struct type template " + name
3842 + " without type arguments"));
3845 case unoidl
::Entity
::SORT_EXCEPTION_TYPE
:
3846 $$
= new unoidl
::detail
::SourceProviderType
(
3847 unoidl
::detail
::SourceProviderType
::TYPE_EXCEPTION
,
3851 case unoidl
::Entity
::SORT_INTERFACE_TYPE
:
3852 $$
= new unoidl
::detail
::SourceProviderType
(
3853 unoidl
::detail
::SourceProviderType
::TYPE_INTERFACE
,
3857 case unoidl
::Entity
::SORT_TYPEDEF
:
3863 case unoidl
::detail
::SourceProviderEntity
::KIND_INTERFACE_DECL
:
3864 if
(data
->publishedContext
) {
3867 ("unpublished entity " + name
3868 + " used in published context"));
3872 case unoidl
::detail
::SourceProviderEntity
::KIND_PUBLISHED_INTERFACE_DECL
:
3873 $$
= new unoidl
::detail
::SourceProviderType
(
3874 unoidl
::detail
::SourceProviderType
::TYPE_INTERFACE
, name
,
3878 case unoidl
::detail
::SourceProviderEntity
::KIND_MODULE
:
3879 assert
(false
&& "this cannot happen");
3882 error(@
1, yyscanner
, "non-type entity " + name
);
3889 | name
'<' typeArguments
'>'
3891 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
3892 OUString name
(convertName
($1));
3893 std
::vector
<unoidl
::detail
::SourceProviderType
> args
(*$3);
3895 unoidl
::detail
::SourceProviderEntity
const * ent
;
3896 if
(findEntity
(@
1, yyscanner
, data
, false
, &name
, &ent
, nullptr
, nullptr
)
3901 if
(ent
== nullptr
) {
3902 error(@
1, yyscanner
, "unknown entity " + name
);
3906 switch
(ent
->kind
) {
3907 case unoidl
::detail
::SourceProviderEntity
::KIND_LOCAL
:
3908 if
(ent
->pad.is
()) {
3909 if
(dynamic_cast
<unoidl
::detail
::SourceProviderPolymorphicStructTypeTemplateEntityPad
*>(
3915 (("recursive reference to polymorphic struct type"
3922 assert
(ent
->entity.is
());
3924 case unoidl
::detail
::SourceProviderEntity
::KIND_EXTERNAL
:
3925 if
(ent
->entity
->getSort
()
3926 == unoidl
::Entity
::SORT_POLYMORPHIC_STRUCT_TYPE_TEMPLATE
)
3928 rtl
::Reference
<unoidl
::PolymorphicStructTypeTemplateEntity
> e
(
3929 static_cast
<unoidl
::PolymorphicStructTypeTemplateEntity
*>(
3930 ent
->entity.get
()));
3931 if
(args.size
() != e
->getTypeParameters
().size
()) {
3934 ("bad number of polymorphic struct type template " + name
3935 + " type arguments"));
3938 if
(data
->publishedContext
&& !e
->isPublished
()) {
3941 ("unpublished polymorphic struct type template " + name
3942 + " used in published context"));
3945 $$
= new unoidl
::detail
::SourceProviderType
(name
, ent
, std
::move
(args
));
3949 case unoidl
::detail
::SourceProviderEntity
::KIND_INTERFACE_DECL
:
3950 case unoidl
::detail
::SourceProviderEntity
::KIND_PUBLISHED_INTERFACE_DECL
:
3952 case unoidl
::detail
::SourceProviderEntity
::KIND_MODULE
:
3953 assert
(false
&& "this cannot happen");
3956 error(@
1, yyscanner
, "non-type entity " + name
);
3963 name TOK_COLONS identifier
{ *$1 += "." + *$3; delete
$3; $$
= $1; }
3964 | TOK_COLONS identifier
{ *$2 = "." + *$2; $$
= $2; }
3970 | TOK_GET
{ $$
= new OString
("get"); }
3971 | TOK_PUBLISHED
{ $$
= new OString
("published"); }
3972 | TOK_SET
{ $$
= new OString
("set"); }
3976 TOK_DEPRECATED
{ $$
= true
; }
3977 |
/* empty */ { $$
= false
; }
3982 namespace unoidl
::detail
{
3984 OUString SourceProviderType
::getName
() const {
3985 if
(!typedefName.isEmpty
()) {
3989 case unoidl
::detail
::SourceProviderType
::TYPE_VOID
:
3991 case unoidl
::detail
::SourceProviderType
::TYPE_BOOLEAN
:
3993 case unoidl
::detail
::SourceProviderType
::TYPE_BYTE
:
3995 case unoidl
::detail
::SourceProviderType
::TYPE_SHORT
:
3997 case unoidl
::detail
::SourceProviderType
::TYPE_UNSIGNED_SHORT
:
3998 return
"unsigned short";
3999 case unoidl
::detail
::SourceProviderType
::TYPE_LONG
:
4001 case unoidl
::detail
::SourceProviderType
::TYPE_UNSIGNED_LONG
:
4002 return
"unsigned long";
4003 case unoidl
::detail
::SourceProviderType
::TYPE_HYPER
:
4005 case unoidl
::detail
::SourceProviderType
::TYPE_UNSIGNED_HYPER
:
4006 return
"unsigned hyper";
4007 case unoidl
::detail
::SourceProviderType
::TYPE_FLOAT
:
4009 case unoidl
::detail
::SourceProviderType
::TYPE_DOUBLE
:
4011 case unoidl
::detail
::SourceProviderType
::TYPE_CHAR
:
4013 case unoidl
::detail
::SourceProviderType
::TYPE_STRING
:
4015 case unoidl
::detail
::SourceProviderType
::TYPE_TYPE
:
4017 case unoidl
::detail
::SourceProviderType
::TYPE_ANY
:
4019 case unoidl
::detail
::SourceProviderType
::TYPE_SEQUENCE
:
4020 assert
(subtypes.size
() == 1);
4021 return
"[]" + subtypes.front
().getName
();
4022 case unoidl
::detail
::SourceProviderType
::TYPE_ENUM
:
4023 case unoidl
::detail
::SourceProviderType
::TYPE_PLAIN_STRUCT
:
4024 case unoidl
::detail
::SourceProviderType
::TYPE_EXCEPTION
:
4025 case unoidl
::detail
::SourceProviderType
::TYPE_INTERFACE
:
4026 case unoidl
::detail
::SourceProviderType
::TYPE_PARAMETER
:
4028 case unoidl
::detail
::SourceProviderType
::TYPE_INSTANTIATED_POLYMORPHIC_STRUCT
:
4030 OUStringBuffer n
(512);
4031 n.append
(name
+ "<");
4032 for
(auto i
(subtypes.begin
()); i
!= subtypes.end
(); ++i
) {
4033 if
(i
!= subtypes.begin
()) {
4036 n.append
(i
->getName
());
4038 return n.append
(">").makeStringAndClear
();
4041 assert
(false
&& "this cannot happen"); for
(;;) { std
::abort
(); }
4045 bool SourceProviderType
::equals
(SourceProviderType
const & other
) const {
4046 if
(type
!= other.type || name
!= other.name
4047 || subtypes.size
() != other.subtypes.size
())
4051 for
(auto i
(subtypes.begin
()), j
(other.subtypes.begin
());
4052 i
!= subtypes.end
(); ++i
, ++j
)
4054 if
(!i
->equals
(*j
)) {
4061 bool SourceProviderInterfaceTypeEntityPad
::addDirectBase
(
4062 YYLTYPE location
, yyscan_t yyscanner
, SourceProviderScannerData
* data
,
4063 DirectBase
const & base
, bool optional
)
4065 std
::set
<OUString
> seen
;
4066 if
(!(checkBaseClashes
(
4067 location
, yyscanner
, data
, base.name
, base.entity
, true
, optional
,
4070 location
, yyscanner
, data
, base.name
, base.name
, base.entity
,
4076 addOptionalBaseMembers
(
4077 location
, yyscanner
, data
, base.name
, base.entity
);
4079 (optional ? directOptionalBases
: directMandatoryBases
).push_back
(base
);
4083 bool SourceProviderInterfaceTypeEntityPad
::addDirectMember
(
4084 YYLTYPE location
, yyscan_t yyscanner
, SourceProviderScannerData
* data
,
4085 OUString
const & name
)
4087 assert
(data
!= nullptr
);
4088 if
(!checkMemberClashes
(location
, yyscanner
, data
, u
"", name
, true
)) {
4091 allMembers.emplace
(name
, Member
(data
->currentName
));
4095 bool SourceProviderInterfaceTypeEntityPad
::checkBaseClashes
(
4096 YYLTYPE location
, yyscan_t yyscanner
, SourceProviderScannerData
* data
,
4097 OUString
const & name
,
4098 rtl
::Reference
<unoidl
::InterfaceTypeEntity
> const & entity
, bool direct
,
4099 bool optional
, bool outerOptional
, std
::set
<OUString
> * seen
) const
4101 assert
(data
!= nullptr
);
4102 assert
(entity.is
());
4103 assert
(seen
!= nullptr
);
4104 if
(direct || optional || seen
->insert
(name
).second
) {
4105 std
::map
<OUString
, BaseKind
>::const_iterator i
(allBases.find
(name
));
4106 if
(i
!= allBases.end
()) {
4107 switch
(i
->second
) {
4108 case BASE_INDIRECT_OPTIONAL
:
4109 if
(direct
&& optional
) {
4111 location
, yyscanner
,
4112 ("interface type " + data
->currentName
4113 + " duplicate base " + name
));
4117 case BASE_DIRECT_OPTIONAL
:
4118 if
(direct ||
!outerOptional
) {
4120 location
, yyscanner
,
4121 ("interface type " + data
->currentName
4122 + " duplicate base " + name
));
4126 case BASE_INDIRECT_MANDATORY
:
4129 location
, yyscanner
,
4130 ("interface type " + data
->currentName
4131 + " duplicate base " + name
));
4135 case BASE_DIRECT_MANDATORY
:
4136 if
(direct ||
(!optional
&& !outerOptional
)) {
4138 location
, yyscanner
,
4139 ("interface type " + data
->currentName
4140 + " duplicate base " + name
));
4146 if
(direct ||
!optional
) {
4147 for
(auto
& j
: entity
->getDirectMandatoryBases
()) {
4148 OUString n
("." + j.name
);
4149 unoidl
::detail
::SourceProviderEntity
const * p
;
4151 location
, yyscanner
, data
, true
, &n
, &p
, nullptr
,
4157 if
(p
== nullptr ||
!p
->entity.is
()
4158 ||
(p
->entity
->getSort
()
4159 != unoidl
::Entity
::SORT_INTERFACE_TYPE
))
4162 location
, yyscanner
,
4163 ("inconsistent type manager: interface type "
4164 + data
->currentName
+ " base " + n
4165 + " does not resolve to an existing interface type"));
4168 if
(!checkBaseClashes
(
4169 location
, yyscanner
, data
, n
,
4170 static_cast
<unoidl
::InterfaceTypeEntity
*>(
4172 false
, false
, outerOptional
, seen
))
4177 for
(auto
& j
: entity
->getDirectOptionalBases
()) {
4178 OUString n
("." + j.name
);
4179 unoidl
::detail
::SourceProviderEntity
const * p
;
4181 location
, yyscanner
, data
, true
, &n
, &p
, nullptr
,
4187 if
(p
== nullptr ||
!p
->entity.is
()
4188 ||
(p
->entity
->getSort
()
4189 != unoidl
::Entity
::SORT_INTERFACE_TYPE
))
4192 location
, yyscanner
,
4193 ("inconsistent type manager: interface type "
4194 + data
->currentName
+ " base " + n
4195 + " does not resolve to an existing interface type"));
4198 if
(!checkBaseClashes
(
4199 location
, yyscanner
, data
, n
,
4200 static_cast
<unoidl
::InterfaceTypeEntity
*>(
4202 false
, true
, outerOptional
, seen
))
4207 for
(auto
& j
: entity
->getDirectAttributes
()) {
4208 if
(!checkMemberClashes
(
4209 location
, yyscanner
, data
, name
, j.name
,
4215 for
(auto
& j
: entity
->getDirectMethods
()) {
4216 if
(!checkMemberClashes
(
4217 location
, yyscanner
, data
, name
, j.name
,
4228 bool SourceProviderInterfaceTypeEntityPad
::checkMemberClashes
(
4229 YYLTYPE location
, yyscan_t yyscanner
, SourceProviderScannerData
* data
,
4230 std
::u16string_view interfaceName
, OUString
const & memberName
,
4231 bool checkOptional
) const
4233 std
::map
<OUString
, Member
>::const_iterator i
(allMembers.find
(memberName
));
4234 if
(i
!= allMembers.end
()) {
4235 if
(!i
->second.mandatory.isEmpty
()) {
4236 // For a direct member, interfaceName will be empty, so this will
4237 // catch two direct members with the same name:
4238 if
(i
->second.mandatory
!= interfaceName
) {
4240 location
, yyscanner
,
4241 ("interface type " + data
->currentName
4242 + " duplicate member " + memberName
));
4245 } else if
(checkOptional
) {
4246 for
(auto
& j
: i
->second.optional
) {
4247 if
(j
!= interfaceName
) {
4249 location
, yyscanner
,
4250 ("interface type " + data
->currentName
4251 + " duplicate member " + memberName
));
4260 bool SourceProviderInterfaceTypeEntityPad
::addBase
(
4261 YYLTYPE location
, yyscan_t yyscanner
, SourceProviderScannerData
* data
,
4262 OUString
const & directBaseName
, OUString
const & name
,
4263 rtl
::Reference
<unoidl
::InterfaceTypeEntity
> const & entity
, bool direct
,
4266 assert
(data
!= nullptr
);
4267 assert
(entity.is
());
4268 BaseKind kind
= optional
4269 ? direct ? BASE_DIRECT_OPTIONAL
: BASE_INDIRECT_OPTIONAL
4270 : direct ? BASE_DIRECT_MANDATORY
: BASE_INDIRECT_MANDATORY
;
4271 std
::pair
<std
::map
<OUString
, BaseKind
>::iterator
, bool> p
(
4272 allBases.emplace
(name
, kind
));
4273 bool seen
= !p.second
&& p.first
->second
>= BASE_INDIRECT_MANDATORY
;
4274 if
(!p.second
&& kind
> p.first
->second
) {
4275 p.first
->second
= kind
;
4277 if
(!optional
&& !seen
) {
4278 for
(auto
& i
: entity
->getDirectMandatoryBases
()) {
4279 OUString n
("." + i.name
);
4280 unoidl
::detail
::SourceProviderEntity
const * q
;
4282 location
, yyscanner
, data
, true
, &n
, &q
, nullptr
, nullptr
)
4287 if
(q
== nullptr ||
!q
->entity.is
()
4288 || q
->entity
->getSort
() != unoidl
::Entity
::SORT_INTERFACE_TYPE
)
4291 location
, yyscanner
,
4292 ("inconsistent type manager: interface type "
4293 + data
->currentName
+ " base " + n
4294 + " does not resolve to an existing interface type"));
4298 location
, yyscanner
, data
, directBaseName
, n
,
4299 static_cast
<unoidl
::InterfaceTypeEntity
*>(q
->entity.get
()),
4305 for
(auto
& i
: entity
->getDirectOptionalBases
())
4307 OUString n
("." + i.name
);
4308 unoidl
::detail
::SourceProviderEntity
const * q
;
4310 location
, yyscanner
, data
, true
, &n
, &q
, nullptr
, nullptr
)
4315 if
(q
== nullptr ||
!q
->entity.is
()
4316 || q
->entity
->getSort
() != unoidl
::Entity
::SORT_INTERFACE_TYPE
)
4319 location
, yyscanner
,
4320 ("inconsistent type manager: interface type "
4321 + data
->currentName
+ " base " + n
4322 + " does not resolve to an existing interface type"));
4326 location
, yyscanner
, data
, directBaseName
, n
,
4327 static_cast
<unoidl
::InterfaceTypeEntity
*>(q
->entity.get
()),
4333 for
(auto
& i
: entity
->getDirectAttributes
()) {
4334 allMembers.emplace
(i.name
, Member
(name
));
4336 for
(auto
& i
: entity
->getDirectMethods
()) {
4337 allMembers.emplace
(i.name
, Member
(name
));
4343 bool SourceProviderInterfaceTypeEntityPad
::addOptionalBaseMembers
(
4344 YYLTYPE location
, yyscan_t yyscanner
, SourceProviderScannerData
* data
,
4345 OUString
const & name
,
4346 rtl
::Reference
<unoidl
::InterfaceTypeEntity
> const & entity
)
4348 assert
(entity.is
());
4349 for
(auto
& i
: entity
->getDirectMandatoryBases
()) {
4350 OUString n
("." + i.name
);
4351 unoidl
::detail
::SourceProviderEntity
const * p
;
4353 location
, yyscanner
, data
, true
, &n
, &p
, nullptr
, nullptr
)
4358 if
(p
== nullptr ||
!p
->entity.is
()
4359 || p
->entity
->getSort
() != unoidl
::Entity
::SORT_INTERFACE_TYPE
)
4362 location
, yyscanner
,
4363 ("inconsistent type manager: interface type "
4364 + data
->currentName
+ " base " + n
4365 + " does not resolve to an existing interface type"));
4368 if
(!addOptionalBaseMembers
(
4369 location
, yyscanner
, data
, n
,
4370 static_cast
<unoidl
::InterfaceTypeEntity
*>(p
->entity.get
())))
4375 for
(auto
& i
: entity
->getDirectAttributes
()) {
4377 allMembers.emplace
(i.name
, Member
(""))
4379 if
(m.mandatory.isEmpty
()) {
4380 m.optional.insert
(name
);
4383 for
(auto
& i
: entity
->getDirectMethods
()) {
4385 allMembers.emplace
(i.name
, Member
(""))
4387 if
(m.mandatory.isEmpty
()) {
4388 m.optional.insert
(name
);
4394 bool parse
(OUString
const & uri
, SourceProviderScannerData
* data
) {
4395 assert
(data
!= nullptr
);
4396 oslFileHandle handle
;
4397 oslFileError e
= osl_openFile
(uri.pData
, &handle
, osl_File_OpenFlag_Read
);
4399 case osl_File_E_None
:
4401 case osl_File_E_NOENT
:
4404 throw FileFormatException
(uri
, "cannot open: " + OUString
::number
(e
));
4407 e
= osl_getFileSize
(handle
, &size
);
4408 if
(e
!= osl_File_E_None
) {
4409 oslFileError e2
= osl_closeFile
(handle
);
4411 e2
!= osl_File_E_None
, "unoidl",
4412 "cannot close " << uri
<< ": " << +e2
);
4413 throw FileFormatException
(
4414 uri
, "cannot get size: " + OUString
::number
(e
));
4417 e
= osl_mapFile
(handle
, &address
, size
, 0, osl_File_MapFlag_RandomAccess
);
4418 if
(e
!= osl_File_E_None
) {
4419 oslFileError e2
= osl_closeFile
(handle
);
4421 e2
!= osl_File_E_None
, "unoidl",
4422 "cannot close " << uri
<< ": " << +e2
);
4423 throw FileFormatException
(uri
, "cannot mmap: " + OUString
::number
(e
));
4426 data
->setSource
(address
, size
);
4428 if
(yylex_init_extra
(data
, &yyscanner
) != 0) {
4429 // Checking errno for the specific EINVAL, ENOMEM documented for
4430 // yylex_init_extra would not work as those values are not defined
4431 // by the C++ Standard:
4433 throw FileFormatException
(
4435 "yylex_init_extra failed with errno " + OUString
::number
(e2
));
4437 int e2
= yyparse(yyscanner
);
4438 yylex_destroy
(yyscanner
);
4445 throw FileFormatException
(
4448 + (data
->errorLine
== 0
4449 ? OUString
() : " line " + OUString
::number
(data
->errorLine
))
4450 + (data
->parserError.isEmpty
()
4453 + OStringToOUString
(
4454 data
->parserError
, osl_getThreadTextEncoding
())))
4455 + (data
->errorMessage.isEmpty
()
4456 ? OUString
() : ": \"" + data
->errorMessage
+ "\"")));
4458 throw std
::bad_alloc
();
4461 e
= osl_unmapMappedFile
(handle
, address
, size
);
4462 SAL_WARN_IF
(e
!= osl_File_E_None
, "unoidl", "cannot unmap: " << +e
);
4463 e
= osl_closeFile
(handle
);
4464 SAL_WARN_IF
(e
!= osl_File_E_None
, "unoidl", "cannot close: " << +e
);
4467 e
= osl_unmapMappedFile
(handle
, address
, size
);
4468 SAL_WARN_IF
(e
!= osl_File_E_None
, "unoidl", "cannot unmap: " << +e
);
4469 e
= osl_closeFile
(handle
);
4470 SAL_WARN_IF
(e
!= osl_File_E_None
, "unoidl", "cannot close: " << +e
);
4476 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */