diff --git a/Gemfile b/Gemfile index e570bdf4..95424ced 100644 --- a/Gemfile +++ b/Gemfile @@ -6,7 +6,7 @@ group :development do gem "rake" gem "rubocop", require: false gem "rubocop_auto_corrector", require: false - gem "ruby_header_parser" + gem "ruby_header_parser", ">= 0.3.0" gem "yard" end diff --git a/Gemfile.lock b/Gemfile.lock index 825b24b8..92ddb9fc 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -112,7 +112,7 @@ GEM rubocop_auto_corrector (0.5.0) rubocop (>= 1.30.0) ruby-progressbar (1.13.0) - ruby_header_parser (0.2.0) + ruby_header_parser (0.3.0) securerandom (0.3.1) serverspec (2.42.3) multi_json @@ -168,7 +168,7 @@ DEPENDENCIES rspec-temp_dir rubocop rubocop_auto_corrector - ruby_header_parser + ruby_header_parser (>= 0.3.0) serverspec steep test-unit diff --git a/ruby/function_generated.go b/ruby/function_generated.go index 8a5a061a..db53052e 100644 --- a/ruby/function_generated.go +++ b/ruby/function_generated.go @@ -14,6 +14,42 @@ import ( "unsafe" ) +// RARRAY_ASET calls `RARRAY_ASET` in C +// +// Original definition is following +// +// RARRAY_ASET(VALUE ary, long i, VALUE v) +func RARRAY_ASET(ary VALUE, i Long, v VALUE) { + C.RARRAY_ASET(C.VALUE(ary), C.long(i), C.VALUE(v)) +} + +// RARRAY_EMBED_LEN calls `RARRAY_EMBED_LEN` in C +// +// Original definition is following +// +// RARRAY_EMBED_LEN(VALUE ary) +func RARRAY_EMBED_LEN(ary VALUE) Long { + return Long(C.RARRAY_EMBED_LEN(C.VALUE(ary))) +} + +// RARRAY_LENINT calls `RARRAY_LENINT` in C +// +// Original definition is following +// +// RARRAY_LENINT(VALUE ary) +func RARRAY_LENINT(ary VALUE) int { + return int(C.RARRAY_LENINT(C.VALUE(ary))) +} + +// RARRAY_PTR calls `RARRAY_PTR` in C +// +// Original definition is following +// +// RARRAY_PTR(VALUE ary) +func RARRAY_PTR(ary VALUE) *VALUE { + return (*VALUE)(C.RARRAY_PTR(C.VALUE(ary))) +} + // RB_BUILTIN_TYPE calls `RB_BUILTIN_TYPE` in C // // Original definition is following diff --git a/ruby/ruby_internal_core_rarray.go b/ruby/ruby_internal_core_rarray.go new file mode 100644 index 00000000..590b882d --- /dev/null +++ b/ruby/ruby_internal_core_rarray.go @@ -0,0 +1,18 @@ +package ruby + +/* +#include "ruby.h" +*/ +import "C" + +// c.f. https://github.com/ruby/ruby/blob/master/include/ruby/internal/core/rarray.h + +// RARRAY_LEN is alias to [RbArrayLen] +func RARRAY_LEN(a VALUE) Long { + return RbArrayLen(a) +} + +// RARRAY_CONST_PTR is alias to [RbArrayConstPtr] +func RARRAY_CONST_PTR(a VALUE) *VALUE { + return RbArrayConstPtr(a) +}