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 <rtl/ustrbuf.hxx>
21 #include <unoidl/unoidl.hxx>
33 #include "sourceprovider-parser-requires.hxx"
43 std
::vector
<OUString
> * excns
;
44 unoidl
::detail
::SourceProviderAccessDecls decls
;
45 unoidl
::InterfaceTypeEntity
::Method
::Parameter
::Direction dir
;
46 unoidl
::detail
::SourceProviderFlags flags
;
47 unoidl
::detail
::SourceProviderExpr expr
;
48 unoidl
::detail
::SourceProviderType
* type
;
49 std
::vector
<unoidl
::detail
::SourceProviderType
> * types
;
52 /* TODO: %destructor { delete $$; } <sval> <excns> <type> <types> */
54 %lex
-param
{yyscan_t yyscanner
}
55 %parse
-param
{yyscan_t yyscanner
}
60 #include <osl/thread.h>
61 #include <sal/log.hxx>
63 #include "sourceprovider-scanner.hxx"
65 #define YYLLOC_DEFAULT(Current, Rhs, N) \
66 do
{ (Current
) = YYRHSLOC
((Rhs
), (N
) ?
1 : 0); } while
(0)
68 static void yyerror(YYLTYPE * locp
, yyscan_t yyscanner
, char const * msg
) {
69 assert
(locp
!= nullptr
);
70 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
71 data
->errorLine
= *locp
;
72 data
->parserError
= OString
(msg
);
77 void error(YYLTYPE location
, yyscan_t yyscanner
, OUString
const & message
) {
78 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
79 data
->errorLine
= location
;
80 data
->errorMessage
= message
;
83 OUString flagName
(unoidl
::detail
::SourceProviderFlags flag
) {
85 case unoidl
::detail
::FLAG_ATTRIBUTE
:
87 case unoidl
::detail
::FLAG_BOUND
:
89 case unoidl
::detail
::FLAG_CONSTRAINED
:
91 case unoidl
::detail
::FLAG_MAYBEAMBIGUOUS
:
92 return
"maybeambiguous";
93 case unoidl
::detail
::FLAG_MAYBEDEFAULT
:
94 return
"maybedefault";
95 case unoidl
::detail
::FLAG_MAYBEVOID
:
97 case unoidl
::detail
::FLAG_OPTIONAL
:
99 case unoidl
::detail
::FLAG_PROPERTY
:
101 case unoidl
::detail
::FLAG_READONLY
:
103 case unoidl
::detail
::FLAG_REMOVABLE
:
105 case unoidl
::detail
::FLAG_TRANSIENT
:
108 assert
(false
&& "this cannot happen"); for
(;;) { std
::abort
(); }
112 OUString convertName
(OString
const * name
) {
113 assert
(name
!= nullptr
);
114 OUString s
(OStringToOUString
(*name
, RTL_TEXTENCODING_ASCII_US
));
119 OUString convertToFullName
(
120 unoidl
::detail
::SourceProviderScannerData
const * data
,
121 OString
const * identifier
)
123 assert
(data
!= nullptr
);
125 if
(!data
->modules.empty
()) {
126 pref
= data
->modules.back
() + ".";
128 return pref
+ convertName
(identifier
);
131 void convertToCurrentName
(
132 unoidl
::detail
::SourceProviderScannerData
* data
,
133 OString
const * identifier
)
135 assert
(data
!= nullptr
);
136 assert
(data
->currentName.isEmpty
());
137 data
->currentName
= convertToFullName
(data
, identifier
);
138 assert
(!data
->currentName.isEmpty
());
141 void clearCurrentState
(unoidl
::detail
::SourceProviderScannerData
* data
) {
142 assert
(data
!= nullptr
);
143 data
->currentName.clear
();
144 data
->publishedContext
= false
;
147 unoidl::detail
::SourceProviderEntity
* getCurrentEntity
(
148 unoidl
::detail
::SourceProviderScannerData
* data
)
150 assert
(data
!= nullptr
);
151 assert
(!data
->currentName.isEmpty
());
152 std
::map
<OUString
, unoidl
::detail
::SourceProviderEntity
>::iterator i
(
153 data
->entities.find
(data
->currentName
));
154 assert
(i
!= data
->entities.end
());
155 assert
(i
->second.kind
== unoidl
::detail
::SourceProviderEntity
::KIND_LOCAL
);
156 assert
(i
->second.pad.is
());
160 template
<typename T
> rtl
::Reference
<T
> getCurrentPad
(
161 unoidl
::detail
::SourceProviderScannerData
* data
)
163 rtl
::Reference
<T
> pad
(dynamic_cast
<T
*>(getCurrentEntity
(data
)->pad.get
()));
168 bool nameHasSameIdentifierAs
(OUString
const & name
, OUString
const & identifier
)
170 sal_Int32 i
= name.lastIndexOf
('.') + 1;
171 return identifier.getLength
() == name.getLength
() - i
172 && name.match
(identifier
, i
);
176 YYLTYPE location
, yyscan_t yyscanner
,
177 unoidl
::detail
::SourceProviderExpr
* lhs
,
178 unoidl
::detail
::SourceProviderExpr
* rhs
)
180 assert
(lhs
!= nullptr
);
181 assert
(rhs
!= nullptr
);
182 bool ok
= bool(); // avoid warnings
184 case unoidl
::detail
::SourceProviderExpr
::TYPE_BOOL
:
185 ok
= rhs
->type
!= unoidl
::detail
::SourceProviderExpr
::TYPE_BOOL
;
187 case unoidl
::detail
::SourceProviderExpr
::TYPE_INT
:
189 case unoidl
::detail
::SourceProviderExpr
::TYPE_BOOL
:
192 case unoidl
::detail
::SourceProviderExpr
::TYPE_INT
:
195 case unoidl
::detail
::SourceProviderExpr
::TYPE_UINT
:
196 if
(lhs
->ival
>= 0) {
197 lhs
->type
= unoidl
::detail
::SourceProviderExpr
::TYPE_UINT
;
199 } else if
(rhs
->uval
<= SAL_MAX_INT64
) {
200 rhs
->type
= unoidl
::detail
::SourceProviderExpr
::TYPE_INT
;
206 case unoidl
::detail
::SourceProviderExpr
::TYPE_FLOAT
:
208 auto tmp
= lhs
->ival
;
215 case unoidl
::detail
::SourceProviderExpr
::TYPE_UINT
:
217 case unoidl
::detail
::SourceProviderExpr
::TYPE_BOOL
:
220 case unoidl
::detail
::SourceProviderExpr
::TYPE_INT
:
221 if
(rhs
->ival
>= 0) {
222 rhs
->type
= unoidl
::detail
::SourceProviderExpr
::TYPE_UINT
;
224 } else if
(lhs
->uval
<= SAL_MAX_INT64
) {
225 lhs
->type
= unoidl
::detail
::SourceProviderExpr
::TYPE_INT
;
231 case unoidl
::detail
::SourceProviderExpr
::TYPE_UINT
:
234 case unoidl
::detail
::SourceProviderExpr
::TYPE_FLOAT
:
236 auto nTmp
= lhs
->uval
;
243 case unoidl
::detail
::SourceProviderExpr
::TYPE_FLOAT
:
245 case unoidl
::detail
::SourceProviderExpr
::TYPE_BOOL
:
248 case unoidl
::detail
::SourceProviderExpr
::TYPE_INT
:
250 auto tmp
= rhs
->ival
;
255 case unoidl
::detail
::SourceProviderExpr
::TYPE_UINT
:
257 auto tmp
= rhs
->uval
;
262 case unoidl
::detail
::SourceProviderExpr
::TYPE_FLOAT
:
269 error(location
, yyscanner
, "cannot coerce binary expression arguments");
274 unoidl::detail
::SourceProviderEntity
* findEntity_
(
275 unoidl
::detail
::SourceProviderScannerData
* data
, OUString
* name
)
277 assert
(data
!= nullptr
);
278 assert
(name
!= nullptr
);
280 if
(!name
->startsWith
(".", &n
)) {
281 for
(auto i
(data
->modules.rbegin
()); i
!= data
->modules.rend
(); ++i
) {
282 n
= *i
+ "." + *name
;
283 std
::map
<OUString
, unoidl
::detail
::SourceProviderEntity
>::iterator j
(
284 data
->entities.find
(n
));
285 if
(j
!= data
->entities.end
()) {
289 rtl
::Reference
<unoidl
::Entity
> ent
(data
->manager
->findEntity
(n
));
291 std
::map
<OUString
, unoidl
::detail
::SourceProviderEntity
>::iterator
292 k
(data
->entities.emplace
(
294 unoidl
::detail
::SourceProviderEntity
(
295 unoidl
::detail
::SourceProviderEntity
::KIND_EXTERNAL
,
304 std
::map
<OUString
, unoidl
::detail
::SourceProviderEntity
>::iterator i
(
305 data
->entities.find
(n
));
306 if
(i
!= data
->entities.end
()) {
310 rtl
::Reference
<unoidl
::Entity
> ent
(data
->manager
->findEntity
(n
));
312 std
::map
<OUString
, unoidl
::detail
::SourceProviderEntity
>::iterator
313 j
(data
->entities.emplace
(
315 unoidl
::detail
::SourceProviderEntity
(
316 unoidl
::detail
::SourceProviderEntity
::KIND_EXTERNAL
,
325 enum Found
{ FOUND_ERROR
, FOUND_TYPE
, FOUND_ENTITY
};
328 YYLTYPE location
, yyscan_t yyscanner
,
329 unoidl
::detail
::SourceProviderScannerData
* data
,
330 bool resolveInterfaceDefinitions
, OUString
* name
,
331 unoidl
::detail
::SourceProviderEntity
const ** entity
, bool * typedefed
,
332 unoidl
::detail
::SourceProviderType
* typedefedType
)
334 //TODO: avoid recursion
335 assert
(data
!= nullptr
);
336 assert
(name
!= nullptr
);
337 assert
(entity
!= nullptr
);
338 unoidl
::detail
::SourceProviderEntity
* e
= findEntity_
(data
, name
);
340 OUString typeNucleus
;
341 std
::size_t rank
= 0;
342 std
::vector
<unoidl
::detail
::SourceProviderType
> args
;
346 case unoidl
::detail
::SourceProviderEntity
::KIND_LOCAL
:
350 assert
(e
->entity.is
());
352 case unoidl
::detail
::SourceProviderEntity
::KIND_EXTERNAL
:
353 if
(e
->entity
->getSort
() == unoidl
::Entity
::SORT_TYPEDEF
) {
354 if
(typedefed
!= nullptr
) {
357 if
(data
->publishedContext
358 && !static_cast
<unoidl
::TypedefEntity
*>(
359 e
->entity.get
())->isPublished
())
363 ("type " + *name
+ " based on unpublished typedef "
364 + n
+ " used in published context"));
368 static_cast
<unoidl
::TypedefEntity
*>(e
->entity.get
())
371 while
(typeNucleus.startsWith
("[]", &typeNucleus
)) {
375 ("inconsistent type manager: bad type " + *name
376 + (" based on instantiated polymorphic struct"
377 " type based on sequence type named ")
381 if
(rank
== std
::numeric_limits
<std
::size_t>::max
()) {
385 + " based on sequence type of too high rank"));
390 sal_Int32 i
= typeNucleus.indexOf
('<');
395 ("inconsistent type manager: bad type " + *name
396 + (" based on instantiated polymorphic struct"
397 " type based on instantiated polymorphic"
398 " struct type named ")
402 OUString tmpl
(typeNucleus.copy
(0, i
));
404 ++i
; // skip '<' or ','
406 for
(sal_Int32 level
= 0;
407 j
!= typeNucleus.getLength
(); ++j
)
409 sal_Unicode c
= typeNucleus
[j
];
414 } else if
(c
== '<') {
416 } else if
(c
== '>') {
423 if
(j
!= typeNucleus.getLength
()) {
424 OUString argName
(typeNucleus.copy
(i
, j
- i
));
425 unoidl
::detail
::SourceProviderEntity
const *
427 unoidl
::detail
::SourceProviderType argType
;
430 location
, yyscanner
, data
, false
,
431 &argName
, &argEnt
, nullptr
, &argType
))
438 if
(argEnt
== nullptr
) {
441 (("inconsistent type manager: bad"
442 " instantiated polymorphic struct"
443 " type template type argument ")
447 unoidl
::detail
::SourceProviderType
::Type
449 = unoidl
::detail
::SourceProviderType
::Type
();
451 switch
(argEnt
->kind
) {
452 case unoidl
::detail
::SourceProviderEntity
::KIND_LOCAL
:
456 (("inconsistent type"
459 " polymorphic struct type"
465 assert
(e
->entity.is
());
467 case unoidl
::detail
::SourceProviderEntity
::KIND_EXTERNAL
:
468 switch
(e
->entity
->getSort
()) {
469 case unoidl
::Entity
::SORT_ENUM_TYPE
:
470 argT
= unoidl
::detail
::SourceProviderType
::TYPE_ENUM
;
472 case unoidl
::Entity
::SORT_PLAIN_STRUCT_TYPE
:
473 argT
= unoidl
::detail
::SourceProviderType
::TYPE_PLAIN_STRUCT
;
475 case unoidl
::Entity
::SORT_INTERFACE_TYPE
:
476 argT
= unoidl
::detail
::SourceProviderType
::TYPE_INTERFACE
;
481 (("inconsistent type"
484 " polymorphic struct type"
491 case unoidl
::detail
::SourceProviderEntity
::KIND_INTERFACE_DECL
:
492 case unoidl
::detail
::SourceProviderEntity
::KIND_PUBLISHED_INTERFACE_DECL
:
493 argT
= unoidl
::detail
::SourceProviderType
::TYPE_INTERFACE
;
495 case unoidl
::detail
::SourceProviderEntity
::KIND_MODULE
:
496 assert
(false
&& "this cannot happen");
499 = unoidl
::detail
::SourceProviderType
(
500 argT
, argName
, argEnt
);
504 args.push_back
(argType
);
507 } while
(i
!= typeNucleus.getLength
()
508 && typeNucleus
[i
] != '>');
509 if
(i
!= typeNucleus.getLength
() - 1
510 || typeNucleus
[i
] != '>')
514 ("inconsistent type manager: bad type name \""
518 assert
(!args.empty
());
521 if
(typeNucleus.isEmpty
()) {
524 ("inconsistent type manager: bad type name \"" + t
528 if
(typeNucleus
== "void") {
531 ("inconsistent type manager: bad type " + *name
532 + " based on void"));
535 if
(typeNucleus
== "boolean" || typeNucleus
== "byte"
536 || typeNucleus
== "short"
537 || typeNucleus
== "unsigned short"
538 || typeNucleus
== "long"
539 || typeNucleus
== "unsigned long"
540 || typeNucleus
== "hyper"
541 || typeNucleus
== "unsigned hyper"
542 || typeNucleus
== "float" || typeNucleus
== "double"
543 || typeNucleus
== "char" || typeNucleus
== "string"
544 || typeNucleus
== "type" || typeNucleus
== "any")
549 ("inconsistent type manager: bad type " + *name
550 + (" based on instantiated polymorphic struct"
557 n
= "." + typeNucleus
;
559 e
= findEntity_
(data
, &n
);
563 case unoidl
::detail
::SourceProviderEntity
::KIND_INTERFACE_DECL
:
564 case unoidl
::detail
::SourceProviderEntity
::KIND_PUBLISHED_INTERFACE_DECL
:
565 if
(resolveInterfaceDefinitions
) {
566 rtl
::Reference
<unoidl
::Entity
> ent
(
567 data
->manager
->findEntity
(n
));
568 // Do not allow ent to be of SORT_TYPEDEF:
571 != unoidl
::Entity
::SORT_INTERFACE_TYPE
))
575 (*name
+ " is based on interface declaration " + n
576 + " that is not an interface type entity"));
580 = unoidl
::detail
::SourceProviderEntity
::KIND_EXTERNAL
;
584 case unoidl
::detail
::SourceProviderEntity
::KIND_MODULE
:
587 *name
+ " is based on module entity " + n
);
591 if
(!typeNucleus.isEmpty
() || rank
!= 0 ||
!args.empty
()) {
592 if
(typeNucleus.isEmpty
() && e
== nullptr
) {
593 // Found a type name based on an unknown entity:
597 unoidl
::detail
::SourceProviderType t
;
599 if
(typeNucleus
== "boolean") {
600 t
= unoidl
::detail
::SourceProviderType
(
601 unoidl
::detail
::SourceProviderType
::TYPE_BOOLEAN
);
602 } else if
(typeNucleus
== "byte") {
603 t
= unoidl
::detail
::SourceProviderType
(
604 unoidl
::detail
::SourceProviderType
::TYPE_BYTE
);
605 } else if
(typeNucleus
== "short") {
606 t
= unoidl
::detail
::SourceProviderType
(
607 unoidl
::detail
::SourceProviderType
::TYPE_SHORT
);
608 } else if
(typeNucleus
== "unsigned short") {
609 t
= unoidl
::detail
::SourceProviderType
(
610 unoidl
::detail
::SourceProviderType
::TYPE_UNSIGNED_SHORT
);
611 } else if
(typeNucleus
== "long") {
612 t
= unoidl
::detail
::SourceProviderType
(
613 unoidl
::detail
::SourceProviderType
::TYPE_LONG
);
614 } else if
(typeNucleus
== "unsigned long") {
615 t
= unoidl
::detail
::SourceProviderType
(
616 unoidl
::detail
::SourceProviderType
::TYPE_UNSIGNED_LONG
);
617 } else if
(typeNucleus
== "hyper") {
618 t
= unoidl
::detail
::SourceProviderType
(
619 unoidl
::detail
::SourceProviderType
::TYPE_HYPER
);
620 } else if
(typeNucleus
== "unsigned hyper") {
621 t
= unoidl
::detail
::SourceProviderType
(
622 unoidl
::detail
::SourceProviderType
::TYPE_UNSIGNED_HYPER
);
623 } else if
(typeNucleus
== "float") {
624 t
= unoidl
::detail
::SourceProviderType
(
625 unoidl
::detail
::SourceProviderType
::TYPE_FLOAT
);
626 } else if
(typeNucleus
== "double") {
627 t
= unoidl
::detail
::SourceProviderType
(
628 unoidl
::detail
::SourceProviderType
::TYPE_DOUBLE
);
629 } else if
(typeNucleus
== "char") {
630 t
= unoidl
::detail
::SourceProviderType
(
631 unoidl
::detail
::SourceProviderType
::TYPE_CHAR
);
632 } else if
(typeNucleus
== "string") {
633 t
= unoidl
::detail
::SourceProviderType
(
634 unoidl
::detail
::SourceProviderType
::TYPE_STRING
);
635 } else if
(typeNucleus
== "type") {
636 t
= unoidl
::detail
::SourceProviderType
(
637 unoidl
::detail
::SourceProviderType
::TYPE_TYPE
);
638 } else if
(typeNucleus
== "any") {
639 t
= unoidl
::detail
::SourceProviderType
(
640 unoidl
::detail
::SourceProviderType
::TYPE_ANY
);
642 assert
(typeNucleus.isEmpty
());
643 assert
(e
!= nullptr
);
645 case unoidl
::detail
::SourceProviderEntity
::KIND_LOCAL
:
647 if
(dynamic_cast
<unoidl
::detail
::SourceProviderEnumTypeEntityPad
*>(
651 t
= unoidl
::detail
::SourceProviderType
(
652 unoidl
::detail
::SourceProviderType
::TYPE_ENUM
,
654 } else if
(dynamic_cast
<unoidl
::detail
::SourceProviderPlainStructTypeEntityPad
*>(
658 t
= unoidl
::detail
::SourceProviderType
(
659 unoidl
::detail
::SourceProviderType
::TYPE_PLAIN_STRUCT
,
661 } else if
(dynamic_cast
<unoidl
::detail
::SourceProviderPolymorphicStructTypeTemplateEntityPad
*>(
668 + (" based on recursive reference to"
669 " polymorphic struct type template ")
672 } else if
(dynamic_cast
<unoidl
::detail
::SourceProviderExceptionTypeEntityPad
*>(
676 t
= unoidl
::detail
::SourceProviderType
(
677 unoidl
::detail
::SourceProviderType
::TYPE_EXCEPTION
,
679 } else if
(dynamic_cast
<unoidl
::detail
::SourceProviderInterfaceTypeEntityPad
*>(
683 t
= unoidl
::detail
::SourceProviderType
(
684 unoidl
::detail
::SourceProviderType
::TYPE_INTERFACE
,
690 + " based on non-type entity " + n
));
695 assert
(e
->entity.is
());
697 case unoidl
::detail
::SourceProviderEntity
::KIND_EXTERNAL
:
698 switch
(e
->entity
->getSort
()) {
699 case unoidl
::Entity
::SORT_ENUM_TYPE
:
700 t
= unoidl
::detail
::SourceProviderType
(
701 unoidl
::detail
::SourceProviderType
::TYPE_ENUM
,
704 case unoidl
::Entity
::SORT_PLAIN_STRUCT_TYPE
:
705 t
= unoidl
::detail
::SourceProviderType
(
706 unoidl
::detail
::SourceProviderType
::TYPE_PLAIN_STRUCT
,
709 case unoidl
::Entity
::SORT_POLYMORPHIC_STRUCT_TYPE_TEMPLATE
:
713 + " based on polymorphic struct type template "
714 + n
+ " without type arguments"));
716 case unoidl
::Entity
::SORT_EXCEPTION_TYPE
:
717 t
= unoidl
::detail
::SourceProviderType
(
718 unoidl
::detail
::SourceProviderType
::TYPE_EXCEPTION
,
721 case unoidl
::Entity
::SORT_INTERFACE_TYPE
:
722 t
= unoidl
::detail
::SourceProviderType
(
723 unoidl
::detail
::SourceProviderType
::TYPE_INTERFACE
,
730 + " based on non-type entity " + n
));
734 case unoidl
::detail
::SourceProviderEntity
::KIND_INTERFACE_DECL
:
735 case unoidl
::detail
::SourceProviderEntity
::KIND_PUBLISHED_INTERFACE_DECL
:
736 t
= unoidl
::detail
::SourceProviderType
(
737 unoidl
::detail
::SourceProviderType
::TYPE_INTERFACE
,
740 case unoidl
::detail
::SourceProviderEntity
::KIND_MODULE
:
741 assert
(false
&& "this cannot happen");
745 assert
(typeNucleus.isEmpty
());
746 assert
(e
!= nullptr
);
748 case unoidl
::detail
::SourceProviderEntity
::KIND_LOCAL
:
753 + (" based on instantiated polymorphic struct type"
756 + (" that is either not a polymorphic struct type"
757 " template or a recursive reference to a"
758 " polymorphic struct type template")));
761 assert
(e
->entity.is
());
763 case unoidl
::detail
::SourceProviderEntity
::KIND_EXTERNAL
:
764 if
(e
->entity
->getSort
()
765 == unoidl
::Entity
::SORT_POLYMORPHIC_STRUCT_TYPE_TEMPLATE
)
769 unoidl
::PolymorphicStructTypeTemplateEntity
*>(
771 ->getTypeParameters
().size
()))
776 + (" based on instantiated polymorphic struct"
778 + OUString
::number
(args.size
())
779 + (" type arguments based on polymorphic"
780 " struct type template ")
784 unoidl
::PolymorphicStructTypeTemplateEntity
*>(
786 ->getTypeParameters
().size
())
787 + " type parameters"));
790 t
= unoidl
::detail
::SourceProviderType
(n
, e
, std
::move
(args
));
794 case unoidl
::detail
::SourceProviderEntity
::KIND_INTERFACE_DECL
:
795 case unoidl
::detail
::SourceProviderEntity
::KIND_PUBLISHED_INTERFACE_DECL
:
799 + (" based on instantiated polymorphic struct type"
802 + " that is not a polymorphic struct type template"));
804 case unoidl
::detail
::SourceProviderEntity
::KIND_MODULE
:
805 assert
(false
&& "this cannot happen");
808 if
(typedefedType
!= nullptr
) {
809 for
(std
::size_t i
= 0; i
!= rank
; ++i
) {
810 t
= unoidl
::detail
::SourceProviderType
(&t
);
813 typedefedType
->typedefName
= *name
;
824 bool checkTypeArgument
(
825 YYLTYPE location
, yyscan_t yyscanner
,
826 unoidl
::detail
::SourceProviderType
const & type
)
829 case unoidl
::detail
::SourceProviderType
::TYPE_VOID
:
830 case unoidl
::detail
::SourceProviderType
::TYPE_UNSIGNED_SHORT
:
831 case unoidl
::detail
::SourceProviderType
::TYPE_UNSIGNED_LONG
:
832 case unoidl
::detail
::SourceProviderType
::TYPE_UNSIGNED_HYPER
:
833 case unoidl
::detail
::SourceProviderType
::TYPE_EXCEPTION
:
834 case unoidl
::detail
::SourceProviderType
::TYPE_PARAMETER
: //TODO?
837 "bad instantiated polymorphic struct type argument");
839 case unoidl
::detail
::SourceProviderType
::TYPE_SEQUENCE
:
840 return checkTypeArgument
(location
, yyscanner
, type.subtypes.front
());
846 bool checkInstantiatedPolymorphicStructTypeArgument
(
847 unoidl
::detail
::SourceProviderType
const & type
, OUString
const & name
)
850 == unoidl
::detail
::SourceProviderType
::TYPE_INSTANTIATED_POLYMORPHIC_STRUCT
)
852 for
(auto
& i
: type.subtypes
) {
853 if
(checkInstantiatedPolymorphicStructTypeArgument
(i
, name
)
854 || i.getName
() == name
) // no need to worry about typedef
863 std::vector
<OUString
> annotations
(bool deprecated
) {
864 std
::vector
<OUString
> ann
;
866 ann.push_back
("deprecated");
878 %token TOK_RIGHTSHIFT
890 %token TOK_CONSTRAINED
901 %token TOK_MAYBEAMBIGUOUS
902 %token TOK_MAYBEDEFAULT
925 %token
<sval
> TOK_IDENTIFIER
926 %token
<ival
> TOK_INTEGER
927 %token
<fval
> TOK_FLOATING
929 %token TOK_DEPRECATED
933 %type
<sval
> identifier name singleInheritance singleInheritance_opt
934 %type
<bval
> ctors_opt deprecated_opt ellipsis_opt published_opt
935 %type
<decls
> attributeAccessDecl attributeAccessDecls
937 %type
<excns
> exceptionSpec exceptionSpec_opt exceptions
938 %type
<flags
> flag flagSection flagSection_opt flags
939 %type
<expr
> addExpr andExpr expr multExpr orExpr primaryExpr shiftExpr unaryExpr
942 %type
<types
> typeArguments
944 %initial
-action
{ yylloc = 1; }
949 definitions definition
957 | polymorphicStructTemplateDefn
962 | singleInterfaceBasedServiceDefn
963 | accumulationBasedServiceDefn
964 | interfaceBasedSingletonDefn
965 | serviceBasedSingletonDefn
970 TOK_MODULE identifier
972 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
973 OUString name
(convertToFullName
(data
, $2));
974 data
->modules.push_back
(name
);
975 std
::pair
<std
::map
<OUString
, unoidl
::detail
::SourceProviderEntity
>::iterator
, bool> p
(
976 data
->entities.emplace
(
978 unoidl
::detail
::SourceProviderEntity
(
979 unoidl
::detail
::SourceProviderEntity
::KIND_MODULE
)));
981 && (p.first
->second.kind
982 != unoidl
::detail
::SourceProviderEntity
::KIND_MODULE
))
984 error(@
2, yyscanner
, "multiple entities named " + name
);
988 '{' definitions
'}' ';' { yyget_extra
(yyscanner
)->modules.pop_back
(); }
992 deprecated_opt published_opt TOK_ENUM identifier
994 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
995 data
->publishedContext
= $2;
996 convertToCurrentName
(data
, $4);
997 if
(!data
->entities.emplace
(
999 unoidl
::detail
::SourceProviderEntity
(
1000 new unoidl
::detail
::SourceProviderEnumTypeEntityPad
(
1004 error(@
4, yyscanner
, "multiple entities named " + data
->currentName
);
1008 '{' enumMembers
'}' ';'
1010 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
1011 unoidl
::detail
::SourceProviderEntity
* ent
= getCurrentEntity
(data
);
1012 unoidl
::detail
::SourceProviderEnumTypeEntityPad
* pad
=
1013 dynamic_cast
<unoidl
::detail
::SourceProviderEnumTypeEntityPad
*>(
1015 assert
(pad
!= nullptr
);
1016 ent
->entity
= new unoidl
::EnumTypeEntity
(
1017 pad
->isPublished
(), std
::move
(pad
->members
), annotations
($1));
1019 clearCurrentState
(data
);
1024 | enumMembers
',' enumMember
1029 deprecated_opt identifier
1031 OUString id
(convertName
($2));
1032 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
1033 rtl
::Reference
<unoidl
::detail
::SourceProviderEnumTypeEntityPad
> pad
(
1034 getCurrentPad
<unoidl
::detail
::SourceProviderEnumTypeEntityPad
>(data
));
1036 if
(pad
->members.empty
()) {
1039 v
= pad
->members.back
().value
;
1040 if
(v
== SAL_MAX_INT32
) {
1043 ("enum " + data
->currentName
+ " member " + id
1044 + " would have out-of-range value 2^31"));
1049 pad
->members.emplace_back
(id
, v
, annotations
($1));
1051 | deprecated_opt identifier
'=' expr
1053 OUString id
(convertName
($2));
1054 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
1055 rtl
::Reference
<unoidl
::detail
::SourceProviderEnumTypeEntityPad
> pad
(
1056 getCurrentPad
<unoidl
::detail
::SourceProviderEnumTypeEntityPad
>(data
));
1059 case unoidl
::detail
::SourceProviderExpr
::TYPE_INT
:
1060 if
($4.ival
< SAL_MIN_INT32 ||
$4.ival
> SAL_MAX_INT32
) {
1063 ("out-of-range enum " + data
->currentName
+ " member " + id
1064 + " value " + OUString
::number
($4.ival
)));
1067 v
= static_cast
<sal_Int32
>($4.ival
);
1069 case unoidl
::detail
::SourceProviderExpr
::TYPE_UINT
:
1070 if
($4.uval
> SAL_MAX_INT32
) {
1073 ("out-of-range enum " + data
->currentName
+ " member " + id
1074 + " value " + OUString
::number
($4.uval
)));
1077 v
= static_cast
<sal_Int32
>($4.uval
);
1082 ("non-integer enum " + data
->currentName
+ " member " + id
1087 pad
->members.emplace_back
(id
, v
, annotations
($1));
1092 deprecated_opt published_opt TOK_STRUCT identifier singleInheritance_opt
1094 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
1095 data
->publishedContext
= $2;
1096 convertToCurrentName
(data
, $4);
1098 rtl
::Reference
<unoidl
::PlainStructTypeEntity
> baseEnt
;
1099 if
($5 != nullptr
) {
1100 baseName
= convertName
($5);
1101 unoidl
::detail
::SourceProviderEntity
const * p
;
1103 @
5, yyscanner
, data
, false
, &baseName
, &p
, nullptr
, nullptr
)
1108 if
(p
== nullptr ||
!p
->entity.is
()
1109 || p
->entity
->getSort
() != unoidl
::Entity
::SORT_PLAIN_STRUCT_TYPE
)
1113 ("plain struct type " + data
->currentName
+ " base "
1115 + " does not resolve to an existing plain struct type"));
1118 baseEnt
= static_cast
<unoidl
::PlainStructTypeEntity
*>(
1120 if
($2 && !baseEnt
->isPublished
()) {
1123 ("published plain struct type " + data
->currentName
+ " base "
1124 + baseName
+ " is unpublished"));
1128 if
(!data
->entities.emplace
(
1130 unoidl
::detail
::SourceProviderEntity
(
1131 new unoidl
::detail
::SourceProviderPlainStructTypeEntityPad
(
1132 $2, baseName
, baseEnt
))).
1135 error(@
4, yyscanner
, "multiple entities named " + data
->currentName
);
1139 '{' structMembers
'}' ';'
1141 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
1142 unoidl
::detail
::SourceProviderEntity
* ent
= getCurrentEntity
(data
);
1143 unoidl
::detail
::SourceProviderPlainStructTypeEntityPad
* pad
=
1145 unoidl
::detail
::SourceProviderPlainStructTypeEntityPad
*>(
1147 assert
(pad
!= nullptr
);
1148 ent
->entity
= new unoidl
::PlainStructTypeEntity
(
1149 pad
->isPublished
(), pad
->baseName
, std
::move
(pad
->members
), annotations
($1));
1151 clearCurrentState
(data
);
1155 polymorphicStructTemplateDefn:
1156 deprecated_opt published_opt TOK_STRUCT identifier
'<'
1158 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
1159 data
->publishedContext
= $2;
1160 convertToCurrentName
(data
, $4);
1161 if
(!data
->entities.emplace
(
1163 unoidl
::detail
::SourceProviderEntity
(
1164 new unoidl
::detail
::SourceProviderPolymorphicStructTypeTemplateEntityPad
(
1168 error(@
4, yyscanner
, "multiple entities named " + data
->currentName
);
1172 typeParameters
'>' '{' structMembers
'}' ';'
1174 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
1175 unoidl
::detail
::SourceProviderEntity
* ent
= getCurrentEntity
(data
);
1176 unoidl
::detail
::SourceProviderPolymorphicStructTypeTemplateEntityPad
*
1178 unoidl
::detail
::SourceProviderPolymorphicStructTypeTemplateEntityPad
*>(
1180 assert
(pad
!= nullptr
);
1181 ent
->entity
= new unoidl
::PolymorphicStructTypeTemplateEntity
(
1182 pad
->isPublished
(), std
::move
(pad
->typeParameters
), std
::move
(pad
->members
),
1185 clearCurrentState
(data
);
1190 typeParameters
',' identifier
1192 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
1193 rtl
::Reference
<unoidl
::detail
::SourceProviderPolymorphicStructTypeTemplateEntityPad
>
1194 pad
(getCurrentPad
<unoidl
::detail
::SourceProviderPolymorphicStructTypeTemplateEntityPad
>(
1196 OUString id
(convertName
($3));
1197 if
(std
::find
(pad
->typeParameters.begin
(), pad
->typeParameters.end
(), id
)
1198 != pad
->typeParameters.end
())
1202 ("polymorphic struct type template " + data
->currentName
1203 + " type parameter " + id
1204 + " has same identifier as another type parameter"));
1207 pad
->typeParameters.push_back
(id
);
1211 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
1212 rtl
::Reference
<unoidl
::detail
::SourceProviderPolymorphicStructTypeTemplateEntityPad
>
1213 pad
(getCurrentPad
<unoidl
::detail
::SourceProviderPolymorphicStructTypeTemplateEntityPad
>(
1215 OUString id
(convertName
($1));
1216 assert
(pad
->typeParameters.empty
());
1217 pad
->typeParameters.push_back
(id
);
1222 deprecated_opt published_opt TOK_EXCEPTION identifier singleInheritance_opt
1224 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
1225 data
->publishedContext
= $2;
1226 convertToCurrentName
(data
, $4);
1228 rtl
::Reference
<unoidl
::ExceptionTypeEntity
> baseEnt
;
1229 if
($5 != nullptr
) {
1230 baseName
= convertName
($5);
1231 unoidl
::detail
::SourceProviderEntity
const * p
;
1233 @
5, yyscanner
, data
, false
, &baseName
, &p
, nullptr
, nullptr
)
1238 if
(p
== nullptr ||
!p
->entity.is
()
1239 || p
->entity
->getSort
() != unoidl
::Entity
::SORT_EXCEPTION_TYPE
)
1243 ("exception type " + data
->currentName
+ " base " + baseName
1244 + " does not resolve to an existing exception type"));
1247 baseEnt
= static_cast
<unoidl
::ExceptionTypeEntity
*>(
1249 if
($2 && !baseEnt
->isPublished
()) {
1252 ("published exception type " + data
->currentName
+ " base "
1253 + baseName
+ " is unpublished"));
1257 if
(!data
->entities.emplace
(
1259 unoidl
::detail
::SourceProviderEntity
(
1260 new unoidl
::detail
::SourceProviderExceptionTypeEntityPad
(
1261 $2, baseName
, baseEnt
))).
1264 error(@
4, yyscanner
, "multiple entities named " + data
->currentName
);
1268 '{' structMembers
'}' ';'
1270 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
1271 unoidl
::detail
::SourceProviderEntity
* ent
= getCurrentEntity
(data
);
1272 unoidl
::detail
::SourceProviderExceptionTypeEntityPad
* pad
=
1273 dynamic_cast
<unoidl
::detail
::SourceProviderExceptionTypeEntityPad
*>(
1275 assert
(pad
!= nullptr
);
1276 ent
->entity
= new unoidl
::ExceptionTypeEntity
(
1277 pad
->isPublished
(), pad
->baseName
, std
::move
(pad
->members
), annotations
($1));
1279 clearCurrentState
(data
);
1284 structMembers structMember
1289 deprecated_opt type identifier
';'
1291 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
1292 unoidl
::detail
::SourceProviderType t
(*$2);
1294 OUString id
(convertName
($3));
1296 case unoidl
::detail
::SourceProviderType
::TYPE_VOID
:
1297 case unoidl
::detail
::SourceProviderType
::TYPE_EXCEPTION
:
1300 ("illegal struct/exception type " + data
->currentName
1301 + " direct member " + id
+ " type"));
1307 if
(t.type
!= unoidl
::detail
::SourceProviderType
::TYPE_PARAMETER
1308 && t.getName
() == data
->currentName
) // no need to worry about typedef
1312 ("struct/exception type " + data
->currentName
+ " direct member "
1313 + id
+ " has same type as the type itself"));
1316 if
(checkInstantiatedPolymorphicStructTypeArgument
(t
, data
->currentName
))
1320 ("struct/exception type " + data
->currentName
+ " direct member "
1322 + (" has instantiated polymorphic struct type that uses the type"
1323 " itself as an argument")));
1326 if
(nameHasSameIdentifierAs
(data
->currentName
, id
)) {
1329 ("struct/exception type " + data
->currentName
+ " direct member "
1330 + id
+ " has same unqualified identifier as the type itself"));
1333 unoidl
::detail
::SourceProviderEntity
* ent
= getCurrentEntity
(data
);
1334 unoidl
::detail
::SourceProviderPlainStructTypeEntityPad
* p1
=
1335 dynamic_cast
<unoidl
::detail
::SourceProviderPlainStructTypeEntityPad
*>(
1337 if
(p1
!= nullptr
) {
1338 for
(const auto
& i
: p1
->members
) {
1342 ("plain struct type " + data
->currentName
1343 + " direct member " + id
1344 + " has same identifier as another direct member"));
1348 if
(p1
->baseEntity.is
()) {
1349 OUString baseName
(p1
->baseName
);
1350 for
(auto baseEnt
(p1
->baseEntity
);;) {
1351 if
(nameHasSameIdentifierAs
(baseName
, id
)) {
1354 ("plain struct type " + data
->currentName
1355 + " direct member " + id
1356 + " has same unqalified identifier as base "
1360 for
(auto
& i
: baseEnt
->getDirectMembers
()) {
1364 ("plain struct type " + data
->currentName
1365 + " direct member " + id
1366 + " has same identifier as a member of base "
1371 baseName
= baseEnt
->getDirectBase
();
1372 if
(baseName.isEmpty
()) {
1375 unoidl
::detail
::SourceProviderEntity
const * p
;
1377 @
2, yyscanner
, data
, false
, &baseName
, &p
, nullptr
,
1383 if
(p
== nullptr ||
!p
->entity.is
()
1384 ||
(p
->entity
->getSort
()
1385 != unoidl
::Entity
::SORT_PLAIN_STRUCT_TYPE
))
1389 ("inconsistent type manager: plain struct type "
1390 + data
->currentName
+ " base " + baseName
1391 + (" does not resolve to an existing plain struct"
1395 baseEnt
= static_cast
<unoidl
::PlainStructTypeEntity
*>(
1399 p1
->members.emplace_back
(id
, t.getName
(), annotations
($1));
1401 unoidl
::detail
::SourceProviderPolymorphicStructTypeTemplateEntityPad
*
1402 p2
= dynamic_cast
<unoidl
::detail
::SourceProviderPolymorphicStructTypeTemplateEntityPad
*>(
1404 if
(p2
!= nullptr
) {
1405 for
(const auto
& i
: p2
->members
) {
1409 ("polymorphic struct type template "
1410 + data
->currentName
+ " direct member " + id
1411 + " has same identifier as another direct member"));
1415 p2
->members.emplace_back
(
1417 t.type
== unoidl
::detail
::SourceProviderType
::TYPE_PARAMETER
,
1420 unoidl
::detail
::SourceProviderExceptionTypeEntityPad
* p3
1421 = dynamic_cast
<unoidl
::detail
::SourceProviderExceptionTypeEntityPad
*>(
1423 assert
(p3
!= nullptr
);
1424 for
(const auto
& i
: p3
->members
) {
1428 ("exception type " + data
->currentName
1429 + " direct member " + id
1430 + " has same identifier as another direct member"));
1434 if
(p3
->baseEntity.is
()) {
1435 OUString baseName
(p3
->baseName
);
1436 for
(auto baseEnt
(p3
->baseEntity
);;) {
1437 if
(nameHasSameIdentifierAs
(baseName
, id
)) {
1440 ("exception type " + data
->currentName
1441 + " direct member " + id
1442 + " has same unqalified identifier as base "
1446 for
(auto
& i
: baseEnt
->getDirectMembers
()) {
1450 ("exception type " + data
->currentName
1451 + " direct member " + id
1452 + " has same identifier as a member of base "
1457 baseName
= baseEnt
->getDirectBase
();
1458 if
(baseName.isEmpty
()) {
1461 unoidl
::detail
::SourceProviderEntity
const * p
;
1463 @
2, yyscanner
, data
, false
, &baseName
, &p
,
1469 if
(p
== nullptr ||
!p
->entity.is
()
1470 ||
(p
->entity
->getSort
()
1471 != unoidl
::Entity
::SORT_EXCEPTION_TYPE
))
1475 ("inconsistent type manager: exception type "
1476 + data
->currentName
+ " base " + baseName
1477 + (" does not resolve to an existing exception"
1481 baseEnt
= static_cast
<unoidl
::ExceptionTypeEntity
*>(
1485 p3
->members.emplace_back
(id
, t.getName
(), annotations
($1));
1492 deprecated_opt published_opt TOK_INTERFACE identifier singleInheritance_opt
1494 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
1495 data
->publishedContext
= $2;
1496 convertToCurrentName
(data
, $4);
1498 rtl
::Reference
<unoidl
::InterfaceTypeEntity
> baseEnt
;
1499 if
($5 != nullptr
) {
1500 baseName
= convertName
($5);
1501 unoidl
::detail
::SourceProviderEntity
const * p
;
1503 @
5, yyscanner
, data
, true
, &baseName
, &p
, nullptr
, nullptr
)
1508 if
(p
== nullptr ||
!p
->entity.is
()
1509 || p
->entity
->getSort
() != unoidl
::Entity
::SORT_INTERFACE_TYPE
)
1513 ("interface type " + data
->currentName
+ " direct base "
1515 + " does not resolve to an existing interface type"));
1518 baseEnt
= static_cast
<unoidl
::InterfaceTypeEntity
*>(p
->entity.get
());
1519 if
($2 && !baseEnt
->isPublished
()) {
1522 ("published interface type " + data
->currentName
1523 + " direct base " + baseName
+ " is unpublished"));
1527 std
::map
<OUString
, unoidl
::detail
::SourceProviderEntity
>::iterator i
(
1528 data
->entities.find
(data
->currentName
));
1529 if
(i
!= data
->entities.end
()) {
1530 switch
(i
->second.kind
) {
1531 case unoidl
::detail
::SourceProviderEntity
::KIND_INTERFACE_DECL
:
1533 case unoidl
::detail
::SourceProviderEntity
::KIND_PUBLISHED_INTERFACE_DECL
:
1537 ("unpublished interface type " + data
->currentName
1538 + " has been declared published"));
1545 "multiple entities named " + data
->currentName
);
1550 rtl
::Reference
<unoidl
::detail
::SourceProviderInterfaceTypeEntityPad
> pad
(
1551 new unoidl
::detail
::SourceProviderInterfaceTypeEntityPad
(
1554 && !pad
->addDirectBase
(
1555 @
4, yyscanner
, data
,
1556 unoidl
::detail
::SourceProviderInterfaceTypeEntityPad
::DirectBase
(
1557 baseName
, baseEnt
, std
::vector
<OUString
>()),
1562 data
->entities
[data
->currentName
] = unoidl
::detail
::SourceProviderEntity
(
1565 '{' interfaceMembers
'}' ';'
1567 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
1568 unoidl
::detail
::SourceProviderEntity
* ent
= getCurrentEntity
(data
);
1569 unoidl
::detail
::SourceProviderInterfaceTypeEntityPad
* pad
=
1570 dynamic_cast
<unoidl
::detail
::SourceProviderInterfaceTypeEntityPad
*>(
1572 assert
(pad
!= nullptr
);
1573 if
(pad
->directMandatoryBases.empty
()
1574 && data
->currentName
!= "com.sun.star.uno.XInterface")
1576 OUString base
(".com.sun.star.uno.XInterface");
1577 unoidl
::detail
::SourceProviderEntity
const * p
;
1578 if
(findEntity
(@
4, yyscanner
, data
, true
, &base
, &p
, nullptr
, nullptr
)
1583 if
(p
== nullptr ||
!p
->entity.is
()
1584 || p
->entity
->getSort
() != unoidl
::Entity
::SORT_INTERFACE_TYPE
)
1588 ("interface type " + data
->currentName
1589 + " implicit direct base " + base
1590 + " does not resolve to an existing interface type"));
1593 if
(!pad
->addDirectBase
(
1594 @
3, yyscanner
, data
,
1595 unoidl
::detail
::SourceProviderInterfaceTypeEntityPad
::DirectBase
(
1597 static_cast
<unoidl
::InterfaceTypeEntity
*>(
1599 std
::vector
<OUString
>()),
1605 std
::vector
<unoidl
::AnnotatedReference
> mbases
;
1606 for
(auto
& i
: pad
->directMandatoryBases
) {
1607 mbases.emplace_back
(i.name
, std
::move
(i.annotations
));
1609 std
::vector
<unoidl
::AnnotatedReference
> obases
;
1610 for
(auto
& i
: pad
->directOptionalBases
) {
1611 obases.emplace_back
(i.name
, std
::move
(i.annotations
));
1613 ent
->entity
= new unoidl
::InterfaceTypeEntity
(
1614 pad
->isPublished
(), std
::move
(mbases
), std
::move
(obases
), std
::move
(pad
->directAttributes
),
1615 std
::move
(pad
->directMethods
), annotations
($1));
1617 clearCurrentState
(data
);
1622 interfaceMembers interfaceMember
1628 | interfaceAttribute
1633 deprecated_opt flagSection_opt TOK_INTERFACE name
';'
1635 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
1636 OUString name
(convertName
($4));
1637 rtl
::Reference
<unoidl
::detail
::SourceProviderInterfaceTypeEntityPad
> pad
(
1638 getCurrentPad
<unoidl
::detail
::SourceProviderInterfaceTypeEntityPad
>(
1640 if
(pad
->singleBase
) {
1643 "single-inheritance interface cannot have additional bases");
1646 if
(($2 & ~unoidl
::detail
::FLAG_OPTIONAL
) != 0) {
1649 "interface base can only be flagged as [optional]");
1652 bool opt
= ($2 & unoidl
::detail
::FLAG_OPTIONAL
) != 0;
1653 OUString orgName
(name
);
1654 unoidl
::detail
::SourceProviderEntity
const * p
;
1655 bool typedefed
= false
;
1656 if
(findEntity
(@
4, yyscanner
, data
, true
, &name
, &p
, &typedefed
, nullptr
)
1661 if
(p
== nullptr ||
!p
->entity.is
()
1662 || p
->entity
->getSort
() != unoidl
::Entity
::SORT_INTERFACE_TYPE
)
1666 ("interface type " + data
->currentName
+ " direct base " + name
1667 + " does not resolve to an existing interface type"));
1673 ("interface type " + data
->currentName
+ " direct base " + orgName
1674 + " is a typedef"));
1677 rtl
::Reference
<unoidl
::InterfaceTypeEntity
> ent
(
1678 static_cast
<unoidl
::InterfaceTypeEntity
*>(p
->entity.get
()));
1679 if
(data
->publishedContext
&& !ent
->isPublished
()) {
1682 ("published interface type " + data
->currentName
+ " direct base "
1683 + name
+ " is unpublished"));
1686 if
(!pad
->addDirectBase
(
1687 @
4, yyscanner
, data
,
1688 unoidl
::detail
::SourceProviderInterfaceTypeEntityPad
::DirectBase
(
1689 name
, ent
, annotations
($1)),
1698 deprecated_opt flagSection type identifier
1700 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
1701 unoidl
::detail
::SourceProviderType t
(*$3);
1703 OUString id
(convertName
($4));
1704 if
(($2 & unoidl
::detail
::FLAG_ATTRIBUTE
) == 0) {
1707 "interface attribute must be flagged as [attribute]");
1711 & ~
(unoidl
::detail
::FLAG_ATTRIBUTE | unoidl
::detail
::FLAG_BOUND
1712 | unoidl
::detail
::FLAG_READONLY
))
1717 ("interface attribute can only be flagged as [attribute,"
1718 " bound, readonly]"));
1722 case unoidl
::detail
::SourceProviderType
::TYPE_VOID
:
1723 case unoidl
::detail
::SourceProviderType
::TYPE_EXCEPTION
:
1726 ("illegal interface type " + data
->currentName
1727 + " direct attribute " + id
+ " type"));
1733 rtl
::Reference
<unoidl
::detail
::SourceProviderInterfaceTypeEntityPad
> pad
(
1734 getCurrentPad
<unoidl
::detail
::SourceProviderInterfaceTypeEntityPad
>(
1736 if
(!pad
->addDirectMember
(@
4, yyscanner
, data
, id
)) {
1739 pad
->directAttributes.emplace_back
(
1740 id
, t.getName
(), ($2 & unoidl
::detail
::FLAG_BOUND
) != 0,
1741 ($2 & unoidl
::detail
::FLAG_READONLY
) != 0,
1742 std
::vector
<OUString
>(), std
::vector
<OUString
>(), annotations
($1));
1744 attributeAccessDecls_opt
';'
1747 attributeAccessDecls_opt:
1748 '{' attributeAccessDecls
'}'
1752 attributeAccessDecls:
1753 attributeAccessDecls attributeAccessDecl
1755 if
(($1 & $2) != 0) {
1757 @
2, yyscanner
, "duplicate get/set attribute access declaration");
1760 $$
= unoidl
::detail
::SourceProviderAccessDecls
($1 |
$2);
1762 |
/* empty */ { $$
= unoidl
::detail
::SourceProviderAccessDecls
(0); }
1765 attributeAccessDecl:
1766 TOK_GET exceptionSpec
';'
1768 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
1769 rtl
::Reference
<unoidl
::detail
::SourceProviderInterfaceTypeEntityPad
>
1770 pad
(getCurrentPad
<unoidl
::detail
::SourceProviderInterfaceTypeEntityPad
>(
1772 assert
(!pad
->directAttributes.empty
());
1773 pad
->directAttributes.back
().getExceptions
= *$2;
1775 $$
= unoidl
::detail
::ACCESS_DECL_GET
;
1777 | TOK_SET exceptionSpec
';'
1779 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
1780 rtl
::Reference
<unoidl
::detail
::SourceProviderInterfaceTypeEntityPad
>
1781 pad
(getCurrentPad
<unoidl
::detail
::SourceProviderInterfaceTypeEntityPad
>(
1783 assert
(!pad
->directAttributes.empty
());
1784 pad
->directAttributes.back
().setExceptions
= *$2;
1786 if
(pad
->directAttributes.back
().readOnly
) {
1789 ("interface type " + data
->currentName
1790 + " direct read-only attribute "
1791 + pad
->directAttributes.back
().name
1792 + " cannot have set access declaration"));
1795 $$
= unoidl
::detail
::ACCESS_DECL_SET
;
1800 deprecated_opt type identifier
1802 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
1803 unoidl
::detail
::SourceProviderType t
(*$2);
1805 OUString id
(convertName
($3));
1806 if
(t.type
== unoidl
::detail
::SourceProviderType
::TYPE_EXCEPTION
) {
1809 ("illegal interface type " + data
->currentName
1810 + " direct method " + id
+ " return type"));
1813 rtl
::Reference
<unoidl
::detail
::SourceProviderInterfaceTypeEntityPad
> pad
(
1814 getCurrentPad
<unoidl
::detail
::SourceProviderInterfaceTypeEntityPad
>(
1816 if
(!pad
->addDirectMember
(@
3, yyscanner
, data
, id
)) {
1819 pad
->directMethods.emplace_back
(
1821 std
::vector
<unoidl
::InterfaceTypeEntity
::Method
::Parameter
>(),
1822 std
::vector
<OUString
>(), annotations
($1));
1824 '(' methodParams_opt
')' exceptionSpec_opt
';'
1826 if
($8 != nullptr
) {
1827 unoidl
::detail
::SourceProviderScannerData
* data
1828 = yyget_extra
(yyscanner
);
1829 rtl
::Reference
<unoidl
::detail
::SourceProviderInterfaceTypeEntityPad
>
1830 pad
(getCurrentPad
<unoidl
::detail
::SourceProviderInterfaceTypeEntityPad
>(
1832 assert
(!pad
->directMethods.empty
());
1833 pad
->directMethods.back
().exceptions
= *$8;
1845 methodParams
',' methodParam
1850 '[' direction
']' type identifier
1852 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
1853 unoidl
::detail
::SourceProviderType t
(*$4);
1855 OUString id
(convertName
($5));
1856 rtl
::Reference
<unoidl
::detail
::SourceProviderInterfaceTypeEntityPad
>
1857 pad
(getCurrentPad
<unoidl
::detail
::SourceProviderInterfaceTypeEntityPad
>(
1859 assert
(!pad
->directMethods.empty
());
1861 case unoidl
::detail
::SourceProviderType
::TYPE_VOID
:
1862 case unoidl
::detail
::SourceProviderType
::TYPE_EXCEPTION
:
1865 ("illegal interface type " + data
->currentName
1866 + " direct method " + pad
->directMethods.back
().name
1867 + " parameter " + id
+ " type"));
1873 for
(const auto
& i
: pad
->directMethods.back
().parameters
) {
1877 ("interface type " + data
->currentName
+ " direct method "
1878 + pad
->directMethods.back
().name
+ " parameter " + id
1879 + " has same identifier as another parameter"));
1883 pad
->directMethods.back
().parameters.emplace_back
(id
, t.getName
(), $2);
1888 TOK_IN
{ $$
= unoidl
::InterfaceTypeEntity
::Method
::Parameter
::DIRECTION_IN
; }
1890 { $$
= unoidl
::InterfaceTypeEntity
::Method
::Parameter
::DIRECTION_OUT
; }
1892 { $$
= unoidl
::InterfaceTypeEntity
::Method
::Parameter
::DIRECTION_IN_OUT
; }
1896 deprecated_opt published_opt TOK_TYPEDEF type identifier
';'
1898 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
1899 data
->publishedContext
= $2;
1900 unoidl
::detail
::SourceProviderType t
(*$4);
1902 OUString name
(convertToFullName
(data
, $5));
1903 // There is no good reason to forbid typedefs to VOID, to instantiated
1904 // polymorphic struct types, and to exception types, but some old client
1905 // code of registry data expects this typedef restriction (like the
1906 // assert(false) default in handleTypedef in
1907 // codemaker/source/javamaker/javatype.cxx), so forbid them for now:
1909 case unoidl
::detail
::SourceProviderType
::TYPE_VOID
:
1910 case unoidl
::detail
::SourceProviderType
::TYPE_EXCEPTION
:
1911 case unoidl
::detail
::SourceProviderType
::TYPE_INSTANTIATED_POLYMORPHIC_STRUCT
:
1912 error(@
4, yyscanner
, "bad typedef type");
1915 case unoidl
::detail
::SourceProviderType
::TYPE_ENUM
:
1916 case unoidl
::detail
::SourceProviderType
::TYPE_PLAIN_STRUCT
:
1917 case unoidl
::detail
::SourceProviderType
::TYPE_INTERFACE
:
1920 switch
(t.entity
->kind
) {
1921 case unoidl
::detail
::SourceProviderEntity
::KIND_INTERFACE_DECL
:
1924 case unoidl
::detail
::SourceProviderEntity
::KIND_PUBLISHED_INTERFACE_DECL
:
1926 case unoidl
::detail
::SourceProviderEntity
::KIND_MODULE
:
1929 assert
(t.entity
->entity.is
() || t.entity
->pad.is
());
1931 = !(t.entity
->entity.is
()
1932 ? static_cast
<unoidl
::PublishableEntity
*>(
1933 t.entity
->entity.get
())->isPublished
()
1934 : t.entity
->pad
->isPublished
());
1940 "published typedef " + name
+ " type is unpublished");
1945 case unoidl
::detail
::SourceProviderType
::TYPE_PARAMETER
:
1950 if
(!data
->entities.emplace
(
1952 unoidl
::detail
::SourceProviderEntity
(
1953 unoidl
::detail
::SourceProviderEntity
::KIND_LOCAL
,
1954 new unoidl
::TypedefEntity
(
1955 $2, t.getName
(), annotations
($1)))).
1958 error(@
5, yyscanner
, "multiple entities named " + name
);
1961 clearCurrentState
(data
);
1966 deprecated_opt published_opt TOK_CONSTANTS identifier
1968 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
1969 data
->publishedContext
= $2;
1970 convertToCurrentName
(data
, $4);
1971 if
(!data
->entities.emplace
(
1973 unoidl
::detail
::SourceProviderEntity
(
1974 new unoidl
::detail
::SourceProviderConstantGroupEntityPad
(
1978 error(@
4, yyscanner
, "multiple entities named " + data
->currentName
);
1982 '{' constants
'}' ';'
1984 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
1985 unoidl
::detail
::SourceProviderEntity
* ent
= getCurrentEntity
(data
);
1986 unoidl
::detail
::SourceProviderConstantGroupEntityPad
* pad
=
1987 dynamic_cast
<unoidl
::detail
::SourceProviderConstantGroupEntityPad
*>(
1989 assert
(pad
!= nullptr
);
1990 ent
->entity
= new unoidl
::ConstantGroupEntity
(
1991 pad
->isPublished
(), std
::move
(pad
->members
), annotations
($1));
1993 clearCurrentState
(data
);
2003 deprecated_opt TOK_CONST type identifier
'=' expr
';'
2005 OUString id
(convertName
($4));
2006 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
2007 rtl
::Reference
<unoidl
::detail
::SourceProviderConstantGroupEntityPad
> pad
(
2008 getCurrentPad
<unoidl
::detail
::SourceProviderConstantGroupEntityPad
>(
2010 unoidl
::detail
::SourceProviderType t
(*$3);
2012 unoidl
::ConstantValue v
(false
); // dummy value
2014 case unoidl
::detail
::SourceProviderType
::TYPE_BOOLEAN
:
2015 if
($6.type
!= unoidl
::detail
::SourceProviderExpr
::TYPE_BOOL
) {
2018 ("bad value of boolean-typed constant " + data
->currentName
2022 v
= unoidl
::ConstantValue
($6.bval
);
2024 case unoidl
::detail
::SourceProviderType
::TYPE_BYTE
:
2026 case unoidl
::detail
::SourceProviderExpr
::TYPE_INT
:
2027 if
($6.ival
< SAL_MIN_INT8 ||
$6.ival
> SAL_MAX_INT8
) {
2030 ("out-of-range byte-typed constant " + data
->currentName
2031 + "." + id
+ " value " + OUString
::number
($6.ival
)));
2034 v
= unoidl
::ConstantValue
(static_cast
<sal_Int8
>($6.ival
));
2036 case unoidl
::detail
::SourceProviderExpr
::TYPE_UINT
:
2037 if
($6.uval
> SAL_MAX_INT8
) {
2040 ("out-of-range byte-typed constant " + data
->currentName
2041 + "." + id
+ " value " + OUString
::number
($6.uval
)));
2044 v
= unoidl
::ConstantValue
(static_cast
<sal_Int8
>($6.uval
));
2049 ("bad value of byte-typed constant " + data
->currentName
+ "."
2055 case unoidl
::detail
::SourceProviderType
::TYPE_SHORT
:
2057 case unoidl
::detail
::SourceProviderExpr
::TYPE_INT
:
2058 if
($6.ival
< SAL_MIN_INT16 ||
$6.ival
> SAL_MAX_INT16
) {
2061 ("out-of-range short-typed constant " + data
->currentName
2062 + "." + id
+ " value " + OUString
::number
($6.ival
)));
2065 v
= unoidl
::ConstantValue
(static_cast
<sal_Int16
>($6.ival
));
2067 case unoidl
::detail
::SourceProviderExpr
::TYPE_UINT
:
2068 if
($6.uval
> SAL_MAX_INT16
) {
2071 ("out-of-range short-typed constant " + data
->currentName
2072 + "." + id
+ " value " + OUString
::number
($6.uval
)));
2075 v
= unoidl
::ConstantValue
(static_cast
<sal_Int16
>($6.uval
));
2080 ("bad value of short-typed constant " + data
->currentName
2086 case unoidl
::detail
::SourceProviderType
::TYPE_UNSIGNED_SHORT
:
2088 case unoidl
::detail
::SourceProviderExpr
::TYPE_INT
:
2089 if
($6.ival
< 0 ||
$6.ival
> SAL_MAX_UINT16
) {
2092 ("out-of-range unsigned-short-typed constant "
2093 + data
->currentName
+ "." + id
+ " value "
2094 + OUString
::number
($6.ival
)));
2097 v
= unoidl
::ConstantValue
(static_cast
<sal_uInt16
>($6.ival
));
2099 case unoidl
::detail
::SourceProviderExpr
::TYPE_UINT
:
2100 if
($6.uval
> SAL_MAX_UINT16
) {
2103 ("out-of-range unsigned-short-typed constant "
2104 + data
->currentName
+ "." + id
+ " value "
2105 + OUString
::number
($6.uval
)));
2108 v
= unoidl
::ConstantValue
(static_cast
<sal_uInt16
>($6.uval
));
2113 ("bad value of unsigned-short-typed constant "
2114 + data
->currentName
+ "." + id
));
2119 case unoidl
::detail
::SourceProviderType
::TYPE_LONG
:
2121 case unoidl
::detail
::SourceProviderExpr
::TYPE_INT
:
2122 if
($6.ival
< SAL_MIN_INT32 ||
$6.ival
> SAL_MAX_INT32
) {
2125 ("out-of-range long-typed constant " + data
->currentName
2126 + "." + id
+ " value " + OUString
::number
($6.ival
)));
2129 v
= unoidl
::ConstantValue
(static_cast
<sal_Int32
>($6.ival
));
2131 case unoidl
::detail
::SourceProviderExpr
::TYPE_UINT
:
2132 if
($6.uval
> SAL_MAX_INT32
) {
2135 ("out-of-range long-typed constant " + data
->currentName
2136 + "." + id
+ " value " + OUString
::number
($6.uval
)));
2139 v
= unoidl
::ConstantValue
(static_cast
<sal_Int32
>($6.uval
));
2144 ("bad value of long-typed constant " + data
->currentName
2150 case unoidl
::detail
::SourceProviderType
::TYPE_UNSIGNED_LONG
:
2152 case unoidl
::detail
::SourceProviderExpr
::TYPE_INT
:
2153 if
($6.ival
< 0 ||
$6.ival
> SAL_MAX_UINT32
) {
2156 ("out-of-range unsigned-long-typed constant "
2157 + data
->currentName
+ "." + id
+ " value "
2158 + OUString
::number
($6.ival
)));
2161 v
= unoidl
::ConstantValue
(static_cast
<sal_uInt32
>($6.ival
));
2163 case unoidl
::detail
::SourceProviderExpr
::TYPE_UINT
:
2164 if
($6.uval
> SAL_MAX_UINT32
) {
2167 ("out-of-range unsigned-long-typed constant "
2168 + data
->currentName
+ "." + id
+ " value "
2169 + OUString
::number
($6.uval
)));
2172 v
= unoidl
::ConstantValue
(static_cast
<sal_uInt32
>($6.uval
));
2177 ("bad value of unsigned-long-typed constant "
2178 + data
->currentName
+ "." + id
));
2183 case unoidl
::detail
::SourceProviderType
::TYPE_HYPER
:
2185 case unoidl
::detail
::SourceProviderExpr
::TYPE_INT
:
2186 v
= unoidl
::ConstantValue
($6.ival
);
2188 case unoidl
::detail
::SourceProviderExpr
::TYPE_UINT
:
2189 if
($6.uval
> SAL_MAX_INT64
) {
2192 ("out-of-range hyper-typed constant " + data
->currentName
2193 + "." + id
+ " value " + OUString
::number
($6.uval
)));
2196 v
= unoidl
::ConstantValue
(static_cast
<sal_Int64
>($6.uval
));
2201 ("bad value of hyper-typed constant " + data
->currentName
2207 case unoidl
::detail
::SourceProviderType
::TYPE_UNSIGNED_HYPER
:
2209 case unoidl
::detail
::SourceProviderExpr
::TYPE_INT
:
2213 ("out-of-range unsigned-hyper-typed constant "
2214 + data
->currentName
+ "." + id
+ " value "
2215 + OUString
::number
($6.ival
)));
2218 v
= unoidl
::ConstantValue
(static_cast
<sal_uInt64
>($6.ival
));
2220 case unoidl
::detail
::SourceProviderExpr
::TYPE_UINT
:
2221 v
= unoidl
::ConstantValue
($6.uval
);
2226 ("bad value of unsigned-hyper-typed constant "
2227 + data
->currentName
+ "." + id
));
2232 case unoidl
::detail
::SourceProviderType
::TYPE_FLOAT
:
2234 case unoidl
::detail
::SourceProviderExpr
::TYPE_BOOL
:
2237 ("bad boolean value of float-typed constant "
2238 + data
->currentName
+ "." + id
));
2241 case unoidl
::detail
::SourceProviderExpr
::TYPE_INT
:
2242 v
= unoidl
::ConstantValue
(static_cast
<float>($6.ival
));
2244 case unoidl
::detail
::SourceProviderExpr
::TYPE_UINT
:
2245 v
= unoidl
::ConstantValue
(static_cast
<float>($6.uval
));
2247 case unoidl
::detail
::SourceProviderExpr
::TYPE_FLOAT
:
2248 v
= unoidl
::ConstantValue
(static_cast
<float>($6.fval
));
2252 case unoidl
::detail
::SourceProviderType
::TYPE_DOUBLE
:
2254 case unoidl
::detail
::SourceProviderExpr
::TYPE_BOOL
:
2257 ("bad boolean value of double-typed constant "
2258 + data
->currentName
+ "." + id
));
2261 case unoidl
::detail
::SourceProviderExpr
::TYPE_INT
:
2262 v
= unoidl
::ConstantValue
(static_cast
<double>($6.ival
));
2264 case unoidl
::detail
::SourceProviderExpr
::TYPE_UINT
:
2265 v
= unoidl
::ConstantValue
(static_cast
<double>($6.uval
));
2267 case unoidl
::detail
::SourceProviderExpr
::TYPE_FLOAT
:
2268 v
= unoidl
::ConstantValue
($6.fval
);
2275 "bad type for constant " + data
->currentName
+ "." + id
);
2279 pad
->members.emplace_back
(id
, v
, annotations
($1));
2283 singleInterfaceBasedServiceDefn:
2284 deprecated_opt published_opt TOK_SERVICE identifier singleInheritance
2286 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
2287 data
->publishedContext
= $2;
2288 convertToCurrentName
(data
, $4);
2289 OUString base
(convertName
($5));
2290 unoidl
::detail
::SourceProviderEntity
const * p
;
2291 if
(findEntity
(@
5, yyscanner
, data
, false
, &base
, &p
, nullptr
, nullptr
)
2296 bool ifcBase
= false
;
2297 bool pubBase
= false
;
2300 case unoidl
::detail
::SourceProviderEntity
::KIND_INTERFACE_DECL
:
2304 case unoidl
::detail
::SourceProviderEntity
::KIND_PUBLISHED_INTERFACE_DECL
:
2310 && (p
->entity
->getSort
()
2311 == unoidl
::Entity
::SORT_INTERFACE_TYPE
))
2314 pubBase
= static_cast
<unoidl
::InterfaceTypeEntity
*>(
2315 p
->entity.get
())->isPublished
();
2323 ("single-interface--based service " + data
->currentName
+ " base "
2324 + base
+ " does not resolve to an interface type"));
2327 if
($2 && !pubBase
) {
2330 ("published single-interface--based service " + data
->currentName
2331 + " base " + base
+ " is unpublished"));
2334 if
(!data
->entities.emplace
(
2336 unoidl
::detail
::SourceProviderEntity
(
2337 new unoidl
::detail
::SourceProviderSingleInterfaceBasedServiceEntityPad
(
2341 error(@
4, yyscanner
, "multiple entities named " + data
->currentName
);
2347 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
2348 unoidl
::detail
::SourceProviderEntity
* ent
= getCurrentEntity
(data
);
2349 unoidl
::detail
::SourceProviderSingleInterfaceBasedServiceEntityPad
* pad
=
2350 dynamic_cast
<unoidl
::detail
::SourceProviderSingleInterfaceBasedServiceEntityPad
*>(
2352 assert
(pad
!= nullptr
);
2353 std
::vector
<unoidl
::SingleInterfaceBasedServiceEntity
::Constructor
> ctors
;
2355 for
(const auto
& i
: pad
->constructors
) {
2356 std
::vector
<unoidl
::SingleInterfaceBasedServiceEntity
::Constructor
::Parameter
> parms
;
2357 for
(auto
& j
: i.parameters
) {
2358 parms.emplace_back
(j.name
, j.type.getName
(), j.rest
);
2361 unoidl
::SingleInterfaceBasedServiceEntity
::Constructor
(
2362 i.name
, std
::vector
(parms
), std
::vector
(i.exceptions
), std
::vector
(i.annotations
)));
2365 assert
(pad
->constructors.empty
());
2367 unoidl
::SingleInterfaceBasedServiceEntity
::Constructor
());
2369 ent
->entity
= new unoidl
::SingleInterfaceBasedServiceEntity
(
2370 pad
->isPublished
(), pad
->base
, std
::move
(ctors
), annotations
($1));
2372 clearCurrentState
(data
);
2377 '{' ctors
'}' { $$
= true
; }
2378 |
/* empty */ { $$
= false
; }
2387 deprecated_opt identifier
2389 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
2390 OUString id
(convertName
($2));
2391 rtl
::Reference
<unoidl
::detail
::SourceProviderSingleInterfaceBasedServiceEntityPad
>
2392 pad
(getCurrentPad
<unoidl
::detail
::SourceProviderSingleInterfaceBasedServiceEntityPad
>(
2394 for
(const auto
& i
: pad
->constructors
) {
2398 ("single-interface--based service " + data
->currentName
2399 + " constructor " + id
2400 + " has same identifier as another constructor"));
2404 pad
->constructors.push_back
(
2405 unoidl
::detail
::SourceProviderSingleInterfaceBasedServiceEntityPad
::Constructor
(
2406 id
, annotations
($1)));
2408 '(' ctorParams_opt
')' exceptionSpec_opt
';'
2410 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
2411 rtl
::Reference
<unoidl
::detail
::SourceProviderSingleInterfaceBasedServiceEntityPad
>
2412 pad
(getCurrentPad
<unoidl
::detail
::SourceProviderSingleInterfaceBasedServiceEntityPad
>(
2414 assert
(!pad
->constructors.empty
());
2415 if
($7 != nullptr
) {
2416 pad
->constructors.back
().exceptions
= *$7;
2419 for
(auto i
(pad
->constructors.begin
()); i
!= pad
->constructors.end
() - 1;
2422 if
(i
->parameters.size
()
2423 == pad
->constructors.back
().parameters.size
())
2427 j
(i
->parameters.begin
()),
2428 k
(pad
->constructors.back
().parameters.begin
());
2429 j
!= i
->parameters.end
(); ++j
, ++k
)
2431 if
(!j
->type.equals
(k
->type
) || j
->rest
!= k
->rest
) {
2439 ("single-interface--based service " + data
->currentName
2440 + " constructor " + pad
->constructors.back
().name
2441 + " has similar paramete list to constructor "
2456 ctorParams
',' ctorParam
2461 '[' direction
']' type ellipsis_opt identifier
2463 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
2464 unoidl
::detail
::SourceProviderType t
(*$4);
2466 OUString id
(convertName
($6));
2467 rtl
::Reference
<unoidl
::detail
::SourceProviderSingleInterfaceBasedServiceEntityPad
>
2468 pad
(getCurrentPad
<unoidl
::detail
::SourceProviderSingleInterfaceBasedServiceEntityPad
>(
2470 assert
(!pad
->constructors.empty
());
2471 if
($2 != unoidl
::InterfaceTypeEntity
::Method
::Parameter
::DIRECTION_IN
) {
2474 ("single-interface--based service " + data
->currentName
2475 + " constructor " + pad
->constructors.back
().name
+ " parameter "
2476 + id
+ " direction must be [in]"));
2480 case unoidl
::detail
::SourceProviderType
::TYPE_VOID
:
2481 case unoidl
::detail
::SourceProviderType
::TYPE_EXCEPTION
:
2484 ("illegal single-interface--based service " + data
->currentName
2485 + " constructor " + pad
->constructors.back
().name
+ " parameter "
2493 if
(t.type
!= unoidl
::detail
::SourceProviderType
::TYPE_ANY
) {
2496 ("illegal single-interface--based service "
2497 + data
->currentName
+ " constructor "
2498 + pad
->constructors.back
().name
+ " rest parameter " + id
2499 + " non-any type"));
2502 if
(!pad
->constructors.back
().parameters.empty
()) {
2505 ("single-interface--based service " + data
->currentName
2506 + " constructor " + pad
->constructors.back
().name
2507 + " rest parameter " + id
+ " must be first parameter"));
2510 } else if
(!pad
->constructors.back
().parameters.empty
()
2511 && pad
->constructors.back
().parameters.back
().rest
)
2515 ("single-interface--based service " + data
->currentName
2516 + " constructor " + pad
->constructors.back
().name
2517 + " rest parameter must be last parameter"));
2520 for
(const auto
& i
: pad
->constructors.back
().parameters
) {
2524 ("single-interface--based service " + data
->currentName
2525 + " constructor " + pad
->constructors.back
().name
2526 + " parameter " + id
2527 + " has same identifier as another parameter"));
2531 pad
->constructors.back
().parameters.push_back
(
2532 unoidl
::detail
::SourceProviderSingleInterfaceBasedServiceEntityPad
::Constructor
::Parameter
(
2538 TOK_ELLIPSIS
{ $$
= true
; }
2539 |
/* empty */ { $$
= false
; }
2541 accumulationBasedServiceDefn:
2542 deprecated_opt published_opt TOK_SERVICE identifier
2544 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
2545 data
->publishedContext
= $2;
2546 convertToCurrentName
(data
, $4);
2547 if
(!data
->entities.emplace
(
2549 unoidl
::detail
::SourceProviderEntity
(
2550 new unoidl
::detail
::SourceProviderAccumulationBasedServiceEntityPad
(
2554 error(@
4, yyscanner
, "multiple entities named " + data
->currentName
);
2558 '{' serviceMembers
'}' ';'
2560 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
2561 unoidl
::detail
::SourceProviderEntity
* ent
= getCurrentEntity
(data
);
2562 unoidl
::detail
::SourceProviderAccumulationBasedServiceEntityPad
* pad
=
2563 dynamic_cast
<unoidl
::detail
::SourceProviderAccumulationBasedServiceEntityPad
*>(
2565 assert
(pad
!= nullptr
);
2566 ent
->entity
= new unoidl
::AccumulationBasedServiceEntity
(
2567 pad
->isPublished
(), std
::move
(pad
->directMandatoryBaseServices
),
2568 std
::move
(pad
->directOptionalBaseServices
), std
::move
(pad
->directMandatoryBaseInterfaces
),
2569 std
::move
(pad
->directOptionalBaseInterfaces
), std
::move
(pad
->directProperties
),
2572 clearCurrentState
(data
);
2577 serviceMembers serviceMember
2583 | serviceInterfaceBase
2588 deprecated_opt flagSection_opt TOK_SERVICE name
';'
2590 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
2591 OUString name
(convertName
($4));
2592 rtl
::Reference
<unoidl
::detail
::SourceProviderAccumulationBasedServiceEntityPad
> pad
(
2593 getCurrentPad
<unoidl
::detail
::SourceProviderAccumulationBasedServiceEntityPad
>(
2595 if
(($2 & ~unoidl
::detail
::FLAG_OPTIONAL
) != 0) {
2598 "service base can only be flagged as [optional]");
2601 bool opt
= ($2 & unoidl
::detail
::FLAG_OPTIONAL
) != 0;
2602 unoidl
::detail
::SourceProviderEntity
const * p
;
2603 if
(findEntity
(@
4, yyscanner
, data
, false
, &name
, &p
, nullptr
, nullptr
)
2608 if
(p
== nullptr ||
!p
->entity.is
()
2609 ||
(p
->entity
->getSort
()
2610 != unoidl
::Entity
::SORT_ACCUMULATION_BASED_SERVICE
))
2614 ("accumulation-based service " + data
->currentName
2615 + " direct base service " + name
2616 + " does not resolve to an accumulation-based service"));
2619 if
(data
->publishedContext
2620 && !static_cast
<unoidl
::AccumulationBasedServiceEntity
*>(
2621 p
->entity.get
())->isPublished
())
2625 ("published accumulation-based service " + data
->currentName
2626 + " direct base service " + name
+ " is unpublished"));
2629 std
::vector
<unoidl
::AnnotatedReference
> & v
(
2631 ? pad
->directOptionalBaseServices
: pad
->directMandatoryBaseServices
);
2632 for
(const auto
& i
: v
) {
2633 if
(name
== i.name
) {
2636 ("accumulation-based service " + data
->currentName
2637 + " duplicate direct base service " + name
));
2641 v.emplace_back
(name
, annotations
($1));
2645 serviceInterfaceBase:
2646 deprecated_opt flagSection_opt TOK_INTERFACE name
';'
2648 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
2649 OUString name
(convertName
($4));
2650 rtl
::Reference
<unoidl
::detail
::SourceProviderAccumulationBasedServiceEntityPad
> pad
(
2651 getCurrentPad
<unoidl
::detail
::SourceProviderAccumulationBasedServiceEntityPad
>(
2653 if
(($2 & ~unoidl
::detail
::FLAG_OPTIONAL
) != 0) {
2656 "interface base can only be flagged as [optional]");
2659 bool opt
= ($2 & unoidl
::detail
::FLAG_OPTIONAL
) != 0;
2660 unoidl
::detail
::SourceProviderEntity
const * p
;
2661 if
(findEntity
(@
4, yyscanner
, data
, false
, &name
, &p
, nullptr
, nullptr
)
2666 bool ifcBase
= false
;
2667 bool pubBase
= false
;
2670 case unoidl
::detail
::SourceProviderEntity
::KIND_INTERFACE_DECL
:
2674 case unoidl
::detail
::SourceProviderEntity
::KIND_PUBLISHED_INTERFACE_DECL
:
2680 && (p
->entity
->getSort
()
2681 == unoidl
::Entity
::SORT_INTERFACE_TYPE
))
2684 pubBase
= static_cast
<unoidl
::InterfaceTypeEntity
*>(
2685 p
->entity.get
())->isPublished
();
2693 ("accumulation-based service " + data
->currentName
2694 + " direct base interface " + name
2695 + " does not resolve to an interface type"));
2698 if
(data
->publishedContext
&& !opt
&& !pubBase
) {
2701 ("published accumulation-based service " + data
->currentName
2702 + " direct base interface " + name
+ " is unpublished"));
2705 std
::vector
<unoidl
::AnnotatedReference
> & v
(
2707 ? pad
->directOptionalBaseInterfaces
2708 : pad
->directMandatoryBaseInterfaces
);
2709 for
(const auto
& i
: v
) {
2710 if
(name
== i.name
) {
2713 ("accumulation-based service " + data
->currentName
2714 + " duplicate direct base interface " + name
));
2718 v.emplace_back
(name
, annotations
($1));
2723 deprecated_opt flagSection type identifier
';'
2725 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
2726 unoidl
::detail
::SourceProviderType t
(*$3);
2728 OUString id
(convertName
($4));
2729 if
(($2 & unoidl
::detail
::FLAG_PROPERTY
) == 0) {
2732 ("accumulation-based service property must be flagged as"
2737 & ~
(unoidl
::detail
::FLAG_BOUND | unoidl
::detail
::FLAG_CONSTRAINED
2738 | unoidl
::detail
::FLAG_MAYBEAMBIGUOUS
2739 | unoidl
::detail
::FLAG_MAYBEDEFAULT
2740 | unoidl
::detail
::FLAG_MAYBEVOID | unoidl
::detail
::FLAG_OPTIONAL
2741 | unoidl
::detail
::FLAG_PROPERTY | unoidl
::detail
::FLAG_READONLY
2742 | unoidl
::detail
::FLAG_REMOVABLE
2743 | unoidl
::detail
::FLAG_TRANSIENT
))
2748 ("accumulation-based service property can only be flagged as"
2749 " [property, bound, constrained, maybeambiguous, maybedefault,"
2750 " maybevoid, optional, readonly, removable, transient]"));
2754 if
(($2 & unoidl
::detail
::FLAG_BOUND
) != 0) {
2755 att |
= unoidl
::AccumulationBasedServiceEntity
::Property
::ATTRIBUTE_BOUND
;
2757 if
(($2 & unoidl
::detail
::FLAG_CONSTRAINED
) != 0) {
2758 att |
= unoidl
::AccumulationBasedServiceEntity
::Property
::ATTRIBUTE_CONSTRAINED
;
2760 if
(($2 & unoidl
::detail
::FLAG_MAYBEAMBIGUOUS
) != 0) {
2761 att |
= unoidl
::AccumulationBasedServiceEntity
::Property
::ATTRIBUTE_MAYBE_AMBIGUOUS
;
2763 if
(($2 & unoidl
::detail
::FLAG_MAYBEDEFAULT
) != 0) {
2764 att |
= unoidl
::AccumulationBasedServiceEntity
::Property
::ATTRIBUTE_MAYBE_DEFAULT
;
2766 if
(($2 & unoidl
::detail
::FLAG_MAYBEVOID
) != 0) {
2767 att |
= unoidl
::AccumulationBasedServiceEntity
::Property
::ATTRIBUTE_MAYBE_VOID
;
2769 if
(($2 & unoidl
::detail
::FLAG_OPTIONAL
) != 0) {
2770 att |
= unoidl
::AccumulationBasedServiceEntity
::Property
::ATTRIBUTE_OPTIONAL
;
2772 if
(($2 & unoidl
::detail
::FLAG_READONLY
) != 0) {
2773 att |
= unoidl
::AccumulationBasedServiceEntity
::Property
::ATTRIBUTE_READ_ONLY
;
2775 if
(($2 & unoidl
::detail
::FLAG_REMOVABLE
) != 0) {
2776 att |
= unoidl
::AccumulationBasedServiceEntity
::Property
::ATTRIBUTE_REMOVABLE
;
2778 if
(($2 & unoidl
::detail
::FLAG_TRANSIENT
) != 0) {
2779 att |
= unoidl
::AccumulationBasedServiceEntity
::Property
::ATTRIBUTE_TRANSIENT
;
2782 case unoidl
::detail
::SourceProviderType
::TYPE_VOID
:
2783 case unoidl
::detail
::SourceProviderType
::TYPE_EXCEPTION
:
2786 ("illegal accumulation-based service " + data
->currentName
2787 + " direct property " + id
+ " type"));
2793 rtl
::Reference
<unoidl
::detail
::SourceProviderAccumulationBasedServiceEntityPad
>
2794 pad
(getCurrentPad
<unoidl
::detail
::SourceProviderAccumulationBasedServiceEntityPad
>(
2796 for
(const auto
& i
: pad
->directProperties
) {
2800 ("accumulation-based service " + data
->currentName
2801 + " duplicate direct property " + id
));
2805 pad
->directProperties.emplace_back
(
2807 unoidl
::AccumulationBasedServiceEntity
::Property
::Attributes
(att
),
2812 interfaceBasedSingletonDefn:
2813 deprecated_opt published_opt TOK_SINGLETON identifier singleInheritance
';'
2815 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
2816 data
->publishedContext
= $2;
2817 OUString name
(convertToFullName
(data
, $4));
2818 OUString base
(convertName
($5));
2819 unoidl
::detail
::SourceProviderEntity
const * p
;
2820 if
(findEntity
(@
5, yyscanner
, data
, false
, &base
, &p
, nullptr
, nullptr
)
2825 bool ifcBase
= false
;
2826 bool pubBase
= false
;
2829 case unoidl
::detail
::SourceProviderEntity
::KIND_INTERFACE_DECL
:
2833 case unoidl
::detail
::SourceProviderEntity
::KIND_PUBLISHED_INTERFACE_DECL
:
2839 && (p
->entity
->getSort
()
2840 == unoidl
::Entity
::SORT_INTERFACE_TYPE
))
2843 pubBase
= static_cast
<unoidl
::InterfaceTypeEntity
*>(
2844 p
->entity.get
())->isPublished
();
2852 ("interface-based singleton " + name
+ " base " + base
2853 + " does not resolve to an interface type"));
2856 if
($2 && !pubBase
) {
2859 ("published interface-based singleton " + name
+ " base " + base
2860 + " is unpublished"));
2863 if
(!data
->entities.emplace
(
2865 unoidl
::detail
::SourceProviderEntity
(
2866 unoidl
::detail
::SourceProviderEntity
::KIND_LOCAL
,
2867 new unoidl
::InterfaceBasedSingletonEntity
(
2868 $2, base
, annotations
($1)))).
2871 error(@
4, yyscanner
, "multiple entities named " + name
);
2874 clearCurrentState
(data
);
2878 serviceBasedSingletonDefn:
2879 deprecated_opt published_opt TOK_SINGLETON identifier
'{' TOK_SERVICE name
';'
2882 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
2883 data
->publishedContext
= $2;
2884 OUString name
(convertToFullName
(data
, $4));
2885 OUString base
(convertName
($7));
2886 unoidl
::detail
::SourceProviderEntity
const * p
;
2887 if
(findEntity
(@
7, yyscanner
, data
, false
, &base
, &p
, nullptr
, nullptr
)
2894 ||
(p
->entity
->getSort
()
2895 != unoidl
::Entity
::SORT_ACCUMULATION_BASED_SERVICE
))
2899 ("service-based singleton " + name
+ " base " + base
2900 + " does not resolve to an accumulation-based service"));
2904 && !static_cast
<unoidl
::AccumulationBasedServiceEntity
*>(
2905 p
->entity.get
())->isPublished
())
2909 ("published service-based singleton " + name
+ " base " + base
2910 + " is unpublished"));
2913 if
(!data
->entities.emplace
(
2915 unoidl
::detail
::SourceProviderEntity
(
2916 unoidl
::detail
::SourceProviderEntity
::KIND_LOCAL
,
2917 new unoidl
::ServiceBasedSingletonEntity
(
2918 $2, base
, annotations
($1)))).
2921 error(@
4, yyscanner
, "multiple entities named " + name
);
2924 clearCurrentState
(data
);
2928 singleInheritance_opt:
2930 |
/* empty */ { $$
= nullptr
; }
2933 singleInheritance: ':' name
{ $$
= $2; }
2938 |
/* empty */ { $$
= nullptr
; }
2941 exceptionSpec: TOK_RAISES
'(' exceptions
')' { $$
= $3; }
2947 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
2948 OUString name
(convertName
($3));
2949 unoidl
::detail
::SourceProviderEntity
const * p
;
2950 if
(findEntity
(@
3, yyscanner
, data
, false
, &name
, &p
, nullptr
, nullptr
)
2953 delete
$1; /* see commented-out %destructor above */
2958 ||
(p
->entity
->getSort
() != unoidl
::Entity
::SORT_EXCEPTION_TYPE
))
2960 delete
$1; /* see commented-out %destructor above */
2963 ("exception " + name
+ " does not resolve to an exception type"));
2966 if
(data
->publishedContext
2967 && !(static_cast
<unoidl
::ExceptionTypeEntity
*>(p
->entity.get
())
2970 delete
$1; /* see commented-out %destructor above */
2973 ("unpublished exception " + name
+ " used in published context"));
2976 if
(std
::find
($1->begin
(), $1->end
(), name
) != $1->end
()) {
2977 delete
$1; /* see commented-out %destructor above */
2979 @
3, yyscanner
, ("exception " + name
+ " listed more than once"));
2982 $1->push_back
(name
);
2987 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
2988 OUString name
(convertName
($1));
2989 unoidl
::detail
::SourceProviderEntity
const * p
;
2990 if
(findEntity
(@
1, yyscanner
, data
, false
, &name
, &p
, nullptr
, nullptr
)
2997 ||
(p
->entity
->getSort
() != unoidl
::Entity
::SORT_EXCEPTION_TYPE
))
3001 ("exception " + name
+ " does not resolve to an exception type"));
3004 if
(data
->publishedContext
3005 && !(static_cast
<unoidl
::ExceptionTypeEntity
*>(p
->entity.get
())
3010 ("unpublished exception " + name
+ " used in published context"));
3013 $$
= new std
::vector
<OUString
>; $$
->push_back
(name
);
3018 deprecated_opt
/*ignored*/ published_opt TOK_INTERFACE identifier
';'
3020 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
3021 data
->publishedContext
= $2;
3022 OUString name
(convertToFullName
(data
, $4));
3023 std
::pair
<std
::map
<OUString
, unoidl
::detail
::SourceProviderEntity
>::iterator
, bool> p
(
3024 data
->entities.emplace
(
3026 unoidl
::detail
::SourceProviderEntity
(
3028 ? unoidl
::detail
::SourceProviderEntity
::KIND_PUBLISHED_INTERFACE_DECL
3029 : unoidl
::detail
::SourceProviderEntity
::KIND_INTERFACE_DECL
)));
3031 switch
(p.first
->second.kind
) {
3032 case unoidl
::detail
::SourceProviderEntity
::KIND_INTERFACE_DECL
:
3034 p.first
->second.kind
3035 = unoidl
::detail
::SourceProviderEntity
::KIND_PUBLISHED_INTERFACE_DECL
;
3038 case unoidl
::detail
::SourceProviderEntity
::KIND_PUBLISHED_INTERFACE_DECL
:
3041 assert
(p.first
->second.entity.is
());
3042 if
(p.first
->second.entity
->getSort
()
3043 != unoidl
::Entity
::SORT_INTERFACE_TYPE
)
3047 "multiple entities named " + data
->currentName
);
3051 && !static_cast
<unoidl
::InterfaceTypeEntity
*>(
3052 p.first
->second.entity.get
())->isPublished
())
3056 ("published interface type declaration "
3057 + data
->currentName
+ " has been defined unpublished"));
3062 clearCurrentState
(data
);
3067 TOK_PUBLISHED
{ $$
= true
; }
3068 |
/* empty */ { $$
= false
; }
3073 |
/* empty */ { $$
= unoidl
::detail
::SourceProviderFlags
(0); }
3076 flagSection: '[' flags
']' { $$
= $2; }
3082 if
(($1 & $3) != 0) {
3083 error(@
3, yyscanner
, "duplicate flag " + flagName
($3));
3086 $$
= unoidl
::detail
::SourceProviderFlags
($1 |
$3);
3092 TOK_ATTRIBUTE
{ $$
= unoidl
::detail
::FLAG_ATTRIBUTE
; }
3093 | TOK_BOUND
{ $$
= unoidl
::detail
::FLAG_BOUND
; }
3094 | TOK_CONSTRAINED
{ $$
= unoidl
::detail
::FLAG_CONSTRAINED
; }
3095 | TOK_MAYBEAMBIGUOUS
{ $$
= unoidl
::detail
::FLAG_MAYBEAMBIGUOUS
; }
3096 | TOK_MAYBEDEFAULT
{ $$
= unoidl
::detail
::FLAG_MAYBEDEFAULT
; }
3097 | TOK_MAYBEVOID
{ $$
= unoidl
::detail
::FLAG_MAYBEVOID
; }
3098 | TOK_OPTIONAL
{ $$
= unoidl
::detail
::FLAG_OPTIONAL
; }
3099 | TOK_PROPERTY
{ $$
= unoidl
::detail
::FLAG_PROPERTY
; }
3100 | TOK_READONLY
{ $$
= unoidl
::detail
::FLAG_READONLY
; }
3101 | TOK_REMOVABLE
{ $$
= unoidl
::detail
::FLAG_REMOVABLE
; }
3102 | TOK_TRANSIENT
{ $$
= unoidl
::detail
::FLAG_TRANSIENT
; }
3111 if
(!coerce
(@
1, yyscanner
, &$1, &$3)) {
3115 case unoidl
::detail
::SourceProviderExpr
::TYPE_INT
:
3116 $$
= unoidl
::detail
::SourceProviderExpr
::Int
($1.ival |
$3.ival
);
3118 case unoidl
::detail
::SourceProviderExpr
::TYPE_UINT
:
3119 $$
= unoidl
::detail
::SourceProviderExpr
::Uint
($1.uval |
$3.uval
);
3122 error(@
1, yyscanner
, "arguments of non-integer type to \"|\"");
3133 if
(!coerce
(@
1, yyscanner
, &$1, &$3)) {
3137 case unoidl
::detail
::SourceProviderExpr
::TYPE_INT
:
3138 $$
= unoidl
::detail
::SourceProviderExpr
::Int
($1.ival ^
$3.ival
);
3140 case unoidl
::detail
::SourceProviderExpr
::TYPE_UINT
:
3141 $$
= unoidl
::detail
::SourceProviderExpr
::Uint
($1.uval ^
$3.uval
);
3144 error(@
1, yyscanner
, "arguments of non-integer type to \"^\"");
3153 andExpr
'&' shiftExpr
3155 if
(!coerce
(@
1, yyscanner
, &$1, &$3)) {
3159 case unoidl
::detail
::SourceProviderExpr
::TYPE_INT
:
3160 $$
= unoidl
::detail
::SourceProviderExpr
::Int
($1.ival
& $3.ival
);
3162 case unoidl
::detail
::SourceProviderExpr
::TYPE_UINT
:
3163 $$
= unoidl
::detail
::SourceProviderExpr
::Uint
($1.uval
& $3.uval
);
3166 error(@
1, yyscanner
, "arguments of non-integer type to \"&\"");
3175 shiftExpr TOK_LEFTSHIFT addExpr
3179 case unoidl
::detail
::SourceProviderExpr
::TYPE_INT
:
3180 if
($3.ival
< 0 ||
$3.ival
> 63) {
3183 ("out-of-range shift argument " + OUString
::number
($3.ival
)
3187 n
= static_cast
<int>($3.ival
);
3189 case unoidl
::detail
::SourceProviderExpr
::TYPE_UINT
:
3193 ("out-of-range shift argument " + OUString
::number
($3.uval
)
3197 n
= static_cast
<int>($3.uval
);
3200 error(@
3, yyscanner
, "right argument of non-integer type to \"<<\"");
3204 case unoidl
::detail
::SourceProviderExpr
::TYPE_INT
:
3208 ("cannot left-shift negative argument "
3209 + OUString
::number
($1.ival
)));
3212 $$
= unoidl
::detail
::SourceProviderExpr
::Int
($1.ival
<< n
);
3214 case unoidl
::detail
::SourceProviderExpr
::TYPE_UINT
:
3215 $$
= unoidl
::detail
::SourceProviderExpr
::Uint
($1.uval
<< n
);
3218 error(@
1, yyscanner
, "left argument of non-integer type to \"<<\"");
3223 | shiftExpr TOK_RIGHTSHIFT addExpr
3227 case unoidl
::detail
::SourceProviderExpr
::TYPE_INT
:
3228 if
($3.ival
< 0 ||
$3.ival
> 63) {
3231 ("out-of-range shift argument " + OUString
::number
($3.ival
)
3235 n
= static_cast
<int>($3.ival
);
3237 case unoidl
::detail
::SourceProviderExpr
::TYPE_UINT
:
3241 ("out-of-range shift argument " + OUString
::number
($3.uval
)
3245 n
= static_cast
<int>($3.uval
);
3248 error(@
3, yyscanner
, "right argument of non-integer type to \">>\"");
3253 case unoidl
::detail
::SourceProviderExpr
::TYPE_INT
:
3254 $$
= unoidl
::detail
::SourceProviderExpr
::Int
($1.ival
>> n
);
3256 case unoidl
::detail
::SourceProviderExpr
::TYPE_UINT
:
3257 $$
= unoidl
::detail
::SourceProviderExpr
::Uint
($1.uval
>> n
);
3260 error(@
1, yyscanner
, "left argument of non-integer type to \">>\"");
3269 addExpr
'+' multExpr
3271 if
(!coerce
(@
1, yyscanner
, &$1, &$3)) {
3275 case unoidl
::detail
::SourceProviderExpr
::TYPE_BOOL
:
3276 error(@
1, yyscanner
, "arguments of boolean type to binary \"+\"");
3279 case unoidl
::detail
::SourceProviderExpr
::TYPE_INT
:
3280 $$
= unoidl
::detail
::SourceProviderExpr
::Int
($1.ival
+ $3.ival
); //TODO: overflow
3282 case unoidl
::detail
::SourceProviderExpr
::TYPE_UINT
:
3283 $$
= unoidl
::detail
::SourceProviderExpr
::Uint
($1.uval
+ $3.uval
); //TODO: overflow
3285 case unoidl
::detail
::SourceProviderExpr
::TYPE_FLOAT
:
3286 $$
= unoidl
::detail
::SourceProviderExpr
::Float
($1.fval
+ $3.fval
);
3290 | addExpr
'-' multExpr
3292 if
(!coerce
(@
1, yyscanner
, &$1, &$3)) {
3296 case unoidl
::detail
::SourceProviderExpr
::TYPE_BOOL
:
3297 error(@
1, yyscanner
, "arguments of boolean type to binary \"-\"");
3300 case unoidl
::detail
::SourceProviderExpr
::TYPE_INT
:
3301 $$
= unoidl
::detail
::SourceProviderExpr
::Int
($1.ival
- $3.ival
); //TODO: overflow
3303 case unoidl
::detail
::SourceProviderExpr
::TYPE_UINT
:
3304 $$
= unoidl
::detail
::SourceProviderExpr
::Uint
($1.uval
- $3.uval
); //TODO: overflow
3306 case unoidl
::detail
::SourceProviderExpr
::TYPE_FLOAT
:
3307 $$
= unoidl
::detail
::SourceProviderExpr
::Float
($1.fval
- $3.fval
);
3315 multExpr
'*' unaryExpr
3317 if
(!coerce
(@
1, yyscanner
, &$1, &$3)) {
3321 case unoidl
::detail
::SourceProviderExpr
::TYPE_BOOL
:
3322 error(@
1, yyscanner
, "arguments of boolean type to \"*\"");
3325 case unoidl
::detail
::SourceProviderExpr
::TYPE_INT
:
3326 $$
= unoidl
::detail
::SourceProviderExpr
::Int
($1.ival
* $3.ival
); //TODO: overflow
3328 case unoidl
::detail
::SourceProviderExpr
::TYPE_UINT
:
3329 $$
= unoidl
::detail
::SourceProviderExpr
::Uint
($1.uval
* $3.uval
); //TODO: overflow
3331 case unoidl
::detail
::SourceProviderExpr
::TYPE_FLOAT
:
3332 $$
= unoidl
::detail
::SourceProviderExpr
::Float
($1.fval
* $3.fval
);
3336 | multExpr
'/' unaryExpr
3338 if
(!coerce
(@
1, yyscanner
, &$1, &$3)) {
3342 case unoidl
::detail
::SourceProviderExpr
::TYPE_BOOL
:
3343 error(@
1, yyscanner
, "arguments of boolean type to \"/\"");
3346 case unoidl
::detail
::SourceProviderExpr
::TYPE_INT
:
3348 error(@
3, yyscanner
, "cannot divide by zero");
3351 $$
= unoidl
::detail
::SourceProviderExpr
::Int
($1.ival
/ $3.ival
);
3353 case unoidl
::detail
::SourceProviderExpr
::TYPE_UINT
:
3355 error(@
3, yyscanner
, "cannot divide by zero");
3358 $$
= unoidl
::detail
::SourceProviderExpr
::Uint
($1.uval
/ $3.uval
);
3360 case unoidl
::detail
::SourceProviderExpr
::TYPE_FLOAT
:
3362 error(@
3, yyscanner
, "cannot divide by zero");
3365 $$
= unoidl
::detail
::SourceProviderExpr
::Float
($1.fval
- $3.fval
);
3369 | multExpr
'%' unaryExpr
3371 if
(!coerce
(@
1, yyscanner
, &$1, &$3)) {
3375 case unoidl
::detail
::SourceProviderExpr
::TYPE_INT
:
3377 error(@
3, yyscanner
, "cannot divide by zero");
3380 $$
= unoidl
::detail
::SourceProviderExpr
::Int
($1.ival %
$3.ival
);
3382 case unoidl
::detail
::SourceProviderExpr
::TYPE_UINT
:
3384 error(@
3, yyscanner
, "cannot divide by zero");
3387 $$
= unoidl
::detail
::SourceProviderExpr
::Uint
($1.uval %
$3.uval
);
3390 error(@
1, yyscanner
, "arguments of non-integer type to \"%\"");
3401 if
($2.type
== unoidl
::detail
::SourceProviderExpr
::TYPE_BOOL
) {
3402 error(@
2, yyscanner
, "argument of boolean type to unary \"+\"");
3410 case unoidl
::detail
::SourceProviderExpr
::TYPE_BOOL
:
3411 error(@
2, yyscanner
, "argument of boolean type to unary \"-\"");
3414 case unoidl
::detail
::SourceProviderExpr
::TYPE_INT
:
3415 if
($2.ival
== SAL_MIN_INT64
) {
3416 error(@
2, yyscanner
, "cannot negate -2^63");
3419 $$
= unoidl
::detail
::SourceProviderExpr
::Int
(-$2.ival
);
3421 case unoidl
::detail
::SourceProviderExpr
::TYPE_UINT
:
3422 if
($2.uval
== SAL_CONST_UINT64
(0x8000000000000000)) {
3423 $$
= unoidl
::detail
::SourceProviderExpr
::Int
(SAL_MIN_INT64
);
3425 if
($2.uval
> SAL_MAX_INT64
) {
3428 ("cannot negate out-of-range value "
3429 + OUString
::number
($2.uval
)));
3432 $$
= unoidl
::detail
::SourceProviderExpr
::Int
(
3433 -static_cast
<sal_Int64
>($2.uval
));
3436 case unoidl
::detail
::SourceProviderExpr
::TYPE_FLOAT
:
3437 $$
= unoidl
::detail
::SourceProviderExpr
::Float
(-$2.fval
);
3444 case unoidl
::detail
::SourceProviderExpr
::TYPE_INT
:
3445 $$
= unoidl
::detail
::SourceProviderExpr
::Int
(~
$2.ival
);
3447 case unoidl
::detail
::SourceProviderExpr
::TYPE_UINT
:
3448 $$
= unoidl
::detail
::SourceProviderExpr
::Uint
(~
$2.uval
);
3451 error(@
2, yyscanner
, "argument of non-integer type to \"~\"");
3460 '(' expr
')' { $$
= $2; }
3461 | TOK_FALSE
{ $$
= unoidl
::detail
::SourceProviderExpr
::Bool
(false
); }
3462 | TOK_TRUE
{ $$
= unoidl
::detail
::SourceProviderExpr
::Bool
(true
); }
3463 | TOK_INTEGER
{ $$
= unoidl
::detail
::SourceProviderExpr
::Uint
($1); }
3464 | TOK_FLOATING
{ $$
= unoidl
::detail
::SourceProviderExpr
::Float
($1); }
3467 OUString name
(convertName
($1));
3468 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
3469 unoidl
::ConstantValue v
(false
); // dummy value
3472 sal_Int32 i
= name.lastIndexOf
('.');
3474 rtl
::Reference
<unoidl
::detail
::SourceProviderEntityPad
> pad
(
3475 getCurrentEntity
(data
)->pad
);
3476 unoidl
::detail
::SourceProviderEnumTypeEntityPad
* p1
= dynamic_cast
<
3477 unoidl
::detail
::SourceProviderEnumTypeEntityPad
*>(pad.get
());
3478 if
(p1
!= nullptr
) {
3479 for
(const auto
& j
: p1
->members
) {
3480 if
(j.name
== name
) {
3481 v
= unoidl
::ConstantValue
(j.value
);
3487 unoidl
::detail
::SourceProviderConstantGroupEntityPad
* p2
3489 unoidl
::detail
::SourceProviderConstantGroupEntityPad
*>(
3491 if
(p2
!= nullptr
) {
3492 for
(const auto
& j
: p2
->members
) {
3493 if
(j.name
== name
) {
3502 OUString scope
(name.copy
(0, i
));
3503 unoidl
::detail
::SourceProviderEntity
const * ent
;
3505 @
1, yyscanner
, data
, false
, &scope
, &ent
, nullptr
, nullptr
)
3510 if
(ent
!= nullptr
) {
3511 OUString id
(name.copy
(i
+ 1));
3512 // No need to check for enum members here, as they cannot be
3513 // referenced in expressions by qualified name (TODO: is that true?):
3514 if
(ent
->entity.is
()) {
3515 if
(ent
->entity
->getSort
()
3516 == unoidl
::Entity
::SORT_CONSTANT_GROUP
)
3518 std
::vector
<unoidl
::ConstantGroupEntity
::Member
> const &
3520 static_cast
<unoidl
::ConstantGroupEntity
*>(
3521 ent
->entity.get
())->
3523 for
(auto
& j
: mems
) {
3528 = !static_cast
<unoidl
::ConstantGroupEntity
*>(
3529 ent
->entity.get
())->isPublished
();
3534 } else if
(ent
->pad.is
()) {
3535 unoidl
::detail
::SourceProviderConstantGroupEntityPad
* pad
3537 unoidl
::detail
::SourceProviderConstantGroupEntityPad
*>(
3539 if
(pad
!= nullptr
) {
3540 for
(const auto
& j
: pad
->members
) {
3544 unpub
= !ent
->pad
->isPublished
();
3556 + (" does not resolve to neither a constant nor an unqualified"
3560 if
(data
->publishedContext
&& unpub
) {
3563 "unpublished value " + name
+ " used in published context");
3567 case unoidl
::ConstantValue
::TYPE_BOOLEAN
:
3568 $$
= unoidl
::detail
::SourceProviderExpr
::Bool
(v.booleanValue
);
3570 case unoidl
::ConstantValue
::TYPE_BYTE
:
3571 $$
= unoidl
::detail
::SourceProviderExpr
::Int
(v.byteValue
);
3573 case unoidl
::ConstantValue
::TYPE_SHORT
:
3574 $$
= unoidl
::detail
::SourceProviderExpr
::Int
(v.shortValue
);
3576 case unoidl
::ConstantValue
::TYPE_UNSIGNED_SHORT
:
3577 $$
= unoidl
::detail
::SourceProviderExpr
::Uint
(v.unsignedShortValue
);
3579 case unoidl
::ConstantValue
::TYPE_LONG
:
3580 $$
= unoidl
::detail
::SourceProviderExpr
::Int
(v.longValue
);
3582 case unoidl
::ConstantValue
::TYPE_UNSIGNED_LONG
:
3583 $$
= unoidl
::detail
::SourceProviderExpr
::Uint
(v.unsignedLongValue
);
3585 case unoidl
::ConstantValue
::TYPE_HYPER
:
3586 $$
= unoidl
::detail
::SourceProviderExpr
::Int
(v.hyperValue
);
3588 case unoidl
::ConstantValue
::TYPE_UNSIGNED_HYPER
:
3589 $$
= unoidl
::detail
::SourceProviderExpr
::Uint
(v.unsignedHyperValue
);
3591 case unoidl
::ConstantValue
::TYPE_FLOAT
:
3592 $$
= unoidl
::detail
::SourceProviderExpr
::Float
(v.floatValue
);
3594 case unoidl
::ConstantValue
::TYPE_DOUBLE
:
3595 $$
= unoidl
::detail
::SourceProviderExpr
::Float
(v.doubleValue
);
3602 typeArguments
',' type
3604 unoidl
::detail
::SourceProviderType t
(*$3);
3606 if
(!checkTypeArgument
(@
3, yyscanner
, t
)) {
3607 delete
$1; /* see commented-out %destructor above */
3615 unoidl
::detail
::SourceProviderType t
(*$1);
3617 if
(!checkTypeArgument
(@
1, yyscanner
, t
)) {
3620 $$
= new std
::vector
<unoidl
::detail
::SourceProviderType
>;
3628 $$
= new unoidl
::detail
::SourceProviderType
(
3629 unoidl
::detail
::SourceProviderType
::TYPE_VOID
);
3633 $$
= new unoidl
::detail
::SourceProviderType
(
3634 unoidl
::detail
::SourceProviderType
::TYPE_BOOLEAN
);
3638 $$
= new unoidl
::detail
::SourceProviderType
(
3639 unoidl
::detail
::SourceProviderType
::TYPE_BYTE
);
3643 $$
= new unoidl
::detail
::SourceProviderType
(
3644 unoidl
::detail
::SourceProviderType
::TYPE_SHORT
);
3646 | TOK_UNSIGNED TOK_SHORT
3648 $$
= new unoidl
::detail
::SourceProviderType
(
3649 unoidl
::detail
::SourceProviderType
::TYPE_UNSIGNED_SHORT
);
3653 $$
= new unoidl
::detail
::SourceProviderType
(
3654 unoidl
::detail
::SourceProviderType
::TYPE_LONG
);
3656 | TOK_UNSIGNED TOK_LONG
3658 $$
= new unoidl
::detail
::SourceProviderType
(
3659 unoidl
::detail
::SourceProviderType
::TYPE_UNSIGNED_LONG
);
3663 $$
= new unoidl
::detail
::SourceProviderType
(
3664 unoidl
::detail
::SourceProviderType
::TYPE_HYPER
);
3666 | TOK_UNSIGNED TOK_HYPER
3668 $$
= new unoidl
::detail
::SourceProviderType
(
3669 unoidl
::detail
::SourceProviderType
::TYPE_UNSIGNED_HYPER
);
3673 $$
= new unoidl
::detail
::SourceProviderType
(
3674 unoidl
::detail
::SourceProviderType
::TYPE_FLOAT
);
3678 $$
= new unoidl
::detail
::SourceProviderType
(
3679 unoidl
::detail
::SourceProviderType
::TYPE_DOUBLE
);
3683 $$
= new unoidl
::detail
::SourceProviderType
(
3684 unoidl
::detail
::SourceProviderType
::TYPE_CHAR
);
3688 $$
= new unoidl
::detail
::SourceProviderType
(
3689 unoidl
::detail
::SourceProviderType
::TYPE_STRING
);
3693 $$
= new unoidl
::detail
::SourceProviderType
(
3694 unoidl
::detail
::SourceProviderType
::TYPE_TYPE
);
3698 $$
= new unoidl
::detail
::SourceProviderType
(
3699 unoidl
::detail
::SourceProviderType
::TYPE_ANY
);
3701 | TOK_SEQUENCE
'<' type
'>'
3704 case unoidl
::detail
::SourceProviderType
::TYPE_VOID
:
3705 case unoidl
::detail
::SourceProviderType
::TYPE_EXCEPTION
:
3706 case unoidl
::detail
::SourceProviderType
::TYPE_PARAMETER
: //TODO?
3707 error(@
3, yyscanner
, "illegal sequence type component type");
3713 $$
= new unoidl
::detail
::SourceProviderType
($3);
3718 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
3719 OUString name
(convertName
($1));
3721 if
(name.indexOf
('.') == -1 && !data
->currentName.isEmpty
()) {
3722 unoidl
::detail
::SourceProviderEntity
* ent
= getCurrentEntity
(data
);
3723 unoidl
::detail
::SourceProviderPolymorphicStructTypeTemplateEntityPad
*
3725 unoidl
::detail
::SourceProviderPolymorphicStructTypeTemplateEntityPad
*>(
3729 pad
->typeParameters.begin
(), pad
->typeParameters.end
(),
3731 != pad
->typeParameters.end
()))
3733 $$
= new unoidl
::detail
::SourceProviderType
(name
);
3738 unoidl
::detail
::SourceProviderEntity
const * ent
;
3739 unoidl
::detail
::SourceProviderType t
;
3741 @
1, yyscanner
, data
, false
, &name
, &ent
, nullptr
, &t
))
3747 $$
= new unoidl
::detail
::SourceProviderType
(t
);
3750 if
(ent
== nullptr
) {
3751 error(@
1, yyscanner
, "unknown entity " + name
);
3755 switch
(ent
->kind
) {
3756 case unoidl
::detail
::SourceProviderEntity
::KIND_LOCAL
:
3757 if
(ent
->pad.is
()) {
3758 if
(data
->publishedContext
&& !ent
->pad
->isPublished
()) {
3761 ("unpublished entity " + name
3762 + " used in published context"));
3765 if
(dynamic_cast
<unoidl
::detail
::SourceProviderEnumTypeEntityPad
*>(
3769 $$
= new unoidl
::detail
::SourceProviderType
(
3770 unoidl
::detail
::SourceProviderType
::TYPE_ENUM
,
3773 } else if
(dynamic_cast
<unoidl
::detail
::SourceProviderPlainStructTypeEntityPad
*>(
3777 $$
= new unoidl
::detail
::SourceProviderType
(
3778 unoidl
::detail
::SourceProviderType
::TYPE_PLAIN_STRUCT
,
3781 } else if
(dynamic_cast
<unoidl
::detail
::SourceProviderPolymorphicStructTypeTemplateEntityPad
*>(
3787 (("recursive reference to polymorphic struct type"
3791 } else if
(dynamic_cast
<unoidl
::detail
::SourceProviderExceptionTypeEntityPad
*>(
3795 $$
= new unoidl
::detail
::SourceProviderType
(
3796 unoidl
::detail
::SourceProviderType
::TYPE_EXCEPTION
,
3799 } else if
(dynamic_cast
<unoidl
::detail
::SourceProviderInterfaceTypeEntityPad
*>(
3803 $$
= new unoidl
::detail
::SourceProviderType
(
3804 unoidl
::detail
::SourceProviderType
::TYPE_INTERFACE
,
3810 assert
(ent
->entity.is
());
3812 case unoidl
::detail
::SourceProviderEntity
::KIND_EXTERNAL
:
3813 if
(data
->publishedContext
3814 && ent
->entity
->getSort
() != unoidl
::Entity
::SORT_MODULE
3815 && !static_cast
<unoidl
::PublishableEntity
*>(
3816 ent
->entity.get
())->isPublished
())
3820 ("unpublished entity " + name
3821 + " used in published context"));
3824 switch
(ent
->entity
->getSort
()) {
3825 case unoidl
::Entity
::SORT_ENUM_TYPE
:
3826 $$
= new unoidl
::detail
::SourceProviderType
(
3827 unoidl
::detail
::SourceProviderType
::TYPE_ENUM
, name
,
3831 case unoidl
::Entity
::SORT_PLAIN_STRUCT_TYPE
:
3832 $$
= new unoidl
::detail
::SourceProviderType
(
3833 unoidl
::detail
::SourceProviderType
::TYPE_PLAIN_STRUCT
,
3837 case unoidl
::Entity
::SORT_POLYMORPHIC_STRUCT_TYPE_TEMPLATE
:
3840 ("polymorphic struct type template " + name
3841 + " without type arguments"));
3844 case unoidl
::Entity
::SORT_EXCEPTION_TYPE
:
3845 $$
= new unoidl
::detail
::SourceProviderType
(
3846 unoidl
::detail
::SourceProviderType
::TYPE_EXCEPTION
,
3850 case unoidl
::Entity
::SORT_INTERFACE_TYPE
:
3851 $$
= new unoidl
::detail
::SourceProviderType
(
3852 unoidl
::detail
::SourceProviderType
::TYPE_INTERFACE
,
3856 case unoidl
::Entity
::SORT_TYPEDEF
:
3862 case unoidl
::detail
::SourceProviderEntity
::KIND_INTERFACE_DECL
:
3863 if
(data
->publishedContext
) {
3866 ("unpublished entity " + name
3867 + " used in published context"));
3871 case unoidl
::detail
::SourceProviderEntity
::KIND_PUBLISHED_INTERFACE_DECL
:
3872 $$
= new unoidl
::detail
::SourceProviderType
(
3873 unoidl
::detail
::SourceProviderType
::TYPE_INTERFACE
, name
,
3877 case unoidl
::detail
::SourceProviderEntity
::KIND_MODULE
:
3878 assert
(false
&& "this cannot happen");
3881 error(@
1, yyscanner
, "non-type entity " + name
);
3888 | name
'<' typeArguments
'>'
3890 unoidl
::detail
::SourceProviderScannerData
* data
= yyget_extra
(yyscanner
);
3891 OUString name
(convertName
($1));
3892 std
::vector
<unoidl
::detail
::SourceProviderType
> args
(*$3);
3894 unoidl
::detail
::SourceProviderEntity
const * ent
;
3895 if
(findEntity
(@
1, yyscanner
, data
, false
, &name
, &ent
, nullptr
, nullptr
)
3900 if
(ent
== nullptr
) {
3901 error(@
1, yyscanner
, "unknown entity " + name
);
3905 switch
(ent
->kind
) {
3906 case unoidl
::detail
::SourceProviderEntity
::KIND_LOCAL
:
3907 if
(ent
->pad.is
()) {
3908 if
(dynamic_cast
<unoidl
::detail
::SourceProviderPolymorphicStructTypeTemplateEntityPad
*>(
3914 (("recursive reference to polymorphic struct type"
3921 assert
(ent
->entity.is
());
3923 case unoidl
::detail
::SourceProviderEntity
::KIND_EXTERNAL
:
3924 if
(ent
->entity
->getSort
()
3925 == unoidl
::Entity
::SORT_POLYMORPHIC_STRUCT_TYPE_TEMPLATE
)
3927 rtl
::Reference
<unoidl
::PolymorphicStructTypeTemplateEntity
> e
(
3928 static_cast
<unoidl
::PolymorphicStructTypeTemplateEntity
*>(
3929 ent
->entity.get
()));
3930 if
(args.size
() != e
->getTypeParameters
().size
()) {
3933 ("bad number of polymorphic struct type template " + name
3934 + " type arguments"));
3937 if
(data
->publishedContext
&& !e
->isPublished
()) {
3940 ("unpublished polymorphic struct type template " + name
3941 + " used in published context"));
3944 $$
= new unoidl
::detail
::SourceProviderType
(name
, ent
, std
::move
(args
));
3948 case unoidl
::detail
::SourceProviderEntity
::KIND_INTERFACE_DECL
:
3949 case unoidl
::detail
::SourceProviderEntity
::KIND_PUBLISHED_INTERFACE_DECL
:
3951 case unoidl
::detail
::SourceProviderEntity
::KIND_MODULE
:
3952 assert
(false
&& "this cannot happen");
3955 error(@
1, yyscanner
, "non-type entity " + name
);
3962 name TOK_COLONS identifier
{ *$1 += "." + *$3; delete
$3; $$
= $1; }
3963 | TOK_COLONS identifier
{ *$2 = "." + *$2; $$
= $2; }
3969 | TOK_GET
{ $$
= new OString
("get"); }
3970 | TOK_PUBLISHED
{ $$
= new OString
("published"); }
3971 | TOK_SET
{ $$
= new OString
("set"); }
3975 TOK_DEPRECATED
{ $$
= true
; }
3976 |
/* empty */ { $$
= false
; }
3981 namespace unoidl
::detail
{
3983 OUString SourceProviderType
::getName
() const {
3984 if
(!typedefName.isEmpty
()) {
3988 case unoidl
::detail
::SourceProviderType
::TYPE_VOID
:
3990 case unoidl
::detail
::SourceProviderType
::TYPE_BOOLEAN
:
3992 case unoidl
::detail
::SourceProviderType
::TYPE_BYTE
:
3994 case unoidl
::detail
::SourceProviderType
::TYPE_SHORT
:
3996 case unoidl
::detail
::SourceProviderType
::TYPE_UNSIGNED_SHORT
:
3997 return
"unsigned short";
3998 case unoidl
::detail
::SourceProviderType
::TYPE_LONG
:
4000 case unoidl
::detail
::SourceProviderType
::TYPE_UNSIGNED_LONG
:
4001 return
"unsigned long";
4002 case unoidl
::detail
::SourceProviderType
::TYPE_HYPER
:
4004 case unoidl
::detail
::SourceProviderType
::TYPE_UNSIGNED_HYPER
:
4005 return
"unsigned hyper";
4006 case unoidl
::detail
::SourceProviderType
::TYPE_FLOAT
:
4008 case unoidl
::detail
::SourceProviderType
::TYPE_DOUBLE
:
4010 case unoidl
::detail
::SourceProviderType
::TYPE_CHAR
:
4012 case unoidl
::detail
::SourceProviderType
::TYPE_STRING
:
4014 case unoidl
::detail
::SourceProviderType
::TYPE_TYPE
:
4016 case unoidl
::detail
::SourceProviderType
::TYPE_ANY
:
4018 case unoidl
::detail
::SourceProviderType
::TYPE_SEQUENCE
:
4019 assert
(subtypes.size
() == 1);
4020 return
"[]" + subtypes.front
().getName
();
4021 case unoidl
::detail
::SourceProviderType
::TYPE_ENUM
:
4022 case unoidl
::detail
::SourceProviderType
::TYPE_PLAIN_STRUCT
:
4023 case unoidl
::detail
::SourceProviderType
::TYPE_EXCEPTION
:
4024 case unoidl
::detail
::SourceProviderType
::TYPE_INTERFACE
:
4025 case unoidl
::detail
::SourceProviderType
::TYPE_PARAMETER
:
4027 case unoidl
::detail
::SourceProviderType
::TYPE_INSTANTIATED_POLYMORPHIC_STRUCT
:
4029 OUStringBuffer n
(512);
4030 n.append
(name
+ "<");
4031 for
(auto i
(subtypes.begin
()); i
!= subtypes.end
(); ++i
) {
4032 if
(i
!= subtypes.begin
()) {
4035 n.append
(i
->getName
());
4037 return n.append
(">").makeStringAndClear
();
4040 assert
(false
&& "this cannot happen"); for
(;;) { std
::abort
(); }
4044 bool SourceProviderType
::equals
(SourceProviderType
const & other
) const {
4045 if
(type
!= other.type || name
!= other.name
4046 || subtypes.size
() != other.subtypes.size
())
4050 for
(auto i
(subtypes.begin
()), j
(other.subtypes.begin
());
4051 i
!= subtypes.end
(); ++i
, ++j
)
4053 if
(!i
->equals
(*j
)) {
4060 bool SourceProviderInterfaceTypeEntityPad
::addDirectBase
(
4061 YYLTYPE location
, yyscan_t yyscanner
, SourceProviderScannerData
* data
,
4062 DirectBase
const & base
, bool optional
)
4064 std
::set
<OUString
> seen
;
4065 if
(!(checkBaseClashes
(
4066 location
, yyscanner
, data
, base.name
, base.entity
, true
, optional
,
4069 location
, yyscanner
, data
, base.name
, base.name
, base.entity
,
4075 addOptionalBaseMembers
(
4076 location
, yyscanner
, data
, base.name
, base.entity
);
4078 (optional ? directOptionalBases
: directMandatoryBases
).push_back
(base
);
4082 bool SourceProviderInterfaceTypeEntityPad
::addDirectMember
(
4083 YYLTYPE location
, yyscan_t yyscanner
, SourceProviderScannerData
* data
,
4084 OUString
const & name
)
4086 assert
(data
!= nullptr
);
4087 if
(!checkMemberClashes
(location
, yyscanner
, data
, u
"", name
, true
)) {
4090 allMembers.emplace
(name
, Member
(data
->currentName
));
4094 bool SourceProviderInterfaceTypeEntityPad
::checkBaseClashes
(
4095 YYLTYPE location
, yyscan_t yyscanner
, SourceProviderScannerData
* data
,
4096 OUString
const & name
,
4097 rtl
::Reference
<unoidl
::InterfaceTypeEntity
> const & entity
, bool direct
,
4098 bool optional
, bool outerOptional
, std
::set
<OUString
> * seen
) const
4100 assert
(data
!= nullptr
);
4101 assert
(entity.is
());
4102 assert
(seen
!= nullptr
);
4103 if
(direct || optional || seen
->insert
(name
).second
) {
4104 std
::map
<OUString
, BaseKind
>::const_iterator i
(allBases.find
(name
));
4105 if
(i
!= allBases.end
()) {
4106 switch
(i
->second
) {
4107 case BASE_INDIRECT_OPTIONAL
:
4108 if
(direct
&& optional
) {
4110 location
, yyscanner
,
4111 ("interface type " + data
->currentName
4112 + " duplicate base " + name
));
4116 case BASE_DIRECT_OPTIONAL
:
4117 if
(direct ||
!outerOptional
) {
4119 location
, yyscanner
,
4120 ("interface type " + data
->currentName
4121 + " duplicate base " + name
));
4125 case BASE_INDIRECT_MANDATORY
:
4128 location
, yyscanner
,
4129 ("interface type " + data
->currentName
4130 + " duplicate base " + name
));
4134 case BASE_DIRECT_MANDATORY
:
4135 if
(direct ||
(!optional
&& !outerOptional
)) {
4137 location
, yyscanner
,
4138 ("interface type " + data
->currentName
4139 + " duplicate base " + name
));
4145 if
(direct ||
!optional
) {
4146 for
(auto
& j
: entity
->getDirectMandatoryBases
()) {
4147 OUString n
("." + j.name
);
4148 unoidl
::detail
::SourceProviderEntity
const * p
;
4150 location
, yyscanner
, data
, true
, &n
, &p
, nullptr
,
4156 if
(p
== nullptr ||
!p
->entity.is
()
4157 ||
(p
->entity
->getSort
()
4158 != unoidl
::Entity
::SORT_INTERFACE_TYPE
))
4161 location
, yyscanner
,
4162 ("inconsistent type manager: interface type "
4163 + data
->currentName
+ " base " + n
4164 + " does not resolve to an existing interface type"));
4167 if
(!checkBaseClashes
(
4168 location
, yyscanner
, data
, n
,
4169 static_cast
<unoidl
::InterfaceTypeEntity
*>(
4171 false
, false
, outerOptional
, seen
))
4176 for
(auto
& j
: entity
->getDirectOptionalBases
()) {
4177 OUString n
("." + j.name
);
4178 unoidl
::detail
::SourceProviderEntity
const * p
;
4180 location
, yyscanner
, data
, true
, &n
, &p
, nullptr
,
4186 if
(p
== nullptr ||
!p
->entity.is
()
4187 ||
(p
->entity
->getSort
()
4188 != unoidl
::Entity
::SORT_INTERFACE_TYPE
))
4191 location
, yyscanner
,
4192 ("inconsistent type manager: interface type "
4193 + data
->currentName
+ " base " + n
4194 + " does not resolve to an existing interface type"));
4197 if
(!checkBaseClashes
(
4198 location
, yyscanner
, data
, n
,
4199 static_cast
<unoidl
::InterfaceTypeEntity
*>(
4201 false
, true
, outerOptional
, seen
))
4206 for
(auto
& j
: entity
->getDirectAttributes
()) {
4207 if
(!checkMemberClashes
(
4208 location
, yyscanner
, data
, name
, j.name
,
4214 for
(auto
& j
: entity
->getDirectMethods
()) {
4215 if
(!checkMemberClashes
(
4216 location
, yyscanner
, data
, name
, j.name
,
4227 bool SourceProviderInterfaceTypeEntityPad
::checkMemberClashes
(
4228 YYLTYPE location
, yyscan_t yyscanner
, SourceProviderScannerData
* data
,
4229 std
::u16string_view interfaceName
, OUString
const & memberName
,
4230 bool checkOptional
) const
4232 std
::map
<OUString
, Member
>::const_iterator i
(allMembers.find
(memberName
));
4233 if
(i
!= allMembers.end
()) {
4234 if
(!i
->second.mandatory.isEmpty
()) {
4235 // For a direct member, interfaceName will be empty, so this will
4236 // catch two direct members with the same name:
4237 if
(i
->second.mandatory
!= interfaceName
) {
4239 location
, yyscanner
,
4240 ("interface type " + data
->currentName
4241 + " duplicate member " + memberName
));
4244 } else if
(checkOptional
) {
4245 for
(auto
& j
: i
->second.optional
) {
4246 if
(j
!= interfaceName
) {
4248 location
, yyscanner
,
4249 ("interface type " + data
->currentName
4250 + " duplicate member " + memberName
));
4259 bool SourceProviderInterfaceTypeEntityPad
::addBase
(
4260 YYLTYPE location
, yyscan_t yyscanner
, SourceProviderScannerData
* data
,
4261 OUString
const & directBaseName
, OUString
const & name
,
4262 rtl
::Reference
<unoidl
::InterfaceTypeEntity
> const & entity
, bool direct
,
4265 assert
(data
!= nullptr
);
4266 assert
(entity.is
());
4267 BaseKind kind
= optional
4268 ? direct ? BASE_DIRECT_OPTIONAL
: BASE_INDIRECT_OPTIONAL
4269 : direct ? BASE_DIRECT_MANDATORY
: BASE_INDIRECT_MANDATORY
;
4270 std
::pair
<std
::map
<OUString
, BaseKind
>::iterator
, bool> p
(
4271 allBases.emplace
(name
, kind
));
4272 bool seen
= !p.second
&& p.first
->second
>= BASE_INDIRECT_MANDATORY
;
4273 if
(!p.second
&& kind
> p.first
->second
) {
4274 p.first
->second
= kind
;
4276 if
(!optional
&& !seen
) {
4277 for
(auto
& i
: entity
->getDirectMandatoryBases
()) {
4278 OUString n
("." + i.name
);
4279 unoidl
::detail
::SourceProviderEntity
const * q
;
4281 location
, yyscanner
, data
, true
, &n
, &q
, nullptr
, nullptr
)
4286 if
(q
== nullptr ||
!q
->entity.is
()
4287 || q
->entity
->getSort
() != unoidl
::Entity
::SORT_INTERFACE_TYPE
)
4290 location
, yyscanner
,
4291 ("inconsistent type manager: interface type "
4292 + data
->currentName
+ " base " + n
4293 + " does not resolve to an existing interface type"));
4297 location
, yyscanner
, data
, directBaseName
, n
,
4298 static_cast
<unoidl
::InterfaceTypeEntity
*>(q
->entity.get
()),
4304 for
(auto
& i
: entity
->getDirectOptionalBases
())
4306 OUString n
("." + i.name
);
4307 unoidl
::detail
::SourceProviderEntity
const * q
;
4309 location
, yyscanner
, data
, true
, &n
, &q
, nullptr
, nullptr
)
4314 if
(q
== nullptr ||
!q
->entity.is
()
4315 || q
->entity
->getSort
() != unoidl
::Entity
::SORT_INTERFACE_TYPE
)
4318 location
, yyscanner
,
4319 ("inconsistent type manager: interface type "
4320 + data
->currentName
+ " base " + n
4321 + " does not resolve to an existing interface type"));
4325 location
, yyscanner
, data
, directBaseName
, n
,
4326 static_cast
<unoidl
::InterfaceTypeEntity
*>(q
->entity.get
()),
4332 for
(auto
& i
: entity
->getDirectAttributes
()) {
4333 allMembers.emplace
(i.name
, Member
(name
));
4335 for
(auto
& i
: entity
->getDirectMethods
()) {
4336 allMembers.emplace
(i.name
, Member
(name
));
4342 bool SourceProviderInterfaceTypeEntityPad
::addOptionalBaseMembers
(
4343 YYLTYPE location
, yyscan_t yyscanner
, SourceProviderScannerData
* data
,
4344 OUString
const & name
,
4345 rtl
::Reference
<unoidl
::InterfaceTypeEntity
> const & entity
)
4347 assert
(entity.is
());
4348 for
(auto
& i
: entity
->getDirectMandatoryBases
()) {
4349 OUString n
("." + i.name
);
4350 unoidl
::detail
::SourceProviderEntity
const * p
;
4352 location
, yyscanner
, data
, true
, &n
, &p
, nullptr
, nullptr
)
4357 if
(p
== nullptr ||
!p
->entity.is
()
4358 || p
->entity
->getSort
() != unoidl
::Entity
::SORT_INTERFACE_TYPE
)
4361 location
, yyscanner
,
4362 ("inconsistent type manager: interface type "
4363 + data
->currentName
+ " base " + n
4364 + " does not resolve to an existing interface type"));
4367 if
(!addOptionalBaseMembers
(
4368 location
, yyscanner
, data
, n
,
4369 static_cast
<unoidl
::InterfaceTypeEntity
*>(p
->entity.get
())))
4374 for
(auto
& i
: entity
->getDirectAttributes
()) {
4376 allMembers.emplace
(i.name
, Member
(""))
4378 if
(m.mandatory.isEmpty
()) {
4379 m.optional.insert
(name
);
4382 for
(auto
& i
: entity
->getDirectMethods
()) {
4384 allMembers.emplace
(i.name
, Member
(""))
4386 if
(m.mandatory.isEmpty
()) {
4387 m.optional.insert
(name
);
4393 bool parse
(OUString
const & uri
, SourceProviderScannerData
* data
) {
4394 assert
(data
!= nullptr
);
4395 oslFileHandle handle
;
4396 oslFileError e
= osl_openFile
(uri.pData
, &handle
, osl_File_OpenFlag_Read
);
4398 case osl_File_E_None
:
4400 case osl_File_E_NOENT
:
4403 throw FileFormatException
(uri
, "cannot open: " + OUString
::number
(e
));
4406 e
= osl_getFileSize
(handle
, &size
);
4407 if
(e
!= osl_File_E_None
) {
4408 oslFileError e2
= osl_closeFile
(handle
);
4410 e2
!= osl_File_E_None
, "unoidl",
4411 "cannot close " << uri
<< ": " << +e2
);
4412 throw FileFormatException
(
4413 uri
, "cannot get size: " + OUString
::number
(e
));
4416 e
= osl_mapFile
(handle
, &address
, size
, 0, osl_File_MapFlag_RandomAccess
);
4417 if
(e
!= osl_File_E_None
) {
4418 oslFileError e2
= osl_closeFile
(handle
);
4420 e2
!= osl_File_E_None
, "unoidl",
4421 "cannot close " << uri
<< ": " << +e2
);
4422 throw FileFormatException
(uri
, "cannot mmap: " + OUString
::number
(e
));
4425 data
->setSource
(address
, size
);
4427 if
(yylex_init_extra
(data
, &yyscanner
) != 0) {
4428 // Checking errno for the specific EINVAL, ENOMEM documented for
4429 // yylex_init_extra would not work as those values are not defined
4430 // by the C++ Standard:
4432 throw FileFormatException
(
4434 "yylex_init_extra failed with errno " + OUString
::number
(e2
));
4436 int e2
= yyparse(yyscanner
);
4437 yylex_destroy
(yyscanner
);
4444 throw FileFormatException
(
4447 + (data
->errorLine
== 0
4448 ? OUString
() : " line " + OUString
::number
(data
->errorLine
))
4449 + (data
->parserError.isEmpty
()
4452 + OStringToOUString
(
4453 data
->parserError
, osl_getThreadTextEncoding
())))
4454 + (data
->errorMessage.isEmpty
()
4455 ? OUString
() : ": \"" + data
->errorMessage
+ "\"")));
4457 throw std
::bad_alloc
();
4460 e
= osl_unmapMappedFile
(handle
, address
, size
);
4461 SAL_WARN_IF
(e
!= osl_File_E_None
, "unoidl", "cannot unmap: " << +e
);
4462 e
= osl_closeFile
(handle
);
4463 SAL_WARN_IF
(e
!= osl_File_E_None
, "unoidl", "cannot close: " << +e
);
4466 e
= osl_unmapMappedFile
(handle
, address
, size
);
4467 SAL_WARN_IF
(e
!= osl_File_E_None
, "unoidl", "cannot unmap: " << +e
);
4468 e
= osl_closeFile
(handle
);
4469 SAL_WARN_IF
(e
!= osl_File_E_None
, "unoidl", "cannot close: " << +e
);
4475 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */