зеркало из https://github.com/mozilla/gecko-dev.git
#include minimization, MOZ_STACK_CLASS application, and other minor jsonparser.h cleanups. No bug, r=lumpy
--HG-- extra : rebase_source : cacc7a0bd2668f247c09bdb6c487755c9a008f90
This commit is contained in:
Родитель
0de2cfbca3
Коммит
7f1070c9de
|
@ -9,15 +9,13 @@
|
||||||
|
|
||||||
#include "mozilla/Attributes.h"
|
#include "mozilla/Attributes.h"
|
||||||
|
|
||||||
#include "jscntxt.h"
|
#include "jsapi.h"
|
||||||
#include "jsstr.h"
|
|
||||||
|
#include "vm/String.h"
|
||||||
|
|
||||||
namespace js {
|
namespace js {
|
||||||
|
|
||||||
/*
|
class MOZ_STACK_CLASS JSONParser : private AutoGCRooter
|
||||||
* NB: This class must only be used on the stack.
|
|
||||||
*/
|
|
||||||
class JSONParser : private AutoGCRooter
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum ErrorHandling { RaiseError, NoError };
|
enum ErrorHandling { RaiseError, NoError };
|
||||||
|
@ -141,23 +139,23 @@ class JSONParser : private AutoGCRooter
|
||||||
* otherwise return true and set *vp to |undefined|. (JSON syntax can't
|
* otherwise return true and set *vp to |undefined|. (JSON syntax can't
|
||||||
* represent |undefined|, so the JSON data couldn't have specified it.)
|
* represent |undefined|, so the JSON data couldn't have specified it.)
|
||||||
*/
|
*/
|
||||||
bool parse(js::MutableHandleValue vp);
|
bool parse(MutableHandleValue vp);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
js::Value numberValue() const {
|
Value numberValue() const {
|
||||||
JS_ASSERT(lastToken == Number);
|
JS_ASSERT(lastToken == Number);
|
||||||
JS_ASSERT(v.isNumber());
|
JS_ASSERT(v.isNumber());
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
js::Value stringValue() const {
|
Value stringValue() const {
|
||||||
JS_ASSERT(lastToken == String);
|
JS_ASSERT(lastToken == String);
|
||||||
JS_ASSERT(v.isString());
|
JS_ASSERT(v.isString());
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
JSAtom *atomValue() const {
|
JSAtom *atomValue() const {
|
||||||
js::Value strval = stringValue();
|
Value strval = stringValue();
|
||||||
return &strval.toString()->asAtom();
|
return &strval.toString()->asAtom();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -171,7 +169,7 @@ class JSONParser : private AutoGCRooter
|
||||||
}
|
}
|
||||||
|
|
||||||
Token stringToken(JSString *str) {
|
Token stringToken(JSString *str) {
|
||||||
this->v = js::StringValue(str);
|
this->v = StringValue(str);
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
lastToken = String;
|
lastToken = String;
|
||||||
#endif
|
#endif
|
||||||
|
@ -179,7 +177,7 @@ class JSONParser : private AutoGCRooter
|
||||||
}
|
}
|
||||||
|
|
||||||
Token numberToken(double d) {
|
Token numberToken(double d) {
|
||||||
this->v = js::NumberValue(d);
|
this->v = NumberValue(d);
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
lastToken = Number;
|
lastToken = Number;
|
||||||
#endif
|
#endif
|
||||||
|
|
Загрузка…
Ссылка в новой задаче