补充
This commit is contained in:
25
Test/CPythonTest/App/cpython.py
Normal file
25
Test/CPythonTest/App/cpython.py
Normal file
@@ -0,0 +1,25 @@
|
||||
import t, c
|
||||
|
||||
|
||||
class PyObject:
|
||||
ob_refcnt: t.CLong
|
||||
ob_type: t.CPtr
|
||||
|
||||
|
||||
def Py_Initialize() -> t.CVoid | t.CExtern:
|
||||
pass
|
||||
|
||||
def PyLong_FromLong(value: t.CLong) -> PyObject | t.CPtr | t.CExtern:
|
||||
pass
|
||||
|
||||
def PyObject_Str(obj: PyObject | t.CPtr) -> PyObject | t.CPtr | t.CExtern:
|
||||
pass
|
||||
|
||||
def PyUnicode_AsUTF8(unicode_obj: PyObject | t.CPtr) -> str | t.CExtern:
|
||||
pass
|
||||
|
||||
def Py_DecRef(obj: PyObject | t.CPtr) -> t.CVoid | t.CExtern:
|
||||
pass
|
||||
|
||||
def Py_Finalize() -> t.CVoid | t.CExtern:
|
||||
pass
|
||||
28
Test/CPythonTest/App/main.py
Normal file
28
Test/CPythonTest/App/main.py
Normal file
@@ -0,0 +1,28 @@
|
||||
import t, c
|
||||
from t import CInt, CPtr, CChar, CLong
|
||||
import viperlib
|
||||
import cpython
|
||||
|
||||
|
||||
def SetDllDirectoryA(lpPathName: str | CPtr) -> CInt | t.CExtern:
|
||||
pass
|
||||
|
||||
def main() -> CInt | t.CExport:
|
||||
SetDllDirectoryA("D:\\Python312")
|
||||
|
||||
cpython.Py_Initialize()
|
||||
|
||||
py_num: cpython.PyObject | t.CPtr = cpython.PyLong_FromLong(12345)
|
||||
|
||||
py_str: cpython.PyObject | t.CPtr = cpython.PyObject_Str(py_num)
|
||||
c_str: str = cpython.PyUnicode_AsUTF8(py_str)
|
||||
print(c_str)
|
||||
|
||||
cpython.Py_DecRef(py_str)
|
||||
cpython.Py_DecRef(py_num)
|
||||
|
||||
cpython.Py_Finalize()
|
||||
return 0
|
||||
|
||||
|
||||
|
||||
1
Test/CPythonTest/output/3e1c3f98e99cff7a.deps.json
Normal file
1
Test/CPythonTest/output/3e1c3f98e99cff7a.deps.json
Normal file
@@ -0,0 +1 @@
|
||||
{"viperlib": "4d342c40331fc964", "stdint": "56cdd754a8a09347", "main": "6999814920e8b3d5", "stdarg": "81ac26077a460417", "viperio": "c9f4be41ca1cc2b4"}
|
||||
1
Test/CPythonTest/output/4d342c40331fc964.deps.json
Normal file
1
Test/CPythonTest/output/4d342c40331fc964.deps.json
Normal file
@@ -0,0 +1 @@
|
||||
{"cpython": "3e1c3f98e99cff7a", "stdarg": "81ac26077a460417", "main": "93131e2ff5450838", "viperio": "d771d4d68d9e75b3"}
|
||||
1
Test/CPythonTest/output/6999814920e8b3d5.deps.json
Normal file
1
Test/CPythonTest/output/6999814920e8b3d5.deps.json
Normal file
@@ -0,0 +1 @@
|
||||
{"cpython": "3e1c3f98e99cff7a", "viperlib": "4d342c40331fc964", "stdint": "56cdd754a8a09347", "stdarg": "81ac26077a460417", "viperio": "c9f4be41ca1cc2b4"}
|
||||
BIN
Test/CPythonTest/output/CPythonTest.exe.tmp0
Normal file
BIN
Test/CPythonTest/output/CPythonTest.exe.tmp0
Normal file
Binary file not shown.
1
Test/CPythonTest/output/c9f4be41ca1cc2b4.deps.json
Normal file
1
Test/CPythonTest/output/c9f4be41ca1cc2b4.deps.json
Normal file
@@ -0,0 +1 @@
|
||||
{"cpython": "3e1c3f98e99cff7a", "viperlib": "4d342c40331fc964", "stdint": "56cdd754a8a09347", "main": "6999814920e8b3d5", "stdarg": "81ac26077a460417"}
|
||||
29
Test/CPythonTest/project.json
Normal file
29
Test/CPythonTest/project.json
Normal file
@@ -0,0 +1,29 @@
|
||||
{
|
||||
"$schema": "https://raw.githubusercontent.com/TermiNexus/TransPyC/main/schemas/project-schema.json",
|
||||
"name": "CPythonTest",
|
||||
"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": ["-L", "D:\\Python312", "-lmsvcrt", "-lucrt", "-lpthread", "D:\\Python312\\python312.dll"],
|
||||
"output": "CPythonTest.exe"
|
||||
},
|
||||
"includes": [
|
||||
"./includes"
|
||||
],
|
||||
"target": {
|
||||
"triple": "x86_64-pc-windows-msvc",
|
||||
"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
|
||||
}
|
||||
}
|
||||
23
Test/CPythonTest/temp/3e1c3f98e99cff7a.pyi
Normal file
23
Test/CPythonTest/temp/3e1c3f98e99cff7a.pyi
Normal file
@@ -0,0 +1,23 @@
|
||||
"""
|
||||
Auto-generated Python stub file from cpython.py
|
||||
Module: cpython
|
||||
"""
|
||||
|
||||
|
||||
import t, c
|
||||
|
||||
class PyObject:
|
||||
ob_refcnt: t.CLong
|
||||
ob_type: t.CPtr
|
||||
|
||||
def Py_Initialize() -> t.CVoid | t.CExtern | t.State: pass
|
||||
|
||||
def PyLong_FromLong(value: t.CLong) -> PyObject | t.CPtr | t.CExtern | t.State: pass
|
||||
|
||||
def PyObject_Str(obj: PyObject | t.CPtr) -> PyObject | t.CPtr | t.CExtern | t.State: pass
|
||||
|
||||
def PyUnicode_AsUTF8(unicode_obj: PyObject | t.CPtr) -> str | t.CExtern | t.State: pass
|
||||
|
||||
def Py_DecRef(obj: PyObject | t.CPtr) -> t.CVoid | t.CExtern | t.State: pass
|
||||
|
||||
def Py_Finalize() -> t.CVoid | t.CExtern | t.State: pass
|
||||
19
Test/CPythonTest/temp/4d342c40331fc964.pyi
Normal file
19
Test/CPythonTest/temp/4d342c40331fc964.pyi
Normal file
@@ -0,0 +1,19 @@
|
||||
"""
|
||||
Auto-generated Python stub file from viperlib.py
|
||||
Module: viperlib
|
||||
"""
|
||||
|
||||
|
||||
import t, c
|
||||
import viperio
|
||||
from stdarg import arg
|
||||
|
||||
TEMP_BUF_SIZE: t.CDefine = 24
|
||||
|
||||
def get_digit_count(num: t.CUnsignedInt, base: t.CInt) -> t.CStatic | t.CInt | t.State: pass
|
||||
|
||||
def sprintf(buf: t.CChar | t.CPtr, rule: str, *args) -> t.CVoid | t.State: pass
|
||||
|
||||
def vsprintf(buf: t.CChar | t.CPtr, rule: str, *args) -> t.CInt | t.State: pass
|
||||
|
||||
def snprintf(buf: t.CChar | t.CPtr, size: t.CSizeT, fmt: str, *args) -> t.CInt | t.State: pass
|
||||
67
Test/CPythonTest/temp/56cdd754a8a09347.pyi
Normal file
67
Test/CPythonTest/temp/56cdd754a8a09347.pyi
Normal file
@@ -0,0 +1,67 @@
|
||||
"""
|
||||
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.CLong | t.CLong
|
||||
ULONGLONG: t.CTypedef = t.CUnsignedLong | t.CLong
|
||||
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
|
||||
UINTPTR: t.CTypedef = t.CUnsignedInt | t.CPtr
|
||||
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
|
||||
14
Test/CPythonTest/temp/6999814920e8b3d5.pyi
Normal file
14
Test/CPythonTest/temp/6999814920e8b3d5.pyi
Normal file
@@ -0,0 +1,14 @@
|
||||
"""
|
||||
Auto-generated Python stub file from main.py
|
||||
Module: main
|
||||
"""
|
||||
|
||||
|
||||
import t, c
|
||||
from t import CInt, CPtr, CChar, CLong
|
||||
import viperlib
|
||||
import cpython
|
||||
|
||||
def SetDllDirectoryA(lpPathName: str | CPtr) -> CInt | t.CExtern | t.State: pass
|
||||
|
||||
def main() -> CInt | t.CExport | t.State: pass
|
||||
20
Test/CPythonTest/temp/81ac26077a460417.pyi
Normal file
20
Test/CPythonTest/temp/81ac26077a460417.pyi
Normal file
@@ -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 | t.CExtern | t.CExport: pass
|
||||
|
||||
def va_arg(args: t.CPtr, type: t.CType) -> t.CType | t.CExtern | t.CExport | t.State: pass
|
||||
|
||||
def va_end(args: t.CPtr) -> t.State | t.CExtern | t.CExport: pass
|
||||
|
||||
|
||||
va_list: t.CTypedef = t.CUnsignedChar | t.CPtr
|
||||
|
||||
def arg(type: t.CType) -> t.State | t.CExtern | t.CExport: pass
|
||||
14
Test/CPythonTest/temp/93131e2ff5450838.pyi
Normal file
14
Test/CPythonTest/temp/93131e2ff5450838.pyi
Normal file
@@ -0,0 +1,14 @@
|
||||
"""
|
||||
Auto-generated Python stub file from main.py
|
||||
Module: main
|
||||
"""
|
||||
|
||||
|
||||
import t, c
|
||||
from t import CInt, CPtr, CChar, CLong
|
||||
import viperlib
|
||||
import cpython
|
||||
|
||||
def SetDllDirectoryA(lpPathName: str | CPtr) -> CInt | t.CExtern | t.State: pass
|
||||
|
||||
def main() -> CInt | t.CExport | t.State: pass
|
||||
6
Test/CPythonTest/temp/_sha1_map.txt
Normal file
6
Test/CPythonTest/temp/_sha1_map.txt
Normal file
@@ -0,0 +1,6 @@
|
||||
3e1c3f98e99cff7a:cpython.py
|
||||
4d342c40331fc964:includes/viperlib.py
|
||||
56cdd754a8a09347:includes/stdint.py
|
||||
6999814920e8b3d5:main.py
|
||||
81ac26077a460417:includes/stdarg.py
|
||||
c9f4be41ca1cc2b4:includes/viperio.py
|
||||
BIN
Test/CPythonTest/temp/_shared_sym.pkl
Normal file
BIN
Test/CPythonTest/temp/_shared_sym.pkl
Normal file
Binary file not shown.
22
Test/CPythonTest/temp/c9f4be41ca1cc2b4.pyi
Normal file
22
Test/CPythonTest/temp/c9f4be41ca1cc2b4.pyi
Normal file
@@ -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.CVoid | t.State: pass
|
||||
def clear(self: Buf) -> t.CVoid | t.State: pass
|
||||
def write(self: Buf, src: t.CChar | t.CPtr, count: t.CSizeT) -> t.CSizeT | t.State: pass
|
||||
def cstr(self: Buf) -> t.CChar | t.CPtr | t.State: pass
|
||||
def reset(self: Buf) -> t.CVoid | t.State: pass
|
||||
def __enter__(self: Buf) -> 'Buf' | t.CPtr | t.State: pass
|
||||
def __exit__(self: Buf) -> t.CVoid | t.State: pass
|
||||
def free(self: Buf) -> t.CVoid | t.State: pass
|
||||
17
Test/CPythonTest/temp/d771d4d68d9e75b3.pyi
Normal file
17
Test/CPythonTest/temp/d771d4d68d9e75b3.pyi
Normal file
@@ -0,0 +1,17 @@
|
||||
"""
|
||||
Auto-generated Python stub file from viperio.py
|
||||
Module: viperio
|
||||
"""
|
||||
|
||||
|
||||
import t, c
|
||||
|
||||
@t.Object
|
||||
class Buf:
|
||||
buf: str
|
||||
length: t.CSizeT
|
||||
capacity: t.CSizeT
|
||||
onHeap: bool
|
||||
def __init__(self: Buf, buf: str, length: t.CSizeT, onHeap: bool) -> t.CVoid | t.State: pass
|
||||
def free(self: Buf) -> t.CVoid | t.State: pass
|
||||
def __del__(self: Buf) -> t.CVoid | t.State: pass
|
||||
Reference in New Issue
Block a user