Previous: C++ Native, Up: C++ mappings


6.2.13 Mapping for exceptions

Each defined exception type is defined as a C++ struct that derives from the generic genom::exception type and implements a what() method returning a unique identifier for the exception. Exceptions with members define an additional struct detail type inside the scope of the exception as well a a detail member of that type. A global identifier for the exception is also defined (it is identical to the return value of the what method).

For example:

      exception foo {
        long dummy;
      };

yields the following C++ declarations:

      genom_event foo_id = <unique identifier for exception>;

      struct foo : public genom::exception {
        struct detail {
          uint32_t dummy;
        } detail;

        const char *what();
      } foo_detail;

Exceptions must be thrown with the C++ throw operator.

The identifier for the exception uniquely identifies this exception type, so that any data of type genom_event can be compared to an exception id with the == operator.