snapshot before regression test
This commit is contained in:
commit
796222a300
2295 files changed
+206453
No files matched your search
@@ -0,0 +1,205 @@
|
||||
import t, c
|
||||
from stdint import *
|
||||
import stdio
|
||||
import stdlib
|
||||
import string
|
||||
import memhub
|
||||
import argparse
|
||||
import testcheck
|
||||
|
||||
|
||||
# 全局 MBuddy 指针
|
||||
_mbuddy: memhub.MemBuddy | t.CPtr
|
||||
|
||||
|
||||
@t.CExport
|
||||
def main() -> int:
|
||||
testcheck.begin("ArgparseTest: 命令行参数解析")
|
||||
|
||||
# 初始化内存管理器
|
||||
arena: bytes = stdlib.malloc(16 * 1024 * 1024)
|
||||
if arena is None:
|
||||
testcheck.fail("malloc arena failed")
|
||||
return 1
|
||||
|
||||
_mbuddy = memhub.MemBuddy(arena, 16 * 1024 * 1024)
|
||||
argparse._mbuddy = _mbuddy
|
||||
|
||||
# 构造模拟 argv: myprog --input test.txt -c 42 --verbose output.dat
|
||||
argv_buf: bytes = _mbuddy.alloc(8 * 7) # 7 个指针
|
||||
argv: str | t.CPtr = argv_buf
|
||||
|
||||
# argv[0] = "myprog"
|
||||
s0: bytes = _mbuddy.alloc(16)
|
||||
string.strcpy(s0, "myprog")
|
||||
argv0: str | t.CPtr = t.CPtr(t.CUInt64T(argv))
|
||||
argv0[0] = s0
|
||||
|
||||
# argv[1] = "--input"
|
||||
s1: bytes = _mbuddy.alloc(16)
|
||||
string.strcpy(s1, "--input")
|
||||
argv1: str | t.CPtr = t.CPtr(t.CUInt64T(argv) + 8)
|
||||
argv1[0] = s1
|
||||
|
||||
# argv[2] = "test.txt"
|
||||
s2: bytes = _mbuddy.alloc(16)
|
||||
string.strcpy(s2, "test.txt")
|
||||
argv2: str | t.CPtr = t.CPtr(t.CUInt64T(argv) + 16)
|
||||
argv2[0] = s2
|
||||
|
||||
# argv[3] = "-c"
|
||||
s3: bytes = _mbuddy.alloc(8)
|
||||
string.strcpy(s3, "-c")
|
||||
argv3: str | t.CPtr = t.CPtr(t.CUInt64T(argv) + 24)
|
||||
argv3[0] = s3
|
||||
|
||||
# argv[4] = "42"
|
||||
s4: bytes = _mbuddy.alloc(8)
|
||||
string.strcpy(s4, "42")
|
||||
argv4: str | t.CPtr = t.CPtr(t.CUInt64T(argv) + 32)
|
||||
argv4[0] = s4
|
||||
|
||||
# argv[5] = "--verbose"
|
||||
s5: bytes = _mbuddy.alloc(16)
|
||||
string.strcpy(s5, "--verbose")
|
||||
argv5: str | t.CPtr = t.CPtr(t.CUInt64T(argv) + 40)
|
||||
argv5[0] = s5
|
||||
|
||||
# argv[6] = "output.dat"
|
||||
s6: bytes = _mbuddy.alloc(16)
|
||||
string.strcpy(s6, "output.dat")
|
||||
argv6: str | t.CPtr = t.CPtr(t.CUInt64T(argv) + 48)
|
||||
argv6[0] = s6
|
||||
|
||||
argc: INT = 7
|
||||
|
||||
# ============================================================
|
||||
# Test 1: 基本解析 (--input, -c, --verbose, output)
|
||||
# ============================================================
|
||||
testcheck.section("Test 1: 基本解析")
|
||||
parser = argparse.ArgumentParser("myprog", "A test program for argparse", pool=_mbuddy)
|
||||
parser.add_argument("--input", "-i", argparse.STRING, 0, None, True, argparse.STORE, "input file path")
|
||||
parser.add_argument("--count", "-c", argparse.INT, 1, None, False, argparse.STORE, "repeat count")
|
||||
parser.add_argument("--verbose", "-v", argparse.BOOL, 0, None, False, argparse.STORE_TRUE, "enable verbose output")
|
||||
parser.add_argument("output", None, argparse.STRING, 0, None, False, argparse.STORE, "output file path")
|
||||
|
||||
args = parser.parse_args(argc, argv)
|
||||
if args is not None:
|
||||
testcheck.ok("parse_args returned non-NULL")
|
||||
inp: str = args.get_str("input")
|
||||
cnt: INT = args.get_int("count")
|
||||
verb: INT = args.get_bool("verbose")
|
||||
out: str = args.get_str("output")
|
||||
stdio.printf("[DBG] has(verbose)=%d, get_bool(verbose)=%d\n", 1 if args.has("verbose") else 0, 1 if verb else 0)
|
||||
testcheck.check(string.strcmp(inp, "test.txt") == 0, "input = test.txt", "input mismatch")
|
||||
testcheck.check(cnt == 42, "count = 42", "count mismatch")
|
||||
testcheck.check(verb == True, "verbose = True", "verbose mismatch")
|
||||
testcheck.check(string.strcmp(out, "output.dat") == 0, "output = output.dat", "output mismatch")
|
||||
argparse.release(args)
|
||||
else:
|
||||
testcheck.fail("parse_args returned NULL")
|
||||
|
||||
# ============================================================
|
||||
# Test 2: --name=value 语法
|
||||
# ============================================================
|
||||
testcheck.section("Test 2: --name=value 语法")
|
||||
|
||||
argv2_buf: bytes = _mbuddy.alloc(8 * 3)
|
||||
argv2: str | t.CPtr = argv2_buf
|
||||
|
||||
a0: bytes = _mbuddy.alloc(16)
|
||||
string.strcpy(a0, "myprog")
|
||||
a0_ptr: str | t.CPtr = t.CPtr(t.CUInt64T(argv2))
|
||||
a0_ptr[0] = a0
|
||||
|
||||
a1: bytes = _mbuddy.alloc(32)
|
||||
string.strcpy(a1, "--input=hello.txt")
|
||||
a1_ptr: str | t.CPtr = t.CPtr(t.CUInt64T(argv2) + 8)
|
||||
a1_ptr[0] = a1
|
||||
|
||||
a2: bytes = _mbuddy.alloc(16)
|
||||
string.strcpy(a2, "output2.dat")
|
||||
a2_ptr: str | t.CPtr = t.CPtr(t.CUInt64T(argv2) + 16)
|
||||
a2_ptr[0] = a2
|
||||
|
||||
args2 = parser.parse_args(3, argv2)
|
||||
if args2 is not None:
|
||||
testcheck.ok("parse_args returned non-NULL")
|
||||
inp2: str = args2.get_str("input")
|
||||
cnt2: INT = args2.get_int("count")
|
||||
out2: str = args2.get_str("output")
|
||||
testcheck.check(string.strcmp(inp2, "hello.txt") == 0, "input = hello.txt", "input mismatch")
|
||||
testcheck.check(cnt2 == 1, "count = 1 (default)", "count mismatch")
|
||||
testcheck.check(string.strcmp(out2, "output2.dat") == 0, "output = output2.dat", "output mismatch")
|
||||
argparse.release(args2)
|
||||
else:
|
||||
testcheck.fail("parse_args returned NULL")
|
||||
|
||||
# ============================================================
|
||||
# Test 3: -v COUNT 计数动作
|
||||
# ============================================================
|
||||
testcheck.section("Test 3: COUNT 计数动作")
|
||||
|
||||
argv3_buf: bytes = _mbuddy.alloc(8 * 4)
|
||||
argv3_arr: str | t.CPtr = argv3_buf
|
||||
|
||||
b0: bytes = _mbuddy.alloc(8)
|
||||
string.strcpy(b0, "myprog")
|
||||
b0_ptr: str | t.CPtr = t.CPtr(t.CUInt64T(argv3_arr))
|
||||
b0_ptr[0] = b0
|
||||
|
||||
b1: bytes = _mbuddy.alloc(8)
|
||||
string.strcpy(b1, "-v")
|
||||
b1_ptr: str | t.CPtr = t.CPtr(t.CUInt64T(argv3_arr) + 8)
|
||||
b1_ptr[0] = b1
|
||||
|
||||
b2: bytes = _mbuddy.alloc(8)
|
||||
string.strcpy(b2, "-v")
|
||||
b2_ptr: str | t.CPtr = t.CPtr(t.CUInt64T(argv3_arr) + 16)
|
||||
b2_ptr[0] = b2
|
||||
|
||||
b3: bytes = _mbuddy.alloc(16)
|
||||
string.strcpy(b3, "output3.dat")
|
||||
b3_ptr: str | t.CPtr = t.CPtr(t.CUInt64T(argv3_arr) + 24)
|
||||
b3_ptr[0] = b3
|
||||
|
||||
parser2 = argparse.ArgumentParser("myprog", "Count test", pool=_mbuddy)
|
||||
parser2.add_argument("--verbose", "-v", argparse.BOOL, 0, None, False, argparse.COUNT, "verbosity level")
|
||||
parser2.add_argument("output", None, argparse.STRING, 0, None, False, argparse.STORE, "output file")
|
||||
|
||||
args3 = parser2.parse_args(4, argv3_arr)
|
||||
if args3 is not None:
|
||||
testcheck.ok("parse_args returned non-NULL")
|
||||
verb3: INT = args3.get_int("verbose")
|
||||
out3: str = args3.get_str("output")
|
||||
testcheck.check(verb3 == 2, "verbose = 2 (counted)", "verbose count mismatch")
|
||||
testcheck.check(string.strcmp(out3, "output3.dat") == 0, "output = output3.dat", "output mismatch")
|
||||
argparse.release(args3)
|
||||
else:
|
||||
testcheck.fail("parse_args returned NULL")
|
||||
|
||||
# ============================================================
|
||||
# Test 4: 关键字参数调用 add_argument
|
||||
# ============================================================
|
||||
testcheck.section("Test 4: 关键字参数")
|
||||
|
||||
parser3 = argparse.ArgumentParser("myprog", "Keyword arg test", pool=_mbuddy)
|
||||
parser3.add_argument("--input", short="-i", arg_type=argparse.STRING, default=0, default_str=None, required=False, action=argparse.STORE, help="input file")
|
||||
parser3.add_argument("--count", short="-c", arg_type=argparse.INT, default=1, required=False, action=argparse.STORE, help="count")
|
||||
parser3.add_argument("--verbose", short="-v", arg_type=argparse.BOOL, default=0, required=False, action=argparse.STORE_TRUE, help="verbose")
|
||||
parser3.add_argument("output", arg_type=argparse.STRING, default=0, required=False, action=argparse.STORE, help="output file")
|
||||
|
||||
args4 = parser3.parse_args(argc, argv)
|
||||
if args4 is not None:
|
||||
testcheck.ok("parse_args returned non-NULL")
|
||||
inp4: str = args4.get_str("input")
|
||||
cnt4: INT = args4.get_int("count")
|
||||
out4: str = args4.get_str("output")
|
||||
testcheck.check(string.strcmp(inp4, "test.txt") == 0, "input = test.txt", "input mismatch")
|
||||
testcheck.check(cnt4 == 42, "count = 42", "count mismatch")
|
||||
testcheck.check(string.strcmp(out4, "output.dat") == 0, "output = output.dat", "output mismatch")
|
||||
argparse.release(args4)
|
||||
else:
|
||||
testcheck.fail("parse_args returned NULL")
|
||||
|
||||
return testcheck.end()
|
||||
@@ -0,0 +1 @@
|
||||
{"atom": "271ea3decb810db2", "stdio": "6f62fe05c5ea1ceb", "w32.win32base": "7e529fe7a078cfef", "win32base": "7e529fe7a078cfef", "stdlib": "90c53dd6db8d41cf", "string": "ab6e54ba9a669f76", "argparse": "aba439b7882ad9d6", "hashtable": "b8c66c8ff44eb874", "w32.win32console": "bbdf3bbd4c3bc28c", "win32console": "bbdf3bbd4c3bc28c", "viperio": "c9f4be41ca1cc2b4", "testcheck": "dd3002730623424b", "memhub": "ee084e9fc6ee413a", "stdint": "f5522571bcce7bcb"}
|
||||
@@ -0,0 +1,30 @@
|
||||
{
|
||||
"$schema": "https://raw.githubusercontent.com/TermiNexus/TransPyC/main/schemas/project-schema.json",
|
||||
"name": "ArgparseTest",
|
||||
"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", "-lmsvcrt", "-lucrt", "-lpthread", "-lmingwex", "-lkernel32"],
|
||||
"output": "ArgparseTest.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,
|
||||
"startup": false
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{}
|
||||
@@ -0,0 +1,19 @@
|
||||
"""
|
||||
Auto-generated Python stub file from main.py
|
||||
Module: main
|
||||
"""
|
||||
|
||||
|
||||
import t, c
|
||||
from stdint import *
|
||||
import stdio
|
||||
import stdlib
|
||||
import string
|
||||
import memhub
|
||||
import argparse
|
||||
import testcheck
|
||||
|
||||
_mbuddy: t.CExtern | memhub.MemBuddy | t.CPtr
|
||||
|
||||
@t.CExport
|
||||
def main() -> int: pass
|
||||
@@ -0,0 +1,26 @@
|
||||
"""
|
||||
Auto-generated Python stub file from atom.py
|
||||
Module: atom
|
||||
"""
|
||||
|
||||
|
||||
import t, c
|
||||
|
||||
ATOMIC_RELAXED: t.CDefine = 0
|
||||
ATOMIC_CONSUME: t.CDefine = 1
|
||||
ATOMIC_ACQUIRE: t.CDefine = 2
|
||||
ATOMIC_RELEASE: t.CDefine = 3
|
||||
ATOMIC_ACQ_REL: t.CDefine = 4
|
||||
ATOMIC_SEQ_CST: t.CDefine = 5
|
||||
|
||||
def __atomic_test_and_set(ptr: t.CUInt64T | t.CPtr, order: t.CInt) -> t.CBool: pass
|
||||
|
||||
def __atomic_clear(ptr: t.CUInt64T | t.CPtr, order: t.CInt) -> t.CVoid: pass
|
||||
|
||||
def __atomic_thread_fence(order: t.CInt) -> t.CVoid: pass
|
||||
|
||||
def __atomic_signal_fence(order: t.CInt) -> t.CVoid: pass
|
||||
|
||||
def __atomic_always_lock_free(size: t.CSizeT, ptr: t.CVoid | t.CPtr) -> t.CBool: pass
|
||||
|
||||
def __atomic_is_lock_free(size: t.CSizeT, ptr: t.CVoid | t.CPtr) -> t.CBool: pass
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -0,0 +1 @@
|
||||
{"D:\\Users\\TermiNexus\\Desktop\\TransPyC\\Test\\ArgparseTest\\App\\main.py": {"sha1": "08ea5281873244fd", "mtime": 1783074740.4694562, "size": 8086}, "D:\\Users\\TermiNexus\\Desktop\\TransPyC\\includes\\argparse.py": {"sha1": "aba439b7882ad9d6", "mtime": 1783072446.3366802, "size": 16968}, "D:\\Users\\TermiNexus\\Desktop\\TransPyC\\includes\\atom.py": {"sha1": "271ea3decb810db2", "mtime": 1782226548.693161, "size": 1290}, "D:\\Users\\TermiNexus\\Desktop\\TransPyC\\includes\\hashtable.py": {"sha1": "b8c66c8ff44eb874", "mtime": 1782826619.490043, "size": 9385}, "D:\\Users\\TermiNexus\\Desktop\\TransPyC\\includes\\memhub.py": {"sha1": "ee084e9fc6ee413a", "mtime": 1784214242.4485993, "size": 17765}, "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\\string.py": {"sha1": "ab6e54ba9a669f76", "mtime": 1783933178.7264287, "size": 9922}, "D:\\Users\\TermiNexus\\Desktop\\TransPyC\\includes\\testcheck.py": {"sha1": "dd3002730623424b", "mtime": 1783927513.1159866, "size": 1818}, "D:\\Users\\TermiNexus\\Desktop\\TransPyC\\includes\\viperio.py": {"sha1": "c9f4be41ca1cc2b4", "mtime": 1782812279.506002, "size": 1556}, "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}}
|
||||
@@ -0,0 +1,13 @@
|
||||
08ea5281873244fd:main.py
|
||||
271ea3decb810db2:includes/atom.py
|
||||
6f62fe05c5ea1ceb:includes/stdio.py
|
||||
7e529fe7a078cfef:includes/w32\win32base.py
|
||||
90c53dd6db8d41cf:includes/stdlib.py
|
||||
ab6e54ba9a669f76:includes/string.py
|
||||
aba439b7882ad9d6:includes/argparse.py
|
||||
b8c66c8ff44eb874:includes/hashtable.py
|
||||
bbdf3bbd4c3bc28c:includes/w32\win32console.py
|
||||
c9f4be41ca1cc2b4:includes/viperio.py
|
||||
dd3002730623424b:includes/testcheck.py
|
||||
ee084e9fc6ee413a:includes/memhub.py
|
||||
f5522571bcce7bcb:includes/stdint.py
|
||||
@@ -0,0 +1,48 @@
|
||||
"""
|
||||
Auto-generated Python stub file from string.py
|
||||
Module: string
|
||||
"""
|
||||
|
||||
|
||||
from stdint import *
|
||||
import t, c
|
||||
|
||||
def strcpy(dest: str, src: str) -> str: pass
|
||||
|
||||
def strcat(dest: str, src: str) -> str: pass
|
||||
|
||||
def strncpy(dest: str, src: str, n: t.CSizeT) -> str: pass
|
||||
|
||||
def strlen(src: str) -> t.CSizeT | t.CExport: pass
|
||||
|
||||
def strcmp(str1: str, str2: str) -> t.CInt: pass
|
||||
|
||||
def samestr(str1: str, str2: str) -> bool: pass
|
||||
|
||||
def strncmp(str1: str, str2: str, n: t.CSizeT) -> t.CInt: pass
|
||||
|
||||
def memcmp(ptr1: t.CVoid | t.CPtr, ptr2: t.CVoid | t.CPtr, n: t.CSizeT) -> t.CInt: pass
|
||||
|
||||
def strchr(s: str, cr: t.CInt) -> str: pass
|
||||
|
||||
def strrchr(s: str, cr: t.CInt) -> str: pass
|
||||
|
||||
def strstr(s: str, needle: str) -> str: pass
|
||||
|
||||
def strspn(s: str, skip: str) -> int: pass
|
||||
|
||||
def memset(ptr: t.CVoid | t.CPtr, value: t.CInt, num: t.CSizeT) -> t.CVoid | t.CPtr | t.CExport: pass
|
||||
|
||||
def memset32(ptr: t.CVoid | t.CPtr, value: t.CUInt32T, count: t.CSizeT) -> t.CVoid | t.CPtr: pass
|
||||
|
||||
def memcpy(dest: t.CVoid | t.CPtr, src: t.CVoid | t.CPtr, num: t.CSizeT) -> t.CVoid | t.CPtr | t.CExport: pass
|
||||
|
||||
def memmove(dest: t.CVoid | t.CPtr, src: t.CVoid | t.CPtr, num: t.CSizeT) -> t.CVoid | t.CPtr: pass
|
||||
|
||||
def atoi(src: str) -> t.CInt: pass
|
||||
|
||||
def atoll(src: str) -> t.CInt64T: pass
|
||||
|
||||
def atof(src: str) -> t.CDouble: pass
|
||||
|
||||
def split(s: str, delim: str, result: t.CArray[str]) -> int: pass
|
||||
@@ -0,0 +1,67 @@
|
||||
"""
|
||||
Auto-generated Python stub file from argparse.py
|
||||
Module: argparse
|
||||
"""
|
||||
|
||||
|
||||
import t, c
|
||||
from stdint import *
|
||||
import string
|
||||
import memhub
|
||||
import stdio
|
||||
import hashtable
|
||||
|
||||
STRING: t.CDefine = 0
|
||||
INT: t.CDefine = 1
|
||||
BOOL: t.CDefine = 2
|
||||
STORE: t.CDefine = 0
|
||||
STORE_TRUE: t.CDefine = 1
|
||||
STORE_FALSE: t.CDefine = 2
|
||||
COUNT: t.CDefine = 3
|
||||
MAX_ARGS: t.CDefine = 32
|
||||
_mbuddy: t.CExtern | memhub.MemBuddy | t.CPtr
|
||||
|
||||
class Argument:
|
||||
name: str
|
||||
short_name: str
|
||||
help_text: str
|
||||
arg_type: INT
|
||||
action: INT
|
||||
default_int: INT
|
||||
default_str: str
|
||||
required: bool
|
||||
is_positional: bool
|
||||
dest: str
|
||||
class ParsedArgs:
|
||||
_ht: hashtable.HashTable | t.CPtr
|
||||
__mbuddy__: memhub.MemBuddy | t.CPtr
|
||||
def __new__(self: ParsedArgs, mb: memhub.MemBuddy | t.CPtr) -> t.CPtr: pass
|
||||
def __init__(self: ParsedArgs, mb: memhub.MemBuddy | t.CPtr) -> t.CInt: pass
|
||||
def get_str(self: ParsedArgs, name: str) -> str: pass
|
||||
def get_int(self: ParsedArgs, name: str) -> INT: pass
|
||||
def get_bool(self: ParsedArgs, name: str) -> INT: pass
|
||||
def has(self: ParsedArgs, name: str) -> bool: pass
|
||||
def _set_str(self: ParsedArgs, name: str, val: str) -> t.CInt: pass
|
||||
def _set_int(self: ParsedArgs, name: str, val: INT) -> t.CInt: pass
|
||||
def _set_bool(self: ParsedArgs, name: str, val: bool) -> t.CInt: pass
|
||||
class ArgumentParser:
|
||||
_prog: str
|
||||
_description: str
|
||||
_args: Argument | t.CPtr
|
||||
_arg_count: INT
|
||||
__mbuddy__: memhub.MemBuddy | t.CPtr
|
||||
def __new__(self: ArgumentParser, prog: str, description: str, pool: memhub.MemBuddy | t.CPtr) -> t.CPtr: pass
|
||||
def __init__(self: ArgumentParser, prog: str, description: str, pool: memhub.MemBuddy | t.CPtr) -> t.CInt: pass
|
||||
def add_argument(self: ArgumentParser, name: str, short: str, arg_type: INT, default: INT, default_str: str, required: bool, action: INT, help: str) -> t.CInt: pass
|
||||
def _get_arg(self: ArgumentParser, idx: INT) -> Argument | t.CPtr: pass
|
||||
def _find_long(self: ArgumentParser, token: str) -> INT: pass
|
||||
def _find_long_prefix(self: ArgumentParser, token: str) -> INT: pass
|
||||
def _find_short(self: ArgumentParser, token: str) -> INT: pass
|
||||
def _find_positional(self: ArgumentParser, pos_idx: INT) -> INT: pass
|
||||
def _store_value(self: ArgumentParser, args: ParsedArgs | t.CPtr, arg: Argument | t.CPtr, value: str) -> t.CInt: pass
|
||||
def _apply_action(self: ArgumentParser, args: ParsedArgs | t.CPtr, arg: Argument | t.CPtr) -> t.CInt: pass
|
||||
def parse_args(self: ArgumentParser, argc: INT, argv: str | t.CPtr) -> ParsedArgs | t.CPtr: pass
|
||||
def print_help(self: ArgumentParser) -> t.CInt: pass
|
||||
def print_usage(self: ArgumentParser) -> t.CInt: pass
|
||||
|
||||
def release(args: ParsedArgs | t.CPtr) -> t.CInt: pass
|
||||
@@ -0,0 +1,46 @@
|
||||
"""
|
||||
Auto-generated Python stub file from hashtable.py
|
||||
Module: hashtable
|
||||
"""
|
||||
|
||||
|
||||
import t, c
|
||||
import string
|
||||
import memhub
|
||||
from stdint import *
|
||||
|
||||
_HT_EMPTY: t.CDefine = 0
|
||||
_HT_TOMBSTONE: t.CDefine = 1
|
||||
_HT_INIT_CAP: t.CDefine = 16
|
||||
_HT_SLOT_SIZE: t.CDefine = 24
|
||||
_FNV_OFFSET: t.CExtern | t.CUInt64T
|
||||
_FNV_PRIME: t.CExtern | t.CUInt64T
|
||||
|
||||
def _fnv1a_hash(key: str) -> t.CUInt64T: pass
|
||||
|
||||
|
||||
class HashTable:
|
||||
__slots__: t.CVoid | t.CPtr
|
||||
__count__: t.CSizeT = 0
|
||||
__capacity__: t.CSizeT = 16
|
||||
__tombstones__: t.CSizeT = 0
|
||||
__mbuddy__: memhub.MemBuddy | t.CPtr
|
||||
__iter_index__: t.CSizeT = 0
|
||||
def __new__(self: HashTable, mb: memhub.MemBuddy | t.CPtr) -> t.CPtr: pass
|
||||
def __init__(self: HashTable, mb: memhub.MemBuddy | t.CPtr) -> t.CInt: pass
|
||||
def _slot_hash(self: HashTable, idx: t.CSizeT) -> t.CUInt64T: pass
|
||||
def _slot_key(self: HashTable, idx: t.CSizeT) -> str: pass
|
||||
def _slot_value(self: HashTable, idx: t.CSizeT) -> t.CPtr: pass
|
||||
def _set_slot(self: HashTable, idx: t.CSizeT, h: t.CUInt64T, key: str, val: t.CPtr) -> t.CInt: pass
|
||||
def _find_slot(self: HashTable, key: str, h: t.CUInt64T) -> t.CSizeT: pass
|
||||
def _resize(self: HashTable, new_cap: t.CSizeT) -> t.CInt: pass
|
||||
def __setitem__(self: HashTable, key: str, val: t.CNeedPtr) -> t.CInt: pass
|
||||
def __getitem__(self: HashTable, key: str) -> t.CPtr: pass
|
||||
def __contains__(self: HashTable, key: str) -> t.CInt: pass
|
||||
def __delitem__(self: HashTable, key: str) -> t.CInt: pass
|
||||
def __len__(self: HashTable) -> t.CSizeT: pass
|
||||
def __iter__(self: HashTable) -> HashTable | t.CPtr: pass
|
||||
def __next__(self: HashTable) -> str: pass
|
||||
def get(self: HashTable, key: str, default: t.CPtr) -> t.CPtr: pass
|
||||
def set_int(self: HashTable, key: str, val: int) -> t.CInt: pass
|
||||
def set_str(self: HashTable, key: str, val: str) -> t.CInt: pass
|
||||
@@ -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
|
||||
@@ -0,0 +1,22 @@
|
||||
"""
|
||||
Auto-generated Python stub file from viperio.py
|
||||
Module: viperio
|
||||
"""
|
||||
|
||||
|
||||
import t, c
|
||||
from stdint import *
|
||||
|
||||
class Buf:
|
||||
data: t.CChar | t.CPtr
|
||||
length: t.CSizeT
|
||||
capacity: t.CSizeT
|
||||
owned: bool
|
||||
def __init__(self: Buf, data: t.CChar | t.CPtr, capacity: t.CSizeT, length: t.CSizeT, owned: bool) -> t.CInt: pass
|
||||
def clear(self: Buf) -> t.CInt: pass
|
||||
def write(self: Buf, src: t.CChar | t.CPtr, count: t.CSizeT) -> t.CSizeT: pass
|
||||
def cstr(self: Buf) -> t.CChar | t.CPtr: pass
|
||||
def reset(self: Buf) -> t.CInt: pass
|
||||
def __enter__(self: Buf) -> 'Buf' | t.CPtr: pass
|
||||
def __exit__(self: Buf) -> t.CInt: pass
|
||||
def free(self: Buf) -> t.CInt: pass
|
||||
@@ -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
|
||||
@@ -0,0 +1,81 @@
|
||||
"""
|
||||
Auto-generated Python stub file from memhub.py
|
||||
Module: memhub
|
||||
"""
|
||||
|
||||
|
||||
import t, c
|
||||
from stdint import *
|
||||
import string
|
||||
import atom
|
||||
import viperio
|
||||
|
||||
MEMHUB_ALIGN: t.CDefine = 8
|
||||
MEMSLAB_MIN_BLOCK: t.CDefine = 16
|
||||
MEMSLAB_BITMAP_BYTES: t.CDefine = 256
|
||||
MEMBUDDY_MIN_BLOCK: t.CDefine = 32
|
||||
MEMBUDDY_MAX_ORDERS: t.CDefine = 32
|
||||
MEMBUDDY_HEADER_SIZE: t.CDefine = 8
|
||||
|
||||
def _align_up(val: t.CSizeT, align: t.CSizeT) -> t.CSizeT: pass
|
||||
|
||||
def _largest_pow2_le(val: t.CSizeT) -> t.CSizeT: pass
|
||||
|
||||
def _block_size_at_order(order: t.CInt) -> t.CSizeT: pass
|
||||
|
||||
|
||||
@t.CVTable
|
||||
class MemManager:
|
||||
__provides__: list[str] = ['__memmgr__']
|
||||
base: t.CVoid | t.CPtr
|
||||
size: t.CSizeT
|
||||
def __init__(self: MemManager, base: t.CVoid | t.CPtr, size: t.CSizeT) -> t.CInt: pass
|
||||
def alloc(self: MemManager, size: t.CSizeT) -> t.CVoid | t.CPtr: pass
|
||||
def free(self: MemManager, ptr: t.CVoid | t.CPtr) -> t.CInt: pass
|
||||
def reset(self: MemManager) -> t.CInt: pass
|
||||
def calloc(self: MemManager, count: t.CSizeT, size: t.CSizeT) -> t.CVoid | t.CPtr: pass
|
||||
def realloc(self: MemManager, ptr: t.CVoid | t.CPtr, old_size: t.CSizeT, new_size: t.CSizeT) -> t.CVoid | t.CPtr: pass
|
||||
def __enter__(self: MemManager) -> 'MemManager' | t.CPtr: pass
|
||||
def __exit__(self: MemManager) -> t.CInt: pass
|
||||
def alloc_buf(self: MemManager, capacity: t.CSizeT) -> viperio.Buf | t.CPtr: pass
|
||||
class MemPool(MemManager):
|
||||
offset: t.CSizeT
|
||||
high_water: t.CSizeT
|
||||
def __init__(self: MemPool, base: t.CVoid | t.CPtr, size: t.CSizeT) -> t.CInt: pass
|
||||
def alloc(self: MemPool, size: t.CSizeT) -> t.CVoid | t.CPtr: pass
|
||||
def free(self: MemPool, ptr: t.CVoid | t.CPtr) -> t.CInt: pass
|
||||
def reset(self: MemPool) -> t.CInt: pass
|
||||
class MemSlab(MemManager):
|
||||
block_size: t.CSizeT
|
||||
block_count: t.CSizeT
|
||||
used_count: t.CSizeT
|
||||
free_list: t.CVoid | t.CPtr
|
||||
alloc_map: t.CUInt8T | t.CPtr
|
||||
alloc_map_size: t.CSizeT
|
||||
usable: t.CVoid | t.CPtr
|
||||
usable_size: t.CSizeT
|
||||
def __init__(self: MemSlab, base: t.CVoid | t.CPtr, size: t.CSizeT, block_size: t.CSizeT) -> t.CInt: pass
|
||||
def alloc(self: MemSlab, size: t.CSizeT) -> t.CVoid | t.CPtr: pass
|
||||
def free(self: MemSlab, ptr: t.CVoid | t.CPtr) -> t.CInt: pass
|
||||
def reset(self: MemSlab) -> t.CInt: pass
|
||||
class MemBuddy(MemManager):
|
||||
max_order: t.CInt
|
||||
free_lists: t.CUInt64T | t.CPtr
|
||||
lock_val: t.CVolatile | t.CInt
|
||||
usable: t.CVoid | t.CPtr
|
||||
usable_size: t.CSizeT
|
||||
def __init__(self: MemBuddy, base: t.CVoid | t.CPtr, size: t.CSizeT) -> t.CInt: pass
|
||||
def _fl_push(self: MemBuddy, order: t.CInt, block: t.CVoid | t.CPtr) -> t.CInt: pass
|
||||
def _fl_pop(self: MemBuddy, order: t.CInt) -> t.CVoid | t.CPtr: pass
|
||||
def _fl_find_and_remove(self: MemBuddy, order: t.CInt, target: t.CVoid | t.CPtr) -> t.CInt: pass
|
||||
def _buddy_of(self: MemBuddy, block: t.CVoid | t.CPtr, order: t.CInt) -> t.CVoid | t.CPtr: pass
|
||||
def _order_for_size(self: MemBuddy, size: t.CSizeT) -> t.CInt: pass
|
||||
def _split_to_order(self: MemBuddy, to_order: t.CInt) -> t.CVoid | t.CPtr: pass
|
||||
def _coalesce(self: MemBuddy, block: t.CVoid | t.CPtr, order: t.CInt) -> t.CInt: pass
|
||||
def _is_valid_ptr(self: MemBuddy, ptr: t.CVoid | t.CPtr) -> t.CInt: pass
|
||||
def _lock(self: MemBuddy) -> t.CInt: pass
|
||||
def _unlock(self: MemBuddy) -> t.CInt: pass
|
||||
def alloc(self: MemBuddy, size: t.CSizeT) -> t.CVoid | t.CPtr: pass
|
||||
def free(self: MemBuddy, ptr: t.CVoid | t.CPtr) -> t.CInt: pass
|
||||
def reset(self: MemBuddy) -> t.CInt: pass
|
||||
def realloc(self: MemBuddy, ptr: t.CVoid | t.CPtr, old_size: t.CSizeT, new_size: t.CSizeT) -> t.CVoid | t.CPtr: pass
|
||||
@@ -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
|
||||
@@ -0,0 +1,105 @@
|
||||
from stdint import *
|
||||
import t, c
|
||||
from t import CInt, CExport
|
||||
from stdio import printf
|
||||
import memhub
|
||||
import stdlib
|
||||
import sys
|
||||
import string
|
||||
import ast
|
||||
import w32.win32console
|
||||
|
||||
|
||||
# MBuddy arena 大小:1MB
|
||||
ARENA_SIZE: t.CDefine = 1048576
|
||||
# mpool 内存大小:512KB
|
||||
POOL_SIZE: t.CDefine = 524288
|
||||
# dump 缓冲区大小:256KB
|
||||
DUMP_SIZE: t.CDefine = 262144
|
||||
|
||||
|
||||
def main() -> CInt | CExport:
|
||||
w32.win32console.SetConsoleCP(65001)
|
||||
w32.win32console.SetConsoleOutputCP(65001)
|
||||
|
||||
printf("AST Comprehensive Test Start\n")
|
||||
|
||||
# 初始化全局 MBuddy 内存分配器
|
||||
arena: bytes = stdlib.malloc(ARENA_SIZE)
|
||||
if arena == None:
|
||||
printf("FAIL: arena alloc failed\n")
|
||||
return 1
|
||||
mbuddy_obj: memhub.MemBuddy | t.CPtr = memhub.MemBuddy(arena, ARENA_SIZE)
|
||||
if mbuddy_obj == None:
|
||||
printf("FAIL: mbuddy init failed\n")
|
||||
return 1
|
||||
|
||||
sys._mbuddy = mbuddy_obj
|
||||
ast._mbuddy = mbuddy_obj
|
||||
|
||||
# 为 ast 解析器创建 mpool
|
||||
pool_mem: bytes = stdlib.malloc(POOL_SIZE)
|
||||
if pool_mem == None:
|
||||
printf("FAIL: malloc for pool failed\n")
|
||||
return 1
|
||||
pool: memhub.MemPool | t.CPtr = memhub.MemPool(pool_mem, POOL_SIZE)
|
||||
if pool == None:
|
||||
printf("FAIL: memhub.MemPool init failed\n")
|
||||
return 1
|
||||
|
||||
# dump 缓冲区(独立分配)
|
||||
dump_mem: bytes = stdlib.malloc(DUMP_SIZE)
|
||||
if dump_mem == None:
|
||||
printf("FAIL: malloc for dump failed\n")
|
||||
return 1
|
||||
dump_buf: t.CChar | t.CPtr = t.CChar(dump_mem, t.CPtr)
|
||||
|
||||
# 综合测试源码:覆盖 CPython 主要语法
|
||||
src: str = """x = 1
|
||||
y = 2
|
||||
z = x + y
|
||||
a = x - y
|
||||
b = x * y
|
||||
c = x / y
|
||||
d = x == y
|
||||
e = x < y
|
||||
f = x > y
|
||||
g = x and y
|
||||
h = x or y
|
||||
i = not x
|
||||
def foo(a, b):
|
||||
return a + b
|
||||
result = foo(x, y)
|
||||
if x > 0:
|
||||
print(x)
|
||||
else:
|
||||
print(y)
|
||||
for i in range(10):
|
||||
print(i)
|
||||
while x > 0:
|
||||
x = x - 1
|
||||
class Point:
|
||||
pass
|
||||
"""
|
||||
|
||||
printf("Parsing comprehensive source...\n")
|
||||
|
||||
# 解析
|
||||
tree: ast.AST | t.CPtr = ast.parse(src, pool)
|
||||
if tree == None:
|
||||
printf("FAIL: parse returned None\n")
|
||||
stdlib.free(pool_mem)
|
||||
stdlib.free(dump_mem)
|
||||
return 1
|
||||
|
||||
printf("PASS: parse succeeded\n")
|
||||
|
||||
# dump AST
|
||||
printf("Calling ast.dump...\n")
|
||||
ast.dump(tree, dump_buf, DUMP_SIZE)
|
||||
printf("ast.dump returned, now printing buffer...\n")
|
||||
printf("=== AST DUMP ===\n%s\n=== END ===\n", dump_buf)
|
||||
|
||||
stdlib.free(pool_mem)
|
||||
stdlib.free(dump_mem)
|
||||
return 0
|
||||
@@ -0,0 +1 @@
|
||||
{"w32.win32process": "067c78e9f121dce3", "win32process": "067c78e9f121dce3", "ast.lexer": "0c212981c180e7fb", "lexer": "0c212981c180e7fb", "atom": "271ea3decb810db2", "ast.__init__": "34548789d646f432", "__init__": "34548789d646f432", "ast": "34548789d646f432", "ast.astaux": "4337fb260448bbe2", "astaux": "4337fb260448bbe2", "ast.exprs": "47767b5026a8ee15", "exprs": "47767b5026a8ee15", "ast.match": "4dd6b3f1427d1cc5", "match": "4dd6b3f1427d1cc5", "ast.base": "5dab8cb390496d22", "base": "5dab8cb390496d22", "posix": "6503c97dde0c79c4", "ast.stmts": "657e182b27c2a022", "stmts": "657e182b27c2a022", "stdio": "6f62fe05c5ea1ceb", "stdarg": "71e0a3ffcb3ebfad", "w32.win32base": "7e529fe7a078cfef", "win32base": "7e529fe7a078cfef", "stdlib": "90c53dd6db8d41cf", "platmacro": "93c1d18e35d188d6", "string": "ab6e54ba9a669f76", "ast.tokens": "b547ac4f380bddb6", "tokens": "b547ac4f380bddb6", "sys": "b5a965302cded36b", "w32.win32console": "bbdf3bbd4c3bc28c", "win32console": "bbdf3bbd4c3bc28c", "viperlib": "c3b259b4059f8668", "viperio": "c9f4be41ca1cc2b4", "memhub": "ee084e9fc6ee413a", "ast.parser": "ee52c08239684346", "parser": "ee52c08239684346", "stdint": "f5522571bcce7bcb", "main.tokens": "b547ac4f380bddb6", "main.base": "5dab8cb390496d22", "main.exprs": "47767b5026a8ee15", "main.stmts": "657e182b27c2a022", "main.astaux": "4337fb260448bbe2", "main.match": "4dd6b3f1427d1cc5", "main.lexer": "0c212981c180e7fb"}
|
||||
@@ -0,0 +1,29 @@
|
||||
{
|
||||
"$schema": "https://raw.githubusercontent.com/TermiNexus/TransPyC/main/schemas/project-schema.json",
|
||||
"name": "AstTest",
|
||||
"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": ["-lmsvcrt", "-lucrt", "-lpthread", "-lmingwex", "-lkernel32", "-Wl,--allow-multiple-definition"],
|
||||
"output": "AstTest.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
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
"""
|
||||
Auto-generated Python stub file from w32.fileio.py
|
||||
Module: w32.fileio
|
||||
"""
|
||||
|
||||
|
||||
import t, c
|
||||
from stdint import *
|
||||
import stdio
|
||||
import w32.win32base
|
||||
import w32.win32file
|
||||
|
||||
class MODE(t.CEnum):
|
||||
R = 0
|
||||
W = 1
|
||||
A = 2
|
||||
RP = 3
|
||||
WP = 4
|
||||
AP = 5
|
||||
X = 6
|
||||
XP = 7
|
||||
class FRESULT(t.CEnum):
|
||||
OK = 0
|
||||
ERR = -1
|
||||
ERR_CLOSED = -2
|
||||
ERR_PERM = -3
|
||||
ERR_IO = -4
|
||||
ERR_NOTFOUND = -5
|
||||
|
||||
SEEK_SET: t.CDefine = 0
|
||||
SEEK_CUR: t.CDefine = 1
|
||||
SEEK_END: t.CDefine = 2
|
||||
INVALID_SET_FILE_POINTER: t.CDefine = -1
|
||||
SHARE_READ: t.CDefine = 0x00000001
|
||||
SHARE_WRITE: t.CDefine = 0x00000002
|
||||
SHARE_DELETE: t.CDefine = 0x00000004
|
||||
|
||||
class File:
|
||||
handle: w32.win32base.HANDLE
|
||||
closed: bool
|
||||
can_read: bool
|
||||
can_write: bool
|
||||
is_append: bool
|
||||
_share_mode: ULONG
|
||||
def __init__(self: File, filename: str, mode: ULONG, share: ULONG) -> t.CInt: pass
|
||||
def __enter__(self: File) -> 'File' | t.CPtr: pass
|
||||
def __exit__(self: File) -> t.CInt: pass
|
||||
def read(self: File, buf: bytes, count: ULONG) -> LONG: pass
|
||||
def write(self: File, buf: bytes, count: ULONG) -> LONG: pass
|
||||
def write_str(self: File, s: str) -> LONG: pass
|
||||
def seek(self: File, offset: LONG, origin: ULONG) -> LONG: pass
|
||||
def tell(self: File) -> LONG: pass
|
||||
def close(self: File) -> LONG: pass
|
||||
def flush(self: File) -> LONG: pass
|
||||
def size(self: File) -> LONGLONG: pass
|
||||
def readline(self: File, buf: bytes, max_count: ULONG) -> LONG: pass
|
||||
def read_all(self: File, buf: bytes, max_count: ULONG) -> LONG: pass
|
||||
class FileW:
|
||||
handle: w32.win32base.HANDLE
|
||||
closed: bool
|
||||
can_read: bool
|
||||
can_write: bool
|
||||
is_append: bool
|
||||
_share_mode: ULONG
|
||||
def __init__(self: FileW, filename: w32.win32base.LPCWSTR, mode: ULONG, share: ULONG) -> t.CInt: pass
|
||||
def __enter__(self: FileW) -> 'FileW' | t.CPtr: pass
|
||||
def __exit__(self: FileW) -> t.CInt: pass
|
||||
def read(self: FileW, buf: bytes, count: ULONG) -> LONG: pass
|
||||
def write(self: FileW, buf: bytes, count: ULONG) -> LONG: pass
|
||||
def write_str(self: FileW, s: str) -> LONG: pass
|
||||
def seek(self: FileW, offset: LONG, origin: ULONG) -> LONG: pass
|
||||
def tell(self: FileW) -> LONG: pass
|
||||
def close(self: FileW) -> LONG: pass
|
||||
def flush(self: FileW) -> LONG: pass
|
||||
def size(self: FileW) -> LONGLONG: pass
|
||||
def readline(self: FileW, buf: bytes, max_count: ULONG) -> LONG: pass
|
||||
def read_all(self: FileW, buf: bytes, max_count: ULONG) -> LONG: pass
|
||||
|
||||
def open(filename: str, mode: ULONG, share: ULONG) -> File | t.CPtr: pass
|
||||
|
||||
def openw(filename: LPCWSTR, mode: ULONG, share: ULONG) -> FileW | t.CPtr: pass
|
||||
@@ -0,0 +1,136 @@
|
||||
"""
|
||||
Auto-generated Python stub file from w32.win32process.py
|
||||
Module: w32.win32process
|
||||
"""
|
||||
|
||||
import c
|
||||
|
||||
|
||||
import t
|
||||
from stdint import *
|
||||
from w32.win32base import *
|
||||
|
||||
PROCESS_TERMINATE: t.CDefine = 0x0001
|
||||
PROCESS_CREATE_THREAD: t.CDefine = 0x0002
|
||||
PROCESS_VM_OPERATION: t.CDefine = 0x0008
|
||||
PROCESS_VM_READ: t.CDefine = 0x0010
|
||||
PROCESS_VM_WRITE: t.CDefine = 0x0020
|
||||
PROCESS_QUERY_INFORMATION: t.CDefine = 0x0400
|
||||
PROCESS_ALL_ACCESS: t.CDefine = 0x001FFFFF
|
||||
THREAD_TERMINATE: t.CDefine = 0x0001
|
||||
THREAD_SUSPEND_RESUME: t.CDefine = 0x0002
|
||||
THREAD_GET_CONTEXT: t.CDefine = 0x0008
|
||||
THREAD_SET_CONTEXT: t.CDefine = 0x0010
|
||||
THREAD_QUERY_INFORMATION: t.CDefine = 0x0040
|
||||
THREAD_ALL_ACCESS: t.CDefine = 0x001FFFFF
|
||||
CREATE_SUSPENDED: t.CDefine = 0x00000004
|
||||
CREATE_NEW_CONSOLE: t.CDefine = 0x00000010
|
||||
CREATE_NEW_PROCESS_GROUP: t.CDefine = 0x00000200
|
||||
CREATE_NO_WINDOW: t.CDefine = 0x08000000
|
||||
DETACHED_PROCESS: t.CDefine = 0x00000008
|
||||
STARTF_USESHOWWINDOW: t.CDefine = 0x00000001
|
||||
STARTF_USESTDHANDLES: t.CDefine = 0x00000100
|
||||
SW_HIDE: t.CDefine = 0
|
||||
SW_SHOW: t.CDefine = 5
|
||||
SW_MINIMIZE: t.CDefine = 6
|
||||
NORMAL_PRIORITY_CLASS: t.CDefine = 0x00000020
|
||||
IDLE_PRIORITY_CLASS: t.CDefine = 0x00000040
|
||||
HIGH_PRIORITY_CLASS: t.CDefine = 0x00000080
|
||||
REALTIME_PRIORITY_CLASS: t.CDefine = 0x00000100
|
||||
BELOW_NORMAL_PRIORITY_CLASS: t.CDefine = 0x00004000
|
||||
ABOVE_NORMAL_PRIORITY_CLASS: t.CDefine = 0x00008000
|
||||
STILL_ACTIVE: t.CDefine = 259
|
||||
|
||||
class STARTUPINFOA:
|
||||
cb: ULONG
|
||||
lpReserved: CHARPTR
|
||||
lpDesktop: CHARPTR
|
||||
lpTitle: CHARPTR
|
||||
dwX: ULONG
|
||||
dwY: ULONG
|
||||
dwXSize: ULONG
|
||||
dwYSize: ULONG
|
||||
dwXCountChars: ULONG
|
||||
dwYCountChars: ULONG
|
||||
dwFillAttribute: ULONG
|
||||
dwFlags: ULONG
|
||||
wShowWindow: WORD
|
||||
cbReserved2: WORD
|
||||
lpReserved2: VOIDPTR
|
||||
hStdInput: HANDLE
|
||||
hStdOutput: HANDLE
|
||||
hStdError: HANDLE
|
||||
class STARTUPINFOW:
|
||||
cb: ULONG
|
||||
lpReserved: WCHARPTR
|
||||
lpDesktop: WCHARPTR
|
||||
lpTitle: WCHARPTR
|
||||
dwX: ULONG
|
||||
dwY: ULONG
|
||||
dwXSize: ULONG
|
||||
dwYSize: ULONG
|
||||
dwXCountChars: ULONG
|
||||
dwYCountChars: ULONG
|
||||
dwFillAttribute: ULONG
|
||||
dwFlags: ULONG
|
||||
wShowWindow: WORD
|
||||
cbReserved2: WORD
|
||||
lpReserved2: VOIDPTR
|
||||
hStdInput: HANDLE
|
||||
hStdOutput: HANDLE
|
||||
hStdError: HANDLE
|
||||
class PROCESS_INFORMATION:
|
||||
hProcess: HANDLE
|
||||
hThread: HANDLE
|
||||
dwProcessId: ULONG
|
||||
dwThreadId: ULONG
|
||||
|
||||
def CreateProcessA(lpApplicationName: LPCSTR, lpCommandLine: CHARPTR, lpProcessAttributes: SECURITY_ATTRIBUTES | t.CPtr, lpThreadAttributes: SECURITY_ATTRIBUTES | t.CPtr, bInheritHandles: BOOL, dwCreationFlags: ULONG, lpEnvironment: VOIDPTR, lpCurrentDirectory: LPCSTR, lpStartupInfo: STARTUPINFOA | t.CPtr, lpProcessInformation: PROCESS_INFORMATION | t.CPtr) -> BOOL | t.State: pass
|
||||
|
||||
def CreateProcessW(lpApplicationName: LPCWSTR, lpCommandLine: WCHARPTR, lpProcessAttributes: SECURITY_ATTRIBUTES | t.CPtr, lpThreadAttributes: SECURITY_ATTRIBUTES | t.CPtr, bInheritHandles: BOOL, dwCreationFlags: ULONG, lpEnvironment: VOIDPTR, lpCurrentDirectory: LPCWSTR, lpStartupInfo: STARTUPINFOW | t.CPtr, lpProcessInformation: PROCESS_INFORMATION | t.CPtr) -> BOOL | t.State: pass
|
||||
|
||||
def TerminateProcess(hProcess: HANDLE, uExitCode: UINT) -> BOOL | t.State: pass
|
||||
|
||||
def GetExitCodeProcess(hProcess: HANDLE, lpExitCode: ULONG | t.CPtr) -> BOOL | t.State: pass
|
||||
|
||||
def GetExitCodeThread(hThread: HANDLE, lpExitCode: ULONG | t.CPtr) -> BOOL | t.State: pass
|
||||
|
||||
def OpenProcess(dwDesiredAccess: ULONG, bInheritHandle: BOOL, dwProcessId: ULONG) -> HANDLE | t.State: pass
|
||||
|
||||
def GetCurrentProcess() -> HANDLE | t.State: pass
|
||||
|
||||
def GetCurrentProcessId() -> ULONG | t.State: pass
|
||||
|
||||
def CreateThread(lpThreadAttributes: SECURITY_ATTRIBUTES | t.CPtr, dwStackSize: t.CSizeT, lpStartAddress: VOIDPTR, lpParameter: VOIDPTR, dwCreationFlags: ULONG, lpThreadId: ULONG | t.CPtr) -> HANDLE | t.State: pass
|
||||
|
||||
def OpenThread(dwDesiredAccess: ULONG, bInheritHandle: BOOL, dwThreadId: ULONG) -> HANDLE | t.State: pass
|
||||
|
||||
def SuspendThread(hThread: HANDLE) -> ULONG | t.State: pass
|
||||
|
||||
def ResumeThread(hThread: HANDLE) -> ULONG | t.State: pass
|
||||
|
||||
def TerminateThread(hThread: HANDLE, dwExitCode: ULONG) -> BOOL | t.State: pass
|
||||
|
||||
def GetCurrentThread() -> HANDLE | t.State: pass
|
||||
|
||||
def GetCurrentThreadId() -> ULONG | t.State: pass
|
||||
|
||||
def GetThreadId(hThread: HANDLE) -> ULONG | t.State: pass
|
||||
|
||||
def GetProcessId(hProcess: HANDLE) -> ULONG | t.State: pass
|
||||
|
||||
def SetThreadPriority(hThread: HANDLE, nPriority: INT) -> BOOL | t.State: pass
|
||||
|
||||
def GetThreadPriority(hThread: HANDLE) -> INT | t.State: pass
|
||||
|
||||
def ExitProcess(uExitCode: UINT) -> VOID | t.State: pass
|
||||
|
||||
def ExitThread(dwExitCode: ULONG) -> VOID | t.State: pass
|
||||
|
||||
def TlsAlloc() -> ULONG | t.State: pass
|
||||
|
||||
def TlsFree(dwTlsIndex: ULONG) -> BOOL | t.State: pass
|
||||
|
||||
def TlsGetValue(dwTlsIndex: ULONG) -> VOIDPTR | t.State: pass
|
||||
|
||||
def TlsSetValue(dwTlsIndex: ULONG, lpTlsValue: VOIDPTR) -> BOOL | t.State: pass
|
||||
@@ -0,0 +1,109 @@
|
||||
"""
|
||||
Auto-generated Python stub file from w32.win32sync.py
|
||||
Module: w32.win32sync
|
||||
"""
|
||||
|
||||
import c
|
||||
|
||||
|
||||
import t
|
||||
from stdint import *
|
||||
from w32.win32base import *
|
||||
|
||||
class CRITICAL_SECTION:
|
||||
DebugInfo: VOIDPTR
|
||||
LockCount: LONG
|
||||
RecursionCount: LONG
|
||||
OwningThread: HANDLE
|
||||
LockSemaphore: HANDLE
|
||||
SpinCount: QWORD
|
||||
|
||||
def InitializeCriticalSection(lpCriticalSection: CRITICAL_SECTION | t.CPtr) -> VOID | t.State: pass
|
||||
|
||||
def EnterCriticalSection(lpCriticalSection: CRITICAL_SECTION | t.CPtr) -> VOID | t.State: pass
|
||||
|
||||
def LeaveCriticalSection(lpCriticalSection: CRITICAL_SECTION | t.CPtr) -> VOID | t.State: pass
|
||||
|
||||
def DeleteCriticalSection(lpCriticalSection: CRITICAL_SECTION | t.CPtr) -> VOID | t.State: pass
|
||||
|
||||
def TryEnterCriticalSection(lpCriticalSection: CRITICAL_SECTION | t.CPtr) -> BOOL | t.State: pass
|
||||
|
||||
def SetCriticalSectionSpinCount(lpCriticalSection: CRITICAL_SECTION | t.CPtr, dwSpinCount: ULONG) -> ULONG | t.State: pass
|
||||
|
||||
def InitializeCriticalSectionAndSpinCount(lpCriticalSection: CRITICAL_SECTION | t.CPtr, dwSpinCount: ULONG) -> BOOL | t.State: pass
|
||||
|
||||
def CreateMutexA(lpMutexAttributes: SECURITY_ATTRIBUTES | t.CPtr, bInitialOwner: BOOL, lpName: LPCSTR) -> HANDLE | t.State: pass
|
||||
|
||||
def CreateMutexW(lpMutexAttributes: SECURITY_ATTRIBUTES | t.CPtr, bInitialOwner: BOOL, lpName: LPCWSTR) -> HANDLE | t.State: pass
|
||||
|
||||
def OpenMutexA(dwDesiredAccess: ULONG, bInheritHandle: BOOL, lpName: LPCSTR) -> HANDLE | t.State: pass
|
||||
|
||||
def OpenMutexW(dwDesiredAccess: ULONG, bInheritHandle: BOOL, lpName: LPCWSTR) -> HANDLE | t.State: pass
|
||||
|
||||
def ReleaseMutex(hMutex: HANDLE) -> BOOL | t.State: pass
|
||||
|
||||
def CreateEventA(lpEventAttributes: SECURITY_ATTRIBUTES | t.CPtr, bManualReset: BOOL, bInitialState: BOOL, lpName: LPCSTR) -> HANDLE | t.State: pass
|
||||
|
||||
def CreateEventW(lpEventAttributes: SECURITY_ATTRIBUTES | t.CPtr, bManualReset: BOOL, bInitialState: BOOL, lpName: LPCWSTR) -> HANDLE | t.State: pass
|
||||
|
||||
def OpenEventA(dwDesiredAccess: ULONG, bInheritHandle: BOOL, lpName: LPCSTR) -> HANDLE | t.State: pass
|
||||
|
||||
def OpenEventW(dwDesiredAccess: ULONG, bInheritHandle: BOOL, lpName: LPCWSTR) -> HANDLE | t.State: pass
|
||||
|
||||
def SetEvent(hEvent: HANDLE) -> BOOL | t.State: pass
|
||||
|
||||
def ResetEvent(hEvent: HANDLE) -> BOOL | t.State: pass
|
||||
|
||||
def PulseEvent(hEvent: HANDLE) -> BOOL | t.State: pass
|
||||
|
||||
def CreateSemaphoreA(lpSemaphoreAttributes: SECURITY_ATTRIBUTES | t.CPtr, lInitialCount: LONG, lMaximumCount: LONG, lpName: LPCSTR) -> HANDLE | t.State: pass
|
||||
|
||||
def CreateSemaphoreW(lpSemaphoreAttributes: SECURITY_ATTRIBUTES | t.CPtr, lInitialCount: LONG, lMaximumCount: LONG, lpName: LPCWSTR) -> HANDLE | t.State: pass
|
||||
|
||||
def OpenSemaphoreA(dwDesiredAccess: ULONG, bInheritHandle: BOOL, lpName: LPCSTR) -> HANDLE | t.State: pass
|
||||
|
||||
def OpenSemaphoreW(dwDesiredAccess: ULONG, bInheritHandle: BOOL, lpName: LPCWSTR) -> HANDLE | t.State: pass
|
||||
|
||||
def ReleaseSemaphore(hSemaphore: HANDLE, lReleaseCount: LONG, lpPreviousCount: LONG | t.CPtr) -> BOOL | t.State: pass
|
||||
|
||||
def WaitForSingleObject(hHandle: HANDLE, dwMilliseconds: ULONG) -> ULONG | t.State: pass
|
||||
|
||||
def WaitForSingleObjectEx(hHandle: HANDLE, dwMilliseconds: ULONG, bAlertable: BOOL) -> ULONG | t.State: pass
|
||||
|
||||
def WaitForMultipleObjects(nCount: ULONG, lpHandles: VOIDPTR, bWaitAll: BOOL, dwMilliseconds: ULONG) -> ULONG | t.State: pass
|
||||
|
||||
def WaitForMultipleObjectsEx(nCount: ULONG, lpHandles: VOIDPTR, bWaitAll: BOOL, dwMilliseconds: ULONG, bAlertable: BOOL) -> ULONG | t.State: pass
|
||||
|
||||
def InitializeSRWLock(SRWLock: VOIDPTR) -> VOID | t.State: pass
|
||||
|
||||
def AcquireSRWLockExclusive(SRWLock: VOIDPTR) -> VOID | t.State: pass
|
||||
|
||||
def AcquireSRWLockShared(SRWLock: VOIDPTR) -> VOID | t.State: pass
|
||||
|
||||
def ReleaseSRWLockExclusive(SRWLock: VOIDPTR) -> VOID | t.State: pass
|
||||
|
||||
def ReleaseSRWLockShared(SRWLock: VOIDPTR) -> VOID | t.State: pass
|
||||
|
||||
|
||||
CONDITION_VARIABLE_LOCKMODE_SHARED: t.CDefine = 0x1
|
||||
|
||||
def InitializeConditionVariable(ConditionVariable: VOIDPTR) -> VOID | t.State: pass
|
||||
|
||||
def SleepConditionVariableCS(ConditionVariable: VOIDPTR, CriticalSection: CRITICAL_SECTION | t.CPtr, dwMilliseconds: ULONG) -> BOOL | t.State: pass
|
||||
|
||||
def SleepConditionVariableSRW(ConditionVariable: VOIDPTR, SRWLock: VOIDPTR, dwMilliseconds: ULONG, Flags: ULONG) -> BOOL | t.State: pass
|
||||
|
||||
def WakeConditionVariable(ConditionVariable: VOIDPTR) -> VOID | t.State: pass
|
||||
|
||||
def WakeAllConditionVariable(ConditionVariable: VOIDPTR) -> VOID | t.State: pass
|
||||
|
||||
|
||||
INIT_ONCE_STATIC_INIT: t.CDefine = 0x00000001
|
||||
INIT_ONCE_CHECK_ONLY: t.CDefine = 0x00000002
|
||||
INIT_ONCE_ASYNC: t.CDefine = 0x00000004
|
||||
INIT_ONCE_INIT_FAILED: t.CDefine = 0x00000008
|
||||
|
||||
class INIT_ONCE:
|
||||
Ptr: t.CPtr
|
||||
|
||||
def InitOnceExecuteOnce(InitOnce: INIT_ONCE | t.CPtr, InitFn: VOIDPTR, Parameter: VOIDPTR, Context: VOIDPTR | t.CPtr) -> BOOL | t.State: pass
|
||||
@@ -0,0 +1 @@
|
||||
{}
|
||||
@@ -0,0 +1,22 @@
|
||||
"""
|
||||
Auto-generated Python stub file from main.py
|
||||
Module: main
|
||||
"""
|
||||
|
||||
|
||||
from stdint import *
|
||||
import t, c
|
||||
from t import CInt, CExport
|
||||
from stdio import printf
|
||||
import memhub
|
||||
import stdlib
|
||||
import sys
|
||||
import string
|
||||
import ast
|
||||
import w32.win32console
|
||||
|
||||
ARENA_SIZE: t.CDefine = 1048576
|
||||
POOL_SIZE: t.CDefine = 524288
|
||||
DUMP_SIZE: t.CDefine = 262144
|
||||
|
||||
def main() -> CInt | CExport: pass
|
||||
@@ -0,0 +1,67 @@
|
||||
"""
|
||||
Auto-generated Python stub file from ast.lexer.py
|
||||
Module: ast.lexer
|
||||
"""
|
||||
|
||||
|
||||
import t, c
|
||||
from stdint import *
|
||||
import memhub
|
||||
import string
|
||||
from .tokens import Token, TokenType, TokOp, _init_tables, _kw_lookup, _op_head, OpEntry, new_token, token_set_str, token_set_str_literal
|
||||
|
||||
LEXER_MAX_INDENT: t.CDefine = 256
|
||||
|
||||
class Lexer:
|
||||
src: str
|
||||
pos: t.CSizeT
|
||||
len: t.CSizeT
|
||||
lineno: t.CInt
|
||||
col: t.CInt
|
||||
pool: memhub.MemManager | t.CPtr
|
||||
indent_stack: t.CInt | t.CPtr
|
||||
indent_top: t.CInt
|
||||
paren_depth: t.CInt
|
||||
tokens_head: Token | t.CPtr
|
||||
tokens_tail: Token | t.CPtr
|
||||
at_line_start: t.CInt
|
||||
error_count: t.CInt
|
||||
def __new__(self: Lexer, pool: memhub.MemManager | t.CPtr) -> t.CInt: pass
|
||||
|
||||
def new_lexer(pool: memhub.MemManager | t.CPtr) -> Lexer | t.CPtr: pass
|
||||
|
||||
def _lexer_init(lx: Lexer | t.CPtr, src: str, pool: memhub.MemManager | t.CPtr) -> t.CInt: pass
|
||||
|
||||
def _peek(lx: Lexer | t.CPtr, offset: t.CSizeT) -> t.CChar: pass
|
||||
|
||||
def _peek_cur(lx: Lexer | t.CPtr) -> t.CChar: pass
|
||||
|
||||
def _advance(lx: Lexer | t.CPtr) -> t.CChar: pass
|
||||
|
||||
def _is_alpha(ch: t.CChar) -> t.CInt: pass
|
||||
|
||||
def _is_digit(ch: t.CChar) -> t.CInt: pass
|
||||
|
||||
def _is_alnum(ch: t.CChar) -> t.CInt: pass
|
||||
|
||||
def _is_hex(ch: t.CChar) -> t.CInt: pass
|
||||
|
||||
def _is_space(ch: t.CChar) -> t.CInt: pass
|
||||
|
||||
def _emit(lx: Lexer | t.CPtr, tok: Token | t.CPtr) -> t.CInt: pass
|
||||
|
||||
def _make_op_token(lx: Lexer | t.CPtr, op_id: t.CInt, length: t.CInt, lineno: t.CInt, col: t.CInt) -> Token | t.CPtr: pass
|
||||
|
||||
def _handle_indent(lx: Lexer | t.CPtr) -> t.CInt: pass
|
||||
|
||||
def _read_name(lx: Lexer | t.CPtr) -> t.CInt: pass
|
||||
|
||||
def _read_number(lx: Lexer | t.CPtr) -> t.CInt: pass
|
||||
|
||||
def _emit_number(lx: Lexer | t.CPtr, start: t.CSizeT, start_lineno: t.CInt, start_col: t.CInt, is_float: t.CInt, is_complex: t.CInt, is_hex: t.CInt) -> t.CInt: pass
|
||||
|
||||
def _read_string(lx: Lexer | t.CPtr) -> t.CInt: pass
|
||||
|
||||
def _read_operator(lx: Lexer | t.CPtr) -> t.CInt: pass
|
||||
|
||||
def tokenize(lx: Lexer | t.CPtr) -> Token | t.CPtr: pass
|
||||
@@ -0,0 +1,26 @@
|
||||
"""
|
||||
Auto-generated Python stub file from atom.py
|
||||
Module: atom
|
||||
"""
|
||||
|
||||
|
||||
import t, c
|
||||
|
||||
ATOMIC_RELAXED: t.CDefine = 0
|
||||
ATOMIC_CONSUME: t.CDefine = 1
|
||||
ATOMIC_ACQUIRE: t.CDefine = 2
|
||||
ATOMIC_RELEASE: t.CDefine = 3
|
||||
ATOMIC_ACQ_REL: t.CDefine = 4
|
||||
ATOMIC_SEQ_CST: t.CDefine = 5
|
||||
|
||||
def __atomic_test_and_set(ptr: t.CUInt64T | t.CPtr, order: t.CInt) -> t.CBool: pass
|
||||
|
||||
def __atomic_clear(ptr: t.CUInt64T | t.CPtr, order: t.CInt) -> t.CVoid: pass
|
||||
|
||||
def __atomic_thread_fence(order: t.CInt) -> t.CVoid: pass
|
||||
|
||||
def __atomic_signal_fence(order: t.CInt) -> t.CVoid: pass
|
||||
|
||||
def __atomic_always_lock_free(size: t.CSizeT, ptr: t.CVoid | t.CPtr) -> t.CBool: pass
|
||||
|
||||
def __atomic_is_lock_free(size: t.CSizeT, ptr: t.CVoid | t.CPtr) -> t.CBool: pass
|
||||
@@ -0,0 +1,26 @@
|
||||
"""
|
||||
Auto-generated Python stub file from ast.__init__.py
|
||||
Module: ast.__init__
|
||||
"""
|
||||
|
||||
|
||||
import t, c
|
||||
from stdint import *
|
||||
import memhub
|
||||
import string
|
||||
from .tokens import Token, TokenType, Keyword, TokOp, _init_tables
|
||||
from .base import AST, ASTKind, ASTCtx, OpKind, ASTFlag, CONST_INT, CONST_FLOAT, CONST_STR, CONST_BOOL, CONST_NONE, FLAG_IS_ASYNC, FLAG_SIMPLE, FLAG_HAS_STAR, _init_ast, _copy_str, _set_pos, _inherit_pos, _set_parent_list, _binop_from_op, _augop_from_op, _cmpop_from_op, _emit, _emit_str, _emit_int, _dump_list, dump
|
||||
from .stmts import Module, Expression, Interactive, FunctionType, FunctionDef, ClassDef, Return, Delete, Assign, AugAssign, AnnAssign, For, While, If, With, Raise, Try, Assert, Global, Nonlocal, Pass, Break, Continue, Expr, Import, ImportFrom, Match
|
||||
from .exprs import BoolOp, BinOp, UnaryOp, Lambda, IfExp, Dict, Set, ListComp, SetComp, DictComp, GeneratorExp, Await, Yield, YieldFrom, FormattedValue, JoinedStr, Constant, NamedExpr, Attribute, Subscript, Starred, Name, List, Tuple, Slice, Call, Compare, OpNode
|
||||
from .astaux import ExceptHandler, Arguments, Arg, Keyword, Alias, WithItem, Comprehension
|
||||
from .match import MatchCase, MatchValue, MatchSingleton, MatchSequence, MatchMapping, MatchClass, MatchStar, MatchAs, MatchOr
|
||||
from .visitor import ASTVisitor
|
||||
from .lexer import Lexer, _lexer_init, tokenize, new_lexer
|
||||
from .parser import Parser, _parser_init, parse_tokens, new_parser
|
||||
from .parser import _parse_test
|
||||
|
||||
_mbuddy: t.CExtern | memhub.MemBuddy | t.CPtr
|
||||
|
||||
def parse(src: str, pool: memhub.MemManager | t.CPtr) -> AST | t.CPtr: pass
|
||||
|
||||
def parse_expression(src: str, pool: memhub.MemManager | t.CPtr) -> AST | t.CPtr: pass
|
||||
@@ -0,0 +1,73 @@
|
||||
"""
|
||||
Auto-generated Python stub file from ast.astaux.py
|
||||
Module: ast.astaux
|
||||
"""
|
||||
|
||||
|
||||
import t, c
|
||||
from stdint import *
|
||||
import memhub
|
||||
import string
|
||||
from .base import AST, ASTKind, _init_ast, _copy_str, _set_parent_list, _emit, _emit_str, _emit_int, _dump_list
|
||||
|
||||
class ExceptHandler(AST):
|
||||
type: AST | t.CPtr
|
||||
name: str
|
||||
def __new__(self: ExceptHandler, pool: memhub.MemManager | t.CPtr, type: AST | t.CPtr, name: str) -> t.CInt: pass
|
||||
def __init__(self: ExceptHandler, pool: memhub.MemManager | t.CPtr, type: AST | t.CPtr, name: str) -> t.CInt: pass
|
||||
def kind(self: ExceptHandler) -> t.CInt: pass
|
||||
def type_name(self: ExceptHandler) -> str: pass
|
||||
def dump(self: ExceptHandler, buf: bytes, size: t.CSizeT, pos: t.CSizeT) -> t.CSizeT: pass
|
||||
class Arguments(AST):
|
||||
args: list[AST | t.CPtr] | t.CPtr
|
||||
vararg: AST | t.CPtr
|
||||
kwarg: AST | t.CPtr
|
||||
defaults: list[AST | t.CPtr] | t.CPtr
|
||||
kw_defaults: list[AST | t.CPtr] | t.CPtr
|
||||
def __new__(self: Arguments, pool: memhub.MemManager | t.CPtr, args: list[AST | t.CPtr] | t.CPtr, vararg: AST | t.CPtr, kwarg: AST | t.CPtr, defaults: list[AST | t.CPtr] | t.CPtr, kw_defaults: list[AST | t.CPtr] | t.CPtr) -> t.CInt: pass
|
||||
def __init__(self: Arguments, pool: memhub.MemManager | t.CPtr, args: list[AST | t.CPtr] | t.CPtr, vararg: AST | t.CPtr, kwarg: AST | t.CPtr, defaults: list[AST | t.CPtr] | t.CPtr, kw_defaults: list[AST | t.CPtr] | t.CPtr) -> t.CInt: pass
|
||||
def kind(self: Arguments) -> t.CInt: pass
|
||||
def type_name(self: Arguments) -> str: pass
|
||||
def dump(self: Arguments, buf: bytes, size: t.CSizeT, pos: t.CSizeT) -> t.CSizeT: pass
|
||||
class Arg(AST):
|
||||
arg: str
|
||||
annotation: AST | t.CPtr
|
||||
def __new__(self: Arg, pool: memhub.MemManager | t.CPtr, arg: str, annotation: AST | t.CPtr) -> t.CInt: pass
|
||||
def __init__(self: Arg, pool: memhub.MemManager | t.CPtr, arg: str, annotation: AST | t.CPtr) -> t.CInt: pass
|
||||
def kind(self: Arg) -> t.CInt: pass
|
||||
def type_name(self: Arg) -> str: pass
|
||||
def dump(self: Arg, buf: bytes, size: t.CSizeT, pos: t.CSizeT) -> t.CSizeT: pass
|
||||
class Keyword(AST):
|
||||
arg: str
|
||||
value: AST | t.CPtr
|
||||
def __new__(self: Keyword, pool: memhub.MemManager | t.CPtr, arg: str, value: AST | t.CPtr) -> t.CInt: pass
|
||||
def __init__(self: Keyword, pool: memhub.MemManager | t.CPtr, arg: str, value: AST | t.CPtr) -> t.CInt: pass
|
||||
def kind(self: Keyword) -> t.CInt: pass
|
||||
def type_name(self: Keyword) -> str: pass
|
||||
def dump(self: Keyword, buf: bytes, size: t.CSizeT, pos: t.CSizeT) -> t.CSizeT: pass
|
||||
class Alias(AST):
|
||||
name: str
|
||||
asname: str
|
||||
def __new__(self: Alias, pool: memhub.MemManager | t.CPtr, name: str, asname: str) -> t.CInt: pass
|
||||
def __init__(self: Alias, pool: memhub.MemManager | t.CPtr, name: str, asname: str) -> t.CInt: pass
|
||||
def kind(self: Alias) -> t.CInt: pass
|
||||
def type_name(self: Alias) -> str: pass
|
||||
def dump(self: Alias, buf: bytes, size: t.CSizeT, pos: t.CSizeT) -> t.CSizeT: pass
|
||||
class WithItem(AST):
|
||||
context_expr: AST | t.CPtr
|
||||
optional_vars: AST | t.CPtr
|
||||
def __new__(self: WithItem, pool: memhub.MemManager | t.CPtr, context_expr: AST | t.CPtr, optional_vars: AST | t.CPtr) -> t.CInt: pass
|
||||
def __init__(self: WithItem, pool: memhub.MemManager | t.CPtr, context_expr: AST | t.CPtr, optional_vars: AST | t.CPtr) -> t.CInt: pass
|
||||
def kind(self: WithItem) -> t.CInt: pass
|
||||
def type_name(self: WithItem) -> str: pass
|
||||
def dump(self: WithItem, buf: bytes, size: t.CSizeT, pos: t.CSizeT) -> t.CSizeT: pass
|
||||
class Comprehension(AST):
|
||||
target: AST | t.CPtr
|
||||
iter: AST | t.CPtr
|
||||
ifs: list[AST | t.CPtr] | t.CPtr
|
||||
is_async: t.CInt
|
||||
def __new__(self: Comprehension, pool: memhub.MemManager | t.CPtr, target: AST | t.CPtr, iter: AST | t.CPtr, ifs: list[AST | t.CPtr] | t.CPtr, is_async: t.CInt) -> t.CInt: pass
|
||||
def __init__(self: Comprehension, pool: memhub.MemManager | t.CPtr, target: AST | t.CPtr, iter: AST | t.CPtr, ifs: list[AST | t.CPtr] | t.CPtr, is_async: t.CInt) -> t.CInt: pass
|
||||
def kind(self: Comprehension) -> t.CInt: pass
|
||||
def type_name(self: Comprehension) -> str: pass
|
||||
def dump(self: Comprehension, buf: bytes, size: t.CSizeT, pos: t.CSizeT) -> t.CSizeT: pass
|
||||
@@ -0,0 +1,241 @@
|
||||
"""
|
||||
Auto-generated Python stub file from ast.exprs.py
|
||||
Module: ast.exprs
|
||||
"""
|
||||
|
||||
|
||||
import t, c
|
||||
from stdint import *
|
||||
import memhub
|
||||
import string
|
||||
from .base import AST, ASTKind, ASTCtx, OpKind, _init_ast, _copy_str, _set_parent_list, _emit, _emit_str, _emit_int, _dump_list, _dump_op_list, _op_name, CONST_INT, CONST_FLOAT, CONST_STR, CONST_BOOL, CONST_NONE
|
||||
|
||||
class Name(AST):
|
||||
id: str
|
||||
ctx: t.CInt
|
||||
def __new__(self: Name, pool: memhub.MemManager | t.CPtr, id: str, ctx: t.CInt) -> t.CInt: pass
|
||||
def __init__(self: Name, pool: memhub.MemManager | t.CPtr, id: str, ctx: t.CInt) -> t.CInt: pass
|
||||
def kind(self: Name) -> t.CInt: pass
|
||||
def type_name(self: Name) -> str: pass
|
||||
def dump(self: Name, buf: t.CChar | t.CPtr, size: t.CSizeT, pos: t.CSizeT) -> t.CSizeT: pass
|
||||
class Constant(AST):
|
||||
int_val: t.CInt64T
|
||||
float_val: t.CDouble
|
||||
str_val: str
|
||||
const_kind: t.CInt
|
||||
def __new__(self: Constant, pool: memhub.MemManager | t.CPtr, const_kind: t.CInt, int_val: t.CInt64T, float_val: t.CDouble, str_val: str, lineno: t.CInt, col: t.CInt) -> t.CInt: pass
|
||||
def __init__(self: Constant, pool: memhub.MemManager | t.CPtr, const_kind: t.CInt, int_val: t.CInt64T, float_val: t.CDouble, str_val: str, lineno: t.CInt, col: t.CInt) -> t.CInt: pass
|
||||
def kind(self: Constant) -> t.CInt: pass
|
||||
def type_name(self: Constant) -> str: pass
|
||||
def dump(self: Constant, buf: t.CChar | t.CPtr, size: t.CSizeT, pos: t.CSizeT) -> t.CSizeT: pass
|
||||
class BinOp(AST):
|
||||
left: AST | t.CPtr
|
||||
op: t.CInt
|
||||
right: AST | t.CPtr
|
||||
def __new__(self: BinOp, pool: memhub.MemManager | t.CPtr, left: AST | t.CPtr, op: t.CInt, right: AST | t.CPtr) -> t.CInt: pass
|
||||
def __init__(self: BinOp, pool: memhub.MemManager | t.CPtr, left: AST | t.CPtr, op: t.CInt, right: AST | t.CPtr) -> t.CInt: pass
|
||||
def kind(self: BinOp) -> t.CInt: pass
|
||||
def type_name(self: BinOp) -> str: pass
|
||||
def dump(self: BinOp, buf: t.CChar | t.CPtr, size: t.CSizeT, pos: t.CSizeT) -> t.CSizeT: pass
|
||||
class UnaryOp(AST):
|
||||
op: t.CInt
|
||||
operand: AST | t.CPtr
|
||||
def __new__(self: UnaryOp, pool: memhub.MemManager | t.CPtr, op: t.CInt, operand: AST | t.CPtr) -> t.CInt: pass
|
||||
def __init__(self: UnaryOp, pool: memhub.MemManager | t.CPtr, op: t.CInt, operand: AST | t.CPtr) -> t.CInt: pass
|
||||
def kind(self: UnaryOp) -> t.CInt: pass
|
||||
def type_name(self: UnaryOp) -> str: pass
|
||||
def dump(self: UnaryOp, buf: t.CChar | t.CPtr, size: t.CSizeT, pos: t.CSizeT) -> t.CSizeT: pass
|
||||
class Compare(AST):
|
||||
left: AST | t.CPtr
|
||||
ops: t.CPtr
|
||||
comparators: list[AST | t.CPtr] | t.CPtr
|
||||
def __new__(self: Compare, pool: memhub.MemManager | t.CPtr, left: AST | t.CPtr, ops: t.CPtr, comparators: list[AST | t.CPtr] | t.CPtr) -> t.CInt: pass
|
||||
def __init__(self: Compare, pool: memhub.MemManager | t.CPtr, left: AST | t.CPtr, ops: t.CPtr, comparators: list[AST | t.CPtr] | t.CPtr) -> t.CInt: pass
|
||||
def kind(self: Compare) -> t.CInt: pass
|
||||
def type_name(self: Compare) -> str: pass
|
||||
def dump(self: Compare, buf: t.CChar | t.CPtr, size: t.CSizeT, pos: t.CSizeT) -> t.CSizeT: pass
|
||||
class Call(AST):
|
||||
func: AST | t.CPtr
|
||||
args: list[AST | t.CPtr] | t.CPtr
|
||||
keywords: list[AST | t.CPtr] | t.CPtr
|
||||
def __new__(self: Call, pool: memhub.MemManager | t.CPtr, func: AST | t.CPtr, args: list[AST | t.CPtr] | t.CPtr, keywords: list[AST | t.CPtr] | t.CPtr) -> t.CInt: pass
|
||||
def __init__(self: Call, pool: memhub.MemManager | t.CPtr, func: AST | t.CPtr, args: list[AST | t.CPtr] | t.CPtr, keywords: list[AST | t.CPtr] | t.CPtr) -> t.CInt: pass
|
||||
def kind(self: Call) -> t.CInt: pass
|
||||
def type_name(self: Call) -> str: pass
|
||||
def dump(self: Call, buf: t.CChar | t.CPtr, size: t.CSizeT, pos: t.CSizeT) -> t.CSizeT: pass
|
||||
class BoolOp(AST):
|
||||
op: t.CInt
|
||||
values: list[AST | t.CPtr] | t.CPtr
|
||||
def __new__(self: BoolOp, pool: memhub.MemManager | t.CPtr, op: t.CInt, values: list[AST | t.CPtr] | t.CPtr) -> t.CInt: pass
|
||||
def __init__(self: BoolOp, pool: memhub.MemManager | t.CPtr, op: t.CInt, values: list[AST | t.CPtr] | t.CPtr) -> t.CInt: pass
|
||||
def kind(self: BoolOp) -> t.CInt: pass
|
||||
def type_name(self: BoolOp) -> str: pass
|
||||
def dump(self: BoolOp, buf: t.CChar | t.CPtr, size: t.CSizeT, pos: t.CSizeT) -> t.CSizeT: pass
|
||||
class Lambda(AST):
|
||||
args: AST | t.CPtr
|
||||
body: AST | t.CPtr
|
||||
def __new__(self: Lambda, pool: memhub.MemManager | t.CPtr, args: AST | t.CPtr, body: AST | t.CPtr) -> t.CInt: pass
|
||||
def __init__(self: Lambda, pool: memhub.MemManager | t.CPtr, args: AST | t.CPtr, body: AST | t.CPtr) -> t.CInt: pass
|
||||
def kind(self: Lambda) -> t.CInt: pass
|
||||
def type_name(self: Lambda) -> str: pass
|
||||
def dump(self: Lambda, buf: t.CChar | t.CPtr, size: t.CSizeT, pos: t.CSizeT) -> t.CSizeT: pass
|
||||
class IfExp(AST):
|
||||
test: AST | t.CPtr
|
||||
body: AST | t.CPtr
|
||||
orelse: AST | t.CPtr
|
||||
def __new__(self: IfExp, pool: memhub.MemManager | t.CPtr, test: AST | t.CPtr, body: AST | t.CPtr, orelse: AST | t.CPtr) -> t.CInt: pass
|
||||
def __init__(self: IfExp, pool: memhub.MemManager | t.CPtr, test: AST | t.CPtr, body: AST | t.CPtr, orelse: AST | t.CPtr) -> t.CInt: pass
|
||||
def kind(self: IfExp) -> t.CInt: pass
|
||||
def type_name(self: IfExp) -> str: pass
|
||||
def dump(self: IfExp, buf: t.CChar | t.CPtr, size: t.CSizeT, pos: t.CSizeT) -> t.CSizeT: pass
|
||||
class Dict(AST):
|
||||
keys: list[AST | t.CPtr] | t.CPtr
|
||||
values: list[AST | t.CPtr] | t.CPtr
|
||||
def __new__(self: Dict, pool: memhub.MemManager | t.CPtr, keys: list[AST | t.CPtr] | t.CPtr, values: list[AST | t.CPtr] | t.CPtr) -> t.CInt: pass
|
||||
def __init__(self: Dict, pool: memhub.MemManager | t.CPtr, keys: list[AST | t.CPtr] | t.CPtr, values: list[AST | t.CPtr] | t.CPtr) -> t.CInt: pass
|
||||
def kind(self: Dict) -> t.CInt: pass
|
||||
def type_name(self: Dict) -> str: pass
|
||||
def dump(self: Dict, buf: t.CChar | t.CPtr, size: t.CSizeT, pos: t.CSizeT) -> t.CSizeT: pass
|
||||
class Set(AST):
|
||||
elts: list[AST | t.CPtr] | t.CPtr
|
||||
def __new__(self: Set, pool: memhub.MemManager | t.CPtr, elts: list[AST | t.CPtr] | t.CPtr) -> t.CInt: pass
|
||||
def __init__(self: Set, pool: memhub.MemManager | t.CPtr, elts: list[AST | t.CPtr] | t.CPtr) -> t.CInt: pass
|
||||
def kind(self: Set) -> t.CInt: pass
|
||||
def type_name(self: Set) -> str: pass
|
||||
def dump(self: Set, buf: t.CChar | t.CPtr, size: t.CSizeT, pos: t.CSizeT) -> t.CSizeT: pass
|
||||
class ListComp(AST):
|
||||
elt: AST | t.CPtr
|
||||
generators: list[AST | t.CPtr] | t.CPtr
|
||||
def __new__(self: ListComp, pool: memhub.MemManager | t.CPtr, elt: AST | t.CPtr, generators: list[AST | t.CPtr] | t.CPtr) -> t.CInt: pass
|
||||
def __init__(self: ListComp, pool: memhub.MemManager | t.CPtr, elt: AST | t.CPtr, generators: list[AST | t.CPtr] | t.CPtr) -> t.CInt: pass
|
||||
def kind(self: ListComp) -> t.CInt: pass
|
||||
def type_name(self: ListComp) -> str: pass
|
||||
def dump(self: ListComp, buf: t.CChar | t.CPtr, size: t.CSizeT, pos: t.CSizeT) -> t.CSizeT: pass
|
||||
class SetComp(AST):
|
||||
elt: AST | t.CPtr
|
||||
generators: list[AST | t.CPtr] | t.CPtr
|
||||
def __new__(self: SetComp, pool: memhub.MemManager | t.CPtr, elt: AST | t.CPtr, generators: list[AST | t.CPtr] | t.CPtr) -> t.CInt: pass
|
||||
def __init__(self: SetComp, pool: memhub.MemManager | t.CPtr, elt: AST | t.CPtr, generators: list[AST | t.CPtr] | t.CPtr) -> t.CInt: pass
|
||||
def kind(self: SetComp) -> t.CInt: pass
|
||||
def type_name(self: SetComp) -> str: pass
|
||||
def dump(self: SetComp, buf: t.CChar | t.CPtr, size: t.CSizeT, pos: t.CSizeT) -> t.CSizeT: pass
|
||||
class DictComp(AST):
|
||||
key: AST | t.CPtr
|
||||
value: AST | t.CPtr
|
||||
generators: list[AST | t.CPtr] | t.CPtr
|
||||
def __new__(self: DictComp, pool: memhub.MemManager | t.CPtr, key: AST | t.CPtr, value: AST | t.CPtr, generators: list[AST | t.CPtr] | t.CPtr) -> t.CInt: pass
|
||||
def __init__(self: DictComp, pool: memhub.MemManager | t.CPtr, key: AST | t.CPtr, value: AST | t.CPtr, generators: list[AST | t.CPtr] | t.CPtr) -> t.CInt: pass
|
||||
def kind(self: DictComp) -> t.CInt: pass
|
||||
def type_name(self: DictComp) -> str: pass
|
||||
def dump(self: DictComp, buf: t.CChar | t.CPtr, size: t.CSizeT, pos: t.CSizeT) -> t.CSizeT: pass
|
||||
class GeneratorExp(AST):
|
||||
elt: AST | t.CPtr
|
||||
generators: list[AST | t.CPtr] | t.CPtr
|
||||
def __new__(self: GeneratorExp, pool: memhub.MemManager | t.CPtr, elt: AST | t.CPtr, generators: list[AST | t.CPtr] | t.CPtr) -> t.CInt: pass
|
||||
def __init__(self: GeneratorExp, pool: memhub.MemManager | t.CPtr, elt: AST | t.CPtr, generators: list[AST | t.CPtr] | t.CPtr) -> t.CInt: pass
|
||||
def kind(self: GeneratorExp) -> t.CInt: pass
|
||||
def type_name(self: GeneratorExp) -> str: pass
|
||||
def dump(self: GeneratorExp, buf: t.CChar | t.CPtr, size: t.CSizeT, pos: t.CSizeT) -> t.CSizeT: pass
|
||||
class Await(AST):
|
||||
value: AST | t.CPtr
|
||||
def __new__(self: Await, pool: memhub.MemManager | t.CPtr, value: AST | t.CPtr) -> t.CInt: pass
|
||||
def __init__(self: Await, pool: memhub.MemManager | t.CPtr, value: AST | t.CPtr) -> t.CInt: pass
|
||||
def kind(self: Await) -> t.CInt: pass
|
||||
def type_name(self: Await) -> str: pass
|
||||
def dump(self: Await, buf: t.CChar | t.CPtr, size: t.CSizeT, pos: t.CSizeT) -> t.CSizeT: pass
|
||||
class Yield(AST):
|
||||
value: AST | t.CPtr
|
||||
def __new__(self: Yield, pool: memhub.MemManager | t.CPtr, value: AST | t.CPtr) -> t.CInt: pass
|
||||
def __init__(self: Yield, pool: memhub.MemManager | t.CPtr, value: AST | t.CPtr) -> t.CInt: pass
|
||||
def kind(self: Yield) -> t.CInt: pass
|
||||
def type_name(self: Yield) -> str: pass
|
||||
def dump(self: Yield, buf: t.CChar | t.CPtr, size: t.CSizeT, pos: t.CSizeT) -> t.CSizeT: pass
|
||||
class YieldFrom(AST):
|
||||
value: AST | t.CPtr
|
||||
def __new__(self: YieldFrom, pool: memhub.MemManager | t.CPtr, value: AST | t.CPtr) -> t.CInt: pass
|
||||
def __init__(self: YieldFrom, pool: memhub.MemManager | t.CPtr, value: AST | t.CPtr) -> t.CInt: pass
|
||||
def kind(self: YieldFrom) -> t.CInt: pass
|
||||
def type_name(self: YieldFrom) -> str: pass
|
||||
def dump(self: YieldFrom, buf: t.CChar | t.CPtr, size: t.CSizeT, pos: t.CSizeT) -> t.CSizeT: pass
|
||||
class FormattedValue(AST):
|
||||
value: AST | t.CPtr
|
||||
conversion: t.CInt
|
||||
format_spec: AST | t.CPtr
|
||||
def __new__(self: FormattedValue, pool: memhub.MemManager | t.CPtr, value: AST | t.CPtr, conversion: t.CInt, format_spec: AST | t.CPtr) -> t.CInt: pass
|
||||
def __init__(self: FormattedValue, pool: memhub.MemManager | t.CPtr, value: AST | t.CPtr, conversion: t.CInt, format_spec: AST | t.CPtr) -> t.CInt: pass
|
||||
def kind(self: FormattedValue) -> t.CInt: pass
|
||||
def type_name(self: FormattedValue) -> str: pass
|
||||
def dump(self: FormattedValue, buf: t.CChar | t.CPtr, size: t.CSizeT, pos: t.CSizeT) -> t.CSizeT: pass
|
||||
class JoinedStr(AST):
|
||||
values: list[AST | t.CPtr] | t.CPtr
|
||||
def __new__(self: JoinedStr, pool: memhub.MemManager | t.CPtr, values: list[AST | t.CPtr] | t.CPtr) -> t.CInt: pass
|
||||
def __init__(self: JoinedStr, pool: memhub.MemManager | t.CPtr, values: list[AST | t.CPtr] | t.CPtr) -> t.CInt: pass
|
||||
def kind(self: JoinedStr) -> t.CInt: pass
|
||||
def type_name(self: JoinedStr) -> str: pass
|
||||
def dump(self: JoinedStr, buf: t.CChar | t.CPtr, size: t.CSizeT, pos: t.CSizeT) -> t.CSizeT: pass
|
||||
class Attribute(AST):
|
||||
value: AST | t.CPtr
|
||||
attr: str
|
||||
ctx: t.CInt
|
||||
def __new__(self: Attribute, pool: memhub.MemManager | t.CPtr, value: AST | t.CPtr, attr: str, ctx: t.CInt) -> t.CInt: pass
|
||||
def __init__(self: Attribute, pool: memhub.MemManager | t.CPtr, value: AST | t.CPtr, attr: str, ctx: t.CInt) -> t.CInt: pass
|
||||
def kind(self: Attribute) -> t.CInt: pass
|
||||
def type_name(self: Attribute) -> str: pass
|
||||
def dump(self: Attribute, buf: t.CChar | t.CPtr, size: t.CSizeT, pos: t.CSizeT) -> t.CSizeT: pass
|
||||
class Subscript(AST):
|
||||
value: AST | t.CPtr
|
||||
slice: AST | t.CPtr
|
||||
ctx: t.CInt
|
||||
def __new__(self: Subscript, pool: memhub.MemManager | t.CPtr, value: AST | t.CPtr, slice: AST | t.CPtr, ctx: t.CInt) -> t.CInt: pass
|
||||
def __init__(self: Subscript, pool: memhub.MemManager | t.CPtr, value: AST | t.CPtr, slice: AST | t.CPtr, ctx: t.CInt) -> t.CInt: pass
|
||||
def kind(self: Subscript) -> t.CInt: pass
|
||||
def type_name(self: Subscript) -> str: pass
|
||||
def dump(self: Subscript, buf: t.CChar | t.CPtr, size: t.CSizeT, pos: t.CSizeT) -> t.CSizeT: pass
|
||||
class Starred(AST):
|
||||
value: AST | t.CPtr
|
||||
ctx: t.CInt
|
||||
def __new__(self: Starred, pool: memhub.MemManager | t.CPtr, value: AST | t.CPtr, ctx: t.CInt) -> t.CInt: pass
|
||||
def __init__(self: Starred, pool: memhub.MemManager | t.CPtr, value: AST | t.CPtr, ctx: t.CInt) -> t.CInt: pass
|
||||
def kind(self: Starred) -> t.CInt: pass
|
||||
def type_name(self: Starred) -> str: pass
|
||||
def dump(self: Starred, buf: t.CChar | t.CPtr, size: t.CSizeT, pos: t.CSizeT) -> t.CSizeT: pass
|
||||
class List(AST):
|
||||
elts: list[AST | t.CPtr] | t.CPtr
|
||||
ctx: t.CInt
|
||||
def __new__(self: List, pool: memhub.MemManager | t.CPtr, elts: list[AST | t.CPtr] | t.CPtr, ctx: t.CInt) -> t.CInt: pass
|
||||
def __init__(self: List, pool: memhub.MemManager | t.CPtr, elts: list[AST | t.CPtr] | t.CPtr, ctx: t.CInt) -> t.CInt: pass
|
||||
def kind(self: List) -> t.CInt: pass
|
||||
def type_name(self: List) -> str: pass
|
||||
def dump(self: List, buf: t.CChar | t.CPtr, size: t.CSizeT, pos: t.CSizeT) -> t.CSizeT: pass
|
||||
class Tuple(AST):
|
||||
elts: list[AST | t.CPtr] | t.CPtr
|
||||
ctx: t.CInt
|
||||
def __new__(self: Tuple, pool: memhub.MemManager | t.CPtr, elts: list[AST | t.CPtr] | t.CPtr, ctx: t.CInt) -> t.CInt: pass
|
||||
def __init__(self: Tuple, pool: memhub.MemManager | t.CPtr, elts: list[AST | t.CPtr] | t.CPtr, ctx: t.CInt) -> t.CInt: pass
|
||||
def kind(self: Tuple) -> t.CInt: pass
|
||||
def type_name(self: Tuple) -> str: pass
|
||||
def dump(self: Tuple, buf: t.CChar | t.CPtr, size: t.CSizeT, pos: t.CSizeT) -> t.CSizeT: pass
|
||||
class Slice(AST):
|
||||
lower: AST | t.CPtr
|
||||
upper: AST | t.CPtr
|
||||
step: AST | t.CPtr
|
||||
def __new__(self: Slice, pool: memhub.MemManager | t.CPtr, lower: AST | t.CPtr, upper: AST | t.CPtr, step: AST | t.CPtr) -> t.CInt: pass
|
||||
def __init__(self: Slice, pool: memhub.MemManager | t.CPtr, lower: AST | t.CPtr, upper: AST | t.CPtr, step: AST | t.CPtr) -> t.CInt: pass
|
||||
def kind(self: Slice) -> t.CInt: pass
|
||||
def type_name(self: Slice) -> str: pass
|
||||
def dump(self: Slice, buf: t.CChar | t.CPtr, size: t.CSizeT, pos: t.CSizeT) -> t.CSizeT: pass
|
||||
class NamedExpr(AST):
|
||||
target: AST | t.CPtr
|
||||
value: AST | t.CPtr
|
||||
def __new__(self: NamedExpr, pool: memhub.MemManager | t.CPtr, target: AST | t.CPtr, value: AST | t.CPtr) -> t.CInt: pass
|
||||
def __init__(self: NamedExpr, pool: memhub.MemManager | t.CPtr, target: AST | t.CPtr, value: AST | t.CPtr) -> t.CInt: pass
|
||||
def kind(self: NamedExpr) -> t.CInt: pass
|
||||
def type_name(self: NamedExpr) -> str: pass
|
||||
def dump(self: NamedExpr, buf: t.CChar | t.CPtr, size: t.CSizeT, pos: t.CSizeT) -> t.CSizeT: pass
|
||||
class OpNode(AST):
|
||||
op: t.CInt
|
||||
def __new__(self: OpNode, pool: memhub.MemManager | t.CPtr, op: t.CInt) -> t.CInt: pass
|
||||
def __init__(self: OpNode, pool: memhub.MemManager | t.CPtr, op: t.CInt) -> t.CInt: pass
|
||||
def kind(self: OpNode) -> t.CInt: pass
|
||||
def type_name(self: OpNode) -> str: pass
|
||||
def dump(self: OpNode, buf: t.CChar | t.CPtr, size: t.CSizeT, pos: t.CSizeT) -> t.CSizeT: pass
|
||||
@@ -0,0 +1,82 @@
|
||||
"""
|
||||
Auto-generated Python stub file from ast.match.py
|
||||
Module: ast.match
|
||||
"""
|
||||
|
||||
|
||||
import t, c
|
||||
from stdint import *
|
||||
import memhub
|
||||
import string
|
||||
from .base import AST, ASTKind, _init_ast, _copy_str, _set_parent_list, _emit, _emit_str, _emit_int, _dump_list
|
||||
|
||||
class MatchCase(AST):
|
||||
pattern: AST | t.CPtr
|
||||
guard: AST | t.CPtr
|
||||
def __new__(self: MatchCase, pool: memhub.MemManager | t.CPtr, pattern: AST | t.CPtr, guard: AST | t.CPtr) -> t.CInt: pass
|
||||
def __init__(self: MatchCase, pool: memhub.MemManager | t.CPtr, pattern: AST | t.CPtr, guard: AST | t.CPtr) -> t.CInt: pass
|
||||
def kind(self: MatchCase) -> t.CInt: pass
|
||||
def type_name(self: MatchCase) -> str: pass
|
||||
def dump(self: MatchCase, buf: t.CChar | t.CPtr, size: t.CSizeT, pos: t.CSizeT) -> t.CSizeT: pass
|
||||
class MatchValue(AST):
|
||||
value: AST | t.CPtr
|
||||
def __new__(self: MatchValue, pool: memhub.MemManager | t.CPtr, value: AST | t.CPtr) -> t.CInt: pass
|
||||
def __init__(self: MatchValue, pool: memhub.MemManager | t.CPtr, value: AST | t.CPtr) -> t.CInt: pass
|
||||
def kind(self: MatchValue) -> t.CInt: pass
|
||||
def type_name(self: MatchValue) -> str: pass
|
||||
def dump(self: MatchValue, buf: t.CChar | t.CPtr, size: t.CSizeT, pos: t.CSizeT) -> t.CSizeT: pass
|
||||
class MatchSingleton(AST):
|
||||
value: AST | t.CPtr
|
||||
def __new__(self: MatchSingleton, pool: memhub.MemManager | t.CPtr, value: AST | t.CPtr) -> t.CInt: pass
|
||||
def __init__(self: MatchSingleton, pool: memhub.MemManager | t.CPtr, value: AST | t.CPtr) -> t.CInt: pass
|
||||
def kind(self: MatchSingleton) -> t.CInt: pass
|
||||
def type_name(self: MatchSingleton) -> str: pass
|
||||
def dump(self: MatchSingleton, buf: t.CChar | t.CPtr, size: t.CSizeT, pos: t.CSizeT) -> t.CSizeT: pass
|
||||
class MatchSequence(AST):
|
||||
patterns: list[AST | t.CPtr] | t.CPtr
|
||||
def __new__(self: MatchSequence, pool: memhub.MemManager | t.CPtr, patterns: list[AST | t.CPtr] | t.CPtr) -> t.CInt: pass
|
||||
def __init__(self: MatchSequence, pool: memhub.MemManager | t.CPtr, patterns: list[AST | t.CPtr] | t.CPtr) -> t.CInt: pass
|
||||
def kind(self: MatchSequence) -> t.CInt: pass
|
||||
def type_name(self: MatchSequence) -> str: pass
|
||||
def dump(self: MatchSequence, buf: t.CChar | t.CPtr, size: t.CSizeT, pos: t.CSizeT) -> t.CSizeT: pass
|
||||
class MatchMapping(AST):
|
||||
keys: list[AST | t.CPtr] | t.CPtr
|
||||
patterns: list[AST | t.CPtr] | t.CPtr
|
||||
rest: str
|
||||
def __new__(self: MatchMapping, pool: memhub.MemManager | t.CPtr, keys: list[AST | t.CPtr] | t.CPtr, patterns: list[AST | t.CPtr] | t.CPtr, rest: str) -> t.CInt: pass
|
||||
def __init__(self: MatchMapping, pool: memhub.MemManager | t.CPtr, keys: list[AST | t.CPtr] | t.CPtr, patterns: list[AST | t.CPtr] | t.CPtr, rest: str) -> t.CInt: pass
|
||||
def kind(self: MatchMapping) -> t.CInt: pass
|
||||
def type_name(self: MatchMapping) -> str: pass
|
||||
def dump(self: MatchMapping, buf: t.CChar | t.CPtr, size: t.CSizeT, pos: t.CSizeT) -> t.CSizeT: pass
|
||||
class MatchClass(AST):
|
||||
cls: AST | t.CPtr
|
||||
patterns: list[AST | t.CPtr] | t.CPtr
|
||||
kwd_attrs: list[AST | t.CPtr] | t.CPtr
|
||||
kwd_patterns: list[AST | t.CPtr] | t.CPtr
|
||||
def __new__(self: MatchClass, pool: memhub.MemManager | t.CPtr, cls: AST | t.CPtr, patterns: list[AST | t.CPtr] | t.CPtr, kwd_attrs: list[AST | t.CPtr] | t.CPtr, kwd_patterns: list[AST | t.CPtr] | t.CPtr) -> t.CInt: pass
|
||||
def __init__(self: MatchClass, pool: memhub.MemManager | t.CPtr, cls: AST | t.CPtr, patterns: list[AST | t.CPtr] | t.CPtr, kwd_attrs: list[AST | t.CPtr] | t.CPtr, kwd_patterns: list[AST | t.CPtr] | t.CPtr) -> t.CInt: pass
|
||||
def kind(self: MatchClass) -> t.CInt: pass
|
||||
def type_name(self: MatchClass) -> str: pass
|
||||
def dump(self: MatchClass, buf: t.CChar | t.CPtr, size: t.CSizeT, pos: t.CSizeT) -> t.CSizeT: pass
|
||||
class MatchStar(AST):
|
||||
name: str
|
||||
def __new__(self: MatchStar, pool: memhub.MemManager | t.CPtr, name: str) -> t.CInt: pass
|
||||
def __init__(self: MatchStar, pool: memhub.MemManager | t.CPtr, name: str) -> t.CInt: pass
|
||||
def kind(self: MatchStar) -> t.CInt: pass
|
||||
def type_name(self: MatchStar) -> str: pass
|
||||
def dump(self: MatchStar, buf: t.CChar | t.CPtr, size: t.CSizeT, pos: t.CSizeT) -> t.CSizeT: pass
|
||||
class MatchAs(AST):
|
||||
pattern: AST | t.CPtr
|
||||
name: str
|
||||
def __new__(self: MatchAs, pool: memhub.MemManager | t.CPtr, pattern: AST | t.CPtr, name: str) -> t.CInt: pass
|
||||
def __init__(self: MatchAs, pool: memhub.MemManager | t.CPtr, pattern: AST | t.CPtr, name: str) -> t.CInt: pass
|
||||
def kind(self: MatchAs) -> t.CInt: pass
|
||||
def type_name(self: MatchAs) -> str: pass
|
||||
def dump(self: MatchAs, buf: t.CChar | t.CPtr, size: t.CSizeT, pos: t.CSizeT) -> t.CSizeT: pass
|
||||
class MatchOr(AST):
|
||||
patterns: list[AST | t.CPtr] | t.CPtr
|
||||
def __new__(self: MatchOr, pool: memhub.MemManager | t.CPtr, patterns: list[AST | t.CPtr] | t.CPtr) -> t.CInt: pass
|
||||
def __init__(self: MatchOr, pool: memhub.MemManager | t.CPtr, patterns: list[AST | t.CPtr] | t.CPtr) -> t.CInt: pass
|
||||
def kind(self: MatchOr) -> t.CInt: pass
|
||||
def type_name(self: MatchOr) -> str: pass
|
||||
def dump(self: MatchOr, buf: t.CChar | t.CPtr, size: t.CSizeT, pos: t.CSizeT) -> t.CSizeT: pass
|
||||
@@ -0,0 +1,182 @@
|
||||
"""
|
||||
Auto-generated Python stub file from ast.base.py
|
||||
Module: ast.base
|
||||
"""
|
||||
|
||||
|
||||
import t, c
|
||||
from stdint import *
|
||||
import memhub
|
||||
import string
|
||||
import viperlib
|
||||
from .tokens import TokOp
|
||||
|
||||
class ASTKind(t.CEnum):
|
||||
Module: t.State
|
||||
FunctionDef: t.State
|
||||
ClassDef: t.State
|
||||
Assign: t.State
|
||||
If: t.State
|
||||
For: t.State
|
||||
While: t.State
|
||||
Return: t.State
|
||||
Expr: t.State
|
||||
Name: t.State
|
||||
Constant: t.State
|
||||
BinOp: t.State
|
||||
UnaryOp: t.State
|
||||
Call: t.State
|
||||
Compare: t.State
|
||||
Expression: t.State
|
||||
Interactive: t.State
|
||||
FunctionType: t.State
|
||||
Delete: t.State
|
||||
AugAssign: t.State
|
||||
AnnAssign: t.State
|
||||
With: t.State
|
||||
Raise: t.State
|
||||
Try: t.State
|
||||
Assert: t.State
|
||||
Global: t.State
|
||||
Nonlocal: t.State
|
||||
Pass: t.State
|
||||
Break: t.State
|
||||
Continue: t.State
|
||||
Import: t.State
|
||||
ImportFrom: t.State
|
||||
Match: t.State
|
||||
BoolOp: t.State
|
||||
Lambda: t.State
|
||||
IfExp: t.State
|
||||
Dict: t.State
|
||||
Set: t.State
|
||||
ListComp: t.State
|
||||
SetComp: t.State
|
||||
DictComp: t.State
|
||||
GeneratorExp: t.State
|
||||
Await: t.State
|
||||
Yield: t.State
|
||||
YieldFrom: t.State
|
||||
FormattedValue: t.State
|
||||
JoinedStr: t.State
|
||||
Attribute: t.State
|
||||
Subscript: t.State
|
||||
Starred: t.State
|
||||
List: t.State
|
||||
Tuple: t.State
|
||||
Slice: t.State
|
||||
NamedExpr: t.State
|
||||
ExceptHandler: t.State
|
||||
Arguments: t.State
|
||||
Arg: t.State
|
||||
Keyword: t.State
|
||||
Alias: t.State
|
||||
WithItem: t.State
|
||||
Comprehension: t.State
|
||||
OpNode: t.State
|
||||
MatchCase: t.State
|
||||
MatchValue: t.State
|
||||
MatchSingleton: t.State
|
||||
MatchSequence: t.State
|
||||
MatchMapping: t.State
|
||||
MatchClass: t.State
|
||||
MatchStar: t.State
|
||||
MatchAs: t.State
|
||||
MatchOr: t.State
|
||||
class ASTCtx(t.CEnum):
|
||||
Load: t.State
|
||||
Store: t.State
|
||||
Del: t.State
|
||||
class OpKind(t.CEnum):
|
||||
Add: t.State
|
||||
Sub: t.State
|
||||
Mult: t.State
|
||||
MatMult: t.State
|
||||
Div: t.State
|
||||
Mod: t.State
|
||||
Pow: t.State
|
||||
LShift: t.State
|
||||
RShift: t.State
|
||||
BitOr: t.State
|
||||
BitXor: t.State
|
||||
BitAnd: t.State
|
||||
FloorDiv: t.State
|
||||
And: t.State
|
||||
Or: t.State
|
||||
Eq: t.State
|
||||
Ne: t.State
|
||||
Lt: t.State
|
||||
Le: t.State
|
||||
Gt: t.State
|
||||
Ge: t.State
|
||||
Is: t.State
|
||||
IsNot: t.State
|
||||
In: t.State
|
||||
NotIn: t.State
|
||||
Not: t.State
|
||||
UAdd: t.State
|
||||
USub: t.State
|
||||
Invert: t.State
|
||||
NoneOp: t.State
|
||||
|
||||
CONST_INT: t.CDefine = 1
|
||||
CONST_FLOAT: t.CDefine = 2
|
||||
CONST_STR: t.CDefine = 3
|
||||
CONST_BOOL: t.CDefine = 4
|
||||
CONST_NONE: t.CDefine = 5
|
||||
FLAG_IS_ASYNC: t.CDefine = 1
|
||||
FLAG_SIMPLE: t.CDefine = 2
|
||||
FLAG_HAS_STAR: t.CDefine = 4
|
||||
|
||||
class ASTFlag(t.CEnum):
|
||||
IsAsync: t.State
|
||||
Simple: t.State
|
||||
HasStar: t.State
|
||||
|
||||
def _copy_str(pool: memhub.MemManager | t.CPtr, src: str) -> str: pass
|
||||
|
||||
def _set_pos(node: AST | t.CPtr, lineno: t.CInt, col_offset: t.CInt, end_lineno: t.CInt, end_col_offset: t.CInt) -> t.CInt: pass
|
||||
|
||||
def _inherit_pos(node: AST | t.CPtr, ref: AST | t.CPtr) -> t.CInt: pass
|
||||
|
||||
def _init_ast(node: AST | t.CPtr, pool: memhub.MemManager | t.CPtr, lineno: t.CInt, col: t.CInt) -> t.CInt: pass
|
||||
|
||||
def _set_parent_list(lst: list[AST | t.CPtr] | t.CPtr, parent: AST | t.CPtr) -> t.CInt: pass
|
||||
|
||||
def _append_child(lst: list[AST | t.CPtr] | t.CPtr, node: AST | t.CPtr, pool: memhub.MemManager | t.CPtr) -> t.CInt: pass
|
||||
|
||||
def _binop_from_op(op_id: t.CInt) -> t.CInt: pass
|
||||
|
||||
def _augop_from_op(op_id: t.CInt) -> t.CInt: pass
|
||||
|
||||
def _cmpop_from_op(op_id: t.CInt) -> t.CInt: pass
|
||||
|
||||
def _emit(buf: t.CChar | t.CPtr, size: t.CSizeT, pos: t.CSizeT, text: str) -> t.CSizeT: pass
|
||||
|
||||
def _emit_str(buf: t.CChar | t.CPtr, size: t.CSizeT, pos: t.CSizeT, text: str) -> t.CSizeT: pass
|
||||
|
||||
def _emit_int(buf: t.CChar | t.CPtr, size: t.CSizeT, pos: t.CSizeT, val: t.CInt64T) -> t.CSizeT: pass
|
||||
|
||||
def _op_name(op: t.CInt) -> str: pass
|
||||
|
||||
def _dump_list(lst: list[AST | t.CPtr] | t.CPtr, buf: t.CChar | t.CPtr, size: t.CSizeT, pos: t.CSizeT) -> t.CSizeT: pass
|
||||
|
||||
def _dump_op_list(lst: t.CPtr, buf: t.CChar | t.CPtr, size: t.CSizeT, pos: t.CSizeT) -> t.CSizeT: pass
|
||||
|
||||
|
||||
@t.CVTable
|
||||
class AST:
|
||||
parent: AST | t.CPtr
|
||||
pool: memhub.MemManager | t.CPtr
|
||||
lineno: t.CInt
|
||||
col_offset: t.CInt
|
||||
end_lineno: t.CInt
|
||||
end_col_offset: t.CInt
|
||||
children: list[AST | t.CPtr] | t.CPtr
|
||||
def kind(self: AST) -> t.CInt: pass
|
||||
def type_name(self: AST) -> str: pass
|
||||
def dump(self: AST, buf: t.CChar | t.CPtr, size: t.CSizeT, pos: t.CSizeT) -> t.CSizeT: pass
|
||||
def accept(self: AST, visitor: t.CPtr) -> t.CInt: pass
|
||||
def append(self: AST, node: AST | t.CPtr) -> t.CInt: pass
|
||||
|
||||
def dump(node: AST | t.CPtr, buf: t.CChar | t.CPtr, size: t.CSizeT) -> t.CInt: pass
|
||||
@@ -0,0 +1,86 @@
|
||||
"""
|
||||
Auto-generated Python stub file from w32.winsock2.py
|
||||
Module: w32.winsock2
|
||||
"""
|
||||
|
||||
|
||||
import t, c
|
||||
from stdint import *
|
||||
from w32.win32base import *
|
||||
|
||||
WINSOCK_VERSION: t.CDefine = 0x0202 # 2.2
|
||||
AF_INET: t.CDefine = 2
|
||||
AF_INET6: t.CDefine = 23
|
||||
SOCK_STREAM: t.CDefine = 1 # TCP
|
||||
SOCK_DGRAM: t.CDefine = 2 # UDP
|
||||
SOCK_RAW: t.CDefine = 3 # 原始套接字
|
||||
IPPROTO_TCP: t.CDefine = 6
|
||||
IPPROTO_UDP: t.CDefine = 17
|
||||
SOL_SOCKET: t.CDefine = 0xFFFF # WinSock2 值
|
||||
SO_RCVTIMEO: t.CDefine = 0x1006 # WinSock2 值
|
||||
SO_SNDTIMEO: t.CDefine = 0x1005 # WinSock2 值
|
||||
SO_REUSEADDR: t.CDefine = 0x0004 # WinSock2 值
|
||||
INADDR_ANY: t.CDefine = 0
|
||||
SOCKET_ERROR: t.CDefine = -1
|
||||
INVALID_SOCKET: t.CDefine = 0xFFFFFFFF # WinSock2: ~0
|
||||
MSG_NOSIGNAL: t.CDefine = 0 # Windows 不支持,设为 0
|
||||
SD_SEND: t.CDefine = 1
|
||||
SD_RECV: t.CDefine = 0
|
||||
SD_BOTH: t.CDefine = 2
|
||||
|
||||
class WSASocketAddr:
|
||||
family: u16
|
||||
port: u16
|
||||
addr: u32
|
||||
zero: u64
|
||||
class WSAData:
|
||||
wVersion: WORD
|
||||
wHighVersion: WORD
|
||||
szDescription: BYTE
|
||||
szSystemStatus: BYTE
|
||||
iMaxSockets: u16
|
||||
iMaxUdpDg: u16
|
||||
lpVendorInfo: CHARPTR
|
||||
class WSAHostEnt:
|
||||
h_name: CHARPTR
|
||||
h_aliases: CHARPTR
|
||||
h_addrtype: SHORT
|
||||
h_length: SHORT
|
||||
h_addr_list: CHARPTR
|
||||
class WinTimeVal:
|
||||
tv_sec: LONG
|
||||
tv_usec: LONG
|
||||
|
||||
def WSAStartup(wVersionRequested: WORD, lpWSAData: WSAData | t.CPtr) -> INT | t.State: pass
|
||||
|
||||
def WSACleanup() -> INT | t.State: pass
|
||||
|
||||
def WSAGetLastError() -> INT | t.State: pass
|
||||
|
||||
def socket(family: INT, type: INT, protocol: INT) -> u64 | t.State: pass
|
||||
|
||||
def closesocket(s: u64) -> INT | t.State: pass
|
||||
|
||||
def connect(s: u64, name: WSASocketAddr | t.CPtr, namelen: INT) -> INT | t.State: pass
|
||||
|
||||
def send(s: u64, buf: t.CVoid | t.CPtr, len: INT, flags: INT) -> INT | t.State: pass
|
||||
|
||||
def recv(s: u64, buf: t.CVoid | t.CPtr, len: INT, flags: INT) -> INT | t.State: pass
|
||||
|
||||
def bind(s: u64, name: WSASocketAddr | t.CPtr, namelen: INT) -> INT | t.State: pass
|
||||
|
||||
def listen(s: u64, backlog: INT) -> INT | t.State: pass
|
||||
|
||||
def accept(s: u64, addr: WSASocketAddr | t.CPtr, addrlen: INT | t.CPtr) -> u64 | t.State: pass
|
||||
|
||||
def setsockopt(s: u64, level: INT, optname: INT, optval: t.CVoid | t.CPtr, optlen: INT) -> INT | t.State: pass
|
||||
|
||||
def shutdown(s: u64, how: INT) -> INT | t.State: pass
|
||||
|
||||
def gethostbyname(name: t.CChar | t.CConst | t.CPtr) -> WSAHostEnt | t.CPtr | t.State: pass
|
||||
|
||||
def ntohs(netshort: u16) -> u16 | t.State: pass
|
||||
|
||||
def htons(hostshort: u16) -> u16 | t.State: pass
|
||||
|
||||
def inet_addr(cp: t.CChar | t.CConst | t.CPtr) -> u32 | t.State: pass
|
||||
@@ -0,0 +1,189 @@
|
||||
"""
|
||||
Auto-generated Python stub file from posix.py
|
||||
Module: posix
|
||||
"""
|
||||
|
||||
|
||||
import t, c
|
||||
from stdint import *
|
||||
|
||||
DIR: t.CTypedef = t.CVoid | t.CPtr
|
||||
mode_t: t.CTypedef = t.CUInt32T
|
||||
pid_t: t.CTypedef = t.CInt32T
|
||||
off_t: t.CTypedef = t.CInt64T
|
||||
dev_t: t.CTypedef = t.CUInt64T
|
||||
ino_t: t.CTypedef = t.CUInt64T
|
||||
nlink_t: t.CTypedef = t.CUInt64T
|
||||
uid_t: t.CTypedef = t.CUInt32T
|
||||
gid_t: t.CTypedef = t.CUInt32T
|
||||
blksize_t: t.CTypedef = t.CInt64T
|
||||
blkcnt_t: t.CTypedef = t.CInt64T
|
||||
time_t: t.CTypedef = t.CInt64T
|
||||
O_RDONLY: t.CDefine = 0
|
||||
O_WRONLY: t.CDefine = 1
|
||||
O_RDWR: t.CDefine = 2
|
||||
O_CREAT: t.CDefine = 0o100
|
||||
O_EXCL: t.CDefine = 0o200
|
||||
O_TRUNC: t.CDefine = 0o1000
|
||||
O_APPEND: t.CDefine = 0o2000
|
||||
O_NONBLOCK: t.CDefine = 0o4000
|
||||
O_CLOEXEC: t.CDefine = 0o2000000
|
||||
F_OK: t.CDefine = 0 # 文件存在
|
||||
R_OK: t.CDefine = 4 # 可读
|
||||
W_OK: t.CDefine = 2 # 可写
|
||||
X_OK: t.CDefine = 1 # 可执行
|
||||
S_IFMT: t.CDefine = 0o170000 # 类型掩码
|
||||
S_IFSOCK: t.CDefine = 0o140000 # 套接字
|
||||
S_IFLNK: t.CDefine = 0o120000 # 符号链接
|
||||
S_IFREG: t.CDefine = 0o100000 # 普通文件
|
||||
S_IFBLK: t.CDefine = 0o060000 # 块设备
|
||||
S_IFDIR: t.CDefine = 0o040000 # 目录
|
||||
S_IFCHR: t.CDefine = 0o020000 # 字符设备
|
||||
S_IFIFO: t.CDefine = 0o010000 # FIFO/管道
|
||||
S_ISUID: t.CDefine = 0o4000 # set-user-ID
|
||||
S_ISGID: t.CDefine = 0o2000 # set-group-ID
|
||||
S_ISVTX: t.CDefine = 0o1000 # sticky 位
|
||||
S_IRWXU: t.CDefine = 0o700 # 用户读写执行
|
||||
S_IRUSR: t.CDefine = 0o400 # 用户读
|
||||
S_IWUSR: t.CDefine = 0o200 # 用户写
|
||||
S_IXUSR: t.CDefine = 0o100 # 用户执行
|
||||
S_IRWXG: t.CDefine = 0o070 # 组读写执行
|
||||
S_IRGRP: t.CDefine = 0o040 # 组读
|
||||
S_IWGRP: t.CDefine = 0o020 # 组写
|
||||
S_IXGRP: t.CDefine = 0o010 # 组执行
|
||||
S_IRWXO: t.CDefine = 0o007 # 其他读写执行
|
||||
S_IROTH: t.CDefine = 0o004 # 其他读
|
||||
S_IWOTH: t.CDefine = 0o002 # 其他写
|
||||
S_IXOTH: t.CDefine = 0o001 # 其他执行
|
||||
SEEK_SET: t.CDefine = 0
|
||||
SEEK_CUR: t.CDefine = 1
|
||||
SEEK_END: t.CDefine = 2
|
||||
PATH_MAX: t.CDefine = 4096
|
||||
NAME_MAX: t.CDefine = 255
|
||||
_SC_NPROCESSORS_ONLN: t.CDefine = 84
|
||||
_SC_PAGESIZE: t.CDefine = 30
|
||||
_SC_CLK_TCK: t.CDefine = 2
|
||||
DT_UNKNOWN: t.CDefine = 0
|
||||
DT_FIFO: t.CDefine = 1
|
||||
DT_CHR: t.CDefine = 2
|
||||
DT_DIR: t.CDefine = 4
|
||||
DT_BLK: t.CDefine = 6
|
||||
DT_REG: t.CDefine = 8
|
||||
DT_LNK: t.CDefine = 10
|
||||
DT_SOCK: t.CDefine = 12
|
||||
DT_WHT: t.CDefine = 14
|
||||
WNOHANG: t.CDefine = 1
|
||||
WUNTRACED: t.CDefine = 2
|
||||
WCONTINUED: t.CDefine = 8
|
||||
|
||||
class Stat:
|
||||
st_dev: dev_t
|
||||
st_ino: ino_t
|
||||
st_nlink: nlink_t
|
||||
st_mode: mode_t
|
||||
st_uid: uid_t
|
||||
st_gid: gid_t
|
||||
__pad0: INT
|
||||
st_rdev: dev_t
|
||||
st_size: off_t
|
||||
st_blksize: blksize_t
|
||||
st_blocks: blkcnt_t
|
||||
st_atim_sec: time_t
|
||||
st_atim_nsec: LONGLONG
|
||||
st_mtim_sec: time_t
|
||||
st_mtim_nsec: LONGLONG
|
||||
st_ctim_sec: time_t
|
||||
st_ctim_nsec: LONGLONG
|
||||
__unused0: LONGLONG
|
||||
__unused1: LONGLONG
|
||||
__unused2: LONGLONG
|
||||
class Dirent:
|
||||
d_ino: ino_t
|
||||
d_off: off_t
|
||||
d_reclen: USHORT
|
||||
d_type: BYTE
|
||||
d_name: CHARPTR
|
||||
|
||||
def open(path: t.CConst | str, oflag: INT, *args) -> INT | t.State: pass
|
||||
|
||||
def close(fd: INT) -> INT | t.State: pass
|
||||
|
||||
def read(fd: INT, buf: bytes, count: t.CSizeT) -> ssize_t | t.State: pass
|
||||
|
||||
def write(fd: INT, buf: t.CConst | bytes, count: t.CSizeT) -> ssize_t | t.State: pass
|
||||
|
||||
def lseek(fd: INT, offset: off_t, whence: INT) -> off_t | t.State: pass
|
||||
|
||||
def unlink(path: t.CConst | str) -> INT | t.State: pass
|
||||
|
||||
def access(path: t.CConst | str, amode: INT) -> INT | t.State: pass
|
||||
|
||||
def realpath(path: t.CConst | str, resolved: CHARPTR) -> CHARPTR | t.State: pass
|
||||
|
||||
def rename(oldpath: t.CConst | str, newpath: t.CConst | str) -> INT | t.State: pass
|
||||
|
||||
def chmod(path: t.CConst | str, mode: mode_t) -> INT | t.State: pass
|
||||
|
||||
def stat(path: t.CConst | str, buf: Stat | t.CPtr) -> INT | t.State: pass
|
||||
|
||||
def fstat(fd: INT, buf: Stat | t.CPtr) -> INT | t.State: pass
|
||||
|
||||
def opendir(name: t.CConst | str) -> DIR | t.CPtr | t.State: pass
|
||||
|
||||
def readdir(dirp: DIR | t.CPtr) -> Dirent | t.CPtr | t.State: pass
|
||||
|
||||
def closedir(dirp: DIR | t.CPtr) -> INT | t.State: pass
|
||||
|
||||
def mkdir(path: t.CConst | str, mode: mode_t) -> INT | t.State: pass
|
||||
|
||||
def rmdir(path: t.CConst | str) -> INT | t.State: pass
|
||||
|
||||
def getcwd(buf: CHARPTR, size: t.CSizeT) -> CHARPTR | t.State: pass
|
||||
|
||||
def chdir(path: t.CConst | str) -> INT | t.State: pass
|
||||
|
||||
def fork() -> pid_t | t.State: pass
|
||||
|
||||
def execvp(file: t.CConst | str, argv: CHARPTR | t.CPtr) -> INT | t.State: pass
|
||||
|
||||
def execv(path: t.CConst | str, argv: CHARPTR | t.CPtr) -> INT | t.State: pass
|
||||
|
||||
def waitpid(pid: pid_t, status: INT | t.CPtr, options: INT) -> pid_t | t.State: pass
|
||||
|
||||
def pipe(fds: INT | t.CPtr) -> INT | t.State: pass
|
||||
|
||||
def dup2(oldfd: INT, newfd: INT) -> INT | t.State: pass
|
||||
|
||||
def _exit(status: INT) -> t.CVoid | t.State: pass
|
||||
|
||||
def getpid() -> pid_t | t.State: pass
|
||||
|
||||
def getenv(name: t.CConst | str) -> CHARPTR | t.State: pass
|
||||
|
||||
def setenv(name: t.CConst | str, value: t.CConst | str, overwrite: INT) -> INT | t.State: pass
|
||||
|
||||
def sysconf(name: INT) -> LONG | t.State: pass
|
||||
|
||||
def isatty(fd: INT) -> INT | t.State: pass
|
||||
|
||||
def S_ISREG(mode: mode_t) -> bool: pass
|
||||
|
||||
def S_ISDIR(mode: mode_t) -> bool: pass
|
||||
|
||||
def S_ISLNK(mode: mode_t) -> bool: pass
|
||||
|
||||
def S_ISCHR(mode: mode_t) -> bool: pass
|
||||
|
||||
def S_ISBLK(mode: mode_t) -> bool: pass
|
||||
|
||||
def S_ISFIFO(mode: mode_t) -> bool: pass
|
||||
|
||||
def S_ISSOCK(mode: mode_t) -> bool: pass
|
||||
|
||||
def WIFEXITED(status: INT) -> bool: pass
|
||||
|
||||
def WEXITSTATUS(status: INT) -> INT: pass
|
||||
|
||||
def WIFSIGNALED(status: INT) -> bool: pass
|
||||
|
||||
def WTERMSIG(status: INT) -> INT: pass
|
||||
@@ -0,0 +1,226 @@
|
||||
"""
|
||||
Auto-generated Python stub file from ast.stmts.py
|
||||
Module: ast.stmts
|
||||
"""
|
||||
|
||||
|
||||
import t, c
|
||||
from stdint import *
|
||||
import memhub
|
||||
import string
|
||||
from .base import AST, ASTKind, ASTCtx, OpKind, _init_ast, _copy_str, _set_parent_list, _emit, _emit_str, _emit_int, _dump_list, FLAG_IS_ASYNC
|
||||
|
||||
@t.CVTable
|
||||
class Module(AST):
|
||||
def __new__(self: Module, pool: memhub.MemManager | t.CPtr) -> t.CInt: pass
|
||||
def __init__(self: Module, pool: memhub.MemManager | t.CPtr) -> t.CInt: pass
|
||||
def kind(self: Module) -> t.CInt: pass
|
||||
def type_name(self: Module) -> str: pass
|
||||
def dump(self: Module, buf: t.CChar | t.CPtr, size: t.CSizeT, pos: t.CSizeT) -> t.CSizeT: pass
|
||||
class Assign(AST):
|
||||
targets: list[AST | t.CPtr] | t.CPtr
|
||||
value: AST | t.CPtr
|
||||
def __new__(self: Assign, pool: memhub.MemManager | t.CPtr, targets: list[AST | t.CPtr] | t.CPtr, value: AST | t.CPtr) -> t.CInt: pass
|
||||
def __init__(self: Assign, pool: memhub.MemManager | t.CPtr, targets: list[AST | t.CPtr] | t.CPtr, value: AST | t.CPtr) -> t.CInt: pass
|
||||
def kind(self: Assign) -> t.CInt: pass
|
||||
def type_name(self: Assign) -> str: pass
|
||||
def dump(self: Assign, buf: t.CChar | t.CPtr, size: t.CSizeT, pos: t.CSizeT) -> t.CSizeT: pass
|
||||
class If(AST):
|
||||
test: AST | t.CPtr
|
||||
orelse: list[AST | t.CPtr] | t.CPtr
|
||||
def __new__(self: If, pool: memhub.MemManager | t.CPtr, test: AST | t.CPtr, orelse: list[AST | t.CPtr] | t.CPtr) -> t.CInt: pass
|
||||
def __init__(self: If, pool: memhub.MemManager | t.CPtr, test: AST | t.CPtr, orelse: list[AST | t.CPtr] | t.CPtr) -> t.CInt: pass
|
||||
def kind(self: If) -> t.CInt: pass
|
||||
def type_name(self: If) -> str: pass
|
||||
def dump(self: If, buf: t.CChar | t.CPtr, size: t.CSizeT, pos: t.CSizeT) -> t.CSizeT: pass
|
||||
class For(AST):
|
||||
target: AST | t.CPtr
|
||||
iter: AST | t.CPtr
|
||||
orelse: list[AST | t.CPtr] | t.CPtr
|
||||
flags: t.CInt
|
||||
def __new__(self: For, pool: memhub.MemManager | t.CPtr, target: AST | t.CPtr, iter: AST | t.CPtr, orelse: list[AST | t.CPtr] | t.CPtr, is_async: t.CInt) -> t.CInt: pass
|
||||
def __init__(self: For, pool: memhub.MemManager | t.CPtr, target: AST | t.CPtr, iter: AST | t.CPtr, orelse: list[AST | t.CPtr] | t.CPtr, is_async: t.CInt) -> t.CInt: pass
|
||||
def kind(self: For) -> t.CInt: pass
|
||||
def type_name(self: For) -> str: pass
|
||||
def dump(self: For, buf: t.CChar | t.CPtr, size: t.CSizeT, pos: t.CSizeT) -> t.CSizeT: pass
|
||||
class While(AST):
|
||||
test: AST | t.CPtr
|
||||
orelse: list[AST | t.CPtr] | t.CPtr
|
||||
def __new__(self: While, pool: memhub.MemManager | t.CPtr, test: AST | t.CPtr, orelse: list[AST | t.CPtr] | t.CPtr) -> t.CInt: pass
|
||||
def __init__(self: While, pool: memhub.MemManager | t.CPtr, test: AST | t.CPtr, orelse: list[AST | t.CPtr] | t.CPtr) -> t.CInt: pass
|
||||
def kind(self: While) -> t.CInt: pass
|
||||
def type_name(self: While) -> str: pass
|
||||
def dump(self: While, buf: t.CChar | t.CPtr, size: t.CSizeT, pos: t.CSizeT) -> t.CSizeT: pass
|
||||
class Return(AST):
|
||||
value: AST | t.CPtr
|
||||
def __new__(self: Return, pool: memhub.MemManager | t.CPtr, value: AST | t.CPtr) -> t.CInt: pass
|
||||
def __init__(self: Return, pool: memhub.MemManager | t.CPtr, value: AST | t.CPtr) -> t.CInt: pass
|
||||
def kind(self: Return) -> t.CInt: pass
|
||||
def type_name(self: Return) -> str: pass
|
||||
def dump(self: Return, buf: t.CChar | t.CPtr, size: t.CSizeT, pos: t.CSizeT) -> t.CSizeT: pass
|
||||
class Expr(AST):
|
||||
value: AST | t.CPtr
|
||||
def __new__(self: Expr, pool: memhub.MemManager | t.CPtr, value: AST | t.CPtr) -> t.CInt: pass
|
||||
def __init__(self: Expr, pool: memhub.MemManager | t.CPtr, value: AST | t.CPtr) -> t.CInt: pass
|
||||
def kind(self: Expr) -> t.CInt: pass
|
||||
def type_name(self: Expr) -> str: pass
|
||||
def dump(self: Expr, buf: t.CChar | t.CPtr, size: t.CSizeT, pos: t.CSizeT) -> t.CSizeT: pass
|
||||
class FunctionDef(AST):
|
||||
name: str
|
||||
args: AST | t.CPtr
|
||||
decorator_list: list[AST | t.CPtr] | t.CPtr
|
||||
returns: AST | t.CPtr
|
||||
flags: t.CInt
|
||||
def __new__(self: FunctionDef, pool: memhub.MemManager | t.CPtr, name: str, args: AST | t.CPtr, decorator_list: list[AST | t.CPtr] | t.CPtr, returns: AST | t.CPtr, is_async: t.CInt) -> t.CInt: pass
|
||||
def __init__(self: FunctionDef, pool: memhub.MemManager | t.CPtr, name: str, args: AST | t.CPtr, decorator_list: list[AST | t.CPtr] | t.CPtr, returns: AST | t.CPtr, is_async: t.CInt) -> t.CInt: pass
|
||||
def kind(self: FunctionDef) -> t.CInt: pass
|
||||
def type_name(self: FunctionDef) -> str: pass
|
||||
def dump(self: FunctionDef, buf: t.CChar | t.CPtr, size: t.CSizeT, pos: t.CSizeT) -> t.CSizeT: pass
|
||||
class Expression(AST):
|
||||
body: AST | t.CPtr
|
||||
def __new__(self: Expression, pool: memhub.MemManager | t.CPtr, body: AST | t.CPtr) -> t.CInt: pass
|
||||
def __init__(self: Expression, pool: memhub.MemManager | t.CPtr, body: AST | t.CPtr) -> t.CInt: pass
|
||||
def kind(self: Expression) -> t.CInt: pass
|
||||
def type_name(self: Expression) -> str: pass
|
||||
def dump(self: Expression, buf: t.CChar | t.CPtr, size: t.CSizeT, pos: t.CSizeT) -> t.CSizeT: pass
|
||||
class Interactive(AST):
|
||||
body: AST | t.CPtr
|
||||
def __new__(self: Interactive, pool: memhub.MemManager | t.CPtr, body: AST | t.CPtr) -> t.CInt: pass
|
||||
def __init__(self: Interactive, pool: memhub.MemManager | t.CPtr, body: AST | t.CPtr) -> t.CInt: pass
|
||||
def kind(self: Interactive) -> t.CInt: pass
|
||||
def type_name(self: Interactive) -> str: pass
|
||||
def dump(self: Interactive, buf: t.CChar | t.CPtr, size: t.CSizeT, pos: t.CSizeT) -> t.CSizeT: pass
|
||||
class FunctionType(AST):
|
||||
argtypes: list[AST | t.CPtr] | t.CPtr
|
||||
returns: AST | t.CPtr
|
||||
def __new__(self: FunctionType, pool: memhub.MemManager | t.CPtr, argtypes: list[AST | t.CPtr] | t.CPtr, returns: AST | t.CPtr) -> t.CInt: pass
|
||||
def __init__(self: FunctionType, pool: memhub.MemManager | t.CPtr, argtypes: list[AST | t.CPtr] | t.CPtr, returns: AST | t.CPtr) -> t.CInt: pass
|
||||
def kind(self: FunctionType) -> t.CInt: pass
|
||||
def type_name(self: FunctionType) -> str: pass
|
||||
def dump(self: FunctionType, buf: t.CChar | t.CPtr, size: t.CSizeT, pos: t.CSizeT) -> t.CSizeT: pass
|
||||
class ClassDef(AST):
|
||||
name: str
|
||||
bases: list[AST | t.CPtr] | t.CPtr
|
||||
keywords: list[AST | t.CPtr] | t.CPtr
|
||||
decorator_list: list[AST | t.CPtr] | t.CPtr
|
||||
type_params: list[str] | t.CPtr
|
||||
def __new__(self: ClassDef, pool: memhub.MemManager | t.CPtr, name: str, bases: list[AST | t.CPtr] | t.CPtr, keywords: list[AST | t.CPtr] | t.CPtr, decorator_list: list[AST | t.CPtr] | t.CPtr, type_params: list[str] | t.CPtr) -> t.CInt: pass
|
||||
def __init__(self: ClassDef, pool: memhub.MemManager | t.CPtr, name: str, bases: list[AST | t.CPtr] | t.CPtr, keywords: list[AST | t.CPtr] | t.CPtr, decorator_list: list[AST | t.CPtr] | t.CPtr, type_params: list[str] | t.CPtr) -> t.CInt: pass
|
||||
def kind(self: ClassDef) -> t.CInt: pass
|
||||
def type_name(self: ClassDef) -> str: pass
|
||||
def dump(self: ClassDef, buf: t.CChar | t.CPtr, size: t.CSizeT, pos: t.CSizeT) -> t.CSizeT: pass
|
||||
class Delete(AST):
|
||||
targets: list[AST | t.CPtr] | t.CPtr
|
||||
def __new__(self: Delete, pool: memhub.MemManager | t.CPtr, targets: list[AST | t.CPtr] | t.CPtr) -> t.CInt: pass
|
||||
def __init__(self: Delete, pool: memhub.MemManager | t.CPtr, targets: list[AST | t.CPtr] | t.CPtr) -> t.CInt: pass
|
||||
def kind(self: Delete) -> t.CInt: pass
|
||||
def type_name(self: Delete) -> str: pass
|
||||
def dump(self: Delete, buf: t.CChar | t.CPtr, size: t.CSizeT, pos: t.CSizeT) -> t.CSizeT: pass
|
||||
class AugAssign(AST):
|
||||
target: AST | t.CPtr
|
||||
op: t.CInt
|
||||
value: AST | t.CPtr
|
||||
def __new__(self: AugAssign, pool: memhub.MemManager | t.CPtr, target: AST | t.CPtr, op: t.CInt, value: AST | t.CPtr) -> t.CInt: pass
|
||||
def __init__(self: AugAssign, pool: memhub.MemManager | t.CPtr, target: AST | t.CPtr, op: t.CInt, value: AST | t.CPtr) -> t.CInt: pass
|
||||
def kind(self: AugAssign) -> t.CInt: pass
|
||||
def type_name(self: AugAssign) -> str: pass
|
||||
def dump(self: AugAssign, buf: t.CChar | t.CPtr, size: t.CSizeT, pos: t.CSizeT) -> t.CSizeT: pass
|
||||
class AnnAssign(AST):
|
||||
target: AST | t.CPtr
|
||||
annotation: AST | t.CPtr
|
||||
value: AST | t.CPtr
|
||||
simple: t.CInt
|
||||
def __new__(self: AnnAssign, pool: memhub.MemManager | t.CPtr, target: AST | t.CPtr, annotation: AST | t.CPtr, value: AST | t.CPtr, simple: t.CInt) -> t.CInt: pass
|
||||
def __init__(self: AnnAssign, pool: memhub.MemManager | t.CPtr, target: AST | t.CPtr, annotation: AST | t.CPtr, value: AST | t.CPtr, simple: t.CInt) -> t.CInt: pass
|
||||
def kind(self: AnnAssign) -> t.CInt: pass
|
||||
def type_name(self: AnnAssign) -> str: pass
|
||||
def dump(self: AnnAssign, buf: t.CChar | t.CPtr, size: t.CSizeT, pos: t.CSizeT) -> t.CSizeT: pass
|
||||
class With(AST):
|
||||
items: list[AST | t.CPtr] | t.CPtr
|
||||
flags: t.CInt
|
||||
def __new__(self: With, pool: memhub.MemManager | t.CPtr, items: list[AST | t.CPtr] | t.CPtr, is_async: t.CInt) -> t.CInt: pass
|
||||
def __init__(self: With, pool: memhub.MemManager | t.CPtr, items: list[AST | t.CPtr] | t.CPtr, is_async: t.CInt) -> t.CInt: pass
|
||||
def kind(self: With) -> t.CInt: pass
|
||||
def type_name(self: With) -> str: pass
|
||||
def dump(self: With, buf: t.CChar | t.CPtr, size: t.CSizeT, pos: t.CSizeT) -> t.CSizeT: pass
|
||||
class Raise(AST):
|
||||
exc: AST | t.CPtr
|
||||
cause: AST | t.CPtr
|
||||
def __new__(self: Raise, pool: memhub.MemManager | t.CPtr, exc: AST | t.CPtr, cause: AST | t.CPtr) -> t.CInt: pass
|
||||
def __init__(self: Raise, pool: memhub.MemManager | t.CPtr, exc: AST | t.CPtr, cause: AST | t.CPtr) -> t.CInt: pass
|
||||
def kind(self: Raise) -> t.CInt: pass
|
||||
def type_name(self: Raise) -> str: pass
|
||||
def dump(self: Raise, buf: t.CChar | t.CPtr, size: t.CSizeT, pos: t.CSizeT) -> t.CSizeT: pass
|
||||
class Try(AST):
|
||||
handlers: list[AST | t.CPtr] | t.CPtr
|
||||
orelse: list[AST | t.CPtr] | t.CPtr
|
||||
finalbody: list[AST | t.CPtr] | t.CPtr
|
||||
def __new__(self: Try, pool: memhub.MemManager | t.CPtr, handlers: list[AST | t.CPtr] | t.CPtr, orelse: list[AST | t.CPtr] | t.CPtr, finalbody: list[AST | t.CPtr] | t.CPtr) -> t.CInt: pass
|
||||
def __init__(self: Try, pool: memhub.MemManager | t.CPtr, handlers: list[AST | t.CPtr] | t.CPtr, orelse: list[AST | t.CPtr] | t.CPtr, finalbody: list[AST | t.CPtr] | t.CPtr) -> t.CInt: pass
|
||||
def kind(self: Try) -> t.CInt: pass
|
||||
def type_name(self: Try) -> str: pass
|
||||
def dump(self: Try, buf: t.CChar | t.CPtr, size: t.CSizeT, pos: t.CSizeT) -> t.CSizeT: pass
|
||||
class Assert(AST):
|
||||
test: AST | t.CPtr
|
||||
msg: AST | t.CPtr
|
||||
def __new__(self: Assert, pool: memhub.MemManager | t.CPtr, test: AST | t.CPtr, msg: AST | t.CPtr) -> t.CInt: pass
|
||||
def __init__(self: Assert, pool: memhub.MemManager | t.CPtr, test: AST | t.CPtr, msg: AST | t.CPtr) -> t.CInt: pass
|
||||
def kind(self: Assert) -> t.CInt: pass
|
||||
def type_name(self: Assert) -> str: pass
|
||||
def dump(self: Assert, buf: t.CChar | t.CPtr, size: t.CSizeT, pos: t.CSizeT) -> t.CSizeT: pass
|
||||
class Global(AST):
|
||||
names: list[AST | t.CPtr] | t.CPtr
|
||||
def __new__(self: Global, pool: memhub.MemManager | t.CPtr, names: list[AST | t.CPtr] | t.CPtr) -> t.CInt: pass
|
||||
def __init__(self: Global, pool: memhub.MemManager | t.CPtr, names: list[AST | t.CPtr] | t.CPtr) -> t.CInt: pass
|
||||
def kind(self: Global) -> t.CInt: pass
|
||||
def type_name(self: Global) -> str: pass
|
||||
def dump(self: Global, buf: t.CChar | t.CPtr, size: t.CSizeT, pos: t.CSizeT) -> t.CSizeT: pass
|
||||
class Nonlocal(AST):
|
||||
names: list[AST | t.CPtr] | t.CPtr
|
||||
def __new__(self: Nonlocal, pool: memhub.MemManager | t.CPtr, names: list[AST | t.CPtr] | t.CPtr) -> t.CInt: pass
|
||||
def __init__(self: Nonlocal, pool: memhub.MemManager | t.CPtr, names: list[AST | t.CPtr] | t.CPtr) -> t.CInt: pass
|
||||
def kind(self: Nonlocal) -> t.CInt: pass
|
||||
def type_name(self: Nonlocal) -> str: pass
|
||||
def dump(self: Nonlocal, buf: t.CChar | t.CPtr, size: t.CSizeT, pos: t.CSizeT) -> t.CSizeT: pass
|
||||
class Pass(AST):
|
||||
def __new__(self: Pass, pool: memhub.MemManager | t.CPtr) -> t.CInt: pass
|
||||
def __init__(self: Pass, pool: memhub.MemManager | t.CPtr) -> t.CInt: pass
|
||||
def kind(self: Pass) -> t.CInt: pass
|
||||
def type_name(self: Pass) -> str: pass
|
||||
def dump(self: Pass, buf: t.CChar | t.CPtr, size: t.CSizeT, pos: t.CSizeT) -> t.CSizeT: pass
|
||||
class Break(AST):
|
||||
def __new__(self: Break, pool: memhub.MemManager | t.CPtr) -> t.CInt: pass
|
||||
def __init__(self: Break, pool: memhub.MemManager | t.CPtr) -> t.CInt: pass
|
||||
def kind(self: Break) -> t.CInt: pass
|
||||
def type_name(self: Break) -> str: pass
|
||||
def dump(self: Break, buf: t.CChar | t.CPtr, size: t.CSizeT, pos: t.CSizeT) -> t.CSizeT: pass
|
||||
class Continue(AST):
|
||||
def __new__(self: Continue, pool: memhub.MemManager | t.CPtr) -> t.CInt: pass
|
||||
def __init__(self: Continue, pool: memhub.MemManager | t.CPtr) -> t.CInt: pass
|
||||
def kind(self: Continue) -> t.CInt: pass
|
||||
def type_name(self: Continue) -> str: pass
|
||||
def dump(self: Continue, buf: t.CChar | t.CPtr, size: t.CSizeT, pos: t.CSizeT) -> t.CSizeT: pass
|
||||
class Import(AST):
|
||||
names: list[AST | t.CPtr] | t.CPtr
|
||||
def __new__(self: Import, pool: memhub.MemManager | t.CPtr, names: list[AST | t.CPtr] | t.CPtr) -> t.CInt: pass
|
||||
def __init__(self: Import, pool: memhub.MemManager | t.CPtr, names: list[AST | t.CPtr] | t.CPtr) -> t.CInt: pass
|
||||
def kind(self: Import) -> t.CInt: pass
|
||||
def type_name(self: Import) -> str: pass
|
||||
def dump(self: Import, buf: t.CChar | t.CPtr, size: t.CSizeT, pos: t.CSizeT) -> t.CSizeT: pass
|
||||
class ImportFrom(AST):
|
||||
module: str
|
||||
names: list[AST | t.CPtr] | t.CPtr
|
||||
level: t.CInt
|
||||
def __new__(self: ImportFrom, pool: memhub.MemManager | t.CPtr, module: str, names: list[AST | t.CPtr] | t.CPtr, level: t.CInt) -> t.CInt: pass
|
||||
def __init__(self: ImportFrom, pool: memhub.MemManager | t.CPtr, module: str, names: list[AST | t.CPtr] | t.CPtr, level: t.CInt) -> t.CInt: pass
|
||||
def kind(self: ImportFrom) -> t.CInt: pass
|
||||
def type_name(self: ImportFrom) -> str: pass
|
||||
def dump(self: ImportFrom, buf: t.CChar | t.CPtr, size: t.CSizeT, pos: t.CSizeT) -> t.CSizeT: pass
|
||||
class Match(AST):
|
||||
subject: AST | t.CPtr
|
||||
cases: list[AST | t.CPtr] | t.CPtr
|
||||
def __new__(self: Match, pool: memhub.MemManager | t.CPtr, subject: AST | t.CPtr, cases: list[AST | t.CPtr] | t.CPtr) -> t.CInt: pass
|
||||
def __init__(self: Match, pool: memhub.MemManager | t.CPtr, subject: AST | t.CPtr, cases: list[AST | t.CPtr] | t.CPtr) -> t.CInt: pass
|
||||
def kind(self: Match) -> t.CInt: pass
|
||||
def type_name(self: Match) -> str: pass
|
||||
def dump(self: Match, buf: t.CChar | t.CPtr, size: t.CSizeT, pos: t.CSizeT) -> t.CSizeT: pass
|
||||
@@ -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
|
||||
@@ -0,0 +1,20 @@
|
||||
"""
|
||||
Auto-generated Python stub file from stdarg.py
|
||||
Module: stdarg
|
||||
"""
|
||||
|
||||
import c
|
||||
|
||||
|
||||
import t
|
||||
|
||||
def va_start(args: t.CPtr, last_arg: t.CPtr) -> t.State: pass
|
||||
|
||||
def va_arg(args: t.CPtr, type: t.CPtr) -> t.CPtr | t.State: pass
|
||||
|
||||
def va_end(args: t.CPtr) -> t.State | t.State: pass
|
||||
|
||||
|
||||
va_list: t.CTypedef = t.CUnsignedChar | t.CPtr
|
||||
|
||||
def arg(type: t.CType) -> t.State: pass
|
||||
@@ -0,0 +1,91 @@
|
||||
"""
|
||||
Auto-generated Python stub file from w32.win32memory.py
|
||||
Module: w32.win32memory
|
||||
"""
|
||||
|
||||
import c
|
||||
|
||||
|
||||
import t
|
||||
from stdint import *
|
||||
from w32.win32base import *
|
||||
|
||||
MEM_COMMIT: t.CDefine = 0x00001000
|
||||
MEM_RESERVE: t.CDefine = 0x00002000
|
||||
MEM_DECOMMIT: t.CDefine = 0x00004000
|
||||
MEM_RELEASE: t.CDefine = 0x00008000
|
||||
MEM_FREE: t.CDefine = 0x00010000
|
||||
MEM_RESET: t.CDefine = 0x00080000
|
||||
MEM_TOP_DOWN: t.CDefine = 0x00100000
|
||||
MEM_WRITE_WATCH: t.CDefine = 0x00200000
|
||||
MEM_PHYSICAL: t.CDefine = 0x00400000
|
||||
MEM_LARGE_PAGES: t.CDefine = 0x20000000
|
||||
PAGE_NOACCESS: t.CDefine = 0x01
|
||||
PAGE_READONLY: t.CDefine = 0x02
|
||||
PAGE_READWRITE: t.CDefine = 0x04
|
||||
PAGE_WRITECOPY: t.CDefine = 0x08
|
||||
PAGE_EXECUTE: t.CDefine = 0x10
|
||||
PAGE_EXECUTE_READ: t.CDefine = 0x20
|
||||
PAGE_EXECUTE_READWRITE: t.CDefine = 0x40
|
||||
PAGE_EXECUTE_WRITECOPY: t.CDefine = 0x80
|
||||
PAGE_GUARD: t.CDefine = 0x100
|
||||
PAGE_NOCACHE: t.CDefine = 0x200
|
||||
PAGE_WRITECOMBINE: t.CDefine = 0x400
|
||||
HEAP_NO_SERIALIZE: t.CDefine = 0x00000001
|
||||
HEAP_GROWABLE: t.CDefine = 0x00000002
|
||||
HEAP_GENERATE_EXCEPTIONS: t.CDefine = 0x00000004
|
||||
HEAP_ZERO_MEMORY: t.CDefine = 0x00000008
|
||||
HEAP_REALLOC_IN_PLACE_ONLY: t.CDefine = 0x00000010
|
||||
|
||||
class MEMORY_BASIC_INFORMATION:
|
||||
BaseAddress: VOIDPTR
|
||||
AllocationBase: VOIDPTR
|
||||
AllocationProtect: ULONG
|
||||
RegionSize: t.CSizeT
|
||||
State: ULONG
|
||||
Protect: ULONG
|
||||
Type: ULONG
|
||||
|
||||
def VirtualAlloc(lpAddress: VOIDPTR, dwSize: t.CSizeT, flAllocationType: ULONG, flProtect: ULONG) -> VOIDPTR | t.State: pass
|
||||
|
||||
def VirtualFree(lpAddress: VOIDPTR, dwSize: t.CSizeT, dwFreeType: ULONG) -> BOOL | t.State: pass
|
||||
|
||||
def VirtualProtect(lpAddress: VOIDPTR, dwSize: t.CSizeT, flNewProtect: ULONG, lpflOldProtect: ULONG | t.CPtr) -> BOOL | t.State: pass
|
||||
|
||||
def VirtualQuery(lpAddress: t.CConst | VOIDPTR, lpBuffer: MEMORY_BASIC_INFORMATION | t.CPtr, dwLength: t.CSizeT) -> t.CSizeT | t.State: pass
|
||||
|
||||
def VirtualLock(lpAddress: VOIDPTR, dwSize: t.CSizeT) -> BOOL | t.State: pass
|
||||
|
||||
def VirtualUnlock(lpAddress: VOIDPTR, dwSize: t.CSizeT) -> BOOL | t.State: pass
|
||||
|
||||
def GetProcessHeap() -> HANDLE | t.State: pass
|
||||
|
||||
def HeapCreate(flOptions: ULONG, dwInitialSize: t.CSizeT, dwMaximumSize: t.CSizeT) -> HANDLE | t.State: pass
|
||||
|
||||
def HeapDestroy(hHeap: HANDLE) -> BOOL | t.State: pass
|
||||
|
||||
def HeapAlloc(hHeap: HANDLE, dwFlags: ULONG, dwBytes: t.CSizeT) -> VOIDPTR | t.State: pass
|
||||
|
||||
def HeapReAlloc(hHeap: HANDLE, dwFlags: ULONG, lpMem: VOIDPTR, dwBytes: t.CSizeT) -> VOIDPTR | t.State: pass
|
||||
|
||||
def HeapFree(hHeap: HANDLE, dwFlags: ULONG, lpMem: VOIDPTR) -> BOOL | t.State: pass
|
||||
|
||||
def HeapSize(hHeap: HANDLE, dwFlags: ULONG, lpMem: t.CConst | VOIDPTR) -> t.CSizeT | t.State: pass
|
||||
|
||||
def HeapValidate(hHeap: HANDLE, dwFlags: ULONG, lpMem: t.CConst | VOIDPTR) -> BOOL | t.State: pass
|
||||
|
||||
def HeapCompact(hHeap: HANDLE, dwFlags: ULONG) -> t.CSizeT | t.State: pass
|
||||
|
||||
def GlobalAlloc(uFlags: UINT, dwBytes: t.CSizeT) -> VOIDPTR | t.State: pass
|
||||
|
||||
def GlobalFree(hMem: VOIDPTR) -> VOIDPTR | t.State: pass
|
||||
|
||||
def GlobalLock(hMem: VOIDPTR) -> VOIDPTR | t.State: pass
|
||||
|
||||
def GlobalUnlock(hMem: VOIDPTR) -> BOOL | t.State: pass
|
||||
|
||||
def GlobalSize(hMem: VOIDPTR) -> t.CSizeT | t.State: pass
|
||||
|
||||
def LocalAlloc(uFlags: UINT, dwBytes: t.CSizeT) -> VOIDPTR | t.State: pass
|
||||
|
||||
def LocalFree(hMem: VOIDPTR) -> VOIDPTR | t.State: pass
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -0,0 +1,53 @@
|
||||
"""
|
||||
Auto-generated Python stub file from platmacro.py
|
||||
Module: platmacro
|
||||
"""
|
||||
|
||||
|
||||
import t, c
|
||||
|
||||
IS_WINDOWS: t.CDefine = 1
|
||||
IS_WIN64: t.CDefine = 1
|
||||
IS_X86_64: t.CDefine = 1
|
||||
IS_LP64: t.CDefine = 1
|
||||
IS_LITTLE_ENDIAN: t.CDefine = 1
|
||||
IS_LINUX: t.CDefine = 0
|
||||
IS_MACOS: t.CDefine = 0
|
||||
IS_ARM64: t.CDefine = 0
|
||||
IS_BIG_ENDIAN: t.CDefine = 0
|
||||
IS_ILP32: t.CDefine = 0
|
||||
PTR_SIZE: t.CDefine = t.CSizeT().Size
|
||||
INT_SIZE: t.CDefine = 4
|
||||
LONG_SIZE: t.CDefine = t.CLong().Size
|
||||
WORD_SIZE: t.CDefine = t.CSizeT().Size
|
||||
CACHE_LINE_SIZE: t.CDefine = 64
|
||||
PAGE_SIZE: t.CDefine = 4096
|
||||
STACK_ALIGN: t.CDefine = 16
|
||||
MAX_PATH_LEN: t.CDefine = 260
|
||||
PLATFORM_NAME: t.CDefine = 1
|
||||
ARCH_NAME: t.CDefine = 1
|
||||
WINVER: t.CDefine = 0x0A00
|
||||
_WIN32_WINNT: t.CDefine = 0x0A00
|
||||
NTDDI_VERSION: t.CDefine = 0x0A000006
|
||||
HAS_SSE2: t.CDefine = 1
|
||||
HAS_AVX: t.CDefine = 1
|
||||
HAS_AVX2: t.CDefine = 1
|
||||
HAS_FMA: t.CDefine = 1
|
||||
HAS_NEON: t.CDefine = 0
|
||||
ALIGNOF_INT: t.CDefine = 4
|
||||
ALIGNOF_LONG: t.CDefine = t.CLong().Size // 8
|
||||
ALIGNOF_PTR: t.CDefine = t.CSizeT().Size // 8
|
||||
ALIGNOF_DOUBLE: t.CDefine = 8
|
||||
ALIGNOF_LONG_DOUBLE: t.CDefine = 16
|
||||
SIZEOF_SHORT: t.CDefine = 2
|
||||
SIZEOF_INT: t.CDefine = 4
|
||||
SIZEOF_LONG: t.CDefine = t.CLong().Size // 8
|
||||
SIZEOF_LONG_LONG: t.CDefine = 8
|
||||
SIZEOF_FLOAT: t.CDefine = 4
|
||||
SIZEOF_DOUBLE: t.CDefine = 8
|
||||
SIZEOF_LONG_DOUBLE: t.CDefine = 16
|
||||
SIZEOF_POINTER: t.CDefine = t.CSizeT().Size // 8
|
||||
SIZEOF_SIZE_T: t.CDefine = t.CSizeT().Size // 8
|
||||
SIZEOF_PTRDIFF_T: t.CDefine = t.CPtrDiffT().Size // 8
|
||||
BYTE_ORDER_LE: t.CDefine = 1
|
||||
BYTE_ORDER_BE: t.CDefine = 0
|
||||
@@ -0,0 +1 @@
|
||||
{"D:\\Users\\TermiNexus\\Desktop\\TransPyC\\Test\\AstTest\\App\\main.py": {"sha1": "0853acdbdfc9b27c", "mtime": 1782892830.6294758, "size": 2439}, "D:\\Users\\TermiNexus\\Desktop\\TransPyC\\includes\\ast\\__init__.py": {"sha1": "34548789d646f432", "mtime": 1784102404.6307266, "size": 3409}, "D:\\Users\\TermiNexus\\Desktop\\TransPyC\\includes\\ast\\astaux.py": {"sha1": "4337fb260448bbe2", "mtime": 1784006094.7981195, "size": 11489}, "D:\\Users\\TermiNexus\\Desktop\\TransPyC\\includes\\ast\\base.py": {"sha1": "5dab8cb390496d22", "mtime": 1784197698.3282094, "size": 14966}, "D:\\Users\\TermiNexus\\Desktop\\TransPyC\\includes\\ast\\exprs.py": {"sha1": "47767b5026a8ee15", "mtime": 1783239758.809719, "size": 40615}, "D:\\Users\\TermiNexus\\Desktop\\TransPyC\\includes\\ast\\lexer.py": {"sha1": "0c212981c180e7fb", "mtime": 1783400609.908198, "size": 23535}, "D:\\Users\\TermiNexus\\Desktop\\TransPyC\\includes\\ast\\match.py": {"sha1": "4dd6b3f1427d1cc5", "mtime": 1782961799.8492737, "size": 12309}, "D:\\Users\\TermiNexus\\Desktop\\TransPyC\\includes\\ast\\parser.py": {"sha1": "ee52c08239684346", "mtime": 1784102405.1933146, "size": 85445}, "D:\\Users\\TermiNexus\\Desktop\\TransPyC\\includes\\ast\\stmts.py": {"sha1": "657e182b27c2a022", "mtime": 1783929993.759902, "size": 37926}, "D:\\Users\\TermiNexus\\Desktop\\TransPyC\\includes\\ast\\tokens.py": {"sha1": "b547ac4f380bddb6", "mtime": 1783165480.469121, "size": 13722}, "D:\\Users\\TermiNexus\\Desktop\\TransPyC\\includes\\atom.py": {"sha1": "271ea3decb810db2", "mtime": 1782226548.693161, "size": 1290}, "D:\\Users\\TermiNexus\\Desktop\\TransPyC\\includes\\memhub.py": {"sha1": "ee084e9fc6ee413a", "mtime": 1784214242.4485993, "size": 17765}, "D:\\Users\\TermiNexus\\Desktop\\TransPyC\\includes\\platmacro.py": {"sha1": "93c1d18e35d188d6", "mtime": 1781237231.03366, "size": 1422}, "D:\\Users\\TermiNexus\\Desktop\\TransPyC\\includes\\posix.py": {"sha1": "6503c97dde0c79c4", "mtime": 1783064077.6376991, "size": 10386}, "D:\\Users\\TermiNexus\\Desktop\\TransPyC\\includes\\stdarg.py": {"sha1": "71e0a3ffcb3ebfad", "mtime": 1781258888.113146, "size": 277}, "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\\string.py": {"sha1": "ab6e54ba9a669f76", "mtime": 1783933178.7264287, "size": 9922}, "D:\\Users\\TermiNexus\\Desktop\\TransPyC\\includes\\sys.py": {"sha1": "b5a965302cded36b", "mtime": 1783569641.07535, "size": 5509}, "D:\\Users\\TermiNexus\\Desktop\\TransPyC\\includes\\viperio.py": {"sha1": "c9f4be41ca1cc2b4", "mtime": 1782812279.506002, "size": 1556}, "D:\\Users\\TermiNexus\\Desktop\\TransPyC\\includes\\viperlib.py": {"sha1": "c3b259b4059f8668", "mtime": 1782821991.979496, "size": 56772}, "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}, "D:\\Users\\TermiNexus\\Desktop\\TransPyC\\includes\\w32\\win32process.py": {"sha1": "067c78e9f121dce3", "mtime": 1781200703.5409546, "size": 4802}}
|
||||
@@ -0,0 +1,25 @@
|
||||
067c78e9f121dce3:includes/w32\win32process.py
|
||||
0853acdbdfc9b27c:main.py
|
||||
0c212981c180e7fb:includes/ast\lexer.py
|
||||
271ea3decb810db2:includes/atom.py
|
||||
34548789d646f432:includes/ast\__init__.py
|
||||
4337fb260448bbe2:includes/ast\astaux.py
|
||||
47767b5026a8ee15:includes/ast\exprs.py
|
||||
4dd6b3f1427d1cc5:includes/ast\match.py
|
||||
5dab8cb390496d22:includes/ast\base.py
|
||||
6503c97dde0c79c4:includes/posix.py
|
||||
657e182b27c2a022:includes/ast\stmts.py
|
||||
6f62fe05c5ea1ceb:includes/stdio.py
|
||||
71e0a3ffcb3ebfad:includes/stdarg.py
|
||||
7e529fe7a078cfef:includes/w32\win32base.py
|
||||
90c53dd6db8d41cf:includes/stdlib.py
|
||||
93c1d18e35d188d6:includes/platmacro.py
|
||||
ab6e54ba9a669f76:includes/string.py
|
||||
b547ac4f380bddb6:includes/ast\tokens.py
|
||||
b5a965302cded36b:includes/sys.py
|
||||
bbdf3bbd4c3bc28c:includes/w32\win32console.py
|
||||
c3b259b4059f8668:includes/viperlib.py
|
||||
c9f4be41ca1cc2b4:includes/viperio.py
|
||||
ee084e9fc6ee413a:includes/memhub.py
|
||||
ee52c08239684346:includes/ast\parser.py
|
||||
f5522571bcce7bcb:includes/stdint.py
|
||||
@@ -0,0 +1,48 @@
|
||||
"""
|
||||
Auto-generated Python stub file from string.py
|
||||
Module: string
|
||||
"""
|
||||
|
||||
|
||||
from stdint import *
|
||||
import t, c
|
||||
|
||||
def strcpy(dest: str, src: str) -> str: pass
|
||||
|
||||
def strcat(dest: str, src: str) -> str: pass
|
||||
|
||||
def strncpy(dest: str, src: str, n: t.CSizeT) -> str: pass
|
||||
|
||||
def strlen(src: str) -> t.CSizeT | t.CExport: pass
|
||||
|
||||
def strcmp(str1: str, str2: str) -> t.CInt: pass
|
||||
|
||||
def samestr(str1: str, str2: str) -> bool: pass
|
||||
|
||||
def strncmp(str1: str, str2: str, n: t.CSizeT) -> t.CInt: pass
|
||||
|
||||
def memcmp(ptr1: t.CVoid | t.CPtr, ptr2: t.CVoid | t.CPtr, n: t.CSizeT) -> t.CInt: pass
|
||||
|
||||
def strchr(s: str, cr: t.CInt) -> str: pass
|
||||
|
||||
def strrchr(s: str, cr: t.CInt) -> str: pass
|
||||
|
||||
def strstr(s: str, needle: str) -> str: pass
|
||||
|
||||
def strspn(s: str, skip: str) -> int: pass
|
||||
|
||||
def memset(ptr: t.CVoid | t.CPtr, value: t.CInt, num: t.CSizeT) -> t.CVoid | t.CPtr | t.CExport: pass
|
||||
|
||||
def memset32(ptr: t.CVoid | t.CPtr, value: t.CUInt32T, count: t.CSizeT) -> t.CVoid | t.CPtr: pass
|
||||
|
||||
def memcpy(dest: t.CVoid | t.CPtr, src: t.CVoid | t.CPtr, num: t.CSizeT) -> t.CVoid | t.CPtr | t.CExport: pass
|
||||
|
||||
def memmove(dest: t.CVoid | t.CPtr, src: t.CVoid | t.CPtr, num: t.CSizeT) -> t.CVoid | t.CPtr: pass
|
||||
|
||||
def atoi(src: str) -> t.CInt: pass
|
||||
|
||||
def atoll(src: str) -> t.CInt64T: pass
|
||||
|
||||
def atof(src: str) -> t.CDouble: pass
|
||||
|
||||
def split(s: str, delim: str, result: t.CArray[str]) -> int: pass
|
||||
@@ -0,0 +1,166 @@
|
||||
"""
|
||||
Auto-generated Python stub file from ast.tokens.py
|
||||
Module: ast.tokens
|
||||
"""
|
||||
|
||||
|
||||
import t, c
|
||||
from stdint import *
|
||||
import memhub
|
||||
import string
|
||||
|
||||
class TokenType(t.CEnum):
|
||||
EndMarker: t.State
|
||||
NewLine: t.State
|
||||
Indent: t.State
|
||||
Dedent: t.State
|
||||
Name: t.State
|
||||
Number: t.State
|
||||
String: t.State
|
||||
FStringStart: t.State
|
||||
FStringMiddle: t.State
|
||||
FStringEnd: t.State
|
||||
Op: t.State
|
||||
Nl: t.State
|
||||
Comment: t.State
|
||||
Encoding: t.State
|
||||
class Keyword(t.CEnum):
|
||||
NotKeyword: t.State
|
||||
False_: t.State
|
||||
None_: t.State
|
||||
True_: t.State
|
||||
And: t.State
|
||||
As: t.State
|
||||
Assert: t.State
|
||||
Async: t.State
|
||||
Await: t.State
|
||||
Break: t.State
|
||||
Class: t.State
|
||||
Continue: t.State
|
||||
Def: t.State
|
||||
Del: t.State
|
||||
Elif: t.State
|
||||
Else: t.State
|
||||
Except: t.State
|
||||
Finally: t.State
|
||||
For: t.State
|
||||
From: t.State
|
||||
Global: t.State
|
||||
If: t.State
|
||||
Import: t.State
|
||||
In: t.State
|
||||
Is: t.State
|
||||
Lambda: t.State
|
||||
Nonlocal: t.State
|
||||
Not: t.State
|
||||
Or: t.State
|
||||
Pass: t.State
|
||||
Raise: t.State
|
||||
Return: t.State
|
||||
Try: t.State
|
||||
While: t.State
|
||||
With: t.State
|
||||
Yield: t.State
|
||||
Match: t.State
|
||||
Case: t.State
|
||||
Type: t.State
|
||||
class TokOp(t.CEnum):
|
||||
LPar: t.State
|
||||
RPar: t.State
|
||||
Lsqb: t.State
|
||||
Rsqb: t.State
|
||||
LBrace: t.State
|
||||
RBrace: t.State
|
||||
Comma: t.State
|
||||
Colon: t.State
|
||||
Dot: t.State
|
||||
Semi: t.State
|
||||
At: t.State
|
||||
Equal: t.State
|
||||
RArrow: t.State
|
||||
PlusEq: t.State
|
||||
MinusEq: t.State
|
||||
StarEq: t.State
|
||||
SlashEq: t.State
|
||||
DSlashEq: t.State
|
||||
PercentEq: t.State
|
||||
AtEq: t.State
|
||||
AmpEq: t.State
|
||||
VBarEq: t.State
|
||||
CaretEq: t.State
|
||||
GtGtEq: t.State
|
||||
LtLtEq: t.State
|
||||
StarEqEq: t.State
|
||||
DSlash: t.State
|
||||
StarStar: t.State
|
||||
LtLt: t.State
|
||||
GtGt: t.State
|
||||
LessEq: t.State
|
||||
GreaterEq: t.State
|
||||
EqEq: t.State
|
||||
ExclaimEq: t.State
|
||||
Less: t.State
|
||||
Greater: t.State
|
||||
Plus: t.State
|
||||
Minus: t.State
|
||||
Star: t.State
|
||||
Slash: t.State
|
||||
Percent: t.State
|
||||
Amp: t.State
|
||||
VBar: t.State
|
||||
Caret: t.State
|
||||
Tilde: t.State
|
||||
ColonEq: t.State
|
||||
Ellipsis: t.State
|
||||
Bang: t.State
|
||||
class Token:
|
||||
type: t.CInt
|
||||
op_subtype: t.CInt
|
||||
kw_subtype: t.CInt
|
||||
str_val: str
|
||||
int_val: t.CInt64T
|
||||
float_val: t.CDouble
|
||||
is_float: t.CInt
|
||||
is_complex: t.CInt
|
||||
lineno: t.CInt
|
||||
col_offset: t.CInt
|
||||
end_lineno: t.CInt
|
||||
end_col_offset: t.CInt
|
||||
next: Token | t.CPtr
|
||||
def __new__(self: Token, pool: memhub.MemManager | t.CPtr) -> t.CInt: pass
|
||||
class KwEntry:
|
||||
name: str
|
||||
kw_id: t.CInt
|
||||
next: KwEntry | t.CPtr
|
||||
def __new__(self: KwEntry, pool: memhub.MemManager | t.CPtr) -> t.CInt: pass
|
||||
|
||||
_kw_head: t.CExtern | KwEntry | t.CPtr
|
||||
_kw_pool: t.CExtern | memhub.MemManager | t.CPtr
|
||||
|
||||
def _kw_intern(pool: memhub.MemManager | t.CPtr, name: str, kw_id: t.CInt) -> t.CInt: pass
|
||||
|
||||
def _kw_lookup(name: str) -> t.CInt: pass
|
||||
|
||||
def _init_keywords(pool: memhub.MemManager | t.CPtr) -> t.CInt: pass
|
||||
|
||||
|
||||
class OpEntry:
|
||||
name: str
|
||||
op_id: t.CInt
|
||||
length: t.CInt
|
||||
next: OpEntry | t.CPtr
|
||||
def __new__(self: OpEntry, pool: memhub.MemManager | t.CPtr) -> t.CInt: pass
|
||||
|
||||
_op_head: t.CExtern | OpEntry | t.CPtr
|
||||
|
||||
def _op_intern(pool: memhub.MemManager | t.CPtr, name: str, op_id: t.CInt) -> t.CInt: pass
|
||||
|
||||
def _init_operators(pool: memhub.MemManager | t.CPtr) -> t.CInt: pass
|
||||
|
||||
def _init_tables(pool: memhub.MemManager | t.CPtr) -> t.CInt: pass
|
||||
|
||||
def new_token(pool: memhub.MemManager | t.CPtr, ttype: t.CInt, lineno: t.CInt, col_offset: t.CInt) -> Token | t.CPtr: pass
|
||||
|
||||
def token_set_str(pool: memhub.MemManager | t.CPtr, tok: Token | t.CPtr, src: str, start: t.CSizeT, length: t.CSizeT) -> t.CInt: pass
|
||||
|
||||
def token_set_str_literal(pool: memhub.MemManager | t.CPtr, tok: Token | t.CPtr, text: str) -> t.CInt: pass
|
||||
@@ -0,0 +1,44 @@
|
||||
"""
|
||||
Auto-generated Python stub file from sys.py
|
||||
Module: sys
|
||||
"""
|
||||
|
||||
|
||||
import t, c
|
||||
from stdint import *
|
||||
import platmacro
|
||||
import memhub
|
||||
import string
|
||||
import stdio
|
||||
import w32.win32base
|
||||
import w32.win32process
|
||||
import posix
|
||||
|
||||
_mbuddy: t.CExtern | memhub.MemBuddy | t.CPtr
|
||||
|
||||
def fgets(buf: t.CChar | t.CPtr, size: t.CInt, stream: t.CVoid | t.CPtr) -> t.CChar | t.CPtr | t.CExtern | t.CExport: pass
|
||||
|
||||
def fflush(stream: t.CVoid | t.CPtr) -> t.CInt | t.CExtern | t.CExport: pass
|
||||
|
||||
def exit(status: INT) -> VOID | t.CExtern | t.CExport: pass
|
||||
|
||||
|
||||
maxsize: t.CDefine = 9223372036854775807
|
||||
|
||||
def platform() -> str: pass
|
||||
|
||||
def get_pid() -> int: pass
|
||||
|
||||
|
||||
_argc: t.CExtern | INT
|
||||
_argv: t.CExtern | str | t.CPtr
|
||||
|
||||
def _init_argv() -> t.CInt: pass
|
||||
|
||||
def _init_argv_win32() -> t.CInt: pass
|
||||
|
||||
def _init_argv_posix() -> t.CInt: pass
|
||||
|
||||
def argc() -> int: pass
|
||||
|
||||
def argv(index: int) -> str: pass
|
||||
@@ -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
|
||||
@@ -0,0 +1,23 @@
|
||||
"""
|
||||
Auto-generated Python stub file from viperlib.py
|
||||
Module: viperlib
|
||||
"""
|
||||
|
||||
|
||||
import t, c
|
||||
import viperio
|
||||
from stdarg import arg, va_arg
|
||||
|
||||
TEMP_BUF_SIZE: t.CDefine = 68
|
||||
|
||||
def get_digit_count(num: t.CUnsignedInt, base: t.CInt) -> t.CStatic | t.CInt: pass
|
||||
|
||||
def sprintf(buf: t.CChar | t.CPtr, rule: str, *args) -> t.CVoid | t.CExport: pass
|
||||
|
||||
def vsprintf(buf: t.CChar | t.CPtr, rule: str, *args) -> t.CInt: pass
|
||||
|
||||
def snprintf(buf: t.CChar | t.CPtr, size: t.CSizeT, fmt: str, *args) -> t.CInt | t.CExport: pass
|
||||
|
||||
def _check_special_float(fv: t.CDouble) -> t.CInt: pass
|
||||
|
||||
def vsnprintf(buf: t.CChar | t.CPtr, size: t.CSizeT, fmt: str, ap: t.CChar | t.CPtr) -> t.CInt | t.CExport: pass
|
||||
@@ -0,0 +1,22 @@
|
||||
"""
|
||||
Auto-generated Python stub file from viperio.py
|
||||
Module: viperio
|
||||
"""
|
||||
|
||||
|
||||
import t, c
|
||||
from stdint import *
|
||||
|
||||
class Buf:
|
||||
data: t.CChar | t.CPtr
|
||||
length: t.CSizeT
|
||||
capacity: t.CSizeT
|
||||
owned: bool
|
||||
def __init__(self: Buf, data: t.CChar | t.CPtr, capacity: t.CSizeT, length: t.CSizeT, owned: bool) -> t.CInt: pass
|
||||
def clear(self: Buf) -> t.CInt: pass
|
||||
def write(self: Buf, src: t.CChar | t.CPtr, count: t.CSizeT) -> t.CSizeT: pass
|
||||
def cstr(self: Buf) -> t.CChar | t.CPtr: pass
|
||||
def reset(self: Buf) -> t.CInt: pass
|
||||
def __enter__(self: Buf) -> 'Buf' | t.CPtr: pass
|
||||
def __exit__(self: Buf) -> t.CInt: pass
|
||||
def free(self: Buf) -> t.CInt: pass
|
||||
@@ -0,0 +1,81 @@
|
||||
"""
|
||||
Auto-generated Python stub file from memhub.py
|
||||
Module: memhub
|
||||
"""
|
||||
|
||||
|
||||
import t, c
|
||||
from stdint import *
|
||||
import string
|
||||
import atom
|
||||
import viperio
|
||||
|
||||
MEMHUB_ALIGN: t.CDefine = 8
|
||||
MEMSLAB_MIN_BLOCK: t.CDefine = 16
|
||||
MEMSLAB_BITMAP_BYTES: t.CDefine = 256
|
||||
MEMBUDDY_MIN_BLOCK: t.CDefine = 32
|
||||
MEMBUDDY_MAX_ORDERS: t.CDefine = 32
|
||||
MEMBUDDY_HEADER_SIZE: t.CDefine = 8
|
||||
|
||||
def _align_up(val: t.CSizeT, align: t.CSizeT) -> t.CSizeT: pass
|
||||
|
||||
def _largest_pow2_le(val: t.CSizeT) -> t.CSizeT: pass
|
||||
|
||||
def _block_size_at_order(order: t.CInt) -> t.CSizeT: pass
|
||||
|
||||
|
||||
@t.CVTable
|
||||
class MemManager:
|
||||
__provides__: list[str] = ['__memmgr__']
|
||||
base: t.CVoid | t.CPtr
|
||||
size: t.CSizeT
|
||||
def __init__(self: MemManager, base: t.CVoid | t.CPtr, size: t.CSizeT) -> t.CInt: pass
|
||||
def alloc(self: MemManager, size: t.CSizeT) -> t.CVoid | t.CPtr: pass
|
||||
def free(self: MemManager, ptr: t.CVoid | t.CPtr) -> t.CInt: pass
|
||||
def reset(self: MemManager) -> t.CInt: pass
|
||||
def calloc(self: MemManager, count: t.CSizeT, size: t.CSizeT) -> t.CVoid | t.CPtr: pass
|
||||
def realloc(self: MemManager, ptr: t.CVoid | t.CPtr, old_size: t.CSizeT, new_size: t.CSizeT) -> t.CVoid | t.CPtr: pass
|
||||
def __enter__(self: MemManager) -> 'MemManager' | t.CPtr: pass
|
||||
def __exit__(self: MemManager) -> t.CInt: pass
|
||||
def alloc_buf(self: MemManager, capacity: t.CSizeT) -> viperio.Buf | t.CPtr: pass
|
||||
class MemPool(MemManager):
|
||||
offset: t.CSizeT
|
||||
high_water: t.CSizeT
|
||||
def __init__(self: MemPool, base: t.CVoid | t.CPtr, size: t.CSizeT) -> t.CInt: pass
|
||||
def alloc(self: MemPool, size: t.CSizeT) -> t.CVoid | t.CPtr: pass
|
||||
def free(self: MemPool, ptr: t.CVoid | t.CPtr) -> t.CInt: pass
|
||||
def reset(self: MemPool) -> t.CInt: pass
|
||||
class MemSlab(MemManager):
|
||||
block_size: t.CSizeT
|
||||
block_count: t.CSizeT
|
||||
used_count: t.CSizeT
|
||||
free_list: t.CVoid | t.CPtr
|
||||
alloc_map: t.CUInt8T | t.CPtr
|
||||
alloc_map_size: t.CSizeT
|
||||
usable: t.CVoid | t.CPtr
|
||||
usable_size: t.CSizeT
|
||||
def __init__(self: MemSlab, base: t.CVoid | t.CPtr, size: t.CSizeT, block_size: t.CSizeT) -> t.CInt: pass
|
||||
def alloc(self: MemSlab, size: t.CSizeT) -> t.CVoid | t.CPtr: pass
|
||||
def free(self: MemSlab, ptr: t.CVoid | t.CPtr) -> t.CInt: pass
|
||||
def reset(self: MemSlab) -> t.CInt: pass
|
||||
class MemBuddy(MemManager):
|
||||
max_order: t.CInt
|
||||
free_lists: t.CUInt64T | t.CPtr
|
||||
lock_val: t.CVolatile | t.CInt
|
||||
usable: t.CVoid | t.CPtr
|
||||
usable_size: t.CSizeT
|
||||
def __init__(self: MemBuddy, base: t.CVoid | t.CPtr, size: t.CSizeT) -> t.CInt: pass
|
||||
def _fl_push(self: MemBuddy, order: t.CInt, block: t.CVoid | t.CPtr) -> t.CInt: pass
|
||||
def _fl_pop(self: MemBuddy, order: t.CInt) -> t.CVoid | t.CPtr: pass
|
||||
def _fl_find_and_remove(self: MemBuddy, order: t.CInt, target: t.CVoid | t.CPtr) -> t.CInt: pass
|
||||
def _buddy_of(self: MemBuddy, block: t.CVoid | t.CPtr, order: t.CInt) -> t.CVoid | t.CPtr: pass
|
||||
def _order_for_size(self: MemBuddy, size: t.CSizeT) -> t.CInt: pass
|
||||
def _split_to_order(self: MemBuddy, to_order: t.CInt) -> t.CVoid | t.CPtr: pass
|
||||
def _coalesce(self: MemBuddy, block: t.CVoid | t.CPtr, order: t.CInt) -> t.CInt: pass
|
||||
def _is_valid_ptr(self: MemBuddy, ptr: t.CVoid | t.CPtr) -> t.CInt: pass
|
||||
def _lock(self: MemBuddy) -> t.CInt: pass
|
||||
def _unlock(self: MemBuddy) -> t.CInt: pass
|
||||
def alloc(self: MemBuddy, size: t.CSizeT) -> t.CVoid | t.CPtr: pass
|
||||
def free(self: MemBuddy, ptr: t.CVoid | t.CPtr) -> t.CInt: pass
|
||||
def reset(self: MemBuddy) -> t.CInt: pass
|
||||
def realloc(self: MemBuddy, ptr: t.CVoid | t.CPtr, old_size: t.CSizeT, new_size: t.CSizeT) -> t.CVoid | t.CPtr: pass
|
||||
@@ -0,0 +1,215 @@
|
||||
"""
|
||||
Auto-generated Python stub file from ast.parser.py
|
||||
Module: ast.parser
|
||||
"""
|
||||
|
||||
|
||||
import t, c
|
||||
from stdint import *
|
||||
import memhub
|
||||
import string
|
||||
from .tokens import Token, TokenType, Keyword, TokOp
|
||||
from .base import AST, ASTCtx, ASTKind, OpKind, ASTFlag, _set_pos, _binop_from_op, _augop_from_op, _cmpop_from_op, _copy_str, _inherit_pos, _init_ast, CONST_INT, CONST_FLOAT, CONST_STR, CONST_BOOL, CONST_NONE, FLAG_IS_ASYNC
|
||||
from .exprs import BoolOp, BinOp, UnaryOp, Lambda, IfExp, Dict, Set, ListComp, SetComp, DictComp, GeneratorExp, Await, Yield, YieldFrom, FormattedValue, JoinedStr, Constant, NamedExpr, Attribute, Subscript, Starred, Name, List, Tuple, Slice, Call, Compare, OpNode
|
||||
from .stmts import Module, Expression, Interactive, FunctionType, FunctionDef, ClassDef, Return, Delete, Assign, AugAssign, AnnAssign, For, While, If, With, Raise, Try, Assert, Global, Nonlocal, Pass, Break, Continue, Expr, Import, ImportFrom, Match
|
||||
from .astaux import ExceptHandler, Arguments, Arg, Keyword as KwNode, Alias, WithItem, Comprehension
|
||||
from .match import MatchCase, MatchValue, MatchSingleton, MatchSequence, MatchMapping, MatchClass, MatchStar, MatchAs, MatchOr
|
||||
from .lexer import Lexer, _lexer_init, tokenize, new_lexer
|
||||
|
||||
class Parser:
|
||||
tokens: Token | t.CPtr
|
||||
cur: Token | t.CPtr
|
||||
pool: memhub.MemManager | t.CPtr
|
||||
error_count: t.CInt
|
||||
pending_decorators: list[AST | t.CPtr] | t.CPtr
|
||||
def __new__(self: Parser, pool: memhub.MemManager | t.CPtr) -> t.CInt: pass
|
||||
|
||||
def new_parser(pool: memhub.MemManager | t.CPtr) -> Parser | t.CPtr: pass
|
||||
|
||||
def _parser_init(ps: Parser | t.CPtr, tokens: Token | t.CPtr, pool: memhub.MemManager | t.CPtr) -> t.CInt: pass
|
||||
|
||||
def _advance(ps: Parser | t.CPtr) -> t.CInt: pass
|
||||
|
||||
def _cur_type(ps: Parser | t.CPtr) -> t.CInt: pass
|
||||
|
||||
def _cur_op(ps: Parser | t.CPtr) -> t.CInt: pass
|
||||
|
||||
def _cur_kw(ps: Parser | t.CPtr) -> t.CInt: pass
|
||||
|
||||
def _cur_str(ps: Parser | t.CPtr) -> str: pass
|
||||
|
||||
def _cur_lineno(ps: Parser | t.CPtr) -> t.CInt: pass
|
||||
|
||||
def _cur_col(ps: Parser | t.CPtr) -> t.CInt: pass
|
||||
|
||||
def _skip_nl(ps: Parser | t.CPtr) -> t.CInt: pass
|
||||
|
||||
def _skip_nls_and_newlines(ps: Parser | t.CPtr) -> t.CInt: pass
|
||||
|
||||
def _expect_type(ps: Parser | t.CPtr, ttype: t.CInt) -> t.CInt: pass
|
||||
|
||||
def _expect_op(ps: Parser | t.CPtr, op_id: t.CInt) -> t.CInt: pass
|
||||
|
||||
def _match_op(ps: Parser | t.CPtr, op_id: t.CInt) -> t.CInt: pass
|
||||
|
||||
def _accept_op(ps: Parser | t.CPtr, op_id: t.CInt) -> t.CInt: pass
|
||||
|
||||
def _new_const_int(pool: memhub.MemManager | t.CPtr, val: t.CInt64T, lineno: t.CInt, col: t.CInt) -> AST | t.CPtr: pass
|
||||
|
||||
def _new_const_float(pool: memhub.MemManager | t.CPtr, val: t.CDouble, lineno: t.CInt, col: t.CInt) -> AST | t.CPtr: pass
|
||||
|
||||
def _new_const_str(pool: memhub.MemManager | t.CPtr, val: str, lineno: t.CInt, col: t.CInt) -> AST | t.CPtr: pass
|
||||
|
||||
def _new_const_bool(pool: memhub.MemManager | t.CPtr, val: t.CInt, lineno: t.CInt, col: t.CInt) -> AST | t.CPtr: pass
|
||||
|
||||
def _new_const_none(pool: memhub.MemManager | t.CPtr, lineno: t.CInt, col: t.CInt) -> AST | t.CPtr: pass
|
||||
|
||||
def _set_ctx(node: AST | t.CPtr, ctx: t.CInt) -> t.CInt: pass
|
||||
|
||||
def _fix_store_ctx(node: AST | t.CPtr) -> t.CInt: pass
|
||||
|
||||
def _parse_expr(ps: Parser | t.CPtr) -> AST | t.CPtr: pass
|
||||
|
||||
def _parse_namedexpr(ps: Parser | t.CPtr) -> AST | t.CPtr: pass
|
||||
|
||||
def _parse_test(ps: Parser | t.CPtr) -> AST | t.CPtr: pass
|
||||
|
||||
def _parse_lambda(ps: Parser | t.CPtr) -> AST | t.CPtr: pass
|
||||
|
||||
def _parse_or_test(ps: Parser | t.CPtr) -> AST | t.CPtr: pass
|
||||
|
||||
def _parse_and_test(ps: Parser | t.CPtr) -> AST | t.CPtr: pass
|
||||
|
||||
def _parse_not_test(ps: Parser | t.CPtr) -> AST | t.CPtr: pass
|
||||
|
||||
def _parse_comparison(ps: Parser | t.CPtr) -> AST | t.CPtr: pass
|
||||
|
||||
def _match_comp_op(ps: Parser | t.CPtr) -> t.CInt: pass
|
||||
|
||||
def _advance_comp_op(ps: Parser | t.CPtr) -> t.CInt: pass
|
||||
|
||||
def _parse_bitor(ps: Parser | t.CPtr) -> AST | t.CPtr: pass
|
||||
|
||||
def _parse_bitxor(ps: Parser | t.CPtr) -> AST | t.CPtr: pass
|
||||
|
||||
def _parse_bitand(ps: Parser | t.CPtr) -> AST | t.CPtr: pass
|
||||
|
||||
def _parse_shift(ps: Parser | t.CPtr) -> AST | t.CPtr: pass
|
||||
|
||||
def _parse_arith(ps: Parser | t.CPtr) -> AST | t.CPtr: pass
|
||||
|
||||
def _parse_term(ps: Parser | t.CPtr) -> AST | t.CPtr: pass
|
||||
|
||||
def _parse_factor(ps: Parser | t.CPtr) -> AST | t.CPtr: pass
|
||||
|
||||
def _parse_power(ps: Parser | t.CPtr) -> AST | t.CPtr: pass
|
||||
|
||||
def _parse_atom_expr(ps: Parser | t.CPtr) -> AST | t.CPtr: pass
|
||||
|
||||
def _parse_call(ps: Parser | t.CPtr, func: AST | t.CPtr) -> AST | t.CPtr: pass
|
||||
|
||||
def _parse_subscript(ps: Parser | t.CPtr, value: AST | t.CPtr) -> AST | t.CPtr: pass
|
||||
|
||||
def _parse_slice(ps: Parser | t.CPtr) -> AST | t.CPtr: pass
|
||||
|
||||
def _parse_atom(ps: Parser | t.CPtr) -> AST | t.CPtr: pass
|
||||
|
||||
def _parse_paren(ps: Parser | t.CPtr) -> AST | t.CPtr: pass
|
||||
|
||||
def _parse_list(ps: Parser | t.CPtr) -> AST | t.CPtr: pass
|
||||
|
||||
def _parse_brace(ps: Parser | t.CPtr) -> AST | t.CPtr: pass
|
||||
|
||||
def _parse_sub_expr(ps: Parser | t.CPtr, src: str) -> AST | t.CPtr: pass
|
||||
|
||||
def _parse_fstring(ps: Parser | t.CPtr, content: str, lineno: t.CInt, col: t.CInt) -> AST | t.CPtr: pass
|
||||
|
||||
def _parse_comprehension(ps: Parser | t.CPtr, elt: AST | t.CPtr, vtype: t.CInt, lineno: t.CInt, col: t.CInt) -> AST | t.CPtr: pass
|
||||
|
||||
def _parse_comp_for(ps: Parser | t.CPtr) -> list[AST | t.CPtr] | t.CPtr: pass
|
||||
|
||||
def _parse_target_list(ps: Parser | t.CPtr) -> AST | t.CPtr: pass
|
||||
|
||||
def _parse_target(ps: Parser | t.CPtr) -> AST | t.CPtr: pass
|
||||
|
||||
def _parse_yield(ps: Parser | t.CPtr) -> AST | t.CPtr: pass
|
||||
|
||||
def _parse_varargslist(ps: Parser | t.CPtr, is_lambda: t.CInt) -> AST | t.CPtr: pass
|
||||
|
||||
def _parse_arg_def(ps: Parser | t.CPtr, is_lambda: t.CInt) -> AST | t.CPtr: pass
|
||||
|
||||
def _parse_suite_into_children(ps: Parser | t.CPtr, parent: AST | t.CPtr) -> t.CInt: pass
|
||||
|
||||
def _parse_statement_into(ps: Parser | t.CPtr, parent: AST | t.CPtr) -> t.CInt: pass
|
||||
|
||||
def _parse_simple_stmt_into(ps: Parser | t.CPtr, parent: AST | t.CPtr) -> t.CInt: pass
|
||||
|
||||
def _parse_small_stmt(ps: Parser | t.CPtr) -> AST | t.CPtr: pass
|
||||
|
||||
def _maybe_tuple(ps: Parser | t.CPtr, first: AST | t.CPtr) -> AST | t.CPtr: pass
|
||||
|
||||
def _parse_testlist(ps: Parser | t.CPtr) -> AST | t.CPtr: pass
|
||||
|
||||
def _parse_expr_stmt(ps: Parser | t.CPtr, first: AST | t.CPtr) -> AST | t.CPtr: pass
|
||||
|
||||
def _parse_return(ps: Parser | t.CPtr) -> AST | t.CPtr: pass
|
||||
|
||||
def _parse_raise(ps: Parser | t.CPtr) -> AST | t.CPtr: pass
|
||||
|
||||
def _parse_global(ps: Parser | t.CPtr) -> AST | t.CPtr: pass
|
||||
|
||||
def _parse_nonlocal(ps: Parser | t.CPtr) -> AST | t.CPtr: pass
|
||||
|
||||
def _parse_import(ps: Parser | t.CPtr) -> AST | t.CPtr: pass
|
||||
|
||||
def _parse_from_import(ps: Parser | t.CPtr) -> AST | t.CPtr: pass
|
||||
|
||||
def _parse_alias_list(ps: Parser | t.CPtr) -> list[AST | t.CPtr] | t.CPtr: pass
|
||||
|
||||
def _parse_del(ps: Parser | t.CPtr) -> AST | t.CPtr: pass
|
||||
|
||||
def _parse_assert(ps: Parser | t.CPtr) -> AST | t.CPtr: pass
|
||||
|
||||
def _parse_compound(ps: Parser | t.CPtr) -> AST | t.CPtr: pass
|
||||
|
||||
def _parse_if(ps: Parser | t.CPtr) -> AST | t.CPtr: pass
|
||||
|
||||
def _parse_if_tail(ps: Parser | t.CPtr) -> list[AST | t.CPtr] | t.CPtr: pass
|
||||
|
||||
def _parse_while(ps: Parser | t.CPtr) -> AST | t.CPtr: pass
|
||||
|
||||
def _parse_for(ps: Parser | t.CPtr, is_async: t.CInt) -> AST | t.CPtr: pass
|
||||
|
||||
def _parse_try(ps: Parser | t.CPtr) -> AST | t.CPtr: pass
|
||||
|
||||
def _parse_except_handler(ps: Parser | t.CPtr) -> AST | t.CPtr: pass
|
||||
|
||||
def _parse_with(ps: Parser | t.CPtr, is_async: t.CInt) -> AST | t.CPtr: pass
|
||||
|
||||
def _parse_with_item(ps: Parser | t.CPtr) -> AST | t.CPtr: pass
|
||||
|
||||
def _parse_funcdef(ps: Parser | t.CPtr, is_async: t.CInt) -> AST | t.CPtr: pass
|
||||
|
||||
def _parse_classdef(ps: Parser | t.CPtr) -> AST | t.CPtr: pass
|
||||
|
||||
def _parse_match(ps: Parser | t.CPtr) -> AST | t.CPtr: pass
|
||||
|
||||
def _make_name_ast(pool: memhub.MemManager | t.CPtr, node: Name | t.CPtr) -> AST | t.CPtr: pass
|
||||
|
||||
def _parse_pattern(ps: Parser | t.CPtr) -> AST | t.CPtr: pass
|
||||
|
||||
def _parse_closed_pattern(ps: Parser | t.CPtr) -> AST | t.CPtr: pass
|
||||
|
||||
def _parse_sequence_pattern(ps: Parser | t.CPtr, close_op: t.CInt, lineno: t.CInt, col: t.CInt) -> AST | t.CPtr: pass
|
||||
|
||||
def _parse_mapping_pattern(ps: Parser | t.CPtr, lineno: t.CInt, col: t.CInt) -> AST | t.CPtr: pass
|
||||
|
||||
def _parse_class_pattern(ps: Parser | t.CPtr, cls: AST | t.CPtr, lineno: t.CInt, col: t.CInt) -> AST | t.CPtr: pass
|
||||
|
||||
def _parse_match_case(ps: Parser | t.CPtr) -> AST | t.CPtr: pass
|
||||
|
||||
def _parse_decorators(ps: Parser | t.CPtr) -> list[AST | t.CPtr] | t.CPtr: pass
|
||||
|
||||
def _parse_module_body(ps: Parser | t.CPtr, module_node: AST | t.CPtr) -> t.CInt: pass
|
||||
|
||||
def parse_tokens(pool: memhub.MemManager | t.CPtr, tokens: Token | t.CPtr) -> AST | t.CPtr: pass
|
||||
@@ -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
|
||||
@@ -0,0 +1,192 @@
|
||||
"""
|
||||
Auto-generated Python stub file from w32.win32file.py
|
||||
Module: w32.win32file
|
||||
"""
|
||||
|
||||
import c
|
||||
|
||||
|
||||
import t
|
||||
from stdint import *
|
||||
from w32.win32base import *
|
||||
|
||||
GENERIC_READ: t.CDefine = 0x80000000
|
||||
GENERIC_WRITE: t.CDefine = 0x40000000
|
||||
GENERIC_EXECUTE: t.CDefine = 0x20000000
|
||||
GENERIC_ALL: t.CDefine = 0x10000000
|
||||
FILE_SHARE_READ: t.CDefine = 0x00000001
|
||||
FILE_SHARE_WRITE: t.CDefine = 0x00000002
|
||||
FILE_SHARE_DELETE: t.CDefine = 0x00000004
|
||||
CREATE_NEW: t.CDefine = 1
|
||||
CREATE_ALWAYS: t.CDefine = 2
|
||||
OPEN_EXISTING: t.CDefine = 3
|
||||
OPEN_ALWAYS: t.CDefine = 4
|
||||
TRUNCATE_EXISTING: t.CDefine = 5
|
||||
FILE_ATTRIBUTE_READONLY: t.CDefine = 0x00000001
|
||||
FILE_ATTRIBUTE_HIDDEN: t.CDefine = 0x00000002
|
||||
FILE_ATTRIBUTE_SYSTEM: t.CDefine = 0x00000004
|
||||
FILE_ATTRIBUTE_DIRECTORY: t.CDefine = 0x00000010
|
||||
FILE_ATTRIBUTE_ARCHIVE: t.CDefine = 0x00000020
|
||||
FILE_ATTRIBUTE_NORMAL: t.CDefine = 0x00000080
|
||||
FILE_ATTRIBUTE_TEMPORARY: t.CDefine = 0x00000100
|
||||
FILE_ATTRIBUTE_COMPRESSED: t.CDefine = 0x00000800
|
||||
FILE_ATTRIBUTE_OFFLINE: t.CDefine = 0x00001000
|
||||
FILE_ATTRIBUTE_ENCRYPTED: t.CDefine = 0x00004000
|
||||
FILE_FLAG_WRITE_THROUGH: t.CDefine = 0x80000000
|
||||
FILE_FLAG_OVERLAPPED: t.CDefine = 0x40000000
|
||||
FILE_FLAG_NO_BUFFERING: t.CDefine = 0x20000000
|
||||
FILE_FLAG_RANDOM_ACCESS: t.CDefine = 0x10000000
|
||||
FILE_FLAG_SEQUENTIAL_SCAN: t.CDefine = 0x08000000
|
||||
FILE_FLAG_DELETE_ON_CLOSE: t.CDefine = 0x04000000
|
||||
FILE_FLAG_BACKUP_SEMANTICS: t.CDefine = 0x02000000
|
||||
FILE_FLAG_POSIX_SEMANTICS: t.CDefine = 0x01000000
|
||||
FILE_BEGIN: t.CDefine = 0
|
||||
FILE_CURRENT: t.CDefine = 1
|
||||
FILE_END: t.CDefine = 2
|
||||
STD_INPUT_HANDLE: t.CDefine = t.CUnsignedLong(-10)
|
||||
STD_OUTPUT_HANDLE: t.CDefine = t.CUnsignedLong(-11)
|
||||
STD_ERROR_HANDLE: t.CDefine = t.CUnsignedLong(-12)
|
||||
MOVEFILE_REPLACE_EXISTING: t.CDefine = 0x00000001
|
||||
MOVEFILE_COPY_ALLOWED: t.CDefine = 0x00000002
|
||||
MOVEFILE_WRITE_THROUGH: t.CDefine = 0x00000008
|
||||
|
||||
class BY_HANDLE_FILE_INFORMATION:
|
||||
dwFileAttributes: ULONG
|
||||
ftCreationTime: FILETIME
|
||||
ftLastAccessTime: FILETIME
|
||||
ftLastWriteTime: FILETIME
|
||||
dwVolumeSerialNumber: ULONG
|
||||
nFileSizeHigh: ULONG
|
||||
nFileSizeLow: ULONG
|
||||
nNumberOfLinks: ULONG
|
||||
nFileIndexHigh: ULONG
|
||||
nFileIndexLow: ULONG
|
||||
class WIN32_FIND_DATAA:
|
||||
dwFileAttributes: ULONG
|
||||
ftCreationTime: FILETIME
|
||||
ftLastAccessTime: FILETIME
|
||||
ftLastWriteTime: FILETIME
|
||||
nFileSizeHigh: ULONG
|
||||
nFileSizeLow: ULONG
|
||||
dwReserved0: ULONG
|
||||
dwReserved1: ULONG
|
||||
cFileName: t.CArray[t.CChar, 260]
|
||||
cAlternateFileName: t.CArray[t.CChar, 14]
|
||||
class WIN32_FIND_DATAW:
|
||||
dwFileAttributes: ULONG
|
||||
ftCreationTime: FILETIME
|
||||
ftLastAccessTime: FILETIME
|
||||
ftLastWriteTime: FILETIME
|
||||
nFileSizeHigh: ULONG
|
||||
nFileSizeLow: ULONG
|
||||
dwReserved0: ULONG
|
||||
dwReserved1: ULONG
|
||||
cFileName: t.CArray[t.CUInt16T, 260]
|
||||
cAlternateFileName: t.CArray[t.CUInt16T, 14]
|
||||
|
||||
def CreateFileA(lpFileName: LPCSTR, dwDesiredAccess: ULONG, dwShareMode: ULONG, lpSecurityAttributes: SECURITY_ATTRIBUTES | t.CPtr, dwCreationDisposition: ULONG, dwFlagsAndAttributes: ULONG, hTemplateFile: HANDLE) -> HANDLE | t.State: pass
|
||||
|
||||
def CreateFileW(lpFileName: LPCWSTR, dwDesiredAccess: ULONG, dwShareMode: ULONG, lpSecurityAttributes: SECURITY_ATTRIBUTES | t.CPtr, dwCreationDisposition: ULONG, dwFlagsAndAttributes: ULONG, hTemplateFile: HANDLE) -> HANDLE | t.State: pass
|
||||
|
||||
def ReadFile(hFile: HANDLE, lpBuffer: VOIDPTR, nNumberOfBytesToRead: ULONG, lpNumberOfBytesRead: ULONG | t.CPtr, lpOverlapped: OVERLAPPED | t.CPtr) -> BOOL | t.State: pass
|
||||
|
||||
def WriteFile(hFile: HANDLE, lpBuffer: t.CConst | VOIDPTR, nNumberOfBytesToWrite: ULONG, lpNumberOfBytesWritten: ULONG | t.CPtr, lpOverlapped: OVERLAPPED | t.CPtr) -> BOOL | t.State: pass
|
||||
|
||||
def SetFilePointer(hFile: HANDLE, lDistanceToMove: LONG, lpDistanceToMoveHigh: LONG | t.CPtr, dwMoveMethod: ULONG) -> LONG | t.State: pass
|
||||
|
||||
def SetFilePointerEx(hFile: HANDLE, liDistanceToMove: LARGE_INTEGER | t.CPtr, lpNewFilePointer: LARGE_INTEGER | t.CPtr, dwMoveMethod: ULONG) -> BOOL | t.State: pass
|
||||
|
||||
def GetFileSize(hFile: HANDLE, lpFileSizeHigh: ULONG | t.CPtr) -> ULONG | t.State: pass
|
||||
|
||||
def GetFileSizeEx(hFile: HANDLE, lpFileSize: LARGE_INTEGER | t.CPtr) -> BOOL | t.State: pass
|
||||
|
||||
def SetEndOfFile(hFile: HANDLE) -> BOOL | t.State: pass
|
||||
|
||||
def FlushFileBuffers(hFile: HANDLE) -> BOOL | t.State: pass
|
||||
|
||||
def GetFileType(hFile: HANDLE) -> ULONG | t.State: pass
|
||||
|
||||
def GetFileAttributesA(lpFileName: LPCSTR) -> ULONG | t.State: pass
|
||||
|
||||
def GetFileAttributesW(lpFileName: LPCWSTR) -> ULONG | t.State: pass
|
||||
|
||||
def SetFileAttributesA(lpFileName: LPCSTR, dwFileAttributes: ULONG) -> BOOL | t.State: pass
|
||||
|
||||
def SetFileAttributesW(lpFileName: LPCWSTR, dwFileAttributes: ULONG) -> BOOL | t.State: pass
|
||||
|
||||
def DeleteFileA(lpFileName: LPCSTR) -> BOOL | t.State: pass
|
||||
|
||||
def DeleteFileW(lpFileName: LPCWSTR) -> BOOL | t.State: pass
|
||||
|
||||
def MoveFileA(lpExistingFileName: LPCSTR, lpNewFileName: LPCSTR) -> BOOL | t.State: pass
|
||||
|
||||
def MoveFileW(lpExistingFileName: LPCWSTR, lpNewFileName: LPCWSTR) -> BOOL | t.State: pass
|
||||
|
||||
def MoveFileExA(lpExistingFileName: LPCSTR, lpNewFileName: LPCSTR, dwFlags: ULONG) -> BOOL | t.State: pass
|
||||
|
||||
def MoveFileExW(lpExistingFileName: LPCWSTR, lpNewFileName: LPCWSTR, dwFlags: ULONG) -> BOOL | t.State: pass
|
||||
|
||||
def CopyFileA(lpExistingFileName: LPCSTR, lpNewFileName: LPCSTR, bFailIfExists: BOOL) -> BOOL | t.State: pass
|
||||
|
||||
def CopyFileW(lpExistingFileName: LPCWSTR, lpNewFileName: LPCWSTR, bFailIfExists: BOOL) -> BOOL | t.State: pass
|
||||
|
||||
def CreateDirectoryA(lpPathName: LPCSTR, lpSecurityAttributes: SECURITY_ATTRIBUTES | t.CPtr) -> BOOL | t.State: pass
|
||||
|
||||
def CreateDirectoryW(lpPathName: LPCWSTR, lpSecurityAttributes: SECURITY_ATTRIBUTES | t.CPtr) -> BOOL | t.State: pass
|
||||
|
||||
def RemoveDirectoryA(lpPathName: LPCSTR) -> BOOL | t.State: pass
|
||||
|
||||
def RemoveDirectoryW(lpPathName: LPCWSTR) -> BOOL | t.State: pass
|
||||
|
||||
def FindFirstFileA(lpFileName: LPCSTR, lpFindFileData: WIN32_FIND_DATAA | t.CPtr) -> HANDLE | t.State: pass
|
||||
|
||||
def FindFirstFileW(lpFileName: LPCWSTR, lpFindFileData: WIN32_FIND_DATAW | t.CPtr) -> HANDLE | t.State: pass
|
||||
|
||||
def FindNextFileA(hFindFile: HANDLE, lpFindFileData: WIN32_FIND_DATAA | t.CPtr) -> BOOL | t.State: pass
|
||||
|
||||
def FindNextFileW(hFindFile: HANDLE, lpFindFileData: WIN32_FIND_DATAW | t.CPtr) -> BOOL | t.State: pass
|
||||
|
||||
def FindClose(hFindFile: HANDLE) -> BOOL | t.State: pass
|
||||
|
||||
def GetStdHandle(nStdHandle: ULONG) -> HANDLE | t.State: pass
|
||||
|
||||
def SetStdHandle(nStdHandle: ULONG, hHandle: HANDLE) -> BOOL | t.State: pass
|
||||
|
||||
def GetFileInformationByHandle(hFile: HANDLE, lpFileInformation: BY_HANDLE_FILE_INFORMATION | t.CPtr) -> BOOL | t.State: pass
|
||||
|
||||
def LockFile(hFile: HANDLE, dwFileOffsetLow: ULONG, dwFileOffsetHigh: ULONG, nNumberOfBytesToLockLow: ULONG, nNumberOfBytesToLockHigh: ULONG) -> BOOL | t.State: pass
|
||||
|
||||
def UnlockFile(hFile: HANDLE, dwFileOffsetLow: ULONG, dwFileOffsetHigh: ULONG, nNumberOfBytesToUnlockLow: ULONG, nNumberOfBytesToUnlockHigh: ULONG) -> BOOL | t.State: pass
|
||||
|
||||
def GetTempPathA(nBufferLength: ULONG, lpBuffer: CHARPTR) -> ULONG | t.State: pass
|
||||
|
||||
def GetTempPathW(nBufferLength: ULONG, lpBuffer: WCHARPTR) -> ULONG | t.State: pass
|
||||
|
||||
def GetTempFileNameA(lpPathName: LPCSTR, lpPrefixString: LPCSTR, uUnique: UINT, lpTempFileName: CHARPTR) -> UINT | t.State: pass
|
||||
|
||||
def GetTempFileNameW(lpPathName: LPCWSTR, lpPrefixString: LPCWSTR, uUnique: UINT, lpTempFileName: WCHARPTR) -> UINT | t.State: pass
|
||||
|
||||
def GetCurrentDirectoryA(nBufferLength: ULONG, lpBuffer: CHARPTR) -> ULONG | t.State: pass
|
||||
|
||||
def GetCurrentDirectoryW(nBufferLength: ULONG, lpBuffer: WCHARPTR) -> ULONG | t.State: pass
|
||||
|
||||
def SetCurrentDirectoryA(lpPathName: LPCSTR) -> BOOL | t.State: pass
|
||||
|
||||
def SetCurrentDirectoryW(lpPathName: LPCWSTR) -> BOOL | t.State: pass
|
||||
|
||||
def GetModuleFileNameA(hModule: HANDLE, lpFilename: CHARPTR, nSize: ULONG) -> ULONG | t.State: pass
|
||||
|
||||
def GetModuleFileNameW(hModule: HANDLE, lpFilename: WCHARPTR, nSize: ULONG) -> ULONG | t.State: pass
|
||||
|
||||
|
||||
HANDLE_FLAG_INHERIT: t.CDefine = 0x00000001
|
||||
HANDLE_FLAG_PROTECT_FROM_CLOSE: t.CDefine = 0x00000002
|
||||
|
||||
def CreatePipe(hReadPipe: HANDLE | t.CPtr, hWritePipe: HANDLE | t.CPtr, lpPipeAttributes: SECURITY_ATTRIBUTES | t.CPtr, nSize: ULONG) -> BOOL | t.State: pass
|
||||
|
||||
def SetHandleInformation(hObject: HANDLE, dwMask: ULONG, dwFlags: ULONG) -> BOOL | t.State: pass
|
||||
|
||||
def DuplicateHandle(hSourceProcessHandle: HANDLE, hSourceHandle: HANDLE, hTargetProcessHandle: HANDLE, lpTargetHandle: HANDLE | t.CPtr, dwDesiredAccess: ULONG, bInheritHandle: BOOL, dwOptions: ULONG) -> BOOL | t.State: pass
|
||||
|
||||
|
||||
DUPLICATE_SAME_ACCESS: t.CDefine = 0x00000002
|
||||
@@ -0,0 +1,12 @@
|
||||
from stdint import *
|
||||
import w32.win32console
|
||||
import t, c
|
||||
from t import CInt, CExport
|
||||
import mbuddytest
|
||||
|
||||
|
||||
def main() -> CInt | CExport:
|
||||
w32.win32console.SetConsoleCP(65001)
|
||||
w32.win32console.SetConsoleOutputCP(65001)
|
||||
|
||||
return mbuddytest.mbuddy_main()
|
||||
@@ -0,0 +1,535 @@
|
||||
import t, c
|
||||
from t import CInt, CPtr, CChar, CUInt8T, CUInt32T, CUInt64T, CSizeT
|
||||
import viperlib
|
||||
import viperio
|
||||
import stdlib
|
||||
import memhub
|
||||
import string
|
||||
import testcheck
|
||||
import w32.win32process
|
||||
import w32.win32sync
|
||||
import w32.win32base
|
||||
|
||||
|
||||
# 线程函数: 在共享 MBuddy 上执行 alloc/free (测试 spinlock 线程安全)
|
||||
def _thread_alloc_free(param: t.CVoid | t.CPtr) -> t.CUInt32T:
|
||||
bd: memhub.MemBuddy | t.CPtr = (memhub.MemBuddy | t.CPtr)(param)
|
||||
i: CInt
|
||||
for i in range(100):
|
||||
p: bytes = bd.alloc(32)
|
||||
if p != None:
|
||||
p_c: CUInt8T | CPtr = CPtr(p)
|
||||
p_c[0] = CUInt8T(i & 0xFF)
|
||||
bd.free(p)
|
||||
return 0
|
||||
|
||||
|
||||
def mbuddy_main() -> CInt:
|
||||
buf: bytes = stdlib.malloc(256)
|
||||
|
||||
testcheck.begin("BuddyTest: 伙伴系统内存分配器测试")
|
||||
|
||||
# === 基础 alloc/free 测试 ===
|
||||
testcheck.section("基础 alloc/free")
|
||||
arena: bytes = stdlib.malloc(65536)
|
||||
bd: memhub.MemBuddy | CPtr = memhub.MemBuddy(arena, 65536)
|
||||
|
||||
viperlib.snprintf(buf, 256, "stats=%lu, free_count=%lu", bd.stats(), bd.free_count())
|
||||
testcheck.info(buf)
|
||||
|
||||
p1: bytes = bd.alloc(16)
|
||||
p2: bytes = bd.alloc(64)
|
||||
p3: bytes = bd.alloc(256)
|
||||
testcheck.check(p1 != None and p2 != None and p3 != None,
|
||||
"3 allocs OK", "alloc FAILED")
|
||||
|
||||
# 写入数据验证指针可用
|
||||
p_c: CUInt8T | CPtr = CPtr(p1)
|
||||
p_c[0] = CUInt8T(0xAB)
|
||||
p_c[1] = CUInt8T(0xCD)
|
||||
viperlib.snprintf(buf, 256, "p1[0]=0x%x p1[1]=0x%x", p_c[0], p_c[1])
|
||||
testcheck.info(buf)
|
||||
testcheck.check(p_c[0] == CUInt8T(0xAB) and p_c[1] == CUInt8T(0xCD),
|
||||
"write/read OK", "write/read FAILED")
|
||||
|
||||
bd.free(p1)
|
||||
bd.free(p2)
|
||||
bd.free(p3)
|
||||
testcheck.ok("3 frees OK")
|
||||
|
||||
# 释放后验证合并: free_count 应回到 1 (单个大块)
|
||||
testcheck.check(bd.free_count() == 1,
|
||||
"coalesce: free_count=1 OK", "coalesce: free_count != 1")
|
||||
|
||||
# 合并后应能分配大块
|
||||
big: bytes = bd.alloc(16000)
|
||||
testcheck.check(big != None, "big alloc OK", "big alloc FAILED")
|
||||
bd.free(big)
|
||||
|
||||
stdlib.free(arena)
|
||||
|
||||
# === calloc 测试 (验证清零) ===
|
||||
testcheck.section("calloc 清零")
|
||||
arena2: bytes = stdlib.malloc(4096)
|
||||
bd2: memhub.MemBuddy | CPtr = memhub.MemBuddy(arena2, 4096)
|
||||
|
||||
dirty: bytes = bd2.alloc(64)
|
||||
d_c: CUInt8T | CPtr = CPtr(dirty)
|
||||
i: CInt
|
||||
for i in range(64):
|
||||
d_c[i] = CUInt8T(0xFF)
|
||||
bd2.free(dirty)
|
||||
|
||||
cl: bytes = bd2.calloc(8, 8)
|
||||
if cl != None:
|
||||
cl_c: CUInt8T | CPtr = CPtr(cl)
|
||||
all_zero: CInt = 1
|
||||
j: CInt
|
||||
for j in range(64):
|
||||
if cl_c[j] != 0:
|
||||
all_zero = 0
|
||||
break
|
||||
testcheck.check(all_zero == 1, "calloc zeroed OK", "calloc NOT zeroed")
|
||||
bd2.free(cl)
|
||||
else:
|
||||
testcheck.fail("calloc FAILED")
|
||||
|
||||
stdlib.free(arena2)
|
||||
|
||||
# === realloc 扩展测试 ===
|
||||
testcheck.section("realloc 扩展")
|
||||
arena3: bytes = stdlib.malloc(4096)
|
||||
bd3: memhub.MemBuddy | CPtr = memhub.MemBuddy(arena3, 4096)
|
||||
|
||||
rp: bytes = bd3.alloc(32)
|
||||
rp_c: CUInt8T | CPtr = CPtr(rp)
|
||||
k: CInt
|
||||
for k in range(32):
|
||||
rp_c[k] = CUInt8T(k + 1)
|
||||
|
||||
rp2: bytes = bd3.realloc(rp, 128)
|
||||
if rp2 != None:
|
||||
rp2_c: CUInt8T | CPtr = CPtr(rp2)
|
||||
ok: CInt = 1
|
||||
m: CInt
|
||||
for m in range(32):
|
||||
if rp2_c[m] != CUInt8T(m + 1):
|
||||
ok = 0
|
||||
break
|
||||
testcheck.check(ok == 1, "realloc grow data preserved OK", "realloc grow data LOST")
|
||||
bd3.free(rp2)
|
||||
else:
|
||||
testcheck.fail("realloc grow FAILED")
|
||||
|
||||
stdlib.free(arena3)
|
||||
|
||||
# === 原地收缩测试 (验证无泄漏) ===
|
||||
testcheck.section("原地收缩 (realloc shrink)")
|
||||
arena_shrink: bytes = stdlib.malloc(4096)
|
||||
bds: memhub.MemBuddy | CPtr = memhub.MemBuddy(arena_shrink, 4096)
|
||||
|
||||
sp: bytes = bds.alloc(256)
|
||||
testcheck.check(sp != None, "alloc 256 OK", "alloc 256 FAILED")
|
||||
|
||||
fc_before: CSizeT = bds.free_count()
|
||||
# realloc 到更小尺寸: 256+8=264 -> order 4 (512); 32+8=40 -> order 1 (64)
|
||||
# new_order(1) <= old_order(4), 应原地返回同一指针
|
||||
sp2: bytes = bds.realloc(sp, 32)
|
||||
fc_after: CSizeT = bds.free_count()
|
||||
|
||||
testcheck.check(sp2 == sp, "shrink same ptr OK", "shrink ptr changed")
|
||||
testcheck.check(fc_after == fc_before, "shrink no leak OK", "shrink LEAKED blocks")
|
||||
|
||||
# 验证数据仍可读写
|
||||
sp_c: CUInt8T | CPtr = CPtr(sp2)
|
||||
sp_c[0] = CUInt8T(0x42)
|
||||
testcheck.check(sp_c[0] == CUInt8T(0x42), "shrink data OK", "shrink data FAILED")
|
||||
|
||||
bds.free(sp2)
|
||||
testcheck.check(bds.free_count() == 1, "shrink+free coalesce OK", "shrink+free coalesce FAILED")
|
||||
|
||||
stdlib.free(arena_shrink)
|
||||
|
||||
# === 边界情况测试 ===
|
||||
testcheck.section("边界情况")
|
||||
arena4: bytes = stdlib.malloc(4096)
|
||||
bd4: memhub.MemBuddy | CPtr = memhub.MemBuddy(arena4, 4096)
|
||||
|
||||
# alloc(0) 应返回 None
|
||||
z: bytes = bd4.alloc(0)
|
||||
testcheck.check(z == None, "alloc(0)=None OK", "alloc(0) should be None")
|
||||
|
||||
# free(None) 应安全
|
||||
bd4.free(None)
|
||||
testcheck.ok("free(None) safe")
|
||||
|
||||
# realloc(None, size) 等价于 alloc
|
||||
rn: bytes = bd4.realloc(None, 32)
|
||||
testcheck.check(rn != None, "realloc(None)=alloc OK", "realloc(None) FAILED")
|
||||
bd4.free(rn)
|
||||
|
||||
# realloc(ptr, 0) 等价于 free
|
||||
rz: bytes = bd4.alloc(32)
|
||||
rz2: bytes = bd4.realloc(rz, 0)
|
||||
testcheck.check(rz2 == None, "realloc(ptr,0)=free OK", "realloc(ptr,0) should be None")
|
||||
|
||||
stdlib.free(arena4)
|
||||
|
||||
# === 非法指针防护测试 ===
|
||||
testcheck.section("非法指针防护")
|
||||
arena5: bytes = stdlib.malloc(4096)
|
||||
bd5: memhub.MemBuddy | CPtr = memhub.MemBuddy(arena5, 4096)
|
||||
|
||||
valid: bytes = bd5.alloc(32)
|
||||
testcheck.check(valid != None, "alloc for illegal test OK", "alloc FAILED")
|
||||
|
||||
# 1. free 随机地址 (地址 1)
|
||||
bd5.free(t.CVoid(t.CUInt64T(1), t.CPtr))
|
||||
testcheck.ok("free(addr=1) ignored")
|
||||
|
||||
# 2. free NULL
|
||||
bd5.free(None)
|
||||
testcheck.ok("free(NULL) ignored")
|
||||
|
||||
# 3. free 越界指针 (arena 之前)
|
||||
bd5.free(t.CVoid(t.CUInt64T(arena5), t.CPtr))
|
||||
testcheck.ok("free(before arena) ignored")
|
||||
|
||||
# 4. free 越界指针 (arena 之后)
|
||||
bd5.free(t.CVoid(t.CUInt64T(arena5) + 99999, t.CPtr))
|
||||
testcheck.ok("free(after arena) ignored")
|
||||
|
||||
# 5. free 未对齐指针 (arena + 1, 在 mem 区域内但不对齐)
|
||||
bd5.free(t.CVoid(t.CUInt64T(bd5.mem) + 1, t.CPtr))
|
||||
testcheck.ok("free(misaligned) ignored")
|
||||
|
||||
# 6. 验证合法 free 仍正常工作 (释放后应能再次分配)
|
||||
bd5.free(valid)
|
||||
retry5: bytes = bd5.alloc(32)
|
||||
testcheck.check(retry5 != None, "valid free still works OK", "valid free BROKEN")
|
||||
if retry5 != None:
|
||||
bd5.free(retry5)
|
||||
|
||||
# 7. realloc 非法指针应返回 None
|
||||
r_illegal: bytes = bd5.realloc(t.CVoid(t.CUInt64T(1), t.CPtr), 64)
|
||||
testcheck.check(r_illegal == None, "realloc(illegal)=None OK", "realloc(illegal) should be None")
|
||||
|
||||
stdlib.free(arena5)
|
||||
|
||||
# === OOM 内存耗尽测试 ===
|
||||
testcheck.section("OOM 内存耗尽")
|
||||
arena6: bytes = stdlib.malloc(4096)
|
||||
bd6: memhub.MemBuddy | CPtr = memhub.MemBuddy(arena6, 4096)
|
||||
|
||||
# 持续分配直到失败
|
||||
alloc_count: CInt = 0
|
||||
ptrs_arr: bytes = stdlib.malloc(8 * 256) # 存储指针的数组
|
||||
ptrs: CUInt64T | CPtr = CPtr(ptrs_arr)
|
||||
|
||||
while alloc_count < 256:
|
||||
p: bytes = bd6.alloc(32)
|
||||
if p == None:
|
||||
break
|
||||
ptrs[alloc_count] = t.CUInt64T(p)
|
||||
alloc_count += 1
|
||||
|
||||
viperlib.snprintf(buf, 256, "allocated %d blocks before OOM", alloc_count)
|
||||
testcheck.info(buf)
|
||||
testcheck.check(alloc_count > 0, "OOM: got some allocs OK", "OOM: no allocs at all")
|
||||
|
||||
# 尝试再分配应失败
|
||||
oom_p: bytes = bd6.alloc(32)
|
||||
testcheck.check(oom_p == None, "OOM: alloc fails OK", "OOM: alloc should fail")
|
||||
|
||||
# 释放一个块后应能再次分配
|
||||
if alloc_count > 0:
|
||||
first_ptr: bytes = t.CVoid(ptrs[0], t.CPtr)
|
||||
bd6.free(first_ptr)
|
||||
retry: bytes = bd6.alloc(32)
|
||||
testcheck.check(retry != None, "OOM: free+alloc OK", "OOM: free+alloc FAILED")
|
||||
if retry != None:
|
||||
bd6.free(retry)
|
||||
|
||||
# 释放所有块
|
||||
idx: CInt = 1
|
||||
while idx < alloc_count:
|
||||
cur_p: bytes = t.CVoid(ptrs[idx], t.CPtr)
|
||||
bd6.free(cur_p)
|
||||
idx += 1
|
||||
|
||||
# 全部释放后应能合并回单个大块
|
||||
testcheck.check(bd6.free_count() == 1,
|
||||
"OOM: full coalesce OK", "OOM: free_count != 1 after full free")
|
||||
|
||||
stdlib.free(ptrs_arr)
|
||||
stdlib.free(arena6)
|
||||
|
||||
# === 空闲链表状态测试 ===
|
||||
testcheck.section("空闲链表状态")
|
||||
arena7: bytes = stdlib.malloc(4096)
|
||||
bd7: memhub.MemBuddy | CPtr = memhub.MemBuddy(arena7, 4096)
|
||||
|
||||
# 初始: 1 个大块
|
||||
testcheck.check(bd7.free_count() == 1, "init: 1 free block OK", "init: free_count != 1")
|
||||
|
||||
# 分配后: 空闲块数应增加 (分裂产生多个小块)
|
||||
a1: bytes = bd7.alloc(32)
|
||||
fc1: CSizeT = bd7.free_count()
|
||||
viperlib.snprintf(buf, 256, "after alloc(32): free_count=%lu", fc1)
|
||||
testcheck.info(buf)
|
||||
testcheck.check(fc1 > 1, "after alloc: split OK", "after alloc: no split")
|
||||
|
||||
# 再分配
|
||||
a2: bytes = bd7.alloc(32)
|
||||
fc2: CSizeT = bd7.free_count()
|
||||
testcheck.check(fc2 >= 1, "after 2nd alloc: free >= 1 OK", "after 2nd alloc: free < 1")
|
||||
|
||||
# 释放 a1: 空闲块数应增加
|
||||
bd7.free(a1)
|
||||
fc3: CSizeT = bd7.free_count()
|
||||
testcheck.check(fc3 > fc2, "after free a1: free increased OK", "after free a1: free not increased")
|
||||
|
||||
# 释放 a2: 应合并, 空闲块数回到 1
|
||||
bd7.free(a2)
|
||||
testcheck.check(bd7.free_count() == 1,
|
||||
"after free all: coalesced to 1 OK", "after free all: free_count != 1")
|
||||
|
||||
stdlib.free(arena7)
|
||||
|
||||
# === with 上下文管理器测试 ===
|
||||
testcheck.section("with 上下文管理器")
|
||||
arena8: bytes = stdlib.malloc(4096)
|
||||
with memhub.MemBuddy(arena8, 4096) as wbd:
|
||||
wp1: bytes = wbd.alloc(32)
|
||||
wp2: bytes = wbd.alloc(64)
|
||||
testcheck.check(wp1 != None and wp2 != None,
|
||||
"with: allocs OK", "with: allocs FAILED")
|
||||
# 退出 with 块时 __exit__ 自动 reset
|
||||
|
||||
# 退出后重新进入,验证 reset 生效
|
||||
with memhub.MemBuddy(arena8, 4096) as wbd2:
|
||||
wp3: bytes = wbd2.alloc(1024)
|
||||
testcheck.check(wp3 != None, "with: reset+realloc OK", "with: reset+realloc FAILED")
|
||||
|
||||
stdlib.free(arena8)
|
||||
|
||||
# === 双重 free 检测测试 ===
|
||||
testcheck.section("双重 free 检测")
|
||||
arena_df: bytes = stdlib.malloc(4096)
|
||||
bd_df: memhub.MemBuddy | CPtr = memhub.MemBuddy(arena_df, 4096)
|
||||
|
||||
df: bytes = bd_df.alloc(64)
|
||||
testcheck.check(df != None, "df: alloc OK", "df: alloc FAILED")
|
||||
|
||||
# 第一次 free
|
||||
bd_df.free(df)
|
||||
fc_df1: CSizeT = bd_df.free_count()
|
||||
testcheck.ok("first free OK")
|
||||
|
||||
# 第二次 free (双重 free) — 应被静默拒绝
|
||||
bd_df.free(df)
|
||||
fc_df2: CSizeT = bd_df.free_count()
|
||||
testcheck.check(fc_df2 == fc_df1, "double free rejected OK", "double free CORRUPTED state")
|
||||
|
||||
# 验证分配器仍正常工作
|
||||
df2: bytes = bd_df.alloc(64)
|
||||
testcheck.check(df2 != None, "df: alloc after double-free OK", "df: alloc after double-free FAILED")
|
||||
if df2 != None:
|
||||
bd_df.free(df2)
|
||||
|
||||
stdlib.free(arena_df)
|
||||
|
||||
# === 自检功能测试 ===
|
||||
testcheck.section("自检功能")
|
||||
arena_sc: bytes = stdlib.malloc(4096)
|
||||
bd_sc: memhub.MemBuddy | CPtr = memhub.MemBuddy(arena_sc, 4096)
|
||||
|
||||
# 初始状态自检
|
||||
testcheck.check(bd_sc.self_check() == 0, "self_check init OK", "self_check init FAILED")
|
||||
|
||||
# 分配后自检
|
||||
sc_p1: bytes = bd_sc.alloc(32)
|
||||
sc_p2: bytes = bd_sc.alloc(128)
|
||||
testcheck.check(bd_sc.self_check() == 0, "self_check after alloc OK", "self_check after alloc FAILED")
|
||||
|
||||
# 部分释放后自检
|
||||
bd_sc.free(sc_p1)
|
||||
testcheck.check(bd_sc.self_check() == 0, "self_check after partial free OK", "self_check after partial free FAILED")
|
||||
|
||||
# 全部释放后自检 (应合并回单个大块)
|
||||
bd_sc.free(sc_p2)
|
||||
testcheck.check(bd_sc.self_check() == 0, "self_check after full free OK", "self_check after full free FAILED")
|
||||
|
||||
# 双重 free 后自检 (验证状态未损坏)
|
||||
sc_p3: bytes = bd_sc.alloc(64)
|
||||
bd_sc.free(sc_p3)
|
||||
bd_sc.free(sc_p3) # 双重 free,应被拒绝
|
||||
testcheck.check(bd_sc.self_check() == 0, "self_check after double-free OK", "self_check after double-free CORRUPTED")
|
||||
|
||||
stdlib.free(arena_sc)
|
||||
|
||||
# === 并发多线程测试 (spinlock) ===
|
||||
testcheck.section("并发多线程 (spinlock)")
|
||||
arena_mt: bytes = stdlib.malloc(65536)
|
||||
bd_mt: memhub.MemBuddy | CPtr = memhub.MemBuddy(arena_mt, 65536)
|
||||
|
||||
NUM_THREADS: CInt = 4
|
||||
handles_arr: bytes = stdlib.malloc(8 * 4)
|
||||
handles: CUInt64T | CPtr = CPtr(handles_arr)
|
||||
tid: CUInt32T = 0
|
||||
|
||||
# 创建 4 个线程并发 alloc/free
|
||||
t_idx: CInt
|
||||
for t_idx in range(NUM_THREADS):
|
||||
h: bytes = w32.win32process.CreateThread(None, 0, _thread_alloc_free, t.CVoid(t.CUInt64T(bd_mt), t.CPtr), 0, c.Addr(tid))
|
||||
handles[t_idx] = CUInt64T(h)
|
||||
|
||||
# 等待所有线程完成
|
||||
for t_idx in range(NUM_THREADS):
|
||||
h: bytes = t.CVoid(handles[t_idx], t.CPtr)
|
||||
w32.win32sync.WaitForSingleObject(h, w32.win32base.INFINITE)
|
||||
w32.win32base.CloseHandle(h)
|
||||
|
||||
# 验证分配器状态: 自检通过,所有块已合并
|
||||
testcheck.check(bd_mt.self_check() == 0, "mt: self_check OK", "mt: self_check FAILED")
|
||||
testcheck.check(bd_mt.free_count() == 1, "mt: free_count=1 OK", "mt: free_count != 1 (leaked)")
|
||||
|
||||
viperlib.snprintf(buf, 256, "mt: free_count=%lu", bd_mt.free_count())
|
||||
testcheck.info(buf)
|
||||
|
||||
stdlib.free(handles_arr)
|
||||
stdlib.free(arena_mt)
|
||||
|
||||
# === 极端边界测试 ===
|
||||
testcheck.section("极端边界")
|
||||
|
||||
# 1. 分配尺寸恰巧是块边界
|
||||
arena_ex: bytes = stdlib.malloc(4096)
|
||||
bd_ex: memhub.MemBuddy | CPtr = memhub.MemBuddy(arena_ex, 4096)
|
||||
|
||||
# 24 + 8 = 32 = MIN_BLOCK, 恰好填满 order 0 块
|
||||
exact_fit: bytes = bd_ex.alloc(24)
|
||||
testcheck.check(exact_fit != None, "exact fit order 0 OK", "exact fit order 0 FAILED")
|
||||
|
||||
# 25 + 8 = 33 > 32, 需要 order 1 (64 字节)
|
||||
over_fit: bytes = bd_ex.alloc(25)
|
||||
testcheck.check(over_fit != None, "over by 1 byte OK", "over by 1 byte FAILED")
|
||||
|
||||
bd_ex.free(exact_fit)
|
||||
bd_ex.free(over_fit)
|
||||
testcheck.check(bd_ex.free_count() == 1, "boundary: coalesce OK", "boundary: coalesce FAILED")
|
||||
|
||||
# 2. 单次分配接近 arena 上限
|
||||
max_usable: CSizeT = bd_ex.mem_size - 8
|
||||
viperlib.snprintf(buf, 256, "mem_size=%lu, max_usable=%lu", bd_ex.mem_size, max_usable)
|
||||
testcheck.info(buf)
|
||||
|
||||
# 恰好用完整个 arena
|
||||
exact_max: bytes = bd_ex.alloc(max_usable)
|
||||
testcheck.check(exact_max != None, "exact max alloc OK", "exact max alloc FAILED")
|
||||
testcheck.check(bd_ex.free_count() == 0, "max alloc: arena full OK", "max alloc: arena not full")
|
||||
|
||||
bd_ex.free(exact_max)
|
||||
testcheck.check(bd_ex.free_count() == 1, "max free: coalesce OK", "max free: coalesce FAILED")
|
||||
|
||||
# 再次分配同样大小 — 验证合并后可再次使用
|
||||
exact_max2: bytes = bd_ex.alloc(max_usable)
|
||||
testcheck.check(exact_max2 != None, "exact max re-alloc OK", "exact max re-alloc FAILED")
|
||||
bd_ex.free(exact_max2)
|
||||
|
||||
# 3. 分配超过 arena 上限 — 应失败
|
||||
over_max: bytes = bd_ex.alloc(bd_ex.mem_size)
|
||||
testcheck.check(over_max == None, "over max: fails OK", "over max: should fail")
|
||||
|
||||
over_max2: bytes = bd_ex.alloc(max_usable + 1)
|
||||
testcheck.check(over_max2 == None, "max+1: fails OK", "max+1: should fail")
|
||||
|
||||
stdlib.free(arena_ex)
|
||||
|
||||
# 4. Arena 太小 (仅够 free_lists 开销, 264 字节)
|
||||
arena_tiny: bytes = stdlib.malloc(264)
|
||||
bd_tiny: memhub.MemBuddy | CPtr = memhub.MemBuddy(arena_tiny, 264)
|
||||
testcheck.check(bd_tiny.stats() == 0, "tiny arena: stats=0 OK", "tiny arena: stats != 0")
|
||||
tiny_p: bytes = bd_tiny.alloc(32)
|
||||
testcheck.check(tiny_p == None, "tiny arena: alloc fails OK", "tiny arena: should fail")
|
||||
stdlib.free(arena_tiny)
|
||||
|
||||
# 5. Arena 刚好够一个最小块 (264 + 32 = 296)
|
||||
arena_one: bytes = stdlib.malloc(296)
|
||||
bd_one: memhub.MemBuddy | CPtr = memhub.MemBuddy(arena_one, 296)
|
||||
testcheck.check(bd_one.stats() == 32, "one block: stats=32 OK", "one block: stats != 32")
|
||||
|
||||
one_p: bytes = bd_one.alloc(24)
|
||||
testcheck.check(one_p != None, "one block: alloc OK", "one block: alloc FAILED")
|
||||
|
||||
one_p2: bytes = bd_one.alloc(24)
|
||||
testcheck.check(one_p2 == None, "one block: OOM OK", "one block: should be OOM")
|
||||
|
||||
bd_one.free(one_p)
|
||||
testcheck.check(bd_one.free_count() == 1, "one block: free OK", "one block: free FAILED")
|
||||
stdlib.free(arena_one)
|
||||
|
||||
# 6. 2 的幂 arena vs 非 2 的幂 arena
|
||||
arena_pow2: bytes = stdlib.malloc(512)
|
||||
bd_pow2: memhub.MemBuddy | CPtr = memhub.MemBuddy(arena_pow2, 512)
|
||||
# 512 - 264 = 248, largest_pow2(248) = 128
|
||||
testcheck.check(bd_pow2.stats() == 128, "pow2 arena: stats=128 OK", "pow2 arena: stats != 128")
|
||||
stdlib.free(arena_pow2)
|
||||
|
||||
arena_non2: bytes = stdlib.malloc(500)
|
||||
bd_non2: memhub.MemBuddy | CPtr = memhub.MemBuddy(arena_non2, 500)
|
||||
# 500 - 264 = 236, largest_pow2(236) = 128
|
||||
testcheck.check(bd_non2.stats() == 128, "non-pow2 arena: stats=128 OK", "non-pow2 arena: stats != 128")
|
||||
stdlib.free(arena_non2)
|
||||
|
||||
# 7. 压力测试: 反复 alloc/free 同一尺寸 1000 次
|
||||
arena_stress: bytes = stdlib.malloc(4096)
|
||||
bd_stress: memhub.MemBuddy | CPtr = memhub.MemBuddy(arena_stress, 4096)
|
||||
|
||||
s: CInt
|
||||
for s in range(1000):
|
||||
sp: bytes = bd_stress.alloc(64)
|
||||
if sp != None:
|
||||
sp_c: CUInt8T | CPtr = CPtr(sp)
|
||||
sp_c[0] = CUInt8T(s & 0xFF)
|
||||
bd_stress.free(sp)
|
||||
|
||||
testcheck.check(bd_stress.self_check() == 0, "stress: self_check OK", "stress: self_check FAILED")
|
||||
testcheck.check(bd_stress.free_count() == 1, "stress: free_count=1 OK", "stress: leaked")
|
||||
stdlib.free(arena_stress)
|
||||
|
||||
# 8. 分配全部最小块然后全部释放
|
||||
arena_fill: bytes = stdlib.malloc(4096)
|
||||
bd_fill: memhub.MemBuddy | CPtr = memhub.MemBuddy(arena_fill, 4096)
|
||||
|
||||
fill_count: CInt = 0
|
||||
fill_ptrs_arr: bytes = stdlib.malloc(8 * 256)
|
||||
fill_ptrs: CUInt64T | CPtr = CPtr(fill_ptrs_arr)
|
||||
|
||||
fc: CInt
|
||||
for fc in range(256):
|
||||
fp: bytes = bd_fill.alloc(24)
|
||||
if fp == None:
|
||||
break
|
||||
fill_ptrs[fill_count] = t.CUInt64T(fp)
|
||||
fill_count += 1
|
||||
|
||||
viperlib.snprintf(buf, 256, "fill: %d min blocks allocated", fill_count)
|
||||
testcheck.info(buf)
|
||||
testcheck.check(fill_count > 0, "fill: got blocks OK", "fill: no blocks")
|
||||
testcheck.check(bd_fill.self_check() == 0, "fill: self_check OK", "fill: self_check FAILED")
|
||||
|
||||
# 全部释放
|
||||
fi: CInt
|
||||
for fi in range(fill_count):
|
||||
fp2: bytes = t.CVoid(fill_ptrs[fi], t.CPtr)
|
||||
bd_fill.free(fp2)
|
||||
|
||||
testcheck.check(bd_fill.free_count() == 1, "fill: all freed OK", "fill: leaked after free all")
|
||||
testcheck.check(bd_fill.self_check() == 0, "fill: self_check after free OK", "fill: self_check FAILED")
|
||||
|
||||
stdlib.free(fill_ptrs_arr)
|
||||
stdlib.free(arena_fill)
|
||||
|
||||
stdlib.free(buf)
|
||||
return testcheck.end()
|
||||
@@ -0,0 +1 @@
|
||||
{"w32.win32process": "067c78e9f121dce3", "win32process": "067c78e9f121dce3", "w32.win32sync": "06f53cc594b4ac6c", "win32sync": "06f53cc594b4ac6c", "atom": "271ea3decb810db2", "stdio": "6f62fe05c5ea1ceb", "stdarg": "71e0a3ffcb3ebfad", "w32.win32base": "7e529fe7a078cfef", "win32base": "7e529fe7a078cfef", "stdlib": "90c53dd6db8d41cf", "string": "ab6e54ba9a669f76", "mbuddytest": "b69cdee68f223fef", "w32.win32console": "bbdf3bbd4c3bc28c", "win32console": "bbdf3bbd4c3bc28c", "viperlib": "c3b259b4059f8668", "viperio": "c9f4be41ca1cc2b4", "testcheck": "dd3002730623424b", "memhub": "ee084e9fc6ee413a", "stdint": "f5522571bcce7bcb"}
|
||||
@@ -0,0 +1,29 @@
|
||||
{
|
||||
"$schema": "https://raw.githubusercontent.com/TermiNexus/TransPyC/main/schemas/project-schema.json",
|
||||
"name": "BuddyTest",
|
||||
"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": ["-lmsvcrt", "-lucrt", "-lpthread", "-lmingwex", "-lkernel32", "-Wl,--allow-multiple-definition"],
|
||||
"output": "BuddyTest.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
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
"""
|
||||
Auto-generated Python stub file from w32.fileio.py
|
||||
Module: w32.fileio
|
||||
"""
|
||||
|
||||
|
||||
import t, c
|
||||
from stdint import *
|
||||
import stdio
|
||||
import w32.win32base
|
||||
import w32.win32file
|
||||
|
||||
class MODE(t.CEnum):
|
||||
R = 0
|
||||
W = 1
|
||||
A = 2
|
||||
RP = 3
|
||||
WP = 4
|
||||
AP = 5
|
||||
X = 6
|
||||
XP = 7
|
||||
class FRESULT(t.CEnum):
|
||||
OK = 0
|
||||
ERR = -1
|
||||
ERR_CLOSED = -2
|
||||
ERR_PERM = -3
|
||||
ERR_IO = -4
|
||||
ERR_NOTFOUND = -5
|
||||
|
||||
SEEK_SET: t.CDefine = 0
|
||||
SEEK_CUR: t.CDefine = 1
|
||||
SEEK_END: t.CDefine = 2
|
||||
INVALID_SET_FILE_POINTER: t.CDefine = -1
|
||||
SHARE_READ: t.CDefine = 0x00000001
|
||||
SHARE_WRITE: t.CDefine = 0x00000002
|
||||
SHARE_DELETE: t.CDefine = 0x00000004
|
||||
|
||||
class File:
|
||||
handle: w32.win32base.HANDLE
|
||||
closed: bool
|
||||
can_read: bool
|
||||
can_write: bool
|
||||
is_append: bool
|
||||
_share_mode: ULONG
|
||||
def __init__(self: File, filename: str, mode: ULONG, share: ULONG) -> t.CInt: pass
|
||||
def __enter__(self: File) -> 'File' | t.CPtr: pass
|
||||
def __exit__(self: File) -> t.CInt: pass
|
||||
def read(self: File, buf: bytes, count: ULONG) -> LONG: pass
|
||||
def write(self: File, buf: bytes, count: ULONG) -> LONG: pass
|
||||
def write_str(self: File, s: str) -> LONG: pass
|
||||
def seek(self: File, offset: LONG, origin: ULONG) -> LONG: pass
|
||||
def tell(self: File) -> LONG: pass
|
||||
def close(self: File) -> LONG: pass
|
||||
def flush(self: File) -> LONG: pass
|
||||
def size(self: File) -> LONGLONG: pass
|
||||
def readline(self: File, buf: bytes, max_count: ULONG) -> LONG: pass
|
||||
def read_all(self: File, buf: bytes, max_count: ULONG) -> LONG: pass
|
||||
class FileW:
|
||||
handle: w32.win32base.HANDLE
|
||||
closed: bool
|
||||
can_read: bool
|
||||
can_write: bool
|
||||
is_append: bool
|
||||
_share_mode: ULONG
|
||||
def __init__(self: FileW, filename: w32.win32base.LPCWSTR, mode: ULONG, share: ULONG) -> t.CInt: pass
|
||||
def __enter__(self: FileW) -> 'FileW' | t.CPtr: pass
|
||||
def __exit__(self: FileW) -> t.CInt: pass
|
||||
def read(self: FileW, buf: bytes, count: ULONG) -> LONG: pass
|
||||
def write(self: FileW, buf: bytes, count: ULONG) -> LONG: pass
|
||||
def write_str(self: FileW, s: str) -> LONG: pass
|
||||
def seek(self: FileW, offset: LONG, origin: ULONG) -> LONG: pass
|
||||
def tell(self: FileW) -> LONG: pass
|
||||
def close(self: FileW) -> LONG: pass
|
||||
def flush(self: FileW) -> LONG: pass
|
||||
def size(self: FileW) -> LONGLONG: pass
|
||||
def readline(self: FileW, buf: bytes, max_count: ULONG) -> LONG: pass
|
||||
def read_all(self: FileW, buf: bytes, max_count: ULONG) -> LONG: pass
|
||||
|
||||
def open(filename: str, mode: ULONG, share: ULONG) -> File | t.CPtr: pass
|
||||
|
||||
def openw(filename: LPCWSTR, mode: ULONG, share: ULONG) -> FileW | t.CPtr: pass
|
||||
@@ -0,0 +1,136 @@
|
||||
"""
|
||||
Auto-generated Python stub file from w32.win32process.py
|
||||
Module: w32.win32process
|
||||
"""
|
||||
|
||||
import c
|
||||
|
||||
|
||||
import t
|
||||
from stdint import *
|
||||
from w32.win32base import *
|
||||
|
||||
PROCESS_TERMINATE: t.CDefine = 0x0001
|
||||
PROCESS_CREATE_THREAD: t.CDefine = 0x0002
|
||||
PROCESS_VM_OPERATION: t.CDefine = 0x0008
|
||||
PROCESS_VM_READ: t.CDefine = 0x0010
|
||||
PROCESS_VM_WRITE: t.CDefine = 0x0020
|
||||
PROCESS_QUERY_INFORMATION: t.CDefine = 0x0400
|
||||
PROCESS_ALL_ACCESS: t.CDefine = 0x001FFFFF
|
||||
THREAD_TERMINATE: t.CDefine = 0x0001
|
||||
THREAD_SUSPEND_RESUME: t.CDefine = 0x0002
|
||||
THREAD_GET_CONTEXT: t.CDefine = 0x0008
|
||||
THREAD_SET_CONTEXT: t.CDefine = 0x0010
|
||||
THREAD_QUERY_INFORMATION: t.CDefine = 0x0040
|
||||
THREAD_ALL_ACCESS: t.CDefine = 0x001FFFFF
|
||||
CREATE_SUSPENDED: t.CDefine = 0x00000004
|
||||
CREATE_NEW_CONSOLE: t.CDefine = 0x00000010
|
||||
CREATE_NEW_PROCESS_GROUP: t.CDefine = 0x00000200
|
||||
CREATE_NO_WINDOW: t.CDefine = 0x08000000
|
||||
DETACHED_PROCESS: t.CDefine = 0x00000008
|
||||
STARTF_USESHOWWINDOW: t.CDefine = 0x00000001
|
||||
STARTF_USESTDHANDLES: t.CDefine = 0x00000100
|
||||
SW_HIDE: t.CDefine = 0
|
||||
SW_SHOW: t.CDefine = 5
|
||||
SW_MINIMIZE: t.CDefine = 6
|
||||
NORMAL_PRIORITY_CLASS: t.CDefine = 0x00000020
|
||||
IDLE_PRIORITY_CLASS: t.CDefine = 0x00000040
|
||||
HIGH_PRIORITY_CLASS: t.CDefine = 0x00000080
|
||||
REALTIME_PRIORITY_CLASS: t.CDefine = 0x00000100
|
||||
BELOW_NORMAL_PRIORITY_CLASS: t.CDefine = 0x00004000
|
||||
ABOVE_NORMAL_PRIORITY_CLASS: t.CDefine = 0x00008000
|
||||
STILL_ACTIVE: t.CDefine = 259
|
||||
|
||||
class STARTUPINFOA:
|
||||
cb: ULONG
|
||||
lpReserved: CHARPTR
|
||||
lpDesktop: CHARPTR
|
||||
lpTitle: CHARPTR
|
||||
dwX: ULONG
|
||||
dwY: ULONG
|
||||
dwXSize: ULONG
|
||||
dwYSize: ULONG
|
||||
dwXCountChars: ULONG
|
||||
dwYCountChars: ULONG
|
||||
dwFillAttribute: ULONG
|
||||
dwFlags: ULONG
|
||||
wShowWindow: WORD
|
||||
cbReserved2: WORD
|
||||
lpReserved2: VOIDPTR
|
||||
hStdInput: HANDLE
|
||||
hStdOutput: HANDLE
|
||||
hStdError: HANDLE
|
||||
class STARTUPINFOW:
|
||||
cb: ULONG
|
||||
lpReserved: WCHARPTR
|
||||
lpDesktop: WCHARPTR
|
||||
lpTitle: WCHARPTR
|
||||
dwX: ULONG
|
||||
dwY: ULONG
|
||||
dwXSize: ULONG
|
||||
dwYSize: ULONG
|
||||
dwXCountChars: ULONG
|
||||
dwYCountChars: ULONG
|
||||
dwFillAttribute: ULONG
|
||||
dwFlags: ULONG
|
||||
wShowWindow: WORD
|
||||
cbReserved2: WORD
|
||||
lpReserved2: VOIDPTR
|
||||
hStdInput: HANDLE
|
||||
hStdOutput: HANDLE
|
||||
hStdError: HANDLE
|
||||
class PROCESS_INFORMATION:
|
||||
hProcess: HANDLE
|
||||
hThread: HANDLE
|
||||
dwProcessId: ULONG
|
||||
dwThreadId: ULONG
|
||||
|
||||
def CreateProcessA(lpApplicationName: LPCSTR, lpCommandLine: CHARPTR, lpProcessAttributes: SECURITY_ATTRIBUTES | t.CPtr, lpThreadAttributes: SECURITY_ATTRIBUTES | t.CPtr, bInheritHandles: BOOL, dwCreationFlags: ULONG, lpEnvironment: VOIDPTR, lpCurrentDirectory: LPCSTR, lpStartupInfo: STARTUPINFOA | t.CPtr, lpProcessInformation: PROCESS_INFORMATION | t.CPtr) -> BOOL | t.State: pass
|
||||
|
||||
def CreateProcessW(lpApplicationName: LPCWSTR, lpCommandLine: WCHARPTR, lpProcessAttributes: SECURITY_ATTRIBUTES | t.CPtr, lpThreadAttributes: SECURITY_ATTRIBUTES | t.CPtr, bInheritHandles: BOOL, dwCreationFlags: ULONG, lpEnvironment: VOIDPTR, lpCurrentDirectory: LPCWSTR, lpStartupInfo: STARTUPINFOW | t.CPtr, lpProcessInformation: PROCESS_INFORMATION | t.CPtr) -> BOOL | t.State: pass
|
||||
|
||||
def TerminateProcess(hProcess: HANDLE, uExitCode: UINT) -> BOOL | t.State: pass
|
||||
|
||||
def GetExitCodeProcess(hProcess: HANDLE, lpExitCode: ULONG | t.CPtr) -> BOOL | t.State: pass
|
||||
|
||||
def GetExitCodeThread(hThread: HANDLE, lpExitCode: ULONG | t.CPtr) -> BOOL | t.State: pass
|
||||
|
||||
def OpenProcess(dwDesiredAccess: ULONG, bInheritHandle: BOOL, dwProcessId: ULONG) -> HANDLE | t.State: pass
|
||||
|
||||
def GetCurrentProcess() -> HANDLE | t.State: pass
|
||||
|
||||
def GetCurrentProcessId() -> ULONG | t.State: pass
|
||||
|
||||
def CreateThread(lpThreadAttributes: SECURITY_ATTRIBUTES | t.CPtr, dwStackSize: t.CSizeT, lpStartAddress: VOIDPTR, lpParameter: VOIDPTR, dwCreationFlags: ULONG, lpThreadId: ULONG | t.CPtr) -> HANDLE | t.State: pass
|
||||
|
||||
def OpenThread(dwDesiredAccess: ULONG, bInheritHandle: BOOL, dwThreadId: ULONG) -> HANDLE | t.State: pass
|
||||
|
||||
def SuspendThread(hThread: HANDLE) -> ULONG | t.State: pass
|
||||
|
||||
def ResumeThread(hThread: HANDLE) -> ULONG | t.State: pass
|
||||
|
||||
def TerminateThread(hThread: HANDLE, dwExitCode: ULONG) -> BOOL | t.State: pass
|
||||
|
||||
def GetCurrentThread() -> HANDLE | t.State: pass
|
||||
|
||||
def GetCurrentThreadId() -> ULONG | t.State: pass
|
||||
|
||||
def GetThreadId(hThread: HANDLE) -> ULONG | t.State: pass
|
||||
|
||||
def GetProcessId(hProcess: HANDLE) -> ULONG | t.State: pass
|
||||
|
||||
def SetThreadPriority(hThread: HANDLE, nPriority: INT) -> BOOL | t.State: pass
|
||||
|
||||
def GetThreadPriority(hThread: HANDLE) -> INT | t.State: pass
|
||||
|
||||
def ExitProcess(uExitCode: UINT) -> VOID | t.State: pass
|
||||
|
||||
def ExitThread(dwExitCode: ULONG) -> VOID | t.State: pass
|
||||
|
||||
def TlsAlloc() -> ULONG | t.State: pass
|
||||
|
||||
def TlsFree(dwTlsIndex: ULONG) -> BOOL | t.State: pass
|
||||
|
||||
def TlsGetValue(dwTlsIndex: ULONG) -> VOIDPTR | t.State: pass
|
||||
|
||||
def TlsSetValue(dwTlsIndex: ULONG, lpTlsValue: VOIDPTR) -> BOOL | t.State: pass
|
||||
@@ -0,0 +1,109 @@
|
||||
"""
|
||||
Auto-generated Python stub file from w32.win32sync.py
|
||||
Module: w32.win32sync
|
||||
"""
|
||||
|
||||
import c
|
||||
|
||||
|
||||
import t
|
||||
from stdint import *
|
||||
from w32.win32base import *
|
||||
|
||||
class CRITICAL_SECTION:
|
||||
DebugInfo: VOIDPTR
|
||||
LockCount: LONG
|
||||
RecursionCount: LONG
|
||||
OwningThread: HANDLE
|
||||
LockSemaphore: HANDLE
|
||||
SpinCount: QWORD
|
||||
|
||||
def InitializeCriticalSection(lpCriticalSection: CRITICAL_SECTION | t.CPtr) -> VOID | t.State: pass
|
||||
|
||||
def EnterCriticalSection(lpCriticalSection: CRITICAL_SECTION | t.CPtr) -> VOID | t.State: pass
|
||||
|
||||
def LeaveCriticalSection(lpCriticalSection: CRITICAL_SECTION | t.CPtr) -> VOID | t.State: pass
|
||||
|
||||
def DeleteCriticalSection(lpCriticalSection: CRITICAL_SECTION | t.CPtr) -> VOID | t.State: pass
|
||||
|
||||
def TryEnterCriticalSection(lpCriticalSection: CRITICAL_SECTION | t.CPtr) -> BOOL | t.State: pass
|
||||
|
||||
def SetCriticalSectionSpinCount(lpCriticalSection: CRITICAL_SECTION | t.CPtr, dwSpinCount: ULONG) -> ULONG | t.State: pass
|
||||
|
||||
def InitializeCriticalSectionAndSpinCount(lpCriticalSection: CRITICAL_SECTION | t.CPtr, dwSpinCount: ULONG) -> BOOL | t.State: pass
|
||||
|
||||
def CreateMutexA(lpMutexAttributes: SECURITY_ATTRIBUTES | t.CPtr, bInitialOwner: BOOL, lpName: LPCSTR) -> HANDLE | t.State: pass
|
||||
|
||||
def CreateMutexW(lpMutexAttributes: SECURITY_ATTRIBUTES | t.CPtr, bInitialOwner: BOOL, lpName: LPCWSTR) -> HANDLE | t.State: pass
|
||||
|
||||
def OpenMutexA(dwDesiredAccess: ULONG, bInheritHandle: BOOL, lpName: LPCSTR) -> HANDLE | t.State: pass
|
||||
|
||||
def OpenMutexW(dwDesiredAccess: ULONG, bInheritHandle: BOOL, lpName: LPCWSTR) -> HANDLE | t.State: pass
|
||||
|
||||
def ReleaseMutex(hMutex: HANDLE) -> BOOL | t.State: pass
|
||||
|
||||
def CreateEventA(lpEventAttributes: SECURITY_ATTRIBUTES | t.CPtr, bManualReset: BOOL, bInitialState: BOOL, lpName: LPCSTR) -> HANDLE | t.State: pass
|
||||
|
||||
def CreateEventW(lpEventAttributes: SECURITY_ATTRIBUTES | t.CPtr, bManualReset: BOOL, bInitialState: BOOL, lpName: LPCWSTR) -> HANDLE | t.State: pass
|
||||
|
||||
def OpenEventA(dwDesiredAccess: ULONG, bInheritHandle: BOOL, lpName: LPCSTR) -> HANDLE | t.State: pass
|
||||
|
||||
def OpenEventW(dwDesiredAccess: ULONG, bInheritHandle: BOOL, lpName: LPCWSTR) -> HANDLE | t.State: pass
|
||||
|
||||
def SetEvent(hEvent: HANDLE) -> BOOL | t.State: pass
|
||||
|
||||
def ResetEvent(hEvent: HANDLE) -> BOOL | t.State: pass
|
||||
|
||||
def PulseEvent(hEvent: HANDLE) -> BOOL | t.State: pass
|
||||
|
||||
def CreateSemaphoreA(lpSemaphoreAttributes: SECURITY_ATTRIBUTES | t.CPtr, lInitialCount: LONG, lMaximumCount: LONG, lpName: LPCSTR) -> HANDLE | t.State: pass
|
||||
|
||||
def CreateSemaphoreW(lpSemaphoreAttributes: SECURITY_ATTRIBUTES | t.CPtr, lInitialCount: LONG, lMaximumCount: LONG, lpName: LPCWSTR) -> HANDLE | t.State: pass
|
||||
|
||||
def OpenSemaphoreA(dwDesiredAccess: ULONG, bInheritHandle: BOOL, lpName: LPCSTR) -> HANDLE | t.State: pass
|
||||
|
||||
def OpenSemaphoreW(dwDesiredAccess: ULONG, bInheritHandle: BOOL, lpName: LPCWSTR) -> HANDLE | t.State: pass
|
||||
|
||||
def ReleaseSemaphore(hSemaphore: HANDLE, lReleaseCount: LONG, lpPreviousCount: LONG | t.CPtr) -> BOOL | t.State: pass
|
||||
|
||||
def WaitForSingleObject(hHandle: HANDLE, dwMilliseconds: ULONG) -> ULONG | t.State: pass
|
||||
|
||||
def WaitForSingleObjectEx(hHandle: HANDLE, dwMilliseconds: ULONG, bAlertable: BOOL) -> ULONG | t.State: pass
|
||||
|
||||
def WaitForMultipleObjects(nCount: ULONG, lpHandles: VOIDPTR, bWaitAll: BOOL, dwMilliseconds: ULONG) -> ULONG | t.State: pass
|
||||
|
||||
def WaitForMultipleObjectsEx(nCount: ULONG, lpHandles: VOIDPTR, bWaitAll: BOOL, dwMilliseconds: ULONG, bAlertable: BOOL) -> ULONG | t.State: pass
|
||||
|
||||
def InitializeSRWLock(SRWLock: VOIDPTR) -> VOID | t.State: pass
|
||||
|
||||
def AcquireSRWLockExclusive(SRWLock: VOIDPTR) -> VOID | t.State: pass
|
||||
|
||||
def AcquireSRWLockShared(SRWLock: VOIDPTR) -> VOID | t.State: pass
|
||||
|
||||
def ReleaseSRWLockExclusive(SRWLock: VOIDPTR) -> VOID | t.State: pass
|
||||
|
||||
def ReleaseSRWLockShared(SRWLock: VOIDPTR) -> VOID | t.State: pass
|
||||
|
||||
|
||||
CONDITION_VARIABLE_LOCKMODE_SHARED: t.CDefine = 0x1
|
||||
|
||||
def InitializeConditionVariable(ConditionVariable: VOIDPTR) -> VOID | t.State: pass
|
||||
|
||||
def SleepConditionVariableCS(ConditionVariable: VOIDPTR, CriticalSection: CRITICAL_SECTION | t.CPtr, dwMilliseconds: ULONG) -> BOOL | t.State: pass
|
||||
|
||||
def SleepConditionVariableSRW(ConditionVariable: VOIDPTR, SRWLock: VOIDPTR, dwMilliseconds: ULONG, Flags: ULONG) -> BOOL | t.State: pass
|
||||
|
||||
def WakeConditionVariable(ConditionVariable: VOIDPTR) -> VOID | t.State: pass
|
||||
|
||||
def WakeAllConditionVariable(ConditionVariable: VOIDPTR) -> VOID | t.State: pass
|
||||
|
||||
|
||||
INIT_ONCE_STATIC_INIT: t.CDefine = 0x00000001
|
||||
INIT_ONCE_CHECK_ONLY: t.CDefine = 0x00000002
|
||||
INIT_ONCE_ASYNC: t.CDefine = 0x00000004
|
||||
INIT_ONCE_INIT_FAILED: t.CDefine = 0x00000008
|
||||
|
||||
class INIT_ONCE:
|
||||
Ptr: t.CPtr
|
||||
|
||||
def InitOnceExecuteOnce(InitOnce: INIT_ONCE | t.CPtr, InitFn: VOIDPTR, Parameter: VOIDPTR, Context: VOIDPTR | t.CPtr) -> BOOL | t.State: pass
|
||||
@@ -0,0 +1,26 @@
|
||||
"""
|
||||
Auto-generated Python stub file from atom.py
|
||||
Module: atom
|
||||
"""
|
||||
|
||||
|
||||
import t, c
|
||||
|
||||
ATOMIC_RELAXED: t.CDefine = 0
|
||||
ATOMIC_CONSUME: t.CDefine = 1
|
||||
ATOMIC_ACQUIRE: t.CDefine = 2
|
||||
ATOMIC_RELEASE: t.CDefine = 3
|
||||
ATOMIC_ACQ_REL: t.CDefine = 4
|
||||
ATOMIC_SEQ_CST: t.CDefine = 5
|
||||
|
||||
def __atomic_test_and_set(ptr: t.CUInt64T | t.CPtr, order: t.CInt) -> t.CBool: pass
|
||||
|
||||
def __atomic_clear(ptr: t.CUInt64T | t.CPtr, order: t.CInt) -> t.CVoid: pass
|
||||
|
||||
def __atomic_thread_fence(order: t.CInt) -> t.CVoid: pass
|
||||
|
||||
def __atomic_signal_fence(order: t.CInt) -> t.CVoid: pass
|
||||
|
||||
def __atomic_always_lock_free(size: t.CSizeT, ptr: t.CVoid | t.CPtr) -> t.CBool: pass
|
||||
|
||||
def __atomic_is_lock_free(size: t.CSizeT, ptr: t.CVoid | t.CPtr) -> t.CBool: pass
|
||||
@@ -0,0 +1 @@
|
||||
{}
|
||||
@@ -0,0 +1,13 @@
|
||||
"""
|
||||
Auto-generated Python stub file from main.py
|
||||
Module: main
|
||||
"""
|
||||
|
||||
|
||||
from stdint import *
|
||||
import w32.win32console
|
||||
import t, c
|
||||
from t import CInt, CExport
|
||||
import mbuddytest
|
||||
|
||||
def main() -> CInt | CExport: pass
|
||||
@@ -0,0 +1,86 @@
|
||||
"""
|
||||
Auto-generated Python stub file from w32.winsock2.py
|
||||
Module: w32.winsock2
|
||||
"""
|
||||
|
||||
|
||||
import t, c
|
||||
from stdint import *
|
||||
from w32.win32base import *
|
||||
|
||||
WINSOCK_VERSION: t.CDefine = 0x0202 # 2.2
|
||||
AF_INET: t.CDefine = 2
|
||||
AF_INET6: t.CDefine = 23
|
||||
SOCK_STREAM: t.CDefine = 1 # TCP
|
||||
SOCK_DGRAM: t.CDefine = 2 # UDP
|
||||
SOCK_RAW: t.CDefine = 3 # 原始套接字
|
||||
IPPROTO_TCP: t.CDefine = 6
|
||||
IPPROTO_UDP: t.CDefine = 17
|
||||
SOL_SOCKET: t.CDefine = 0xFFFF # WinSock2 值
|
||||
SO_RCVTIMEO: t.CDefine = 0x1006 # WinSock2 值
|
||||
SO_SNDTIMEO: t.CDefine = 0x1005 # WinSock2 值
|
||||
SO_REUSEADDR: t.CDefine = 0x0004 # WinSock2 值
|
||||
INADDR_ANY: t.CDefine = 0
|
||||
SOCKET_ERROR: t.CDefine = -1
|
||||
INVALID_SOCKET: t.CDefine = 0xFFFFFFFF # WinSock2: ~0
|
||||
MSG_NOSIGNAL: t.CDefine = 0 # Windows 不支持,设为 0
|
||||
SD_SEND: t.CDefine = 1
|
||||
SD_RECV: t.CDefine = 0
|
||||
SD_BOTH: t.CDefine = 2
|
||||
|
||||
class WSASocketAddr:
|
||||
family: u16
|
||||
port: u16
|
||||
addr: u32
|
||||
zero: u64
|
||||
class WSAData:
|
||||
wVersion: WORD
|
||||
wHighVersion: WORD
|
||||
szDescription: BYTE
|
||||
szSystemStatus: BYTE
|
||||
iMaxSockets: u16
|
||||
iMaxUdpDg: u16
|
||||
lpVendorInfo: CHARPTR
|
||||
class WSAHostEnt:
|
||||
h_name: CHARPTR
|
||||
h_aliases: CHARPTR
|
||||
h_addrtype: SHORT
|
||||
h_length: SHORT
|
||||
h_addr_list: CHARPTR
|
||||
class WinTimeVal:
|
||||
tv_sec: LONG
|
||||
tv_usec: LONG
|
||||
|
||||
def WSAStartup(wVersionRequested: WORD, lpWSAData: WSAData | t.CPtr) -> INT | t.State: pass
|
||||
|
||||
def WSACleanup() -> INT | t.State: pass
|
||||
|
||||
def WSAGetLastError() -> INT | t.State: pass
|
||||
|
||||
def socket(family: INT, type: INT, protocol: INT) -> u64 | t.State: pass
|
||||
|
||||
def closesocket(s: u64) -> INT | t.State: pass
|
||||
|
||||
def connect(s: u64, name: WSASocketAddr | t.CPtr, namelen: INT) -> INT | t.State: pass
|
||||
|
||||
def send(s: u64, buf: t.CVoid | t.CPtr, len: INT, flags: INT) -> INT | t.State: pass
|
||||
|
||||
def recv(s: u64, buf: t.CVoid | t.CPtr, len: INT, flags: INT) -> INT | t.State: pass
|
||||
|
||||
def bind(s: u64, name: WSASocketAddr | t.CPtr, namelen: INT) -> INT | t.State: pass
|
||||
|
||||
def listen(s: u64, backlog: INT) -> INT | t.State: pass
|
||||
|
||||
def accept(s: u64, addr: WSASocketAddr | t.CPtr, addrlen: INT | t.CPtr) -> u64 | t.State: pass
|
||||
|
||||
def setsockopt(s: u64, level: INT, optname: INT, optval: t.CVoid | t.CPtr, optlen: INT) -> INT | t.State: pass
|
||||
|
||||
def shutdown(s: u64, how: INT) -> INT | t.State: pass
|
||||
|
||||
def gethostbyname(name: t.CChar | t.CConst | t.CPtr) -> WSAHostEnt | t.CPtr | t.State: pass
|
||||
|
||||
def ntohs(netshort: u16) -> u16 | t.State: pass
|
||||
|
||||
def htons(hostshort: u16) -> u16 | t.State: pass
|
||||
|
||||
def inet_addr(cp: t.CChar | t.CConst | t.CPtr) -> u32 | t.State: pass
|
||||
@@ -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
|
||||
@@ -0,0 +1,20 @@
|
||||
"""
|
||||
Auto-generated Python stub file from stdarg.py
|
||||
Module: stdarg
|
||||
"""
|
||||
|
||||
import c
|
||||
|
||||
|
||||
import t
|
||||
|
||||
def va_start(args: t.CPtr, last_arg: t.CPtr) -> t.State: pass
|
||||
|
||||
def va_arg(args: t.CPtr, type: t.CPtr) -> t.CPtr | t.State: pass
|
||||
|
||||
def va_end(args: t.CPtr) -> t.State | t.State: pass
|
||||
|
||||
|
||||
va_list: t.CTypedef = t.CUnsignedChar | t.CPtr
|
||||
|
||||
def arg(type: t.CType) -> t.State: pass
|
||||
@@ -0,0 +1,91 @@
|
||||
"""
|
||||
Auto-generated Python stub file from w32.win32memory.py
|
||||
Module: w32.win32memory
|
||||
"""
|
||||
|
||||
import c
|
||||
|
||||
|
||||
import t
|
||||
from stdint import *
|
||||
from w32.win32base import *
|
||||
|
||||
MEM_COMMIT: t.CDefine = 0x00001000
|
||||
MEM_RESERVE: t.CDefine = 0x00002000
|
||||
MEM_DECOMMIT: t.CDefine = 0x00004000
|
||||
MEM_RELEASE: t.CDefine = 0x00008000
|
||||
MEM_FREE: t.CDefine = 0x00010000
|
||||
MEM_RESET: t.CDefine = 0x00080000
|
||||
MEM_TOP_DOWN: t.CDefine = 0x00100000
|
||||
MEM_WRITE_WATCH: t.CDefine = 0x00200000
|
||||
MEM_PHYSICAL: t.CDefine = 0x00400000
|
||||
MEM_LARGE_PAGES: t.CDefine = 0x20000000
|
||||
PAGE_NOACCESS: t.CDefine = 0x01
|
||||
PAGE_READONLY: t.CDefine = 0x02
|
||||
PAGE_READWRITE: t.CDefine = 0x04
|
||||
PAGE_WRITECOPY: t.CDefine = 0x08
|
||||
PAGE_EXECUTE: t.CDefine = 0x10
|
||||
PAGE_EXECUTE_READ: t.CDefine = 0x20
|
||||
PAGE_EXECUTE_READWRITE: t.CDefine = 0x40
|
||||
PAGE_EXECUTE_WRITECOPY: t.CDefine = 0x80
|
||||
PAGE_GUARD: t.CDefine = 0x100
|
||||
PAGE_NOCACHE: t.CDefine = 0x200
|
||||
PAGE_WRITECOMBINE: t.CDefine = 0x400
|
||||
HEAP_NO_SERIALIZE: t.CDefine = 0x00000001
|
||||
HEAP_GROWABLE: t.CDefine = 0x00000002
|
||||
HEAP_GENERATE_EXCEPTIONS: t.CDefine = 0x00000004
|
||||
HEAP_ZERO_MEMORY: t.CDefine = 0x00000008
|
||||
HEAP_REALLOC_IN_PLACE_ONLY: t.CDefine = 0x00000010
|
||||
|
||||
class MEMORY_BASIC_INFORMATION:
|
||||
BaseAddress: VOIDPTR
|
||||
AllocationBase: VOIDPTR
|
||||
AllocationProtect: ULONG
|
||||
RegionSize: t.CSizeT
|
||||
State: ULONG
|
||||
Protect: ULONG
|
||||
Type: ULONG
|
||||
|
||||
def VirtualAlloc(lpAddress: VOIDPTR, dwSize: t.CSizeT, flAllocationType: ULONG, flProtect: ULONG) -> VOIDPTR | t.State: pass
|
||||
|
||||
def VirtualFree(lpAddress: VOIDPTR, dwSize: t.CSizeT, dwFreeType: ULONG) -> BOOL | t.State: pass
|
||||
|
||||
def VirtualProtect(lpAddress: VOIDPTR, dwSize: t.CSizeT, flNewProtect: ULONG, lpflOldProtect: ULONG | t.CPtr) -> BOOL | t.State: pass
|
||||
|
||||
def VirtualQuery(lpAddress: t.CConst | VOIDPTR, lpBuffer: MEMORY_BASIC_INFORMATION | t.CPtr, dwLength: t.CSizeT) -> t.CSizeT | t.State: pass
|
||||
|
||||
def VirtualLock(lpAddress: VOIDPTR, dwSize: t.CSizeT) -> BOOL | t.State: pass
|
||||
|
||||
def VirtualUnlock(lpAddress: VOIDPTR, dwSize: t.CSizeT) -> BOOL | t.State: pass
|
||||
|
||||
def GetProcessHeap() -> HANDLE | t.State: pass
|
||||
|
||||
def HeapCreate(flOptions: ULONG, dwInitialSize: t.CSizeT, dwMaximumSize: t.CSizeT) -> HANDLE | t.State: pass
|
||||
|
||||
def HeapDestroy(hHeap: HANDLE) -> BOOL | t.State: pass
|
||||
|
||||
def HeapAlloc(hHeap: HANDLE, dwFlags: ULONG, dwBytes: t.CSizeT) -> VOIDPTR | t.State: pass
|
||||
|
||||
def HeapReAlloc(hHeap: HANDLE, dwFlags: ULONG, lpMem: VOIDPTR, dwBytes: t.CSizeT) -> VOIDPTR | t.State: pass
|
||||
|
||||
def HeapFree(hHeap: HANDLE, dwFlags: ULONG, lpMem: VOIDPTR) -> BOOL | t.State: pass
|
||||
|
||||
def HeapSize(hHeap: HANDLE, dwFlags: ULONG, lpMem: t.CConst | VOIDPTR) -> t.CSizeT | t.State: pass
|
||||
|
||||
def HeapValidate(hHeap: HANDLE, dwFlags: ULONG, lpMem: t.CConst | VOIDPTR) -> BOOL | t.State: pass
|
||||
|
||||
def HeapCompact(hHeap: HANDLE, dwFlags: ULONG) -> t.CSizeT | t.State: pass
|
||||
|
||||
def GlobalAlloc(uFlags: UINT, dwBytes: t.CSizeT) -> VOIDPTR | t.State: pass
|
||||
|
||||
def GlobalFree(hMem: VOIDPTR) -> VOIDPTR | t.State: pass
|
||||
|
||||
def GlobalLock(hMem: VOIDPTR) -> VOIDPTR | t.State: pass
|
||||
|
||||
def GlobalUnlock(hMem: VOIDPTR) -> BOOL | t.State: pass
|
||||
|
||||
def GlobalSize(hMem: VOIDPTR) -> t.CSizeT | t.State: pass
|
||||
|
||||
def LocalAlloc(uFlags: UINT, dwBytes: t.CSizeT) -> VOIDPTR | t.State: pass
|
||||
|
||||
def LocalFree(hMem: VOIDPTR) -> VOIDPTR | t.State: pass
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -0,0 +1 @@
|
||||
{"D:\\Users\\TermiNexus\\Desktop\\TransPyC\\Test\\BuddyTest\\App\\main.py": {"sha1": "5e430ae5bf7af3a2", "mtime": 1782224154.785576, "size": 260}, "D:\\Users\\TermiNexus\\Desktop\\TransPyC\\Test\\BuddyTest\\App\\mbuddytest.py": {"sha1": "b69cdee68f223fef", "mtime": 1782827825.044477, "size": 19246}, "D:\\Users\\TermiNexus\\Desktop\\TransPyC\\includes\\atom.py": {"sha1": "271ea3decb810db2", "mtime": 1782226548.693161, "size": 1290}, "D:\\Users\\TermiNexus\\Desktop\\TransPyC\\includes\\memhub.py": {"sha1": "ee084e9fc6ee413a", "mtime": 1784214242.4485993, "size": 17765}, "D:\\Users\\TermiNexus\\Desktop\\TransPyC\\includes\\stdarg.py": {"sha1": "71e0a3ffcb3ebfad", "mtime": 1781258888.113146, "size": 277}, "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\\string.py": {"sha1": "ab6e54ba9a669f76", "mtime": 1783933178.7264287, "size": 9922}, "D:\\Users\\TermiNexus\\Desktop\\TransPyC\\includes\\testcheck.py": {"sha1": "dd3002730623424b", "mtime": 1783927513.1159866, "size": 1818}, "D:\\Users\\TermiNexus\\Desktop\\TransPyC\\includes\\viperio.py": {"sha1": "c9f4be41ca1cc2b4", "mtime": 1782812279.506002, "size": 1556}, "D:\\Users\\TermiNexus\\Desktop\\TransPyC\\includes\\viperlib.py": {"sha1": "c3b259b4059f8668", "mtime": 1782821991.979496, "size": 56772}, "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}, "D:\\Users\\TermiNexus\\Desktop\\TransPyC\\includes\\w32\\win32process.py": {"sha1": "067c78e9f121dce3", "mtime": 1781200703.5409546, "size": 4802}, "D:\\Users\\TermiNexus\\Desktop\\TransPyC\\includes\\w32\\win32sync.py": {"sha1": "06f53cc594b4ac6c", "mtime": 1782297500.2581685, "size": 4726}}
|
||||
@@ -0,0 +1,16 @@
|
||||
067c78e9f121dce3:includes/w32\win32process.py
|
||||
06f53cc594b4ac6c:includes/w32\win32sync.py
|
||||
271ea3decb810db2:includes/atom.py
|
||||
5e430ae5bf7af3a2:main.py
|
||||
6f62fe05c5ea1ceb:includes/stdio.py
|
||||
71e0a3ffcb3ebfad:includes/stdarg.py
|
||||
7e529fe7a078cfef:includes/w32\win32base.py
|
||||
90c53dd6db8d41cf:includes/stdlib.py
|
||||
ab6e54ba9a669f76:includes/string.py
|
||||
b69cdee68f223fef:mbuddytest.py
|
||||
bbdf3bbd4c3bc28c:includes/w32\win32console.py
|
||||
c3b259b4059f8668:includes/viperlib.py
|
||||
c9f4be41ca1cc2b4:includes/viperio.py
|
||||
dd3002730623424b:includes/testcheck.py
|
||||
ee084e9fc6ee413a:includes/memhub.py
|
||||
f5522571bcce7bcb:includes/stdint.py
|
||||
Binary file not shown.
@@ -0,0 +1,48 @@
|
||||
"""
|
||||
Auto-generated Python stub file from string.py
|
||||
Module: string
|
||||
"""
|
||||
|
||||
|
||||
from stdint import *
|
||||
import t, c
|
||||
|
||||
def strcpy(dest: str, src: str) -> str: pass
|
||||
|
||||
def strcat(dest: str, src: str) -> str: pass
|
||||
|
||||
def strncpy(dest: str, src: str, n: t.CSizeT) -> str: pass
|
||||
|
||||
def strlen(src: str) -> t.CSizeT | t.CExport: pass
|
||||
|
||||
def strcmp(str1: str, str2: str) -> t.CInt: pass
|
||||
|
||||
def samestr(str1: str, str2: str) -> bool: pass
|
||||
|
||||
def strncmp(str1: str, str2: str, n: t.CSizeT) -> t.CInt: pass
|
||||
|
||||
def memcmp(ptr1: t.CVoid | t.CPtr, ptr2: t.CVoid | t.CPtr, n: t.CSizeT) -> t.CInt: pass
|
||||
|
||||
def strchr(s: str, cr: t.CInt) -> str: pass
|
||||
|
||||
def strrchr(s: str, cr: t.CInt) -> str: pass
|
||||
|
||||
def strstr(s: str, needle: str) -> str: pass
|
||||
|
||||
def strspn(s: str, skip: str) -> int: pass
|
||||
|
||||
def memset(ptr: t.CVoid | t.CPtr, value: t.CInt, num: t.CSizeT) -> t.CVoid | t.CPtr | t.CExport: pass
|
||||
|
||||
def memset32(ptr: t.CVoid | t.CPtr, value: t.CUInt32T, count: t.CSizeT) -> t.CVoid | t.CPtr: pass
|
||||
|
||||
def memcpy(dest: t.CVoid | t.CPtr, src: t.CVoid | t.CPtr, num: t.CSizeT) -> t.CVoid | t.CPtr | t.CExport: pass
|
||||
|
||||
def memmove(dest: t.CVoid | t.CPtr, src: t.CVoid | t.CPtr, num: t.CSizeT) -> t.CVoid | t.CPtr: pass
|
||||
|
||||
def atoi(src: str) -> t.CInt: pass
|
||||
|
||||
def atoll(src: str) -> t.CInt64T: pass
|
||||
|
||||
def atof(src: str) -> t.CDouble: pass
|
||||
|
||||
def split(s: str, delim: str, result: t.CArray[str]) -> int: pass
|
||||
@@ -0,0 +1 @@
|
||||
{}
|
||||
@@ -0,0 +1,21 @@
|
||||
"""
|
||||
Auto-generated Python stub file from mbuddytest.py
|
||||
Module: mbuddytest
|
||||
"""
|
||||
|
||||
|
||||
import t, c
|
||||
from t import CInt, CPtr, CChar, CUInt8T, CUInt32T, CUInt64T, CSizeT
|
||||
import viperlib
|
||||
import viperio
|
||||
import stdlib
|
||||
import memhub
|
||||
import string
|
||||
import testcheck
|
||||
import w32.win32process
|
||||
import w32.win32sync
|
||||
import w32.win32base
|
||||
|
||||
def _thread_alloc_free(param: t.CVoid | t.CPtr) -> t.CUInt32T: pass
|
||||
|
||||
def mbuddy_main() -> CInt: pass
|
||||
@@ -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
|
||||
@@ -0,0 +1,23 @@
|
||||
"""
|
||||
Auto-generated Python stub file from viperlib.py
|
||||
Module: viperlib
|
||||
"""
|
||||
|
||||
|
||||
import t, c
|
||||
import viperio
|
||||
from stdarg import arg, va_arg
|
||||
|
||||
TEMP_BUF_SIZE: t.CDefine = 68
|
||||
|
||||
def get_digit_count(num: t.CUnsignedInt, base: t.CInt) -> t.CStatic | t.CInt: pass
|
||||
|
||||
def sprintf(buf: t.CChar | t.CPtr, rule: str, *args) -> t.CVoid | t.CExport: pass
|
||||
|
||||
def vsprintf(buf: t.CChar | t.CPtr, rule: str, *args) -> t.CInt: pass
|
||||
|
||||
def snprintf(buf: t.CChar | t.CPtr, size: t.CSizeT, fmt: str, *args) -> t.CInt | t.CExport: pass
|
||||
|
||||
def _check_special_float(fv: t.CDouble) -> t.CInt: pass
|
||||
|
||||
def vsnprintf(buf: t.CChar | t.CPtr, size: t.CSizeT, fmt: str, ap: t.CChar | t.CPtr) -> t.CInt | t.CExport: pass
|
||||
@@ -0,0 +1,22 @@
|
||||
"""
|
||||
Auto-generated Python stub file from viperio.py
|
||||
Module: viperio
|
||||
"""
|
||||
|
||||
|
||||
import t, c
|
||||
from stdint import *
|
||||
|
||||
class Buf:
|
||||
data: t.CChar | t.CPtr
|
||||
length: t.CSizeT
|
||||
capacity: t.CSizeT
|
||||
owned: bool
|
||||
def __init__(self: Buf, data: t.CChar | t.CPtr, capacity: t.CSizeT, length: t.CSizeT, owned: bool) -> t.CInt: pass
|
||||
def clear(self: Buf) -> t.CInt: pass
|
||||
def write(self: Buf, src: t.CChar | t.CPtr, count: t.CSizeT) -> t.CSizeT: pass
|
||||
def cstr(self: Buf) -> t.CChar | t.CPtr: pass
|
||||
def reset(self: Buf) -> t.CInt: pass
|
||||
def __enter__(self: Buf) -> 'Buf' | t.CPtr: pass
|
||||
def __exit__(self: Buf) -> t.CInt: pass
|
||||
def free(self: Buf) -> t.CInt: pass
|
||||
@@ -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
|
||||
@@ -0,0 +1,81 @@
|
||||
"""
|
||||
Auto-generated Python stub file from memhub.py
|
||||
Module: memhub
|
||||
"""
|
||||
|
||||
|
||||
import t, c
|
||||
from stdint import *
|
||||
import string
|
||||
import atom
|
||||
import viperio
|
||||
|
||||
MEMHUB_ALIGN: t.CDefine = 8
|
||||
MEMSLAB_MIN_BLOCK: t.CDefine = 16
|
||||
MEMSLAB_BITMAP_BYTES: t.CDefine = 256
|
||||
MEMBUDDY_MIN_BLOCK: t.CDefine = 32
|
||||
MEMBUDDY_MAX_ORDERS: t.CDefine = 32
|
||||
MEMBUDDY_HEADER_SIZE: t.CDefine = 8
|
||||
|
||||
def _align_up(val: t.CSizeT, align: t.CSizeT) -> t.CSizeT: pass
|
||||
|
||||
def _largest_pow2_le(val: t.CSizeT) -> t.CSizeT: pass
|
||||
|
||||
def _block_size_at_order(order: t.CInt) -> t.CSizeT: pass
|
||||
|
||||
|
||||
@t.CVTable
|
||||
class MemManager:
|
||||
__provides__: list[str] = ['__memmgr__']
|
||||
base: t.CVoid | t.CPtr
|
||||
size: t.CSizeT
|
||||
def __init__(self: MemManager, base: t.CVoid | t.CPtr, size: t.CSizeT) -> t.CInt: pass
|
||||
def alloc(self: MemManager, size: t.CSizeT) -> t.CVoid | t.CPtr: pass
|
||||
def free(self: MemManager, ptr: t.CVoid | t.CPtr) -> t.CInt: pass
|
||||
def reset(self: MemManager) -> t.CInt: pass
|
||||
def calloc(self: MemManager, count: t.CSizeT, size: t.CSizeT) -> t.CVoid | t.CPtr: pass
|
||||
def realloc(self: MemManager, ptr: t.CVoid | t.CPtr, old_size: t.CSizeT, new_size: t.CSizeT) -> t.CVoid | t.CPtr: pass
|
||||
def __enter__(self: MemManager) -> 'MemManager' | t.CPtr: pass
|
||||
def __exit__(self: MemManager) -> t.CInt: pass
|
||||
def alloc_buf(self: MemManager, capacity: t.CSizeT) -> viperio.Buf | t.CPtr: pass
|
||||
class MemPool(MemManager):
|
||||
offset: t.CSizeT
|
||||
high_water: t.CSizeT
|
||||
def __init__(self: MemPool, base: t.CVoid | t.CPtr, size: t.CSizeT) -> t.CInt: pass
|
||||
def alloc(self: MemPool, size: t.CSizeT) -> t.CVoid | t.CPtr: pass
|
||||
def free(self: MemPool, ptr: t.CVoid | t.CPtr) -> t.CInt: pass
|
||||
def reset(self: MemPool) -> t.CInt: pass
|
||||
class MemSlab(MemManager):
|
||||
block_size: t.CSizeT
|
||||
block_count: t.CSizeT
|
||||
used_count: t.CSizeT
|
||||
free_list: t.CVoid | t.CPtr
|
||||
alloc_map: t.CUInt8T | t.CPtr
|
||||
alloc_map_size: t.CSizeT
|
||||
usable: t.CVoid | t.CPtr
|
||||
usable_size: t.CSizeT
|
||||
def __init__(self: MemSlab, base: t.CVoid | t.CPtr, size: t.CSizeT, block_size: t.CSizeT) -> t.CInt: pass
|
||||
def alloc(self: MemSlab, size: t.CSizeT) -> t.CVoid | t.CPtr: pass
|
||||
def free(self: MemSlab, ptr: t.CVoid | t.CPtr) -> t.CInt: pass
|
||||
def reset(self: MemSlab) -> t.CInt: pass
|
||||
class MemBuddy(MemManager):
|
||||
max_order: t.CInt
|
||||
free_lists: t.CUInt64T | t.CPtr
|
||||
lock_val: t.CVolatile | t.CInt
|
||||
usable: t.CVoid | t.CPtr
|
||||
usable_size: t.CSizeT
|
||||
def __init__(self: MemBuddy, base: t.CVoid | t.CPtr, size: t.CSizeT) -> t.CInt: pass
|
||||
def _fl_push(self: MemBuddy, order: t.CInt, block: t.CVoid | t.CPtr) -> t.CInt: pass
|
||||
def _fl_pop(self: MemBuddy, order: t.CInt) -> t.CVoid | t.CPtr: pass
|
||||
def _fl_find_and_remove(self: MemBuddy, order: t.CInt, target: t.CVoid | t.CPtr) -> t.CInt: pass
|
||||
def _buddy_of(self: MemBuddy, block: t.CVoid | t.CPtr, order: t.CInt) -> t.CVoid | t.CPtr: pass
|
||||
def _order_for_size(self: MemBuddy, size: t.CSizeT) -> t.CInt: pass
|
||||
def _split_to_order(self: MemBuddy, to_order: t.CInt) -> t.CVoid | t.CPtr: pass
|
||||
def _coalesce(self: MemBuddy, block: t.CVoid | t.CPtr, order: t.CInt) -> t.CInt: pass
|
||||
def _is_valid_ptr(self: MemBuddy, ptr: t.CVoid | t.CPtr) -> t.CInt: pass
|
||||
def _lock(self: MemBuddy) -> t.CInt: pass
|
||||
def _unlock(self: MemBuddy) -> t.CInt: pass
|
||||
def alloc(self: MemBuddy, size: t.CSizeT) -> t.CVoid | t.CPtr: pass
|
||||
def free(self: MemBuddy, ptr: t.CVoid | t.CPtr) -> t.CInt: pass
|
||||
def reset(self: MemBuddy) -> t.CInt: pass
|
||||
def realloc(self: MemBuddy, ptr: t.CVoid | t.CPtr, old_size: t.CSizeT, new_size: t.CSizeT) -> t.CVoid | t.CPtr: pass
|
||||
@@ -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
|
||||
@@ -0,0 +1,192 @@
|
||||
"""
|
||||
Auto-generated Python stub file from w32.win32file.py
|
||||
Module: w32.win32file
|
||||
"""
|
||||
|
||||
import c
|
||||
|
||||
|
||||
import t
|
||||
from stdint import *
|
||||
from w32.win32base import *
|
||||
|
||||
GENERIC_READ: t.CDefine = 0x80000000
|
||||
GENERIC_WRITE: t.CDefine = 0x40000000
|
||||
GENERIC_EXECUTE: t.CDefine = 0x20000000
|
||||
GENERIC_ALL: t.CDefine = 0x10000000
|
||||
FILE_SHARE_READ: t.CDefine = 0x00000001
|
||||
FILE_SHARE_WRITE: t.CDefine = 0x00000002
|
||||
FILE_SHARE_DELETE: t.CDefine = 0x00000004
|
||||
CREATE_NEW: t.CDefine = 1
|
||||
CREATE_ALWAYS: t.CDefine = 2
|
||||
OPEN_EXISTING: t.CDefine = 3
|
||||
OPEN_ALWAYS: t.CDefine = 4
|
||||
TRUNCATE_EXISTING: t.CDefine = 5
|
||||
FILE_ATTRIBUTE_READONLY: t.CDefine = 0x00000001
|
||||
FILE_ATTRIBUTE_HIDDEN: t.CDefine = 0x00000002
|
||||
FILE_ATTRIBUTE_SYSTEM: t.CDefine = 0x00000004
|
||||
FILE_ATTRIBUTE_DIRECTORY: t.CDefine = 0x00000010
|
||||
FILE_ATTRIBUTE_ARCHIVE: t.CDefine = 0x00000020
|
||||
FILE_ATTRIBUTE_NORMAL: t.CDefine = 0x00000080
|
||||
FILE_ATTRIBUTE_TEMPORARY: t.CDefine = 0x00000100
|
||||
FILE_ATTRIBUTE_COMPRESSED: t.CDefine = 0x00000800
|
||||
FILE_ATTRIBUTE_OFFLINE: t.CDefine = 0x00001000
|
||||
FILE_ATTRIBUTE_ENCRYPTED: t.CDefine = 0x00004000
|
||||
FILE_FLAG_WRITE_THROUGH: t.CDefine = 0x80000000
|
||||
FILE_FLAG_OVERLAPPED: t.CDefine = 0x40000000
|
||||
FILE_FLAG_NO_BUFFERING: t.CDefine = 0x20000000
|
||||
FILE_FLAG_RANDOM_ACCESS: t.CDefine = 0x10000000
|
||||
FILE_FLAG_SEQUENTIAL_SCAN: t.CDefine = 0x08000000
|
||||
FILE_FLAG_DELETE_ON_CLOSE: t.CDefine = 0x04000000
|
||||
FILE_FLAG_BACKUP_SEMANTICS: t.CDefine = 0x02000000
|
||||
FILE_FLAG_POSIX_SEMANTICS: t.CDefine = 0x01000000
|
||||
FILE_BEGIN: t.CDefine = 0
|
||||
FILE_CURRENT: t.CDefine = 1
|
||||
FILE_END: t.CDefine = 2
|
||||
STD_INPUT_HANDLE: t.CDefine = t.CUnsignedLong(-10)
|
||||
STD_OUTPUT_HANDLE: t.CDefine = t.CUnsignedLong(-11)
|
||||
STD_ERROR_HANDLE: t.CDefine = t.CUnsignedLong(-12)
|
||||
MOVEFILE_REPLACE_EXISTING: t.CDefine = 0x00000001
|
||||
MOVEFILE_COPY_ALLOWED: t.CDefine = 0x00000002
|
||||
MOVEFILE_WRITE_THROUGH: t.CDefine = 0x00000008
|
||||
|
||||
class BY_HANDLE_FILE_INFORMATION:
|
||||
dwFileAttributes: ULONG
|
||||
ftCreationTime: FILETIME
|
||||
ftLastAccessTime: FILETIME
|
||||
ftLastWriteTime: FILETIME
|
||||
dwVolumeSerialNumber: ULONG
|
||||
nFileSizeHigh: ULONG
|
||||
nFileSizeLow: ULONG
|
||||
nNumberOfLinks: ULONG
|
||||
nFileIndexHigh: ULONG
|
||||
nFileIndexLow: ULONG
|
||||
class WIN32_FIND_DATAA:
|
||||
dwFileAttributes: ULONG
|
||||
ftCreationTime: FILETIME
|
||||
ftLastAccessTime: FILETIME
|
||||
ftLastWriteTime: FILETIME
|
||||
nFileSizeHigh: ULONG
|
||||
nFileSizeLow: ULONG
|
||||
dwReserved0: ULONG
|
||||
dwReserved1: ULONG
|
||||
cFileName: t.CArray[t.CChar, 260]
|
||||
cAlternateFileName: t.CArray[t.CChar, 14]
|
||||
class WIN32_FIND_DATAW:
|
||||
dwFileAttributes: ULONG
|
||||
ftCreationTime: FILETIME
|
||||
ftLastAccessTime: FILETIME
|
||||
ftLastWriteTime: FILETIME
|
||||
nFileSizeHigh: ULONG
|
||||
nFileSizeLow: ULONG
|
||||
dwReserved0: ULONG
|
||||
dwReserved1: ULONG
|
||||
cFileName: t.CArray[t.CUInt16T, 260]
|
||||
cAlternateFileName: t.CArray[t.CUInt16T, 14]
|
||||
|
||||
def CreateFileA(lpFileName: LPCSTR, dwDesiredAccess: ULONG, dwShareMode: ULONG, lpSecurityAttributes: SECURITY_ATTRIBUTES | t.CPtr, dwCreationDisposition: ULONG, dwFlagsAndAttributes: ULONG, hTemplateFile: HANDLE) -> HANDLE | t.State: pass
|
||||
|
||||
def CreateFileW(lpFileName: LPCWSTR, dwDesiredAccess: ULONG, dwShareMode: ULONG, lpSecurityAttributes: SECURITY_ATTRIBUTES | t.CPtr, dwCreationDisposition: ULONG, dwFlagsAndAttributes: ULONG, hTemplateFile: HANDLE) -> HANDLE | t.State: pass
|
||||
|
||||
def ReadFile(hFile: HANDLE, lpBuffer: VOIDPTR, nNumberOfBytesToRead: ULONG, lpNumberOfBytesRead: ULONG | t.CPtr, lpOverlapped: OVERLAPPED | t.CPtr) -> BOOL | t.State: pass
|
||||
|
||||
def WriteFile(hFile: HANDLE, lpBuffer: t.CConst | VOIDPTR, nNumberOfBytesToWrite: ULONG, lpNumberOfBytesWritten: ULONG | t.CPtr, lpOverlapped: OVERLAPPED | t.CPtr) -> BOOL | t.State: pass
|
||||
|
||||
def SetFilePointer(hFile: HANDLE, lDistanceToMove: LONG, lpDistanceToMoveHigh: LONG | t.CPtr, dwMoveMethod: ULONG) -> LONG | t.State: pass
|
||||
|
||||
def SetFilePointerEx(hFile: HANDLE, liDistanceToMove: LARGE_INTEGER | t.CPtr, lpNewFilePointer: LARGE_INTEGER | t.CPtr, dwMoveMethod: ULONG) -> BOOL | t.State: pass
|
||||
|
||||
def GetFileSize(hFile: HANDLE, lpFileSizeHigh: ULONG | t.CPtr) -> ULONG | t.State: pass
|
||||
|
||||
def GetFileSizeEx(hFile: HANDLE, lpFileSize: LARGE_INTEGER | t.CPtr) -> BOOL | t.State: pass
|
||||
|
||||
def SetEndOfFile(hFile: HANDLE) -> BOOL | t.State: pass
|
||||
|
||||
def FlushFileBuffers(hFile: HANDLE) -> BOOL | t.State: pass
|
||||
|
||||
def GetFileType(hFile: HANDLE) -> ULONG | t.State: pass
|
||||
|
||||
def GetFileAttributesA(lpFileName: LPCSTR) -> ULONG | t.State: pass
|
||||
|
||||
def GetFileAttributesW(lpFileName: LPCWSTR) -> ULONG | t.State: pass
|
||||
|
||||
def SetFileAttributesA(lpFileName: LPCSTR, dwFileAttributes: ULONG) -> BOOL | t.State: pass
|
||||
|
||||
def SetFileAttributesW(lpFileName: LPCWSTR, dwFileAttributes: ULONG) -> BOOL | t.State: pass
|
||||
|
||||
def DeleteFileA(lpFileName: LPCSTR) -> BOOL | t.State: pass
|
||||
|
||||
def DeleteFileW(lpFileName: LPCWSTR) -> BOOL | t.State: pass
|
||||
|
||||
def MoveFileA(lpExistingFileName: LPCSTR, lpNewFileName: LPCSTR) -> BOOL | t.State: pass
|
||||
|
||||
def MoveFileW(lpExistingFileName: LPCWSTR, lpNewFileName: LPCWSTR) -> BOOL | t.State: pass
|
||||
|
||||
def MoveFileExA(lpExistingFileName: LPCSTR, lpNewFileName: LPCSTR, dwFlags: ULONG) -> BOOL | t.State: pass
|
||||
|
||||
def MoveFileExW(lpExistingFileName: LPCWSTR, lpNewFileName: LPCWSTR, dwFlags: ULONG) -> BOOL | t.State: pass
|
||||
|
||||
def CopyFileA(lpExistingFileName: LPCSTR, lpNewFileName: LPCSTR, bFailIfExists: BOOL) -> BOOL | t.State: pass
|
||||
|
||||
def CopyFileW(lpExistingFileName: LPCWSTR, lpNewFileName: LPCWSTR, bFailIfExists: BOOL) -> BOOL | t.State: pass
|
||||
|
||||
def CreateDirectoryA(lpPathName: LPCSTR, lpSecurityAttributes: SECURITY_ATTRIBUTES | t.CPtr) -> BOOL | t.State: pass
|
||||
|
||||
def CreateDirectoryW(lpPathName: LPCWSTR, lpSecurityAttributes: SECURITY_ATTRIBUTES | t.CPtr) -> BOOL | t.State: pass
|
||||
|
||||
def RemoveDirectoryA(lpPathName: LPCSTR) -> BOOL | t.State: pass
|
||||
|
||||
def RemoveDirectoryW(lpPathName: LPCWSTR) -> BOOL | t.State: pass
|
||||
|
||||
def FindFirstFileA(lpFileName: LPCSTR, lpFindFileData: WIN32_FIND_DATAA | t.CPtr) -> HANDLE | t.State: pass
|
||||
|
||||
def FindFirstFileW(lpFileName: LPCWSTR, lpFindFileData: WIN32_FIND_DATAW | t.CPtr) -> HANDLE | t.State: pass
|
||||
|
||||
def FindNextFileA(hFindFile: HANDLE, lpFindFileData: WIN32_FIND_DATAA | t.CPtr) -> BOOL | t.State: pass
|
||||
|
||||
def FindNextFileW(hFindFile: HANDLE, lpFindFileData: WIN32_FIND_DATAW | t.CPtr) -> BOOL | t.State: pass
|
||||
|
||||
def FindClose(hFindFile: HANDLE) -> BOOL | t.State: pass
|
||||
|
||||
def GetStdHandle(nStdHandle: ULONG) -> HANDLE | t.State: pass
|
||||
|
||||
def SetStdHandle(nStdHandle: ULONG, hHandle: HANDLE) -> BOOL | t.State: pass
|
||||
|
||||
def GetFileInformationByHandle(hFile: HANDLE, lpFileInformation: BY_HANDLE_FILE_INFORMATION | t.CPtr) -> BOOL | t.State: pass
|
||||
|
||||
def LockFile(hFile: HANDLE, dwFileOffsetLow: ULONG, dwFileOffsetHigh: ULONG, nNumberOfBytesToLockLow: ULONG, nNumberOfBytesToLockHigh: ULONG) -> BOOL | t.State: pass
|
||||
|
||||
def UnlockFile(hFile: HANDLE, dwFileOffsetLow: ULONG, dwFileOffsetHigh: ULONG, nNumberOfBytesToUnlockLow: ULONG, nNumberOfBytesToUnlockHigh: ULONG) -> BOOL | t.State: pass
|
||||
|
||||
def GetTempPathA(nBufferLength: ULONG, lpBuffer: CHARPTR) -> ULONG | t.State: pass
|
||||
|
||||
def GetTempPathW(nBufferLength: ULONG, lpBuffer: WCHARPTR) -> ULONG | t.State: pass
|
||||
|
||||
def GetTempFileNameA(lpPathName: LPCSTR, lpPrefixString: LPCSTR, uUnique: UINT, lpTempFileName: CHARPTR) -> UINT | t.State: pass
|
||||
|
||||
def GetTempFileNameW(lpPathName: LPCWSTR, lpPrefixString: LPCWSTR, uUnique: UINT, lpTempFileName: WCHARPTR) -> UINT | t.State: pass
|
||||
|
||||
def GetCurrentDirectoryA(nBufferLength: ULONG, lpBuffer: CHARPTR) -> ULONG | t.State: pass
|
||||
|
||||
def GetCurrentDirectoryW(nBufferLength: ULONG, lpBuffer: WCHARPTR) -> ULONG | t.State: pass
|
||||
|
||||
def SetCurrentDirectoryA(lpPathName: LPCSTR) -> BOOL | t.State: pass
|
||||
|
||||
def SetCurrentDirectoryW(lpPathName: LPCWSTR) -> BOOL | t.State: pass
|
||||
|
||||
def GetModuleFileNameA(hModule: HANDLE, lpFilename: CHARPTR, nSize: ULONG) -> ULONG | t.State: pass
|
||||
|
||||
def GetModuleFileNameW(hModule: HANDLE, lpFilename: WCHARPTR, nSize: ULONG) -> ULONG | t.State: pass
|
||||
|
||||
|
||||
HANDLE_FLAG_INHERIT: t.CDefine = 0x00000001
|
||||
HANDLE_FLAG_PROTECT_FROM_CLOSE: t.CDefine = 0x00000002
|
||||
|
||||
def CreatePipe(hReadPipe: HANDLE | t.CPtr, hWritePipe: HANDLE | t.CPtr, lpPipeAttributes: SECURITY_ATTRIBUTES | t.CPtr, nSize: ULONG) -> BOOL | t.State: pass
|
||||
|
||||
def SetHandleInformation(hObject: HANDLE, dwMask: ULONG, dwFlags: ULONG) -> BOOL | t.State: pass
|
||||
|
||||
def DuplicateHandle(hSourceProcessHandle: HANDLE, hSourceHandle: HANDLE, hTargetProcessHandle: HANDLE, lpTargetHandle: HANDLE | t.CPtr, dwDesiredAccess: ULONG, bInheritHandle: BOOL, dwOptions: ULONG) -> BOOL | t.State: pass
|
||||
|
||||
|
||||
DUPLICATE_SAME_ACCESS: t.CDefine = 0x00000002
|
||||
@@ -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"}
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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}}
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -0,0 +1 @@
|
||||
{}
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -0,0 +1,777 @@
|
||||
import t, c
|
||||
|
||||
|
||||
# ============================================================
|
||||
# PyObject — 所有 Python 对象的基类
|
||||
# ============================================================
|
||||
class PyObject:
|
||||
ob_refcnt: t.CLong
|
||||
ob_type: t.CPtr
|
||||
|
||||
|
||||
# ============================================================
|
||||
# 引用计数
|
||||
# ============================================================
|
||||
def Py_INCREF(op: PyObject | t.CPtr) -> t.CVoid | t.State: pass
|
||||
def Py_DECREF(op: PyObject | t.CPtr) -> t.CVoid | t.State: pass
|
||||
def Py_XINCREF(op: PyObject | t.CPtr) -> t.CVoid | t.State: pass
|
||||
def Py_XDECREF(op: PyObject | t.CPtr) -> t.CVoid | t.State: pass
|
||||
def Py_DecRef(op: PyObject | t.CPtr) -> t.CVoid | t.State: pass
|
||||
|
||||
|
||||
# ============================================================
|
||||
# 解释器初始化/终止
|
||||
# ============================================================
|
||||
def Py_Initialize() -> t.CVoid | t.State: pass
|
||||
def Py_Finalize() -> t.CVoid | t.State: pass
|
||||
def Py_InitializeEx(initsigs: t.CInt) -> t.CVoid | t.State: pass
|
||||
def Py_FinalizeEx() -> t.CInt | t.State: pass
|
||||
def Py_IsInitialized() -> t.CInt | t.State: pass
|
||||
|
||||
|
||||
# ============================================================
|
||||
# PyConfig
|
||||
# ============================================================
|
||||
class PySTATUS:
|
||||
func: t.CConst | str
|
||||
err_msg: t.CConst | str
|
||||
exitcode: t.CInt
|
||||
|
||||
class PyPreConfig:
|
||||
_config_version: t.CInt
|
||||
_config_init: t.CInt
|
||||
parse_argv: t.CInt
|
||||
isolated: t.CInt
|
||||
use_environment: t.CInt
|
||||
utf8_mode: t.CInt
|
||||
coerce_c_locale: t.CInt
|
||||
C_locale_warnings: t.CInt
|
||||
allocator: t.CInt
|
||||
dev_mode: t.CInt
|
||||
|
||||
class PyWideStringList:
|
||||
length: t.CSizeT
|
||||
items: t.CPtr
|
||||
|
||||
class PyConfig:
|
||||
_config_version: t.CInt
|
||||
_config_init: t.CInt
|
||||
isolated: t.CInt
|
||||
use_environment: t.CInt
|
||||
dev_mode: t.CInt
|
||||
install_signal_handlers: t.CInt
|
||||
use_hash_seed: t.CInt
|
||||
hash_seed: t.CUnsignedLong
|
||||
faulthandler: t.CInt
|
||||
tracemalloc: t.CInt
|
||||
import_time: t.CInt
|
||||
show_ref_count: t.CInt
|
||||
dump_refs: t.CInt
|
||||
dump_refs_file: t.CConst | str
|
||||
malloc_stats: t.CInt
|
||||
filesystem_errors: t.CInt
|
||||
pycache_prefix: t.CConst | str
|
||||
parse_argv: t.CInt
|
||||
argv: PyWideStringList
|
||||
program_name: t.CConst | str
|
||||
xoptions: PyWideStringList
|
||||
warnoptions: PyWideStringList
|
||||
site_import: t.CInt
|
||||
bytes_warning: t.CInt
|
||||
warn_default_encoding: t.CInt
|
||||
inspect: t.CInt
|
||||
interactive: t.CInt
|
||||
optimization_level: t.CInt
|
||||
parser_debug: t.CInt
|
||||
verbose: t.CInt
|
||||
quiet: t.CInt
|
||||
home: t.CConst | str
|
||||
pythonpath_env: t.CConst | str
|
||||
module_search_paths: PyWideStringList
|
||||
module_search_paths_set: t.CInt
|
||||
executable: t.CConst | str
|
||||
base_executable: t.CConst | str
|
||||
prefix: t.CConst | str
|
||||
base_prefix: t.CConst | str
|
||||
exec_prefix: t.CConst | str
|
||||
base_exec_prefix: t.CConst | str
|
||||
platlibdir: t.CConst | str
|
||||
stdio_filename: t.CConst | str
|
||||
|
||||
def PyConfig_InitPythonConfig(config: PyConfig | t.CPtr) -> t.CVoid | t.State: pass
|
||||
def PyConfig_InitIsolatedConfig(config: PyConfig | t.CPtr) -> t.CVoid | t.State: pass
|
||||
def PyConfig_Clear(config: PyConfig | t.CPtr) -> t.CVoid | t.State: pass
|
||||
def PyConfig_Read(config: PyConfig | t.CPtr) -> PySTATUS | t.State: pass
|
||||
def Py_InitializeFromConfig(config: PyConfig | t.CPtr) -> PySTATUS | t.State: pass
|
||||
def Py_DecodeLocale(s: t.CConst | str) -> str | t.State: pass
|
||||
def PyStatus_Exception(status: PySTATUS) -> t.CInt | t.State: pass
|
||||
|
||||
|
||||
# ============================================================
|
||||
# 整数操作 (PyLong)
|
||||
# ============================================================
|
||||
def PyLong_FromLong(v: t.CLong) -> PyObject | t.CPtr | t.State: pass
|
||||
def PyLong_FromUnsignedLong(v: t.CUnsignedLong) -> PyObject | t.CPtr | t.State: pass
|
||||
def PyLong_FromLongLong(v: t.CLong) -> PyObject | t.CPtr | t.State: pass
|
||||
def PyLong_FromUnsignedLongLong(v: t.CUnsignedLong) -> PyObject | t.CPtr | t.State: pass
|
||||
def PyLong_FromSsize_t(v: t.CPtrDiffT) -> PyObject | t.CPtr | t.State: pass
|
||||
def PyLong_FromSize_t(v: t.CSizeT) -> PyObject | t.CPtr | t.State: pass
|
||||
def PyLong_FromDouble(v: t.CDouble) -> PyObject | t.CPtr | t.State: pass
|
||||
def PyLong_AsLong(obj: PyObject | t.CPtr) -> t.CLong | t.State: pass
|
||||
def PyLong_AsUnsignedLong(obj: PyObject | t.CPtr) -> t.CUnsignedLong | t.State: pass
|
||||
def PyLong_AsLongLong(obj: PyObject | t.CPtr) -> t.CLong | t.State: pass
|
||||
def PyLong_AsUnsignedLongLong(obj: PyObject | t.CPtr) -> t.CUnsignedLong | t.State: pass
|
||||
def PyLong_AsDouble(obj: PyObject | t.CPtr) -> t.CDouble | t.State: pass
|
||||
def PyLong_AsSsize_t(obj: PyObject | t.CPtr) -> t.CPtrDiffT | t.State: pass
|
||||
def PyLong_AsSize_t(obj: PyObject | t.CPtr) -> t.CSizeT | t.State: pass
|
||||
|
||||
|
||||
# ============================================================
|
||||
# 浮点数操作 (PyFloat)
|
||||
# ============================================================
|
||||
def PyFloat_FromDouble(v: t.CDouble) -> PyObject | t.CPtr | t.State: pass
|
||||
def PyFloat_AsDouble(obj: PyObject | t.CPtr) -> t.CDouble | t.State: pass
|
||||
def PyFloat_FromString(s: PyObject | t.CPtr) -> PyObject | t.CPtr | t.State: pass
|
||||
|
||||
|
||||
# ============================================================
|
||||
# 字符串操作 (PyUnicode / PyBytes)
|
||||
# ============================================================
|
||||
def PyUnicode_FromString(u: t.CConst | str) -> PyObject | t.CPtr | t.State: pass
|
||||
def PyUnicode_FromStringAndSize(u: t.CConst | str, size: t.CSizeT) -> PyObject | t.CPtr | t.State: pass
|
||||
def PyUnicode_FromFormat(fmt: t.CConst | str) -> PyObject | t.CPtr | t.State: pass
|
||||
def PyUnicode_AsUTF8(obj: PyObject | t.CPtr) -> str | t.State: pass
|
||||
def PyUnicode_AsUTF8AndSize(obj: PyObject | t.CPtr, size: t.CPtrDiffT | t.CPtr) -> str | t.State: pass
|
||||
def PyUnicode_AsWideChar(obj: PyObject | t.CPtr, wbuf: t.CPtr, bufsize: t.CSizeT) -> t.CSizeT | t.State: pass
|
||||
def PyUnicode_GetLength(obj: PyObject | t.CPtr) -> t.CPtrDiffT | t.State: pass
|
||||
def PyUnicode_ReadChar(obj: PyObject | t.CPtr, idx: t.CSizeT) -> t.CUInt32T | t.State: pass
|
||||
def PyUnicode_WriteChar(obj: PyObject | t.CPtr, idx: t.CSizeT, ch: t.CUInt32T) -> t.CInt | t.State: pass
|
||||
def PyUnicode_Compare(l: PyObject | t.CPtr, r: PyObject | t.CPtr) -> t.CInt | t.State: pass
|
||||
def PyUnicode_Concat(l: PyObject | t.CPtr, r: PyObject | t.CPtr) -> PyObject | t.CPtr | t.State: pass
|
||||
def PyUnicode_Contains(container: PyObject | t.CPtr, element: PyObject | t.CPtr) -> t.CInt | t.State: pass
|
||||
def PyUnicode_Format(fmt: PyObject | t.CPtr, args: PyObject | t.CPtr) -> PyObject | t.CPtr | t.State: pass
|
||||
def PyUnicode_InternInPlace(s: PyObject | t.CPtr | t.CPtr) -> t.CVoid | t.State: pass
|
||||
def PyUnicode_InternFromString(u: t.CConst | str) -> PyObject | t.CPtr | t.State: pass
|
||||
|
||||
def PyBytes_FromString(v: t.CConst | str) -> PyObject | t.CPtr | t.State: pass
|
||||
def PyBytes_FromStringAndSize(v: t.CConst | str, size: t.CSizeT) -> PyObject | t.CPtr | t.State: pass
|
||||
def PyBytes_AsString(obj: PyObject | t.CPtr) -> str | t.State: pass
|
||||
def PyBytes_Size(obj: PyObject | t.CPtr) -> t.CSizeT | t.State: pass
|
||||
def PyBytes_FromObject(o: PyObject | t.CPtr) -> PyObject | t.CPtr | t.State: pass
|
||||
def PyBytes_FromFormat(fmt: t.CConst | str) -> PyObject | t.CPtr | t.State: pass
|
||||
|
||||
|
||||
# ============================================================
|
||||
# 布尔 / None
|
||||
# ============================================================
|
||||
def PyBool_FromLong(v: t.CLong) -> PyObject | t.CPtr | t.State: pass
|
||||
|
||||
Py_True: PyObject | t.CPtr | t.State
|
||||
Py_False: PyObject | t.CPtr | t.State
|
||||
Py_None: PyObject | t.CPtr | t.State
|
||||
|
||||
|
||||
# ============================================================
|
||||
# 列表操作 (PyList)
|
||||
# ============================================================
|
||||
def PyList_New(len: t.CSizeT) -> PyObject | t.CPtr | t.State: pass
|
||||
def PyList_Size(lst: PyObject | t.CPtr) -> t.CSizeT | t.State: pass
|
||||
def PyList_GetItem(lst: PyObject | t.CPtr, idx: t.CSizeT) -> PyObject | t.CPtr | t.State: pass
|
||||
def PyList_SetItem(lst: PyObject | t.CPtr, idx: t.CSizeT, item: PyObject | t.CPtr) -> t.CInt | t.State: pass
|
||||
def PyList_Insert(lst: PyObject | t.CPtr, idx: t.CSizeT, item: PyObject | t.CPtr) -> t.CInt | t.State: pass
|
||||
def PyList_Append(lst: PyObject | t.CPtr, item: PyObject | t.CPtr) -> t.CInt | t.State: pass
|
||||
def PyList_GetSlice(lst: PyObject | t.CPtr, lo: t.CSizeT, hi: t.CSizeT) -> PyObject | t.CPtr | t.State: pass
|
||||
def PyList_SetSlice(lst: PyObject | t.CPtr, lo: t.CSizeT, hi: t.CSizeT, items: PyObject | t.CPtr) -> t.CInt | t.State: pass
|
||||
def PyList_Sort(lst: PyObject | t.CPtr) -> t.CInt | t.State: pass
|
||||
def PyList_Reverse(lst: PyObject | t.CPtr) -> t.CInt | t.State: pass
|
||||
def PyList_AsTuple(lst: PyObject | t.CPtr) -> PyObject | t.CPtr | t.State: pass
|
||||
|
||||
|
||||
# ============================================================
|
||||
# 元组操作 (PyTuple)
|
||||
# ============================================================
|
||||
def PyTuple_New(len: t.CSizeT) -> PyObject | t.CPtr | t.State: pass
|
||||
def PyTuple_Size(tup: PyObject | t.CPtr) -> t.CSizeT | t.State: pass
|
||||
def PyTuple_GetItem(tup: PyObject | t.CPtr, idx: t.CSizeT) -> PyObject | t.CPtr | t.State: pass
|
||||
def PyTuple_SetItem(tup: PyObject | t.CPtr, idx: t.CSizeT, item: PyObject | t.CPtr) -> t.CInt | t.State: pass
|
||||
def PyTuple_GetSlice(tup: PyObject | t.CPtr, lo: t.CSizeT, hi: t.CSizeT) -> PyObject | t.CPtr | t.State: pass
|
||||
def PyTuple_Pack(n: t.CSizeT) -> PyObject | t.CPtr | t.State: pass
|
||||
|
||||
|
||||
# ============================================================
|
||||
# 字典操作 (PyDict)
|
||||
# ============================================================
|
||||
def PyDict_New() -> PyObject | t.CPtr | t.State: pass
|
||||
def PyDict_GetItem(d: PyObject | t.CPtr, key: PyObject | t.CPtr) -> PyObject | t.CPtr | t.State: pass
|
||||
def PyDict_GetItemString(d: PyObject | t.CPtr, key: t.CConst | str) -> PyObject | t.CPtr | t.State: pass
|
||||
def PyDict_SetItem(d: PyObject | t.CPtr, key: PyObject | t.CPtr, val: PyObject | t.CPtr) -> t.CInt | t.State: pass
|
||||
def PyDict_SetItemString(d: PyObject | t.CPtr, key: t.CConst | str, val: PyObject | t.CPtr) -> t.CInt | t.State: pass
|
||||
def PyDict_DelItem(d: PyObject | t.CPtr, key: PyObject | t.CPtr) -> t.CInt | t.State: pass
|
||||
def PyDict_DelItemString(d: PyObject | t.CPtr, key: t.CConst | str) -> t.CInt | t.State: pass
|
||||
def PyDict_Size(d: PyObject | t.CPtr) -> t.CSizeT | t.State: pass
|
||||
def PyDict_Keys(d: PyObject | t.CPtr) -> PyObject | t.CPtr | t.State: pass
|
||||
def PyDict_Values(d: PyObject | t.CPtr) -> PyObject | t.CPtr | t.State: pass
|
||||
def PyDict_Items(d: PyObject | t.CPtr) -> PyObject | t.CPtr | t.State: pass
|
||||
def PyDict_Copy(d: PyObject | t.CPtr) -> PyObject | t.CPtr | t.State: pass
|
||||
def PyDict_Clear(d: PyObject | t.CPtr) -> t.CVoid | t.State: pass
|
||||
def PyDict_Contains(d: PyObject | t.CPtr, key: PyObject | t.CPtr) -> t.CInt | t.State: pass
|
||||
def PyDict_Next(d: PyObject | t.CPtr, pos: t.CPtrDiffT | t.CPtr, key: PyObject | t.CPtr | t.CPtr, val: PyObject | t.CPtr | t.CPtr) -> t.CInt | t.State: pass
|
||||
def PyDict_Merge(d: PyObject | t.CPtr, other: PyObject | t.CPtr, override: t.CInt) -> t.CInt | t.State: pass
|
||||
def PyDict_Update(d: PyObject | t.CPtr, other: PyObject | t.CPtr) -> t.CInt | t.State: pass
|
||||
|
||||
|
||||
# ============================================================
|
||||
# 对象通用操作
|
||||
# ============================================================
|
||||
def PyObject_Str(obj: PyObject | t.CPtr) -> PyObject | t.CPtr | t.State: pass
|
||||
def PyObject_Repr(obj: PyObject | t.CPtr) -> PyObject | t.CPtr | t.State: pass
|
||||
def PyObject_Type(obj: PyObject | t.CPtr) -> PyObject | t.CPtr | t.State: pass
|
||||
def PyObject_IsInstance(obj: PyObject | t.CPtr, cls: PyObject | t.CPtr) -> t.CInt | t.State: pass
|
||||
def PyObject_IsSubclass(obj: PyObject | t.CPtr, cls: PyObject | t.CPtr) -> t.CInt | t.State: pass
|
||||
def PyObject_HasAttr(obj: PyObject | t.CPtr, name: PyObject | t.CPtr) -> t.CInt | t.State: pass
|
||||
def PyObject_HasAttrString(obj: PyObject | t.CPtr, name: t.CConst | str) -> t.CInt | t.State: pass
|
||||
def PyObject_GetAttr(obj: PyObject | t.CPtr, name: PyObject | t.CPtr) -> PyObject | t.CPtr | t.State: pass
|
||||
def PyObject_GetAttrString(obj: PyObject | t.CPtr, name: t.CConst | str) -> PyObject | t.CPtr | t.State: pass
|
||||
def PyObject_SetAttr(obj: PyObject | t.CPtr, name: PyObject | t.CPtr, val: PyObject | t.CPtr) -> t.CInt | t.State: pass
|
||||
def PyObject_SetAttrString(obj: PyObject | t.CPtr, name: t.CConst | str, val: PyObject | t.CPtr) -> t.CInt | t.State: pass
|
||||
def PyObject_DelAttr(obj: PyObject | t.CPtr, name: PyObject | t.CPtr) -> t.CInt | t.State: pass
|
||||
def PyObject_DelAttrString(obj: PyObject | t.CPtr, name: t.CConst | str) -> t.CInt | t.State: pass
|
||||
def PyObject_Call(callable: PyObject | t.CPtr, args: PyObject | t.CPtr, kwargs: PyObject | t.CPtr) -> PyObject | t.CPtr | t.State: pass
|
||||
def PyObject_CallObject(callable: PyObject | t.CPtr, args: PyObject | t.CPtr) -> PyObject | t.CPtr | t.State: pass
|
||||
def PyObject_CallNoArgs(callable: PyObject | t.CPtr) -> PyObject | t.CPtr | t.State: pass
|
||||
def PyObject_CallOneArg(callable: PyObject | t.CPtr, arg: PyObject | t.CPtr) -> PyObject | t.CPtr | t.State: pass
|
||||
def PyObject_IsTrue(obj: PyObject | t.CPtr) -> t.CInt | t.State: pass
|
||||
def PyObject_Not(obj: PyObject | t.CPtr) -> t.CInt | t.State: pass
|
||||
def PyObject_RichCompare(o1: PyObject | t.CPtr, o2: PyObject | t.CPtr, opid: t.CInt) -> PyObject | t.CPtr | t.State: pass
|
||||
def PyObject_RichCompareBool(o1: PyObject | t.CPtr, o2: PyObject | t.CPtr, opid: t.CInt) -> t.CInt | t.State: pass
|
||||
def PyObject_Hash(obj: PyObject | t.CPtr) -> t.CLong | t.State: pass
|
||||
def PyObject_Length(obj: PyObject | t.CPtr) -> t.CSizeT | t.State: pass
|
||||
def PyObject_GetItem(obj: PyObject | t.CPtr, key: PyObject | t.CPtr) -> PyObject | t.CPtr | t.State: pass
|
||||
def PyObject_SetItem(obj: PyObject | t.CPtr, key: PyObject | t.CPtr, val: PyObject | t.CPtr) -> t.CInt | t.State: pass
|
||||
def PyObject_DelItem(obj: PyObject | t.CPtr, key: PyObject | t.CPtr) -> t.CInt | t.State: pass
|
||||
def PyObject_Dir(obj: PyObject | t.CPtr) -> PyObject | t.CPtr | t.State: pass
|
||||
def PyObject_GetIter(obj: PyObject | t.CPtr) -> PyObject | t.CPtr | t.State: pass
|
||||
def PyIter_Next(obj: PyObject | t.CPtr) -> PyObject | t.CPtr | t.State: pass
|
||||
|
||||
|
||||
# ============================================================
|
||||
# 比较常量
|
||||
# ============================================================
|
||||
Py_LT: t.CInt | t.State
|
||||
Py_LE: t.CInt | t.State
|
||||
Py_EQ: t.CInt | t.State
|
||||
Py_NE: t.CInt | t.State
|
||||
Py_GT: t.CInt | t.State
|
||||
Py_GE: t.CInt | t.State
|
||||
|
||||
|
||||
# ============================================================
|
||||
# 模块操作
|
||||
# ============================================================
|
||||
def PyImport_ImportModule(name: t.CConst | str) -> PyObject | t.CPtr | t.State: pass
|
||||
def PyImport_Import(name: PyObject | t.CPtr) -> PyObject | t.CPtr | t.State: pass
|
||||
def PyImport_ImportModuleLevelObject(name: PyObject | t.CPtr, globs: PyObject | t.CPtr, locs: PyObject | t.CPtr, fromlist: PyObject | t.CPtr, level: t.CInt) -> PyObject | t.CPtr | t.State: pass
|
||||
def PyImport_ReloadModule(mod: PyObject | t.CPtr) -> PyObject | t.CPtr | t.State: pass
|
||||
def PyImport_AddModule(name: t.CConst | str) -> PyObject | t.CPtr | t.State: pass
|
||||
def PyImport_GetModuleDict() -> PyObject | t.CPtr | t.State: pass
|
||||
def PyImport_ImportModuleEx(name: t.CConst | str, globs: PyObject | t.CPtr, locs: PyObject | t.CPtr, fromlist: PyObject | t.CPtr) -> PyObject | t.CPtr | t.State: pass
|
||||
|
||||
|
||||
# ============================================================
|
||||
# 模块创建
|
||||
# ============================================================
|
||||
class PyMethodDef:
|
||||
ml_name: t.CConst | str
|
||||
ml_meth: t.CPtr
|
||||
ml_flags: t.CInt
|
||||
ml_doc: t.CConst | str
|
||||
|
||||
class PyModuleDef_Base:
|
||||
ob_base: PyObject
|
||||
m_init: t.CPtr
|
||||
m_index: t.CSizeT
|
||||
m_copy: PyObject | t.CPtr
|
||||
|
||||
class PyModuleDef:
|
||||
m_base: PyModuleDef_Base
|
||||
m_name: t.CConst | str
|
||||
m_doc: t.CConst | str
|
||||
m_size: t.CPtrDiffT
|
||||
m_methods: PyMethodDef | t.CPtr
|
||||
m_slots: t.CPtr
|
||||
m_traverse: t.CPtr
|
||||
m_clear: t.CPtr
|
||||
m_free: t.CPtr
|
||||
|
||||
def PyModule_Create(mod: PyModuleDef | t.CPtr) -> PyObject | t.CPtr | t.State: pass
|
||||
def PyModule_Create2(mod: PyModuleDef | t.CPtr, ver: t.CInt) -> PyObject | t.CPtr | t.State: pass
|
||||
def PyModule_GetName(mod: PyObject | t.CPtr) -> str | t.State: pass
|
||||
def PyModule_GetDict(mod: PyObject | t.CPtr) -> PyObject | t.CPtr | t.State: pass
|
||||
def PyModule_GetFilenameObject(mod: PyObject | t.CPtr) -> PyObject | t.CPtr | t.State: pass
|
||||
def PyModule_AddObject(mod: PyObject | t.CPtr, name: t.CConst | str, val: PyObject | t.CPtr) -> t.CInt | t.State: pass
|
||||
def PyModule_AddObjectRef(mod: PyObject | t.CPtr, name: t.CConst | str, val: PyObject | t.CPtr) -> t.CInt | t.State: pass
|
||||
def PyModule_AddIntConstant(mod: PyObject | t.CPtr, name: t.CConst | str, val: t.CLong) -> t.CInt | t.State: pass
|
||||
def PyModule_AddStringConstant(mod: PyObject | t.CPtr, name: t.CConst | str, val: t.CConst | str) -> t.CInt | t.State: pass
|
||||
|
||||
|
||||
# ============================================================
|
||||
# GIL 管理
|
||||
# ============================================================
|
||||
def PyGILState_Ensure() -> t.CInt | t.State: pass
|
||||
def PyGILState_Release(state: t.CInt) -> t.CVoid | t.State: pass
|
||||
def PyEval_SaveThread() -> t.CPtr | t.State: pass
|
||||
def PyEval_RestoreThread(tstate: t.CPtr) -> t.CVoid | t.State: pass
|
||||
def PyEval_AcquireThread(tstate: t.CPtr) -> t.CVoid | t.State: pass
|
||||
def PyEval_ReleaseThread(tstate: t.CPtr) -> t.CVoid | t.State: pass
|
||||
def PyEval_AcquireLock() -> t.CVoid | t.State: pass
|
||||
def PyEval_ReleaseLock() -> t.CVoid | t.State: pass
|
||||
def PyEval_ThreadsInitialized() -> t.CInt | t.State: pass
|
||||
def PyEval_InitThreads() -> t.CVoid | t.State: pass
|
||||
|
||||
|
||||
# ============================================================
|
||||
# 错误处理
|
||||
# ============================================================
|
||||
def PyErr_Occurred() -> PyObject | t.CPtr | t.State: pass
|
||||
def PyErr_Clear() -> t.CVoid | t.State: pass
|
||||
def PyErr_Fetch(tp: PyObject | t.CPtr | t.CPtr, val: PyObject | t.CPtr | t.CPtr, tb: PyObject | t.CPtr | t.CPtr) -> t.CVoid | t.State: pass
|
||||
def PyErr_Restore(tp: PyObject | t.CPtr, val: PyObject | t.CPtr, tb: PyObject | t.CPtr) -> t.CVoid | t.State: pass
|
||||
def PyErr_NormalizeException(tp: PyObject | t.CPtr | t.CPtr, val: PyObject | t.CPtr | t.CPtr, tb: PyObject | t.CPtr | t.CPtr) -> t.CVoid | t.State: pass
|
||||
def PyErr_SetString(tp: PyObject | t.CPtr, msg: t.CConst | str) -> t.CVoid | t.State: pass
|
||||
def PyErr_SetObject(tp: PyObject | t.CPtr, val: PyObject | t.CPtr) -> t.CVoid | t.State: pass
|
||||
def PyErr_BadArgument() -> t.CPtr | t.State: pass
|
||||
def PyErr_NoMemory() -> t.CPtr | t.State: pass
|
||||
def PyErr_Print() -> t.CVoid | t.State: pass
|
||||
def PyErr_ExceptionMatches(exc: PyObject | t.CPtr) -> t.CInt | t.State: pass
|
||||
def PyErr_GivenExceptionMatches(given: PyObject | t.CPtr, exc: PyObject | t.CPtr) -> t.CInt | t.State: pass
|
||||
|
||||
|
||||
# ============================================================
|
||||
# 内置异常类型
|
||||
# ============================================================
|
||||
PyExc_BaseException: PyObject | t.CPtr | t.State
|
||||
PyExc_Exception: PyObject | t.CPtr | t.State
|
||||
PyExc_TypeError: PyObject | t.CPtr | t.State
|
||||
PyExc_ValueError: PyObject | t.CPtr | t.State
|
||||
PyExc_RuntimeError: PyObject | t.CPtr | t.State
|
||||
PyExc_KeyError: PyObject | t.CPtr | t.State
|
||||
PyExc_IndexError: PyObject | t.CPtr | t.State
|
||||
PyExc_AttributeError: PyObject | t.CPtr | t.State
|
||||
PyExc_ImportError: PyObject | t.CPtr | t.State
|
||||
PyExc_OSError: PyObject | t.CPtr | t.State
|
||||
PyExc_IOError: PyObject | t.CPtr | t.State
|
||||
PyExc_ZeroDivisionError: PyObject | t.CPtr | t.State
|
||||
PyExc_OverflowError: PyObject | t.CPtr | t.State
|
||||
PyExc_MemoryError: PyObject | t.CPtr | t.State
|
||||
PyExc_NameError: PyObject | t.CPtr | t.State
|
||||
PyExc_StopIteration: PyObject | t.CPtr | t.State
|
||||
PyExc_NotImplementedError: PyObject | t.CPtr | t.State
|
||||
PyExc_SyntaxError: PyObject | t.CPtr | t.State
|
||||
PyExc_FileNotFoundError: PyObject | t.CPtr | t.State
|
||||
PyExc_PermissionError: PyObject | t.CPtr | t.State
|
||||
PyExc_IsADirectoryError: PyObject | t.CPtr | t.State
|
||||
PyExc_NotADirectoryError: PyObject | t.CPtr | t.State
|
||||
|
||||
|
||||
# ============================================================
|
||||
# 内置函数
|
||||
# ============================================================
|
||||
def Py_BuildValue(fmt: t.CConst | str) -> PyObject | t.CPtr | t.State: pass
|
||||
def Py_VaBuildValue(fmt: t.CConst | str, va: t.CPtr) -> PyObject | t.CPtr | t.State: pass
|
||||
|
||||
|
||||
# ============================================================
|
||||
# 类型检查
|
||||
# ============================================================
|
||||
def PyLong_Check(obj: PyObject | t.CPtr) -> t.CInt | t.State: pass
|
||||
def PyFloat_Check(obj: PyObject | t.CPtr) -> t.CInt | t.State: pass
|
||||
def PyUnicode_Check(obj: PyObject | t.CPtr) -> t.CInt | t.State: pass
|
||||
def PyBytes_Check(obj: PyObject | t.CPtr) -> t.CInt | t.State: pass
|
||||
def PyList_Check(obj: PyObject | t.CPtr) -> t.CInt | t.State: pass
|
||||
def PyTuple_Check(obj: PyObject | t.CPtr) -> t.CInt | t.State: pass
|
||||
def PyDict_Check(obj: PyObject | t.CPtr) -> t.CInt | t.State: pass
|
||||
def PyBool_Check(obj: PyObject | t.CPtr) -> t.CInt | t.State: pass
|
||||
def PyNone_Check(obj: PyObject | t.CPtr) -> t.CInt | t.State: pass
|
||||
|
||||
|
||||
# ============================================================
|
||||
# 内存管理
|
||||
# ============================================================
|
||||
def PyMem_Malloc(size: t.CSizeT) -> t.CPtr | t.State: pass
|
||||
def PyMem_Realloc(ptr: t.CPtr, size: t.CSizeT) -> t.CPtr | t.State: pass
|
||||
def PyMem_Free(ptr: t.CPtr) -> t.CVoid | t.State: pass
|
||||
def PyMem_Calloc(nelem: t.CSizeT, elsize: t.CSizeT) -> t.CPtr | t.State: pass
|
||||
def PyObject_Malloc(size: t.CSizeT) -> t.CPtr | t.State: pass
|
||||
def PyObject_Realloc(ptr: t.CPtr, size: t.CSizeT) -> t.CPtr | t.State: pass
|
||||
def PyObject_Free(ptr: t.CPtr) -> t.CVoid | t.State: pass
|
||||
def PyObject_Calloc(nelem: t.CSizeT, elsize: t.CSizeT) -> t.CPtr | t.State: pass
|
||||
def PyObject_Init(obj: PyObject | t.CPtr, tp: t.CPtr) -> PyObject | t.CPtr | t.State: pass
|
||||
def PyObject_InitVar(obj: PyObject | t.CPtr, tp: t.CPtr, size: t.CSizeT) -> PyObject | t.CPtr | t.State: pass
|
||||
|
||||
|
||||
# ============================================================
|
||||
# 文件操作
|
||||
# ============================================================
|
||||
def PyFile_FromString(filename: t.CConst | str, mode: t.CConst | str) -> PyObject | t.CPtr | t.State: pass
|
||||
def PyFile_AsFile(file: PyObject | t.CPtr) -> t.CPtr | t.State: pass
|
||||
def PyFile_WriteObject(obj: PyObject | t.CPtr, file: PyObject | t.CPtr, flags: t.CInt) -> t.CInt | t.State: pass
|
||||
def PyFile_WriteString(s: t.CConst | str, file: PyObject | t.CPtr) -> t.CInt | t.State: pass
|
||||
|
||||
|
||||
# ============================================================
|
||||
# 编译/执行
|
||||
# ============================================================
|
||||
def Py_CompileString(s: t.CConst | str, filename: t.CConst | str, start: t.CInt) -> PyObject | t.CPtr | t.State: pass
|
||||
def PyEval_EvalCode(code: PyObject | t.CPtr, globs: PyObject | t.CPtr, locs: PyObject | t.CPtr) -> PyObject | t.CPtr | t.State: pass
|
||||
def PyEval_EvalCodeEx(code: PyObject | t.CPtr, globs: PyObject | t.CPtr, locs: PyObject | t.CPtr, args: PyObject | t.CPtr | t.CPtr, argc: t.CInt, kws: PyObject | t.CPtr | t.CPtr, kwc: t.CInt, defs: PyObject | t.CPtr | t.CPtr, defc: t.CInt, kwdefs: PyObject | t.CPtr, closure: PyObject | t.CPtr) -> PyObject | t.CPtr | t.State: pass
|
||||
def PyEval_EvalFrame(frame: t.CPtr) -> PyObject | t.CPtr | t.State: pass
|
||||
def PyEval_CallObject(callable: PyObject | t.CPtr, args: PyObject | t.CPtr) -> PyObject | t.CPtr | t.State: pass
|
||||
def PyEval_CallFunction(callable: PyObject | t.CPtr, fmt: t.CConst | str) -> PyObject | t.CPtr | t.State: pass
|
||||
def PyEval_CallMethod(obj: PyObject | t.CPtr, method: t.CConst | str, fmt: t.CConst | str) -> PyObject | t.CPtr | t.State: pass
|
||||
|
||||
|
||||
# ============================================================
|
||||
# PyRun
|
||||
# ============================================================
|
||||
def PyRun_SimpleString(cmd: t.CConst | str) -> t.CInt | t.State: pass
|
||||
def PyRun_SimpleFile(fp: t.CPtr, filename: t.CConst | str) -> t.CInt | t.State: pass
|
||||
def PyRun_AnyFile(fp: t.CPtr, filename: t.CConst | str) -> t.CInt | t.State: pass
|
||||
def PyRun_String(s: t.CConst | str, start: t.CInt, globs: PyObject | t.CPtr, locs: PyObject | t.CPtr) -> PyObject | t.CPtr | t.State: pass
|
||||
def PyRun_File(fp: t.CPtr, filename: t.CConst | str, start: t.CInt, globs: PyObject | t.CPtr, locs: PyObject | t.CPtr) -> PyObject | t.CPtr | t.State: pass
|
||||
|
||||
Py_single_input: t.CInt | t.State
|
||||
Py_file_input: t.CInt | t.State
|
||||
Py_eval_input: t.CInt | t.State
|
||||
|
||||
|
||||
# ============================================================
|
||||
# Capsule
|
||||
# ============================================================
|
||||
def PyCapsule_New(ptr: t.CPtr, name: t.CConst | str, dtor: t.CPtr) -> PyObject | t.CPtr | t.State: pass
|
||||
def PyCapsule_GetPointer(cap: PyObject | t.CPtr, name: t.CConst | str) -> t.CPtr | t.State: pass
|
||||
def PyCapsule_GetName(cap: PyObject | t.CPtr) -> str | t.State: pass
|
||||
def PyCapsule_IsValid(cap: PyObject | t.CPtr, name: t.CConst | str) -> t.CInt | t.State: pass
|
||||
def PyCapsule_SetPointer(cap: PyObject | t.CPtr, ptr: t.CPtr) -> t.CInt | t.State: pass
|
||||
def PyCapsule_SetName(cap: PyObject | t.CPtr, name: t.CConst | str) -> t.CInt | t.State: pass
|
||||
def PyCapsule_SetDestructor(cap: PyObject | t.CPtr, dtor: t.CPtr) -> t.CInt | t.State: pass
|
||||
|
||||
|
||||
# ============================================================
|
||||
# 序列操作
|
||||
# ============================================================
|
||||
def PySequence_Check(obj: PyObject | t.CPtr) -> t.CInt | t.State: pass
|
||||
def PySequence_Size(obj: PyObject | t.CPtr) -> t.CSizeT | t.State: pass
|
||||
def PySequence_Length(obj: PyObject | t.CPtr) -> t.CSizeT | t.State: pass
|
||||
def PySequence_Concat(o1: PyObject | t.CPtr, o2: PyObject | t.CPtr) -> PyObject | t.CPtr | t.State: pass
|
||||
def PySequence_Repeat(obj: PyObject | t.CPtr, count: t.CSizeT) -> PyObject | t.CPtr | t.State: pass
|
||||
def PySequence_GetItem(obj: PyObject | t.CPtr, idx: t.CSizeT) -> PyObject | t.CPtr | t.State: pass
|
||||
def PySequence_SetItem(obj: PyObject | t.CPtr, idx: t.CSizeT, val: PyObject | t.CPtr) -> t.CInt | t.State: pass
|
||||
def PySequence_DelItem(obj: PyObject | t.CPtr, idx: t.CSizeT) -> t.CInt | t.State: pass
|
||||
def PySequence_GetSlice(obj: PyObject | t.CPtr, start: t.CSizeT, end: t.CSizeT) -> PyObject | t.CPtr | t.State: pass
|
||||
def PySequence_SetSlice(obj: PyObject | t.CPtr, start: t.CSizeT, end: t.CSizeT, val: PyObject | t.CPtr) -> t.CInt | t.State: pass
|
||||
def PySequence_DelSlice(obj: PyObject | t.CPtr, start: t.CSizeT, end: t.CSizeT) -> t.CInt | t.State: pass
|
||||
def PySequence_Contains(obj: PyObject | t.CPtr, val: PyObject | t.CPtr) -> t.CInt | t.State: pass
|
||||
def PySequence_Index(obj: PyObject | t.CPtr, val: PyObject | t.CPtr) -> t.CSizeT | t.State: pass
|
||||
def PySequence_Count(obj: PyObject | t.CPtr, val: PyObject | t.CPtr) -> t.CSizeT | t.State: pass
|
||||
def PySequence_List(obj: PyObject | t.CPtr) -> PyObject | t.CPtr | t.State: pass
|
||||
def PySequence_Tuple(obj: PyObject | t.CPtr) -> PyObject | t.CPtr | t.State: pass
|
||||
|
||||
|
||||
# ============================================================
|
||||
# 映射操作
|
||||
# ============================================================
|
||||
def PyMapping_Check(obj: PyObject | t.CPtr) -> t.CInt | t.State: pass
|
||||
def PyMapping_Size(obj: PyObject | t.CPtr) -> t.CSizeT | t.State: pass
|
||||
def PyMapping_Length(obj: PyObject | t.CPtr) -> t.CSizeT | t.State: pass
|
||||
def PyMapping_HasKey(obj: PyObject | t.CPtr, key: PyObject | t.CPtr) -> t.CInt | t.State: pass
|
||||
def PyMapping_HasKeyString(obj: PyObject | t.CPtr, key: t.CConst | str) -> t.CInt | t.State: pass
|
||||
def PyMapping_GetItemString(obj: PyObject | t.CPtr, key: t.CConst | str) -> PyObject | t.CPtr | t.State: pass
|
||||
def PyMapping_SetItemString(obj: PyObject | t.CPtr, key: t.CConst | str, val: PyObject | t.CPtr) -> t.CInt | t.State: pass
|
||||
def PyMapping_Keys(obj: PyObject | t.CPtr) -> PyObject | t.CPtr | t.State: pass
|
||||
def PyMapping_Values(obj: PyObject | t.CPtr) -> PyObject | t.CPtr | t.State: pass
|
||||
def PyMapping_Items(obj: PyObject | t.CPtr) -> PyObject | t.CPtr | t.State: pass
|
||||
|
||||
|
||||
# ============================================================
|
||||
# 数字操作
|
||||
# ============================================================
|
||||
def PyNumber_Add(o1: PyObject | t.CPtr, o2: PyObject | t.CPtr) -> PyObject | t.CPtr | t.State: pass
|
||||
def PyNumber_Subtract(o1: PyObject | t.CPtr, o2: PyObject | t.CPtr) -> PyObject | t.CPtr | t.State: pass
|
||||
def PyNumber_Multiply(o1: PyObject | t.CPtr, o2: PyObject | t.CPtr) -> PyObject | t.CPtr | t.State: pass
|
||||
def PyNumber_MatrixMultiply(o1: PyObject | t.CPtr, o2: PyObject | t.CPtr) -> PyObject | t.CPtr | t.State: pass
|
||||
def PyNumber_FloorDivide(o1: PyObject | t.CPtr, o2: PyObject | t.CPtr) -> PyObject | t.CPtr | t.State: pass
|
||||
def PyNumber_TrueDivide(o1: PyObject | t.CPtr, o2: PyObject | t.CPtr) -> PyObject | t.CPtr | t.State: pass
|
||||
def PyNumber_Modulo(o1: PyObject | t.CPtr, o2: PyObject | t.CPtr) -> PyObject | t.CPtr | t.State: pass
|
||||
def PyNumber_Power(o1: PyObject | t.CPtr, o2: PyObject | t.CPtr, o3: PyObject | t.CPtr) -> PyObject | t.CPtr | t.State: pass
|
||||
def PyNumber_Negative(obj: PyObject | t.CPtr) -> PyObject | t.CPtr | t.State: pass
|
||||
def PyNumber_Positive(obj: PyObject | t.CPtr) -> PyObject | t.CPtr | t.State: pass
|
||||
def PyNumber_Absolute(obj: PyObject | t.CPtr) -> PyObject | t.CPtr | t.State: pass
|
||||
def PyNumber_Invert(obj: PyObject | t.CPtr) -> PyObject | t.CPtr | t.State: pass
|
||||
def PyNumber_Lshift(o1: PyObject | t.CPtr, o2: PyObject | t.CPtr) -> PyObject | t.CPtr | t.State: pass
|
||||
def PyNumber_Rshift(o1: PyObject | t.CPtr, o2: PyObject | t.CPtr) -> PyObject | t.CPtr | t.State: pass
|
||||
def PyNumber_And(o1: PyObject | t.CPtr, o2: PyObject | t.CPtr) -> PyObject | t.CPtr | t.State: pass
|
||||
def PyNumber_Xor(o1: PyObject | t.CPtr, o2: PyObject | t.CPtr) -> PyObject | t.CPtr | t.State: pass
|
||||
def PyNumber_Or(o1: PyObject | t.CPtr, o2: PyObject | t.CPtr) -> PyObject | t.CPtr | t.State: pass
|
||||
def PyNumber_Index(obj: PyObject | t.CPtr) -> PyObject | t.CPtr | t.State: pass
|
||||
def PyNumber_Long(obj: PyObject | t.CPtr) -> PyObject | t.CPtr | t.State: pass
|
||||
def PyNumber_Float(obj: PyObject | t.CPtr) -> PyObject | t.CPtr | t.State: pass
|
||||
def PyNumber_Check(obj: PyObject | t.CPtr) -> t.CInt | t.State: pass
|
||||
|
||||
|
||||
# ============================================================
|
||||
# 弱引用
|
||||
# ============================================================
|
||||
def PyWeakref_NewRef(obj: PyObject | t.CPtr, cb: PyObject | t.CPtr) -> PyObject | t.CPtr | t.State: pass
|
||||
def PyWeakref_GetObject(ref: PyObject | t.CPtr) -> PyObject | t.CPtr | t.State: pass
|
||||
def PyWeakref_Check(obj: PyObject | t.CPtr) -> t.CInt | t.State: pass
|
||||
|
||||
|
||||
# ============================================================
|
||||
# 属性描述符
|
||||
# ============================================================
|
||||
class PyGetSetDef:
|
||||
name: t.CConst | str
|
||||
get: t.CPtr
|
||||
set: t.CPtr
|
||||
doc: t.CConst | str
|
||||
closure: t.CPtr
|
||||
|
||||
class PyMemberDef:
|
||||
name: t.CConst | str
|
||||
type: t.CInt
|
||||
offset: t.CPtrDiffT
|
||||
flags: t.CInt
|
||||
doc: t.CConst | str
|
||||
|
||||
|
||||
# ============================================================
|
||||
# sys 模块
|
||||
# ============================================================
|
||||
def PySys_GetObject(name: t.CConst | str) -> PyObject | t.CPtr | t.State: pass
|
||||
def PySys_SetObject(name: t.CConst | str, val: PyObject | t.CPtr) -> t.CInt | t.State: pass
|
||||
def PySys_ResetWarnOptions() -> t.CVoid | t.State: pass
|
||||
def PySys_AddWarnOption(s: PyObject | t.CPtr) -> t.CVoid | t.State: pass
|
||||
def PySYS_AddXOption(s: PyObject | t.CPtr) -> t.CVoid | t.State: pass
|
||||
def PySys_WriteStdout(fmt: t.CConst | str) -> t.CVoid | t.State: pass
|
||||
def PySys_WriteStderr(fmt: t.CConst | str) -> t.CVoid | t.State: pass
|
||||
def PySys_FormatStdout(fmt: t.CConst | str) -> t.CVoid | t.State: pass
|
||||
def PySys_FormatStderr(fmt: t.CConst | str) -> t.CVoid | t.State: pass
|
||||
|
||||
|
||||
# ============================================================
|
||||
# 内存视图
|
||||
# ============================================================
|
||||
def PyMemoryView_FromObject(obj: PyObject | t.CPtr) -> PyObject | t.CPtr | t.State: pass
|
||||
def PyMemoryView_GetContiguous(obj: PyObject | t.CPtr, btype: t.CInt, order: t.CChar) -> PyObject | t.CPtr | t.State: pass
|
||||
def PyMemoryView_Check(obj: PyObject | t.CPtr) -> t.CInt | t.State: pass
|
||||
|
||||
|
||||
# ============================================================
|
||||
# set / frozenset
|
||||
# ============================================================
|
||||
def PySet_New(iterable: PyObject | t.CPtr) -> PyObject | t.CPtr | t.State: pass
|
||||
def PySet_Add(s: PyObject | t.CPtr, key: PyObject | t.CPtr) -> t.CInt | t.State: pass
|
||||
def PySet_Discard(s: PyObject | t.CPtr, key: PyObject | t.CPtr) -> t.CInt | t.State: pass
|
||||
def PySet_Contains(s: PyObject | t.CPtr, key: PyObject | t.CPtr) -> t.CInt | t.State: pass
|
||||
def PySet_Size(s: PyObject | t.CPtr) -> t.CSizeT | t.State: pass
|
||||
def PySet_Clear(s: PyObject | t.CPtr) -> t.CVoid | t.State: pass
|
||||
def PySet_Check(obj: PyObject | t.CPtr) -> t.CInt | t.State: pass
|
||||
def PyFrozenSet_New(iterable: PyObject | t.CPtr) -> PyObject | t.CPtr | t.State: pass
|
||||
def PyFrozenSet_Check(obj: PyObject | t.CPtr) -> t.CInt | t.State: pass
|
||||
|
||||
|
||||
# ============================================================
|
||||
# slice
|
||||
# ============================================================
|
||||
def PySlice_New(start: PyObject | t.CPtr, stop: PyObject | t.CPtr, step: PyObject | t.CPtr) -> PyObject | t.CPtr | t.State: pass
|
||||
def PySlice_GetIndicesEx(sl: PyObject | t.CPtr, length: t.CSizeT, start: t.CSizeT | t.CPtr, stop: t.CSizeT | t.CPtr, step: t.CSizeT | t.CPtr, slicelen: t.CSizeT | t.CPtr) -> t.CInt | t.State: pass
|
||||
def PySlice_Unpack(sl: PyObject | t.CPtr, start: t.CPtrDiffT | t.CPtr, stop: t.CPtrDiffT | t.CPtr, step: t.CPtrDiffT | t.CPtr) -> t.CVoid | t.State: pass
|
||||
def PySlice_AdjustIndices(length: t.CSizeT, start: t.CPtrDiffT | t.CPtr, stop: t.CPtrDiffT | t.CPtr, step: t.CPtrDiffT) -> t.CSizeT | t.State: pass
|
||||
def PySlice_Check(obj: PyObject | t.CPtr) -> t.CInt | t.State: pass
|
||||
|
||||
|
||||
# ============================================================
|
||||
# 类型包装类 — 带运算符重载
|
||||
# ============================================================
|
||||
|
||||
# --- PyLongObj: Python 整数包装 ---
|
||||
class PyLongObj:
|
||||
ptr: PyObject | t.CPtr
|
||||
|
||||
def __new__(self) -> 'PyLongObj' | t.CPtr:
|
||||
return t.CPtr(malloc(PyLongObj.__sizeof__()))
|
||||
|
||||
@staticmethod
|
||||
def from_long(val: t.CLong) -> 'PyLongObj' | t.CPtr:
|
||||
obj: PyLongObj | t.CPtr = PyLongObj()
|
||||
obj.ptr = PyLong_FromLong(val)
|
||||
return obj
|
||||
|
||||
def __add__(self, other: PyLongObj | t.CPtr) -> 'PyLongObj' | t.CPtr:
|
||||
res: PyLongObj | t.CPtr = PyLongObj()
|
||||
res.ptr = PyNumber_Add(self.ptr, other.ptr)
|
||||
return res
|
||||
|
||||
def __sub__(self, other: PyLongObj | t.CPtr) -> 'PyLongObj' | t.CPtr:
|
||||
res: PyLongObj | t.CPtr = PyLongObj()
|
||||
res.ptr = PyNumber_Subtract(self.ptr, other.ptr)
|
||||
return res
|
||||
|
||||
def __mul__(self, other: PyLongObj | t.CPtr) -> 'PyLongObj' | t.CPtr:
|
||||
res: PyLongObj | t.CPtr = PyLongObj()
|
||||
res.ptr = PyNumber_Multiply(self.ptr, other.ptr)
|
||||
return res
|
||||
|
||||
def __neg__(self) -> 'PyLongObj' | t.CPtr:
|
||||
res: PyLongObj | t.CPtr = PyLongObj()
|
||||
res.ptr = PyNumber_Negative(self.ptr)
|
||||
return res
|
||||
|
||||
def to_long(self) -> t.CLong:
|
||||
return PyLong_AsLong(self.ptr)
|
||||
|
||||
def __str__(self) -> PyObject | t.CPtr:
|
||||
return PyObject_Str(self.ptr)
|
||||
|
||||
def dec_ref(self):
|
||||
Py_DecRef(self.ptr)
|
||||
|
||||
|
||||
# --- PyFloatObj: Python 浮点数包装 ---
|
||||
class PyFloatObj:
|
||||
ptr: PyObject | t.CPtr
|
||||
|
||||
def __new__(self) -> 'PyFloatObj' | t.CPtr:
|
||||
return t.CPtr(malloc(PyFloatObj.__sizeof__()))
|
||||
|
||||
@staticmethod
|
||||
def from_double(val: t.CDouble) -> 'PyFloatObj' | t.CPtr:
|
||||
obj: PyFloatObj | t.CPtr = PyFloatObj()
|
||||
obj.ptr = PyFloat_FromDouble(val)
|
||||
return obj
|
||||
|
||||
def __add__(self, other: PyFloatObj | t.CPtr) -> 'PyFloatObj' | t.CPtr:
|
||||
res: PyFloatObj | t.CPtr = PyFloatObj()
|
||||
res.ptr = PyNumber_Add(self.ptr, other.ptr)
|
||||
return res
|
||||
|
||||
def __sub__(self, other: PyFloatObj | t.CPtr) -> 'PyFloatObj' | t.CPtr:
|
||||
res: PyFloatObj | t.CPtr = PyFloatObj()
|
||||
res.ptr = PyNumber_Subtract(self.ptr, other.ptr)
|
||||
return res
|
||||
|
||||
def __mul__(self, other: PyFloatObj | t.CPtr) -> 'PyFloatObj' | t.CPtr:
|
||||
res: PyFloatObj | t.CPtr = PyFloatObj()
|
||||
res.ptr = PyNumber_Multiply(self.ptr, other.ptr)
|
||||
return res
|
||||
|
||||
def __truediv__(self, other: PyFloatObj | t.CPtr) -> 'PyFloatObj' | t.CPtr:
|
||||
res: PyFloatObj | t.CPtr = PyFloatObj()
|
||||
res.ptr = PyNumber_TrueDivide(self.ptr, other.ptr)
|
||||
return res
|
||||
|
||||
def __neg__(self) -> 'PyFloatObj' | t.CPtr:
|
||||
res: PyFloatObj | t.CPtr = PyFloatObj()
|
||||
res.ptr = PyNumber_Negative(self.ptr)
|
||||
return res
|
||||
|
||||
def to_double(self) -> t.CDouble:
|
||||
return PyFloat_AsDouble(self.ptr)
|
||||
|
||||
def __str__(self) -> PyObject | t.CPtr:
|
||||
return PyObject_Str(self.ptr)
|
||||
|
||||
def dec_ref(self):
|
||||
Py_DecRef(self.ptr)
|
||||
|
||||
|
||||
# --- PyUnicodeObj: Python 字符串包装 ---
|
||||
class PyUnicodeObj:
|
||||
ptr: PyObject | t.CPtr
|
||||
|
||||
def __new__(self) -> 'PyUnicodeObj' | t.CPtr:
|
||||
return t.CPtr(malloc(PyUnicodeObj.__sizeof__()))
|
||||
|
||||
@staticmethod
|
||||
def from_string(s: t.CChar | t.CPtr) -> 'PyUnicodeObj' | t.CPtr:
|
||||
obj: PyUnicodeObj | t.CPtr = PyUnicodeObj()
|
||||
obj.ptr = PyUnicode_FromString(s)
|
||||
return obj
|
||||
|
||||
def __add__(self, other: PyUnicodeObj | t.CPtr) -> 'PyUnicodeObj' | t.CPtr:
|
||||
res: PyUnicodeObj | t.CPtr = PyUnicodeObj()
|
||||
res.ptr = PyUnicode_Concat(self.ptr, other.ptr)
|
||||
return res
|
||||
|
||||
def __len__(self) -> t.CPtrDiffT:
|
||||
return PyUnicode_GetLength(self.ptr)
|
||||
|
||||
def as_utf8(self) -> t.CChar | t.CPtr:
|
||||
return PyUnicode_AsUTF8(self.ptr)
|
||||
|
||||
def __str__(self) -> PyObject | t.CPtr:
|
||||
return self.ptr
|
||||
|
||||
def dec_ref(self):
|
||||
Py_DecRef(self.ptr)
|
||||
|
||||
|
||||
# --- PyListObj: Python 列表包装 ---
|
||||
class PyListObj:
|
||||
ptr: PyObject | t.CPtr
|
||||
|
||||
def __new__(self) -> 'PyListObj' | t.CPtr:
|
||||
return t.CPtr(malloc(PyListObj.__sizeof__()))
|
||||
|
||||
@staticmethod
|
||||
def new() -> 'PyListObj' | t.CPtr:
|
||||
obj: PyListObj | t.CPtr = PyListObj()
|
||||
obj.ptr = PyList_New(0)
|
||||
return obj
|
||||
|
||||
def __getitem__(self, idx: t.CSizeT) -> PyObject | t.CPtr:
|
||||
return PyList_GetItem(self.ptr, idx)
|
||||
|
||||
def __setitem__(self, idx: t.CSizeT, val: PyObject | t.CPtr):
|
||||
PyList_SetItem(self.ptr, idx, val)
|
||||
|
||||
def __len__(self) -> t.CSizeT:
|
||||
return PyList_Size(self.ptr)
|
||||
|
||||
def append(self, item: PyObject | t.CPtr) -> t.CInt:
|
||||
return PyList_Append(self.ptr, item)
|
||||
|
||||
def dec_ref(self):
|
||||
Py_DecRef(self.ptr)
|
||||
|
||||
|
||||
# --- PyDictObj: Python 字典包装 ---
|
||||
class PyDictObj:
|
||||
ptr: PyObject | t.CPtr
|
||||
|
||||
def __new__(self) -> 'PyDictObj' | t.CPtr:
|
||||
return t.CPtr(malloc(PyDictObj.__sizeof__()))
|
||||
|
||||
@staticmethod
|
||||
def new() -> 'PyDictObj' | t.CPtr:
|
||||
obj: PyDictObj | t.CPtr = PyDictObj()
|
||||
obj.ptr = PyDict_New()
|
||||
return obj
|
||||
|
||||
def __getitem__(self, key: PyObject | t.CPtr) -> PyObject | t.CPtr:
|
||||
return PyDict_GetItem(self.ptr, key)
|
||||
|
||||
def __setitem__(self, key: PyObject | t.CPtr, val: PyObject | t.CPtr):
|
||||
PyDict_SetItem(self.ptr, key, val)
|
||||
|
||||
def __len__(self) -> t.CSizeT:
|
||||
return PyDict_Size(self.ptr)
|
||||
|
||||
def get_string(self, key: t.CChar | t.CPtr) -> PyObject | t.CPtr:
|
||||
return PyDict_GetItemString(self.ptr, key)
|
||||
|
||||
def set_string(self, key: t.CChar | t.CPtr, val: PyObject | t.CPtr):
|
||||
PyDict_SetItemString(self.ptr, key, val)
|
||||
|
||||
def dec_ref(self):
|
||||
Py_DecRef(self.ptr)
|
||||
@@ -0,0 +1,359 @@
|
||||
import t, c
|
||||
from t import CInt, CLong, CDouble, CPtr, CSizeT
|
||||
from stdio import printf
|
||||
import cpython
|
||||
import testcheck
|
||||
|
||||
|
||||
def test_init_finalize():
|
||||
testcheck.section("Py_Initialize / Py_Finalize")
|
||||
cpython.Py_Initialize()
|
||||
testcheck.check(cpython.Py_IsInitialized() != 0, "Py_Initialize succeeded", "Py_Initialize succeeded")
|
||||
cpython.Py_Finalize()
|
||||
testcheck.check(cpython.Py_IsInitialized() == 0, "Py_Finalize succeeded", "Py_Finalize succeeded")
|
||||
|
||||
|
||||
def test_long_operations():
|
||||
testcheck.section("PyLong operations")
|
||||
cpython.Py_Initialize()
|
||||
|
||||
# 创建整数
|
||||
py_num: cpython.PyObject | CPtr = cpython.PyLong_FromLong(12345)
|
||||
testcheck.check(py_num != 0, "PyLong_FromLong != NULL", "PyLong_FromLong != NULL")
|
||||
|
||||
# 整数转字符串
|
||||
py_str: cpython.PyObject | CPtr = cpython.PyObject_Str(py_num)
|
||||
testcheck.check(py_str != 0, "PyObject_Str != NULL", "PyObject_Str != NULL")
|
||||
|
||||
# 获取 C 字符串
|
||||
c_str: t.CChar | CPtr = cpython.PyUnicode_AsUTF8(py_str)
|
||||
testcheck.check(c_str != 0, "PyUnicode_AsUTF8 != NULL", "PyUnicode_AsUTF8 != NULL")
|
||||
printf(" PyLong_FromLong(12345) -> str = %s\n", c_str)
|
||||
|
||||
# 读取回来
|
||||
val: CLong = cpython.PyLong_AsLong(py_num)
|
||||
testcheck.check(val == 12345, "PyLong_AsLong == 12345", "PyLong_AsLong == 12345")
|
||||
|
||||
# 负数
|
||||
py_neg: cpython.PyObject | CPtr = cpython.PyLong_FromLong(-999)
|
||||
neg_val: CLong = cpython.PyLong_AsLong(py_neg)
|
||||
testcheck.check(neg_val == -999, "PyLong_FromLong(-999) == -999", "PyLong_FromLong(-999) == -999")
|
||||
|
||||
# 浮点数转整数
|
||||
py_dbl: cpython.PyObject | CPtr = cpython.PyFloat_FromDouble(3.14159)
|
||||
testcheck.check(py_dbl != 0, "PyFloat_FromDouble != NULL", "PyFloat_FromDouble != NULL")
|
||||
dbl_val: CDouble = cpython.PyFloat_AsDouble(py_dbl)
|
||||
testcheck.check(dbl_val > 3.14 and dbl_val < 3.15, "PyFloat_AsDouble ~= 3.14", "PyFloat_AsDouble ~= 3.14")
|
||||
|
||||
# 清理
|
||||
cpython.Py_DecRef(py_dbl)
|
||||
cpython.Py_DecRef(py_neg)
|
||||
cpython.Py_DecRef(py_str)
|
||||
cpython.Py_DecRef(py_num)
|
||||
|
||||
cpython.Py_Finalize()
|
||||
|
||||
|
||||
def test_string_operations():
|
||||
testcheck.section("PyUnicode operations")
|
||||
cpython.Py_Initialize()
|
||||
|
||||
# 从 C 字符串创建
|
||||
py_s1: cpython.PyObject | CPtr = cpython.PyUnicode_FromString("Hello, Viper!")
|
||||
testcheck.check(py_s1 != 0, "PyUnicode_FromString != NULL", "PyUnicode_FromString != NULL")
|
||||
|
||||
# 获取 UTF8
|
||||
utf8: t.CChar | CPtr = cpython.PyUnicode_AsUTF8(py_s1)
|
||||
testcheck.check(utf8 != 0, "AsUTF8 != NULL", "AsUTF8 != NULL")
|
||||
printf(" PyUnicode_FromString -> %s\n", utf8)
|
||||
|
||||
# 字符串长度
|
||||
length: CLong = cpython.PyUnicode_GetLength(py_s1)
|
||||
testcheck.check(length == 13, "GetLength == 13", "GetLength == 13")
|
||||
|
||||
# 字符串拼接
|
||||
py_s2: cpython.PyObject | CPtr = cpython.PyUnicode_FromString(" World")
|
||||
py_concat: cpython.PyObject | CPtr = cpython.PyUnicode_Concat(py_s1, py_s2)
|
||||
concat_utf8: t.CChar | CPtr = cpython.PyUnicode_AsUTF8(py_concat)
|
||||
testcheck.check(py_concat != 0, "Concat != NULL", "Concat != NULL")
|
||||
printf(" Concat -> %s\n", concat_utf8)
|
||||
|
||||
# 清理
|
||||
cpython.Py_DecRef(py_concat)
|
||||
cpython.Py_DecRef(py_s2)
|
||||
cpython.Py_DecRef(py_s1)
|
||||
|
||||
cpython.Py_Finalize()
|
||||
|
||||
|
||||
def test_list_operations():
|
||||
testcheck.section("PyList operations")
|
||||
cpython.Py_Initialize()
|
||||
|
||||
# 创建列表
|
||||
py_list: cpython.PyObject | CPtr = cpython.PyList_New(0)
|
||||
testcheck.check(py_list != 0, "PyList_New != NULL", "PyList_New != NULL")
|
||||
|
||||
# Append 元素
|
||||
py_i1: cpython.PyObject | CPtr = cpython.PyLong_FromLong(10)
|
||||
py_i2: cpython.PyObject | CPtr = cpython.PyLong_FromLong(20)
|
||||
py_i3: cpython.PyObject | CPtr = cpython.PyLong_FromLong(30)
|
||||
cpython.PyList_Append(py_list, py_i1)
|
||||
cpython.PyList_Append(py_list, py_i2)
|
||||
cpython.PyList_Append(py_list, py_i3)
|
||||
|
||||
# 检查大小
|
||||
list_size: CSizeT = cpython.PyList_Size(py_list)
|
||||
testcheck.check(list_size == 3, "PyList_Size == 3", "PyList_Size == 3")
|
||||
|
||||
# 获取元素
|
||||
item0: cpython.PyObject | CPtr = cpython.PyList_GetItem(py_list, 0)
|
||||
val0: CLong = cpython.PyLong_AsLong(item0)
|
||||
testcheck.check(val0 == 10, "list[0] == 10", "list[0] == 10")
|
||||
|
||||
item2: cpython.PyObject | CPtr = cpython.PyList_GetItem(py_list, 2)
|
||||
val2: CLong = cpython.PyLong_AsLong(item2)
|
||||
testcheck.check(val2 == 30, "list[2] == 30", "list[2] == 30")
|
||||
|
||||
# 清理
|
||||
cpython.Py_DecRef(py_i3)
|
||||
cpython.Py_DecRef(py_i2)
|
||||
cpython.Py_DecRef(py_i1)
|
||||
cpython.Py_DecRef(py_list)
|
||||
|
||||
cpython.Py_Finalize()
|
||||
|
||||
|
||||
def test_dict_operations():
|
||||
testcheck.section("PyDict operations")
|
||||
cpython.Py_Initialize()
|
||||
|
||||
# 创建字典
|
||||
py_dict: cpython.PyObject | CPtr = cpython.PyDict_New()
|
||||
testcheck.check(py_dict != 0, "PyDict_New != NULL", "PyDict_New != NULL")
|
||||
|
||||
# 设置键值对
|
||||
py_key1: cpython.PyObject | CPtr = cpython.PyUnicode_FromString("name")
|
||||
py_val1: cpython.PyObject | CPtr = cpython.PyUnicode_FromString("Viper")
|
||||
cpython.PyDict_SetItem(py_dict, py_key1, py_val1)
|
||||
|
||||
py_key2: cpython.PyObject | CPtr = cpython.PyUnicode_FromString("version")
|
||||
py_val2: cpython.PyObject | CPtr = cpython.PyLong_FromLong(1)
|
||||
cpython.PyDict_SetItem(py_dict, py_key2, py_val2)
|
||||
|
||||
# 检查大小
|
||||
dict_size: CSizeT = cpython.PyDict_Size(py_dict)
|
||||
testcheck.check(dict_size == 2, "PyDict_Size == 2", "PyDict_Size == 2")
|
||||
|
||||
# 获取值
|
||||
got_val: cpython.PyObject | CPtr = cpython.PyDict_GetItem(py_dict, py_key1)
|
||||
testcheck.check(got_val != 0, "GetItem(name) != NULL", "GetItem(name) != NULL")
|
||||
got_str: t.CChar | CPtr = cpython.PyUnicode_AsUTF8(got_val)
|
||||
testcheck.check(got_str != 0, "name == Viper", "name == Viper")
|
||||
printf(" dict['name'] = %s\n", got_str)
|
||||
|
||||
# 使用 GetItemString
|
||||
got_ver: cpython.PyObject | CPtr = cpython.PyDict_GetItemString(py_dict, "version")
|
||||
testcheck.check(got_ver != 0, "GetItemString(version) != NULL", "GetItemString(version) != NULL")
|
||||
ver_val: CLong = cpython.PyLong_AsLong(got_ver)
|
||||
testcheck.check(ver_val == 1, "version == 1", "version == 1")
|
||||
|
||||
# 清理
|
||||
cpython.Py_DecRef(py_val2)
|
||||
cpython.Py_DecRef(py_key2)
|
||||
cpython.Py_DecRef(py_val1)
|
||||
cpython.Py_DecRef(py_key1)
|
||||
cpython.Py_DecRef(py_dict)
|
||||
|
||||
cpython.Py_Finalize()
|
||||
|
||||
|
||||
def test_pyrun_string():
|
||||
testcheck.section("PyRun_SimpleString")
|
||||
cpython.Py_Initialize()
|
||||
|
||||
# 执行简单 Python 代码
|
||||
rc: CInt = cpython.PyRun_SimpleString("print('Hello from embedded Python!')")
|
||||
testcheck.check(rc == 0, "PyRun_SimpleString == 0", "PyRun_SimpleString == 0")
|
||||
|
||||
# 执行赋值
|
||||
rc2: CInt = cpython.PyRun_SimpleString("x = 6 * 7")
|
||||
testcheck.check(rc2 == 0, "PyRun_SimpleString(assign) == 0", "PyRun_SimpleString(assign) == 0")
|
||||
|
||||
# 读取结果
|
||||
rc3: CInt = cpython.PyRun_SimpleString("print(f'The answer is {x}')")
|
||||
testcheck.check(rc3 == 0, "PyRun_SimpleString(print) == 0", "PyRun_SimpleString(print) == 0")
|
||||
|
||||
cpython.Py_Finalize()
|
||||
|
||||
|
||||
def test_import_module():
|
||||
testcheck.section("PyImport_ImportModule")
|
||||
cpython.Py_Initialize()
|
||||
|
||||
# 导入 math 模块
|
||||
math_mod: cpython.PyObject | CPtr = cpython.PyImport_ImportModule("math")
|
||||
testcheck.check(math_mod != 0, "import math != NULL", "import math != NULL")
|
||||
|
||||
if math_mod != 0:
|
||||
# 获取 math.pi
|
||||
pi_val: cpython.PyObject | CPtr = cpython.PyObject_GetAttrString(math_mod, "pi")
|
||||
testcheck.check(pi_val != 0, "math.pi != NULL", "math.pi != NULL")
|
||||
if pi_val != 0:
|
||||
pi_dbl: CDouble = cpython.PyFloat_AsDouble(pi_val)
|
||||
testcheck.check(pi_dbl > 3.14 and pi_dbl < 3.15, "math.pi ~= 3.14", "math.pi ~= 3.14")
|
||||
printf(" math.pi = %f\n", pi_dbl)
|
||||
cpython.Py_DecRef(pi_val)
|
||||
|
||||
# 获取 math.sqrt 函数
|
||||
sqrt_func: cpython.PyObject | CPtr = cpython.PyObject_GetAttrString(math_mod, "sqrt")
|
||||
testcheck.check(sqrt_func != 0, "math.sqrt != NULL", "math.sqrt != NULL")
|
||||
if sqrt_func != 0:
|
||||
cpython.Py_DecRef(sqrt_func)
|
||||
|
||||
cpython.Py_DecRef(math_mod)
|
||||
|
||||
cpython.Py_Finalize()
|
||||
|
||||
|
||||
def test_operator_overload():
|
||||
testcheck.section("Operator Overload (PyLongObj / PyFloatObj / PyUnicodeObj / PyListObj / PyDictObj)")
|
||||
cpython.Py_Initialize()
|
||||
|
||||
# --- PyLongObj: from_long, to_long, +, -, *, - (neg) ---
|
||||
a: cpython.PyLongObj | CPtr = cpython.PyLongObj.from_long(10)
|
||||
b: cpython.PyLongObj | CPtr = cpython.PyLongObj.from_long(3)
|
||||
testcheck.check(a != 0 and b != 0, "PyLongObj.from_long != NULL", "PyLongObj.from_long != NULL")
|
||||
|
||||
add_r: cpython.PyLongObj | CPtr = a + b
|
||||
testcheck.check(add_r.to_long() == 13, "PyLongObj 10 + 3 == 13", "PyLongObj 10 + 3 == 13")
|
||||
|
||||
sub_r: cpython.PyLongObj | CPtr = a - b
|
||||
testcheck.check(sub_r.to_long() == 7, "PyLongObj 10 - 3 == 7", "PyLongObj 10 - 3 == 7")
|
||||
|
||||
mul_r: cpython.PyLongObj | CPtr = a * b
|
||||
testcheck.check(mul_r.to_long() == 30, "PyLongObj 10 * 3 == 30", "PyLongObj 10 * 3 == 30")
|
||||
|
||||
neg_r: cpython.PyLongObj | CPtr = -b
|
||||
testcheck.check(neg_r.to_long() == -3, "PyLongObj -3 == -3", "PyLongObj -3 == -3")
|
||||
|
||||
mul_r.dec_ref()
|
||||
sub_r.dec_ref()
|
||||
add_r.dec_ref()
|
||||
neg_r.dec_ref()
|
||||
b.dec_ref()
|
||||
a.dec_ref()
|
||||
|
||||
# --- PyFloatObj: from_double, to_double, +, -, *, /, - (neg) ---
|
||||
fa: cpython.PyFloatObj | CPtr = cpython.PyFloatObj.from_double(10.0)
|
||||
fb: cpython.PyFloatObj | CPtr = cpython.PyFloatObj.from_double(4.0)
|
||||
testcheck.check(fa != 0 and fb != 0, "PyFloatObj.from_double != NULL", "PyFloatObj.from_double != NULL")
|
||||
|
||||
fadd: cpython.PyFloatObj | CPtr = fa + fb
|
||||
testcheck.check(fadd.to_double() == 14.0, "PyFloatObj 10.0 + 4.0 == 14.0", "PyFloatObj 10.0 + 4.0 == 14.0")
|
||||
|
||||
fsub: cpython.PyFloatObj | CPtr = fa - fb
|
||||
testcheck.check(fsub.to_double() == 6.0, "PyFloatObj 10.0 - 4.0 == 6.0", "PyFloatObj 10.0 - 4.0 == 6.0")
|
||||
|
||||
fmul: cpython.PyFloatObj | CPtr = fa * fb
|
||||
testcheck.check(fmul.to_double() == 40.0, "PyFloatObj 10.0 * 4.0 == 40.0", "PyFloatObj 10.0 * 4.0 == 40.0")
|
||||
|
||||
fdiv: cpython.PyFloatObj | CPtr = fa / fb
|
||||
testcheck.check(fdiv.to_double() == 2.5, "PyFloatObj 10.0 / 4.0 == 2.5", "PyFloatObj 10.0 / 4.0 == 2.5")
|
||||
|
||||
fneg: cpython.PyFloatObj | CPtr = -fb
|
||||
testcheck.check(fneg.to_double() == -4.0, "PyFloatObj -4.0 == -4.0", "PyFloatObj -4.0 == -4.0")
|
||||
|
||||
fadd.dec_ref()
|
||||
fsub.dec_ref()
|
||||
fmul.dec_ref()
|
||||
fdiv.dec_ref()
|
||||
fneg.dec_ref()
|
||||
fb.dec_ref()
|
||||
fa.dec_ref()
|
||||
|
||||
# --- PyUnicodeObj: from_string, as_utf8, len, + (concat) ---
|
||||
sa: cpython.PyUnicodeObj | CPtr = cpython.PyUnicodeObj.from_string("Hello")
|
||||
sb: cpython.PyUnicodeObj | CPtr = cpython.PyUnicodeObj.from_string(" World")
|
||||
testcheck.check(sa != 0 and sb != 0, "PyUnicodeObj.from_string != NULL", "PyUnicodeObj.from_string != NULL")
|
||||
|
||||
sc: cpython.PyUnicodeObj | CPtr = sa + sb
|
||||
sc_utf8: t.CChar | CPtr = sc.as_utf8()
|
||||
testcheck.check(sc_utf8 != 0, "PyUnicodeObj concat != NULL", "PyUnicodeObj concat != NULL")
|
||||
if sc_utf8 != 0:
|
||||
printf(" PyUnicodeObj 'Hello' + ' World' = %s\n", sc_utf8)
|
||||
|
||||
sa_len: t.CPtrDiffT = len(sa)
|
||||
testcheck.check(sa_len == 5, "PyUnicodeObj len('Hello') == 5", "PyUnicodeObj len('Hello') == 5")
|
||||
|
||||
sc.dec_ref()
|
||||
sb.dec_ref()
|
||||
sa.dec_ref()
|
||||
|
||||
# --- PyListObj: new, append, len, [], []= ---
|
||||
lst: cpython.PyListObj | CPtr = cpython.PyListObj.new()
|
||||
testcheck.check(lst != 0, "PyListObj.new != NULL", "PyListObj.new != NULL")
|
||||
if lst != 0:
|
||||
e1: cpython.PyObject | CPtr = cpython.PyLong_FromLong(100)
|
||||
e2: cpython.PyObject | CPtr = cpython.PyLong_FromLong(200)
|
||||
e3: cpython.PyObject | CPtr = cpython.PyLong_FromLong(300)
|
||||
lst.append(e1)
|
||||
lst.append(e2)
|
||||
lst.append(e3)
|
||||
testcheck.check(len(lst) == 3, "PyListObj len == 3", "PyListObj len == 3")
|
||||
|
||||
item0: cpython.PyObject | CPtr = lst[t.CSizeT(0)]
|
||||
testcheck.check(cpython.PyLong_AsLong(item0) == 100, "PyListObj lst[0] == 100", "PyListObj lst[0] == 100")
|
||||
|
||||
# __setitem__
|
||||
e4: cpython.PyObject | CPtr = cpython.PyLong_FromLong(999)
|
||||
lst[t.CSizeT(1)] = e4
|
||||
item1: cpython.PyObject | CPtr = lst[t.CSizeT(1)]
|
||||
testcheck.check(cpython.PyLong_AsLong(item1) == 999, "PyListObj lst[1] = 999", "PyListObj lst[1] = 999")
|
||||
|
||||
cpython.Py_DecRef(e4)
|
||||
cpython.Py_DecRef(e3)
|
||||
cpython.Py_DecRef(e2)
|
||||
cpython.Py_DecRef(e1)
|
||||
lst.dec_ref()
|
||||
|
||||
# --- PyDictObj: new, [], []=, len, set_string, get_string ---
|
||||
dct: cpython.PyDictObj | CPtr = cpython.PyDictObj.new()
|
||||
testcheck.check(dct != 0, "PyDictObj.new != NULL", "PyDictObj.new != NULL")
|
||||
if dct != 0:
|
||||
dk1: cpython.PyObject | CPtr = cpython.PyUnicode_FromString("lang")
|
||||
dv1: cpython.PyObject | CPtr = cpython.PyUnicode_FromString("Viper")
|
||||
dct[dk1] = dv1
|
||||
testcheck.check(len(dct) == 1, "PyDictObj len == 1", "PyDictObj len == 1")
|
||||
|
||||
got_lang: cpython.PyObject | CPtr = dct[dk1]
|
||||
got_str: t.CChar | CPtr = cpython.PyUnicode_AsUTF8(got_lang)
|
||||
testcheck.check(got_str != 0, "PyDictObj dct['lang'] == Viper", "PyDictObj dct['lang'] == Viper")
|
||||
if got_str != 0:
|
||||
printf(" PyDictObj dct['lang'] = %s\n", got_str)
|
||||
|
||||
# get_string / set_string
|
||||
dct.set_string("ver", cpython.PyLong_FromLong(3))
|
||||
got_ver: cpython.PyObject | CPtr = dct.get_string("ver")
|
||||
testcheck.check(got_ver != 0 and cpython.PyLong_AsLong(got_ver) == 3, "PyDictObj get_string('ver') == 3", "PyDictObj get_string('ver') == 3")
|
||||
|
||||
cpython.Py_DecRef(dv1)
|
||||
cpython.Py_DecRef(dk1)
|
||||
dct.dec_ref()
|
||||
|
||||
cpython.Py_Finalize()
|
||||
|
||||
|
||||
def main() -> CInt | t.CExport:
|
||||
testcheck.begin("CPython Integration Test")
|
||||
|
||||
test_init_finalize()
|
||||
test_long_operations()
|
||||
test_string_operations()
|
||||
test_list_operations()
|
||||
test_dict_operations()
|
||||
test_pyrun_string()
|
||||
test_import_module()
|
||||
test_operator_overload()
|
||||
|
||||
return testcheck.end()
|
||||
@@ -0,0 +1 @@
|
||||
{"stdio": "6f62fe05c5ea1ceb", "w32.win32base": "7e529fe7a078cfef", "win32base": "7e529fe7a078cfef", "w32.win32console": "bbdf3bbd4c3bc28c", "win32console": "bbdf3bbd4c3bc28c", "testcheck": "dd3002730623424b", "stdint": "f5522571bcce7bcb", "main": "fb6cea4f70fade7a"}
|
||||
Loaded 100 of 2295 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user