Skip to content

Commit 2dd2966

Browse files
committed
Removed commented code and print statements. Added an error for no arguments
1 parent b5a91fd commit 2dd2966

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

ext/symengine/ruby_function.c

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,37 +41,34 @@ IMPLEMENT_ONE_ARG_FUNC(gamma);
4141

4242
VALUE cfunction_functionsymbol_init(VALUE self, VALUE args)
4343
{
44-
int argc = NUM2INT(rb_funcall(args, rb_intern("length"), 0, NULL));
45-
printf("argc : %d\n", argc);
44+
int argc = NUM2INT(rb_ary_length(args));
45+
if(argc == 0){
46+
rb_raise(rb_eTypeError, "Arguments Expected");
47+
}
48+
4649
VALUE first = rb_ary_shift(args);
4750
if( TYPE(first) != T_STRING ){
4851
rb_raise(rb_eTypeError, "String expected as first argument");
4952
}
50-
char *name = StringValueCStr( first );
51-
char *c;
53+
char *name = StringValueCStr(first);
5254

5355
CVecBasic *cargs = vecbasic_new();
5456

55-
//basic_struct *cargs[argc];
56-
5757
basic x;
58-
basic y;
5958
basic_new_stack(x);
6059
int i;
6160
for(i = 0; i < argc-1; i++){
62-
printf("%d : ", i);
6361
sympify(rb_ary_shift(args), x);
6462
vecbasic_push_back(cargs, x);
6563
}
66-
67-
basic_free_stack(x);
6864

6965
basic_struct *this;
7066
Data_Get_Struct(self, basic_struct, this);
71-
7267
function_symbol_set(this, name, cargs);
7368

7469
vecbasic_free(cargs);
70+
basic_free_stack(x);
71+
7572
return self;
7673
}
7774

0 commit comments

Comments
 (0)