summaryrefslogtreecommitdiff
path: root/ext/fiddle
diff options
context:
space:
mode:
authorSutou Kouhei <kou@clear-code.com>2021-02-17 16:54:35 +0900
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2021-05-18 12:48:40 +0900
commitab5212b3c9e696b13a5959e22df75db7b54fed93 (patch)
treeb664e8587daddb5fc135d24646e867dff29ca10e /ext/fiddle
parent4d1bb460f64eafacc2ef8c4116a1bbe7e63e732f (diff)
[ruby/fiddle] Add support for "const" in type
GitHub: fix #68 Reported by kojix2. Thanks!!! https://github.com/ruby/fiddle/commit/d7322c234a
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/4506
Diffstat (limited to 'ext/fiddle')
-rw-r--r--ext/fiddle/lib/fiddle/cparser.rb6
1 files changed, 4 insertions, 2 deletions
diff --git a/ext/fiddle/lib/fiddle/cparser.rb b/ext/fiddle/lib/fiddle/cparser.rb
index 8a269393c6..93a05513c9 100644
--- a/ext/fiddle/lib/fiddle/cparser.rb
+++ b/ext/fiddle/lib/fiddle/cparser.rb
@@ -148,9 +148,11 @@ module Fiddle
#
def parse_ctype(ty, tymap=nil)
tymap ||= {}
- case ty
- when Array
+ if ty.is_a?(Array)
return [parse_ctype(ty[0], tymap), ty[1]]
+ end
+ ty = ty.gsub(/\Aconst\s+/, "")
+ case ty
when 'void'
return TYPE_VOID
when /\A(?:(?:signed\s+)?long\s+long(?:\s+int\s+)?|int64_t)(?:\s+\w+)?\z/