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

cpp: interface with exceptions #17

Open
ftynse opened this issue Aug 10, 2017 · 1 comment
Open

cpp: interface with exceptions #17

ftynse opened this issue Aug 10, 2017 · 1 comment

Comments

@ftynse
Copy link
Member

ftynse commented Aug 10, 2017

What would be the best way to add support for exceptions in the interface? Generate different bindings with a flag to generator?

Ideally, I would like to have meaningful messages inside exceptions. For example, include messages passed to isl_die. The main problem is that internal memory management relies on the errors being propagated until the user call through isl_stat/isl_bool or null pointers to do some cleenups. So we cannot just throw on isl_die. We could try to copy the message into the isl_ctx and then query it, similarly to errno in POSIX. This would complicate the wrapper functions and make them do the following:

  • find the ctx of their arguments;
  • do the call and check if it did not return error/null (except if marked as __isl_null);
  • if did return error, query the context and throw
  • stack unwinding should take care of clearing the relevant C++ wrappers.
    This requires that all functions that may fail could obtain the context from their arguments. Is this the case?

Any other thoughts?

@tobiasgrosser
Copy link
Member

AFAIK Sven started to look into this as well. Maybe also ask this on the isl mailing list?

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

No branches or pull requests

2 participants