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

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

Issue 10068019: Fix ApiDoc to work with new dart:html code. Tweak dart:html generator to generate clearer @domName … (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 8 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) 2011, the Dart project authors. Please see the AUTHORS file 2 # Copyright (c) 2011, 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 import sys 6 import sys
7 7
8 8
9 class IDLNode(object): 9 class IDLNode(object):
10 """Base class for all IDL elements. 10 """Base class for all IDL elements.
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 class IDLInterface(IDLNode): 361 class IDLInterface(IDLNode):
362 """IDLInterface node contains operations, attributes, constants, 362 """IDLInterface node contains operations, attributes, constants,
363 as well as parent references.""" 363 as well as parent references."""
364 364
365 def __init__(self, ast): 365 def __init__(self, ast):
366 IDLNode.__init__(self, ast) 366 IDLNode.__init__(self, ast)
367 self._convert_ext_attrs(ast) 367 self._convert_ext_attrs(ast)
368 self._convert_annotations(ast) 368 self._convert_annotations(ast)
369 self.parents = self._convert_all(ast, 'ParentInterface', 369 self.parents = self._convert_all(ast, 'ParentInterface',
370 IDLParentInterface) 370 IDLParentInterface)
371 self.operations = self._convert_all(ast, 'Operation', IDLOperation) 371 self.javascript_binding_name = self.id
sra1 2012/04/12 17:58:21 Since this field is about documentation and not th
Jacob 2012/04/13 08:56:01 Done.
372 self.attributes = self._convert_all(ast, 'Attribute', IDLAttribute) 372 self.operations = self._convert_all(ast, 'Operation',
373 self.constants = self._convert_all(ast, 'Const', IDLConstant) 373 lambda ast: IDLOperation(ast, self.javascript_binding_name))
374 self.attributes = self._convert_all(ast, 'Attribute',
375 lambda ast: IDLAttribute(ast, self.javascript_binding_name))
376 self.constants = self._convert_all(ast, 'Const',
377 lambda ast: IDLConstant(ast, self.javascript_binding_name))
374 self.is_supplemental = 'Supplemental' in self.ext_attrs 378 self.is_supplemental = 'Supplemental' in self.ext_attrs
375 self.is_no_interface_object = 'NoInterfaceObject' in self.ext_attrs 379 self.is_no_interface_object = 'NoInterfaceObject' in self.ext_attrs
376 self.is_fc_suppressed = 'Suppressed' in self.ext_attrs 380 self.is_fc_suppressed = 'Suppressed' in self.ext_attrs
377 self.javascript_binding_name = self.id
378 381
379 def has_attribute(self, candidate): 382 def has_attribute(self, candidate):
380 for attribute in self.attributes: 383 for attribute in self.attributes:
381 if (attribute.id == candidate.id and 384 if (attribute.id == candidate.id and
382 attribute.is_fc_getter == candidate.is_fc_getter and 385 attribute.is_fc_getter == candidate.is_fc_getter and
383 attribute.is_fc_setter == candidate.is_fc_setter): 386 attribute.is_fc_setter == candidate.is_fc_setter):
384 return True 387 return True
385 return False 388 return False
386 389
387 390
388 class IDLParentInterface(IDLNode): 391 class IDLParentInterface(IDLNode):
389 """This IDLNode specialization is for 'Interface Child : Parent {}' 392 """This IDLNode specialization is for 'Interface Child : Parent {}'
390 declarations.""" 393 declarations."""
391 def __init__(self, ast): 394 def __init__(self, ast):
392 IDLNode.__init__(self, ast) 395 IDLNode.__init__(self, ast)
393 self._convert_annotations(ast) 396 self._convert_annotations(ast)
394 self.type = self._convert_first(ast, 'InterfaceType', IDLType) 397 self.type = self._convert_first(ast, 'InterfaceType', IDLType)
395 398
396 399
397 class IDLMember(IDLNode): 400 class IDLMember(IDLNode):
398 """A base class for constants, attributes and operations.""" 401 """A base class for constants, attributes and operations."""
399 402
400 def __init__(self, ast): 403 def __init__(self, ast, interface_javascript_binding_name):
401 IDLNode.__init__(self, ast) 404 IDLNode.__init__(self, ast)
402 self.type = self._convert_first(ast, 'Type', IDLType) 405 self.type = self._convert_first(ast, 'Type', IDLType)
403 self._convert_ext_attrs(ast) 406 self._convert_ext_attrs(ast)
404 self._convert_annotations(ast) 407 self._convert_annotations(ast)
408 self.interface_javascript_binding_name = interface_javascript_binding_name
405 self.is_fc_suppressed = 'Suppressed' in self.ext_attrs 409 self.is_fc_suppressed = 'Suppressed' in self.ext_attrs
406 410
407 411
408 class IDLOperation(IDLMember): 412 class IDLOperation(IDLMember):
409 """IDLNode specialization for 'type name(args)' declarations.""" 413 """IDLNode specialization for 'type name(args)' declarations."""
410 def __init__(self, ast): 414 def __init__(self, ast, interface_javascript_binding_name):
411 IDLMember.__init__(self, ast) 415 IDLMember.__init__(self, ast, interface_javascript_binding_name)
412 self.type = self._convert_first(ast, 'ReturnType', IDLType) 416 self.type = self._convert_first(ast, 'ReturnType', IDLType)
413 self.arguments = self._convert_all(ast, 'Argument', IDLArgument) 417 self.arguments = self._convert_all(ast, 'Argument', IDLArgument)
414 self.raises = self._convert_first(ast, 'Raises', IDLType) 418 self.raises = self._convert_first(ast, 'Raises', IDLType)
415 self.specials = self._find_all(ast, 'Special') 419 self.specials = self._find_all(ast, 'Special')
416 self.is_stringifier = self._has(ast, 'Stringifier') 420 self.is_stringifier = self._has(ast, 'Stringifier')
417 self.is_static = self._has(ast, 'Static') 421 self.is_static = self._has(ast, 'Static')
418 def _extra_repr(self): 422 def _extra_repr(self):
419 return [self.arguments] 423 return [self.arguments]
420 424
421 425
422 class IDLAttribute(IDLMember): 426 class IDLAttribute(IDLMember):
423 """IDLNode specialization for 'attribute type name' declarations.""" 427 """IDLNode specialization for 'attribute type name' declarations."""
424 def __init__(self, ast): 428 def __init__(self, ast, interface_javascript_binding_name):
425 IDLMember.__init__(self, ast) 429 IDLMember.__init__(self, ast, interface_javascript_binding_name)
426 self.is_read_only = self._has(ast, 'ReadOnly') 430 self.is_read_only = self._has(ast, 'ReadOnly')
427 # There are various ways to define exceptions for attributes: 431 # There are various ways to define exceptions for attributes:
428 self.raises = self._convert_first(ast, 'Raises', IDLType) 432 self.raises = self._convert_first(ast, 'Raises', IDLType)
429 self.get_raises = self.raises \ 433 self.get_raises = self.raises \
430 or self._convert_first(ast, 'GetRaises', IDLType) 434 or self._convert_first(ast, 'GetRaises', IDLType)
431 self.set_raises = self.raises \ 435 self.set_raises = self.raises \
432 or self._convert_first(ast, 'SetRaises', IDLType) 436 or self._convert_first(ast, 'SetRaises', IDLType)
433 # FremontCut IDL syntax defines getters and setters separately: 437 # FremontCut IDL syntax defines getters and setters separately:
434 self.is_fc_getter = self._has(ast, 'AttrGetter') 438 self.is_fc_getter = self._has(ast, 'AttrGetter')
435 self.is_fc_setter = self._has(ast, 'AttrSetter') 439 self.is_fc_setter = self._has(ast, 'AttrSetter')
436 def _extra_repr(self): 440 def _extra_repr(self):
437 extra = [] 441 extra = []
438 if self.is_fc_getter: extra.append('get') 442 if self.is_fc_getter: extra.append('get')
439 if self.is_fc_setter: extra.append('set') 443 if self.is_fc_setter: extra.append('set')
440 if self.is_read_only: extra.append('readonly') 444 if self.is_read_only: extra.append('readonly')
441 if self.raises: extra.append('raises') 445 if self.raises: extra.append('raises')
442 return extra 446 return extra
443 447
444 class IDLConstant(IDLMember): 448 class IDLConstant(IDLMember):
445 """IDLNode specialization for 'const type name = value' declarations.""" 449 """IDLNode specialization for 'const type name = value' declarations."""
446 def __init__(self, ast): 450 def __init__(self, ast, interface_javascript_binding_name):
447 IDLMember.__init__(self, ast) 451 IDLMember.__init__(self, ast, interface_javascript_binding_name)
448 self.value = self._find_first(ast, 'ConstExpr') 452 self.value = self._find_first(ast, 'ConstExpr')
449 453
450 454
451 class IDLArgument(IDLNode): 455 class IDLArgument(IDLNode):
452 """IDLNode specialization for operation arguments.""" 456 """IDLNode specialization for operation arguments."""
453 def __init__(self, ast): 457 def __init__(self, ast):
454 IDLNode.__init__(self, ast) 458 IDLNode.__init__(self, ast)
455 self.type = self._convert_first(ast, 'Type', IDLType) 459 self.type = self._convert_first(ast, 'Type', IDLType)
456 self._convert_ext_attrs(ast) 460 self._convert_ext_attrs(ast)
457 # WebKit and Web IDL differ in how Optional is declared: 461 # WebKit and Web IDL differ in how Optional is declared:
(...skipping 28 matching lines...) Expand all
486 """IDLDictNode specialization for one annotation.""" 490 """IDLDictNode specialization for one annotation."""
487 def __init__(self, ast=None): 491 def __init__(self, ast=None):
488 IDLDictNode.__init__(self, ast) 492 IDLDictNode.__init__(self, ast)
489 self.id = None 493 self.id = None
490 if not ast: 494 if not ast:
491 return 495 return
492 for arg in self._find_all(ast, 'AnnotationArg'): 496 for arg in self._find_all(ast, 'AnnotationArg'):
493 name = self._find_first(arg, 'Id') 497 name = self._find_first(arg, 'Id')
494 value = self._find_first(arg, 'AnnotationArgValue') 498 value = self._find_first(arg, 'AnnotationArgValue')
495 self[name] = value 499 self[name] = value
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698