[gjs] don't use reserved c++ keywords class, namespace and throw



commit 9a4881618869ea3035c8552f205a1b35477295a6
Author: Tim Lunn <tim feathertop org>
Date:   Mon Sep 23 09:55:41 2013 +1000

    don't use reserved c++ keywords class, namespace and throw
    
    https://bugzilla.gnome.org/show_bug.cgi?id=710875

 gi/boxed.c                |    8 ++++----
 gi/boxed.h                |    2 +-
 gi/foreign.c              |   14 +++++++-------
 gi/foreign.h              |    2 +-
 gi/gerror.c               |    4 ++--
 gi/gerror.h               |    2 +-
 gi/gtype.c                |    4 ++--
 gi/gtype.h                |    2 +-
 gi/ns.c                   |   10 +++++-----
 gi/object.c               |   22 +++++++++++-----------
 gi/object.h               |    2 +-
 gi/param.c                |    8 ++++----
 gi/param.h                |    2 +-
 gi/repo.c                 |   16 ++++++++--------
 gi/union.c                |    8 ++++----
 gi/union.h                |    2 +-
 gjs/byteArray.c           |    4 ++--
 gjs/byteArray.h           |    2 +-
 gjs/jsapi-dynamic-class.c |    4 ++--
 gjs/jsapi-util.h          |    8 ++++----
 gjs/type-module.h         |    4 ++--
 21 files changed, 65 insertions(+), 65 deletions(-)
---
diff --git a/gi/boxed.c b/gi/boxed.c
index 8e94438..176accf 100644
--- a/gi/boxed.c
+++ b/gi/boxed.c
@@ -1273,18 +1273,18 @@ gjs_typecheck_boxed(JSContext     *context,
                     JSObject      *object,
                     GIStructInfo  *expected_info,
                     GType          expected_type,
-                    JSBool         throw)
+                    JSBool         throw_error)
 {
     Boxed *priv;
     JSBool result;
 
-    if (!do_base_typecheck(context, object, throw))
+    if (!do_base_typecheck(context, object, throw_error))
         return JS_FALSE;
 
     priv = priv_from_js(context, object);
 
     if (priv->gboxed == NULL) {
-        if (throw) {
+        if (throw_error) {
             gjs_throw_custom(context, "TypeError",
                              "Object is %s.%s.prototype, not an object instance - cannot convert to a boxed 
instance",
                              g_base_info_get_namespace( (GIBaseInfo*) priv->info),
@@ -1301,7 +1301,7 @@ gjs_typecheck_boxed(JSContext     *context,
     else
         result = JS_TRUE;
 
-    if (!result && throw) {
+    if (!result && throw_error) {
         if (expected_info != NULL) {
             gjs_throw_custom(context, "TypeError",
                              "Object is of type %s.%s - cannot convert to %s.%s",
diff --git a/gi/boxed.h b/gi/boxed.h
index d113d97..65448f7 100644
--- a/gi/boxed.h
+++ b/gi/boxed.h
@@ -55,7 +55,7 @@ JSBool    gjs_typecheck_boxed          (JSContext             *context,
                                         JSObject              *obj,
                                         GIStructInfo          *expected_info,
                                         GType                  expected_type,
-                                        JSBool                 throw);
+                                        JSBool                 throw_error);
 
 G_END_DECLS
 
diff --git a/gi/foreign.c b/gi/foreign.c
index cb5e4c5..a81cf18 100644
--- a/gi/foreign.c
+++ b/gi/foreign.c
@@ -32,7 +32,7 @@
 #include "foreign.h"
 
 static struct {
-    char *namespace;
+    char *gi_namespace;
     char *module; // relative to "imports."
     gboolean loaded;
 } foreign_modules[] = {
@@ -57,16 +57,16 @@ get_foreign_structs(void)
 
 static JSBool
 gjs_foreign_load_foreign_module(JSContext *context,
-                                const gchar *namespace)
+                                const gchar *gi_namespace)
 {
     int i;
 
-    for (i = 0; foreign_modules[i].namespace; ++i) {
+    for (i = 0; foreign_modules[i].gi_namespace; ++i) {
         int code;
         GError *error = NULL;
         char *script;
 
-        if (strcmp(namespace, foreign_modules[i].namespace) != 0)
+        if (strcmp(gi_namespace, foreign_modules[i].gi_namespace) != 0)
             continue;
 
         if (foreign_modules[i].loaded) {
@@ -75,7 +75,7 @@ gjs_foreign_load_foreign_module(JSContext *context,
 
         // FIXME: Find a way to check if a module is imported
         //        and only execute this statement if isn't
-        script = g_strdup_printf("imports.%s;", namespace);
+        script = g_strdup_printf("imports.%s;", gi_namespace);
         if (!gjs_context_eval(JS_GetContextPrivate(context), script, strlen(script),
                               "<internal>", &code,
                               &error)) {
@@ -92,7 +92,7 @@ gjs_foreign_load_foreign_module(JSContext *context,
 }
 
 JSBool
-gjs_struct_foreign_register(const char *namespace,
+gjs_struct_foreign_register(const char *gi_namespace,
                             const char *type_name,
                             GjsForeignInfo *info)
 {
@@ -102,7 +102,7 @@ gjs_struct_foreign_register(const char *namespace,
     g_return_val_if_fail(info->to_func != NULL, JS_FALSE);
     g_return_val_if_fail(info->from_func != NULL, JS_FALSE);
 
-    canonical_name = g_strdup_printf("%s.%s", namespace, type_name);
+    canonical_name = g_strdup_printf("%s.%s", gi_namespace, type_name);
     g_hash_table_insert(get_foreign_structs(), canonical_name, info);
     return JS_TRUE;
 }
diff --git a/gi/foreign.h b/gi/foreign.h
index 2b38601..a4d3cf3 100644
--- a/gi/foreign.h
+++ b/gi/foreign.h
@@ -49,7 +49,7 @@ typedef struct {
     GjsArgOverrideReleaseGArgumentFunc release_func;
 } GjsForeignInfo;
 
-JSBool  gjs_struct_foreign_register                (const char         *namespace,
+JSBool  gjs_struct_foreign_register                (const char         *gi_namespace,
                                                     const char         *type_name,
                                                     GjsForeignInfo *info);
 
diff --git a/gi/gerror.c b/gi/gerror.c
index 9eb3497..f6a0cd2 100644
--- a/gi/gerror.c
+++ b/gi/gerror.c
@@ -557,10 +557,10 @@ gjs_gerror_from_error(JSContext    *context,
 JSBool
 gjs_typecheck_gerror (JSContext *context,
                       JSObject  *obj,
-                      JSBool     throw)
+                      JSBool     throw_error)
 {
     if (gjs_typecheck_boxed (context, obj, NULL, G_TYPE_ERROR, JS_FALSE))
         return TRUE;
 
-    return do_base_typecheck(context, obj, throw);
+    return do_base_typecheck(context, obj, throw_error);
 }
diff --git a/gi/gerror.h b/gi/gerror.h
index dfd2a38..ce25477 100644
--- a/gi/gerror.h
+++ b/gi/gerror.h
@@ -41,7 +41,7 @@ JSObject* gjs_error_from_gerror        (JSContext             *context,
                                         gboolean               add_stack);
 JSBool    gjs_typecheck_gerror         (JSContext             *context,
                                         JSObject              *obj,
-                                        JSBool                 throw);
+                                        JSBool                 throw_error);
 
 G_END_DECLS
 
diff --git a/gi/gtype.c b/gi/gtype.c
index b5e1726..01c2e62 100644
--- a/gi/gtype.c
+++ b/gi/gtype.c
@@ -196,7 +196,7 @@ gjs_gtype_get_actual_gtype (JSContext *context,
 JSBool
 gjs_typecheck_gtype (JSContext             *context,
                      JSObject              *obj,
-                     JSBool                 throw)
+                     JSBool                 throw_error)
 {
-    return do_base_typecheck(context, obj, throw);
+    return do_base_typecheck(context, obj, throw_error);
 }
diff --git a/gi/gtype.h b/gi/gtype.h
index 88832b0..b2351e6 100644
--- a/gi/gtype.h
+++ b/gi/gtype.h
@@ -44,7 +44,7 @@ GType      gjs_gtype_get_actual_gtype (JSContext *context,
 
 JSBool    gjs_typecheck_gtype         (JSContext             *context,
                                        JSObject              *obj,
-                                       JSBool                 throw);
+                                       JSBool                 throw_error);
 
 G_END_DECLS
 
diff --git a/gi/ns.c b/gi/ns.c
index 33aec80..aaf1e65 100644
--- a/gi/ns.c
+++ b/gi/ns.c
@@ -36,7 +36,7 @@
 
 typedef struct {
     GIRepository *repo;
-    char *namespace;
+    char *gi_namespace;
 
 } Ns;
 
@@ -94,7 +94,7 @@ ns_new_resolve(JSContext *context,
 
     repo = g_irepository_get_default();
 
-    info = g_irepository_find_by_name(repo, priv->namespace, name);
+    info = g_irepository_find_by_name(repo, priv->gi_namespace, name);
     if (info == NULL) {
         /* No property defined, but no error either, so return TRUE */
         JS_EndRequest(context);
@@ -140,8 +140,8 @@ ns_finalize(JSFreeOp *fop,
     if (priv == NULL)
         return; /* we are the prototype, not a real instance */
 
-    if (priv->namespace)
-        g_free(priv->namespace);
+    if (priv->gi_namespace)
+        g_free(priv->gi_namespace);
     if (priv->repo)
         g_object_unref(priv->repo);
 
@@ -237,7 +237,7 @@ ns_new(JSContext    *context,
 
     priv = priv_from_js(context, ns);
     priv->repo = g_object_ref(repo);
-    priv->namespace = g_strdup(ns_name);
+    priv->gi_namespace = g_strdup(ns_name);
 
     return ns;
 }
diff --git a/gi/object.c b/gi/object.c
index 42c1740..ab32987 100644
--- a/gi/object.c
+++ b/gi/object.c
@@ -2052,18 +2052,18 @@ JSBool
 gjs_typecheck_object(JSContext     *context,
                      JSObject      *object,
                      GType          expected_type,
-                     JSBool         throw)
+                     JSBool         throw_error)
 {
     ObjectInstance *priv;
     JSBool result;
 
-    if (!do_base_typecheck(context, object, throw))
+    if (!do_base_typecheck(context, object, throw_error))
         return JS_FALSE;
 
     priv = priv_from_js(context, object);
 
     if (priv == NULL) {
-        if (throw) {
+        if (throw_error) {
             gjs_throw(context,
                       "Object instance or prototype has not been properly initialized yet. "
                       "Did you forget to chain-up from _init()?");
@@ -2073,7 +2073,7 @@ gjs_typecheck_object(JSContext     *context,
     }
 
     if (priv->gobj == NULL) {
-        if (throw) {
+        if (throw_error) {
             gjs_throw(context,
                       "Object is %s.%s.prototype, not an object instance - cannot convert to GObject*",
                       priv->info ? g_base_info_get_namespace( (GIBaseInfo*) priv->info) : "",
@@ -2090,7 +2090,7 @@ gjs_typecheck_object(JSContext     *context,
     else
         result = JS_TRUE;
 
-    if (!result && throw) {
+    if (!result && throw_error) {
         if (priv->info) {
             gjs_throw_custom(context, "TypeError",
                              "Object is of type %s.%s - cannot convert to %s",
@@ -2356,17 +2356,17 @@ gjs_object_set_gproperty (GObject      *object,
 }
 
 static void
-gjs_object_class_init(GObjectClass *class,
+gjs_object_class_init(GObjectClass *klass,
                       gpointer      user_data)
 {
     GPtrArray *properties;
     GType gtype;
     guint i;
 
-    gtype = G_OBJECT_CLASS_TYPE (class);
+    gtype = G_OBJECT_CLASS_TYPE (klass);
 
-    class->set_property = gjs_object_set_gproperty;
-    class->get_property = gjs_object_get_gproperty;
+    klass->set_property = gjs_object_set_gproperty;
+    klass->get_property = gjs_object_get_gproperty;
 
     gjs_eval_thread = g_thread_self();
 
@@ -2375,7 +2375,7 @@ gjs_object_class_init(GObjectClass *class,
         for (i = 0; i < properties->len; i++) {
             GParamSpec *pspec = properties->pdata[i];
             g_param_spec_set_qdata(pspec, gjs_is_custom_property_quark(), GINT_TO_POINTER(1));
-            g_object_class_install_property (class, i+1, pspec);
+            g_object_class_install_property (klass, i+1, pspec);
         }
         
         gjs_hash_table_for_gsize_remove (class_init_properties, gtype);
@@ -2384,7 +2384,7 @@ gjs_object_class_init(GObjectClass *class,
 
 static void
 gjs_object_custom_init(GTypeInstance *instance,
-                       gpointer       g_class)
+                       gpointer       klass)
 {
     GjsContext *gjs_context;
     JSContext *context;
diff --git a/gi/object.h b/gi/object.h
index b1a8a1f..046a71a 100644
--- a/gi/object.h
+++ b/gi/object.h
@@ -42,7 +42,7 @@ GObject*  gjs_g_object_from_object      (JSContext     *context,
 JSBool    gjs_typecheck_object          (JSContext     *context,
                                          JSObject      *obj,
                                          GType          expected_type,
-                                         JSBool         throw);
+                                         JSBool         throw_error);
 
 void      gjs_object_process_pending_toggles (void);
 
diff --git a/gi/param.c b/gi/param.c
index 6976c3a..74c0135 100644
--- a/gi/param.c
+++ b/gi/param.c
@@ -563,18 +563,18 @@ JSBool
 gjs_typecheck_param(JSContext     *context,
                     JSObject      *object,
                     GType          expected_type,
-                    JSBool         throw)
+                    JSBool         throw_error)
 {
     Param *priv;
     JSBool result;
 
-    if (!do_base_typecheck(context, object, throw))
+    if (!do_base_typecheck(context, object, throw_error))
         return JS_FALSE;
 
     priv = priv_from_js(context, object);
 
     if (priv->gparam == NULL) {
-        if (throw) {
+        if (throw_error) {
             gjs_throw_custom(context, "TypeError",
                              "Object is GObject.ParamSpec.prototype, not an object instance - "
                              "cannot convert to a GObject.ParamSpec instance");
@@ -588,7 +588,7 @@ gjs_typecheck_param(JSContext     *context,
     else
         result = JS_TRUE;
 
-    if (!result && throw) {
+    if (!result && throw_error) {
         gjs_throw_custom(context, "TypeError",
                          "Object is of type %s - cannot convert to %s",
                          g_type_name(G_TYPE_FROM_INSTANCE (priv->gparam)),
diff --git a/gi/param.h b/gi/param.h
index cb3e69c..3de1bb4 100644
--- a/gi/param.h
+++ b/gi/param.h
@@ -39,7 +39,7 @@ JSObject*   gjs_param_from_g_param     (JSContext  *context,
 JSBool      gjs_typecheck_param        (JSContext  *context,
                                         JSObject   *obj,
                                         GType       expected_type,
-                                        JSBool      throw);
+                                        JSBool      throw_error);
 
 G_END_DECLS
 
diff --git a/gi/repo.c b/gi/repo.c
index 993290a..767c1d6 100644
--- a/gi/repo.c
+++ b/gi/repo.c
@@ -97,7 +97,7 @@ resolve_namespace_object(JSContext  *context,
     char *version;
     JSObject *override;
     jsval result;
-    JSObject *namespace = NULL;
+    JSObject *gi_namespace = NULL;
     JSBool ret = JS_FALSE;
 
     JS_BeginRequest(context);
@@ -125,20 +125,20 @@ resolve_namespace_object(JSContext  *context,
      * with the given namespace name, pointing to that namespace
      * in the repo.
      */
-    namespace = gjs_create_ns(context, ns_name, repo);
-    JS_AddObjectRoot(context, &namespace);
+    gi_namespace = gjs_create_ns(context, ns_name, repo);
+    JS_AddObjectRoot(context, &gi_namespace);
 
     /* Define the property early, to avoid reentrancy issues if
        the override module looks for namespaces that import this */
     if (!JS_DefineProperty(context, repo_obj,
-                           ns_name, OBJECT_TO_JSVAL(namespace),
+                           ns_name, OBJECT_TO_JSVAL(gi_namespace),
                            NULL, NULL,
                            GJS_MODULE_PROP_FLAGS))
         g_error("no memory to define ns property");
 
     override = lookup_override_function(context, ns_id);
     if (override && !JS_CallFunctionValue (context,
-                                           namespace, /* thisp */
+                                           gi_namespace, /* thisp */
                                            OBJECT_TO_JSVAL(override), /* callee */
                                            0, /* argc */
                                            NULL, /* argv */
@@ -146,13 +146,13 @@ resolve_namespace_object(JSContext  *context,
         goto out;
 
     gjs_debug(GJS_DEBUG_GNAMESPACE,
-              "Defined namespace '%s' %p in GIRepository %p", ns_name, namespace, repo_obj);
+              "Defined namespace '%s' %p in GIRepository %p", ns_name, gi_namespace, repo_obj);
 
     ret = JS_TRUE;
 
  out:
-    if (namespace)
-        JS_RemoveObjectRoot(context, &namespace);
+    if (gi_namespace)
+        JS_RemoveObjectRoot(context, &gi_namespace);
     JS_EndRequest(context);
     return ret;
 }
diff --git a/gi/union.c b/gi/union.c
index d634870..c84846b 100644
--- a/gi/union.c
+++ b/gi/union.c
@@ -459,18 +459,18 @@ gjs_typecheck_union(JSContext     *context,
                     JSObject      *object,
                     GIStructInfo  *expected_info,
                     GType          expected_type,
-                    JSBool         throw)
+                    JSBool         throw_error)
 {
     Union *priv;
     JSBool result;
 
-    if (!do_base_typecheck(context, object, throw))
+    if (!do_base_typecheck(context, object, throw_error))
         return JS_FALSE;
 
     priv = priv_from_js(context, object);
 
     if (priv->gboxed == NULL) {
-        if (throw) {
+        if (throw_error) {
             gjs_throw_custom(context, "TypeError",
                              "Object is %s.%s.prototype, not an object instance - cannot convert to a union 
instance",
                              g_base_info_get_namespace( (GIBaseInfo*) priv->info),
@@ -487,7 +487,7 @@ gjs_typecheck_union(JSContext     *context,
     else
         result = JS_TRUE;
 
-    if (!result && throw) {
+    if (!result && throw_error) {
         if (expected_info != NULL) {
             gjs_throw_custom(context, "TypeError",
                              "Object is of type %s.%s - cannot convert to %s.%s",
diff --git a/gi/union.h b/gi/union.h
index cf5157a..bf97ef4 100644
--- a/gi/union.h
+++ b/gi/union.h
@@ -42,7 +42,7 @@ JSBool    gjs_typecheck_union          (JSContext             *context,
                                         JSObject              *obj,
                                         GIStructInfo          *expected_info,
                                         GType                  expected_type,
-                                        JSBool                 throw);
+                                        JSBool                 throw_error);
 
 G_END_DECLS
 
diff --git a/gjs/byteArray.c b/gjs/byteArray.c
index 1145b9e..fdba76a 100644
--- a/gjs/byteArray.c
+++ b/gjs/byteArray.c
@@ -73,9 +73,9 @@ static struct JSClass gjs_byte_array_class = {
 JSBool
 gjs_typecheck_bytearray(JSContext     *context,
                         JSObject      *object,
-                        JSBool         throw)
+                        JSBool         throw_error)
 {
-    return do_base_typecheck(context, object, throw);
+    return do_base_typecheck(context, object, throw_error);
 }
 
 static JSBool
diff --git a/gjs/byteArray.h b/gjs/byteArray.h
index c3b4234..bc186ed 100644
--- a/gjs/byteArray.h
+++ b/gjs/byteArray.h
@@ -35,7 +35,7 @@ G_BEGIN_DECLS
 
 JSBool    gjs_typecheck_bytearray        (JSContext     *context,
                                           JSObject      *obj,
-                                          JSBool         throw);
+                                          JSBool         throw_error);
 
 JSBool        gjs_define_byte_array_stuff    (JSContext  *context,
                                               JSObject  **module_out);
diff --git a/gjs/jsapi-dynamic-class.c b/gjs/jsapi-dynamic-class.c
index 30fe98a..536701d 100644
--- a/gjs/jsapi-dynamic-class.c
+++ b/gjs/jsapi-dynamic-class.c
@@ -180,10 +180,10 @@ JSBool
 gjs_typecheck_instance(JSContext *context,
                        JSObject  *obj,
                        JSClass   *static_clasp,
-                       JSBool     throw)
+                       JSBool     throw_error)
 {
     if (!JS_InstanceOf(context, obj, static_clasp, NULL)) {
-        if (throw) {
+        if (throw_error) {
             JSClass *obj_class = JS_GetClass(obj);
 
             gjs_throw_custom(context, "TypeError",
diff --git a/gjs/jsapi-util.h b/gjs/jsapi-util.h
index 62cffed..7b9af07 100644
--- a/gjs/jsapi-util.h
+++ b/gjs/jsapi-util.h
@@ -74,13 +74,13 @@ typedef struct GjsRootedArray GjsRootedArray;
  * priv_from_js_with_typecheck: a convenience function to call
  *                              do_base_typecheck and priv_from_js
  */
-#define GJS_DEFINE_PRIV_FROM_JS(type, class)                            \
+#define GJS_DEFINE_PRIV_FROM_JS(type, klass)                          \
     __attribute__((unused)) static inline JSBool                        \
     do_base_typecheck(JSContext *context,                               \
                       JSObject  *object,                                \
-                      JSBool     throw)                                 \
+                      JSBool     throw_error)                           \
     {                                                                   \
-        return gjs_typecheck_instance(context, object, &class, throw);  \
+        return gjs_typecheck_instance(context, object, &klass, throw_error);  \
     }                                                                   \
     static inline type *                                                \
     priv_from_js(JSContext *context,                                    \
@@ -88,7 +88,7 @@ typedef struct GjsRootedArray GjsRootedArray;
     {                                                                   \
         type *priv;                                                     \
         JS_BeginRequest(context);                                       \
-        priv = JS_GetInstancePrivate(context, object, &class, NULL);    \
+        priv = JS_GetInstancePrivate(context, object, &klass, NULL);  \
         JS_EndRequest(context);                                         \
         return priv;                                                    \
     }                                                                   \
diff --git a/gjs/type-module.h b/gjs/type-module.h
index a4ea514..9d6fb45 100644
--- a/gjs/type-module.h
+++ b/gjs/type-module.h
@@ -31,9 +31,9 @@ typedef struct _GjsTypeModuleClass GjsTypeModuleClass;
 
 #define GJS_TYPE_TYPE_MODULE              (gjs_type_module_get_type ())
 #define GJS_TYPE_MODULE(module)           (G_TYPE_CHECK_INSTANCE_CAST ((module), GJS_TYPE_TYPE_MODULE, 
GjsTypeModule))
-#define GJS_TYPE_MODULE_CLASS(class)      (G_TYPE_CHECK_CLASS_CAST ((class), GJS_TYPE_TYPE_MODULE, 
GjsTypeModuleClass))
+#define GJS_TYPE_MODULE_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST ((klass), GJS_TYPE_TYPE_MODULE, 
GjsTypeModuleClass))
 #define GJS_IS_TYPE_MODULE(module)        (G_TYPE_CHECK_INSTANCE_TYPE ((module), GJS_TYPE_TYPE_MODULE))
-#define GJS_IS_TYPE_MODULE_CLASS(class)   (G_TYPE_CHECK_CLASS_TYPE ((class), GJS_TYPE_TYPE_MODULE))
+#define GJS_IS_TYPE_MODULE_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), GJS_TYPE_TYPE_MODULE))
 #define GJS_TYPE_MODULE_GET_CLASS(module) (G_TYPE_INSTANCE_GET_CLASS ((module), GJS_TYPE_TYPE_MODULE, 
GjsTypeModuleClass))
 
 GType gjs_type_module_get_type (void) G_GNUC_CONST;


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