1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* ext/fiddle/lib/fiddle/cparser.rb: r49110 brake Fiddle::Import with

type_alias
* test/fiddle/test_cparser.rb: added type_alias test for parse_ctype
  and parse_struct_signature.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49119 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
hsbt 2015-01-03 09:23:43 +00:00
parent 68f7424bde
commit 1ba6e8868c
3 changed files with 24 additions and 0 deletions

View file

@ -1,3 +1,10 @@
Sat Jan 3 18:19:50 2015 SHIBATA Hiroshi <shibata.hiroshi@gmail.com>
* ext/fiddle/lib/fiddle/cparser.rb: r49110 brake Fiddle::Import with
type_alias
* test/fiddle/test_cparser.rb: added type_alias test for parse_ctype
and parse_struct_signature.
Sat Jan 3 16:02:20 2015 Ayumu AIZAWA <ayumu.aizawa@gmail.com>
* lib/net/http.rb (Net::HTTP.proxy_user): retrieve proxy user from http_proxy.

View file

@ -169,6 +169,7 @@ module Fiddle
when /\*/, /\[[\s\d]*\]/
return TYPE_VOIDP
else
ty = ty.split(' ')[0]
if( tymap[ty] )
return parse_ctype(tymap[ty], tymap)
else

View file

@ -59,6 +59,14 @@ module Fiddle
assert_equal(TYPE_UINTPTR_T, parse_ctype("uintptr_t"))
end
def test_undefined_ctype
assert_raises(DLError) { parse_ctype('DWORD') }
end
def test_undefined_ctype_with_type_alias
assert_equal(-TYPE_LONG, parse_ctype('DWORD', {"DWORD" => "unsigned long"}))
end
def test_struct_basic
assert_equal [[TYPE_INT, TYPE_CHAR], ['i', 'c']], parse_struct_signature(['int i', 'char c'])
end
@ -83,6 +91,14 @@ module Fiddle
assert_equal [[TYPE_INT,TYPE_VOIDP,TYPE_VOIDP], ['x', 'cb', 'name']], parse_struct_signature('int x; void (*cb)(); const char* name')
end
def test_struct_undefined
assert_raises(DLError) { parse_struct_signature(['int i', 'DWORD cb']) }
end
def test_struct_undefined_with_type_alias
assert_equal [[TYPE_INT,-TYPE_LONG], ['i', 'cb']], parse_struct_signature(['int i', 'DWORD cb'], {"DWORD" => "unsigned long"})
end
def test_signature_basic
func, ret, args = parse_signature('void func()')
assert_equal 'func', func