Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(309)

Issue 9428050: Automatically generate most constructors (Closed)

Created:
8 years, 10 months ago by sra1
Modified:
8 years, 10 months ago
Reviewers:
vsm, podivilov1
CC:
reviews_dartlang.org, Anton Muhin, Jacob, vsm
Visibility:
Public.

Description

This CL generates factory provider classes for any interface with a [Constructor] or [NamedConstructor] extended attribute. The factory provider is generated from a template, using the pattern of an IDL interface specific template for the exceptional cases and a general template for the other cases. I used the special case to adjust the number of arguments in the JavaScript call - longer term I think we might want to be a bit more intelligent about default argument values. This CL generates for frog and dummy, the others need to be added. Once the others have been added we might see an opportunity for abstracting out some of the mechanism but I it might turn out they are all slightly different. BUG= TEST= Committed: https://code.google.com/p/dart/source/detail?r=4560

Patch Set 1 #

Patch Set 2 : templates for factory provider classes #

Patch Set 3 : dummy factory providers #

Patch Set 4 : again #

Total comments: 6

Patch Set 5 : fix comments #

Patch Set 6 : Fix named constructor missing 'default' clause #

Patch Set 7 : add test #

Unified diffs Side-by-side diffs Delta from patch set Stats (+898 lines, -275 lines) Patch
M client/dom/dom.dart View 1 2 1 chunk +1 line, -0 lines 0 comments Download
M client/dom/dom_dummy.dart View 1 2 1 chunk +1 line, -0 lines 0 comments Download
M client/dom/dom_frog.dart View 1 1 chunk +21 lines, -0 lines 0 comments Download
M client/dom/frog/dom_frog.dart View 1 2 3 4 5 22 chunks +241 lines, -44 lines 0 comments Download
A client/dom/generated/src/dummy/RegularFactoryProviders.dart View 1 2 1 chunk +147 lines, -0 lines 0 comments Download
A + client/dom/generated/src/frog/_DOMParserFactoryProvider.dart View 1 1 chunk +3 lines, -3 lines 0 comments Download
A + client/dom/generated/src/frog/_DOMURLFactoryProvider.dart View 1 1 chunk +3 lines, -3 lines 0 comments Download
A + client/dom/generated/src/frog/_EventSourceFactoryProvider.dart View 1 2 1 chunk +3 lines, -3 lines 0 comments Download
A + client/dom/generated/src/frog/_FileReaderFactoryProvider.dart View 1 1 chunk +3 lines, -3 lines 0 comments Download
A + client/dom/generated/src/frog/_FileReaderSyncFactoryProvider.dart View 1 2 1 chunk +3 lines, -3 lines 0 comments Download
A + client/dom/generated/src/frog/_HTMLAudioElementFactoryProvider.dart View 1 2 1 chunk +6 lines, -3 lines 0 comments Download
A client/dom/generated/src/frog/_HTMLOptionElementFactoryProvider.dart View 1 1 chunk +16 lines, -0 lines 0 comments Download
A + client/dom/generated/src/frog/_MediaControllerFactoryProvider.dart View 1 2 1 chunk +3 lines, -3 lines 0 comments Download
A + client/dom/generated/src/frog/_MediaStreamFactoryProvider.dart View 1 2 1 chunk +3 lines, -3 lines 0 comments Download
A + client/dom/generated/src/frog/_MessageChannelFactoryProvider.dart View 1 2 1 chunk +3 lines, -3 lines 0 comments Download
A + client/dom/generated/src/frog/_PeerConnectionFactoryProvider.dart View 1 2 1 chunk +3 lines, -3 lines 0 comments Download
A + client/dom/generated/src/frog/_ShadowRootFactoryProvider.dart View 1 2 1 chunk +3 lines, -3 lines 0 comments Download
A + client/dom/generated/src/frog/_SharedWorkerFactoryProvider.dart View 1 2 1 chunk +6 lines, -3 lines 0 comments Download
A client/dom/generated/src/frog/_TextTrackCueFactoryProvider.dart View 1 1 chunk +15 lines, -0 lines 0 comments Download
A + client/dom/generated/src/frog/_WebKitBlobBuilderFactoryProvider.dart View 1 2 1 chunk +3 lines, -3 lines 0 comments Download
A + client/dom/generated/src/frog/_WebKitCSSMatrixFactoryProvider.dart View 1 2 1 chunk +6 lines, -3 lines 0 comments Download
A + client/dom/generated/src/frog/_WorkerFactoryProvider.dart View 1 2 1 chunk +3 lines, -3 lines 0 comments Download
A + client/dom/generated/src/frog/_XMLHttpRequestFactoryProvider.dart View 1 2 1 chunk +3 lines, -3 lines 0 comments Download
A + client/dom/generated/src/frog/_XMLSerializerFactoryProvider.dart View 1 2 1 chunk +3 lines, -3 lines 0 comments Download
A + client/dom/generated/src/frog/_XPathEvaluatorFactoryProvider.dart View 1 2 1 chunk +3 lines, -3 lines 0 comments Download
A + client/dom/generated/src/frog/_XSLTProcessorFactoryProvider.dart View 1 2 1 chunk +3 lines, -3 lines 0 comments Download
M client/dom/generated/src/interface/DOMURL.dart View 1 1 chunk +3 lines, -1 line 0 comments Download
M client/dom/generated/src/interface/EventSource.dart View 1 1 chunk +3 lines, -1 line 0 comments Download
M client/dom/generated/src/interface/FileReaderSync.dart View 1 1 chunk +3 lines, -1 line 0 comments Download
M client/dom/generated/src/interface/HTMLAudioElement.dart View 1 2 3 4 5 1 chunk +3 lines, -1 line 0 comments Download
M client/dom/generated/src/interface/HTMLOptionElement.dart View 1 2 3 4 5 1 chunk +3 lines, -1 line 0 comments Download
M client/dom/generated/src/interface/MediaController.dart View 1 1 chunk +3 lines, -1 line 0 comments Download
M client/dom/generated/src/interface/MediaStream.dart View 1 1 chunk +3 lines, -1 line 0 comments Download
M client/dom/generated/src/interface/MessageChannel.dart View 1 1 chunk +3 lines, -1 line 0 comments Download
M client/dom/generated/src/interface/PeerConnection.dart View 1 1 chunk +3 lines, -1 line 0 comments Download
M client/dom/generated/src/interface/ShadowRoot.dart View 1 1 chunk +3 lines, -1 line 0 comments Download
M client/dom/generated/src/interface/SharedWorker.dart View 1 1 chunk +3 lines, -1 line 0 comments Download
M client/dom/generated/src/interface/TextTrackCue.dart View 1 1 chunk +3 lines, -1 line 0 comments Download
M client/dom/generated/src/interface/WebKitBlobBuilder.dart View 1 1 chunk +3 lines, -1 line 0 comments Download
M client/dom/generated/src/interface/WebKitCSSMatrix.dart View 1 1 chunk +1 line, -1 line 0 comments Download
M client/dom/generated/src/interface/Worker.dart View 1 1 chunk +3 lines, -1 line 0 comments Download
M client/dom/generated/src/interface/XMLHttpRequest.dart View 1 1 chunk +0 lines, -1 line 0 comments Download
M client/dom/generated/src/interface/XMLSerializer.dart View 1 1 chunk +3 lines, -1 line 0 comments Download
M client/dom/generated/src/interface/XPathEvaluator.dart View 1 1 chunk +3 lines, -1 line 0 comments Download
M client/dom/scripts/dartgenerator.py View 1 2 2 chunks +24 lines, -7 lines 0 comments Download
M client/dom/scripts/generator.py View 1 2 3 4 4 chunks +56 lines, -19 lines 0 comments Download
M client/dom/scripts/systemfrog.py View 1 2 3 4 5 chunks +29 lines, -10 lines 0 comments Download
M client/dom/scripts/systeminterface.py View 1 2 3 4 5 2 chunks +16 lines, -1 line 0 comments Download
M client/dom/src/dummy_FactoryProviders.dart View 1 2 3 3 chunks +0 lines, -25 lines 0 comments Download
M client/dom/src/frog_FactoryProviders.dart View 1 3 chunks +0 lines, -26 lines 0 comments Download
M client/dom/src/native_FactoryProviders.dart View 1 2 3 4 5 6 3 chunks +50 lines, -0 lines 0 comments Download
M client/dom/src/native_FactoryProvidersImplementation.dart View 1 2 chunks +23 lines, -0 lines 0 comments Download
M client/dom/src/wrapping_FactoryProviders.dart View 1 5 chunks +67 lines, -2 lines 0 comments Download
A + client/dom/templates/dom/dummy/factoryprovider.darttemplate View 1 2 1 chunk +2 lines, -3 lines 0 comments Download
A + client/dom/templates/dom/frog/factoryprovider.darttemplate View 1 2 1 chunk +3 lines, -3 lines 0 comments Download
A + client/dom/templates/dom/frog/factoryprovider_HTMLAudioElement.darttemplate View 1 2 1 chunk +6 lines, -3 lines 0 comments Download
A client/dom/templates/dom/frog/factoryprovider_HTMLOptionElement.darttemplate View 1 1 chunk +16 lines, -0 lines 0 comments Download
A + client/dom/templates/dom/frog/factoryprovider_SharedWorker.darttemplate View 1 2 1 chunk +6 lines, -3 lines 0 comments Download
A client/dom/templates/dom/frog/factoryprovider_TextTrackCue.darttemplate View 1 1 chunk +15 lines, -0 lines 0 comments Download
A + client/dom/templates/dom/frog/factoryprovider_WebKitCSSMatrix.darttemplate View 1 2 1 chunk +6 lines, -3 lines 0 comments Download
D client/dom/templates/dom/interface/interface_DOMParser.darttemplate View 1 1 chunk +0 lines, -10 lines 0 comments Download
D client/dom/templates/dom/interface/interface_FileReader.darttemplate View 1 1 chunk +0 lines, -10 lines 0 comments Download
D client/dom/templates/dom/interface/interface_WebKitCSSMatrix.darttemplate View 1 1 chunk +0 lines, -10 lines 0 comments Download
D client/dom/templates/dom/interface/interface_XMLHttpRequest.darttemplate View 1 1 chunk +0 lines, -11 lines 0 comments Download
D client/dom/templates/dom/interface/interface_XSLTProcessor.darttemplate View 1 1 chunk +0 lines, -10 lines 0 comments Download
M client/tests/client/client.status View 1 2 3 4 5 6 1 chunk +1 line, -0 lines 0 comments Download
A client/tests/client/dom/HTMLAudioElementTest.dart View 1 2 3 4 5 6 1 chunk +21 lines, -0 lines 0 comments Download

Messages

Total messages: 5 (0 generated)
sra1
Hi Pavel, Anton This is what I am thinking for the constructors. Since many new ...
8 years, 10 months ago (2012-02-23 07:08:06 UTC) #1
vsm
LGTM https://chromiumcodereview.appspot.com/9428050/diff/2029/client/dom/scripts/generator.py File client/dom/scripts/generator.py (right): https://chromiumcodereview.appspot.com/9428050/diff/2029/client/dom/scripts/generator.py#newcode245 client/dom/scripts/generator.py:245: """Returns an OperationInfo object for the constructor, or ...
8 years, 10 months ago (2012-02-23 23:04:28 UTC) #2
sra1
https://chromiumcodereview.appspot.com/9428050/diff/2029/client/dom/scripts/generator.py File client/dom/scripts/generator.py (right): https://chromiumcodereview.appspot.com/9428050/diff/2029/client/dom/scripts/generator.py#newcode245 client/dom/scripts/generator.py:245: """Returns an OperationInfo object for the constructor, or None ...
8 years, 10 months ago (2012-02-24 00:35:05 UTC) #3
podivilov
On 2012/02/23 07:08:06, sra1 wrote: > Hi Pavel, Anton > > This is what I ...
8 years, 10 months ago (2012-02-24 12:16:29 UTC) #4
sra1
8 years, 10 months ago (2012-02-24 22:43:07 UTC) #5
On 2012/02/24 12:16:29, podivilov wrote:
> On 2012/02/23 07:08:06, sra1 wrote:
> > Hi Pavel, Anton
> > 
> > This is what I am thinking for the constructors.
> > 
> > Since many new interfaces have 'default' clause naming a factory provider
> class,
> > the factory provider classes must be defined.
> > 
> > For dummy, they also had to contain the correct factory constructor as dartc
> > checks that.
> > 
> > For native, I started making changes but stopped half way through when I
> > realized that an empty factory provider class is enough to get Dartium to
> > compile and pass existing test.
> > I stopped making changes since it was clear that you probably want to do
> > something similar to this CL, but I'm not sure why the static native methods
> are
> > in their own class - perhaps with templates it would be easier to move them
to
> > the _XXXFactoryProvider classes.
> 
> In Dartium we have two dom libs: dart:dom and dart:domimpl. Native callbacks
> could be used in dart:domimpl only, but if we define _XXXFactoryProvider in
> dart:domimpl, it would not be visible from dart:dom because it's private.
That's
> why we need this additional level of indirection.
> 
> I think it would be very nice to split frog dom into two tiers as well, and
make
> sure that Dartium uses exactly the same public dart:dom. I could take this, if
> there is no objections.

I don't want to split frog dart:dom at this time.
The timing is not right: we are still fixing things in the new frog dart:html
which has the same one-lib structure.
Lets revisit this after we switch to the new dart:html - splitting is not on our
critical path.

A disadvantage of splitting the lib is that the impl types are now public in the
impl lib
This has some bad side effects:
(1) Users can import the impl lib, which contains native classes which have many
strange restrictions with no checking.
(2) Lots of irrelevant classes show up at http://api.dartlang.org/index.html
(3) I want to avoid the extra call for the factory constructors that you have -
people can see the generated JS.

Powered by Google App Engine
This is Rietveld 408576698