Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cwrapper module [WIP] #5

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Conversation

ivan-pi
Copy link
Member

@ivan-pi ivan-pi commented Oct 3, 2020

I believe I now have a complete interface to the routines in <cwrapper.h>. To ease the task I have leveraged fypp to do part of the work. I've also used fypp for conditional compilation, meaning that commands such as:

fypp -DHAVE_SYMENGINE_LLVM symengine_cwrapper.fypp symengine_cwrapper.f90

are needed. This also means the flags from the C++ SymEngine build need to be somehow propagated to the Fortran version.

I still need to create the unit tests to make sure that my type translations are correct:

C Fortran
basic s type(c_ptr) :: s This is because of typedef basic_struct basic[1]; which is used to force reference semantics
const basic s type(c_ptr), intent(in) :: s
char * (returned value) type(c_ptr)
const char *str (input value) character(c_char), intent(in) :: str(*)
size_t n integer(c_size_t), value :: n
int i integer(c_int), value :: i
unsigned i integer(c_int), value :: i
long i integer(c_long), value :: i
unsigned long i integer(c_long), value :: i
CWRAPPER_OUTPUT_TYPE type(c_ptr)
float f real(c_float), value :: f
double d real(c_double), value :: d
CVecBasic *self type(c_ptr) :: self
CDenseMatrix *self type(c_ptr) :: self
CSparseMatrix *self type(c_ptr) :: self
CSetBasic *self type(c_ptr) :: self
CMapBasicBasic *self type(c_ptr) :: self

@certik Do you think unit tests are needed on the level of the C interface (where we work explicitly with the handles to type(c_ptr)) or would it suffice to have tests of the higher level interface (still to be developed)?

My current plan was to adapt the tests found in test_cwrapper.c of SymEngine. I won't be able to make progress that fast, but thought I will just create a PR if anyone else would like to contribute to my fork.

@certik
Copy link
Contributor

certik commented Oct 3, 2020

Awesome, great job!

I think we don't need to thoroughly test the low level interface, if we test the high level (to be written) interface and it works, that should robustly test the low level interface also.

Let me know if you need any help with this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants