Closed Bug 643532 Opened 13 years ago Closed 13 years ago

Implement JS_ParseJSON, JS_ParseJSONWithReviver

Categories

(Core :: JavaScript Engine, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla5

People

(Reporter: Waldo, Assigned: Waldo)

References

Details

(Keywords: dev-doc-complete, Whiteboard: fixed-in-tracemonkey)

Attachments

(1 file, 1 obsolete file)

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.
Attachment #520727 - Flags: review?(brendan)
Attached patch Fix thinkoSplinter Review
Attachment #520727 - Attachment is obsolete: true
Attachment #520727 - Flags: review?(brendan)
Attachment #520738 - Flags: review?(brendan)
Comment on attachment 520738 [details] [diff] [review]
Fix thinko

This is one I will duck due to Servo ramping up. Trying Luke.

/be
Attachment #520738 - Flags: review?(brendan) → review?(luke)
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)?
Attachment #520738 - Flags: review?(luke) → review+
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
Status: ASSIGNED → RESOLVED
Closed: 13 years ago
Resolution: --- → FIXED
Whiteboard: fixed-in-tracemonkey
Target Milestone: --- → mozilla5
https://developer.mozilla.org/en/SpiderMonkey/JSAPI_Reference/JS_ParseJSON (which also documents the *WithReviver special-case)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: