snapshot before regression test

This commit is contained in:
t
2026-07-18 19:25:40 +08:00
commit 796222a300
2295 changed files with 206453 additions and 0 deletions

View File

@@ -0,0 +1,268 @@
import t
import stdio
import c
import testcheck
# ============================================================
# Test 1: 泛型函数 - 不同整数类型特化
# ============================================================
def square[T](x: T) -> T:
return x * x
def test_generic_square_types():
testcheck.section("Test 1: generic square with different types")
r1: t.CInt = square(5)
r2: t.CInt = square(10)
testcheck.check(r1 == 25 and r2 == 100, "square (5^2=25 10^2=100)", "square expect 25 100")
# ============================================================
# Test 2: 泛型函数 - 三参数
# ============================================================
def clamp[T](val: T, lo: T, hi: T) -> T:
if val < lo:
return lo
if val > hi:
return hi
return val
def test_generic_clamp():
testcheck.section("Test 2: generic clamp")
r1: t.CInt = clamp(5, 0, 10)
r2: t.CInt = clamp(-3, 0, 10)
r3: t.CInt = clamp(15, 0, 10)
testcheck.check(r1 == 5 and r2 == 0 and r3 == 10, "clamp (5 0 10)", "clamp expect 5 0 10")
# ============================================================
# Test 3: 泛型类 - Stack[T]
# ============================================================
class Stack[T]():
data: t.CArray[t.CInt, 16]
top: t.CInt
def __init__(self):
self.top = 0
def push(self, val: T):
self.data[self.top] = t.CInt(val)
self.top += 1
def pop(self) -> T:
self.top -= 1
return T(self.data[self.top])
def is_empty(self) -> t.CInt:
if self.top == 0:
return 1
return 0
def size_of(self) -> t.CSizeT:
return self.__sizeof__()
def type_size(self) -> t.CSizeT:
return Stack[T].__sizeof__()
def test_generic_stack():
testcheck.section("Test 3: generic Stack[T]")
s = Stack()
s.push(10)
s.push(20)
s.push(30)
r1: t.CInt = s.pop()
r2: t.CInt = s.pop()
r3: t.CInt = s.pop()
testcheck.check(r1 == 30 and r2 == 20 and r3 == 10, "Stack (pop=30 20 10)", "Stack expect 30 20 10")
# ============================================================
# Test 4: 泛型函数 - swap via pointer
# ============================================================
class IntPair:
a: t.CInt
b: t.CInt
def generic_swap[T](p: IntPair | t.CPtr):
tmp: t.CInt = c.Deref(p).a
c.Deref(p).a = c.Deref(p).b
c.Deref(p).b = tmp
def test_generic_swap():
testcheck.section("Test 4: generic swap via pointer")
p: IntPair = IntPair()
p.a = 100
p.b = 200
generic_swap(c.Addr(p))
testcheck.check(p.a == 200 and p.b == 100, "swap (a=200 b=100)", "swap expect 200 100")
# ============================================================
# Test 5: 泛型类 - Range[T] 迭代器
# ============================================================
class Range[T]():
start: T
end_val: T
step: T
def __init__(self, s: T, e: T, st: T):
self.start = T(s)
self.end_val = T(e)
self.step = T(st)
def sum_all(self) -> T:
result: T = T(0)
i: T = self.start
while i < self.end_val:
result = result + i
i = i + self.step
return result
def test_generic_range():
testcheck.section("Test 5: generic Range[T]")
r = Range(0, 10, 1) # 0+1+2+...+9=45
s: t.CInt = r.sum_all()
testcheck.check(s == 45, "Range sum (0..9=45)", "Range sum expect 45")
# ============================================================
# Test 6: 泛型函数 - 数组求和(非泛型数组参数)
# ============================================================
def array_sum(arr: t.CArray[t.CInt, 8], n: t.CInt) -> t.CInt:
result: t.CInt = 0
for i in range(n):
result += arr[i]
return result
def test_generic_array_sum():
testcheck.section("Test 6: array sum")
arr: t.CArray[t.CInt, 8] = [0]
for i in range(8):
arr[i] = (i + 1) * 10
s: t.CInt = array_sum(arr, 8)
testcheck.check(s == 360, "array sum (360)", "array sum expect 360")
# ============================================================
# Test 7: 泛型函数 - 比较并返回较大值
# ============================================================
def max_of_three[T](a: T, b: T, c_val: T) -> T:
m: T = a
if b > m:
m = b
if c_val > m:
m = c_val
return m
def test_generic_max_three():
testcheck.section("Test 7: generic max of three")
r1: t.CInt = max_of_three(1, 2, 3)
r2: t.CInt = max_of_three(10, 30, 20)
r3: t.CInt = max_of_three(50, 50, 50)
testcheck.check(r1 == 3 and r2 == 30 and r3 == 50, "max3 (3 30 50)", "max3 expect 3 30 50")
# ============================================================
# Test 8: 泛型类 - 带方法的容器
# ============================================================
class Container[T]():
values: t.CArray[t.CInt, 8]
size: t.CInt
def __init__(self):
self.size = 0
def add(self, v: T):
self.values[self.size] = t.CInt(v)
self.size += 1
def get(self, idx: t.CInt) -> T:
return T(self.values[idx])
def contains(self, v: T) -> t.CInt:
for i in range(self.size):
if self.values[i] == t.CInt(v):
return 1
return 0
def total(self) -> T:
result: T = T(0)
for i in range(self.size):
result = result + T(self.values[i])
return result
def test_generic_container():
testcheck.section("Test 8: generic Container[T]")
c = Container()
c.add(10)
c.add(20)
c.add(30)
has20: t.CInt = c.contains(20)
has99: t.CInt = c.contains(99)
total: t.CInt = c.total()
testcheck.check(has20 == 1 and has99 == 0 and total == 60, "Container (has20=1 has99=0 total=60)", "Container expect 1 0 60")
# ============================================================
# Test 9: 泛型函数 - 阶乘
# ============================================================
def factorial[T](n: T) -> T:
result: T = T(1)
i: T = T(2)
while i <= n:
result = result * i
i = i + T(1)
return result
def test_generic_factorial():
testcheck.section("Test 9: generic factorial")
r1: t.CInt = factorial(5)
r2: t.CInt = factorial(10)
testcheck.check(r1 == 120 and r2 == 3628800, "factorial (5!=120 10!=3628800)", "factorial expect 120 3628800")
# ============================================================
# Test 10: 泛型类 - 累加器
# ============================================================
class Accumulator[T]():
total: T
def __init__(self, start: T):
self.total = T(start)
def add_val(self, v: T):
self.total = self.total + v
def get_result(self) -> T:
return self.total
def test_generic_accumulator():
testcheck.section("Test 10: generic Accumulator[T]")
a = Accumulator(0)
a.add_val(10)
a.add_val(20)
a.add_val(30)
r: t.CInt = a.get_result()
testcheck.check(r == 60, "Accumulator (result=60)", "Accumulator expect 60")
# ============================================================
# Test 11: 泛型结构体 sizeof (修复验证)
# 特化后 Stack[int] = { [16 x i32], i32 } = 68 字节
# 验证 obj.__sizeof__() 和类内部 self.__sizeof__() 均返回正确大小
# ============================================================
def test_generic_sizeof_bug():
testcheck.section("Test 11: generic sizeof (fixed)")
s = Stack()
s.push(10)
sz: t.CSizeT = s.__sizeof__()
inner_sz: t.CSizeT = s.size_of()
type_sz: t.CSizeT = s.type_size()
stdio.printf("Stack[int] obj.__sizeof__() = %lu, self.__sizeof__() = %lu, Stack[T].__sizeof__() = %lu (expect 68)\n", sz, inner_sz, type_sz)
testcheck.check(sz == 68, "obj.__sizeof__() == 68 OK", "obj.__sizeof__() FAILED")
testcheck.check(inner_sz == 68, "self.__sizeof__() == 68 OK", "self.__sizeof__() FAILED")
testcheck.check(type_sz == 68, "Stack[T].__sizeof__() == 68 OK", "Stack[T].__sizeof__() FAILED")
def main() -> t.CInt:
testcheck.begin("GenericTest2: Advanced Generic Tests")
test_generic_square_types()
test_generic_clamp()
test_generic_stack()
test_generic_swap()
test_generic_range()
test_generic_array_sum()
test_generic_max_three()
test_generic_container()
test_generic_factorial()
test_generic_accumulator()
test_generic_sizeof_bug()
return testcheck.end()

View File

@@ -0,0 +1 @@
{"stdio": "6f62fe05c5ea1ceb", "w32.win32base": "7e529fe7a078cfef", "win32base": "7e529fe7a078cfef", "w32.win32console": "bbdf3bbd4c3bc28c", "win32console": "bbdf3bbd4c3bc28c", "testcheck": "dd3002730623424b", "stdint": "f5522571bcce7bcb"}

View File

@@ -0,0 +1,29 @@
{
"$schema": "https://raw.githubusercontent.com/TermiNexus/TransPyC/main/schemas/project-schema.json",
"name": "GenericTest2",
"version": "1.0.0",
"source_dir": "./App",
"temp_dir": "./temp",
"output_dir": "./output",
"compiler": {
"cmd": "llc",
"flags": ["-filetype=obj", "-relocation-model=pic"]
},
"linker": {
"cmd": "clang++",
"flags": ["-Wl,--allow-multiple-definition", "-Wl,--unresolved-symbols=ignore-in-object-files", "-lmsvcrt", "-lucrt", "-lpthread", "-lmingwex", "-lkernel32", "-luser32", "-latomic"],
"output": "GenericTest2.exe"
},
"includes": [
"../../includes"
],
"target": {
"triple": "x86_64-pc-windows-gnu",
"datalayout": "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
},
"options": {
"slice_level": 3,
"target": "llvm",
"strict_mode": true
}
}

View File

@@ -0,0 +1,28 @@
"""
Auto-generated Python stub file from stdio.py
Module: stdio
"""
import t, c
def printf(fmt: t.CConst | str, *args) -> t.CInt | t.State: pass
def fprintf(stream: bytes, fmt: t.CConst | str, *args) -> t.CInt | t.State: pass
def sprintf(buf: bytes, fmt: t.CConst | str, *args) -> t.CInt | t.State: pass
def snprintf(buf: bytes, size: t.CSizeT, fmt: t.CConst | str, *args) -> t.CInt | t.State: pass
def puts(s: t.CConst | str) -> t.CInt | t.State: pass
def fputs(s: t.CConst | str, stream: bytes) -> t.CInt | t.State: pass
def fgets(buf: bytes, size: t.CInt, stream: bytes) -> bytes | t.State: pass
def fflush(stream: bytes) -> t.CInt | t.State: pass
stdin: t.CExtern | bytes
stdout: t.CExtern | bytes
stderr: t.CExtern | bytes

View File

@@ -0,0 +1,100 @@
"""
Auto-generated Python stub file from w32.win32base.py
Module: w32.win32base
"""
import c
import t
from stdint import *
HANDLE: t.CTypedef = VOIDPTR
LPCSTR: t.CTypedef = t.CConst | t.CChar | t.CPtr
LPCWSTR: t.CTypedef = t.CConst | t.CUnsignedShort | t.CPtr
INVALID_HANDLE_VALUE: t.CDefine = t.CVoid(-1)
NULL: t.CDefine = 0
TRUE: t.CDefine = 1
FALSE: t.CDefine = 0
INFINITE: t.CDefine = 0xFFFFFFFF
WAIT_FAILED: t.CDefine = 0xFFFFFFFF
WAIT_OBJECT_0: t.CDefine = 0
WAIT_TIMEOUT: t.CDefine = 258
WAIT_ABANDONED: t.CDefine = 0x80
MAX_PATH: t.CDefine = 260
ERROR_SUCCESS: t.CDefine = 0
ERROR_FILE_NOT_FOUND: t.CDefine = 2
ERROR_ACCESS_DENIED: t.CDefine = 5
ERROR_INSUFFICIENT_BUFFER: t.CDefine = 122
class SECURITY_ATTRIBUTES:
nLength: ULONG
lpSecurityDescriptor: VOIDPTR
bInheritHandle: BOOL
class OVERLAPPED:
Internal: ULONGLONG
InternalHigh: ULONGLONG
Offset: ULONG
OffsetHigh: ULONG
hEvent: HANDLE
class FILETIME:
dwLowDateTime: DWORD
dwHighDateTime: DWORD
class SYSTEMTIME:
wYear: WORD
wMonth: WORD
wDayOfWeek: WORD
wDay: WORD
wHour: WORD
wMinute: WORD
wSecond: WORD
wMilliseconds: WORD
class GUID:
Data1: DWORD
Data2: WORD
Data3: WORD
Data4: BYTEPTR
class LARGE_INTEGER:
QuadPart: LONGLONG
class ULARGE_INTEGER:
QuadPart: ULONGLONG
def GetLastError() -> ULONG | t.State: pass
def SetLastError(dwErrCode: ULONG) -> t.State: pass
def CloseHandle(hObject: HANDLE) -> BOOL | t.State: pass
def GetProcAddress(hModule: HANDLE, lpProcName: LPCSTR) -> VOIDPTR | t.State: pass
def GetModuleHandleA(lpModuleName: LPCSTR) -> HANDLE | t.State: pass
def GetModuleHandleW(lpModuleName: LPCWSTR) -> HANDLE | t.State: pass
def LoadLibraryA(lpLibFileName: LPCSTR) -> HANDLE | t.State: pass
def LoadLibraryW(lpLibFileName: LPCWSTR) -> HANDLE | t.State: pass
def FreeLibrary(hLibModule: HANDLE) -> BOOL | t.State: pass
def GetSystemTime(lpSystemTime: SYSTEMTIME | t.CPtr) -> t.State: pass
def GetLocalTime(lpSystemTime: SYSTEMTIME | t.CPtr) -> t.State: pass
def FileTimeToSystemTime(lpFileTime: FILETIME | t.CPtr, lpSystemTime: SYSTEMTIME | t.CPtr) -> BOOL | t.State: pass
def SystemTimeToFileTime(lpSystemTime: SYSTEMTIME | t.CPtr, lpFileTime: FILETIME | t.CPtr) -> BOOL | t.State: pass
def QueryPerformanceCounter(lpPerformanceCount: LARGE_INTEGER | t.CPtr) -> BOOL | t.State: pass
def QueryPerformanceFrequency(lpFrequency: LARGE_INTEGER | t.CPtr) -> BOOL | t.State: pass
def Sleep(dwMilliseconds: ULONG) -> t.State: pass
def SleepEx(dwMilliseconds: ULONG, bAlertable: BOOL) -> ULONG | t.State: pass
def GetTickCount() -> ULONG | t.State: pass
def GetTickCount64() -> ULONGLONG | t.State: pass
def GetCommandLineA() -> CHARPTR | t.State: pass

View File

@@ -0,0 +1 @@
{"D:\\Users\\TermiNexus\\Desktop\\TransPyC\\Test\\GenericTest2\\App\\main.py": {"sha1": "bdfc8bd243b7e5b7", "mtime": 1782479447.3739374, "size": 8453}, "D:\\Users\\TermiNexus\\Desktop\\TransPyC\\includes\\stdint.py": {"sha1": "f5522571bcce7bcb", "mtime": 1782383975.8824987, "size": 4356}, "D:\\Users\\TermiNexus\\Desktop\\TransPyC\\includes\\stdio.py": {"sha1": "6f62fe05c5ea1ceb", "mtime": 1783239556.0959673, "size": 714}, "D:\\Users\\TermiNexus\\Desktop\\TransPyC\\includes\\testcheck.py": {"sha1": "dd3002730623424b", "mtime": 1783927513.1159866, "size": 1818}, "D:\\Users\\TermiNexus\\Desktop\\TransPyC\\includes\\w32\\win32base.py": {"sha1": "7e529fe7a078cfef", "mtime": 1782488356.7736557, "size": 2662}, "D:\\Users\\TermiNexus\\Desktop\\TransPyC\\includes\\w32\\win32console.py": {"sha1": "bbdf3bbd4c3bc28c", "mtime": 1781200703.5338137, "size": 5604}}

View File

@@ -0,0 +1,6 @@
6f62fe05c5ea1ceb:includes/stdio.py
7e529fe7a078cfef:includes/w32\win32base.py
bbdf3bbd4c3bc28c:includes/w32\win32console.py
bdfc8bd243b7e5b7:main.py
dd3002730623424b:includes/testcheck.py
f5522571bcce7bcb:includes/stdint.py

View File

@@ -0,0 +1,138 @@
"""
Auto-generated Python stub file from w32.win32console.py
Module: w32.win32console
"""
import c
import t
from stdint import *
from w32.win32base import *
ENABLE_PROCESSED_INPUT: t.CDefine = 0x0001
ENABLE_LINE_INPUT: t.CDefine = 0x0002
ENABLE_ECHO_INPUT: t.CDefine = 0x0004
ENABLE_WINDOW_INPUT: t.CDefine = 0x0008
ENABLE_MOUSE_INPUT: t.CDefine = 0x0010
ENABLE_INSERT_MODE: t.CDefine = 0x0020
ENABLE_QUICK_EDIT_MODE: t.CDefine = 0x0040
ENABLE_EXTENDED_FLAGS: t.CDefine = 0x0080
ENABLE_PROCESSED_OUTPUT: t.CDefine = 0x0001
ENABLE_WRAP_AT_EOL_OUTPUT: t.CDefine = 0x0002
ENABLE_VIRTUAL_TERMINAL_PROCESSING: t.CDefine = 0x0004
DISABLE_NEWLINE_AUTO_RETURN: t.CDefine = 0x0008
ENABLE_LVB_GRID_WORLDWIDE: t.CDefine = 0x0010
FOREGROUND_BLUE: t.CDefine = 0x0001
FOREGROUND_GREEN: t.CDefine = 0x0002
FOREGROUND_RED: t.CDefine = 0x0004
FOREGROUND_INTENSITY: t.CDefine = 0x0008
BACKGROUND_BLUE: t.CDefine = 0x0010
BACKGROUND_GREEN: t.CDefine = 0x0020
BACKGROUND_RED: t.CDefine = 0x0040
BACKGROUND_INTENSITY: t.CDefine = 0x0080
KEY_EVENT: t.CDefine = 0x0001
MOUSE_EVENT: t.CDefine = 0x0002
WINDOW_BUFFER_SIZE_EVENT: t.CDefine = 0x0004
MENU_EVENT: t.CDefine = 0x0008
FOCUS_EVENT: t.CDefine = 0x0010
class COORD:
X: SHORT
Y: SHORT
class SMALL_RECT:
Left: SHORT
Top: SHORT
Right: SHORT
Bottom: SHORT
class CONSOLE_SCREEN_BUFFER_INFO:
dwSize: COORD
dwCursorPosition: COORD
wAttributes: WORD
srWindow: SMALL_RECT
dwMaximumWindowSize: COORD
class CONSOLE_CURSOR_INFO:
dwSize: ULONG
bVisible: BOOL
class CHAR_INFO:
UnicodeChar: WCHAR
Attributes: WORD
class KEY_EVENT_RECORD:
bKeyDown: BOOL
wRepeatCount: WORD
wVirtualKeyCode: WORD
wVirtualScanCode: WORD
uChar: WCHAR
dwControlKeyState: ULONG
class MOUSE_EVENT_RECORD:
dwMousePosition: COORD
dwButtonState: ULONG
dwControlKeyState: ULONG
dwEventFlags: ULONG
class WINDOW_BUFFER_SIZE_RECORD:
dwSize: COORD
class INPUT_RECORD:
EventType: WORD
Event: KEY_EVENT_RECORD
def SetConsoleOutputCP(codepage: UINT) -> BOOL | t.State: pass
def SetConsoleCP(codepage: UINT) -> BOOL | t.State: pass
def GetConsoleCP() -> UINT | t.State: pass
def GetConsoleOutputCP() -> UINT | t.State: pass
def GetConsoleScreenBufferInfo(hConsoleOutput: HANDLE, lpConsoleScreenBufferInfo: CONSOLE_SCREEN_BUFFER_INFO | t.CPtr) -> BOOL | t.State: pass
def SetConsoleScreenBufferSize(hConsoleOutput: HANDLE, dwSize: COORD) -> BOOL | t.State: pass
def SetConsoleCursorPosition(hConsoleOutput: HANDLE, dwCursorPosition: COORD) -> BOOL | t.State: pass
def GetConsoleCursorInfo(hConsoleOutput: HANDLE, lpConsoleCursorInfo: CONSOLE_CURSOR_INFO | t.CPtr) -> BOOL | t.State: pass
def SetConsoleCursorInfo(hConsoleOutput: HANDLE, lpConsoleCursorInfo: CONSOLE_CURSOR_INFO | t.CPtr) -> BOOL | t.State: pass
def SetConsoleTextAttribute(hConsoleOutput: HANDLE, wAttributes: WORD) -> BOOL | t.State: pass
def FillConsoleOutputCharacterA(hConsoleOutput: HANDLE, cCharacter: t.CChar, nLength: ULONG, dwWriteCoord: COORD, lpNumberOfCharsWritten: ULONG | t.CPtr) -> BOOL | t.State: pass
def FillConsoleOutputCharacterW(hConsoleOutput: HANDLE, cCharacter: WCHAR, nLength: ULONG, dwWriteCoord: COORD, lpNumberOfCharsWritten: ULONG | t.CPtr) -> BOOL | t.State: pass
def FillConsoleOutputAttribute(hConsoleOutput: HANDLE, wAttribute: WORD, nLength: ULONG, dwWriteCoord: COORD, lpNumberOfAttrsWritten: ULONG | t.CPtr) -> BOOL | t.State: pass
def WriteConsoleA(hConsoleOutput: HANDLE, lpBuffer: t.CConst | VOIDPTR, nNumberOfCharsToWrite: ULONG, lpNumberOfCharsWritten: ULONG | t.CPtr, lpReserved: VOIDPTR) -> BOOL | t.State: pass
def WriteConsoleW(hConsoleOutput: HANDLE, lpBuffer: t.CConst | VOIDPTR, nNumberOfCharsToWrite: ULONG, lpNumberOfCharsWritten: ULONG | t.CPtr, lpReserved: VOIDPTR) -> BOOL | t.State: pass
def ReadConsoleA(hConsoleInput: HANDLE, lpBuffer: VOIDPTR, nNumberOfCharsToRead: ULONG, lpNumberOfCharsRead: ULONG | t.CPtr, pInputControl: VOIDPTR) -> BOOL | t.State: pass
def ReadConsoleW(hConsoleInput: HANDLE, lpBuffer: VOIDPTR, nNumberOfCharsToRead: ULONG, lpNumberOfCharsRead: ULONG | t.CPtr, pInputControl: VOIDPTR) -> BOOL | t.State: pass
def GetConsoleMode(hConsoleHandle: HANDLE, lpMode: ULONG | t.CPtr) -> BOOL | t.State: pass
def SetConsoleMode(hConsoleHandle: HANDLE, dwMode: ULONG) -> BOOL | t.State: pass
def ReadConsoleInputA(hConsoleInput: HANDLE, lpBuffer: INPUT_RECORD | t.CPtr, nLength: ULONG, lpNumberOfEventsRead: ULONG | t.CPtr) -> BOOL | t.State: pass
def ReadConsoleInputW(hConsoleInput: HANDLE, lpBuffer: INPUT_RECORD | t.CPtr, nLength: ULONG, lpNumberOfEventsRead: ULONG | t.CPtr) -> BOOL | t.State: pass
def GetNumberOfConsoleInputEvents(hConsoleInput: HANDLE, lpNumberOfEvents: ULONG | t.CPtr) -> BOOL | t.State: pass
def FlushConsoleInputBuffer(hConsoleInput: HANDLE) -> BOOL | t.State: pass
def SetConsoleTitleA(lpConsoleTitle: LPCSTR) -> BOOL | t.State: pass
def SetConsoleTitleW(lpConsoleTitle: LPCWSTR) -> BOOL | t.State: pass
def GetConsoleTitleA(lpConsoleTitle: CHARPTR, nSize: ULONG) -> ULONG | t.State: pass
def GetConsoleTitleW(lpConsoleTitle: WCHARPTR, nSize: ULONG) -> ULONG | t.State: pass
def AllocConsole() -> BOOL | t.State: pass
def FreeConsole() -> BOOL | t.State: pass
def SetConsoleWindowInfo(hConsoleOutput: HANDLE, bAbsolute: BOOL, lpConsoleWindow: SMALL_RECT | t.CPtr) -> BOOL | t.State: pass
def ScrollConsoleScreenBufferA(hConsoleOutput: HANDLE, lpScrollRectangle: SMALL_RECT | t.CPtr, lpClipRectangle: SMALL_RECT | t.CPtr, dwDestinationOrigin: COORD, lpFill: CHAR_INFO | t.CPtr) -> BOOL | t.State: pass

View File

@@ -0,0 +1 @@
{}

View File

@@ -0,0 +1,87 @@
"""
Auto-generated Python stub file from main.py
Module: main
"""
import t
import stdio
import c
import testcheck
def square[T](x: T) -> T: pass
def test_generic_square_types() -> t.CInt: pass
def clamp[T](val: T, lo: T, hi: T) -> T: pass
def test_generic_clamp() -> t.CInt: pass
class Stack[T]:
data: t.CArray[t.CInt, 16]
top: t.CInt
def __init__(self: Stack) -> t.CInt: pass
def push(self: Stack, val: T) -> t.CInt: pass
def pop(self: Stack) -> T: pass
def is_empty(self: Stack) -> t.CInt: pass
def size_of(self: Stack) -> t.CSizeT: pass
def type_size(self: Stack) -> t.CSizeT: pass
def test_generic_stack() -> t.CInt: pass
class IntPair:
a: t.CInt
b: t.CInt
def generic_swap[T](p: IntPair | t.CPtr) -> t.CInt: pass
def test_generic_swap() -> t.CInt: pass
class Range[T]:
start: T
end_val: T
step: T
def __init__(self: Range, s: T, e: T, st: T) -> t.CInt: pass
def sum_all(self: Range) -> T: pass
def test_generic_range() -> t.CInt: pass
def array_sum(arr: t.CArray[t.CInt, 8], n: t.CInt) -> t.CInt: pass
def test_generic_array_sum() -> t.CInt: pass
def max_of_three[T](a: T, b: T, c_val: T) -> T: pass
def test_generic_max_three() -> t.CInt: pass
class Container[T]:
values: t.CArray[t.CInt, 8]
size: t.CInt
def __init__(self: Container) -> t.CInt: pass
def add(self: Container, v: T) -> t.CInt: pass
def get(self: Container, idx: t.CInt) -> T: pass
def contains(self: Container, v: T) -> t.CInt: pass
def total(self: Container) -> T: pass
def test_generic_container() -> t.CInt: pass
def factorial[T](n: T) -> T: pass
def test_generic_factorial() -> t.CInt: pass
class Accumulator[T]:
total: T
def __init__(self: Accumulator, start: T) -> t.CInt: pass
def add_val(self: Accumulator, v: T) -> t.CInt: pass
def get_result(self: Accumulator) -> T: pass
def test_generic_accumulator() -> t.CInt: pass
def test_generic_sizeof_bug() -> t.CInt: pass
def main() -> t.CInt: pass

View File

@@ -0,0 +1,31 @@
"""
Auto-generated Python stub file from testcheck.py
Module: testcheck
"""
import t, c
import stdio
from w32.win32console import SetConsoleOutputCP, SetConsoleCP
CP_UTF8: t.CDefine = 65001
_pass_count: t.CExtern | t.CInt
_fail_count: t.CExtern | t.CInt
_total_pass: t.CExtern | t.CInt
_total_fail: t.CExtern | t.CInt
def begin(name: str) -> t.CInt: pass
def section(name: str) -> t.CInt: pass
def ok(msg: str) -> t.CInt: pass
def fail(msg: str) -> t.CInt: pass
def check(cond: t.CInt, ok_msg: str, fail_msg: str) -> t.CInt: pass
def info(msg: str) -> t.CInt: pass
def end() -> t.CInt: pass
def summary() -> t.CInt: pass

View File

@@ -0,0 +1,100 @@
"""
Auto-generated Python stub file from stdint.py
Module: stdint
"""
import c
import t
INT: t.CTypedef = t.CInt
INTPTR: t.CTypedef = t.CInt | t.CPtr
BOOL: t.CTypedef = t.CInt
UINT: t.CTypedef = t.CUnsignedInt
UINTPTR: t.CTypedef = UINT | t.CPtr
BYTE: t.CTypedef = t.CUnsignedChar
BYTEPTR: t.CTypedef = BYTE | t.CPtr
WORD: t.CTypedef = t.CUInt16T
DWORD: t.CTypedef = t.CUInt32T
QWORD: t.CTypedef = t.CUInt64T
TCHAR: t.CTypedef = t.CChar
CHARLIST: t.CTypedef = str | t.CPtr
VOID: t.CTypedef = t.CVoid
SHORT: t.CTypedef = t.CShort
SHORTPTR: t.CTypedef = t.CShort | t.CPtr
USHORT: t.CTypedef = t.CUnsignedShort
USHORTPTR: t.CTypedef = t.CUnsignedShort | t.CPtr
LONGLONG: t.CTypedef = t.CLongLong
ULONGLONG: t.CTypedef = t.CUnsignedLongLong
LONG: t.CTypedef = t.CLong
ULONG: t.CTypedef = t.CUnsignedLong
WCHAR: t.CTypedef = WORD
WCHARPTR: t.CTypedef = WORD | t.CPtr
CHARPTR: t.CTypedef = t.CChar | t.CPtr
FSIZE_t: t.CTypedef = DWORD
LBA_t: t.CTypedef = DWORD
VOIDPTR: t.CTypedef = t.CVoid | t.CPtr
FLOAT: t.CTypedef = t.CFloat
DOUBLE: t.CTypedef = t.CDouble
FLOAT8: t.CTypedef = t.CFloat8T
FLOAT16: t.CTypedef = t.CFloat16T
FLOAT32: t.CTypedef = t.CFloat32T
FLOAT64: t.CTypedef = t.CFloat64T
FLOAT128: t.CTypedef = t.CFloat128T
INT8: t.CTypedef = t.CInt8T
INT16: t.CTypedef = t.CInt16T
INT32: t.CTypedef = t.CInt32T
INT64: t.CTypedef = t.CInt64T
UINT8: t.CTypedef = t.CUInt8T
UINT16: t.CTypedef = t.CUInt16T
UINT32: t.CTypedef = t.CUInt32T
UINT64: t.CTypedef = t.CUInt64T
INT8PTR: t.CTypedef = t.CInt8T | t.CPtr
INT16PTR: t.CTypedef = t.CInt16T | t.CPtr
INT32PTR: t.CTypedef = t.CInt32T | t.CPtr
INT64PTR: t.CTypedef = t.CInt64T | t.CPtr
UINT8PTR: t.CTypedef = t.CUInt8T | t.CPtr
UINT16PTR: t.CTypedef = t.CUInt16T | t.CPtr
UINT32PTR: t.CTypedef = t.CUInt32T | t.CPtr
UINT64PTR: t.CTypedef = t.CUInt64T | t.CPtr
CHAR8: t.CTypedef = t.CChar8T
CHAR16: t.CTypedef = t.CChar16T
CHAR32: t.CTypedef = t.CChar32T
CHAR8PTR: t.CTypedef = t.CChar8T | t.CPtr
CHAR16PTR: t.CTypedef = t.CChar16T | t.CPtr
CHAR32PTR: t.CTypedef = t.CChar32T | t.CPtr
i8: t.CTypedef = t.CInt8T
i16: t.CTypedef = t.CInt16T
i32: t.CTypedef = t.CInt32T
i64: t.CTypedef = t.CInt64T
u8: t.CTypedef = t.CUInt8T
u16: t.CTypedef = t.CUInt16T
u32: t.CTypedef = t.CUInt32T
u64: t.CTypedef = t.CUInt64T
SIZE_T: t.CTypedef = t.CSizeT
SSIZE_T: t.CTypedef = t.CPtrDiffT
PTRDIFF_T: t.CTypedef = t.CPtrDiffT
int8_t: t.CTypedef = t.CInt8T
int16_t: t.CTypedef = t.CInt16T
int32_t: t.CTypedef = t.CInt32T
int64_t: t.CTypedef = t.CInt64T
uint8_t: t.CTypedef = t.CUInt8T
uint16_t: t.CTypedef = t.CUInt16T
uint32_t: t.CTypedef = t.CUInt32T
uint64_t: t.CTypedef = t.CUInt64T
size_t: t.CTypedef = t.CSizeT
ssize_t: t.CTypedef = t.CPtrDiffT
ptrdiff_t: t.CTypedef = t.CPtrDiffT
intptr_t: t.CTypedef = t.CIntPtrT
uintptr_t: t.CTypedef = t.CUIntPtrT
wchar_t: t.CTypedef = t.CWCharT
char8_t: t.CTypedef = t.CChar8T
char16_t: t.CTypedef = t.CChar16T
char32_t: t.CTypedef = t.CChar32T
float8_t: t.CTypedef = t.CFloat8T
float16_t: t.CTypedef = t.CFloat16T
float32_t: t.CTypedef = t.CFloat32T
float64_t: t.CTypedef = t.CFloat64T
float128_t: t.CTypedef = t.CFloat128T
_Bool: t.CTypedef = t.CBool