Skip to content

Commit b5a91fd

Browse files
committed
FunctionSymbol init working
1 parent e8a5670 commit b5a91fd

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

ext/symengine/ruby_function.c

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#include "ruby_function.h"
22

3+
typedef struct CVecBasic CVecBasic;
4+
35
#define IMPLEMENT_ONE_ARG_FUNC(func) \
46
VALUE cfunction_ ## func(VALUE self, VALUE operand1) { \
57
return function_onearg(basic_ ## func, operand1); \
@@ -40,28 +42,36 @@ IMPLEMENT_ONE_ARG_FUNC(gamma);
4042
VALUE cfunction_functionsymbol_init(VALUE self, VALUE args)
4143
{
4244
int argc = NUM2INT(rb_funcall(args, rb_intern("length"), 0, NULL));
43-
printf("%d\n", argc);
45+
printf("argc : %d\n", argc);
4446
VALUE first = rb_ary_shift(args);
4547
if( TYPE(first) != T_STRING ){
4648
rb_raise(rb_eTypeError, "String expected as first argument");
4749
}
4850
char *name = StringValueCStr( first );
51+
char *c;
52+
53+
CVecBasic *cargs = vecbasic_new();
54+
55+
//basic_struct *cargs[argc];
4956

50-
basic_struct *cargs[argc];
57+
basic x;
58+
basic y;
59+
basic_new_stack(x);
5160
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);
5565
}
66+
67+
basic_free_stack(x);
5668

5769
basic_struct *this;
5870
Data_Get_Struct(self, basic_struct, this);
5971

6072
function_symbol_set(this, name, cargs);
6173

62-
for(i = 0; i < argc; i++){
63-
basic_free_heap(cargs[i]);
64-
}
74+
vecbasic_free(cargs);
6575
return self;
6676
}
6777

0 commit comments

Comments
 (0)