Cpp2 exceptions

PR is ready for review: ENHANCED: C++-compatible exception handling + more wrapper functions and classes by kamahen · Pull Request #39 · SWI-Prolog/packages-cpp · GitHub is ready for review.

Here are the main changes:

  • SWI-cpp2-plx.h contains wrapper functions (imported from SWI-cpp2.h)
  • throw PlException for Prolog errors
  • most SWI-Prolog.h functions have a wrapper.
  • verify() methods removed from PlAtom, PlTerm, etc.
  • the wrapper functions do the checking.
  • Some executable code has been moved to SWI-cpp2.cpp
  • can be inlined, if desired.
  • PlException is now a subclass of std::exception, not a subclass of PlTerm.
  • PlTypeError, PlDomainError, etc. are no longer subclasses of PlTerm, but are functions for creating suitable PlException objects.
  • The string comparison operators are deprecated; use as_string() and std::string comparison instead, which allows specifying the encoding.
  • Added PlRecord, PlRecordExternal, PlControl (used by PREDICATE_NONDET), PlStream.
  • Fixed numerous bugs and misfeatures; added tests.

I’ve also made PRs for swipl-win, rocksdb, and rolog.

I apologize for the large size of the PR, but I didn’t see an easy way to break it into smaller pieces.

The documentation is still a bit rough; I’ll try to review it and improve it “in the future”.

There are still a few things that need to be done, mostly to do with text encodings. However, their lack shouldn’t be a significant issue, and missing functionality should be easy to add.

1 Like