Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • tests/exceptions/polymorphic.cfa

    recfd758 rfd54fef  
    33#include <exception.hfa>
    44
    5 EHM_FORALL_EXCEPTION(proxy, (T&), (T))();
     5FORALL_TRIVIAL_EXCEPTION(proxy, (T), (T));
     6FORALL_TRIVIAL_INSTANCE(proxy, (U), (U))
    67
    7 EHM_FORALL_VIRTUAL_TABLE(proxy, (int), proxy_int);
    8 EHM_FORALL_VIRTUAL_TABLE(proxy, (char), proxy_char);
     8const char * msg(proxy(int) * this) { return "proxy(int)"; }
     9const char * msg(proxy(char) * this) { return "proxy(char)"; }
     10POLY_VTABLE_INSTANCE(proxy, int)(msg);
     11POLY_VTABLE_INSTANCE(proxy, char)(msg);
    912
    1013void proxy_test(void) {
    11         proxy(int) an_int = {&proxy_int};
    12         proxy(char) a_char = {&proxy_char};
    13 
    1414    try {
    15                 throw an_int;
     15                throw (proxy(int)){};
    1616        } catch (proxy(int) *) {
    1717                printf("terminate catch\n");
     
    1919
    2020        try {
    21                 throwResume a_char;
     21                throwResume (proxy(char)){};
    2222        } catchResume (proxy(char) *) {
    2323                printf("resume catch\n");
     
    2525
    2626        try {
    27                 throw a_char;
     27                throw (proxy(char)){};
    2828        } catch (proxy(int) *) {
    2929                printf("caught proxy(int)\n");
     
    3333}
    3434
    35 EHM_FORALL_EXCEPTION(cell, (T), (T))(
     35FORALL_DATA_EXCEPTION(cell, (T), (T))(
    3636        T data;
    3737);
    3838
    39 EHM_FORALL_VIRTUAL_TABLE(cell, (int), int_cell);
    40 EHM_FORALL_VIRTUAL_TABLE(cell, (char), char_cell);
    41 EHM_FORALL_VIRTUAL_TABLE(cell, (bool), bool_cell);
     39FORALL_DATA_INSTANCE(cell, (T), (T))
     40
     41const char * msg(cell(int) * this) { return "cell(int)"; }
     42const char * msg(cell(char) * this) { return "cell(char)"; }
     43const char * msg(cell(bool) * this) { return "cell(bool)"; }
     44POLY_VTABLE_INSTANCE(cell, int)(msg);
     45POLY_VTABLE_INSTANCE(cell, char)(msg);
     46POLY_VTABLE_INSTANCE(cell, bool)(msg);
    4247
    4348void cell_test(void) {
    4449        try {
    45                 cell(int) except = {&int_cell, -7};
     50                cell(int) except;
     51                except.data = -7;
    4652                throw except;
    4753        } catch (cell(int) * error) {
     
    5056
    5157        try {
    52                 cell(bool) ball = {&bool_cell, false};
     58                cell(bool) ball;
     59                ball.data = false;
    5360                throwResume ball;
    5461                printf("%i\n", ball.data);
Note: See TracChangeset for help on using the changeset viewer.