- File:
-
- 1 edited
-
tests/exceptions/data-except.cfa (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
tests/exceptions/data-except.cfa
recfd758 r046a890 3 3 #include <exception.hfa> 4 4 5 EHM_EXCEPTION(paired)(5 DATA_EXCEPTION(paired)( 6 6 int first; 7 7 int second; 8 8 ); 9 9 10 EHM_VIRTUAL_TABLE(paired, paired_vt); 10 void ?{}(paired & this, int first, int second) { 11 VTABLE_INIT(this, paired); 12 this.first = first; 13 this.second = second; 14 } 11 15 12 const char * virtual_msg(paired * this) { 13 return this->virtual_table->msg(this); 16 const char * paired_msg(paired * this) { 17 return "paired"; 18 } 19 20 VTABLE_INSTANCE(paired)(paired_msg); 21 22 void throwPaired(int first, int second) { 23 paired exc = {first, second}; 14 24 } 15 25 16 26 int main(int argc, char * argv[]) { 17 paired except = { &paired_vt,3, 13};27 paired except = {3, 13}; 18 28 19 29 try { 20 30 throw except; 21 31 } 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); 23 33 ++exc->first; 24 34 } 25 35 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); 27 37 28 38 try { 29 39 throwResume except; 30 40 } 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); 32 42 ++exc->first; 33 43 } 34 44 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); 36 46 }
Note:
See TracChangeset
for help on using the changeset viewer.