static CGPoint rb_mouse_unwrap_point(const VALUE maybe_point) { const VALUE point = rb_funcall(maybe_point, sel_to_point, 0); const double x = NUM2DBL(rb_struct_getmember(point, sel_x)); const double y = NUM2DBL(rb_struct_getmember(point, sel_y)); return CGPointMake(x, y); }
/* * call-seq: call(in_start, in_end) * * Call technical function with input data from in_start..in_end. */ static VALUE ta_func_call(VALUE self, VALUE in_start, VALUE in_end) { TA_RetCode ret_code; ParamHolder *param_holder; TA_Integer out_start, out_num; VALUE ary, sub_ary; int i,j; VALUE out_info; int integer = 0; Data_Get_Struct(self, ParamHolder, param_holder); ret_code = TA_CallFunc( param_holder->p, FIX2INT(in_start), FIX2INT(in_end), &out_start, &out_num); if ( ret_code != TA_SUCCESS ) rb_raise(rb_eRuntimeError, "unsuccess return code TA_CallFunc"); ary = rb_iv_get(self, "@result"); // Find out output Integer or Real out_info = ta_func_output_param_info(self, INT2FIX(0)); if (rb_struct_getmember(out_info, rb_intern("type")) == INT2FIX(TA_Output_Integer)) { integer = 1; }; /* if (INT2FIX(TA_Output_Integer) == rb_struct_getmember(out_info, rb_intern("type"))) { */ /* rb_warn("Integer output"); */ /* } else { */ /* rb_warn("Real output"); */ /* } */ for (i = 0; i<RARRAY_LEN(ary); i++) if (TYPE(rb_ary_entry(ary, i)) == T_ARRAY) { sub_ary = rb_ary_entry(ary, i); for (j=0; j<out_num; j++) { if (integer == 1) { int el = (param_holder->out_int[i])[j]; /* rb_warn("output integer %i", el); */ rb_ary_store(sub_ary, j+out_start, INT2NUM(el)); } else { double el = ((double*)param_holder->out[i])[j]; rb_ary_store(sub_ary, j+out_start, rb_float_new(el)); } } } return rb_ary_new3(2, INT2FIX(out_start), INT2FIX(out_num)); }
static VALUE struct_spec_rb_struct_getmember(VALUE self, VALUE st, VALUE key) { return rb_struct_getmember(st, SYM2ID(key)); }
static VALUE rb_struct_ref(VALUE obj) { return rb_struct_getmember(obj, rb_frame_this_func()); }
static VALUE rb_struct_ref(VALUE obj) { return rb_struct_getmember(obj, ruby_frame->orig_func); }