Last active
November 30, 2020 18:21
-
-
Save djberg96/b5ad384d91d325d846290c361fcde81f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include "ruby.h" | |
| VALUE cBar; | |
| struct stuff_struct { | |
| int age; | |
| int data[]; | |
| }; | |
| static VALUE bar_foo(VALUE self){ | |
| static struct stuff_struct s = {50, {1, 2, 3}}; | |
| //v_array = rb_ary_new4(sizeof(s.data), (VALUE*)s.data); | |
| printf("Age: %i\n", s.age); | |
| printf("Data: %i\n", s.data[2]); | |
| return self; | |
| } | |
| void Init_bar(){ | |
| cBar = rb_define_class("Bar", rb_cObject); | |
| rb_define_method(cBar, "foo", bar_foo, 0); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment