summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiovanni Campagna <gcampagna@src.gnome.org>2014-02-26 22:46:53 +0100
committerGiovanni Campagna <gcampagna@src.gnome.org>2014-04-11 01:35:53 +0200
commitaae358fda5f6d57444276ccc63cbe4994cc90453 (patch)
tree72dfc8e39d530065040506c532d95a82bcb3eb81
parentd8bf3f99b6a46c820a37f6fc6a4a779351f1bf44 (diff)
downloadgjs-aae358fda5f6d57444276ccc63cbe4994cc90453.tar.gz
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
-rw-r--r--gi/boxed.cpp27
-rw-r--r--gi/fundamental.cpp55
-rw-r--r--gi/interface.cpp15
-rw-r--r--gi/object.cpp36
-rw-r--r--gi/param.cpp18
-rw-r--r--gi/union.cpp39
6 files changed, 102 insertions, 88 deletions
diff --git a/gi/boxed.cpp b/gi/boxed.cpp
index 4fcda3bb..497352f8 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 1cb2a198..c5c82d8f 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 fcb67367..8fb1253b 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 04c05139..d8c5beb4 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 0f3c18bf..11cf3554 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 8364473e..7ac58e37 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 {