Ignore:
Timestamp:
Apr 28, 2024, 7:50:11 PM (5 weeks ago)
Author:
JiadaL <j82liang@…>
Branches:
master
Children:
c5c123f
Parents:
7042c60
Message:
  1. Change return value of typed Enum in null context: they now return the position. Therefore, printf with enumeration value will no longer be supported. 2. sout now will return the enumeration value. So sout | enumValue will print what we expect. 3. Provide enum.hfa, which contains traits that related to enum. 4. Implement functions declare in enum.hfa for enum types, so enum type fulfill the traits. Known defeat: error if we use the enum traits on enum types. They work but c compiler gives an warning
File:
1 edited

Legend:

Unmodified
Added
Removed
  • tests/enum_tests/typedIntEnum.cfa

    r7042c60 reb7586e  
    1 #include <stdio.h>
     1#include <fstream.hfa>
    22
    33enum(int) IntEnum {
     
    1212
    1313int main() {
    14     printf("0=%d\n", zero);
    15     printf("1=%d\n", one);
    16     printf("1000=%d\n", thousand);
    17     printf("1001=%d\n", thousand_one);
    18     printf("2000=%d\n", two_thousand);
    19     printf("2001=%d\n", two_thousand_one);
    20     printf("2002=%d\n", two_thousand_two);
     14    sout | "0=" | zero;
     15    sout | "1=" | one;
     16    sout | "1000=" | thousand;
     17    sout | "1001=" | thousand_one;
     18    sout | "2000=" | two_thousand;
     19    sout | "2001=" | two_thousand_one;
     20    sout | "2002=" | two_thousand_two;
    2121    return 0;
    2222}
Note: See TracChangeset for help on using the changeset viewer.