Bug 648801 (new DOM list bindings) - Add a way to test whether a particular object is the function object for a particular JSNative. r=bz/jst/mrbkap.
authorAndreas Gal <gal@mozilla.com>
Mon, 23 May 2011 17:39:25 +0200
changeset 79055 aca2001154a83ce60a34a43fedcbb8a5e4cc8c00
parent 79054 bd16e71072282406b7c82ca2f9f5cc85699fd0b2
child 79056 e76de73e29bfbd8de6511a42ca947ef010f58655
push id506
push userclegnitto@mozilla.com
push dateWed, 09 Nov 2011 02:03:18 +0000
treeherdermozilla-aurora@63587fc7bb93 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz, jst, mrbkap
bugs648801
milestone10.0a1
Bug 648801 (new DOM list bindings) - Add a way to test whether a particular object is the function object for a particular JSNative. r=bz/jst/mrbkap.
js/src/jsapi.cpp
js/src/jsapi.h
--- a/js/src/jsapi.cpp
+++ b/js/src/jsapi.cpp
@@ -4404,16 +4404,25 @@ JS_ObjectIsFunction(JSContext *cx, JSObj
 }
 
 JS_PUBLIC_API(JSBool)
 JS_ObjectIsCallable(JSContext *cx, JSObject *obj)
 {
     return obj->isCallable();
 }
 
+JS_PUBLIC_API(JSBool)
+JS_IsNativeFunction(JSObject *funobj, JSNative call)
+{
+    if (!funobj->isFunction())
+        return false;
+    JSFunction *fun = funobj->getFunctionPrivate();
+    return fun->isNative() && fun->native() == call;
+}
+
 static JSBool
 js_generic_native_method_dispatcher(JSContext *cx, uintN argc, Value *vp)
 {
     JSFunctionSpec *fs = (JSFunctionSpec *) vp->toObject().getReservedSlot(0).toPrivate();
     JS_ASSERT((fs->flags & JSFUN_GENERIC_NATIVE) != 0);
 
     if (argc < 1) {
         js_ReportMissingArg(cx, *vp, 0);
--- a/js/src/jsapi.h
+++ b/js/src/jsapi.h
@@ -3687,16 +3687,19 @@ JS_GetFunctionArity(JSFunction *fun);
  */
 extern JS_PUBLIC_API(JSBool)
 JS_ObjectIsFunction(JSContext *cx, JSObject *obj);
 
 extern JS_PUBLIC_API(JSBool)
 JS_ObjectIsCallable(JSContext *cx, JSObject *obj);
 
 extern JS_PUBLIC_API(JSBool)
+JS_IsNativeFunction(JSObject *funobj, JSNative call);
+
+extern JS_PUBLIC_API(JSBool)
 JS_DefineFunctions(JSContext *cx, JSObject *obj, JSFunctionSpec *fs);
 
 extern JS_PUBLIC_API(JSFunction *)
 JS_DefineFunction(JSContext *cx, JSObject *obj, const char *name, JSNative call,
                   uintN nargs, uintN attrs);
 
 extern JS_PUBLIC_API(JSFunction *)
 JS_DefineUCFunction(JSContext *cx, JSObject *obj,