diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ee7f0ed..b322ea8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -59,7 +59,6 @@ jobs: # macOS with venv - { os: macos-latest , ruby: "3.3" , python: "3.x" , python_architecture: x64 , venv: "venv:" } - - { os: macos-latest , ruby: "3.3" , python: "3.8" , python_architecture: x64 , venv: "venv:" } #- { os: macos-latest , ruby: debug , python: "3.x" , python_architecture: x64 , venv: "" } diff --git a/ext/pycall/extconf.rb b/ext/pycall/extconf.rb index 6405fe9..7dd1167 100644 --- a/ext/pycall/extconf.rb +++ b/ext/pycall/extconf.rb @@ -1,3 +1,5 @@ require 'mkmf' +have_func("RTYPEDDATA_GET_DATA") + create_makefile('pycall') diff --git a/ext/pycall/range.c b/ext/pycall/range.c index 40fc0cc..c9d1e1c 100644 --- a/ext/pycall/range.c +++ b/ext/pycall/range.c @@ -6,6 +6,12 @@ struct enumerator_head { VALUE args; }; +#ifdef HAVE_RTYPEDDATA_GET_DATA +# define GET_ENUMERATOR_DATA(obj) ((struct enumerator_head *)RTYPEDDATA_GET_DATA(obj)) +#else +# define GET_ENUMERATOR_DATA(obj) ((struct enumerator_head *)DATA_PTR(obj)) +#endif + int pycall_obj_is_step_range(VALUE obj) { @@ -19,7 +25,7 @@ pycall_obj_is_step_range(VALUE obj) return 0; } - eh = (struct enumerator_head *)DATA_PTR(obj); + eh = GET_ENUMERATOR_DATA(obj); if (!rb_obj_is_kind_of(eh->obj, rb_cRange)) { return 0; @@ -50,7 +56,7 @@ pycall_extract_range(VALUE obj, VALUE *pbegin, VALUE *pend, int *pexclude_end, V exclude_end = rb_funcallv(obj, id_exclude_end, 0, 0); } else if (pycall_obj_is_step_range(obj)) { - struct enumerator_head *eh = (struct enumerator_head *)DATA_PTR(obj); + struct enumerator_head *eh = GET_ENUMERATOR_DATA(obj); begin = rb_funcallv(eh->obj, id_begin, 0, 0); end = rb_funcallv(eh->obj, id_end, 0, 0); exclude_end = rb_funcallv(eh->obj, id_exclude_end, 0, 0);