Closed
Bug 71689
Opened 24 years ago
Closed 17 years ago
Need helper utilities for JS component authors
Categories
(Core :: XPConnect, defect, P3)
Core
XPConnect
Tracking
()
RESOLVED
FIXED
People
(Reporter: shaver, Assigned: alex)
References
Details
(Keywords: helpwanted)
Attachments
(2 files, 2 obsolete files)
(deleted),
patch
|
Details | Diff | Splinter Review | |
(deleted),
application/gzip
|
Details |
The suffer without a generic module implementation, and the cutting-and-pasting
breaks my little heart.
Utils.GenericFactory and such should live in resource://jsloader/utils.js and be
autoloaded by the JS loader into the globals given to components.
Thus it shall be.
Reporter | ||
Updated•24 years ago
|
Status: NEW → ASSIGNED
OS: Linux → All
Priority: -- → P3
Hardware: PC → All
Target Milestone: --- → mozilla0.9
Comment 1•24 years ago
|
||
And he looked upon it and saw it was good.
And thus they spake:
Go forth and commiteth thyself to implementing this.
And when thou art done, and done thou art,
Showeth us the fruit of thy labor.
And if the fruit pleases us,
Our blessings thou wilt receive.
Reporter | ||
Comment 3•24 years ago
|
||
Moving to 0.9.2, because my 0.9.1 list is already too huge, and nobody's
protesting in the streets to get this fixed.
Target Milestone: mozilla0.9.1 → mozilla0.9.2
Reporter | ||
Comment 4•23 years ago
|
||
Asa just told me that we shipped 0.9.2! Who knew?
Target Milestone: mozilla0.9.2 → mozilla0.9.3
Updated•23 years ago
|
Target Milestone: mozilla0.9.3 → mozilla0.9.4
Comment 5•23 years ago
|
||
->0.9.5 since we have run out of time
Target Milestone: mozilla0.9.4 → mozilla0.9.5
Comment 6•23 years ago
|
||
And an easy way to add ClassInfo would be very nice indeed.
Reporter | ||
Comment 7•23 years ago
|
||
I don't really know when I will get this done, so I'm removing the lying
milestone marker.
Keywords: helpwanted
Target Milestone: mozilla0.9.5 → ---
Comment 8•22 years ago
|
||
Yes, to suffer. I've just been writing my first Javascript component, and after
hours of finding bad examples, cutting, pasting, more cutting, more pasting,
trial and error, I was hoping that there might be something just like this to
help automate and standardize this process. But alas, there still is not. For
looking at my finally operational stub of a module, I realize that I have about
a hundred lines of code, not one of which is yet application specific.
I might (temporarily putting aside my current unfamiliarity with some of the
relevant technologies) be up for trying to write such utilities. So tell me,
what would these utilities look like? Would they be patterned after the C++
macros? Would the generic factory be a factory to be used by the component, or
would it be a factory to produce a whole default component? Would all the
pieces be in Javascript, or would some be in mozJSComponentLoader.cpp, or might
there need to be some external utility to generate a template component?
What would be wonderful would be for a couple people to provide me with a sample
of what a bare Javascript component using the (as yet unimplemented) utilities
would look like, so I can have a better idea of what needs to be implemented.
Comment 9•22 years ago
|
||
Here's a first draft of a module using functions that would appear in utils.js.
Currently, the functions are just at the top of the file; I haven't worked on
having them loaded into the sandbox. But that's going to be simple, right?
The sample is a working module that uses the Content Policy manager to deny
loading of any images that contain "mozilla". The module itself is the 35
lines at the bottom of the file. The rest is the proposed Utils package. It
is definitely a first draft, and hasn't been tested rigorously.
Comments on interface and implementation would be greatly appreciated.
Suggestions to scrap it and do it right also welcomed, if accompanied by a
good definition of 'right'. Pointers on loading from
resource://jsloader/utils.js into the sandbox wouldn't hurt.
Comment 10•22 years ago
|
||
Here's an xpt file to accompany the previous sample module, if you are inclined
to try it. Save this as "nsGenericModule.xpt" and drop it off in
dist/bin/components. Save the sample module as "nsGenericModule.js" and do the
same. If all goes well, you'll be able to tell it is working by the lack of
images on mozilla.org sites.
Comment 11•22 years ago
|
||
I had some more time to spend on this, and now have the C++ side of things
working so that it loads and compiles "resource:///res/jsloader/utils", and
then executes it on the Utils object of the context used by the component. It's
an ugly mess right now and needs some error handling, but seems like it's all
going to work.
Patch to follow later this week. Again, input on interface would be appreciated.
Comment 12•22 years ago
|
||
This patch (along with the tar file to follow) should provide a Utils object to
all Javascript modules. I think this is a useful addition that will make it
significantly easier for people to write Javascript modules. It still includes
some excessive debugging statements, and a few places marked FIXME where I
could use some outside input, but otherwise seems like a working solution to
me. It's only been tested lightly, and only on Phoenix under Linux. I'd
appreciate if people could try this out and offer their review. Thanks!
Attachment #109387 -
Attachment is obsolete: true
Attachment #109389 -
Attachment is obsolete: true
Comment 13•22 years ago
|
||
Here are some more files necessary for the previous patch. I didn't do them as
diffs because they are new, and hence not in CVS. Untar at the top mozilla/
directory. In js/src/xpconnect/loader/sample/ you will find a sample generic
Javscript module.
Reporter | ||
Comment 14•20 years ago
|
||
Alex: I think you'd own this better than I, given your subscriptloader work.
Updated•18 years ago
|
QA Contact: pschwartau → xpconnect
Comment 15•17 years ago
|
||
shaver, we now have Components.utils.import, and XPCOMUtils.jsm. Is this adequate enough to close this bug?
Assignee | ||
Comment 16•17 years ago
|
||
XPCOMUtils.jsm is what this bug was all about, so closing.
Status: NEW → RESOLVED
Closed: 17 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•