|
1 | 1 | #include "ruby_function.h" |
2 | 2 |
|
| 3 | +typedef struct CVecBasic CVecBasic; |
| 4 | + |
3 | 5 | #define IMPLEMENT_ONE_ARG_FUNC(func) \ |
4 | 6 | VALUE cfunction_ ## func(VALUE self, VALUE operand1) { \ |
5 | 7 | return function_onearg(basic_ ## func, operand1); \ |
@@ -40,28 +42,36 @@ IMPLEMENT_ONE_ARG_FUNC(gamma); |
40 | 42 | VALUE cfunction_functionsymbol_init(VALUE self, VALUE args) |
41 | 43 | { |
42 | 44 | int argc = NUM2INT(rb_funcall(args, rb_intern("length"), 0, NULL)); |
43 | | - printf("%d\n", argc); |
| 45 | + printf("argc : %d\n", argc); |
44 | 46 | VALUE first = rb_ary_shift(args); |
45 | 47 | if( TYPE(first) != T_STRING ){ |
46 | 48 | rb_raise(rb_eTypeError, "String expected as first argument"); |
47 | 49 | } |
48 | 50 | char *name = StringValueCStr( first ); |
| 51 | + char *c; |
| 52 | + |
| 53 | + CVecBasic *cargs = vecbasic_new(); |
| 54 | + |
| 55 | + //basic_struct *cargs[argc]; |
49 | 56 |
|
50 | | - basic_struct *cargs[argc]; |
| 57 | + basic x; |
| 58 | + basic y; |
| 59 | + basic_new_stack(x); |
51 | 60 | int i; |
52 | | - for(i = 0; i < argc; i++){ |
53 | | - cargs[i] = basic_new_heap(); |
54 | | - sympify(rb_ary_shift(args), cargs[i]); |
| 61 | + for(i = 0; i < argc-1; i++){ |
| 62 | + printf("%d : ", i); |
| 63 | + sympify(rb_ary_shift(args), x); |
| 64 | + vecbasic_push_back(cargs, x); |
55 | 65 | } |
| 66 | + |
| 67 | + basic_free_stack(x); |
56 | 68 |
|
57 | 69 | basic_struct *this; |
58 | 70 | Data_Get_Struct(self, basic_struct, this); |
59 | 71 |
|
60 | 72 | function_symbol_set(this, name, cargs); |
61 | 73 |
|
62 | | - for(i = 0; i < argc; i++){ |
63 | | - basic_free_heap(cargs[i]); |
64 | | - } |
| 74 | + vecbasic_free(cargs); |
65 | 75 | return self; |
66 | 76 | } |
67 | 77 |
|
0 commit comments