[gjs] Fix comparisons with JSVAL_VOID and JSVAL_NULL
- From: Giovanni Campagna <gcampagna src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs] Fix comparisons with JSVAL_VOID and JSVAL_NULL
- Date: Thu, 1 Mar 2012 17:09:02 +0000 (UTC)
commit 83dd969e83ce3dda7ee6c30aea380d5abfdebbb6
Author: Pierre Lejeune <superheron gmail com>
Date: Mon Nov 21 22:37:41 2011 +0100
Fix comparisons with JSVAL_VOID and JSVAL_NULL
gi/boxed.c | 2 +-
gi/function.c | 2 +-
gi/object.c | 2 +-
gi/param.c | 3 +--
gi/union.c | 2 +-
gi/value.c | 2 +-
gjs/byteArray.c | 2 +-
gjs/importer.c | 10 +++++-----
gjs/jsapi-util-error.c | 4 ++--
gjs/jsapi-util.c | 8 ++++----
gjs/native.c | 2 +-
modules/cairo-context.c | 2 +-
modules/cairo.c | 24 ++++++++++++------------
modules/console.c | 2 +-
modules/dbus-exports.c | 20 ++++++++++----------
modules/dbus-values.c | 10 +++++-----
16 files changed, 48 insertions(+), 49 deletions(-)
---
diff --git a/gi/boxed.c b/gi/boxed.c
index c8bc3ad..1168ae4 100644
--- a/gi/boxed.c
+++ b/gi/boxed.c
@@ -1173,7 +1173,7 @@ gjs_define_boxed_class(JSContext *context,
constructor = NULL;
gjs_object_get_property(context, in_object, constructor_name, &value);
- if (value != JSVAL_VOID) {
+ if (!JSVAL_IS_VOID(value)) {
if (!JSVAL_IS_OBJECT(value)) {
gjs_throw(context, "Property '%s' does not look like a constructor",
constructor_name);
diff --git a/gi/function.c b/gi/function.c
index f405131..4322721 100644
--- a/gi/function.c
+++ b/gi/function.c
@@ -431,7 +431,7 @@ gjs_callback_trampoline_new(JSContext *context,
GjsCallbackTrampoline *trampoline;
int n_args, i;
- if (function == JSVAL_NULL) {
+ if (JSVAL_IS_NULL(function)) {
return NULL;
}
diff --git a/gi/object.c b/gi/object.c
index 2c4bad6..17c70b4 100644
--- a/gi/object.c
+++ b/gi/object.c
@@ -1652,7 +1652,7 @@ gjs_define_object_class(JSContext *context,
*/
gjs_object_get_property(context, in_object, constructor_name, &value);
constructor = NULL;
- if (value != JSVAL_VOID) {
+ if (!JSVAL_IS_VOID(value)) {
if (!JSVAL_IS_OBJECT(value)) {
gjs_throw(context, "Property '%s' does not look like a constructor",
constructor_name);
diff --git a/gi/param.c b/gi/param.c
index 11adb6b..cea0408 100644
--- a/gi/param.c
+++ b/gi/param.c
@@ -490,8 +490,7 @@ gjs_define_param_class(JSContext *context,
constructor_name = "ParamSpec";
gjs_object_get_property(context, in_object, constructor_name, &value);
- if (value != JSVAL_VOID) {
-
+ if (!JSVAL_IS_VOID(value)) {
if (!JSVAL_IS_OBJECT(value)) {
gjs_throw(context, "Existing property '%s' does not look like a constructor",
constructor_name);
diff --git a/gi/union.c b/gi/union.c
index cc4f84e..a714728 100644
--- a/gi/union.c
+++ b/gi/union.c
@@ -459,7 +459,7 @@ gjs_define_union_class(JSContext *context,
constructor_name, prototype, JS_GET_CLASS(context, prototype), in_object);
gjs_object_get_property(context, in_object, constructor_name, &value);
- if (value != JSVAL_VOID) {
+ if (!JSVAL_IS_VOID(value)) {
if (!JSVAL_IS_OBJECT(value)) {
gjs_throw(context, "Property '%s' does not look like a constructor",
constructor_name);
diff --git a/gi/value.c b/gi/value.c
index d7c01da..305abf0 100644
--- a/gi/value.c
+++ b/gi/value.c
@@ -125,7 +125,7 @@ closure_marshal(GClosure *closure,
gjs_closure_invoke(closure, argc, argv, &rval);
if (return_value != NULL) {
- if (rval == JSVAL_VOID) {
+ if (JSVAL_IS_VOID(rval)) {
/* something went wrong invoking, error should be set already */
goto cleanup;
}
diff --git a/gjs/byteArray.c b/gjs/byteArray.c
index 36a7406..14d744e 100644
--- a/gjs/byteArray.c
+++ b/gjs/byteArray.c
@@ -771,7 +771,7 @@ from_array_func(JSContext *context,
goto out;
}
- if (elem == JSVAL_VOID)
+ if (JSVAL_IS_VOID(elem))
continue;
if (!gjs_value_to_byte(context, elem, &b))
diff --git a/gjs/importer.c b/gjs/importer.c
index cfcee62..a2496f6 100644
--- a/gjs/importer.c
+++ b/gjs/importer.c
@@ -534,7 +534,7 @@ do_import(JSContext *context,
goto out;
}
- if (elem == JSVAL_VOID)
+ if (JSVAL_IS_VOID(elem))
continue;
if (!JSVAL_IS_STRING(elem)) {
@@ -566,7 +566,7 @@ do_import(JSContext *context,
module_obj,
name,
&obj_val)) {
- if (obj_val != JSVAL_VOID &&
+ if (!JSVAL_IS_VOID(obj_val) &&
JS_DefineProperty(context, obj,
name, obj_val,
NULL, NULL,
@@ -791,7 +791,7 @@ importer_new_enumerate(JSContext *context,
return JS_FALSE;
}
- if (elem == JSVAL_VOID)
+ if (JSVAL_IS_VOID(elem))
continue;
if (!JSVAL_IS_STRING(elem)) {
@@ -866,7 +866,7 @@ importer_new_enumerate(JSContext *context,
return JS_FALSE;
}
- if (*state_p == JSVAL_NULL) /* Iterating prototype */
+ if (JSVAL_IS_NULL(*state_p)) /* Iterating prototype */
return JS_TRUE;
iter = JSVAL_TO_PRIVATE(*state_p);
@@ -888,7 +888,7 @@ importer_new_enumerate(JSContext *context,
}
case JSENUMERATE_DESTROY: {
- if (state_p && *state_p != JSVAL_NULL) {
+ if (state_p && !JSVAL_IS_NULL(*state_p)) {
iter = JSVAL_TO_PRIVATE(*state_p);
importer_iterator_free(iter);
diff --git a/gjs/jsapi-util-error.c b/gjs/jsapi-util-error.c
index 56c8e6d..db3188f 100644
--- a/gjs/jsapi-util-error.c
+++ b/gjs/jsapi-util-error.c
@@ -218,7 +218,7 @@ gjstest_test_func_gjs_jsapi_util_error_throw(void)
exc = JSVAL_VOID;
JS_GetPendingException(context, &exc);
- g_assert(exc != JSVAL_VOID);
+ g_assert(!JSVAL_IS_VOID(exc));
value = JSVAL_VOID;
JS_GetProperty(context, JSVAL_TO_OBJECT(exc), "message",
@@ -252,7 +252,7 @@ gjstest_test_func_gjs_jsapi_util_error_throw(void)
exc = JSVAL_VOID;
JS_GetPendingException(context, &exc);
- g_assert(exc != JSVAL_VOID);
+ g_assert(!JSVAL_IS_VOID(exc));
g_assert(exc == previous);
JS_RemoveValueRoot(context, &previous);
diff --git a/gjs/jsapi-util.c b/gjs/jsapi-util.c
index 17bd946..6efd528 100644
--- a/gjs/jsapi-util.c
+++ b/gjs/jsapi-util.c
@@ -396,7 +396,7 @@ gjs_object_get_property(JSContext *context,
JS_EndRequest(context);
- return value != JSVAL_VOID;
+ return !JSVAL_IS_VOID(value);
}
/* Returns whether the object had the property; if the object did
@@ -423,7 +423,7 @@ gjs_object_require_property(JSContext *context,
if (value_p)
*value_p = value;
- if (value != JSVAL_VOID) {
+ if (!JSVAL_IS_VOID(value)) {
JS_ClearPendingException(context); /* in case JS_GetProperty() was on crack */
JS_EndRequest(context);
return TRUE;
@@ -539,7 +539,7 @@ gjs_init_class_dynamic(JSContext *context,
class_copy->base.name, &value))
goto error;
}
- g_assert(value != JSVAL_VOID);
+ g_assert(!JSVAL_IS_VOID(value));
g_assert(prototype != NULL);
/* Now manually define our constructor with a sane name, in the
@@ -1257,7 +1257,7 @@ gjs_get_type_name(jsval value)
{
if (JSVAL_IS_NULL(value)) {
return "null";
- } else if (value == JSVAL_VOID) {
+ } else if (JSVAL_IS_VOID(value)) {
return "undefined";
} else if (JSVAL_IS_INT(value)) {
return "integer";
diff --git a/gjs/native.c b/gjs/native.c
index 8a08112..fce6d58 100644
--- a/gjs/native.c
+++ b/gjs/native.c
@@ -82,7 +82,7 @@ module_get_parent(JSContext *context,
jsval value;
if (gjs_object_get_property(context, module_obj, "__parentModule__", &value) &&
- value != JSVAL_NULL &&
+ !JSVAL_IS_NULL(value) &&
JSVAL_IS_OBJECT(value)) {
return JSVAL_TO_OBJECT(value);
} else {
diff --git a/modules/cairo-context.c b/modules/cairo-context.c
index ed012ef..1db749e 100644
--- a/modules/cairo-context.c
+++ b/modules/cairo-context.c
@@ -574,7 +574,7 @@ setDash_func(JSContext *context,
if (!JS_GetElement(context, dashes, i, &elem)) {
goto out;
}
- if (elem == JSVAL_VOID)
+ if (JSVAL_IS_VOID(elem))
continue;
if (!JS_ValueToNumber(context, elem, &b))
diff --git a/modules/cairo.c b/modules/cairo.c
index 7ee6652..e662ede 100644
--- a/modules/cairo.c
+++ b/modules/cairo.c
@@ -52,73 +52,73 @@ gjs_js_define_cairo_stuff(JSContext *context,
obj = gjs_cairo_context_create_proto(context, module,
"Context", NULL);
- if (obj == JSVAL_NULL)
+ if (JSVAL_IS_NULL(obj))
return JS_FALSE;
gjs_cairo_context_init(context);
obj = gjs_cairo_surface_create_proto(context, module,
"Surface", NULL);
- if (obj == JSVAL_NULL)
+ if (JSVAL_IS_NULL(obj))
return JS_FALSE;
surface_proto = JSVAL_TO_OBJECT(obj);
obj = gjs_cairo_image_surface_create_proto(context, module,
"ImageSurface", surface_proto);
- if (obj == JSVAL_NULL)
+ if (JSVAL_IS_NULL(obj))
return JS_FALSE;
gjs_cairo_image_surface_init(context, JSVAL_TO_OBJECT(obj));
#if CAIRO_HAS_PS_SURFACE
obj = gjs_cairo_ps_surface_create_proto(context, module,
"PSSurface", surface_proto);
- if (obj == JSVAL_NULL)
+ if (JSVAL_IS_NULL(obj))
return JS_FALSE;
#endif
#if CAIRO_HAS_PDF_SURFACE
obj = gjs_cairo_pdf_surface_create_proto(context, module,
"PDFSurface", surface_proto);
- if (obj == JSVAL_NULL)
+ if (JSVAL_IS_NULL(obj))
return JS_FALSE;
#endif
#if CAIRO_HAS_SVG_SURFACE
obj = gjs_cairo_svg_surface_create_proto(context, module,
"SVGSurface", surface_proto);
- if (obj == JSVAL_NULL)
+ if (JSVAL_IS_NULL(obj))
return JS_FALSE;
#endif
obj = gjs_cairo_pattern_create_proto(context, module,
"Pattern", NULL);
- if (obj == JSVAL_NULL)
+ if (JSVAL_IS_NULL(obj))
return JS_FALSE;
pattern_proto = JSVAL_TO_OBJECT(obj);
obj = gjs_cairo_gradient_create_proto(context, module,
"Gradient", pattern_proto);
- if (obj == JSVAL_NULL)
+ if (JSVAL_IS_NULL(obj))
return JS_FALSE;
gradient_proto = JSVAL_TO_OBJECT(obj);
obj = gjs_cairo_linear_gradient_create_proto(context, module,
"LinearGradient", gradient_proto);
- if (obj == JSVAL_NULL)
+ if (JSVAL_IS_NULL(obj))
return JS_FALSE;
obj = gjs_cairo_radial_gradient_create_proto(context, module,
"RadialGradient", gradient_proto);
- if (obj == JSVAL_NULL)
+ if (JSVAL_IS_NULL(obj))
return JS_FALSE;
obj = gjs_cairo_surface_pattern_create_proto(context, module,
"SurfacePattern", pattern_proto);
- if (obj == JSVAL_NULL)
+ if (JSVAL_IS_NULL(obj))
return JS_FALSE;
obj = gjs_cairo_solid_pattern_create_proto(context, module,
"SolidPattern", pattern_proto);
- if (obj == JSVAL_NULL)
+ if (JSVAL_IS_NULL(obj))
return JS_FALSE;
return JS_TRUE;
diff --git a/modules/console.c b/modules/console.c
index 03506ec..9e401b8 100644
--- a/modules/console.c
+++ b/modules/console.c
@@ -216,7 +216,7 @@ gjs_console_interact(JSContext *context,
if (JS_GetPendingException(context, &result)) {
str = JS_ValueToString(context, result);
JS_ClearPendingException(context);
- } else if (result == JSVAL_VOID) {
+ } else if (JSVAL_IS_VOID(result)) {
goto next;
} else {
str = JS_ValueToString(context, result);
diff --git a/modules/dbus-exports.c b/modules/dbus-exports.c
index a9a1b0a..8feb62e 100644
--- a/modules/dbus-exports.c
+++ b/modules/dbus-exports.c
@@ -252,7 +252,7 @@ build_reply_from_jsval(JSContext *context,
dbus_message_iter_init_append(reply, &arg_iter);
- if (rval == JSVAL_VOID || g_str_equal(signature, "")) {
+ if (JSVAL_IS_VOID(rval) || g_str_equal(signature, "")) {
/* We don't want to send anything in these cases so skip the
* marshalling altogether.
*/
@@ -681,7 +681,7 @@ find_js_property_by_path(JSContext *context,
gjs_object_get_property(context, obj, elements[i], &value);
- if (value == JSVAL_VOID ||
+ if (JSVAL_IS_VOID(value) ||
JSVAL_IS_NULL(value) ||
!JSVAL_IS_OBJECT(value)) {
obj = NULL;
@@ -701,7 +701,7 @@ find_js_property_by_path(JSContext *context,
if (obj != NULL) {
gjs_object_get_property(context, obj, "-impl-", &value);
- if (value == JSVAL_VOID ||
+ if (JSVAL_IS_VOID(value) ||
JSVAL_IS_NULL(value) ||
!JSVAL_IS_OBJECT(value)) {
obj = NULL;
@@ -724,7 +724,7 @@ find_method(JSContext *context,
method_name,
method_value);
- if (*method_value == JSVAL_VOID ||
+ if (JSVAL_IS_VOID(*method_value) ||
JSVAL_IS_NULL(*method_value) ||
!JSVAL_IS_OBJECT(*method_value)) {
return JS_FALSE;
@@ -772,7 +772,7 @@ find_properties_array(JSContext *context,
* have any properties so there's no case where
* we actually want to use it.
*/
- if (iface_val == JSVAL_VOID &&
+ if (JSVAL_IS_VOID(iface_val) &&
strcmp(iface, DBUS_INTERFACE_PROPERTIES) == 0) {
gjs_debug(GJS_DEBUG_DBUS,
"Changing interface to work around GNOME bug 569933");
@@ -785,7 +785,7 @@ find_properties_array(JSContext *context,
}
}
- if (iface_val == JSVAL_VOID) {
+ if (JSVAL_IS_VOID(iface_val)) {
/* NOT an exception ... object simply lacks the interface */
return JS_TRUE;
}
@@ -938,7 +938,7 @@ find_property_details(JSContext *context,
return JS_FALSE;
}
- if (properties_array_val == JSVAL_VOID) {
+ if (JSVAL_IS_VOID(properties_array_val)) {
/* NOT an exception ... interface simply has no properties */
return JS_TRUE;
}
@@ -949,7 +949,7 @@ find_property_details(JSContext *context,
property_val = JSVAL_VOID;
if (!JS_GetElement(context, JSVAL_TO_OBJECT(properties_array_val),
i, &property_val) ||
- property_val == JSVAL_VOID) {
+ JSVAL_IS_VOID(property_val)) {
gjs_throw(context,
"Error accessing element %d of properties array",
i);
@@ -1150,7 +1150,7 @@ handle_get_all_properties(JSContext *context,
dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY,
"{sv}", &dict_iter);
- if (properties_array_val != JSVAL_VOID) {
+ if (!JSVAL_IS_VOID(properties_array_val)) {
for (i = 0; i < length; ++i) {
jsval property_val;
PropertyDetails details;
@@ -1162,7 +1162,7 @@ handle_get_all_properties(JSContext *context,
property_val = JSVAL_VOID;
if (!JS_GetElement(context, JSVAL_TO_OBJECT(properties_array_val),
i, &property_val) ||
- property_val == JSVAL_VOID) {
+ JSVAL_IS_VOID(property_val)) {
gjs_throw(context,
"Error accessing element %d of properties array",
i);
diff --git a/modules/dbus-values.c b/modules/dbus-values.c
index 00f1dc3..98e0c66 100644
--- a/modules/dbus-values.c
+++ b/modules/dbus-values.c
@@ -794,14 +794,14 @@ append_dict(JSContext *context,
"_dbus_signatures",
&prop_signatures);
- if (prop_signatures != JSVAL_VOID &&
+ if (!JSVAL_IS_VOID(prop_signatures) &&
!JSVAL_IS_OBJECT(prop_signatures)) {
gjs_throw(context,
"_dbus_signatures prop must be an object");
return JS_FALSE;
}
- if (prop_signatures != JSVAL_VOID &&
+ if (!JSVAL_IS_VOID(prop_signatures) &&
dbus_signature_iter_get_current_type(&dict_value_sig_iter) !=
DBUS_TYPE_VARIANT) {
gjs_throw(context,
@@ -839,13 +839,13 @@ append_dict(JSContext *context,
/* see if this prop has a forced signature */
value_signature = NULL;
- if (prop_signatures != JSVAL_VOID) {
+ if (!JSVAL_IS_VOID(prop_signatures)) {
jsval signature_value;
signature_value = JSVAL_VOID;
gjs_object_get_property(context,
JSVAL_TO_OBJECT(prop_signatures),
name, &signature_value);
- if (signature_value != JSVAL_VOID) {
+ if (!JSVAL_IS_VOID(signature_value)) {
value_signature = gjs_string_get_ascii(context,
signature_value);
if (value_signature == NULL) {
@@ -1020,7 +1020,7 @@ gjs_js_one_value_to_dbus(JSContext *context,
if (!append_dict(context, iter, sig_iter, obj))
return JS_FALSE;
}
- } else if (value == JSVAL_VOID) {
+ } else if (JSVAL_IS_VOID(value)) {
gjs_debug(GJS_DEBUG_DBUS, "Can't send void (undefined) values over dbus");
gjs_throw(context, "Can't send void (undefined) values over dbus");
return JS_FALSE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]