From 0cc01ddf21f56fa7c6648c0cc15c27950415670d Mon Sep 17 00:00:00 2001 From: Jim Blandy Date: Thu, 21 Nov 2013 13:25:15 -0800 Subject: [PATCH] Bug 637572: Add elementProperty to CompileOptions. r=sfink --- js/src/jsapi.cpp | 5 +++-- js/src/jsapi.h | 19 +++++++++++++------ 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/js/src/jsapi.cpp b/js/src/jsapi.cpp index c6f99bd722a8..c36643973a5b 100644 --- a/js/src/jsapi.cpp +++ b/js/src/jsapi.cpp @@ -4398,7 +4398,8 @@ JS::ReadOnlyCompileOptions::originPrincipals() const JS::OwningCompileOptions::OwningCompileOptions(JSContext *cx) : ReadOnlyCompileOptions(), runtime(GetRuntime(cx)), - elementRoot(cx) + elementRoot(cx), + elementPropertyRoot(cx) { } @@ -4463,7 +4464,7 @@ JS::OwningCompileOptions::setSourceMapURL(JSContext *cx, const jschar *s) } JS::CompileOptions::CompileOptions(JSContext *cx, JSVersion version) - : ReadOnlyCompileOptions(), elementRoot(cx) + : ReadOnlyCompileOptions(), elementRoot(cx), elementPropertyRoot(cx) { this->version = (version != JSVERSION_UNKNOWN) ? version : cx->findVersion(); diff --git a/js/src/jsapi.h b/js/src/jsapi.h index 0802ac9b562e..3d01ee49d28a 100644 --- a/js/src/jsapi.h +++ b/js/src/jsapi.h @@ -3449,6 +3449,7 @@ class JS_PUBLIC_API(ReadOnlyCompileOptions) const char *filename() const { return filename_; } const jschar *sourceMapURL() const { return sourceMapURL_; } virtual JSObject *element() const = 0; + virtual JSString *elementProperty() const = 0; // POD options. JSVersion version; @@ -3493,6 +3494,7 @@ class JS_PUBLIC_API(OwningCompileOptions) : public ReadOnlyCompileOptions { JSRuntime *runtime; PersistentRootedObject elementRoot; + PersistentRootedString elementPropertyRoot; public: // A minimal constructor, for use with OwningCompileOptions::copy. This @@ -3503,6 +3505,7 @@ class JS_PUBLIC_API(OwningCompileOptions) : public ReadOnlyCompileOptions ~OwningCompileOptions(); JSObject *element() const MOZ_OVERRIDE { return elementRoot; } + JSString *elementProperty() const MOZ_OVERRIDE { return elementPropertyRoot; } // Set this to a copy of |rhs|. Return false on OOM. bool copy(JSContext *cx, const ReadOnlyCompileOptions &rhs); @@ -3512,7 +3515,8 @@ class JS_PUBLIC_API(OwningCompileOptions) : public ReadOnlyCompileOptions bool setSourceMapURL(JSContext *cx, const jschar *s); /* These setters are infallible, and can be chained. */ - OwningCompileOptions &setElement(JSObject *e) { elementRoot = e; return *this; } + OwningCompileOptions &setElement(JSObject *e) { elementRoot = e; return *this; } + OwningCompileOptions &setElementProperty(JSString *p) { elementPropertyRoot = p; return *this; } OwningCompileOptions &setPrincipals(JSPrincipals *p) { if (p) JS_HoldPrincipals(p); if (principals_) JS_DropPrincipals(runtime, principals_); @@ -3550,11 +3554,12 @@ class JS_PUBLIC_API(OwningCompileOptions) : public ReadOnlyCompileOptions class MOZ_STACK_CLASS JS_PUBLIC_API(CompileOptions) : public ReadOnlyCompileOptions { RootedObject elementRoot; + RootedString elementPropertyRoot; public: explicit CompileOptions(JSContext *cx, JSVersion version = JSVERSION_UNKNOWN); CompileOptions(js::ContextFriendFields *cx, const ReadOnlyCompileOptions &rhs) - : ReadOnlyCompileOptions(), elementRoot(cx) + : ReadOnlyCompileOptions(), elementRoot(cx), elementPropertyRoot(cx) { copyPODOptions(rhs); @@ -3563,17 +3568,19 @@ class MOZ_STACK_CLASS JS_PUBLIC_API(CompileOptions) : public ReadOnlyCompileOpti filename_ = rhs.filename(); sourceMapURL_ = rhs.sourceMapURL(); elementRoot = rhs.element(); + elementPropertyRoot = rhs.elementProperty(); } JSObject *element() const MOZ_OVERRIDE { return elementRoot; } + JSString *elementProperty() const MOZ_OVERRIDE { return elementPropertyRoot; } CompileOptions &setFileAndLine(const char *f, unsigned l) { filename_ = f; lineno = l; return *this; } - CompileOptions &setSourceMapURL(const jschar *s) { sourceMapURL_ = s; return *this; } - CompileOptions &setElement(JSObject *e) { elementRoot = e; return *this; } - - CompileOptions &setPrincipals(JSPrincipals *p) { principals_ = p; return *this; } + CompileOptions &setSourceMapURL(const jschar *s) { sourceMapURL_ = s; return *this; } + CompileOptions &setElement(JSObject *e) { elementRoot = e; return *this; } + CompileOptions &setElementProperty(JSString *p) { elementPropertyRoot = p; return *this; } + CompileOptions &setPrincipals(JSPrincipals *p) { principals_ = p; return *this; } CompileOptions &setOriginPrincipals(JSPrincipals *p) { originPrincipals_ = p; return *this;