Previous: C Native, Up: C mappings


6.1.12 Mapping for exceptions

Each defined exception type is defined as a struct tag and a typedef with the C global name for the exception suffixed by _detail. An identifier for the exception is also defined, as is a type-specific function for raising the exception. For example:

      exception foo {
        long dummy;
      };

yields the following C declarations:

      genom_event ex_foo_id = <unique identifier for exception>;

      typedef struct foo_detail {
        uint32_t dummy;
      } foo_detail;

      genom_event foo(const foo_detail *detail);

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.

The function throwing the exception returns a genom_event that should be used as the return value of a codel. It makes a copy of the exception details.

Since exceptions are allowed to have no members, but C structs must have at least one member, exceptions with no members map to the C void type and the type-specific throw function takes no argument.