Closed Bug 741125 Opened 12 years ago Closed 12 years ago

Fix up Paris Bindings WebIDL parser

Categories

(Core :: DOM: Core & HTML, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla14

People

(Reporter: justin.lebar+bug, Assigned: khuey)

References

Details

Attachments

(25 files, 2 obsolete files)

475 bytes, patch
khuey
: review+
khuey
: checkin+
Details | Diff | Splinter Review
773 bytes, patch
khuey
: review+
khuey
: checkin+
Details | Diff | Splinter Review
290 bytes, patch
khuey
: review+
khuey
: checkin+
Details | Diff | Splinter Review
1.07 KB, patch
khuey
: review+
khuey
: checkin+
Details | Diff | Splinter Review
3.30 KB, patch
khuey
: review+
khuey
: checkin+
Details | Diff | Splinter Review
863 bytes, patch
khuey
: review+
khuey
: checkin+
Details | Diff | Splinter Review
819 bytes, patch
khuey
: review+
khuey
: checkin+
Details | Diff | Splinter Review
2.08 KB, patch
khuey
: review+
khuey
: checkin+
Details | Diff | Splinter Review
1010 bytes, patch
khuey
: review+
khuey
: checkin+
Details | Diff | Splinter Review
46.09 KB, patch
khuey
: review+
khuey
: checkin+
Details | Diff | Splinter Review
956 bytes, patch
khuey
: review+
khuey
: checkin+
Details | Diff | Splinter Review
238 bytes, patch
khuey
: review+
khuey
: checkin+
Details | Diff | Splinter Review
2.13 KB, patch
khuey
: review+
khuey
: checkin+
Details | Diff | Splinter Review
897 bytes, patch
khuey
: review+
khuey
: checkin+
Details | Diff | Splinter Review
1.64 KB, patch
khuey
: review+
khuey
: checkin+
Details | Diff | Splinter Review
1.55 KB, patch
khuey
: review+
khuey
: checkin+
Details | Diff | Splinter Review
830 bytes, patch
khuey
: review+
khuey
: checkin+
Details | Diff | Splinter Review
3.33 KB, patch
khuey
: review+
khuey
: checkin+
Details | Diff | Splinter Review
5.55 KB, patch
khuey
: review+
khuey
: checkin+
Details | Diff | Splinter Review
856 bytes, patch
khuey
: review+
khuey
: checkin+
Details | Diff | Splinter Review
3.10 KB, patch
khuey
: review+
khuey
: checkin+
Details | Diff | Splinter Review
1.96 KB, patch
Details | Diff | Splinter Review
7.13 KB, patch
khuey
: review+
khuey
: checkin+
Details | Diff | Splinter Review
4.84 KB, patch
khuey
: review+
khuey
: checkin+
Details | Diff | Splinter Review
43.17 KB, patch
ted
: review+
Details | Diff | Splinter Review
I've been reviewing and editing the Paris Bindings WebIDL parser, and Kyle and I can use this bug to track at least one iteration of fixing it up.
Kyle, I'm not entirely sure how we want to do this.  I have a bunch of patches, which I'm going to attach here.  I'll also attach a roll-up patch with all the changes.

Some of these patches are fixes, which you'll need to review.  Some of them are questions of mine for you -- these are marked with "REVIEW".

I also added some tests which currently fail.  In particular, test_array_of_interface asserts, and test_nullable_equivalency fails for the same reason.  There's a separate failure in test_nullable_equivalency, which you'll see after we fix the assertion.

I'm not done with my review, but we may want to use more than one bug for the review.  It seems to me that the easiest way to handle this would be to push the code to github, hack on it there, and eventually push back to m-c, but I'm not sure you'd like that.  :)
Attached patch Rollup patch (obsolete) — Splinter Review
Attachment #611219 - Attachment is obsolete: true
Attached patch Rollup patch (obsolete) — Splinter Review
Attachment #611220 - Flags: review?(khuey)
I knew my parser code was less than great, but wow.
(In reply to Kyle Huey [:khuey] (khuey@mozilla.com) from comment #28)
> I knew my parser code was less than great, but wow.

Well, it might have been smaller as a set of review comments, I'm not sure.  I was hoping a patch queue would be easier overall, but I might have been wrong.  :)

The big thing is the edge cases where the parser falls over or does the wrong thing.  We're not out of the woods in that respect.
Comment on attachment 611216 [details] [diff] [review]
Make Location and BuiltinLocation have the same interface, and rename BuiltinType::type to BuiltinType::_typeTag

This one is necessary to pass some of the tests I added.  There are cases when we'd try to read _file on a BuiltinLocation, which didn't work.

Although looking at this, it has a bug which I'm surprised isn't caught by any tests:

+    def filename(self):
+        return self.filename
+

should be

        return self._file.
Comment on attachment 611196 [details] [diff] [review]
Add .gitignore (for .pyc).  You'll probably want to delete this before committing to hg.

What about the various other things in .hgignore?
Comment on attachment 611202 [details] [diff] [review]
De-duplicate results in finish(), making test_deduplicate pass.

Review of attachment 611202 [details] [diff] [review]:
-----------------------------------------------------------------

::: WebIDL.py
@@ +2865,5 @@
> +        for p in self._productions:
> +            if p not in seen:
> +                seen.add(p)
> +                result.append(p)
> +        return result

Why do we need the set and the array here?  Isn't if p not in result: enough?
Comment on attachment 611204 [details] [diff] [review]
Define Location._line as an instance variable, not a class variable.

Review of attachment 611204 [details] [diff] [review]:
-----------------------------------------------------------------

Is _line actually used?
(In reply to Kyle Huey [:khuey] (khuey@mozilla.com) from comment #32)
> Comment on attachment 611202 [details] [diff] [review]
> De-duplicate results in finish(), making test_deduplicate pass.
> 
> Review of attachment 611202 [details] [diff] [review]:
> -----------------------------------------------------------------
> 
> ::: WebIDL.py
> @@ +2865,5 @@
> > +        for p in self._productions:
> > +            if p not in seen:
> > +                seen.add(p)
> > +                result.append(p)
> > +        return result
> 
> Why do we need the set and the array here?  Isn't if p not in result: enough?

Sure, but that's O(n^2) in the number of interfaces.  Which may be fine -- I dunno.
(In reply to Kyle Huey [:khuey] (khuey@mozilla.com) from comment #33)
> Comment on attachment 611204 [details] [diff] [review]
> Define Location._line as an instance variable, not a class variable.
> 
> Review of attachment 611204 [details] [diff] [review]:
> -----------------------------------------------------------------
> 
> Is _line actually used?

Yes, in lots of places (e.g. Location.__str__).
(In reply to Justin Lebar [:jlebar] from comment #34)
> (In reply to Kyle Huey [:khuey] (khuey@mozilla.com) from comment #32)
> > Comment on attachment 611202 [details] [diff] [review]
> > De-duplicate results in finish(), making test_deduplicate pass.
> > 
> > Review of attachment 611202 [details] [diff] [review]:
> > -----------------------------------------------------------------
> > 
> > ::: WebIDL.py
> > @@ +2865,5 @@
> > > +        for p in self._productions:
> > > +            if p not in seen:
> > > +                seen.add(p)
> > > +                result.append(p)
> > > +        return result
> > 
> > Why do we need the set and the array here?  Isn't if p not in result: enough?
> 
> Sure, but that's O(n^2) in the number of interfaces.  Which may be fine -- I
> dunno.

Aha.  For some reason I only think about perf when writing C++ :-/
(In reply to Kyle Huey [:khuey] (khuey@mozilla.com) from comment #31)
> Comment on attachment 611196 [details] [diff] [review]
> Add .gitignore (for .pyc).  You'll probably want to delete this before
> committing to hg.
> 
> What about the various other things in .hgignore?

.hgignore will take care of .pyc.  The gitignore also has webidlyacc.py and parser.out, but I thought you were planning to move these to the objdir?
Comment on attachment 611198 [details] [diff] [review]
Let runtests.py take --quiet and a list of tests to run.

Review of attachment 611198 [details] [diff] [review]:
-----------------------------------------------------------------

::: runtests.py
@@ +102,5 @@
>  
>  if __name__ == '__main__':
> +    usage = """%prog [OPTIONS] [TESTS]
> +               Where TESTS are relative to the tests directory."""
> +    parser = optparse.OptionParser(usage='%prog [OPTIONS] [TESTS]')

Why have a usage string and then not use it?
Attachment #611198 - Flags: review-
Comment on attachment 611211 [details] [diff] [review]
Some review comments.

Review of attachment 611211 [details] [diff] [review]:
-----------------------------------------------------------------

::: WebIDL.py
@@ +196,5 @@
>              return self._name.QName() + "::"
>          return "::"
>  
>      def ensureUnique(self, identifier, object):
> +        # REVIEW: This is tricky; please add a docstring.

What part exactly do you find tricky about this?

@@ +289,5 @@
>          return "<unresolved scope>::" + self.name
>  
>      def resolve(self, scope, object):
> +        # REVIEW: It would be good to explain the difference between resolve
> +        # and finish, in general.

Agreed.

@@ +378,5 @@
>      def __str__(self):
>          return "Interface '%s'" % self.identifier.name
>  
>      def ctor(self):
> +        # REVIEW: getCtor(), getConstructor()?

Yeah, probably.

@@ +899,5 @@
> +        # REVIEW: Is this, and the rest of the forwarding to inner below,
> +        # correct?  Like, why should the type "string[]" return true for
> +        # isString()?
> +        #
> +        # This appears in other types, too.

No, its totally bogus.
Comment on attachment 611215 [details] [diff] [review]
More review comments.

Review of attachment 611215 [details] [diff] [review]:
-----------------------------------------------------------------

::: WebIDL.py
@@ +606,5 @@
>      def isType(self):
>          return True
>  
>      def nullable(self):
> +        # REVIEW: isNullable?

Yes.

@@ +694,5 @@
>          assert obj
>          if obj.isType():
>              return obj
>  
> +        name = self.name.resolve(scope, None) # Review: why None, rather than obj, here?

Good question.  I'll have to try to page that back in.
(In reply to Kyle Huey [:khuey] (khuey@mozilla.com) from comment #40)
> Comment on attachment 611215 [details] [diff] [review]
>
> More review comments.
> @@ +694,5 @@
> >          assert obj
> >          if obj.isType():
> >              return obj
> >  
> > +        name = self.name.resolve(scope, None) # Review: why None, rather than obj, here?
> 
> Good question.  I'll have to try to page that back in.

Just add a comment once you figure it out, if you don't mind.  Seems important, whatever is going on here.  :)
> > +    parser = optparse.OptionParser(usage='%prog [OPTIONS] [TESTS]')
>
> Why have a usage string and then not use it?

The usage string is just the first line of '--help':

> Usage: runtests.py [OPTIONS] [TESTS]
>
> Options:
>   -h, --help   show this help message and exit
>   -q, --quiet  Don't print passing tests.

Does this look OK to you?
(In reply to Kyle Huey [:khuey] (khuey@mozilla.com) from comment #39)
> Comment on attachment 611211 [details] [diff] [review]
> Some review comments.
> 
> Review of attachment 611211 [details] [diff] [review]:
> -----------------------------------------------------------------
> 
> ::: WebIDL.py
> @@ +196,5 @@
> >              return self._name.QName() + "::"
> >          return "::"
> >  
> >      def ensureUnique(self, identifier, object):
> > +        # REVIEW: This is tricky; please add a docstring.
> 
> What part exactly do you find tricky about this?

Specifically the object argument.  It wasn't clear to me what object I should be passing in.  And there's a rule that you can't pass in the same object twice (and, iirc, the object may be null, so what does that mean?).
How do you want to handle landing these changes plus review comments?  Do you want to qimport these patches (and qfold some of them, or whatever) and make the changes we've agreed on here yourself?  Or do you want some help from me somehow?
(In reply to Justin Lebar [:jlebar] from comment #44)
> How do you want to handle landing these changes plus review comments?  Do
> you want to qimport these patches (and qfold some of them, or whatever) and
> make the changes we've agreed on here yourself?

Yeah, I think that's the way to go.
Assignee: nobody → khuey
Comment on attachment 611198 [details] [diff] [review]
Let runtests.py take --quiet and a list of tests to run.

I changed this to actually use the usage variable.
Attachment #611198 - Flags: review-
Attachment #611198 - Flags: review+
Attachment #611198 - Flags: checkin+
Comment on attachment 611211 [details] [diff] [review]
Some review comments.

Made some, will file bugs on the others.
Attachment #611211 - Flags: review+
Attachment #611211 - Flags: checkin+
Comment on attachment 611214 [details] [diff] [review]
Don't pass a billion False's to IDLMethod constructor -- add default params instead.

Review of attachment 611214 [details] [diff] [review]:
-----------------------------------------------------------------

::: WebIDL.py
@@ +1464,5 @@
>      def __init__(self, location, identifier, returnType, arguments,
> +                 static=False, getter=False, setter=False, creator=False,
> +                 deleter=False, specialType=NamedOrIndexed.Neither,
> +                 legacycaller=False, stringifier=False):
> +        # REVIEW: specialType is NamedOrIndexed -- wow, this is messed up.

Will file a bug on this.
Attachment #611214 - Flags: review+
Attachment #611214 - Flags: checkin+
Comment on attachment 611216 [details] [diff] [review]
Make Location and BuiltinLocation have the same interface, and rename BuiltinType::type to BuiltinType::_typeTag

Review of attachment 611216 [details] [diff] [review]:
-----------------------------------------------------------------

::: WebIDL.py
@@ +785,5 @@
>          self.name = self.inner.name
>          return self
>  
>      def unroll(self):
> +        # REVIEW: Should this be self.inner.unroll()?

Yes, and that's not the only place that has this problem.
Attachment #611216 - Flags: review+
Attachment #611216 - Flags: checkin+
Comment on attachment 611217 [details] [diff] [review]
Adding three new tests.  They don't all pass.

Review of attachment 611217 [details] [diff] [review]:
-----------------------------------------------------------------

And a commit to make these tests pass.
Attachment #611217 - Flags: review+
Attachment #611217 - Flags: checkin+
Attachment #611220 - Attachment is obsolete: true
Attachment #611220 - Flags: review?(khuey)
Comment on attachment 612230 [details] [diff] [review]
Patch for m-c

Do you think Ted needs to review the changes we made to WebIDL.py?  They had two sets of eyes on them...
No I think Ted should review the changes I made to client.py.
Comment on attachment 612230 [details] [diff] [review]
Patch for m-c

Review of attachment 612230 [details] [diff] [review]:
-----------------------------------------------------------------

::: client.py
@@ +52,5 @@
> +    if os.path.exists(fulldir):
> +        shutil.rmtree(fulldir)
> +
> +    assert not os.path.exists(fulldir)
> +    check_call_noisy([hg, 'clone', '-u', tag, repository, fulldir])

Maybe you should just call do_hg_pull here, or merge this function with do_hg_pull? There's a bit of overlap.
Attachment #612230 - Flags: review?(ted.mielczarek) → review+
I attempted to land this, but it broke the tree :-)
Comment on attachment 611216 [details] [diff] [review]
Make Location and BuiltinLocation have the same interface, and rename BuiltinType::type to BuiltinType::_typeTag

Review of attachment 611216 [details] [diff] [review]:
-----------------------------------------------------------------

::: WebIDL.py
@@ +106,5 @@
>          return self._lexpos == other._lexpos and \
>                 self._file == other._file
>  
> +    def filename(self):
> +        return self.filename

Should be self._file of course.
Like I said in comment 30, I'm pretty surprised that's not caught by a test.
https://hg.mozilla.org/mozilla-central/rev/adef80d2b5a0
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla14
FYI, I'm planning to do another pass over the parser during the trip to or from Australia.
And backed out again :-/

https://hg.mozilla.org/mozilla-central/rev/b7c1c0145079
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
I sprinkled some fairy dust on it and it stuck this time.
Status: REOPENED → RESOLVED
Closed: 12 years ago12 years ago
Resolution: --- → FIXED
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: