Closed
Bug 44997
Opened 25 years ago
Closed 25 years ago
JS "ECMA reference type" returns from host method support
Categories
(Core :: JavaScript Engine, enhancement, P3)
Core
JavaScript Engine
Tracking
()
RESOLVED
FIXED
M18
People
(Reporter: brendan, Assigned: brendan)
Details
(Keywords: js1.5)
Attachments
(7 files)
15.01 KB,
patch
|
Details | Diff | Splinter Review | |
15.01 KB,
patch
|
Details | Diff | Splinter Review | |
197 bytes,
patch
|
Details | Diff | Splinter Review | |
13.92 KB,
patch
|
Details | Diff | Splinter Review | |
562 bytes,
patch
|
Details | Diff | Splinter Review | |
14.91 KB,
patch
|
Details | Diff | Splinter Review | |
15.74 KB,
patch
|
Details | Diff | Splinter Review |
I've got a patch that's not too big, and not too rickety a hack. Comments
please -- we would also need to consider extending Rhino to support such evil
'o.item(i) = j' expressions. The win here is obvious: help Mozilla consumers
who want their customers "JScript" to run without change on non-Windows systems
using Mozilla's JS engines.
/be
Assignee | ||
Comment 1•25 years ago
|
||
Assignee | ||
Updated•25 years ago
|
Severity: normal → enhancement
Status: NEW → ASSIGNED
Assignee | ||
Comment 2•25 years ago
|
||
If we do this, it should be for js1.5 (and for rhino, I think, which also
implements js1.5).
/be
Keywords: js1.5
Assignee | ||
Comment 3•25 years ago
|
||
Assignee | ||
Comment 4•25 years ago
|
||
Assignee | ||
Comment 5•25 years ago
|
||
Norris, mccabe: any thoughts on extending Rhino to support this JScript-ism?
/be
Assignee | ||
Comment 6•25 years ago
|
||
People are crawling out of the woodwork wanting this "feature" (most recently in
private email to me; I urged my correspondent to post to mozilla-jseng with code
examples showing why he's in need of this patch). If we can get a rhino patch,
I think we should do this for js1.5.
/be
Target Milestone: --- → M17
Comment 7•25 years ago
|
||
So only a "native" function can return a reference type, as per ECMA, correct?
I guess the way we'd implement this in Rhino is to define a new interface with a
callback for setting a value; functions that return references could be defined
in Java as returning an instance of this new interface. Rhino would then ensure
that the callback is invoked when the assignment occurs.
Like you, I'm not too crazy about adding support for it, but I can see the
motivation from the COM compatiblity side.
Assignee | ||
Comment 8•25 years ago
|
||
Right, only "host functions" in ECMA parlance might contrive (through
unspecified means) to return a reference type. It's important that such
functions, when called on the right-hand side of assignment, or otherwise in
"rvalue" contexts, evaluate per ECMA's [[GetValue]]. So Rhino would have to
call a getter when such a function returns the "Reference" interface type in an
rvalue context, and as you wrote, it would have to call the setter for lvalue
contexts.
Assignee | ||
Comment 9•25 years ago
|
||
Anyone working on a Rhino patch?
Janna guys, how is this patch treating you?
We need to get consensus for or against this patch going into Mozilla's JS
engines, or even (gasp) into SpiderMonkey only. I'll kick the newsgroup thread.
I still think we should do this in Rhino and SM, or neither, but not only in SM.
/be
Comment 10•25 years ago
|
||
I haven't been working on a Rhino patch. Since the ability to return references
from functions is only a property of native functions, it seems okay to me to
only support it in SpiderMonkey. The only motivation seems to be COM
compatibility, which is either irrelevant or less important to Rhino.
Assignee | ||
Comment 11•25 years ago
|
||
Norris: I hope you are right, but "JScript" may find its way into Rhino-based JS
implementations too (server-side JScript, Rhino as the engine). Time will tell.
Is everyone else ok with adding this patch to SpiderMonkey? Should we do so
even if the XPIDL and XPConnect support for "parameterized attributes" is not
there, and may not be agreed to by those subsystems' owners?
/be
Comment 12•25 years ago
|
||
I think the patch is useful enough to be added, so at least that ECMA behaviour
can be done if so desired. IMO it is significantly less useful than it'd be if
it had XPIDL/XPCom mappings, since it still requires the programmer to
mix-and-match JS and XPCom, making the code uglier and less maintainable.
However, that's neither here nor there; at least the patch adds the basic
capabilities to the JS engine.
We actually haven't been using the patch, since this functionality's relatively
easily replacable by adding a new XPCom method to the class for replacing an
item at a given index. This does have the drawback of requiring changes in the
original scripting code, but this feature isn't too widely used and isn't worth
the price of being able to cleanly specify the class in XPCom as opposed to a
mixture.
My apologies for the delay in responding.
//Mark
Assignee | ||
Comment 13•25 years ago
|
||
Are we there yet?
What about XPIDL?
/be
Target Milestone: M17 → M18
Comment 14•25 years ago
|
||
I've done no xpidl/xpconnect work towards this. It sounds pretty low priority.
Assignee | ||
Comment 15•25 years ago
|
||
Fair enough. janna guys, you feel the priority more -- can you cough up a
patch?
/be
Assignee | ||
Comment 16•25 years ago
|
||
I fear this patch will rust or moulder if I don't check it in soon. Does anyone
think I should not commit it?
/be
Assignee | ||
Comment 17•25 years ago
|
||
Comment 18•25 years ago
|
||
I want script support too, dammit, but I'll take a look.
Assignee | ||
Comment 19•25 years ago
|
||
Assignee | ||
Comment 20•25 years ago
|
||
Assignee | ||
Comment 21•25 years ago
|
||
Assignee | ||
Comment 22•25 years ago
|
||
Shaver gave an r= already, but I went and changed things very slightly. Other
than comment tweaks, I made sure that js_DecompileValueGenerator, which knows
all about assignment opcodes, knew about JSOP_SETCALL. Note that JSOP_SETCALL
has format flag JOF_SET, but its mode is 0 (not JOF_NAME, JOF_PROP, or JOF_ELEM)
because o.item(i)=j is not i=j, o.i=j, or o[i]=j. I could make a new mode, but
for now I'll use the "zero mode".
Everyone besides me who understands the decompiler, raise your hand.
/be
Assignee | ||
Comment 23•25 years ago
|
||
Checked in. Hope someone uses it.
/be
Status: ASSIGNED → RESOLVED
Closed: 25 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•