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

Side by Side Diff: lib/dom/scripts/systemwrapping.py

Issue 10334003: Rework static method support. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/python
2 # Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 2 # Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
3 # for details. All rights reserved. Use of this source code is governed by a 3 # for details. All rights reserved. Use of this source code is governed by a
4 # BSD-style license that can be found in the LICENSE file. 4 # BSD-style license that can be found in the LICENSE file.
5 5
6 """This module provides shared functionality for the systems to generate 6 """This module provides shared functionality for the systems to generate
7 wrapping binding from the IDL database.""" 7 wrapping binding from the IDL database."""
8 8
9 import os 9 import os
10 from generator import * 10 from generator import *
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 ' return $METHOD(this, index, value);\n' 351 ' return $METHOD(this, index, value);\n'
352 ' }\n' 352 ' }\n'
353 ' static $METHOD(_this, index, value) native;\n', 353 ' static $METHOD(_this, index, value) native;\n',
354 TYPE=dart_element_type, METHOD=method_name) 354 TYPE=dart_element_type, METHOD=method_name)
355 355
356 def AddOperation(self, info): 356 def AddOperation(self, info):
357 """ 357 """
358 Arguments: 358 Arguments:
359 info: An OperationInfo object. 359 info: An OperationInfo object.
360 """ 360 """
361 if info.IsStatic():
362 return
363
361 body = self._members_emitter.Emit( 364 body = self._members_emitter.Emit(
362 '\n' 365 '\n'
363 ' $TYPE $NAME($PARAMS) {\n' 366 ' $TYPE $NAME($PARAMS) {\n'
364 '$!BODY' 367 '$!BODY'
365 ' }\n', 368 ' }\n',
366 TYPE=info.type_name, 369 TYPE=info.type_name,
367 NAME=info.name, 370 NAME=info.name,
368 PARAMS=info.ParametersImplementationDeclaration()) 371 PARAMS=info.ParametersImplementationDeclaration())
369 372
370 # Process in order of ascending number of arguments to ensure missing 373 # Process in order of ascending number of arguments to ensure missing
371 # optional arguments are processed early. 374 # optional arguments are processed early.
372 overloads = sorted(info.overloads, 375 overloads = sorted(info.overloads,
373 key=lambda overload: len(overload.arguments)) 376 key=lambda overload: len(overload.arguments))
374 self._native_version = 0 377 self._native_version = 0
375 fallthrough = self.GenerateDispatch(body, info, ' ', 0, overloads) 378 fallthrough = self.GenerateDispatch(body, info, ' ', 0, overloads)
376 if fallthrough: 379 if fallthrough:
377 body.Emit(' throw "Incorrect number or type of arguments";\n'); 380 body.Emit(' throw "Incorrect number or type of arguments";\n');
378 381
379 def GenerateSingleOperation(self, emitter, info, indent, operation): 382 def GenerateSingleOperation(self, emitter, info, indent, operation):
380 """Generates a call to a single operation. 383 """Generates a call to a single operation.
381 384
382 Arguments: 385 Arguments:
383 emitter: an Emitter for the body of a block of code. 386 emitter: an Emitter for the body of a block of code.
384 info: the compound information about the operation and its overloads. 387 info: the compound information about the operation and its overloads.
385 indent: an indentation string for generated code. 388 indent: an indentation string for generated code.
386 operation: the IDLOperation to call. 389 operation: the IDLOperation to call.
387 """ 390 """
388 # TODO(sra): Do we need to distinguish calling with missing optional 391 # TODO(sra): Do we need to distinguish calling with missing optional
389 # arguments from passing 'null' which is represented as 'undefined'? 392 # arguments from passing 'null' which is represented as 'undefined'?
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
534 # dispatch has removed f(X), leaving only f(Y), but there is no guarantee 537 # dispatch has removed f(X), leaving only f(Y), but there is no guarantee
535 # that Y = Z-X, so we need to check for Y. 538 # that Y = Z-X, so we need to check for Y.
536 true_code = emitter.Emit( 539 true_code = emitter.Emit(
537 '$(INDENT)if ($COND) {\n' 540 '$(INDENT)if ($COND) {\n'
538 '$!TRUE' 541 '$!TRUE'
539 '$(INDENT)}\n', 542 '$(INDENT)}\n',
540 COND=test, INDENT=indent) 543 COND=test, INDENT=indent)
541 self.GenerateDispatch( 544 self.GenerateDispatch(
542 true_code, info, indent + ' ', position + 1, positive) 545 true_code, info, indent + ' ', position + 1, positive)
543 return True 546 return True
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698