@@ -199,11 +199,12 @@ VALUE Klass_of_Basic(const basic_struct *basic_ptr)
199199 }
200200}
201201
202- VALUE function_onearg (int (* cwfunc_ptr )(basic_struct * , const basic_struct * ),
202+ VALUE function_onearg (CWRAPPER_OUTPUT_TYPE (* cwfunc_ptr )(basic_struct * ,
203+ const basic_struct * ),
203204 VALUE operand1 )
204205{
205206 basic_struct * cresult ;
206- VALUE result ;
207+ VALUE result = Qnil ;
207208
208209 basic cbasic_operand1 ;
209210 basic_new_stack (cbasic_operand1 );
@@ -215,20 +216,20 @@ VALUE function_onearg(int (*cwfunc_ptr)(basic_struct *, const basic_struct *),
215216 result = Data_Wrap_Struct (Klass_of_Basic (cresult ), NULL ,
216217 cbasic_free_heap , cresult );
217218 basic_free_stack (cbasic_operand1 );
218-
219- return result ;
220219 } else {
221220 basic_free_stack (cbasic_operand1 );
222- rb_raise ( rb_eRuntimeError , "Runtime Error" );
221+ raise_exception ( error_code );
223222 }
223+ return result ;
224224}
225225
226- VALUE function_twoarg (int (* cwfunc_ptr )(basic_struct * , const basic_struct * ,
227- const basic_struct * ),
226+ VALUE function_twoarg (CWRAPPER_OUTPUT_TYPE (* cwfunc_ptr )(basic_struct * ,
227+ const basic_struct * ,
228+ const basic_struct * ),
228229 VALUE operand1 , VALUE operand2 )
229230{
230231 basic_struct * cresult ;
231- VALUE result ;
232+ VALUE result = Qnil ;
232233
233234 basic cbasic_operand1 ;
234235 basic_new_stack (cbasic_operand1 );
@@ -246,24 +247,35 @@ VALUE function_twoarg(int (*cwfunc_ptr)(basic_struct *, const basic_struct *,
246247 cbasic_free_heap , cresult );
247248 basic_free_stack (cbasic_operand1 );
248249 basic_free_stack (cbasic_operand2 );
249- return result ;
250250 } else {
251251 basic_free_stack (cbasic_operand1 );
252252 basic_free_stack (cbasic_operand2 );
253- rb_raise ( rb_eRuntimeError , "Runtime Error" );
253+ raise_exception ( error_code );
254254 }
255+ return result ;
255256}
256257
257- void raise_exception (int error_code )
258+ void raise_exception (symengine_exceptions_t error_code )
258259{
259260 char * str = "" ;
260261 switch (error_code ) {
261- case -1 :
262+ case SYMENGINE_NO_EXCEPTION :
263+ return ;
264+ case SYMENGINE_RUNTIME_ERROR :
262265 str = "Runtime Error" ;
263266 break ;
264- case 1 :
267+ case SYMENGINE_DIV_BY_ZERO :
265268 str = "Division by Zero" ;
266269 break ;
270+ case SYMENGINE_NOT_IMPLEMENTED :
271+ str = "Not Implemented" ;
272+ break ;
273+ case SYMENGINE_UNDEFINED :
274+ str = "Undefined" ;
275+ break ;
276+ case SYMENGINE_PARSE_ERROR :
277+ str = "Parse Error" ;
278+ break ;
267279 }
268280 rb_raise (rb_eRuntimeError , "%s" , str );
269281}
0 commit comments