Closed
Bug 655641
Opened 15 years ago
Closed 15 years ago
Expose RegExp flags and source in JS API
Categories
(Core :: JavaScript Engine, defect)
Core
JavaScript Engine
Tracking
()
RESOLVED
FIXED
People
(Reporter: philikon, Assigned: philikon)
Details
(Whiteboard: [spidernode][fixed-in-tracemonkey])
Attachments
(1 file, 1 obsolete file)
|
2.87 KB,
patch
|
gal
:
review+
|
Details | Diff | Splinter Review |
v8monkey needs to access RegExp flags and source, would be good to have those exposed in the public API. I propose adding JS_GetRegExpFlags and JS_GetRegExpSource. Patch coming up.
| Assignee | ||
Comment 1•15 years ago
|
||
I debated for a while with myself whether JS_GetRegExpSource should return char*, jschar* or JSString*. In the end I chose consistency with JS_NewRegExpObject and hence made it char*. I don't feel strongly about this, though.
(N.B.: Patch is on top of bug 650931)
Comment 2•15 years ago
|
||
Comment on attachment 530973 [details] [diff] [review]
v1
Review of attachment 530973 [details] [diff] [review]:
-----------------------------------------------------------------
What about unicode?
Comment 3•15 years ago
|
||
Yeah, the NewRegExpObject signature is a bug that shouldn't be copied, IMO.
Comment 4•15 years ago
|
||
JSString*, I think, because it flows naturally into other code that needs JS values. We should not use char* in APIs as a general rule because it has conversion costs, it has no obvious encoding, and it's potentially lossy. It also seems worth noting that returning stuff like JSString* that's "automatically" kept alive and is "automatically" released when no longer needed is better than returning stuff that requires manual deallocation like char*.
| Assignee | ||
Comment 5•15 years ago
|
||
Good to know that the JS_NewRegExpObject API is busted. I do agree with Waldo about the conversion cost and allocation. In any case, JSString would be easier for us in v8monkey, so here we go: JS_GetRegExpSource now returns JSString.
Attachment #530977 -
Flags: review?(gal)
| Assignee | ||
Comment 6•15 years ago
|
||
(Also, I now see there's JS_NewUCRegExpObjectNoStatics which takes jschar instead of char, so the consistency argument wasn't valid anyway. Pretty clear now that JS_NewRegExpObject isn't a great API.)
Updated•15 years ago
|
Attachment #530977 -
Flags: review?(gal) → review+
| Assignee | ||
Updated•15 years ago
|
Attachment #530973 -
Attachment is obsolete: true
Attachment #530973 -
Flags: review?(gal)
| Assignee | ||
Comment 7•15 years ago
|
||
Whiteboard: [spidernode] → [spidernode][fixed-in-tracemonkey]
Comment 8•15 years ago
|
||
cdleary-bot mozilla-central merge info:
http://hg.mozilla.org/mozilla-central/rev/8376b783d165
Updated•15 years ago
|
Status: ASSIGNED → RESOLVED
Closed: 15 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•