[gjs] all: fix method resolution on prototypes
- From: Giovanni Campagna <gcampagna src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs] all: fix method resolution on prototypes
- Date: Thu, 10 Apr 2014 23:36:35 +0000 (UTC)
commit aae358fda5f6d57444276ccc63cbe4994cc90453
Author: Giovanni Campagna <gcampagna src gnome org>
Date: Wed Feb 26 22:46:53 2014 +0100
all: fix method resolution on prototypes
We must define as methods on prototypes only the functions
that have the IS_METHOD flag, or we get static functions there.
https://bugzilla.gnome.org/show_bug.cgi?id=725282
gi/boxed.cpp | 27 +++++++++++++------------
gi/fundamental.cpp | 55 +++++++++++++++++++++++++++------------------------
gi/interface.cpp | 15 ++++++++-----
gi/object.cpp | 36 ++++++++++++++++++---------------
gi/param.cpp | 18 +++++++++-------
gi/union.cpp | 39 ++++++++++++++++++------------------
6 files changed, 102 insertions(+), 88 deletions(-)
---
diff --git a/gi/boxed.cpp b/gi/boxed.cpp
index 4fcda3b..497352f 100644
--- a/gi/boxed.cpp
+++ b/gi/boxed.cpp
@@ -152,25 +152,26 @@ boxed_new_resolve(JSContext *context,
#if GJS_VERBOSE_ENABLE_GI_USAGE
_gjs_log_info_usage((GIBaseInfo*) method_info);
#endif
+ if (g_function_info_get_flags (method_info) & GI_FUNCTION_IS_METHOD) {
+ method_name = g_base_info_get_name( (GIBaseInfo*) method_info);
- method_name = g_base_info_get_name( (GIBaseInfo*) method_info);
+ gjs_debug(GJS_DEBUG_GBOXED,
+ "Defining method %s in prototype for %s.%s",
+ method_name,
+ g_base_info_get_namespace( (GIBaseInfo*) priv->info),
+ g_base_info_get_name( (GIBaseInfo*) priv->info));
- gjs_debug(GJS_DEBUG_GBOXED,
- "Defining method %s in prototype for %s.%s",
- method_name,
- g_base_info_get_namespace( (GIBaseInfo*) priv->info),
- g_base_info_get_name( (GIBaseInfo*) priv->info));
+ boxed_proto = *obj;
- boxed_proto = *obj;
+ if (gjs_define_function(context, boxed_proto, priv->gtype,
+ (GICallableInfo *)method_info) == NULL) {
+ g_base_info_unref( (GIBaseInfo*) method_info);
+ goto out;
+ }
- if (gjs_define_function(context, boxed_proto, priv->gtype,
- (GICallableInfo *)method_info) == NULL) {
- g_base_info_unref( (GIBaseInfo*) method_info);
- goto out;
+ *objp = boxed_proto; /* we defined the prop in object_proto */
}
- *objp = boxed_proto; /* we defined the prop in object_proto */
-
g_base_info_unref( (GIBaseInfo*) method_info);
}
} else {
diff --git a/gi/fundamental.cpp b/gi/fundamental.cpp
index 1cb2a19..c5c82d8 100644
--- a/gi/fundamental.cpp
+++ b/gi/fundamental.cpp
@@ -302,12 +302,14 @@ fundamental_instance_new_resolve_interface(JSContext *context,
if (method_info != NULL) {
- if (gjs_define_function(context, obj,
- proto_priv->gtype,
- (GICallableInfo *) method_info)) {
- *objp = obj;
- } else {
- ret = JS_FALSE;
+ if (g_function_info_get_flags (method_info) & GI_FUNCTION_IS_METHOD) {
+ if (gjs_define_function(context, obj,
+ proto_priv->gtype,
+ (GICallableInfo *) method_info)) {
+ *objp = obj;
+ } else {
+ ret = JS_FALSE;
+ }
}
g_base_info_unref((GIBaseInfo *) method_info);
@@ -367,35 +369,36 @@ fundamental_instance_new_resolve(JSContext *context,
#if GJS_VERBOSE_ENABLE_GI_USAGE
_gjs_log_info_usage((GIBaseInfo *) method_info);
#endif
+ if (g_function_info_get_flags (method_info) & GI_FUNCTION_IS_METHOD) {
+ method_name = g_base_info_get_name((GIBaseInfo *) method_info);
+
+ /* we do not define deprecated methods in the prototype */
+ if (g_base_info_is_deprecated((GIBaseInfo *) method_info)) {
+ gjs_debug(GJS_DEBUG_GFUNDAMENTAL,
+ "Ignoring definition of deprecated method %s in prototype %s.%s",
+ method_name,
+ g_base_info_get_namespace((GIBaseInfo *) proto_priv->info),
+ g_base_info_get_name((GIBaseInfo *) proto_priv->info));
+ g_base_info_unref((GIBaseInfo *) method_info);
+ ret = JS_TRUE;
+ goto out;
+ }
- method_name = g_base_info_get_name((GIBaseInfo *) method_info);
-
- /* we do not define deprecated methods in the prototype */
- if (g_base_info_is_deprecated((GIBaseInfo *) method_info)) {
gjs_debug(GJS_DEBUG_GFUNDAMENTAL,
- "Ignoring definition of deprecated method %s in prototype %s.%s",
+ "Defining method %s in prototype for %s.%s",
method_name,
g_base_info_get_namespace((GIBaseInfo *) proto_priv->info),
g_base_info_get_name((GIBaseInfo *) proto_priv->info));
- g_base_info_unref((GIBaseInfo *) method_info);
- ret = JS_TRUE;
- goto out;
- }
- gjs_debug(GJS_DEBUG_GFUNDAMENTAL,
- "Defining method %s in prototype for %s.%s",
- method_name,
- g_base_info_get_namespace((GIBaseInfo *) proto_priv->info),
- g_base_info_get_name((GIBaseInfo *) proto_priv->info));
+ if (gjs_define_function(context, *obj, proto_priv->gtype,
+ method_info) == NULL) {
+ g_base_info_unref((GIBaseInfo *) method_info);
+ goto out;
+ }
- if (gjs_define_function(context, *obj, proto_priv->gtype,
- method_info) == NULL) {
- g_base_info_unref((GIBaseInfo *) method_info);
- goto out;
+ *objp = *obj;
}
- *objp = *obj;
-
g_base_info_unref((GIBaseInfo *) method_info);
}
diff --git a/gi/interface.cpp b/gi/interface.cpp
index fcb6736..8fb1253 100644
--- a/gi/interface.cpp
+++ b/gi/interface.cpp
@@ -123,14 +123,17 @@ interface_new_resolve(JSContext *context,
method_info = g_interface_info_find_method((GIInterfaceInfo*) priv->info, name);
if (method_info != NULL) {
- if (gjs_define_function(context, *obj,
- priv->gtype,
- (GICallableInfo*)method_info) == NULL) {
- g_base_info_unref((GIBaseInfo*)method_info);
- goto out;
+ if (g_function_info_get_flags (method_info) & GI_FUNCTION_IS_METHOD) {
+ if (gjs_define_function(context, *obj,
+ priv->gtype,
+ (GICallableInfo*)method_info) == NULL) {
+ g_base_info_unref((GIBaseInfo*)method_info);
+ goto out;
+ }
+
+ *objp = *obj;
}
- *objp = *obj;
g_base_info_unref((GIBaseInfo*)method_info);
}
diff --git a/gi/object.cpp b/gi/object.cpp
index 04c0513..d8c5beb 100644
--- a/gi/object.cpp
+++ b/gi/object.cpp
@@ -469,11 +469,13 @@ object_instance_new_resolve_no_info(JSContext *context,
if (method_info != NULL) {
- if (gjs_define_function(context, obj, priv->gtype,
- (GICallableInfo *)method_info)) {
- *objp = obj;
- } else {
- ret = JS_FALSE;
+ if (g_function_info_get_flags (method_info) & GI_FUNCTION_IS_METHOD) {
+ if (gjs_define_function(context, obj, priv->gtype,
+ (GICallableInfo *)method_info)) {
+ *objp = obj;
+ } else {
+ ret = JS_FALSE;
+ }
}
g_base_info_unref( (GIBaseInfo*) method_info);
@@ -621,19 +623,21 @@ object_instance_new_resolve(JSContext *context,
_gjs_log_info_usage((GIBaseInfo*) method_info);
#endif
- gjs_debug(GJS_DEBUG_GOBJECT,
- "Defining method %s in prototype for %s (%s.%s)",
- g_base_info_get_name( (GIBaseInfo*) method_info),
- g_type_name(priv->gtype),
- g_base_info_get_namespace( (GIBaseInfo*) priv->info),
- g_base_info_get_name( (GIBaseInfo*) priv->info));
+ if (g_function_info_get_flags (method_info) & GI_FUNCTION_IS_METHOD) {
+ gjs_debug(GJS_DEBUG_GOBJECT,
+ "Defining method %s in prototype for %s (%s.%s)",
+ g_base_info_get_name( (GIBaseInfo*) method_info),
+ g_type_name(priv->gtype),
+ g_base_info_get_namespace( (GIBaseInfo*) priv->info),
+ g_base_info_get_name( (GIBaseInfo*) priv->info));
- if (gjs_define_function(context, *obj, priv->gtype, method_info) == NULL) {
- g_base_info_unref( (GIBaseInfo*) method_info);
- goto out;
- }
+ if (gjs_define_function(context, *obj, priv->gtype, method_info) == NULL) {
+ g_base_info_unref( (GIBaseInfo*) method_info);
+ goto out;
+ }
- *objp = *obj; /* we defined the prop in obj */
+ *objp = *obj; /* we defined the prop in obj */
+ }
g_base_info_unref( (GIBaseInfo*) method_info);
}
diff --git a/gi/param.cpp b/gi/param.cpp
index 0f3c18b..11cf355 100644
--- a/gi/param.cpp
+++ b/gi/param.cpp
@@ -94,17 +94,19 @@ param_new_resolve(JSContext *context,
_gjs_log_info_usage((GIBaseInfo*) method_info);
#endif
- gjs_debug(GJS_DEBUG_GOBJECT,
- "Defining method %s in prototype for GObject.ParamSpec",
- g_base_info_get_name( (GIBaseInfo*) method_info));
+ if (g_function_info_get_flags (method_info) & GI_FUNCTION_IS_METHOD) {
+ gjs_debug(GJS_DEBUG_GOBJECT,
+ "Defining method %s in prototype for GObject.ParamSpec",
+ g_base_info_get_name( (GIBaseInfo*) method_info));
+
+ if (gjs_define_function(context, *obj, G_TYPE_PARAM, method_info) == NULL) {
+ g_base_info_unref( (GIBaseInfo*) method_info);
+ goto out;
+ }
- if (gjs_define_function(context, *obj, G_TYPE_PARAM, method_info) == NULL) {
- g_base_info_unref( (GIBaseInfo*) method_info);
- goto out;
+ *objp = *obj; /* we defined the prop in obj */
}
- *objp = *obj; /* we defined the prop in obj */
-
g_base_info_unref( (GIBaseInfo*) method_info);
ret = JS_TRUE;
diff --git a/gi/union.cpp b/gi/union.cpp
index 8364473..7ac58e3 100644
--- a/gi/union.cpp
+++ b/gi/union.cpp
@@ -100,27 +100,28 @@ union_new_resolve(JSContext *context,
#if GJS_VERBOSE_ENABLE_GI_USAGE
_gjs_log_info_usage((GIBaseInfo*) method_info);
#endif
-
- method_name = g_base_info_get_name( (GIBaseInfo*) method_info);
-
- gjs_debug(GJS_DEBUG_GBOXED,
- "Defining method %s in prototype for %s.%s",
- method_name,
- g_base_info_get_namespace( (GIBaseInfo*) priv->info),
- g_base_info_get_name( (GIBaseInfo*) priv->info));
-
- union_proto = *obj;
-
- if (gjs_define_function(context, union_proto,
- g_registered_type_info_get_g_type(priv->info),
- method_info) == NULL) {
- g_base_info_unref( (GIBaseInfo*) method_info);
- ret = JS_FALSE;
- goto out;
+ if (g_function_info_get_flags (method_info) & GI_FUNCTION_IS_METHOD) {
+ method_name = g_base_info_get_name( (GIBaseInfo*) method_info);
+
+ gjs_debug(GJS_DEBUG_GBOXED,
+ "Defining method %s in prototype for %s.%s",
+ method_name,
+ g_base_info_get_namespace( (GIBaseInfo*) priv->info),
+ g_base_info_get_name( (GIBaseInfo*) priv->info));
+
+ union_proto = *obj;
+
+ if (gjs_define_function(context, union_proto,
+ g_registered_type_info_get_g_type(priv->info),
+ method_info) == NULL) {
+ g_base_info_unref( (GIBaseInfo*) method_info);
+ ret = JS_FALSE;
+ goto out;
+ }
+
+ *objp = union_proto; /* we defined the prop in object_proto */
}
- *objp = union_proto; /* we defined the prop in object_proto */
-
g_base_info_unref( (GIBaseInfo*) method_info);
}
} else {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]