Merge the last PGO-green inbound changeset to m-c.

This commit is contained in:
Ryan VanderMeulen 2012-05-19 23:52:43 -04:00
Родитель fd2d58b29a 1b562164d1
Коммит 4e6bdfffa8
119 изменённых файлов: 1912 добавлений и 1694 удалений

Просмотреть файл

@ -426,8 +426,8 @@ private:
virtual ~nsScriptSecurityManager();
static JSBool
CheckObjectAccess(JSContext *cx, JSObject *obj,
jsid id, JSAccessMode mode,
CheckObjectAccess(JSContext *cx, JSHandleObject obj,
JSHandleId id, JSAccessMode mode,
jsval *vp);
static JSPrincipals *

Просмотреть файл

@ -631,8 +631,8 @@ nsScriptSecurityManager::ContentSecurityPolicyPermitsJSAction(JSContext *cx)
JSBool
nsScriptSecurityManager::CheckObjectAccess(JSContext *cx, JSObject *obj,
jsid id, JSAccessMode mode,
nsScriptSecurityManager::CheckObjectAccess(JSContext *cx, JSHandleObject obj,
JSHandleId id, JSAccessMode mode,
jsval *vp)
{
// Get the security manager

Просмотреть файл

@ -135,25 +135,25 @@ Canvas2D_GetStyleHelper(JSContext *cx, JSObject *obj, jsid id, jsval *vp,
}
static JSBool
nsIDOMCanvasRenderingContext2D_SetStrokeStyle(JSContext *cx, JSObject *obj, jsid id, JSBool strict, jsval *vp)
nsIDOMCanvasRenderingContext2D_SetStrokeStyle(JSContext *cx, JSHandleObject obj, JSHandleId id, JSBool strict, jsval *vp)
{
return Canvas2D_SetStyleHelper(cx, obj, id, vp, &nsIDOMCanvasRenderingContext2D::SetStrokeStyle_multi);
}
static JSBool
nsIDOMCanvasRenderingContext2D_GetStrokeStyle(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
nsIDOMCanvasRenderingContext2D_GetStrokeStyle(JSContext *cx, JSHandleObject obj, JSHandleId id, jsval *vp)
{
return Canvas2D_GetStyleHelper(cx, obj, id, vp, &nsIDOMCanvasRenderingContext2D::GetStrokeStyle_multi);
}
static JSBool
nsIDOMCanvasRenderingContext2D_SetFillStyle(JSContext *cx, JSObject *obj, jsid id, JSBool strict, jsval *vp)
nsIDOMCanvasRenderingContext2D_SetFillStyle(JSContext *cx, JSHandleObject obj, JSHandleId id, JSBool strict, jsval *vp)
{
return Canvas2D_SetStyleHelper(cx, obj, id, vp, &nsIDOMCanvasRenderingContext2D::SetFillStyle_multi);
}
static JSBool
nsIDOMCanvasRenderingContext2D_GetFillStyle(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
nsIDOMCanvasRenderingContext2D_GetFillStyle(JSContext *cx, JSHandleObject obj, JSHandleId id, jsval *vp)
{
return Canvas2D_GetStyleHelper(cx, obj, id, vp, &nsIDOMCanvasRenderingContext2D::GetFillStyle_multi);
}

Просмотреть файл

@ -113,7 +113,7 @@ XBLFinalize(JSFreeOp *fop, JSObject *obj)
}
static JSBool
XBLResolve(JSContext *cx, JSObject *obj, jsid id, unsigned flags,
XBLResolve(JSContext *cx, JSHandleObject obj, JSHandleId id, unsigned flags,
JSObject **objp)
{
// Note: if we get here, that means that the implementation for some binding

Просмотреть файл

@ -143,23 +143,23 @@ nsXBLDocGlobalObject::doCheckAccess(JSContext *cx, JSObject *obj, jsid id, PRUin
}
static JSBool
nsXBLDocGlobalObject_getProperty(JSContext *cx, JSObject *obj,
jsid id, jsval *vp)
nsXBLDocGlobalObject_getProperty(JSContext *cx, JSHandleObject obj,
JSHandleId id, jsval *vp)
{
return nsXBLDocGlobalObject::
doCheckAccess(cx, obj, id, nsIXPCSecurityManager::ACCESS_GET_PROPERTY);
}
static JSBool
nsXBLDocGlobalObject_setProperty(JSContext *cx, JSObject *obj,
jsid id, JSBool strict, jsval *vp)
nsXBLDocGlobalObject_setProperty(JSContext *cx, JSHandleObject obj,
JSHandleId id, JSBool strict, jsval *vp)
{
return nsXBLDocGlobalObject::
doCheckAccess(cx, obj, id, nsIXPCSecurityManager::ACCESS_SET_PROPERTY);
}
static JSBool
nsXBLDocGlobalObject_checkAccess(JSContext *cx, JSObject *obj, jsid id,
nsXBLDocGlobalObject_checkAccess(JSContext *cx, JSHandleObject obj, JSHandleId id,
JSAccessMode mode, jsval *vp)
{
PRUint32 translated;
@ -190,7 +190,7 @@ nsXBLDocGlobalObject_finalize(JSFreeOp *fop, JSObject *obj)
}
static JSBool
nsXBLDocGlobalObject_resolve(JSContext *cx, JSObject *obj, jsid id)
nsXBLDocGlobalObject_resolve(JSContext *cx, JSHandleObject obj, JSHandleId id)
{
JSBool did_resolve = JS_FALSE;
return JS_ResolveStandardClass(cx, obj, id, &did_resolve);

Просмотреть файл

@ -137,7 +137,7 @@ nsXULPDGlobalObject_finalize(JSFreeOp *fop, JSObject *obj)
JSBool
nsXULPDGlobalObject_resolve(JSContext *cx, JSObject *obj, jsid id)
nsXULPDGlobalObject_resolve(JSContext *cx, JSHandleObject obj, JSHandleId id)
{
JSBool did_resolve = JS_FALSE;

Просмотреть файл

@ -5246,8 +5246,8 @@ static JSClass sGlobalScopePolluterClass = {
// static
JSBool
nsWindowSH::GlobalScopePolluterGetProperty(JSContext *cx, JSObject *obj,
jsid id, jsval *vp)
nsWindowSH::GlobalScopePolluterGetProperty(JSContext *cx, JSHandleObject obj,
JSHandleId id, jsval *vp)
{
// Someone is accessing a element by referencing its name/id in the
// global scope, do a security check to make sure that's ok.
@ -5273,7 +5273,7 @@ nsWindowSH::GlobalScopePolluterGetProperty(JSContext *cx, JSObject *obj,
// static
JSBool
nsWindowSH::SecurityCheckOnAddDelProp(JSContext *cx, JSObject *obj, jsid id,
nsWindowSH::SecurityCheckOnAddDelProp(JSContext *cx, JSHandleObject obj, JSHandleId id,
jsval *vp)
{
// Someone is accessing a element by referencing its name/id in the
@ -5291,7 +5291,7 @@ nsWindowSH::SecurityCheckOnAddDelProp(JSContext *cx, JSObject *obj, jsid id,
// static
JSBool
nsWindowSH::SecurityCheckOnSetProp(JSContext *cx, JSObject *obj, jsid id, JSBool strict,
nsWindowSH::SecurityCheckOnSetProp(JSContext *cx, JSHandleObject obj, JSHandleId id, JSBool strict,
jsval *vp)
{
return SecurityCheckOnAddDelProp(cx, obj, id, vp);
@ -5306,8 +5306,8 @@ GetDocument(JSObject *obj)
// static
JSBool
nsWindowSH::GlobalScopePolluterNewResolve(JSContext *cx, JSObject *obj,
jsid id, unsigned flags,
nsWindowSH::GlobalScopePolluterNewResolve(JSContext *cx, JSHandleObject obj,
JSHandleId id, unsigned flags,
JSObject **objp)
{
if (flags & (JSRESOLVE_ASSIGNING | JSRESOLVE_DECLARING |
@ -5796,7 +5796,7 @@ static const IDBConstant sIDBConstants[] = {
};
static JSBool
IDBConstantGetter(JSContext *cx, JSObject *obj, jsid id, jsval* vp)
IDBConstantGetter(JSContext *cx, JSHandleObject obj, JSHandleId id, jsval* vp)
{
MOZ_ASSERT(JSID_IS_INT(id));
@ -6931,7 +6931,7 @@ LocationSetterGuts(JSContext *cx, JSObject *obj, jsval *vp)
template<class Interface>
static JSBool
LocationSetter(JSContext *cx, JSObject *obj, jsid id, JSBool strict,
LocationSetter(JSContext *cx, JSHandleObject obj, JSHandleId id, JSBool strict,
jsval *vp)
{
nsresult rv = LocationSetterGuts<Interface>(cx, obj, vp);
@ -6946,9 +6946,11 @@ LocationSetter(JSContext *cx, JSObject *obj, jsid id, JSBool strict,
}
static JSBool
LocationSetterUnwrapper(JSContext *cx, JSObject *obj, jsid id, JSBool strict,
LocationSetterUnwrapper(JSContext *cx, JSHandleObject obj_, JSHandleId id, JSBool strict,
jsval *vp)
{
JS::RootedVarObject obj(cx, obj_);
JSObject *wrapped = XPCWrapper::UnsafeUnwrapSecurityWrapper(obj);
if (wrapped) {
obj = wrapped;
@ -6959,9 +6961,12 @@ LocationSetterUnwrapper(JSContext *cx, JSObject *obj, jsid id, JSBool strict,
NS_IMETHODIMP
nsWindowSH::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
JSObject *obj, jsid id, PRUint32 flags,
JSObject *obj_, jsid id_, PRUint32 flags,
JSObject **objp, bool *_retval)
{
JS::RootedVarObject obj(cx, obj_);
JS::RootedVarId id(cx, id_);
nsGlobalWindow *win = nsGlobalWindow::FromWrapper(wrapper);
if (!JSID_IS_STRING(id)) {
@ -7057,7 +7062,7 @@ nsWindowSH::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
// We want this code to be before the child frame lookup code
// below so that a child frame named 'constructor' doesn't
// shadow the window's constructor property.
if (id == sConstructor_id) {
if (sConstructor_id == id) {
return ResolveConstructor(cx, obj, objp);
}
}
@ -7069,7 +7074,7 @@ nsWindowSH::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
return NS_OK;
}
if (id == sLocation_id) {
if (sLocation_id == id) {
// This must be done even if we're just getting the value of
// window.location (i.e. no checking flags & JSRESOLVE_ASSIGNING
// here) since we must define window.location to prevent the
@ -7208,7 +7213,7 @@ nsWindowSH::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
}
}
if (id == s_content_id) {
if (s_content_id == id) {
// Map window._content to window.content for backwards
// compatibility, this should spit out an message on the JS
// console.
@ -7257,7 +7262,7 @@ nsWindowSH::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
return NS_OK;
}
} else {
if (id == sNavigator_id) {
if (sNavigator_id == id) {
nsCOMPtr<nsIDOMNavigator> navigator;
rv = win->GetNavigator(getter_AddRefs(navigator));
NS_ENSURE_SUCCESS(rv, rv);
@ -7280,7 +7285,7 @@ nsWindowSH::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
return NS_OK;
}
if (id == sDocument_id) {
if (sDocument_id == id) {
nsCOMPtr<nsIDOMDocument> document;
rv = win->GetDocument(getter_AddRefs(document));
NS_ENSURE_SUCCESS(rv, rv);
@ -7314,7 +7319,7 @@ nsWindowSH::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
return NS_OK;
}
if (id == sDialogArguments_id && win->IsModalContentWindow()) {
if (sDialogArguments_id == id && win->IsModalContentWindow()) {
nsCOMPtr<nsIArray> args;
((nsGlobalModalWindow *)win)->GetDialogArguments(getter_AddRefs(args));
@ -7602,7 +7607,7 @@ nsNavigatorSH::PreCreate(nsISupports *nativeObj, JSContext *cx,
template<nsresult (*func)(JSContext *cx, JSObject *obj, jsval *vp)>
static JSBool
GetterShim(JSContext *cx, JSObject *obj, jsid /* unused */, jsval *vp)
GetterShim(JSContext *cx, JSHandleObject obj, JSHandleId /* unused */, jsval *vp)
{
nsresult rv = (*func)(cx, obj, vp);
if (NS_FAILED(rv)) {
@ -8783,14 +8788,16 @@ nsHTMLDocumentSH::GetDocumentAllNodeList(JSContext *cx, JSObject *obj,
}
JSBool
nsHTMLDocumentSH::DocumentAllGetProperty(JSContext *cx, JSObject *obj,
jsid id, jsval *vp)
nsHTMLDocumentSH::DocumentAllGetProperty(JSContext *cx, JSHandleObject obj_,
JSHandleId id, jsval *vp)
{
JSObject *obj = obj_;
// document.all.item and .namedItem get their value in the
// newResolve hook, so nothing to do for those properties here. And
// we need to return early to prevent <div id="item"> from shadowing
// document.all.item(), etc.
if (id == sItem_id || id == sNamedItem_id) {
if (sItem_id == id || sNamedItem_id == id) {
return JS_TRUE;
}
@ -8810,7 +8817,7 @@ nsHTMLDocumentSH::DocumentAllGetProperty(JSContext *cx, JSObject *obj,
nsresult rv = NS_OK;
if (JSID_IS_STRING(id)) {
if (id == sLength_id) {
if (sLength_id == id) {
// Map document.all.length to the length of the collection
// document.getElementsByTagName("*"), and make sure <div
// id="length"> doesn't shadow document.all.length.
@ -8832,7 +8839,7 @@ nsHTMLDocumentSH::DocumentAllGetProperty(JSContext *cx, JSObject *obj,
*vp = INT_TO_JSVAL(length);
return JS_TRUE;
} else if (id != sTags_id) {
} else if (sTags_id != id) {
// For all other strings, look for an element by id or name.
nsDependentJSString str(id);
@ -8880,7 +8887,7 @@ nsHTMLDocumentSH::DocumentAllGetProperty(JSContext *cx, JSObject *obj,
}
JSBool
nsHTMLDocumentSH::DocumentAllNewResolve(JSContext *cx, JSObject *obj, jsid id,
nsHTMLDocumentSH::DocumentAllNewResolve(JSContext *cx, JSHandleObject obj, JSHandleId id,
unsigned flags, JSObject **objp)
{
if (flags & JSRESOLVE_ASSIGNING) {
@ -8891,7 +8898,7 @@ nsHTMLDocumentSH::DocumentAllNewResolve(JSContext *cx, JSObject *obj, jsid id,
jsval v = JSVAL_VOID;
if (id == sItem_id || id == sNamedItem_id) {
if (sItem_id == id || sNamedItem_id == id) {
// Define the item() or namedItem() method.
JSFunction *fnc = ::JS_DefineFunctionById(cx, obj, id, CallToGetPropMapper,
@ -8901,14 +8908,14 @@ nsHTMLDocumentSH::DocumentAllNewResolve(JSContext *cx, JSObject *obj, jsid id,
return fnc != nsnull;
}
if (id == sLength_id) {
if (sLength_id == id) {
// document.all.length. Any jsval other than undefined would do
// here, all we need is to get into the code below that defines
// this propery on obj, the rest happens in
// DocumentAllGetProperty().
v = JSVAL_ONE;
} else if (id == sTags_id) {
} else if (sTags_id == id) {
nsHTMLDocument *doc = GetDocument(obj);
JSObject *tags = ::JS_NewObject(cx, &sHTMLDocumentAllTagsClass, nsnull,
@ -9018,10 +9025,10 @@ PrivateToFlags(void *priv)
}
JSBool
nsHTMLDocumentSH::DocumentAllHelperGetProperty(JSContext *cx, JSObject *obj,
jsid id, JS::Value *vp)
nsHTMLDocumentSH::DocumentAllHelperGetProperty(JSContext *cx, JSHandleObject obj,
JSHandleId id, JS::Value *vp)
{
if (id != nsDOMClassInfo::sAll_id) {
if (nsDOMClassInfo::sAll_id != id) {
return JS_TRUE;
}
@ -9077,11 +9084,11 @@ nsHTMLDocumentSH::DocumentAllHelperGetProperty(JSContext *cx, JSObject *obj,
}
JSBool
nsHTMLDocumentSH::DocumentAllHelperNewResolve(JSContext *cx, JSObject *obj,
jsid id, unsigned flags,
nsHTMLDocumentSH::DocumentAllHelperNewResolve(JSContext *cx, JSHandleObject obj,
JSHandleId id, unsigned flags,
JSObject **objp)
{
if (id == nsDOMClassInfo::sAll_id) {
if (nsDOMClassInfo::sAll_id == id) {
// document.all is resolved for the first time. Define it.
JSObject *helper = GetDocumentAllHelper(obj);
@ -9100,8 +9107,8 @@ nsHTMLDocumentSH::DocumentAllHelperNewResolve(JSContext *cx, JSObject *obj,
JSBool
nsHTMLDocumentSH::DocumentAllTagsNewResolve(JSContext *cx, JSObject *obj,
jsid id, unsigned flags,
nsHTMLDocumentSH::DocumentAllTagsNewResolve(JSContext *cx, JSHandleObject obj,
JSHandleId id, unsigned flags,
JSObject **objp)
{
if (JSID_IS_STRING(id)) {

Просмотреть файл

@ -421,14 +421,14 @@ public:
NS_IMETHOD OuterObject(nsIXPConnectWrappedNative *wrapper, JSContext * cx,
JSObject * obj, JSObject * *_retval);
static JSBool GlobalScopePolluterNewResolve(JSContext *cx, JSObject *obj,
jsid id, unsigned flags,
static JSBool GlobalScopePolluterNewResolve(JSContext *cx, JSHandleObject obj,
JSHandleId id, unsigned flags,
JSObject **objp);
static JSBool GlobalScopePolluterGetProperty(JSContext *cx, JSObject *obj,
jsid id, jsval *vp);
static JSBool SecurityCheckOnAddDelProp(JSContext *cx, JSObject *obj, jsid id,
static JSBool GlobalScopePolluterGetProperty(JSContext *cx, JSHandleObject obj,
JSHandleId id, jsval *vp);
static JSBool SecurityCheckOnAddDelProp(JSContext *cx, JSHandleObject obj, JSHandleId id,
jsval *vp);
static JSBool SecurityCheckOnSetProp(JSContext *cx, JSObject *obj, jsid id,
static JSBool SecurityCheckOnSetProp(JSContext *cx, JSHandleObject obj, JSHandleId id,
JSBool strict, jsval *vp);
static void InvalidateGlobalScopePolluter(JSContext *cx, JSObject *obj);
static nsresult InstallGlobalScopePolluter(JSContext *cx, JSObject *obj,
@ -794,19 +794,19 @@ protected:
nsContentList **nodeList);
public:
static JSBool DocumentAllGetProperty(JSContext *cx, JSObject *obj, jsid id,
static JSBool DocumentAllGetProperty(JSContext *cx, JSHandleObject obj, JSHandleId id,
jsval *vp);
static JSBool DocumentAllNewResolve(JSContext *cx, JSObject *obj, jsid id,
static JSBool DocumentAllNewResolve(JSContext *cx, JSHandleObject obj, JSHandleId id,
unsigned flags, JSObject **objp);
static void ReleaseDocument(JSFreeOp *fop, JSObject *obj);
static JSBool CallToGetPropMapper(JSContext *cx, unsigned argc, jsval *vp);
static JSBool DocumentAllHelperGetProperty(JSContext *cx, JSObject *obj,
jsid id, jsval *vp);
static JSBool DocumentAllHelperNewResolve(JSContext *cx, JSObject *obj,
jsid id, unsigned flags,
static JSBool DocumentAllHelperGetProperty(JSContext *cx, JSHandleObject obj,
JSHandleId id, jsval *vp);
static JSBool DocumentAllHelperNewResolve(JSContext *cx, JSHandleObject obj,
JSHandleId id, unsigned flags,
JSObject **objp);
static JSBool DocumentAllTagsNewResolve(JSContext *cx, JSObject *obj,
jsid id, unsigned flags,
static JSBool DocumentAllTagsNewResolve(JSContext *cx, JSHandleObject obj,
JSHandleId id, unsigned flags,
JSObject **objp);
NS_IMETHOD NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,

Просмотреть файл

@ -1820,7 +1820,7 @@ nsDOMWindowUtils::GetParent(const JS::Value& aObject,
// Outerize if necessary.
if (parent) {
if (JSObjectOp outerize = js::GetObjectClass(parent)->ext.outerObject) {
*aParent = OBJECT_TO_JSVAL(outerize(aCx, parent));
*aParent = OBJECT_TO_JSVAL(outerize(aCx, JS::RootedVarObject(aCx, parent)));
}
}

Просмотреть файл

@ -473,8 +473,8 @@ class CGAddPropertyHook(CGAbstractClassHook):
A hook for addProperty, used to preserve our wrapper from GC.
"""
def __init__(self, descriptor):
args = [Argument('JSContext*', 'cx'), Argument('JSObject*', 'obj'),
Argument('jsid', 'id'), Argument('jsval*', 'vp')]
args = [Argument('JSContext*', 'cx'), Argument('JSHandleObject', 'obj'),
Argument('JSHandleId', 'id'), Argument('jsval*', 'vp')]
CGAbstractClassHook.__init__(self, descriptor, ADDPROPERTY_HOOK_NAME,
'JSBool', args)
@ -581,7 +581,7 @@ class CGClassConstructHook(CGAbstractStaticMethod):
class CGClassHasInstanceHook(CGAbstractStaticMethod):
def __init__(self, descriptor):
args = [Argument('JSContext*', 'cx'), Argument('JSObject*', 'obj'),
args = [Argument('JSContext*', 'cx'), Argument('JSHandleObject', 'obj'),
Argument('const jsval*', 'v'), Argument('JSBool*', 'bp')]
CGAbstractStaticMethod.__init__(self, descriptor, HASINSTANCE_HOOK_NAME,
'JSBool', args)
@ -608,12 +608,12 @@ class CGClassHasInstanceHook(CGAbstractStaticMethod):
"%s");
return false;
}
obj = &protov.toObject();
JSObject *objProto = &protov.toObject();
JSObject* instance = &v->toObject();
JSObject* proto = JS_GetPrototype(instance);
while (proto) {
if (proto == obj) {
if (proto == objProto) {
*bp = true;
return true;
}
@ -2428,8 +2428,8 @@ class CGNativeGetter(CGAbstractBindingMethod):
args = [Argument('JSContext*', 'cx'), Argument('unsigned', 'argc'),
Argument('JS::Value*', 'vp')]
else:
args = [Argument('JSContext*', 'cx'), Argument('JSObject*', 'obj'),
Argument('jsid', 'id'), Argument('JS::Value*', 'vp')]
args = [Argument('JSContext*', 'cx'), Argument('JSHandleObject', 'obj'),
Argument('JSHandleId', 'id'), Argument('JS::Value*', 'vp')]
CGAbstractBindingMethod.__init__(self, descriptor, name, args,
descriptor.getExtendedAttributes(self.attr, getter=True))
@ -2457,8 +2457,8 @@ class CGNativeSetter(CGAbstractBindingMethod):
args = [Argument('JSContext*', 'cx'), Argument('unsigned', 'argc'),
Argument('JS::Value*', 'vp')]
else:
args = [Argument('JSContext*', 'cx'), Argument('JSObject*', 'obj'),
Argument('jsid', 'id'), Argument('JSBool', 'strict'),
args = [Argument('JSContext*', 'cx'), Argument('JSHandleObject', 'obj'),
Argument('JSHandleId', 'id'), Argument('JSBool', 'strict'),
Argument('JS::Value*', 'vp')]
CGAbstractBindingMethod.__init__(self, descriptor, name, args,
descriptor.getExtendedAttributes(self.attr, setter=True))

Просмотреть файл

@ -143,27 +143,27 @@ NPClass nsJSObjWrapper::sJSObjWrapperNPClass =
};
static JSBool
NPObjWrapper_AddProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp);
NPObjWrapper_AddProperty(JSContext *cx, JSHandleObject obj, JSHandleId id, jsval *vp);
static JSBool
NPObjWrapper_DelProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp);
NPObjWrapper_DelProperty(JSContext *cx, JSHandleObject obj, JSHandleId id, jsval *vp);
static JSBool
NPObjWrapper_SetProperty(JSContext *cx, JSObject *obj, jsid id, JSBool strict, jsval *vp);
NPObjWrapper_SetProperty(JSContext *cx, JSHandleObject obj, JSHandleId id, JSBool strict, jsval *vp);
static JSBool
NPObjWrapper_GetProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp);
NPObjWrapper_GetProperty(JSContext *cx, JSHandleObject obj, JSHandleId id, jsval *vp);
static JSBool
NPObjWrapper_newEnumerate(JSContext *cx, JSObject *obj, JSIterateOp enum_op,
NPObjWrapper_newEnumerate(JSContext *cx, JSHandleObject obj, JSIterateOp enum_op,
jsval *statep, jsid *idp);
static JSBool
NPObjWrapper_NewResolve(JSContext *cx, JSObject *obj, jsid id, unsigned flags,
NPObjWrapper_NewResolve(JSContext *cx, JSHandleObject obj, JSHandleId id, unsigned flags,
JSObject **objp);
static JSBool
NPObjWrapper_Convert(JSContext *cx, JSObject *obj, JSType type, jsval *vp);
NPObjWrapper_Convert(JSContext *cx, JSHandleObject obj, JSType type, jsval *vp);
static void
NPObjWrapper_Finalize(JSFreeOp *fop, JSObject *obj);
@ -204,7 +204,7 @@ typedef struct NPObjectMemberPrivate {
} NPObjectMemberPrivate;
static JSBool
NPObjectMember_Convert(JSContext *cx, JSObject *obj, JSType type, jsval *vp);
NPObjectMember_Convert(JSContext *cx, JSHandleObject obj, JSType type, jsval *vp);
static void
NPObjectMember_Finalize(JSFreeOp *fop, JSObject *obj);
@ -1177,7 +1177,7 @@ GetNPObject(JSObject *obj)
// Does not actually add a property because this is always followed by a
// SetProperty call.
static JSBool
NPObjWrapper_AddProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
NPObjWrapper_AddProperty(JSContext *cx, JSHandleObject obj, JSHandleId id, jsval *vp)
{
NPObject *npobj = GetNPObject(obj);
@ -1218,7 +1218,7 @@ NPObjWrapper_AddProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
}
static JSBool
NPObjWrapper_DelProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
NPObjWrapper_DelProperty(JSContext *cx, JSHandleObject obj, JSHandleId id, jsval *vp)
{
NPObject *npobj = GetNPObject(obj);
@ -1249,7 +1249,7 @@ NPObjWrapper_DelProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
}
static JSBool
NPObjWrapper_SetProperty(JSContext *cx, JSObject *obj, jsid id, JSBool strict, jsval *vp)
NPObjWrapper_SetProperty(JSContext *cx, JSHandleObject obj, JSHandleId id, JSBool strict, jsval *vp)
{
NPObject *npobj = GetNPObject(obj);
@ -1308,7 +1308,7 @@ NPObjWrapper_SetProperty(JSContext *cx, JSObject *obj, jsid id, JSBool strict, j
}
static JSBool
NPObjWrapper_GetProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
NPObjWrapper_GetProperty(JSContext *cx, JSHandleObject obj, JSHandleId id, jsval *vp)
{
NPObject *npobj = GetNPObject(obj);
@ -1548,7 +1548,7 @@ struct NPObjectEnumerateState {
};
static JSBool
NPObjWrapper_newEnumerate(JSContext *cx, JSObject *obj, JSIterateOp enum_op,
NPObjWrapper_newEnumerate(JSContext *cx, JSHandleObject obj, JSIterateOp enum_op,
jsval *statep, jsid *idp)
{
NPObject *npobj = GetNPObject(obj);
@ -1628,7 +1628,7 @@ NPObjWrapper_newEnumerate(JSContext *cx, JSObject *obj, JSIterateOp enum_op,
}
static JSBool
NPObjWrapper_NewResolve(JSContext *cx, JSObject *obj, jsid id, unsigned flags,
NPObjWrapper_NewResolve(JSContext *cx, JSHandleObject obj, JSHandleId id, unsigned flags,
JSObject **objp)
{
NPObject *npobj = GetNPObject(obj);
@ -1682,7 +1682,7 @@ NPObjWrapper_NewResolve(JSContext *cx, JSObject *obj, jsid id, unsigned flags,
}
static JSBool
NPObjWrapper_Convert(JSContext *cx, JSObject *obj, JSType hint, jsval *vp)
NPObjWrapper_Convert(JSContext *cx, JSHandleObject obj, JSType hint, jsval *vp)
{
JS_ASSERT(hint == JSTYPE_NUMBER || hint == JSTYPE_STRING || hint == JSTYPE_VOID);
@ -2185,7 +2185,7 @@ CreateNPObjectMember(NPP npp, JSContext *cx, JSObject *obj, NPObject* npobj,
}
static JSBool
NPObjectMember_Convert(JSContext *cx, JSObject *obj, JSType type, jsval *vp)
NPObjectMember_Convert(JSContext *cx, JSHandleObject obj, JSType type, jsval *vp)
{
NPObjectMemberPrivate *memberPrivate =
(NPObjectMemberPrivate *)::JS_GetInstancePrivate(cx, obj,

Просмотреть файл

@ -46,7 +46,7 @@ JSCTypesCallbacks gCTypesCallbacks = {
};
JSBool
CTypesLazyGetter(JSContext* aCx, JSObject* aObj, jsid aId, jsval* aVp)
CTypesLazyGetter(JSContext* aCx, JSHandleObject aObj, JSHandleId aId, jsval* aVp)
{
NS_ASSERTION(JS_GetGlobalObject(aCx) == aObj, "Not a global object!");
NS_ASSERTION(JSID_IS_STRING(aId), "Bad id!");

Просмотреть файл

@ -253,7 +253,7 @@ private:
}
static JSBool
GetProperty(JSContext* aCx, JSObject* aObj, jsid aIdval, jsval* aVp)
GetProperty(JSContext* aCx, JSHandleObject aObj, JSHandleId aIdval, jsval* aVp)
{
JS_ASSERT(JSID_IS_INT(aIdval));
@ -269,7 +269,7 @@ private:
}
static JSBool
GetConstant(JSContext* aCx, JSObject* aObj, jsid idval, jsval* aVp)
GetConstant(JSContext* aCx, JSHandleObject aObj, JSHandleId idval, jsval* aVp)
{
JS_ASSERT(JSID_IS_INT(idval));
JS_ASSERT(JSID_TO_INT(idval) >= CAPTURING_PHASE &&
@ -543,7 +543,7 @@ private:
}
static JSBool
GetProperty(JSContext* aCx, JSObject* aObj, jsid aIdval, jsval* aVp)
GetProperty(JSContext* aCx, JSHandleObject aObj, JSHandleId aIdval, jsval* aVp)
{
JS_ASSERT(JSID_IS_INT(aIdval));
@ -751,7 +751,7 @@ private:
}
static JSBool
GetProperty(JSContext* aCx, JSObject* aObj, jsid aIdval, jsval* aVp)
GetProperty(JSContext* aCx, JSHandleObject aObj, JSHandleId aIdval, jsval* aVp)
{
JS_ASSERT(JSID_IS_INT(aIdval));
@ -931,7 +931,7 @@ private:
}
static JSBool
GetProperty(JSContext* aCx, JSObject* aObj, jsid aIdval, jsval* aVp)
GetProperty(JSContext* aCx, JSHandleObject aObj, JSHandleId aIdval, jsval* aVp)
{
JS_ASSERT(JSID_IS_INT(aIdval));

Просмотреть файл

@ -159,7 +159,7 @@ private:
}
static JSBool
GetProperty(JSContext* aCx, JSObject* aObj, jsid aIdval, jsval* aVp)
GetProperty(JSContext* aCx, JSHandleObject aObj, JSHandleId aIdval, jsval* aVp)
{
JS_ASSERT(JSID_IS_INT(aIdval));
@ -179,7 +179,7 @@ private:
}
static JSBool
GetConstant(JSContext* aCx, JSObject* aObj, jsid idval, jsval* aVp)
GetConstant(JSContext* aCx, JSHandleObject aObj, JSHandleId idval, jsval* aVp)
{
JS_ASSERT(JSID_IS_INT(idval));
*aVp = INT_TO_JSVAL(JSID_TO_INT(idval));

Просмотреть файл

@ -148,7 +148,7 @@ private:
}
static JSBool
GetSize(JSContext* aCx, JSObject* aObj, jsid aIdval, jsval* aVp)
GetSize(JSContext* aCx, JSHandleObject aObj, JSHandleId aIdval, jsval* aVp)
{
nsIDOMBlob* blob = GetInstancePrivate(aCx, aObj, "size");
if (!blob) {
@ -169,7 +169,7 @@ private:
}
static JSBool
GetType(JSContext* aCx, JSObject* aObj, jsid aIdval, jsval* aVp)
GetType(JSContext* aCx, JSHandleObject aObj, JSHandleId aIdval, jsval* aVp)
{
nsIDOMBlob* blob = GetInstancePrivate(aCx, aObj, "type");
if (!blob) {
@ -339,7 +339,7 @@ private:
}
static JSBool
GetMozFullPath(JSContext* aCx, JSObject* aObj, jsid aIdval, jsval* aVp)
GetMozFullPath(JSContext* aCx, JSHandleObject aObj, JSHandleId aIdval, jsval* aVp)
{
nsIDOMFile* file = GetInstancePrivate(aCx, aObj, "mozFullPath");
if (!file) {
@ -365,7 +365,7 @@ private:
}
static JSBool
GetName(JSContext* aCx, JSObject* aObj, jsid aIdval, jsval* aVp)
GetName(JSContext* aCx, JSHandleObject aObj, JSHandleId aIdval, jsval* aVp)
{
nsIDOMFile* file = GetInstancePrivate(aCx, aObj, "name");
if (!file) {

Просмотреть файл

@ -114,7 +114,7 @@ private:
}
static JSBool
GetProperty(JSContext* aCx, JSObject* aObj, jsid aIdval, jsval* aVp)
GetProperty(JSContext* aCx, JSHandleObject aObj, JSHandleId aIdval, jsval* aVp)
{
JSClass* classPtr = JS_GetClass(aObj);
if (classPtr != &sClass) {

Просмотреть файл

@ -161,7 +161,7 @@ private:
}
static JSBool
GetProperty(JSContext* aCx, JSObject* aObj, jsid aIdval, jsval* aVp)
GetProperty(JSContext* aCx, JSHandleObject aObj, JSHandleId aIdval, jsval* aVp)
{
JSClass* classPtr = JS_GetClass(aObj);
if (classPtr != &sClass) {

Просмотреть файл

@ -150,7 +150,7 @@ private:
}
static JSBool
GetProperty(JSContext* aCx, JSObject* aObj, jsid aIdval, jsval* aVp)
GetProperty(JSContext* aCx, JSHandleObject aObj, JSHandleId aIdval, jsval* aVp)
{
JSClass* classPtr = JS_GetClass(aObj);
if (classPtr != &sClass) {

Просмотреть файл

@ -394,7 +394,7 @@ BEGIN_WORKERS_NAMESPACE
// Entry point for the DOM.
JSBool
ResolveWorkerClasses(JSContext* aCx, JSObject* aObj, jsid aId, unsigned aFlags,
ResolveWorkerClasses(JSContext* aCx, JSHandleObject aObj, JSHandleId aId, unsigned aFlags,
JSObject** aObjp)
{
AssertIsOnMainThread();
@ -423,7 +423,7 @@ ResolveWorkerClasses(JSContext* aCx, JSObject* aObj, jsid aId, unsigned aFlags,
bool shouldResolve = false;
for (PRUint32 i = 0; i < ID_COUNT; i++) {
if (aId == gStringIDs[i]) {
if (gStringIDs[i] == aId) {
nsIScriptSecurityManager* ssm = nsContentUtils::GetSecurityManager();
NS_ASSERTION(ssm, "This should never be null!");
@ -437,7 +437,7 @@ ResolveWorkerClasses(JSContext* aCx, JSObject* aObj, jsid aId, unsigned aFlags,
// Don't resolve if this is ChromeWorker and we're not chrome. Otherwise
// always resolve.
shouldResolve = aId == gStringIDs[ID_ChromeWorker] ? isChrome : true;
shouldResolve = gStringIDs[ID_ChromeWorker] == aId ? isChrome : true;
break;
}
}

Просмотреть файл

@ -187,7 +187,7 @@ private:
~Worker();
static JSBool
GetEventListener(JSContext* aCx, JSObject* aObj, jsid aIdval, jsval* aVp)
GetEventListener(JSContext* aCx, JSHandleObject aObj, JSHandleId aIdval, jsval* aVp)
{
JS_ASSERT(JSID_IS_INT(aIdval));
JS_ASSERT(JSID_TO_INT(aIdval) >= 0 && JSID_TO_INT(aIdval) < STRING_COUNT);
@ -211,7 +211,7 @@ private:
}
static JSBool
SetEventListener(JSContext* aCx, JSObject* aObj, jsid aIdval, JSBool aStrict,
SetEventListener(JSContext* aCx, JSHandleObject aObj, JSHandleId aIdval, JSBool aStrict,
jsval* aVp)
{
JS_ASSERT(JSID_IS_INT(aIdval));

Просмотреть файл

@ -167,7 +167,7 @@ protected:
private:
static JSBool
_GetEventListener(JSContext* aCx, JSObject* aObj, jsid aIdval, jsval* aVp)
_GetEventListener(JSContext* aCx, JSHandleObject aObj, JSHandleId aIdval, jsval* aVp)
{
JS_ASSERT(JSID_IS_INT(aIdval));
JS_ASSERT(JSID_TO_INT(aIdval) >= 0 && JSID_TO_INT(aIdval) < STRING_COUNT);
@ -193,7 +193,7 @@ private:
}
static JSBool
_SetEventListener(JSContext* aCx, JSObject* aObj, jsid aIdval, JSBool aStrict,
_SetEventListener(JSContext* aCx, JSHandleObject aObj, JSHandleId aIdval, JSBool aStrict,
jsval* aVp)
{
JS_ASSERT(JSID_IS_INT(aIdval));
@ -233,7 +233,7 @@ private:
}
static JSBool
GetSelf(JSContext* aCx, JSObject* aObj, jsid aIdval, jsval* aVp)
GetSelf(JSContext* aCx, JSHandleObject aObj, JSHandleId aIdval, jsval* aVp)
{
if (!GetInstancePrivate(aCx, aObj, "self")) {
return false;
@ -244,7 +244,7 @@ private:
}
static JSBool
GetLocation(JSContext* aCx, JSObject* aObj, jsid aIdval, jsval* aVp)
GetLocation(JSContext* aCx, JSHandleObject aObj, JSHandleId aIdval, jsval* aVp)
{
WorkerGlobalScope* scope =
GetInstancePrivate(aCx, aObj, sProperties[SLOT_location].name);
@ -333,7 +333,7 @@ private:
}
static JSBool
GetOnErrorListener(JSContext* aCx, JSObject* aObj, jsid aIdval, jsval* aVp)
GetOnErrorListener(JSContext* aCx, JSHandleObject aObj, JSHandleId aIdval, jsval* aVp)
{
const char* name = sEventStrings[STRING_onerror];
WorkerGlobalScope* scope = GetInstancePrivate(aCx, aObj, name);
@ -364,7 +364,7 @@ private:
}
static JSBool
SetOnErrorListener(JSContext* aCx, JSObject* aObj, jsid aIdval,
SetOnErrorListener(JSContext* aCx, JSHandleObject aObj, JSHandleId aIdval,
JSBool aStrict, jsval* aVp)
{
const char* name = sEventStrings[STRING_onerror];
@ -407,7 +407,7 @@ private:
}
static JSBool
GetNavigator(JSContext* aCx, JSObject* aObj, jsid aIdval, jsval* aVp)
GetNavigator(JSContext* aCx, JSHandleObject aObj, JSHandleId aIdval, jsval* aVp)
{
WorkerGlobalScope* scope =
GetInstancePrivate(aCx, aObj, sProperties[SLOT_navigator].name);
@ -734,7 +734,7 @@ protected:
private:
static JSBool
_GetEventListener(JSContext* aCx, JSObject* aObj, jsid aIdval, jsval* aVp)
_GetEventListener(JSContext* aCx, JSHandleObject aObj, JSHandleId aIdval, jsval* aVp)
{
JS_ASSERT(JSID_IS_INT(aIdval));
JS_ASSERT(JSID_TO_INT(aIdval) >= 0 && JSID_TO_INT(aIdval) < STRING_COUNT);
@ -760,7 +760,7 @@ private:
}
static JSBool
_SetEventListener(JSContext* aCx, JSObject* aObj, jsid aIdval, JSBool aStrict,
_SetEventListener(JSContext* aCx, JSHandleObject aObj, JSHandleId aIdval, JSBool aStrict,
jsval* aVp)
{
JS_ASSERT(JSID_IS_INT(aIdval));
@ -813,7 +813,7 @@ private:
}
static JSBool
Resolve(JSContext* aCx, JSObject* aObj, jsid aId, unsigned aFlags,
Resolve(JSContext* aCx, JSHandleObject aObj, JSHandleId aId, unsigned aFlags,
JSObject** aObjp)
{
JSBool resolved;
@ -821,7 +821,7 @@ private:
return false;
}
*aObjp = resolved ? aObj : NULL;
*aObjp = resolved ? aObj.value() : NULL;
return true;
}

Просмотреть файл

@ -44,7 +44,7 @@ AssertIsOnMainThread()
// All of these are implemented in RuntimeService.cpp
JSBool
ResolveWorkerClasses(JSContext* aCx, JSObject* aObj, jsid aId, unsigned aFlags,
ResolveWorkerClasses(JSContext* aCx, JSHandleObject aObj, JSHandleId aId, unsigned aFlags,
JSObject** aObjp);
void

Просмотреть файл

@ -74,7 +74,7 @@ extern "C" {
#endif
static JSBool
global_enumerate(JSContext *cx, JSObject *obj)
global_enumerate(JSContext *cx, JSHandleObject obj)
{
#ifdef LAZY_STANDARD_CLASSES
return JS_EnumerateStandardClasses(cx, obj);
@ -84,7 +84,7 @@ global_enumerate(JSContext *cx, JSObject *obj)
}
static JSBool
global_resolve(JSContext *cx, JSObject *obj, jsval id, unsigned flags, JSObject **objp)
global_resolve(JSContext *cx, JSHandleObject obj, JSHandleId id, unsigned flags, JSObject **objp)
{
#ifdef LAZY_STANDARD_CLASSES
if ((flags & JSRESOLVE_ASSIGNING) == 0) {

Просмотреть файл

@ -278,8 +278,7 @@ nsBMPDecoder::WriteInternal(const char* aBuffer, PRUint32 aCount)
// Post our size to the superclass
PostSize(mBIH.width, real_height);
if (HasError()) {
// Setting the size lead to an error; this can happen when for example
// a multipart channel sends an image of a different size.
// Setting the size led to an error.
return;
}

Просмотреть файл

@ -920,8 +920,7 @@ nsGIFDecoder2::WriteInternal(const char *aBuffer, PRUint32 aCount)
// Create the image container with the right size.
BeginGIF();
if (HasError()) {
// Setting the size lead to an error; this can happen when for example
// a multipart channel sends an image of a different size.
// Setting the size led to an error.
mGIFStruct.state = gif_error;
return;
}

Просмотреть файл

@ -101,8 +101,7 @@ nsIconDecoder::WriteInternal(const char *aBuffer, PRUint32 aCount)
// Post our size to the superclass
PostSize(mWidth, mHeight);
if (HasError()) {
// Setting the size lead to an error; this can happen when for example
// a multipart channel sends an image of a different size.
// Setting the size led to an error.
mState = iconStateFinished;
return;
}

Просмотреть файл

@ -263,8 +263,7 @@ nsJPEGDecoder::WriteInternal(const char *aBuffer, PRUint32 aCount)
// Post our size to the superclass
PostSize(mInfo.image_width, mInfo.image_height);
if (HasError()) {
// Setting the size lead to an error; this can happen when for example
// a multipart channel sends an image of a different size.
// Setting the size led to an error.
mState = JPEG_ERROR;
return;
}

Просмотреть файл

@ -519,8 +519,7 @@ nsPNGDecoder::info_callback(png_structp png_ptr, png_infop info_ptr)
// Post our size to the superclass
decoder->PostSize(width, height);
if (decoder->HasError()) {
// Setting the size lead to an error; this can happen when for example
// a multipart channel sends an image of a different size.
// Setting the size led to an error.
longjmp(png_jmpbuf(decoder->mPNG), 1);
}

Просмотреть файл

@ -52,7 +52,7 @@ interface nsIPrincipal;
* @version 0.1
* @see imagelib2
*/
[scriptable, uuid(d35a9adb-8328-4b64-b06f-72a165acd080)]
[scriptable, uuid(a5a785a8-9881-11e1-aaff-001fbc092072)]
interface imgIRequest : nsIRequest
{
/**
@ -132,6 +132,11 @@ interface imgIRequest : nsIRequest
*/
readonly attribute nsIPrincipal imagePrincipal;
/**
* Whether the request is multipart (ie, multipart/x-mixed-replace)
*/
readonly attribute bool multipart;
/**
* CORS modes images can be loaded with.
*

Просмотреть файл

@ -343,7 +343,7 @@ RasterImage::AdvanceFrame(TimeStamp aTime, nsIntRect* aDirtyRect)
// If we don't have a decoder, we know we've got everything we're going to
// get. If we do, we only display fully-downloaded frames; everything else
// gets delayed.
bool haveFullNextFrame = !mDecoder ||
bool haveFullNextFrame = (mMultipart && mBytesDecoded == 0) || !mDecoder ||
nextFrameIndex < mDecoder->GetCompleteFrameCount();
// If we're done decoding the next frame, go ahead and display it now and
@ -1136,14 +1136,9 @@ RasterImage::SetSize(PRInt32 aWidth, PRInt32 aHeight)
return NS_ERROR_INVALID_ARG;
// if we already have a size, check the new size against the old one
if (mHasSize &&
if (!mMultipart && mHasSize &&
((aWidth != mSize.width) || (aHeight != mSize.height))) {
// Alter the warning depending on whether the channel is multipart
if (!mMultipart)
NS_WARNING("Image changed size on redecode! This should not happen!");
else
NS_WARNING("Multipart channel sent an image of a different size");
NS_WARNING("Image changed size on redecode! This should not happen!");
// Make the decoder aware of the error so that it doesn't try to call
// FinishInternal during ShutdownDecoder.
@ -1215,10 +1210,14 @@ RasterImage::EnsureFrame(PRUint32 aFrameNum, PRInt32 aX, PRInt32 aY,
}
}
// Not reusable, so replace the frame directly.
DeleteImgFrame(aFrameNum);
return InternalAddFrame(aFrameNum, aX, aY, aWidth, aHeight, aFormat,
aPaletteDepth, imageData, imageLength,
paletteData, paletteLength);
mFrames.RemoveElementAt(aFrameNum);
nsAutoPtr<imgFrame> newFrame(new imgFrame());
nsresult rv = newFrame->Init(aX, aY, aWidth, aHeight, aFormat, aPaletteDepth);
NS_ENSURE_SUCCESS(rv, rv);
return InternalAddFrameHelper(aFrameNum, newFrame.forget(), imageData,
imageLength, paletteData, paletteLength);
}
nsresult
@ -1491,6 +1490,31 @@ RasterImage::AddSourceData(const char *aBuffer, PRUint32 aCount)
// This call should come straight from necko - no reentrancy allowed
NS_ABORT_IF_FALSE(!mInDecoder, "Re-entrant call to AddSourceData!");
// Starting a new part's frames, let's clean up before we add any
// This needs to happen just before we start getting EnsureFrame() call(s),
// so that there's no gap for anything to miss us.
if (mBytesDecoded == 0) {
// Our previous state may have been animated, so let's clean up
bool wasAnimating = mAnimating;
if (mAnimating) {
StopAnimation();
mAnimating = false;
}
mAnimationFinished = false;
if (mAnim) {
delete mAnim;
mAnim = nsnull;
}
// If there's only one frame, this could cause flickering
int old_frame_count = mFrames.Length();
if (old_frame_count > 1) {
for (int i = 0; i < old_frame_count; ++i) {
DeleteImgFrame(i);
}
mFrames.Clear();
}
}
// If we're not storing source data, write it directly to the decoder
if (!StoringSourceData()) {
rv = WriteToDecoder(aBuffer, aCount);
@ -1620,7 +1644,7 @@ RasterImage::SourceDataComplete()
}
nsresult
RasterImage::NewSourceData()
RasterImage::NewSourceData(const char* aMimeType)
{
nsresult rv;
@ -1655,6 +1679,8 @@ RasterImage::NewSourceData()
mDecoded = false;
mHasSourceData = false;
mSourceDataMimeType.Assign(aMimeType);
// We're decode-on-load here. Open up a new decoder just like what happens when
// we call Init() for decode-on-load images.
rv = InitDecoder(/* aDoSizeDecode = */ false);

Просмотреть файл

@ -304,7 +304,7 @@ public:
nsresult SourceDataComplete();
/* Called for multipart images when there's a new source image to add. */
nsresult NewSourceData();
nsresult NewSourceData(const char *aMimeType);
/**
* A hint of the number of bytes of source data that the image contains. If

Просмотреть файл

@ -182,7 +182,7 @@ nsresult imgRequest::Init(nsIURI *aURI,
imgStatusTracker&
imgRequest::GetStatusTracker()
{
if (mImage) {
if (mImage && mGotData) {
NS_ABORT_IF_FALSE(!mStatusTracker,
"Should have given mStatusTracker to mImage");
return mImage->GetStatusTracker();
@ -768,14 +768,19 @@ NS_IMETHODIMP imgRequest::OnStartRequest(nsIRequest *aRequest, nsISupports *ctxt
// If we're multipart, and our image is initialized, fix things up for another round
if (mIsMultiPartChannel && mImage) {
if (mImage->GetType() == imgIContainer::TYPE_RASTER) {
// Update the content type for this new part
nsCOMPtr<nsIChannel> partChan(do_QueryInterface(aRequest));
partChan->GetContentType(mContentType);
if (mContentType.EqualsLiteral(SVG_MIMETYPE) ||
mImage->GetType() == imgIContainer::TYPE_VECTOR) {
// mImage won't be reusable due to format change or a new SVG part
// Reset the tracker and forget that we have data for OnDataAvailable to
// treat its next call as a fresh image.
mStatusTracker = new imgStatusTracker(nsnull);
mGotData = false;
} else if (mImage->GetType() == imgIContainer::TYPE_RASTER) {
// Inform the RasterImage that we have new source data
static_cast<RasterImage*>(mImage.get())->NewSourceData();
} else { // imageType == imgIContainer::TYPE_VECTOR
nsCOMPtr<nsIStreamListener> imageAsStream = do_QueryInterface(mImage);
NS_ABORT_IF_FALSE(imageAsStream,
"SVG-typed Image failed QI to nsIStreamListener");
imageAsStream->OnStartRequest(aRequest, ctxt);
static_cast<RasterImage*>(mImage.get())->NewSourceData(mContentType.get());
}
}

Просмотреть файл

@ -131,6 +131,8 @@ public:
// wins.
static void SetCacheValidation(imgCacheEntry* aEntry, nsIRequest* aRequest);
bool GetMultipart() const { return mIsMultiPartChannel; }
// The CORS mode for which we loaded this image.
PRInt32 GetCORSMode() const { return mCORSMode; }

Просмотреть файл

@ -558,6 +558,17 @@ NS_IMETHODIMP imgRequestProxy::GetImagePrincipal(nsIPrincipal **aPrincipal)
return NS_OK;
}
/* readonly attribute bool multipart; */
NS_IMETHODIMP imgRequestProxy::GetMultipart(bool *aMultipart)
{
if (!mOwner)
return NS_ERROR_FAILURE;
*aMultipart = mOwner->GetMultipart();
return NS_OK;
}
/* readonly attribute PRInt32 CORSMode; */
NS_IMETHODIMP imgRequestProxy::GetCORSMode(PRInt32* aCorsMode)
{
@ -695,6 +706,10 @@ void imgRequestProxy::OnStopContainer(imgIContainer *image)
nsCOMPtr<imgIDecoderObserver> kungFuDeathGrip(mListener);
mListener->OnStopContainer(this, image);
}
// Multipart needs reset for next OnStartContainer
if (mOwner && mOwner->GetMultipart())
mSentStartContainer = false;
}
void imgRequestProxy::OnStopDecode(nsresult status, const PRUnichar *statusArg)
@ -880,7 +895,8 @@ void
imgRequestProxy::SetImage(Image* aImage)
{
NS_ABORT_IF_FALSE(aImage, "Setting null image");
NS_ABORT_IF_FALSE(!mImage, "Setting image when we already have one");
NS_ABORT_IF_FALSE(!mImage || mOwner->GetMultipart(),
"Setting image when we already have one");
mImage = aImage;

Просмотреть файл

@ -253,7 +253,7 @@ private:
bool mDeferNotifications;
// We only want to send OnStartContainer once for each proxy, but we might
// get multiple OnStartContainer calls (e.g. from multipart/x-mixed-replace).
// get multiple OnStartContainer calls.
bool mSentStartContainer;
};

Просмотреть файл

@ -86,6 +86,10 @@ _TEST_FILES = imgutils.js \
bug671906-iframe.html \
bug671906.sjs \
test_bug671906.html \
test_bug733553.html \
bug733553-iframe.html \
bug733553.sjs \
animated-gif2.gif \
test_error_events.html \
error-early.png \
test_drawDiscardedImage.html \

Просмотреть файл

@ -0,0 +1,7 @@
<html>
<head>
<title>Bug 733553 iframe</title>
<body>
<img src="bug733553.sjs" id="image1" />
</body>
</html>

Просмотреть файл

@ -0,0 +1,77 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
var bodyPartIndex = 0;
var bodyParts = [
["red.png", "image/png"],
["red.png", "image/png"], // Tests actually begin here
["animated-gif2.gif", "image/gif"],
["red.png", "image/png"],
["lime100x100.svg", "image/svg+xml"],
["big.png", "image/png"],
["animated-gif2.gif", "image/gif"],
["red.png", "image/png"],
["lime100x100.svg", "image/svg+xml"]
];
var timer = Components.classes["@mozilla.org/timer;1"];
var partTimer = timer.createInstance(Components.interfaces.nsITimer);
function getFileAsInputStream(aFilename) {
var file = Components.classes["@mozilla.org/file/directory_service;1"]
.getService(Components.interfaces.nsIProperties)
.get("CurWorkD", Components.interfaces.nsIFile);
file.append("tests");
file.append("image");
file.append("test");
file.append("mochitest");
file.append(aFilename);
var fileStream = Components.classes['@mozilla.org/network/file-input-stream;1']
.createInstance(Components.interfaces.nsIFileInputStream);
fileStream.init(file, 1, 0, false);
return fileStream;
}
function handleRequest(request, response)
{
response.setHeader("Content-Type",
"multipart/x-mixed-replace;boundary=BOUNDARYOMG", false);
response.setHeader("Cache-Control", "no-cache", false);
response.setStatusLine(request.httpVersion, 200, "OK");
// We're sending parts off in a delayed fashion, to let the tests occur.
response.processAsync();
response.write("--BOUNDARYOMG\r\n");
sendParts(response);
}
function sendParts(response) {
if (bodyParts.length > bodyPartIndex) {
partTimer.initWithCallback(getSendNextPart(response), 1000,
Components.interfaces.nsITimer.TYPE_ONE_SHOT);
}
else {
sendClose(response);
}
}
function sendClose(response) {
response.write("--BOUNDARYOMG--\r\n");
response.finish();
}
function getSendNextPart(response) {
var part = bodyParts[bodyPartIndex++];
var nextPartHead = "Content-Type: " + part[1] + "\r\n\r\n";
var inputStream = getFileAsInputStream(part[0]);
return function () {
response.bodyOutputStream.write(nextPartHead, nextPartHead.length);
response.bodyOutputStream.writeFrom(inputStream, inputStream.available());
inputStream.close();
// Toss in the boundary, so the browser can know this part is complete
response.write("--BOUNDARYOMG\r\n");
sendParts(response);
}
}

Просмотреть файл

@ -0,0 +1,55 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=733553
-->
<head>
<title>Test for Bug 733553</title>
<script type="application/javascript" src="/MochiKit/MochiKit.js"></script>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=733553">Mozilla Bug 733553</a>
<p id="display"></p>
<pre id="test">
<script type="application/javascript">
SimpleTest.waitForExplicitFinish();
var testIndex = 0;
var testParts = [
[1, "red.png"],
[40, "animated-gif2.gif"],
[1, "red.png"],
[100, "lime100x100.svg"],
[3000, "big.png"],
[40, "animated-gif2.gif"],
[1, "red.png"]
];
function initializeOnload() {
var iframeelem = document.getElementById('test-iframe');
var firstimg = iframeelem.contentDocument.getElementById('image1');
firstimg.addEventListener("load", imageLoad, false);
}
function imageLoad(aEvent) {
if (testParts.length > testIndex) {
var [width, fileName] = testParts[testIndex++];
is(aEvent.target.width, width,
"Test " + (testIndex - 1) + " " + fileName + " width not correct");
}
else {
aEvent.target.removeEventListener("load", arguments.callee, false);
SimpleTest.finish();
}
}
</script>
</pre>
<div id="content"> <!-- style="display: none" -->
<iframe id="test-iframe" src="http://mochi.test:8888/tests/image/test/mochitest/bug733553-iframe.html" onload="initializeOnload()"></iframe>
</div>
</body>
</html>

Просмотреть файл

@ -386,7 +386,7 @@ jsval_to_nsString(JSContext* cx, jsid from, nsString* to)
}
/*static*/ JSBool
ObjectWrapperParent::CPOW_AddProperty(JSContext *cx, JSObject *obj, jsid id,
ObjectWrapperParent::CPOW_AddProperty(JSContext *cx, JSHandleObject obj, JSHandleId id,
jsval *vp)
{
CPOW_LOG(("Calling CPOW_AddProperty (%s)...",
@ -413,7 +413,7 @@ ObjectWrapperParent::CPOW_AddProperty(JSContext *cx, JSObject *obj, jsid id,
}
/*static*/ JSBool
ObjectWrapperParent::CPOW_GetProperty(JSContext *cx, JSObject *obj, jsid id,
ObjectWrapperParent::CPOW_GetProperty(JSContext *cx, JSHandleObject obj, JSHandleId id,
jsval *vp)
{
CPOW_LOG(("Calling CPOW_GetProperty (%s)...",
@ -440,7 +440,7 @@ ObjectWrapperParent::CPOW_GetProperty(JSContext *cx, JSObject *obj, jsid id,
}
/*static*/ JSBool
ObjectWrapperParent::CPOW_SetProperty(JSContext *cx, JSObject *obj, jsid id,
ObjectWrapperParent::CPOW_SetProperty(JSContext *cx, JSHandleObject obj, JSHandleId id,
JSBool strict, jsval *vp)
{
CPOW_LOG(("Calling CPOW_SetProperty (%s)...",
@ -469,7 +469,7 @@ ObjectWrapperParent::CPOW_SetProperty(JSContext *cx, JSObject *obj, jsid id,
}
/*static*/ JSBool
ObjectWrapperParent::CPOW_DelProperty(JSContext *cx, JSObject *obj, jsid id,
ObjectWrapperParent::CPOW_DelProperty(JSContext *cx, JSHandleObject obj, JSHandleId id,
jsval *vp)
{
CPOW_LOG(("Calling CPOW_DelProperty (%s)...",
@ -550,7 +550,7 @@ ObjectWrapperParent::NewEnumerateDestroy(JSContext* cx, jsval state)
}
/*static*/ JSBool
ObjectWrapperParent::CPOW_NewEnumerate(JSContext *cx, JSObject *obj,
ObjectWrapperParent::CPOW_NewEnumerate(JSContext *cx, JSHandleObject obj,
JSIterateOp enum_op, jsval *statep,
jsid *idp)
{
@ -576,7 +576,7 @@ ObjectWrapperParent::CPOW_NewEnumerate(JSContext *cx, JSObject *obj,
}
/*static*/ JSBool
ObjectWrapperParent::CPOW_NewResolve(JSContext *cx, JSObject *obj, jsid id,
ObjectWrapperParent::CPOW_NewResolve(JSContext *cx, JSHandleObject obj, JSHandleId id,
unsigned flags, JSObject **objp)
{
CPOW_LOG(("Calling CPOW_NewResolve (%s)...",
@ -611,7 +611,7 @@ ObjectWrapperParent::CPOW_NewResolve(JSContext *cx, JSObject *obj, jsid id,
}
/*static*/ JSBool
ObjectWrapperParent::CPOW_Convert(JSContext *cx, JSObject *obj, JSType type,
ObjectWrapperParent::CPOW_Convert(JSContext *cx, JSHandleObject obj, JSType type,
jsval *vp)
{
CPOW_LOG(("Calling CPOW_Convert (to %s)...",
@ -704,7 +704,7 @@ ObjectWrapperParent::CPOW_Construct(JSContext* cx, unsigned argc, jsval* vp)
}
/*static*/ JSBool
ObjectWrapperParent::CPOW_HasInstance(JSContext *cx, JSObject *obj, const jsval *v,
ObjectWrapperParent::CPOW_HasInstance(JSContext *cx, JSHandleObject obj, const jsval *v,
JSBool *bp)
{
CPOW_LOG(("Calling CPOW_HasInstance..."));
@ -729,7 +729,7 @@ ObjectWrapperParent::CPOW_HasInstance(JSContext *cx, JSObject *obj, const jsval
}
/*static*/ JSBool
ObjectWrapperParent::CPOW_Equality(JSContext *cx, JSObject *obj, const jsval *v,
ObjectWrapperParent::CPOW_Equality(JSContext *cx, JSHandleObject obj, const jsval *v,
JSBool *bp)
{
CPOW_LOG(("Calling CPOW_Equality..."));

Просмотреть файл

@ -93,30 +93,30 @@ private:
mutable JSObject* mObj;
static JSBool
CPOW_AddProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp);
CPOW_AddProperty(JSContext *cx, JSHandleObject obj, JSHandleId id, jsval *vp);
static JSBool
CPOW_DelProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp);
CPOW_DelProperty(JSContext *cx, JSHandleObject obj, JSHandleId id, jsval *vp);
static JSBool
CPOW_GetProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp);
CPOW_GetProperty(JSContext *cx, JSHandleObject obj, JSHandleId id, jsval *vp);
static JSBool
CPOW_SetProperty(JSContext *cx, JSObject *obj, jsid id, JSBool strict, jsval *vp);
CPOW_SetProperty(JSContext *cx, JSHandleObject obj, JSHandleId id, JSBool strict, jsval *vp);
JSBool NewEnumerateInit(JSContext* cx, jsval* statep, jsid* idp);
JSBool NewEnumerateNext(JSContext* cx, jsval* statep, jsid* idp);
JSBool NewEnumerateDestroy(JSContext* cx, jsval state);
static JSBool
CPOW_NewEnumerate(JSContext *cx, JSObject *obj, JSIterateOp enum_op,
CPOW_NewEnumerate(JSContext *cx, JSHandleObject obj, JSIterateOp enum_op,
jsval *statep, jsid *idp);
static JSBool
CPOW_NewResolve(JSContext *cx, JSObject *obj, jsid id, unsigned flags,
CPOW_NewResolve(JSContext *cx, JSHandleObject obj, JSHandleId id, unsigned flags,
JSObject **objp);
static JSBool
CPOW_Convert(JSContext *cx, JSObject *obj, JSType type, jsval *vp);
CPOW_Convert(JSContext *cx, JSHandleObject obj, JSType type, jsval *vp);
static void
CPOW_Finalize(js::FreeOp* fop, JSObject* obj);
@ -128,10 +128,10 @@ private:
CPOW_Construct(JSContext *cx, unsigned argc, jsval *vp);
static JSBool
CPOW_HasInstance(JSContext *cx, JSObject *obj, const jsval *v, JSBool *bp);
CPOW_HasInstance(JSContext *cx, JSHandleObject obj, const jsval *v, JSBool *bp);
static JSBool
CPOW_Equality(JSContext *cx, JSObject *obj, const jsval *v, JSBool *bp);
CPOW_Equality(JSContext *cx, JSHandleObject obj, const jsval *v, JSBool *bp);
static bool jsval_to_JSVariant(JSContext* cx, jsval from, JSVariant* to);
static bool jsval_from_JSVariant(JSContext* cx, const JSVariant& from,

Просмотреть файл

@ -57,8 +57,8 @@ class RegExpMatchBuilder
RootedVarObject array;
bool setProperty(JSAtom *name, Value v) {
return !!js_DefineProperty(cx, array, AtomToId(name), &v,
JS_PropertyStub, JS_StrictPropertyStub, JSPROP_ENUMERATE);
return !!baseops::DefineProperty(cx, array, RootedVarId(cx, AtomToId(name)), &v,
JS_PropertyStub, JS_StrictPropertyStub, JSPROP_ENUMERATE);
}
public:
@ -66,8 +66,8 @@ class RegExpMatchBuilder
bool append(uint32_t index, Value v) {
JS_ASSERT(!array->getOps()->getElement);
return !!js_DefineElement(cx, array, index, &v, JS_PropertyStub, JS_StrictPropertyStub,
JSPROP_ENUMERATE);
return !!baseops::DefineElement(cx, array, index, &v, JS_PropertyStub, JS_StrictPropertyStub,
JSPROP_ENUMERATE);
}
bool setIndex(int index) {
@ -405,7 +405,7 @@ static JSFunctionSpec regexp_methods[] = {
#define DEFINE_STATIC_GETTER(name, code) \
static JSBool \
name(JSContext *cx, JSObject *obj, jsid id, jsval *vp) \
name(JSContext *cx, HandleObject obj, HandleId id, jsval *vp) \
{ \
RegExpStatics *res = cx->regExpStatics(); \
code; \
@ -431,7 +431,7 @@ DEFINE_STATIC_GETTER(static_paren9_getter, return res->createParen(cx, 9,
#define DEFINE_STATIC_SETTER(name, code) \
static JSBool \
name(JSContext *cx, JSObject *obj, jsid id, JSBool strict, jsval *vp) \
name(JSContext *cx, HandleObject obj, HandleId id, JSBool strict, jsval *vp)\
{ \
RegExpStatics *res = cx->regExpStatics(); \
code; \

Просмотреть файл

@ -87,17 +87,17 @@ namespace CType {
static void Finalize(JSFreeOp *fop, JSObject* obj);
static void FinalizeProtoClass(JSFreeOp *fop, JSObject* obj);
static JSBool PrototypeGetter(JSContext* cx, JSObject* obj, jsid idval,
static JSBool PrototypeGetter(JSContext* cx, JSHandleObject obj, JSHandleId idval,
jsval* vp);
static JSBool NameGetter(JSContext* cx, JSObject* obj, jsid idval,
static JSBool NameGetter(JSContext* cx, JSHandleObject obj, JSHandleId idval,
jsval* vp);
static JSBool SizeGetter(JSContext* cx, JSObject* obj, jsid idval,
static JSBool SizeGetter(JSContext* cx, JSHandleObject obj, JSHandleId idval,
jsval* vp);
static JSBool PtrGetter(JSContext* cx, JSObject* obj, jsid idval, jsval* vp);
static JSBool PtrGetter(JSContext* cx, JSHandleObject obj, JSHandleId idval, jsval* vp);
static JSBool CreateArray(JSContext* cx, unsigned argc, jsval* vp);
static JSBool ToString(JSContext* cx, unsigned argc, jsval* vp);
static JSBool ToSource(JSContext* cx, unsigned argc, jsval* vp);
static JSBool HasInstance(JSContext* cx, JSObject* obj, const jsval* v, JSBool* bp);
static JSBool HasInstance(JSContext* cx, JSHandleObject obj, const jsval* v, JSBool* bp);
/*
@ -120,11 +120,11 @@ namespace PointerType {
static JSBool Create(JSContext* cx, unsigned argc, jsval* vp);
static JSBool ConstructData(JSContext* cx, JSObject* obj, unsigned argc, jsval* vp);
static JSBool TargetTypeGetter(JSContext* cx, JSObject* obj, jsid idval,
static JSBool TargetTypeGetter(JSContext* cx, JSHandleObject obj, JSHandleId idval,
jsval* vp);
static JSBool ContentsGetter(JSContext* cx, JSObject* obj, jsid idval,
static JSBool ContentsGetter(JSContext* cx, JSHandleObject obj, JSHandleId idval,
jsval* vp);
static JSBool ContentsSetter(JSContext* cx, JSObject* obj, jsid idval, JSBool strict,
static JSBool ContentsSetter(JSContext* cx, JSHandleObject obj, JSHandleId idval, JSBool strict,
jsval* vp);
static JSBool IsNull(JSContext* cx, unsigned argc, jsval* vp);
static JSBool Increment(JSContext* cx, unsigned argc, jsval* vp);
@ -138,12 +138,12 @@ namespace ArrayType {
static JSBool Create(JSContext* cx, unsigned argc, jsval* vp);
static JSBool ConstructData(JSContext* cx, JSObject* obj, unsigned argc, jsval* vp);
static JSBool ElementTypeGetter(JSContext* cx, JSObject* obj, jsid idval,
static JSBool ElementTypeGetter(JSContext* cx, JSHandleObject obj, JSHandleId idval,
jsval* vp);
static JSBool LengthGetter(JSContext* cx, JSObject* obj, jsid idval,
static JSBool LengthGetter(JSContext* cx, JSHandleObject obj, JSHandleId idval,
jsval* vp);
static JSBool Getter(JSContext* cx, JSObject* obj, jsid idval, jsval* vp);
static JSBool Setter(JSContext* cx, JSObject* obj, jsid idval, JSBool strict, jsval* vp);
static JSBool Getter(JSContext* cx, JSHandleObject obj, JSHandleId idval, jsval* vp);
static JSBool Setter(JSContext* cx, JSHandleObject obj, JSHandleId idval, JSBool strict, jsval* vp);
static JSBool AddressOfElement(JSContext* cx, unsigned argc, jsval* vp);
}
@ -151,11 +151,11 @@ namespace StructType {
static JSBool Create(JSContext* cx, unsigned argc, jsval* vp);
static JSBool ConstructData(JSContext* cx, JSObject* obj, unsigned argc, jsval* vp);
static JSBool FieldsArrayGetter(JSContext* cx, JSObject* obj, jsid idval,
static JSBool FieldsArrayGetter(JSContext* cx, JSHandleObject obj, JSHandleId idval,
jsval* vp);
static JSBool FieldGetter(JSContext* cx, JSObject* obj, jsid idval,
static JSBool FieldGetter(JSContext* cx, JSHandleObject obj, JSHandleId idval,
jsval* vp);
static JSBool FieldSetter(JSContext* cx, JSObject* obj, jsid idval, JSBool strict,
static JSBool FieldSetter(JSContext* cx, JSHandleObject obj, JSHandleId idval, JSBool strict,
jsval* vp);
static JSBool AddressOfField(JSContext* cx, unsigned argc, jsval* vp);
static JSBool Define(JSContext* cx, unsigned argc, jsval* vp);
@ -168,12 +168,12 @@ namespace FunctionType {
static JSBool Call(JSContext* cx, unsigned argc, jsval* vp);
static JSBool ArgTypesGetter(JSContext* cx, JSObject* obj, jsid idval,
static JSBool ArgTypesGetter(JSContext* cx, JSHandleObject obj, JSHandleId idval,
jsval* vp);
static JSBool ReturnTypeGetter(JSContext* cx, JSObject* obj, jsid idval,
static JSBool ReturnTypeGetter(JSContext* cx, JSHandleObject obj, JSHandleId idval,
jsval* vp);
static JSBool ABIGetter(JSContext* cx, JSObject* obj, jsid idval, jsval* vp);
static JSBool IsVariadicGetter(JSContext* cx, JSObject* obj, jsid idval,
static JSBool ABIGetter(JSContext* cx, JSHandleObject obj, JSHandleId idval, jsval* vp);
static JSBool IsVariadicGetter(JSContext* cx, JSHandleObject obj, JSHandleId idval,
jsval* vp);
}
@ -189,20 +189,20 @@ namespace CClosure {
namespace CData {
static void Finalize(JSFreeOp *fop, JSObject* obj);
static JSBool ValueGetter(JSContext* cx, JSObject* obj, jsid idval,
static JSBool ValueGetter(JSContext* cx, JSHandleObject obj, JSHandleId idval,
jsval* vp);
static JSBool ValueSetter(JSContext* cx, JSObject* obj, jsid idval,
static JSBool ValueSetter(JSContext* cx, JSHandleObject obj, JSHandleId idval,
JSBool strict, jsval* vp);
static JSBool Address(JSContext* cx, unsigned argc, jsval* vp);
static JSBool ReadString(JSContext* cx, unsigned argc, jsval* vp);
static JSBool ToSource(JSContext* cx, unsigned argc, jsval* vp);
static JSString *GetSourceString(JSContext *cx, JSObject *typeObj,
void *data);
static JSBool ErrnoGetter(JSContext* cx, JSObject *obj, jsid idval,
static JSBool ErrnoGetter(JSContext* cx, JSHandleObject obj, JSHandleId idval,
jsval* vp);
#if defined(XP_WIN)
static JSBool LastErrorGetter(JSContext* cx, JSObject *obj, jsid idval,
static JSBool LastErrorGetter(JSContext* cx, JSHandleObject obj, JSHandleId idval,
jsval* vp);
#endif // defined(XP_WIN)
}
@ -3378,7 +3378,7 @@ CType::GetProtoFromType(JSObject* obj, CTypeProtoSlot slot)
}
JSBool
CType::PrototypeGetter(JSContext* cx, JSObject* obj, jsid idval, jsval* vp)
CType::PrototypeGetter(JSContext* cx, JSHandleObject obj, JSHandleId idval, jsval* vp)
{
if (!(CType::IsCType(obj) || CType::IsCTypeProto(obj))) {
JS_ReportError(cx, "not a CType or CTypeProto");
@ -3393,7 +3393,7 @@ CType::PrototypeGetter(JSContext* cx, JSObject* obj, jsid idval, jsval* vp)
}
JSBool
CType::NameGetter(JSContext* cx, JSObject* obj, jsid idval, jsval* vp)
CType::NameGetter(JSContext* cx, JSHandleObject obj, JSHandleId idval, jsval* vp)
{
if (!CType::IsCType(obj)) {
JS_ReportError(cx, "not a CType");
@ -3409,7 +3409,7 @@ CType::NameGetter(JSContext* cx, JSObject* obj, jsid idval, jsval* vp)
}
JSBool
CType::SizeGetter(JSContext* cx, JSObject* obj, jsid idval, jsval* vp)
CType::SizeGetter(JSContext* cx, JSHandleObject obj, JSHandleId idval, jsval* vp)
{
if (!CType::IsCType(obj)) {
JS_ReportError(cx, "not a CType");
@ -3422,7 +3422,7 @@ CType::SizeGetter(JSContext* cx, JSObject* obj, jsid idval, jsval* vp)
}
JSBool
CType::PtrGetter(JSContext* cx, JSObject* obj, jsid idval, jsval* vp)
CType::PtrGetter(JSContext* cx, JSHandleObject obj, JSHandleId idval, jsval* vp)
{
if (!CType::IsCType(obj)) {
JS_ReportError(cx, "not a CType");
@ -3530,7 +3530,7 @@ CType::ToSource(JSContext* cx, unsigned argc, jsval* vp)
}
JSBool
CType::HasInstance(JSContext* cx, JSObject* obj, const jsval* v, JSBool* bp)
CType::HasInstance(JSContext* cx, JSHandleObject obj, const jsval* v, JSBool* bp)
{
JS_ASSERT(CType::IsCType(obj));
@ -3774,8 +3774,8 @@ PointerType::GetBaseType(JSObject* obj)
JSBool
PointerType::TargetTypeGetter(JSContext* cx,
JSObject* obj,
jsid idval,
JSHandleObject obj,
JSHandleId idval,
jsval* vp)
{
if (!CType::IsCType(obj) || CType::GetTypeCode(obj) != TYPE_pointer) {
@ -3862,8 +3862,8 @@ PointerType::Decrement(JSContext* cx, unsigned argc, jsval* vp)
JSBool
PointerType::ContentsGetter(JSContext* cx,
JSObject* obj,
jsid idval,
JSHandleObject obj,
JSHandleId idval,
jsval* vp)
{
if (!CData::IsCData(obj)) {
@ -3900,8 +3900,8 @@ PointerType::ContentsGetter(JSContext* cx,
JSBool
PointerType::ContentsSetter(JSContext* cx,
JSObject* obj,
jsid idval,
JSHandleObject obj,
JSHandleId idval,
JSBool strict,
jsval* vp)
{
@ -4219,7 +4219,7 @@ ArrayType::BuildFFIType(JSContext* cx, JSObject* obj)
}
JSBool
ArrayType::ElementTypeGetter(JSContext* cx, JSObject* obj, jsid idval, jsval* vp)
ArrayType::ElementTypeGetter(JSContext* cx, JSHandleObject obj, JSHandleId idval, jsval* vp)
{
if (!CType::IsCType(obj) || CType::GetTypeCode(obj) != TYPE_array) {
JS_ReportError(cx, "not an ArrayType");
@ -4232,8 +4232,10 @@ ArrayType::ElementTypeGetter(JSContext* cx, JSObject* obj, jsid idval, jsval* vp
}
JSBool
ArrayType::LengthGetter(JSContext* cx, JSObject* obj, jsid idval, jsval* vp)
ArrayType::LengthGetter(JSContext* cx, JSHandleObject obj_, JSHandleId idval, jsval* vp)
{
JSObject *obj = obj_;
// This getter exists for both CTypes and CDatas of the ArrayType persuasion.
// If we're dealing with a CData, get the CType from it.
if (CData::IsCData(obj))
@ -4250,7 +4252,7 @@ ArrayType::LengthGetter(JSContext* cx, JSObject* obj, jsid idval, jsval* vp)
}
JSBool
ArrayType::Getter(JSContext* cx, JSObject* obj, jsid idval, jsval* vp)
ArrayType::Getter(JSContext* cx, JSHandleObject obj, JSHandleId idval, jsval* vp)
{
// This should never happen, but we'll check to be safe.
if (!CData::IsCData(obj)) {
@ -4286,7 +4288,7 @@ ArrayType::Getter(JSContext* cx, JSObject* obj, jsid idval, jsval* vp)
}
JSBool
ArrayType::Setter(JSContext* cx, JSObject* obj, jsid idval, JSBool strict, jsval* vp)
ArrayType::Setter(JSContext* cx, JSHandleObject obj, JSHandleId idval, JSBool strict, jsval* vp)
{
// This should never happen, but we'll check to be safe.
if (!CData::IsCData(obj)) {
@ -4874,7 +4876,7 @@ StructType::BuildFieldsArray(JSContext* cx, JSObject* obj)
}
JSBool
StructType::FieldsArrayGetter(JSContext* cx, JSObject* obj, jsid idval, jsval* vp)
StructType::FieldsArrayGetter(JSContext* cx, JSHandleObject obj, JSHandleId idval, jsval* vp)
{
if (!CType::IsCType(obj) || CType::GetTypeCode(obj) != TYPE_struct) {
JS_ReportError(cx, "not a StructType");
@ -4904,7 +4906,7 @@ StructType::FieldsArrayGetter(JSContext* cx, JSObject* obj, jsid idval, jsval* v
}
JSBool
StructType::FieldGetter(JSContext* cx, JSObject* obj, jsid idval, jsval* vp)
StructType::FieldGetter(JSContext* cx, JSHandleObject obj, JSHandleId idval, jsval* vp)
{
if (!CData::IsCData(obj)) {
JS_ReportError(cx, "not a CData");
@ -4926,7 +4928,7 @@ StructType::FieldGetter(JSContext* cx, JSObject* obj, jsid idval, jsval* vp)
}
JSBool
StructType::FieldSetter(JSContext* cx, JSObject* obj, jsid idval, JSBool strict, jsval* vp)
StructType::FieldSetter(JSContext* cx, JSHandleObject obj, JSHandleId idval, JSBool strict, jsval* vp)
{
if (!CData::IsCData(obj)) {
JS_ReportError(cx, "not a CData");
@ -5642,7 +5644,7 @@ CheckFunctionType(JSContext* cx, JSObject* obj)
}
JSBool
FunctionType::ArgTypesGetter(JSContext* cx, JSObject* obj, jsid idval, jsval* vp)
FunctionType::ArgTypesGetter(JSContext* cx, JSHandleObject obj, JSHandleId idval, jsval* vp)
{
if (!CheckFunctionType(cx, obj))
return JS_FALSE;
@ -5677,7 +5679,7 @@ FunctionType::ArgTypesGetter(JSContext* cx, JSObject* obj, jsid idval, jsval* vp
}
JSBool
FunctionType::ReturnTypeGetter(JSContext* cx, JSObject* obj, jsid idval, jsval* vp)
FunctionType::ReturnTypeGetter(JSContext* cx, JSHandleObject obj, JSHandleId idval, jsval* vp)
{
if (!CheckFunctionType(cx, obj))
return JS_FALSE;
@ -5688,7 +5690,7 @@ FunctionType::ReturnTypeGetter(JSContext* cx, JSObject* obj, jsid idval, jsval*
}
JSBool
FunctionType::ABIGetter(JSContext* cx, JSObject* obj, jsid idval, jsval* vp)
FunctionType::ABIGetter(JSContext* cx, JSHandleObject obj, JSHandleId idval, jsval* vp)
{
if (!CheckFunctionType(cx, obj))
return JS_FALSE;
@ -5699,7 +5701,7 @@ FunctionType::ABIGetter(JSContext* cx, JSObject* obj, jsid idval, jsval* vp)
}
JSBool
FunctionType::IsVariadicGetter(JSContext* cx, JSObject* obj, jsid idval, jsval* vp)
FunctionType::IsVariadicGetter(JSContext* cx, JSHandleObject obj, JSHandleId idval, jsval* vp)
{
if (!CheckFunctionType(cx, obj))
return JS_FALSE;
@ -6145,7 +6147,7 @@ CData::IsCDataProto(JSObject* obj)
}
JSBool
CData::ValueGetter(JSContext* cx, JSObject* obj, jsid idval, jsval* vp)
CData::ValueGetter(JSContext* cx, JSHandleObject obj, JSHandleId idval, jsval* vp)
{
if (!IsCData(obj)) {
JS_ReportError(cx, "not a CData");
@ -6160,7 +6162,7 @@ CData::ValueGetter(JSContext* cx, JSObject* obj, jsid idval, jsval* vp)
}
JSBool
CData::ValueSetter(JSContext* cx, JSObject* obj, jsid idval, JSBool strict, jsval* vp)
CData::ValueSetter(JSContext* cx, JSHandleObject obj, JSHandleId idval, JSBool strict, jsval* vp)
{
if (!IsCData(obj)) {
JS_ReportError(cx, "not a CData");
@ -6427,7 +6429,7 @@ CData::ToSource(JSContext* cx, unsigned argc, jsval* vp)
}
JSBool
CData::ErrnoGetter(JSContext* cx, JSObject* obj, jsid, jsval* vp)
CData::ErrnoGetter(JSContext* cx, JSHandleObject obj, JSHandleId, jsval* vp)
{
if (!IsCTypesGlobal(obj)) {
JS_ReportError(cx, "this is not not global object ctypes");
@ -6440,7 +6442,7 @@ CData::ErrnoGetter(JSContext* cx, JSObject* obj, jsid, jsval* vp)
#if defined(XP_WIN)
JSBool
CData::LastErrorGetter(JSContext* cx, JSObject* obj, jsid, jsval* vp)
CData::LastErrorGetter(JSContext* cx, JSHandleObject obj, JSHandleId, jsval* vp)
{
if (!IsCTypesGlobal(obj)) {
JS_ReportError(cx, "not global object ctypes");

Просмотреть файл

@ -3722,11 +3722,13 @@ ParseNode::getConstantValue(JSContext *cx, bool strictChecks, Value *vp)
return false;
unsigned idx = 0;
RootedVarId id(cx);
for (ParseNode *pn = pn_head; pn; idx++, pn = pn->pn_next) {
Value value;
if (!pn->getConstantValue(cx, strictChecks, &value))
return false;
if (!obj->defineGeneric(cx, INT_TO_JSID(idx), value, NULL, NULL, JSPROP_ENUMERATE))
id = INT_TO_JSID(idx);
if (!obj->defineGeneric(cx, id, value, NULL, NULL, JSPROP_ENUMERATE))
return false;
}
JS_ASSERT(idx == pn_count);
@ -3751,17 +3753,17 @@ ParseNode::getConstantValue(JSContext *cx, bool strictChecks, Value *vp)
ParseNode *pnid = pn->pn_left;
if (pnid->isKind(PNK_NUMBER)) {
Value idvalue = NumberValue(pnid->pn_dval);
jsid id;
RootedVarId id(cx);
if (idvalue.isInt32() && INT_FITS_IN_JSID(idvalue.toInt32()))
id = INT_TO_JSID(idvalue.toInt32());
else if (!InternNonIntElementId(cx, obj, idvalue, &id))
else if (!InternNonIntElementId(cx, obj, idvalue, id.address()))
return false;
if (!obj->defineGeneric(cx, id, value, NULL, NULL, JSPROP_ENUMERATE))
return false;
} else {
JS_ASSERT(pnid->isKind(PNK_NAME) || pnid->isKind(PNK_STRING));
JS_ASSERT(pnid->pn_atom != cx->runtime->atomState.protoAtom);
jsid id = AtomToId(pnid->pn_atom);
RootedVarId id(cx, AtomToId(pnid->pn_atom));
if (!DefineNativeProperty(cx, obj, id, value, NULL, NULL,
JSPROP_ENUMERATE, 0, 0)) {
return false;
@ -5764,7 +5766,7 @@ EmitObject(JSContext *cx, BytecodeEmitter *bce, ParseNode *pn)
if (obj) {
JS_ASSERT(!obj->inDictionaryMode());
if (!DefineNativeProperty(cx, obj, AtomToId(pn3->pn_atom),
if (!DefineNativeProperty(cx, obj, RootedVarId(cx, AtomToId(pn3->pn_atom)),
UndefinedValue(), NULL, NULL,
JSPROP_ENUMERATE, 0, 0))
{

Просмотреть файл

@ -136,11 +136,11 @@ class Handle
template <typename S> inline Handle(const Root<S> &root);
template <typename S> inline Handle(const RootedVar<S> &root);
const T *address() { return ptr; }
T value() { return *ptr; }
const T *address() const { return ptr; }
T value() const { return *ptr; }
operator T () { return value(); }
T operator ->() { return value(); }
operator T () const { return value(); }
T operator ->() const { return value(); }
private:
Handle() {}

Просмотреть файл

@ -10,7 +10,7 @@ static const int expectedCount = 100;
static int callCount = 0;
static JSBool
addProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
addProperty(JSContext *cx, JS::HandleObject obj, JS::HandleId id, jsval *vp)
{
callCount++;
return true;

Просмотреть файл

@ -9,7 +9,7 @@
int called_test_fn;
int called_test_prop_get;
static JSBool test_prop_get( JSContext *cx, JSObject *obj, jsid id, jsval *vp )
static JSBool test_prop_get( JSContext *cx, JS::HandleObject obj, JS::HandleId id, jsval *vp )
{
called_test_prop_get++;
return JS_TRUE;

Просмотреть файл

@ -14,7 +14,7 @@ IterNext(JSContext *cx, unsigned argc, jsval *vp)
}
static JSObject *
IterHook(JSContext *cx, JSObject *obj, JSBool keysonly)
IterHook(JSContext *cx, JS::HandleObject obj, JSBool keysonly)
{
JSObject *iterObj = JS_NewObject(cx, NULL, NULL, NULL);
if (!iterObj)

Просмотреть файл

@ -9,7 +9,7 @@
#include "jsobj.h"
static JSBool
my_Equality(JSContext *cx, JSObject *obj, const jsval *, JSBool *bp)
my_Equality(JSContext *cx, JS::HandleObject obj, const jsval *, JSBool *bp)
{
*bp = JS_TRUE;
return JS_TRUE;

Просмотреть файл

@ -34,7 +34,7 @@ BEGIN_TEST(testLookup_bug522590)
END_TEST(testLookup_bug522590)
JSBool
document_resolve(JSContext *cx, JSObject *obj, jsid id, unsigned flags, JSObject **objp)
document_resolve(JSContext *cx, JSHandleObject obj, JSHandleId id, unsigned flags, JSObject **objp)
{
// If id is "all", and we're not detecting, resolve document.all=true.
jsvalRoot v(cx);
@ -47,7 +47,7 @@ document_resolve(JSContext *cx, JSObject *obj, jsid id, unsigned flags, JSObject
return false;
if (JS_FlatStringEqualsAscii(flatStr, "all") && !(flags & JSRESOLVE_DETECTING)) {
JSBool ok = JS_DefinePropertyById(cx, obj, id, JSVAL_TRUE, NULL, NULL, 0);
*objp = ok ? obj : NULL;
*objp = ok ? obj.value() : NULL;
return ok;
}
}

Просмотреть файл

@ -7,7 +7,7 @@
#include "tests.h"
static JSBool
my_convert(JSContext* context, JSObject* obj, JSType type, jsval* rval)
my_convert(JSContext* context, JS::HandleObject obj, JSType type, jsval* rval)
{
if (type == JSTYPE_VOID || type == JSTYPE_STRING || type == JSTYPE_NUMBER || type == JSTYPE_BOOLEAN)
return JS_NewNumberValue(context, 123, rval);

Просмотреть файл

@ -7,7 +7,7 @@
static int g_counter;
static JSBool
CounterAdd(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
CounterAdd(JSContext *cx, JS::HandleObject obj, JS::HandleId id, jsval *vp)
{
g_counter++;
return JS_TRUE;

Просмотреть файл

@ -123,7 +123,7 @@ doResolve(JSObject *obj, jsid id, unsigned flags, JSObject **objp)
}
static JSBool
my_resolve(JSContext *cx, JSObject *obj, jsid id, unsigned flags, JSObject **objp)
my_resolve(JSContext *cx, JSHandleObject obj, JSHandleId id, unsigned flags, JSObject **objp)
{
return static_cast<cls_testResolveRecursion *>(JS_GetPrivate(obj))->
doResolve(obj, id, flags, objp);

Просмотреть файл

@ -5,7 +5,7 @@
#include "tests.h"
static JSBool
nativeGet(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
nativeGet(JSContext *cx, JS::HandleObject obj, JS::HandleId id, jsval *vp)
{
*vp = INT_TO_JSVAL(17);
return JS_TRUE;

Просмотреть файл

@ -1788,7 +1788,7 @@ JS_InitStandardClasses(JSContext *cx, JSObject *obj)
#define EAGER_ATOM_AND_CLASP(name) EAGER_CLASS_ATOM(name), CLASP(name)
typedef struct JSStdName {
JSObjectOp init;
JSClassInitializerOp init;
size_t atomOffset; /* offset of atom pointer in JSAtomState */
Class *clasp;
} JSStdName;
@ -2116,7 +2116,7 @@ JS_EnumerateResolvedStandardClasses(JSContext *cx, JSObject *obj, JSIdArray *ida
int i, j, k;
PropertyName *name;
JSBool found;
JSObjectOp init;
JSClassInitializerOp init;
AssertNoGC(cx);
CHECK_REQUEST(cx);
@ -3098,31 +3098,31 @@ JS_DefaultValue(JSContext *cx, JSObject *obj, JSType hint, jsval *vp)
}
JS_PUBLIC_API(JSBool)
JS_PropertyStub(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
JS_PropertyStub(JSContext *cx, JSHandleObject obj, JSHandleId id, jsval *vp)
{
return JS_TRUE;
}
JS_PUBLIC_API(JSBool)
JS_StrictPropertyStub(JSContext *cx, JSObject *obj, jsid id, JSBool strict, jsval *vp)
JS_StrictPropertyStub(JSContext *cx, JSHandleObject obj, JSHandleId id, JSBool strict, jsval *vp)
{
return JS_TRUE;
}
JS_PUBLIC_API(JSBool)
JS_EnumerateStub(JSContext *cx, JSObject *obj)
JS_EnumerateStub(JSContext *cx, JSHandleObject obj)
{
return JS_TRUE;
}
JS_PUBLIC_API(JSBool)
JS_ResolveStub(JSContext *cx, JSObject *obj, jsid id)
JS_ResolveStub(JSContext *cx, JSHandleObject obj, JSHandleId id)
{
return JS_TRUE;
}
JS_PUBLIC_API(JSBool)
JS_ConvertStub(JSContext *cx, JSObject *obj, JSType type, jsval *vp)
JS_ConvertStub(JSContext *cx, JSHandleObject obj, JSType type, jsval *vp)
{
JS_ASSERT(type != JSTYPE_OBJECT && type != JSTYPE_FUNCTION);
JS_ASSERT(obj);
@ -3175,8 +3175,10 @@ JS_InstanceOf(JSContext *cx, JSObject *obj, JSClass *clasp, jsval *argv)
}
JS_PUBLIC_API(JSBool)
JS_HasInstance(JSContext *cx, JSObject *obj, jsval v, JSBool *bp)
JS_HasInstance(JSContext *cx, JSObject *obj_, jsval v, JSBool *bp)
{
RootedVarObject obj(cx, obj_);
AssertNoGC(cx);
assertSameCompartment(cx, obj, v);
return HasInstance(cx, obj, &v, bp);
@ -3472,7 +3474,7 @@ JS_ConstructObjectWithArguments(JSContext *cx, JSClass *jsclasp, JSObject *paren
}
static JSBool
LookupPropertyById(JSContext *cx, JSObject *obj, jsid id, unsigned flags,
LookupPropertyById(JSContext *cx, JSObject *obj, HandleId id, unsigned flags,
JSObject **objp, JSProperty **propp)
{
AssertNoGC(cx);
@ -3523,8 +3525,10 @@ LookupResult(JSContext *cx, JSObject *obj, JSObject *obj2, jsid id,
}
JS_PUBLIC_API(JSBool)
JS_LookupPropertyById(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
JS_LookupPropertyById(JSContext *cx, JSObject *obj, jsid id_, jsval *vp)
{
RootedVarId id(cx, id_);
JSObject *obj2;
JSProperty *prop;
return LookupPropertyById(cx, obj, id, JSRESOLVE_QUALIFIED, &obj2, &prop) &&
@ -3556,9 +3560,12 @@ JS_LookupUCProperty(JSContext *cx, JSObject *obj, const jschar *name, size_t nam
}
JS_PUBLIC_API(JSBool)
JS_LookupPropertyWithFlagsById(JSContext *cx, JSObject *obj, jsid id, unsigned flags,
JS_LookupPropertyWithFlagsById(JSContext *cx, JSObject *obj_, jsid id_, unsigned flags,
JSObject **objp, jsval *vp)
{
RootedVarObject obj(cx, obj_);
RootedVarId id(cx, id_);
JSBool ok;
JSProperty *prop;
@ -3580,8 +3587,10 @@ JS_LookupPropertyWithFlags(JSContext *cx, JSObject *obj, const char *name, unsig
}
JS_PUBLIC_API(JSBool)
JS_HasPropertyById(JSContext *cx, JSObject *obj, jsid id, JSBool *foundp)
JS_HasPropertyById(JSContext *cx, JSObject *obj, jsid id_, JSBool *foundp)
{
RootedVarId id(cx, id_);
JSObject *obj2;
JSProperty *prop;
JSBool ok = LookupPropertyById(cx, obj, id, JSRESOLVE_QUALIFIED | JSRESOLVE_DETECTING,
@ -3616,8 +3625,10 @@ JS_HasUCProperty(JSContext *cx, JSObject *obj, const jschar *name, size_t namele
}
JS_PUBLIC_API(JSBool)
JS_AlreadyHasOwnPropertyById(JSContext *cx, JSObject *obj, jsid id, JSBool *foundp)
JS_AlreadyHasOwnPropertyById(JSContext *cx, JSObject *obj, jsid id_, JSBool *foundp)
{
RootedVarId id(cx, id_);
AssertNoGC(cx);
CHECK_REQUEST(cx);
assertSameCompartment(cx, obj, id);
@ -3888,7 +3899,7 @@ JS_DefineProperties(JSContext *cx, JSObject *obj, JSPropertySpec *ps)
}
static JSBool
GetPropertyDescriptorById(JSContext *cx, JSObject *obj, jsid id, unsigned flags,
GetPropertyDescriptorById(JSContext *cx, JSObject *obj, HandleId id, unsigned flags,
JSBool own, PropertyDescriptor *desc)
{
JSObject *obj2;
@ -3933,17 +3944,19 @@ GetPropertyDescriptorById(JSContext *cx, JSObject *obj, jsid id, unsigned flags,
}
JS_PUBLIC_API(JSBool)
JS_GetPropertyDescriptorById(JSContext *cx, JSObject *obj, jsid id, unsigned flags,
JS_GetPropertyDescriptorById(JSContext *cx, JSObject *obj, jsid id_, unsigned flags,
JSPropertyDescriptor *desc)
{
RootedVarId id(cx, id_);
return GetPropertyDescriptorById(cx, obj, id, flags, JS_FALSE, desc);
}
JS_PUBLIC_API(JSBool)
JS_GetPropertyAttrsGetterAndSetterById(JSContext *cx, JSObject *obj, jsid id,
JS_GetPropertyAttrsGetterAndSetterById(JSContext *cx, JSObject *obj, jsid id_,
unsigned *attrsp, JSBool *foundp,
JSPropertyOp *getterp, JSStrictPropertyOp *setterp)
{
RootedVarId id(cx, id_);
PropertyDescriptor desc;
if (!GetPropertyDescriptorById(cx, obj, id, JSRESOLVE_QUALIFIED, JS_FALSE, &desc))
return false;
@ -4005,7 +4018,7 @@ JS_GetOwnPropertyDescriptor(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
}
static JSBool
SetPropertyAttributesById(JSContext *cx, JSObject *obj, jsid id, unsigned attrs, JSBool *foundp)
SetPropertyAttributesById(JSContext *cx, JSObject *obj, HandleId id, unsigned attrs, JSBool *foundp)
{
JSObject *obj2;
JSProperty *prop;
@ -4030,7 +4043,7 @@ JS_SetPropertyAttributes(JSContext *cx, JSObject *obj, const char *name,
unsigned attrs, JSBool *foundp)
{
JSAtom *atom = js_Atomize(cx, name, strlen(name));
return atom && SetPropertyAttributesById(cx, obj, AtomToId(atom), attrs, foundp);
return atom && SetPropertyAttributesById(cx, obj, RootedVarId(cx, AtomToId(atom)), attrs, foundp);
}
JS_PUBLIC_API(JSBool)
@ -4038,7 +4051,7 @@ JS_SetUCPropertyAttributes(JSContext *cx, JSObject *obj, const jschar *name, siz
unsigned attrs, JSBool *foundp)
{
JSAtom *atom = js_AtomizeChars(cx, name, AUTO_NAMELEN(name, namelen));
return atom && SetPropertyAttributesById(cx, obj, AtomToId(atom), attrs, foundp);
return atom && SetPropertyAttributesById(cx, obj, RootedVarId(cx, AtomToId(atom)), attrs, foundp);
}
JS_PUBLIC_API(JSBool)
@ -4048,8 +4061,11 @@ JS_GetPropertyById(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
}
JS_PUBLIC_API(JSBool)
JS_ForwardGetPropertyTo(JSContext *cx, JSObject *obj, jsid id, JSObject *onBehalfOf, jsval *vp)
JS_ForwardGetPropertyTo(JSContext *cx, JSObject *obj, jsid id_, JSObject *onBehalfOf_, jsval *vp)
{
RootedVarId id(cx, id_);
RootedVarObject onBehalfOf(cx, onBehalfOf_);
AssertNoGC(cx);
CHECK_REQUEST(cx);
assertSameCompartment(cx, obj, id);
@ -4061,7 +4077,7 @@ JS_ForwardGetPropertyTo(JSContext *cx, JSObject *obj, jsid id, JSObject *onBehal
JS_PUBLIC_API(JSBool)
JS_GetPropertyByIdDefault(JSContext *cx, JSObject *obj, jsid id, jsval def, jsval *vp)
{
return GetPropertyDefault(cx, RootedVarObject(cx, obj), RootedVarId(cx, id), def, vp);
return baseops::GetPropertyDefault(cx, RootedVarObject(cx, obj), RootedVarId(cx, id), def, vp);
}
JS_PUBLIC_API(JSBool)
@ -4071,8 +4087,10 @@ JS_GetElement(JSContext *cx, JSObject *obj, uint32_t index, jsval *vp)
}
JS_PUBLIC_API(JSBool)
JS_ForwardGetElementTo(JSContext *cx, JSObject *obj, uint32_t index, JSObject *onBehalfOf, jsval *vp)
JS_ForwardGetElementTo(JSContext *cx, JSObject *obj, uint32_t index, JSObject *onBehalfOf_, jsval *vp)
{
RootedVarObject onBehalfOf(cx, onBehalfOf_);
AssertNoGC(cx);
CHECK_REQUEST(cx);
assertSameCompartment(cx, obj);
@ -4081,8 +4099,10 @@ JS_ForwardGetElementTo(JSContext *cx, JSObject *obj, uint32_t index, JSObject *o
}
JS_PUBLIC_API(JSBool)
JS_GetElementIfPresent(JSContext *cx, JSObject *obj, uint32_t index, JSObject *onBehalfOf, jsval *vp, JSBool* present)
JS_GetElementIfPresent(JSContext *cx, JSObject *obj, uint32_t index, JSObject *onBehalfOf_, jsval *vp, JSBool* present)
{
RootedVarObject onBehalfOf(cx, onBehalfOf_);
AssertNoGC(cx);
CHECK_REQUEST(cx);
assertSameCompartment(cx, obj);
@ -4119,12 +4139,15 @@ JS_GetUCProperty(JSContext *cx, JSObject *obj_, const jschar *name, size_t namel
}
JS_PUBLIC_API(JSBool)
JS_GetMethodById(JSContext *cx, JSObject *obj, jsid id, JSObject **objp, jsval *vp)
JS_GetMethodById(JSContext *cx, JSObject *obj_, jsid id_, JSObject **objp, jsval *vp)
{
RootedVarObject obj(cx, obj_);
RootedVarId id(cx, id_);
AssertNoGC(cx);
CHECK_REQUEST(cx);
assertSameCompartment(cx, obj, id);
if (!js_GetMethod(cx, RootedVarObject(cx, obj), id, 0, vp))
if (!GetMethod(cx, obj, id, 0, vp))
return JS_FALSE;
if (objp)
*objp = obj;
@ -4139,8 +4162,10 @@ JS_GetMethod(JSContext *cx, JSObject *obj, const char *name, JSObject **objp, js
}
JS_PUBLIC_API(JSBool)
JS_SetPropertyById(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
JS_SetPropertyById(JSContext *cx, JSObject *obj, jsid id_, jsval *vp)
{
RootedVarId id(cx, id_);
AssertNoGC(cx);
CHECK_REQUEST(cx);
assertSameCompartment(cx, obj, id);
@ -4151,11 +4176,11 @@ JS_SetPropertyById(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
JS_PUBLIC_API(JSBool)
JS_SetElement(JSContext *cx, JSObject *obj_, uint32_t index, jsval *vp)
{
RootedVarObject obj(cx, obj_);
AssertNoGC(cx);
CHECK_REQUEST(cx);
assertSameCompartment(cx, obj_, *vp);
RootedVarObject obj(cx, obj_);
RootValue vpRoot(cx, vp);
assertSameCompartment(cx, obj, *vp);
JSAutoResolveFlags rf(cx, JSRESOLVE_QUALIFIED | JSRESOLVE_ASSIGNING);
return obj->setElement(cx, index, vp, false);
}
@ -4164,7 +4189,7 @@ JS_PUBLIC_API(JSBool)
JS_SetProperty(JSContext *cx, JSObject *obj_, const char *name, jsval *vp)
{
RootedVarObject obj(cx, obj_);
RootValue vpRoot(cx, vp);
JSAtom *atom = js_Atomize(cx, name, strlen(name));
return atom && JS_SetPropertyById(cx, obj, AtomToId(atom), vp);
}
@ -4185,7 +4210,7 @@ JS_DeletePropertyById2(JSContext *cx, JSObject *obj, jsid id, jsval *rval)
JSAutoResolveFlags rf(cx, JSRESOLVE_QUALIFIED);
if (JSID_IS_SPECIAL(id))
return obj->deleteSpecial(cx, JSID_TO_SPECIALID(id), rval, false);
return obj->deleteSpecial(cx, RootedVar<SpecialId>(cx, JSID_TO_SPECIALID(id)), rval, false);
return obj->deleteByValue(cx, IdToValue(id), rval, false);
}
@ -4250,8 +4275,10 @@ JS_DeleteProperty(JSContext *cx, JSObject *obj, const char *name)
}
JS_PUBLIC_API(void)
JS_ClearScope(JSContext *cx, JSObject *obj)
JS_ClearScope(JSContext *cx, JSObject *obj_)
{
RootedVarObject obj(cx, obj_);
AssertNoGC(cx);
CHECK_REQUEST(cx);
assertSameCompartment(cx, obj);
@ -4438,7 +4465,7 @@ JS_NewElementIterator(JSContext *cx, JSObject *obj)
}
JS_PUBLIC_API(JSObject *)
JS_ElementIteratorStub(JSContext *cx, JSObject *obj, JSBool keysonly)
JS_ElementIteratorStub(JSContext *cx, JSHandleObject obj, JSBool keysonly)
{
JS_ASSERT(!keysonly);
return JS_NewElementIterator(cx, obj);
@ -4493,9 +4520,11 @@ JS_SetArrayLength(JSContext *cx, JSObject *obj, uint32_t length)
}
JS_PUBLIC_API(JSBool)
JS_CheckAccess(JSContext *cx, JSObject *obj, jsid id, JSAccessMode mode,
JS_CheckAccess(JSContext *cx, JSObject *obj, jsid id_, JSAccessMode mode,
jsval *vp, unsigned *attrsp)
{
RootedVarId id(cx, id_);
AssertNoGC(cx);
CHECK_REQUEST(cx);
assertSameCompartment(cx, obj, id);
@ -4736,7 +4765,7 @@ JS_DefineFunctions(JSContext *cx, JSObject *obj, JSFunctionSpec *fs)
}
flags &= ~JSFUN_GENERIC_NATIVE;
fun = js_DefineFunction(cx, ctor, AtomToId(atom),
fun = js_DefineFunction(cx, ctor, RootedVarId(cx, AtomToId(atom)),
js_generic_native_method_dispatcher,
fs->nargs + 1,
flags,
@ -4752,7 +4781,7 @@ JS_DefineFunctions(JSContext *cx, JSObject *obj, JSFunctionSpec *fs)
}
fun = js_DefineFunction(cx, objRoot,
AtomToId(atom), fs->call, fs->nargs, flags);
RootedVarId(cx, AtomToId(atom)), fs->call, fs->nargs, flags);
if (!fun)
return JS_FALSE;
}
@ -4772,7 +4801,7 @@ JS_DefineFunction(JSContext *cx, JSObject *obj, const char *name, JSNative call,
JSAtom *atom = js_Atomize(cx, name, strlen(name));
if (!atom)
return NULL;
return js_DefineFunction(cx, objRoot, AtomToId(atom), call, nargs, attrs);
return js_DefineFunction(cx, objRoot, RootedVarId(cx, AtomToId(atom)), call, nargs, attrs);
}
JS_PUBLIC_API(JSFunction *)
@ -4789,20 +4818,21 @@ JS_DefineUCFunction(JSContext *cx, JSObject *obj,
JSAtom *atom = js_AtomizeChars(cx, name, AUTO_NAMELEN(name, namelen));
if (!atom)
return NULL;
return js_DefineFunction(cx, objRoot, AtomToId(atom), call, nargs, attrs);
return js_DefineFunction(cx, objRoot, RootedVarId(cx, AtomToId(atom)), call, nargs, attrs);
}
extern JS_PUBLIC_API(JSFunction *)
JS_DefineFunctionById(JSContext *cx, JSObject *obj, jsid id, JSNative call,
JS_DefineFunctionById(JSContext *cx, JSObject *obj_, jsid id_, JSNative call,
unsigned nargs, unsigned attrs)
{
RootObject objRoot(cx, &obj);
RootedVarObject obj(cx, obj_);
RootedVarId id(cx, id_);
JS_THREADSAFE_ASSERT(cx->compartment != cx->runtime->atomsCompartment);
AssertNoGC(cx);
CHECK_REQUEST(cx);
assertSameCompartment(cx, obj);
return js_DefineFunction(cx, objRoot, id, call, nargs, attrs);
return js_DefineFunction(cx, obj, id, call, nargs, attrs);
}
struct AutoLastFrameCheck {
@ -5154,7 +5184,7 @@ CompileUCFunctionForPrincipalsCommon(JSContext *cx, JSObject *obj,
}
if (obj && funAtom &&
!obj->defineGeneric(cx, AtomToId(funAtom), ObjectValue(*fun), NULL, NULL,
!obj->defineGeneric(cx, RootedVarId(cx, AtomToId(funAtom)), ObjectValue(*fun), NULL, NULL,
JSPROP_ENUMERATE))
{
return NULL;
@ -5456,7 +5486,7 @@ JS_CallFunctionName(JSContext *cx, JSObject *obj_, const char *name, unsigned ar
Value v;
JSAtom *atom = js_Atomize(cx, name, strlen(name));
return atom &&
js_GetMethod(cx, obj, AtomToId(atom), 0, &v) &&
GetMethod(cx, obj, RootedVarId(cx, AtomToId(atom)), 0, &v) &&
Invoke(cx, ObjectOrNullValue(obj), v, argc, argv, rval);
}

Просмотреть файл

@ -1304,6 +1304,29 @@ JS_STATIC_ASSERT(sizeof(jsval_layout) == sizeof(jsval));
/************************************************************************/
#ifdef __cplusplus
typedef JS::Handle<JSObject*> JSHandleObject;
typedef JS::Handle<jsid> JSHandleId;
#else
/*
* Handle support for C API users. Handles must be destroyed in the reverse
* order that they were created (as in a stack).
*/
typedef struct { JSObject **_; } JSHandleObject;
typedef struct { jsid *_; } JSHandleId;
JSBool JS_CreateHandleObject(JSContext *cx, JSObject *obj, JSHandleObject *phandle);
void JS_DestroyHandleObject(JSContext *cx, JSHandleObject handle);
JSBool JS_CreateHandleId(JSContext *cx, jsid id, JSHandleId *phandle);
void JS_DestroyHandleId(JSContext *cx, JSHandleId handle);
#endif
/* JSClass operation signatures. */
/*
@ -1314,7 +1337,7 @@ JS_STATIC_ASSERT(sizeof(jsval_layout) == sizeof(jsval));
* obj[id] can't be deleted (because it's permanent).
*/
typedef JSBool
(* JSPropertyOp)(JSContext *cx, JSObject *obj, jsid id, jsval *vp);
(* JSPropertyOp)(JSContext *cx, JSHandleObject obj, JSHandleId id, jsval *vp);
/*
* Set a property named by id in obj, treating the assignment as strict
@ -1324,7 +1347,7 @@ typedef JSBool
* set.
*/
typedef JSBool
(* JSStrictPropertyOp)(JSContext *cx, JSObject *obj, jsid id, JSBool strict, jsval *vp);
(* JSStrictPropertyOp)(JSContext *cx, JSHandleObject obj, JSHandleId id, JSBool strict, jsval *vp);
/*
* This function type is used for callbacks that enumerate the properties of
@ -1359,7 +1382,7 @@ typedef JSBool
* indicating failure.
*/
typedef JSBool
(* JSNewEnumerateOp)(JSContext *cx, JSObject *obj, JSIterateOp enum_op,
(* JSNewEnumerateOp)(JSContext *cx, JSHandleObject obj, JSIterateOp enum_op,
jsval *statep, jsid *idp);
/*
@ -1367,7 +1390,7 @@ typedef JSBool
* yet reflected in obj.
*/
typedef JSBool
(* JSEnumerateOp)(JSContext *cx, JSObject *obj);
(* JSEnumerateOp)(JSContext *cx, JSHandleObject obj);
/*
* Resolve a lazy property named by id in obj by defining it directly in obj.
@ -1382,7 +1405,7 @@ typedef JSBool
* NB: JSNewResolveOp provides a cheaper way to resolve lazy properties.
*/
typedef JSBool
(* JSResolveOp)(JSContext *cx, JSObject *obj, jsid id);
(* JSResolveOp)(JSContext *cx, JSHandleObject obj, JSHandleId id);
/*
* Like JSResolveOp, but flags provide contextual information as follows:
@ -1414,7 +1437,7 @@ typedef JSBool
* *objp without a new JSClass flag.
*/
typedef JSBool
(* JSNewResolveOp)(JSContext *cx, JSObject *obj, jsid id, unsigned flags,
(* JSNewResolveOp)(JSContext *cx, JSHandleObject obj, JSHandleId id, unsigned flags,
JSObject **objp);
/*
@ -1422,7 +1445,7 @@ typedef JSBool
* *vp on success, and returning false on error or exception.
*/
typedef JSBool
(* JSConvertOp)(JSContext *cx, JSObject *obj, JSType type, jsval *vp);
(* JSConvertOp)(JSContext *cx, JSHandleObject obj, JSType type, jsval *vp);
/*
* Delegate typeof to an object so it can cloak a primitive or another object.
@ -1474,7 +1497,7 @@ struct JSStringFinalizer {
* is either a string or an int jsval.
*/
typedef JSBool
(* JSCheckAccessOp)(JSContext *cx, JSObject *obj, jsid id, JSAccessMode mode,
(* JSCheckAccessOp)(JSContext *cx, JSHandleObject obj, JSHandleId id, JSAccessMode mode,
jsval *vp);
/*
@ -1483,7 +1506,7 @@ typedef JSBool
* *bp otherwise.
*/
typedef JSBool
(* JSHasInstanceOp)(JSContext *cx, JSObject *obj, const jsval *v, JSBool *bp);
(* JSHasInstanceOp)(JSContext *cx, JSHandleObject obj, const jsval *v, JSBool *bp);
/*
* Function type for trace operation of the class called to enumerate all
@ -1513,7 +1536,7 @@ typedef void
(* JSTraceNamePrinter)(JSTracer *trc, char *buf, size_t bufsize);
typedef JSBool
(* JSEqualityOp)(JSContext *cx, JSObject *obj, const jsval *v, JSBool *bp);
(* JSEqualityOp)(JSContext *cx, JSHandleObject obj, const jsval *v, JSBool *bp);
/*
* Typedef for native functions called by the JS VM.
@ -3818,19 +3841,19 @@ extern JS_PUBLIC_API(JSBool)
JS_DefaultValue(JSContext *cx, JSObject *obj, JSType hint, jsval *vp);
extern JS_PUBLIC_API(JSBool)
JS_PropertyStub(JSContext *cx, JSObject *obj, jsid id, jsval *vp);
JS_PropertyStub(JSContext *cx, JSHandleObject obj, JSHandleId id, jsval *vp);
extern JS_PUBLIC_API(JSBool)
JS_StrictPropertyStub(JSContext *cx, JSObject *obj, jsid id, JSBool strict, jsval *vp);
JS_StrictPropertyStub(JSContext *cx, JSHandleObject obj, JSHandleId id, JSBool strict, jsval *vp);
extern JS_PUBLIC_API(JSBool)
JS_EnumerateStub(JSContext *cx, JSObject *obj);
JS_EnumerateStub(JSContext *cx, JSHandleObject obj);
extern JS_PUBLIC_API(JSBool)
JS_ResolveStub(JSContext *cx, JSObject *obj, jsid id);
JS_ResolveStub(JSContext *cx, JSHandleObject obj, JSHandleId id);
extern JS_PUBLIC_API(JSBool)
JS_ConvertStub(JSContext *cx, JSObject *obj, JSType type, jsval *vp);
JS_ConvertStub(JSContext *cx, JSHandleObject obj, JSType type, jsval *vp);
struct JSConstDoubleSpec {
double dval;
@ -4300,7 +4323,7 @@ JS_NewElementIterator(JSContext *cx, JSObject *obj);
* .ext.iteratorObject hook to this function.
*/
extern JS_PUBLIC_API(JSObject *)
JS_ElementIteratorStub(JSContext *cx, JSObject *obj, JSBool keysonly);
JS_ElementIteratorStub(JSContext *cx, JSHandleObject obj, JSBool keysonly);
extern JS_PUBLIC_API(JSBool)
JS_CheckAccess(JSContext *cx, JSObject *obj, jsid id, JSAccessMode mode,

Просмотреть файл

@ -395,7 +395,7 @@ DoGetElement(JSContext *cx, JSObject *obj_, double index, JSBool *hole, Value *v
}
static inline JSBool
DoGetElement(JSContext *cx, JSObject *obj, uint32_t index, JSBool *hole, Value *vp)
DoGetElement(JSContext *cx, HandleObject obj, uint32_t index, JSBool *hole, Value *vp)
{
bool present;
if (!obj->getElementIfPresent(cx, obj, index, vp, &present))
@ -512,14 +512,14 @@ SetArrayElement(JSContext *cx, HandleObject obj, double index, const Value &v)
return JS_FALSE;
}
AutoIdRooter idr(cx);
RootedVarId id(cx);
if (!IndexToId(cx, obj, index, NULL, idr.addr(), JS_TRUE))
if (!IndexToId(cx, obj, index, NULL, id.address(), JS_TRUE))
return JS_FALSE;
JS_ASSERT(!JSID_IS_VOID(idr.id()));
JS_ASSERT(!JSID_IS_VOID(id));
RootedVarValue tmp(cx, v);
return obj->setGeneric(cx, idr.id(), tmp.address(), true);
return obj->setGeneric(cx, id, tmp.address(), true);
}
/*
@ -598,8 +598,9 @@ js_SetLengthProperty(JSContext *cx, JSObject *obj, double length)
* the JSPROP_SHARED attribute, we must define a shadowing length property.
*/
static JSBool
array_length_getter(JSContext *cx, JSObject *obj, jsid id, Value *vp)
array_length_getter(JSContext *cx, HandleObject obj_, HandleId id, Value *vp)
{
JSObject *obj = obj_;
do {
if (obj->isArray()) {
vp->setNumber(obj->getArrayLength());
@ -610,10 +611,8 @@ array_length_getter(JSContext *cx, JSObject *obj, jsid id, Value *vp)
}
static JSBool
array_length_setter(JSContext *cx, JSObject *obj_, jsid id, JSBool strict, Value *vp)
array_length_setter(JSContext *cx, HandleObject obj, HandleId id, JSBool strict, Value *vp)
{
RootedVarObject obj(cx, obj_);
if (!obj->isArray()) {
return obj->defineProperty(cx, cx->runtime->atomState.lengthAtom, *vp,
NULL, NULL, JSPROP_ENUMERATE);
@ -682,13 +681,14 @@ array_length_setter(JSContext *cx, JSObject *obj_, jsid id, JSBool strict, Value
uint32_t gap = oldlen - newlen;
for (;;) {
if (!JS_CHECK_OPERATION_LIMIT(cx) || !JS_NextProperty(cx, iter, &id))
jsid nid;
if (!JS_CHECK_OPERATION_LIMIT(cx) || !JS_NextProperty(cx, iter, &nid))
return false;
if (JSID_IS_VOID(id))
if (JSID_IS_VOID(nid))
break;
uint32_t index;
Value junk;
if (js_IdIsIndex(id, &index) && index - newlen < gap &&
if (js_IdIsIndex(nid, &index) && index - newlen < gap &&
!obj->deleteElement(cx, index, &junk, false)) {
return false;
}
@ -724,11 +724,11 @@ IsDenseArrayId(JSContext *cx, JSObject *obj, jsid id)
}
static JSBool
array_lookupGeneric(JSContext *cx, JSObject *obj, jsid id, JSObject **objp,
array_lookupGeneric(JSContext *cx, HandleObject obj, HandleId id, JSObject **objp,
JSProperty **propp)
{
if (!obj->isDenseArray())
return js_LookupProperty(cx, obj, id, objp, propp);
return baseops::LookupProperty(cx, obj, id, objp, propp);
if (IsDenseArrayId(cx, obj, id)) {
*propp = (JSProperty *) 1; /* non-null to indicate found */
@ -746,18 +746,18 @@ array_lookupGeneric(JSContext *cx, JSObject *obj, jsid id, JSObject **objp,
}
static JSBool
array_lookupProperty(JSContext *cx, JSObject *obj, PropertyName *name, JSObject **objp,
array_lookupProperty(JSContext *cx, HandleObject obj, HandlePropertyName name, JSObject **objp,
JSProperty **propp)
{
return array_lookupGeneric(cx, obj, NameToId(name), objp, propp);
return array_lookupGeneric(cx, obj, RootedVarId(cx, NameToId(name)), objp, propp);
}
static JSBool
array_lookupElement(JSContext *cx, JSObject *obj, uint32_t index, JSObject **objp,
array_lookupElement(JSContext *cx, HandleObject obj, uint32_t index, JSObject **objp,
JSProperty **propp)
{
if (!obj->isDenseArray())
return js_LookupElement(cx, obj, index, objp, propp);
return baseops::LookupElement(cx, obj, index, objp, propp);
if (IsDenseArrayIndex(obj, index)) {
*propp = (JSProperty *) 1; /* non-null to indicate found */
@ -774,10 +774,10 @@ array_lookupElement(JSContext *cx, JSObject *obj, uint32_t index, JSObject **obj
}
static JSBool
array_lookupSpecial(JSContext *cx, JSObject *obj, SpecialId sid, JSObject **objp,
array_lookupSpecial(JSContext *cx, HandleObject obj, HandleSpecialId sid, JSObject **objp,
JSProperty **propp)
{
return array_lookupGeneric(cx, obj, SPECIALID_TO_JSID(sid), objp, propp);
return array_lookupGeneric(cx, obj, RootedVarId(cx, SPECIALID_TO_JSID(sid)), objp, propp);
}
JSBool
@ -796,7 +796,7 @@ js_GetDenseArrayElementValue(JSContext *cx, JSObject *obj, jsid id, Value *vp)
}
static JSBool
array_getProperty(JSContext *cx, JSObject *obj, JSObject *receiver, PropertyName *name, Value *vp)
array_getProperty(JSContext *cx, HandleObject obj, HandleObject receiver, HandlePropertyName name, Value *vp)
{
if (name == cx->runtime->atomState.lengthAtom) {
vp->setNumber(obj->getArrayLength());
@ -809,13 +809,7 @@ array_getProperty(JSContext *cx, JSObject *obj, JSObject *receiver, PropertyName
}
if (!obj->isDenseArray())
{
return js_GetProperty(cx,
RootedVarObject(cx, obj),
RootedVarObject(cx, receiver),
NameToId(name),
vp);
}
return baseops::GetProperty(cx, obj, receiver, RootedVarId(cx, NameToId(name)), vp);
JSObject *proto = obj->getProto();
if (!proto) {
@ -827,16 +821,10 @@ array_getProperty(JSContext *cx, JSObject *obj, JSObject *receiver, PropertyName
}
static JSBool
array_getElement(JSContext *cx, JSObject *obj, JSObject *receiver, uint32_t index, Value *vp)
array_getElement(JSContext *cx, HandleObject obj, HandleObject receiver, uint32_t index, Value *vp)
{
if (!obj->isDenseArray())
{
return js_GetElement(cx,
RootedVarObject(cx, obj),
RootedVarObject(cx, receiver),
index,
vp);
}
return baseops::GetElement(cx, obj, receiver, index, vp);
if (index < obj->getDenseArrayInitializedLength()) {
*vp = obj->getDenseArrayElement(index);
@ -859,22 +847,18 @@ array_getElement(JSContext *cx, JSObject *obj, JSObject *receiver, uint32_t inde
}
static JSBool
array_getSpecial(JSContext *cx, JSObject *obj, JSObject *receiver, SpecialId sid, Value *vp)
array_getSpecial(JSContext *cx, HandleObject obj, HandleObject receiver, HandleSpecialId sid, Value *vp)
{
if (obj->isDenseArray() && !obj->getProto()) {
vp->setUndefined();
return true;
}
return js_GetProperty(cx,
RootedVarObject(cx, obj),
RootedVarObject(cx, receiver),
SPECIALID_TO_JSID(sid),
vp);
return baseops::GetProperty(cx, obj, receiver, RootedVarId(cx, SPECIALID_TO_JSID(sid)), vp);
}
static JSBool
array_getGeneric(JSContext *cx, JSObject *obj, JSObject *receiver, jsid id, Value *vp)
array_getGeneric(JSContext *cx, HandleObject obj, HandleObject receiver, HandleId id, Value *vp)
{
Value idval = IdToValue(id);
@ -884,7 +868,7 @@ array_getGeneric(JSContext *cx, JSObject *obj, JSObject *receiver, jsid id, Valu
SpecialId sid;
if (ValueIsSpecial(obj, &idval, &sid, cx))
return array_getSpecial(cx, obj, receiver, sid, vp);
return array_getSpecial(cx, obj, receiver, RootedVar<SpecialId>(cx, sid), vp);
JSAtom *atom;
if (!js_ValueToAtom(cx, idval, &atom))
@ -893,11 +877,11 @@ array_getGeneric(JSContext *cx, JSObject *obj, JSObject *receiver, jsid id, Valu
if (atom->isIndex(&index))
return array_getElement(cx, obj, receiver, index, vp);
return array_getProperty(cx, obj, receiver, atom->asPropertyName(), vp);
return array_getProperty(cx, obj, receiver, RootedVarPropertyName(cx, atom->asPropertyName()), vp);
}
static JSBool
slowarray_addProperty(JSContext *cx, JSObject *obj, jsid id, Value *vp)
slowarray_addProperty(JSContext *cx, HandleObject obj, HandleId id, Value *vp)
{
uint32_t index, length;
@ -910,22 +894,19 @@ slowarray_addProperty(JSContext *cx, JSObject *obj, jsid id, Value *vp)
}
static JSType
array_typeOf(JSContext *cx, JSObject *obj)
array_typeOf(JSContext *cx, HandleObject obj)
{
return JSTYPE_OBJECT;
}
static JSBool
array_setGeneric(JSContext *cx, JSObject *obj_, jsid id_, Value *vp, JSBool strict)
array_setGeneric(JSContext *cx, HandleObject obj, HandleId id, Value *vp, JSBool strict)
{
RootedVarObject obj(cx, obj_);
RootedVarId id(cx, id_);
if (JSID_IS_ATOM(id, cx->runtime->atomState.lengthAtom))
return array_length_setter(cx, obj, id, strict, vp);
if (!obj->isDenseArray())
return js_SetPropertyHelper(cx, obj, id, 0, vp, strict);
return baseops::SetPropertyHelper(cx, obj, id, 0, vp, strict);
do {
uint32_t i;
@ -950,26 +931,24 @@ array_setGeneric(JSContext *cx, JSObject *obj_, jsid id_, Value *vp, JSBool stri
if (!JSObject::makeDenseArraySlow(cx, obj))
return false;
return js_SetPropertyHelper(cx, obj, id, 0, vp, strict);
return baseops::SetPropertyHelper(cx, obj, id, 0, vp, strict);
}
static JSBool
array_setProperty(JSContext *cx, JSObject *obj, PropertyName *name, Value *vp, JSBool strict)
array_setProperty(JSContext *cx, HandleObject obj, HandlePropertyName name, Value *vp, JSBool strict)
{
return array_setGeneric(cx, obj, NameToId(name), vp, strict);
return array_setGeneric(cx, obj, RootedVarId(cx, NameToId(name)), vp, strict);
}
static JSBool
array_setElement(JSContext *cx, JSObject *obj_, uint32_t index, Value *vp, JSBool strict)
array_setElement(JSContext *cx, HandleObject obj, uint32_t index, Value *vp, JSBool strict)
{
RootedVarObject obj(cx, obj_);
jsid id;
if (!IndexToId(cx, index, &id))
RootedVarId id(cx);
if (!IndexToId(cx, index, id.address()))
return false;
if (!obj->isDenseArray())
return js_SetPropertyHelper(cx, obj, id, 0, vp, strict);
return baseops::SetPropertyHelper(cx, obj, id, 0, vp, strict);
do {
/*
@ -997,13 +976,13 @@ array_setElement(JSContext *cx, JSObject *obj_, uint32_t index, Value *vp, JSBoo
if (!JSObject::makeDenseArraySlow(cx, obj))
return false;
return js_SetPropertyHelper(cx, obj, id, 0, vp, strict);
return baseops::SetPropertyHelper(cx, obj, id, 0, vp, strict);
}
static JSBool
array_setSpecial(JSContext *cx, JSObject *obj, SpecialId sid, Value *vp, JSBool strict)
array_setSpecial(JSContext *cx, HandleObject obj, HandleSpecialId sid, Value *vp, JSBool strict)
{
return array_setGeneric(cx, obj, SPECIALID_TO_JSID(sid), vp, strict);
return array_setGeneric(cx, obj, RootedVarId(cx, SPECIALID_TO_JSID(sid)), vp, strict);
}
JSBool
@ -1029,16 +1008,14 @@ js_PrototypeHasIndexedProperties(JSContext *cx, JSObject *obj)
}
static JSBool
array_defineGeneric(JSContext *cx, JSObject *obj_, jsid id, const Value *value,
array_defineGeneric(JSContext *cx, HandleObject obj, HandleId id, const Value *value,
JSPropertyOp getter, StrictPropertyOp setter, unsigned attrs)
{
RootedVarObject obj(cx, obj_);
if (JSID_IS_ATOM(id, cx->runtime->atomState.lengthAtom))
return JS_TRUE;
if (!obj->isDenseArray())
return js_DefineProperty(cx, obj, id, value, getter, setter, attrs);
return baseops::DefineProperty(cx, obj, id, value, getter, setter, attrs);
do {
uint32_t i = 0; // init to shut GCC up
@ -1060,27 +1037,29 @@ array_defineGeneric(JSContext *cx, JSObject *obj_, jsid id, const Value *value,
return true;
} while (false);
RootGetterSetter gsRoot(cx, attrs, &getter, &setter);
if (!JSObject::makeDenseArraySlow(cx, obj))
return false;
return js_DefineProperty(cx, obj, id, value, getter, setter, attrs);
return baseops::DefineProperty(cx, obj, id, value, getter, setter, attrs);
}
static JSBool
array_defineProperty(JSContext *cx, JSObject *obj, PropertyName *name, const Value *value,
array_defineProperty(JSContext *cx, HandleObject obj, HandlePropertyName name, const Value *value,
JSPropertyOp getter, StrictPropertyOp setter, unsigned attrs)
{
return array_defineGeneric(cx, obj, NameToId(name), value, getter, setter, attrs);
return array_defineGeneric(cx, obj, RootedVarId(cx, NameToId(name)), value, getter, setter, attrs);
}
namespace js {
/* non-static for direct definition of array elements within the engine */
JSBool
array_defineElement(JSContext *cx, JSObject *obj, uint32_t index, const Value *value,
array_defineElement(JSContext *cx, HandleObject obj, uint32_t index, const Value *value,
PropertyOp getter, StrictPropertyOp setter, unsigned attrs)
{
if (!obj->isDenseArray())
return js_DefineElement(cx, obj, index, value, getter, setter, attrs);
return baseops::DefineElement(cx, obj, index, value, getter, setter, attrs);
do {
/*
@ -1104,26 +1083,26 @@ array_defineElement(JSContext *cx, JSObject *obj, uint32_t index, const Value *v
return true;
} while (false);
RootObject objRoot(cx, &obj);
RootValue valueRoot(cx, value);
RootGetterSetter gsRoot(cx, attrs, &getter, &setter);
if (!JSObject::makeDenseArraySlow(cx, objRoot))
if (!JSObject::makeDenseArraySlow(cx, obj))
return false;
return js_DefineElement(cx, obj, index, value, getter, setter, attrs);
return baseops::DefineElement(cx, obj, index, value, getter, setter, attrs);
}
} // namespace js
static JSBool
array_defineSpecial(JSContext *cx, JSObject *obj, SpecialId sid, const Value *value,
array_defineSpecial(JSContext *cx, HandleObject obj, HandleSpecialId sid, const Value *value,
PropertyOp getter, StrictPropertyOp setter, unsigned attrs)
{
return array_defineGeneric(cx, obj, SPECIALID_TO_JSID(sid), value, getter, setter, attrs);
return array_defineGeneric(cx, obj, RootedVarId(cx, SPECIALID_TO_JSID(sid)),
value, getter, setter, attrs);
}
static JSBool
array_getGenericAttributes(JSContext *cx, JSObject *obj, jsid id, unsigned *attrsp)
array_getGenericAttributes(JSContext *cx, HandleObject obj, HandleId id, unsigned *attrsp)
{
*attrsp = JSID_IS_ATOM(id, cx->runtime->atomState.lengthAtom)
? JSPROP_PERMANENT : JSPROP_ENUMERATE;
@ -1131,7 +1110,7 @@ array_getGenericAttributes(JSContext *cx, JSObject *obj, jsid id, unsigned *attr
}
static JSBool
array_getPropertyAttributes(JSContext *cx, JSObject *obj, PropertyName *name, unsigned *attrsp)
array_getPropertyAttributes(JSContext *cx, HandleObject obj, HandlePropertyName name, unsigned *attrsp)
{
*attrsp = (name == cx->runtime->atomState.lengthAtom)
? JSPROP_PERMANENT
@ -1140,52 +1119,52 @@ array_getPropertyAttributes(JSContext *cx, JSObject *obj, PropertyName *name, un
}
static JSBool
array_getElementAttributes(JSContext *cx, JSObject *obj, uint32_t index, unsigned *attrsp)
array_getElementAttributes(JSContext *cx, HandleObject obj, uint32_t index, unsigned *attrsp)
{
*attrsp = JSPROP_ENUMERATE;
return true;
}
static JSBool
array_getSpecialAttributes(JSContext *cx, JSObject *obj, SpecialId sid, unsigned *attrsp)
array_getSpecialAttributes(JSContext *cx, HandleObject obj, HandleSpecialId sid, unsigned *attrsp)
{
*attrsp = JSPROP_ENUMERATE;
return true;
}
static JSBool
array_setGenericAttributes(JSContext *cx, JSObject *obj, jsid id, unsigned *attrsp)
array_setGenericAttributes(JSContext *cx, HandleObject obj, HandleId id, unsigned *attrsp)
{
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_CANT_SET_ARRAY_ATTRS);
return false;
}
static JSBool
array_setPropertyAttributes(JSContext *cx, JSObject *obj, PropertyName *name, unsigned *attrsp)
array_setPropertyAttributes(JSContext *cx, HandleObject obj, HandlePropertyName name, unsigned *attrsp)
{
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_CANT_SET_ARRAY_ATTRS);
return false;
}
static JSBool
array_setElementAttributes(JSContext *cx, JSObject *obj, uint32_t index, unsigned *attrsp)
array_setElementAttributes(JSContext *cx, HandleObject obj, uint32_t index, unsigned *attrsp)
{
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_CANT_SET_ARRAY_ATTRS);
return false;
}
static JSBool
array_setSpecialAttributes(JSContext *cx, JSObject *obj, SpecialId sid, unsigned *attrsp)
array_setSpecialAttributes(JSContext *cx, HandleObject obj, HandleSpecialId sid, unsigned *attrsp)
{
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_CANT_SET_ARRAY_ATTRS);
return false;
}
static JSBool
array_deleteProperty(JSContext *cx, JSObject *obj, PropertyName *name, Value *rval, JSBool strict)
array_deleteProperty(JSContext *cx, HandleObject obj, HandlePropertyName name, Value *rval, JSBool strict)
{
if (!obj->isDenseArray())
return js_DeleteProperty(cx, obj, name, rval, strict);
return baseops::DeleteProperty(cx, obj, name, rval, strict);
if (name == cx->runtime->atomState.lengthAtom) {
rval->setBoolean(false);
@ -1200,10 +1179,10 @@ namespace js {
/* non-static for direct deletion of array elements within the engine */
JSBool
array_deleteElement(JSContext *cx, JSObject *obj, uint32_t index, Value *rval, JSBool strict)
array_deleteElement(JSContext *cx, HandleObject obj, uint32_t index, Value *rval, JSBool strict)
{
if (!obj->isDenseArray())
return js_DeleteElement(cx, obj, index, rval, strict);
return baseops::DeleteElement(cx, obj, index, rval, strict);
if (index < obj->getDenseArrayInitializedLength()) {
obj->markDenseArrayNotPacked(cx);
@ -1220,10 +1199,10 @@ array_deleteElement(JSContext *cx, JSObject *obj, uint32_t index, Value *rval, J
} // namespace js
static JSBool
array_deleteSpecial(JSContext *cx, JSObject *obj, SpecialId sid, Value *rval, JSBool strict)
array_deleteSpecial(JSContext *cx, HandleObject obj, HandleSpecialId sid, Value *rval, JSBool strict)
{
if (!obj->isDenseArray())
return js_DeleteSpecial(cx, obj, sid, rval, strict);
return baseops::DeleteSpecial(cx, obj, sid, rval, strict);
rval->setBoolean(true);
return true;
@ -1349,7 +1328,7 @@ AddLengthProperty(JSContext *cx, JSObject *obj)
* as accesses to 'length' will use the elements header.
*/
const jsid lengthId = NameToId(cx->runtime->atomState.lengthAtom);
RootedVarId lengthId(cx, NameToId(cx->runtime->atomState.lengthAtom));
JS_ASSERT(!obj->nativeLookup(cx, lengthId));
if (!obj->allocateSlowArrayElements(cx))
@ -1685,7 +1664,7 @@ array_toString_sub(JSContext *cx, HandleObject obj, JSBool locale,
JSObject *robj = ToObject(cx, &elt);
if (!robj)
return false;
jsid id = NameToId(cx->runtime->atomState.toLocaleStringAtom);
RootedVarId id(cx, NameToId(cx->runtime->atomState.toLocaleStringAtom));
if (!robj->callMethod(cx, id, 0, NULL, &elt))
return false;
}
@ -2430,16 +2409,16 @@ array_push1_dense(JSContext* cx, HandleObject obj, CallArgs &args)
}
JS_ALWAYS_INLINE JSBool
NewbornArrayPushImpl(JSContext *cx, JSObject *obj, const Value &v)
NewbornArrayPushImpl(JSContext *cx, HandleObject obj, const Value &v)
{
JS_ASSERT(!v.isMagic());
uint32_t length = obj->getArrayLength();
if (obj->isSlowArray()) {
/* This can happen in one evil case. See bug 630377. */
jsid id;
return IndexToId(cx, length, &id) &&
js_DefineProperty(cx, obj, id, &v, NULL, NULL, JSPROP_ENUMERATE);
RootedVarId id(cx);
return IndexToId(cx, length, id.address()) &&
baseops::DefineProperty(cx, obj, id, &v, NULL, NULL, JSPROP_ENUMERATE);
}
JS_ASSERT(obj->isDenseArray());
@ -2455,7 +2434,7 @@ NewbornArrayPushImpl(JSContext *cx, JSObject *obj, const Value &v)
}
JSBool
js_NewbornArrayPush(JSContext *cx, JSObject *obj, const Value &vp)
js_NewbornArrayPush(JSContext *cx, HandleObject obj, const Value &vp)
{
return NewbornArrayPushImpl(cx, obj, vp);
}

Просмотреть файл

@ -123,11 +123,11 @@ js_SetLengthProperty(JSContext *cx, JSObject *obj, double length);
namespace js {
extern JSBool
array_defineElement(JSContext *cx, JSObject *obj, uint32_t index, const Value *value,
array_defineElement(JSContext *cx, HandleObject obj, uint32_t index, const Value *value,
PropertyOp getter, StrictPropertyOp setter, unsigned attrs);
extern JSBool
array_deleteElement(JSContext *cx, JSObject *obj, uint32_t index, Value *rval, JSBool strict);
array_deleteElement(JSContext *cx, HandleObject obj, uint32_t index, Value *rval, JSBool strict);
/*
* Copy 'length' elements from aobj to vp.
@ -170,7 +170,7 @@ js_ArrayInfo(JSContext *cx, unsigned argc, jsval *vp);
* sparse, which requires that the array be completely filled.)
*/
extern JSBool
js_NewbornArrayPush(JSContext *cx, JSObject *obj, const js::Value &v);
js_NewbornArrayPush(JSContext *cx, js::HandleObject obj, const js::Value &v);
JSBool
js_PrototypeHasIndexedProperties(JSContext *cx, JSObject *obj);

Просмотреть файл

@ -174,73 +174,75 @@ JSID_TO_SPECIALID(jsid id)
return SpecialId::defaultXMLNamespace();
}
typedef JS::Handle<SpecialId> HandleSpecialId;
/* js::Class operation signatures. */
typedef JSBool
(* LookupGenericOp)(JSContext *cx, JSObject *obj, jsid id, JSObject **objp,
(* LookupGenericOp)(JSContext *cx, HandleObject obj, HandleId id, JSObject **objp,
JSProperty **propp);
typedef JSBool
(* LookupPropOp)(JSContext *cx, JSObject *obj, PropertyName *name, JSObject **objp,
(* LookupPropOp)(JSContext *cx, HandleObject obj, HandlePropertyName name, JSObject **objp,
JSProperty **propp);
typedef JSBool
(* LookupElementOp)(JSContext *cx, JSObject *obj, uint32_t index, JSObject **objp,
(* LookupElementOp)(JSContext *cx, HandleObject obj, uint32_t index, JSObject **objp,
JSProperty **propp);
typedef JSBool
(* LookupSpecialOp)(JSContext *cx, JSObject *obj, SpecialId sid, JSObject **objp,
(* LookupSpecialOp)(JSContext *cx, HandleObject obj, HandleSpecialId sid, JSObject **objp,
JSProperty **propp);
typedef JSBool
(* DefineGenericOp)(JSContext *cx, JSObject *obj, jsid id, const Value *value,
(* DefineGenericOp)(JSContext *cx, HandleObject obj, HandleId id, const Value *value,
PropertyOp getter, StrictPropertyOp setter, unsigned attrs);
typedef JSBool
(* DefinePropOp)(JSContext *cx, JSObject *obj, PropertyName *name, const Value *value,
(* DefinePropOp)(JSContext *cx, HandleObject obj, HandlePropertyName name, const Value *value,
PropertyOp getter, StrictPropertyOp setter, unsigned attrs);
typedef JSBool
(* DefineElementOp)(JSContext *cx, JSObject *obj, uint32_t index, const Value *value,
(* DefineElementOp)(JSContext *cx, HandleObject obj, uint32_t index, const Value *value,
PropertyOp getter, StrictPropertyOp setter, unsigned attrs);
typedef JSBool
(* DefineSpecialOp)(JSContext *cx, JSObject *obj, SpecialId sid, const Value *value,
(* DefineSpecialOp)(JSContext *cx, HandleObject obj, HandleSpecialId sid, const Value *value,
PropertyOp getter, StrictPropertyOp setter, unsigned attrs);
typedef JSBool
(* GenericIdOp)(JSContext *cx, JSObject *obj, JSObject *receiver, jsid id, Value *vp);
(* GenericIdOp)(JSContext *cx, HandleObject obj, HandleObject receiver, HandleId id, Value *vp);
typedef JSBool
(* PropertyIdOp)(JSContext *cx, JSObject *obj, JSObject *receiver, PropertyName *name, Value *vp);
(* PropertyIdOp)(JSContext *cx, HandleObject obj, HandleObject receiver, HandlePropertyName name, Value *vp);
typedef JSBool
(* ElementIdOp)(JSContext *cx, JSObject *obj, JSObject *receiver, uint32_t index, Value *vp);
(* ElementIdOp)(JSContext *cx, HandleObject obj, HandleObject receiver, uint32_t index, Value *vp);
typedef JSBool
(* ElementIfPresentOp)(JSContext *cx, JSObject *obj, JSObject *receiver, uint32_t index, Value *vp, bool* present);
(* ElementIfPresentOp)(JSContext *cx, HandleObject obj, HandleObject receiver, uint32_t index, Value *vp, bool* present);
typedef JSBool
(* SpecialIdOp)(JSContext *cx, JSObject *obj, JSObject *receiver, SpecialId sid, Value *vp);
(* SpecialIdOp)(JSContext *cx, HandleObject obj, HandleObject receiver, HandleSpecialId sid, Value *vp);
typedef JSBool
(* StrictGenericIdOp)(JSContext *cx, JSObject *obj, jsid id, Value *vp, JSBool strict);
(* StrictGenericIdOp)(JSContext *cx, HandleObject obj, HandleId id, Value *vp, JSBool strict);
typedef JSBool
(* StrictPropertyIdOp)(JSContext *cx, JSObject *obj, PropertyName *name, Value *vp, JSBool strict);
(* StrictPropertyIdOp)(JSContext *cx, HandleObject obj, HandlePropertyName name, Value *vp, JSBool strict);
typedef JSBool
(* StrictElementIdOp)(JSContext *cx, JSObject *obj, uint32_t index, Value *vp, JSBool strict);
(* StrictElementIdOp)(JSContext *cx, HandleObject obj, uint32_t index, Value *vp, JSBool strict);
typedef JSBool
(* StrictSpecialIdOp)(JSContext *cx, JSObject *obj, SpecialId sid, Value *vp, JSBool strict);
(* StrictSpecialIdOp)(JSContext *cx, HandleObject obj, HandleSpecialId sid, Value *vp, JSBool strict);
typedef JSBool
(* GenericAttributesOp)(JSContext *cx, JSObject *obj, jsid id, unsigned *attrsp);
(* GenericAttributesOp)(JSContext *cx, HandleObject obj, HandleId id, unsigned *attrsp);
typedef JSBool
(* PropertyAttributesOp)(JSContext *cx, JSObject *obj, PropertyName *name, unsigned *attrsp);
(* PropertyAttributesOp)(JSContext *cx, HandleObject obj, HandlePropertyName name, unsigned *attrsp);
typedef JSBool
(* ElementAttributesOp)(JSContext *cx, JSObject *obj, uint32_t index, unsigned *attrsp);
(* ElementAttributesOp)(JSContext *cx, HandleObject obj, uint32_t index, unsigned *attrsp);
typedef JSBool
(* SpecialAttributesOp)(JSContext *cx, JSObject *obj, SpecialId sid, unsigned *attrsp);
(* SpecialAttributesOp)(JSContext *cx, HandleObject obj, HandleSpecialId sid, unsigned *attrsp);
typedef JSBool
(* DeletePropertyOp)(JSContext *cx, JSObject *obj, PropertyName *name, Value *vp, JSBool strict);
(* DeletePropertyOp)(JSContext *cx, HandleObject obj, HandlePropertyName name, Value *vp, JSBool strict);
typedef JSBool
(* DeleteElementOp)(JSContext *cx, JSObject *obj, uint32_t index, Value *vp, JSBool strict);
(* DeleteElementOp)(JSContext *cx, HandleObject obj, uint32_t index, Value *vp, JSBool strict);
typedef JSBool
(* DeleteSpecialOp)(JSContext *cx, JSObject *obj, SpecialId sid, Value *vp, JSBool strict);
(* DeleteSpecialOp)(JSContext *cx, HandleObject obj, HandleSpecialId sid, Value *vp, JSBool strict);
typedef JSType
(* TypeOfOp)(JSContext *cx, JSObject *obj);
(* TypeOfOp)(JSContext *cx, HandleObject obj);
typedef JSObject *
(* ObjectOp)(JSContext *cx, JSObject *obj);
(* ObjectOp)(JSContext *cx, HandleObject obj);
typedef void
(* ClearOp)(JSContext *cx, HandleObject obj);
typedef void
(* FinalizeOp)(FreeOp *fop, JSObject *obj);
typedef void
(* ClearOp)(JSContext *cx, JSObject *obj);
#define JS_CLASS_MEMBERS \
const char *name; \

Просмотреть файл

@ -1065,7 +1065,7 @@ JSContext::~JSContext()
void
JSContext::resetCompartment()
{
JSObject *scopeobj;
RootedVarObject scopeobj(this);
if (stack.hasfp()) {
scopeobj = fp()->scopeChain();
} else {
@ -1077,7 +1077,7 @@ JSContext::resetCompartment()
* Innerize. Assert, but check anyway, that this succeeds. (It
* can only fail due to bugs in the engine or embedding.)
*/
OBJ_TO_INNER_OBJECT(this, scopeobj);
scopeobj = GetInnerObject(this, scopeobj);
if (!scopeobj)
goto error;
}

Просмотреть файл

@ -363,7 +363,7 @@ class CompartmentChecker
CompartmentChecker c(cx)
template <class T1> inline void
assertSameCompartment(JSContext *cx, T1 t1)
assertSameCompartment(JSContext *cx, const T1 &t1)
{
#ifdef DEBUG
START_ASSERT_SAME_COMPARTMENT();
@ -372,7 +372,7 @@ assertSameCompartment(JSContext *cx, T1 t1)
}
template <class T1, class T2> inline void
assertSameCompartment(JSContext *cx, T1 t1, T2 t2)
assertSameCompartment(JSContext *cx, const T1 &t1, const T2 &t2)
{
#ifdef DEBUG
START_ASSERT_SAME_COMPARTMENT();
@ -382,7 +382,7 @@ assertSameCompartment(JSContext *cx, T1 t1, T2 t2)
}
template <class T1, class T2, class T3> inline void
assertSameCompartment(JSContext *cx, T1 t1, T2 t2, T3 t3)
assertSameCompartment(JSContext *cx, const T1 &t1, const T2 &t2, const T3 &t3)
{
#ifdef DEBUG
START_ASSERT_SAME_COMPARTMENT();
@ -393,7 +393,7 @@ assertSameCompartment(JSContext *cx, T1 t1, T2 t2, T3 t3)
}
template <class T1, class T2, class T3, class T4> inline void
assertSameCompartment(JSContext *cx, T1 t1, T2 t2, T3 t3, T4 t4)
assertSameCompartment(JSContext *cx, const T1 &t1, const T2 &t2, const T3 &t3, const T4 &t4)
{
#ifdef DEBUG
START_ASSERT_SAME_COMPARTMENT();
@ -405,7 +405,7 @@ assertSameCompartment(JSContext *cx, T1 t1, T2 t2, T3 t3, T4 t4)
}
template <class T1, class T2, class T3, class T4, class T5> inline void
assertSameCompartment(JSContext *cx, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5)
assertSameCompartment(JSContext *cx, const T1 &t1, const T2 &t2, const T3 &t3, const T4 &t4, const T5 &t5)
{
#ifdef DEBUG
START_ASSERT_SAME_COMPARTMENT();
@ -473,7 +473,7 @@ CallJSNativeConstructor(JSContext *cx, Native native, const CallArgs &args)
}
JS_ALWAYS_INLINE bool
CallJSPropertyOp(JSContext *cx, PropertyOp op, JSObject *receiver, jsid id, Value *vp)
CallJSPropertyOp(JSContext *cx, PropertyOp op, HandleObject receiver, HandleId id, Value *vp)
{
assertSameCompartment(cx, receiver, id, *vp);
JSBool ok = op(cx, receiver, id, vp);
@ -483,7 +483,7 @@ CallJSPropertyOp(JSContext *cx, PropertyOp op, JSObject *receiver, jsid id, Valu
}
JS_ALWAYS_INLINE bool
CallJSPropertyOpSetter(JSContext *cx, StrictPropertyOp op, JSObject *obj, jsid id,
CallJSPropertyOpSetter(JSContext *cx, StrictPropertyOp op, HandleObject obj, HandleId id,
JSBool strict, Value *vp)
{
assertSameCompartment(cx, obj, id, *vp);
@ -491,7 +491,7 @@ CallJSPropertyOpSetter(JSContext *cx, StrictPropertyOp op, JSObject *obj, jsid i
}
inline bool
CallSetter(JSContext *cx, JSObject *obj, jsid id, StrictPropertyOp op, unsigned attrs,
CallSetter(JSContext *cx, HandleObject obj, HandleId id, StrictPropertyOp op, unsigned attrs,
unsigned shortid, JSBool strict, Value *vp)
{
if (attrs & JSPROP_SETTER)
@ -500,9 +500,12 @@ CallSetter(JSContext *cx, JSObject *obj, jsid id, StrictPropertyOp op, unsigned
if (attrs & JSPROP_GETTER)
return js_ReportGetterOnlyAssignment(cx);
if (attrs & JSPROP_SHORTID)
id = INT_TO_JSID(shortid);
return CallJSPropertyOpSetter(cx, op, obj, id, strict, vp);
if (!(attrs & JSPROP_SHORTID))
return CallJSPropertyOpSetter(cx, op, obj, id, strict, vp);
RootedVarId nid(cx, INT_TO_JSID(shortid));
return CallJSPropertyOpSetter(cx, op, obj, nid, strict, vp);
}
static inline HeapPtrAtom *

Просмотреть файл

@ -217,8 +217,7 @@ JSCompartment::wrap(JSContext *cx, Value *vp)
#ifdef DEBUG
{
JSObject *outer = obj;
OBJ_TO_OUTER_OBJECT(cx, outer);
JSObject *outer = GetOuterObject(cx, RootedVarObject(cx, obj));
JS_ASSERT(outer && outer == obj);
}
#endif

Просмотреть файл

@ -499,13 +499,12 @@ msFromTime(double t)
*/
static JSBool
date_convert(JSContext *cx, JSObject *obj, JSType hint, Value *vp)
date_convert(JSContext *cx, HandleObject obj, JSType hint, Value *vp)
{
JS_ASSERT(hint == JSTYPE_NUMBER || hint == JSTYPE_STRING || hint == JSTYPE_VOID);
JS_ASSERT(obj->isDate());
return DefaultValue(cx, RootedVarObject(cx, obj),
(hint == JSTYPE_VOID) ? JSTYPE_STRING : hint, vp);
return DefaultValue(cx, obj, (hint == JSTYPE_VOID) ? JSTYPE_STRING : hint, vp);
}
/*
@ -2693,11 +2692,11 @@ js_InitDateClass(JSContext *cx, JSObject *obj)
if (!JS_DefineFunctions(cx, dateProto, date_methods))
return NULL;
Value toUTCStringFun;
jsid toUTCStringId = NameToId(cx->runtime->atomState.toUTCStringAtom);
jsid toGMTStringId = NameToId(cx->runtime->atomState.toGMTStringAtom);
if (!js_GetProperty(cx, dateProto, toUTCStringId, &toUTCStringFun) ||
!js_DefineProperty(cx, dateProto, toGMTStringId, &toUTCStringFun,
JS_PropertyStub, JS_StrictPropertyStub, 0))
RootedVarId toUTCStringId(cx, NameToId(cx->runtime->atomState.toUTCStringAtom));
RootedVarId toGMTStringId(cx, NameToId(cx->runtime->atomState.toGMTStringAtom));
if (!baseops::GetProperty(cx, dateProto, toUTCStringId, &toUTCStringFun) ||
!baseops::DefineProperty(cx, dateProto, toGMTStringId, &toUTCStringFun,
JS_PropertyStub, JS_StrictPropertyStub, 0))
{
return NULL;
}

Просмотреть файл

@ -282,15 +282,14 @@ JS_SetWatchPoint(JSContext *cx, JSObject *obj_, jsid id,
RootedVarObject obj(cx, obj_), closure(cx, closure_);
JSObject *origobj;
Value v;
unsigned attrs;
origobj = obj;
OBJ_TO_INNER_OBJECT(cx, obj.reference());
JSObject *origobj = obj;
obj = GetInnerObject(cx, obj);
if (!obj)
return false;
Value v;
unsigned attrs;
RootedVarId propid(cx);
if (JSID_IS_INT(id)) {
@ -821,7 +820,7 @@ GetPropertyDesc(JSContext *cx, JSObject *obj_, Shape *shape, JSPropertyDesc *pd)
lastException = cx->getPendingException();
cx->clearPendingException();
if (!js_GetProperty(cx, obj, shape->propid(), &pd->value)) {
if (!baseops::GetProperty(cx, obj, RootedVarId(cx, shape->propid()), &pd->value)) {
if (!cx->isExceptionPending()) {
pd->flags = JSPD_ERROR;
pd->value = JSVAL_VOID;
@ -855,8 +854,10 @@ GetPropertyDesc(JSContext *cx, JSObject *obj_, Shape *shape, JSPropertyDesc *pd)
}
JS_PUBLIC_API(JSBool)
JS_GetPropertyDescArray(JSContext *cx, JSObject *obj, JSPropertyDescArray *pda)
JS_GetPropertyDescArray(JSContext *cx, JSObject *obj_, JSPropertyDescArray *pda)
{
RootedVarObject obj(cx, obj_);
assertSameCompartment(cx, obj);
uint32_t i = 0;
JSPropertyDesc *pd = NULL;

Просмотреть файл

@ -89,7 +89,7 @@ static void
exn_finalize(FreeOp *fop, JSObject *obj);
static JSBool
exn_resolve(JSContext *cx, JSObject *obj, jsid id, unsigned flags,
exn_resolve(JSContext *cx, HandleObject obj, HandleId id, unsigned flags,
JSObject **objp);
Class js::ErrorClass = {
@ -301,8 +301,8 @@ InitExnPrivate(JSContext *cx, HandleObject exnObject, HandleString message,
*/
if (checkAccess && i.isNonEvalFunctionFrame()) {
Value v = NullValue();
jsid callerid = NameToId(cx->runtime->atomState.callerAtom);
if (!checkAccess(cx, i.callee(), callerid, JSACC_READ, &v))
RootedVarId callerid(cx, NameToId(cx->runtime->atomState.callerAtom));
if (!checkAccess(cx, RootedVarObject(cx, i.callee()), callerid, JSACC_READ, &v))
break;
}
@ -418,7 +418,7 @@ exn_finalize(FreeOp *fop, JSObject *obj)
}
static JSBool
exn_resolve(JSContext *cx, JSObject *obj_, jsid id, unsigned flags,
exn_resolve(JSContext *cx, HandleObject obj, HandleId id, unsigned flags,
JSObject **objp)
{
JSExnPrivate *priv;
@ -429,8 +429,6 @@ exn_resolve(JSContext *cx, JSObject *obj_, jsid id, unsigned flags,
jsval v;
unsigned attrs;
RootedVarObject obj(cx, obj_);
*objp = NULL;
priv = GetExnPrivate(obj);
if (priv && JSID_IS_ATOM(id)) {

Просмотреть файл

@ -69,8 +69,10 @@ JS_GetAnonymousString(JSRuntime *rt)
}
JS_FRIEND_API(JSObject *)
JS_FindCompilationScope(JSContext *cx, JSObject *obj)
JS_FindCompilationScope(JSContext *cx, JSObject *obj_)
{
RootedVarObject obj(cx, obj_);
/*
* We unwrap wrappers here. This is a little weird, but it's what's being
* asked of us.
@ -230,7 +232,7 @@ JS_DefineFunctionsWithHelp(JSContext *cx, JSObject *obj, const JSFunctionSpecWit
return false;
RootedVarFunction fun(cx);
fun = js_DefineFunction(cx, objRoot, AtomToId(atom),
fun = js_DefineFunction(cx, objRoot, RootedVarId(cx, AtomToId(atom)),
fs->call, fs->nargs, fs->flags);
if (!fun)
return false;
@ -337,7 +339,7 @@ js::DefineFunctionWithReserved(JSContext *cx, JSObject *obj, const char *name, J
JSAtom *atom = js_Atomize(cx, name, strlen(name));
if (!atom)
return NULL;
return js_DefineFunction(cx, objRoot, AtomToId(atom),
return js_DefineFunction(cx, objRoot, RootedVarId(cx, AtomToId(atom)),
call, nargs, attrs,
JSFunction::ExtendedFinalizeKind);
}

Просмотреть файл

@ -129,7 +129,7 @@ extern JS_FRIEND_API(JSObject *)
JS_CloneObject(JSContext *cx, JSObject *obj, JSObject *proto, JSObject *parent);
extern JS_FRIEND_API(JSBool)
js_GetterOnlyPropertyStub(JSContext *cx, JSObject *obj, jsid id, JSBool strict, jsval *vp);
js_GetterOnlyPropertyStub(JSContext *cx, JSHandleObject obj, JSHandleId id, JSBool strict, jsval *vp);
JS_FRIEND_API(void)
js_ReportOverRecursed(JSContext *maybecx);
@ -164,7 +164,7 @@ extern JS_FRIEND_API(JSBool)
JS_WrapPropertyDescriptor(JSContext *cx, js::PropertyDescriptor *desc);
extern JS_FRIEND_API(JSBool)
JS_EnumerateState(JSContext *cx, JSObject *obj, JSIterateOp enum_op, js::Value *statep, jsid *idp);
JS_EnumerateState(JSContext *cx, JSHandleObject obj, JSIterateOp enum_op, js::Value *statep, jsid *idp);
struct JSFunctionSpecWithHelp {
const char *name;

Просмотреть файл

@ -97,8 +97,9 @@ using namespace js::gc;
using namespace js::types;
static JSBool
fun_getProperty(JSContext *cx, JSObject *obj, jsid id, Value *vp)
fun_getProperty(JSContext *cx, HandleObject obj_, HandleId id, Value *vp)
{
JSObject *obj = obj_;
while (!obj->isFunction()) {
obj = obj->getProto();
if (!obj)
@ -208,13 +209,11 @@ static const uint16_t poisonPillProps[] = {
};
static JSBool
fun_enumerate(JSContext *cx, JSObject *obj)
fun_enumerate(JSContext *cx, HandleObject obj)
{
JS_ASSERT(obj->isFunction());
RootObject root(cx, &obj);
jsid id;
RootedVarId id(cx);
bool found;
if (!obj->isBoundFunction()) {
@ -288,7 +287,7 @@ ResolveInterpretedFunctionPrototype(JSContext *cx, HandleObject obj)
}
static JSBool
fun_resolve(JSContext *cx, JSObject *obj, jsid id, unsigned flags,
fun_resolve(JSContext *cx, HandleObject obj, HandleId id, unsigned flags,
JSObject **objp)
{
if (!JSID_IS_ATOM(id))
@ -477,8 +476,10 @@ js::CloneInterpretedFunction(JSContext *cx, JSFunction *srcFun)
* if v is an object) returning true if .prototype is found.
*/
static JSBool
fun_hasInstance(JSContext *cx, JSObject *obj, const Value *v, JSBool *bp)
fun_hasInstance(JSContext *cx, HandleObject obj_, const Value *v, JSBool *bp)
{
RootedVarObject obj(cx, obj_);
while (obj->isFunction()) {
if (!obj->isBoundFunction())
break;
@ -1315,11 +1316,9 @@ js_CloneFunctionObject(JSContext *cx, HandleFunction fun, HandleObject parent,
}
JSFunction *
js_DefineFunction(JSContext *cx, HandleObject obj, jsid id, Native native,
js_DefineFunction(JSContext *cx, HandleObject obj, HandleId id, Native native,
unsigned nargs, unsigned attrs, AllocKind kind)
{
RootId idRoot(cx, &id);
PropertyOp gop;
StrictPropertyOp sop;

Просмотреть файл

@ -246,7 +246,7 @@ js_CloneFunctionObject(JSContext *cx, js::HandleFunction fun,
js::gc::AllocKind kind = JSFunction::FinalizeKind);
extern JSFunction *
js_DefineFunction(JSContext *cx, js::HandleObject obj, jsid id, JSNative native,
js_DefineFunction(JSContext *cx, js::HandleObject obj, js::HandleId id, JSNative native,
unsigned nargs, unsigned flags,
js::gc::AllocKind kind = JSFunction::FinalizeKind);

Просмотреть файл

@ -4393,10 +4393,10 @@ AnalyzeNewScriptProperties(JSContext *cx, TypeObject *type, JSFunction *fun, JSO
* integer properties and bail out. We can't mark the aggregate
* JSID_VOID type property as being in a definite slot.
*/
jsid id = NameToId(script->getName(GET_UINT32_INDEX(pc)));
RootedVarId id(cx, NameToId(script->getName(GET_UINT32_INDEX(pc))));
if (MakeTypeId(cx, id) != id)
return false;
if (id == id_prototype(cx) || id == id___proto__(cx) || id == id_constructor(cx))
if (id_prototype(cx) == id || id___proto__(cx) == id || id_constructor(cx) == id)
return false;
/*

Просмотреть файл

@ -194,9 +194,9 @@ js::OnUnknownMethod(JSContext *cx, HandleObject obj, Value idval_, Value *vp)
{
RootedVarValue idval(cx, idval_);
jsid id = NameToId(cx->runtime->atomState.noSuchMethodAtom);
RootedVarId id(cx, NameToId(cx->runtime->atomState.noSuchMethodAtom));
RootedVarValue value(cx);
if (!js_GetMethod(cx, obj, id, 0, value.address()))
if (!GetMethod(cx, obj, id, 0, value.address()))
return false;
TypeScript::MonitorUnknown(cx, cx->fp()->script(), cx->regs().pc);
@ -207,7 +207,7 @@ js::OnUnknownMethod(JSContext *cx, HandleObject obj, Value idval_, Value *vp)
/* Extract the function name from function::name qname. */
if (idval.reference().isObject()) {
JSObject *obj = &idval.reference().toObject();
if (js_GetLocalNameFromFunctionQName(obj, &id, cx))
if (js_GetLocalNameFromFunctionQName(obj, id.address(), cx))
idval = IdToValue(id);
}
#endif
@ -513,8 +513,8 @@ bool
js::Execute(JSContext *cx, JSScript *script, JSObject &scopeChainArg, Value *rval)
{
/* The scope chain could be anything, so innerize just in case. */
JSObject *scopeChain = &scopeChainArg;
OBJ_TO_INNER_OBJECT(cx, scopeChain);
RootedVarObject scopeChain(cx, &scopeChainArg);
scopeChain = GetInnerObject(cx, scopeChain);
if (!scopeChain)
return false;
@ -542,7 +542,7 @@ js::Execute(JSContext *cx, JSScript *script, JSObject &scopeChainArg, Value *rva
}
JSBool
js::HasInstance(JSContext *cx, JSObject *obj, const Value *v, JSBool *bp)
js::HasInstance(JSContext *cx, HandleObject obj, const Value *v, JSBool *bp)
{
Class *clasp = obj->getClass();
if (clasp->hasInstance)
@ -585,7 +585,7 @@ js::LooselyEqual(JSContext *cx, const Value &lval, const Value &rval, bool *resu
if (JSEqualityOp eq = l->getClass()->ext.equality) {
JSBool res;
if (!eq(cx, l, &rval, &res))
if (!eq(cx, RootedVarObject(cx, l), &rval, &res))
return false;
*result = !!res;
return true;
@ -1030,7 +1030,7 @@ js::AssertValidPropertyCacheHit(JSContext *cx,
if (JOF_OPMODE(*pc) == JOF_NAME)
ok = FindProperty(cx, name, start, &obj, &pobj, &prop);
else
ok = LookupProperty(cx, start, name, &pobj, &prop);
ok = baseops::LookupProperty(cx, start, name.reference(), &pobj, &prop);
JS_ASSERT(ok);
if (cx->runtime->gcNumber != sample)
@ -1349,6 +1349,7 @@ js::Interpret(JSContext *cx, StackFrame *entryFrame, InterpMode interpMode)
RootedVarFunction rootFunction0(cx);
RootedVarTypeObject rootType0(cx);
RootedVarPropertyName rootName0(cx);
RootedVarId rootId0(cx);
if (rt->profilingScripts)
ENABLE_INTERRUPTS();
@ -1800,7 +1801,7 @@ END_CASE(JSOP_AND)
#define FETCH_ELEMENT_ID(obj, n, id) \
JS_BEGIN_MACRO \
const Value &idval_ = regs.sp[n]; \
if (!ValueToId(cx, obj, idval_, &id)) \
if (!ValueToId(cx, obj, idval_, id.address())) \
goto error; \
JS_END_MACRO
@ -1829,7 +1830,7 @@ BEGIN_CASE(JSOP_IN)
}
RootedVarObject &obj = rootObject0;
obj = &rref.toObject();
jsid id;
RootedVarId &id = rootId0;
FETCH_ELEMENT_ID(obj, -2, id);
JSObject *obj2;
JSProperty *prop;
@ -1944,7 +1945,7 @@ BEGIN_CASE(JSOP_ENUMCONSTELEM)
const Value &ref = regs.sp[-3];
JSObject *obj;
FETCH_OBJECT(cx, -2, obj);
jsid id;
RootedVarId &id = rootId0;
FETCH_ELEMENT_ID(obj, -1, id);
if (!obj->defineGeneric(cx, id, ref,
JS_PropertyStub, JS_StrictPropertyStub,
@ -2329,7 +2330,8 @@ BEGIN_CASE(JSOP_DELELEM)
JSObject *obj;
FETCH_OBJECT(cx, -2, obj);
const Value &propval = regs.sp[-1];
RootedVarValue &propval = rootValue0;
propval = regs.sp[-1];
Value &rval = regs.sp[-2];
if (!obj->deleteByValue(cx, propval, &rval, script->strictModeCode))
@ -2477,7 +2479,7 @@ BEGIN_CASE(JSOP_SETELEM)
{
RootedVarObject &obj = rootObject0;
FETCH_OBJECT(cx, -3, obj);
jsid id;
RootedVarId &id = rootId0;
FETCH_ELEMENT_ID(obj, -2, id);
Value &value = regs.sp[-1];
if (!SetObjectElementOperation(cx, obj, id, value, script->strictModeCode))
@ -2494,7 +2496,7 @@ BEGIN_CASE(JSOP_ENUMELEM)
/* Funky: the value to set is under the [obj, id] pair. */
FETCH_OBJECT(cx, -2, obj);
jsid id;
RootedVarId &id = rootId0;
FETCH_ELEMENT_ID(obj, -1, id);
rval = regs.sp[-3];
if (!obj->setGeneric(cx, id, rval.address(), script->strictModeCode))
@ -3065,7 +3067,7 @@ BEGIN_CASE(JSOP_GETTER)
BEGIN_CASE(JSOP_SETTER)
{
JSOp op2 = JSOp(*++regs.pc);
jsid id;
RootedVarId &id = rootId0;
Value rval;
int i;
JSObject *obj;
@ -3229,12 +3231,14 @@ BEGIN_CASE(JSOP_INITPROP)
obj = &regs.sp[-2].toObject();
JS_ASSERT(obj->isObject());
RootedVarId &id = rootId0;
PropertyName *name;
LOAD_NAME(0, name);
jsid id = NameToId(name);
id = NameToId(name);
if (JS_UNLIKELY(name == cx->runtime->atomState.protoAtom)
? !js_SetPropertyHelper(cx, obj, id, 0, &rval, script->strictModeCode)
? !baseops::SetPropertyHelper(cx, obj, id, 0, &rval, script->strictModeCode)
: !DefineNativeProperty(cx, obj, id, rval, NULL, NULL,
JSPROP_ENUMERATE, 0, 0, 0)) {
goto error;
@ -3258,7 +3262,7 @@ BEGIN_CASE(JSOP_INITELEM)
obj = &lref.toObject();
/* Fetch id now that we have obj. */
jsid id;
RootedVarId &id = rootId0;
FETCH_ELEMENT_ID(obj, -2, id);
/*
@ -3351,7 +3355,8 @@ BEGIN_CASE(JSOP_INSTANCEOF)
js_ReportValueError(cx, JSMSG_BAD_INSTANCEOF_RHS, -1, rref, NULL);
goto error;
}
JSObject *obj = &rref.toObject();
RootedVarObject &obj = rootObject0;
obj = &rref.toObject();
const Value &lref = regs.sp[-2];
JSBool cond = JS_FALSE;
if (!HasInstance(cx, obj, &lref, &cond))
@ -3520,7 +3525,7 @@ BEGIN_CASE(JSOP_SETXMLNAME)
JSObject *obj = &regs.sp[-3].toObject();
Value rval = regs.sp[-1];
jsid id;
RootedVarId &id = rootId0;
FETCH_ELEMENT_ID(obj, -2, id);
if (!obj->setGeneric(cx, id, &rval, script->strictModeCode))
goto error;
@ -3537,8 +3542,8 @@ BEGIN_CASE(JSOP_XMLNAME)
Value lval = regs.sp[-1];
JSObject *obj;
jsid id;
if (!js_FindXMLProperty(cx, lval, &obj, &id))
RootedVarId &id = rootId0;
if (!js_FindXMLProperty(cx, lval, &obj, id.address()))
goto error;
Value rval;
if (!obj->getGeneric(cx, id, &rval))
@ -3814,7 +3819,8 @@ BEGIN_CASE(JSOP_ARRAYPUSH)
JS_ASSERT(script->nfixed <= slot);
JS_ASSERT(slot < script->nslots);
CheckLocalAccess(regs.fp(), slot);
JSObject *obj = &regs.fp()->slots()[slot].toObject();
RootedVarObject &obj = rootObject0;
obj = &regs.fp()->slots()[slot].toObject();
if (!js_NewbornArrayPush(cx, obj, regs.sp[-1]))
goto error;
regs.sp--;

Просмотреть файл

@ -244,7 +244,7 @@ extern JSType
TypeOfValue(JSContext *cx, const Value &v);
extern JSBool
HasInstance(JSContext *cx, JSObject *obj, const js::Value *v, JSBool *bp);
HasInstance(JSContext *cx, HandleObject obj, const js::Value *v, JSBool *bp);
/*
* A linked list of the |FrameRegs regs;| variables belonging to all

Просмотреть файл

@ -183,7 +183,7 @@ AssertValidPropertyCacheHit(JSContext *cx, JSObject *start, JSObject *found,
#endif
inline bool
GetPropertyGenericMaybeCallXML(JSContext *cx, JSOp op, HandleObject obj, jsid id, Value *vp)
GetPropertyGenericMaybeCallXML(JSContext *cx, JSOp op, HandleObject obj, HandleId id, Value *vp)
{
/*
* Various XML properties behave differently when accessed in a
@ -339,12 +339,12 @@ SetPropertyOperation(JSContext *cx, jsbytecode *pc, const Value &lval, const Val
RootObject objRoot(cx, &obj);
jsid id = NameToId(name);
RootedVarId id(cx, NameToId(name));
if (JS_LIKELY(!obj->getOps()->setProperty)) {
unsigned defineHow = (op == JSOP_SETNAME)
? DNP_CACHE_RESULT | DNP_UNQUALIFIED
: DNP_CACHE_RESULT;
if (!js_SetPropertyHelper(cx, objRoot, id, defineHow, rref.address(), strict))
if (!baseops::SetPropertyHelper(cx, objRoot, id, defineHow, rref.address(), strict))
return false;
} else {
if (!obj->setGeneric(cx, id, rref.address(), strict))
@ -405,7 +405,7 @@ NameOperation(JSContext *cx, jsbytecode *pc, Value *vp)
/* Take the slow path if prop was not found in a native object. */
if (!obj->isNative() || !obj2->isNative()) {
if (!obj->getGeneric(cx, id, vp))
if (!obj->getGeneric(cx, RootedVarId(cx, id), vp))
return false;
} else {
Shape *shape = (Shape *)prop;
@ -710,14 +710,14 @@ ModOperation(JSContext *cx, HandleValue lhs, HandleValue rhs, Value *res)
}
static inline bool
FetchElementId(JSContext *cx, JSObject *obj, const Value &idval, jsid &id, Value *vp)
FetchElementId(JSContext *cx, JSObject *obj, const Value &idval, jsid *idp, Value *vp)
{
int32_t i_;
if (ValueFitsInInt32(idval, &i_) && INT_FITS_IN_JSID(i_)) {
id = INT_TO_JSID(i_);
*idp = INT_TO_JSID(i_);
return true;
}
return !!InternNonIntElementId(cx, obj, idval, &id, vp);
return !!InternNonIntElementId(cx, obj, idval, idp, vp);
}
static JS_ALWAYS_INLINE bool
@ -747,7 +747,7 @@ GetObjectElementOperation(JSContext *cx, JSOp op, HandleObject obj, const Value
#if JS_HAS_XML_SUPPORT
if (op == JSOP_CALLELEM && JS_UNLIKELY(obj->isXML())) {
jsid id;
if (!FetchElementId(cx, obj, rref, id, res))
if (!FetchElementId(cx, obj, rref, &id, res))
return false;
return js_GetXMLMethod(cx, obj, id, res);
}
@ -838,7 +838,7 @@ GetElementOperation(JSContext *cx, JSOp op, const Value &lref, const Value &rref
}
static JS_ALWAYS_INLINE bool
SetObjectElementOperation(JSContext *cx, JSObject *obj, jsid id, const Value &value, bool strict)
SetObjectElementOperation(JSContext *cx, JSObject *obj, HandleId id, const Value &value, bool strict)
{
types::TypeScript::MonitorAssign(cx, obj, id);

Просмотреть файл

@ -86,7 +86,7 @@ using namespace js::gc;
static void iterator_finalize(FreeOp *fop, JSObject *obj);
static void iterator_trace(JSTracer *trc, JSObject *obj);
static JSObject *iterator_iterator(JSContext *cx, JSObject *obj, JSBool keysonly);
static JSObject *iterator_iterator(JSContext *cx, HandleObject obj, JSBool keysonly);
Class js::IteratorClass = {
"Iterator",
@ -464,7 +464,7 @@ GetCustomIterator(JSContext *cx, HandleObject obj, unsigned flags, Value *vp)
/* Check whether we have a valid __iterator__ method. */
PropertyName *name = cx->runtime->atomState.iteratorAtom;
if (!js_GetMethod(cx, obj, NameToId(name), 0, vp))
if (!GetMethod(cx, obj, name, 0, vp))
return false;
/* If there is no custom __iterator__ method, we are done here. */
@ -822,7 +822,7 @@ GetIterator(JSContext *cx, HandleObject obj, unsigned flags, Value *vp)
}
static JSObject *
iterator_iterator(JSContext *cx, JSObject *obj, JSBool keysonly)
iterator_iterator(JSContext *cx, HandleObject obj, JSBool keysonly)
{
return obj;
}
@ -1018,8 +1018,8 @@ SuppressDeletedPropertyHelper(JSContext *cx, HandleObject obj, StringPredicate p
JSObject *proto = obj->getProto();
JSObject *obj2;
JSProperty *prop;
jsid id;
if (!ValueToId(cx, StringValue(*idp), &id))
RootedVarId id(cx);
if (!ValueToId(cx, StringValue(*idp), id.address()))
return false;
if (!proto->lookupGeneric(cx, id, &obj2, &prop))
return false;
@ -1218,8 +1218,8 @@ js_IteratorMore(JSContext *cx, HandleObject iterobj, Value *rval)
/* Fetch and cache the next value from the iterator. */
if (ni) {
JS_ASSERT(!ni->isKeyIter());
jsid id;
if (!ValueToId(cx, StringValue(*ni->current()), &id))
RootedVarId id(cx);
if (!ValueToId(cx, StringValue(*ni->current()), id.address()))
return false;
ni->incCursor();
if (!ni->obj->getGeneric(cx, id, rval))
@ -1247,8 +1247,7 @@ js_IteratorMore(JSContext *cx, HandleObject iterobj, Value *rval)
}
} else {
/* Call the iterator object's .next method. */
jsid id = NameToId(cx->runtime->atomState.nextAtom);
if (!js_GetMethod(cx, iterobj, id, 0, rval))
if (!GetMethod(cx, iterobj, cx->runtime->atomState.nextAtom, 0, rval))
return false;
if (!Invoke(cx, ObjectValue(*iterobj), *rval, 0, NULL, rval)) {
/* Check for StopIteration. */
@ -1310,7 +1309,7 @@ js_IteratorNext(JSContext *cx, JSObject *iterobj, Value *rval)
}
static JSBool
stopiter_hasInstance(JSContext *cx, JSObject *obj, const Value *v, JSBool *bp)
stopiter_hasInstance(JSContext *cx, HandleObject obj, const Value *v, JSBool *bp)
{
*bp = IsStopIteration(*v);
return JS_TRUE;

Просмотреть файл

@ -1039,10 +1039,10 @@ js_InitNumberClass(JSContext *cx, JSObject *obj)
return NULL;
/* ES5 15.1.1.1, 15.1.1.2 */
if (!DefineNativeProperty(cx, global, NameToId(cx->runtime->atomState.NaNAtom),
if (!DefineNativeProperty(cx, global, cx->runtime->atomState.NaNAtom,
cx->runtime->NaNValue, JS_PropertyStub, JS_StrictPropertyStub,
JSPROP_PERMANENT | JSPROP_READONLY, 0, 0) ||
!DefineNativeProperty(cx, global, NameToId(cx->runtime->atomState.InfinityAtom),
!DefineNativeProperty(cx, global, cx->runtime->atomState.InfinityAtom,
cx->runtime->positiveInfinityValue,
JS_PropertyStub, JS_StrictPropertyStub,
JSPROP_PERMANENT | JSPROP_READONLY, 0, 0))

Просмотреть файл

@ -123,24 +123,22 @@ JS_ObjectToInnerObject(JSContext *cx, JSObject *obj)
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_INACTIVE);
return NULL;
}
OBJ_TO_INNER_OBJECT(cx, obj);
return obj;
return GetInnerObject(cx, RootedVarObject(cx, obj));
}
JS_FRIEND_API(JSObject *)
JS_ObjectToOuterObject(JSContext *cx, JSObject *obj)
{
OBJ_TO_OUTER_OBJECT(cx, obj);
return obj;
return GetOuterObject(cx, RootedVarObject(cx, obj));
}
#if JS_HAS_OBJ_PROTO_PROP
static JSBool
obj_getProto(JSContext *cx, JSObject *obj, jsid id, Value *vp);
obj_getProto(JSContext *cx, HandleObject obj, HandleId id, Value *vp);
static JSBool
obj_setProto(JSContext *cx, JSObject *obj, jsid id, JSBool strict, Value *vp);
obj_setProto(JSContext *cx, HandleObject obj, HandleId id, JSBool strict, Value *vp);
JSPropertySpec object_props[] = {
{js_proto_str, 0, JSPROP_PERMANENT|JSPROP_SHARED, obj_getProto, obj_setProto},
@ -148,21 +146,19 @@ JSPropertySpec object_props[] = {
};
static JSBool
obj_getProto(JSContext *cx, JSObject *obj, jsid id, Value *vp)
obj_getProto(JSContext *cx, HandleObject obj, HandleId id, Value *vp)
{
/* Let CheckAccess get the slot's value, based on the access mode. */
unsigned attrs;
id = NameToId(cx->runtime->atomState.protoAtom);
return CheckAccess(cx, obj, id, JSACC_PROTO, vp, &attrs);
RootedVarId nid(cx, NameToId(cx->runtime->atomState.protoAtom));
return CheckAccess(cx, obj, nid, JSACC_PROTO, vp, &attrs);
}
size_t sSetProtoCalled = 0;
static JSBool
obj_setProto(JSContext *cx, JSObject *obj_, jsid id, JSBool strict, Value *vp)
obj_setProto(JSContext *cx, HandleObject obj, HandleId id, JSBool strict, Value *vp)
{
RootedVarObject obj(cx, obj_);
if (!cx->runningWithTrustedPrincipals())
++sSetProtoCalled;
@ -177,8 +173,8 @@ obj_setProto(JSContext *cx, JSObject *obj_, jsid id, JSBool strict, Value *vp)
RootedVarObject pobj(cx, vp->toObjectOrNull());
unsigned attrs;
id = NameToId(cx->runtime->atomState.protoAtom);
if (!CheckAccess(cx, obj, id, JSAccessMode(JSACC_PROTO|JSACC_WRITE), vp, &attrs))
RootedVarId nid(cx, NameToId(cx->runtime->atomState.protoAtom));
if (!CheckAccess(cx, obj, nid, JSAccessMode(JSACC_PROTO|JSACC_WRITE), vp, &attrs))
return false;
return SetProto(cx, obj, pobj, true);
@ -210,8 +206,9 @@ MarkSharpObjects(JSContext *cx, HandleObject obj, JSIdArray **idap, JSSharpInfo
return false;
bool ok = true;
RootedVarId id(cx);
for (int i = 0, length = ida->length; i < length; i++) {
jsid id = ida->vector[i];
id = ida->vector[i];
JSObject *obj2;
JSProperty *prop;
ok = obj->lookupGeneric(cx, id, &obj2, &prop);
@ -484,9 +481,10 @@ obj_toSource(JSContext *cx, unsigned argc, Value *vp)
*/
val = localroot + 2;
RootedVarId id(cx);
for (int i = 0; i < ida->length; i++) {
/* Get strings for id and value and GC-root them via vp. */
jsid id = ida->vector[i];
id = ida->vector[i];
JSLinearString *idstr;
JSObject *obj2;
@ -716,7 +714,8 @@ obj_toLocaleString(JSContext *cx, unsigned argc, Value *vp)
return false;
/* Steps 2-4. */
return obj->callMethod(cx, NameToId(cx->runtime->atomState.toStringAtom), 0, NULL, vp);
RootedVarId id(cx, NameToId(cx->runtime->atomState.toStringAtom));
return obj->callMethod(cx, id, 0, NULL, vp);
}
static JSBool
@ -736,7 +735,7 @@ AssertInnerizedScopeChain(JSContext *cx, JSObject &scopeobj)
#ifdef DEBUG
for (JSObject *o = &scopeobj; o; o = o->enclosingScope()) {
if (JSObjectOp op = o->getClass()->ext.innerObject)
JS_ASSERT(op(cx, o) == o);
JS_ASSERT(op(cx, RootedVarObject(cx, o)) == o);
}
#endif
}
@ -1277,8 +1276,8 @@ JSBool
js_HasOwnPropertyHelper(JSContext *cx, LookupGenericOp lookup, unsigned argc,
Value *vp)
{
jsid id;
if (!ValueToId(cx, argc != 0 ? vp[2] : UndefinedValue(), &id))
RootedVarId id(cx);
if (!ValueToId(cx, argc != 0 ? vp[2] : UndefinedValue(), id.address()))
return JS_FALSE;
RootedVarObject obj(cx, ToObject(cx, &vp[1]));
@ -1300,12 +1299,17 @@ js_HasOwnPropertyHelper(JSContext *cx, LookupGenericOp lookup, unsigned argc,
}
JSBool
js_HasOwnProperty(JSContext *cx, LookupGenericOp lookup, HandleObject obj, jsid id,
js_HasOwnProperty(JSContext *cx, LookupGenericOp lookup, HandleObject obj, HandleId id,
JSObject **objp, JSProperty **propp)
{
JSAutoResolveFlags rf(cx, JSRESOLVE_QUALIFIED | JSRESOLVE_DETECTING);
if (!(lookup ? lookup : js_LookupProperty)(cx, obj, id, objp, propp))
return false;
if (lookup) {
if (!lookup(cx, obj, id, objp, propp))
return false;
} else {
if (!baseops::LookupProperty(cx, obj, id, objp, propp))
return false;
}
if (!*propp)
return true;
@ -1314,7 +1318,7 @@ js_HasOwnProperty(JSContext *cx, LookupGenericOp lookup, HandleObject obj, jsid
JSObject *outer = NULL;
if (JSObjectOp op = (*objp)->getClass()->ext.outerObject) {
outer = op(cx, *objp);
outer = op(cx, RootedVarObject(cx, *objp));
if (!outer)
return false;
}
@ -1349,12 +1353,12 @@ static JSBool
obj_propertyIsEnumerable(JSContext *cx, unsigned argc, Value *vp)
{
/* Step 1. */
jsid id;
if (!ValueToId(cx, argc != 0 ? vp[2] : UndefinedValue(), &id))
RootedVarId id(cx);
if (!ValueToId(cx, argc != 0 ? vp[2] : UndefinedValue(), id.address()))
return false;
/* Step 2. */
JSObject *obj = ToObject(cx, &vp[1]);
RootedVarObject obj(cx, ToObject(cx, &vp[1]));
if (!obj)
return false;
@ -1363,7 +1367,7 @@ obj_propertyIsEnumerable(JSContext *cx, unsigned argc, Value *vp)
}
JSBool
js_PropertyIsEnumerable(JSContext *cx, JSObject *obj, jsid id, Value *vp)
js_PropertyIsEnumerable(JSContext *cx, HandleObject obj, HandleId id, Value *vp)
{
JSObject *pobj;
JSProperty *prop;
@ -1458,10 +1462,10 @@ js::obj_defineSetter(JSContext *cx, unsigned argc, Value *vp)
static JSBool
obj_lookupGetter(JSContext *cx, unsigned argc, Value *vp)
{
jsid id;
if (!ValueToId(cx, argc != 0 ? vp[2] : UndefinedValue(), &id))
RootedVarId id(cx);
if (!ValueToId(cx, argc != 0 ? vp[2] : UndefinedValue(), id.address()))
return JS_FALSE;
JSObject *obj = ToObject(cx, &vp[1]);
RootedVarObject obj(cx, ToObject(cx, &vp[1]));
if (!obj)
return JS_FALSE;
JSObject *pobj;
@ -1482,10 +1486,10 @@ obj_lookupGetter(JSContext *cx, unsigned argc, Value *vp)
static JSBool
obj_lookupSetter(JSContext *cx, unsigned argc, Value *vp)
{
jsid id;
if (!ValueToId(cx, argc != 0 ? vp[2] : UndefinedValue(), &id))
RootedVarId id(cx);
if (!ValueToId(cx, argc != 0 ? vp[2] : UndefinedValue(), id.address()))
return JS_FALSE;
JSObject *obj = ToObject(cx, &vp[1]);
RootedVarObject obj(cx, ToObject(cx, &vp[1]));
if (!obj)
return JS_FALSE;
JSObject *pobj;
@ -1524,8 +1528,8 @@ obj_getPrototypeOf(JSContext *cx, unsigned argc, Value *vp)
JSObject *obj = &vp[2].toObject();
unsigned attrs;
return CheckAccess(cx, obj, NameToId(cx->runtime->atomState.protoAtom),
JSACC_PROTO, vp, &attrs);
RootedVarId nid(cx, NameToId(cx->runtime->atomState.protoAtom));
return CheckAccess(cx, obj, nid, JSACC_PROTO, vp, &attrs);
}
namespace js {
@ -1736,7 +1740,7 @@ obj_keys(JSContext *cx, unsigned argc, Value *vp)
}
static bool
HasProperty(JSContext *cx, JSObject *obj, jsid id, Value *vp, bool *foundp)
HasProperty(JSContext *cx, HandleObject obj, HandleId id, Value *vp, bool *foundp)
{
if (!obj->hasProperty(cx, id, foundp, JSRESOLVE_QUALIFIED | JSRESOLVE_DETECTING))
return false;
@ -1764,7 +1768,7 @@ PropDesc::initialize(JSContext *cx, const Value &origval, bool checkAccessors)
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_NOT_NONNULL_OBJECT);
return false;
}
JSObject *desc = &v.toObject();
RootedVarObject desc(cx, &v.toObject());
/* Make a copy of the descriptor. We might need it later. */
pd_ = v;
@ -1777,13 +1781,12 @@ PropDesc::initialize(JSContext *cx, const Value &origval, bool checkAccessors)
*/
attrs = JSPROP_PERMANENT | JSPROP_READONLY;
bool found;
bool found = false;
RootedVarId id(cx);
/* 8.10.5 step 3 */
#ifdef __GNUC__ /* quell GCC overwarning */
found = false;
#endif
if (!HasProperty(cx, desc, NameToId(cx->runtime->atomState.enumerableAtom), &v, &found))
id = NameToId(cx->runtime->atomState.enumerableAtom);
if (!HasProperty(cx, desc, id, &v, &found))
return false;
if (found) {
hasEnumerable_ = true;
@ -1792,7 +1795,8 @@ PropDesc::initialize(JSContext *cx, const Value &origval, bool checkAccessors)
}
/* 8.10.5 step 4 */
if (!HasProperty(cx, desc, NameToId(cx->runtime->atomState.configurableAtom), &v, &found))
id = NameToId(cx->runtime->atomState.configurableAtom);
if (!HasProperty(cx, desc, id, &v, &found))
return false;
if (found) {
hasConfigurable_ = true;
@ -1801,7 +1805,8 @@ PropDesc::initialize(JSContext *cx, const Value &origval, bool checkAccessors)
}
/* 8.10.5 step 5 */
if (!HasProperty(cx, desc, NameToId(cx->runtime->atomState.valueAtom), &v, &found))
id = NameToId(cx->runtime->atomState.valueAtom);
if (!HasProperty(cx, desc, id, &v, &found))
return false;
if (found) {
hasValue_ = true;
@ -1809,7 +1814,8 @@ PropDesc::initialize(JSContext *cx, const Value &origval, bool checkAccessors)
}
/* 8.10.6 step 6 */
if (!HasProperty(cx, desc, NameToId(cx->runtime->atomState.writableAtom), &v, &found))
id = NameToId(cx->runtime->atomState.writableAtom);
if (!HasProperty(cx, desc, id, &v, &found))
return false;
if (found) {
hasWritable_ = true;
@ -1818,7 +1824,8 @@ PropDesc::initialize(JSContext *cx, const Value &origval, bool checkAccessors)
}
/* 8.10.7 step 7 */
if (!HasProperty(cx, desc, NameToId(cx->runtime->atomState.getAtom), &v, &found))
id = NameToId(cx->runtime->atomState.getAtom);
if (!HasProperty(cx, desc, id, &v, &found))
return false;
if (found) {
hasGet_ = true;
@ -1830,7 +1837,8 @@ PropDesc::initialize(JSContext *cx, const Value &origval, bool checkAccessors)
}
/* 8.10.7 step 8 */
if (!HasProperty(cx, desc, NameToId(cx->runtime->atomState.setAtom), &v, &found))
id = NameToId(cx->runtime->atomState.setAtom);
if (!HasProperty(cx, desc, id, &v, &found))
return false;
if (found) {
hasSet_ = true;
@ -1928,9 +1936,9 @@ DefinePropertyOnObject(JSContext *cx, HandleObject obj, HandleId id, const PropD
if (desc.isGenericDescriptor() || desc.isDataDescriptor()) {
JS_ASSERT(!obj->getOps()->defineProperty);
Value v = desc.hasValue() ? desc.value() : UndefinedValue();
return js_DefineProperty(cx, obj, id, &v,
JS_PropertyStub, JS_StrictPropertyStub,
desc.attributes());
return baseops::DefineProperty(cx, obj, id, &v,
JS_PropertyStub, JS_StrictPropertyStub,
desc.attributes());
}
JS_ASSERT(desc.isAccessorDescriptor());
@ -1945,8 +1953,8 @@ DefinePropertyOnObject(JSContext *cx, HandleObject obj, HandleId id, const PropD
return JS_FALSE;
Value tmp = UndefinedValue();
return js_DefineProperty(cx, obj, id, &tmp,
desc.getter(), desc.setter(), desc.attributes());
return baseops::DefineProperty(cx, obj, id, &tmp,
desc.getter(), desc.setter(), desc.attributes());
}
/* 8.12.9 steps 5-6 (note 5 is merely a special case of 6). */
@ -2196,7 +2204,7 @@ DefinePropertyOnObject(JSContext *cx, HandleObject obj, HandleId id, const PropD
return false;
}
return js_DefineProperty(cx, obj, id, &v, getter, setter, attrs);
return baseops::DefineProperty(cx, obj, id, &v, getter, setter, attrs);
}
static JSBool
@ -2317,8 +2325,9 @@ ReadPropertyDescriptors(JSContext *cx, JSObject *props, bool checkAccessors,
if (!GetPropertyNames(cx, props, JSITER_OWNONLY, ids))
return false;
RootedVarId id(cx);
for (size_t i = 0, len = ids->length(); i < len; i++) {
jsid id = (*ids)[i];
id = (*ids)[i];
PropDesc* desc = descs->append();
Value v;
if (!desc || !props->getGeneric(cx, id, &v) || !desc->initialize(cx, v, checkAccessors))
@ -2562,8 +2571,9 @@ JSObject::sealOrFreeze(JSContext *cx, ImmutabilityType it)
JS_ASSERT(self->lastProperty()->slotSpan() == last->slotSpan());
JS_ALWAYS_TRUE(self->setLastProperty(cx, last));
} else {
RootedVarId id(cx);
for (size_t i = 0; i < props.length(); i++) {
jsid id = props[i];
id = props[i];
unsigned attrs;
if (!self->getGenericAttributes(cx, id, &attrs))
@ -2596,8 +2606,9 @@ JSObject::isSealedOrFrozen(JSContext *cx, ImmutabilityType it, bool *resultp)
if (!GetPropertyNames(cx, this, JSITER_HIDDEN | JSITER_OWNONLY, &props))
return false;
RootedVarId id(cx);
for (size_t i = 0, len = props.length(); i < len; i++) {
jsid id = props[i];
id = props[i];
unsigned attrs;
if (!getGenericAttributes(cx, id, &attrs))
@ -2916,8 +2927,10 @@ js::NewReshapedObject(JSContext *cx, HandleTypeObject type, JSObject *parent,
}
/* Construct the new shape. */
RootedVarId id(cx);
for (unsigned i = 0; i < ids.length(); i++) {
if (!DefineNativeProperty(cx, res, ids[i], js::UndefinedValue(), NULL, NULL,
id = ids[i];
if (!DefineNativeProperty(cx, res, id, js::UndefinedValue(), NULL, NULL,
JSPROP_ENUMERATE, 0, 0, DNP_SKIP_TYPE)) {
return NULL;
}
@ -3093,15 +3106,12 @@ js_InferFlags(JSContext *cx, unsigned defaultFlags)
}
JSBool
JSObject::nonNativeSetProperty(JSContext *cx, jsid id, js::Value *vp, JSBool strict)
JSObject::nonNativeSetProperty(JSContext *cx, HandleId id, js::Value *vp, JSBool strict)
{
JSObject *self = this;
RootedVarObject self(cx, this);
if (JS_UNLIKELY(watched())) {
RootObject selfRoot(cx, &self);
RootId idRoot(cx, &id);
WatchpointMap *wpmap = cx->compartment->watchpointMap;
if (wpmap && !wpmap->triggerWatchpoint(cx, selfRoot, idRoot, vp))
if (wpmap && !wpmap->triggerWatchpoint(cx, self, id, vp))
return false;
}
return self->getOps()->setGeneric(cx, self, id, vp, strict);
@ -3110,18 +3120,14 @@ JSObject::nonNativeSetProperty(JSContext *cx, jsid id, js::Value *vp, JSBool str
JSBool
JSObject::nonNativeSetElement(JSContext *cx, uint32_t index, js::Value *vp, JSBool strict)
{
JSObject *self = this;
RootedVarObject self(cx, this);
if (JS_UNLIKELY(watched())) {
RootObject selfRoot(cx, &self);
jsid id;
if (!IndexToId(cx, index, &id))
RootedVarId id(cx);
if (!IndexToId(cx, index, id.address()))
return false;
RootId idRoot(cx, &id);
WatchpointMap *wpmap = cx->compartment->watchpointMap;
if (wpmap && !wpmap->triggerWatchpoint(cx, selfRoot, idRoot, vp))
if (wpmap && !wpmap->triggerWatchpoint(cx, self, id, vp))
return false;
}
return self->getOps()->setElement(cx, self, index, vp, strict);
@ -3137,7 +3143,7 @@ JSObject::deleteByValue(JSContext *cx, const Value &property, Value *rval, bool
Value propval = property;
SpecialId sid;
if (ValueIsSpecial(this, &propval, &sid, cx))
return deleteSpecial(cx, sid, rval, strict);
return deleteSpecial(cx, RootedVar<SpecialId>(cx, sid), rval, strict);
RootedVarObject self(cx, this);
@ -3148,7 +3154,7 @@ JSObject::deleteByValue(JSContext *cx, const Value &property, Value *rval, bool
if (name->isIndex(&index))
return self->deleteElement(cx, index, rval, false);
return self->deleteProperty(cx, name->asPropertyName(), rval, false);
return self->deleteProperty(cx, RootedVarPropertyName(cx, name->asPropertyName()), rval, false);
}
JS_FRIEND_API(bool)
@ -3170,15 +3176,16 @@ JS_CopyPropertiesFrom(JSContext *cx, JSObject *target, JSObject *obj)
const Shape *shape = shapes[--n];
unsigned attrs = shape->attributes();
PropertyOp getter = shape->getter();
StrictPropertyOp setter = shape->setter();
RootGetterSetter gsRoot(cx, attrs, &getter, &setter);
if ((attrs & JSPROP_GETTER) && !cx->compartment->wrap(cx, &getter))
return false;
StrictPropertyOp setter = shape->setter();
if ((attrs & JSPROP_SETTER) && !cx->compartment->wrap(cx, &setter))
return false;
Value v = shape->hasSlot() ? obj->getSlot(shape->slot()) : UndefinedValue();
if (!cx->compartment->wrap(cx, &v))
return false;
if (!target->defineGeneric(cx, shape->propid(), v, getter, setter, attrs))
if (!target->defineGeneric(cx, RootedVarId(cx, shape->propid()), v, getter, setter, attrs))
return false;
}
return true;
@ -3558,7 +3565,7 @@ static bool
DefineStandardSlot(JSContext *cx, JSObject *obj, JSProtoKey key, JSAtom *atom,
const Value &v, uint32_t attrs, bool &named)
{
jsid id = AtomToId(atom);
RootedVarId id(cx, AtomToId(atom));
if (key != JSProto_Null) {
/*
@ -4117,7 +4124,7 @@ js_InitNullClass(JSContext *cx, JSObject *obj)
#include "jsproto.tbl"
#undef JS_PROTO
static JSObjectOp lazy_prototype_init[JSProto_LIMIT] = {
static JSClassInitializerOp lazy_prototype_init[JSProto_LIMIT] = {
#define JS_PROTO(name,code,init) init,
#include "jsproto.tbl"
#undef JS_PROTO
@ -4242,7 +4249,7 @@ js_GetClassObject(JSContext *cx, JSObject *obj, JSProtoKey key,
}
JSObject *cobj = NULL;
if (JSObjectOp init = lazy_prototype_init[key]) {
if (JSClassInitializerOp init = lazy_prototype_init[key]) {
if (!init(cx, obj))
return false;
v = obj->getReservedSlot(key);
@ -4259,7 +4266,7 @@ js_FindClassObject(JSContext *cx, JSObject *start, JSProtoKey protoKey,
Value *vp, Class *clasp)
{
JSObject *cobj, *pobj;
jsid id;
RootedVarId id(cx);
JSProperty *prop;
const Shape *shape;
@ -4267,7 +4274,7 @@ js_FindClassObject(JSContext *cx, JSObject *start, JSProtoKey protoKey,
if (start) {
obj = &start->global();
OBJ_TO_INNER_OBJECT(cx, *obj.address());
obj = GetInnerObject(cx, obj);
} else {
obj = GetGlobalForScopeChain(cx);
}
@ -4445,31 +4452,28 @@ js_AddNativeProperty(JSContext *cx, HandleObject obj, jsid id_,
}
JSBool
js_DefineProperty(JSContext *cx, JSObject *obj_, jsid id, const Value *value,
PropertyOp getter, StrictPropertyOp setter, unsigned attrs)
baseops::DefineProperty(JSContext *cx, HandleObject obj, HandleId id, const Value *value,
PropertyOp getter, StrictPropertyOp setter, unsigned attrs)
{
RootObject obj(cx, &obj_);
return !!DefineNativeProperty(cx, obj, id, *value, getter, setter, attrs, 0, 0);
}
JSBool
js_DefineElement(JSContext *cx, JSObject *obj, uint32_t index, const Value *value,
PropertyOp getter, StrictPropertyOp setter, unsigned attrs)
baseops::DefineElement(JSContext *cx, HandleObject obj, uint32_t index, const Value *value,
PropertyOp getter, StrictPropertyOp setter, unsigned attrs)
{
if (index <= JSID_INT_MAX) {
return !!DefineNativeProperty(cx, RootedVarObject(cx, obj), INT_TO_JSID(index), *value,
return !!DefineNativeProperty(cx, obj, RootedVarId(cx, INT_TO_JSID(index)), *value,
getter, setter, attrs, 0, 0);
}
RootObject objRoot(cx, &obj);
RootGetterSetter gsRoot(cx, attrs, &getter, &setter);
RootValue valueRoot(cx, value);
jsid id;
if (!IndexToId(cx, index, &id))
RootedVarId id(cx);
if (!IndexToId(cx, index, id.address()))
return false;
return !!DefineNativeProperty(cx, objRoot, id, *value, getter, setter, attrs, 0, 0);
return !!DefineNativeProperty(cx, obj, id, *value, getter, setter, attrs, 0, 0);
}
/*
@ -4479,12 +4483,12 @@ js_DefineElement(JSContext *cx, JSObject *obj, uint32_t index, const Value *valu
* both while saving cycles for classes that stub their addProperty hook.
*/
static inline bool
CallAddPropertyHook(JSContext *cx, Class *clasp, JSObject *obj, const Shape *shape, Value *vp)
CallAddPropertyHook(JSContext *cx, Class *clasp, HandleObject obj, HandleShape shape, Value *vp)
{
if (clasp->addProperty != JS_PropertyStub) {
Value nominal = *vp;
if (!CallJSPropertyOp(cx, clasp->addProperty, obj, shape->propid(), vp))
if (!CallJSPropertyOp(cx, clasp->addProperty, obj, RootedVarId(cx, shape->propid()), vp))
return false;
if (*vp != nominal) {
if (shape->hasSlot())
@ -4497,7 +4501,7 @@ CallAddPropertyHook(JSContext *cx, Class *clasp, JSObject *obj, const Shape *sha
namespace js {
const Shape *
DefineNativeProperty(JSContext *cx, HandleObject obj, jsid id, const Value &value_,
DefineNativeProperty(JSContext *cx, HandleObject obj, HandleId id, const Value &value_,
PropertyOp getter, StrictPropertyOp setter, unsigned attrs,
unsigned flags, int shortid, unsigned defineHow /* = 0 */)
{
@ -4505,7 +4509,6 @@ DefineNativeProperty(JSContext *cx, HandleObject obj, jsid id, const Value &valu
DNP_SKIP_TYPE)) == 0);
JS_ASSERT(!(attrs & JSPROP_NATIVE_ACCESSORS));
RootId idRoot(cx, &id);
RootGetterSetter gsRoot(cx, attrs, &getter, &setter);
/* Make a local copy of value so addProperty can mutate its inout parameter. */
@ -4517,7 +4520,7 @@ DefineNativeProperty(JSContext *cx, HandleObject obj, jsid id, const Value &valu
* update the attributes and property ops. A getter or setter is really
* only half of a property.
*/
Shape *shape = NULL;
RootedVarShape shape(cx);
if (attrs & (JSPROP_GETTER | JSPROP_SETTER)) {
JSObject *pobj;
JSProperty *prop;
@ -4531,7 +4534,7 @@ DefineNativeProperty(JSContext *cx, HandleObject obj, jsid id, const Value &valu
* vice versa, finish the job via obj->changeProperty, and refresh the
* property cache line for (obj, id) to map shape.
*/
if (!js_LookupProperty(cx, obj, id, &pobj, &prop))
if (!baseops::LookupProperty(cx, obj, id, &pobj, &prop))
return NULL;
if (prop && pobj == obj) {
shape = (Shape *) prop;
@ -4686,26 +4689,23 @@ CallResolveOp(JSContext *cx, JSObject *start, HandleObject obj, HandleId id, uns
}
static JS_ALWAYS_INLINE bool
LookupPropertyWithFlagsInline(JSContext *cx, JSObject *obj_, jsid id_, unsigned flags,
LookupPropertyWithFlagsInline(JSContext *cx, HandleObject obj, HandleId id, unsigned flags,
JSObject **objp, JSProperty **propp)
{
RootedVarObject obj(cx, obj_);
RootedVarId id(cx, id_);
/* Search scopes starting with obj and following the prototype link. */
RootedVarObject start(cx, obj);
RootedVarObject current(cx, obj);
while (true) {
const Shape *shape = obj->nativeLookup(cx, id);
const Shape *shape = current->nativeLookup(cx, id);
if (shape) {
*objp = obj;
*objp = current;
*propp = (JSProperty *) shape;
return true;
}
/* Try obj's class resolve hook if id was not found in obj's scope. */
if (obj->getClass()->resolve != JS_ResolveStub) {
if (current->getClass()->resolve != JS_ResolveStub) {
bool recursed;
if (!CallResolveOp(cx, start, obj, id, flags, objp, propp, &recursed))
if (!CallResolveOp(cx, obj, current, id, flags, objp, propp, &recursed))
return false;
if (recursed)
break;
@ -4718,7 +4718,7 @@ LookupPropertyWithFlagsInline(JSContext *cx, JSObject *obj_, jsid id_, unsigned
}
}
JSObject *proto = obj->getProto();
JSObject *proto = current->getProto();
if (!proto)
break;
if (!proto->isNative()) {
@ -4742,7 +4742,7 @@ LookupPropertyWithFlagsInline(JSContext *cx, JSObject *obj_, jsid id_, unsigned
return true;
}
obj = proto;
current = proto;
}
*objp = NULL;
@ -4751,24 +4751,24 @@ LookupPropertyWithFlagsInline(JSContext *cx, JSObject *obj_, jsid id_, unsigned
}
JS_FRIEND_API(JSBool)
js_LookupProperty(JSContext *cx, JSObject *obj, jsid id, JSObject **objp,
JSProperty **propp)
baseops::LookupProperty(JSContext *cx, HandleObject obj, HandleId id, JSObject **objp,
JSProperty **propp)
{
return LookupPropertyWithFlagsInline(cx, obj, id, cx->resolveFlags, objp, propp);
}
JS_FRIEND_API(JSBool)
js_LookupElement(JSContext *cx, JSObject *obj, uint32_t index, JSObject **objp, JSProperty **propp)
baseops::LookupElement(JSContext *cx, HandleObject obj, uint32_t index, JSObject **objp, JSProperty **propp)
{
jsid id;
if (!IndexToId(cx, index, &id))
RootedVarId id(cx);
if (!IndexToId(cx, index, id.address()))
return false;
return LookupPropertyWithFlagsInline(cx, obj, id, cx->resolveFlags, objp, propp);
}
bool
js::LookupPropertyWithFlags(JSContext *cx, JSObject *obj, jsid id, unsigned flags,
js::LookupPropertyWithFlags(JSContext *cx, HandleObject obj, HandleId id, unsigned flags,
JSObject **objp, JSProperty **propp)
{
return LookupPropertyWithFlagsInline(cx, obj, id, flags, objp, propp);
@ -4900,7 +4900,7 @@ js::FindIdentifierBase(JSContext *cx, HandleObject scopeChain, HandlePropertyNam
scopeIndex++) {
JSObject *pobj;
JSProperty *prop;
if (!LookupPropertyWithFlags(cx, obj, name, cx->resolveFlags, &pobj, &prop))
if (!LookupPropertyWithFlags(cx, obj, name.value(), cx->resolveFlags, &pobj, &prop))
return NULL;
if (prop) {
if (!pobj->isNative()) {
@ -4968,7 +4968,7 @@ js_NativeGetInline(JSContext *cx, JSObject *receiver, JSObject *obj, JSObject *p
Root<const Shape*> rootShape(cx, &shape);
RootObject pobjRoot(cx, &pobj);
if (!shape->get(cx, receiver, obj, pobj, vp))
if (!shape->get(cx, RootedVarObject(cx, receiver), obj, pobj, vp))
return false;
/* Update slotful shapes according to the value produced by the getter. */
@ -5011,11 +5011,10 @@ js_NativeSet(JSContext *cx, JSObject *obj, const Shape *shape, bool added, bool
return js_ReportGetterOnlyAssignment(cx);
}
RootObject objRoot(cx, &obj);
Root<const Shape *> shapeRoot(cx, &shape);
int32_t sample = cx->runtime->propertyRemovals;
if (!shape->set(cx, obj, strict, vp))
if (!shape->set(cx, RootedVarObject(cx, obj), strict, vp))
return false;
/*
@ -5131,14 +5130,14 @@ js::GetPropertyHelper(JSContext *cx, HandleObject obj, jsid id, uint32_t getHow,
}
JSBool
js_GetProperty(JSContext *cx, HandleObject obj, HandleObject receiver, jsid id, Value *vp)
baseops::GetProperty(JSContext *cx, HandleObject obj, HandleObject receiver, HandleId id, Value *vp)
{
/* This call site is hot -- use the always-inlined variant of js_GetPropertyHelper(). */
return js_GetPropertyHelperInline(cx, obj, receiver, id, 0, vp);
}
JSBool
js_GetElement(JSContext *cx, HandleObject obj, HandleObject receiver, uint32_t index, Value *vp)
baseops::GetElement(JSContext *cx, HandleObject obj, HandleObject receiver, uint32_t index, Value *vp)
{
jsid id;
if (!IndexToId(cx, index, &id))
@ -5149,7 +5148,7 @@ js_GetElement(JSContext *cx, HandleObject obj, HandleObject receiver, uint32_t i
}
JSBool
js::GetPropertyDefault(JSContext *cx, HandleObject obj, HandleId id, const Value &def, Value *vp)
baseops::GetPropertyDefault(JSContext *cx, HandleObject obj, HandleId id, const Value &def, Value *vp)
{
JSProperty *prop;
RootedVarObject obj2(cx);
@ -5161,11 +5160,11 @@ js::GetPropertyDefault(JSContext *cx, HandleObject obj, HandleId id, const Value
return true;
}
return js_GetProperty(cx, obj2, id, vp);
return baseops::GetProperty(cx, obj2, id, vp);
}
JSBool
js_GetMethod(JSContext *cx, HandleObject obj, jsid id, unsigned getHow, Value *vp)
js::GetMethod(JSContext *cx, HandleObject obj, HandleId id, unsigned getHow, Value *vp)
{
JSAutoResolveFlags rf(cx, JSRESOLVE_QUALIFIED);
@ -5230,16 +5229,16 @@ JSObject::reportNotExtensible(JSContext *cx, unsigned report)
}
bool
JSObject::callMethod(JSContext *cx, jsid id, unsigned argc, Value *argv, Value *vp)
JSObject::callMethod(JSContext *cx, HandleId id, unsigned argc, Value *argv, Value *vp)
{
Value fval;
return js_GetMethod(cx, RootedVarObject(cx, this), id, 0, &fval) &&
return GetMethod(cx, RootedVarObject(cx, this), id, 0, &fval) &&
Invoke(cx, ObjectValue(*this), fval, argc, argv, vp);
}
JSBool
js_SetPropertyHelper(JSContext *cx, HandleObject obj, jsid id, unsigned defineHow,
Value *vp, JSBool strict)
baseops::SetPropertyHelper(JSContext *cx, HandleObject obj, HandleId id, unsigned defineHow,
Value *vp, JSBool strict)
{
JSObject *pobj;
JSProperty *prop;
@ -5251,12 +5250,11 @@ js_SetPropertyHelper(JSContext *cx, HandleObject obj, jsid id, unsigned defineHo
bool added;
JS_ASSERT((defineHow & ~(DNP_CACHE_RESULT | DNP_UNQUALIFIED)) == 0);
RootId idRoot(cx, &id);
if (JS_UNLIKELY(obj->watched())) {
/* Fire watchpoints, if any. */
WatchpointMap *wpmap = cx->compartment->watchpointMap;
if (wpmap && !wpmap->triggerWatchpoint(cx, obj, idRoot, vp))
if (wpmap && !wpmap->triggerWatchpoint(cx, obj, id, vp))
return false;
}
@ -5424,27 +5422,28 @@ js_SetPropertyHelper(JSContext *cx, HandleObject obj, jsid id, unsigned defineHo
}
JSBool
js_SetElementHelper(JSContext *cx, HandleObject obj, uint32_t index, unsigned defineHow,
Value *vp, JSBool strict)
baseops::SetElementHelper(JSContext *cx, HandleObject obj, uint32_t index, unsigned defineHow,
Value *vp, JSBool strict)
{
jsid id;
if (!IndexToId(cx, index, &id))
RootedVarId id(cx);
if (!IndexToId(cx, index, id.address()))
return false;
return js_SetPropertyHelper(cx, obj, id, defineHow, vp, strict);
return baseops::SetPropertyHelper(cx, obj, id, defineHow, vp, strict);
}
JSBool
js_GetAttributes(JSContext *cx, JSObject *obj, jsid id, unsigned *attrsp)
baseops::GetAttributes(JSContext *cx, HandleObject obj, HandleId id, unsigned *attrsp)
{
JSObject *nobj;
JSProperty *prop;
if (!js_LookupProperty(cx, obj, id, &obj, &prop))
if (!baseops::LookupProperty(cx, obj, id, &nobj, &prop))
return false;
if (!prop) {
*attrsp = 0;
return true;
}
if (!obj->isNative())
return obj->getGenericAttributes(cx, id, attrsp);
if (!nobj->isNative())
return nobj->getGenericAttributes(cx, id, attrsp);
const Shape *shape = (Shape *)prop;
*attrsp = shape->attributes();
@ -5452,17 +5451,18 @@ js_GetAttributes(JSContext *cx, JSObject *obj, jsid id, unsigned *attrsp)
}
JSBool
js_GetElementAttributes(JSContext *cx, JSObject *obj, uint32_t index, unsigned *attrsp)
baseops::GetElementAttributes(JSContext *cx, HandleObject obj, uint32_t index, unsigned *attrsp)
{
JSObject *nobj;
JSProperty *prop;
if (!js_LookupElement(cx, obj, index, &obj, &prop))
if (!baseops::LookupElement(cx, obj, index, &nobj, &prop))
return false;
if (!prop) {
*attrsp = 0;
return true;
}
if (!obj->isNative())
return obj->getElementAttributes(cx, index, attrsp);
if (!nobj->isNative())
return nobj->getElementAttributes(cx, index, attrsp);
const Shape *shape = (Shape *)prop;
*attrsp = shape->attributes();
@ -5470,33 +5470,35 @@ js_GetElementAttributes(JSContext *cx, JSObject *obj, uint32_t index, unsigned *
}
JSBool
js_SetAttributes(JSContext *cx, JSObject *obj, jsid id, unsigned *attrsp)
baseops::SetAttributes(JSContext *cx, HandleObject obj, HandleId id, unsigned *attrsp)
{
JSObject *nobj;
JSProperty *prop;
if (!js_LookupProperty(cx, obj, id, &obj, &prop))
if (!baseops::LookupProperty(cx, obj, id, &nobj, &prop))
return false;
if (!prop)
return true;
return obj->isNative()
? obj->changePropertyAttributes(cx, (Shape *) prop, *attrsp)
: obj->setGenericAttributes(cx, id, attrsp);
return nobj->isNative()
? nobj->changePropertyAttributes(cx, (Shape *) prop, *attrsp)
: nobj->setGenericAttributes(cx, id, attrsp);
}
JSBool
js_SetElementAttributes(JSContext *cx, JSObject *obj, uint32_t index, unsigned *attrsp)
baseops::SetElementAttributes(JSContext *cx, HandleObject obj, uint32_t index, unsigned *attrsp)
{
JSObject *nobj;
JSProperty *prop;
if (!js_LookupElement(cx, obj, index, &obj, &prop))
if (!baseops::LookupElement(cx, obj, index, &nobj, &prop))
return false;
if (!prop)
return true;
return obj->isNative()
? obj->changePropertyAttributes(cx, (Shape *) prop, *attrsp)
: obj->setElementAttributes(cx, index, attrsp);
return nobj->isNative()
? nobj->changePropertyAttributes(cx, (Shape *) prop, *attrsp)
: nobj->setElementAttributes(cx, index, attrsp);
}
JSBool
js_DeleteGeneric(JSContext *cx, JSObject *obj_, jsid id_, Value *rval, JSBool strict)
baseops::DeleteGeneric(JSContext *cx, HandleObject obj, HandleId id, Value *rval, JSBool strict)
{
JSObject *proto;
JSProperty *prop;
@ -5504,10 +5506,7 @@ js_DeleteGeneric(JSContext *cx, JSObject *obj_, jsid id_, Value *rval, JSBool st
rval->setBoolean(true);
RootedVarObject obj(cx, obj_);
RootedVarId id(cx, id_);
if (!js_LookupProperty(cx, obj, id, &proto, &prop))
if (!baseops::LookupProperty(cx, obj, id, &proto, &prop))
return false;
if (!prop || proto != obj) {
/*
@ -5530,8 +5529,8 @@ js_DeleteGeneric(JSContext *cx, JSObject *obj_, jsid id_, Value *rval, JSBool st
GCPoke(cx->runtime, v);
}
jsid userid;
if (!shape->getUserId(cx, &userid))
RootedVarId userid(cx);
if (!shape->getUserId(cx, userid.address()))
return false;
if (!CallJSPropertyOp(cx, obj->getClass()->delProperty, obj, userid, rval))
@ -5543,26 +5542,24 @@ js_DeleteGeneric(JSContext *cx, JSObject *obj_, jsid id_, Value *rval, JSBool st
}
JSBool
js_DeleteProperty(JSContext *cx, JSObject *obj, PropertyName *name, Value *rval, JSBool strict)
baseops::DeleteProperty(JSContext *cx, HandleObject obj, HandlePropertyName name, Value *rval, JSBool strict)
{
return js_DeleteGeneric(cx, obj, NameToId(name), rval, strict);
return baseops::DeleteGeneric(cx, obj, RootedVarId(cx, NameToId(name)), rval, strict);
}
JSBool
js_DeleteElement(JSContext *cx, JSObject *obj_, uint32_t index, Value *rval, JSBool strict)
baseops::DeleteElement(JSContext *cx, HandleObject obj, uint32_t index, Value *rval, JSBool strict)
{
RootedVarObject obj(cx, obj_);
jsid id;
if (!IndexToId(cx, index, &id))
RootedVarId id(cx);
if (!IndexToId(cx, index, id.address()))
return false;
return js_DeleteGeneric(cx, obj, id, rval, strict);
return baseops::DeleteGeneric(cx, obj, id, rval, strict);
}
JSBool
js_DeleteSpecial(JSContext *cx, JSObject *obj, SpecialId sid, Value *rval, JSBool strict)
baseops::DeleteSpecial(JSContext *cx, HandleObject obj, HandleSpecialId sid, Value *rval, JSBool strict)
{
return js_DeleteGeneric(cx, obj, SPECIALID_TO_JSID(sid), rval, strict);
return baseops::DeleteGeneric(cx, obj, RootedVarId(cx, SPECIALID_TO_JSID(sid)), rval, strict);
}
namespace js {
@ -5591,7 +5588,7 @@ HasDataProperty(JSContext *cx, HandleObject obj, jsid id, Value *vp)
static bool
MaybeCallMethod(JSContext *cx, HandleObject obj, jsid id, Value *vp)
{
if (!js_GetMethod(cx, obj, id, 0, vp))
if (!GetMethod(cx, obj, RootedVarId(cx, id), 0, vp))
return false;
if (!js_IsCallable(*vp)) {
*vp = ObjectValue(*obj);
@ -5674,7 +5671,7 @@ DefaultValue(JSContext *cx, HandleObject obj, JSType hint, Value *vp)
} /* namespace js */
JS_FRIEND_API(JSBool)
JS_EnumerateState(JSContext *cx, JSObject *obj, JSIterateOp enum_op, Value *statep, jsid *idp)
JS_EnumerateState(JSContext *cx, JSHandleObject obj, JSIterateOp enum_op, Value *statep, jsid *idp)
{
/* If the class has a custom JSCLASS_NEW_ENUMERATE hook, call it. */
Class *clasp = obj->getClass();
@ -5696,14 +5693,15 @@ JS_EnumerateState(JSContext *cx, JSObject *obj, JSIterateOp enum_op, Value *stat
namespace js {
JSBool
CheckAccess(JSContext *cx, JSObject *obj, jsid id, JSAccessMode mode,
CheckAccess(JSContext *cx, JSObject *obj_, HandleId id, JSAccessMode mode,
Value *vp, unsigned *attrsp)
{
JSBool writing;
JSObject *pobj;
JSProperty *prop;
const Shape *shape;
RootedVarObject obj(cx, obj_), pobj(cx);
while (JS_UNLIKELY(obj->isWith()))
obj = obj->getProto();
@ -5724,7 +5722,7 @@ CheckAccess(JSContext *cx, JSObject *obj, jsid id, JSAccessMode mode,
break;
default:
if (!obj->lookupGeneric(cx, id, &pobj, &prop))
if (!obj->lookupGeneric(cx, id, pobj.address(), &prop))
return JS_FALSE;
if (!prop) {
if (!writing)
@ -5775,7 +5773,7 @@ CheckAccess(JSContext *cx, JSObject *obj, jsid id, JSAccessMode mode,
}
JSType
js_TypeOf(JSContext *cx, JSObject *obj)
baseops::TypeOf(JSContext *cx, HandleObject obj)
{
return obj->isCallable() ? JSTYPE_FUNCTION : JSTYPE_OBJECT;
}
@ -6005,7 +6003,7 @@ js_ReportGetterOnlyAssignment(JSContext *cx)
}
JS_FRIEND_API(JSBool)
js_GetterOnlyPropertyStub(JSContext *cx, JSObject *obj, jsid id, JSBool strict, jsval *vp)
js_GetterOnlyPropertyStub(JSContext *cx, JSHandleObject obj, JSHandleId id, JSBool strict, jsval *vp)
{
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_GETTER_ONLY);
return JS_FALSE;

Просмотреть файл

@ -117,7 +117,13 @@ CastAsObjectJsval(StrictPropertyOp op)
typedef Vector<PropDesc, 1> PropDescArray;
} /* namespace js */
/*
* The baseops namespace encapsulates the default behavior when performing
* various operations on an object, irrespective of hooks installed in the
* object's class. In general, instance methods on the object itself should be
* called instead of calling these methods directly.
*/
namespace baseops {
/*
* On success, and if id was found, return true with *objp non-null and with a
@ -125,104 +131,92 @@ typedef Vector<PropDesc, 1> PropDescArray;
* return true with both *objp and *propp null.
*/
extern JS_FRIEND_API(JSBool)
js_LookupProperty(JSContext *cx, JSObject *obj, jsid id, JSObject **objp,
JSProperty **propp);
namespace js {
LookupProperty(JSContext *cx, HandleObject obj, HandleId id, JSObject **objp,
JSProperty **propp);
inline bool
LookupProperty(JSContext *cx, JSObject *obj, PropertyName *name,
LookupProperty(JSContext *cx, HandleObject obj, PropertyName *name,
JSObject **objp, JSProperty **propp)
{
return js_LookupProperty(cx, obj, NameToId(name), objp, propp);
}
return LookupProperty(cx, obj, RootedVarId(cx, NameToId(name)), objp, propp);
}
extern JS_FRIEND_API(JSBool)
js_LookupElement(JSContext *cx, JSObject *obj, uint32_t index,
JSObject **objp, JSProperty **propp);
LookupElement(JSContext *cx, HandleObject obj, uint32_t index,
JSObject **objp, JSProperty **propp);
extern JSBool
js_DefineProperty(JSContext *cx, JSObject *obj, jsid id, const js::Value *value,
JSPropertyOp getter, JSStrictPropertyOp setter, unsigned attrs);
DefineProperty(JSContext *cx, HandleObject obj, HandleId id, const js::Value *value,
JSPropertyOp getter, JSStrictPropertyOp setter, unsigned attrs);
extern JSBool
js_DefineElement(JSContext *cx, JSObject *obj, uint32_t index, const js::Value *value,
JSPropertyOp getter, JSStrictPropertyOp setter, unsigned attrs);
DefineElement(JSContext *cx, HandleObject obj, uint32_t index, const js::Value *value,
JSPropertyOp getter, JSStrictPropertyOp setter, unsigned attrs);
extern JSBool
js_GetProperty(JSContext *cx, js::HandleObject obj, js::HandleObject receiver, jsid id, js::Value *vp);
GetProperty(JSContext *cx, HandleObject obj, HandleObject receiver, HandleId id, js::Value *vp);
extern JSBool
js_GetElement(JSContext *cx, js::HandleObject obj, js::HandleObject receiver, uint32_t, js::Value *vp);
GetElement(JSContext *cx, HandleObject obj, HandleObject receiver, uint32_t index, js::Value *vp);
inline JSBool
js_GetProperty(JSContext *cx, js::HandleObject obj, jsid id, js::Value *vp)
GetProperty(JSContext *cx, HandleObject obj, HandleId id, js::Value *vp)
{
return js_GetProperty(cx, obj, obj, id, vp);
return GetProperty(cx, obj, obj, id, vp);
}
inline JSBool
js_GetElement(JSContext *cx, js::HandleObject obj, uint32_t index, js::Value *vp)
GetElement(JSContext *cx, HandleObject obj, uint32_t index, js::Value *vp)
{
return js_GetElement(cx, obj, obj, index, vp);
return GetElement(cx, obj, obj, index, vp);
}
namespace js {
extern JSBool
GetPropertyDefault(JSContext *cx, HandleObject obj, HandleId id, const Value &def, Value *vp);
extern JSBool
GetPropertyDefault(JSContext *cx, js::HandleObject obj, js::HandleId id, const Value &def, Value *vp);
} /* namespace js */
extern JSBool
js_SetPropertyHelper(JSContext *cx, js::HandleObject obj, jsid id, unsigned defineHow,
js::Value *vp, JSBool strict);
namespace js {
SetPropertyHelper(JSContext *cx, HandleObject obj, HandleId id, unsigned defineHow,
Value *vp, JSBool strict);
inline bool
SetPropertyHelper(JSContext *cx, HandleObject obj, PropertyName *name, unsigned defineHow,
Value *vp, JSBool strict)
{
return !!js_SetPropertyHelper(cx, obj, NameToId(name), defineHow, vp, strict);
return SetPropertyHelper(cx, obj, RootedVarId(cx, NameToId(name)), defineHow, vp, strict);
}
} /* namespace js */
extern JSBool
js_SetElementHelper(JSContext *cx, js::HandleObject obj, uint32_t index, unsigned defineHow,
js::Value *vp, JSBool strict);
extern JSBool
js_GetAttributes(JSContext *cx, JSObject *obj, jsid id, unsigned *attrsp);
extern JSBool
js_GetElementAttributes(JSContext *cx, JSObject *obj, uint32_t index, unsigned *attrsp);
extern JSBool
js_SetAttributes(JSContext *cx, JSObject *obj, jsid id, unsigned *attrsp);
extern JSBool
js_SetElementAttributes(JSContext *cx, JSObject *obj, uint32_t index, unsigned *attrsp);
extern JSBool
js_DeleteProperty(JSContext *cx, JSObject *obj, js::PropertyName *name, js::Value *rval, JSBool strict);
extern JSBool
js_DeleteElement(JSContext *cx, JSObject *obj, uint32_t index, js::Value *rval, JSBool strict);
extern JSBool
js_DeleteSpecial(JSContext *cx, JSObject *obj, js::SpecialId sid, js::Value *rval, JSBool strict);
extern JSBool
js_DeleteGeneric(JSContext *cx, JSObject *obj, jsid id, js::Value *rval, JSBool strict);
SetElementHelper(JSContext *cx, HandleObject obj, uint32_t index, unsigned defineHow,
Value *vp, JSBool strict);
extern JSType
js_TypeOf(JSContext *cx, JSObject *obj);
TypeOf(JSContext *cx, HandleObject obj);
namespace js {
extern JSBool
GetAttributes(JSContext *cx, HandleObject obj, HandleId id, unsigned *attrsp);
extern JSBool
SetAttributes(JSContext *cx, HandleObject obj, HandleId id, unsigned *attrsp);
extern JSBool
GetElementAttributes(JSContext *cx, HandleObject obj, uint32_t index, unsigned *attrsp);
extern JSBool
SetElementAttributes(JSContext *cx, HandleObject obj, uint32_t index, unsigned *attrsp);
extern JSBool
DeleteProperty(JSContext *cx, HandleObject obj, HandlePropertyName name, Value *rval, JSBool strict);
extern JSBool
DeleteElement(JSContext *cx, HandleObject obj, uint32_t index, Value *rval, JSBool strict);
extern JSBool
DeleteSpecial(JSContext *cx, HandleObject obj, HandleSpecialId sid, Value *rval, JSBool strict);
extern JSBool
DeleteGeneric(JSContext *cx, HandleObject obj, HandleId id, Value *rval, JSBool strict);
} /* namespace js::baseops */
/* ES5 8.12.8. */
extern JSBool
@ -725,7 +719,7 @@ struct JSObject : public js::ObjectImpl
inline void finish(js::FreeOp *fop);
JS_ALWAYS_INLINE void finalize(js::FreeOp *fop);
inline bool hasProperty(JSContext *cx, jsid id, bool *foundp, unsigned flags = 0);
inline bool hasProperty(JSContext *cx, js::HandleId id, bool *foundp, unsigned flags = 0);
/*
* Allocate and free an object slot.
@ -747,7 +741,7 @@ struct JSObject : public js::ObjectImpl
* callable a TypeError will be thrown. On success the value returned by
* the call is stored in *vp.
*/
bool callMethod(JSContext *cx, jsid id, unsigned argc, js::Value *argv, js::Value *vp);
bool callMethod(JSContext *cx, js::HandleId id, unsigned argc, js::Value *argv, js::Value *vp);
private:
js::Shape *getChildProperty(JSContext *cx, js::Shape *parent, js::StackShape &child);
@ -813,14 +807,14 @@ struct JSObject : public js::ObjectImpl
/* Clear the scope, making it empty. */
void clear(JSContext *cx);
inline JSBool lookupGeneric(JSContext *cx, jsid id, JSObject **objp, JSProperty **propp);
inline JSBool lookupGeneric(JSContext *cx, js::HandleId id, JSObject **objp, JSProperty **propp);
inline JSBool lookupProperty(JSContext *cx, js::PropertyName *name, JSObject **objp, JSProperty **propp);
inline JSBool lookupElement(JSContext *cx, uint32_t index,
JSObject **objp, JSProperty **propp);
inline JSBool lookupSpecial(JSContext *cx, js::SpecialId sid,
JSObject **objp, JSProperty **propp);
inline JSBool defineGeneric(JSContext *cx, jsid id, const js::Value &value,
inline JSBool defineGeneric(JSContext *cx, js::HandleId id, const js::Value &value,
JSPropertyOp getter = JS_PropertyStub,
JSStrictPropertyOp setter = JS_StrictPropertyStub,
unsigned attrs = JSPROP_ENUMERATE);
@ -838,42 +832,42 @@ struct JSObject : public js::ObjectImpl
JSStrictPropertyOp setter = JS_StrictPropertyStub,
unsigned attrs = JSPROP_ENUMERATE);
inline JSBool getGeneric(JSContext *cx, JSObject *receiver, jsid id, js::Value *vp);
inline JSBool getProperty(JSContext *cx, JSObject *receiver, js::PropertyName *name,
inline JSBool getGeneric(JSContext *cx, js::HandleObject receiver, js::HandleId id, js::Value *vp);
inline JSBool getProperty(JSContext *cx, js::HandleObject receiver, js::PropertyName *name,
js::Value *vp);
inline JSBool getElement(JSContext *cx, JSObject *receiver, uint32_t index, js::Value *vp);
inline JSBool getElement(JSContext *cx, js::HandleObject receiver, uint32_t index, js::Value *vp);
/* If element is not present (e.g. array hole) *present is set to
false and the contents of *vp are unusable garbage. */
inline JSBool getElementIfPresent(JSContext *cx, JSObject *receiver, uint32_t index,
inline JSBool getElementIfPresent(JSContext *cx, js::HandleObject receiver, uint32_t index,
js::Value *vp, bool *present);
inline JSBool getSpecial(JSContext *cx, JSObject *receiver, js::SpecialId sid, js::Value *vp);
inline JSBool getSpecial(JSContext *cx, js::HandleObject receiver, js::SpecialId sid, js::Value *vp);
inline JSBool getGeneric(JSContext *cx, jsid id, js::Value *vp);
inline JSBool getGeneric(JSContext *cx, js::HandleId id, js::Value *vp);
inline JSBool getProperty(JSContext *cx, js::PropertyName *name, js::Value *vp);
inline JSBool getElement(JSContext *cx, uint32_t index, js::Value *vp);
inline JSBool getSpecial(JSContext *cx, js::SpecialId sid, js::Value *vp);
inline JSBool setGeneric(JSContext *cx, jsid id, js::Value *vp, JSBool strict);
inline JSBool setGeneric(JSContext *cx, js::HandleId id, js::Value *vp, JSBool strict);
inline JSBool setProperty(JSContext *cx, js::PropertyName *name, js::Value *vp, JSBool strict);
inline JSBool setElement(JSContext *cx, uint32_t index, js::Value *vp, JSBool strict);
inline JSBool setSpecial(JSContext *cx, js::SpecialId sid, js::Value *vp, JSBool strict);
JSBool nonNativeSetProperty(JSContext *cx, jsid id, js::Value *vp, JSBool strict);
JSBool nonNativeSetProperty(JSContext *cx, js::HandleId id, js::Value *vp, JSBool strict);
JSBool nonNativeSetElement(JSContext *cx, uint32_t index, js::Value *vp, JSBool strict);
inline JSBool getGenericAttributes(JSContext *cx, jsid id, unsigned *attrsp);
inline JSBool getGenericAttributes(JSContext *cx, js::HandleId id, unsigned *attrsp);
inline JSBool getPropertyAttributes(JSContext *cx, js::PropertyName *name, unsigned *attrsp);
inline JSBool getElementAttributes(JSContext *cx, uint32_t index, unsigned *attrsp);
inline JSBool getSpecialAttributes(JSContext *cx, js::SpecialId sid, unsigned *attrsp);
inline JSBool setGenericAttributes(JSContext *cx, jsid id, unsigned *attrsp);
inline JSBool setGenericAttributes(JSContext *cx, js::HandleId id, unsigned *attrsp);
inline JSBool setPropertyAttributes(JSContext *cx, js::PropertyName *name, unsigned *attrsp);
inline JSBool setElementAttributes(JSContext *cx, uint32_t index, unsigned *attrsp);
inline JSBool setSpecialAttributes(JSContext *cx, js::SpecialId sid, unsigned *attrsp);
inline bool deleteProperty(JSContext *cx, js::PropertyName *name, js::Value *rval, bool strict);
inline bool deleteProperty(JSContext *cx, js::HandlePropertyName name, js::Value *rval, bool strict);
inline bool deleteElement(JSContext *cx, uint32_t index, js::Value *rval, bool strict);
inline bool deleteSpecial(JSContext *cx, js::SpecialId sid, js::Value *rval, bool strict);
inline bool deleteSpecial(JSContext *cx, js::HandleSpecialId sid, js::Value *rval, bool strict);
bool deleteByValue(JSContext *cx, const js::Value &property, js::Value *rval, bool strict);
inline bool enumerate(JSContext *cx, JSIterateOp iterop, js::Value *statep, jsid *idp);
@ -1069,11 +1063,11 @@ js_HasOwnPropertyHelper(JSContext *cx, js::LookupGenericOp lookup, unsigned argc
js::Value *vp);
extern JSBool
js_HasOwnProperty(JSContext *cx, js::LookupGenericOp lookup, js::HandleObject obj, jsid id,
js_HasOwnProperty(JSContext *cx, js::LookupGenericOp lookup, js::HandleObject obj, js::HandleId id,
JSObject **objp, JSProperty **propp);
extern JSBool
js_PropertyIsEnumerable(JSContext *cx, JSObject *obj, jsid id, js::Value *vp);
js_PropertyIsEnumerable(JSContext *cx, js::HandleObject obj, js::HandleId id, js::Value *vp);
#if JS_HAS_OBJ_PROTO_PROP
extern JSPropertySpec object_props[];
@ -1170,7 +1164,7 @@ const unsigned DNP_SKIP_TYPE = 8; /* Don't update type information */
* Return successfully added or changed shape or NULL on error.
*/
extern const Shape *
DefineNativeProperty(JSContext *cx, HandleObject obj, jsid id, const Value &value,
DefineNativeProperty(JSContext *cx, HandleObject obj, HandleId id, const Value &value,
PropertyOp getter, StrictPropertyOp setter, unsigned attrs,
unsigned flags, int shortid, unsigned defineHow = 0);
@ -1179,7 +1173,8 @@ DefineNativeProperty(JSContext *cx, HandleObject obj, PropertyName *name, const
PropertyOp getter, StrictPropertyOp setter, unsigned attrs,
unsigned flags, int shortid, unsigned defineHow = 0)
{
return DefineNativeProperty(cx, obj, NameToId(name), value, getter, setter, attrs, flags,
return DefineNativeProperty(cx, obj, RootedVarId(cx, NameToId(name)),
value, getter, setter, attrs, flags,
shortid, defineHow);
}
@ -1187,14 +1182,14 @@ DefineNativeProperty(JSContext *cx, HandleObject obj, PropertyName *name, const
* Specialized subroutine that allows caller to preset JSRESOLVE_* flags.
*/
extern bool
LookupPropertyWithFlags(JSContext *cx, JSObject *obj, jsid id, unsigned flags,
LookupPropertyWithFlags(JSContext *cx, HandleObject obj, HandleId id, unsigned flags,
JSObject **objp, JSProperty **propp);
inline bool
LookupPropertyWithFlags(JSContext *cx, JSObject *obj, PropertyName *name, unsigned flags,
LookupPropertyWithFlags(JSContext *cx, HandleObject obj, PropertyName *name, unsigned flags,
JSObject **objp, JSProperty **propp)
{
return LookupPropertyWithFlags(cx, obj, NameToId(name), flags, objp, propp);
return LookupPropertyWithFlags(cx, obj, RootedVarId(cx, NameToId(name)), flags, objp, propp);
}
/*
@ -1248,7 +1243,7 @@ FindIdentifierBase(JSContext *cx, HandleObject scopeChain, HandlePropertyName na
extern JSObject *
js_FindVariableScope(JSContext *cx, JSFunction **funp);
/* JSGET_CACHE_RESULT is the analogue of DNP_CACHE_RESULT for js_GetMethod. */
/* JSGET_CACHE_RESULT is the analogue of DNP_CACHE_RESULT for GetMethod. */
const unsigned JSGET_CACHE_RESULT = 1; // from a caching interpreter opcode
/*
@ -1285,23 +1280,15 @@ GetOwnPropertyDescriptor(JSContext *cx, HandleObject obj, HandleId id, Value *vp
bool
NewPropertyDescriptorObject(JSContext *cx, const PropertyDescriptor *desc, Value *vp);
} /* namespace js */
extern JSBool
js_GetMethod(JSContext *cx, js::HandleObject obj, jsid id, unsigned getHow, js::Value *vp);
namespace js {
GetMethod(JSContext *cx, HandleObject obj, HandleId id, unsigned getHow, Value *vp);
inline bool
GetMethod(JSContext *cx, HandleObject obj, PropertyName *name, unsigned getHow, Value *vp)
{
return js_GetMethod(cx, obj, NameToId(name), getHow, vp);
return GetMethod(cx, obj, RootedVarId(cx, NameToId(name)), getHow, vp);
}
} /* namespace js */
namespace js {
/*
* If obj has an already-resolved data property for id, return true and
* store the property value in *vp.
@ -1316,7 +1303,7 @@ HasDataProperty(JSContext *cx, HandleObject obj, PropertyName *name, Value *vp)
}
extern JSBool
CheckAccess(JSContext *cx, JSObject *obj, jsid id, JSAccessMode mode,
CheckAccess(JSContext *cx, JSObject *obj, HandleId id, JSAccessMode mode,
js::Value *vp, unsigned *attrsp);
} /* namespace js */

Просмотреть файл

@ -87,18 +87,20 @@ inline bool
JSObject::enumerate(JSContext *cx, JSIterateOp iterop, js::Value *statep, jsid *idp)
{
JSNewEnumerateOp op = getOps()->enumerate;
return (op ? op : JS_EnumerateState)(cx, this, iterop, statep, idp);
return (op ? op : JS_EnumerateState)(cx, js::RootedVarObject(cx, this), iterop, statep, idp);
}
inline bool
JSObject::defaultValue(JSContext *cx, JSType hint, js::Value *vp)
{
js::RootedVarObject self(cx, this);
JSConvertOp op = getClass()->convert;
bool ok;
if (op == JS_ConvertStub)
ok = js::DefaultValue(cx, js::RootedVarObject(cx, this), hint, vp);
ok = js::DefaultValue(cx, self, hint, vp);
else
ok = op(cx, this, hint, vp);
ok = op(cx, self, hint, vp);
JS_ASSERT_IF(ok, vp->isPrimitive());
return ok;
}
@ -107,31 +109,30 @@ inline JSType
JSObject::typeOf(JSContext *cx)
{
js::TypeOfOp op = getOps()->typeOf;
return (op ? op : js_TypeOf)(cx, this);
return (op ? op : js::baseops::TypeOf)(cx, js::RootedVarObject(cx, this));
}
inline JSObject *
JSObject::thisObject(JSContext *cx)
{
JSObjectOp op = getOps()->thisObject;
return op ? op(cx, this) : this;
return op ? op(cx, js::RootedVarObject(cx, this)) : this;
}
inline JSBool
JSObject::setGeneric(JSContext *cx, jsid id, js::Value *vp, JSBool strict)
JSObject::setGeneric(JSContext *cx, js::HandleId id, js::Value *vp, JSBool strict)
{
if (getOps()->setGeneric)
return nonNativeSetProperty(cx, id, vp, strict);
return js_SetPropertyHelper(cx,
js::RootedVarObject(cx, this),
js::RootedVarId(cx, id),
0, vp, strict);
return js::baseops::SetPropertyHelper(cx,
js::RootedVarObject(cx, this),
id, 0, vp, strict);
}
inline JSBool
JSObject::setProperty(JSContext *cx, js::PropertyName *name, js::Value *vp, JSBool strict)
{
return setGeneric(cx, js::NameToId(name), vp, strict);
return setGeneric(cx, js::RootedVarId(cx, js::NameToId(name)), vp, strict);
}
inline JSBool
@ -139,40 +140,40 @@ JSObject::setElement(JSContext *cx, uint32_t index, js::Value *vp, JSBool strict
{
if (getOps()->setElement)
return nonNativeSetElement(cx, index, vp, strict);
return js_SetElementHelper(cx, js::RootedVarObject(cx, this), index, 0, vp, strict);
return js::baseops::SetElementHelper(cx, js::RootedVarObject(cx, this), index, 0, vp, strict);
}
inline JSBool
JSObject::setSpecial(JSContext *cx, js::SpecialId sid, js::Value *vp, JSBool strict)
{
return setGeneric(cx, SPECIALID_TO_JSID(sid), vp, strict);
return setGeneric(cx, js::RootedVarId(cx, SPECIALID_TO_JSID(sid)), vp, strict);
}
inline JSBool
JSObject::setGenericAttributes(JSContext *cx, jsid id, unsigned *attrsp)
JSObject::setGenericAttributes(JSContext *cx, js::HandleId id, unsigned *attrsp)
{
js::types::MarkTypePropertyConfigured(cx, this, id);
js::GenericAttributesOp op = getOps()->setGenericAttributes;
return (op ? op : js_SetAttributes)(cx, this, id, attrsp);
return (op ? op : js::baseops::SetAttributes)(cx, js::RootedVarObject(cx, this), id, attrsp);
}
inline JSBool
JSObject::setPropertyAttributes(JSContext *cx, js::PropertyName *name, unsigned *attrsp)
{
return setGenericAttributes(cx, js::NameToId(name), attrsp);
return setGenericAttributes(cx, js::RootedVarId(cx, js::NameToId(name)), attrsp);
}
inline JSBool
JSObject::setElementAttributes(JSContext *cx, uint32_t index, unsigned *attrsp)
{
js::ElementAttributesOp op = getOps()->setElementAttributes;
return (op ? op : js_SetElementAttributes)(cx, this, index, attrsp);
return (op ? op : js::baseops::SetElementAttributes)(cx, js::RootedVarObject(cx, this), index, attrsp);
}
inline JSBool
JSObject::setSpecialAttributes(JSContext *cx, js::SpecialId sid, unsigned *attrsp)
{
return setGenericAttributes(cx, SPECIALID_TO_JSID(sid), attrsp);
return setGenericAttributes(cx, js::RootedVarId(cx, SPECIALID_TO_JSID(sid)), attrsp);
}
inline bool
@ -182,45 +183,47 @@ JSObject::changePropertyAttributes(JSContext *cx, js::Shape *shape, unsigned att
}
inline JSBool
JSObject::getGeneric(JSContext *cx, JSObject *receiver, jsid id, js::Value *vp)
JSObject::getGeneric(JSContext *cx, js::HandleObject receiver, js::HandleId id, js::Value *vp)
{
js::RootedVarObject self(cx, this);
js::GenericIdOp op = getOps()->getGeneric;
if (op) {
if (!op(cx, this, receiver, id, vp))
if (!op(cx, self, receiver, id, vp))
return false;
} else {
if (!js_GetProperty(cx, js::RootedVarObject(cx, this), js::RootedVarObject(cx, receiver), id, vp))
if (!js::baseops::GetProperty(cx, self, receiver, id, vp))
return false;
}
return true;
}
inline JSBool
JSObject::getProperty(JSContext *cx, JSObject *receiver, js::PropertyName *name, js::Value *vp)
JSObject::getProperty(JSContext *cx, js::HandleObject receiver, js::PropertyName *name, js::Value *vp)
{
return getGeneric(cx, receiver, js::NameToId(name), vp);
return getGeneric(cx, receiver, js::RootedVarId(cx, js::NameToId(name)), vp);
}
inline JSBool
JSObject::getGeneric(JSContext *cx, jsid id, js::Value *vp)
JSObject::getGeneric(JSContext *cx, js::HandleId id, js::Value *vp)
{
return getGeneric(cx, this, id, vp);
return getGeneric(cx, js::RootedVarObject(cx, this), id, vp);
}
inline JSBool
JSObject::getProperty(JSContext *cx, js::PropertyName *name, js::Value *vp)
{
return getGeneric(cx, js::NameToId(name), vp);
return getGeneric(cx, js::RootedVarId(cx, js::NameToId(name)), vp);
}
inline bool
JSObject::deleteProperty(JSContext *cx, js::PropertyName *name, js::Value *rval, bool strict)
JSObject::deleteProperty(JSContext *cx, js::HandlePropertyName name, js::Value *rval, bool strict)
{
jsid id = js::NameToId(name);
js::types::AddTypePropertyId(cx, this, id, js::types::Type::UndefinedType());
js::types::MarkTypePropertyConfigured(cx, this, id);
js::DeletePropertyOp op = getOps()->deleteProperty;
return (op ? op : js_DeleteProperty)(cx, this, name, rval, strict);
return (op ? op : js::baseops::DeleteProperty)(cx, js::RootedVarObject(cx, this), name, rval, strict);
}
inline bool
@ -234,17 +237,17 @@ JSObject::deleteElement(JSContext *cx, uint32_t index, js::Value *rval, bool str
js::types::AddTypePropertyId(cx, self, id, js::types::Type::UndefinedType());
js::types::MarkTypePropertyConfigured(cx, self, id);
js::DeleteElementOp op = self->getOps()->deleteElement;
return (op ? op : js_DeleteElement)(cx, self, index, rval, strict);
return (op ? op : js::baseops::DeleteElement)(cx, self, index, rval, strict);
}
inline bool
JSObject::deleteSpecial(JSContext *cx, js::SpecialId sid, js::Value *rval, bool strict)
JSObject::deleteSpecial(JSContext *cx, js::HandleSpecialId sid, js::Value *rval, bool strict)
{
jsid id = SPECIALID_TO_JSID(sid);
js::types::AddTypePropertyId(cx, this, id, js::types::Type::UndefinedType());
js::types::MarkTypePropertyConfigured(cx, this, id);
js::DeleteSpecialOp op = getOps()->deleteSpecial;
return (op ? op : js_DeleteSpecial)(cx, this, sid, rval, strict);
return (op ? op : js::baseops::DeleteSpecial)(cx, js::RootedVarObject(cx, this), sid, rval, strict);
}
inline void
@ -933,7 +936,7 @@ JSObject::finish(js::FreeOp *fop)
}
inline bool
JSObject::hasProperty(JSContext *cx, jsid id, bool *foundp, unsigned flags)
JSObject::hasProperty(JSContext *cx, js::HandleId id, bool *foundp, unsigned flags)
{
JSObject *pobj;
JSProperty *prop;
@ -1043,27 +1046,33 @@ JSObject::sizeOfExcludingThis(JSMallocSizeOfFun mallocSizeOf,
}
inline JSBool
JSObject::lookupGeneric(JSContext *cx, jsid id, JSObject **objp, JSProperty **propp)
JSObject::lookupGeneric(JSContext *cx, js::HandleId id, JSObject **objp, JSProperty **propp)
{
js::RootedVarObject self(cx, this);
js::LookupGenericOp op = getOps()->lookupGeneric;
return (op ? op : js_LookupProperty)(cx, this, id, objp, propp);
if (op)
return op(cx, self, id, objp, propp);
return js::baseops::LookupProperty(cx, self, id, objp, propp);
}
inline JSBool
JSObject::lookupProperty(JSContext *cx, js::PropertyName *name, JSObject **objp, JSProperty **propp)
{
return lookupGeneric(cx, js::NameToId(name), objp, propp);
return lookupGeneric(cx, js::RootedVarId(cx, js::NameToId(name)), objp, propp);
}
inline JSBool
JSObject::defineGeneric(JSContext *cx, jsid id, const js::Value &value,
JSObject::defineGeneric(JSContext *cx, js::HandleId id, const js::Value &value,
JSPropertyOp getter /* = JS_PropertyStub */,
JSStrictPropertyOp setter /* = JS_StrictPropertyStub */,
unsigned attrs /* = JSPROP_ENUMERATE */)
{
js::RootedVarObject self(cx, this);
JS_ASSERT(!(attrs & JSPROP_NATIVE_ACCESSORS));
js::DefineGenericOp op = getOps()->defineGeneric;
return (op ? op : js_DefineProperty)(cx, this, id, &value, getter, setter, attrs);
return (op ? op : js::baseops::DefineProperty)(cx, self, id, &value, getter, setter, attrs);
}
inline JSBool
@ -1072,7 +1081,7 @@ JSObject::defineProperty(JSContext *cx, js::PropertyName *name, const js::Value
JSStrictPropertyOp setter /* = JS_StrictPropertyStub */,
unsigned attrs /* = JSPROP_ENUMERATE */)
{
return defineGeneric(cx, js::NameToId(name), value, getter, setter, attrs);
return defineGeneric(cx, js::RootedVarId(cx, js::NameToId(name)), value, getter, setter, attrs);
}
inline JSBool
@ -1081,8 +1090,10 @@ JSObject::defineElement(JSContext *cx, uint32_t index, const js::Value &value,
JSStrictPropertyOp setter /* = JS_StrictPropertyStub */,
unsigned attrs /* = JSPROP_ENUMERATE */)
{
js::RootedVarObject self(cx, this);
js::DefineElementOp op = getOps()->defineElement;
return (op ? op : js_DefineElement)(cx, this, index, &value, getter, setter, attrs);
return (op ? op : js::baseops::DefineElement)(cx, self, index, &value, getter, setter, attrs);
}
inline JSBool
@ -1091,34 +1102,35 @@ JSObject::defineSpecial(JSContext *cx, js::SpecialId sid, const js::Value &value
JSStrictPropertyOp setter /* = JS_StrictPropertyStub */,
unsigned attrs /* = JSPROP_ENUMERATE */)
{
return defineGeneric(cx, SPECIALID_TO_JSID(sid), value, getter, setter, attrs);
return defineGeneric(cx, js::RootedVarId(cx, SPECIALID_TO_JSID(sid)), value, getter, setter, attrs);
}
inline JSBool
JSObject::lookupElement(JSContext *cx, uint32_t index, JSObject **objp, JSProperty **propp)
{
js::RootedVarObject self(cx, this);
js::LookupElementOp op = getOps()->lookupElement;
return (op ? op : js_LookupElement)(cx, this, index, objp, propp);
return (op ? op : js::baseops::LookupElement)(cx, self, index, objp, propp);
}
inline JSBool
JSObject::lookupSpecial(JSContext *cx, js::SpecialId sid, JSObject **objp, JSProperty **propp)
{
return lookupGeneric(cx, SPECIALID_TO_JSID(sid), objp, propp);
return lookupGeneric(cx, js::RootedVarId(cx, SPECIALID_TO_JSID(sid)), objp, propp);
}
inline JSBool
JSObject::getElement(JSContext *cx, JSObject *receiver_, uint32_t index, js::Value *vp)
JSObject::getElement(JSContext *cx, js::HandleObject receiver, uint32_t index, js::Value *vp)
{
js::RootedVarObject self(cx, this);
js::ElementIdOp op = getOps()->getElement;
if (op)
return op(cx, this, receiver_, index, vp);
return op(cx, self, receiver, index, vp);
js::RootedVarObject self(cx, this);
js::RootedVarObject receiver(cx, receiver_);
jsid id;
if (!js::IndexToId(cx, index, &id))
js::RootedVarId id(cx);
if (!js::IndexToId(cx, index, id.address()))
return false;
return self->getGeneric(cx, receiver, id, vp);
}
@ -1126,26 +1138,26 @@ JSObject::getElement(JSContext *cx, JSObject *receiver_, uint32_t index, js::Val
inline JSBool
JSObject::getElement(JSContext *cx, uint32_t index, js::Value *vp)
{
return getElement(cx, this, index, vp);
return getElement(cx, js::RootedVarObject(cx, this), index, vp);
}
inline JSBool
JSObject::getElementIfPresent(JSContext *cx, JSObject *receiver_, uint32_t index, js::Value *vp,
JSObject::getElementIfPresent(JSContext *cx, js::HandleObject receiver, uint32_t index, js::Value *vp,
bool *present)
{
js::RootedVarObject self(cx, this), receiver(cx, receiver_);
js::RootedVarObject self(cx, this);
js::ElementIfPresentOp op = getOps()->getElementIfPresent;
if (op)
return op(cx, this, receiver, index, vp, present);
return op(cx, self, receiver, index, vp, present);
/*
* For now, do the index-to-id conversion just once, then use
* lookupGeneric/getGeneric. Once lookupElement and getElement stop both
* doing index-to-id conversions, we can use those here.
*/
jsid id;
if (!js::IndexToId(cx, index, &id))
js::RootedVarId id(cx);
if (!js::IndexToId(cx, index, id.address()))
return false;
JSObject *obj2;
@ -1164,29 +1176,29 @@ JSObject::getElementIfPresent(JSContext *cx, JSObject *receiver_, uint32_t index
}
inline JSBool
JSObject::getSpecial(JSContext *cx, JSObject *receiver, js::SpecialId sid, js::Value *vp)
JSObject::getSpecial(JSContext *cx, js::HandleObject receiver, js::SpecialId sid, js::Value *vp)
{
return getGeneric(cx, receiver, SPECIALID_TO_JSID(sid), vp);
return getGeneric(cx, receiver, js::RootedVarId(cx, SPECIALID_TO_JSID(sid)), vp);
}
inline JSBool
JSObject::getGenericAttributes(JSContext *cx, jsid id, unsigned *attrsp)
JSObject::getGenericAttributes(JSContext *cx, js::HandleId id, unsigned *attrsp)
{
js::GenericAttributesOp op = getOps()->getGenericAttributes;
return (op ? op : js_GetAttributes)(cx, this, id, attrsp);
return (op ? op : js::baseops::GetAttributes)(cx, js::RootedVarObject(cx, this), id, attrsp);
}
inline JSBool
JSObject::getPropertyAttributes(JSContext *cx, js::PropertyName *name, unsigned *attrsp)
{
return getGenericAttributes(cx, js::NameToId(name), attrsp);
return getGenericAttributes(cx, js::RootedVarId(cx, js::NameToId(name)), attrsp);
}
inline JSBool
JSObject::getElementAttributes(JSContext *cx, uint32_t index, unsigned *attrsp)
{
jsid id;
if (!js::IndexToId(cx, index, &id))
js::RootedVarId id(cx);
if (!js::IndexToId(cx, index, id.address()))
return false;
return getGenericAttributes(cx, id, attrsp);
}
@ -1194,7 +1206,7 @@ JSObject::getElementAttributes(JSContext *cx, uint32_t index, unsigned *attrsp)
inline JSBool
JSObject::getSpecialAttributes(JSContext *cx, js::SpecialId sid, unsigned *attrsp)
{
return getGenericAttributes(cx, SPECIALID_TO_JSID(sid), attrsp);
return getGenericAttributes(cx, js::RootedVarId(cx, SPECIALID_TO_JSID(sid)), attrsp);
}
inline bool
@ -1232,18 +1244,20 @@ js_IsCallable(const js::Value &v)
namespace js {
inline void
OBJ_TO_INNER_OBJECT(JSContext *cx, JSObject *&obj)
inline JSObject *
GetInnerObject(JSContext *cx, HandleObject obj)
{
if (JSObjectOp op = obj->getClass()->ext.innerObject)
obj = op(cx, obj);
return op(cx, obj);
return obj;
}
inline void
OBJ_TO_OUTER_OBJECT(JSContext *cx, JSObject *&obj)
inline JSObject *
GetOuterObject(JSContext *cx, HandleObject obj)
{
if (JSObjectOp op = obj->getClass()->ext.outerObject)
obj = op(cx, obj);
return op(cx, obj);
return obj;
}
#if JS_HAS_XML_SUPPORT

Просмотреть файл

@ -313,8 +313,8 @@ PreprocessValue(JSContext *cx, JSObject *holder, KeyType key, Value *vp, Stringi
/* Step 2. */
if (vp->isObject()) {
Value toJSON;
jsid id = NameToId(cx->runtime->atomState.toJSONAtom);
if (!js_GetMethod(cx, RootedVarObject(cx, &vp->toObject()), id, 0, &toJSON))
RootedVarId id(cx, NameToId(cx->runtime->atomState.toJSONAtom));
if (!GetMethod(cx, RootedVarObject(cx, &vp->toObject()), id, 0, &toJSON))
return false;
if (js_IsCallable(toJSON)) {
@ -435,6 +435,7 @@ JO(JSContext *cx, HandleObject obj, StringifyContext *scx)
/* Steps 8-10, 13. */
bool wroteMember = false;
RootedVarId id(cx);
for (size_t i = 0, len = propertyList.length(); i < len; i++) {
/*
* Steps 8a-8b. Note that the call to Str is broken up into 1) getting
@ -443,11 +444,11 @@ JO(JSContext *cx, HandleObject obj, StringifyContext *scx)
* values which process to |undefined|, and 4) stringifying all values
* which pass the filter.
*/
const jsid &id = propertyList[i];
id = propertyList[i];
Value outputValue;
if (!obj->getGeneric(cx, id, &outputValue))
return false;
if (!PreprocessValue(cx, obj, id, &outputValue, scx))
if (!PreprocessValue(cx, obj, id.reference(), &outputValue, scx))
return false;
if (IsFilteredValue(outputValue))
continue;
@ -753,7 +754,7 @@ js_Stringify(JSContext *cx, Value *vp, JSObject *replacer_, Value space, StringB
return false;
/* Step 10. */
jsid emptyId = NameToId(cx->runtime->atomState.emptyAtom);
RootedVarId emptyId(cx, NameToId(cx->runtime->atomState.emptyAtom));
if (!DefineNativeProperty(cx, wrapper, emptyId, *vp, JS_PropertyStub, JS_StrictPropertyStub,
JSPROP_ENUMERATE, 0, 0))
{
@ -765,7 +766,7 @@ js_Stringify(JSContext *cx, Value *vp, JSObject *replacer_, Value space, StringB
if (!scx.init())
return false;
if (!PreprocessValue(cx, wrapper, emptyId, vp, &scx))
if (!PreprocessValue(cx, wrapper, emptyId.reference(), vp, &scx))
return false;
if (IsFilteredValue(*vp))
return true;
@ -775,7 +776,7 @@ js_Stringify(JSContext *cx, Value *vp, JSObject *replacer_, Value space, StringB
/* ES5 15.12.2 Walk. */
static bool
Walk(JSContext *cx, JSObject *holder, jsid name, const Value &reviver, Value *vp)
Walk(JSContext *cx, HandleObject holder, HandleId name, const Value &reviver, Value *vp)
{
JS_CHECK_RECURSION(cx, return false);
@ -795,9 +796,9 @@ Walk(JSContext *cx, JSObject *holder, jsid name, const Value &reviver, Value *vp
uint32_t length = obj->getArrayLength();
/* Step 2a(i), 2a(iii-iv). */
RootedVarId id(cx);
for (uint32_t i = 0; i < length; i++) {
jsid id;
if (!IndexToId(cx, i, &id))
if (!IndexToId(cx, i, id.address()))
return false;
/* Step 2a(iii)(1). */
@ -832,10 +833,11 @@ Walk(JSContext *cx, JSObject *holder, jsid name, const Value &reviver, Value *vp
return false;
/* Step 2b(ii). */
RootedVarId id(cx);
for (size_t i = 0, len = keys.length(); i < len; i++) {
/* Step 2b(ii)(1). */
Value newElement;
jsid id = keys[i];
id = keys[i];
if (!Walk(cx, obj, id, reviver, &newElement))
return false;
@ -879,15 +881,14 @@ Walk(JSContext *cx, JSObject *holder, jsid name, const Value &reviver, Value *vp
static bool
Revive(JSContext *cx, const Value &reviver, Value *vp)
{
JSObject *obj = NewBuiltinClassInstance(cx, &ObjectClass);
RootedVarObject obj(cx, NewBuiltinClassInstance(cx, &ObjectClass));
if (!obj)
return false;
if (!obj->defineProperty(cx, cx->runtime->atomState.emptyAtom, *vp))
return false;
return Walk(cx, obj, NameToId(cx->runtime->atomState.emptyAtom), reviver, vp);
return Walk(cx, obj, RootedVarId(cx, NameToId(cx->runtime->atomState.emptyAtom)), reviver, vp);
}
namespace js {

Просмотреть файл

@ -534,7 +534,7 @@ JSONParser::parse(Value *vp)
switch (state) {
case FinishObjectMember: {
Value v = valueStack.popCopy();
jsid propid = AtomToId(&valueStack.popCopy().toString()->asAtom());
RootedVarId propid(cx, AtomToId(&valueStack.popCopy().toString()->asAtom()));
RootedVarObject obj(cx, &valueStack.back().toObject());
if (!DefineNativeProperty(cx, obj, propid, v,
JS_PropertyStub, JS_StrictPropertyStub, JSPROP_ENUMERATE,
@ -582,7 +582,7 @@ JSONParser::parse(Value *vp)
case FinishArrayElement: {
Value v = valueStack.popCopy();
if (!js_NewbornArrayPush(cx, &valueStack.back().toObject(), v))
if (!js_NewbornArrayPush(cx, RootedVarObject(cx, &valueStack.back().toObject()), v))
return false;
token = advanceAfterArrayElement();
if (token == Comma) {

Просмотреть файл

@ -172,7 +172,7 @@ OPDEF(JSOP_NAMEDEC, 50, "namedec", NULL, 6, 0, 1, 15, JOF_ATOM|J
OPDEF(JSOP_PROPDEC, 51, "propdec", NULL, 6, 1, 1, 15, JOF_ATOM|JOF_PROP|JOF_DEC|JOF_POST|JOF_TMPSLOT3|JOF_DECOMPOSE)
OPDEF(JSOP_ELEMDEC, 52, "elemdec", NULL, 2, 2, 1, 15, JOF_BYTE |JOF_ELEM|JOF_DEC|JOF_POST|JOF_TMPSLOT2|JOF_DECOMPOSE)
OPDEF(JSOP_GETPROP, 53, "getprop", NULL, 5, 1, 1, 18, JOF_ATOM|JOF_PROP|JOF_TYPESET)
OPDEF(JSOP_GETPROP, 53, "getprop", NULL, 5, 1, 1, 18, JOF_ATOM|JOF_PROP|JOF_TYPESET|JOF_TMPSLOT3)
OPDEF(JSOP_SETPROP, 54, "setprop", NULL, 5, 2, 1, 3, JOF_ATOM|JOF_PROP|JOF_SET|JOF_DETECTING)
OPDEF(JSOP_GETELEM, 55, "getelem", NULL, 1, 2, 1, 18, JOF_BYTE |JOF_ELEM|JOF_TYPESET|JOF_LEFTASSOC)
OPDEF(JSOP_SETELEM, 56, "setelem", NULL, 1, 3, 1, 3, JOF_BYTE |JOF_ELEM|JOF_SET|JOF_DETECTING)

Просмотреть файл

@ -128,8 +128,11 @@ BaseProxyHandler::hasOwn(JSContext *cx, JSObject *proxy, jsid id, bool *bp)
}
bool
BaseProxyHandler::get(JSContext *cx, JSObject *proxy, JSObject *receiver, jsid id, Value *vp)
BaseProxyHandler::get(JSContext *cx, JSObject *proxy, JSObject *receiver_, jsid id_, Value *vp)
{
RootedVarObject receiver(cx, receiver_);
RootedVarId id(cx, id_);
JS_ASSERT(OperationInProgress(cx, proxy));
AutoPropertyDescriptorRooter desc(cx);
if (!getPropertyDescriptor(cx, proxy, id, false, &desc))
@ -176,9 +179,12 @@ BaseProxyHandler::getElementIfPresent(JSContext *cx, JSObject *proxy_, JSObject
}
bool
BaseProxyHandler::set(JSContext *cx, JSObject *proxy, JSObject *receiver, jsid id, bool strict,
Value *vp)
BaseProxyHandler::set(JSContext *cx, JSObject *proxy, JSObject *receiver_, jsid id_, bool strict,
Value *vp)
{
RootedVarObject receiver(cx, receiver_);
RootedVarId id(cx, id_);
JS_ASSERT(OperationInProgress(cx, proxy));
AutoPropertyDescriptorRooter desc(cx);
if (!getOwnPropertyDescriptor(cx, proxy, id, true, &desc))
@ -571,7 +577,7 @@ GetTrap(JSContext *cx, JSObject *handler, PropertyName *name, Value *fvalp)
{
JS_CHECK_RECURSION(cx, return false);
return handler->getGeneric(cx, NameToId(name), fvalp);
return handler->getGeneric(cx, RootedVarId(cx, NameToId(name)), fvalp);
}
static bool
@ -1176,17 +1182,15 @@ Proxy::iteratorNext(JSContext *cx, JSObject *proxy, Value *vp)
}
static JSObject *
proxy_innerObject(JSContext *cx, JSObject *obj)
proxy_innerObject(JSContext *cx, HandleObject obj)
{
return GetProxyPrivate(obj).toObjectOrNull();
}
static JSBool
proxy_LookupGeneric(JSContext *cx, JSObject *obj_, jsid id, JSObject **objp,
proxy_LookupGeneric(JSContext *cx, HandleObject obj, HandleId id, JSObject **objp,
JSProperty **propp)
{
RootedVarObject obj(cx, obj_);
bool found;
if (!Proxy::has(cx, obj, id, &found))
return false;
@ -1202,32 +1206,30 @@ proxy_LookupGeneric(JSContext *cx, JSObject *obj_, jsid id, JSObject **objp,
}
static JSBool
proxy_LookupProperty(JSContext *cx, JSObject *obj, PropertyName *name, JSObject **objp,
proxy_LookupProperty(JSContext *cx, HandleObject obj, HandlePropertyName name, JSObject **objp,
JSProperty **propp)
{
return proxy_LookupGeneric(cx, obj, NameToId(name), objp, propp);
return proxy_LookupGeneric(cx, obj, RootedVarId(cx, NameToId(name)), objp, propp);
}
static JSBool
proxy_LookupElement(JSContext *cx, JSObject *obj_, uint32_t index, JSObject **objp,
proxy_LookupElement(JSContext *cx, HandleObject obj, uint32_t index, JSObject **objp,
JSProperty **propp)
{
RootedVarObject obj(cx, obj_);
jsid id;
if (!IndexToId(cx, index, &id))
RootedVarId id(cx);
if (!IndexToId(cx, index, id.address()))
return false;
return proxy_LookupGeneric(cx, obj, id, objp, propp);
}
static JSBool
proxy_LookupSpecial(JSContext *cx, JSObject *obj, SpecialId sid, JSObject **objp, JSProperty **propp)
proxy_LookupSpecial(JSContext *cx, HandleObject obj, HandleSpecialId sid, JSObject **objp, JSProperty **propp)
{
return proxy_LookupGeneric(cx, obj, SPECIALID_TO_JSID(sid), objp, propp);
return proxy_LookupGeneric(cx, obj, RootedVarId(cx, SPECIALID_TO_JSID(sid)), objp, propp);
}
static JSBool
proxy_DefineGeneric(JSContext *cx, JSObject *obj, jsid id, const Value *value,
proxy_DefineGeneric(JSContext *cx, HandleObject obj, HandleId id, const Value *value,
PropertyOp getter, StrictPropertyOp setter, unsigned attrs)
{
AutoPropertyDescriptorRooter desc(cx);
@ -1241,99 +1243,93 @@ proxy_DefineGeneric(JSContext *cx, JSObject *obj, jsid id, const Value *value,
}
static JSBool
proxy_DefineProperty(JSContext *cx, JSObject *obj, PropertyName *name, const Value *value,
proxy_DefineProperty(JSContext *cx, HandleObject obj, HandlePropertyName name, const Value *value,
PropertyOp getter, StrictPropertyOp setter, unsigned attrs)
{
return proxy_DefineGeneric(cx, obj, NameToId(name), value, getter, setter, attrs);
return proxy_DefineGeneric(cx, obj, RootedVarId(cx, NameToId(name)), value, getter, setter, attrs);
}
static JSBool
proxy_DefineElement(JSContext *cx, JSObject *obj_, uint32_t index, const Value *value,
proxy_DefineElement(JSContext *cx, HandleObject obj, uint32_t index, const Value *value,
PropertyOp getter, StrictPropertyOp setter, unsigned attrs)
{
RootedVarObject obj(cx, obj_);
jsid id;
if (!IndexToId(cx, index, &id))
RootedVarId id(cx);
if (!IndexToId(cx, index, id.address()))
return false;
return proxy_DefineGeneric(cx, obj, id, value, getter, setter, attrs);
}
static JSBool
proxy_DefineSpecial(JSContext *cx, JSObject *obj, SpecialId sid, const Value *value,
proxy_DefineSpecial(JSContext *cx, HandleObject obj, HandleSpecialId sid, const Value *value,
PropertyOp getter, StrictPropertyOp setter, unsigned attrs)
{
return proxy_DefineGeneric(cx, obj, SPECIALID_TO_JSID(sid), value, getter, setter, attrs);
return proxy_DefineGeneric(cx, obj, RootedVarId(cx, SPECIALID_TO_JSID(sid)),
value, getter, setter, attrs);
}
static JSBool
proxy_GetGeneric(JSContext *cx, JSObject *obj, JSObject *receiver, jsid id, Value *vp)
proxy_GetGeneric(JSContext *cx, HandleObject obj, HandleObject receiver, HandleId id, Value *vp)
{
return Proxy::get(cx, obj, receiver, id, vp);
}
static JSBool
proxy_GetProperty(JSContext *cx, JSObject *obj, JSObject *receiver, PropertyName *name, Value *vp)
proxy_GetProperty(JSContext *cx, HandleObject obj, HandleObject receiver, HandlePropertyName name, Value *vp)
{
return proxy_GetGeneric(cx, obj, receiver, NameToId(name), vp);
return proxy_GetGeneric(cx, obj, receiver, RootedVarId(cx, NameToId(name)), vp);
}
static JSBool
proxy_GetElement(JSContext *cx, JSObject *obj_, JSObject *receiver_, uint32_t index, Value *vp)
proxy_GetElement(JSContext *cx, HandleObject obj, HandleObject receiver, uint32_t index, Value *vp)
{
RootedVarObject obj(cx, obj_);
RootedVarObject receiver(cx, receiver_);
jsid id;
if (!IndexToId(cx, index, &id))
RootedVarId id(cx);
if (!IndexToId(cx, index, id.address()))
return false;
return proxy_GetGeneric(cx, obj, receiver, id, vp);
}
static JSBool
proxy_GetElementIfPresent(JSContext *cx, JSObject *obj, JSObject *receiver, uint32_t index,
proxy_GetElementIfPresent(JSContext *cx, HandleObject obj, HandleObject receiver, uint32_t index,
Value *vp, bool *present)
{
return Proxy::getElementIfPresent(cx, obj, receiver, index, vp, present);
}
static JSBool
proxy_GetSpecial(JSContext *cx, JSObject *obj, JSObject *receiver, SpecialId sid, Value *vp)
proxy_GetSpecial(JSContext *cx, HandleObject obj, HandleObject receiver, HandleSpecialId sid, Value *vp)
{
return proxy_GetGeneric(cx, obj, receiver, SPECIALID_TO_JSID(sid), vp);
return proxy_GetGeneric(cx, obj, receiver, RootedVarId(cx, SPECIALID_TO_JSID(sid)), vp);
}
static JSBool
proxy_SetGeneric(JSContext *cx, JSObject *obj, jsid id, Value *vp, JSBool strict)
proxy_SetGeneric(JSContext *cx, HandleObject obj, HandleId id, Value *vp, JSBool strict)
{
return Proxy::set(cx, obj, obj, id, strict, vp);
}
static JSBool
proxy_SetProperty(JSContext *cx, JSObject *obj, PropertyName *name, Value *vp, JSBool strict)
proxy_SetProperty(JSContext *cx, HandleObject obj, HandlePropertyName name, Value *vp, JSBool strict)
{
return proxy_SetGeneric(cx, obj, NameToId(name), vp, strict);
return proxy_SetGeneric(cx, obj, RootedVarId(cx, NameToId(name)), vp, strict);
}
static JSBool
proxy_SetElement(JSContext *cx, JSObject *obj_, uint32_t index, Value *vp, JSBool strict)
proxy_SetElement(JSContext *cx, HandleObject obj, uint32_t index, Value *vp, JSBool strict)
{
RootedVarObject obj(cx, obj_);
jsid id;
if (!IndexToId(cx, index, &id))
RootedVarId id(cx);
if (!IndexToId(cx, index, id.address()))
return false;
return proxy_SetGeneric(cx, obj, id, vp, strict);
}
static JSBool
proxy_SetSpecial(JSContext *cx, JSObject *obj, SpecialId sid, Value *vp, JSBool strict)
proxy_SetSpecial(JSContext *cx, HandleObject obj, HandleSpecialId sid, Value *vp, JSBool strict)
{
return proxy_SetGeneric(cx, obj, SPECIALID_TO_JSID(sid), vp, strict);
return proxy_SetGeneric(cx, obj, RootedVarId(cx, SPECIALID_TO_JSID(sid)), vp, strict);
}
static JSBool
proxy_GetGenericAttributes(JSContext *cx, JSObject *obj, jsid id, unsigned *attrsp)
proxy_GetGenericAttributes(JSContext *cx, HandleObject obj, HandleId id, unsigned *attrsp)
{
AutoPropertyDescriptorRooter desc(cx);
if (!Proxy::getOwnPropertyDescriptor(cx, obj, id, false, &desc))
@ -1343,30 +1339,28 @@ proxy_GetGenericAttributes(JSContext *cx, JSObject *obj, jsid id, unsigned *attr
}
static JSBool
proxy_GetPropertyAttributes(JSContext *cx, JSObject *obj, PropertyName *name, unsigned *attrsp)
proxy_GetPropertyAttributes(JSContext *cx, HandleObject obj, HandlePropertyName name, unsigned *attrsp)
{
return proxy_GetGenericAttributes(cx, obj, NameToId(name), attrsp);
return proxy_GetGenericAttributes(cx, obj, RootedVarId(cx, NameToId(name)), attrsp);
}
static JSBool
proxy_GetElementAttributes(JSContext *cx, JSObject *obj_, uint32_t index, unsigned *attrsp)
proxy_GetElementAttributes(JSContext *cx, HandleObject obj, uint32_t index, unsigned *attrsp)
{
RootedVarObject obj(cx, obj_);
jsid id;
if (!IndexToId(cx, index, &id))
RootedVarId id(cx);
if (!IndexToId(cx, index, id.address()))
return false;
return proxy_GetGenericAttributes(cx, obj, id, attrsp);
}
static JSBool
proxy_GetSpecialAttributes(JSContext *cx, JSObject *obj, SpecialId sid, unsigned *attrsp)
proxy_GetSpecialAttributes(JSContext *cx, HandleObject obj, HandleSpecialId sid, unsigned *attrsp)
{
return proxy_GetGenericAttributes(cx, obj, SPECIALID_TO_JSID(sid), attrsp);
return proxy_GetGenericAttributes(cx, obj, RootedVarId(cx, SPECIALID_TO_JSID(sid)), attrsp);
}
static JSBool
proxy_SetGenericAttributes(JSContext *cx, JSObject *obj, jsid id, unsigned *attrsp)
proxy_SetGenericAttributes(JSContext *cx, HandleObject obj, HandleId id, unsigned *attrsp)
{
/* Lookup the current property descriptor so we have setter/getter/value. */
AutoPropertyDescriptorRooter desc(cx);
@ -1377,33 +1371,29 @@ proxy_SetGenericAttributes(JSContext *cx, JSObject *obj, jsid id, unsigned *attr
}
static JSBool
proxy_SetPropertyAttributes(JSContext *cx, JSObject *obj, PropertyName *name, unsigned *attrsp)
proxy_SetPropertyAttributes(JSContext *cx, HandleObject obj, HandlePropertyName name, unsigned *attrsp)
{
return proxy_SetGenericAttributes(cx, obj, NameToId(name), attrsp);
return proxy_SetGenericAttributes(cx, obj, RootedVarId(cx, NameToId(name)), attrsp);
}
static JSBool
proxy_SetElementAttributes(JSContext *cx, JSObject *obj_, uint32_t index, unsigned *attrsp)
proxy_SetElementAttributes(JSContext *cx, HandleObject obj, uint32_t index, unsigned *attrsp)
{
RootedVarObject obj(cx, obj_);
jsid id;
if (!IndexToId(cx, index, &id))
RootedVarId id(cx);
if (!IndexToId(cx, index, id.address()))
return false;
return proxy_SetGenericAttributes(cx, obj, id, attrsp);
}
static JSBool
proxy_SetSpecialAttributes(JSContext *cx, JSObject *obj, SpecialId sid, unsigned *attrsp)
proxy_SetSpecialAttributes(JSContext *cx, HandleObject obj, HandleSpecialId sid, unsigned *attrsp)
{
return proxy_SetGenericAttributes(cx, obj, SPECIALID_TO_JSID(sid), attrsp);
return proxy_SetGenericAttributes(cx, obj, RootedVarId(cx, SPECIALID_TO_JSID(sid)), attrsp);
}
static JSBool
proxy_DeleteGeneric(JSContext *cx, JSObject *obj_, jsid id, Value *rval, JSBool strict)
proxy_DeleteGeneric(JSContext *cx, HandleObject obj, HandleId id, Value *rval, JSBool strict)
{
RootedVarObject obj(cx, obj_);
// TODO: throwing away strict
bool deleted;
if (!Proxy::delete_(cx, obj, id, &deleted) || !js_SuppressDeletedProperty(cx, obj, id))
@ -1413,26 +1403,24 @@ proxy_DeleteGeneric(JSContext *cx, JSObject *obj_, jsid id, Value *rval, JSBool
}
static JSBool
proxy_DeleteProperty(JSContext *cx, JSObject *obj, PropertyName *name, Value *rval, JSBool strict)
proxy_DeleteProperty(JSContext *cx, HandleObject obj, HandlePropertyName name, Value *rval, JSBool strict)
{
return proxy_DeleteGeneric(cx, obj, NameToId(name), rval, strict);
return proxy_DeleteGeneric(cx, obj, RootedVarId(cx, NameToId(name)), rval, strict);
}
static JSBool
proxy_DeleteElement(JSContext *cx, JSObject *obj_, uint32_t index, Value *rval, JSBool strict)
proxy_DeleteElement(JSContext *cx, HandleObject obj, uint32_t index, Value *rval, JSBool strict)
{
RootedVarObject obj(cx, obj_);
jsid id;
if (!IndexToId(cx, index, &id))
RootedVarId id(cx);
if (!IndexToId(cx, index, id.address()))
return false;
return proxy_DeleteGeneric(cx, obj, id, rval, strict);
}
static JSBool
proxy_DeleteSpecial(JSContext *cx, JSObject *obj, SpecialId sid, Value *rval, JSBool strict)
proxy_DeleteSpecial(JSContext *cx, HandleObject obj, HandleSpecialId sid, Value *rval, JSBool strict)
{
return proxy_DeleteGeneric(cx, obj, SPECIALID_TO_JSID(sid), rval, strict);
return proxy_DeleteGeneric(cx, obj, RootedVarId(cx, SPECIALID_TO_JSID(sid)), rval, strict);
}
static void
@ -1457,7 +1445,7 @@ proxy_TraceFunction(JSTracer *trc, JSObject *obj)
}
static JSBool
proxy_Convert(JSContext *cx, JSObject *proxy, JSType hint, Value *vp)
proxy_Convert(JSContext *cx, HandleObject proxy, JSType hint, Value *vp)
{
JS_ASSERT(proxy->isProxy());
return Proxy::defaultValue(cx, proxy, hint, vp);
@ -1472,7 +1460,7 @@ proxy_Finalize(FreeOp *fop, JSObject *obj)
}
static JSBool
proxy_HasInstance(JSContext *cx, JSObject *proxy, const Value *v, JSBool *bp)
proxy_HasInstance(JSContext *cx, HandleObject proxy, const Value *v, JSBool *bp)
{
AutoPendingProxyOperation pending(cx, proxy);
bool b;
@ -1483,7 +1471,7 @@ proxy_HasInstance(JSContext *cx, JSObject *proxy, const Value *v, JSBool *bp)
}
static JSType
proxy_TypeOf(JSContext *cx, JSObject *proxy)
proxy_TypeOf(JSContext *cx, HandleObject proxy)
{
JS_ASSERT(proxy->isProxy());
return Proxy::typeOf(cx, proxy);

Просмотреть файл

@ -408,41 +408,23 @@ typedef struct JSDebugHooks {
/* js::ObjectOps function pointer typedefs. */
/*
* Look for id in obj and its prototype chain, returning false on error or
* exception, true on success. On success, return null in *propp if id was
* not found. If id was found, return the first object searching from obj
* along its prototype chain in which id names a direct property in *objp, and
* return a non-null, opaque property pointer in *propp.
*
* If JSLookupPropOp succeeds and returns with *propp non-null, that pointer
* may be passed as the prop parameter to a JSAttributesOp, as a short-cut
* that bypasses id re-lookup.
*/
typedef JSBool
(* JSLookupPropOp)(JSContext *cx, JSObject *obj, jsid id, JSObject **objp,
JSProperty **propp);
/*
* Get or set attributes of the property obj[id]. Return false on error or
* exception, true with current attributes in *attrsp.
*/
typedef JSBool
(* JSAttributesOp)(JSContext *cx, JSObject *obj, jsid id, unsigned *attrsp);
/*
* A generic type for functions mapping an object to another object, or null
* if an error or exception was thrown on cx.
*/
typedef JSObject *
(* JSObjectOp)(JSContext *cx, JSObject *obj);
(* JSObjectOp)(JSContext *cx, JSHandleObject obj);
/* Signature for class initialization ops. */
typedef JSObject *
(* JSClassInitializerOp)(JSContext *cx, JSObject *obj);
/*
* Hook that creates an iterator object for a given object. Returns the
* iterator object or null if an error or exception was thrown on cx.
*/
typedef JSObject *
(* JSIteratorOp)(JSContext *cx, JSObject *obj, JSBool keysonly);
(* JSIteratorOp)(JSContext *cx, JSHandleObject obj, JSBool keysonly);
/*
* The following determines whether JS_EncodeCharacters and JS_DecodeBytes

Просмотреть файл

@ -207,7 +207,7 @@ class NodeBuilder
if (!atom)
return false;
RootedVarId id(cx, AtomToId(atom));
if (!GetPropertyDefault(cx, userobj, id, NullValue(), &funv))
if (!baseops::GetPropertyDefault(cx, userobj, id, NullValue(), &funv))
return false;
if (funv.isNullOrUndefined()) {
@ -3136,7 +3136,7 @@ reflect_parse(JSContext *cx, uint32_t argc, jsval *vp)
/* config.loc */
RootedVarId locId(cx, NameToId(cx->runtime->atomState.locAtom));
if (!GetPropertyDefault(cx, config, locId, BooleanValue(true), &prop))
if (!baseops::GetPropertyDefault(cx, config, locId, BooleanValue(true), &prop))
return JS_FALSE;
loc = js_ValueToBoolean(prop);
@ -3144,7 +3144,7 @@ reflect_parse(JSContext *cx, uint32_t argc, jsval *vp)
if (loc) {
/* config.source */
RootedVarId sourceId(cx, NameToId(cx->runtime->atomState.sourceAtom));
if (!GetPropertyDefault(cx, config, sourceId, NullValue(), &prop))
if (!baseops::GetPropertyDefault(cx, config, sourceId, NullValue(), &prop))
return JS_FALSE;
if (!prop.isNullOrUndefined()) {
@ -3165,7 +3165,7 @@ reflect_parse(JSContext *cx, uint32_t argc, jsval *vp)
/* config.line */
RootedVarId lineId(cx, NameToId(cx->runtime->atomState.lineAtom));
if (!GetPropertyDefault(cx, config, lineId, Int32Value(1), &prop) ||
if (!baseops::GetPropertyDefault(cx, config, lineId, Int32Value(1), &prop) ||
!ToUint32(cx, prop, &lineno)) {
return JS_FALSE;
}
@ -3173,7 +3173,7 @@ reflect_parse(JSContext *cx, uint32_t argc, jsval *vp)
/* config.builder */
RootedVarId builderId(cx, NameToId(cx->runtime->atomState.builderAtom));
if (!GetPropertyDefault(cx, config, builderId, NullValue(), &prop))
if (!baseops::GetPropertyDefault(cx, config, builderId, NullValue(), &prop))
return JS_FALSE;
if (!prop.isNullOrUndefined()) {

Просмотреть файл

@ -704,8 +704,8 @@ struct Shape : public js::gc::Cell
uint32_t aslot, unsigned aattrs, unsigned aflags,
int ashortid) const;
bool get(JSContext* cx, JSObject *receiver, JSObject *obj, JSObject *pobj, js::Value* vp) const;
bool set(JSContext* cx, JSObject *obj, bool strict, js::Value* vp) const;
bool get(JSContext* cx, HandleObject receiver, JSObject *obj, JSObject *pobj, js::Value* vp) const;
bool set(JSContext* cx, HandleObject obj, bool strict, js::Value* vp) const;
BaseShape *base() const { return base_; }

Просмотреть файл

@ -298,51 +298,49 @@ Shape::getUserId(JSContext *cx, jsid *idp) const
}
inline bool
Shape::get(JSContext* cx, JSObject *receiver, JSObject* obj, JSObject *pobj, js::Value* vp) const
Shape::get(JSContext* cx, HandleObject receiver, JSObject* obj, JSObject *pobj, Value* vp) const
{
JS_ASSERT(!hasDefaultGetter());
if (hasGetterValue()) {
js::Value fval = getterValue();
return js::InvokeGetterOrSetter(cx, receiver, fval, 0, 0, vp);
Value fval = getterValue();
return InvokeGetterOrSetter(cx, receiver, fval, 0, 0, vp);
}
/*
* |with (it) color;| ends up here, as do XML filter-expressions.
* Avoid exposing the With object to native getters.
*/
if (obj->isWith())
obj = &obj->asWith().object();
jsid id;
if (!getUserId(cx, &id))
RootedVarId id(cx);
if (!getUserId(cx, id.address()))
return false;
return js::CallJSPropertyOp(cx, getterOp(), receiver, id, vp);
return CallJSPropertyOp(cx, getterOp(), receiver, id, vp);
}
inline bool
Shape::set(JSContext* cx, JSObject* obj, bool strict, js::Value* vp) const
Shape::set(JSContext* cx, HandleObject obj, bool strict, Value* vp) const
{
JS_ASSERT_IF(hasDefaultSetter(), hasGetterValue());
if (attrs & JSPROP_SETTER) {
js::Value fval = setterValue();
return js::InvokeGetterOrSetter(cx, obj, fval, 1, vp, vp);
Value fval = setterValue();
return InvokeGetterOrSetter(cx, obj, fval, 1, vp, vp);
}
if (attrs & JSPROP_GETTER)
return js_ReportGetterOnlyAssignment(cx);
/* See the comment in js::Shape::get as to why we check for With. */
if (obj->isWith())
obj = &obj->asWith().object();
jsid id;
if (!getUserId(cx, &id))
RootedVarId id(cx);
if (!getUserId(cx, id.address()))
return false;
return js::CallJSPropertyOpSetter(cx, setterOp(), obj, id, strict, vp);
/*
* |with (it) color;| ends up here, as do XML filter-expressions.
* Avoid exposing the With object to native setters.
*/
if (obj->isWith()) {
RootedVarObject nobj(cx, &obj->asWith().object());
return CallJSPropertyOpSetter(cx, setterOp(), nobj, id, strict, vp);
}
return CallJSPropertyOpSetter(cx, setterOp(), obj, id, strict, vp);
}
inline void

Просмотреть файл

@ -392,9 +392,8 @@ JSSubString js_EmptySubString = {0, js_empty_ucstr};
static const unsigned STRING_ELEMENT_ATTRS = JSPROP_ENUMERATE | JSPROP_READONLY | JSPROP_PERMANENT;
static JSBool
str_enumerate(JSContext *cx, JSObject *obj_)
str_enumerate(JSContext *cx, HandleObject obj)
{
RootedVarObject obj(cx, obj_);
RootedVarString str(cx, obj->asString().unbox());
for (size_t i = 0, length = str->length(); i < length; i++) {
JSString *str1 = js_NewDependentString(cx, str, i, 1);
@ -411,14 +410,12 @@ str_enumerate(JSContext *cx, JSObject *obj_)
}
static JSBool
str_resolve(JSContext *cx, JSObject *obj_, jsid id, unsigned flags,
str_resolve(JSContext *cx, HandleObject obj, HandleId id, unsigned flags,
JSObject **objp)
{
if (!JSID_IS_INT(id))
return JS_TRUE;
RootedVarObject obj(cx, obj_);
JSString *str = obj->asString().unbox();
int32_t slot = JSID_TO_INT(id);
@ -3325,8 +3322,8 @@ js_ValueToSource(JSContext *cx, const Value &v)
Value rval = NullValue();
Value fval;
jsid id = NameToId(cx->runtime->atomState.toSourceAtom);
if (!js_GetMethod(cx, RootedVarObject(cx, &v.toObject()), id, 0, &fval))
RootedVarId id(cx, NameToId(cx->runtime->atomState.toSourceAtom));
if (!GetMethod(cx, RootedVarObject(cx, &v.toObject()), id, 0, &fval))
return NULL;
if (js_IsCallable(fval)) {
if (!Invoke(cx, v, fval, 0, NULL, &rval))

Просмотреть файл

@ -149,7 +149,7 @@ getArrayBuffer(JSObject *obj)
}
JSBool
ArrayBufferObject::prop_getByteLength(JSContext *cx, JSObject *obj, jsid id, Value *vp)
ArrayBufferObject::prop_getByteLength(JSContext *cx, HandleObject obj, HandleId id, Value *vp)
{
ArrayBufferObject *buffer = getArrayBuffer(obj);
if (!buffer) {
@ -343,12 +343,9 @@ ArrayBufferObject::obj_trace(JSTracer *trc, JSObject *obj)
static JSProperty * const PROPERTY_FOUND = reinterpret_cast<JSProperty *>(1);
JSBool
ArrayBufferObject::obj_lookupGeneric(JSContext *cx, JSObject *obj_, jsid id_,
ArrayBufferObject::obj_lookupGeneric(JSContext *cx, HandleObject obj, HandleId id,
JSObject **objp, JSProperty **propp)
{
RootedVarObject obj(cx, obj_);
RootedVarId id(cx, id_);
if (JSID_IS_ATOM(id, cx->runtime->atomState.byteLengthAtom)) {
*propp = PROPERTY_FOUND;
*objp = getArrayBuffer(obj);
@ -386,18 +383,16 @@ ArrayBufferObject::obj_lookupGeneric(JSContext *cx, JSObject *obj_, jsid id_,
}
JSBool
ArrayBufferObject::obj_lookupProperty(JSContext *cx, JSObject *obj, PropertyName *name,
ArrayBufferObject::obj_lookupProperty(JSContext *cx, HandleObject obj, HandlePropertyName name,
JSObject **objp, JSProperty **propp)
{
return obj_lookupGeneric(cx, obj, NameToId(name), objp, propp);
return obj_lookupGeneric(cx, obj, RootedVarId(cx, NameToId(name)), objp, propp);
}
JSBool
ArrayBufferObject::obj_lookupElement(JSContext *cx, JSObject *obj_, uint32_t index,
ArrayBufferObject::obj_lookupElement(JSContext *cx, HandleObject obj, uint32_t index,
JSObject **objp, JSProperty **propp)
{
RootedVarObject obj(cx, obj_);
RootedVarObject delegate(cx, DelegateObject(cx, obj));
if (!delegate)
return false;
@ -426,84 +421,80 @@ ArrayBufferObject::obj_lookupElement(JSContext *cx, JSObject *obj_, uint32_t ind
}
JSBool
ArrayBufferObject::obj_lookupSpecial(JSContext *cx, JSObject *obj, SpecialId sid,
ArrayBufferObject::obj_lookupSpecial(JSContext *cx, HandleObject obj, HandleSpecialId sid,
JSObject **objp, JSProperty **propp)
{
return obj_lookupGeneric(cx, obj, SPECIALID_TO_JSID(sid), objp, propp);
return obj_lookupGeneric(cx, obj, RootedVarId(cx, SPECIALID_TO_JSID(sid)), objp, propp);
}
JSBool
ArrayBufferObject::obj_defineGeneric(JSContext *cx, JSObject *obj_, jsid id_, const Value *v,
ArrayBufferObject::obj_defineGeneric(JSContext *cx, HandleObject obj, HandleId id, const Value *v,
PropertyOp getter, StrictPropertyOp setter, unsigned attrs)
{
if (JSID_IS_ATOM(id_, cx->runtime->atomState.byteLengthAtom))
if (JSID_IS_ATOM(id, cx->runtime->atomState.byteLengthAtom))
return true;
RootedVarObject obj(cx, obj_);
RootedVarId id(cx, id_);
RootGetterSetter gsRoot(cx, attrs, &getter, &setter);
JSObject *delegate = DelegateObject(cx, obj);
if (!delegate)
return false;
return js_DefineProperty(cx, delegate, id, v, getter, setter, attrs);
}
JSBool
ArrayBufferObject::obj_defineProperty(JSContext *cx, JSObject *obj,
PropertyName *name, const Value *v,
PropertyOp getter, StrictPropertyOp setter, unsigned attrs)
{
return obj_defineGeneric(cx, obj, NameToId(name), v, getter, setter, attrs);
}
JSBool
ArrayBufferObject::obj_defineElement(JSContext *cx, JSObject *obj_, uint32_t index, const Value *v,
PropertyOp getter, StrictPropertyOp setter, unsigned attrs)
{
RootedVarObject obj(cx, obj_);
RootGetterSetter gsRoot(cx, attrs, &getter, &setter);
JSObject *delegate = DelegateObject(cx, obj);
if (!delegate)
return false;
return js_DefineElement(cx, delegate, index, v, getter, setter, attrs);
}
JSBool
ArrayBufferObject::obj_defineSpecial(JSContext *cx, JSObject *obj, SpecialId sid, const Value *v,
PropertyOp getter, StrictPropertyOp setter, unsigned attrs)
{
return obj_defineGeneric(cx, obj, SPECIALID_TO_JSID(sid), v, getter, setter, attrs);
}
JSBool
ArrayBufferObject::obj_getGeneric(JSContext *cx, JSObject *obj_, JSObject *receiver_, jsid id_, Value *vp)
{
RootedVarObject obj(cx, obj_), receiver(cx, receiver_);
RootedVarId id(cx, id_);
obj = getArrayBuffer(obj);
JS_ASSERT(obj);
if (JSID_IS_ATOM(id, cx->runtime->atomState.byteLengthAtom)) {
vp->setInt32(obj->asArrayBuffer().byteLength());
return true;
}
RootedVarObject delegate(cx, DelegateObject(cx, obj));
if (!delegate)
return false;
return js_GetProperty(cx, delegate, receiver, id, vp);
return baseops::DefineProperty(cx, delegate, id, v, getter, setter, attrs);
}
JSBool
ArrayBufferObject::obj_getProperty(JSContext *cx, JSObject *obj_,
JSObject *receiver_, PropertyName *name_, Value *vp)
ArrayBufferObject::obj_defineProperty(JSContext *cx, HandleObject obj,
HandlePropertyName name, const Value *v,
PropertyOp getter, StrictPropertyOp setter, unsigned attrs)
{
RootedVarObject obj(cx, obj_), receiver(cx, receiver_);
RootedVarPropertyName name(cx, name_);
return obj_defineGeneric(cx, obj, RootedVarId(cx, NameToId(name)), v, getter, setter, attrs);
}
if (!(obj = getArrayBuffer(obj))) {
JSBool
ArrayBufferObject::obj_defineElement(JSContext *cx, HandleObject obj, uint32_t index, const Value *v,
PropertyOp getter, StrictPropertyOp setter, unsigned attrs)
{
RootGetterSetter gsRoot(cx, attrs, &getter, &setter);
RootedVarObject delegate(cx, DelegateObject(cx, obj));
if (!delegate)
return false;
return baseops::DefineElement(cx, delegate, index, v, getter, setter, attrs);
}
JSBool
ArrayBufferObject::obj_defineSpecial(JSContext *cx, HandleObject obj, HandleSpecialId sid, const Value *v,
PropertyOp getter, StrictPropertyOp setter, unsigned attrs)
{
return obj_defineGeneric(cx, obj, RootedVarId(cx, SPECIALID_TO_JSID(sid)),
v, getter, setter, attrs);
}
JSBool
ArrayBufferObject::obj_getGeneric(JSContext *cx, HandleObject obj, HandleObject receiver,
HandleId id, Value *vp)
{
RootedVarObject nobj(cx, getArrayBuffer(obj));
JS_ASSERT(nobj);
if (JSID_IS_ATOM(id, cx->runtime->atomState.byteLengthAtom)) {
vp->setInt32(nobj->asArrayBuffer().byteLength());
return true;
}
nobj = DelegateObject(cx, nobj);
if (!nobj)
return false;
return baseops::GetProperty(cx, nobj, receiver, id, vp);
}
JSBool
ArrayBufferObject::obj_getProperty(JSContext *cx, HandleObject obj,
HandleObject receiver, HandlePropertyName name, Value *vp)
{
RootedVarObject nobj(cx, getArrayBuffer(obj));
if (!nobj) {
JSAutoByteString bs(cx, name);
if (!bs)
return false;
@ -513,34 +504,30 @@ ArrayBufferObject::obj_getProperty(JSContext *cx, JSObject *obj_,
}
if (name == cx->runtime->atomState.byteLengthAtom) {
vp->setInt32(obj->asArrayBuffer().byteLength());
vp->setInt32(nobj->asArrayBuffer().byteLength());
return true;
}
RootedVarObject delegate(cx, DelegateObject(cx, obj));
if (!delegate)
nobj = DelegateObject(cx, nobj);
if (!nobj)
return false;
return js_GetProperty(cx, delegate, receiver, NameToId(name), vp);
return baseops::GetProperty(cx, nobj, receiver, RootedVarId(cx, NameToId(name)), vp);
}
JSBool
ArrayBufferObject::obj_getElement(JSContext *cx, JSObject *obj,
JSObject *receiver_, uint32_t index, Value *vp)
ArrayBufferObject::obj_getElement(JSContext *cx, HandleObject obj,
HandleObject receiver, uint32_t index, Value *vp)
{
RootedVarObject receiver(cx, receiver_);
RootedVarObject delegate(cx, DelegateObject(cx, RootedVarObject(cx, getArrayBuffer(obj))));
if (!delegate)
return false;
return js_GetElement(cx, delegate, receiver, index, vp);
return baseops::GetElement(cx, delegate, receiver, index, vp);
}
JSBool
ArrayBufferObject::obj_getElementIfPresent(JSContext *cx, JSObject *obj, JSObject *receiver_,
ArrayBufferObject::obj_getElementIfPresent(JSContext *cx, HandleObject obj, HandleObject receiver,
uint32_t index, Value *vp, bool *present)
{
RootedVarObject receiver(cx, receiver_);
JSObject *delegate = DelegateObject(cx, RootedVarObject(cx, getArrayBuffer(obj)));
if (!delegate)
return false;
@ -548,18 +535,15 @@ ArrayBufferObject::obj_getElementIfPresent(JSContext *cx, JSObject *obj, JSObjec
}
JSBool
ArrayBufferObject::obj_getSpecial(JSContext *cx, JSObject *obj,
JSObject *receiver, SpecialId sid, Value *vp)
ArrayBufferObject::obj_getSpecial(JSContext *cx, HandleObject obj,
HandleObject receiver, HandleSpecialId sid, Value *vp)
{
return obj_getGeneric(cx, obj, receiver, SPECIALID_TO_JSID(sid), vp);
return obj_getGeneric(cx, obj, receiver, RootedVarId(cx, SPECIALID_TO_JSID(sid)), vp);
}
JSBool
ArrayBufferObject::obj_setGeneric(JSContext *cx, JSObject *obj_, jsid id_, Value *vp, JSBool strict)
ArrayBufferObject::obj_setGeneric(JSContext *cx, HandleObject obj, HandleId id, Value *vp, JSBool strict)
{
RootedVarObject obj(cx, obj_);
RootedVarId id(cx, id_);
if (JSID_IS_ATOM(id, cx->runtime->atomState.byteLengthAtom))
return true;
@ -589,7 +573,7 @@ ArrayBufferObject::obj_setGeneric(JSContext *cx, JSObject *obj_, jsid id_, Value
RootedVarObject oldDelegateProto(cx, delegate->getProto());
if (!js_SetPropertyHelper(cx, delegate, id, 0, vp, strict))
if (!baseops::SetPropertyHelper(cx, delegate, id, 0, vp, strict))
return false;
if (delegate->getProto() != oldDelegateProto) {
@ -609,170 +593,150 @@ ArrayBufferObject::obj_setGeneric(JSContext *cx, JSObject *obj_, jsid id_, Value
return true;
}
return js_SetPropertyHelper(cx, delegate, id, 0, vp, strict);
return baseops::SetPropertyHelper(cx, delegate, id, 0, vp, strict);
}
JSBool
ArrayBufferObject::obj_setProperty(JSContext *cx, JSObject *obj,
PropertyName *name, Value *vp, JSBool strict)
ArrayBufferObject::obj_setProperty(JSContext *cx, HandleObject obj,
HandlePropertyName name, Value *vp, JSBool strict)
{
return obj_setGeneric(cx, obj, NameToId(name), vp, strict);
return obj_setGeneric(cx, obj, RootedVarId(cx, NameToId(name)), vp, strict);
}
JSBool
ArrayBufferObject::obj_setElement(JSContext *cx, JSObject *obj_,
ArrayBufferObject::obj_setElement(JSContext *cx, HandleObject obj,
uint32_t index, Value *vp, JSBool strict)
{
RootedVarObject obj(cx, obj_);
RootedVarObject delegate(cx, DelegateObject(cx, obj));
if (!delegate)
return false;
return js_SetElementHelper(cx, delegate, index, 0, vp, strict);
return baseops::SetElementHelper(cx, delegate, index, 0, vp, strict);
}
JSBool
ArrayBufferObject::obj_setSpecial(JSContext *cx, JSObject *obj,
SpecialId sid, Value *vp, JSBool strict)
ArrayBufferObject::obj_setSpecial(JSContext *cx, HandleObject obj,
HandleSpecialId sid, Value *vp, JSBool strict)
{
return obj_setGeneric(cx, obj, SPECIALID_TO_JSID(sid), vp, strict);
return obj_setGeneric(cx, obj, RootedVarId(cx, SPECIALID_TO_JSID(sid)), vp, strict);
}
JSBool
ArrayBufferObject::obj_getGenericAttributes(JSContext *cx, JSObject *obj_,
jsid id_, unsigned *attrsp)
ArrayBufferObject::obj_getGenericAttributes(JSContext *cx, HandleObject obj,
HandleId id, unsigned *attrsp)
{
RootedVarObject obj(cx, obj_);
RootedVarId id(cx, id_);
if (JSID_IS_ATOM(id, cx->runtime->atomState.byteLengthAtom)) {
*attrsp = JSPROP_PERMANENT | JSPROP_READONLY;
return true;
}
JSObject *delegate = DelegateObject(cx, obj);
RootedVarObject delegate(cx, DelegateObject(cx, obj));
if (!delegate)
return false;
return js_GetAttributes(cx, delegate, id, attrsp);
return baseops::GetAttributes(cx, delegate, id, attrsp);
}
JSBool
ArrayBufferObject::obj_getPropertyAttributes(JSContext *cx, JSObject *obj,
PropertyName *name, unsigned *attrsp)
ArrayBufferObject::obj_getPropertyAttributes(JSContext *cx, HandleObject obj,
HandlePropertyName name, unsigned *attrsp)
{
return obj_getGenericAttributes(cx, obj, NameToId(name), attrsp);
return obj_getGenericAttributes(cx, obj, RootedVarId(cx, NameToId(name)), attrsp);
}
JSBool
ArrayBufferObject::obj_getElementAttributes(JSContext *cx, JSObject *obj_,
ArrayBufferObject::obj_getElementAttributes(JSContext *cx, HandleObject obj,
uint32_t index, unsigned *attrsp)
{
RootedVarObject obj(cx, obj_);
JSObject *delegate = DelegateObject(cx, obj);
RootedVarObject delegate(cx, DelegateObject(cx, obj));
if (!delegate)
return false;
return js_GetElementAttributes(cx, delegate, index, attrsp);
return baseops::GetElementAttributes(cx, delegate, index, attrsp);
}
JSBool
ArrayBufferObject::obj_getSpecialAttributes(JSContext *cx, JSObject *obj,
SpecialId sid, unsigned *attrsp)
ArrayBufferObject::obj_getSpecialAttributes(JSContext *cx, HandleObject obj,
HandleSpecialId sid, unsigned *attrsp)
{
return obj_getGenericAttributes(cx, obj, SPECIALID_TO_JSID(sid), attrsp);
return obj_getGenericAttributes(cx, obj, RootedVarId(cx, SPECIALID_TO_JSID(sid)), attrsp);
}
JSBool
ArrayBufferObject::obj_setGenericAttributes(JSContext *cx, JSObject *obj_,
jsid id_, unsigned *attrsp)
ArrayBufferObject::obj_setGenericAttributes(JSContext *cx, HandleObject obj,
HandleId id, unsigned *attrsp)
{
RootedVarObject obj(cx, obj_);
RootedVarId id(cx, id_);
if (JSID_IS_ATOM(id, cx->runtime->atomState.byteLengthAtom)) {
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL,
JSMSG_CANT_SET_ARRAY_ATTRS);
return false;
}
JSObject *delegate = DelegateObject(cx, obj);
RootedVarObject delegate(cx, DelegateObject(cx, obj));
if (!delegate)
return false;
return js_SetAttributes(cx, delegate, id, attrsp);
return baseops::SetAttributes(cx, delegate, id, attrsp);
}
JSBool
ArrayBufferObject::obj_setPropertyAttributes(JSContext *cx, JSObject *obj,
PropertyName *name, unsigned *attrsp)
ArrayBufferObject::obj_setPropertyAttributes(JSContext *cx, HandleObject obj,
HandlePropertyName name, unsigned *attrsp)
{
return obj_setGenericAttributes(cx, obj, NameToId(name), attrsp);
return obj_setGenericAttributes(cx, obj, RootedVarId(cx, NameToId(name)), attrsp);
}
JSBool
ArrayBufferObject::obj_setElementAttributes(JSContext *cx, JSObject *obj_,
ArrayBufferObject::obj_setElementAttributes(JSContext *cx, HandleObject obj,
uint32_t index, unsigned *attrsp)
{
RootedVarObject obj(cx, obj_);
JSObject *delegate = DelegateObject(cx, obj);
RootedVarObject delegate(cx, DelegateObject(cx, obj));
if (!delegate)
return false;
return js_SetElementAttributes(cx, delegate, index, attrsp);
return baseops::SetElementAttributes(cx, delegate, index, attrsp);
}
JSBool
ArrayBufferObject::obj_setSpecialAttributes(JSContext *cx, JSObject *obj,
SpecialId sid, unsigned *attrsp)
ArrayBufferObject::obj_setSpecialAttributes(JSContext *cx, HandleObject obj,
HandleSpecialId sid, unsigned *attrsp)
{
return obj_setGenericAttributes(cx, obj, SPECIALID_TO_JSID(sid), attrsp);
return obj_setGenericAttributes(cx, obj, RootedVarId(cx, SPECIALID_TO_JSID(sid)), attrsp);
}
JSBool
ArrayBufferObject::obj_deleteProperty(JSContext *cx, JSObject *obj_,
PropertyName *name_, Value *rval, JSBool strict)
ArrayBufferObject::obj_deleteProperty(JSContext *cx, HandleObject obj,
HandlePropertyName name, Value *rval, JSBool strict)
{
RootedVarObject obj(cx, obj_);
RootedVarPropertyName name(cx, name_);
if (name == cx->runtime->atomState.byteLengthAtom) {
rval->setBoolean(false);
return true;
}
JSObject *delegate = DelegateObject(cx, obj);
RootedVarObject delegate(cx, DelegateObject(cx, obj));
if (!delegate)
return false;
return js_DeleteProperty(cx, delegate, name, rval, strict);
return baseops::DeleteProperty(cx, delegate, name, rval, strict);
}
JSBool
ArrayBufferObject::obj_deleteElement(JSContext *cx, JSObject *obj_,
ArrayBufferObject::obj_deleteElement(JSContext *cx, HandleObject obj,
uint32_t index, Value *rval, JSBool strict)
{
RootedVarObject obj(cx, obj_);
JSObject *delegate = DelegateObject(cx, obj);
RootedVarObject delegate(cx, DelegateObject(cx, obj));
if (!delegate)
return false;
return js_DeleteElement(cx, delegate, index, rval, strict);
return baseops::DeleteElement(cx, delegate, index, rval, strict);
}
JSBool
ArrayBufferObject::obj_deleteSpecial(JSContext *cx, JSObject *obj_,
SpecialId sid_, Value *rval, JSBool strict)
ArrayBufferObject::obj_deleteSpecial(JSContext *cx, HandleObject obj,
HandleSpecialId sid, Value *rval, JSBool strict)
{
RootedVarObject obj(cx, obj_);
RootedVar<SpecialId> sid(cx, sid_);
JSObject *delegate = DelegateObject(cx, obj);
RootedVarObject delegate(cx, DelegateObject(cx, obj));
if (!delegate)
return false;
return js_DeleteSpecial(cx, delegate, sid, rval, strict);
return baseops::DeleteSpecial(cx, delegate, sid, rval, strict);
}
JSBool
ArrayBufferObject::obj_enumerate(JSContext *cx, JSObject *obj,
ArrayBufferObject::obj_enumerate(JSContext *cx, HandleObject obj,
JSIterateOp enum_op, Value *statep, jsid *idp)
{
statep->setNull();
@ -780,7 +744,7 @@ ArrayBufferObject::obj_enumerate(JSContext *cx, JSObject *obj,
}
JSType
ArrayBufferObject::obj_typeOf(JSContext *cx, JSObject *obj)
ArrayBufferObject::obj_typeOf(JSContext *cx, HandleObject obj)
{
return JSTYPE_OBJECT;
}
@ -845,59 +809,67 @@ js::IsDataView(JSObject* obj)
* slots data element points to the JSObject representing the ArrayBuffer.
*/
JSBool
TypedArray::prop_getBuffer(JSContext *cx, JSObject *obj, jsid id, Value *vp)
TypedArray::prop_getBuffer(JSContext *cx, HandleObject obj, HandleId id, Value *vp)
{
if (!(obj = getTypedArray(obj))) {
JSObject *tarray = getTypedArray(obj);
if (!tarray) {
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL,
JSMSG_INCOMPATIBLE_PROTO, "TypedArray", "buffer", "object");
return false;
}
JS_SET_RVAL(cx, vp, ObjectValue(*TypedArray::getBuffer(obj)));
JS_SET_RVAL(cx, vp, ObjectValue(*TypedArray::getBuffer(tarray)));
return true;
}
JSBool
TypedArray::prop_getByteOffset(JSContext *cx, JSObject *obj, jsid id, Value *vp)
TypedArray::prop_getByteOffset(JSContext *cx, HandleObject obj, HandleId id, Value *vp)
{
if (!(obj = getTypedArray(obj))) {
JSObject *tarray = getTypedArray(obj);
if (!tarray) {
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL,
JSMSG_INCOMPATIBLE_PROTO, "TypedArray", "byteOffset", "object");
return false;
}
JS_SET_RVAL(cx, vp, Int32Value(TypedArray::getByteOffset(obj)));
JS_SET_RVAL(cx, vp, Int32Value(TypedArray::getByteOffset(tarray)));
return true;
}
JSBool
TypedArray::prop_getByteLength(JSContext *cx, JSObject *obj, jsid id, Value *vp)
TypedArray::prop_getByteLength(JSContext *cx, HandleObject obj, HandleId id, Value *vp)
{
if (!(obj = getTypedArray(obj))) {
JSObject *tarray = getTypedArray(obj);
if (!tarray) {
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL,
JSMSG_INCOMPATIBLE_PROTO, "TypedArray", "byteLength", "object");
return false;
}
JS_SET_RVAL(cx, vp, Int32Value(TypedArray::getByteLength(obj)));
JS_SET_RVAL(cx, vp, Int32Value(TypedArray::getByteLength(tarray)));
return true;
}
JSBool
TypedArray::prop_getLength(JSContext *cx, JSObject *obj, jsid id, Value *vp)
TypedArray::prop_getLength(JSContext *cx, HandleObject obj, HandleId id, Value *vp)
{
if (!(obj = getTypedArray(obj))) {
JSObject *tarray = getTypedArray(obj);
if (!tarray) {
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL,
JSMSG_INCOMPATIBLE_PROTO, "TypedArray", "length", "object");
return false;
}
JS_SET_RVAL(cx, vp, Int32Value(TypedArray::getLength(obj)));
JS_SET_RVAL(cx, vp, Int32Value(TypedArray::getLength(tarray)));
return true;
}
JSBool
TypedArray::obj_lookupGeneric(JSContext *cx, JSObject *obj, jsid id,
TypedArray::obj_lookupGeneric(JSContext *cx, HandleObject obj, HandleId id,
JSObject **objp, JSProperty **propp)
{
JSObject *tarray = getTypedArray(obj);
@ -920,14 +892,14 @@ TypedArray::obj_lookupGeneric(JSContext *cx, JSObject *obj, jsid id,
}
JSBool
TypedArray::obj_lookupProperty(JSContext *cx, JSObject *obj, PropertyName *name,
TypedArray::obj_lookupProperty(JSContext *cx, HandleObject obj, HandlePropertyName name,
JSObject **objp, JSProperty **propp)
{
return obj_lookupGeneric(cx, obj, NameToId(name), objp, propp);
return obj_lookupGeneric(cx, obj, RootedVarId(cx, NameToId(name)), objp, propp);
}
JSBool
TypedArray::obj_lookupElement(JSContext *cx, JSObject *obj, uint32_t index,
TypedArray::obj_lookupElement(JSContext *cx, HandleObject obj, uint32_t index,
JSObject **objp, JSProperty **propp)
{
JSObject *tarray = getTypedArray(obj);
@ -948,14 +920,14 @@ TypedArray::obj_lookupElement(JSContext *cx, JSObject *obj, uint32_t index,
}
JSBool
TypedArray::obj_lookupSpecial(JSContext *cx, JSObject *obj, SpecialId sid,
TypedArray::obj_lookupSpecial(JSContext *cx, HandleObject obj, HandleSpecialId sid,
JSObject **objp, JSProperty **propp)
{
return obj_lookupGeneric(cx, obj, SPECIALID_TO_JSID(sid), objp, propp);
return obj_lookupGeneric(cx, obj, RootedVarId(cx, SPECIALID_TO_JSID(sid)), objp, propp);
}
JSBool
TypedArray::obj_getGenericAttributes(JSContext *cx, JSObject *obj, jsid id, unsigned *attrsp)
TypedArray::obj_getGenericAttributes(JSContext *cx, HandleObject obj, HandleId id, unsigned *attrsp)
{
*attrsp = (JSID_IS_ATOM(id, cx->runtime->atomState.lengthAtom))
? JSPROP_PERMANENT | JSPROP_READONLY
@ -964,48 +936,48 @@ TypedArray::obj_getGenericAttributes(JSContext *cx, JSObject *obj, jsid id, unsi
}
JSBool
TypedArray::obj_getPropertyAttributes(JSContext *cx, JSObject *obj, PropertyName *name, unsigned *attrsp)
TypedArray::obj_getPropertyAttributes(JSContext *cx, HandleObject obj, HandlePropertyName name, unsigned *attrsp)
{
*attrsp = JSPROP_PERMANENT | JSPROP_ENUMERATE;
return true;
}
JSBool
TypedArray::obj_getElementAttributes(JSContext *cx, JSObject *obj, uint32_t index, unsigned *attrsp)
TypedArray::obj_getElementAttributes(JSContext *cx, HandleObject obj, uint32_t index, unsigned *attrsp)
{
*attrsp = JSPROP_PERMANENT | JSPROP_ENUMERATE;
return true;
}
JSBool
TypedArray::obj_getSpecialAttributes(JSContext *cx, JSObject *obj, SpecialId sid, unsigned *attrsp)
TypedArray::obj_getSpecialAttributes(JSContext *cx, HandleObject obj, HandleSpecialId sid, unsigned *attrsp)
{
return obj_getGenericAttributes(cx, obj, SPECIALID_TO_JSID(sid), attrsp);
return obj_getGenericAttributes(cx, obj, RootedVarId(cx, SPECIALID_TO_JSID(sid)), attrsp);
}
JSBool
TypedArray::obj_setGenericAttributes(JSContext *cx, JSObject *obj, jsid id, unsigned *attrsp)
TypedArray::obj_setGenericAttributes(JSContext *cx, HandleObject obj, HandleId id, unsigned *attrsp)
{
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_CANT_SET_ARRAY_ATTRS);
return false;
}
JSBool
TypedArray::obj_setPropertyAttributes(JSContext *cx, JSObject *obj, PropertyName *name, unsigned *attrsp)
TypedArray::obj_setPropertyAttributes(JSContext *cx, HandleObject obj, HandlePropertyName name, unsigned *attrsp)
{
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_CANT_SET_ARRAY_ATTRS);
return false;
}
JSBool
TypedArray::obj_setElementAttributes(JSContext *cx, JSObject *obj, uint32_t index, unsigned *attrsp)
TypedArray::obj_setElementAttributes(JSContext *cx, HandleObject obj, uint32_t index, unsigned *attrsp)
{
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_CANT_SET_ARRAY_ATTRS);
return false;
}
JSBool
TypedArray::obj_setSpecialAttributes(JSContext *cx, JSObject *obj, SpecialId sid, unsigned *attrsp)
TypedArray::obj_setSpecialAttributes(JSContext *cx, HandleObject obj, HandleSpecialId sid, unsigned *attrsp)
{
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_CANT_SET_ARRAY_ATTRS);
return false;
@ -1111,7 +1083,7 @@ class TypedArrayTemplate
}
static JSBool
obj_getProperty(JSContext *cx, JSObject *obj, JSObject *receiver, PropertyName *name,
obj_getProperty(JSContext *cx, HandleObject obj, HandleObject receiver, HandlePropertyName name,
Value *vp)
{
JSObject *tarray = getTypedArray(obj);
@ -1131,7 +1103,7 @@ class TypedArrayTemplate
}
static JSBool
obj_getElement(JSContext *cx, JSObject *obj, JSObject *receiver, uint32_t index, Value *vp)
obj_getElement(JSContext *cx, HandleObject obj, HandleObject receiver, uint32_t index, Value *vp)
{
JSObject *tarray = getTypedArray(obj);
@ -1150,7 +1122,7 @@ class TypedArrayTemplate
}
static JSBool
obj_getSpecial(JSContext *cx, JSObject *obj, JSObject *receiver, SpecialId sid, Value *vp)
obj_getSpecial(JSContext *cx, HandleObject obj, HandleObject receiver, HandleSpecialId sid, Value *vp)
{
JSObject *proto = obj->getProto();
if (!proto) {
@ -1162,7 +1134,7 @@ class TypedArrayTemplate
}
static JSBool
obj_getGeneric(JSContext *cx, JSObject *obj, JSObject *receiver, jsid id, Value *vp)
obj_getGeneric(JSContext *cx, HandleObject obj, HandleObject receiver, HandleId id, Value *vp)
{
Value idval = IdToValue(id);
@ -1172,7 +1144,7 @@ class TypedArrayTemplate
SpecialId sid;
if (ValueIsSpecial(obj, &idval, &sid, cx))
return obj_getSpecial(cx, obj, receiver, sid, vp);
return obj_getSpecial(cx, obj, receiver, RootedVar<SpecialId>(cx, sid), vp);
JSAtom *atom;
if (!js_ValueToAtom(cx, idval, &atom))
@ -1181,11 +1153,11 @@ class TypedArrayTemplate
if (atom->isIndex(&index))
return obj_getElement(cx, obj, receiver, index, vp);
return obj_getProperty(cx, obj, receiver, atom->asPropertyName(), vp);
return obj_getProperty(cx, obj, receiver, RootedVarPropertyName(cx, atom->asPropertyName()), vp);
}
static JSBool
obj_getElementIfPresent(JSContext *cx, JSObject *obj, JSObject *receiver, uint32_t index, Value *vp, bool *present)
obj_getElementIfPresent(JSContext *cx, HandleObject obj, HandleObject receiver, uint32_t index, Value *vp, bool *present)
{
// Fast-path the common case of index < length
JSObject *tarray = getTypedArray(obj);
@ -1271,7 +1243,7 @@ class TypedArrayTemplate
}
static JSBool
obj_setGeneric(JSContext *cx, JSObject *obj, jsid id, Value *vp, JSBool strict)
obj_setGeneric(JSContext *cx, HandleObject obj, HandleId id, Value *vp, JSBool strict)
{
RootedVarObject tarray(cx, getTypedArray(obj));
JS_ASSERT(tarray);
@ -1297,13 +1269,13 @@ class TypedArrayTemplate
}
static JSBool
obj_setProperty(JSContext *cx, JSObject *obj, PropertyName *name, Value *vp, JSBool strict)
obj_setProperty(JSContext *cx, HandleObject obj, HandlePropertyName name, Value *vp, JSBool strict)
{
return obj_setGeneric(cx, obj, NameToId(name), vp, strict);
return obj_setGeneric(cx, obj, RootedVarId(cx, NameToId(name)), vp, strict);
}
static JSBool
obj_setElement(JSContext *cx, JSObject *obj, uint32_t index, Value *vp, JSBool strict)
obj_setElement(JSContext *cx, HandleObject obj, uint32_t index, Value *vp, JSBool strict)
{
RootedVarObject tarray(cx, getTypedArray(obj));
JS_ASSERT(tarray);
@ -1322,13 +1294,13 @@ class TypedArrayTemplate
}
static JSBool
obj_setSpecial(JSContext *cx, JSObject *obj, SpecialId sid, Value *vp, JSBool strict)
obj_setSpecial(JSContext *cx, HandleObject obj, HandleSpecialId sid, Value *vp, JSBool strict)
{
return obj_setGeneric(cx, obj, SPECIALID_TO_JSID(sid), vp, strict);
return obj_setGeneric(cx, obj, RootedVarId(cx, SPECIALID_TO_JSID(sid)), vp, strict);
}
static JSBool
obj_defineGeneric(JSContext *cx, JSObject *obj, jsid id, const Value *v,
obj_defineGeneric(JSContext *cx, HandleObject obj, HandleId id, const Value *v,
PropertyOp getter, StrictPropertyOp setter, unsigned attrs)
{
if (JSID_IS_ATOM(id, cx->runtime->atomState.lengthAtom))
@ -1339,14 +1311,14 @@ class TypedArrayTemplate
}
static JSBool
obj_defineProperty(JSContext *cx, JSObject *obj, PropertyName *name, const Value *v,
obj_defineProperty(JSContext *cx, HandleObject obj, HandlePropertyName name, const Value *v,
PropertyOp getter, StrictPropertyOp setter, unsigned attrs)
{
return obj_defineGeneric(cx, obj, NameToId(name), v, getter, setter, attrs);
return obj_defineGeneric(cx, obj, RootedVarId(cx, NameToId(name)), v, getter, setter, attrs);
}
static JSBool
obj_defineElement(JSContext *cx, JSObject *obj, uint32_t index, const Value *v,
obj_defineElement(JSContext *cx, HandleObject obj, uint32_t index, const Value *v,
PropertyOp getter, StrictPropertyOp setter, unsigned attrs)
{
Value tmp = *v;
@ -1354,14 +1326,14 @@ class TypedArrayTemplate
}
static JSBool
obj_defineSpecial(JSContext *cx, JSObject *obj, SpecialId sid, const Value *v,
obj_defineSpecial(JSContext *cx, HandleObject obj, HandleSpecialId sid, const Value *v,
PropertyOp getter, StrictPropertyOp setter, unsigned attrs)
{
return obj_defineGeneric(cx, obj, SPECIALID_TO_JSID(sid), v, getter, setter, attrs);
return obj_defineGeneric(cx, obj, RootedVarId(cx, SPECIALID_TO_JSID(sid)), v, getter, setter, attrs);
}
static JSBool
obj_deleteProperty(JSContext *cx, JSObject *obj, PropertyName *name, Value *rval, JSBool strict)
obj_deleteProperty(JSContext *cx, HandleObject obj, HandlePropertyName name, Value *rval, JSBool strict)
{
if (name == cx->runtime->atomState.lengthAtom) {
rval->setBoolean(false);
@ -1373,7 +1345,7 @@ class TypedArrayTemplate
}
static JSBool
obj_deleteElement(JSContext *cx, JSObject *obj, uint32_t index, Value *rval, JSBool strict)
obj_deleteElement(JSContext *cx, HandleObject obj, uint32_t index, Value *rval, JSBool strict)
{
JSObject *tarray = getTypedArray(obj);
JS_ASSERT(tarray);
@ -1388,14 +1360,14 @@ class TypedArrayTemplate
}
static JSBool
obj_deleteSpecial(JSContext *cx, JSObject *obj, SpecialId sid, Value *rval, JSBool strict)
obj_deleteSpecial(JSContext *cx, HandleObject obj, HandleSpecialId sid, Value *rval, JSBool strict)
{
rval->setBoolean(true);
return true;
}
static JSBool
obj_enumerate(JSContext *cx, JSObject *obj, JSIterateOp enum_op,
obj_enumerate(JSContext *cx, HandleObject obj, JSIterateOp enum_op,
Value *statep, jsid *idp)
{
JSObject *tarray = getTypedArray(obj);
@ -1444,7 +1416,7 @@ class TypedArrayTemplate
}
static JSType
obj_typeOf(JSContext *cx, JSObject *obj)
obj_typeOf(JSContext *cx, HandleObject obj)
{
return JSTYPE_OBJECT;
}
@ -2285,7 +2257,7 @@ DataViewObject::construct(JSContext *cx, JSObject *bufobj, const CallArgs &args,
}
JSBool
DataViewObject::prop_getBuffer(JSContext *cx, JSObject *obj, jsid id, Value *vp)
DataViewObject::prop_getBuffer(JSContext *cx, HandleObject obj, HandleId id, Value *vp)
{
if (!obj->isDataView()) {
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL,
@ -2302,7 +2274,7 @@ DataViewObject::prop_getBuffer(JSContext *cx, JSObject *obj, jsid id, Value *vp)
}
JSBool
DataViewObject::prop_getByteOffset(JSContext *cx, JSObject *obj, jsid id, Value *vp)
DataViewObject::prop_getByteOffset(JSContext *cx, HandleObject obj, HandleId id, Value *vp)
{
if (!obj->isDataView()) {
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL,
@ -2360,7 +2332,7 @@ DataViewObject::class_constructor(JSContext *cx, unsigned argc, Value *vp)
}
JSBool
DataViewObject::prop_getByteLength(JSContext *cx, JSObject *obj, jsid id, Value *vp)
DataViewObject::prop_getByteLength(JSContext *cx, HandleObject obj, HandleId id, Value *vp)
{
if (!obj->isDataView()) {
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL,

Просмотреть файл

@ -65,7 +65,7 @@ class ArrayBufferObject : public JSObject
static JSPropertySpec jsprops[];
static JSFunctionSpec jsfuncs[];
static JSBool prop_getByteLength(JSContext *cx, JSObject *obj, jsid id, Value *vp);
static JSBool prop_getByteLength(JSContext *cx, HandleObject obj, HandleId id, Value *vp);
static JSBool fun_slice(JSContext *cx, unsigned argc, Value *vp);
@ -80,87 +80,87 @@ class ArrayBufferObject : public JSObject
obj_trace(JSTracer *trc, JSObject *obj);
static JSBool
obj_lookupGeneric(JSContext *cx, JSObject *obj, jsid id,
obj_lookupGeneric(JSContext *cx, HandleObject obj, HandleId id,
JSObject **objp, JSProperty **propp);
static JSBool
obj_lookupProperty(JSContext *cx, JSObject *obj, PropertyName *name,
obj_lookupProperty(JSContext *cx, HandleObject obj, HandlePropertyName name,
JSObject **objp, JSProperty **propp);
static JSBool
obj_lookupElement(JSContext *cx, JSObject *obj, uint32_t index,
obj_lookupElement(JSContext *cx, HandleObject obj, uint32_t index,
JSObject **objp, JSProperty **propp);
static JSBool
obj_lookupSpecial(JSContext *cx, JSObject *obj, SpecialId sid, JSObject **objp,
obj_lookupSpecial(JSContext *cx, HandleObject obj, HandleSpecialId sid, JSObject **objp,
JSProperty **propp);
static JSBool
obj_defineGeneric(JSContext *cx, JSObject *obj, jsid id, const Value *v,
obj_defineGeneric(JSContext *cx, HandleObject obj, HandleId id, const Value *v,
PropertyOp getter, StrictPropertyOp setter, unsigned attrs);
static JSBool
obj_defineProperty(JSContext *cx, JSObject *obj, PropertyName *name, const Value *v,
obj_defineProperty(JSContext *cx, HandleObject obj, HandlePropertyName name, const Value *v,
PropertyOp getter, StrictPropertyOp setter, unsigned attrs);
static JSBool
obj_defineElement(JSContext *cx, JSObject *obj, uint32_t index, const Value *v,
obj_defineElement(JSContext *cx, HandleObject obj, uint32_t index, const Value *v,
PropertyOp getter, StrictPropertyOp setter, unsigned attrs);
static JSBool
obj_defineSpecial(JSContext *cx, JSObject *obj, SpecialId sid, const Value *v,
obj_defineSpecial(JSContext *cx, HandleObject obj, HandleSpecialId sid, const Value *v,
PropertyOp getter, StrictPropertyOp setter, unsigned attrs);
static JSBool
obj_getGeneric(JSContext *cx, JSObject *obj, JSObject *receiver, jsid id, Value *vp);
obj_getGeneric(JSContext *cx, HandleObject obj, HandleObject receiver, HandleId id, Value *vp);
static JSBool
obj_getProperty(JSContext *cx, JSObject *obj, JSObject *receiver, PropertyName *name,
obj_getProperty(JSContext *cx, HandleObject obj, HandleObject receiver, HandlePropertyName name,
Value *vp);
static JSBool
obj_getElement(JSContext *cx, JSObject *obj, JSObject *receiver, uint32_t index, Value *vp);
obj_getElement(JSContext *cx, HandleObject obj, HandleObject receiver, uint32_t index, Value *vp);
static JSBool
obj_getElementIfPresent(JSContext *cx, JSObject *obj, JSObject *receiver, uint32_t index,
obj_getElementIfPresent(JSContext *cx, HandleObject obj, HandleObject receiver, uint32_t index,
Value *vp, bool *present);
static JSBool
obj_getSpecial(JSContext *cx, JSObject *obj, JSObject *receiver, SpecialId sid, Value *vp);
obj_getSpecial(JSContext *cx, HandleObject obj, HandleObject receiver, HandleSpecialId sid, Value *vp);
static JSBool
obj_setGeneric(JSContext *cx, JSObject *obj, jsid id, Value *vp, JSBool strict);
obj_setGeneric(JSContext *cx, HandleObject obj, HandleId id, Value *vp, JSBool strict);
static JSBool
obj_setProperty(JSContext *cx, JSObject *obj, PropertyName *name, Value *vp, JSBool strict);
obj_setProperty(JSContext *cx, HandleObject obj, HandlePropertyName name, Value *vp, JSBool strict);
static JSBool
obj_setElement(JSContext *cx, JSObject *obj, uint32_t index, Value *vp, JSBool strict);
obj_setElement(JSContext *cx, HandleObject obj, uint32_t index, Value *vp, JSBool strict);
static JSBool
obj_setSpecial(JSContext *cx, JSObject *obj, SpecialId sid, Value *vp, JSBool strict);
obj_setSpecial(JSContext *cx, HandleObject obj, HandleSpecialId sid, Value *vp, JSBool strict);
static JSBool
obj_getGenericAttributes(JSContext *cx, JSObject *obj, jsid id, unsigned *attrsp);
obj_getGenericAttributes(JSContext *cx, HandleObject obj, HandleId id, unsigned *attrsp);
static JSBool
obj_getPropertyAttributes(JSContext *cx, JSObject *obj, PropertyName *name, unsigned *attrsp);
obj_getPropertyAttributes(JSContext *cx, HandleObject obj, HandlePropertyName name, unsigned *attrsp);
static JSBool
obj_getElementAttributes(JSContext *cx, JSObject *obj, uint32_t index, unsigned *attrsp);
obj_getElementAttributes(JSContext *cx, HandleObject obj, uint32_t index, unsigned *attrsp);
static JSBool
obj_getSpecialAttributes(JSContext *cx, JSObject *obj, SpecialId sid, unsigned *attrsp);
obj_getSpecialAttributes(JSContext *cx, HandleObject obj, HandleSpecialId sid, unsigned *attrsp);
static JSBool
obj_setGenericAttributes(JSContext *cx, JSObject *obj, jsid id, unsigned *attrsp);
obj_setGenericAttributes(JSContext *cx, HandleObject obj, HandleId id, unsigned *attrsp);
static JSBool
obj_setPropertyAttributes(JSContext *cx, JSObject *obj, PropertyName *name, unsigned *attrsp);
obj_setPropertyAttributes(JSContext *cx, HandleObject obj, HandlePropertyName name, unsigned *attrsp);
static JSBool
obj_setElementAttributes(JSContext *cx, JSObject *obj, uint32_t index, unsigned *attrsp);
obj_setElementAttributes(JSContext *cx, HandleObject obj, uint32_t index, unsigned *attrsp);
static JSBool
obj_setSpecialAttributes(JSContext *cx, JSObject *obj, SpecialId sid, unsigned *attrsp);
obj_setSpecialAttributes(JSContext *cx, HandleObject obj, HandleSpecialId sid, unsigned *attrsp);
static JSBool
obj_deleteProperty(JSContext *cx, JSObject *obj, PropertyName *name, Value *rval, JSBool strict);
obj_deleteProperty(JSContext *cx, HandleObject obj, HandlePropertyName name, Value *rval, JSBool strict);
static JSBool
obj_deleteElement(JSContext *cx, JSObject *obj, uint32_t index, Value *rval, JSBool strict);
obj_deleteElement(JSContext *cx, HandleObject obj, uint32_t index, Value *rval, JSBool strict);
static JSBool
obj_deleteSpecial(JSContext *cx, JSObject *obj, SpecialId sid, Value *rval, JSBool strict);
obj_deleteSpecial(JSContext *cx, HandleObject obj, HandleSpecialId sid, Value *rval, JSBool strict);
static JSBool
obj_enumerate(JSContext *cx, JSObject *obj, JSIterateOp enum_op,
obj_enumerate(JSContext *cx, HandleObject obj, JSIterateOp enum_op,
Value *statep, jsid *idp);
static JSType
obj_typeOf(JSContext *cx, JSObject *obj);
obj_typeOf(JSContext *cx, HandleObject obj);
bool
allocateSlots(JSContext *cx, uint32_t size, uint8_t *contents = NULL);
@ -224,29 +224,29 @@ struct TypedArray {
static JSPropertySpec jsprops[];
static JSBool prop_getBuffer(JSContext *cx, JSObject *obj, jsid id, Value *vp);
static JSBool prop_getByteOffset(JSContext *cx, JSObject *obj, jsid id, Value *vp);
static JSBool prop_getByteLength(JSContext *cx, JSObject *obj, jsid id, Value *vp);
static JSBool prop_getLength(JSContext *cx, JSObject *obj, jsid id, Value *vp);
static JSBool prop_getBuffer(JSContext *cx, HandleObject obj, HandleId id, Value *vp);
static JSBool prop_getByteOffset(JSContext *cx, HandleObject obj, HandleId id, Value *vp);
static JSBool prop_getByteLength(JSContext *cx, HandleObject obj, HandleId id, Value *vp);
static JSBool prop_getLength(JSContext *cx, HandleObject obj, HandleId id, Value *vp);
static JSBool obj_lookupGeneric(JSContext *cx, JSObject *obj, jsid id,
static JSBool obj_lookupGeneric(JSContext *cx, HandleObject obj, HandleId id,
JSObject **objp, JSProperty **propp);
static JSBool obj_lookupProperty(JSContext *cx, JSObject *obj, PropertyName *name,
static JSBool obj_lookupProperty(JSContext *cx, HandleObject obj, HandlePropertyName name,
JSObject **objp, JSProperty **propp);
static JSBool obj_lookupElement(JSContext *cx, JSObject *obj, uint32_t index,
static JSBool obj_lookupElement(JSContext *cx, HandleObject obj, uint32_t index,
JSObject **objp, JSProperty **propp);
static JSBool obj_lookupSpecial(JSContext *cx, JSObject *obj, SpecialId sid,
static JSBool obj_lookupSpecial(JSContext *cx, HandleObject obj, HandleSpecialId sid,
JSObject **objp, JSProperty **propp);
static JSBool obj_getGenericAttributes(JSContext *cx, JSObject *obj, jsid id, unsigned *attrsp);
static JSBool obj_getPropertyAttributes(JSContext *cx, JSObject *obj, PropertyName *name, unsigned *attrsp);
static JSBool obj_getElementAttributes(JSContext *cx, JSObject *obj, uint32_t index, unsigned *attrsp);
static JSBool obj_getSpecialAttributes(JSContext *cx, JSObject *obj, SpecialId sid, unsigned *attrsp);
static JSBool obj_getGenericAttributes(JSContext *cx, HandleObject obj, HandleId id, unsigned *attrsp);
static JSBool obj_getPropertyAttributes(JSContext *cx, HandleObject obj, HandlePropertyName name, unsigned *attrsp);
static JSBool obj_getElementAttributes(JSContext *cx, HandleObject obj, uint32_t index, unsigned *attrsp);
static JSBool obj_getSpecialAttributes(JSContext *cx, HandleObject obj, HandleSpecialId sid, unsigned *attrsp);
static JSBool obj_setGenericAttributes(JSContext *cx, JSObject *obj, jsid id, unsigned *attrsp);
static JSBool obj_setPropertyAttributes(JSContext *cx, JSObject *obj, PropertyName *name, unsigned *attrsp);
static JSBool obj_setElementAttributes(JSContext *cx, JSObject *obj, uint32_t index, unsigned *attrsp);
static JSBool obj_setSpecialAttributes(JSContext *cx, JSObject *obj, SpecialId sid, unsigned *attrsp);
static JSBool obj_setGenericAttributes(JSContext *cx, HandleObject obj, HandleId id, unsigned *attrsp);
static JSBool obj_setPropertyAttributes(JSContext *cx, HandleObject obj, HandlePropertyName name, unsigned *attrsp);
static JSBool obj_setElementAttributes(JSContext *cx, HandleObject obj, uint32_t index, unsigned *attrsp);
static JSBool obj_setSpecialAttributes(JSContext *cx, HandleObject obj, HandleSpecialId sid, unsigned *attrsp);
static uint32_t getLength(JSObject *obj);
static uint32_t getByteOffset(JSObject *obj);
@ -325,9 +325,9 @@ class DataViewObject : public JSObject
public:
static const size_t RESERVED_SLOTS = 3;
static JSBool prop_getBuffer(JSContext *cx, JSObject *obj, jsid id, Value *vp);
static JSBool prop_getByteOffset(JSContext *cx, JSObject *obj, jsid id, Value *vp);
static JSBool prop_getByteLength(JSContext *cx, JSObject *obj, jsid id, Value *vp);
static JSBool prop_getBuffer(JSContext *cx, HandleObject obj, HandleId id, Value *vp);
static JSBool prop_getByteOffset(JSContext *cx, HandleObject obj, HandleId id, Value *vp);
static JSBool prop_getByteLength(JSContext *cx, HandleObject obj, HandleId id, Value *vp);
static JSBool class_constructor(JSContext *cx, unsigned argc, Value *vp);
static JSBool constructWithProto(JSContext *cx, unsigned argc, Value *vp);

Просмотреть файл

@ -308,7 +308,7 @@ JS_NondeterministicGetWeakMapKeys(JSContext *cx, JSObject *obj, JSObject **ret)
*ret = NULL;
return true;
}
JSObject *arr = NewDenseEmptyArray(cx);
RootedVarObject arr(cx, NewDenseEmptyArray(cx));
if (!arr)
return false;
ObjectValueMap *map = GetObjectMap(obj);

Просмотреть файл

@ -214,14 +214,14 @@ bool
Wrapper::get(JSContext *cx, JSObject *wrapper, JSObject *receiver, jsid id, Value *vp)
{
vp->setUndefined(); // default result if we refuse to perform this action
GET(wrappedObject(wrapper)->getGeneric(cx, receiver, id, vp));
GET(wrappedObject(wrapper)->getGeneric(cx, RootedVarObject(cx, receiver), RootedVarId(cx, id), vp));
}
bool
Wrapper::set(JSContext *cx, JSObject *wrapper, JSObject *receiver, jsid id, bool strict,
Value *vp)
{
SET(wrappedObject(wrapper)->setGeneric(cx, id, vp, strict));
SET(wrappedObject(wrapper)->setGeneric(cx, RootedVarId(cx, id), vp, strict));
}
bool

Просмотреть файл

@ -193,7 +193,7 @@ NewBuiltinClassInstanceXML(JSContext *cx, Class *clasp)
#define DEFINE_GETTER(name,code) \
static JSBool \
name(JSContext *cx, JSObject *obj, jsid id, jsval *vp) \
name(JSContext *cx, HandleObject obj, HandleId id, jsval *vp) \
{ \
code; \
return true; \
@ -208,7 +208,7 @@ DEFINE_GETTER(NameURI_getter,
if (obj->getClass() == &NamespaceClass) *vp = obj->getNameURIVal())
static JSBool
namespace_equality(JSContext *cx, JSObject *obj, const Value *v, JSBool *bp)
namespace_equality(JSContext *cx, HandleObject obj, const Value *v, JSBool *bp)
{
JSObject *obj2;
@ -323,7 +323,7 @@ qname_identity(JSObject *qna, const JSObject *qnb)
}
static JSBool
qname_equality(JSContext *cx, JSObject *qn, const Value *v, JSBool *bp)
qname_equality(JSContext *cx, HandleObject qn, const Value *v, JSBool *bp)
{
JSObject *obj2;
@ -3764,16 +3764,13 @@ GetNamedProperty(JSContext *cx, JSXML *xml, JSObject* nameqn, JSXML *list)
/* ECMA-357 9.1.1.1 XML [[Get]] and 9.2.1.1 XMLList [[Get]]. */
static JSBool
GetProperty(JSContext *cx, JSObject *obj_, jsid id_, jsval *vp)
GetProperty(JSContext *cx, HandleObject obj, HandleId id, jsval *vp)
{
JSXML *xml, *list, *kid;
uint32_t index;
JSObject *kidobj, *listobj;
JSObject *nameqn;
RootedVarObject obj(cx, obj_);
RootedVarId id(cx, id_);
if (!obj->isXML())
return true;
xml = (JSXML *) obj->getPrivate();
@ -3882,20 +3879,19 @@ ResolveValue(JSContext *cx, JSXML *list, JSXML **result);
/* ECMA-357 9.1.1.2 XML [[Put]] and 9.2.1.2 XMLList [[Put]]. */
static JSBool
PutProperty(JSContext *cx, JSObject *obj_, jsid id_, JSBool strict, jsval *vp)
PutProperty(JSContext *cx, HandleObject obj_, HandleId id_, JSBool strict, jsval *vp)
{
JSBool ok, primitiveAssign;
enum { OBJ_ROOT, ID_ROOT, VAL_ROOT };
JSXML *xml, *vxml, *rxml, *kid, *attr, *parent, *copy, *kid2, *match;
JSObject *vobj, *nameobj, *attrobj, *kidobj, *copyobj;
JSObject *vobj, *nameobj, *attrobj, *copyobj;
JSObject *targetprop, *nameqn, *attrqn;
uint32_t index, i, j, k, n, q, matchIndex;
jsval attrval, nsval;
jsid funid;
JSObject *ns;
RootedVarObject obj(cx, obj_);
RootedVarId id(cx, id_);
RootedVarObject obj(cx, obj_), kidobj(cx);
RootedVarId id(cx, id_), funid(cx);
if (!obj->isXML())
return JS_TRUE;
@ -3999,7 +3995,7 @@ PutProperty(JSContext *cx, JSObject *obj_, jsid id_, JSBool strict, jsval *vp)
* Note that rxml can't be null here, because target
* and targetprop are non-null.
*/
ok = GetProperty(cx, rxml->object, id, &attrval);
ok = GetProperty(cx, RootedVarObject(cx, rxml->object), id, &attrval);
if (!ok)
goto out;
if (JSVAL_IS_PRIMITIVE(attrval)) /* no such attribute */
@ -4222,11 +4218,11 @@ PutProperty(JSContext *cx, JSObject *obj_, jsid id_, JSBool strict, jsval *vp)
/*
* ECMA-357 9.2.1.2/9.1.1.2 qname case.
*/
nameqn = ToXMLName(cx, IdToJsval(id), &funid);
nameqn = ToXMLName(cx, IdToJsval(id), funid.address());
if (!nameqn)
goto bad;
if (!JSID_IS_VOID(funid)) {
ok = js_SetPropertyHelper(cx, obj, funid, 0, vp, false);
ok = baseops::SetPropertyHelper(cx, obj, funid, 0, vp, false);
goto out;
}
nameobj = nameqn;
@ -4563,7 +4559,7 @@ ResolveValue(JSContext *cx, JSXML *list, JSXML **result)
return JS_FALSE;
RootedVarId id(cx, OBJECT_TO_JSID(targetprop));
if (!GetProperty(cx, base->object, id, &tv))
if (!GetProperty(cx, RootedVarObject(cx, base->object), id, &tv))
return JS_FALSE;
target = (JSXML *) JSVAL_TO_OBJECT(tv)->getPrivate();
@ -4573,9 +4569,9 @@ ResolveValue(JSContext *cx, JSXML *list, JSXML **result)
return JS_TRUE;
}
tv = STRING_TO_JSVAL(cx->runtime->emptyString);
if (!PutProperty(cx, base->object, id, false, &tv))
if (!PutProperty(cx, RootedVarObject(cx, base->object), id, false, &tv))
return JS_FALSE;
if (!GetProperty(cx, base->object, id, &tv))
if (!GetProperty(cx, RootedVarObject(cx, base->object), id, &tv))
return JS_FALSE;
target = (JSXML *) JSVAL_TO_OBJECT(tv)->getPrivate();
}
@ -4637,7 +4633,7 @@ static JSBool
HasSimpleContent(JSXML *xml);
static JSBool
HasFunctionProperty(JSContext *cx, JSObject *obj, jsid funid, JSBool *found)
HasFunctionProperty(JSContext *cx, JSObject *obj, jsid funid_, JSBool *found)
{
JSObject *pobj;
JSProperty *prop;
@ -4645,7 +4641,9 @@ HasFunctionProperty(JSContext *cx, JSObject *obj, jsid funid, JSBool *found)
JS_ASSERT(obj->getClass() == &XMLClass);
if (!js_LookupProperty(cx, obj, funid, &pobj, &prop))
RootedVarId funid(cx, funid_);
if (!baseops::LookupProperty(cx, RootedVarObject(cx, obj), funid, &pobj, &prop))
return false;
if (!prop) {
xml = (JSXML *) obj->getPrivate();
@ -4654,11 +4652,11 @@ HasFunctionProperty(JSContext *cx, JSObject *obj, jsid funid, JSBool *found)
* Search in String.prototype to set found whenever
* GetXMLFunction returns existing function.
*/
JSObject *proto = obj->global().getOrCreateStringPrototype(cx);
RootedVarObject proto(cx, obj->global().getOrCreateStringPrototype(cx));
if (!proto)
return false;
if (!js_LookupProperty(cx, proto, funid, &pobj, &prop))
if (!baseops::LookupProperty(cx, proto, funid, &pobj, &prop))
return false;
}
}
@ -4747,23 +4745,24 @@ HasProperty(JSContext *cx, JSObject *obj, jsval id, JSBool *found)
* For a proper solution see bug 355257.
*/
static JSBool
xml_lookupGeneric(JSContext *cx, JSObject *obj, jsid id, JSObject **objp, JSProperty **propp)
xml_lookupGeneric(JSContext *cx, HandleObject obj, HandleId id, JSObject **objp, JSProperty **propp)
{
JSBool found;
JSXML *xml;
uint32_t i;
JSObject *qn;
jsid funid;
RootedVarId funid(cx);
xml = (JSXML *) obj->getPrivate();
if (js_IdIsIndex(id, &i)) {
found = HasIndexedProperty(xml, i);
} else {
qn = ToXMLName(cx, IdToJsval(id), &funid);
qn = ToXMLName(cx, IdToJsval(id), funid.address());
if (!qn)
return JS_FALSE;
if (!JSID_IS_VOID(funid))
return js_LookupProperty(cx, obj, funid, objp, propp);
return baseops::LookupProperty(cx, obj, funid, objp, propp);
found = HasNamedProperty(xml, qn);
}
if (!found) {
@ -4771,7 +4770,7 @@ xml_lookupGeneric(JSContext *cx, JSObject *obj, jsid id, JSObject **objp, JSProp
*propp = NULL;
} else {
const Shape *shape =
js_AddNativeProperty(cx, RootedVarObject(cx, obj), id, GetProperty, PutProperty,
js_AddNativeProperty(cx, obj, id, GetProperty, PutProperty,
SHAPE_INVALID_SLOT, JSPROP_ENUMERATE,
0, 0);
if (!shape)
@ -4784,14 +4783,14 @@ xml_lookupGeneric(JSContext *cx, JSObject *obj, jsid id, JSObject **objp, JSProp
}
static JSBool
xml_lookupProperty(JSContext *cx, JSObject *obj, PropertyName *name, JSObject **objp,
xml_lookupProperty(JSContext *cx, HandleObject obj, HandlePropertyName name, JSObject **objp,
JSProperty **propp)
{
return xml_lookupGeneric(cx, obj, NameToId(name), objp, propp);
return xml_lookupGeneric(cx, obj, RootedVarId(cx, NameToId(name)), objp, propp);
}
static JSBool
xml_lookupElement(JSContext *cx, JSObject *obj, uint32_t index, JSObject **objp,
xml_lookupElement(JSContext *cx, HandleObject obj, uint32_t index, JSObject **objp,
JSProperty **propp)
{
JSXML *xml = reinterpret_cast<JSXML *>(obj->getPrivate());
@ -4818,19 +4817,19 @@ xml_lookupElement(JSContext *cx, JSObject *obj, uint32_t index, JSObject **objp,
}
static JSBool
xml_lookupSpecial(JSContext *cx, JSObject *obj, SpecialId sid, JSObject **objp, JSProperty **propp)
xml_lookupSpecial(JSContext *cx, HandleObject obj, HandleSpecialId sid, JSObject **objp, JSProperty **propp)
{
return xml_lookupGeneric(cx, obj, SPECIALID_TO_JSID(sid), objp, propp);
return xml_lookupGeneric(cx, obj, RootedVarId(cx, SPECIALID_TO_JSID(sid)), objp, propp);
}
static JSBool
xml_defineGeneric(JSContext *cx, JSObject *obj, jsid id, const Value *v,
xml_defineGeneric(JSContext *cx, HandleObject obj, HandleId id, const Value *v,
PropertyOp getter, StrictPropertyOp setter, unsigned attrs)
{
if (IsFunctionObject(*v) || getter || setter ||
(attrs & JSPROP_ENUMERATE) == 0 ||
(attrs & (JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_SHARED))) {
return js_DefineProperty(cx, obj, id, v, getter, setter, attrs);
return baseops::DefineProperty(cx, obj, id, v, getter, setter, attrs);
}
jsval tmp = *v;
@ -4838,31 +4837,31 @@ xml_defineGeneric(JSContext *cx, JSObject *obj, jsid id, const Value *v,
}
static JSBool
xml_defineProperty(JSContext *cx, JSObject *obj, PropertyName *name, const Value *v,
xml_defineProperty(JSContext *cx, HandleObject obj, HandlePropertyName name, const Value *v,
PropertyOp getter, StrictPropertyOp setter, unsigned attrs)
{
return xml_defineGeneric(cx, obj, NameToId(name), v, getter, setter, attrs);
return xml_defineGeneric(cx, obj, RootedVarId(cx, NameToId(name)), v, getter, setter, attrs);
}
static JSBool
xml_defineElement(JSContext *cx, JSObject *obj, uint32_t index, const Value *v,
xml_defineElement(JSContext *cx, HandleObject obj, uint32_t index, const Value *v,
PropertyOp getter, StrictPropertyOp setter, unsigned attrs)
{
jsid id;
if (!IndexToId(cx, index, &id))
RootedVarId id(cx);
if (!IndexToId(cx, index, id.address()))
return false;
return xml_defineGeneric(cx, obj, id, v, getter, setter, attrs);
}
static JSBool
xml_defineSpecial(JSContext *cx, JSObject *obj, SpecialId sid, const Value *v,
xml_defineSpecial(JSContext *cx, HandleObject obj, HandleSpecialId sid, const Value *v,
PropertyOp getter, StrictPropertyOp setter, unsigned attrs)
{
return xml_defineGeneric(cx, obj, SPECIALID_TO_JSID(sid), v, getter, setter, attrs);
return xml_defineGeneric(cx, obj, RootedVarId(cx, SPECIALID_TO_JSID(sid)), v, getter, setter, attrs);
}
static JSBool
xml_getGeneric(JSContext *cx, JSObject *obj, JSObject *receiver, jsid id, Value *vp)
xml_getGeneric(JSContext *cx, HandleObject obj, HandleObject receiver, HandleId id, Value *vp)
{
if (JSID_IS_DEFAULT_XML_NAMESPACE(id)) {
vp->setUndefined();
@ -4873,55 +4872,55 @@ xml_getGeneric(JSContext *cx, JSObject *obj, JSObject *receiver, jsid id, Value
}
static JSBool
xml_getProperty(JSContext *cx, JSObject *obj, JSObject *receiver, PropertyName *name, Value *vp)
xml_getProperty(JSContext *cx, HandleObject obj, HandleObject receiver, HandlePropertyName name, Value *vp)
{
return xml_getGeneric(cx, obj, receiver, NameToId(name), vp);
return xml_getGeneric(cx, obj, receiver, RootedVarId(cx, NameToId(name)), vp);
}
static JSBool
xml_getElement(JSContext *cx, JSObject *obj, JSObject *receiver, uint32_t index, Value *vp)
xml_getElement(JSContext *cx, HandleObject obj, HandleObject receiver, uint32_t index, Value *vp)
{
jsid id;
if (!IndexToId(cx, index, &id))
RootedVarId id(cx);
if (!IndexToId(cx, index, id.address()))
return false;
return xml_getGeneric(cx, obj, receiver, id, vp);
}
static JSBool
xml_getSpecial(JSContext *cx, JSObject *obj, JSObject *receiver, SpecialId sid, Value *vp)
xml_getSpecial(JSContext *cx, HandleObject obj, HandleObject receiver, HandleSpecialId sid, Value *vp)
{
return xml_getGeneric(cx, obj, receiver, SPECIALID_TO_JSID(sid), vp);
return xml_getGeneric(cx, obj, receiver, RootedVarId(cx, SPECIALID_TO_JSID(sid)), vp);
}
static JSBool
xml_setGeneric(JSContext *cx, JSObject *obj, jsid id, Value *vp, JSBool strict)
xml_setGeneric(JSContext *cx, HandleObject obj, HandleId id, Value *vp, JSBool strict)
{
return PutProperty(cx, obj, id, strict, vp);
}
static JSBool
xml_setProperty(JSContext *cx, JSObject *obj, PropertyName *name, Value *vp, JSBool strict)
xml_setProperty(JSContext *cx, HandleObject obj, HandlePropertyName name, Value *vp, JSBool strict)
{
return xml_setGeneric(cx, obj, NameToId(name), vp, strict);
return xml_setGeneric(cx, obj, RootedVarId(cx, NameToId(name)), vp, strict);
}
static JSBool
xml_setElement(JSContext *cx, JSObject *obj, uint32_t index, Value *vp, JSBool strict)
xml_setElement(JSContext *cx, HandleObject obj, uint32_t index, Value *vp, JSBool strict)
{
jsid id;
if (!IndexToId(cx, index, &id))
RootedVarId id(cx);
if (!IndexToId(cx, index, id.address()))
return false;
return xml_setGeneric(cx, obj, id, vp, strict);
}
static JSBool
xml_setSpecial(JSContext *cx, JSObject *obj, SpecialId sid, Value *vp, JSBool strict)
xml_setSpecial(JSContext *cx, HandleObject obj, HandleSpecialId sid, Value *vp, JSBool strict)
{
return xml_setGeneric(cx, obj, SPECIALID_TO_JSID(sid), vp, strict);
return xml_setGeneric(cx, obj, RootedVarId(cx, SPECIALID_TO_JSID(sid)), vp, strict);
}
static JSBool
xml_getGenericAttributes(JSContext *cx, JSObject *obj, jsid id, unsigned *attrsp)
xml_getGenericAttributes(JSContext *cx, HandleObject obj, HandleId id, unsigned *attrsp)
{
JSBool found;
if (!HasProperty(cx, obj, IdToJsval(id), &found))
@ -4932,28 +4931,28 @@ xml_getGenericAttributes(JSContext *cx, JSObject *obj, jsid id, unsigned *attrsp
}
static JSBool
xml_getPropertyAttributes(JSContext *cx, JSObject *obj, PropertyName *name, unsigned *attrsp)
xml_getPropertyAttributes(JSContext *cx, HandleObject obj, HandlePropertyName name, unsigned *attrsp)
{
return xml_getGenericAttributes(cx, obj, NameToId(name), attrsp);
return xml_getGenericAttributes(cx, obj, RootedVarId(cx, NameToId(name)), attrsp);
}
static JSBool
xml_getElementAttributes(JSContext *cx, JSObject *obj, uint32_t index, unsigned *attrsp)
xml_getElementAttributes(JSContext *cx, HandleObject obj, uint32_t index, unsigned *attrsp)
{
jsid id;
if (!IndexToId(cx, index, &id))
RootedVarId id(cx);
if (!IndexToId(cx, index, id.address()))
return false;
return xml_getGenericAttributes(cx, obj, id, attrsp);
}
static JSBool
xml_getSpecialAttributes(JSContext *cx, JSObject *obj, SpecialId sid, unsigned *attrsp)
xml_getSpecialAttributes(JSContext *cx, HandleObject obj, HandleSpecialId sid, unsigned *attrsp)
{
return xml_getGenericAttributes(cx, obj, SPECIALID_TO_JSID(sid), attrsp);
return xml_getGenericAttributes(cx, obj, RootedVarId(cx, SPECIALID_TO_JSID(sid)), attrsp);
}
static JSBool
xml_setGenericAttributes(JSContext *cx, JSObject *obj, jsid id, unsigned *attrsp)
xml_setGenericAttributes(JSContext *cx, HandleObject obj, HandleId id, unsigned *attrsp)
{
JSBool found;
if (!HasProperty(cx, obj, IdToJsval(id), &found))
@ -4968,32 +4967,32 @@ xml_setGenericAttributes(JSContext *cx, JSObject *obj, jsid id, unsigned *attrsp
}
static JSBool
xml_setPropertyAttributes(JSContext *cx, JSObject *obj, PropertyName *name, unsigned *attrsp)
xml_setPropertyAttributes(JSContext *cx, HandleObject obj, HandlePropertyName name, unsigned *attrsp)
{
return xml_setGenericAttributes(cx, obj, NameToId(name), attrsp);
return xml_setGenericAttributes(cx, obj, RootedVarId(cx, NameToId(name)), attrsp);
}
static JSBool
xml_setElementAttributes(JSContext *cx, JSObject *obj, uint32_t index, unsigned *attrsp)
xml_setElementAttributes(JSContext *cx, HandleObject obj, uint32_t index, unsigned *attrsp)
{
jsid id;
if (!IndexToId(cx, index, &id))
RootedVarId id(cx);
if (!IndexToId(cx, index, id.address()))
return false;
return xml_setGenericAttributes(cx, obj, id, attrsp);
}
static JSBool
xml_setSpecialAttributes(JSContext *cx, JSObject *obj, SpecialId sid, unsigned *attrsp)
xml_setSpecialAttributes(JSContext *cx, HandleObject obj, HandleSpecialId sid, unsigned *attrsp)
{
return xml_setGenericAttributes(cx, obj, SPECIALID_TO_JSID(sid), attrsp);
return xml_setGenericAttributes(cx, obj, RootedVarId(cx, SPECIALID_TO_JSID(sid)), attrsp);
}
static JSBool
xml_deleteGeneric(JSContext *cx, JSObject *obj, jsid id, Value *rval, JSBool strict)
xml_deleteGeneric(JSContext *cx, HandleObject obj, HandleId id, Value *rval, JSBool strict)
{
uint32_t index;
JSObject *nameqn;
jsid funid;
RootedVarId funid(cx);
Value idval = IdToValue(id);
JSXML *xml = (JSXML *) obj->getPrivate();
@ -5007,11 +5006,11 @@ xml_deleteGeneric(JSContext *cx, JSObject *obj, jsid id, Value *rval, JSBool str
/* ECMA-357 9.2.1.3. */
DeleteListElement(cx, xml, index);
} else {
nameqn = ToXMLName(cx, idval, &funid);
nameqn = ToXMLName(cx, idval, funid.address());
if (!nameqn)
return false;
if (!JSID_IS_VOID(funid))
return js_DeleteGeneric(cx, obj, funid, rval, false);
return baseops::DeleteGeneric(cx, obj, funid, rval, false);
DeleteNamedProperty(cx, xml, nameqn,
nameqn->getClass() == &AttributeNameClass);
@ -5024,7 +5023,7 @@ xml_deleteGeneric(JSContext *cx, JSObject *obj, jsid id, Value *rval, JSBool str
* property's getter or setter. But now it's time to remove any such
* property, to purge the property cache and remove the scope entry.
*/
if (!obj->nativeEmpty() && !js_DeleteGeneric(cx, obj, id, rval, false))
if (!obj->nativeEmpty() && !baseops::DeleteGeneric(cx, obj, id, rval, false))
return false;
rval->setBoolean(true);
@ -5032,13 +5031,13 @@ xml_deleteGeneric(JSContext *cx, JSObject *obj, jsid id, Value *rval, JSBool str
}
static JSBool
xml_deleteProperty(JSContext *cx, JSObject *obj, PropertyName *name, Value *rval, JSBool strict)
xml_deleteProperty(JSContext *cx, HandleObject obj, HandlePropertyName name, Value *rval, JSBool strict)
{
return xml_deleteGeneric(cx, obj, NameToId(name), rval, strict);
return xml_deleteGeneric(cx, obj, RootedVarId(cx, NameToId(name)), rval, strict);
}
static JSBool
xml_deleteElement(JSContext *cx, JSObject *obj, uint32_t index, Value *rval, JSBool strict)
xml_deleteElement(JSContext *cx, HandleObject obj, uint32_t index, Value *rval, JSBool strict)
{
JSXML *xml = reinterpret_cast<JSXML *>(obj->getPrivate());
if (xml->xml_class != JSXML_CLASS_LIST) {
@ -5057,7 +5056,7 @@ xml_deleteElement(JSContext *cx, JSObject *obj, uint32_t index, Value *rval, JSB
* property's getter or setter. But now it's time to remove any such
* property, to purge the property cache and remove the scope entry.
*/
if (!obj->nativeEmpty() && !js_DeleteElement(cx, obj, index, rval, false))
if (!obj->nativeEmpty() && !baseops::DeleteElement(cx, obj, index, rval, false))
return false;
rval->setBoolean(true);
@ -5065,16 +5064,16 @@ xml_deleteElement(JSContext *cx, JSObject *obj, uint32_t index, Value *rval, JSB
}
static JSBool
xml_deleteSpecial(JSContext *cx, JSObject *obj, SpecialId sid, Value *rval, JSBool strict)
xml_deleteSpecial(JSContext *cx, HandleObject obj, HandleSpecialId sid, Value *rval, JSBool strict)
{
return xml_deleteGeneric(cx, obj, SPECIALID_TO_JSID(sid), rval, strict);
return xml_deleteGeneric(cx, obj, RootedVarId(cx, SPECIALID_TO_JSID(sid)), rval, strict);
}
static JSString *
xml_toString_helper(JSContext *cx, JSXML *xml);
JSBool
xml_convert(JSContext *cx, JSObject *obj, JSType hint, Value *rval)
xml_convert(JSContext *cx, HandleObject obj, JSType hint, Value *rval)
{
JS_ASSERT(hint == JSTYPE_NUMBER || hint == JSTYPE_STRING || hint == JSTYPE_VOID);
JS_ASSERT(obj->isXML());
@ -5088,7 +5087,7 @@ xml_convert(JSContext *cx, JSObject *obj, JSType hint, Value *rval)
}
static JSBool
xml_enumerate(JSContext *cx, JSObject *obj, JSIterateOp enum_op, Value *statep, jsid *idp)
xml_enumerate(JSContext *cx, HandleObject obj, JSIterateOp enum_op, Value *statep, jsid *idp)
{
JSXML *xml;
uint32_t length, index;
@ -5138,13 +5137,13 @@ xml_enumerate(JSContext *cx, JSObject *obj, JSIterateOp enum_op, Value *statep,
}
static JSType
xml_typeOf(JSContext *cx, JSObject *obj)
xml_typeOf(JSContext *cx, HandleObject obj)
{
return JSTYPE_XML;
}
static JSBool
xml_hasInstance(JSContext *cx, JSObject *obj, const Value *, JSBool *bp)
xml_hasInstance(JSContext *cx, HandleObject obj, const Value *, JSBool *bp)
{
return JS_TRUE;
}
@ -5164,7 +5163,7 @@ xml_trace(JSTracer *trc, JSObject *obj)
}
static void
xml_clear(JSContext *cx, JSObject *obj)
xml_clear(JSContext *cx, HandleObject obj)
{
}
@ -5464,8 +5463,8 @@ StartNonListXMLMethod(JSContext *cx, jsval *vp, JSObject **objp)
return JS_FALSE
#define NON_LIST_XML_METHOD_PROLOG \
JSObject *obj; \
JSXML *xml = StartNonListXMLMethod(cx, vp, &obj); \
RootedVarObject obj(cx); \
JSXML *xml = StartNonListXMLMethod(cx, vp, obj.address()); \
if (!xml) \
return JS_FALSE; \
JS_ASSERT(xml->xml_class != JSXML_CLASS_LIST)
@ -5508,8 +5507,8 @@ xml_appendChild(JSContext *cx, unsigned argc, jsval *vp)
if (!xml)
return JS_FALSE;
jsid name;
if (!js_GetAnyName(cx, &name))
RootedVarId name(cx);
if (!js_GetAnyName(cx, name.address()))
return JS_FALSE;
if (!GetProperty(cx, obj, name, &v))
@ -5521,11 +5520,11 @@ xml_appendChild(JSContext *cx, unsigned argc, jsval *vp)
vxml = (JSXML *) vobj->getPrivate();
JS_ASSERT(vxml->xml_class == JSXML_CLASS_LIST);
if (!IndexToId(cx, vxml->xml_kids.length, &name))
if (!IndexToId(cx, vxml->xml_kids.length, name.address()))
return JS_FALSE;
*vp = (argc != 0) ? vp[2] : JSVAL_VOID;
if (!PutProperty(cx, JSVAL_TO_OBJECT(v), name, false, vp))
if (!PutProperty(cx, RootedVarObject(cx, JSVAL_TO_OBJECT(v)), name, false, vp))
return JS_FALSE;
*vp = OBJECT_TO_JSVAL(obj);
@ -5548,8 +5547,8 @@ xml_attribute(JSContext *cx, unsigned argc, jsval *vp)
return JS_FALSE;
vp[2] = OBJECT_TO_JSVAL(qn); /* local root */
jsid id = OBJECT_TO_JSID(qn);
JSObject *obj = ToObject(cx, &vp[1]);
RootedVarId id(cx, OBJECT_TO_JSID(qn));
RootedVarObject obj(cx, ToObject(cx, &vp[1]));
if (!obj)
return JS_FALSE;
return GetProperty(cx, obj, id, vp);
@ -5564,8 +5563,8 @@ xml_attributes(JSContext *cx, unsigned argc, jsval *vp)
if (!qn)
return JS_FALSE;
jsid id = OBJECT_TO_JSID(qn);
JSObject *obj = ToObject(cx, &vp[1]);
RootedVarId id(cx, OBJECT_TO_JSID(qn));
RootedVarObject obj(cx, ToObject(cx, &vp[1]));
if (!obj)
return JS_FALSE;
return GetProperty(cx, obj, id, vp);
@ -5588,21 +5587,21 @@ xml_list_helper(JSContext *cx, JSXML *xml, jsval *rval)
}
static JSBool
ValueToId(JSContext *cx, jsval v, AutoIdRooter *idr)
ValueToIdForXML(JSContext *cx, jsval v, jsid *idp)
{
if (JSVAL_IS_INT(v)) {
int32_t i = JSVAL_TO_INT(v);
if (INT_FITS_IN_JSID(i))
*idr->addr() = INT_TO_JSID(i);
else if (!ValueToId(cx, v, idr->addr()))
*idp = INT_TO_JSID(i);
else if (!ValueToId(cx, v, idp))
return JS_FALSE;
} else if (JSVAL_IS_STRING(v)) {
JSAtom *atom = js_AtomizeString(cx, JSVAL_TO_STRING(v));
if (!atom)
return JS_FALSE;
*idr->addr() = AtomToId(atom);
*idp = AtomToId(atom);
} else if (!JSVAL_IS_PRIMITIVE(v)) {
*idr->addr() = OBJECT_TO_JSID(JSVAL_TO_OBJECT(v));
*idp = OBJECT_TO_JSID(JSVAL_TO_OBJECT(v));
} else {
ReportBadXMLName(cx, v);
return JS_FALSE;
@ -5642,11 +5641,11 @@ xml_child_helper(JSContext *cx, JSObject *obj, JSXML *xml, jsval name,
return JS_TRUE;
}
AutoIdRooter idr(cx);
if (!ValueToId(cx, name, &idr))
RootedVarId id(cx);
if (!ValueToIdForXML(cx, name, id.address()))
return JS_FALSE;
return GetProperty(cx, obj, idr.id(), rval);
return GetProperty(cx, RootedVarObject(cx, obj), id, rval);
}
/* XML and XMLList */
@ -5723,10 +5722,10 @@ xml_childIndex(JSContext *cx, unsigned argc, jsval *vp)
static JSBool
xml_children(JSContext *cx, unsigned argc, jsval *vp)
{
JSObject *obj = ToObject(cx, &vp[1]);
RootedVarObject obj(cx, ToObject(cx, &vp[1]));
if (!obj)
return false;
jsid name = NameToId(cx->runtime->atomState.starAtom);
RootedVarId name(cx, NameToId(cx->runtime->atomState.starAtom));
return GetProperty(cx, obj, name, vp);
}
@ -5953,7 +5952,7 @@ xml_hasOwnProperty(JSContext *cx, unsigned argc, jsval *vp)
*vp = JSVAL_TRUE;
return JS_TRUE;
}
return js_HasOwnPropertyHelper(cx, js_LookupProperty, argc, vp);
return js_HasOwnPropertyHelper(cx, baseops::LookupProperty, argc, vp);
}
/* XML and XMLList */
@ -6675,13 +6674,13 @@ xml_replace(JSContext *cx, unsigned argc, jsval *vp)
static JSBool
xml_setChildren(JSContext *cx, unsigned argc, jsval *vp)
{
JSObject *obj;
RootedVarObject obj(cx);
if (!StartNonListXMLMethod(cx, vp, &obj))
if (!StartNonListXMLMethod(cx, vp, obj.address()))
return JS_FALSE;
*vp = argc != 0 ? vp[2] : JSVAL_VOID; /* local root */
if (!PutProperty(cx, obj, NameToId(cx->runtime->atomState.starAtom), false, vp))
if (!PutProperty(cx, obj, RootedVarId(cx, NameToId(cx->runtime->atomState.starAtom)), false, vp))
return JS_FALSE;
*vp = OBJECT_TO_JSVAL(obj);
@ -7578,9 +7577,11 @@ GlobalObject::getFunctionNamespace(JSContext *cx, Value *vp)
JSBool
js_GetDefaultXMLNamespace(JSContext *cx, jsval *vp)
{
JSObject *ns, *obj, *tmp;
JSObject *ns, *obj;
jsval v;
RootedVarObject tmp(cx);
JSObject *scopeChain = GetCurrentScopeChain(cx);
if (!scopeChain)
return false;
@ -7724,7 +7725,7 @@ js_FindXMLProperty(JSContext *cx, const Value &nameval, JSObject **objp, jsid *i
JSObject *nameobj;
jsval v;
JSObject *qn;
jsid funid;
RootedVarId funid(cx);
JSObject *obj, *target, *proto, *pobj;
JSXML *xml;
JSBool found;
@ -7804,7 +7805,7 @@ GetXMLFunction(JSContext *cx, HandleObject obj, HandleId id, jsval *vp)
*/
RootedVarObject target(cx, obj);
for (;;) {
if (!js_GetProperty(cx, target, id, vp))
if (!baseops::GetProperty(cx, target, id, vp))
return false;
if (!JSVAL_IS_PRIMITIVE(*vp) && JSVAL_TO_OBJECT(*vp)->isFunction())
return true;

Просмотреть файл

@ -93,7 +93,7 @@ mjit::Compiler::Compiler(JSContext *cx, JSScript *outerScript,
isConstructing(isConstructing),
outerChunk(outerJIT()->chunkDescriptor(chunkIndex)),
ssa(cx, outerScript),
globalObj(outerScript->hasGlobal() ? outerScript->global() : NULL),
globalObj(cx, outerScript->hasGlobal() ? outerScript->global() : NULL),
globalSlots(globalObj ? globalObj->getRawSlots() : NULL),
frame(cx, *thisFromCtor(), masm, stubcc),
a(NULL), outer(NULL), script(NULL), PC(NULL), loop(NULL),
@ -4860,7 +4860,7 @@ mjit::Compiler::jsop_getprop(PropertyName *name, JSValueType knownType,
JSObject *singleton =
(*PC == JSOP_GETPROP || *PC == JSOP_CALLPROP) ? pushedSingleton(0) : NULL;
if (singleton && singleton->isFunction() && !hasTypeBarriers(PC) &&
testSingletonPropertyTypes(top, NameToId(name), &testObject)) {
testSingletonPropertyTypes(top, RootedVarId(cx, NameToId(name)), &testObject)) {
if (testObject) {
Jump notObject = frame.testObject(Assembler::NotEqual, top);
stubcc.linkExit(notObject, Uses(1));
@ -5074,7 +5074,7 @@ mjit::Compiler::jsop_getprop(PropertyName *name, JSValueType knownType,
}
bool
mjit::Compiler::testSingletonProperty(JSObject *obj, jsid id)
mjit::Compiler::testSingletonProperty(HandleObject obj, HandleId id)
{
/*
* We would like to completely no-op property/global accesses which can
@ -5119,7 +5119,7 @@ mjit::Compiler::testSingletonProperty(JSObject *obj, jsid id)
}
bool
mjit::Compiler::testSingletonPropertyTypes(FrameEntry *top, jsid id, bool *testObject)
mjit::Compiler::testSingletonPropertyTypes(FrameEntry *top, HandleId id, bool *testObject)
{
*testObject = false;
@ -5127,7 +5127,7 @@ mjit::Compiler::testSingletonPropertyTypes(FrameEntry *top, jsid id, bool *testO
if (!types || types->unknownObject())
return false;
JSObject *singleton = types->getSingleton(cx);
RootedVarObject singleton(cx, types->getSingleton(cx));
if (singleton)
return testSingletonProperty(singleton, id);
@ -5156,7 +5156,7 @@ mjit::Compiler::testSingletonPropertyTypes(FrameEntry *top, jsid id, bool *testO
JS_ASSERT_IF(top->isTypeKnown(), top->isType(JSVAL_TYPE_OBJECT));
types::TypeObject *object = types->getTypeObject(0);
if (object && object->proto) {
if (!testSingletonProperty(object->proto, id))
if (!testSingletonProperty(RootedVarObject(cx, object->proto), id))
return false;
types->addFreeze(cx);
@ -5171,8 +5171,8 @@ mjit::Compiler::testSingletonPropertyTypes(FrameEntry *top, jsid id, bool *testO
return false;
}
JSObject *proto;
if (!js_GetClassPrototype(cx, globalObj, key, &proto, NULL))
RootedVarObject proto(cx);
if (!js_GetClassPrototype(cx, globalObj, key, proto.address(), NULL))
return NULL;
return testSingletonProperty(proto, id);
@ -5191,8 +5191,8 @@ mjit::Compiler::jsop_getprop_dispatch(PropertyName *name)
if (top->isNotType(JSVAL_TYPE_OBJECT))
return false;
jsid id = NameToId(name);
if (id != types::MakeTypeId(cx, id))
RootedVarId id(cx, NameToId(name));
if (id.reference() != types::MakeTypeId(cx, id))
return false;
types::TypeSet *pushedTypes = pushedTypeSet(0);
@ -5233,7 +5233,7 @@ mjit::Compiler::jsop_getprop_dispatch(PropertyName *name)
if (ownTypes->isOwnProperty(cx, object, false))
return false;
if (!testSingletonProperty(object->proto, id))
if (!testSingletonProperty(RootedVarObject(cx, object->proto), id))
return false;
if (object->proto->getType(cx)->unknownProperties())
@ -6196,7 +6196,7 @@ mjit::Compiler::jsop_getgname(uint32_t index)
/* Optimize singletons like Math for JSOP_CALLPROP. */
JSObject *obj = pushedSingleton(0);
if (obj && !hasTypeBarriers(PC) && testSingletonProperty(globalObj, NameToId(name))) {
if (obj && !hasTypeBarriers(PC) && testSingletonProperty(globalObj, RootedVarId(cx, NameToId(name)))) {
frame.push(ObjectValue(*obj));
return;
}

Просмотреть файл

@ -405,7 +405,7 @@ class Compiler : public BaseCompiler
/* SSA information for the outer script and all frames we will be inlining. */
analyze::CrossScriptSSA ssa;
GlobalObject *globalObj;
RootedVar<GlobalObject*> globalObj;
const HeapSlot *globalSlots; /* Original slots pointer. */
Assembler masm;
@ -589,8 +589,8 @@ private:
types::TypeSet *pushedTypeSet(uint32_t which);
bool monitored(jsbytecode *pc);
bool hasTypeBarriers(jsbytecode *pc);
bool testSingletonProperty(JSObject *obj, jsid id);
bool testSingletonPropertyTypes(FrameEntry *top, jsid id, bool *testObject);
bool testSingletonProperty(HandleObject obj, HandleId id);
bool testSingletonPropertyTypes(FrameEntry *top, HandleId id, bool *testObject);
CompileStatus addInlineFrame(JSScript *script, uint32_t depth, uint32_t parent, jsbytecode *parentpc);
CompileStatus scanInlineCalls(uint32_t index, uint32_t depth);
CompileStatus checkAnalysis(JSScript *script);

Просмотреть файл

@ -2665,7 +2665,7 @@ mjit::Compiler::jsop_initprop()
FrameEntry *fe = frame.peek(-1);
PropertyName *name = script->getName(GET_UINT32_INDEX(PC));
JSObject *baseobj = frame.extra(obj).initObject;
RootedVarObject baseobj(cx, frame.extra(obj).initObject);
if (!baseobj || monitored(PC)) {
prepareStubCall(Uses(2));
@ -2679,7 +2679,7 @@ mjit::Compiler::jsop_initprop()
#ifdef DEBUG
bool res =
#endif
LookupPropertyWithFlags(cx, baseobj, NameToId(name),
LookupPropertyWithFlags(cx, baseobj, RootedVarId(cx, NameToId(name)),
JSRESOLVE_QUALIFIED, &holder, &prop);
JS_ASSERT(res && prop && holder == baseobj);

Просмотреть файл

@ -1087,11 +1087,32 @@ class GetPropCompiler : public PICStubCompiler
masm.bumpStubCount(f.script(), f.pc(), t0);
/*
* Initialize vp, which is either a slot in the object (the holder,
* actually, which must equal the object here) or undefined.
* Use vp == sp to avoid clobbering stack values.
* Use three values above sp on the stack for use by the call to store
* the object and id being passed into the call as handles and to store
* the resulting value. Temporary slots are used by GETPROP for this,
* plus there is extra room on the stack reserved for a callee frame.
*/
int32_t initialFrameDepth = f.regs.sp - f.fp()->slots() + 3;
int32_t vpOffset = (char *) f.regs.sp - (char *) f.fp();
int32_t idHandleOffset = (char *) (f.regs.sp + 1) - (char *) f.fp();
int32_t objHandleOffset = (char *) (f.regs.sp + 2) - (char *) f.fp();
masm.storePtr(holdObjReg, Address(JSFrameReg, objHandleOffset));
masm.storePtr(ImmPtr((void *) JSID_BITS(userid)), Address(JSFrameReg, idHandleOffset));
/*
* On 32 bit platforms zero the upper portion of the values so that
* the GC does not see a corrupt value in the handle slots. The two
* slots will look like doubles, so won't be traced, but the objects
* will be held live by the object value still in place on the stack.
* This will need to be addressed once a moving GC can relocate the
* objects, as the created handles will need to be properly registered.
*/
#if JS_BITS_PER_WORD == 32
masm.storePtr(ImmPtr(NULL), masm.tagOf(Address(JSFrameReg, objHandleOffset)));
masm.storePtr(ImmPtr(NULL), masm.tagOf(Address(JSFrameReg, idHandleOffset)));
#endif
if (shape->hasSlot()) {
masm.loadObjProp(obj, holdObjReg, shape,
Registers::ClobberInCall, t0);
@ -1100,8 +1121,6 @@ class GetPropCompiler : public PICStubCompiler
masm.storeValue(UndefinedValue(), Address(JSFrameReg, vpOffset));
}
/* sp + 1 to avoid clobbering vp if the getter calls scripted functions. */
int32_t initialFrameDepth = f.regs.sp + 1 - f.fp()->slots();
masm.setupFallibleABICall(cx->typeInferenceEnabled(), f.regs.pc, initialFrameDepth);
/* Grab cx. */
@ -1112,15 +1131,16 @@ class GetPropCompiler : public PICStubCompiler
#endif
masm.loadPtr(FrameAddress(offsetof(VMFrame, cx)), cxReg);
/* Grap vp. */
RegisterID vpReg = t0;
masm.addPtr(Imm32(vpOffset), JSFrameReg, vpReg);
/* Use a temporary for parameters. */
masm.addPtr(Imm32(vpOffset), JSFrameReg, t0);
masm.restoreStackBase();
masm.setupABICall(Registers::NormalCall, 4);
masm.storeArg(3, vpReg);
masm.storeArg(2, ImmPtr((void *) JSID_BITS(userid)));
masm.storeArg(1, holdObjReg);
masm.storeArg(3, t0);
masm.addPtr(Imm32(idHandleOffset - vpOffset), t0);
masm.storeArg(2, t0);
masm.addPtr(Imm32(objHandleOffset - idHandleOffset), t0);
masm.storeArg(1, t0);
masm.storeArg(0, cxReg);
masm.callWithABI(JS_FUNC_TO_DATA_PTR(void *, getter), false);
@ -1205,7 +1225,7 @@ class GetPropCompiler : public PICStubCompiler
#endif
masm.loadPtr(FrameAddress(offsetof(VMFrame, cx)), cxReg);
/* Grap vp. */
/* Grab vp. */
RegisterID vpReg = t0;
masm.addPtr(Imm32(vpOffset), JSFrameReg, vpReg);
@ -2483,7 +2503,7 @@ GetElementIC::attachTypedArray(VMFrame &f, JSObject *obj, const Value &v, jsid i
disable(f, "generated typed array stub");
// Fetch the value as expected of Lookup_Cacheable for GetElement.
if (!obj->getGeneric(cx, id, vp))
if (!obj->getGeneric(cx, RootedVarId(cx, id), vp))
return Lookup_Error;
return Lookup_Cacheable;
@ -2573,7 +2593,7 @@ ic::GetElement(VMFrame &f, ic::GetElementIC *ic)
}
}
if (!obj->getGeneric(cx, id, &f.regs.sp[-2]))
if (!obj->getGeneric(cx, RootedVarId(cx, id), &f.regs.sp[-2]))
THROW();
#if JS_HAS_NO_SUCH_METHOD

Просмотреть файл

@ -159,13 +159,13 @@ stubs::SetElem(VMFrame &f)
Value rval = regs.sp[-1];
JSObject *obj;
jsid id;
RootedVarId id(cx);
obj = ValueToObject(cx, objval);
if (!obj)
THROW();
if (!FetchElementId(f.cx, obj, idval, id, &regs.sp[-2]))
if (!FetchElementId(f.cx, obj, idval, id.address(), &regs.sp[-2]))
THROW();
TypeScript::MonitorAssign(cx, obj, id);
@ -212,8 +212,8 @@ stubs::ToId(VMFrame &f)
if (!obj)
THROW();
jsid id;
if (!FetchElementId(f.cx, obj, idval, id, &idval))
RootedVarId id(f.cx);
if (!FetchElementId(f.cx, obj, idval, id.address(), &idval))
THROW();
if (!idval.isInt32())
@ -538,7 +538,7 @@ StubEqualityOp(VMFrame &f)
JSObject *l = &lval.toObject(), *r = &rval.toObject();
if (JSEqualityOp eq = l->getClass()->ext.equality) {
JSBool equal;
if (!eq(cx, l, &rval, &equal))
if (!eq(cx, RootedVarObject(cx, l), &rval, &equal))
return false;
cond = !!equal == EQ;
} else {
@ -954,9 +954,9 @@ stubs::InitElem(VMFrame &f, uint32_t last)
JSObject *obj = &lref.toObject();
/* Fetch id now that we have obj. */
jsid id;
RootedVarId id(cx);
const Value &idval = regs.sp[-2];
if (!FetchElementId(f.cx, obj, idval, id, &regs.sp[-2]))
if (!FetchElementId(f.cx, obj, idval, id.address(), &regs.sp[-2]))
THROW();
/*
@ -1062,10 +1062,10 @@ InitPropOrMethod(VMFrame &f, PropertyName *name, JSOp op)
JS_ASSERT(obj->isNative());
/* Get the immediate property name into id. */
jsid id = NameToId(name);
RootedVarId id(cx, NameToId(name));
if (JS_UNLIKELY(name == cx->runtime->atomState.protoAtom)
? !js_SetPropertyHelper(cx, obj, id, 0, &rval, false)
? !baseops::SetPropertyHelper(cx, obj, id, 0, &rval, false)
: !DefineNativeProperty(cx, obj, id, rval, NULL, NULL,
JSPROP_ENUMERATE, 0, 0, 0)) {
THROW();
@ -1176,7 +1176,7 @@ stubs::InstanceOf(VMFrame &f)
-1, rref, NULL);
THROWV(JS_FALSE);
}
JSObject *obj = &rref.toObject();
RootedVarObject obj(cx, &rref.toObject());
const Value &lref = regs.sp[-2];
JSBool cond = JS_FALSE;
if (!HasInstance(cx, obj, &lref, &cond))
@ -1394,9 +1394,10 @@ stubs::DelName(VMFrame &f, PropertyName *name_)
template<JSBool strict>
void JS_FASTCALL
stubs::DelProp(VMFrame &f, PropertyName *name)
stubs::DelProp(VMFrame &f, PropertyName *name_)
{
JSContext *cx = f.cx;
RootedVarPropertyName name(cx, name_);
JSObject *obj = ValueToObject(cx, f.regs.sp[-1]);
if (!obj)
@ -1471,8 +1472,8 @@ stubs::In(VMFrame &f)
}
JSObject *obj = &rref.toObject();
jsid id;
if (!FetchElementId(f.cx, obj, f.regs.sp[-2], id, &f.regs.sp[-2]))
RootedVarId id(cx);
if (!FetchElementId(f.cx, obj, f.regs.sp[-2], id.address(), &f.regs.sp[-2]))
THROWV(JS_FALSE);
JSObject *obj2;

Просмотреть файл

@ -53,7 +53,7 @@ static PerfMeasurement* GetPMFromThis(JSContext* cx, jsval* vp);
#define GETTER(name) \
static JSBool \
pm_get_##name(JSContext* cx, JSObject* obj, jsid /*unused*/, jsval* vp) \
pm_get_##name(JSContext* cx, JS::HandleObject obj, JS::HandleId /*unused*/, jsval* vp) \
{ \
PerfMeasurement* p = GetPM(cx, obj, #name); \
if (!p) \

Просмотреть файл

@ -2563,10 +2563,8 @@ typedef struct ComplexObject {
} ComplexObject;
static JSBool
sandbox_enumerate(JSContext *cx, JSObject *obj_)
sandbox_enumerate(JSContext *cx, HandleObject obj)
{
RootedVarObject obj(cx, obj_);
jsval v;
JSBool b;
@ -2578,12 +2576,9 @@ sandbox_enumerate(JSContext *cx, JSObject *obj_)
}
static JSBool
sandbox_resolve(JSContext *cx, JSObject *obj_, jsid id_, unsigned flags,
sandbox_resolve(JSContext *cx, HandleObject obj, HandleId id, unsigned flags,
JSObject **objp)
{
RootedVarObject obj(cx, obj_);
RootedVarId id(cx, id_);
jsval v;
JSBool b, resolved;
@ -2641,8 +2636,8 @@ static JSBool
EvalInContext(JSContext *cx, unsigned argc, jsval *vp)
{
JSString *str;
JSObject *sobj = NULL;
if (!JS_ConvertArguments(cx, argc, JS_ARGV(cx, vp), "S / o", &str, &sobj))
RootedVarObject sobj(cx);
if (!JS_ConvertArguments(cx, argc, JS_ARGV(cx, vp), "S / o", &str, sobj.address()))
return false;
size_t srclen;
@ -2686,7 +2681,7 @@ EvalInContext(JSContext *cx, unsigned argc, jsval *vp)
return false;
}
OBJ_TO_INNER_OBJECT(cx, sobj);
sobj = GetInnerObject(cx, sobj);
if (!sobj)
return false;
if (!(sobj->getClass()->flags & JSCLASS_IS_GLOBAL)) {
@ -2779,7 +2774,7 @@ ShapeOf(JSContext *cx, unsigned argc, JS::Value *vp)
* non-native referent may be simplified to data properties.
*/
static JSBool
CopyProperty(JSContext *cx, JSObject *obj_, JSObject *referent, jsid id,
CopyProperty(JSContext *cx, HandleObject obj, HandleObject referent, HandleId id,
unsigned lookupFlags, JSObject **objp)
{
JSProperty *prop;
@ -2787,8 +2782,6 @@ CopyProperty(JSContext *cx, JSObject *obj_, JSObject *referent, jsid id,
unsigned propFlags = 0;
JSObject *obj2;
RootedVarObject obj(cx, obj_);
*objp = NULL;
if (referent->isNative()) {
if (!LookupPropertyWithFlags(cx, referent, id, lookupFlags, &obj2, &prop))
@ -2839,23 +2832,23 @@ CopyProperty(JSContext *cx, JSObject *obj_, JSObject *referent, jsid id,
}
static JSBool
resolver_resolve(JSContext *cx, JSObject *obj, jsid id, unsigned flags, JSObject **objp)
resolver_resolve(JSContext *cx, HandleObject obj, HandleId id, unsigned flags, JSObject **objp)
{
jsval v = JS_GetReservedSlot(obj, 0);
return CopyProperty(cx, obj, JSVAL_TO_OBJECT(v), id, flags, objp);
return CopyProperty(cx, obj, RootedVarObject(cx, JSVAL_TO_OBJECT(v)), id, flags, objp);
}
static JSBool
resolver_enumerate(JSContext *cx, JSObject *obj)
resolver_enumerate(JSContext *cx, HandleObject obj)
{
jsval v = JS_GetReservedSlot(obj, 0);
JSObject *referent = JSVAL_TO_OBJECT(v);
RootedVarObject referent(cx, JSVAL_TO_OBJECT(v));
AutoIdArray ida(cx, JS_Enumerate(cx, referent));
bool ok = !!ida;
JSObject *ignore;
for (size_t i = 0; ok && i < ida.length(); i++)
ok = CopyProperty(cx, obj, referent, ida[i], JSRESOLVE_QUALIFIED, &ignore);
ok = CopyProperty(cx, obj, referent, RootedVarId(cx, ida[i]), JSRESOLVE_QUALIFIED, &ignore);
return ok;
}
@ -3211,7 +3204,7 @@ Parent(JSContext *cx, unsigned argc, jsval *vp)
/* Outerize if necessary. Embrace the ugliness! */
if (parent) {
if (JSObjectOp op = parent->getClass()->ext.outerObject)
*vp = OBJECT_TO_JSVAL(op(cx, parent));
*vp = OBJECT_TO_JSVAL(op(cx, RootedVarObject(cx, parent)));
}
return JS_TRUE;
@ -3941,10 +3934,10 @@ enum its_tinyid {
};
static JSBool
its_getter(JSContext *cx, JSObject *obj, jsid id, jsval *vp);
its_getter(JSContext *cx, HandleObject obj, HandleId id, jsval *vp);
static JSBool
its_setter(JSContext *cx, JSObject *obj, jsid id, JSBool strict, jsval *vp);
its_setter(JSContext *cx, HandleObject obj, HandleId id, JSBool strict, jsval *vp);
static JSBool
its_get_customNative(JSContext *cx, unsigned argc, jsval *vp);
@ -3974,7 +3967,7 @@ static JSBool its_noisy; /* whether to be noisy when finalizing it */
static JSBool its_enum_fail;/* whether to fail when enumerating it */
static JSBool
its_addProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
its_addProperty(JSContext *cx, HandleObject obj, HandleId id, jsval *vp)
{
if (!its_noisy)
return JS_TRUE;
@ -3987,7 +3980,7 @@ its_addProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
}
static JSBool
its_delProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
its_delProperty(JSContext *cx, HandleObject obj, HandleId id, jsval *vp)
{
if (!its_noisy)
return JS_TRUE;
@ -4000,7 +3993,7 @@ its_delProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
}
static JSBool
its_getProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
its_getProperty(JSContext *cx, HandleObject obj, HandleId id, jsval *vp)
{
if (!its_noisy)
return JS_TRUE;
@ -4013,7 +4006,7 @@ its_getProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
}
static JSBool
its_setProperty(JSContext *cx, JSObject *obj, jsid id, JSBool strict, jsval *vp)
its_setProperty(JSContext *cx, HandleObject obj, HandleId id, JSBool strict, jsval *vp)
{
IdStringifier idString(cx, id);
if (its_noisy) {
@ -4038,7 +4031,7 @@ its_setProperty(JSContext *cx, JSObject *obj, jsid id, JSBool strict, jsval *vp)
* see class flags.
*/
static JSBool
its_enumerate(JSContext *cx, JSObject *obj, JSIterateOp enum_op,
its_enumerate(JSContext *cx, HandleObject obj, JSIterateOp enum_op,
jsval *statep, jsid *idp)
{
JSObject *iterator;
@ -4082,7 +4075,7 @@ its_enumerate(JSContext *cx, JSObject *obj, JSIterateOp enum_op,
}
static JSBool
its_resolve(JSContext *cx, JSObject *obj, jsid id, unsigned flags,
its_resolve(JSContext *cx, HandleObject obj, HandleId id, unsigned flags,
JSObject **objp)
{
if (its_noisy) {
@ -4097,7 +4090,7 @@ its_resolve(JSContext *cx, JSObject *obj, jsid id, unsigned flags,
}
static JSBool
its_convert(JSContext *cx, JSObject *obj, JSType type, jsval *vp)
its_convert(JSContext *cx, HandleObject obj, JSType type, jsval *vp)
{
if (its_noisy)
fprintf(gOutFile, "converting it to %s type\n", JS_GetTypeName(cx, type));
@ -4126,7 +4119,7 @@ static JSClass its_class = {
};
static JSBool
its_getter(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
its_getter(JSContext *cx, HandleObject obj, HandleId id, jsval *vp)
{
if (JS_GetClass(obj) == &its_class) {
jsval *val = (jsval *) JS_GetPrivate(obj);
@ -4139,7 +4132,7 @@ its_getter(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
}
static JSBool
its_setter(JSContext *cx, JSObject *obj, jsid id, JSBool strict, jsval *vp)
its_setter(JSContext *cx, HandleObject obj, HandleId id, JSBool strict, jsval *vp)
{
if (JS_GetClass(obj) != &its_class)
return JS_TRUE;
@ -4384,7 +4377,7 @@ Exec(JSContext *cx, unsigned argc, jsval *vp)
#endif
static JSBool
global_enumerate(JSContext *cx, JSObject *obj)
global_enumerate(JSContext *cx, HandleObject obj)
{
#ifdef LAZY_STANDARD_CLASSES
return JS_EnumerateStandardClasses(cx, obj);
@ -4394,11 +4387,9 @@ global_enumerate(JSContext *cx, JSObject *obj)
}
static JSBool
global_resolve(JSContext *cx, JSObject *obj_, jsid id, unsigned flags,
global_resolve(JSContext *cx, HandleObject obj, HandleId id, unsigned flags,
JSObject **objp)
{
RootedVarObject obj(cx, obj_);
#ifdef LAZY_STANDARD_CLASSES
JSBool resolved;
@ -4473,7 +4464,7 @@ JSClass global_class = {
};
static JSBool
env_setProperty(JSContext *cx, JSObject *obj, jsid id, JSBool strict, jsval *vp)
env_setProperty(JSContext *cx, HandleObject obj, HandleId id, JSBool strict, jsval *vp)
{
/* XXX porting may be easy, but these don't seem to supply setenv by default */
#if !defined XP_OS2 && !defined SOLARIS
@ -4517,7 +4508,7 @@ env_setProperty(JSContext *cx, JSObject *obj, jsid id, JSBool strict, jsval *vp)
}
static JSBool
env_enumerate(JSContext *cx, JSObject *obj)
env_enumerate(JSContext *cx, HandleObject obj)
{
static JSBool reflected;
char **evp, *name, *value;
@ -4549,7 +4540,7 @@ env_enumerate(JSContext *cx, JSObject *obj)
}
static JSBool
env_resolve(JSContext *cx, JSObject *obj, jsid id, unsigned flags,
env_resolve(JSContext *cx, HandleObject obj, HandleId id, unsigned flags,
JSObject **objp)
{
JSString *valstr;
@ -4912,7 +4903,7 @@ MaybeOverrideOutFileFromEnv(const char* const envVar,
JSPrincipals shellTrustedPrincipals = { 1 };
JSBool
CheckObjectAccess(JSContext *cx, JSObject *obj, jsid id, JSAccessMode mode, jsval *vp)
CheckObjectAccess(JSContext *cx, HandleObject obj, HandleId id, JSAccessMode mode, jsval *vp)
{
return true;
}

Просмотреть файл

@ -180,7 +180,7 @@ ArgumentsObject::createUnexpected(JSContext *cx, StackFrame *fp)
}
static JSBool
args_delProperty(JSContext *cx, JSObject *obj, jsid id, Value *vp)
args_delProperty(JSContext *cx, HandleObject obj, HandleId id, Value *vp)
{
ArgumentsObject &argsobj = obj->asArguments();
if (JSID_IS_INT(id)) {
@ -198,7 +198,7 @@ args_delProperty(JSContext *cx, JSObject *obj, jsid id, Value *vp)
}
static JSBool
ArgGetter(JSContext *cx, JSObject *obj, jsid id, Value *vp)
ArgGetter(JSContext *cx, HandleObject obj, HandleId id, Value *vp)
{
if (!obj->isNormalArguments())
return true;
@ -231,7 +231,7 @@ ArgGetter(JSContext *cx, JSObject *obj, jsid id, Value *vp)
}
static JSBool
ArgSetter(JSContext *cx, JSObject *obj, jsid id, JSBool strict, Value *vp)
ArgSetter(JSContext *cx, HandleObject obj, HandleId id, JSBool strict, Value *vp)
{
if (!obj->isNormalArguments())
return true;
@ -266,12 +266,12 @@ ArgSetter(JSContext *cx, JSObject *obj, jsid id, JSBool strict, Value *vp)
* that has a setter for this id.
*/
RootedVarValue value(cx);
return js_DeleteGeneric(cx, &argsobj, id, value.address(), false) &&
js_DefineProperty(cx, &argsobj, id, vp, NULL, NULL, JSPROP_ENUMERATE);
return baseops::DeleteGeneric(cx, obj, id, value.address(), false) &&
baseops::DefineProperty(cx, obj, id, vp, NULL, NULL, JSPROP_ENUMERATE);
}
static JSBool
args_resolve(JSContext *cx, JSObject *obj, jsid id, unsigned flags,
args_resolve(JSContext *cx, HandleObject obj, HandleId id, unsigned flags,
JSObject **objp)
{
*objp = NULL;
@ -297,7 +297,7 @@ args_resolve(JSContext *cx, JSObject *obj, jsid id, unsigned flags,
}
Value undef = UndefinedValue();
if (!js_DefineProperty(cx, argsobj, id, &undef, ArgGetter, ArgSetter, attrs))
if (!baseops::DefineProperty(cx, argsobj, id, &undef, ArgGetter, ArgSetter, attrs))
return JS_FALSE;
*objp = argsobj;
@ -346,13 +346,14 @@ NormalArgumentsObject::optimizedGetElem(JSContext *cx, StackFrame *fp, const Val
if (!proto)
return false;
return proto->getGeneric(cx, id, vp);
return proto->getGeneric(cx, RootedVarId(cx, id), vp);
}
static JSBool
args_enumerate(JSContext *cx, JSObject *obj)
args_enumerate(JSContext *cx, HandleObject obj)
{
RootedVar<NormalArgumentsObject*> argsobj(cx, &obj->asNormalArguments());
RootedVarId id(cx);
/*
* Trigger reflection in args_resolve using a series of js_LookupProperty
@ -360,22 +361,22 @@ args_enumerate(JSContext *cx, JSObject *obj)
*/
int argc = int(argsobj->initialLength());
for (int i = -2; i != argc; i++) {
jsid id = (i == -2)
? NameToId(cx->runtime->atomState.lengthAtom)
: (i == -1)
? NameToId(cx->runtime->atomState.calleeAtom)
: INT_TO_JSID(i);
id = (i == -2)
? NameToId(cx->runtime->atomState.lengthAtom)
: (i == -1)
? NameToId(cx->runtime->atomState.calleeAtom)
: INT_TO_JSID(i);
JSObject *pobj;
JSProperty *prop;
if (!js_LookupProperty(cx, argsobj, id, &pobj, &prop))
if (!baseops::LookupProperty(cx, argsobj, id, &pobj, &prop))
return false;
}
return true;
}
static JSBool
StrictArgGetter(JSContext *cx, JSObject *obj, jsid id, Value *vp)
StrictArgGetter(JSContext *cx, HandleObject obj, HandleId id, Value *vp)
{
if (!obj->isStrictArguments())
return true;
@ -399,13 +400,12 @@ StrictArgGetter(JSContext *cx, JSObject *obj, jsid id, Value *vp)
}
static JSBool
StrictArgSetter(JSContext *cx, JSObject *obj, jsid id, JSBool strict, Value *vp)
StrictArgSetter(JSContext *cx, HandleObject obj, HandleId id, JSBool strict, Value *vp)
{
if (!obj->isStrictArguments())
return true;
RootedVar<StrictArgumentsObject*> argsobj(cx, &obj->asStrictArguments());
RootId idRoot(cx, &id);
if (JSID_IS_INT(id)) {
unsigned arg = unsigned(JSID_TO_INT(id));
@ -424,12 +424,12 @@ StrictArgSetter(JSContext *cx, JSObject *obj, jsid id, JSBool strict, Value *vp)
* collect its value.
*/
RootedVarValue value(cx);
return js_DeleteGeneric(cx, argsobj, id, value.address(), strict) &&
js_SetPropertyHelper(cx, argsobj, id, 0, vp, strict);
return baseops::DeleteGeneric(cx, argsobj, id, value.address(), strict) &&
baseops::SetPropertyHelper(cx, argsobj, id, 0, vp, strict);
}
static JSBool
strictargs_resolve(JSContext *cx, JSObject *obj, jsid id, unsigned flags, JSObject **objp)
strictargs_resolve(JSContext *cx, HandleObject obj, HandleId id, unsigned flags, JSObject **objp)
{
*objp = NULL;
@ -460,7 +460,7 @@ strictargs_resolve(JSContext *cx, JSObject *obj, jsid id, unsigned flags, JSObje
}
Value undef = UndefinedValue();
if (!js_DefineProperty(cx, argsobj, id, &undef, getter, setter, attrs))
if (!baseops::DefineProperty(cx, argsobj, id, &undef, getter, setter, attrs))
return false;
*objp = argsobj;
@ -468,9 +468,9 @@ strictargs_resolve(JSContext *cx, JSObject *obj, jsid id, unsigned flags, JSObje
}
static JSBool
strictargs_enumerate(JSContext *cx, JSObject *obj)
strictargs_enumerate(JSContext *cx, HandleObject obj)
{
StrictArgumentsObject *argsobj = &obj->asStrictArguments();
RootedVar<StrictArgumentsObject*> argsobj(cx, &obj->asStrictArguments());
/*
* Trigger reflection in strictargs_resolve using a series of
@ -478,21 +478,26 @@ strictargs_enumerate(JSContext *cx, JSObject *obj)
*/
JSObject *pobj;
JSProperty *prop;
RootedVarId id(cx);
// length
if (!js_LookupProperty(cx, argsobj, NameToId(cx->runtime->atomState.lengthAtom), &pobj, &prop))
id = NameToId(cx->runtime->atomState.lengthAtom);
if (!baseops::LookupProperty(cx, argsobj, id, &pobj, &prop))
return false;
// callee
if (!js_LookupProperty(cx, argsobj, NameToId(cx->runtime->atomState.calleeAtom), &pobj, &prop))
id = NameToId(cx->runtime->atomState.calleeAtom);
if (!baseops::LookupProperty(cx, argsobj, id, &pobj, &prop))
return false;
// caller
if (!js_LookupProperty(cx, argsobj, NameToId(cx->runtime->atomState.callerAtom), &pobj, &prop))
id = NameToId(cx->runtime->atomState.callerAtom);
if (!baseops::LookupProperty(cx, argsobj, id, &pobj, &prop))
return false;
for (uint32_t i = 0, argc = argsobj->initialLength(); i < argc; i++) {
if (!js_LookupProperty(cx, argsobj, INT_TO_JSID(i), &pobj, &prop))
id = INT_TO_JSID(i);
if (!baseops::LookupProperty(cx, argsobj, id, &pobj, &prop))
return false;
}

Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше