Write a wrapper library to access XPConnect native wrapped objects from within chrome JS



UI Design
16 years ago
14 years ago


(Reporter: Christopher Aillon (sabbatical, not receiving bugmail), Assigned: Christopher Aillon (sabbatical, not receiving bugmail))


Firefox Tracking Flags

(Not tracked)



(1 attachment, 2 obsolete attachments)

I've fussed over this making it better and better.  I think we're ready for
prime time.  Patch to follow.

Comment 2

16 years ago
Looks good. Get input from some other folks, perhaps blake, I'm sure Phoenix can
(and should) use this.
Created attachment 99450 [details] [diff] [review]
nativeDOM.js  v.1.1

I had rginda have a look at this from a JS standpoint.	This fixes his issues:

- Checks the exception for the one we want to eat, throws all others.
- return null instead of undefined; undefined can be assigned to, null can't.
- small optimization in getNativePropertyProxyFor()
- remove unnecessary consts in _getNativesForProp()
Attachment #99392 - Attachment is obsolete: true

Comment 4

16 years ago
Comment on attachment 99450 [details] [diff] [review]
nativeDOM.js  v.1.1

Attachment #99450 - Flags: superreview+

Comment 5

16 years ago
Talking with jag on IRC, we came to the conclusion that an XPCOMProxy object
would be a better idea.

Clients would say something like...

var proxy = new XPCOMProxy (obj);
// create getter/setter pairs for these property names.
proxy.fetch ("foo", "bar", ...);

// for..in over this object, creating properties for each key found.
property.fetch (Components.interfaces.nsIFoo);
Comment on attachment 99450 [details] [diff] [review]
nativeDOM.js  v.1.1

I have this working, but waiting on changes in bug 169321 to land first, since
this relies on that.
Attachment #99450 - Flags: needs-work+
Oh, there is a workaround for that bug that brendan mentioned.  I'll attach a
patch anyway either later tonight or tomorrow morning that implements rginda's
suggestion.  I'd prefer to do this though with the fix in bug 169321.
I'm missing the motivation here -- can someone give a pep-talk?

Responded to Brendan via private e-mail.
Created attachment 107789 [details] [diff] [review]
Updated patch

Implements the syntax proposal from rginda and jag.
Attachment #99450 - Attachment is obsolete: true
Attachment #107789 - Flags: superreview?(jst)
Attachment #107789 - Flags: review?(jaggernaut)
Comment on attachment 107789 [details] [diff] [review]
Updated patch

Attachment #107789 - Flags: superreview?(jst) → superreview+

Comment 12

16 years ago
+      var ary = aName.match(/([^(]*)(\(\))?$/);
+      var name = ary[1];
+      // If we are passed a string like "foo()", ary[2] will be of type string,
+      // and contain "()".  If passed "foo", then it will be of type undefined.
+      if (typeof ary[2] === "string")
+        this._doImportMethod(name);
+      else
+        this._doImportProperty(name);

IMHO this is very ugly.

if (name.slice(-2) == "()")
  this._doImportMethod(name.slice(0, -2));

Comment 13

15 years ago
Comment on attachment 107789 [details] [diff] [review]
Updated patch

Fix Neil's nit and r=jag
Attachment #107789 - Flags: review?(jaggernaut) → review+

Comment 14

15 years ago
Unless of course the regexp is faster than two slices.

Comment 15

15 years ago
Fix checked in.
Last Resolved: 15 years ago
Resolution: --- → FIXED
Product: Core → Mozilla Application Suite
You need to log in before you can comment on or make changes to this bug.