Commit 1258b57d

1258b57df6ccMerged

Yukihiro "Matz" Matsumoto <[email protected]> · 5 months ago · 3 files · +2 added · ~1 modified

Description

Merge pull request #1018 from rubys/fix/1017-ffi-ptr-proc-tail

codegen: cast FFI :ptr proc body tail to mrb_int round-trip (#1017)

Details

Commit
1258b57df6cc
Parent
564e96fe5d4d
Merge parent
662e40796596

spinel_codegen.rbmodifiedView file

@@ -37917,8 +37917,11 @@
3791737917 # Proc fn ABI returns mrb_int; a pointer-typed body tail (string,
3791837918 # array, hash, ...) round-trips through the integer slot. Cast
3791937919 # explicitly so the return doesn't warn under -Wint-conversion.
37920- # Issue #709 (string-returning ctor block).
37921- elsif type_is_pointer(bexpr_t_proc) == 1
37920+ # Issue #709 (string-returning ctor block); extended for FFI :ptr
37921+ # (issue #1017) — ffi_read_ptr / ffi_func :ret => :ptr return a
37922+ # raw C pointer that type_is_pointer() reports as 0 (not GC-traced)
37923+ # but still needs the same mrb_int round-trip in the proc-fn ABI.
37924+ elsif type_is_pointer(bexpr_t_proc) == 1 || base_type(bexpr_t_proc) == "ptr"
3792237925 bexpr = "(mrb_int)(uintptr_t)(" + bexpr + ")"
3792337926 end
3792437927 pop_scope