zomg 1.0.1 → 1.0.2

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.
@@ -1,3 +1,10 @@
1
+ === 1.0.2
2
+
3
+ * 2 bugfixes
4
+
5
+ * Generating attribute functions that raise rather than attr_accessors
6
+ * Removed extra "do not modify" comments
7
+
1
8
  === 1.0.1
2
9
 
3
10
  * 1 bugfix
@@ -13,9 +13,9 @@ module ZOMG
13
13
 
14
14
  class Lexer < Racc::Parser
15
15
 
16
- module_eval <<'..end lib/yacc.y modeval..ideff8129053', 'lib/yacc.y', 861
16
+ module_eval <<'..end lib/yacc.y modeval..id0b7ea27db0', 'lib/yacc.y', 861
17
17
  include ZOMG::IDL::Nodes
18
- ..end lib/yacc.y modeval..ideff8129053
18
+ ..end lib/yacc.y modeval..id0b7ea27db0
19
19
 
20
20
  ##### racc 1.4.5 generates ###
21
21
 
@@ -9,18 +9,29 @@ module ZOMG
9
9
  def visit_Module(o)
10
10
  [ :module,
11
11
  classify(o.name),
12
- [:scope, [:block] + o.children.map { |c| c.accept(self) }]
12
+ [:scope, [:block] +
13
+ o.children.map { |c| c.accept(self) }.compact
14
+ ]
13
15
  ]
14
16
  end
15
17
 
16
18
  def visit_Interface(o)
17
19
  header = o.header.accept(self)
18
20
  header = header ? [:block, header] : [:block]
21
+ o.children.each { |c|
22
+ list = c.accept(self)
23
+ if list
24
+ if list.first.is_a?(Symbol)
25
+ header << list
26
+ else
27
+ header += list
28
+ end
29
+ end
30
+ }
19
31
  [ :module,
20
32
  classify(o.header.name),
21
33
  [:scope,
22
- header +
23
- o.children.map { |c| c.accept(self) }
34
+ header
24
35
  ]
25
36
  ]
26
37
  end
@@ -50,11 +61,31 @@ module ZOMG
50
61
  end
51
62
 
52
63
  def visit_Attribute(o)
53
- [:fcall,
54
- o.readonly ? :attr_reader : :attr_accessor,
55
- [:array] +
56
- o.children.map { |c| [:lit, c.accept(self)] }
57
- ]
64
+ attributes = []
65
+ o.children.each { |name|
66
+ name = name.accept(self)
67
+
68
+ # Reader
69
+ attributes <<
70
+ [:defn, name.to_sym,
71
+ [:scope, [:block, [:args],
72
+ [:fcall, :raise, [:array,
73
+ [:call, [:const, :NotImplementedError], :new]]
74
+ ]
75
+ ]]
76
+ ]
77
+ unless o.readonly
78
+ attributes <<
79
+ [:defn, :"#{name}=",
80
+ [:scope, [:block, [:args, :_],
81
+ [:fcall, :raise, [:array,
82
+ [:call, [:const, :NotImplementedError], :new]]
83
+ ]
84
+ ]]
85
+ ]
86
+ end
87
+ }
88
+ attributes
58
89
  end
59
90
 
60
91
  def visit_ScopedName(o)
@@ -1,3 +1,3 @@
1
1
  module ZOMG
2
- VERSION = '1.0.1'
2
+ VERSION = '1.0.2'
3
3
  end
@@ -19,10 +19,26 @@ module ZOMG
19
19
  assert sexp
20
20
  ruby_sexp =
21
21
  [:block,
22
- [:module, :Foo,
23
- [:scope, [:block,
24
- [:fcall, :attr_accessor, [:array, [:lit, :awesome]]]
25
- ]]]]
22
+ [:module,
23
+ :Foo,
24
+ [:scope,
25
+ [:block,
26
+ [:defn,
27
+ :awesome,
28
+ [:scope,
29
+ [:block,
30
+ [:args],
31
+ [:fcall,
32
+ :raise,
33
+ [:array, [:call, [:const, :NotImplementedError], :new]]]]]],
34
+ [:defn,
35
+ :awesome=,
36
+ [:scope,
37
+ [:block,
38
+ [:args, :_],
39
+ [:fcall,
40
+ :raise,
41
+ [:array, [:call, [:const, :NotImplementedError], :new]]]]]]]]]]
26
42
  assert_equal(ruby_sexp, sexp)
27
43
  end
28
44
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zomg
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aaron Patterson
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-08-19 00:00:00 -07:00
12
+ date: 2008-08-22 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency