Bug 433529: Part 6 - Add JS_GetFunctionDisplayId as a jsapi function for a JSFunction's displayAtom. r=jimb
authorAlex Crichton <acrichton@mozilla.com>
Sat, 18 Aug 2012 21:45:54 -0700
changeset 105151 6735faf4d313655951b1557775e3c3da4439407c
parent 105150 d26a8e451fa2526e011de1ac6b77cd396bc81814
child 105152 17607e337dfd2587a835cae76a6e292f1b294667
push id55
push usershu@rfrn.org
push dateThu, 30 Aug 2012 01:33:09 +0000
reviewersjimb
bugs433529
milestone17.0a1
Bug 433529: Part 6 - Add JS_GetFunctionDisplayId as a jsapi function for a JSFunction's displayAtom. r=jimb
js/src/jsapi.cpp
js/src/jsapi.h
--- a/js/src/jsapi.cpp
+++ b/js/src/jsapi.cpp
@@ -4919,16 +4919,22 @@ JS_GetFunctionObject(JSFunction *fun)
 }
 
 JS_PUBLIC_API(JSString *)
 JS_GetFunctionId(JSFunction *fun)
 {
     return fun->atom();
 }
 
+JS_PUBLIC_API(JSString *)
+JS_GetFunctionDisplayId(JSFunction *fun)
+{
+    return fun->displayAtom();
+}
+
 JS_PUBLIC_API(unsigned)
 JS_GetFunctionFlags(JSFunction *fun)
 {
     return fun->flags;
 }
 
 JS_PUBLIC_API(uint16_t)
 JS_GetFunctionArity(JSFunction *fun)
--- a/js/src/jsapi.h
+++ b/js/src/jsapi.h
@@ -4970,16 +4970,26 @@ JS_GetFunctionObject(JSFunction *fun);
  * The returned string lives as long as fun, so you don't need to root a saved
  * reference to it if fun is well-connected or rooted, and provided you bound
  * the use of the saved reference by fun's lifetime.
  */
 extern JS_PUBLIC_API(JSString *)
 JS_GetFunctionId(JSFunction *fun);
 
 /*
+ * Return a function's display name. This is the defined name if one was given
+ * where the function was defined, or it could be an inferred name by the JS
+ * engine in the case that the function was defined to be anonymous. This can
+ * still return NULL if a useful display name could not be inferred. The same
+ * restrictions on rooting as those in JS_GetFunctionId apply.
+ */
+extern JS_PUBLIC_API(JSString *)
+JS_GetFunctionDisplayId(JSFunction *fun);
+
+/*
  * Return JSFUN_* flags for fun.
  */
 extern JS_PUBLIC_API(unsigned)
 JS_GetFunctionFlags(JSFunction *fun);
 
 /*
  * Return the arity (length) of fun.
  */