Skip to content

Instantly share code, notes, and snippets.

@syg
Created February 27, 2013 23:51
Show Gist options
  • Save syg/5052981 to your computer and use it in GitHub Desktop.
Save syg/5052981 to your computer and use it in GitHub Desktop.
static JSBool
Timeout(JSContext *cx, unsigned argc, jsval *vp)
{
if (argc == 0) {
JS_SET_RVAL(cx, vp, JS_NumberValue(gTimeoutInterval));
return true;
}
if (argc > 2) {
JS_ReportError(cx, "Wrong number of arguments");
return false;
}
double t;
if (!JS_ValueToNumber(cx, JS_ARGV(cx, vp)[0], &t))
return false;
<<<<<<< HEAD
if (argc > 1) {
RootedValue value(cx, JS_ARGV(cx, vp)[1]);
if (!value.isObject() || !value.toObject().isFunction()) {
JS_ReportError(cx, "Second argument must be a timeout function");
return false;
}
gTimeoutFunc = value;
}
*vp = JSVAL_VOID;
||||||| merged common ancestors
*vp = JSVAL_VOID;
=======
if (argc > 1) {
RootedValue value(cx, JS_ARGV(cx, vp)[1]);
if (!value.isObject() || !value.toObject().isFunction()) {
JS_ReportError(cx, "Second argument must be a timeout function");
return false;
}
gTimeoutFunc = value;
}
JS_SET_RVAL(cx, vp, UndefinedValue());
>>>>>>> mozilla/master
return SetTimeoutValue(cx, t);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment