[gjs] Port all functions to JSFUN_FAST_NATIVE
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs] Port all functions to JSFUN_FAST_NATIVE
- Date: Wed, 20 Oct 2010 20:33:06 +0000 (UTC)
commit c78646ed3f24bd915c7cfe4acac0176186df1d74
Author: Colin Walters <walters verbum org>
Date: Wed Oct 20 15:04:23 2010 -0400
Port all functions to JSFUN_FAST_NATIVE
"slow" natives have been removed in mozjs; this prepares us for
a patch which adapts to their removal.
See upstream commit: http://hg.mozilla.org/mozilla-central/rev/66c8ad02543b
https://bugzilla.gnome.org/show_bug.cgi?id=632159
gi/object.c | 71 +++++-----
gjs/byteArray.c | 106 +++++++-------
modules/cairo-context.c | 291 ++++++++++++++++++++-------------------
modules/cairo-gradient.c | 22 ++--
modules/cairo-image-surface.c | 13 +-
modules/cairo-pattern.c | 11 +-
modules/cairo-solid-pattern.c | 18 +--
modules/cairo-surface-pattern.c | 44 +++---
modules/cairo-surface.c | 24 ++--
modules/dbus-exports.c | 12 +-
10 files changed, 312 insertions(+), 300 deletions(-)
---
diff --git a/gi/object.c b/gi/object.c
index aba7bde..0a4fb6d 100644
--- a/gi/object.c
+++ b/gi/object.c
@@ -842,20 +842,19 @@ gjs_lookup_object_prototype(JSContext *context,
static JSBool
real_connect_func(JSContext *context,
- JSObject *obj,
uintN argc,
- jsval *argv,
- jsval *retval,
+ jsval *vp,
gboolean after)
{
+ JSObject *obj = JS_THIS_OBJECT(context, vp);
+ jsval *argv = JS_ARGV(context, vp);
ObjectInstance *priv;
GClosure *closure;
gulong id;
guint signal_id;
const char *signal_name;
GQuark signal_detail;
-
- *retval = JSID_VOID;
+ jsval retval;
priv = priv_from_js(context, obj);
gjs_debug_gsignal("connect obj %p priv %p argc %d", obj, priv, argc);
@@ -907,46 +906,42 @@ real_connect_func(JSContext *context,
closure,
after);
- if (!JS_NewNumberValue(context, id, retval)) {
+ if (!JS_NewNumberValue(context, id, &retval)) {
g_signal_handler_disconnect(priv->gobj, id);
return JS_FALSE;
}
+
+ JS_SET_RVAL(context, vp, retval);
return JS_TRUE;
}
static JSBool
connect_after_func(JSContext *context,
- JSObject *obj,
uintN argc,
- jsval *argv,
- jsval *retval)
+ jsval *vp)
{
- return real_connect_func(context, obj, argc, argv, retval, TRUE);
+ return real_connect_func(context, argc, vp, TRUE);
}
static JSBool
connect_func(JSContext *context,
- JSObject *obj,
uintN argc,
- jsval *argv,
- jsval *retval)
+ jsval *vp)
{
- return real_connect_func(context, obj, argc, argv, retval, FALSE);
+ return real_connect_func(context, argc, vp, FALSE);
}
static JSBool
disconnect_func(JSContext *context,
- JSObject *obj,
uintN argc,
- jsval *argv,
- jsval *retval)
+ jsval *vp)
{
+ jsval *argv = JS_ARGV(context, vp);
+ JSObject *obj = JS_THIS_OBJECT(context, vp);
ObjectInstance *priv;
gulong id;
- *retval = JSVAL_VOID;
-
priv = priv_from_js(context, obj);
gjs_debug_gsignal("disconnect obj %p priv %p argc %d", obj, priv, argc);
@@ -970,17 +965,19 @@ disconnect_func(JSContext *context,
id = JSVAL_TO_INT(argv[0]);
g_signal_handler_disconnect(priv->gobj, id);
+
+ JS_SET_RVAL(context, vp, JSVAL_VOID);
return JS_TRUE;
}
static JSBool
emit_func(JSContext *context,
- JSObject *obj,
uintN argc,
- jsval *argv,
- jsval *retval)
+ jsval *vp)
{
+ jsval *argv = JS_ARGV(context, vp);
+ JSObject *obj = JS_THIS_OBJECT(context, vp);
ObjectInstance *priv;
guint signal_id;
GQuark signal_detail;
@@ -990,8 +987,7 @@ emit_func(JSContext *context,
GValue rvalue;
unsigned int i;
gboolean failed;
-
- *retval = JSVAL_VOID;
+ jsval retval;
priv = priv_from_js(context, obj);
gjs_debug_gsignal("emit obj %p priv %p argc %d", obj, priv, argc);
@@ -1072,7 +1068,7 @@ emit_func(JSContext *context,
if (signal_query.return_type != G_TYPE_NONE) {
if (!gjs_value_from_g_value(context,
- retval,
+ &retval,
&rvalue))
failed = TRUE;
@@ -1083,6 +1079,9 @@ emit_func(JSContext *context,
g_value_unset(&instance_and_args[i]);
}
+ if (!failed)
+ JS_SET_RVAL(context, vp, retval);
+
return !failed;
}
@@ -1092,18 +1091,16 @@ emit_func(JSContext *context,
*/
static JSBool
to_string_func(JSContext *context,
- JSObject *obj,
uintN argc,
- jsval *argv,
- jsval *retval)
+ jsval *vp)
{
+ JSObject *obj = JS_THIS_OBJECT(context, vp);
ObjectInstance *priv;
char *strval;
JSBool ret;
const char *namespace;
const char *name;
-
- *retval = JSVAL_VOID;
+ jsval retval;
priv = priv_from_js(context, obj);
@@ -1119,7 +1116,9 @@ to_string_func(JSContext *context,
strval = g_strdup_printf ("[object instance proxy GIName:%s.%s jsobj %p native %p]", namespace, name, obj, priv->gobj);
}
- ret = gjs_string_from_utf8 (context, strval, -1, retval);
+ ret = gjs_string_from_utf8 (context, strval, -1, &retval);
+ if (ret)
+ JS_SET_RVAL(context, vp, retval);
g_free (strval);
return ret;
}
@@ -1155,11 +1154,11 @@ static JSPropertySpec gjs_object_instance_proto_props[] = {
};
static JSFunctionSpec gjs_object_instance_proto_funcs[] = {
- { "connect", connect_func, 0, 0 },
- { "connect_after", connect_after_func, 0, 0 },
- { "disconnect", disconnect_func, 0, 0 },
- { "emit", emit_func, 0, 0 },
- { "toString", to_string_func, 0, 0 },
+ { "connect", (JSNative)connect_func, 0, JSFUN_FAST_NATIVE },
+ { "connect_after", (JSNative)connect_after_func, 0, JSFUN_FAST_NATIVE },
+ { "disconnect", (JSNative)disconnect_func, 0, JSFUN_FAST_NATIVE },
+ { "emit", (JSNative)emit_func, 0, JSFUN_FAST_NATIVE },
+ { "toString", (JSNative)to_string_func, 0, JSFUN_FAST_NATIVE },
{ NULL }
};
diff --git a/gjs/byteArray.c b/gjs/byteArray.c
index 6bd9003..5842ce9 100644
--- a/gjs/byteArray.c
+++ b/gjs/byteArray.c
@@ -504,18 +504,16 @@ byte_array_finalize(JSContext *context,
/* implement toString() with an optional encoding arg */
static JSBool
to_string_func(JSContext *context,
- JSObject *obj,
uintN argc,
- jsval *argv,
- jsval *retval)
+ jsval *vp)
{
+ jsval *argv = JS_ARGV(context, vp);
+ JSObject *object = JS_THIS_OBJECT(context, vp);
ByteArrayInstance *priv;
const char *encoding;
gboolean encoding_is_utf8;
- *retval = JSVAL_VOID;
-
- priv = priv_from_js(context, obj);
+ priv = priv_from_js(context, object);
if (priv == NULL)
return JS_FALSE; /* wrong class passed in */
@@ -544,12 +542,18 @@ to_string_func(JSContext *context,
/* optimization, avoids iconv overhead and runs
* glib's hardwired utf8-to-utf16
*/
- return gjs_string_from_utf8(context,
- (char*) priv->array->data,
- priv->array->len,
- retval);
- } else {
+ jsval retval;
JSBool ok;
+
+ ok = gjs_string_from_utf8(context,
+ (char*) priv->array->data,
+ priv->array->len,
+ &retval);
+ if (ok)
+ JS_SET_RVAL(context, vp, retval);
+ return ok;
+ } else {
+ JSBool ok = JS_FALSE;
gsize bytes_written;
GError *error;
JSString *s;
@@ -577,12 +581,9 @@ to_string_func(JSContext *context,
s = JS_NewUCStringCopyN(context,
(jschar*) u16_str,
bytes_written / 2);
- if (s == NULL) {
- ok = FALSE;
- *retval = JSVAL_VOID;
- } else {
- ok = TRUE;
- *retval = STRING_TO_JSVAL(s);
+ if (s != NULL) {
+ ok = JS_TRUE;
+ JS_SET_RVAL(context, vp, STRING_TO_JSVAL(s));
}
g_free(u16_str);
@@ -591,8 +592,7 @@ to_string_func(JSContext *context,
}
static JSObject*
-byte_array_new(JSContext *context,
- JSObject *module)
+byte_array_new(JSContext *context)
{
JSObject *array;
ByteArrayInstance *priv;
@@ -611,34 +611,31 @@ byte_array_new(JSContext *context,
/* fromString() function implementation */
static JSBool
from_string_func(JSContext *context,
- JSObject *module,
uintN argc,
- jsval *argv,
- jsval *retval)
+ jsval *vp)
{
+ jsval *argv = JS_ARGV(context, vp);
ByteArrayInstance *priv;
const char *encoding;
gboolean encoding_is_utf8;
JSObject *obj;
+ JSBool retval = JS_FALSE;
- *retval = JSVAL_VOID;
-
- obj = byte_array_new(context, module);
+ obj = byte_array_new(context);
if (obj == NULL)
return JS_FALSE;
- *retval = OBJECT_TO_JSVAL(obj); /* side effect: roots obj */
- priv = priv_from_js(context, obj);
+ JS_AddObjectRoot(context, &obj);
- if (priv == NULL)
- return JS_FALSE; /* wrong class passed in */
+ priv = priv_from_js(context, obj);
+ g_assert (priv != NULL);
g_assert(argc > 0); /* because we specified min args 1 */
if (!JSVAL_IS_STRING(argv[0])) {
gjs_throw(context,
"byteArray.fromString() called with non-string as first arg");
- return JS_FALSE;
+ goto out;
}
encoding_is_utf8 = TRUE;
@@ -646,7 +643,7 @@ from_string_func(JSContext *context,
JSVAL_IS_STRING(argv[1])) {
encoding = gjs_string_get_ascii_checked(context, argv[1]);
if (encoding == NULL)
- return JS_FALSE;
+ goto out;
/* maybe we should be smarter about utf8 synonyms here.
* doesn't matter much though. encoding_is_utf8 is
@@ -673,7 +670,7 @@ from_string_func(JSContext *context,
if (!gjs_string_to_utf8(context,
argv[0],
&utf8))
- return JS_FALSE;
+ goto out;
g_byte_array_set_size(priv->array, 0);
g_byte_array_append(priv->array, (guint8*) utf8, strlen(utf8));
@@ -699,7 +696,7 @@ from_string_func(JSContext *context,
if (encoded == NULL) {
/* frees the GError */
gjs_throw_g_error(context, error);
- return JS_FALSE;
+ goto out;
}
g_byte_array_set_size(priv->array, 0);
@@ -707,48 +704,49 @@ from_string_func(JSContext *context,
g_free(encoded);
}
+
+ JS_SET_RVAL(context, vp, OBJECT_TO_JSVAL(obj));
- return JS_TRUE;
+ retval = JS_TRUE;
+ out:
+ JS_RemoveObjectRoot(context, &obj);
+ return retval;
}
/* fromArray() function implementation */
static JSBool
from_array_func(JSContext *context,
- JSObject *module,
uintN argc,
- jsval *argv,
- jsval *retval)
+ jsval *vp)
{
+ jsval *argv = JS_ARGV(context, vp);
ByteArrayInstance *priv;
jsuint len;
jsuint i;
JSObject *obj;
+ JSBool ret = JS_FALSE;
- *retval = JSVAL_VOID;
-
- obj = byte_array_new(context, module);
+ obj = byte_array_new(context);
if (obj == NULL)
return JS_FALSE;
- *retval = OBJECT_TO_JSVAL(obj); /* side effect: roots obj */
+ JS_AddObjectRoot(context, &obj);
priv = priv_from_js(context, obj);
-
- if (priv == NULL)
- return JS_FALSE; /* wrong class passed in */
+ g_assert (priv != NULL);
g_assert(argc > 0); /* because we specified min args 1 */
if (!JS_IsArrayObject(context, JSVAL_TO_OBJECT(argv[0]))) {
gjs_throw(context,
"byteArray.fromArray() called with non-array as first arg");
- return JS_FALSE;
+ goto out;
}
if (!JS_GetArrayLength(context, JSVAL_TO_OBJECT(argv[0]), &len)) {
gjs_throw(context,
"byteArray.fromArray() can't get length of first array arg");
- return JS_FALSE;
+ goto out;
}
g_byte_array_set_size(priv->array, len);
@@ -762,19 +760,23 @@ from_array_func(JSContext *context,
/* this means there was an exception, while elem == JSVAL_VOID
* means no element found
*/
- return JS_FALSE;
+ goto out;
}
if (elem == JSVAL_VOID)
continue;
if (!gjs_value_to_byte(context, elem, &b))
- return JS_FALSE;
+ goto out;
g_array_index(priv->array, guint8, i) = b;
}
- return JS_TRUE;
+ ret = JS_TRUE;
+ JS_SET_RVAL(context, vp, OBJECT_TO_JSVAL(obj));
+ out:
+ JS_RemoveObjectRoot(context, &obj);
+ return ret;
}
JSObject *
@@ -842,13 +844,13 @@ static JSPropertySpec gjs_byte_array_proto_props[] = {
};
static JSFunctionSpec gjs_byte_array_proto_funcs[] = {
- { "toString", to_string_func, 0, 0 },
+ { "toString", (JSNative) to_string_func, 0, JSFUN_FAST_NATIVE },
{ NULL }
};
static JSFunctionSpec gjs_byte_array_module_funcs[] = {
- { "fromString", from_string_func, 1, 0 },
- { "fromArray", from_array_func, 1, 0 },
+ { "fromString", (JSNative)from_string_func, 1, JSFUN_FAST_NATIVE },
+ { "fromArray", (JSNative)from_array_func, 1, JSFUN_FAST_NATIVE },
{ NULL }
};
diff --git a/modules/cairo-context.c b/modules/cairo-context.c
index c5ca1a9..246f826 100644
--- a/modules/cairo-context.c
+++ b/modules/cairo-context.c
@@ -32,11 +32,10 @@
#define _GJS_CAIRO_CONTEXT_DEFINE_FUNC_BEGIN(mname) \
static JSBool \
mname##_func(JSContext *context, \
- JSObject *obj, \
uintN argc, \
- jsval *argv, \
- jsval *retval) \
+ jsval *vp) \
{ \
+ JSObject *obj = JS_THIS_OBJECT(context, vp); \
cairo_t *cr;
#define _GJS_CAIRO_CONTEXT_DEFINE_FUNC_END \
@@ -55,6 +54,7 @@ mname##_func(JSContext *context, \
_GJS_CAIRO_CONTEXT_DEFINE_FUNC_BEGIN(method) \
cr = gjs_cairo_context_get_context(context, obj); \
cfunc(cr); \
+ JS_SET_RVAL(context, vp, JSVAL_VOID); \
_GJS_CAIRO_CONTEXT_DEFINE_FUNC_END
#define _GJS_CAIRO_CONTEXT_DEFINE_FUNC0I(method, cfunc) \
@@ -63,7 +63,7 @@ _GJS_CAIRO_CONTEXT_DEFINE_FUNC_BEGIN(method) \
_GJS_CAIRO_CONTEXT_CHECK_NO_ARGS(method) \
cr = gjs_cairo_context_get_context(context, obj); \
ret = (int)cfunc(cr); \
- *retval = INT_TO_JSVAL(ret); \
+ JS_SET_RVAL(context, vp, INT_TO_JSVAL(ret)); \
_GJS_CAIRO_CONTEXT_DEFINE_FUNC_END
#define _GJS_CAIRO_CONTEXT_DEFINE_FUNC0B(method, cfunc) \
@@ -72,7 +72,7 @@ _GJS_CAIRO_CONTEXT_DEFINE_FUNC_BEGIN(method) \
_GJS_CAIRO_CONTEXT_CHECK_NO_ARGS(method) \
cr = gjs_cairo_context_get_context(context, obj); \
ret = cfunc(cr); \
- *retval = BOOLEAN_TO_JSVAL(ret); \
+ JS_SET_RVAL(context, vp, BOOLEAN_TO_JSVAL(ret)); \
_GJS_CAIRO_CONTEXT_DEFINE_FUNC_END
#define _GJS_CAIRO_CONTEXT_DEFINE_FUNC0AFF(method, cfunc) \
@@ -90,7 +90,7 @@ _GJS_CAIRO_CONTEXT_DEFINE_FUNC_BEGIN(method) \
if (!JS_SetElement(context, array, 0, &r)) return JS_FALSE; \
if (!JS_NewNumberValue(context, arg2, &r)) return JS_FALSE; \
if (!JS_SetElement(context, array, 1, &r)) return JS_FALSE; \
- *retval = OBJECT_TO_JSVAL(array); \
+ JS_SET_RVAL(context, vp, OBJECT_TO_JSVAL(array)); \
} \
_GJS_CAIRO_CONTEXT_DEFINE_FUNC_END
@@ -113,39 +113,43 @@ _GJS_CAIRO_CONTEXT_DEFINE_FUNC_BEGIN(method) \
if (!JS_SetElement(context, array, 2, &r)) return JS_FALSE; \
if (!JS_NewNumberValue(context, arg4, &r)) return JS_FALSE; \
if (!JS_SetElement(context, array, 3, &r)) return JS_FALSE; \
- *retval = OBJECT_TO_JSVAL(array); \
+ JS_SET_RVAL(context, vp, OBJECT_TO_JSVAL(array)); \
} \
_GJS_CAIRO_CONTEXT_DEFINE_FUNC_END
#define _GJS_CAIRO_CONTEXT_DEFINE_FUNC0F(method, cfunc) \
_GJS_CAIRO_CONTEXT_DEFINE_FUNC_BEGIN(method) \
double ret; \
+ jsval retval; \
_GJS_CAIRO_CONTEXT_CHECK_NO_ARGS(method) \
cr = gjs_cairo_context_get_context(context, obj); \
ret = cfunc(cr); \
- if (!JS_NewNumberValue(context, ret, retval)) \
+ if (!JS_NewNumberValue(context, ret, &retval)) \
return JS_FALSE; \
+ JS_SET_RVAL(context, vp, retval); \
_GJS_CAIRO_CONTEXT_DEFINE_FUNC_END
#define _GJS_CAIRO_CONTEXT_DEFINE_FUNC1(method, cfunc, fmt, t1, n1) \
_GJS_CAIRO_CONTEXT_DEFINE_FUNC_BEGIN(method) \
t1 arg1; \
- if (!gjs_parse_args(context, #method, fmt, argc, argv, \
+ if (!gjs_parse_args(context, #method, fmt, argc, JS_ARGV(context, vp), \
#n1, &arg1)) \
return JS_FALSE; \
cr = gjs_cairo_context_get_context(context, obj); \
cfunc(cr, arg1); \
+ JS_SET_RVAL(context, vp, JSVAL_VOID); \
_GJS_CAIRO_CONTEXT_DEFINE_FUNC_END
#define _GJS_CAIRO_CONTEXT_DEFINE_FUNC2(method, cfunc, fmt, t1, n1, t2, n2) \
_GJS_CAIRO_CONTEXT_DEFINE_FUNC_BEGIN(method) \
t1 arg1; \
t2 arg2; \
- if (!gjs_parse_args(context, #method, fmt, argc, argv, \
+ if (!gjs_parse_args(context, #method, fmt, argc, JS_ARGV(context, vp), \
#n1, &arg1, #n2, &arg2)) \
return JS_FALSE; \
cr = gjs_cairo_context_get_context(context, obj); \
cfunc(cr, arg1, arg2); \
+ JS_SET_RVAL(context, vp, JSVAL_VOID); \
_GJS_CAIRO_CONTEXT_DEFINE_FUNC_END
#define _GJS_CAIRO_CONTEXT_DEFINE_FUNC2B(method, cfunc, fmt, t1, n1, t2, n2) \
@@ -153,12 +157,12 @@ _GJS_CAIRO_CONTEXT_DEFINE_FUNC_BEGIN(method) \
t1 arg1; \
t2 arg2; \
cairo_bool_t ret; \
- if (!gjs_parse_args(context, #method, fmt, argc, argv, \
+ if (!gjs_parse_args(context, #method, fmt, argc, JS_ARGV(context, vp), \
#n1, &arg1, #n2, &arg2)) \
return JS_FALSE; \
cr = gjs_cairo_context_get_context(context, obj); \
ret = cfunc(cr, arg1, arg2); \
- *retval = BOOLEAN_TO_JSVAL(ret); \
+ JS_SET_RVAL(context, vp, BOOLEAN_TO_JSVAL(ret)); \
_GJS_CAIRO_CONTEXT_DEFINE_FUNC_END
#define _GJS_CAIRO_CONTEXT_DEFINE_FUNC3(method, cfunc, fmt, t1, n1, t2, n2, t3, n3) \
@@ -166,11 +170,12 @@ _GJS_CAIRO_CONTEXT_DEFINE_FUNC_BEGIN(method) \
t1 arg1; \
t2 arg2; \
t3 arg3; \
- if (!gjs_parse_args(context, #method, fmt, argc, argv, \
+ if (!gjs_parse_args(context, #method, fmt, argc, JS_ARGV(context, vp), \
#n1, &arg1, #n2, &arg2, #n3, &arg3)) \
return JS_FALSE; \
cr = gjs_cairo_context_get_context(context, obj); \
cfunc(cr, arg1, arg2, arg3); \
+ JS_SET_RVAL(context, vp, JSVAL_VOID); \
_GJS_CAIRO_CONTEXT_DEFINE_FUNC_END
#define _GJS_CAIRO_CONTEXT_DEFINE_FUNC4(method, cfunc, fmt, t1, n1, t2, n2, t3, n3, t4, n4) \
@@ -179,7 +184,7 @@ _GJS_CAIRO_CONTEXT_DEFINE_FUNC_BEGIN(method) \
t2 arg2; \
t3 arg3; \
t4 arg4; \
- if (!gjs_parse_args(context, #method, fmt, argc, argv, \
+ if (!gjs_parse_args(context, #method, fmt, argc, JS_ARGV(context, vp), \
#n1, &arg1, #n2, &arg2, #n3, &arg3, #n4, &arg4)) \
return JS_FALSE; \
cr = gjs_cairo_context_get_context(context, obj); \
@@ -193,12 +198,13 @@ _GJS_CAIRO_CONTEXT_DEFINE_FUNC_BEGIN(method) \
t3 arg3; \
t4 arg4; \
t5 arg5; \
- if (!gjs_parse_args(context, #method, fmt, argc, argv, \
+ if (!gjs_parse_args(context, #method, fmt, argc, JS_ARGV(context, vp), \
#n1, &arg1, #n2, &arg2, #n3, &arg3, \
#n4, &arg4, #n5, &arg5)) \
return JS_FALSE; \
cr = gjs_cairo_context_get_context(context, obj); \
cfunc(cr, arg1, arg2, arg3, arg4, arg5); \
+ JS_SET_RVAL(context, vp, JSVAL_VOID); \
_GJS_CAIRO_CONTEXT_DEFINE_FUNC_END
#define _GJS_CAIRO_CONTEXT_DEFINE_FUNC6(method, cfunc, fmt, t1, n1, t2, n2, t3, n3, t4, n4, t5, n5, t6, n6) \
@@ -209,12 +215,13 @@ _GJS_CAIRO_CONTEXT_DEFINE_FUNC_BEGIN(method) \
t4 arg4; \
t5 arg5; \
t6 arg6; \
- if (!gjs_parse_args(context, #method, fmt, argc, argv, \
+ if (!gjs_parse_args(context, #method, fmt, argc, JS_ARGV(context, vp), \
#n1, &arg1, #n2, &arg2, #n3, &arg3, \
#n4, &arg4, #n5, &arg5, #n6, &arg6)) \
return JS_FALSE; \
cr = gjs_cairo_context_get_context(context, obj); \
cfunc(cr, arg1, arg2, arg3, arg4, arg5, arg6); \
+ JS_SET_RVAL(context, vp, JSVAL_VOID); \
_GJS_CAIRO_CONTEXT_DEFINE_FUNC_END
typedef struct {
@@ -379,11 +386,11 @@ _GJS_CAIRO_CONTEXT_DEFINE_FUNC0AFF(userToDeviceDistance, cairo_user_to_device_di
static JSBool
appendPath_func(JSContext *context,
- JSObject *obj,
uintN argc,
- jsval *argv,
- jsval *retval)
+ jsval *vp)
{
+ jsval *argv = JS_ARGV(context, vp);
+ JSObject *obj = JS_THIS_OBJECT(context, vp);
JSObject *path_wrapper;
cairo_path_t *path;
cairo_t *cr;
@@ -400,17 +407,17 @@ appendPath_func(JSContext *context,
cr = gjs_cairo_context_get_context(context, obj);
cairo_append_path(cr, path);
- *retval = JSVAL_VOID;
+ JS_SET_RVAL(context, vp, JSVAL_VOID);
return JS_TRUE;
}
static JSBool
copyPath_func(JSContext *context,
- JSObject *obj,
uintN argc,
- jsval *argv,
- jsval *retval)
+ jsval *vp)
{
+ jsval *argv = JS_ARGV(context, vp);
+ JSObject *obj = JS_THIS_OBJECT(context, vp);
cairo_path_t *path;
cairo_t *cr;
@@ -419,17 +426,18 @@ copyPath_func(JSContext *context,
cr = gjs_cairo_context_get_context(context, obj);
path = cairo_copy_path(cr);
- *retval = OBJECT_TO_JSVAL(gjs_cairo_path_from_path(context, path));
+ JS_SET_RVAL(context, vp,
+ OBJECT_TO_JSVAL(gjs_cairo_path_from_path(context, path)));
return JS_TRUE;
}
static JSBool
copyPathFlat_func(JSContext *context,
- JSObject *obj,
uintN argc,
- jsval *argv,
- jsval *retval)
+ jsval *vp)
{
+ jsval *argv = JS_ARGV(context, vp);
+ JSObject *obj = JS_THIS_OBJECT(context, vp);
cairo_path_t *path;
cairo_t *cr;
@@ -438,17 +446,17 @@ copyPathFlat_func(JSContext *context,
cr = gjs_cairo_context_get_context(context, obj);
path = cairo_copy_path_flat(cr);
- *retval = OBJECT_TO_JSVAL(gjs_cairo_path_from_path(context, path));
+ JS_SET_RVAL(context, vp, OBJECT_TO_JSVAL(gjs_cairo_path_from_path(context, path)));
return JS_TRUE;
}
static JSBool
mask_func(JSContext *context,
- JSObject *obj,
uintN argc,
- jsval *argv,
- jsval *retval)
+ jsval *vp)
{
+ jsval *argv = JS_ARGV(context, vp);
+ JSObject *obj = JS_THIS_OBJECT(context, vp);
JSObject *pattern_wrapper;
cairo_pattern_t *pattern;
cairo_t *cr;
@@ -469,16 +477,17 @@ mask_func(JSContext *context,
if (!gjs_cairo_check_status(context, cairo_status(cr), "context"))
return JS_FALSE;
+ JS_SET_RVAL(context, vp, JSVAL_VOID);
return JS_TRUE;
}
static JSBool
maskSurface_func(JSContext *context,
- JSObject *obj,
uintN argc,
- jsval *argv,
- jsval *retval)
+ jsval *vp)
{
+ jsval *argv = JS_ARGV(context, vp);
+ JSObject *obj = JS_THIS_OBJECT(context, vp);
JSObject *surface_wrapper;
double x, y;
cairo_surface_t *surface;
@@ -503,16 +512,17 @@ maskSurface_func(JSContext *context,
if (!gjs_cairo_check_status(context, cairo_status(cr), "context"))
return JS_FALSE;
+ JS_SET_RVAL(context, vp, JSVAL_VOID);
return JS_TRUE;
}
static JSBool
setSource_func(JSContext *context,
- JSObject *obj,
uintN argc,
- jsval *argv,
- jsval *retval)
+ jsval *vp)
{
+ jsval *argv = JS_ARGV(context, vp);
+ JSObject *obj = JS_THIS_OBJECT(context, vp);
JSObject *pattern_wrapper;
cairo_pattern_t *pattern;
cairo_t *cr;
@@ -534,16 +544,18 @@ setSource_func(JSContext *context,
if (!gjs_cairo_check_status(context, cairo_status(cr), "context"))
return JS_FALSE;
+ JS_SET_RVAL(context, vp, JSVAL_VOID);
+
return JS_TRUE;
}
static JSBool
setSourceSurface_func(JSContext *context,
- JSObject *obj,
uintN argc,
- jsval *argv,
- jsval *retval)
+ jsval *vp)
{
+ jsval *argv = JS_ARGV(context, vp);
+ JSObject *obj = JS_THIS_OBJECT(context, vp);
JSObject *surface_wrapper;
double x, y;
cairo_surface_t *surface;
@@ -568,16 +580,18 @@ setSourceSurface_func(JSContext *context,
if (!gjs_cairo_check_status(context, cairo_status(cr), "context"))
return JS_FALSE;
+ JS_SET_RVAL(context, vp, JSVAL_VOID);
+
return JS_TRUE;
}
static JSBool
showText_func(JSContext *context,
- JSObject *obj,
uintN argc,
- jsval *argv,
- jsval *retval)
+ jsval *vp)
{
+ jsval *argv = JS_ARGV(context, vp);
+ JSObject *obj = JS_THIS_OBJECT(context, vp);
char *utf8;
cairo_t *cr;
@@ -593,16 +607,18 @@ showText_func(JSContext *context,
if (!gjs_cairo_check_status(context, cairo_status(cr), "context"))
return JS_FALSE;
+ JS_SET_RVAL(context, vp, JSVAL_VOID);
+
return JS_TRUE;
}
static JSBool
selectFontFace_func(JSContext *context,
- JSObject *obj,
uintN argc,
- jsval *argv,
- jsval *retval)
+ jsval *vp)
{
+ jsval *argv = JS_ARGV(context, vp);
+ JSObject *obj = JS_THIS_OBJECT(context, vp);
char *family;
cairo_font_slant_t slant;
cairo_font_weight_t weight;
@@ -621,17 +637,17 @@ selectFontFace_func(JSContext *context,
if (!gjs_cairo_check_status(context, cairo_status(cr), "context"))
return JS_FALSE;
+ JS_SET_RVAL(context, vp, JSVAL_VOID);
return JS_TRUE;
}
static JSBool
popGroup_func(JSContext *context,
- JSObject *obj,
uintN argc,
- jsval *argv,
- jsval *retval)
+ jsval *vp)
{
+ JSObject *obj = JS_THIS_OBJECT(context, vp);
cairo_t *cr;
cairo_pattern_t *pattern;
JSObject *pattern_wrapper;
@@ -653,17 +669,16 @@ popGroup_func(JSContext *context,
return JS_FALSE;
}
- *retval = OBJECT_TO_JSVAL(pattern_wrapper);
+ JS_SET_RVAL(context, vp, OBJECT_TO_JSVAL(pattern_wrapper));
return JS_TRUE;
}
static JSBool
getSource_func(JSContext *context,
- JSObject *obj,
uintN argc,
- jsval *argv,
- jsval *retval)
+ jsval *vp)
{
+ JSObject *obj = JS_THIS_OBJECT(context, vp);
cairo_t *cr;
cairo_pattern_t *pattern;
JSObject *pattern_wrapper;
@@ -685,18 +700,17 @@ getSource_func(JSContext *context,
return JS_FALSE;
}
- *retval = OBJECT_TO_JSVAL(pattern_wrapper);
+ JS_SET_RVAL(context, vp, OBJECT_TO_JSVAL(pattern_wrapper));
return JS_TRUE;
}
static JSBool
getTarget_func(JSContext *context,
- JSObject *obj,
uintN argc,
- jsval *argv,
- jsval *retval)
+ jsval *vp)
{
+ JSObject *obj = JS_THIS_OBJECT(context, vp);
cairo_t *cr;
cairo_surface_t *surface;
JSObject *surface_wrapper;
@@ -718,18 +732,17 @@ getTarget_func(JSContext *context,
return JS_FALSE;
}
- *retval = OBJECT_TO_JSVAL(surface_wrapper);
+ JS_SET_RVAL(context, vp, OBJECT_TO_JSVAL(surface_wrapper));
return JS_TRUE;
}
static JSBool
getGroupTarget_func(JSContext *context,
- JSObject *obj,
uintN argc,
- jsval *argv,
- jsval *retval)
+ jsval *vp)
{
+ JSObject *obj = JS_THIS_OBJECT(context, vp);
cairo_t *cr;
cairo_surface_t *surface;
JSObject *surface_wrapper;
@@ -751,109 +764,109 @@ getGroupTarget_func(JSContext *context,
return JS_FALSE;
}
- *retval = OBJECT_TO_JSVAL(surface_wrapper);
+ JS_SET_RVAL(context, vp, OBJECT_TO_JSVAL(surface_wrapper));
return JS_TRUE;
}
static JSFunctionSpec gjs_cairo_context_proto_funcs[] = {
- { "appendPath", appendPath_func, 0, 0},
- { "arc", arc_func, 0, 0 },
- { "arcNegative", arcNegative_func, 0, 0 },
- { "clip", clip_func, 0, 0 },
- { "clipExtents", clipExtents_func, 0, 0 },
- { "clipPreserve", clipPreserve_func, 0, 0 },
- { "closePath", closePath_func, 0, 0 },
- { "copyPage", copyPage_func, 0, 0 },
- { "copyPath", copyPath_func, 0, 0 },
- { "copyPathFlat", copyPathFlat_func, 0, 0 },
- { "curveTo", curveTo_func, 0, 0 },
- { "deviceToUser", deviceToUser_func, 0, 0 },
- { "deviceToUserDistance", deviceToUserDistance_func, 0, 0 },
- { "fill", fill_func, 0, 0 },
- { "fillPreserve", fillPreserve_func, 0, 0 },
- { "fillExtents", fillExtents_func, 0, 0 },
+ { "appendPath", (JSNative)appendPath_func, 0, JSFUN_FAST_NATIVE},
+ { "arc", (JSNative)arc_func, 0, JSFUN_FAST_NATIVE },
+ { "arcNegative", (JSNative)arcNegative_func, 0, JSFUN_FAST_NATIVE },
+ { "clip", (JSNative)clip_func, 0, JSFUN_FAST_NATIVE },
+ { "clipExtents", (JSNative)clipExtents_func, 0, JSFUN_FAST_NATIVE },
+ { "clipPreserve", (JSNative)clipPreserve_func, 0, JSFUN_FAST_NATIVE },
+ { "closePath", (JSNative)closePath_func, 0, JSFUN_FAST_NATIVE },
+ { "copyPage", (JSNative)copyPage_func, 0, JSFUN_FAST_NATIVE },
+ { "copyPath", (JSNative)copyPath_func, 0, JSFUN_FAST_NATIVE },
+ { "copyPathFlat", (JSNative)copyPathFlat_func, 0, JSFUN_FAST_NATIVE },
+ { "curveTo", (JSNative)curveTo_func, 0, JSFUN_FAST_NATIVE },
+ { "deviceToUser", (JSNative)deviceToUser_func, 0, JSFUN_FAST_NATIVE },
+ { "deviceToUserDistance", (JSNative)deviceToUserDistance_func, 0, JSFUN_FAST_NATIVE },
+ { "fill", (JSNative)fill_func, 0, JSFUN_FAST_NATIVE },
+ { "fillPreserve", (JSNative)fillPreserve_func, 0, JSFUN_FAST_NATIVE },
+ { "fillExtents", (JSNative)fillExtents_func, 0, JSFUN_FAST_NATIVE },
// fontExtents
- { "getAntialias", getAntialias_func, 0, 0 },
- { "getCurrentPoint", getCurrentPoint_func, 0, 0 },
+ { "getAntialias", (JSNative)getAntialias_func, 0, JSFUN_FAST_NATIVE },
+ { "getCurrentPoint", (JSNative)getCurrentPoint_func, 0, JSFUN_FAST_NATIVE },
// getDash
- { "getDashCount", getDashCount_func, 0, 0 },
- { "getFillRule", getFillRule_func, 0, 0 },
+ { "getDashCount", (JSNative)getDashCount_func, 0, JSFUN_FAST_NATIVE },
+ { "getFillRule", (JSNative)getFillRule_func, 0, JSFUN_FAST_NATIVE },
// getFontFace
// getFontMatrix
// getFontOptions
- { "getGroupTarget", getGroupTarget_func, 0, 0 },
- { "getLineCap", getLineCap_func, 0, 0 },
- { "getLineJoin", getLineJoin_func, 0, 0 },
- { "getLineWidth", getLineWidth_func, 0, 0 },
+ { "getGroupTarget", (JSNative)getGroupTarget_func, 0, JSFUN_FAST_NATIVE },
+ { "getLineCap", (JSNative)getLineCap_func, 0, JSFUN_FAST_NATIVE },
+ { "getLineJoin", (JSNative)getLineJoin_func, 0, JSFUN_FAST_NATIVE },
+ { "getLineWidth", (JSNative)getLineWidth_func, 0, JSFUN_FAST_NATIVE },
// getMatrix
- { "getMiterLimit", getMiterLimit_func, 0, 0 },
- { "getOperator", getOperator_func, 0, 0 },
+ { "getMiterLimit", (JSNative)getMiterLimit_func, 0, JSFUN_FAST_NATIVE },
+ { "getOperator", (JSNative)getOperator_func, 0, JSFUN_FAST_NATIVE },
// getScaledFont
- { "getSource", getSource_func, 0, 0 },
- { "getTarget", getTarget_func, 0, 0 },
- { "getTolerance", getTolerance_func, 0, 0 },
+ { "getSource", (JSNative)getSource_func, 0, JSFUN_FAST_NATIVE },
+ { "getTarget", (JSNative)getTarget_func, 0, JSFUN_FAST_NATIVE },
+ { "getTolerance", (JSNative)getTolerance_func, 0, JSFUN_FAST_NATIVE },
// glyphPath
// glyphExtents
- { "hasCurrentPoint", hasCurrentPoint_func, 0, 0 },
- { "identityMatrix", identityMatrix_func, 0, 0 },
- { "inFill", inFill_func, 0, 0 },
- { "inStroke", inStroke_func, 0, 0 },
- { "lineTo", lineTo_func, 0, 0 },
- { "mask", mask_func, 0, 0 },
- { "maskSurface", maskSurface_func, 0, 0 },
- { "moveTo", moveTo_func, 0, 0 },
- { "newPath", newPath_func, 0, 0 },
- { "newSubPath", newSubPath_func, 0, 0 },
- { "paint", paint_func, 0, 0 },
- { "paintWithAlpha", paintWithAlpha_func, 0, 0 },
- { "pathExtents", pathExtents_func, 0, 0 },
- { "popGroup", popGroup_func, 0, 0 },
- { "popGroupToSource", popGroupToSource_func, 0, 0 },
- { "pushGroup", pushGroup_func, 0, 0 },
- { "pushGroupWithContent", pushGroupWithContent_func, 0, 0 },
- { "rectangle", rectangle_func, 0, 0 },
- { "relCurveTo", relCurveTo_func, 0, 0 },
- { "relLineTo", relLineTo_func, 0, 0 },
- { "relMoveTo", relMoveTo_func, 0, 0 },
- { "resetClip", resetClip_func, 0, 0 },
- { "restore", restore_func, 0, 0 },
- { "rotate", rotate_func, 0, 0 },
- { "save", save_func, 0, 0 },
- { "scale", scale_func, 0, 0 },
- { "selectFontFace", selectFontFace_func, 0, 0 },
- { "setAntialias", setAntialias_func, 0, 0 },
+ { "hasCurrentPoint", (JSNative)hasCurrentPoint_func, 0, JSFUN_FAST_NATIVE },
+ { "identityMatrix", (JSNative)identityMatrix_func, 0, JSFUN_FAST_NATIVE },
+ { "inFill", (JSNative)inFill_func, 0, JSFUN_FAST_NATIVE },
+ { "inStroke", (JSNative)inStroke_func, 0, JSFUN_FAST_NATIVE },
+ { "lineTo", (JSNative)lineTo_func, 0, JSFUN_FAST_NATIVE },
+ { "mask", (JSNative)mask_func, 0, JSFUN_FAST_NATIVE },
+ { "maskSurface", (JSNative)maskSurface_func, 0, JSFUN_FAST_NATIVE },
+ { "moveTo", (JSNative)moveTo_func, 0, JSFUN_FAST_NATIVE },
+ { "newPath", (JSNative)newPath_func, 0, JSFUN_FAST_NATIVE },
+ { "newSubPath", (JSNative)newSubPath_func, 0, JSFUN_FAST_NATIVE },
+ { "paint", (JSNative)paint_func, 0, JSFUN_FAST_NATIVE },
+ { "paintWithAlpha", (JSNative)paintWithAlpha_func, 0, JSFUN_FAST_NATIVE },
+ { "pathExtents", (JSNative)pathExtents_func, 0, JSFUN_FAST_NATIVE },
+ { "popGroup", (JSNative)popGroup_func, 0, JSFUN_FAST_NATIVE },
+ { "popGroupToSource", (JSNative)popGroupToSource_func, 0, JSFUN_FAST_NATIVE },
+ { "pushGroup", (JSNative)pushGroup_func, 0, JSFUN_FAST_NATIVE },
+ { "pushGroupWithContent", (JSNative)pushGroupWithContent_func, 0, JSFUN_FAST_NATIVE },
+ { "rectangle", (JSNative)rectangle_func, 0, JSFUN_FAST_NATIVE },
+ { "relCurveTo", (JSNative)relCurveTo_func, 0, JSFUN_FAST_NATIVE },
+ { "relLineTo", (JSNative)relLineTo_func, 0, JSFUN_FAST_NATIVE },
+ { "relMoveTo", (JSNative)relMoveTo_func, 0, JSFUN_FAST_NATIVE },
+ { "resetClip", (JSNative)resetClip_func, 0, JSFUN_FAST_NATIVE },
+ { "restore", (JSNative)restore_func, 0, JSFUN_FAST_NATIVE },
+ { "rotate", (JSNative)rotate_func, 0, JSFUN_FAST_NATIVE },
+ { "save", (JSNative)save_func, 0, JSFUN_FAST_NATIVE },
+ { "scale", (JSNative)scale_func, 0, JSFUN_FAST_NATIVE },
+ { "selectFontFace", (JSNative)selectFontFace_func, 0, JSFUN_FAST_NATIVE },
+ { "setAntialias", (JSNative)setAntialias_func, 0, JSFUN_FAST_NATIVE },
// setDash
// setFontFace
// setFontMatrix
// setFontOptions
- { "setFontSize", setFontSize_func, 0, 0 },
- { "setFillRule", setFillRule_func, 0, 0 },
- { "setLineCap", setLineCap_func, 0, 0 },
- { "setLineJoin", setLineJoin_func, 0, 0 },
- { "setLineWidth", setLineWidth_func, 0, 0 },
+ { "setFontSize", (JSNative)setFontSize_func, 0, JSFUN_FAST_NATIVE },
+ { "setFillRule", (JSNative)setFillRule_func, 0, JSFUN_FAST_NATIVE },
+ { "setLineCap", (JSNative)setLineCap_func, 0, JSFUN_FAST_NATIVE },
+ { "setLineJoin", (JSNative)setLineJoin_func, 0, JSFUN_FAST_NATIVE },
+ { "setLineWidth", (JSNative)setLineWidth_func, 0, JSFUN_FAST_NATIVE },
// setMatrix
- { "setMiterLimit", setMiterLimit_func, 0, 0 },
- { "setOperator", setOperator_func, 0, 0 },
+ { "setMiterLimit", (JSNative)setMiterLimit_func, 0, JSFUN_FAST_NATIVE },
+ { "setOperator", (JSNative)setOperator_func, 0, JSFUN_FAST_NATIVE },
// setScaledFont
- { "setSource", setSource_func, 0, 0 },
- { "setSourceRGB", setSourceRGB_func, 0, 0 },
- { "setSourceRGBA", setSourceRGBA_func, 0, 0 },
- { "setSourceSurface", setSourceSurface_func, 0, 0 },
- { "setTolerance", setTolerance_func, 0, 0 },
+ { "setSource", (JSNative)setSource_func, 0, JSFUN_FAST_NATIVE },
+ { "setSourceRGB", (JSNative)setSourceRGB_func, 0, JSFUN_FAST_NATIVE },
+ { "setSourceRGBA", (JSNative)setSourceRGBA_func, 0, JSFUN_FAST_NATIVE },
+ { "setSourceSurface", (JSNative)setSourceSurface_func, 0, JSFUN_FAST_NATIVE },
+ { "setTolerance", (JSNative)setTolerance_func, 0, JSFUN_FAST_NATIVE },
// showGlyphs
- { "showPage", showPage_func, 0, 0 },
- { "showText", showText_func, 0, 0 },
+ { "showPage", (JSNative)showPage_func, 0, JSFUN_FAST_NATIVE },
+ { "showText", (JSNative)showText_func, 0, JSFUN_FAST_NATIVE },
// showTextGlyphs
- { "stroke", stroke_func, 0, 0 },
- { "strokeExtents", strokeExtents_func, 0, 0 },
- { "strokePreserve", strokePreserve_func, 0, 0 },
+ { "stroke", (JSNative)stroke_func, 0, JSFUN_FAST_NATIVE },
+ { "strokeExtents", (JSNative)strokeExtents_func, 0, JSFUN_FAST_NATIVE },
+ { "strokePreserve", (JSNative)strokePreserve_func, 0, JSFUN_FAST_NATIVE },
// textPath
// textExtends
// transform
- { "translate", translate_func, 0, 0 },
- { "userToDevice", userToDevice_func, 0, 0 },
- { "userToDeviceDistance", userToDeviceDistance_func, 0, 0 },
+ { "translate", (JSNative)translate_func, 0, JSFUN_FAST_NATIVE },
+ { "userToDevice", (JSNative)userToDevice_func, 0, JSFUN_FAST_NATIVE },
+ { "userToDeviceDistance", (JSNative)userToDeviceDistance_func, 0, JSFUN_FAST_NATIVE },
{ NULL }
};
diff --git a/modules/cairo-gradient.c b/modules/cairo-gradient.c
index dd89ae8..c752ddb 100644
--- a/modules/cairo-gradient.c
+++ b/modules/cairo-gradient.c
@@ -45,11 +45,11 @@ static JSPropertySpec gjs_cairo_gradient_proto_props[] = {
static JSBool
addColorStopRGB_func(JSContext *context,
- JSObject *object,
uintN argc,
- jsval *argv,
- jsval *retval)
+ jsval *vp)
{
+ jsval *argv = JS_ARGV(context, vp);
+ JSObject *obj = JS_THIS_OBJECT(context, vp);
double offset, red, green, blue;
cairo_pattern_t *pattern;
@@ -60,23 +60,24 @@ addColorStopRGB_func(JSContext *context,
"blue", &blue))
return JS_FALSE;
- pattern = gjs_cairo_pattern_get_pattern(context, object);
+ pattern = gjs_cairo_pattern_get_pattern(context, obj);
cairo_pattern_add_color_stop_rgb(pattern, offset, red, green, blue);
if (!gjs_cairo_check_status(context, cairo_pattern_status(pattern), "pattern"))
return JS_FALSE;
+ JS_SET_RVAL(context, vp, JSVAL_VOID);
return JS_TRUE;
}
static JSBool
addColorStopRGBA_func(JSContext *context,
- JSObject *object,
uintN argc,
- jsval *argv,
- jsval *retval)
+ jsval *vp)
{
+ jsval *argv = JS_ARGV(context, vp);
+ JSObject *obj = JS_THIS_OBJECT(context, vp);
double offset, red, green, blue, alpha;
cairo_pattern_t *pattern;
@@ -88,18 +89,19 @@ addColorStopRGBA_func(JSContext *context,
"alpha", &alpha))
return JS_FALSE;
- pattern = gjs_cairo_pattern_get_pattern(context, object);
+ pattern = gjs_cairo_pattern_get_pattern(context, obj);
cairo_pattern_add_color_stop_rgba(pattern, offset, red, green, blue, alpha);
if (!gjs_cairo_check_status(context, cairo_pattern_status(pattern), "pattern"))
return JS_FALSE;
+ JS_SET_RVAL(context, vp, JSVAL_VOID);
return JS_TRUE;
}
static JSFunctionSpec gjs_cairo_gradient_proto_funcs[] = {
- { "addColorStopRGB", addColorStopRGB_func, 0, 0 },
- { "addColorStopRGBA", addColorStopRGBA_func, 0, 0 },
+ { "addColorStopRGB", (JSNative)addColorStopRGB_func, 0, JSFUN_FAST_NATIVE },
+ { "addColorStopRGBA", (JSNative)addColorStopRGBA_func, 0, JSFUN_FAST_NATIVE },
// getColorStopRGB
// getColorStopRGBA
{ NULL }
diff --git a/modules/cairo-image-surface.c b/modules/cairo-image-surface.c
index c69e1ce..6972a4c 100644
--- a/modules/cairo-image-surface.c
+++ b/modules/cairo-image-surface.c
@@ -73,11 +73,10 @@ static JSPropertySpec gjs_cairo_image_surface_proto_props[] = {
static JSBool
createFromPNG_func(JSContext *context,
- JSObject *obj,
uintN argc,
- jsval *argv,
- jsval *retval)
+ jsval *vp)
{
+ jsval *argv = JS_ARGV(context, vp);
char *filename;
cairo_surface_t *surface;
JSObject *surface_wrapper;
@@ -99,12 +98,12 @@ createFromPNG_func(JSContext *context,
gjs_cairo_surface_construct(context, surface_wrapper, surface);
cairo_surface_destroy(surface);
- *retval = OBJECT_TO_JSVAL(surface_wrapper);
+ JS_SET_RVAL(context, vp, OBJECT_TO_JSVAL(surface_wrapper));
return JS_TRUE;
}
static JSFunctionSpec gjs_cairo_image_surface_proto_funcs[] = {
- { "createFromPNG", createFromPNG_func, 0, 0},
+ { "createFromPNG", (JSNative)createFromPNG_func, 0, JSFUN_FAST_NATIVE},
// getData
// getFormat
// getWidth
@@ -140,7 +139,7 @@ gjs_cairo_image_surface_init(JSContext *context, JSObject *module_obj)
if (!JS_DefineFunction(context, module_obj,
"createFromPNG",
- createFromPNG_func,
- 1, GJS_MODULE_PROP_FLAGS))
+ (JSNative)createFromPNG_func,
+ 1, GJS_MODULE_PROP_FLAGS | JSFUN_FAST_NATIVE))
return;
}
diff --git a/modules/cairo-pattern.c b/modules/cairo-pattern.c
index d459bcb..ef2d2aa 100644
--- a/modules/cairo-pattern.c
+++ b/modules/cairo-pattern.c
@@ -59,11 +59,10 @@ static JSPropertySpec gjs_cairo_pattern_proto_props[] = {
static JSBool
getType_func(JSContext *context,
- JSObject *object,
uintN argc,
- jsval *argv,
- jsval *retval)
+ jsval *vp)
{
+ JSObject *obj = JS_THIS_OBJECT(context, vp);
cairo_pattern_t *pattern;
cairo_pattern_type_t type;
@@ -72,19 +71,19 @@ getType_func(JSContext *context,
return JS_FALSE;
}
- pattern = gjs_cairo_pattern_get_pattern(context, object);
+ pattern = gjs_cairo_pattern_get_pattern(context, obj);
type = cairo_pattern_get_type(pattern);
if (!gjs_cairo_check_status(context, cairo_pattern_status(pattern), "pattern"))
return JS_FALSE;
- *retval = INT_TO_JSVAL(type);
+ JS_SET_RVAL(context, vp, INT_TO_JSVAL(type));
return JS_TRUE;
}
static JSFunctionSpec gjs_cairo_pattern_proto_funcs[] = {
// getMatrix
- { "getType", getType_func, 0, 0 },
+ { "getType", (JSNative)getType_func, 0, JSFUN_FAST_NATIVE },
// setMatrix
{ NULL }
};
diff --git a/modules/cairo-solid-pattern.c b/modules/cairo-solid-pattern.c
index 1c1478c..c93442d 100644
--- a/modules/cairo-solid-pattern.c
+++ b/modules/cairo-solid-pattern.c
@@ -42,11 +42,10 @@ static JSPropertySpec gjs_cairo_solid_pattern_proto_props[] = {
static JSBool
createRGB_func(JSContext *context,
- JSObject *object,
uintN argc,
- jsval *argv,
- jsval *retval)
+ jsval *vp)
{
+ jsval *argv = JS_ARGV(context, vp);
double red, green, blue;
cairo_pattern_t *pattern;
JSObject *pattern_wrapper;
@@ -64,18 +63,17 @@ createRGB_func(JSContext *context,
pattern_wrapper = gjs_cairo_solid_pattern_from_pattern(context, pattern);
cairo_pattern_destroy(pattern);
- *retval = OBJECT_TO_JSVAL(pattern_wrapper);
+ JS_SET_RVAL(context, vp, OBJECT_TO_JSVAL(pattern_wrapper));
return JS_TRUE;
}
static JSBool
createRGBA_func(JSContext *context,
- JSObject *object,
uintN argc,
- jsval *argv,
- jsval *retval)
+ jsval *vp)
{
+ jsval *argv = JS_ARGV(context, vp);
double red, green, blue, alpha;
cairo_pattern_t *pattern;
JSObject *pattern_wrapper;
@@ -94,14 +92,14 @@ createRGBA_func(JSContext *context,
pattern_wrapper = gjs_cairo_solid_pattern_from_pattern(context, pattern);
cairo_pattern_destroy(pattern);
- *retval = OBJECT_TO_JSVAL(pattern_wrapper);
+ JS_SET_RVAL(context, vp, OBJECT_TO_JSVAL(pattern_wrapper));
return JS_TRUE;
}
static JSFunctionSpec gjs_cairo_solid_pattern_proto_funcs[] = {
- { "createRGB", createRGB_func, 0, 0 },
- { "createRGBA", createRGBA_func, 0, 0 },
+ { "createRGB", (JSNative)createRGB_func, 0, JSFUN_FAST_NATIVE },
+ { "createRGBA", (JSNative)createRGBA_func, 0, JSFUN_FAST_NATIVE },
{ NULL }
};
diff --git a/modules/cairo-surface-pattern.c b/modules/cairo-surface-pattern.c
index 47f36c4..e43aa6b 100644
--- a/modules/cairo-surface-pattern.c
+++ b/modules/cairo-surface-pattern.c
@@ -79,11 +79,11 @@ static JSPropertySpec gjs_cairo_surface_pattern_proto_props[] = {
static JSBool
setExtend_func(JSContext *context,
- JSObject *object,
uintN argc,
- jsval *argv,
- jsval *retval)
+ jsval *vp)
{
+ jsval *argv = JS_ARGV(context, vp);
+ JSObject *obj = JS_THIS_OBJECT(context, vp);
cairo_extend_t extend;
cairo_pattern_t *pattern;
@@ -91,22 +91,22 @@ setExtend_func(JSContext *context,
"extend", &extend))
return JS_FALSE;
- pattern = gjs_cairo_pattern_get_pattern(context, object);
+ pattern = gjs_cairo_pattern_get_pattern(context, obj);
cairo_pattern_set_extend(pattern, extend);
if (!gjs_cairo_check_status(context, cairo_pattern_status(pattern), "pattern"))
return JS_FALSE;
+ JS_SET_RVAL(context, vp, JSVAL_VOID);
return JS_TRUE;
}
static JSBool
getExtend_func(JSContext *context,
- JSObject *object,
uintN argc,
- jsval *argv,
- jsval *retval)
+ jsval *vp)
{
+ JSObject *obj = JS_THIS_OBJECT(context, vp);
cairo_extend_t extend;
cairo_pattern_t *pattern;
@@ -115,24 +115,24 @@ getExtend_func(JSContext *context,
return JS_FALSE;
}
- pattern = gjs_cairo_pattern_get_pattern(context, object);
+ pattern = gjs_cairo_pattern_get_pattern(context, obj);
extend = cairo_pattern_get_extend(pattern);
if (!gjs_cairo_check_status(context, cairo_pattern_status(pattern), "pattern"))
return JS_FALSE;
- *retval = INT_TO_JSVAL(extend);
+ JS_SET_RVAL(context, vp, INT_TO_JSVAL(extend));
return JS_TRUE;
}
static JSBool
setFilter_func(JSContext *context,
- JSObject *object,
uintN argc,
- jsval *argv,
- jsval *retval)
+ jsval *vp)
{
+ jsval *argv = JS_ARGV(context, vp);
+ JSObject *obj = JS_THIS_OBJECT(context, vp);
cairo_filter_t filter;
cairo_pattern_t *pattern;
@@ -140,22 +140,22 @@ setFilter_func(JSContext *context,
"filter", &filter))
return JS_FALSE;
- pattern = gjs_cairo_pattern_get_pattern(context, object);
+ pattern = gjs_cairo_pattern_get_pattern(context, obj);
cairo_pattern_set_filter(pattern, filter);
if (!gjs_cairo_check_status(context, cairo_pattern_status(pattern), "pattern"))
return JS_FALSE;
+ JS_SET_RVAL(context, vp, JSVAL_VOID);
return JS_TRUE;
}
static JSBool
getFilter_func(JSContext *context,
- JSObject *object,
uintN argc,
- jsval *argv,
- jsval *retval)
+ jsval *vp)
{
+ JSObject *obj = JS_THIS_OBJECT(context, vp);
cairo_filter_t filter;
cairo_pattern_t *pattern;
@@ -164,22 +164,22 @@ getFilter_func(JSContext *context,
return JS_FALSE;
}
- pattern = gjs_cairo_pattern_get_pattern(context, object);
+ pattern = gjs_cairo_pattern_get_pattern(context, obj);
filter = cairo_pattern_get_filter(pattern);
if (!gjs_cairo_check_status(context, cairo_pattern_status(pattern), "pattern"))
return JS_FALSE;
- *retval = INT_TO_JSVAL(filter);
+ JS_SET_RVAL(context, vp, INT_TO_JSVAL(filter));
return JS_TRUE;
}
static JSFunctionSpec gjs_cairo_surface_pattern_proto_funcs[] = {
- { "setExtend", setExtend_func, 0, 0 },
- { "getExtend", getExtend_func, 0, 0 },
- { "setFilter", setFilter_func, 0, 0 },
- { "getFilter", getFilter_func, 0, 0 },
+ { "setExtend", (JSNative)setExtend_func, 0, JSFUN_FAST_NATIVE },
+ { "getExtend", (JSNative)getExtend_func, 0, JSFUN_FAST_NATIVE },
+ { "setFilter", (JSNative)setFilter_func, 0, JSFUN_FAST_NATIVE },
+ { "getFilter", (JSNative)getFilter_func, 0, JSFUN_FAST_NATIVE },
{ NULL }
};
diff --git a/modules/cairo-surface.c b/modules/cairo-surface.c
index ebdd029..d6fda11 100644
--- a/modules/cairo-surface.c
+++ b/modules/cairo-surface.c
@@ -58,11 +58,11 @@ static JSPropertySpec gjs_cairo_surface_proto_props[] = {
/* Methods */
static JSBool
writeToPNG_func(JSContext *context,
- JSObject *obj,
uintN argc,
- jsval *argv,
- jsval *retval)
+ jsval *vp)
{
+ jsval *argv = JS_ARGV(context, vp);
+ JSObject *obj = JS_THIS_OBJECT(context, vp);
char *filename;
cairo_surface_t *surface;
@@ -79,17 +79,17 @@ writeToPNG_func(JSContext *context,
g_free(filename);
if (!gjs_cairo_check_status(context, cairo_surface_status(surface),
"surface"))
- return JS_TRUE;
+ return JS_FALSE;
+ JS_SET_RVAL(context, vp, JSVAL_VOID);
return JS_TRUE;
}
static JSBool
getType_func(JSContext *context,
- JSObject *object,
uintN argc,
- jsval *argv,
- jsval *retval)
+ jsval *vp)
{
+ JSObject *obj = JS_THIS_OBJECT(context, vp);
cairo_surface_t *surface;
cairo_surface_type_t type;
@@ -98,13 +98,13 @@ getType_func(JSContext *context,
return JS_FALSE;
}
- surface = gjs_cairo_surface_get_surface(context, object);
+ surface = gjs_cairo_surface_get_surface(context, obj);
type = cairo_surface_get_type(surface);
if (!gjs_cairo_check_status(context, cairo_surface_status(surface),
"surface"))
- return JS_TRUE;
+ return JS_FALSE;
- *retval = INT_TO_JSVAL(type);
+ JS_SET_RVAL(context, vp, INT_TO_JSVAL(type));
return JS_TRUE;
}
@@ -112,7 +112,7 @@ static JSFunctionSpec gjs_cairo_surface_proto_funcs[] = {
// flush
// getContent
// getFontOptions
- { "getType", getType_func, 0, 0 },
+ { "getType", (JSNative)getType_func, 0, JSFUN_FAST_NATIVE},
// markDirty
// markDirtyRectangle
// setDeviceOffset
@@ -122,7 +122,7 @@ static JSFunctionSpec gjs_cairo_surface_proto_funcs[] = {
// copyPage
// showPage
// hasShowTextGlyphs
- { "writeToPNG", writeToPNG_func, 0, 0 },
+ { "writeToPNG", (JSNative)writeToPNG_func, 0, JSFUN_FAST_NATIVE },
{ NULL }
};
diff --git a/modules/dbus-exports.c b/modules/dbus-exports.c
index 2b15585..1801274 100644
--- a/modules/dbus-exports.c
+++ b/modules/dbus-exports.c
@@ -380,11 +380,10 @@ invoke_js_from_dbus(JSContext *context,
static JSBool
async_call_callback(JSContext *context,
- JSObject *obj,
uintN argc,
- jsval *argv,
- jsval *retval)
+ jsval *vp)
{
+ jsval *argv = JS_ARGV(context, vp);
DBusConnection *connection;
DBusBusType which_bus;
DBusMessage *reply;
@@ -395,7 +394,6 @@ async_call_callback(JSContext *context,
const char *signature;
gboolean thrown;
- *retval = JSVAL_VOID;
callback_object = JSVAL_TO_OBJECT(JS_ARGV_CALLEE(argv));
reply = NULL;
thrown = FALSE;
@@ -483,6 +481,8 @@ async_call_callback(JSContext *context,
gjs_dbus_remove_bus_weakref(which_bus, &connection);
dbus_message_unref(reply);
}
+ if (!thrown)
+ JS_SET_RVAL(context, vp, JSVAL_VOID);
return (thrown == FALSE);
}
@@ -531,8 +531,8 @@ invoke_js_async_from_dbus(JSContext *context,
/* we will add an argument, the callback */
callback = JS_NewFunction(context,
- async_call_callback,
- 1, 0,
+ (JSNative)async_call_callback,
+ 1, JSFUN_FAST_NATIVE,
NULL,
"" /* anonymous */);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]