summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Walters <walters@verbum.org>2010-10-20 18:40:20 -0400
committerColin Walters <walters@verbum.org>2010-10-21 17:35:41 -0400
commite5c9ce4a88882ce2fde9b06037e14aff8dd2663d (patch)
tree051f3ff8ff8ec6bd7b84fa875f5d0b8e54f9e992
parent35b80b9312f8c62459271696eef11469c4bded9c (diff)
downloadgjs-e5c9ce4a88882ce2fde9b06037e14aff8dd2663d.tar.gz
Port more custom functions to be "fast" nativeswip/xulrunner-2
These were missed in the big conversion to fast natives in c78646ed3f24bd915c7cfe4aca
-rw-r--r--gjs/context.c38
-rw-r--r--modules/console.c15
-rw-r--r--modules/console.h4
3 files changed, 25 insertions, 32 deletions
diff --git a/gjs/context.c b/gjs/context.c
index 7c0363e6..34fdac88 100644
--- a/gjs/context.c
+++ b/gjs/context.c
@@ -93,11 +93,10 @@ static GList *all_contexts = NULL;
static JSBool
gjs_log(JSContext *context,
- JSObject *obj,
uintN argc,
- jsval *argv,
- jsval *retval)
+ jsval *vp)
{
+ jsval *argv = JS_ARGV(context, vp);
char *s;
JSExceptionState *exc_state;
JSString *jstr;
@@ -137,11 +136,10 @@ gjs_log(JSContext *context,
static JSBool
gjs_log_error(JSContext *context,
- JSObject *obj,
- uintN argc,
- jsval *argv,
- jsval *retval)
+ uintN argc,
+ jsval *vp)
{
+ jsval *argv = JS_ARGV(context, vp);
char *s;
JSExceptionState *exc_state;
JSString *jstr;
@@ -243,11 +241,10 @@ gjs_print_parse_args(JSContext *context,
static JSBool
gjs_print(JSContext *context,
- JSObject *obj,
uintN argc,
- jsval *argv,
- jsval *retval)
+ jsval *vp)
{
+ jsval *argv = JS_ARGV(context, vp);
char *buffer;
if (!gjs_print_parse_args(context, argc, argv, &buffer)) {
@@ -262,11 +259,10 @@ gjs_print(JSContext *context,
static JSBool
gjs_printerr(JSContext *context,
- JSObject *obj,
uintN argc,
- jsval *argv,
- jsval *retval)
+ jsval *vp)
{
+ jsval *argv = JS_ARGV(context, vp);
char *buffer;
if (!gjs_print_parse_args(context, argc, argv, &buffer)) {
@@ -584,26 +580,26 @@ gjs_context_constructor (GType type,
/* Define a global function called log() */
if (!JS_DefineFunction(js_context->context, js_context->global,
"log",
- gjs_log,
- 1, GJS_MODULE_PROP_FLAGS))
+ (JSNative)gjs_log,
+ 1, GJS_MODULE_PROP_FLAGS | JSFUN_FAST_NATIVE))
gjs_fatal("Failed to define log function");
if (!JS_DefineFunction(js_context->context, js_context->global,
"logError",
- gjs_log_error,
- 2, GJS_MODULE_PROP_FLAGS))
+ (JSNative)gjs_log_error,
+ 2, GJS_MODULE_PROP_FLAGS | JSFUN_FAST_NATIVE))
gjs_fatal("Failed to define logError function");
/* Define global functions called print() and printerr() */
if (!JS_DefineFunction(js_context->context, js_context->global,
"print",
- gjs_print,
- 3, GJS_MODULE_PROP_FLAGS))
+ (JSNative)gjs_print,
+ 3, GJS_MODULE_PROP_FLAGS | JSFUN_FAST_NATIVE))
gjs_fatal("Failed to define print function");
if (!JS_DefineFunction(js_context->context, js_context->global,
"printerr",
- gjs_printerr,
- 4, GJS_MODULE_PROP_FLAGS))
+ (JSNative)gjs_printerr,
+ 4, GJS_MODULE_PROP_FLAGS | JSFUN_FAST_NATIVE))
gjs_fatal("Failed to define printerr function");
/* We need to know what the default context is, since it's the context whose
diff --git a/modules/console.c b/modules/console.c
index 76381257..bb930a74 100644
--- a/modules/console.c
+++ b/modules/console.c
@@ -158,11 +158,10 @@ gjs_console_readline(JSContext *cx, char *bufp, FILE *file, const char *prompt)
JSBool
gjs_console_interact(JSContext *context,
- JSObject *obj,
uintN argc,
- jsval *argv,
- jsval *retval)
+ jsval *vp)
{
+ JSObject *object = JS_THIS_OBJECT(context, vp);
gboolean eof = FALSE;
JSScript *script;
jsval result;
@@ -196,13 +195,13 @@ gjs_console_interact(JSContext *context,
}
bufp += strlen(bufp);
lineno++;
- } while (!JS_BufferIsCompilableUnit(context, obj, buffer, strlen(buffer)));
+ } while (!JS_BufferIsCompilableUnit(context, object, buffer, strlen(buffer)));
- script = JS_CompileScript(context, obj, buffer, strlen(buffer), "typein",
+ script = JS_CompileScript(context, object, buffer, strlen(buffer), "typein",
startline);
if (script)
- JS_ExecuteScript(context, obj, script, &result);
+ JS_ExecuteScript(context, object, script, &result);
if (JS_GetPendingException(context, &result)) {
str = JS_ValueToString(context, result);
@@ -234,8 +233,8 @@ gjs_define_console_stuff(JSContext *context,
{
if (!JS_DefineFunction(context, module_obj,
"interact",
- gjs_console_interact,
- 1, GJS_MODULE_PROP_FLAGS))
+ (JSNative) gjs_console_interact,
+ 1, GJS_MODULE_PROP_FLAGS | JSFUN_FAST_NATIVE))
return JS_FALSE;
return JS_TRUE;
diff --git a/modules/console.h b/modules/console.h
index 07d457e3..da787600 100644
--- a/modules/console.h
+++ b/modules/console.h
@@ -34,10 +34,8 @@ G_BEGIN_DECLS
JSBool gjs_define_console_stuff (JSContext *context,
JSObject *in_object);
JSBool gjs_console_interact (JSContext *context,
- JSObject *obj,
uintN argc,
- jsval *argv,
- jsval *rval);
+ jsval *vp);
G_END_DECLS