From 9a3fcd5cdb1f72a2ec3ef9ac10a494dd97bc96d7 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Sat, 3 Nov 2012 22:56:55 +0000 Subject: take unsigned type modifier into account on webidl long (int32_t) types --- src/jsapi-libdom-operator.c | 32 +++++++++++++++++++++++++++----- src/jsapi-libdom-property.c | 16 +++++++++++++++- 2 files changed, 42 insertions(+), 6 deletions(-) diff --git a/src/jsapi-libdom-operator.c b/src/jsapi-libdom-operator.c index 7633331..e0be9eb 100644 --- a/src/jsapi-libdom-operator.c +++ b/src/jsapi-libdom-operator.c @@ -244,9 +244,10 @@ static int output_return_declaration(struct binding *binding, { struct webidl_node *arglist_node = NULL; struct webidl_node *type_node = NULL; - struct webidl_node *type_base = NULL; struct webidl_node *type_name = NULL; + struct webidl_node *type_base = NULL; enum webidl_type webidl_arg_type; + struct webidl_node *type_mod = NULL; arglist_node = webidl_node_find_type(node, NULL, @@ -266,6 +267,7 @@ static int output_return_declaration(struct binding *binding, webidl_arg_type = webidl_node_getint(type_base); + switch (webidl_arg_type) { case WEBIDL_TYPE_USER: /* User type are represented with jsobject */ @@ -309,7 +311,15 @@ static int output_return_declaration(struct binding *binding, case WEBIDL_TYPE_LONG: /* int32_t */ - fprintf(binding->outfile, "\tint32_t %s = 0;\n", ident); + type_mod = webidl_node_find_type(webidl_node_getnode(type_node), + NULL, + WEBIDL_NODE_TYPE_MODIFIER); + if ((type_mod != NULL) && + (webidl_node_getint(type_mod) == WEBIDL_TYPE_MODIFIER_UNSIGNED)) { + fprintf(binding->outfile, "\tuint32_t %s = 0;\n", ident); + } else { + fprintf(binding->outfile, "\tint32_t %s = 0;\n", ident); + } break; case WEBIDL_TYPE_STRING: @@ -360,6 +370,7 @@ output_variable_definitions(struct binding *binding, struct webidl_node *arg_type_base = NULL; struct webidl_node *arg_type_ident = NULL; enum webidl_type webidl_arg_type; + struct webidl_node *type_mod = NULL; /* input variables */ arglist_node = webidl_node_find_type(operation_list, @@ -457,9 +468,20 @@ output_variable_definitions(struct binding *binding, case WEBIDL_TYPE_LONG: /* int32_t */ - fprintf(binding->outfile, - "\tint32_t %s = 0;\n", - webidl_node_gettext(arg_ident)); + type_mod = webidl_node_find_type(webidl_node_getnode(arg_type), + NULL, + WEBIDL_NODE_TYPE_MODIFIER); + if ((type_mod != NULL) && + (webidl_node_getint(type_mod) == WEBIDL_TYPE_MODIFIER_UNSIGNED)) { + fprintf(binding->outfile, + "\tuint32_t %s = 0;\n", + webidl_node_gettext(arg_ident)); + } else { + fprintf(binding->outfile, + "\tint32_t %s = 0;\n", + webidl_node_gettext(arg_ident)); + } + break; case WEBIDL_TYPE_STRING: diff --git a/src/jsapi-libdom-property.c b/src/jsapi-libdom-property.c index 702de15..6bd698d 100644 --- a/src/jsapi-libdom-property.c +++ b/src/jsapi-libdom-property.c @@ -251,6 +251,7 @@ static int output_return_declaration(struct binding *binding, struct webidl_node *type_node = NULL; struct webidl_node *type_base = NULL; struct webidl_node *type_name = NULL; + struct webidl_node *type_mod = NULL; enum webidl_type webidl_arg_type; type_node = webidl_node_find_type(webidl_node_getnode(node), @@ -306,7 +307,20 @@ static int output_return_declaration(struct binding *binding, case WEBIDL_TYPE_LONG: /* int32_t */ - fprintf(binding->outfile, "\tint32_t %s = 0;\n", ident); + type_mod = webidl_node_find_type(webidl_node_getnode(type_node), + NULL, + WEBIDL_NODE_TYPE_MODIFIER); + if ((type_mod != NULL) && + (webidl_node_getint(type_mod) == WEBIDL_TYPE_MODIFIER_UNSIGNED)) { + fprintf(binding->outfile, + "\tuint32_t %s = 0;\n", + ident); + } else { + fprintf(binding->outfile, + "\tint32_t %s = 0;\n", + ident); + } + break; case WEBIDL_TYPE_STRING: -- cgit v1.2.3