Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

metaprogramming the string node

  • Loading branch information...
commit c4927cbb0b9afa5cf035cf757e2aaf24dc6a468a 1 parent 32bc93a
Aaron Patterson authored
2  lib/yacc.y
View
@@ -699,7 +699,7 @@ sequence_type
/*81*/
string_type
: T_STRING T_LESS_THAN_SIGN positive_int_const T_GREATER_THAN_SIGN {
- result = String.new(val[2])
+ result = String.new([val[2]])
}
| T_STRING { result = String.new }
;
1  lib/zomg.rb
View
@@ -21,7 +21,6 @@
typedef
interface_header
scoped_name
- string
constant
binary
value_box_dcl
2  lib/zomg/idl/nodes/node.rb
View
@@ -37,7 +37,7 @@ def to_ruby
UnsignedLongLong LongLong Any ForwardDeclaration WChar
FloatingPointLiteral BooleanLiteral Context StringLiteral
WideStringLiteral WideCharacterLiteral UnaryMinus Object
- UnaryPlus
+ UnaryPlus WString String
}.each { |type| const_set(type.to_sym, Class.new(Node)) }
end
end
13 lib/zomg/idl/nodes/string.rb
View
@@ -1,13 +0,0 @@
-module ZOMG
- module IDL
- module Nodes
- class String < Node
- attr_accessor :size
- def initialize(size = nil)
- @size = size
- end
- end
- WString = String
- end
- end
-end
4 lib/zomg/idl/visitors/sexp.rb
View
@@ -202,11 +202,11 @@ def visit_WChar(o)
end
def visit_String(o)
- [:string, o.size && o.size.accept(self)]
+ [:string, o.children.map { |c| c.accept(self)}]
end
def visit_WString(o)
- [:string, o.size && o.size.accept(self)]
+ [:wstring, o.children.map { |c| c.accept(self)}]
end
def visit_Short(o)
2  test/simple/test_basictypes4.rb
View
@@ -7,7 +7,7 @@ def setup
def test_module_to_sexp
assert_sexp(
- [:typedef, [:string, [:int, 10]], [[:decl, "BndString"]]],
+ [:typedef, [:string, [[:int, 10]]], [[:decl, "BndString"]]],
@tree.duhr.Module[0].Interface[0].Typedef[0]
)
end
Please sign in to comment.
Something went wrong with that request. Please try again.