Integer and Rational classes
10 Jul 2015 GSoC-2015 · SymEngineHola! The refactoring of the C Interface has been done, and I did figure out how to test the Ruby bindings with the help of Valgrind
and without the rake-tester
gem. It needs a bunch a flags to tell the tool that it’s ok the way ruby accesses memory, and that the warnings can be suppressed. Still, to be sure that the memory leaks that we see in the report/output are all good memory leaks we need to execute the tests in a loop. Which is pending. I have a arit_spec.rb
that reproduces the test cases from test_arit.py
, the python test file for testing the python wrappers.
I am still debugging the errors in the wrappers for get_args
and free_symbols
. The test arit_spec.rb
depends on it. Only then I can maybe run them in a loop. I am still not yet sure how to run rspec tests in a loop. Shouldn’t be that complex. My closest guess is that, it might be because of a premature GC collection. We do have RB_GC_GUARD
for that in the Ruby C API. I came to this conclusion, since it wasn’t solved even after we implemented the functions to allocate basic
in a heap and rectified the possible errors in the C API code.
I decided to come back to the error after I made some progress with the Integer
and Rational
classes. I think I made the wrong decision, I should have resolved that earlier error first. But good thing is, I have figured out the way I can use polymorphism(mixins, and overloading) and function overloading(decide inside a single function definition by switch) in them. I need the method get_type_code
for that so that in the function I can call the method to know the type of the VALUE that has been passed to the function inside the C API code(objects made with Data_Wrap_Struct
have the data type as T_DATA
).
Next Week
I will make the script that will run the tests in the loop to check for memory leaks. And get my other unmerged PRs merged, they have been there for a long time now. Then, implement the ways that I mentioned above in the Integer
and Rational
classes. These will also require modifying the existing tested code for arithmetic operations. This is why, I would get the other PRs get merged first. Things have turned a little bit dependent on each other.
Commits
- Moved TypeIDs to a common header for both C & C++
- Attempt to use TypeID in cwrapper files
- [ci skip] rectified indentation in Ruby files
- Removed old defs: free_symbols & get_args in Cwrp
- Added setbasic_get in cwrappers
- Added
#free_symbols
to Basic class, tests fail - Added method
#args
to Basic, tests don’t pass - args & free_symbols return basic allocated on heap
- Fixed Typo in
Integer
andRational
headers
comments powered by Disqus