Closed Bug 208211 Opened 22 years ago Closed 14 years ago

Implement object call semantics for IDispatch objects: obj(x) for obj.item(x)

Categories

(Core :: XPConnect, enhancement)

x86
Windows XP
enhancement
Not set
normal

Tracking

()

RESOLVED INVALID
mozilla1.7alpha

People

(Reporter: dbradley, Assigned: dbradley)

References

Details

Microsoft provides some syntatic sugar that allows callers to make a call on a object. For instance, if objA had a method foo. And it was considered the default method. objA("test"); would invoke foo on objA passing test. foo could also be a property, this often occurs when the object represent a collection of items. Rather than explicitly saying objA.items(x), MS allows the shorthand objA(x);
See http://lxr.mozilla.org/mozilla/source/js/src/js.c#1604 for an example of how to use JS_SetCallReturnValue2 in conjunction with returning an object (typically the |this| parameter, canonically named |obj| in native JS functions), to return a reference type (obj, id) where id is |argv[0]|. Such a return type is handled by getting the value of that property, when the call occurs in an "rvalue" content; else by setting that reference to a value when the call occurs on the left-hand side of an assignment operator. /be
Summary: Implement object call symantics for IDispatch objects: obj(x) for obj.item(x) → Implement object call semantics for IDispatch objects: obj(x) for obj.item(x)
I finally found an example/description in MSDN: The Fields collection is the default member of the Recordset object. As a result, the following two code statements are equivalent. Debug.Print objRs.Fields.Item(0) ' Both statements print Debug.Print objRs(0) ' the Value of Item(0).
Status: NEW → ASSIGNED
From what I can tell, the key is the dispid which is zero. I've checked several cases, and this seems to be the common factor, so that's easy enough to check for.
Target Milestone: --- → mozilla1.5alpha
Target Milestone: mozilla1.5alpha → mozilla1.5beta
Moving out, speak up if you believe this needs to be considered for 1.5b
Target Milestone: mozilla1.5beta → mozilla1.6alpha
Moving out
Target Milestone: mozilla1.6alpha → mozilla1.7alpha
QA Contact: pschwartau → xpconnect
The IDispatch API was removed in bug 662000. -> INVALID [Filter bugspam on idispatchinvalid]
Status: ASSIGNED → RESOLVED
Closed: 14 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.