Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.

Commit 7b76878

Browse files
author
Jose Cortes
committed
Bug 842186 - Replace use of jsval with JS::Value in h and cpp files in the dom/bindings/ dom/plugins/ dom/src/ dom/activities/ directories. r=jwalden
--HG-- extra : rebase_source : 2757a7ab265153fa4c769a69a4947b9258e4413e
1 parent a6eab2b commit 7b76878

9 files changed

Lines changed: 53 additions & 50 deletions

File tree

dom/bindings/BindingUtils.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,8 @@ InterfaceObjectToString(JSContext* cx, unsigned argc, JS::Value *vp)
230230
return false;
231231
}
232232

233-
jsval v = js::GetFunctionNativeReserved(callee, TOSTRING_CLASS_RESERVED_SLOT);
233+
JS::Value v = js::GetFunctionNativeReserved(callee,
234+
TOSTRING_CLASS_RESERVED_SLOT);
234235
JSClass* clasp = static_cast<JSClass*>(JSVAL_TO_PRIVATE(v));
235236

236237
v = js::GetFunctionNativeReserved(callee, TOSTRING_NAME_RESERVED_SLOT);

dom/bindings/DOMJSProxyHandler.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ IdToInt32(JSContext* cx, jsid id)
254254
{
255255
JSAutoRequest ar(cx);
256256

257-
jsval idval;
257+
JS::Value idval;
258258
double array_index;
259259
int32_t i;
260260
if (!::JS_IdToValue(cx, id, &idval) ||

dom/bindings/DOMJSProxyHandler.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ FillPropertyDescriptor(JSPropertyDescriptor* desc, JSObject* obj, bool readonly)
113113
}
114114

115115
inline void
116-
FillPropertyDescriptor(JSPropertyDescriptor* desc, JSObject* obj, jsval v, bool readonly)
116+
FillPropertyDescriptor(JSPropertyDescriptor* desc, JSObject* obj, JS::Value v, bool readonly)
117117
{
118118
desc->value = v;
119119
FillPropertyDescriptor(desc, obj, readonly);

dom/plugins/base/nsJSNPRuntime.cpp

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ NPObjWrapper_GetProperty(JSContext *cx, JSHandleObject obj, JSHandleId id, JSMut
126126

127127
static JSBool
128128
NPObjWrapper_newEnumerate(JSContext *cx, JSHandleObject obj, JSIterateOp enum_op,
129-
jsval *statep, jsid *idp);
129+
JS::Value *statep, jsid *idp);
130130

131131
static JSBool
132132
NPObjWrapper_NewResolve(JSContext *cx, JSHandleObject obj, JSHandleId id, unsigned flags,
@@ -139,14 +139,14 @@ static void
139139
NPObjWrapper_Finalize(JSFreeOp *fop, JSObject *obj);
140140

141141
static JSBool
142-
NPObjWrapper_Call(JSContext *cx, unsigned argc, jsval *vp);
142+
NPObjWrapper_Call(JSContext *cx, unsigned argc, JS::Value *vp);
143143

144144
static JSBool
145-
NPObjWrapper_Construct(JSContext *cx, unsigned argc, jsval *vp);
145+
NPObjWrapper_Construct(JSContext *cx, unsigned argc, JS::Value *vp);
146146

147147
static JSBool
148148
CreateNPObjectMember(NPP npp, JSContext *cx, JSObject *obj, NPObject *npobj,
149-
jsid id, NPVariant* getPropertyResult, jsval *vp);
149+
jsid id, NPVariant* getPropertyResult, JS::Value *vp);
150150

151151
JSClass sNPObjectJSWrapperClass =
152152
{
@@ -168,7 +168,7 @@ JSClass sNPObjectJSWrapperClass =
168168

169169
typedef struct NPObjectMemberPrivate {
170170
JSObject *npobjWrapper;
171-
jsval fieldValue;
171+
JS::Value fieldValue;
172172
NPIdentifier methodName;
173173
NPP npp;
174174
} NPObjectMemberPrivate;
@@ -180,7 +180,7 @@ static void
180180
NPObjectMember_Finalize(JSFreeOp *fop, JSObject *obj);
181181

182182
static JSBool
183-
NPObjectMember_Call(JSContext *cx, unsigned argc, jsval *vp);
183+
NPObjectMember_Call(JSContext *cx, unsigned argc, JS::Value *vp);
184184

185185
static void
186186
NPObjectMember_Trace(JSTracer *trc, JSObject *obj);
@@ -348,7 +348,7 @@ static NPP
348348
LookupNPP(NPObject *npobj);
349349

350350

351-
static jsval
351+
static JS::Value
352352
NPVariantToJSVal(NPP npp, JSContext *cx, const NPVariant *variant)
353353
{
354354
switch (variant->type) {
@@ -361,7 +361,7 @@ NPVariantToJSVal(NPP npp, JSContext *cx, const NPVariant *variant)
361361
case NPVariantType_Int32 :
362362
{
363363
// Don't use INT_TO_JSVAL directly to prevent bugs when dealing
364-
// with ints larger than what fits in a integer jsval.
364+
// with ints larger than what fits in a integer JS::Value.
365365
return ::JS_NumberValue(NPVARIANT_TO_INT32(*variant));
366366
}
367367
case NPVariantType_Double :
@@ -409,7 +409,7 @@ NPVariantToJSVal(NPP npp, JSContext *cx, const NPVariant *variant)
409409
}
410410

411411
bool
412-
JSValToNPVariant(NPP npp, JSContext *cx, jsval val, NPVariant *variant)
412+
JSValToNPVariant(NPP npp, JSContext *cx, JS::Value val, NPVariant *variant)
413413
{
414414
NS_ASSERTION(npp, "Must have an NPP to wrap a jsval!");
415415

@@ -587,7 +587,7 @@ nsJSObjWrapper::NP_Invalidate(NPObject *npobj)
587587
}
588588

589589
static JSBool
590-
GetProperty(JSContext *cx, JSObject *obj, NPIdentifier id, jsval *rval)
590+
GetProperty(JSContext *cx, JSObject *obj, NPIdentifier id, JS::Value *rval)
591591
{
592592
NS_ASSERTION(NPIdentifierIsInt(id) || NPIdentifierIsString(id),
593593
"id must be either string or int!\n");
@@ -620,7 +620,7 @@ nsJSObjWrapper::NP_HasMethod(NPObject *npobj, NPIdentifier id)
620620

621621
AutoJSExceptionReporter reporter(cx);
622622

623-
jsval v;
623+
JS::Value v;
624624
JSBool ok = GetProperty(cx, npjsobj->mJSObj, id, &v);
625625

626626
return ok && !JSVAL_IS_PRIMITIVE(v) &&
@@ -648,7 +648,7 @@ doInvoke(NPObject *npobj, NPIdentifier method, const NPVariant *args,
648648
VOID_TO_NPVARIANT(*result);
649649

650650
nsJSObjWrapper *npjsobj = (nsJSObjWrapper *)npobj;
651-
jsval fv;
651+
JS::Value fv;
652652

653653
AutoCXPusher pusher(cx);
654654
JSAutoRequest ar(cx);
@@ -665,21 +665,21 @@ doInvoke(NPObject *npobj, NPIdentifier method, const NPVariant *args,
665665
fv = OBJECT_TO_JSVAL(npjsobj->mJSObj);
666666
}
667667

668-
jsval jsargs_buf[8];
669-
jsval *jsargs = jsargs_buf;
668+
JS::Value jsargs_buf[8];
669+
JS::Value *jsargs = jsargs_buf;
670670

671-
if (argCount > (sizeof(jsargs_buf) / sizeof(jsval))) {
671+
if (argCount > (sizeof(jsargs_buf) / sizeof(JS::Value))) {
672672
// Our stack buffer isn't large enough to hold all arguments,
673673
// malloc a buffer.
674-
jsargs = (jsval *)PR_Malloc(argCount * sizeof(jsval));
674+
jsargs = (JS::Value *)PR_Malloc(argCount * sizeof(JS::Value));
675675
if (!jsargs) {
676676
::JS_ReportOutOfMemory(cx);
677677

678678
return false;
679679
}
680680
}
681681

682-
jsval v;
682+
JS::Value v;
683683
JSBool ok;
684684

685685
{
@@ -798,7 +798,7 @@ nsJSObjWrapper::NP_GetProperty(NPObject *npobj, NPIdentifier id,
798798
AutoJSExceptionReporter reporter(cx);
799799
JSAutoCompartment ac(cx, npjsobj->mJSObj);
800800

801-
jsval v;
801+
JS::Value v;
802802
return (GetProperty(cx, npjsobj->mJSObj, id, &v) &&
803803
JSValToNPVariant(npp, cx, v, result));
804804
}
@@ -830,7 +830,7 @@ nsJSObjWrapper::NP_SetProperty(NPObject *npobj, NPIdentifier id,
830830
AutoJSExceptionReporter reporter(cx);
831831
JSAutoCompartment ac(cx, npjsobj->mJSObj);
832832

833-
jsval v = NPVariantToJSVal(npp, cx, value);
833+
JS::Value v = NPVariantToJSVal(npp, cx, value);
834834
JS::AutoValueRooter tvr(cx, v);
835835

836836
NS_ASSERTION(NPIdentifierIsInt(id) || NPIdentifierIsString(id),
@@ -866,7 +866,7 @@ nsJSObjWrapper::NP_RemoveProperty(NPObject *npobj, NPIdentifier id)
866866
AutoCXPusher pusher(cx);
867867
JSAutoRequest ar(cx);
868868
AutoJSExceptionReporter reporter(cx);
869-
jsval deleted = JSVAL_FALSE;
869+
JS::Value deleted = JSVAL_FALSE;
870870
JSAutoCompartment ac(cx, npjsobj->mJSObj);
871871

872872
NS_ASSERTION(NPIdentifierIsInt(id) || NPIdentifierIsString(id),
@@ -934,7 +934,7 @@ nsJSObjWrapper::NP_Enumerate(NPObject *npobj, NPIdentifier **idarray,
934934
}
935935

936936
for (uint32_t i = 0; i < *count; i++) {
937-
jsval v;
937+
JS::Value v;
938938
if (!JS_IdToValue(cx, ida[i], &v)) {
939939
PR_Free(*idarray);
940940
return false;
@@ -1375,8 +1375,8 @@ NPObjWrapper_GetProperty(JSContext *cx, JSHandleObject obj, JSHandleId id, JSMut
13751375
}
13761376

13771377
static JSBool
1378-
CallNPMethodInternal(JSContext *cx, JSObject *obj, unsigned argc, jsval *argv,
1379-
jsval *rval, bool ctorCall)
1378+
CallNPMethodInternal(JSContext *cx, JSObject *obj, unsigned argc,
1379+
JS::Value *argv, JS::Value *rval, bool ctorCall)
13801380
{
13811381
NPObject *npobj = GetNPObject(cx, obj);
13821382

@@ -1502,7 +1502,7 @@ CallNPMethodInternal(JSContext *cx, JSObject *obj, unsigned argc, jsval *argv,
15021502
}
15031503

15041504
static JSBool
1505-
CallNPMethod(JSContext *cx, unsigned argc, jsval *vp)
1505+
CallNPMethod(JSContext *cx, unsigned argc, JS::Value *vp)
15061506
{
15071507
JSObject *obj = JS_THIS_OBJECT(cx, vp);
15081508
if (!obj)
@@ -1519,7 +1519,7 @@ struct NPObjectEnumerateState {
15191519

15201520
static JSBool
15211521
NPObjWrapper_newEnumerate(JSContext *cx, JSHandleObject obj, JSIterateOp enum_op,
1522-
jsval *statep, jsid *idp)
1522+
JS::Value *statep, jsid *idp)
15231523
{
15241524
NPObject *npobj = GetNPObject(cx, obj);
15251525
NPIdentifier *enum_value;
@@ -1667,7 +1667,7 @@ NPObjWrapper_Convert(JSContext *cx, JSHandleObject obj, JSType hint, JSMutableHa
16671667
// poorly when called with no arguments. We work around this problem by
16681668
// giving plugins a [[DefaultValue]] which uses only toString and not valueOf.
16691669

1670-
jsval v = JSVAL_VOID;
1670+
JS::Value v = JSVAL_VOID;
16711671
if (!JS_GetProperty(cx, obj, "toString", &v))
16721672
return false;
16731673
if (!JSVAL_IS_PRIMITIVE(v) && JS_ObjectIsCallable(cx, JSVAL_TO_OBJECT(v))) {
@@ -1703,14 +1703,14 @@ NPObjWrapper_Finalize(JSFreeOp *fop, JSObject *obj)
17031703
}
17041704

17051705
static JSBool
1706-
NPObjWrapper_Call(JSContext *cx, unsigned argc, jsval *vp)
1706+
NPObjWrapper_Call(JSContext *cx, unsigned argc, JS::Value *vp)
17071707
{
17081708
return CallNPMethodInternal(cx, JSVAL_TO_OBJECT(JS_CALLEE(cx, vp)), argc,
17091709
JS_ARGV(cx, vp), vp, false);
17101710
}
17111711

17121712
static JSBool
1713-
NPObjWrapper_Construct(JSContext *cx, unsigned argc, jsval *vp)
1713+
NPObjWrapper_Construct(JSContext *cx, unsigned argc, JS::Value *vp)
17141714
{
17151715
return CallNPMethodInternal(cx, JSVAL_TO_OBJECT(JS_CALLEE(cx, vp)), argc,
17161716
JS_ARGV(cx, vp), vp, true);
@@ -2014,7 +2014,7 @@ LookupNPP(NPObject *npobj)
20142014

20152015
JSBool
20162016
CreateNPObjectMember(NPP npp, JSContext *cx, JSObject *obj, NPObject* npobj,
2017-
jsid id, NPVariant* getPropertyResult, jsval *vp)
2017+
jsid id, NPVariant* getPropertyResult, JS::Value *vp)
20182018
{
20192019
NS_ENSURE_TRUE(vp, JS_FALSE);
20202020

@@ -2047,7 +2047,7 @@ CreateNPObjectMember(NPP npp, JSContext *cx, JSObject *obj, NPObject* npobj,
20472047

20482048
NPIdentifier identifier = JSIdToNPIdentifier(id);
20492049

2050-
jsval fieldValue;
2050+
JS::Value fieldValue;
20512051
NPVariant npv;
20522052

20532053
if (getPropertyResult) {
@@ -2135,7 +2135,7 @@ NPObjectMember_Finalize(JSFreeOp *fop, JSObject *obj)
21352135
}
21362136

21372137
static JSBool
2138-
NPObjectMember_Call(JSContext *cx, unsigned argc, jsval *vp)
2138+
NPObjectMember_Call(JSContext *cx, unsigned argc, JS::Value *vp)
21392139
{
21402140
JSObject *memobj = JSVAL_TO_OBJECT(JS_CALLEE(cx, vp));
21412141
NS_ENSURE_TRUE(memobj, JS_FALSE);
@@ -2171,7 +2171,7 @@ NPObjectMember_Call(JSContext *cx, unsigned argc, jsval *vp)
21712171

21722172
// Convert arguments
21732173
uint32_t i;
2174-
jsval *argv = JS_ARGV(cx, vp);
2174+
JS::Value *argv = JS_ARGV(cx, vp);
21752175
for (i = 0; i < argc; ++i) {
21762176
if (!JSValToNPVariant(memberPrivate->npp, cx, argv[i], npargs + i)) {
21772177
ThrowJSException(cx, "Error converting jsvals to NPVariants!");

dom/plugins/base/nsJSNPRuntime.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ class nsNPObjWrapper
7575
};
7676

7777
bool
78-
JSValToNPVariant(NPP npp, JSContext *cx, jsval val, NPVariant *variant);
78+
JSValToNPVariant(NPP npp, JSContext *cx, JS::Value val, NPVariant *variant);
7979

8080

8181
#endif // nsJSNPRuntime_h_

dom/plugins/base/nsNPAPIPlugin.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1525,9 +1525,9 @@ _evaluate(NPP npp, NPObject* npobj, NPString *script, NPVariant *result)
15251525
"JS_ObjectToInnerObject should never return null with non-null input.");
15261526

15271527
// Root obj and the rval (below).
1528-
jsval vec[] = { OBJECT_TO_JSVAL(obj), JSVAL_NULL };
1528+
JS::Value vec[] = { OBJECT_TO_JSVAL(obj), JSVAL_NULL };
15291529
JS::AutoArrayRooter tvr(cx, ArrayLength(vec), vec);
1530-
jsval *rval = &vec[1];
1530+
JS::Value *rval = &vec[1];
15311531

15321532
if (result) {
15331533
// Initialize the out param to void

dom/src/geolocation/nsGeolocation.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ class GeolocationSettingsCallback : public nsISettingsServiceCallback
9090
MOZ_COUNT_DTOR(GeolocationSettingsCallback);
9191
}
9292

93-
NS_IMETHOD Handle(const nsAString& aName, const jsval& aResult)
93+
NS_IMETHOD Handle(const nsAString& aName, const JS::Value& aResult)
9494
{
9595
MOZ_ASSERT(NS_IsMainThread());
9696

@@ -307,7 +307,7 @@ nsGeolocationRequest::~nsGeolocationRequest()
307307

308308

309309
static mozilla::idl::GeoPositionOptions*
310-
OptionsFromJSOptions(JSContext* aCx, const jsval& aOptions, nsresult* aRv)
310+
OptionsFromJSOptions(JSContext* aCx, const JS::Value& aOptions, nsresult* aRv)
311311
{
312312
*aRv = NS_OK;
313313
nsAutoPtr<mozilla::idl::GeoPositionOptions> options(nullptr);
@@ -1281,7 +1281,7 @@ nsGeolocation::Update(nsIDOMGeoPosition *aSomewhere, bool aIsBetter)
12811281
NS_IMETHODIMP
12821282
nsGeolocation::GetCurrentPosition(nsIDOMGeoPositionCallback *callback,
12831283
nsIDOMGeoPositionErrorCallback *errorCallback,
1284-
const jsval& jsoptions,
1284+
const JS::Value& jsoptions,
12851285
JSContext* cx)
12861286
{
12871287
nsresult rv;
@@ -1353,7 +1353,7 @@ nsGeolocation::GetCurrentPositionReady(nsGeolocationRequest* aRequest)
13531353
NS_IMETHODIMP
13541354
nsGeolocation::WatchPosition(nsIDOMGeoPositionCallback *callback,
13551355
nsIDOMGeoPositionErrorCallback *errorCallback,
1356-
const jsval& jsoptions,
1356+
const JS::Value& jsoptions,
13571357
JSContext* cx,
13581358
int32_t *_retval)
13591359
{

dom/src/json/nsJSON.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ WarnDeprecatedMethod(DeprecationWarning warning)
5757
}
5858

5959
NS_IMETHODIMP
60-
nsJSON::Encode(const JS::Value& aValue, JSContext* cx, uint8_t aArgc, nsAString &aJSON)
60+
nsJSON::Encode(const JS::Value& aValue, JSContext* cx, uint8_t aArgc,
61+
nsAString &aJSON)
6162
{
6263
// This function should only be called from JS.
6364
nsresult rv = WarnDeprecatedMethod(EncodeWarning);
@@ -194,7 +195,8 @@ nsJSON::EncodeFromJSVal(JS::Value *value, JSContext *cx, nsAString &result)
194195
}
195196

196197
nsresult
197-
nsJSON::EncodeInternal(JSContext* cx, const JS::Value& aValue, nsJSONWriter* writer)
198+
nsJSON::EncodeInternal(JSContext* cx, const JS::Value& aValue,
199+
nsJSONWriter* writer)
198200
{
199201
JSAutoRequest ar(cx);
200202

@@ -214,7 +216,7 @@ nsJSON::EncodeInternal(JSContext* cx, const JS::Value& aValue, nsJSONWriter* wri
214216
* Note: It is perfectly fine to not implement toJSON, so it is
215217
* perfectly fine for GetMethod to fail
216218
*/
217-
jsval toJSON;
219+
JS::Value toJSON;
218220
if (JS_GetMethod(cx, obj, "toJSON", NULL, &toJSON) &&
219221
!JSVAL_IS_PRIMITIVE(toJSON) &&
220222
JS_ObjectIsCallable(cx, JSVAL_TO_OBJECT(toJSON))) {
@@ -388,7 +390,7 @@ nsJSON::DecodeFromStream(nsIInputStream *aStream, int32_t aContentLength,
388390
}
389391

390392
NS_IMETHODIMP
391-
nsJSON::DecodeToJSVal(const nsAString &str, JSContext *cx, jsval *result)
393+
nsJSON::DecodeToJSVal(const nsAString &str, JSContext *cx, JS::Value *result)
392394
{
393395
JSAutoRequest ar(cx);
394396

@@ -497,7 +499,7 @@ nsJSON::LegacyDecodeFromStream(nsIInputStream *aStream, int32_t aContentLength,
497499
}
498500

499501
NS_IMETHODIMP
500-
nsJSON::LegacyDecodeToJSVal(const nsAString &str, JSContext *cx, jsval *result)
502+
nsJSON::LegacyDecodeToJSVal(const nsAString &str, JSContext *cx, JS::Value *result)
501503
{
502504
JSAutoRequest ar(cx);
503505

@@ -527,7 +529,7 @@ NS_NewJSON(nsISupports* aOuter, REFNSIID aIID, void** aResult)
527529
return NS_OK;
528530
}
529531

530-
nsJSONListener::nsJSONListener(JSContext *cx, jsval *rootVal,
532+
nsJSONListener::nsJSONListener(JSContext *cx, JS::Value *rootVal,
531533
bool needsConverter,
532534
DecodingMode mode /* = STRICT */)
533535
: mNeedsConverter(needsConverter),

0 commit comments

Comments
 (0)