Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • tests/exceptions/data-except.cfa

    recfd758 r046a890  
    33#include <exception.hfa>
    44
    5 EHM_EXCEPTION(paired)(
     5DATA_EXCEPTION(paired)(
    66        int first;
    77        int second;
    88);
    99
    10 EHM_VIRTUAL_TABLE(paired, paired_vt);
     10void ?{}(paired & this, int first, int second) {
     11        VTABLE_INIT(this, paired);
     12        this.first = first;
     13        this.second = second;
     14}
    1115
    12 const char * virtual_msg(paired * this) {
    13         return this->virtual_table->msg(this);
     16const char * paired_msg(paired * this) {
     17        return "paired";
     18}
     19
     20VTABLE_INSTANCE(paired)(paired_msg);
     21
     22void throwPaired(int first, int second) {
     23        paired exc = {first, second};
    1424}
    1525
    1626int main(int argc, char * argv[]) {
    17         paired except = {&paired_vt, 3, 13};
     27        paired except = {3, 13};
    1828
    1929        try {
    2030                throw except;
    2131        } catch (paired * exc) {
    22                 printf("%s(%d, %d)\n", virtual_msg(exc), exc->first, exc->second);
     32                printf("%s(%d, %d)\n", paired_msg(exc), exc->first, exc->second);
    2333                ++exc->first;
    2434        }
    2535
    26         printf("%s(%d, %d)\n", virtual_msg(&except), except.first, except.second);
     36        printf("%s(%d, %d)\n", paired_msg(&except), except.first, except.second);
    2737
    2838        try {
    2939                throwResume except;
    3040        } catchResume (paired * exc) {
    31                 printf("%s(%d, %d)\n", virtual_msg(exc), exc->first, exc->second);
     41                printf("%s(%d, %d)\n", paired_msg(exc), exc->first, exc->second);
    3242                ++exc->first;
    3343        }
    3444
    35         printf("%s(%d, %d)\n", virtual_msg(&except), except.first, except.second);
     45        printf("%s(%d, %d)\n", paired_msg(&except), except.first, except.second);
    3646}
Note: See TracChangeset for help on using the changeset viewer.