webidl 0.0.9 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8,6 +8,7 @@ require "webidl/parse_tree/definitions"
8
8
  require "webidl/parse_tree/module"
9
9
  require "webidl/parse_tree/attribute"
10
10
  require "webidl/parse_tree/typedef"
11
+ require "webidl/parse_tree/inheritance"
11
12
  require "webidl/parse_tree/interface"
12
13
  require "webidl/parse_tree/argument"
13
14
  require "webidl/parse_tree/argument_list"
@@ -23,7 +24,6 @@ require "webidl/parse_tree/specials"
23
24
  require "webidl/parse_tree/exception"
24
25
  require "webidl/parse_tree/exception_field"
25
26
  require "webidl/parse_tree/implements_statement"
26
- require "webidl/parse_tree/interface_inheritance"
27
27
  require "webidl/parse_tree/scoped_name_list"
28
28
  require "webidl/parse_tree/stringifier_attribute_or_operation"
29
29
 
@@ -2,12 +2,13 @@ module WebIDL
2
2
  module Ast
3
3
  class Exception < Node
4
4
  attr_reader :name
5
- attr_accessor :members, :extended_attributes
5
+ attr_accessor :members, :extended_attributes, :inherits
6
6
 
7
7
  def initialize(parent, name)
8
8
  @parent = parent
9
9
  @name = name
10
10
  @members = []
11
+ @inherits = []
11
12
  @extended_attributes = []
12
13
  end
13
14
 
@@ -5,6 +5,10 @@ module WebIDL
5
5
  def build(parent)
6
6
  ex = Ast::Exception.new(parent, name.text_value)
7
7
 
8
+ unless inherits.empty?
9
+ ex.inherits = inherits.build(parent)
10
+ end
11
+
8
12
  members.build(ex) unless members.empty?
9
13
 
10
14
  ex
@@ -1,11 +1,11 @@
1
1
  module WebIDL
2
2
  module ParseTree
3
- class InterfaceInheritance < Treetop::Runtime::SyntaxNode
3
+ class Inheritance < Treetop::Runtime::SyntaxNode
4
4
 
5
5
  def build(parent)
6
6
  names.build(parent)
7
7
  end
8
8
 
9
- end # InterfaceInheritance
9
+ end # Inheritance
10
10
  end # ParseTree
11
11
  end # WebIDL
@@ -349,7 +349,7 @@ module WebIDL
349
349
  r4 = _nt_ws
350
350
  s0 << r4
351
351
  if r4
352
- r5 = _nt_InterfaceInheritance
352
+ r5 = _nt_Inheritance
353
353
  s0 << r5
354
354
  if r5
355
355
  r6 = _nt_ws
@@ -418,7 +418,7 @@ module WebIDL
418
418
  r0
419
419
  end
420
420
 
421
- module InterfaceInheritance0
421
+ module Inheritance0
422
422
  def ws
423
423
  elements[1]
424
424
  end
@@ -428,10 +428,10 @@ module WebIDL
428
428
  end
429
429
  end
430
430
 
431
- def _nt_InterfaceInheritance
431
+ def _nt_Inheritance
432
432
  start_index = index
433
- if node_cache[:InterfaceInheritance].has_key?(index)
434
- cached = node_cache[:InterfaceInheritance][index]
433
+ if node_cache[:Inheritance].has_key?(index)
434
+ cached = node_cache[:Inheritance][index]
435
435
  if cached
436
436
  cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
437
437
  @index = cached.interval.end
@@ -457,8 +457,8 @@ module WebIDL
457
457
  end
458
458
  end
459
459
  if s1.last
460
- r1 = instantiate_node(ParseTree::InterfaceInheritance,input, i1...index, s1)
461
- r1.extend(InterfaceInheritance0)
460
+ r1 = instantiate_node(ParseTree::Inheritance,input, i1...index, s1)
461
+ r1.extend(Inheritance0)
462
462
  else
463
463
  @index = i1
464
464
  r1 = nil
@@ -469,7 +469,7 @@ module WebIDL
469
469
  r0 = instantiate_node(SyntaxNode,input, index...index)
470
470
  end
471
471
 
472
- node_cache[:InterfaceInheritance][start_index] = r0
472
+ node_cache[:Inheritance][start_index] = r0
473
473
 
474
474
  r0
475
475
  end
@@ -595,22 +595,30 @@ module WebIDL
595
595
  elements[3]
596
596
  end
597
597
 
598
- def ws3
599
- elements[5]
598
+ def inherits
599
+ elements[4]
600
600
  end
601
601
 
602
- def members
603
- elements[6]
602
+ def ws3
603
+ elements[5]
604
604
  end
605
605
 
606
606
  def ws4
607
607
  elements[7]
608
608
  end
609
609
 
610
+ def members
611
+ elements[8]
612
+ end
613
+
610
614
  def ws5
611
615
  elements[9]
612
616
  end
613
617
 
618
+ def ws6
619
+ elements[11]
620
+ end
621
+
614
622
  end
615
623
 
616
624
  def _nt_Exception
@@ -643,44 +651,52 @@ module WebIDL
643
651
  r4 = _nt_ws
644
652
  s0 << r4
645
653
  if r4
646
- if has_terminal?("{", false, index)
647
- r5 = instantiate_node(SyntaxNode,input, index...(index + 1))
648
- @index += 1
649
- else
650
- terminal_parse_failure("{")
651
- r5 = nil
652
- end
654
+ r5 = _nt_Inheritance
653
655
  s0 << r5
654
656
  if r5
655
657
  r6 = _nt_ws
656
658
  s0 << r6
657
659
  if r6
658
- r7 = _nt_ExceptionMembers
660
+ if has_terminal?("{", false, index)
661
+ r7 = instantiate_node(SyntaxNode,input, index...(index + 1))
662
+ @index += 1
663
+ else
664
+ terminal_parse_failure("{")
665
+ r7 = nil
666
+ end
659
667
  s0 << r7
660
668
  if r7
661
669
  r8 = _nt_ws
662
670
  s0 << r8
663
671
  if r8
664
- if has_terminal?("}", false, index)
665
- r9 = instantiate_node(SyntaxNode,input, index...(index + 1))
666
- @index += 1
667
- else
668
- terminal_parse_failure("}")
669
- r9 = nil
670
- end
672
+ r9 = _nt_ExceptionMembers
671
673
  s0 << r9
672
674
  if r9
673
675
  r10 = _nt_ws
674
676
  s0 << r10
675
677
  if r10
676
- if has_terminal?(";", false, index)
678
+ if has_terminal?("}", false, index)
677
679
  r11 = instantiate_node(SyntaxNode,input, index...(index + 1))
678
680
  @index += 1
679
681
  else
680
- terminal_parse_failure(";")
682
+ terminal_parse_failure("}")
681
683
  r11 = nil
682
684
  end
683
685
  s0 << r11
686
+ if r11
687
+ r12 = _nt_ws
688
+ s0 << r12
689
+ if r12
690
+ if has_terminal?(";", false, index)
691
+ r13 = instantiate_node(SyntaxNode,input, index...(index + 1))
692
+ @index += 1
693
+ else
694
+ terminal_parse_failure(";")
695
+ r13 = nil
696
+ end
697
+ s0 << r13
698
+ end
699
+ end
684
700
  end
685
701
  end
686
702
  end
@@ -21,11 +21,11 @@ module WebIDL
21
21
  end
22
22
 
23
23
  rule Interface
24
- "interface" ws name:identifier ws inherits:InterfaceInheritance ws "{" ws members:InterfaceMembers ws "}" ws ";" <ParseTree::Interface>
24
+ "interface" ws name:identifier ws inherits:Inheritance ws "{" ws members:InterfaceMembers ws "}" ws ";" <ParseTree::Interface>
25
25
  end
26
26
 
27
- rule InterfaceInheritance
28
- (":" ws names:ScopedNameList <ParseTree::InterfaceInheritance>)?
27
+ rule Inheritance
28
+ (":" ws names:ScopedNameList <ParseTree::Inheritance>)?
29
29
  end
30
30
 
31
31
  # extract to a generic Members syntax node?
@@ -38,7 +38,7 @@ module WebIDL
38
38
  end
39
39
 
40
40
  rule Exception
41
- "exception" ws name:identifier ws "{" ws members:ExceptionMembers ws "}" ws ";" <ParseTree::Exception>
41
+ "exception" ws name:identifier ws inherits:Inheritance ws "{" ws members:ExceptionMembers ws "}" ws ";" <ParseTree::Exception>
42
42
  end
43
43
 
44
44
  # extract to a generic Members syntax node?
@@ -1,3 +1,3 @@
1
1
  module WebIDL
2
- VERSION = "0.0.9"
2
+ VERSION = "0.1.0"
3
3
  end
@@ -138,6 +138,12 @@ describe WebIDL::Ast do
138
138
  interface.inherits.first.qualified_name.should == "::foo"
139
139
  end
140
140
 
141
+ it "creates an exception with inheritance" do
142
+ exception = parse(fixture("exception_with_inheritance.idl")).build.last
143
+ exception.inherits.should_not be_empty
144
+ exception.inherits.first.name.should == "NotFoundException"
145
+ end
146
+
141
147
  it "creates an interface with an array type member" do
142
148
  interface = parse(fixture("interface_with_array_member.idl")).build.first
143
149
  interface.should be_kind_of(WebIDL::Ast::Interface)
@@ -0,0 +1,3 @@
1
+ exception NotFoundException { };
2
+ exception NoSuchElementException : NotFoundException { };
3
+ exception NoSuchFrameException : NotFoundException { };
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: webidl
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.9
5
+ version: 0.1.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - Jari Bakken
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-04-09 00:00:00 Z
13
+ date: 2011-04-12 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: treetop
@@ -92,8 +92,8 @@ files:
92
92
  - lib/webidl/parse_tree/exception_field.rb
93
93
  - lib/webidl/parse_tree/extended_attributes.rb
94
94
  - lib/webidl/parse_tree/implements_statement.rb
95
+ - lib/webidl/parse_tree/inheritance.rb
95
96
  - lib/webidl/parse_tree/interface.rb
96
- - lib/webidl/parse_tree/interface_inheritance.rb
97
97
  - lib/webidl/parse_tree/interface_members.rb
98
98
  - lib/webidl/parse_tree/module.rb
99
99
  - lib/webidl/parse_tree/nullable_type.rb
@@ -111,6 +111,7 @@ files:
111
111
  - spec/ast_spec.rb
112
112
  - spec/fixtures/empty_interface.idl
113
113
  - spec/fixtures/empty_module.idl
114
+ - spec/fixtures/exception_with_inheritance.idl
114
115
  - spec/fixtures/framework.idl
115
116
  - spec/fixtures/html5.idl
116
117
  - spec/fixtures/interface_with_array_member.idl
@@ -167,6 +168,7 @@ test_files:
167
168
  - spec/ast_spec.rb
168
169
  - spec/fixtures/empty_interface.idl
169
170
  - spec/fixtures/empty_module.idl
171
+ - spec/fixtures/exception_with_inheritance.idl
170
172
  - spec/fixtures/framework.idl
171
173
  - spec/fixtures/html5.idl
172
174
  - spec/fixtures/interface_with_array_member.idl