Skip to content

Commit c5f755a

Browse files
committed
Changed all instances of error codes to symengine_exceptions_t
1 parent 2ada844 commit c5f755a

File tree

5 files changed

+30
-28
lines changed

5 files changed

+30
-28
lines changed

ext/symengine/ruby_basic.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@ VALUE cbasic_alloc(VALUE klass)
1818
return Data_Wrap_Struct(klass, NULL, cbasic_free_heap, struct_ptr);
1919
}
2020

21-
VALUE cbasic_binary_op(VALUE self, VALUE operand2,
22-
int (*cwfunc_ptr)(basic_struct *, const basic_struct *,
21+
VALUE cbasic_binary_op(
22+
VALUE self, VALUE operand2,
23+
symengine_exceptions_t (*cwfunc_ptr)(basic_struct *, const basic_struct *,
2324
const basic_struct *))
2425
{
2526
basic_struct *this, *cresult;
@@ -35,7 +36,7 @@ VALUE cbasic_binary_op(VALUE self, VALUE operand2,
3536

3637
symengine_exceptions_t error_code
3738
= cwfunc_ptr(cresult, this, cbasic_operand2);
38-
if (error_code == 0) {
39+
if (error_code == SYMENGINE_NO_EXCEPTION) {
3940
result = Data_Wrap_Struct(Klass_of_Basic(cresult), NULL,
4041
cbasic_free_heap, cresult);
4142
basic_free_stack(cbasic_operand2);
@@ -46,8 +47,8 @@ VALUE cbasic_binary_op(VALUE self, VALUE operand2,
4647
return result;
4748
}
4849

49-
VALUE cbasic_unary_op(VALUE self,
50-
int (*cwfunc_ptr)(basic_struct *, const basic_struct *))
50+
VALUE cbasic_unary_op(VALUE self, symengine_exceptions_t (*cwfunc_ptr)(
51+
basic_struct *, const basic_struct *))
5152
{
5253
basic_struct *this, *cresult;
5354
VALUE result = Qnil;
@@ -57,7 +58,7 @@ VALUE cbasic_unary_op(VALUE self,
5758
cresult = basic_new_heap();
5859

5960
symengine_exceptions_t error_code = cwfunc_ptr(cresult, this);
60-
if (error_code == 0) {
61+
if (error_code == SYMENGINE_NO_EXCEPTION) {
6162
result = Data_Wrap_Struct(Klass_of_Basic(cresult), NULL,
6263
cbasic_free_heap, cresult);
6364
} else {

ext/symengine/ruby_basic.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,13 @@ void cbasic_free_heap(void *ptr);
1212

1313
VALUE cbasic_alloc(VALUE klass);
1414

15-
VALUE cbasic_binary_op(VALUE self, VALUE operand2,
16-
int (*cwfunc_ptr)(basic_struct *, const basic_struct *,
15+
VALUE cbasic_binary_op(
16+
VALUE self, VALUE operand2,
17+
symengine_exceptions_t (*cwfunc_ptr)(basic_struct *, const basic_struct *,
1718
const basic_struct *));
1819

19-
VALUE cbasic_unary_op(VALUE self,
20-
int (*cwfunc_ptr)(basic_struct *, const basic_struct *));
20+
VALUE cbasic_unary_op(VALUE self, symengine_exceptions_t (*cwfunc_ptr)(
21+
basic_struct *, const basic_struct *));
2122

2223
VALUE cbasic_add(VALUE self, VALUE operand2);
2324

ext/symengine/ruby_utils.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ VALUE cutils_evalf(VALUE self, VALUE operand, VALUE prec, VALUE real)
2323
cresult = basic_new_heap();
2424

2525
sympify(operand, cresult);
26-
int error_code
26+
symengine_exceptions_t error_code
2727
= basic_evalf(cresult, cresult, NUM2INT(prec), (real == Qtrue ? 1 : 0));
2828

29-
if (error_code == 0) {
29+
if (error_code == SYMENGINE_NO_EXCEPTION) {
3030
result = Data_Wrap_Struct(Klass_of_Basic(cresult), NULL,
3131
cbasic_free_heap, cresult);
3232
} else {

ext/symengine/symengine_utils.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -199,9 +199,9 @@ VALUE Klass_of_Basic(const basic_struct *basic_ptr)
199199
}
200200
}
201201

202-
VALUE function_onearg(CWRAPPER_OUTPUT_TYPE (*cwfunc_ptr)(basic_struct *,
203-
const basic_struct *),
204-
VALUE operand1)
202+
VALUE function_onearg(
203+
symengine_exceptions_t (*cwfunc_ptr)(basic_struct *, const basic_struct *),
204+
VALUE operand1)
205205
{
206206
basic_struct *cresult;
207207
VALUE result = Qnil;
@@ -212,7 +212,7 @@ VALUE function_onearg(CWRAPPER_OUTPUT_TYPE (*cwfunc_ptr)(basic_struct *,
212212

213213
cresult = basic_new_heap();
214214
symengine_exceptions_t error_code = cwfunc_ptr(cresult, cbasic_operand1);
215-
if (error_code == 0) {
215+
if (error_code == SYMENGINE_NO_EXCEPTION) {
216216
result = Data_Wrap_Struct(Klass_of_Basic(cresult), NULL,
217217
cbasic_free_heap, cresult);
218218
basic_free_stack(cbasic_operand1);
@@ -223,10 +223,10 @@ VALUE function_onearg(CWRAPPER_OUTPUT_TYPE (*cwfunc_ptr)(basic_struct *,
223223
return result;
224224
}
225225

226-
VALUE function_twoarg(CWRAPPER_OUTPUT_TYPE (*cwfunc_ptr)(basic_struct *,
227-
const basic_struct *,
228-
const basic_struct *),
229-
VALUE operand1, VALUE operand2)
226+
VALUE function_twoarg(
227+
symengine_exceptions_t (*cwfunc_ptr)(basic_struct *, const basic_struct *,
228+
const basic_struct *),
229+
VALUE operand1, VALUE operand2)
230230
{
231231
basic_struct *cresult;
232232
VALUE result = Qnil;
@@ -243,7 +243,7 @@ VALUE function_twoarg(CWRAPPER_OUTPUT_TYPE (*cwfunc_ptr)(basic_struct *,
243243
symengine_exceptions_t error_code
244244
= cwfunc_ptr(cresult, cbasic_operand1, cbasic_operand2);
245245

246-
if (error_code == 0) {
246+
if (error_code == SYMENGINE_NO_EXCEPTION) {
247247
result = Data_Wrap_Struct(Klass_of_Basic(cresult), NULL,
248248
cbasic_free_heap, cresult);
249249
basic_free_stack(cbasic_operand1);

ext/symengine/symengine_utils.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@ void get_symintfromval(VALUE operand2, basic_struct *cbasic_operand2);
1717
VALUE Klass_of_Basic(const basic_struct *basic_ptr);
1818
// Returns the result from the function pointed by cwfunc_ptr: for one argument
1919
// functions
20-
VALUE function_onearg(CWRAPPER_OUTPUT_TYPE (*cwfunc_ptr)(basic_struct *,
21-
const basic_struct *),
22-
VALUE operand1);
20+
VALUE function_onearg(
21+
symengine_exceptions_t (*cwfunc_ptr)(basic_struct *, const basic_struct *),
22+
VALUE operand1);
2323
// Returns the result from the function pointed by cwfunc_ptr: for two argument
2424
// functions
25-
VALUE function_twoarg(CWRAPPER_OUTPUT_TYPE (*cwfunc_ptr)(basic_struct *,
26-
const basic_struct *,
27-
const basic_struct *),
28-
VALUE operand1, VALUE operand2);
25+
VALUE function_twoarg(
26+
symengine_exceptions_t (*cwfunc_ptr)(basic_struct *, const basic_struct *,
27+
const basic_struct *),
28+
VALUE operand1, VALUE operand2);
2929
void raise_exception(symengine_exceptions_t error_code);
3030

3131
#endif // SYMENGINE_UTILS_H_

0 commit comments

Comments
 (0)