Gitweb links:
...log
http://git.netsurf-browser.org/nsgenjsbind.git/shortlog/307050bb1e83299f9...
...commit
http://git.netsurf-browser.org/nsgenjsbind.git/commit/307050bb1e83299f9f5...
...tree
http://git.netsurf-browser.org/nsgenjsbind.git/tree/307050bb1e83299f9f536...
The branch, master has been updated
via 307050bb1e83299f9f53642798a86f0d67104682 (commit)
via dd91309f44948babd07fc5d9a11510ba7a3ab626 (commit)
via 57a94255f0c62dc7035390b5997fc707bba2e3bb (commit)
from 80458e743b1571240bdfa2ccd5cadba3b9e512b3 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff
http://git.netsurf-browser.org/nsgenjsbind.git/commitdiff/307050bb1e83299...
commit 307050bb1e83299f9f53642798a86f0d67104682
Author: Vincent Sanders <vincent.sanders(a)collabora.co.uk>
Commit: Vincent Sanders <vincent.sanders(a)collabora.co.uk>
output setter body
diff --git a/src/jsapi-libdom-property.c b/src/jsapi-libdom-property.c
index a6cc819..7ead531 100644
--- a/src/jsapi-libdom-property.c
+++ b/src/jsapi-libdom-property.c
@@ -828,6 +828,7 @@ static int output_property_setter(struct binding *binding,
struct webidl_node *node,
const char *ident)
{
+ struct genbind_node *property_node;
char *putforwards;
putforwards = get_keyval_extended_attribute(node, "PutForwards");
@@ -859,13 +860,24 @@ static int output_property_setter(struct binding *binding,
return 0;
}
+ property_node = genbind_node_find_type_ident(binding->gb_ast,
+ NULL,
+ GENBIND_NODE_TYPE_SETTER,
+ ident);
fprintf(binding->outfile,
- "static JSBool JSAPI_STRICTPROP(%s_set, JSContext *cx, JSObject *obj, jsval
*vp)\n",
+ "static JSBool JSAPI_STRICTPROP(%s_set, JSContext *cx, JSObject *obj, jsval
*vp)\n"
+ "{\n",
ident);
+ if (property_node != NULL) {
+ /* binding source block */
+ output_code_block(binding, genbind_node_getnode(property_node));
+ } else {
+ output_property_placeholder(binding, node, ident);
+ }
+
fprintf(binding->outfile,
- "{\n"
" return JS_FALSE; /* disallow the asignment by default */\n"
"}\n\n");
commitdiff
http://git.netsurf-browser.org/nsgenjsbind.git/commitdiff/dd91309f44948ba...
commit dd91309f44948babd07fc5d9a11510ba7a3ab626
Author: Vincent Sanders <vincent.sanders(a)collabora.co.uk>
Commit: Vincent Sanders <vincent.sanders(a)collabora.co.uk>
generate putforwards output based on WebIDL extended attribute
diff --git a/src/jsapi-libdom-property.c b/src/jsapi-libdom-property.c
index 81f385c..a6cc819 100644
--- a/src/jsapi-libdom-property.c
+++ b/src/jsapi-libdom-property.c
@@ -244,6 +244,67 @@ get_binding_shared_modifier(struct binding *binding, const char
*type, const cha
return GENBIND_TYPE_NONE;
}
+/* obtain the value for a key/value type extended attribute */
+static char *
+get_keyval_extended_attribute(struct webidl_node *node, const char *attribute)
+{
+ struct webidl_node *ext_node;
+ struct webidl_node *ident_node;
+ char *value;
+
+ ext_node = webidl_node_find_type_ident(webidl_node_getnode(node),
+ WEBIDL_NODE_TYPE_EXTENDED_ATTRIBUTE,
+ attribute);
+
+ if (ext_node == NULL) {
+ return NULL; /* no matching extended attribute at all */
+ }
+
+ /* should be extended atrribute name node */
+ ident_node = webidl_node_find_type(webidl_node_getnode(ext_node),
+ NULL,
+ WEBIDL_NODE_TYPE_IDENT);
+ if (ident_node == NULL) {
+ /* not the attribute name already matched - bail
+ * somethings broken
+ */
+ return NULL;
+ }
+ value = webidl_node_gettext(ident_node);
+ if (strcmp(attribute, value) != 0) {
+ /* not the attribute name already matched - bail
+ * somethings broken
+ */
+ return NULL;
+ }
+
+ /* should be an = sign for key/value pair */
+ ident_node = webidl_node_find_type(webidl_node_getnode(ext_node),
+ ident_node,
+ WEBIDL_NODE_TYPE_IDENT);
+ if (ident_node == NULL) {
+ /* no additional attribute - not key/value then */
+ return NULL;
+ }
+ value = webidl_node_gettext(ident_node);
+ if (strcmp("=", value) != 0) {
+ /* not a key/value pair then */
+ return NULL;
+ }
+
+ /* value */
+ ident_node = webidl_node_find_type(webidl_node_getnode(ext_node),
+ ident_node,
+ WEBIDL_NODE_TYPE_IDENT);
+ if (ident_node == NULL) {
+ /* no value */
+ return NULL;
+ }
+ value = webidl_node_gettext(ident_node);
+
+ return value;
+}
+
static bool property_is_ro(struct webidl_node *node)
{
struct webidl_node *modifier_node;
@@ -290,13 +351,14 @@ static int webidl_property_spec_cb(struct webidl_node *node, void
*ctx)
/* generate JSAPI_PS macro entry */
- if (property_is_ro(node)) {
+ /* if there is a putforwards the property requires a setter */
+ if ((property_is_ro(node)) &&
+ (get_keyval_extended_attribute(node, "PutForwards") == NULL)) {
fprintf(binding->outfile, "\tJSAPI_PS_RO(\"%s\",\n", ident);
} else {
fprintf(binding->outfile, "\tJSAPI_PS(\"%s\",\n", ident);
}
-
/* generate property shared status */
switch (get_binding_shared_modifier(binding, type, ident)) {
@@ -766,6 +828,32 @@ static int output_property_setter(struct binding *binding,
struct webidl_node *node,
const char *ident)
{
+ char *putforwards;
+ putforwards = get_keyval_extended_attribute(node, "PutForwards");
+
+ if (putforwards != NULL) {
+ /* generate a putforwards setter */
+ fprintf(binding->outfile,
+ "/* PutForwards setter */\n"
+ "static JSBool JSAPI_STRICTPROP(%s_set, JSContext *cx, JSObject *obj, jsval
*vp)\n"
+ "{\n",
+ ident);
+
+ fprintf(binding->outfile,
+ "\tjsval propval;\n"
+ "\tif (JS_GetProperty(cx, obj, \"%s\", &propval) == JS_TRUE)
{\n"
+ "\t\tJS_SetProperty(cx, JSVAL_TO_OBJECT(propval), \"%s\", vp);\n"
+ "\t}\n",
+ ident, putforwards);
+
+ fprintf(binding->outfile,
+ "\treturn JS_FALSE; /* disallow the asignment */\n"
+ "}\n\n");
+
+
+ return 0;
+ }
+
if (property_is_ro(node)) {
/* readonly so a set function is not required */
return 0;
@@ -778,7 +866,7 @@ static int output_property_setter(struct binding *binding,
fprintf(binding->outfile,
"{\n"
- " return JS_FALSE;\n"
+ " return JS_FALSE; /* disallow the asignment by default */\n"
"}\n\n");
commitdiff
http://git.netsurf-browser.org/nsgenjsbind.git/commitdiff/57a94255f0c62dc...
commit 57a94255f0c62dc7035390b5997fc707bba2e3bb
Author: Vincent Sanders <vincent.sanders(a)collabora.co.uk>
Commit: Vincent Sanders <vincent.sanders(a)collabora.co.uk>
fix extended attribute AST ordering and nesting
diff --git a/src/webidl-parser.y b/src/webidl-parser.y
index 8e0db72..55ab221 100644
--- a/src/webidl-parser.y
+++ b/src/webidl-parser.y
@@ -185,7 +185,7 @@ webidl_error(YYLTYPE *locp, struct webidl_node **winbind_ast, const
char *str)
%%
/* [1] default rule to add built AST to passed in one, altered from
- * original grammar to be left recusive,
+ * original grammar to be left recusive,
*/
Definitions:
/* empty */
@@ -260,7 +260,7 @@ Interface:
interface_node = webidl_node_find_type_ident(*webidl_ast,
WEBIDL_NODE_TYPE_INTERFACE,
$2);
-
+
if (interface_node == NULL) {
/* no existing interface - create one with ident */
members = webidl_node_new(WEBIDL_NODE_TYPE_IDENT, members, $2);
@@ -378,7 +378,7 @@ InterfaceMembers:
if (member_node == NULL) {
/* not a member with that ident already present */
$$ = webidl_node_prepend($1, $3);
- } else {
+ } else {
webidl_node_add(member_node, list_node);
$$ = $1; /* updated existing node do not add new one */
}
@@ -540,10 +540,10 @@ Const:
constant = webidl_node_new(WEBIDL_NODE_TYPE_IDENT, NULL, $3);
/* add constant type */
- constant = webidl_node_prepend(constant, $2);
+ constant = webidl_node_prepend(constant, $2);
/* add constant value */
- constant = webidl_node_prepend(constant, $5);
+ constant = webidl_node_prepend(constant, $5);
$$ = webidl_node_new(WEBIDL_NODE_TYPE_CONST, NULL, constant);
}
@@ -560,7 +560,7 @@ ConstValue:
$$ = webidl_node_new(WEBIDL_NODE_TYPE_LITERAL_INT, NULL, (void *)$1);
}
|
- TOK_NULL_LITERAL
+ TOK_NULL_LITERAL
{
$$ = webidl_node_new(WEBIDL_NODE_TYPE_LITERAL_NULL, NULL, NULL);
}
@@ -651,7 +651,7 @@ Attribute:
attribute = webidl_node_new(WEBIDL_NODE_TYPE_IDENT, NULL, $5);
/* add attributes type */
- attribute = webidl_node_prepend(attribute, $4);
+ attribute = webidl_node_prepend(attribute, $4);
/* deal with readonly modifier */
if ($2) {
@@ -870,26 +870,31 @@ ExtendedAttributes:
}
;
- /* [51] extended attributes are nested with normal, square and curly braces */
+ /* [51] extended attributes internal nesting with normal, square and curly
+ * braces
+ */
ExtendedAttribute:
'(' ExtendedAttributeInner ')' ExtendedAttributeRest
{
- $$ = webidl_node_prepend($2, $4);
+ $$ = webidl_node_new(WEBIDL_NODE_TYPE_EXTENDED_ATTRIBUTE, $4, $2);
}
|
'[' ExtendedAttributeInner ']' ExtendedAttributeRest
{
- $$ = webidl_node_prepend($2, $4);
+ /* @todo should be a WEBIDL_NODE_TYPE_EXTENDED_ATTRIBUTE_SQUARE */
+ $$ = webidl_node_new(WEBIDL_NODE_TYPE_EXTENDED_ATTRIBUTE, $4, $2);
}
|
'{' ExtendedAttributeInner '}' ExtendedAttributeRest
{
- $$ = webidl_node_prepend($2, $4);
+ /* @todo should be a WEBIDL_NODE_TYPE_EXTENDED_ATTRIBUTE_CURLY */
+ $$ = webidl_node_new(WEBIDL_NODE_TYPE_EXTENDED_ATTRIBUTE, $4, $2);
}
|
Other ExtendedAttributeRest
{
- $$ = webidl_node_new(WEBIDL_NODE_TYPE_IDENT, $2, $1);
+ $$ = webidl_node_append($2,
+ webidl_node_new(WEBIDL_NODE_TYPE_IDENT, NULL, $1));
}
;
@@ -915,22 +920,37 @@ ExtendedAttributeInner:
|
'(' ExtendedAttributeInner ')' ExtendedAttributeInner
{
- $$ = webidl_node_prepend($2, $4);
+ $$ = webidl_node_prepend(
+ webidl_node_new(WEBIDL_NODE_TYPE_EXTENDED_ATTRIBUTE,
+ NULL,
+ $2),
+ $4);
}
|
'[' ExtendedAttributeInner ']' ExtendedAttributeInner
{
- $$ = webidl_node_prepend($2, $4);
+ /* @todo should be a WEBIDL_NODE_TYPE_EXTENDED_ATTRIBUTE_SQUARE */
+ $$ = webidl_node_prepend(
+ webidl_node_new(WEBIDL_NODE_TYPE_EXTENDED_ATTRIBUTE,
+ NULL,
+ $2),
+ $4);
}
|
'{' ExtendedAttributeInner '}' ExtendedAttributeInner
{
- $$ = webidl_node_prepend($2, $4);
+ /* @todo should be a WEBIDL_NODE_TYPE_EXTENDED_ATTRIBUTE_CURLY */
+ $$ = webidl_node_prepend(
+ webidl_node_new(WEBIDL_NODE_TYPE_EXTENDED_ATTRIBUTE,
+ NULL,
+ $2),
+ $4);
}
|
OtherOrComma ExtendedAttributeInner
{
- $$ = webidl_node_new(WEBIDL_NODE_TYPE_IDENT, $2, $1);
+ $$ = webidl_node_append($2,
+ webidl_node_new(WEBIDL_NODE_TYPE_IDENT, NULL, $1));
}
;
-----------------------------------------------------------------------
Summary of changes:
src/jsapi-libdom-property.c | 110 +++++++++++++++++++++++++++++++++++++++++--
src/webidl-parser.y | 52 ++++++++++++++------
2 files changed, 141 insertions(+), 21 deletions(-)
diff --git a/src/jsapi-libdom-property.c b/src/jsapi-libdom-property.c
index 81f385c..7ead531 100644
--- a/src/jsapi-libdom-property.c
+++ b/src/jsapi-libdom-property.c
@@ -244,6 +244,67 @@ get_binding_shared_modifier(struct binding *binding, const char
*type, const cha
return GENBIND_TYPE_NONE;
}
+/* obtain the value for a key/value type extended attribute */
+static char *
+get_keyval_extended_attribute(struct webidl_node *node, const char *attribute)
+{
+ struct webidl_node *ext_node;
+ struct webidl_node *ident_node;
+ char *value;
+
+ ext_node = webidl_node_find_type_ident(webidl_node_getnode(node),
+ WEBIDL_NODE_TYPE_EXTENDED_ATTRIBUTE,
+ attribute);
+
+ if (ext_node == NULL) {
+ return NULL; /* no matching extended attribute at all */
+ }
+
+ /* should be extended atrribute name node */
+ ident_node = webidl_node_find_type(webidl_node_getnode(ext_node),
+ NULL,
+ WEBIDL_NODE_TYPE_IDENT);
+ if (ident_node == NULL) {
+ /* not the attribute name already matched - bail
+ * somethings broken
+ */
+ return NULL;
+ }
+ value = webidl_node_gettext(ident_node);
+ if (strcmp(attribute, value) != 0) {
+ /* not the attribute name already matched - bail
+ * somethings broken
+ */
+ return NULL;
+ }
+
+ /* should be an = sign for key/value pair */
+ ident_node = webidl_node_find_type(webidl_node_getnode(ext_node),
+ ident_node,
+ WEBIDL_NODE_TYPE_IDENT);
+ if (ident_node == NULL) {
+ /* no additional attribute - not key/value then */
+ return NULL;
+ }
+ value = webidl_node_gettext(ident_node);
+ if (strcmp("=", value) != 0) {
+ /* not a key/value pair then */
+ return NULL;
+ }
+
+ /* value */
+ ident_node = webidl_node_find_type(webidl_node_getnode(ext_node),
+ ident_node,
+ WEBIDL_NODE_TYPE_IDENT);
+ if (ident_node == NULL) {
+ /* no value */
+ return NULL;
+ }
+ value = webidl_node_gettext(ident_node);
+
+ return value;
+}
+
static bool property_is_ro(struct webidl_node *node)
{
struct webidl_node *modifier_node;
@@ -290,13 +351,14 @@ static int webidl_property_spec_cb(struct webidl_node *node, void
*ctx)
/* generate JSAPI_PS macro entry */
- if (property_is_ro(node)) {
+ /* if there is a putforwards the property requires a setter */
+ if ((property_is_ro(node)) &&
+ (get_keyval_extended_attribute(node, "PutForwards") == NULL)) {
fprintf(binding->outfile, "\tJSAPI_PS_RO(\"%s\",\n", ident);
} else {
fprintf(binding->outfile, "\tJSAPI_PS(\"%s\",\n", ident);
}
-
/* generate property shared status */
switch (get_binding_shared_modifier(binding, type, ident)) {
@@ -766,19 +828,57 @@ static int output_property_setter(struct binding *binding,
struct webidl_node *node,
const char *ident)
{
+ struct genbind_node *property_node;
+ char *putforwards;
+ putforwards = get_keyval_extended_attribute(node, "PutForwards");
+
+ if (putforwards != NULL) {
+ /* generate a putforwards setter */
+ fprintf(binding->outfile,
+ "/* PutForwards setter */\n"
+ "static JSBool JSAPI_STRICTPROP(%s_set, JSContext *cx, JSObject *obj, jsval
*vp)\n"
+ "{\n",
+ ident);
+
+ fprintf(binding->outfile,
+ "\tjsval propval;\n"
+ "\tif (JS_GetProperty(cx, obj, \"%s\", &propval) == JS_TRUE)
{\n"
+ "\t\tJS_SetProperty(cx, JSVAL_TO_OBJECT(propval), \"%s\", vp);\n"
+ "\t}\n",
+ ident, putforwards);
+
+ fprintf(binding->outfile,
+ "\treturn JS_FALSE; /* disallow the asignment */\n"
+ "}\n\n");
+
+
+ return 0;
+ }
+
if (property_is_ro(node)) {
/* readonly so a set function is not required */
return 0;
}
+ property_node = genbind_node_find_type_ident(binding->gb_ast,
+ NULL,
+ GENBIND_NODE_TYPE_SETTER,
+ ident);
fprintf(binding->outfile,
- "static JSBool JSAPI_STRICTPROP(%s_set, JSContext *cx, JSObject *obj, jsval
*vp)\n",
+ "static JSBool JSAPI_STRICTPROP(%s_set, JSContext *cx, JSObject *obj, jsval
*vp)\n"
+ "{\n",
ident);
+ if (property_node != NULL) {
+ /* binding source block */
+ output_code_block(binding, genbind_node_getnode(property_node));
+ } else {
+ output_property_placeholder(binding, node, ident);
+ }
+
fprintf(binding->outfile,
- "{\n"
- " return JS_FALSE;\n"
+ " return JS_FALSE; /* disallow the asignment by default */\n"
"}\n\n");
diff --git a/src/webidl-parser.y b/src/webidl-parser.y
index 8e0db72..55ab221 100644
--- a/src/webidl-parser.y
+++ b/src/webidl-parser.y
@@ -185,7 +185,7 @@ webidl_error(YYLTYPE *locp, struct webidl_node **winbind_ast, const
char *str)
%%
/* [1] default rule to add built AST to passed in one, altered from
- * original grammar to be left recusive,
+ * original grammar to be left recusive,
*/
Definitions:
/* empty */
@@ -260,7 +260,7 @@ Interface:
interface_node = webidl_node_find_type_ident(*webidl_ast,
WEBIDL_NODE_TYPE_INTERFACE,
$2);
-
+
if (interface_node == NULL) {
/* no existing interface - create one with ident */
members = webidl_node_new(WEBIDL_NODE_TYPE_IDENT, members, $2);
@@ -378,7 +378,7 @@ InterfaceMembers:
if (member_node == NULL) {
/* not a member with that ident already present */
$$ = webidl_node_prepend($1, $3);
- } else {
+ } else {
webidl_node_add(member_node, list_node);
$$ = $1; /* updated existing node do not add new one */
}
@@ -540,10 +540,10 @@ Const:
constant = webidl_node_new(WEBIDL_NODE_TYPE_IDENT, NULL, $3);
/* add constant type */
- constant = webidl_node_prepend(constant, $2);
+ constant = webidl_node_prepend(constant, $2);
/* add constant value */
- constant = webidl_node_prepend(constant, $5);
+ constant = webidl_node_prepend(constant, $5);
$$ = webidl_node_new(WEBIDL_NODE_TYPE_CONST, NULL, constant);
}
@@ -560,7 +560,7 @@ ConstValue:
$$ = webidl_node_new(WEBIDL_NODE_TYPE_LITERAL_INT, NULL, (void *)$1);
}
|
- TOK_NULL_LITERAL
+ TOK_NULL_LITERAL
{
$$ = webidl_node_new(WEBIDL_NODE_TYPE_LITERAL_NULL, NULL, NULL);
}
@@ -651,7 +651,7 @@ Attribute:
attribute = webidl_node_new(WEBIDL_NODE_TYPE_IDENT, NULL, $5);
/* add attributes type */
- attribute = webidl_node_prepend(attribute, $4);
+ attribute = webidl_node_prepend(attribute, $4);
/* deal with readonly modifier */
if ($2) {
@@ -870,26 +870,31 @@ ExtendedAttributes:
}
;
- /* [51] extended attributes are nested with normal, square and curly braces */
+ /* [51] extended attributes internal nesting with normal, square and curly
+ * braces
+ */
ExtendedAttribute:
'(' ExtendedAttributeInner ')' ExtendedAttributeRest
{
- $$ = webidl_node_prepend($2, $4);
+ $$ = webidl_node_new(WEBIDL_NODE_TYPE_EXTENDED_ATTRIBUTE, $4, $2);
}
|
'[' ExtendedAttributeInner ']' ExtendedAttributeRest
{
- $$ = webidl_node_prepend($2, $4);
+ /* @todo should be a WEBIDL_NODE_TYPE_EXTENDED_ATTRIBUTE_SQUARE */
+ $$ = webidl_node_new(WEBIDL_NODE_TYPE_EXTENDED_ATTRIBUTE, $4, $2);
}
|
'{' ExtendedAttributeInner '}' ExtendedAttributeRest
{
- $$ = webidl_node_prepend($2, $4);
+ /* @todo should be a WEBIDL_NODE_TYPE_EXTENDED_ATTRIBUTE_CURLY */
+ $$ = webidl_node_new(WEBIDL_NODE_TYPE_EXTENDED_ATTRIBUTE, $4, $2);
}
|
Other ExtendedAttributeRest
{
- $$ = webidl_node_new(WEBIDL_NODE_TYPE_IDENT, $2, $1);
+ $$ = webidl_node_append($2,
+ webidl_node_new(WEBIDL_NODE_TYPE_IDENT, NULL, $1));
}
;
@@ -915,22 +920,37 @@ ExtendedAttributeInner:
|
'(' ExtendedAttributeInner ')' ExtendedAttributeInner
{
- $$ = webidl_node_prepend($2, $4);
+ $$ = webidl_node_prepend(
+ webidl_node_new(WEBIDL_NODE_TYPE_EXTENDED_ATTRIBUTE,
+ NULL,
+ $2),
+ $4);
}
|
'[' ExtendedAttributeInner ']' ExtendedAttributeInner
{
- $$ = webidl_node_prepend($2, $4);
+ /* @todo should be a WEBIDL_NODE_TYPE_EXTENDED_ATTRIBUTE_SQUARE */
+ $$ = webidl_node_prepend(
+ webidl_node_new(WEBIDL_NODE_TYPE_EXTENDED_ATTRIBUTE,
+ NULL,
+ $2),
+ $4);
}
|
'{' ExtendedAttributeInner '}' ExtendedAttributeInner
{
- $$ = webidl_node_prepend($2, $4);
+ /* @todo should be a WEBIDL_NODE_TYPE_EXTENDED_ATTRIBUTE_CURLY */
+ $$ = webidl_node_prepend(
+ webidl_node_new(WEBIDL_NODE_TYPE_EXTENDED_ATTRIBUTE,
+ NULL,
+ $2),
+ $4);
}
|
OtherOrComma ExtendedAttributeInner
{
- $$ = webidl_node_new(WEBIDL_NODE_TYPE_IDENT, $2, $1);
+ $$ = webidl_node_append($2,
+ webidl_node_new(WEBIDL_NODE_TYPE_IDENT, NULL, $1));
}
;
--
NetSurf Generator for JavaScript bindings