Bug 986304 - Augment JSAPI to give callers the option to not define named functions on the scope object. r=terrence

This commit is contained in:
Bobby Holley 2014-03-21 23:31:02 -03:00
parent 6e30090928
commit 483948e0a1
2 changed files with 5 additions and 1 deletions

View File

@ -4622,7 +4622,7 @@ JS::CompileFunction(JSContext *cx, HandleObject obj, const ReadOnlyCompileOption
if (!frontend::CompileFunctionBody(cx, &fun, options, formals, chars, length))
return nullptr;
if (obj && funAtom) {
if (obj && funAtom && options.defineOnScope) {
Rooted<jsid> id(cx, AtomToId(funAtom));
RootedValue value(cx, ObjectValue(*fun));
if (!JSObject::defineGeneric(cx, obj, id, value, nullptr, nullptr, JSPROP_ENUMERATE))

View File

@ -3377,6 +3377,7 @@ class JS_FRIEND_API(ReadOnlyCompileOptions)
column(0),
compileAndGo(false),
forEval(false),
defineOnScope(true),
noScriptRval(false),
selfHostingMode(false),
canLazilyParse(true),
@ -3416,6 +3417,7 @@ class JS_FRIEND_API(ReadOnlyCompileOptions)
unsigned column;
bool compileAndGo;
bool forEval;
bool defineOnScope;
bool noScriptRval;
bool selfHostingMode;
bool canLazilyParse;
@ -3517,6 +3519,7 @@ class JS_FRIEND_API(OwningCompileOptions) : public ReadOnlyCompileOptions
OwningCompileOptions &setColumn(unsigned c) { column = c; return *this; }
OwningCompileOptions &setCompileAndGo(bool cng) { compileAndGo = cng; return *this; }
OwningCompileOptions &setForEval(bool eval) { forEval = eval; return *this; }
OwningCompileOptions &setDefineOnScope(bool define) { defineOnScope = define; return *this; }
OwningCompileOptions &setNoScriptRval(bool nsr) { noScriptRval = nsr; return *this; }
OwningCompileOptions &setSelfHostingMode(bool shm) { selfHostingMode = shm; return *this; }
OwningCompileOptions &setCanLazilyParse(bool clp) { canLazilyParse = clp; return *this; }
@ -3602,6 +3605,7 @@ class MOZ_STACK_CLASS JS_FRIEND_API(CompileOptions) : public ReadOnlyCompileOpti
CompileOptions &setColumn(unsigned c) { column = c; return *this; }
CompileOptions &setCompileAndGo(bool cng) { compileAndGo = cng; return *this; }
CompileOptions &setForEval(bool eval) { forEval = eval; return *this; }
CompileOptions &setDefineOnScope(bool define) { defineOnScope = define; return *this; }
CompileOptions &setNoScriptRval(bool nsr) { noScriptRval = nsr; return *this; }
CompileOptions &setSelfHostingMode(bool shm) { selfHostingMode = shm; return *this; }
CompileOptions &setCanLazilyParse(bool clp) { canLazilyParse = clp; return *this; }