Closed Bug 480850 (JS_New) Opened 11 years ago Closed 10 years ago

JSAPI should support creating objects given a constructor Function

Categories

(Core :: JavaScript Engine, enhancement)

Other Branch
enhancement
Not set

Tracking

()

RESOLVED FIXED

People

(Reporter: jorendorff, Assigned: jorendorff)

References

Details

(Whiteboard: fixed-in-tracemonkey)

Attachments

(1 file, 1 obsolete file)

We've known this is a missing API for a long time now.

Because FUN_CLASP is for good reasons non-public, it's far from straightforward for JSAPI applications to implement this.  (I don't know that it's even possible without eval/JS_EvaluateScript.)
I file this now because we've got an embedder rolling his own--and suffering:

http://github.com/meh/lulzjs/blob/93ea51e4a174cf5a3f1c0df9029cb38327de664d/js/lulzjs/lulzjs.cpp#L21-64

Note the bug obtaining `klass`.  :(  Incidentally, the crazy consequences of (unintentionally) creating objects with js_FunctionClass are surprisingly hard to diagnose.
Attached patch v1 (obsolete) — Splinter Review
Totally untested.
Assignee: general → jorendorff
(memo to myself) Ash pointed out this is missing CHECK_REQUEST.
jorendorff: any reason (other than the missing CHECK_REQUEST mentioned in comment 3) that this isn't up for review/checkin?
I need this, and it works for me.  Let's get it in?
Severity: normal → enhancement
I'll post a patch with jsapi-test in the next couple hours.
Attached patch v2Splinter Review
Attachment #390253 - Attachment is obsolete: true
Attachment #432616 - Flags: review?(mrbkap)
Attachment #432616 - Flags: review?(mrbkap) → review+
What additional review does this patch need?
It landed in tracemonkey last week.

http://hg.mozilla.org/tracemonkey/rev/869bebcf1f21
Alias: JS_New
Whiteboard: fixed-in-tracemonkey
http://hg.mozilla.org/mozilla-central/rev/869bebcf1f21
Status: NEW → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.