ext/arrow-gsl/arrow-gsl.c in red-arrow-gsl-0.0.2 vs ext/arrow-gsl/arrow-gsl.c in red-arrow-gsl-0.0.3

- old
+ new

@@ -16,12 +16,15 @@ #include <arrow-glib/arrow-glib.h> #include <rbgobject.h> -#include <rb_gsl.h> +#include <include/rb_gsl.h> +static VALUE rb_GSLMatrix; +static VALUE rb_GSLMatrixInt; + void Init_arrow_gsl(void); static VALUE rb_arrow_int32_array_to_gsl(VALUE self) { @@ -80,11 +83,11 @@ data_raw = g_bytes_get_data(data, &data_size); memcpy(matrix->data, data_raw, data_size); g_bytes_unref(data); g_object_unref(buffer); - rb_matrix = Data_Wrap_Struct(cgsl_matrix_int, + rb_matrix = Data_Wrap_Struct(rb_GSLMatrixInt, NULL, gsl_matrix_int_free, matrix); } else if (value_type == GARROW_TYPE_DOUBLE) { gsl_matrix *matrix; @@ -99,11 +102,11 @@ data_raw = g_bytes_get_data(data, &data_size); memcpy(matrix->data, data_raw, data_size); g_bytes_unref(data); g_object_unref(buffer); - rb_matrix = Data_Wrap_Struct(cgsl_matrix, + rb_matrix = Data_Wrap_Struct(rb_GSLMatrix, NULL, gsl_matrix_free, matrix); } else { GArrowDataType *value_data_type; @@ -205,17 +208,23 @@ rb_define_method(rb_ArrowInt32Array, "to_gsl", rb_arrow_int32_array_to_gsl, 0); rb_define_method(rb_ArrowTensor, "to_gsl", rb_arrow_tensor_to_gsl, 0); - /* - rb_define_method(cgsl_vector_int, "to_arrow", - rb_gsl_vector_int_to_arrow, 0); - rb_define_method(cgsl_vector, "to_arrow", - rb_gsl_vector_to_arrow, 0); - */ + { + VALUE rb_GSL = rb_const_get(rb_cObject, rb_intern("GSL")); - rb_define_method(cgsl_matrix_int, "to_arrow", - rb_gsl_matrix_int_to_arrow, 0); - rb_define_method(cgsl_matrix, "to_arrow", - rb_gsl_matrix_to_arrow, 0); + /* + rb_define_method(cgsl_vector_int, "to_arrow", + rb_gsl_vector_int_to_arrow, 0); + rb_define_method(cgsl_vector, "to_arrow", + rb_gsl_vector_to_arrow, 0); + */ + + rb_GSLMatrix = rb_const_get(rb_GSL, rb_intern("Matrix")); + rb_GSLMatrixInt = rb_const_get(rb_GSLMatrix, rb_intern("Int")); + rb_define_method(rb_GSLMatrixInt, "to_arrow", + rb_gsl_matrix_int_to_arrow, 0); + rb_define_method(rb_GSLMatrix, "to_arrow", + rb_gsl_matrix_to_arrow, 0); + } }