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

Make the C extension build with Ruby 1.9.1 and newer. #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
16 changes: 8 additions & 8 deletions ext/tcl_ruby/tcl_ruby.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ static VALUE rb_tcl_interp_send_begin(VALUE args) {
VALUE obj = rb_ary_entry(args, 0);
VALUE interp_receive_args = rb_ary_entry(args, 1);

VALUE result = rb_funcall2(obj, rb_intern("interp_receive"), RARRAY(interp_receive_args)->len, RARRAY(interp_receive_args)->ptr);
VALUE result = rb_funcall2(obj, rb_intern("interp_receive"), RARRAYLEN(interp_receive_args), RARRAYPTR(interp_receive_args));

tcl_interp_struct *tcl_interp;
Data_Get_Struct(obj, tcl_interp_struct, tcl_interp);

char *tcl_result = strdup(RSTRING(rb_value_to_s(result))->ptr);
char *tcl_result = strdup(RSTRING_PTR(rb_value_to_s(result)));
Tcl_SetResult(tcl_interp->interp, tcl_result, (Tcl_FreeProc *)free);

return Qtrue;
Expand All @@ -36,7 +36,7 @@ static VALUE rb_tcl_interp_send_rescue(VALUE args, VALUE error_info) {
tcl_interp_struct *tcl_interp;
Data_Get_Struct(obj, tcl_interp_struct, tcl_interp);

char *tcl_result = strdup(RSTRING(rb_value_to_s(error_info))->ptr);
char *tcl_result = strdup(RSTRING_PTR(rb_value_to_s(error_info)));
Tcl_SetResult(tcl_interp->interp, tcl_result, (Tcl_FreeProc *)free);

if (rb_obj_is_kind_of(error_info, rb_eSystemExit)) {
Expand Down Expand Up @@ -97,7 +97,7 @@ static VALUE rb_tcl_interp_eval(VALUE self, VALUE args) {
VALUE script = rb_ary_entry(args, 0);

int timeout = 0;
if (RARRAY(args)->len == 2) {
if (RARRAYLEN(args) == 2) {
timeout = NUM2INT(rb_ary_entry(args, 1));
}
#else
Expand All @@ -119,7 +119,7 @@ static VALUE rb_tcl_interp_eval(VALUE self, VALUE script) {
}
#endif

int result = Tcl_Eval(tcl_interp->interp, RSTRING(rb_value_to_s(script))->ptr);
int result = Tcl_Eval(tcl_interp->interp, RSTRING_PTR(rb_value_to_s(script)));

VALUE error_class = rb_const_get(rb_const_get(rb_cObject, rb_intern("Tcl")), rb_intern("Error"));

Expand Down Expand Up @@ -150,7 +150,7 @@ static VALUE rb_tcl_interp_list_to_array(VALUE self, VALUE list) {
tcl_interp_struct *tcl_interp;
Data_Get_Struct(self, tcl_interp_struct, tcl_interp);

Tcl_Obj *string = Tcl_NewStringObj(RSTRING(rb_value_to_s(list))->ptr, -1);
Tcl_Obj *string = Tcl_NewStringObj(RSTRING_PTR(rb_value_to_s(list)), -1);
Tcl_IncrRefCount(string);

int list_length, i;
Expand Down Expand Up @@ -184,14 +184,14 @@ static VALUE rb_tcl_interp_array_to_list(VALUE self, VALUE array) {
tcl_interp_struct *tcl_interp;
Data_Get_Struct(self, tcl_interp_struct, tcl_interp);

int array_length = RARRAY(array)->len, i;
int array_length = RARRAYLEN(array), i;

Tcl_Obj *list = Tcl_NewObj();
Tcl_IncrRefCount(list);

for (i = 0; i < array_length; i++) {
VALUE element = rb_ary_entry(array, i);
Tcl_Obj *string = Tcl_NewStringObj(RSTRING(rb_value_to_s(element))->ptr, -1);
Tcl_Obj *string = Tcl_NewStringObj(RSTRING_PTR(rb_value_to_s(element)), -1);

Tcl_IncrRefCount(string);
Tcl_ListObjAppendElement(tcl_interp->interp, list, string);
Expand Down