snapshot before regression test
This commit is contained in:
268
Test/BuiltinDecoratorTest/App/main.py
Normal file
268
Test/BuiltinDecoratorTest/App/main.py
Normal file
@@ -0,0 +1,268 @@
|
||||
import t
|
||||
from stdint import *
|
||||
from stdio import printf
|
||||
from stdlib import malloc
|
||||
import testcheck
|
||||
|
||||
|
||||
# ============================================================
|
||||
# 测试 1:@property getter
|
||||
# ============================================================
|
||||
class Rect:
|
||||
width: t.CInt
|
||||
height: t.CInt
|
||||
|
||||
def __new__(self, w: t.CInt, h: t.CInt) -> 'Rect' | t.CPtr:
|
||||
return t.CPtr(malloc(Rect.__sizeof__()))
|
||||
|
||||
def __init__(self, w: t.CInt, h: t.CInt):
|
||||
self.width = w
|
||||
self.height = h
|
||||
|
||||
@property
|
||||
def area(self) -> t.CInt:
|
||||
return self.width * self.height
|
||||
|
||||
@property
|
||||
def is_square(self) -> bool:
|
||||
return self.width == self.height
|
||||
|
||||
|
||||
def test_property_getter():
|
||||
testcheck.section("@property getter")
|
||||
r1: Rect = Rect(3, 4)
|
||||
testcheck.check(r1.area == 12, "area == 12", "area expect 12")
|
||||
testcheck.check(not r1.is_square, "not square", "should not be square")
|
||||
r2: Rect = Rect(5, 5)
|
||||
testcheck.check(r2.area == 25, "square area == 25", "square area expect 25")
|
||||
testcheck.check(r2.is_square, "is_square", "should be square")
|
||||
|
||||
|
||||
# ============================================================
|
||||
# 测试 2:@property.setter
|
||||
# ============================================================
|
||||
class Temperature:
|
||||
_celsius: t.CDouble
|
||||
|
||||
def __new__(self, celsius_val: t.CDouble) -> 'Temperature' | t.CPtr:
|
||||
return t.CPtr(malloc(Temperature.__sizeof__()))
|
||||
|
||||
def __init__(self, celsius_val: t.CDouble):
|
||||
self._celsius = celsius_val
|
||||
|
||||
@property
|
||||
def celsius(self) -> t.CDouble:
|
||||
return self._celsius
|
||||
|
||||
@celsius.setter
|
||||
def celsius(self, val: t.CDouble):
|
||||
self._celsius = val
|
||||
|
||||
@property
|
||||
def fahrenheit(self) -> t.CDouble:
|
||||
return self._celsius * 1.8 + 32.0
|
||||
|
||||
|
||||
def test_property_setter():
|
||||
testcheck.section("@property.setter")
|
||||
tmp1: Temperature = Temperature(0.0)
|
||||
testcheck.check(tmp1.fahrenheit > 31.9 and tmp1.fahrenheit < 32.1, "0C == 32F", "0C expect 32F")
|
||||
tmp1.celsius = 100.0
|
||||
testcheck.check(tmp1.fahrenheit > 211.9 and tmp1.fahrenheit < 212.1, "100C == 212F", "100C expect 212F")
|
||||
testcheck.check(tmp1.celsius > 99.9 and tmp1.celsius < 100.1, "celsius == 100", "celsius expect 100")
|
||||
|
||||
|
||||
# ============================================================
|
||||
# 测试 3:@property.getter(重新定义 getter)
|
||||
# ============================================================
|
||||
class Counter:
|
||||
_count: t.CInt
|
||||
|
||||
def __new__(self) -> 'Counter' | t.CPtr:
|
||||
return t.CPtr(malloc(Counter.__sizeof__()))
|
||||
|
||||
def __init__(self):
|
||||
self._count = 0
|
||||
|
||||
@property
|
||||
def value(self) -> t.CInt:
|
||||
return self._count
|
||||
|
||||
@value.setter
|
||||
def value(self, v: t.CInt):
|
||||
self._count = v
|
||||
|
||||
|
||||
def test_property_getter_redef():
|
||||
testcheck.section("@property.getter redef")
|
||||
cnt: Counter = Counter()
|
||||
testcheck.check(cnt.value == 0, "init == 0", "init expect 0")
|
||||
cnt.value = 42
|
||||
testcheck.check(cnt.value == 42, "set == 42", "set expect 42")
|
||||
|
||||
|
||||
# ============================================================
|
||||
# 测试 4:@property.deleter
|
||||
# ============================================================
|
||||
class Config:
|
||||
_value: t.CInt
|
||||
_deleted: t.CInt
|
||||
|
||||
def __new__(self, v: t.CInt) -> 'Config' | t.CPtr:
|
||||
return t.CPtr(malloc(Config.__sizeof__()))
|
||||
|
||||
def __init__(self, v: t.CInt):
|
||||
self._value = v
|
||||
self._deleted = 0
|
||||
|
||||
@property
|
||||
def value(self) -> t.CInt:
|
||||
return self._value
|
||||
|
||||
@value.setter
|
||||
def value(self, v: t.CInt):
|
||||
self._value = v
|
||||
|
||||
@value.deleter
|
||||
def value(self):
|
||||
self._value = 0
|
||||
self._deleted = 1
|
||||
|
||||
def is_deleted(self) -> bool:
|
||||
return self._deleted != 0
|
||||
|
||||
|
||||
def test_property_deleter():
|
||||
testcheck.section("@property.deleter")
|
||||
cfg: Config = Config(99)
|
||||
testcheck.check(cfg.value == 99, "init == 99", "init expect 99")
|
||||
testcheck.check(not cfg.is_deleted(), "not deleted", "should not be deleted")
|
||||
del cfg.value
|
||||
testcheck.check(cfg.value == 0, "after del == 0", "after del expect 0")
|
||||
testcheck.check(cfg.is_deleted(), "is_deleted", "should be deleted")
|
||||
|
||||
|
||||
# ============================================================
|
||||
# 测试 5:@staticmethod
|
||||
# ============================================================
|
||||
class MathUtils:
|
||||
@staticmethod
|
||||
def add(a: t.CInt, b: t.CInt) -> t.CInt:
|
||||
return a + b
|
||||
|
||||
@staticmethod
|
||||
def max_val(a: t.CInt, b: t.CInt) -> t.CInt:
|
||||
return a if a > b else b
|
||||
|
||||
|
||||
def test_staticmethod():
|
||||
testcheck.section("@staticmethod")
|
||||
# 通过类名调用
|
||||
testcheck.check(MathUtils.add(3, 4) == 7, "MathUtils.add(3,4)==7", "MathUtils.add(3,4) expect 7")
|
||||
testcheck.check(MathUtils.max_val(5, 10) == 10, "MathUtils.max(5,10)==10", "MathUtils.max(5,10) expect 10")
|
||||
|
||||
|
||||
# ============================================================
|
||||
# 测试 6:@classmethod
|
||||
# ============================================================
|
||||
class Point:
|
||||
x: t.CDouble
|
||||
y: t.CDouble
|
||||
|
||||
def __new__(self, x: t.CDouble, y: t.CDouble) -> 'Point' | t.CPtr:
|
||||
return t.CPtr(malloc(Point.__sizeof__()))
|
||||
|
||||
def __init__(self, x: t.CDouble, y: t.CDouble):
|
||||
self.x = x
|
||||
self.y = y
|
||||
|
||||
@classmethod
|
||||
def origin(cls: Point) -> Point:
|
||||
return Point(0.0, 0.0)
|
||||
|
||||
@classmethod
|
||||
def from_int(cls: Point, x: t.CInt, y: t.CInt) -> Point:
|
||||
return Point(x * 1.0, y * 1.0)
|
||||
|
||||
def dist_sq(self) -> t.CDouble:
|
||||
return self.x * self.x + self.y * self.y
|
||||
|
||||
|
||||
def test_classmethod():
|
||||
testcheck.section("@classmethod")
|
||||
# 通过类名调用
|
||||
p1: Point = Point.origin()
|
||||
testcheck.check(p1.x > -0.01 and p1.x < 0.01, "origin.x ~= 0", "origin.x expect ~0")
|
||||
testcheck.check(p1.y > -0.01 and p1.y < 0.01, "origin.y ~= 0", "origin.y expect ~0")
|
||||
testcheck.check(p1.dist_sq() < 0.01, "origin.dist ~= 0", "origin.dist expect ~0")
|
||||
|
||||
p2: Point = Point.from_int(3, 4)
|
||||
testcheck.check(p2.x > 2.99 and p2.x < 3.01, "from_int(3,4).x ~= 3", "from_int(3,4).x expect ~3")
|
||||
testcheck.check(p2.y > 3.99 and p2.y < 4.01, "from_int(3,4).y ~= 4", "from_int(3,4).y expect ~4")
|
||||
testcheck.check(p2.dist_sq() > 24.99 and p2.dist_sq() < 25.01, "dist_sq ~= 25", "dist_sq expect ~25")
|
||||
|
||||
|
||||
# ============================================================
|
||||
# 测试 7:综合测试 — @property + @staticmethod + @classmethod
|
||||
# ============================================================
|
||||
class Circle:
|
||||
_radius: t.CDouble
|
||||
|
||||
def __new__(self, r: t.CDouble) -> 'Circle' | t.CPtr:
|
||||
return t.CPtr(malloc(Circle.__sizeof__()))
|
||||
|
||||
def __init__(self, r: t.CDouble):
|
||||
self._radius = r
|
||||
|
||||
@property
|
||||
def radius(self) -> t.CDouble:
|
||||
return self._radius
|
||||
|
||||
@radius.setter
|
||||
def radius(self, val: t.CDouble):
|
||||
self._radius = val
|
||||
|
||||
@property
|
||||
def area(self) -> t.CDouble:
|
||||
return 3.14159265 * self._radius * self._radius
|
||||
|
||||
@staticmethod
|
||||
def is_unit(r: t.CDouble) -> bool:
|
||||
return r > 0.99 and r < 1.01
|
||||
|
||||
@classmethod
|
||||
def unit(cls: Circle) -> Circle:
|
||||
return Circle(1.0)
|
||||
|
||||
|
||||
def test_combined():
|
||||
testcheck.section("Combined @property + @staticmethod + @classmethod")
|
||||
# 先测试直接构造
|
||||
cr0: Circle = Circle(1.0)
|
||||
testcheck.check(cr0.radius > 0.99 and cr0.radius < 1.01, "direct radius ~= 1", "direct radius expect ~1")
|
||||
testcheck.check(cr0.area > 3.14 and cr0.area < 3.15, "direct area ~= pi", "direct area expect ~pi")
|
||||
cr0.radius = 2.0
|
||||
testcheck.check(cr0.radius > 1.99 and cr0.radius < 2.01, "direct radius 2.0", "direct radius expect 2.0")
|
||||
testcheck.check(cr0.area > 12.56 and cr0.area < 12.58, "direct area ~= 4pi", "direct area expect ~4pi")
|
||||
# 测试 classmethod
|
||||
cr1: Circle = Circle.unit()
|
||||
testcheck.check(cr1.radius > 0.99 and cr1.radius < 1.01, "unit radius ~= 1", "unit radius expect ~1")
|
||||
testcheck.check(Circle.is_unit(1.0), "is_unit(1.0)", "is_unit(1.0) should be true")
|
||||
testcheck.check(not Circle.is_unit(2.0), "not is_unit(2.0)", "is_unit(2.0) should be false")
|
||||
|
||||
|
||||
# ============================================================
|
||||
# 主函数
|
||||
# ============================================================
|
||||
def main() -> t.CInt | t.CExport:
|
||||
testcheck.begin("Builtin Decorator Test")
|
||||
|
||||
test_property_getter()
|
||||
test_property_setter()
|
||||
test_property_getter_redef()
|
||||
test_property_deleter()
|
||||
test_staticmethod()
|
||||
test_classmethod()
|
||||
test_combined()
|
||||
|
||||
return testcheck.end()
|
||||
@@ -0,0 +1 @@
|
||||
{"stdio": "6f62fe05c5ea1ceb", "w32.win32base": "7e529fe7a078cfef", "win32base": "7e529fe7a078cfef", "stdlib": "90c53dd6db8d41cf", "w32.win32console": "bbdf3bbd4c3bc28c", "win32console": "bbdf3bbd4c3bc28c", "testcheck": "dd3002730623424b", "stdint": "f5522571bcce7bcb"}
|
||||
28
Test/BuiltinDecoratorTest/project.json
Normal file
28
Test/BuiltinDecoratorTest/project.json
Normal file
@@ -0,0 +1,28 @@
|
||||
{
|
||||
"name": "BuiltinDecoratorTest",
|
||||
"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": "BuiltinDecoratorTest.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
|
||||
}
|
||||
}
|
||||
28
Test/BuiltinDecoratorTest/temp/6f62fe05c5ea1ceb.pyi
Normal file
28
Test/BuiltinDecoratorTest/temp/6f62fe05c5ea1ceb.pyi
Normal 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
|
||||
100
Test/BuiltinDecoratorTest/temp/7e529fe7a078cfef.pyi
Normal file
100
Test/BuiltinDecoratorTest/temp/7e529fe7a078cfef.pyi
Normal 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
|
||||
20
Test/BuiltinDecoratorTest/temp/90c53dd6db8d41cf.pyi
Normal file
20
Test/BuiltinDecoratorTest/temp/90c53dd6db8d41cf.pyi
Normal file
@@ -0,0 +1,20 @@
|
||||
"""
|
||||
Auto-generated Python stub file from stdlib.py
|
||||
Module: stdlib
|
||||
"""
|
||||
|
||||
import c
|
||||
|
||||
|
||||
from stdint import *
|
||||
import t
|
||||
|
||||
def malloc(size: t.CSizeT) -> t.CVoid | t.CPtr | t.State: pass
|
||||
|
||||
def calloc(nmemb: t.CSizeT, size: t.CSizeT) -> t.CVoid | t.CPtr | t.State: pass
|
||||
|
||||
def realloc(p: t.CVoid | t.CPtr, size: t.CSizeT) -> t.CVoid | t.CPtr | t.State: pass
|
||||
|
||||
def free(p: t.CVoid | t.CPtr) -> t.State: pass
|
||||
|
||||
def system(cmd: t.CConst | t.CChar | t.CPtr) -> INT | t.State: pass
|
||||
1
Test/BuiltinDecoratorTest/temp/_phase1_manifest.json
Normal file
1
Test/BuiltinDecoratorTest/temp/_phase1_manifest.json
Normal file
@@ -0,0 +1 @@
|
||||
{"D:\\Users\\TermiNexus\\Desktop\\TransPyC\\Test\\BuiltinDecoratorTest\\App\\main.py": {"sha1": "e3ac223bdaf94a0c", "mtime": 1782110312.4550886, "size": 8488}, "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\\stdlib.py": {"sha1": "90c53dd6db8d41cf", "mtime": 1783874975.3597875, "size": 375}, "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}}
|
||||
7
Test/BuiltinDecoratorTest/temp/_sha1_map.txt
Normal file
7
Test/BuiltinDecoratorTest/temp/_sha1_map.txt
Normal file
@@ -0,0 +1,7 @@
|
||||
6f62fe05c5ea1ceb:includes/stdio.py
|
||||
7e529fe7a078cfef:includes/w32\win32base.py
|
||||
90c53dd6db8d41cf:includes/stdlib.py
|
||||
bbdf3bbd4c3bc28c:includes/w32\win32console.py
|
||||
dd3002730623424b:includes/testcheck.py
|
||||
e3ac223bdaf94a0c:main.py
|
||||
f5522571bcce7bcb:includes/stdint.py
|
||||
138
Test/BuiltinDecoratorTest/temp/bbdf3bbd4c3bc28c.pyi
Normal file
138
Test/BuiltinDecoratorTest/temp/bbdf3bbd4c3bc28c.pyi
Normal 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
|
||||
31
Test/BuiltinDecoratorTest/temp/dd3002730623424b.pyi
Normal file
31
Test/BuiltinDecoratorTest/temp/dd3002730623424b.pyi
Normal 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
|
||||
1
Test/BuiltinDecoratorTest/temp/e3ac223bdaf94a0c.doc.json
Normal file
1
Test/BuiltinDecoratorTest/temp/e3ac223bdaf94a0c.doc.json
Normal file
@@ -0,0 +1 @@
|
||||
{}
|
||||
110
Test/BuiltinDecoratorTest/temp/e3ac223bdaf94a0c.pyi
Normal file
110
Test/BuiltinDecoratorTest/temp/e3ac223bdaf94a0c.pyi
Normal file
@@ -0,0 +1,110 @@
|
||||
"""
|
||||
Auto-generated Python stub file from main.py
|
||||
Module: main
|
||||
"""
|
||||
|
||||
import c
|
||||
|
||||
|
||||
import t
|
||||
from stdint import *
|
||||
from stdio import printf
|
||||
from stdlib import malloc
|
||||
import testcheck
|
||||
|
||||
class Rect:
|
||||
width: t.CInt
|
||||
height: t.CInt
|
||||
def __new__(self: Rect, w: t.CInt, h: t.CInt) -> 'Rect' | t.CPtr: pass
|
||||
def __init__(self: Rect, w: t.CInt, h: t.CInt) -> t.CInt: pass
|
||||
@property
|
||||
def area(self: Rect) -> t.CInt: pass
|
||||
@property
|
||||
def is_square(self: Rect) -> bool: pass
|
||||
|
||||
def test_property_getter() -> t.CInt: pass
|
||||
|
||||
|
||||
class Temperature:
|
||||
_celsius: t.CDouble
|
||||
def __new__(self: Temperature, celsius_val: t.CDouble) -> 'Temperature' | t.CPtr: pass
|
||||
def __init__(self: Temperature, celsius_val: t.CDouble) -> t.CInt: pass
|
||||
@property
|
||||
def celsius(self: Temperature) -> t.CDouble: pass
|
||||
@celsius.setter
|
||||
def celsius(self: Temperature, val: t.CDouble) -> t.CInt: pass
|
||||
@property
|
||||
def fahrenheit(self: Temperature) -> t.CDouble: pass
|
||||
|
||||
def test_property_setter() -> t.CInt: pass
|
||||
|
||||
|
||||
class Counter:
|
||||
_count: t.CInt
|
||||
def __new__(self: Counter) -> 'Counter' | t.CPtr: pass
|
||||
def __init__(self: Counter) -> t.CInt: pass
|
||||
@property
|
||||
def value(self: Counter) -> t.CInt: pass
|
||||
@value.setter
|
||||
def value(self: Counter, v: t.CInt) -> t.CInt: pass
|
||||
|
||||
def test_property_getter_redef() -> t.CInt: pass
|
||||
|
||||
|
||||
class Config:
|
||||
_value: t.CInt
|
||||
_deleted: t.CInt
|
||||
def __new__(self: Config, v: t.CInt) -> 'Config' | t.CPtr: pass
|
||||
def __init__(self: Config, v: t.CInt) -> t.CInt: pass
|
||||
@property
|
||||
def value(self: Config) -> t.CInt: pass
|
||||
@value.setter
|
||||
def value(self: Config, v: t.CInt) -> t.CInt: pass
|
||||
@value.deleter
|
||||
def value(self: Config) -> t.CInt: pass
|
||||
def is_deleted(self: Config) -> bool: pass
|
||||
|
||||
def test_property_deleter() -> t.CInt: pass
|
||||
|
||||
|
||||
class MathUtils:
|
||||
@staticmethod
|
||||
def add(a: t.CInt, b: t.CInt) -> t.CInt: pass
|
||||
@staticmethod
|
||||
def max_val(a: t.CInt, b: t.CInt) -> t.CInt: pass
|
||||
|
||||
def test_staticmethod() -> t.CInt: pass
|
||||
|
||||
|
||||
class Point:
|
||||
x: t.CDouble
|
||||
y: t.CDouble
|
||||
def __new__(self: Point, x: t.CDouble, y: t.CDouble) -> 'Point' | t.CPtr: pass
|
||||
def __init__(self: Point, x: t.CDouble, y: t.CDouble) -> t.CInt: pass
|
||||
@classmethod
|
||||
def origin(cls: Point) -> Point: pass
|
||||
@classmethod
|
||||
def from_int(cls: Point, x: t.CInt, y: t.CInt) -> Point: pass
|
||||
def dist_sq(self: Point) -> t.CDouble: pass
|
||||
|
||||
def test_classmethod() -> t.CInt: pass
|
||||
|
||||
|
||||
class Circle:
|
||||
_radius: t.CDouble
|
||||
def __new__(self: Circle, r: t.CDouble) -> 'Circle' | t.CPtr: pass
|
||||
def __init__(self: Circle, r: t.CDouble) -> t.CInt: pass
|
||||
@property
|
||||
def radius(self: Circle) -> t.CDouble: pass
|
||||
@radius.setter
|
||||
def radius(self: Circle, val: t.CDouble) -> t.CInt: pass
|
||||
@property
|
||||
def area(self: Circle) -> t.CDouble: pass
|
||||
@staticmethod
|
||||
def is_unit(r: t.CDouble) -> bool: pass
|
||||
@classmethod
|
||||
def unit(cls: Circle) -> Circle: pass
|
||||
|
||||
def test_combined() -> t.CInt: pass
|
||||
|
||||
def main() -> t.CInt | t.CExport: pass
|
||||
100
Test/BuiltinDecoratorTest/temp/f5522571bcce7bcb.pyi
Normal file
100
Test/BuiltinDecoratorTest/temp/f5522571bcce7bcb.pyi
Normal 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
|
||||
Reference in New Issue
Block a user