diff --git a/CPythonTest/App/cpython.vp b/CPythonTest/App/cpython.vp index 1321105..fd55172 100644 --- a/CPythonTest/App/cpython.vp +++ b/CPythonTest/App/cpython.vp @@ -109,8 +109,8 @@ extern def PyLong_FromSize_t(v: sizet) -> PyObject* extern def PyLong_FromDouble(v: double) -> PyObject* extern def PyLong_AsLong(obj: PyObject*) -> int extern def PyLong_AsUnsignedLong(obj: PyObject*) -> t.CUnsignedLong -extern def PyLong_AsLongLong(obj: PyObject*) -> t.CLong -extern def PyLong_AsUnsignedLongLong(obj: PyObject*) -> t.CUnsignedLong +extern def PyLong_AsLongLong(obj: PyObject*) -> t.CLongLong +extern def PyLong_AsUnsignedLongLong(obj: PyObject*) -> t.CUnsignedLongLong extern def PyLong_AsDouble(obj: PyObject*) -> double extern def PyLong_AsSsize_t(obj: PyObject*) -> t.CPtrDiffT extern def PyLong_AsSize_t(obj: PyObject*) -> sizet @@ -220,7 +220,7 @@ extern def PyObject_IsTrue(obj: PyObject*) -> int extern def PyObject_Not(obj: PyObject*) -> int extern def PyObject_RichCompare(o1: PyObject*, o2: PyObject*, opid: int) -> PyObject* extern def PyObject_RichCompareBool(o1: PyObject*, o2: PyObject*, opid: int) -> int -extern def PyObject_Hash(obj: PyObject*) -> t.CLong +extern def PyObject_Hash(obj: PyObject*) -> t.CPtrDiffT extern def PyObject_Length(obj: PyObject*) -> sizet extern def PyObject_GetItem(obj: PyObject*, key: PyObject*) -> PyObject* extern def PyObject_SetItem(obj: PyObject*, key: PyObject*, val: PyObject*) -> int diff --git a/CPythonTest/App/main.vp b/CPythonTest/App/main.vp index 93f9cfe..d595b10 100644 --- a/CPythonTest/App/main.vp +++ b/CPythonTest/App/main.vp @@ -68,7 +68,9 @@ def test_string_operations(): printf(" PyUnicode_FromString -> %s\n", utf8) # String length - length: CLong = cpython.PyUnicode_GetLength(py_s1) + # PyUnicode_GetLength 返回 CPython 的 Py_ssize_t(= ptrdiff_t,64 位);CLong 在本目标 + # (x86_64-pc-windows-gnu / LLP64) 只有 32 位,用 CLong 接收会触发「隐式窄化禁止」。 + length: t.CPtrDiffT = cpython.PyUnicode_GetLength(py_s1) testcheck.check(length == 13, "GetLength == 13", "GetLength == 13") # String concat