import t
from stdio import printf
import testcheck


# 装饰器形式：@t.CStruct 等同于 class Point(t.CStruct):
@t.CStruct
class Point:
    x: t.CInt
    y: t.CInt


# 装饰器形式：@t.CEnum 等同于 class Color(t.CEnum):
@t.CEnum
class Color:
    RED = 1
    GREEN = 2
    BLUE = 3


# 装饰器形式：@t.CUnion 等同于 class Data(t.CUnion):
@t.CUnion
class Data:
    i: t.CInt
    f: t.CFloat


# 装饰器形式：@t.CExport 等同于 def test() -> t.CInt | t.CExport:
@t.CExport
def test() -> t.CInt:
    printf("test_export called\n")
    return 42


# 装饰器形式：@t.CStatic 等同于 def static_func() -> t.CInt | t.CStatic:
@t.CStatic
def static_func() -> t.CInt:
    return 100


# 混合形式：装饰器 + 注解
@t.CStatic
def mixed_func() -> t.CInt | t.CExport:
    return 200


def main() -> t.CInt:
    testcheck.begin("DecoratorMarkerTest: 装饰器标记测试")

    p: Point = Point()
    p.x = 10
    p.y = 20
    printf("Point: (%d, %d)\n", p.x, p.y)
    testcheck.check(p.x == 10 and p.y == 20, "Point (10, 20)", "Point expect (10, 20)")

    c: t.CInt = Color.GREEN
    printf("Color: %d\n", c)
    testcheck.check(c == 2, "Color.GREEN == 2", "Color.GREEN expect 2")

    d: Data = Data()
    d.i = 65
    printf("Data.i: %d\n", d.i)
    testcheck.check(d.i == 65, "Data.i == 65", "Data.i expect 65")

    ret: t.CInt = test()
    printf("test() returned: %d\n", ret)
    testcheck.check(ret == 42, "test() returned 42", "test() expect 42")

    s: t.CInt = static_func()
    printf("static_func() returned: %d\n", s)
    testcheck.check(s == 100, "static_func() returned 100", "static_func() expect 100")

    m: t.CInt = mixed_func()
    printf("mixed_func() returned: %d\n", m)
    testcheck.check(m == 200, "mixed_func() returned 200", "mixed_func() expect 200")

    return testcheck.end()
