diff options
author | Vincent Sanders <vincent.sanders@collabora.co.uk> | 2013-01-28 18:07:39 +0000 |
---|---|---|
committer | Vincent Sanders <vincent.sanders@collabora.co.uk> | 2013-01-28 18:07:39 +0000 |
commit | 80458e743b1571240bdfa2ccd5cadba3b9e512b3 (patch) | |
tree | 3a2bc398b8fde20c4594b615321b0a8c85df81d7 /src | |
parent | 6f13eb3a9984d00c2b803b9b435a911c0081d84f (diff) | |
download | nsgenbind-80458e743b1571240bdfa2ccd5cadba3b9e512b3.tar.gz nsgenbind-80458e743b1571240bdfa2ccd5cadba3b9e512b3.tar.bz2 |
make readonly property decision in a single place
Diffstat (limited to 'src')
-rw-r--r-- | src/jsapi-libdom-property.c | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/src/jsapi-libdom-property.c b/src/jsapi-libdom-property.c index ae1aed3..81f385c 100644 --- a/src/jsapi-libdom-property.c +++ b/src/jsapi-libdom-property.c @@ -244,6 +244,20 @@ get_binding_shared_modifier(struct binding *binding, const char *type, const cha return GENBIND_TYPE_NONE; } +static bool property_is_ro(struct webidl_node *node) +{ + struct webidl_node *modifier_node; + modifier_node = webidl_node_find_type(webidl_node_getnode(node), + NULL, + WEBIDL_NODE_TYPE_MODIFIER); + + if (webidl_node_getint(modifier_node) == WEBIDL_TYPE_READONLY) { + return true; + } + + return false; +} + static int webidl_property_spec_cb(struct webidl_node *node, void *ctx) { struct binding *binding = ctx; @@ -252,7 +266,6 @@ static int webidl_property_spec_cb(struct webidl_node *node, void *ctx) const char *type = NULL; struct webidl_node *ident_node; const char *ident; - struct webidl_node *modifier_node; ident_node = webidl_node_find_type(webidl_node_getnode(node), NULL, @@ -277,16 +290,13 @@ static int webidl_property_spec_cb(struct webidl_node *node, void *ctx) /* generate JSAPI_PS macro entry */ - modifier_node = webidl_node_find_type(webidl_node_getnode(node), - NULL, - WEBIDL_NODE_TYPE_MODIFIER); - - if (webidl_node_getint(modifier_node) == WEBIDL_TYPE_READONLY) { + if (property_is_ro(node)) { 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)) { @@ -756,14 +766,7 @@ static int output_property_setter(struct binding *binding, struct webidl_node *node, const char *ident) { - struct webidl_node *modifier_node; - - modifier_node = webidl_node_find_type(webidl_node_getnode(node), - NULL, - WEBIDL_NODE_TYPE_MODIFIER); - - - if (webidl_node_getint(modifier_node) == WEBIDL_TYPE_READONLY) { + if (property_is_ro(node)) { /* readonly so a set function is not required */ return 0; } |