Closed Bug 169000 Opened 22 years ago Closed 21 years ago

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

Categories

(SeaMonkey :: UI Design, defect)

x86
Linux
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: caillon, Assigned: caillon)

References

Details

Attachments

(1 file, 2 obsolete files)

I've fussed over this making it better and better.  I think we're ready for
prime time.  Patch to follow.
Looks good. Get input from some other folks, perhaps blake, I'm sure Phoenix can
(and should) use this.
Attached patch nativeDOM.js v.1.1 (obsolete) — Splinter Review
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 on attachment 99450 [details] [diff] [review]
nativeDOM.js  v.1.1

sr=jag
Attachment #99450 - Flags: superreview+
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?

/be
Responded to Brendan via private e-mail.
Attached patch Updated patchSplinter Review
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

sr=jst
Attachment #107789 - Flags: superreview?(jst) → superreview+
+      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));
else
  this._doImportProperty(name);
Comment on attachment 107789 [details] [diff] [review]
Updated patch

Fix Neil's nit and r=jag
Attachment #107789 - Flags: review?(jaggernaut) → review+
Unless of course the regexp is faster than two slices.
Fix checked in.
Status: NEW → RESOLVED
Closed: 21 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.

Attachment

General

Created:
Updated:
Size: