On Wed, Jan 3, 2018 at 5:30 PM, Ben Kelly <bke...@mozilla.com> wrote:
> On Wed, Jan 3, 2018 at 5:09 PM, Gabriele Svelto <gsve...@mozilla.com> wrote:
>> So after validating my approach in that bug (which is almost ready) I've
>> thought that it might be time to give the observer service the same
>> treatment. First of all we'd have a list of topics (I've picked YAML for
>> the list but it could be anything that fits the bill):
>
> Could we use our existing idl/webidl/ipdl for this?  It would be nice not to
> have to maintain another code generator in the tree if possible.

I don't understand this objection on two levels:

1) Why does maintaining another code generator in tree hurt anything?
We have many one-off code generators for specific purposes:

https://searchfox.org/mozilla-central/search?q=GENERATED_FILES&case=false&regexp=false&path=moz.build

Some of these use non-Python generators (e.g. the a11y files and gfx
shaders), but there are probably enough to count on multiple hands.

I would expect modifications of the code generator to be infrequent,
and the code generator itself is liable to be a screenful or so of
straightforward code.

2) How would one shoehorn this into *DL?  The options that come to mind are:

- Separate methods for every observer topic, which sounds terrible
from a code duplication perspective.  Though maybe this would be nice
for JS clients, so we could say things like:

  Services.obs.notifyXPCOMShutdown(...)

which would save on some xpconnect traffic and representing a
large-ish enum in JS?
- WebIDL enums (I think), which would carry a large space penalty and
make everything that wants to use the observer service depend on code
from dom/, which seems undesirable.
- IDL enums, which aren't reflected into JS, so we'd need some custom
work there.
- IPDL doesn't even have the concept of definable enums, and wouldn't
reflect things into JS, so we'd need even more work there.  (Some of
this may be desirable; we talked about extending IPDL bits into JS in
Austin, and kmaglione felt this was reasonable, so...)

The first and third don't sound *too* bad, but I don't think that
writing a one-off code generator would be strictly worse...

-Nathan
_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform

Reply via email to