Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add regex for bool parsing & test struct w/ bool parsing #169

Merged
merged 2 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/fiddle/cparser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ def parse_ctype(ty, tymap=nil)
return TYPE_INTPTR_T
when /\Auintptr_t(?:\s+\w+)?\z/
return TYPE_UINTPTR_T
when "bool"
when /\Abool(?:\s+\w+)?\z/
return TYPE_BOOL
when /\*/, /\[[\s\d]*\]/
return TYPE_VOIDP
Expand Down
5 changes: 5 additions & 0 deletions test/fiddle/test_cparser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,11 @@ def test_struct_string
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_bool
assert_equal([[TYPE_INT, TYPE_BOOL], ['x', 'toggle']],
parse_struct_signature('int x; bool toggle'))
end

def test_struct_undefined
assert_raise(DLError) { parse_struct_signature(['int i', 'DWORD cb']) }
end
Expand Down
Loading