Created attachment 520727 [details] [diff] [review] Patch, also add some simple-ish JSAPI tests for them Almost all callers of JS_BeginJSONParse/JS_ConsumeJSONText/JS_EndJSONParse would really rather have an API where they can just provide source characters and get back the object you get by parsing it. We should give them such an API, rather than requiring a tedious three-step. And since so far no one uses the reviver functionality, we should add a separate API to use it: keep the most common API simple, and leave the less-common case under its own separate heading. There's more refactoring to come in this area, and eventually these method implementations won't just directly implement the begin-consume-finish idiom. But it seems best to separate out that cleanup from the initial additions: more patches, but smaller and simpler patches.
Created attachment 520738 [details] [diff] [review] Fix thinko
Comment on attachment 520738 [details] [diff] [review] Fix thinko This is one I will duck due to Servo ramping up. Trying Luke. /be
Comment on attachment 520738 [details] [diff] [review] Fix thinko Nice observation. >+extern JS_FRIEND_API(JSBool) >+ParseJSONWithReviver(JSContext *cx, const jschar *chars, uint32 length, const Value &filter, >+ Value *vp, DecodingMode decodingMode = STRICT); Alignment. Also, we have this new jsfriendapi.h... should we use it as such (in support of the eventual goal of not having code outside js/src #include into js/src)?
http://hg.mozilla.org/tracemonkey/rev/9d41622b29f4 There's entanglement of the friend API with enums defined in json.h, and it looked messy disentangling things, and we really really really don't want to encourage use of this anyway, and the APIs here are changing anyway to make the JSON parsing work easier, so I didn't make that change.
This landed in TM and later got merged to m-c: http://hg.mozilla.org/mozilla-central/rev/9d41622b29f4
https://developer.mozilla.org/en/SpiderMonkey/JSAPI_Reference/JS_ParseJSON (which also documents the *WithReviver special-case)