[gjs/wip/js17: 3/12] JS_GetClass remove context argument



commit 309f8980ac0a0135f1409aae0aafbc621ec34fe2
Author: Tim Lunn <tim feathertop org>
Date:   Thu Jan 3 13:51:26 2013 +1100

    JS_GetClass remove context argument
    
    JS_GetClass no longer takes *context as first argument,
    consequently the JS_GET_CLASS Macro is also removed.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=690982

 gi/boxed.c                |    8 ++++----
 gi/gerror.c               |    6 +++---
 gi/object.c               |    4 ++--
 gi/param.c                |    4 ++--
 gi/union.c                |    6 +++---
 gjs/jsapi-dynamic-class.c |    2 +-
 gjs/jsapi-util.c          |    9 +++------
 gjs/stack.c               |    2 +-
 8 files changed, 19 insertions(+), 22 deletions(-)
---
diff --git a/gi/boxed.c b/gi/boxed.c
index f46cec5..bbea2c7 100644
--- a/gi/boxed.c
+++ b/gi/boxed.c
@@ -598,7 +598,7 @@ get_nested_interface_object (JSContext   *context,
     offset = g_field_info_get_offset (field_info);
 
     obj = JS_NewObjectWithGivenProto(context,
-                                     JS_GET_CLASS(context, proto), proto,
+                                     JS_GetClass(proto), proto,
                                      gjs_get_import_global (context));
 
     if (obj == NULL)
@@ -1001,7 +1001,7 @@ gjs_lookup_boxed_class(JSContext    *context,
 
     prototype = gjs_lookup_boxed_prototype(context, info);
 
-    return JS_GET_CLASS(context, prototype);
+    return JS_GetClass(prototype);
 }
 
 static gboolean
@@ -1242,7 +1242,7 @@ gjs_define_boxed_class(JSContext    *context,
     JS_SetPrivate(context, prototype, priv);
 
     gjs_debug(GJS_DEBUG_GBOXED, "Defined class %s prototype is %p class %p in object %p",
-              constructor_name, prototype, JS_GET_CLASS(context, prototype), in_object);
+              constructor_name, prototype, JS_GetClass(prototype), in_object);
 
     priv->can_allocate_directly = struct_is_simple (priv->info);
 
@@ -1284,7 +1284,7 @@ gjs_boxed_from_c_struct(JSContext             *context,
     proto_priv = priv_from_js(context, proto);
 
     obj = JS_NewObjectWithGivenProto(context,
-                                     JS_GET_CLASS(context, proto), proto,
+                                     JS_GetClass(proto), proto,
                                      gjs_get_import_global (context));
 
     GJS_INC_COUNTER(boxed);
diff --git a/gi/gerror.c b/gi/gerror.c
index ad75721..ea36b18 100644
--- a/gi/gerror.c
+++ b/gi/gerror.c
@@ -380,7 +380,7 @@ gjs_lookup_error_class(JSContext    *context,
 
     prototype = gjs_lookup_error_prototype(context, info);
 
-    return JS_GET_CLASS(context, prototype);
+    return JS_GetClass(prototype);
 }
 
 JSBool
@@ -463,7 +463,7 @@ gjs_define_error_class(JSContext    *context,
     JS_SetPrivate(context, prototype, priv);
 
     gjs_debug(GJS_DEBUG_GBOXED, "Defined class %s prototype is %p class %p in object %p",
-              constructor_name, prototype, JS_GET_CLASS(context, prototype), in_object);
+              constructor_name, prototype, JS_GetClass(prototype), in_object);
 
     gjs_define_enum_values(context, constructor, priv->info);
 
@@ -590,7 +590,7 @@ gjs_error_from_gerror(JSContext             *context,
     proto_priv = priv_from_js(context, proto);
 
     obj = JS_NewObjectWithGivenProto(context,
-                                     JS_GET_CLASS(context, proto), proto,
+                                     JS_GetClass(proto), proto,
                                      gjs_get_import_global (context));
 
     GJS_INC_COUNTER(gerror);
diff --git a/gi/object.c b/gi/object.c
index bfb3a3c..dab446e 100644
--- a/gi/object.c
+++ b/gi/object.c
@@ -1692,7 +1692,7 @@ gjs_define_object_class(JSContext     *context,
     JS_SetPrivate(context, prototype, priv);
 
     gjs_debug(GJS_DEBUG_GOBJECT, "Defined class %s prototype %p class %p in object %p",
-              constructor_name, prototype, JS_GET_CLASS(context, prototype), in_object);
+              constructor_name, prototype, JS_GetClass(prototype), in_object);
 
     if (info)
         gjs_define_static_methods(context, constructor, gtype, info);
@@ -1753,7 +1753,7 @@ gjs_object_from_g_object(JSContext    *context,
         JS_BeginRequest(context);
 
         obj = JS_NewObjectWithGivenProto(context,
-                                         JS_GET_CLASS(context, proto), proto,
+                                         JS_GetClass(proto), proto,
                                          gjs_get_import_global (context));
 
         JS_EndRequest(context);
diff --git a/gi/param.c b/gi/param.c
index c8594d8..8e6d67d 100644
--- a/gi/param.c
+++ b/gi/param.c
@@ -536,7 +536,7 @@ gjs_define_param_class(JSContext    *context,
         *prototype_p = prototype;
 
     gjs_debug(GJS_DEBUG_GPARAM, "Defined class %s prototype is %p class %p in object %p",
-              constructor_name, prototype, JS_GET_CLASS(context, prototype), in_object);
+              constructor_name, prototype, JS_GetClass(prototype), in_object);
 
     return JS_TRUE;
 }
@@ -561,7 +561,7 @@ gjs_param_from_g_param(JSContext    *context,
     proto = gjs_lookup_param_prototype(context);
 
     obj = JS_NewObjectWithGivenProto(context,
-                                     JS_GET_CLASS(context, proto), proto,
+                                     JS_GetClass(proto), proto,
                                      gjs_get_import_global (context));
 
     GJS_INC_COUNTER(param);
diff --git a/gi/union.c b/gi/union.c
index b21c72a..bfd7501 100644
--- a/gi/union.c
+++ b/gi/union.c
@@ -380,7 +380,7 @@ gjs_lookup_union_class(JSContext    *context,
 
     prototype = gjs_lookup_union_prototype(context, info);
 
-    return JS_GET_CLASS(context, prototype);
+    return JS_GetClass(prototype);
 }
 
 JSBool
@@ -463,7 +463,7 @@ gjs_define_union_class(JSContext    *context,
     JS_SetPrivate(context, prototype, priv);
 
     gjs_debug(GJS_DEBUG_GBOXED, "Defined class %s prototype is %p class %p in object %p",
-              constructor_name, prototype, JS_GET_CLASS(context, prototype), in_object);
+              constructor_name, prototype, JS_GetClass(prototype), in_object);
 
     value = OBJECT_TO_JSVAL(gjs_gtype_create_gtype_wrapper(context, gtype));
     JS_DefineProperty(context, constructor, "$gtype", value,
@@ -507,7 +507,7 @@ gjs_union_from_c_union(JSContext    *context,
     proto = gjs_lookup_union_prototype(context, (GIUnionInfo*) info);
 
     obj = JS_NewObjectWithGivenProto(context,
-                                     JS_GET_CLASS(context, proto), proto,
+                                     JS_GetClass(proto), proto,
                                      gjs_get_import_global (context));
 
     GJS_INC_COUNTER(boxed);
diff --git a/gjs/jsapi-dynamic-class.c b/gjs/jsapi-dynamic-class.c
index d2648d8..e0df4dc 100644
--- a/gjs/jsapi-dynamic-class.c
+++ b/gjs/jsapi-dynamic-class.c
@@ -184,7 +184,7 @@ gjs_typecheck_instance(JSContext *context,
 {
     if (!JS_InstanceOf(context, obj, static_clasp, NULL)) {
         if (throw) {
-            JSClass *obj_class = JS_GET_CLASS(context, obj);
+            JSClass *obj_class = JS_GetClass(obj);
 
             gjs_throw_custom(context, "TypeError",
                              "Object %p is not a subclass of %s, it's a %s",
diff --git a/gjs/jsapi-util.c b/gjs/jsapi-util.c
index 6eab2ed..2bf38be 100644
--- a/gjs/jsapi-util.c
+++ b/gjs/jsapi-util.c
@@ -220,7 +220,7 @@ gjs_throw_abstract_constructor_error(JSContext *context,
     if (JSVAL_IS_OBJECT(callee)) {
         if (gjs_object_get_property(context, JSVAL_TO_OBJECT(callee),
                                     "prototype", &prototype)) {
-            proto_class = JS_GetClass(context, JSVAL_TO_OBJECT(prototype));
+            proto_class = JS_GetClass(JSVAL_TO_OBJECT(prototype));
             name = proto_class->name;
         }
     }
@@ -348,7 +348,7 @@ gjs_value_debug_string(JSContext      *context,
              */
             JSClass *klass;
 
-            klass = JS_GET_CLASS(context, JSVAL_TO_OBJECT(value));
+            klass = JS_GetClass(JSVAL_TO_OBJECT(value));
             if (klass != NULL) {
                 str = JS_NewStringCopyZ(context, klass->name);
                 JS_ClearPendingException(context);
@@ -821,13 +821,10 @@ gjs_date_from_time_t (JSContext *context, time_t time)
     if (!JS_GetProperty(context, date_constructor, "prototype", &date_prototype))
         gjs_fatal("Failed to get prototype from Date constructor");
 
-    date_class = JS_GET_CLASS(context, JSVAL_TO_OBJECT (date_prototype));
-
     if (!JS_NewNumberValue(context, ((double) time) * 1000, &(args[0])))
         gjs_fatal("Failed to convert time_t to number");
 
-    date = JS_ConstructObjectWithArguments(context, date_class,
-                                           NULL, NULL, 1, args);
+    date = JS_New(context, JSVAL_TO_OBJECT (date_prototype), 1, args);
 
     result = OBJECT_TO_JSVAL(date);
     JS_LeaveLocalRootScope(context);
diff --git a/gjs/stack.c b/gjs/stack.c
index 54317d6..aec76ed 100644
--- a/gjs/stack.c
+++ b/gjs/stack.c
@@ -68,7 +68,7 @@ jsvalue_to_string(JSContext* cx, jsval val, gboolean* is_string)
        if (!value_str)
          value = g_strdup("[unknown function]");
       } else {
-       value = g_strdup_printf("[object %s]", JS_GetClass(cx, obj)->name);
+       value = g_strdup_printf("[object %s]", JS_GetClass(obj)->name);
       }
     }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]