- File:
-
- 1 edited
-
tests/exceptions/polymorphic.cfa (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
tests/exceptions/polymorphic.cfa
recfd758 rfd54fef 3 3 #include <exception.hfa> 4 4 5 EHM_FORALL_EXCEPTION(proxy, (T&), (T))(); 5 FORALL_TRIVIAL_EXCEPTION(proxy, (T), (T)); 6 FORALL_TRIVIAL_INSTANCE(proxy, (U), (U)) 6 7 7 EHM_FORALL_VIRTUAL_TABLE(proxy, (int), proxy_int); 8 EHM_FORALL_VIRTUAL_TABLE(proxy, (char), proxy_char); 8 const char * msg(proxy(int) * this) { return "proxy(int)"; } 9 const char * msg(proxy(char) * this) { return "proxy(char)"; } 10 POLY_VTABLE_INSTANCE(proxy, int)(msg); 11 POLY_VTABLE_INSTANCE(proxy, char)(msg); 9 12 10 13 void proxy_test(void) { 11 proxy(int) an_int = {&proxy_int};12 proxy(char) a_char = {&proxy_char};13 14 14 try { 15 throw an_int;15 throw (proxy(int)){}; 16 16 } catch (proxy(int) *) { 17 17 printf("terminate catch\n"); … … 19 19 20 20 try { 21 throwResume a_char;21 throwResume (proxy(char)){}; 22 22 } catchResume (proxy(char) *) { 23 23 printf("resume catch\n"); … … 25 25 26 26 try { 27 throw a_char;27 throw (proxy(char)){}; 28 28 } catch (proxy(int) *) { 29 29 printf("caught proxy(int)\n"); … … 33 33 } 34 34 35 EHM_FORALL_EXCEPTION(cell, (T), (T))(35 FORALL_DATA_EXCEPTION(cell, (T), (T))( 36 36 T data; 37 37 ); 38 38 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); 39 FORALL_DATA_INSTANCE(cell, (T), (T)) 40 41 const char * msg(cell(int) * this) { return "cell(int)"; } 42 const char * msg(cell(char) * this) { return "cell(char)"; } 43 const char * msg(cell(bool) * this) { return "cell(bool)"; } 44 POLY_VTABLE_INSTANCE(cell, int)(msg); 45 POLY_VTABLE_INSTANCE(cell, char)(msg); 46 POLY_VTABLE_INSTANCE(cell, bool)(msg); 42 47 43 48 void cell_test(void) { 44 49 try { 45 cell(int) except = {&int_cell, -7}; 50 cell(int) except; 51 except.data = -7; 46 52 throw except; 47 53 } catch (cell(int) * error) { … … 50 56 51 57 try { 52 cell(bool) ball = {&bool_cell, false}; 58 cell(bool) ball; 59 ball.data = false; 53 60 throwResume ball; 54 61 printf("%i\n", ball.data);
Note:
See TracChangeset
for help on using the changeset viewer.