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

Use RTYPEDDATA_GET_DATA if exist #181

Merged
merged 2 commits into from
May 24, 2024
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
1 change: 0 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: "" }

Expand Down
2 changes: 2 additions & 0 deletions ext/pycall/extconf.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
require 'mkmf'

have_func("RTYPEDDATA_GET_DATA")

create_makefile('pycall')
10 changes: 8 additions & 2 deletions ext/pycall/range.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
Loading