From 57f5df240d23ee0405252893cb7ccbf9228512e6 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Sat, 18 Aug 2012 21:45:54 -0700 Subject: [PATCH] Bug 433529: Part 6 - Add JS_GetFunctionDisplayId as a jsapi function for a JSFunction's displayAtom. r=jimb --- js/src/jsapi.cpp | 6 ++++++ js/src/jsapi.h | 10 ++++++++++ 2 files changed, 16 insertions(+) diff --git a/js/src/jsapi.cpp b/js/src/jsapi.cpp index 6e7689e901f5..5571fc05e37e 100644 --- a/js/src/jsapi.cpp +++ b/js/src/jsapi.cpp @@ -4924,6 +4924,12 @@ 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) { diff --git a/js/src/jsapi.h b/js/src/jsapi.h index da7a6689a801..c8ab0f09c61b 100644 --- a/js/src/jsapi.h +++ b/js/src/jsapi.h @@ -4974,6 +4974,16 @@ JS_GetFunctionObject(JSFunction *fun); 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. */