- Work around Mozilla JS API changes
This commit is contained in:
parent
1e24437abe
commit
5f133f05c4
20
gjs.spec
20
gjs.spec
@ -1,6 +1,6 @@
|
||||
Name: gjs
|
||||
Version: 0.7.7
|
||||
Release: 2%{?dist}
|
||||
Release: 3%{?dist}
|
||||
Summary: Javascript Bindings for GNOME
|
||||
|
||||
Group: System Environment/Libraries
|
||||
@ -14,6 +14,14 @@ URL: http://live.gnome.org/Gjs/
|
||||
Source0: ftp://ftp.gnome.org/pub/GNOME/sources/%{name}/%{version}/%{name}-%{version}.tar.bz2
|
||||
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
|
||||
|
||||
Patch0: js-no-string-get-ascii.patch
|
||||
Patch1: js-always-utf8.patch
|
||||
Patch2: js-getstringbytes-1.patch
|
||||
Patch3: js-getstringbytes-2.patch
|
||||
Patch4: js-getfunctionname-1.patch
|
||||
Patch5: js-getfunctionname-2.patch
|
||||
Patch6: js-getfunctionname-3.patch
|
||||
|
||||
BuildRequires: xulrunner-devel
|
||||
BuildRequires: gobject-introspection-devel
|
||||
BuildRequires: dbus-glib-devel
|
||||
@ -38,6 +46,13 @@ Files for development with %{name}.
|
||||
|
||||
%prep
|
||||
%setup -q
|
||||
%patch0 -p1 -b .no-string-get-ascii
|
||||
%patch1 -p1 -b .always-utf8
|
||||
%patch2 -p1 -b .getstringbytes-1
|
||||
%patch3 -p1 -b .getstringbytes-2
|
||||
%patch4 -p1 -b .getfunctionname-1
|
||||
%patch5 -p1 -b .getfunctionname-2
|
||||
%patch6 -p1 -b .getfunctionname-3
|
||||
|
||||
%build
|
||||
(if ! test -x configure; then NOCONFIGURE=1 ./autogen.sh; fi;
|
||||
@ -82,6 +97,9 @@ rm -rf %{buildroot}
|
||||
%{_libdir}/*.so
|
||||
|
||||
%changelog
|
||||
* Wed Dec 29 2010 Dan Williams <dcbw@redhat.com> - 0.7.7-3
|
||||
- Work around Mozilla JS API changes
|
||||
|
||||
* Wed Dec 22 2010 Colin Walters <walters@verbum.org> - 0.7.7-2
|
||||
- Remove rpath removal; we need an rpath on libmozjs, since
|
||||
it's in a nonstandard directory.
|
||||
|
215
js-always-utf8.patch
Normal file
215
js-always-utf8.patch
Normal file
@ -0,0 +1,215 @@
|
||||
commit 52593563c9e9873231f5fdae3dc1668460bee37e
|
||||
Author: Colin Walters <walters@verbum.org>
|
||||
Date: Wed Dec 1 17:11:16 2010 -0500
|
||||
|
||||
gjs_value_debug_string: Always return UTF-8
|
||||
|
||||
Returning whatever JS_GetStringBytes gave us will blow up if
|
||||
the string contains non-UTF8 characters and we're trying to g_print
|
||||
to a UTF-8 terminal (the standard case). Since this is just a
|
||||
debugging string, import a copy of _g_utf8_make_valid which
|
||||
squashes it to UTF-8 in a useful way.
|
||||
|
||||
diff --git a/gjs/jsapi-util.c b/gjs/jsapi-util.c
|
||||
index 11c890a..714b91e 100644
|
||||
--- a/gjs/jsapi-util.c
|
||||
+++ b/gjs/jsapi-util.c
|
||||
@@ -755,12 +755,20 @@ gjs_define_string_array(JSContext *context,
|
||||
return array;
|
||||
}
|
||||
|
||||
-const char*
|
||||
+/**
|
||||
+ * gjs_value_debug_string:
|
||||
+ * @context:
|
||||
+ * @value: Any JavaScript value
|
||||
+ *
|
||||
+ * Returns: A UTF-8 encoded string describing @value
|
||||
+ */
|
||||
+char*
|
||||
gjs_value_debug_string(JSContext *context,
|
||||
jsval value)
|
||||
{
|
||||
JSString *str;
|
||||
const char *bytes;
|
||||
+ char *debugstr;
|
||||
|
||||
JS_BeginRequest(context);
|
||||
|
||||
@@ -778,14 +786,14 @@ gjs_value_debug_string(JSContext *context,
|
||||
str = JS_NewStringCopyZ(context, klass->name);
|
||||
JS_ClearPendingException(context);
|
||||
if (str == NULL) {
|
||||
- return "[out of memory copying class name]";
|
||||
+ return g_strdup("[out of memory copying class name]");
|
||||
}
|
||||
} else {
|
||||
gjs_log_exception(context, NULL);
|
||||
- return "[unknown object]";
|
||||
+ return g_strdup("[unknown object]");
|
||||
}
|
||||
} else {
|
||||
- return "[unknown non-object]";
|
||||
+ return g_strdup("[unknown non-object]");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -795,7 +803,9 @@ gjs_value_debug_string(JSContext *context,
|
||||
|
||||
JS_EndRequest(context);
|
||||
|
||||
- return bytes;
|
||||
+ debugstr = _gjs_g_utf8_make_valid(bytes);
|
||||
+
|
||||
+ return debugstr;
|
||||
}
|
||||
|
||||
void
|
||||
@@ -829,6 +839,7 @@ gjs_log_object_props(JSContext *context,
|
||||
while (!JSID_IS_VOID(prop_id)) {
|
||||
jsval propval;
|
||||
const char *name;
|
||||
+ char *debugstr;
|
||||
|
||||
if (!gjs_get_string_id(context, prop_id, &name))
|
||||
goto next;
|
||||
@@ -836,10 +847,12 @@ gjs_log_object_props(JSContext *context,
|
||||
if (!gjs_object_get_property(context, obj, name, &propval))
|
||||
goto next;
|
||||
|
||||
+ debugstr = gjs_value_debug_string(context, propval);
|
||||
gjs_debug(topic,
|
||||
"%s%s = '%s'",
|
||||
prefix, name,
|
||||
- gjs_value_debug_string(context, propval));
|
||||
+ debugstr);
|
||||
+ g_free(debugstr);
|
||||
|
||||
next:
|
||||
prop_id = JSID_VOID;
|
||||
@@ -859,6 +872,7 @@ gjs_explain_scope(JSContext *context,
|
||||
JSObject *global;
|
||||
JSObject *parent;
|
||||
GString *chain;
|
||||
+ char *debugstr;
|
||||
|
||||
gjs_debug(GJS_DEBUG_SCOPE,
|
||||
"=== %s ===",
|
||||
@@ -874,14 +888,16 @@ gjs_explain_scope(JSContext *context,
|
||||
"");
|
||||
|
||||
global = JS_GetGlobalObject(context);
|
||||
+ debugstr = gjs_value_debug_string(context, OBJECT_TO_JSVAL(global));
|
||||
gjs_debug(GJS_DEBUG_SCOPE,
|
||||
" Global: %p %s",
|
||||
- global, gjs_value_debug_string(context, OBJECT_TO_JSVAL(global)));
|
||||
+ global, debugstr);
|
||||
+ g_free(debugstr);
|
||||
|
||||
parent = JS_GetScopeChain(context);
|
||||
chain = g_string_new(NULL);
|
||||
while (parent != NULL) {
|
||||
- const char *debug;
|
||||
+ char *debug;
|
||||
debug = gjs_value_debug_string(context, OBJECT_TO_JSVAL(parent));
|
||||
|
||||
if (chain->len > 0)
|
||||
@@ -889,6 +905,7 @@ gjs_explain_scope(JSContext *context,
|
||||
|
||||
g_string_append_printf(chain, "%p %s",
|
||||
parent, debug);
|
||||
+ g_free(debug);
|
||||
parent = JS_GetParent(context, parent);
|
||||
}
|
||||
gjs_debug(GJS_DEBUG_SCOPE,
|
||||
diff --git a/gjs/jsapi-util.h b/gjs/jsapi-util.h
|
||||
index 424cded..b7c6a8b 100644
|
||||
--- a/gjs/jsapi-util.h
|
||||
+++ b/gjs/jsapi-util.h
|
||||
@@ -267,7 +267,7 @@ void gjs_log_object_props (JSContext *context,
|
||||
GjsDebugTopic topic,
|
||||
const char *prefix);
|
||||
#endif
|
||||
-const char* gjs_value_debug_string (JSContext *context,
|
||||
+char* gjs_value_debug_string (JSContext *context,
|
||||
jsval value);
|
||||
void gjs_explain_scope (JSContext *context,
|
||||
const char *title);
|
||||
diff --git a/util/glib.c b/util/glib.c
|
||||
index 316e6e0..b79e75f 100644
|
||||
--- a/util/glib.c
|
||||
+++ b/util/glib.c
|
||||
@@ -21,10 +21,12 @@
|
||||
* IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
-#include <config.h>
|
||||
+#include <string.h>
|
||||
|
||||
#include "glib.h"
|
||||
|
||||
+#include <config.h>
|
||||
+
|
||||
typedef struct {
|
||||
void *key;
|
||||
void *value;
|
||||
@@ -125,6 +127,46 @@ gjs_g_strv_concat(char ***strv_array, int len)
|
||||
return (char**)g_ptr_array_free(array, FALSE);
|
||||
}
|
||||
|
||||
+gchar *
|
||||
+_gjs_g_utf8_make_valid (const gchar *name)
|
||||
+{
|
||||
+ GString *string;
|
||||
+ const gchar *remainder, *invalid;
|
||||
+ gint remaining_bytes, valid_bytes;
|
||||
+
|
||||
+ g_return_val_if_fail (name != NULL, NULL);
|
||||
+
|
||||
+ string = NULL;
|
||||
+ remainder = name;
|
||||
+ remaining_bytes = strlen (name);
|
||||
+
|
||||
+ while (remaining_bytes != 0)
|
||||
+ {
|
||||
+ if (g_utf8_validate (remainder, remaining_bytes, &invalid))
|
||||
+ break;
|
||||
+ valid_bytes = invalid - remainder;
|
||||
+
|
||||
+ if (string == NULL)
|
||||
+ string = g_string_sized_new (remaining_bytes);
|
||||
+
|
||||
+ g_string_append_len (string, remainder, valid_bytes);
|
||||
+ /* append U+FFFD REPLACEMENT CHARACTER */
|
||||
+ g_string_append (string, "\357\277\275");
|
||||
+
|
||||
+ remaining_bytes -= valid_bytes + 1;
|
||||
+ remainder = invalid + 1;
|
||||
+ }
|
||||
+
|
||||
+ if (string == NULL)
|
||||
+ return g_strdup (name);
|
||||
+
|
||||
+ g_string_append (string, remainder);
|
||||
+
|
||||
+ g_assert (g_utf8_validate (string->str, -1, NULL));
|
||||
+
|
||||
+ return g_string_free (string, FALSE);
|
||||
+}
|
||||
+
|
||||
#if GJS_BUILD_TESTS
|
||||
|
||||
void
|
||||
diff --git a/util/glib.h b/util/glib.h
|
||||
index 7bdc01a..5be171f 100644
|
||||
--- a/util/glib.h
|
||||
+++ b/util/glib.h
|
||||
@@ -28,6 +28,8 @@
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
+gchar * _gjs_g_utf8_make_valid (const gchar *name);
|
||||
+
|
||||
gboolean gjs_g_hash_table_remove_one (GHashTable *hash,
|
||||
void **key_p,
|
||||
void **value_p);
|
148
js-getfunctionname-1.patch
Normal file
148
js-getfunctionname-1.patch
Normal file
@ -0,0 +1,148 @@
|
||||
commit aa8e8aa60a172f13757d5f0e374c009ffdb9ccfa
|
||||
Author: Marc-Antoine Perennou <Marc-Antoine@Perennou.com>
|
||||
Date: Tue Dec 14 18:23:29 2010 +0100
|
||||
|
||||
xulrunner2: Conditionnaly adapt to JS_GetFunctionName removal
|
||||
|
||||
Upstream removed JS_GetFunctionName in commit:
|
||||
http://hg.mozilla.org/mozilla-central/changeset/e35b70ffed69
|
||||
|
||||
We now have to use JS_GetFunctionId which returns a JSString*
|
||||
instead of a const char*
|
||||
|
||||
https://bugzilla.gnome.org/show_bug.cgi?id=637246
|
||||
|
||||
diff --git a/configure.ac b/configure.ac
|
||||
index 9d3f829..13db4f5 100644
|
||||
--- a/configure.ac
|
||||
+++ b/configure.ac
|
||||
@@ -147,6 +147,7 @@ else
|
||||
fi
|
||||
|
||||
AC_CHECK_LIB([mozjs], [JS_GetStringBytes], AC_DEFINE([HAVE_JS_GETSTRINGBYTES], [1], [Define if we still have JS_GetStringBytes]),, [$JS_LIBS])
|
||||
+AC_CHECK_LIB([mozjs], [JS_GetFunctionName], AC_DEFINE([HAVE_JS_GETFUNCTIONNAME], [1], [Define if we still have JS_GetFunctionName]),, [$JS_LIBS])
|
||||
|
||||
AC_MSG_CHECKING([for mozilla-js >= 2 ])
|
||||
if `$PKG_CONFIG --exists $JS_PACKAGE '>=' 2`; then
|
||||
diff --git a/gjs/profiler.c b/gjs/profiler.c
|
||||
index c579400..327a33a 100644
|
||||
--- a/gjs/profiler.c
|
||||
+++ b/gjs/profiler.c
|
||||
@@ -26,6 +26,7 @@
|
||||
#include "profiler.h"
|
||||
#include <jsdbgapi.h>
|
||||
#include "compat.h"
|
||||
+#include "jsapi-util.h"
|
||||
|
||||
#include <signal.h>
|
||||
#include <sys/types.h>
|
||||
@@ -109,7 +110,8 @@ gjs_profile_function_new(GjsProfileFunctionKey *key)
|
||||
self = g_slice_new0(GjsProfileFunction);
|
||||
self->key.filename = g_strdup(key->filename);
|
||||
self->key.lineno = key->lineno;
|
||||
- self->key.function_name = g_strdup(key->function_name);
|
||||
+ // Pass ownership of function_name from key to the new function
|
||||
+ self->key.function_name = key->function_name;
|
||||
|
||||
g_assert(self->key.filename != NULL);
|
||||
g_assert(self->key.function_name != NULL);
|
||||
@@ -132,6 +134,7 @@ gjs_profile_function_key_from_js(JSContext *cx,
|
||||
{
|
||||
JSScript *script;
|
||||
JSFunction *function;
|
||||
+ JSString *function_name = NULL;
|
||||
|
||||
/* We're not using the JSScript or JSFunction as the key since the script
|
||||
* could be unloaded and addresses reused.
|
||||
@@ -151,8 +154,15 @@ gjs_profile_function_key_from_js(JSContext *cx,
|
||||
* (or other object with a 'call' method) and would be good to somehow
|
||||
* figure out the name of the called function.
|
||||
*/
|
||||
- key->function_name = (char*)(function != NULL ? JS_GetFunctionName(function) : "(unknown)");
|
||||
-
|
||||
+#ifdef HAVE_JS_GETFUNCTIONNAME
|
||||
+ key->function_name = g_strdup(function != NULL ? JS_GetFunctionName(function) : "(unknown)");
|
||||
+#else
|
||||
+ function_name = JS_GetFunctionId(function);
|
||||
+ if (function_name)
|
||||
+ key->function_name = gjs_string_get_ascii(cx, STRING_TO_JSVAL(function_name));
|
||||
+ else
|
||||
+ key->function_name = g_strdup("(unknown)");
|
||||
+#endif
|
||||
|
||||
g_assert(key->filename != NULL);
|
||||
g_assert(key->function_name != NULL);
|
||||
@@ -171,16 +181,23 @@ gjs_profiler_lookup_function(GjsProfiler *self,
|
||||
|
||||
function = g_hash_table_lookup(self->by_file, &key);
|
||||
if (function)
|
||||
- return function;
|
||||
+ goto error;
|
||||
|
||||
if (!create_if_missing)
|
||||
- return NULL;
|
||||
+ goto error;
|
||||
|
||||
function = gjs_profile_function_new(&key);
|
||||
|
||||
g_hash_table_insert(self->by_file, &function->key, function);
|
||||
|
||||
+ /* Don't free key.function_name if we get here since we passed its
|
||||
+ * ownership to the new function.
|
||||
+ */
|
||||
return function;
|
||||
+
|
||||
+ error:
|
||||
+ g_free(key.function_name);
|
||||
+ return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
diff --git a/gjs/stack.c b/gjs/stack.c
|
||||
index 6e2b987..6c852c1 100644
|
||||
--- a/gjs/stack.c
|
||||
+++ b/gjs/stack.c
|
||||
@@ -83,7 +83,8 @@ format_frame(JSContext* cx, JSStackFrame* fp,
|
||||
JSPropertyDescArray call_props = { 0, NULL };
|
||||
JSObject* this_obj = NULL;
|
||||
JSObject* call_obj = NULL;
|
||||
- const char* funname = NULL;
|
||||
+ JSString* funname = NULL;
|
||||
+ char* funname_str = NULL;
|
||||
const char* filename = NULL;
|
||||
guint32 lineno = 0;
|
||||
guint32 named_arg_count = 0;
|
||||
@@ -115,7 +116,11 @@ format_frame(JSContext* cx, JSStackFrame* fp,
|
||||
lineno = (guint32) JS_PCToLineNumber(cx, script, pc);
|
||||
fun = JS_GetFrameFunction(cx, fp);
|
||||
if (fun)
|
||||
- funname = JS_GetFunctionName(fun);
|
||||
+#ifdef HAVE_JS_GETFUNCTIONNAME
|
||||
+ funname_str = JS_GetFunctionName(fun);
|
||||
+#else
|
||||
+ funname = JS_GetFunctionId(fun);
|
||||
+#endif
|
||||
|
||||
call_obj = JS_GetFrameCallObject(cx, fp);
|
||||
if (call_obj) {
|
||||
@@ -140,8 +145,18 @@ format_frame(JSContext* cx, JSStackFrame* fp,
|
||||
|
||||
/* print the frame number and function name */
|
||||
|
||||
- if (funname)
|
||||
- g_string_append_printf(buf, "%d %s(", num, funname);
|
||||
+#ifndef HAVE_JS_GETFUNCTIONNAME
|
||||
+ if (funname) {
|
||||
+ funname_str = gjs_string_get_ascii(cx, STRING_TO_JSVAL(funname));
|
||||
+ g_string_append_printf(buf, "%d %s(", num, funname_str);
|
||||
+ }
|
||||
+#endif
|
||||
+ if (funname_str) {
|
||||
+ g_string_append_printf(buf, "%d %s(", num, funname_str);
|
||||
+#ifndef HAVE_JS_GETFUNCTIONNAME
|
||||
+ g_free(funname_str);
|
||||
+#endif
|
||||
+ }
|
||||
else if (fun)
|
||||
g_string_append_printf(buf, "%d anonymous(", num);
|
||||
else
|
34
js-getfunctionname-2.patch
Normal file
34
js-getfunctionname-2.patch
Normal file
@ -0,0 +1,34 @@
|
||||
commit 8c9b27fdae70dfc285db12b929c66f78722b5f1a
|
||||
Author: Marc-Antoine Perennou <Marc-Antoine@Perennou.com>
|
||||
Date: Thu Dec 16 00:36:36 2010 +0100
|
||||
|
||||
Fix previous commit
|
||||
|
||||
Don"t append 2 times the frame number and the function name
|
||||
|
||||
diff --git a/gjs/stack.c b/gjs/stack.c
|
||||
index 6c852c1..92b589d 100644
|
||||
--- a/gjs/stack.c
|
||||
+++ b/gjs/stack.c
|
||||
@@ -120,6 +120,8 @@ format_frame(JSContext* cx, JSStackFrame* fp,
|
||||
funname_str = JS_GetFunctionName(fun);
|
||||
#else
|
||||
funname = JS_GetFunctionId(fun);
|
||||
+ if (funname)
|
||||
+ funname_str = gjs_string_get_ascii(cx, STRING_TO_JSVAL(funname));
|
||||
#endif
|
||||
|
||||
call_obj = JS_GetFrameCallObject(cx, fp);
|
||||
@@ -145,12 +147,6 @@ format_frame(JSContext* cx, JSStackFrame* fp,
|
||||
|
||||
/* print the frame number and function name */
|
||||
|
||||
-#ifndef HAVE_JS_GETFUNCTIONNAME
|
||||
- if (funname) {
|
||||
- funname_str = gjs_string_get_ascii(cx, STRING_TO_JSVAL(funname));
|
||||
- g_string_append_printf(buf, "%d %s(", num, funname_str);
|
||||
- }
|
||||
-#endif
|
||||
if (funname_str) {
|
||||
g_string_append_printf(buf, "%d %s(", num, funname_str);
|
||||
#ifndef HAVE_JS_GETFUNCTIONNAME
|
50
js-getfunctionname-3.patch
Normal file
50
js-getfunctionname-3.patch
Normal file
@ -0,0 +1,50 @@
|
||||
commit 08ed898f10ee888497708299f28d91fc67602699
|
||||
Author: Colin Walters <walters@verbum.org>
|
||||
Date: Wed Dec 15 18:52:13 2010 -0500
|
||||
|
||||
More fixes for previous commit
|
||||
|
||||
* Change to always malloc() to avoid compiler warnings
|
||||
* Add missing brackets to fix control flow
|
||||
|
||||
diff --git a/gjs/stack.c b/gjs/stack.c
|
||||
index 92b589d..90d15b6 100644
|
||||
--- a/gjs/stack.c
|
||||
+++ b/gjs/stack.c
|
||||
@@ -83,7 +83,6 @@ format_frame(JSContext* cx, JSStackFrame* fp,
|
||||
JSPropertyDescArray call_props = { 0, NULL };
|
||||
JSObject* this_obj = NULL;
|
||||
JSObject* call_obj = NULL;
|
||||
- JSString* funname = NULL;
|
||||
char* funname_str = NULL;
|
||||
const char* filename = NULL;
|
||||
guint32 lineno = 0;
|
||||
@@ -115,14 +114,15 @@ format_frame(JSContext* cx, JSStackFrame* fp,
|
||||
filename = JS_GetScriptFilename(cx, script);
|
||||
lineno = (guint32) JS_PCToLineNumber(cx, script, pc);
|
||||
fun = JS_GetFrameFunction(cx, fp);
|
||||
- if (fun)
|
||||
+ if (fun) {
|
||||
#ifdef HAVE_JS_GETFUNCTIONNAME
|
||||
- funname_str = JS_GetFunctionName(fun);
|
||||
+ funname_str = g_strdup(JS_GetFunctionName(fun));
|
||||
#else
|
||||
- funname = JS_GetFunctionId(fun);
|
||||
+ JSString* funname = JS_GetFunctionId(fun);
|
||||
if (funname)
|
||||
funname_str = gjs_string_get_ascii(cx, STRING_TO_JSVAL(funname));
|
||||
#endif
|
||||
+ }
|
||||
|
||||
call_obj = JS_GetFrameCallObject(cx, fp);
|
||||
if (call_obj) {
|
||||
@@ -149,9 +149,7 @@ format_frame(JSContext* cx, JSStackFrame* fp,
|
||||
|
||||
if (funname_str) {
|
||||
g_string_append_printf(buf, "%d %s(", num, funname_str);
|
||||
-#ifndef HAVE_JS_GETFUNCTIONNAME
|
||||
g_free(funname_str);
|
||||
-#endif
|
||||
}
|
||||
else if (fun)
|
||||
g_string_append_printf(buf, "%d anonymous(", num);
|
2090
js-getstringbytes-1.patch
Normal file
2090
js-getstringbytes-1.patch
Normal file
File diff suppressed because it is too large
Load Diff
131
js-getstringbytes-2.patch
Normal file
131
js-getstringbytes-2.patch
Normal file
@ -0,0 +1,131 @@
|
||||
commit 7222ad74d05fa226de5f236539a67e366a66ad56
|
||||
Author: Marc-Antoine Perennou <Marc-Antoine@Perennou.com>
|
||||
Date: Thu Dec 2 23:22:02 2010 +0100
|
||||
|
||||
Follow on to last patch to clean up goto handling
|
||||
|
||||
diff --git a/modules/dbus.c b/modules/dbus.c
|
||||
index 94267e8..d422e68 100644
|
||||
--- a/modules/dbus.c
|
||||
+++ b/modules/dbus.c
|
||||
@@ -804,10 +804,10 @@ gjs_js_dbus_unwatch_signal(JSContext *context,
|
||||
{
|
||||
jsval *argv = JS_ARGV(context, vp);
|
||||
JSObject *obj = JS_THIS_OBJECT(context, vp);
|
||||
- char *bus_name;
|
||||
- char *object_path;
|
||||
- char *iface;
|
||||
- char *signal;
|
||||
+ char *bus_name = NULL;
|
||||
+ char *object_path = NULL;
|
||||
+ char *iface = NULL;
|
||||
+ char *signal = NULL;
|
||||
SignalHandler *handler;
|
||||
DBusBusType bus_type;
|
||||
JSBool ret = JS_FALSE;
|
||||
@@ -831,25 +831,25 @@ gjs_js_dbus_unwatch_signal(JSContext *context,
|
||||
if (!fill_with_null_or_string(context, &bus_name, argv[0]))
|
||||
return JS_FALSE;
|
||||
if (!fill_with_null_or_string(context, &object_path, argv[1]))
|
||||
- goto object_path_fail;
|
||||
+ goto fail;
|
||||
if (!fill_with_null_or_string(context, &iface, argv[2]))
|
||||
- goto iface_fail;
|
||||
+ goto fail;
|
||||
if (!fill_with_null_or_string(context, &signal, argv[3]))
|
||||
- goto signal_fail;
|
||||
+ goto fail;
|
||||
|
||||
/* we don't complain if the signal seems to have been already removed
|
||||
* or to never have been watched, to match g_signal_handler_disconnect
|
||||
*/
|
||||
if (!signal_handlers_by_callable) {
|
||||
ret = JS_TRUE;
|
||||
- goto free_and_exit;
|
||||
+ goto fail;
|
||||
}
|
||||
|
||||
handler = g_hash_table_lookup(signal_handlers_by_callable, JSVAL_TO_OBJECT(argv[4]));
|
||||
|
||||
if (!handler) {
|
||||
ret = JS_TRUE;
|
||||
- goto free_and_exit;
|
||||
+ goto fail;
|
||||
}
|
||||
|
||||
/* This should dispose the handler which should in turn
|
||||
@@ -868,13 +868,10 @@ gjs_js_dbus_unwatch_signal(JSContext *context,
|
||||
|
||||
ret = JS_TRUE;
|
||||
|
||||
- free_and_exit:
|
||||
+ fail:
|
||||
g_free(signal);
|
||||
- signal_fail:
|
||||
g_free(iface);
|
||||
- iface_fail:
|
||||
g_free(object_path);
|
||||
- object_path_fail:
|
||||
g_free(bus_name);
|
||||
|
||||
return ret;
|
||||
@@ -892,10 +889,10 @@ gjs_js_dbus_emit_signal(JSContext *context,
|
||||
DBusMessage *message;
|
||||
DBusMessageIter arg_iter;
|
||||
DBusSignatureIter sig_iter;
|
||||
- char *object_path;
|
||||
- char *iface;
|
||||
- char *signal;
|
||||
- char *in_signature;
|
||||
+ char *object_path = NULL;
|
||||
+ char *iface = NULL;
|
||||
+ char *signal = NULL;
|
||||
+ char *in_signature = NULL;
|
||||
DBusBusType bus_type;
|
||||
JSBool ret = JS_FALSE;
|
||||
|
||||
@@ -917,16 +914,16 @@ gjs_js_dbus_emit_signal(JSContext *context,
|
||||
return JS_FALSE;
|
||||
iface = gjs_string_get_ascii(context, argv[1]);
|
||||
if (!iface)
|
||||
- goto iface_fail;
|
||||
+ goto fail;
|
||||
signal = gjs_string_get_ascii(context, argv[2]);
|
||||
if (!signal)
|
||||
- goto signal_fail;
|
||||
+ goto fail;
|
||||
in_signature = gjs_string_get_ascii(context, argv[3]);
|
||||
if (!in_signature)
|
||||
- goto in_signature_fail;
|
||||
+ goto fail;
|
||||
|
||||
if (!bus_check(context, bus_type))
|
||||
- goto free_and_exit;
|
||||
+ goto fail;
|
||||
|
||||
gjs_debug(GJS_DEBUG_DBUS,
|
||||
"Emitting signal %s %s %s",
|
||||
@@ -946,7 +943,7 @@ gjs_js_dbus_emit_signal(JSContext *context,
|
||||
|
||||
if (!gjs_js_values_to_dbus(context, 0, argv[4], &arg_iter, &sig_iter)) {
|
||||
dbus_message_unref(message);
|
||||
- goto free_and_exit;
|
||||
+ goto fail;
|
||||
}
|
||||
|
||||
dbus_connection_send(bus_connection, message, NULL);
|
||||
@@ -955,13 +952,10 @@ gjs_js_dbus_emit_signal(JSContext *context,
|
||||
|
||||
ret = JS_TRUE;
|
||||
|
||||
- free_and_exit:
|
||||
+ fail:
|
||||
g_free(in_signature);
|
||||
- in_signature_fail:
|
||||
g_free(signal);
|
||||
- signal_fail:
|
||||
g_free(iface);
|
||||
- iface_fail:
|
||||
g_free(object_path);
|
||||
|
||||
return ret;
|
348
js-no-string-get-ascii.patch
Normal file
348
js-no-string-get-ascii.patch
Normal file
@ -0,0 +1,348 @@
|
||||
commit 60ae0e25d58feb93f76c39aa84ffb49046a4f91e
|
||||
Author: Marc-Antoine Perennou <Marc-Antoine@Perennou.com>
|
||||
Date: Tue Nov 30 18:29:02 2010 +0100
|
||||
|
||||
xulrunner2: Get rid of gjs_string_get_ascii
|
||||
|
||||
In xulrunner2, JS_GetStringBytes has been removed, we will now always need a context.
|
||||
We won't be able to use gjs_string_get_ascii anymore, port each call to it to gjs_string_get_ascii_checked
|
||||
Btw, rename gjs_string_get_ascii_checked to gjs_string_get_ascii
|
||||
|
||||
https://bugzilla.gnome.org/show_bug.cgi?id=635707
|
||||
|
||||
diff --git a/gi/object.c b/gi/object.c
|
||||
index ffa4fa6..04c3073 100644
|
||||
--- a/gi/object.c
|
||||
+++ b/gi/object.c
|
||||
@@ -889,7 +889,7 @@ real_connect_func(JSContext *context,
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
- signal_name = gjs_string_get_ascii_checked(context, argv[0]);
|
||||
+ signal_name = gjs_string_get_ascii(context, argv[0]);
|
||||
if (signal_name == NULL) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
@@ -1017,7 +1017,7 @@ emit_func(JSContext *context,
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
- signal_name = gjs_string_get_ascii_checked(context,
|
||||
+ signal_name = gjs_string_get_ascii(context,
|
||||
argv[0]);
|
||||
if (signal_name == NULL)
|
||||
return JS_FALSE;
|
||||
diff --git a/gi/repo.c b/gi/repo.c
|
||||
index 7d3bbbc..a103c6d 100644
|
||||
--- a/gi/repo.c
|
||||
+++ b/gi/repo.c
|
||||
@@ -78,7 +78,7 @@ resolve_namespace_object(JSContext *context,
|
||||
version = NULL;
|
||||
if (JS_GetProperty(context, versions, ns_name, &version_val) &&
|
||||
JSVAL_IS_STRING(version_val)) {
|
||||
- version = gjs_string_get_ascii(version_val);
|
||||
+ version = gjs_string_get_ascii(context, version_val);
|
||||
}
|
||||
|
||||
repo = g_irepository_get_default();
|
||||
diff --git a/gjs/byteArray.c b/gjs/byteArray.c
|
||||
index b00be17..f8b650f 100644
|
||||
--- a/gjs/byteArray.c
|
||||
+++ b/gjs/byteArray.c
|
||||
@@ -514,7 +514,7 @@ to_string_func(JSContext *context,
|
||||
encoding_is_utf8 = TRUE;
|
||||
if (argc >= 1 &&
|
||||
JSVAL_IS_STRING(argv[0])) {
|
||||
- encoding = gjs_string_get_ascii_checked(context, argv[0]);
|
||||
+ encoding = gjs_string_get_ascii(context, argv[0]);
|
||||
if (encoding == NULL)
|
||||
return JS_FALSE;
|
||||
|
||||
@@ -634,7 +634,7 @@ from_string_func(JSContext *context,
|
||||
encoding_is_utf8 = TRUE;
|
||||
if (argc > 1 &&
|
||||
JSVAL_IS_STRING(argv[1])) {
|
||||
- encoding = gjs_string_get_ascii_checked(context, argv[1]);
|
||||
+ encoding = gjs_string_get_ascii(context, argv[1]);
|
||||
if (encoding == NULL)
|
||||
goto out;
|
||||
|
||||
diff --git a/gjs/jsapi-util-string.c b/gjs/jsapi-util-string.c
|
||||
index 1934097..32d7166 100644
|
||||
--- a/gjs/jsapi-util-string.c
|
||||
+++ b/gjs/jsapi-util-string.c
|
||||
@@ -238,25 +238,6 @@ gjs_string_from_filename(JSContext *context,
|
||||
|
||||
/**
|
||||
* gjs_string_get_ascii:
|
||||
- * @value: a jsval
|
||||
- *
|
||||
- * Get the char array in the JSString contained in @value.
|
||||
- * The string is expected to be encoded in ASCII, otherwise
|
||||
- * you will get garbage out. See the documentation for
|
||||
- * JS_GetStringBytes() for more details.
|
||||
- *
|
||||
- * Returns: an ASCII C string
|
||||
- **/
|
||||
-const char*
|
||||
-gjs_string_get_ascii(jsval value)
|
||||
-{
|
||||
- g_return_val_if_fail(JSVAL_IS_STRING(value), NULL);
|
||||
-
|
||||
- return JS_GetStringBytes(JSVAL_TO_STRING(value));
|
||||
-}
|
||||
-
|
||||
-/**
|
||||
- * gjs_string_get_ascii_checked:
|
||||
* @context: a JSContext
|
||||
* @value: a jsval
|
||||
*
|
||||
@@ -267,7 +248,7 @@ gjs_string_get_ascii(jsval value)
|
||||
* Returns: an ASCII C string or %NULL on error
|
||||
**/
|
||||
const char*
|
||||
-gjs_string_get_ascii_checked(JSContext *context,
|
||||
+gjs_string_get_ascii(JSContext *context,
|
||||
jsval value)
|
||||
{
|
||||
if (!JSVAL_IS_STRING(value)) {
|
||||
@@ -517,9 +498,9 @@ gjstest_test_func_gjs_jsapi_util_string_get_ascii(void)
|
||||
context = fixture.context;
|
||||
|
||||
js_string = JS_NewStringCopyZ(context, ascii_string);
|
||||
- g_assert(g_str_equal(gjs_string_get_ascii(STRING_TO_JSVAL(js_string)), ascii_string));
|
||||
+ g_assert(g_str_equal(gjs_string_get_ascii(context, STRING_TO_JSVAL(js_string)), ascii_string));
|
||||
void_value = JSVAL_VOID;
|
||||
- g_assert(gjs_string_get_ascii_checked(context, void_value) == NULL);
|
||||
+ g_assert(gjs_string_get_ascii(context, void_value) == NULL);
|
||||
g_assert(JS_IsExceptionPending(context));
|
||||
|
||||
_gjs_unit_test_fixture_finish(&fixture);
|
||||
diff --git a/gjs/jsapi-util.c b/gjs/jsapi-util.c
|
||||
index 4695ec0..11c890a 100644
|
||||
--- a/gjs/jsapi-util.c
|
||||
+++ b/gjs/jsapi-util.c
|
||||
@@ -1128,7 +1128,7 @@ log_prop(JSContext *context,
|
||||
if (JSVAL_IS_STRING(id)) {
|
||||
const char *name;
|
||||
|
||||
- name = gjs_string_get_ascii(id);
|
||||
+ name = gjs_string_get_ascii(context, id);
|
||||
gjs_debug(GJS_DEBUG_PROPS,
|
||||
"prop %s: %s",
|
||||
name, what);
|
||||
diff --git a/gjs/jsapi-util.h b/gjs/jsapi-util.h
|
||||
index b4a07ef..424cded 100644
|
||||
--- a/gjs/jsapi-util.h
|
||||
+++ b/gjs/jsapi-util.h
|
||||
@@ -311,8 +311,7 @@ JSBool gjs_string_from_filename (JSContext *context,
|
||||
const char *filename_string,
|
||||
gssize n_bytes,
|
||||
jsval *value_p);
|
||||
-const char* gjs_string_get_ascii (jsval value);
|
||||
-const char* gjs_string_get_ascii_checked (JSContext *context,
|
||||
+const char* gjs_string_get_ascii (JSContext *context,
|
||||
jsval value);
|
||||
JSBool gjs_string_get_binary_data (JSContext *context,
|
||||
jsval value,
|
||||
diff --git a/gjs/native.c b/gjs/native.c
|
||||
index 48175e3..3d97d70 100644
|
||||
--- a/gjs/native.c
|
||||
+++ b/gjs/native.c
|
||||
@@ -141,7 +141,7 @@ gjs_import_native_module(JSContext *context,
|
||||
if (gjs_object_get_property(context, parent, "__moduleName__", &value) &&
|
||||
JSVAL_IS_STRING(value)) {
|
||||
const char *name;
|
||||
- name = gjs_string_get_ascii(value);
|
||||
+ name = gjs_string_get_ascii(context, value);
|
||||
|
||||
if (module_id->len > 0)
|
||||
g_string_prepend(module_id, ".");
|
||||
diff --git a/modules/dbus-exports.c b/modules/dbus-exports.c
|
||||
index bd86ac8..0d8d9f3 100644
|
||||
--- a/modules/dbus-exports.c
|
||||
+++ b/modules/dbus-exports.c
|
||||
@@ -161,7 +161,7 @@ dbus_reply_from_exception_and_sender(JSContext *context,
|
||||
if (JSVAL_IS_OBJECT(exc) &&
|
||||
gjs_object_get_property(context, JSVAL_TO_OBJECT(exc),
|
||||
"dbusErrorName", &nameval))
|
||||
- name = gjs_string_get_ascii_checked(context, nameval);
|
||||
+ name = gjs_string_get_ascii(context, nameval);
|
||||
|
||||
if (!gjs_log_exception(context, &s))
|
||||
return JS_FALSE;
|
||||
@@ -204,7 +204,7 @@ signature_from_method(JSContext *context,
|
||||
if (gjs_object_get_property(context,
|
||||
method_obj, "outSignature",
|
||||
&signature_value)) {
|
||||
- *signature = gjs_string_get_ascii_checked(context,
|
||||
+ *signature = gjs_string_get_ascii(context,
|
||||
signature_value);
|
||||
if (*signature == NULL) {
|
||||
return JS_FALSE;
|
||||
@@ -408,7 +408,7 @@ async_call_callback(JSContext *context,
|
||||
gjs_log_and_keep_exception(context, NULL);
|
||||
return JS_FALSE;
|
||||
}
|
||||
- sender = gjs_string_get_ascii_checked(context, prop_value);
|
||||
+ sender = gjs_string_get_ascii(context, prop_value);
|
||||
if (!sender)
|
||||
return JS_FALSE;
|
||||
|
||||
@@ -444,7 +444,7 @@ async_call_callback(JSContext *context,
|
||||
thrown = TRUE;
|
||||
goto out;
|
||||
}
|
||||
- signature = gjs_string_get_ascii_checked(context, prop_value);
|
||||
+ signature = gjs_string_get_ascii(context, prop_value);
|
||||
if (!signature)
|
||||
return JS_FALSE;
|
||||
|
||||
@@ -834,7 +834,7 @@ unpack_property_details(JSContext *context,
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
- name = gjs_string_get_ascii_checked(context,
|
||||
+ name = gjs_string_get_ascii(context,
|
||||
name_val);
|
||||
if (name == NULL) {
|
||||
return JS_FALSE;
|
||||
@@ -850,7 +850,7 @@ unpack_property_details(JSContext *context,
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
- signature = gjs_string_get_ascii_checked(context,
|
||||
+ signature = gjs_string_get_ascii(context,
|
||||
signature_val);
|
||||
if (signature == NULL) {
|
||||
return JS_FALSE;
|
||||
@@ -866,7 +866,7 @@ unpack_property_details(JSContext *context,
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
- access = gjs_string_get_ascii_checked(context,
|
||||
+ access = gjs_string_get_ascii(context,
|
||||
access_val);
|
||||
if (access == NULL) {
|
||||
return JS_FALSE;
|
||||
diff --git a/modules/dbus-values.c b/modules/dbus-values.c
|
||||
index 2b23ca0..2d94c4a 100644
|
||||
--- a/modules/dbus-values.c
|
||||
+++ b/modules/dbus-values.c
|
||||
@@ -807,7 +807,7 @@ append_dict(JSContext *context,
|
||||
JSVAL_TO_OBJECT(prop_signatures),
|
||||
name, &signature_value);
|
||||
if (signature_value != JSVAL_VOID) {
|
||||
- value_signature = gjs_string_get_ascii_checked(context,
|
||||
+ value_signature = gjs_string_get_ascii(context,
|
||||
signature_value);
|
||||
if (value_signature == NULL) {
|
||||
return JS_FALSE;
|
||||
diff --git a/modules/dbus.c b/modules/dbus.c
|
||||
index 0ab3c79..f93f7ff 100644
|
||||
--- a/modules/dbus.c
|
||||
+++ b/modules/dbus.c
|
||||
@@ -134,31 +134,31 @@ prepare_call(JSContext *context,
|
||||
if (!bus_check(context, bus_type))
|
||||
return NULL;
|
||||
|
||||
- bus_name = gjs_string_get_ascii_checked(context, argv[0]);
|
||||
+ bus_name = gjs_string_get_ascii(context, argv[0]);
|
||||
if (bus_name == NULL)
|
||||
return NULL;
|
||||
|
||||
- path = gjs_string_get_ascii_checked(context, argv[1]);
|
||||
+ path = gjs_string_get_ascii(context, argv[1]);
|
||||
if (path == NULL)
|
||||
return NULL;
|
||||
|
||||
if (JSVAL_IS_NULL(argv[2])) {
|
||||
interface = NULL;
|
||||
} else {
|
||||
- interface = gjs_string_get_ascii_checked(context, argv[2]);
|
||||
+ interface = gjs_string_get_ascii(context, argv[2]);
|
||||
if (interface == NULL)
|
||||
return NULL; /* exception was set */
|
||||
}
|
||||
|
||||
- method = gjs_string_get_ascii_checked(context, argv[3]);
|
||||
+ method = gjs_string_get_ascii(context, argv[3]);
|
||||
if (method == NULL)
|
||||
return NULL;
|
||||
|
||||
- out_signature = gjs_string_get_ascii_checked(context, argv[4]);
|
||||
+ out_signature = gjs_string_get_ascii(context, argv[4]);
|
||||
if (out_signature == NULL)
|
||||
return NULL;
|
||||
|
||||
- in_signature = gjs_string_get_ascii_checked(context, argv[5]);
|
||||
+ in_signature = gjs_string_get_ascii(context, argv[5]);
|
||||
if (in_signature == NULL)
|
||||
return NULL;
|
||||
|
||||
@@ -447,7 +447,7 @@ fill_with_null_or_string(JSContext *context, const char **string_p, jsval value)
|
||||
if (JSVAL_IS_NULL(value))
|
||||
*string_p = NULL;
|
||||
else {
|
||||
- *string_p = gjs_string_get_ascii_checked(context, value);
|
||||
+ *string_p = gjs_string_get_ascii(context, value);
|
||||
if (!*string_p)
|
||||
return JS_FALSE;
|
||||
}
|
||||
@@ -878,16 +878,16 @@ gjs_js_dbus_emit_signal(JSContext *context,
|
||||
if (!get_bus_type_from_object(context, obj, &bus_type))
|
||||
return JS_FALSE;
|
||||
|
||||
- object_path = gjs_string_get_ascii_checked(context, argv[0]);
|
||||
+ object_path = gjs_string_get_ascii(context, argv[0]);
|
||||
if (!object_path)
|
||||
return JS_FALSE;
|
||||
- iface = gjs_string_get_ascii_checked(context, argv[1]);
|
||||
+ iface = gjs_string_get_ascii(context, argv[1]);
|
||||
if (!iface)
|
||||
return JS_FALSE;
|
||||
- signal = gjs_string_get_ascii_checked(context, argv[2]);
|
||||
+ signal = gjs_string_get_ascii(context, argv[2]);
|
||||
if (!signal)
|
||||
return JS_FALSE;
|
||||
- in_signature = gjs_string_get_ascii_checked(context, argv[3]);
|
||||
+ in_signature = gjs_string_get_ascii(context, argv[3]);
|
||||
if (!in_signature)
|
||||
return JS_FALSE;
|
||||
|
||||
@@ -1134,7 +1134,7 @@ gjs_js_dbus_acquire_name(JSContext *context,
|
||||
if (!get_bus_type_from_object(context, obj, &bus_type))
|
||||
return JS_FALSE;
|
||||
|
||||
- bus_name = gjs_string_get_ascii_checked(context, argv[0]);
|
||||
+ bus_name = gjs_string_get_ascii(context, argv[0]);
|
||||
if (bus_name == NULL)
|
||||
return JS_FALSE;
|
||||
|
||||
@@ -1369,7 +1369,7 @@ gjs_js_dbus_watch_name(JSContext *context,
|
||||
if (!get_bus_type_from_object(context, obj, &bus_type))
|
||||
return JS_FALSE;
|
||||
|
||||
- bus_name = gjs_string_get_ascii_checked(context, argv[0]);
|
||||
+ bus_name = gjs_string_get_ascii(context, argv[0]);
|
||||
if (bus_name == NULL)
|
||||
return JS_FALSE;
|
||||
|
||||
@@ -1482,7 +1482,7 @@ gjs_js_dbus_signature_length(JSContext *context,
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
- signature = gjs_string_get_ascii_checked(context, argv[0]);
|
||||
+ signature = gjs_string_get_ascii(context, argv[0]);
|
||||
if (signature == NULL)
|
||||
return JS_FALSE;
|
||||
|
||||
@@ -1523,7 +1523,7 @@ gjs_js_dbus_start_service(JSContext *context,
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
- name = gjs_string_get_ascii_checked(context, argv[0]);
|
||||
+ name = gjs_string_get_ascii(context, argv[0]);
|
||||
if (!name)
|
||||
return JS_FALSE;
|
||||
|
Loading…
Reference in New Issue
Block a user