Skip to content

Commit 52e1870

Browse files
committed
Fixing further errors
1 parent e96d934 commit 52e1870

File tree

3 files changed

+9
-44
lines changed

3 files changed

+9
-44
lines changed

ext/symengine/ruby_complex.c

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,9 @@
11
#include "ruby_complex.h"
22

33
VALUE ccomplex_real_part(VALUE self) {
4-
basic_struct *c_result = basic_new_heap();
5-
6-
basic cbasic_operand;
7-
basic_new_stack(cbasic_operand);
8-
9-
VALUE result;
10-
11-
sympify(self, cbasic_operand);
12-
complex_real_part(c_result, cbasic_operand);
13-
14-
result = Data_Wrap_Struct(Klass_of_Basic(c_result), NULL, cbasic_free_heap, c_result);
15-
16-
basic_free_stack(cbasic_operand);
17-
18-
return result;
4+
return function_onearg(complex_real_part, self);
195
}
206

217
VALUE ccomplex_imaginary_part(VALUE self) {
22-
basic_struct *c_result = basic_new_heap();
23-
24-
basic cbasic_operand;
25-
basic_new_stack(cbasic_operand);
26-
27-
VALUE result;
28-
29-
sympify(self, cbasic_operand);
30-
complex_imaginary_part(c_result, cbasic_operand);
31-
32-
result = Data_Wrap_Struct(Klass_of_Basic(c_result), NULL, cbasic_free_heap, c_result);
33-
34-
basic_free_stack(cbasic_operand);
35-
36-
return result;
8+
return function_onearg(complex_imaginary_part, self);
379
}

ext/symengine/ruby_constant.c

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,28 @@
11
#include "ruby_constant.h"
22

3-
VALUE cconstant_const(void (*cwfunc_ptr)(basic_struct*)) {
3+
VALUE cconstant_const(void (*cwfunc_ptr)(basic_struct*), VALUE klass) {
44
basic_struct *cresult;
55
VALUE result;
66

77
cresult = basic_new_heap();
88
cwfunc_ptr(cresult);
99

10-
result = Data_Wrap_Struct(c_constant, NULL, cbasic_free_heap, cresult);
10+
result = Data_Wrap_Struct(klass, NULL, cbasic_free_heap, cresult);
1111
return result;
1212
}
1313

1414
VALUE cconstant_pi() {
15-
return cconstant_const(basic_const_pi);
15+
return cconstant_const(basic_const_pi, c_constant);
1616
}
1717

1818
VALUE cconstant_e() {
19-
return cconstant_const(basic_const_E);
19+
return cconstant_const(basic_const_E, c_constant);
2020
}
2121

2222
VALUE cconstant_euler_gamma() {
23-
return cconstant_const(basic_const_EulerGamma);
23+
return cconstant_const(basic_const_EulerGamma, c_constant);
2424
}
2525

2626
VALUE cconstant_i() {
27-
basic_struct *cresult;
28-
VALUE result;
29-
30-
cresult = basic_new_heap();
31-
basic_const_I(cresult);
32-
33-
result = Data_Wrap_Struct(c_complex, NULL, cbasic_free_heap, cresult);
34-
return result;
27+
return cconstant_const(basic_const_I, c_complex);
3528
}

ext/symengine/ruby_constant.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#include "symengine.h"
88
#include "symengine_utils.h"
99

10-
VALUE cconstant_const(void (*cwfunc_ptr)(basic_struct*));
10+
VALUE cconstant_const(void (*cwfunc_ptr)(basic_struct*), VALUE klass);
1111

1212
VALUE cconstant_pi();
1313

0 commit comments

Comments
 (0)