summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorVincent Sanders <vince@kyllikki.org>2015-08-11 14:32:54 +0100
committerVincent Sanders <vince@kyllikki.org>2015-08-11 14:32:54 +0100
commitb86883a7cce7d982c3f0d0069332dd490331e630 (patch)
treeda0bcaca426701b687fbad3aa0d4a878c66dcfe3 /src
parentc232cf149a7aa105398d7b76b035daa346c41c99 (diff)
downloadnsgenbind-b86883a7cce7d982c3f0d0069332dd490331e630.tar.gz
nsgenbind-b86883a7cce7d982c3f0d0069332dd490331e630.tar.bz2
Extend WebIDL parsing to cope with second edition IDL static interface elements
Diffstat (limited to 'src')
-rw-r--r--src/webidl-ast.h3
-rw-r--r--src/webidl-parser.y106
2 files changed, 95 insertions, 14 deletions
diff --git a/src/webidl-ast.h b/src/webidl-ast.h
index 25ef9a0..5126de8 100644
--- a/src/webidl-ast.h
+++ b/src/webidl-ast.h
@@ -63,11 +63,14 @@ enum webidl_type {
WEBIDL_TYPE_VOID,
};
+/** modifiers for operations, attributes and arguments */
enum webidl_type_modifier {
WEBIDL_TYPE_MODIFIER_NONE,
WEBIDL_TYPE_MODIFIER_UNSIGNED,
WEBIDL_TYPE_MODIFIER_UNRESTRICTED,
WEBIDL_TYPE_MODIFIER_READONLY,
+ WEBIDL_TYPE_MODIFIER_STATIC, /**< operation or attribute is static */
+ WEBIDL_TYPE_MODIFIER_INHERIT, /**< attribute inherits */
};
/* the type of special node */
diff --git a/src/webidl-parser.y b/src/webidl-parser.y
index 9cfd84e..14385d6 100644
--- a/src/webidl-parser.y
+++ b/src/webidl-parser.y
@@ -150,10 +150,13 @@ webidl_error(YYLTYPE *locp, struct webidl_node **winbind_ast, const char *str)
%type <node> CallbackRestOrInterface
%type <node> Attribute
+%type <node> AttributeRest
%type <node> AttributeOrOperation
%type <node> StringifierAttributeOrOperation
%type <node> Const
+%type <node> StaticMember
+%type <node> StaticMemberRest
%type <node> Operation
%type <node> SpecialOperation
%type <node> Specials
@@ -412,13 +415,15 @@ InterfaceMembers:
/* [10]
* SE[10]
* Second edition actually splits up AttributeOrOperation completely
- * here we "just" add Iterable as thats what the specs use
+ * here we "just" add Iterable and static member as thats what the specs use
*/
InterfaceMember:
Const
|
AttributeOrOperation
|
+ StaticMember
+ |
Iterable
;
@@ -690,28 +695,97 @@ StringifierAttributeOrOperation:
}
;
- /* [32] */
+ /* [32]
+ * Modified for SE to use AttributeRest
+ */
Attribute:
- Inherit ReadOnly TOK_ATTRIBUTE Type TOK_IDENTIFIER ';'
+ Inherit ReadOnly AttributeRest
{
- struct webidl_node *attribute;
+ struct webidl_node *attribute;
- attribute = webidl_node_new(WEBIDL_NODE_TYPE_IDENT, NULL, $5);
+ attribute = $3;
- /* add attributes type */
- attribute = webidl_node_prepend(attribute, $4);
+ /* deal with inherit modifier */
+ if ($1) {
+ attribute = webidl_node_new(WEBIDL_NODE_TYPE_MODIFIER,
+ attribute,
+ (void *)WEBIDL_TYPE_MODIFIER_INHERIT);
+ }
- /* deal with readonly modifier */
- if ($2) {
- attribute = webidl_node_new(WEBIDL_NODE_TYPE_MODIFIER, attribute, (void *)WEBIDL_TYPE_MODIFIER_READONLY);
- }
+ /* deal with readonly modifier */
+ if ($2) {
+ attribute = webidl_node_new(WEBIDL_NODE_TYPE_MODIFIER,
+ attribute,
+ (void *)WEBIDL_TYPE_MODIFIER_READONLY);
+ }
+
+ $$ = webidl_node_new(WEBIDL_NODE_TYPE_ATTRIBUTE,
+ NULL,
+ attribute);
+ }
+ ;
+
+
+/* SE[37] */
+StaticMember:
+ TOK_STATIC StaticMemberRest
+ {
+ $$ = $2;
+ }
+ ;
+
+
+/* SE[38] */
+StaticMemberRest:
+ ReadOnly AttributeRest
+ {
+ struct webidl_node *attribute;
+
+ attribute = webidl_node_new(WEBIDL_NODE_TYPE_MODIFIER,
+ $2, (void *)WEBIDL_TYPE_MODIFIER_STATIC);
+
+ /* deal with readonly modifier */
+ if ($1) {
+ attribute = webidl_node_new(WEBIDL_NODE_TYPE_MODIFIER,
+ attribute,
+ (void *)WEBIDL_TYPE_MODIFIER_READONLY);
+ }
+
+ $$ = webidl_node_new(WEBIDL_NODE_TYPE_ATTRIBUTE,
+ NULL,
+ attribute);
+ }
+ |
+ ReturnType OperationRest
+ {
+ struct webidl_node *operation;
+
+ /* add static modifier */
+ operation = webidl_node_new(WEBIDL_NODE_TYPE_MODIFIER,
+ $2, (void *)WEBIDL_TYPE_MODIFIER_STATIC);
+
+ /* put return type on the operation */
+ operation = webidl_node_prepend($1, operation);
- $$ = webidl_node_new(WEBIDL_NODE_TYPE_ATTRIBUTE, NULL, attribute);
+ $$ = webidl_node_new(WEBIDL_NODE_TYPE_OPERATION,
+ NULL,
+ operation);
+ }
+ ;
+
+ /* SE[42] */
+AttributeRest:
+ TOK_ATTRIBUTE Type TOK_IDENTIFIER ';'
+ {
+ $$ = webidl_node_new(WEBIDL_NODE_TYPE_IDENT, $2, $3);
}
;
- /* [33] */
+
+/* [33]
+ * SE[45]
+ */
Inherit:
/* empty */
{
@@ -724,7 +798,10 @@ Inherit:
}
;
- /* [34] */
+
+/* [34]
+ * SE[46]
+ */
ReadOnly:
/* empty */
{
@@ -737,6 +814,7 @@ ReadOnly:
}
;
+
/* SE[47] */
Operation:
ReturnType OperationRest