diff --git a/python-multiplatform/src/androidMain/kotlin/python/multiplatform/ffi/PyObject.android.kt b/python-multiplatform/src/androidMain/kotlin/python/multiplatform/ffi/PyObject.android.kt deleted file mode 100644 index 05f57af0..00000000 --- a/python-multiplatform/src/androidMain/kotlin/python/multiplatform/ffi/PyObject.android.kt +++ /dev/null @@ -1,11 +0,0 @@ -package python.multiplatform.ffi - -import python.native.ffi.NativePointer - - -actual open class PyObject actual constructor(actual override val pointer: NativePointer, borrowed: Boolean): PyObjectAutoCloseable(pointer, borrowed) { - - //actual external fun incRef() - - //... -} diff --git a/python-multiplatform/src/androidMain/kotlin/python/multiplatform/ref/PyAutoCloseable.android.kt b/python-multiplatform/src/androidMain/kotlin/python/multiplatform/ref/PyAutoCloseable.android.kt new file mode 100644 index 00000000..88b92f00 --- /dev/null +++ b/python-multiplatform/src/androidMain/kotlin/python/multiplatform/ref/PyAutoCloseable.android.kt @@ -0,0 +1,79 @@ +package python.multiplatform.ref + +import android.os.Build +import android.os.Build.VERSION.SDK_INT +import python.multiplatform.currentPlatform +import python.native.ffi.NativePointer +import java.lang.ref.Cleaner +import java.lang.ref.PhantomReference +import java.lang.ref.ReferenceQueue +import java.util.concurrent.ConcurrentHashMap + + +actual abstract class PyAutoCloseable actual constructor(pointer: NativePointer): AutoCloseable { + private val cleaner: Cleaner? + private val cleanable: Cleaner.Cleanable? + private var phantomRef: PhantomCleanupReference? + + companion object { + private val referenceQueue = ReferenceQueue() + // TODO: activeReferences가 계속 커질 위험이 있음 + // TODO: 성능 오버헤드: 모든 객체마다 HashMap 엔트리 생성 + // TODO: 여러 이유로 TIRAMISU 미만 버전에서는 이 방법 말고 다른 방법으로 객체 소멸을 감지해야할 듯 + private val activeReferences = ConcurrentHashMap Unit>() + + init { + Thread { + while (true) { + try { + val ref = referenceQueue.remove() as? PhantomCleanupReference + ref?.let { + activeReferences.remove(it)?.invoke() + } + } catch (e: InterruptedException) { + Thread.currentThread().interrupt() + break + } + } + }.apply { + isDaemon = true + name = "PyAutoCloseable-Cleaner" + }.start() + } + } + + init { + if (SDK_INT >= Build.VERSION_CODES.TIRAMISU) { + cleaner = Cleaner.create() + cleanable = cleaner.register(this) { + clean() + } + phantomRef = null + } else { + cleaner = null + cleanable = null + phantomRef = PhantomCleanupReference(this, referenceQueue).also { + ref -> activeReferences[ref] = { clean() } + } + } + } + + actual abstract fun clean() + + override fun close() { + if (SDK_INT >= Build.VERSION_CODES.TIRAMISU) { + cleanable?.clean() + } else { + phantomRef?.let { + ref -> activeReferences.remove(ref) + clean() + } + phantomRef = null + } + } + + private class PhantomCleanupReference( + referent: PyAutoCloseable, + queue: ReferenceQueue + ): PhantomReference(referent, queue) +} diff --git a/python-multiplatform/src/androidMain/kotlin/python/native/ffi/EmbedAPI.android.kt b/python-multiplatform/src/androidMain/kotlin/python/native/ffi/EmbedAPI.android.kt index 06e082b9..4208a942 100644 --- a/python-multiplatform/src/androidMain/kotlin/python/native/ffi/EmbedAPI.android.kt +++ b/python-multiplatform/src/androidMain/kotlin/python/native/ffi/EmbedAPI.android.kt @@ -19,6 +19,7 @@ actual fun Long.toNativePointer(): NativePointer? = toNativePointer() internal inline fun JNIPointer?.toNativePointer(): NativePointer? = this?.let { if (it > 0) NativePointer(it) else null } +/** // Section 1 actual inline fun Py_Initialize() = python.native.ffi.bindings.Py_Initialize() actual inline fun Py_InitializeEx(initsigs: Int) = python.native.ffi.bindings.Py_InitializeEx(initsigs) @@ -60,3 +61,384 @@ actual fun PyUnicode_FromString(str: String): NativePointer? = actual inline fun PyUnicode_AsUTF8(unicode: NativePointer): String? = python.native.ffi.bindings.PyUnicode_AsUTF8(unicode.toPlatformPointer()) + +*/ + + +//************************************************** +// Section 1 +actual inline fun Py_Initialize() = python.native.ffi.bindings.Py_Initialize() +actual inline fun Py_InitializeEx(initsigs: Int) = python.native.ffi.bindings.Py_InitializeEx(initsigs) +actual inline fun Py_IsInitialized(): Int = python.native.ffi.bindings.Py_IsInitialized() +actual inline fun Py_IsFinalizing(): Int = python.native.ffi.bindings.Py_IsFinalizing() +actual inline fun Py_FinalizeEx(): Int = python.native.ffi.bindings.Py_FinalizeEx() +actual inline fun Py_Finalize() = python.native.ffi.bindings.Py_Finalize() +// actual inline fun Py_BytesMain(argc: Int, argv: List): Int // 수동 추가 +actual inline fun Py_RunMain(): Int = python.native.ffi.bindings.Py_RunMain() // 수동 추가 +actual inline fun Py_GetVersion(): String? = python.native.ffi.bindings.Py_GetVersion() +actual inline fun Py_GetPlatform(): String? = python.native.ffi.bindings.Py_GetPlatform() +actual inline fun Py_GetCopyright(): String? = python.native.ffi.bindings.Py_GetCopyright() +actual inline fun Py_GetCompiler(): String? = python.native.ffi.bindings.Py_GetCompiler() +actual inline fun Py_GetBuildInfo(): String? = python.native.ffi.bindings.Py_GetBuildInfo() +actual inline fun PyEval_InitThreads() = python.native.ffi.bindings.PyEval_InitThreads() +actual fun PyThreadState_GetDict(): NativePointer? = python.native.ffi.bindings.PyThreadState_GetDict().toNativePointer() + + +// Section 2 +actual inline fun PyRun_SimpleString(command: String): Int = python.native.ffi.bindings.PyRun_SimpleString(command) // 수동 추가 +actual fun PyRun_String(str: String, start: Int, globals: NativePointer, locals: NativePointer): NativePointer? = python.native.ffi.bindings.PyRun_String(str, start, globals.toPlatformPointer(), locals.toPlatformPointer()).toNativePointer() // 수동 추가 +actual fun Py_CompileString(str: String, filename: String, start: Int): NativePointer? = python.native.ffi.bindings.Py_CompileString(str, filename, start).toNativePointer() +actual fun PyEval_EvalCode(co: NativePointer, globals: NativePointer, locals: NativePointer): NativePointer? = python.native.ffi.bindings.PyEval_EvalCode(co.toPlatformPointer(), globals.toPlatformPointer(), locals.toPlatformPointer()).toNativePointer() + + +// Section 3 +actual inline fun PyErr_Clear() = python.native.ffi.bindings.PyErr_Clear() +actual inline fun PyErr_PrintEx(set_sys_last_vars: Int) = python.native.ffi.bindings.PyErr_PrintEx(set_sys_last_vars) +actual inline fun PyErr_Print() = python.native.ffi.bindings.PyErr_Print() +actual inline fun PyErr_WriteUnraisable(obj: NativePointer) = python.native.ffi.bindings.PyErr_WriteUnraisable(obj.toPlatformPointer()) +actual inline fun PyErr_DisplayException(exc: NativePointer) = python.native.ffi.bindings.PyErr_DisplayException(exc.toPlatformPointer()) +actual inline fun PyErr_SetString(type: NativePointer, message: String) = python.native.ffi.bindings.PyErr_SetString(type.toPlatformPointer(), message) +actual inline fun PyErr_SetObject(type: NativePointer, value: NativePointer) = python.native.ffi.bindings.PyErr_SetObject(type.toPlatformPointer(), value.toPlatformPointer()) +actual inline fun PyErr_SetNone(type: NativePointer) = python.native.ffi.bindings.PyErr_SetNone(type.toPlatformPointer()) +actual inline fun PyErr_BadArgument(): Int = python.native.ffi.bindings.PyErr_BadArgument() +actual fun PyErr_NoMemory(): NativePointer? = python.native.ffi.bindings.PyErr_NoMemory().toNativePointer() +actual fun PyErr_SetFromErrno(type: NativePointer): NativePointer? = python.native.ffi.bindings.PyErr_SetFromErrno(type.toPlatformPointer()).toNativePointer() +actual fun PyErr_SetFromErrnoWithFilenameObject(type: NativePointer, filenameObject: NativePointer): NativePointer? = python.native.ffi.bindings.PyErr_SetFromErrnoWithFilenameObject(type.toPlatformPointer(), filenameObject.toPlatformPointer()).toNativePointer() +actual fun PyErr_SetFromErrnoWithFilenameObjects(type: NativePointer, filenameObject: NativePointer, filenameObject2: NativePointer): NativePointer? = python.native.ffi.bindings.PyErr_SetFromErrnoWithFilenameObjects(type.toPlatformPointer(), filenameObject.toPlatformPointer(), filenameObject2.toPlatformPointer()).toNativePointer() +actual fun PyErr_SetFromErrnoWithFilename(type: NativePointer, filename: String): NativePointer? = python.native.ffi.bindings.PyErr_SetFromErrnoWithFilename(type.toPlatformPointer(), filename).toNativePointer() +actual fun PyErr_SetImportError(msg: NativePointer, name: NativePointer, path: NativePointer): NativePointer? = python.native.ffi.bindings.PyErr_SetImportError(msg.toPlatformPointer(), name.toPlatformPointer(), path.toPlatformPointer()).toNativePointer() +actual fun PyErr_SetImportErrorSubclass(exception: NativePointer, msg: NativePointer, name: NativePointer, path: NativePointer): NativePointer? = python.native.ffi.bindings.PyErr_SetImportErrorSubclass(exception.toPlatformPointer(), msg.toPlatformPointer(), name.toPlatformPointer(), path.toPlatformPointer()).toNativePointer() +actual inline fun PyErr_SyntaxLocationEx(filename: String, lineno: Int, col_offset: Int) = python.native.ffi.bindings.PyErr_SyntaxLocationEx(filename, lineno, col_offset) +actual inline fun PyErr_SyntaxLocation(filename: String, lineno: Int) = python.native.ffi.bindings.PyErr_SyntaxLocation(filename, lineno) +actual inline fun PyErr_BadInternalCall() = python.native.ffi.bindings.PyErr_BadInternalCall() +actual inline fun PyErr_WarnExplicit(category: NativePointer, message: String, filename: String, lineno: Int, module: String, registry: NativePointer): Int = python.native.ffi.bindings.PyErr_WarnExplicit(category.toPlatformPointer(), message, filename, lineno, module, registry.toPlatformPointer()) +actual fun PyErr_Occurred(): NativePointer? = python.native.ffi.bindings.PyErr_Occurred().toNativePointer() +actual inline fun PyErr_ExceptionMatches(exc: NativePointer): Int = python.native.ffi.bindings.PyErr_ExceptionMatches(exc.toPlatformPointer()) +actual inline fun PyErr_GivenExceptionMatches(given: NativePointer, exc: NativePointer): Int = python.native.ffi.bindings.PyErr_GivenExceptionMatches(given.toPlatformPointer(), exc.toPlatformPointer()) +actual fun PyErr_GetRaisedException(): NativePointer? = python.native.ffi.bindings.PyErr_GetRaisedException().toNativePointer() +actual inline fun PyErr_SetRaisedException(exc: NativePointer) = python.native.ffi.bindings.PyErr_SetRaisedException(exc.toPlatformPointer()) +actual inline fun PyErr_Restore(type: NativePointer, value: NativePointer, traceback: NativePointer) = python.native.ffi.bindings.PyErr_Restore(type.toPlatformPointer(), value.toPlatformPointer(), traceback.toPlatformPointer()) +actual fun PyErr_GetHandledException(): NativePointer? = python.native.ffi.bindings.PyErr_GetHandledException().toNativePointer() +actual inline fun PyErr_SetHandledException(exc: NativePointer) = python.native.ffi.bindings.PyErr_SetHandledException(exc.toPlatformPointer()) +actual inline fun PyErr_SetExcInfo(type: NativePointer, value: NativePointer, traceback: NativePointer) = python.native.ffi.bindings.PyErr_SetExcInfo(type.toPlatformPointer(), value.toPlatformPointer(), traceback.toPlatformPointer()) +actual inline fun PyErr_CheckSignals(): Int = python.native.ffi.bindings.PyErr_CheckSignals() +actual inline fun PyErr_SetInterrupt() = python.native.ffi.bindings.PyErr_SetInterrupt() +actual inline fun PyErr_SetInterruptEx(signum: Int): Int = python.native.ffi.bindings.PyErr_SetInterruptEx(signum) +actual fun PyErr_NewException(name: String, base: NativePointer, dict: NativePointer): NativePointer? = python.native.ffi.bindings.PyErr_NewException(name, base.toPlatformPointer(), dict.toPlatformPointer()).toNativePointer() +actual fun PyErr_NewExceptionWithDoc(name: String, doc: String, base: NativePointer, dict: NativePointer): NativePointer? = python.native.ffi.bindings.PyErr_NewExceptionWithDoc(name, doc, base.toPlatformPointer(), dict.toPlatformPointer()).toNativePointer() +actual fun PyException_GetTraceback(ex: NativePointer): NativePointer? = python.native.ffi.bindings.PyException_GetTraceback(ex.toPlatformPointer()).toNativePointer() +actual inline fun PyException_SetTraceback(ex: NativePointer, tb: NativePointer): Int = python.native.ffi.bindings.PyException_SetTraceback(ex.toPlatformPointer(), tb.toPlatformPointer()) +actual fun PyException_GetContext(ex: NativePointer): NativePointer? = python.native.ffi.bindings.PyException_GetContext(ex.toPlatformPointer()).toNativePointer() +actual inline fun PyException_SetContext(ex: NativePointer, ctx: NativePointer) = python.native.ffi.bindings.PyException_SetContext(ex.toPlatformPointer(), ctx.toPlatformPointer()) +actual fun PyException_GetCause(ex: NativePointer): NativePointer? = python.native.ffi.bindings.PyException_GetCause(ex.toPlatformPointer()).toNativePointer() +actual inline fun PyException_SetCause(ex: NativePointer, cause: NativePointer) = python.native.ffi.bindings.PyException_SetCause(ex.toPlatformPointer(), cause.toPlatformPointer()) +actual fun PyException_GetArgs(ex: NativePointer): NativePointer? = python.native.ffi.bindings.PyException_GetArgs(ex.toPlatformPointer()).toNativePointer() +actual inline fun PyException_SetArgs(ex: NativePointer, args: NativePointer) = python.native.ffi.bindings.PyException_SetArgs(ex.toPlatformPointer(), args.toPlatformPointer()) +actual fun PyUnicodeEncodeError_GetEncoding(exc: NativePointer): NativePointer? = python.native.ffi.bindings.PyUnicodeEncodeError_GetEncoding(exc.toPlatformPointer()).toNativePointer() +actual fun PyUnicodeTranslateError_GetObject(exc: NativePointer): NativePointer? = python.native.ffi.bindings.PyUnicodeTranslateError_GetObject(exc.toPlatformPointer()).toNativePointer() +actual fun PyUnicodeTranslateError_GetReason(exc: NativePointer): NativePointer? = python.native.ffi.bindings.PyUnicodeTranslateError_GetReason(exc.toPlatformPointer()).toNativePointer() +actual inline fun PyUnicodeTranslateError_SetReason(exc: NativePointer, reason: String): Int = python.native.ffi.bindings.PyUnicodeTranslateError_SetReason(exc.toPlatformPointer(), reason) +actual inline fun Py_EnterRecursiveCall(where: String): Int = python.native.ffi.bindings.Py_EnterRecursiveCall(where) +actual inline fun Py_LeaveRecursiveCall() = python.native.ffi.bindings.Py_LeaveRecursiveCall() +actual inline fun Py_ReprEnter(o: NativePointer): Int = python.native.ffi.bindings.Py_ReprEnter(o.toPlatformPointer()) +actual inline fun Py_ReprLeave(o: NativePointer) = python.native.ffi.bindings.Py_ReprLeave(o.toPlatformPointer()) + + +// Section 4 +actual fun Py_NewRef(o: NativePointer): NativePointer? = python.native.ffi.bindings.Py_NewRef(o.toPlatformPointer()).toNativePointer() +actual fun Py_XNewRef(o: NativePointer): NativePointer? = python.native.ffi.bindings.Py_XNewRef(o.toPlatformPointer()).toNativePointer() +actual inline fun Py_IncRef(o: NativePointer) = python.native.ffi.bindings.Py_IncRef(o.toPlatformPointer()) +actual inline fun Py_DecRef(o: NativePointer) = python.native.ffi.bindings.Py_DecRef(o.toPlatformPointer()) + + +// Section 5 +actual fun PyOS_FSPath(path: NativePointer): NativePointer? = python.native.ffi.bindings.PyOS_FSPath(path.toPlatformPointer()).toNativePointer() + + +// Section 6 +actual fun PySys_GetObject(name: String): NativePointer? = python.native.ffi.bindings.PySys_GetObject(name).toNativePointer() +actual inline fun PySys_SetObject(name: String, v: NativePointer): Int = python.native.ffi.bindings.PySys_SetObject(name, v.toPlatformPointer()) +actual inline fun PySys_ResetWarnOptions() = python.native.ffi.bindings.PySys_ResetWarnOptions() +actual fun PySys_GetXOptions(): NativePointer? = python.native.ffi.bindings.PySys_GetXOptions().toNativePointer() +actual inline fun PySys_AuditTuple(event: String, args: NativePointer): Int = python.native.ffi.bindings.PySys_AuditTuple(event, args.toPlatformPointer()) + + +// Section 7 +actual inline fun Py_FatalError(message: String) = python.native.ffi.bindings.Py_FatalError(message) +actual inline fun Py_Exit(status: Int) = python.native.ffi.bindings.Py_Exit(status) + + +// Section 8 +actual fun PyImport_ImportModule(name: String): NativePointer? = python.native.ffi.bindings.PyImport_ImportModule(name).toNativePointer() +actual fun PyImport_ImportModuleNoBlock(name: String): NativePointer? = python.native.ffi.bindings.PyImport_ImportModuleNoBlock(name).toNativePointer() +actual fun PyImport_ImportModuleLevelObject(name: NativePointer, globals: NativePointer, locals: NativePointer, fromlist: NativePointer, level: Int): NativePointer? = python.native.ffi.bindings.PyImport_ImportModuleLevelObject(name.toPlatformPointer(), globals.toPlatformPointer(), locals.toPlatformPointer(), fromlist.toPlatformPointer(), level).toNativePointer() +actual fun PyImport_ImportModuleLevel(name: String, globals: NativePointer, locals: NativePointer, fromlist: NativePointer, level: Int): NativePointer? = python.native.ffi.bindings.PyImport_ImportModuleLevel(name, globals.toPlatformPointer(), locals.toPlatformPointer(), fromlist.toPlatformPointer(), level).toNativePointer() +actual fun PyImport_Import(name: NativePointer): NativePointer? = python.native.ffi.bindings.PyImport_Import(name.toPlatformPointer()).toNativePointer() +actual fun PyImport_ReloadModule(m: NativePointer): NativePointer? = python.native.ffi.bindings.PyImport_ReloadModule(m.toPlatformPointer()).toNativePointer() +actual fun PyImport_AddModuleRef(name: String): NativePointer? = python.native.ffi.bindings.PyImport_AddModuleRef(name).toNativePointer() +actual fun PyImport_AddModuleObject(name: NativePointer): NativePointer? = python.native.ffi.bindings.PyImport_AddModuleObject(name.toPlatformPointer()).toNativePointer() +actual fun PyImport_AddModule(name: String): NativePointer? = python.native.ffi.bindings.PyImport_AddModule(name).toNativePointer() +actual fun PyImport_ExecCodeModule(name: String, co: NativePointer): NativePointer? = python.native.ffi.bindings.PyImport_ExecCodeModule(name, co.toPlatformPointer()).toNativePointer() +actual fun PyImport_ExecCodeModuleEx(name: String, co: NativePointer, pathname: String): NativePointer? = python.native.ffi.bindings.PyImport_ExecCodeModuleEx(name, co.toPlatformPointer(), pathname).toNativePointer() +actual fun PyImport_ExecCodeModuleObject(name: NativePointer, co: NativePointer, pathname: NativePointer, cpathname: NativePointer): NativePointer? = python.native.ffi.bindings.PyImport_ExecCodeModuleObject(name.toPlatformPointer(), co.toPlatformPointer(), pathname.toPlatformPointer(), cpathname.toPlatformPointer()).toNativePointer() +actual fun PyImport_ExecCodeModuleWithPathnames(name: String, co: NativePointer, pathname: String, cpathname: String): NativePointer? = python.native.ffi.bindings.PyImport_ExecCodeModuleWithPathnames(name, co.toPlatformPointer(), pathname, cpathname).toNativePointer() +actual inline fun PyImport_GetMagicTag(): String? = python.native.ffi.bindings.PyImport_GetMagicTag() +actual fun PyImport_GetModuleDict(): NativePointer? = python.native.ffi.bindings.PyImport_GetModuleDict().toNativePointer() +actual fun PyImport_GetModule(name: NativePointer): NativePointer? = python.native.ffi.bindings.PyImport_GetModule(name.toPlatformPointer()).toNativePointer() +actual fun PyImport_GetImporter(path: NativePointer): NativePointer? = python.native.ffi.bindings.PyImport_GetImporter(path.toPlatformPointer()).toNativePointer() +actual inline fun PyImport_ImportFrozenModuleObject(name: NativePointer): Int = python.native.ffi.bindings.PyImport_ImportFrozenModuleObject(name.toPlatformPointer()) +actual inline fun PyImport_ImportFrozenModule(name: String): Int = python.native.ffi.bindings.PyImport_ImportFrozenModule(name) + + +// Section 9 +actual fun PyEval_GetBuiltins(): NativePointer? = python.native.ffi.bindings.PyEval_GetBuiltins().toNativePointer() +actual fun PyEval_GetLocals(): NativePointer? = python.native.ffi.bindings.PyEval_GetLocals().toNativePointer() +actual fun PyEval_GetGlobals(): NativePointer? = python.native.ffi.bindings.PyEval_GetGlobals().toNativePointer() +actual fun PyEval_GetFrameBuiltins(): NativePointer? = python.native.ffi.bindings.PyEval_GetFrameBuiltins().toNativePointer() +actual fun PyEval_GetFrameLocals(): NativePointer? = python.native.ffi.bindings.PyEval_GetFrameLocals().toNativePointer() +actual fun PyEval_GetFrameGlobals(): NativePointer? = python.native.ffi.bindings.PyEval_GetFrameGlobals().toNativePointer() +actual inline fun PyEval_GetFuncName(func: NativePointer): String? = python.native.ffi.bindings.PyEval_GetFuncName(func.toPlatformPointer()) +actual inline fun PyEval_GetFuncDesc(func: NativePointer): String? = python.native.ffi.bindings.PyEval_GetFuncDesc(func.toPlatformPointer()) + + +// Section 10 +actual inline fun PyObject_HasAttrWithError(o: NativePointer, attr_name: NativePointer): Int = python.native.ffi.bindings.PyObject_HasAttrWithError(o.toPlatformPointer(), attr_name.toPlatformPointer()) +actual inline fun PyObject_HasAttrStringWithError(o: NativePointer, attr_name: String): Int = python.native.ffi.bindings.PyObject_HasAttrStringWithError(o.toPlatformPointer(), attr_name) +actual inline fun PyObject_HasAttr(o: NativePointer, attr_name: NativePointer): Int = python.native.ffi.bindings.PyObject_HasAttr(o.toPlatformPointer(), attr_name.toPlatformPointer()) +actual inline fun PyObject_HasAttrString(o: NativePointer, attr_name: String): Int = python.native.ffi.bindings.PyObject_HasAttrString(o.toPlatformPointer(), attr_name) +actual fun PyObject_GetAttr(o: NativePointer, attr_name: NativePointer): NativePointer? = python.native.ffi.bindings.PyObject_GetAttr(o.toPlatformPointer(), attr_name.toPlatformPointer()).toNativePointer() +actual fun PyObject_GetAttrString(o: NativePointer, attr_name: String): NativePointer? = python.native.ffi.bindings.PyObject_GetAttrString(o.toPlatformPointer(), attr_name).toNativePointer() +actual fun PyObject_GenericGetAttr(o: NativePointer, name: NativePointer): NativePointer? = python.native.ffi.bindings.PyObject_GenericGetAttr(o.toPlatformPointer(), name.toPlatformPointer()).toNativePointer() +actual inline fun PyObject_SetAttr(o: NativePointer, attr_name: NativePointer, v: NativePointer): Int = python.native.ffi.bindings.PyObject_SetAttr(o.toPlatformPointer(), attr_name.toPlatformPointer(), v.toPlatformPointer()) +actual inline fun PyObject_SetAttrString(o: NativePointer, attr_name: String, v: NativePointer): Int = python.native.ffi.bindings.PyObject_SetAttrString(o.toPlatformPointer(), attr_name, v.toPlatformPointer()) +actual inline fun PyObject_GenericSetAttr(o: NativePointer, name: NativePointer, value: NativePointer): Int = python.native.ffi.bindings.PyObject_GenericSetAttr(o.toPlatformPointer(), name.toPlatformPointer(), value.toPlatformPointer()) +actual inline fun PyObject_DelAttr(o: NativePointer, attr_name: NativePointer): Int = python.native.ffi.bindings.PyObject_DelAttr(o.toPlatformPointer(), attr_name.toPlatformPointer()) +actual inline fun PyObject_DelAttrString(o: NativePointer, attr_name: String): Int = python.native.ffi.bindings.PyObject_DelAttrString(o.toPlatformPointer(), attr_name) +actual fun PyObject_RichCompare(o1: NativePointer, o2: NativePointer, opid: Int): NativePointer? = python.native.ffi.bindings.PyObject_RichCompare(o1.toPlatformPointer(), o2.toPlatformPointer(), opid).toNativePointer() +actual inline fun PyObject_RichCompareBool(o1: NativePointer, o2: NativePointer, opid: Int): Int = python.native.ffi.bindings.PyObject_RichCompareBool(o1.toPlatformPointer(), o2.toPlatformPointer(), opid) +actual fun PyObject_Format(obj: NativePointer, format_spec: NativePointer): NativePointer? = python.native.ffi.bindings.PyObject_Format(obj.toPlatformPointer(), format_spec.toPlatformPointer()).toNativePointer() +actual fun PyObject_Repr(o: NativePointer): NativePointer? = python.native.ffi.bindings.PyObject_Repr(o.toPlatformPointer()).toNativePointer() +actual fun PyObject_ASCII(o: NativePointer): NativePointer? = python.native.ffi.bindings.PyObject_ASCII(o.toPlatformPointer()).toNativePointer() +actual fun PyObject_Str(o: NativePointer): NativePointer? = python.native.ffi.bindings.PyObject_Str(o.toPlatformPointer()).toNativePointer() +actual fun PyObject_Bytes(o: NativePointer): NativePointer? = python.native.ffi.bindings.PyObject_Bytes(o.toPlatformPointer()).toNativePointer() +actual inline fun PyObject_IsSubclass(derived: NativePointer, cls: NativePointer): Int = python.native.ffi.bindings.PyObject_IsSubclass(derived.toPlatformPointer(), cls.toPlatformPointer()) +actual inline fun PyObject_IsInstance(inst: NativePointer, cls: NativePointer): Int = python.native.ffi.bindings.PyObject_IsInstance(inst.toPlatformPointer(), cls.toPlatformPointer()) +actual inline fun PyObject_IsTrue(o: NativePointer): Int = python.native.ffi.bindings.PyObject_IsTrue(o.toPlatformPointer()) +actual inline fun PyObject_Not(o: NativePointer): Int = python.native.ffi.bindings.PyObject_Not(o.toPlatformPointer()) +actual fun PyObject_Type(o: NativePointer): NativePointer? = python.native.ffi.bindings.PyObject_Type(o.toPlatformPointer()).toNativePointer() +actual fun PyObject_GetItem(o: NativePointer, key: NativePointer): NativePointer? = python.native.ffi.bindings.PyObject_GetItem(o.toPlatformPointer(), key.toPlatformPointer()).toNativePointer() +actual inline fun PyObject_SetItem(o: NativePointer, key: NativePointer, v: NativePointer): Int = python.native.ffi.bindings.PyObject_SetItem(o.toPlatformPointer(), key.toPlatformPointer(), v.toPlatformPointer()) +actual inline fun PyObject_DelItem(o: NativePointer, key: NativePointer): Int = python.native.ffi.bindings.PyObject_DelItem(o.toPlatformPointer(), key.toPlatformPointer()) +actual fun PyObject_Dir(o: NativePointer): NativePointer? = python.native.ffi.bindings.PyObject_Dir(o.toPlatformPointer()).toNativePointer() +actual fun PyObject_GetIter(o: NativePointer): NativePointer? = python.native.ffi.bindings.PyObject_GetIter(o.toPlatformPointer()).toNativePointer() +actual fun PyObject_GetAIter(o: NativePointer): NativePointer? = python.native.ffi.bindings.PyObject_GetAIter(o.toPlatformPointer()).toNativePointer() + + +// Section 11 +actual fun PyVectorcall_Call(callable: NativePointer, tuple: NativePointer, dict: NativePointer): NativePointer? = python.native.ffi.bindings.PyVectorcall_Call(callable.toPlatformPointer(), tuple.toPlatformPointer(), dict.toPlatformPointer()).toNativePointer() +actual fun PyObject_Call(callable: NativePointer, args: NativePointer, kwargs: NativePointer): NativePointer? = python.native.ffi.bindings.PyObject_Call(callable.toPlatformPointer(), args.toPlatformPointer(), kwargs.toPlatformPointer()).toNativePointer() +actual fun PyObject_CallNoArgs(callable: NativePointer): NativePointer? = python.native.ffi.bindings.PyObject_CallNoArgs(callable.toPlatformPointer()).toNativePointer() +actual fun PyObject_CallObject(callable: NativePointer, args: NativePointer): NativePointer? = python.native.ffi.bindings.PyObject_CallObject(callable.toPlatformPointer(), args.toPlatformPointer()).toNativePointer() +actual inline fun PyCallable_Check(o: NativePointer): Int = python.native.ffi.bindings.PyCallable_Check(o.toPlatformPointer()) + + +// Section 12 +actual inline fun PyNumber_Check(o: NativePointer): Int = python.native.ffi.bindings.PyNumber_Check(o.toPlatformPointer()) +actual fun PyNumber_Add(o1: NativePointer, o2: NativePointer): NativePointer? = python.native.ffi.bindings.PyNumber_Add(o1.toPlatformPointer(), o2.toPlatformPointer()).toNativePointer() +actual fun PyNumber_Subtract(o1: NativePointer, o2: NativePointer): NativePointer? = python.native.ffi.bindings.PyNumber_Subtract(o1.toPlatformPointer(), o2.toPlatformPointer()).toNativePointer() +actual fun PyNumber_Multiply(o1: NativePointer, o2: NativePointer): NativePointer? = python.native.ffi.bindings.PyNumber_Multiply(o1.toPlatformPointer(), o2.toPlatformPointer()).toNativePointer() +actual fun PyNumber_MatrixMultiply(o1: NativePointer, o2: NativePointer): NativePointer? = python.native.ffi.bindings.PyNumber_MatrixMultiply(o1.toPlatformPointer(), o2.toPlatformPointer()).toNativePointer() +actual fun PyNumber_FloorDivide(o1: NativePointer, o2: NativePointer): NativePointer? = python.native.ffi.bindings.PyNumber_FloorDivide(o1.toPlatformPointer(), o2.toPlatformPointer()).toNativePointer() +actual fun PyNumber_TrueDivide(o1: NativePointer, o2: NativePointer): NativePointer? = python.native.ffi.bindings.PyNumber_TrueDivide(o1.toPlatformPointer(), o2.toPlatformPointer()).toNativePointer() +actual fun PyNumber_Remainder(o1: NativePointer, o2: NativePointer): NativePointer? = python.native.ffi.bindings.PyNumber_Remainder(o1.toPlatformPointer(), o2.toPlatformPointer()).toNativePointer() +actual fun PyNumber_Divmod(o1: NativePointer, o2: NativePointer): NativePointer? = python.native.ffi.bindings.PyNumber_Divmod(o1.toPlatformPointer(), o2.toPlatformPointer()).toNativePointer() +actual fun PyNumber_Power(o1: NativePointer, o2: NativePointer, o3: NativePointer): NativePointer? = python.native.ffi.bindings.PyNumber_Power(o1.toPlatformPointer(), o2.toPlatformPointer(), o3.toPlatformPointer()).toNativePointer() +actual fun PyNumber_Negative(o: NativePointer): NativePointer? = python.native.ffi.bindings.PyNumber_Negative(o.toPlatformPointer()).toNativePointer() +actual fun PyNumber_Positive(o: NativePointer): NativePointer? = python.native.ffi.bindings.PyNumber_Positive(o.toPlatformPointer()).toNativePointer() +actual fun PyNumber_Absolute(o: NativePointer): NativePointer? = python.native.ffi.bindings.PyNumber_Absolute(o.toPlatformPointer()).toNativePointer() +actual fun PyNumber_Invert(o: NativePointer): NativePointer? = python.native.ffi.bindings.PyNumber_Invert(o.toPlatformPointer()).toNativePointer() +actual fun PyNumber_Lshift(o1: NativePointer, o2: NativePointer): NativePointer? = python.native.ffi.bindings.PyNumber_Lshift(o1.toPlatformPointer(), o2.toPlatformPointer()).toNativePointer() +actual fun PyNumber_Rshift(o1: NativePointer, o2: NativePointer): NativePointer? = python.native.ffi.bindings.PyNumber_Rshift(o1.toPlatformPointer(), o2.toPlatformPointer()).toNativePointer() +actual fun PyNumber_And(o1: NativePointer, o2: NativePointer): NativePointer? = python.native.ffi.bindings.PyNumber_And(o1.toPlatformPointer(), o2.toPlatformPointer()).toNativePointer() +actual fun PyNumber_Xor(o1: NativePointer, o2: NativePointer): NativePointer? = python.native.ffi.bindings.PyNumber_Xor(o1.toPlatformPointer(), o2.toPlatformPointer()).toNativePointer() +actual fun PyNumber_Or(o1: NativePointer, o2: NativePointer): NativePointer? = python.native.ffi.bindings.PyNumber_Or(o1.toPlatformPointer(), o2.toPlatformPointer()).toNativePointer() +actual fun PyNumber_InPlaceAdd(o1: NativePointer, o2: NativePointer): NativePointer? = python.native.ffi.bindings.PyNumber_InPlaceAdd(o1.toPlatformPointer(), o2.toPlatformPointer()).toNativePointer() +actual fun PyNumber_InPlaceSubtract(o1: NativePointer, o2: NativePointer): NativePointer? = python.native.ffi.bindings.PyNumber_InPlaceSubtract(o1.toPlatformPointer(), o2.toPlatformPointer()).toNativePointer() +actual fun PyNumber_InPlaceMultiply(o1: NativePointer, o2: NativePointer): NativePointer? = python.native.ffi.bindings.PyNumber_InPlaceMultiply(o1.toPlatformPointer(), o2.toPlatformPointer()).toNativePointer() +actual fun PyNumber_InPlaceMatrixMultiply(o1: NativePointer, o2: NativePointer): NativePointer? = python.native.ffi.bindings.PyNumber_InPlaceMatrixMultiply(o1.toPlatformPointer(), o2.toPlatformPointer()).toNativePointer() +actual fun PyNumber_InPlaceFloorDivide(o1: NativePointer, o2: NativePointer): NativePointer? = python.native.ffi.bindings.PyNumber_InPlaceFloorDivide(o1.toPlatformPointer(), o2.toPlatformPointer()).toNativePointer() +actual fun PyNumber_InPlaceTrueDivide(o1: NativePointer, o2: NativePointer): NativePointer? = python.native.ffi.bindings.PyNumber_InPlaceTrueDivide(o1.toPlatformPointer(), o2.toPlatformPointer()).toNativePointer() +actual fun PyNumber_InPlaceRemainder(o1: NativePointer, o2: NativePointer): NativePointer? = python.native.ffi.bindings.PyNumber_InPlaceRemainder(o1.toPlatformPointer(), o2.toPlatformPointer()).toNativePointer() +actual fun PyNumber_InPlacePower(o1: NativePointer, o2: NativePointer, o3: NativePointer): NativePointer? = python.native.ffi.bindings.PyNumber_InPlacePower(o1.toPlatformPointer(), o2.toPlatformPointer(), o3.toPlatformPointer()).toNativePointer() +actual fun PyNumber_InPlaceLshift(o1: NativePointer, o2: NativePointer): NativePointer? = python.native.ffi.bindings.PyNumber_InPlaceLshift(o1.toPlatformPointer(), o2.toPlatformPointer()).toNativePointer() +actual fun PyNumber_InPlaceRshift(o1: NativePointer, o2: NativePointer): NativePointer? = python.native.ffi.bindings.PyNumber_InPlaceRshift(o1.toPlatformPointer(), o2.toPlatformPointer()).toNativePointer() +actual fun PyNumber_InPlaceAnd(o1: NativePointer, o2: NativePointer): NativePointer? = python.native.ffi.bindings.PyNumber_InPlaceAnd(o1.toPlatformPointer(), o2.toPlatformPointer()).toNativePointer() +actual fun PyNumber_InPlaceXor(o1: NativePointer, o2: NativePointer): NativePointer? = python.native.ffi.bindings.PyNumber_InPlaceXor(o1.toPlatformPointer(), o2.toPlatformPointer()).toNativePointer() +actual fun PyNumber_InPlaceOr(o1: NativePointer, o2: NativePointer): NativePointer? = python.native.ffi.bindings.PyNumber_InPlaceOr(o1.toPlatformPointer(), o2.toPlatformPointer()).toNativePointer() +actual fun PyNumber_Long(o: NativePointer): NativePointer? = python.native.ffi.bindings.PyNumber_Long(o.toPlatformPointer()).toNativePointer() +actual fun PyNumber_Float(o: NativePointer): NativePointer? = python.native.ffi.bindings.PyNumber_Float(o.toPlatformPointer()).toNativePointer() +actual fun PyNumber_Index(o: NativePointer): NativePointer? = python.native.ffi.bindings.PyNumber_Index(o.toPlatformPointer()).toNativePointer() +actual fun PyNumber_ToBase(n: NativePointer, base: Int): NativePointer? = python.native.ffi.bindings.PyNumber_ToBase(n.toPlatformPointer(), base).toNativePointer() +actual inline fun PyIndex_Check(o: NativePointer): Int = python.native.ffi.bindings.PyIndex_Check(o.toPlatformPointer()) + + +// Section 13 +actual inline fun PySequence_Check(o: NativePointer): Int = python.native.ffi.bindings.PySequence_Check(o.toPlatformPointer()) +actual fun PySequence_Concat(o1: NativePointer, o2: NativePointer): NativePointer? = python.native.ffi.bindings.PySequence_Concat(o1.toPlatformPointer(), o2.toPlatformPointer()).toNativePointer() +actual fun PySequence_InPlaceConcat(o1: NativePointer, o2: NativePointer): NativePointer? = python.native.ffi.bindings.PySequence_InPlaceConcat(o1.toPlatformPointer(), o2.toPlatformPointer()).toNativePointer() +actual inline fun PySequence_Contains(o: NativePointer, value: NativePointer): Int = python.native.ffi.bindings.PySequence_Contains(o.toPlatformPointer(), value.toPlatformPointer()) +actual fun PySequence_List(o: NativePointer): NativePointer? = python.native.ffi.bindings.PySequence_List(o.toPlatformPointer()).toNativePointer() +actual fun PySequence_Tuple(o: NativePointer): NativePointer? = python.native.ffi.bindings.PySequence_Tuple(o.toPlatformPointer()).toNativePointer() +actual fun PySequence_Fast(o: NativePointer, m: String): NativePointer? = python.native.ffi.bindings.PySequence_Fast(o.toPlatformPointer(), m).toNativePointer() + + +// Section 14 +actual inline fun PyMapping_Check(o: NativePointer): Int = python.native.ffi.bindings.PyMapping_Check(o.toPlatformPointer()) +actual fun PyMapping_GetItemString(o: NativePointer, key: String): NativePointer? = python.native.ffi.bindings.PyMapping_GetItemString(o.toPlatformPointer(), key).toNativePointer() +actual inline fun PyMapping_SetItemString(o: NativePointer, key: String, v: NativePointer): Int = python.native.ffi.bindings.PyMapping_SetItemString(o.toPlatformPointer(), key, v.toPlatformPointer()) +actual inline fun PyMapping_HasKeyWithError(o: NativePointer, key: NativePointer): Int = python.native.ffi.bindings.PyMapping_HasKeyWithError(o.toPlatformPointer(), key.toPlatformPointer()) +actual inline fun PyMapping_HasKeyStringWithError(o: NativePointer, key: String): Int = python.native.ffi.bindings.PyMapping_HasKeyStringWithError(o.toPlatformPointer(), key) +actual inline fun PyMapping_HasKey(o: NativePointer, key: NativePointer): Int = python.native.ffi.bindings.PyMapping_HasKey(o.toPlatformPointer(), key.toPlatformPointer()) +actual inline fun PyMapping_HasKeyString(o: NativePointer, key: String): Int = python.native.ffi.bindings.PyMapping_HasKeyString(o.toPlatformPointer(), key) +actual fun PyMapping_Keys(o: NativePointer): NativePointer? = python.native.ffi.bindings.PyMapping_Keys(o.toPlatformPointer()).toNativePointer() +actual fun PyMapping_Values(o: NativePointer): NativePointer? = python.native.ffi.bindings.PyMapping_Values(o.toPlatformPointer()).toNativePointer() +actual fun PyMapping_Items(o: NativePointer): NativePointer? = python.native.ffi.bindings.PyMapping_Items(o.toPlatformPointer()).toNativePointer() + + +// Section 15 +actual inline fun PyIter_Check(o: NativePointer): Int = python.native.ffi.bindings.PyIter_Check(o.toPlatformPointer()) +actual inline fun PyAIter_Check(o: NativePointer): Int = python.native.ffi.bindings.PyAIter_Check(o.toPlatformPointer()) +actual fun PyIter_Next(o: NativePointer): NativePointer? = python.native.ffi.bindings.PyIter_Next(o.toPlatformPointer()).toNativePointer() + + +// Section 16 +actual fun PyLong_FromLongLong(v: Long): NativePointer? = python.native.ffi.bindings.PyLong_FromLongLong(v).toNativePointer() +actual fun PyLong_FromDouble(v: Double): NativePointer? = python.native.ffi.bindings.PyLong_FromDouble(v).toNativePointer() +actual inline fun PyLong_AsInt(obj: NativePointer): Int = python.native.ffi.bindings.PyLong_AsInt(obj.toPlatformPointer()) +actual inline fun PyLong_AsLongLong(obj: NativePointer): Long = python.native.ffi.bindings.PyLong_AsLongLong(obj.toPlatformPointer()) +actual inline fun PyLong_AsDouble(pylong: NativePointer): Double = python.native.ffi.bindings.PyLong_AsDouble(pylong.toPlatformPointer()) +actual fun PyLong_GetInfo(): NativePointer? = python.native.ffi.bindings.PyLong_GetInfo().toNativePointer() + + +// Section 17 +actual fun PyBool_FromLong(v: Int): NativePointer? = python.native.ffi.bindings.PyBool_FromLong(v.toLong()).toNativePointer() + + +// Section 18 +actual fun PyFloat_FromString(str: NativePointer): NativePointer? = python.native.ffi.bindings.PyFloat_FromString(str.toPlatformPointer()).toNativePointer() +actual fun PyFloat_FromDouble(v: Double): NativePointer? = python.native.ffi.bindings.PyFloat_FromDouble(v).toNativePointer() +actual inline fun PyFloat_AsDouble(pyfloat: NativePointer): Double = python.native.ffi.bindings.PyFloat_AsDouble(pyfloat.toPlatformPointer()) +actual fun PyFloat_GetInfo(): NativePointer? = python.native.ffi.bindings.PyFloat_GetInfo().toNativePointer() +actual inline fun PyFloat_GetMax(): Double = python.native.ffi.bindings.PyFloat_GetMax() +actual inline fun PyFloat_GetMin(): Double = python.native.ffi.bindings.PyFloat_GetMin() + + +// Section 19 +actual fun PyBytes_FromString(v: String): NativePointer? = python.native.ffi.bindings.PyBytes_FromString(v).toNativePointer() +actual fun PyBytes_FromObject(o: NativePointer): NativePointer? = python.native.ffi.bindings.PyBytes_FromObject(o.toPlatformPointer()).toNativePointer() +actual inline fun PyBytes_AsString(o: NativePointer): String? = python.native.ffi.bindings.PyBytes_AsString(o.toPlatformPointer()) + + +// Section 20 +actual fun PyByteArray_FromObject(o: NativePointer): NativePointer? = python.native.ffi.bindings.PyByteArray_FromObject(o.toPlatformPointer()).toNativePointer() +actual fun PyByteArray_Concat(a: NativePointer, b: NativePointer): NativePointer? = python.native.ffi.bindings.PyByteArray_Concat(a.toPlatformPointer(), b.toPlatformPointer()).toNativePointer() +actual inline fun PyByteArray_AsString(bytearray: NativePointer): String? = python.native.ffi.bindings.PyByteArray_AsString(bytearray.toPlatformPointer()) + + +// Section 21 +actual inline fun PyUnicode_IsIdentifier(unicode: NativePointer): Int = python.native.ffi.bindings.PyUnicode_IsIdentifier(unicode.toPlatformPointer()) +actual fun PyUnicode_FromString(str: String): NativePointer? = python.native.ffi.bindings.PyUnicode_FromString(str).toNativePointer() +actual fun PyUnicode_FromObject(obj: NativePointer): NativePointer? = python.native.ffi.bindings.PyUnicode_FromObject(obj.toPlatformPointer()).toNativePointer() +actual fun PyUnicode_FromEncodedObject(obj: NativePointer, encoding: String, errors: String): NativePointer? = python.native.ffi.bindings.PyUnicode_FromEncodedObject(obj.toPlatformPointer(), encoding, errors).toNativePointer() +actual fun PyUnicode_DecodeLocale(str: String, errors: String): NativePointer? = python.native.ffi.bindings.PyUnicode_DecodeLocale(str, errors).toNativePointer() +actual fun PyUnicode_EncodeLocale(unicode: NativePointer, errors: String): NativePointer? = python.native.ffi.bindings.PyUnicode_EncodeLocale(unicode.toPlatformPointer(), errors).toNativePointer() +actual fun PyUnicode_DecodeFSDefault(str: String): NativePointer? = python.native.ffi.bindings.PyUnicode_DecodeFSDefault(str).toNativePointer() +actual fun PyUnicode_EncodeFSDefault(unicode: NativePointer): NativePointer? = python.native.ffi.bindings.PyUnicode_EncodeFSDefault(unicode.toPlatformPointer()).toNativePointer() +actual fun PyUnicode_AsEncodedString(unicode: NativePointer, encoding: String, errors: String): NativePointer? = python.native.ffi.bindings.PyUnicode_AsEncodedString(unicode.toPlatformPointer(), encoding, errors).toNativePointer() +actual fun PyUnicode_AsUTF8String(unicode: NativePointer): NativePointer? = python.native.ffi.bindings.PyUnicode_AsUTF8String(unicode.toPlatformPointer()).toNativePointer() +actual inline fun PyUnicode_AsUTF8(unicode: NativePointer): String? = python.native.ffi.bindings.PyUnicode_AsUTF8(unicode.toPlatformPointer()) // 수동 추가 +actual fun PyUnicode_AsUTF32String(unicode: NativePointer): NativePointer? = python.native.ffi.bindings.PyUnicode_AsUTF32String(unicode.toPlatformPointer()).toNativePointer() +actual fun PyUnicode_AsUTF16String(unicode: NativePointer): NativePointer? = python.native.ffi.bindings.PyUnicode_AsUTF16String(unicode.toPlatformPointer()).toNativePointer() +actual fun PyUnicode_AsUnicodeEscapeString(unicode: NativePointer): NativePointer? = python.native.ffi.bindings.PyUnicode_AsUnicodeEscapeString(unicode.toPlatformPointer()).toNativePointer() +actual fun PyUnicode_AsRawUnicodeEscapeString(unicode: NativePointer): NativePointer? = python.native.ffi.bindings.PyUnicode_AsRawUnicodeEscapeString(unicode.toPlatformPointer()).toNativePointer() +actual fun PyUnicode_AsLatin1String(unicode: NativePointer): NativePointer? = python.native.ffi.bindings.PyUnicode_AsLatin1String(unicode.toPlatformPointer()).toNativePointer() +actual fun PyUnicode_AsASCIIString(unicode: NativePointer): NativePointer? = python.native.ffi.bindings.PyUnicode_AsASCIIString(unicode.toPlatformPointer()).toNativePointer() +actual fun PyUnicode_AsCharmapString(unicode: NativePointer, mapping: NativePointer): NativePointer? = python.native.ffi.bindings.PyUnicode_AsCharmapString(unicode.toPlatformPointer(), mapping.toPlatformPointer()).toNativePointer() +actual fun PyUnicode_Translate(unicode: NativePointer, table: NativePointer, errors: String): NativePointer? = python.native.ffi.bindings.PyUnicode_Translate(unicode.toPlatformPointer(), table.toPlatformPointer(), errors).toNativePointer() +actual fun PyUnicode_Concat(left: NativePointer, right: NativePointer): NativePointer? = python.native.ffi.bindings.PyUnicode_Concat(left.toPlatformPointer(), right.toPlatformPointer()).toNativePointer() +actual fun PyUnicode_Splitlines(unicode: NativePointer, keepends: Int): NativePointer? = python.native.ffi.bindings.PyUnicode_Splitlines(unicode.toPlatformPointer(), keepends).toNativePointer() +actual fun PyUnicode_Join(separator: NativePointer, seq: NativePointer): NativePointer? = python.native.ffi.bindings.PyUnicode_Join(separator.toPlatformPointer(), seq.toPlatformPointer()).toNativePointer() +actual inline fun PyUnicode_Compare(left: NativePointer, right: NativePointer): Int = python.native.ffi.bindings.PyUnicode_Compare(left.toPlatformPointer(), right.toPlatformPointer()) +actual inline fun PyUnicode_EqualToUTF8(unicode: NativePointer, string: String): Int = python.native.ffi.bindings.PyUnicode_EqualToUTF8(unicode.toPlatformPointer(), string) +actual inline fun PyUnicode_CompareWithASCIIString(unicode: NativePointer, string: String): Int = python.native.ffi.bindings.PyUnicode_CompareWithASCIIString(unicode.toPlatformPointer(), string) +actual fun PyUnicode_RichCompare(left: NativePointer, right: NativePointer, op: Int): NativePointer? = python.native.ffi.bindings.PyUnicode_RichCompare(left.toPlatformPointer(), right.toPlatformPointer(), op).toNativePointer() +actual fun PyUnicode_Format(format: NativePointer, args: NativePointer): NativePointer? = python.native.ffi.bindings.PyUnicode_Format(format.toPlatformPointer(), args.toPlatformPointer()).toNativePointer() +actual inline fun PyUnicode_Contains(unicode: NativePointer, substr: NativePointer): Int = python.native.ffi.bindings.PyUnicode_Contains(unicode.toPlatformPointer(), substr.toPlatformPointer()) +actual fun PyUnicode_InternFromString(str: String): NativePointer? = python.native.ffi.bindings.PyUnicode_InternFromString(str).toNativePointer() + + +// Section 22 +actual inline fun PyList_Append(list: NativePointer, item: NativePointer): Int = python.native.ffi.bindings.PyList_Append(list.toPlatformPointer(), item.toPlatformPointer()) +actual inline fun PyList_Sort(list: NativePointer): Int = python.native.ffi.bindings.PyList_Sort(list.toPlatformPointer()) +actual inline fun PyList_Reverse(list: NativePointer): Int = python.native.ffi.bindings.PyList_Reverse(list.toPlatformPointer()) +actual fun PyList_AsTuple(list: NativePointer): NativePointer? = python.native.ffi.bindings.PyList_AsTuple(list.toPlatformPointer()).toNativePointer() + + +// Section 23 +actual fun PyDict_New(): NativePointer? = python.native.ffi.bindings.PyDict_New().toNativePointer() +actual fun PyDictProxy_New(mapping: NativePointer): NativePointer? = python.native.ffi.bindings.PyDictProxy_New(mapping.toPlatformPointer()).toNativePointer() +actual inline fun PyDict_Clear(p: NativePointer) = python.native.ffi.bindings.PyDict_Clear(p.toPlatformPointer()) +actual inline fun PyDict_Contains(p: NativePointer, key: NativePointer): Int = python.native.ffi.bindings.PyDict_Contains(p.toPlatformPointer(), key.toPlatformPointer()) +actual fun PyDict_Copy(p: NativePointer): NativePointer? = python.native.ffi.bindings.PyDict_Copy(p.toPlatformPointer()).toNativePointer() +actual inline fun PyDict_SetItem(p: NativePointer, key: NativePointer, v: NativePointer): Int = python.native.ffi.bindings.PyDict_SetItem(p.toPlatformPointer(), key.toPlatformPointer(), v.toPlatformPointer()) +actual inline fun PyDict_SetItemString(p: NativePointer, key: String, v: NativePointer): Int = python.native.ffi.bindings.PyDict_SetItemString(p.toPlatformPointer(), key, v.toPlatformPointer()) +actual inline fun PyDict_DelItem(p: NativePointer, key: NativePointer): Int = python.native.ffi.bindings.PyDict_DelItem(p.toPlatformPointer(), key.toPlatformPointer()) +actual inline fun PyDict_DelItemString(p: NativePointer, key: String): Int = python.native.ffi.bindings.PyDict_DelItemString(p.toPlatformPointer(), key) +actual fun PyDict_GetItem(p: NativePointer, key: NativePointer): NativePointer? = python.native.ffi.bindings.PyDict_GetItem(p.toPlatformPointer(), key.toPlatformPointer()).toNativePointer() +actual fun PyDict_GetItemWithError(p: NativePointer, key: NativePointer): NativePointer? = python.native.ffi.bindings.PyDict_GetItemWithError(p.toPlatformPointer(), key.toPlatformPointer()).toNativePointer() +actual fun PyDict_GetItemString(p: NativePointer, key: String): NativePointer? = python.native.ffi.bindings.PyDict_GetItemString(p.toPlatformPointer(), key).toNativePointer() +actual fun PyDict_Items(p: NativePointer): NativePointer? = python.native.ffi.bindings.PyDict_Items(p.toPlatformPointer()).toNativePointer() +actual fun PyDict_Keys(p: NativePointer): NativePointer? = python.native.ffi.bindings.PyDict_Keys(p.toPlatformPointer()).toNativePointer() +actual fun PyDict_Values(p: NativePointer): NativePointer? = python.native.ffi.bindings.PyDict_Values(p.toPlatformPointer()).toNativePointer() +actual inline fun PyDict_Merge(a: NativePointer, b: NativePointer, override: Int): Int = python.native.ffi.bindings.PyDict_Merge(a.toPlatformPointer(), b.toPlatformPointer(), override) +actual inline fun PyDict_Update(a: NativePointer, b: NativePointer): Int = python.native.ffi.bindings.PyDict_Update(a.toPlatformPointer(), b.toPlatformPointer()) +actual inline fun PyDict_MergeFromSeq2(a: NativePointer, seq2: NativePointer, override: Int): Int = python.native.ffi.bindings.PyDict_MergeFromSeq2(a.toPlatformPointer(), seq2.toPlatformPointer(), override) + + +// Section 24 +actual fun PySet_New(iterable: NativePointer): NativePointer? = python.native.ffi.bindings.PySet_New(iterable.toPlatformPointer()).toNativePointer() +actual fun PyFrozenSet_New(iterable: NativePointer): NativePointer? = python.native.ffi.bindings.PyFrozenSet_New(iterable.toPlatformPointer()).toNativePointer() +actual inline fun PySet_Contains(anyset: NativePointer, key: NativePointer): Int = python.native.ffi.bindings.PySet_Contains(anyset.toPlatformPointer(), key.toPlatformPointer()) +actual inline fun PySet_Add(set: NativePointer, key: NativePointer): Int = python.native.ffi.bindings.PySet_Add(set.toPlatformPointer(), key.toPlatformPointer()) +actual inline fun PySet_Discard(set: NativePointer, key: NativePointer): Int = python.native.ffi.bindings.PySet_Discard(set.toPlatformPointer(), key.toPlatformPointer()) +actual fun PySet_Pop(set: NativePointer): NativePointer? = python.native.ffi.bindings.PySet_Pop(set.toPlatformPointer()).toNativePointer() +actual inline fun PySet_Clear(set: NativePointer): Int = python.native.ffi.bindings.PySet_Clear(set.toPlatformPointer()) + + +// Section 25 +actual fun PySeqIter_New(seq: NativePointer): NativePointer? = python.native.ffi.bindings.PySeqIter_New(seq.toPlatformPointer()).toNativePointer() +actual fun PyCallIter_New(callable: NativePointer, sentinel: NativePointer): NativePointer? = python.native.ffi.bindings.PyCallIter_New(callable.toPlatformPointer(), sentinel.toPlatformPointer()).toNativePointer() + + +// Section 26 +actual fun PyWeakref_NewRef(ob: NativePointer, callback: NativePointer): NativePointer? = python.native.ffi.bindings.PyWeakref_NewRef(ob.toPlatformPointer(), callback.toPlatformPointer()).toNativePointer() +actual fun PyWeakref_NewProxy(ob: NativePointer, callback: NativePointer): NativePointer? = python.native.ffi.bindings.PyWeakref_NewProxy(ob.toPlatformPointer(), callback.toPlatformPointer()).toNativePointer() +actual fun PyWeakref_GetObject(ref: NativePointer): NativePointer? = python.native.ffi.bindings.PyWeakref_GetObject(ref.toPlatformPointer()).toNativePointer() +actual inline fun PyObject_ClearWeakRefs(o: NativePointer) = python.native.ffi.bindings.PyObject_ClearWeakRefs(o.toPlatformPointer()) + + +// Section 27 +actual inline fun PyType_IsSubtype(a: NativePointer, b: NativePointer): Int = python.native.ffi.bindings.PyType_IsSubtype(a.toPlatformPointer(), b.toPlatformPointer()) +actual inline fun PyType_Ready(type: NativePointer): Int = python.native.ffi.bindings.PyType_Ready(type.toPlatformPointer()) +actual fun PyType_GetName(type: NativePointer): NativePointer? = python.native.ffi.bindings.PyType_GetName(type.toPlatformPointer()).toNativePointer() +actual fun PyType_GetFullyQualifiedName(type: NativePointer): NativePointer? = python.native.ffi.bindings.PyType_GetFullyQualifiedName(type.toPlatformPointer()).toNativePointer() +actual fun PyType_GetModuleName(type: NativePointer): NativePointer? = python.native.ffi.bindings.PyType_GetModuleName(type.toPlatformPointer()).toNativePointer() +actual fun PyType_GetModule(type: NativePointer): NativePointer? = python.native.ffi.bindings.PyType_GetModule(type.toPlatformPointer()).toNativePointer() + + +// Section 28 +actual fun PyTuple_New(len: Long): NativePointer? = python.native.ffi.bindings.PyTuple_New(len).toNativePointer() +actual inline fun PyTuple_Size(p: NativePointer): Long = python.native.ffi.bindings.PyTuple_Size(p.toPlatformPointer()) +actual fun PyTuple_GetItem(p: NativePointer, pos: Long): NativePointer? = python.native.ffi.bindings.PyTuple_GetItem(p.toPlatformPointer(), pos).toNativePointer() +actual fun PyTuple_GetSlice(p: NativePointer, low: Long, high: Long): NativePointer? = python.native.ffi.bindings.PyTuple_GetSlice(p.toPlatformPointer(), low, high).toNativePointer() +actual inline fun PyTuple_SetItem(p: NativePointer, pos: Long, o: NativePointer): Int = python.native.ffi.bindings.PyTuple_SetItem(p.toPlatformPointer(), pos, o.toPlatformPointer()) diff --git a/python-multiplatform/src/androidMain/kotlin/python/native/ffi/bindings.kt b/python-multiplatform/src/androidMain/kotlin/python/native/ffi/bindings.kt index 0c98bd4d..82d69208 100644 --- a/python-multiplatform/src/androidMain/kotlin/python/native/ffi/bindings.kt +++ b/python-multiplatform/src/androidMain/kotlin/python/native/ffi/bindings.kt @@ -10,6 +10,7 @@ object bindings { loadLibPython() } + /** external fun Py_Initialize() external fun Py_InitializeEx(sigint: Int) //external fun Py_InitializeFromConfig() @@ -38,4 +39,384 @@ object bindings { external fun PyUnicode_FromString(str: String): JNIPointer? external fun PyUnicode_AsUTF8(unicode: JNIPointer): String? + */ + + + //************************************************** + // Section 1 + external fun Py_Initialize() + external fun Py_InitializeEx(initsigs: Int) + external fun Py_IsInitialized(): Int + external fun Py_IsFinalizing(): Int + external fun Py_FinalizeEx(): Int + external fun Py_Finalize() + // external fun Py_BytesMain(args: Array): Int // 수동 추가 + external fun Py_RunMain(): Int // 수동 추가 + external fun Py_GetVersion(): String? + external fun Py_GetPlatform(): String? + external fun Py_GetCopyright(): String? + external fun Py_GetCompiler(): String? + external fun Py_GetBuildInfo(): String? + external fun PyEval_InitThreads() + external fun PyThreadState_GetDict(): JNIPointer? + + + // Section 2 + external fun PyRun_SimpleString(command: String): Int // 수동 추가 + external fun PyRun_String(str: String, start: Int, globals: JNIPointer, locals: JNIPointer): JNIPointer? // 수동 추가 + external fun Py_CompileString(str: String, filename: String, start: Int): JNIPointer? + external fun PyEval_EvalCode(co: JNIPointer, globals: JNIPointer, locals: JNIPointer): JNIPointer? + + + // Section 3 + external fun PyErr_Clear() + external fun PyErr_PrintEx(set_sys_last_vars: Int) + external fun PyErr_Print() + external fun PyErr_WriteUnraisable(obj: JNIPointer) + external fun PyErr_DisplayException(exc: JNIPointer) + external fun PyErr_SetString(type: JNIPointer, message: String) + external fun PyErr_SetObject(type: JNIPointer, value: JNIPointer) + external fun PyErr_SetNone(type: JNIPointer) + external fun PyErr_BadArgument(): Int + external fun PyErr_NoMemory(): JNIPointer? + external fun PyErr_SetFromErrno(type: JNIPointer): JNIPointer? + external fun PyErr_SetFromErrnoWithFilenameObject(type: JNIPointer, filenameObject: JNIPointer): JNIPointer? + external fun PyErr_SetFromErrnoWithFilenameObjects(type: JNIPointer, filenameObject: JNIPointer, filenameObject2: JNIPointer): JNIPointer? + external fun PyErr_SetFromErrnoWithFilename(type: JNIPointer, filename: String): JNIPointer? + external fun PyErr_SetImportError(msg: JNIPointer, name: JNIPointer, path: JNIPointer): JNIPointer? + external fun PyErr_SetImportErrorSubclass(exception: JNIPointer, msg: JNIPointer, name: JNIPointer, path: JNIPointer): JNIPointer? + external fun PyErr_SyntaxLocationEx(filename: String, lineno: Int, col_offset: Int) + external fun PyErr_SyntaxLocation(filename: String, lineno: Int) + external fun PyErr_BadInternalCall() + external fun PyErr_WarnExplicit(category: JNIPointer, message: String, filename: String, lineno: Int, module: String, registry: JNIPointer): Int + external fun PyErr_Occurred(): JNIPointer? + external fun PyErr_ExceptionMatches(exc: JNIPointer): Int + external fun PyErr_GivenExceptionMatches(given: JNIPointer, exc: JNIPointer): Int + external fun PyErr_GetRaisedException(): JNIPointer? + external fun PyErr_SetRaisedException(exc: JNIPointer) + external fun PyErr_Restore(type: JNIPointer, value: JNIPointer, traceback: JNIPointer) + external fun PyErr_GetHandledException(): JNIPointer? + external fun PyErr_SetHandledException(exc: JNIPointer) + external fun PyErr_SetExcInfo(type: JNIPointer, value: JNIPointer, traceback: JNIPointer) + external fun PyErr_CheckSignals(): Int + external fun PyErr_SetInterrupt() + external fun PyErr_SetInterruptEx(signum: Int): Int + external fun PyErr_NewException(name: String, base: JNIPointer, dict: JNIPointer): JNIPointer? + external fun PyErr_NewExceptionWithDoc(name: String, doc: String, base: JNIPointer, dict: JNIPointer): JNIPointer? + external fun PyException_GetTraceback(ex: JNIPointer): JNIPointer? + external fun PyException_SetTraceback(ex: JNIPointer, tb: JNIPointer): Int + external fun PyException_GetContext(ex: JNIPointer): JNIPointer? + external fun PyException_SetContext(ex: JNIPointer, ctx: JNIPointer) + external fun PyException_GetCause(ex: JNIPointer): JNIPointer? + external fun PyException_SetCause(ex: JNIPointer, cause: JNIPointer) + external fun PyException_GetArgs(ex: JNIPointer): JNIPointer? + external fun PyException_SetArgs(ex: JNIPointer, args: JNIPointer) + external fun PyUnicodeEncodeError_GetEncoding(exc: JNIPointer): JNIPointer? + external fun PyUnicodeTranslateError_GetObject(exc: JNIPointer): JNIPointer? + external fun PyUnicodeTranslateError_GetReason(exc: JNIPointer): JNIPointer? + external fun PyUnicodeTranslateError_SetReason(exc: JNIPointer, reason: String): Int + external fun Py_EnterRecursiveCall(where: String): Int + external fun Py_LeaveRecursiveCall() + external fun Py_ReprEnter(o: JNIPointer): Int + external fun Py_ReprLeave(o: JNIPointer) + + + // Section 4 + external fun Py_NewRef(o: JNIPointer): JNIPointer? + external fun Py_XNewRef(o: JNIPointer): JNIPointer? + external fun Py_IncRef(o: JNIPointer) + external fun Py_DecRef(o: JNIPointer) + + + // Section 5 + external fun PyOS_FSPath(path: JNIPointer): JNIPointer? + + + // Section 6 + external fun PySys_GetObject(name: String): JNIPointer? + external fun PySys_SetObject(name: String, v: JNIPointer): Int + external fun PySys_ResetWarnOptions() + external fun PySys_GetXOptions(): JNIPointer? + external fun PySys_AuditTuple(event: String, args: JNIPointer): Int + + + // Section 7 + external fun Py_FatalError(message: String) + external fun Py_Exit(status: Int) + + + // Section 8 + external fun PyImport_ImportModule(name: String): JNIPointer? + external fun PyImport_ImportModuleNoBlock(name: String): JNIPointer? + external fun PyImport_ImportModuleLevelObject(name: JNIPointer, globals: JNIPointer, locals: JNIPointer, fromlist: JNIPointer, level: Int): JNIPointer? + external fun PyImport_ImportModuleLevel(name: String, globals: JNIPointer, locals: JNIPointer, fromlist: JNIPointer, level: Int): JNIPointer? + external fun PyImport_Import(name: JNIPointer): JNIPointer? + external fun PyImport_ReloadModule(m: JNIPointer): JNIPointer? + external fun PyImport_AddModuleRef(name: String): JNIPointer? + external fun PyImport_AddModuleObject(name: JNIPointer): JNIPointer? + external fun PyImport_AddModule(name: String): JNIPointer? + external fun PyImport_ExecCodeModule(name: String, co: JNIPointer): JNIPointer? + external fun PyImport_ExecCodeModuleEx(name: String, co: JNIPointer, pathname: String): JNIPointer? + external fun PyImport_ExecCodeModuleObject(name: JNIPointer, co: JNIPointer, pathname: JNIPointer, cpathname: JNIPointer): JNIPointer? + external fun PyImport_ExecCodeModuleWithPathnames(name: String, co: JNIPointer, pathname: String, cpathname: String): JNIPointer? + external fun PyImport_GetMagicTag(): String? + external fun PyImport_GetModuleDict(): JNIPointer? + external fun PyImport_GetModule(name: JNIPointer): JNIPointer? + external fun PyImport_GetImporter(path: JNIPointer): JNIPointer? + external fun PyImport_ImportFrozenModuleObject(name: JNIPointer): Int + external fun PyImport_ImportFrozenModule(name: String): Int + + + // Section 9 + external fun PyEval_GetBuiltins(): JNIPointer? + external fun PyEval_GetLocals(): JNIPointer? + external fun PyEval_GetGlobals(): JNIPointer? + external fun PyEval_GetFrameBuiltins(): JNIPointer? + external fun PyEval_GetFrameLocals(): JNIPointer? + external fun PyEval_GetFrameGlobals(): JNIPointer? + external fun PyEval_GetFuncName(func: JNIPointer): String? + external fun PyEval_GetFuncDesc(func: JNIPointer): String? + + + // Section 10 + external fun PyObject_HasAttrWithError(o: JNIPointer, attr_name: JNIPointer): Int + external fun PyObject_HasAttrStringWithError(o: JNIPointer, attr_name: String): Int + external fun PyObject_HasAttr(o: JNIPointer, attr_name: JNIPointer): Int + external fun PyObject_HasAttrString(o: JNIPointer, attr_name: String): Int + external fun PyObject_GetAttr(o: JNIPointer, attr_name: JNIPointer): JNIPointer? + external fun PyObject_GetAttrString(o: JNIPointer, attr_name: String): JNIPointer? + external fun PyObject_GenericGetAttr(o: JNIPointer, name: JNIPointer): JNIPointer? + external fun PyObject_SetAttr(o: JNIPointer, attr_name: JNIPointer, v: JNIPointer): Int + external fun PyObject_SetAttrString(o: JNIPointer, attr_name: String, v: JNIPointer): Int + external fun PyObject_GenericSetAttr(o: JNIPointer, name: JNIPointer, value: JNIPointer): Int + external fun PyObject_DelAttr(o: JNIPointer, attr_name: JNIPointer): Int + external fun PyObject_DelAttrString(o: JNIPointer, attr_name: String): Int + external fun PyObject_RichCompare(o1: JNIPointer, o2: JNIPointer, opid: Int): JNIPointer? + external fun PyObject_RichCompareBool(o1: JNIPointer, o2: JNIPointer, opid: Int): Int + external fun PyObject_Format(obj: JNIPointer, format_spec: JNIPointer): JNIPointer? + external fun PyObject_Repr(o: JNIPointer): JNIPointer? + external fun PyObject_ASCII(o: JNIPointer): JNIPointer? + external fun PyObject_Str(o: JNIPointer): JNIPointer? + external fun PyObject_Bytes(o: JNIPointer): JNIPointer? + external fun PyObject_IsSubclass(derived: JNIPointer, cls: JNIPointer): Int + external fun PyObject_IsInstance(inst: JNIPointer, cls: JNIPointer): Int + external fun PyObject_IsTrue(o: JNIPointer): Int + external fun PyObject_Not(o: JNIPointer): Int + external fun PyObject_Type(o: JNIPointer): JNIPointer? + external fun PyObject_GetItem(o: JNIPointer, key: JNIPointer): JNIPointer? + external fun PyObject_SetItem(o: JNIPointer, key: JNIPointer, v: JNIPointer): Int + external fun PyObject_DelItem(o: JNIPointer, key: JNIPointer): Int + external fun PyObject_Dir(o: JNIPointer): JNIPointer? + external fun PyObject_GetIter(o: JNIPointer): JNIPointer? + external fun PyObject_GetAIter(o: JNIPointer): JNIPointer? + + + // Section 11 + external fun PyVectorcall_Call(callable: JNIPointer, tuple: JNIPointer, dict: JNIPointer): JNIPointer? + external fun PyObject_Call(callable: JNIPointer, args: JNIPointer, kwargs: JNIPointer): JNIPointer? + external fun PyObject_CallNoArgs(callable: JNIPointer): JNIPointer? + external fun PyObject_CallObject(callable: JNIPointer, args: JNIPointer): JNIPointer? + external fun PyCallable_Check(o: JNIPointer): Int + + + // Section 12 + external fun PyNumber_Check(o: JNIPointer): Int + external fun PyNumber_Add(o1: JNIPointer, o2: JNIPointer): JNIPointer? + external fun PyNumber_Subtract(o1: JNIPointer, o2: JNIPointer): JNIPointer? + external fun PyNumber_Multiply(o1: JNIPointer, o2: JNIPointer): JNIPointer? + external fun PyNumber_MatrixMultiply(o1: JNIPointer, o2: JNIPointer): JNIPointer? + external fun PyNumber_FloorDivide(o1: JNIPointer, o2: JNIPointer): JNIPointer? + external fun PyNumber_TrueDivide(o1: JNIPointer, o2: JNIPointer): JNIPointer? + external fun PyNumber_Remainder(o1: JNIPointer, o2: JNIPointer): JNIPointer? + external fun PyNumber_Divmod(o1: JNIPointer, o2: JNIPointer): JNIPointer? + external fun PyNumber_Power(o1: JNIPointer, o2: JNIPointer, o3: JNIPointer): JNIPointer? + external fun PyNumber_Negative(o: JNIPointer): JNIPointer? + external fun PyNumber_Positive(o: JNIPointer): JNIPointer? + external fun PyNumber_Absolute(o: JNIPointer): JNIPointer? + external fun PyNumber_Invert(o: JNIPointer): JNIPointer? + external fun PyNumber_Lshift(o1: JNIPointer, o2: JNIPointer): JNIPointer? + external fun PyNumber_Rshift(o1: JNIPointer, o2: JNIPointer): JNIPointer? + external fun PyNumber_And(o1: JNIPointer, o2: JNIPointer): JNIPointer? + external fun PyNumber_Xor(o1: JNIPointer, o2: JNIPointer): JNIPointer? + external fun PyNumber_Or(o1: JNIPointer, o2: JNIPointer): JNIPointer? + external fun PyNumber_InPlaceAdd(o1: JNIPointer, o2: JNIPointer): JNIPointer? + external fun PyNumber_InPlaceSubtract(o1: JNIPointer, o2: JNIPointer): JNIPointer? + external fun PyNumber_InPlaceMultiply(o1: JNIPointer, o2: JNIPointer): JNIPointer? + external fun PyNumber_InPlaceMatrixMultiply(o1: JNIPointer, o2: JNIPointer): JNIPointer? + external fun PyNumber_InPlaceFloorDivide(o1: JNIPointer, o2: JNIPointer): JNIPointer? + external fun PyNumber_InPlaceTrueDivide(o1: JNIPointer, o2: JNIPointer): JNIPointer? + external fun PyNumber_InPlaceRemainder(o1: JNIPointer, o2: JNIPointer): JNIPointer? + external fun PyNumber_InPlacePower(o1: JNIPointer, o2: JNIPointer, o3: JNIPointer): JNIPointer? + external fun PyNumber_InPlaceLshift(o1: JNIPointer, o2: JNIPointer): JNIPointer? + external fun PyNumber_InPlaceRshift(o1: JNIPointer, o2: JNIPointer): JNIPointer? + external fun PyNumber_InPlaceAnd(o1: JNIPointer, o2: JNIPointer): JNIPointer? + external fun PyNumber_InPlaceXor(o1: JNIPointer, o2: JNIPointer): JNIPointer? + external fun PyNumber_InPlaceOr(o1: JNIPointer, o2: JNIPointer): JNIPointer? + external fun PyNumber_Long(o: JNIPointer): JNIPointer? + external fun PyNumber_Float(o: JNIPointer): JNIPointer? + external fun PyNumber_Index(o: JNIPointer): JNIPointer? + external fun PyNumber_ToBase(n: JNIPointer, base: Int): JNIPointer? + external fun PyIndex_Check(o: JNIPointer): Int + + + // Section 13 + external fun PySequence_Check(o: JNIPointer): Int + external fun PySequence_Concat(o1: JNIPointer, o2: JNIPointer): JNIPointer? + external fun PySequence_InPlaceConcat(o1: JNIPointer, o2: JNIPointer): JNIPointer? + external fun PySequence_Contains(o: JNIPointer, value: JNIPointer): Int + external fun PySequence_List(o: JNIPointer): JNIPointer? + external fun PySequence_Tuple(o: JNIPointer): JNIPointer? + external fun PySequence_Fast(o: JNIPointer, m: String): JNIPointer? + + + // Section 14 + external fun PyMapping_Check(o: JNIPointer): Int + external fun PyMapping_GetItemString(o: JNIPointer, key: String): JNIPointer? + external fun PyMapping_SetItemString(o: JNIPointer, key: String, v: JNIPointer): Int + external fun PyMapping_HasKeyWithError(o: JNIPointer, key: JNIPointer): Int + external fun PyMapping_HasKeyStringWithError(o: JNIPointer, key: String): Int + external fun PyMapping_HasKey(o: JNIPointer, key: JNIPointer): Int + external fun PyMapping_HasKeyString(o: JNIPointer, key: String): Int + external fun PyMapping_Keys(o: JNIPointer): JNIPointer? + external fun PyMapping_Values(o: JNIPointer): JNIPointer? + external fun PyMapping_Items(o: JNIPointer): JNIPointer? + + + // Section 15 + external fun PyIter_Check(o: JNIPointer): Int + external fun PyAIter_Check(o: JNIPointer): Int + external fun PyIter_Next(o: JNIPointer): JNIPointer? + + + // Section 16 + external fun PyLong_FromLongLong(v: Long): JNIPointer? + external fun PyLong_FromDouble(v: Double): JNIPointer? + external fun PyLong_AsInt(obj: JNIPointer): Int + external fun PyLong_AsLongLong(obj: JNIPointer): Long + external fun PyLong_AsDouble(pylong: JNIPointer): Double + external fun PyLong_GetInfo(): JNIPointer? + + + // Section 17 + external fun PyBool_FromLong(v: Long): JNIPointer? + + + // Section 18 + external fun PyFloat_FromString(str: JNIPointer): JNIPointer? + external fun PyFloat_FromDouble(v: Double): JNIPointer? + external fun PyFloat_AsDouble(pyfloat: JNIPointer): Double + external fun PyFloat_GetInfo(): JNIPointer? + external fun PyFloat_GetMax(): Double + external fun PyFloat_GetMin(): Double + + + // Section 19 + external fun PyBytes_FromString(v: String): JNIPointer? + external fun PyBytes_FromObject(o: JNIPointer): JNIPointer? + external fun PyBytes_AsString(o: JNIPointer): String? + + + // Section 20 + external fun PyByteArray_FromObject(o: JNIPointer): JNIPointer? + external fun PyByteArray_Concat(a: JNIPointer, b: JNIPointer): JNIPointer? + external fun PyByteArray_AsString(bytearray: JNIPointer): String? + + + // Section 21 + external fun PyUnicode_IsIdentifier(unicode: JNIPointer): Int + external fun PyUnicode_FromString(str: String): JNIPointer? + external fun PyUnicode_FromObject(obj: JNIPointer): JNIPointer? + external fun PyUnicode_FromEncodedObject(obj: JNIPointer, encoding: String, errors: String): JNIPointer? + external fun PyUnicode_DecodeLocale(str: String, errors: String): JNIPointer? + external fun PyUnicode_EncodeLocale(unicode: JNIPointer, errors: String): JNIPointer? + external fun PyUnicode_DecodeFSDefault(str: String): JNIPointer? + external fun PyUnicode_EncodeFSDefault(unicode: JNIPointer): JNIPointer? + external fun PyUnicode_AsEncodedString(unicode: JNIPointer, encoding: String, errors: String): JNIPointer? + external fun PyUnicode_AsUTF8String(unicode: JNIPointer): JNIPointer? + external fun PyUnicode_AsUTF8(unicode: JNIPointer): String? // 수동 추가 + external fun PyUnicode_AsUTF32String(unicode: JNIPointer): JNIPointer? + external fun PyUnicode_AsUTF16String(unicode: JNIPointer): JNIPointer? + external fun PyUnicode_AsUnicodeEscapeString(unicode: JNIPointer): JNIPointer? + external fun PyUnicode_AsRawUnicodeEscapeString(unicode: JNIPointer): JNIPointer? + external fun PyUnicode_AsLatin1String(unicode: JNIPointer): JNIPointer? + external fun PyUnicode_AsASCIIString(unicode: JNIPointer): JNIPointer? + external fun PyUnicode_AsCharmapString(unicode: JNIPointer, mapping: JNIPointer): JNIPointer? + external fun PyUnicode_Translate(unicode: JNIPointer, table: JNIPointer, errors: String): JNIPointer? + external fun PyUnicode_Concat(left: JNIPointer, right: JNIPointer): JNIPointer? + external fun PyUnicode_Splitlines(unicode: JNIPointer, keepends: Int): JNIPointer? + external fun PyUnicode_Join(separator: JNIPointer, seq: JNIPointer): JNIPointer? + external fun PyUnicode_Compare(left: JNIPointer, right: JNIPointer): Int + external fun PyUnicode_EqualToUTF8(unicode: JNIPointer, string: String): Int + external fun PyUnicode_CompareWithASCIIString(unicode: JNIPointer, string: String): Int + external fun PyUnicode_RichCompare(left: JNIPointer, right: JNIPointer, op: Int): JNIPointer? + external fun PyUnicode_Format(format: JNIPointer, args: JNIPointer): JNIPointer? + external fun PyUnicode_Contains(unicode: JNIPointer, substr: JNIPointer): Int + external fun PyUnicode_InternFromString(str: String): JNIPointer? + + + // Section 22 + external fun PyList_Append(list: JNIPointer, item: JNIPointer): Int + external fun PyList_Sort(list: JNIPointer): Int + external fun PyList_Reverse(list: JNIPointer): Int + external fun PyList_AsTuple(list: JNIPointer): JNIPointer? + + + // Section 23 + external fun PyDict_New(): JNIPointer? + external fun PyDictProxy_New(mapping: JNIPointer): JNIPointer? + external fun PyDict_Clear(p: JNIPointer) + external fun PyDict_Contains(p: JNIPointer, key: JNIPointer): Int + external fun PyDict_Copy(p: JNIPointer): JNIPointer? + external fun PyDict_SetItem(p: JNIPointer, key: JNIPointer, v: JNIPointer): Int + external fun PyDict_SetItemString(p: JNIPointer, key: String, v: JNIPointer): Int + external fun PyDict_DelItem(p: JNIPointer, key: JNIPointer): Int + external fun PyDict_DelItemString(p: JNIPointer, key: String): Int + external fun PyDict_GetItem(p: JNIPointer, key: JNIPointer): JNIPointer? + external fun PyDict_GetItemWithError(p: JNIPointer, key: JNIPointer): JNIPointer? + external fun PyDict_GetItemString(p: JNIPointer, key: String): JNIPointer? + external fun PyDict_Items(p: JNIPointer): JNIPointer? + external fun PyDict_Keys(p: JNIPointer): JNIPointer? + external fun PyDict_Values(p: JNIPointer): JNIPointer? + external fun PyDict_Merge(a: JNIPointer, b: JNIPointer, override: Int): Int + external fun PyDict_Update(a: JNIPointer, b: JNIPointer): Int + external fun PyDict_MergeFromSeq2(a: JNIPointer, seq2: JNIPointer, override: Int): Int + + + // Section 24 + external fun PySet_New(iterable: JNIPointer): JNIPointer? + external fun PyFrozenSet_New(iterable: JNIPointer): JNIPointer? + external fun PySet_Contains(anyset: JNIPointer, key: JNIPointer): Int + external fun PySet_Add(set: JNIPointer, key: JNIPointer): Int + external fun PySet_Discard(set: JNIPointer, key: JNIPointer): Int + external fun PySet_Pop(set: JNIPointer): JNIPointer? + external fun PySet_Clear(set: JNIPointer): Int + + + // Section 25 + external fun PySeqIter_New(seq: JNIPointer): JNIPointer? + external fun PyCallIter_New(callable: JNIPointer, sentinel: JNIPointer): JNIPointer? + + + // Section 26 + external fun PyWeakref_NewRef(ob: JNIPointer, callback: JNIPointer): JNIPointer? + external fun PyWeakref_NewProxy(ob: JNIPointer, callback: JNIPointer): JNIPointer? + external fun PyWeakref_GetObject(ref: JNIPointer): JNIPointer? + external fun PyObject_ClearWeakRefs(o: JNIPointer) + + + // Section 27 + external fun PyType_IsSubtype(a: JNIPointer, b: JNIPointer): Int + external fun PyType_Ready(type: JNIPointer): Int + external fun PyType_GetName(type: JNIPointer): JNIPointer? + external fun PyType_GetFullyQualifiedName(type: JNIPointer): JNIPointer? + external fun PyType_GetModuleName(type: JNIPointer): JNIPointer? + external fun PyType_GetModule(type: JNIPointer): JNIPointer? + + + // Section 28 + external fun PyTuple_New(len: Long): JNIPointer? + external fun PyTuple_Size(p: JNIPointer): Long + external fun PyTuple_GetItem(p: JNIPointer, pos: Long): JNIPointer? + external fun PyTuple_GetSlice(p: JNIPointer, low: Long, high: Long): JNIPointer? + external fun PyTuple_SetItem(p: JNIPointer, pos: Long, o: JNIPointer): Int } diff --git a/python-multiplatform/src/commonMain/kotlin/python/multiplatform/ffi/PyObject.kt b/python-multiplatform/src/commonMain/kotlin/python/multiplatform/ffi/PyObject.kt index 2e608d8b..20ce6c9d 100644 --- a/python-multiplatform/src/commonMain/kotlin/python/multiplatform/ffi/PyObject.kt +++ b/python-multiplatform/src/commonMain/kotlin/python/multiplatform/ffi/PyObject.kt @@ -1,32 +1,44 @@ package python.multiplatform.ffi import python.multiplatform.ffi.exceptions.PyException +import python.multiplatform.ref.PyAutoCloseable import python.native.ffi.NativePointer - - -expect open class PyObject(pointer: NativePointer, borrowed: Boolean) { - val pointer: NativePointer -} -/* - //init { - // if (!borrowed) { - //PyIncRef(pointer) +import python.native.ffi.PyErr_Occurred +import python.native.ffi.PyLong_AsLongLong +import python.native.ffi.PyLong_FromLongLong +import python.native.ffi.PyObject_DelAttrString +import python.native.ffi.PyObject_GetAttrString +import python.native.ffi.PyObject_SetAttrString +import python.native.ffi.PyObject_Str +import python.native.ffi.PyObject_Type +import python.native.ffi.PyUnicode_AsUTF8 +import python.native.ffi.Py_DecRef +import python.native.ffi.Py_IncRef +import python.native.ffi.memScoped + +// TODO: !!IMPORTANT!! We need to check the case where the pointer is null one more time. (PyObject, PyType, PyException) +open class PyObject(val pointer: NativePointer, borrowed: Boolean): PyAutoCloseable(pointer) { + + init { + if (borrowed) { + Py_IncRef(pointer) // TODO: PyIncRef을 사용하는게 적절한 선택일까? - // } - //} - // TODO: Temporary commented due to the error: Expected declaration cannot have a body. - // TODO: Move this to the actual implementation. + } + } - val pointer: NativePointer - protected val typePointer: NativePointer = lazy { PyType_GetType(this.pointer) } - val Type: PyType = lazy { PyType(typePointer!!) } +// @Throws(PyException::class) + protected val type: PyType by lazy { + val typePointer: NativePointer? = PyObject_Type(pointer) +// throw PyException("Failed to get pointer of type") + PyType.getInstance(typePointer!!) + } - fun incRef() { - println("hi") + protected fun incRef() { + Py_IncRef(pointer) } - fun decRef() { - println("hi") + protected fun decRef() { + Py_DecRef(pointer) } @Throws(PyException::class) @@ -51,7 +63,7 @@ expect open class PyObject(pointer: NativePointer, borrowed: Boolean) { } fun setAttrOrNull(name: String, value: PyObject?) { - PyObject_SetAttrString(pointer, name, value?.pointer) + value?.pointer?.let { PyObject_SetAttrString(pointer, name, it) } } @Throws(PyException::class) @@ -66,7 +78,9 @@ expect open class PyObject(pointer: NativePointer, borrowed: Boolean) { } override fun toString(): String { - return PyObject_GetStr(pointer) + // TODO: null check + return PyUnicode_AsUTF8(PyObject_Str(pointer)!!)!! +// return PyObject_GetStr(pointer) } override fun hashCode(): Int { @@ -81,23 +95,31 @@ expect open class PyObject(pointer: NativePointer, borrowed: Boolean) { return false } - operator fun invoke(arg0: PyObject): PyObject { - return PyObject_CallObject(pointer, arg0) - } - - operator fun invoke(arg0: PyObject, arg1: PyObject): PyObject { - return PyObject_CallObject(pointer, arg0, arg1) + override fun clean() { + type.decRef() } - //... + // TODO: 밑에 세 함수 수정 (return type 불일치 등) +// operator fun invoke(arg0: PyObject): PyObject { +// return PyObject_CallObject(pointer, arg0) +// } +// +// operator fun invoke(arg0: PyObject, arg1: PyObject): PyObject { +// return PyObject_CallObject(pointer, arg0, arg1) +// } +// +// //... +// +// operator fun invoke(vararg args: PyObject): PyObject { +// return PyObject_CallObject(pointer, args) // TODO: 이거는 변수 하나로 잡히던가? 아님 여러개인가? +// // 리스트로 들어오는 거였던가? +// } - operator fun invoke(vararg args: PyObject): PyObject { - return PyObject_CallObject(pointer, args) // TODO: 이거는 변수 하나로 잡히던가? 아님 여러개인가? - // 리스트로 들어오는 거였던가? - }// actual fun pyLongFromLong(arg0: Long): Long { -// if (!isInitialized) return -1 +// actual fun pyLongFromLong(arg0: Long): Long { +// if (!Python3.isInitialized) return -1 // memScoped { -// val pyLong = PyLong_FromLong(arg0) +//// val pyLong = PyLong_FromLong(arg0) // TODO: PyLong_FromLong을 PyLong_FromLongLong으로 교체 +// val pyLong = PyLong_FromLongLong(arg0) // if (pyLong == null) { // throw IllegalStateException("Python long from long failed") // } @@ -106,15 +128,15 @@ expect open class PyObject(pointer: NativePointer, borrowed: Boolean) { // } // // actual fun pyLongAsLong(arg0: Long): Long { -// if (!isInitialized) return -1 +// if (!Python3.isInitialized) return -1 // memScoped { // val restoredPyObj: CValuesRef<_object>? = arg0.toCPointer() -// val ktLong = PyLong_AsLong(restoredPyObj) +//// val ktLong = PyLong_AsLong(restoredPyObj) // TODO: PyLong_AsLong을 PyLong_AsLongLong으로 교체 +// val ktLong = PyLong_AsLongLong(restoredPyObj) // if (ktLong == -1L && PyErr_Occurred() != null) { // throw IllegalStateException("Python long as long failed") // } // return ktLong // } // } -} -*/ \ No newline at end of file +} \ No newline at end of file diff --git a/python-multiplatform/src/commonMain/kotlin/python/multiplatform/ffi/PyType.kt b/python-multiplatform/src/commonMain/kotlin/python/multiplatform/ffi/PyType.kt index b6419fcc..ea3390b1 100644 --- a/python-multiplatform/src/commonMain/kotlin/python/multiplatform/ffi/PyType.kt +++ b/python-multiplatform/src/commonMain/kotlin/python/multiplatform/ffi/PyType.kt @@ -1,4 +1,148 @@ package python.multiplatform.ffi -class PyType { +import python.multiplatform.ffi.exceptions.PyException +import python.multiplatform.ffi.types.collections.PyDict +import python.multiplatform.ffi.types.iteration.PyIterator +import python.native.ffi.NativePointer +import python.native.ffi.PyLong_AsInt +import python.native.ffi.PyLong_AsLongLong +import python.native.ffi.PyObject_CallNoArgs +import python.native.ffi.PyObject_GetAttr +import python.native.ffi.PyObject_GetAttrString +import python.native.ffi.PyObject_Type +import python.native.ffi.PyTuple_GetItem +import python.native.ffi.PyTuple_Size +import python.native.ffi.PyType_GetName +import python.native.ffi.PyUnicode_AsUTF8 +import python.native.ffi.Py_DecRef + + +class PyType private constructor(pointer: NativePointer): PyObject(pointer, false) { + companion object { + private val cachedObjects: MutableMap = mutableMapOf() + fun getInstance(pointer: NativePointer): PyType = cachedObjects.getOrPut(pointer) { PyType(pointer) } + } + + val name: String by lazy { + val namePtr: NativePointer? = PyType_GetName(pointer) + if (namePtr == null) throw PyException("Failed to get pointer of name") + + val nameStr: String? = PyUnicode_AsUTF8(namePtr) + if (nameStr == null) throw PyException("Failed to get String of name") + + nameStr + } + + val baseType: PyType by lazy { + val attrPtr: NativePointer? = PyObject_GetAttrString(pointer, "__base__") + if (attrPtr == null) throw PyException("Failed to get __base__") + + PyType(attrPtr) + } + + private var cachedBaseTypes: List? = null + private var cachedBaseTypesPointer: NativePointer? = null + val baseTypes: List + get() { + // TODO: 에러 발생 여부 확인이 필요한건가? + val bases = PyObject_GetAttrString(pointer, "__bases__") // tuple object + if (bases != null) { + + } else { + // TODO: 에러? 아니면 항상 성공 보장? + } + val baseTypes = cachedBaseTypes + val baseTypesPointer = cachedBaseTypesPointer + if (baseTypesPointer != null && bases?.address == baseTypesPointer.address) { + return baseTypes ?: listOf() + } else { + // TODO: Do null check + val lenFunc = PyObject_GetAttrString(pointer, "__len__") + val lenObj = PyObject_CallNoArgs(lenFunc!!) + val size = PyLong_AsInt(lenObj!!) + + + val list: MutableList = let { + val temp: MutableList = mutableListOf() + for (i in 0 until size) { + temp[i] = getInstance(PyTuple_GetItem(bases!!, i.toLong())!!) + } + temp + } + + + return list.toList() + } + } + +// val mro: List + val dict: PyDict by lazy { + // TODO: Add null check for PyObject_GetAttrString. And you should replace PyObject_GetAttrString to PyType_GetDict(). + PyDict(PyObject_GetAttrString(pointer, "__dict__")!!, false) +} + + init { + if (!isPyTypeObject()) throw PyException("Object is not a type") + + var temp: MutableList = mutableListOf() + // TODO: PyObject_GetAttrString return값이 Tuple인지도 확인 해야할까? + val basesPyObject: NativePointer = PyObject_GetAttrString(pointer, "__bases__").let {it ?: throw PyException("Failed to get base types")} + val basesSize: Long = PyTuple_Size(basesPyObject).let { + if (it == -1L) throw PyException("Failed to get base types size") + else it + } + for (i in 0 until basesSize) { + // TODO: type check 필요 +// temp.add(PyType(PyTuple_GetItem(basesPyObject, i)!!, true)) + } + } + +// fun isSubtypeOf(other: PyType): Boolean { +// // TODO: PyType_IsSubtype(PyTypeObject *a, PyTypeObject *b) 사용 +// } +// +// fun cast(obj: PyObject): PyObject { +// +// } +// +// fun isInstance(obj: PyObject): Boolean { +// // TODO: PyObject_IsInstance 이용 +// } +// +// fun getIterator(): PyIterator { +// +// } +// +// operator fun invoke(args: Array<>): PyObject { +// +// } +// +// fun __new__(): PyObject { +// +// } +// +// fun __init__(obj: PyObject, args: Array<>) { +// +// } + + private fun isPyTypeObject(): Boolean { + val pyTypeObject: NativePointer? = PyObject_Type(pointer) + val typeNamePyObject: NativePointer? = PyObject_GetAttrString(pointer, "__name__") + + if (pyTypeObject != null && typeNamePyObject != null) { + val typeName: String = PyUnicode_AsUTF8(typeNamePyObject).let {it ?: throw PyException("Failed to get type name") } + val result: Boolean = typeName == "type" + + Py_DecRef(typeNamePyObject) + Py_DecRef(pyTypeObject) + + return result + } + + return false + } + + override fun hashCode(): Int { + return super.hashCode() + } } \ No newline at end of file diff --git a/python-multiplatform/src/commonMain/kotlin/python/multiplatform/ffi/Python3.kt b/python-multiplatform/src/commonMain/kotlin/python/multiplatform/ffi/Python3.kt index 8cee7e75..6874c59e 100644 --- a/python-multiplatform/src/commonMain/kotlin/python/multiplatform/ffi/Python3.kt +++ b/python-multiplatform/src/commonMain/kotlin/python/multiplatform/ffi/Python3.kt @@ -102,8 +102,20 @@ object Python3 { /** * Import Python module */ - fun import(): PyModule { - return PyModule() + fun import(name: String): PyModule { + // TODO: 실제 모듈이 있는지 검사하는 코드 추가 + val pyModuleDict: NativePointer? = PyImport_GetModuleDict() // 변수 이름 적절? + if (pyModuleDict == null) throw IllegalStateException("Failed to import module (Failed to get module dictionary)") + + val pyStringFromName: NativePointer? = PyUnicode_FromString(name) // 변수 이름 적절? + if (pyStringFromName == null) throw IllegalStateException("Failed to import module (Failed to get module name)") + + if (PyDict_Contains(pyModuleDict, pyStringFromName) == 0) throw IllegalStateException("Failed to import module (Module not found)") + + val module: NativePointer? = PyImport_ImportModule(name) + if (module == null) throw IllegalStateException("Failed to import module") + + return PyModule(module, false) } val version by lazy { withPython { Py_GetVersion() ?: throw IllegalStateException("Failed to get Python version") } } diff --git a/python-multiplatform/src/commonMain/kotlin/python/multiplatform/ffi/exceptions/PyException.kt b/python-multiplatform/src/commonMain/kotlin/python/multiplatform/ffi/exceptions/PyException.kt index 90e392da..117021a2 100644 --- a/python-multiplatform/src/commonMain/kotlin/python/multiplatform/ffi/exceptions/PyException.kt +++ b/python-multiplatform/src/commonMain/kotlin/python/multiplatform/ffi/exceptions/PyException.kt @@ -1,7 +1,21 @@ package python.multiplatform.ffi.exceptions -class PyException { +import python.multiplatform.ffi.PyObject +import python.multiplatform.ffi.PyType +import python.native.ffi.NativePointer +class PyException(val errMsg: String): Exception() { +// private val pyException = object: PyObject(pointer, false) { +// val type: PyType by lazy { +// //TODO: PyType은 python의 BaseException 이어야 하나? PyException과 BaseException이 같은 층위에 있는건가? 근데 Python Exception 중 Exception이 아니라 BaseException을 직접 상속받는 에러가 있음. 그런데 이것들은 프로그램 종료와 관련있음. +// } +// +// +// } +// +// fun toPyObject(): PyObject { +// return +// } // // // fun checkPyError(): Boolean { diff --git a/python-multiplatform/src/commonMain/kotlin/python/multiplatform/ffi/types/modules/PyModule.kt b/python-multiplatform/src/commonMain/kotlin/python/multiplatform/ffi/types/modules/PyModule.kt index 20ccbb5a..76085b8f 100644 --- a/python-multiplatform/src/commonMain/kotlin/python/multiplatform/ffi/types/modules/PyModule.kt +++ b/python-multiplatform/src/commonMain/kotlin/python/multiplatform/ffi/types/modules/PyModule.kt @@ -1,8 +1,17 @@ package python.multiplatform.ffi.types.modules +import python.multiplatform.ffi.Python3.isInitialized +import python.multiplatform.ffi.PyObject +import python.native.ffi.* -class PyModule { + +// PyModule -> PyObject 상속하기 +// PyObject 상속할 때 pointer와 borrowed는 어떻게 받아오지? +class PyModule(pointer: NativePointer, borrowed: Boolean): PyObject(pointer, borrowed) { //val builtins: Builtins + + init { + } } diff --git a/python-multiplatform/src/commonMain/kotlin/python/multiplatform/ref/PyAutoCloseable.kt b/python-multiplatform/src/commonMain/kotlin/python/multiplatform/ref/PyAutoCloseable.kt new file mode 100644 index 00000000..7393665f --- /dev/null +++ b/python-multiplatform/src/commonMain/kotlin/python/multiplatform/ref/PyAutoCloseable.kt @@ -0,0 +1,8 @@ +package python.multiplatform.ref + +import python.native.ffi.NativePointer + + +expect abstract class PyAutoCloseable(pointer: NativePointer) { + abstract fun clean() +} diff --git a/python-multiplatform/src/commonMain/kotlin/python/native/ffi/EmbedAPI.kt b/python-multiplatform/src/commonMain/kotlin/python/native/ffi/EmbedAPI.kt index d35e61cb..9dcce9aa 100644 --- a/python-multiplatform/src/commonMain/kotlin/python/native/ffi/EmbedAPI.kt +++ b/python-multiplatform/src/commonMain/kotlin/python/native/ffi/EmbedAPI.kt @@ -25,12 +25,13 @@ expect fun AddressValue.toNativePointer(): NativePointer expect fun Long.toNativePointer(): NativePointer? +/** //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Section 1 // Initializing and finalizing the interpreter //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /** - * Part of the Stable ABI. + *Part of the Stable ABI. * * Initialize the Python interpreter. * In an application embedding Python, this should be called before using any other Python/C API functions; see Before Python Initialization for the few exceptions. @@ -46,7 +47,7 @@ expect fun Long.toNativePointer(): NativePointer? expect inline fun Py_Initialize() /** - * Part of the Stable ABI. + *Part of the Stable ABI. * * This function works like Py_Initialize() if initsigs is 1. * If initsigs is 0, it skips initialization registration of signal handlers, which may be useful when CPython is embedded as part of a larger application. @@ -60,7 +61,7 @@ expect inline fun Py_InitializeEx(initsigs: Int) //expect inline fun Py_InitializeFromConfig() /** - * Part of the Stable ABI. + *Part of the Stable ABI. * * Return true (nonzero) when the Python interpreter has been initialized, false (zero) if not. * After Py_FinalizeEx() is called, this returns false until Py_Initialize() is called again. @@ -80,7 +81,7 @@ expect inline fun Py_IsInitialized(): Int expect inline fun Py_IsFinalizing(): Int /** - * Part of the Stable ABI. + *Part of the Stable ABI. * * This is a backwards-compatible version of Py_FinalizeEx() that disregards the return value. */ @@ -170,7 +171,7 @@ expect inline fun PyRun_SimpleString(command: String): Int expect fun PyRun_String(str: String, start: Int, globals: NativePointer, locals: NativePointer): NativePointer? /** - * Part of the Stable ABI. + *Part of the Stable ABI. * * Return the version of this Python interpreter. This is a string that looks something like * "3.0a5+ (py3k:63103M, May 12 2008, 00:53:55) \n[GCC 4.2.3]" @@ -182,7 +183,7 @@ expect fun PyRun_String(str: String, start: Int, globals: NativePointer, locals: expect inline fun Py_GetVersion(): String? /** - * Part of the Stable ABI. + *Part of the Stable ABI. * * Return the platform identifier for the current platform. * On Unix, this is formed from the “official” name of the operating system, converted to lower case, followed by the major revision number; @@ -194,7 +195,7 @@ expect inline fun Py_GetVersion(): String? expect inline fun Py_GetPlatform(): String? /** - * Part of the Stable ABI. + *Part of the Stable ABI. * * Return the official copyright string for the current Python version, for example * @@ -206,7 +207,7 @@ expect inline fun Py_GetPlatform(): String? expect inline fun Py_GetCopyright(): String? /** - * Part of the Stable ABI. + *Part of the Stable ABI. * * Return an indication of the compiler used to build the current Python version, in square brackets, for example: * "[GCC 2.7.2.2]" @@ -217,7 +218,7 @@ expect inline fun Py_GetCopyright(): String? expect inline fun Py_GetCompiler(): String? /** - * Part of the Stable ABI. + *Part of the Stable ABI. * * Return information about the sequence number and build date and time of the current Python interpreter instance, for example * "#67, Aug 1 1997, 22:34:28" @@ -245,6 +246,3842 @@ expect inline fun PyLong_AsInt(p: NativePointer): Int expect fun PyUnicode_FromString(str: String): NativePointer? expect inline fun PyUnicode_AsUTF8(unicode: NativePointer): String? +*/ + + +//************************************************** +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// Section 1 +// Initialization, Finalization, and Threads +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/** + * *Part of the Stable ABI.* + * + * Initialize the Python interpreter. In an application embedding + * Python, this should be called before using any other Python/C API + * functions; see Before Python Initialization for the few exceptions. + * + * This initializes the table of loaded modules ("sys.modules"), and + * creates the fundamental modules "builtins", "__main__" and "sys". + * It also initializes the module search path ("sys.path"). It does + * not set "sys.argv"; use the Python Initialization Configuration API + * for that. This is a no-op when called for a second time (without + * calling "Py_FinalizeEx()" first). There is no return value; it is + * a fatal error if the initialization fails. + * + * Use "Py_InitializeFromConfig()" to customize the Python + * Initialization Configuration. + * + * Note: + * + * On Windows, changes the console mode from "O_TEXT" to "O_BINARY", + * which will also affect non-Python uses of the console using the C + * Runtime. + */ +expect inline fun Py_Initialize() + +/** + * *Part of the Stable ABI.* + * + * This function works like "Py_Initialize()" if *initsigs* is "1". If + * *initsigs* is "0", it skips initialization registration of signal + * handlers, which may be useful when CPython is embedded as part of a + * larger application. + * + * Use "Py_InitializeFromConfig()" to customize the Python + * Initialization Configuration. + */ +expect inline fun Py_InitializeEx(initsigs: Int) + +/** + * *Part of the Stable ABI.* + * + * Return true (nonzero) when the Python interpreter has been + * initialized, false (zero) if not. After "Py_FinalizeEx()" is + * called, this returns false until "Py_Initialize()" is called again. + */ +expect inline fun Py_IsInitialized(): Int + +/** + * *Part of the Stable ABI since version 3.13.* + * + * Return true (non-zero) if the main Python interpreter is *shutting + * down*. Return false (zero) otherwise. + * + * Added in version 3.13. + */ +expect inline fun Py_IsFinalizing(): Int + +/** + * *Part of the Stable ABI since version 3.6.* + * + * Undo all initializations made by "Py_Initialize()" and subsequent + * use of Python/C API functions, and destroy all sub-interpreters + * (see "Py_NewInterpreter()" below) that were created and not yet + * destroyed since the last call to "Py_Initialize()". Ideally, this + * frees all memory allocated by the Python interpreter. This is a + * no-op when called for a second time (without calling + * "Py_Initialize()" again first). + * + * Since this is the reverse of "Py_Initialize()", it should be called + * in the same thread with the same interpreter active. That means + * the main thread and the main interpreter. This should never be + * called while "Py_RunMain()" is running. + * + * Normally the return value is "0". If there were errors during + * finalization (flushing buffered data), "-1" is returned. + * + * This function is provided for a number of reasons. An embedding + * application might want to restart Python without having to restart + * the application itself. An application that has loaded the Python + * interpreter from a dynamically loadable library (or DLL) might want + * to free all memory allocated by Python before unloading the DLL. + * During a hunt for memory leaks in an application a developer might + * want to free all memory allocated by Python before exiting from the + * application. + * + * **Bugs and caveats:** The destruction of modules and objects in + * modules is done in random order; this may cause destructors + * ("__del__()" methods) to fail when they depend on other objects + * (even functions) or modules. Dynamically loaded extension modules + * loaded by Python are not unloaded. Small amounts of memory + * allocated by the Python interpreter may not be freed (if you find a + * leak, please report it). Memory tied up in circular references + * between objects is not freed. Some memory allocated by extension + * modules may not be freed. Some extensions may not work properly if + * their initialization routine is called more than once; this can + * happen if an application calls "Py_Initialize()" and + * "Py_FinalizeEx()" more than once. + * + * Raises an auditing event "cpython._PySys_ClearAuditHooks" with no + * arguments. + * + * Added in version 3.6. + */ +expect inline fun Py_FinalizeEx(): Int + +/** + * *Part of the Stable ABI.* + * + * This is a backwards-compatible version of "Py_FinalizeEx()" that + * disregards the return value. + */ +expect inline fun Py_Finalize() + +/** + * *Part of the Stable ABI since version 3.8.* + * + * Similar to "Py_Main()" but *argv* is an array of bytes strings, + * allowing the calling application to delegate the text decoding step + * to the CPython runtime. + * + * Added in version 3.8. + */ +//expect inline fun Py_BytesMain(args: Array): Int // 수동 추가 + +/** + * Executes the main module in a fully configured CPython runtime. + * + * Executes the command ("PyConfig.run_command"), the script + * ("PyConfig.run_filename") or the module ("PyConfig.run_module") + * specified on the command line or in the configuration. If none of + * these values are set, runs the interactive Python prompt (REPL) + * using the "__main__" module’s global namespace. + * + * If "PyConfig.inspect" is not set (the default), the return value + * will be "0" if the interpreter exits normally (that is, without + * raising an exception), or "1" if the interpreter exits due to an + * exception. If an otherwise unhandled "SystemExit" is raised, the + * function will immediately exit the process instead of returning + * "1". + * + * If "PyConfig.inspect" is set (such as when the "-i" option is + * used), rather than returning when the interpreter exits, execution + * will instead resume in an interactive Python prompt (REPL) using + * the "__main__" module’s global namespace. If the interpreter exited + * with an exception, it is immediately raised in the REPL session. + * The function return value is then determined by the way the *REPL + * session* terminates: returning "0" if the session terminates + * without raising an unhandled exception, exiting immediately for an + * unhandled "SystemExit", and returning "1" for any other unhandled + * exception. + * + * This function always finalizes the Python interpreter regardless of + * whether it returns a value or immediately exits the process due to + * an unhandled "SystemExit" exception. + * + * See Python Configuration for an example of a customized Python that + * always runs in isolated mode using "Py_RunMain()". + */ +expect inline fun Py_RunMain(): Int // 수동 추가 + +/** + * *Part of the Stable ABI.* + * + * Return the version of this Python interpreter. This is a string + * that looks something like + * + * "3.0a5+ (py3k:63103M, May 12 2008, 00:53:55) \n[GCC 4.2.3]" + * + * The first word (up to the first space character) is the current + * Python version; the first characters are the major and minor + * version separated by a period. The returned string points into + * static storage; the caller should not modify its value. The value + * is available to Python code as "sys.version". + * + * See also the "Py_Version" constant. + */ +expect inline fun Py_GetVersion(): String? + +/** + * *Part of the Stable ABI.* + * + * Return the platform identifier for the current platform. On Unix, + * this is formed from the “official” name of the operating system, + * converted to lower case, followed by the major revision number; + * e.g., for Solaris 2.x, which is also known as SunOS 5.x, the value + * is "'sunos5'". On macOS, it is "'darwin'". On Windows, it is + * "'win'". The returned string points into static storage; the + * caller should not modify its value. The value is available to + * Python code as "sys.platform". + */ +expect inline fun Py_GetPlatform(): String? + +/** + * *Part of the Stable ABI.* + * + * Return the official copyright string for the current Python + * version, for example + * + * "'Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam'" + * + * The returned string points into static storage; the caller should + * not modify its value. The value is available to Python code as + * "sys.copyright". + */ +expect inline fun Py_GetCopyright(): String? + +/** + * *Part of the Stable ABI.* + * + * Return an indication of the compiler used to build the current + * Python version, in square brackets, for example: + * + * "[GCC 2.7.2.2]" + * + * The returned string points into static storage; the caller should + * not modify its value. The value is available to Python code as + * part of the variable "sys.version". + */ +expect inline fun Py_GetCompiler(): String? + +/** + * *Part of the Stable ABI.* + * + * Return information about the sequence number and build date and + * time of the current Python interpreter instance, for example + * + * "#67, Aug 1 1997, 22:34:28" + * + * The returned string points into static storage; the caller should + * not modify its value. The value is available to Python code as + * part of the variable "sys.version". + */ +expect inline fun Py_GetBuildInfo(): String? + +/** + * *Part of the Stable ABI.* + * + * Deprecated function which does nothing. + * + * In Python 3.6 and older, this function created the GIL if it didn’t + * exist. + * + * Changed in version 3.9: The function now does nothing. + * + * Changed in version 3.7: This function is now called by + * "Py_Initialize()", so you don’t have to call it yourself anymore. + * + * Changed in version 3.2: This function cannot be called before + * "Py_Initialize()" anymore. + * + * Deprecated since version 3.9. + */ +expect inline fun PyEval_InitThreads() + +/** + * *Return value: Borrowed reference.* + * *Part of the Stable ABI.* + * + * Return a dictionary in which extensions can store thread-specific + * state information. Each extension should use a unique key to use + * to store state in the dictionary. It is okay to call this function + * when no current thread state is available. If this function returns + * "NULL", no exception has been raised and the caller should assume + * no current thread state is available. + */ +expect fun PyThreadState_GetDict(): NativePointer? + + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// Section 2 +// The Very High Level Layer +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/** + * + * This is a simplified interface to "PyRun_SimpleStringFlags()" + * below, leaving the "PyCompilerFlags"* argument set to "NULL". + */ +expect inline fun PyRun_SimpleString(command: String): Int // 수동 추가 + +/** + * *Return value: New reference.* + * + * This is a simplified interface to "PyRun_StringFlags()" below, + * leaving *flags* set to "NULL". + */ +expect fun PyRun_String(str: String, start: Int, globals: NativePointer, locals: NativePointer): NativePointer? // 수동 추가 + +/** + * *Return value: New reference.* + * *Part of the Stable ABI.* + * + * This is a simplified interface to "Py_CompileStringFlags()" below, + * leaving *flags* set to "NULL". + */ +expect fun Py_CompileString(str: String, filename: String, start: Int): NativePointer? + +/** + * *Return value: New reference.* + * *Part of the Stable ABI.* + * + * This is a simplified interface to "PyEval_EvalCodeEx()", with just + * the code object, and global and local variables. The other + * arguments are set to "NULL". + */ +expect fun PyEval_EvalCode(co: NativePointer, globals: NativePointer, locals: NativePointer): NativePointer? + + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// Section 3 +// Exception Handling +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/** + * *Part of the Stable ABI.* + * + * Clear the error indicator. If the error indicator is not set, + * there is no effect. + */ +expect inline fun PyErr_Clear() + +/** + * *Part of the Stable ABI.* + * + * Print a standard traceback to "sys.stderr" and clear the error + * indicator. **Unless** the error is a "SystemExit", in that case no + * traceback is printed and the Python process will exit with the + * error code specified by the "SystemExit" instance. + * + * Call this function **only** when the error indicator is set. + * Otherwise it will cause a fatal error! + * + * If *set_sys_last_vars* is nonzero, the variable "sys.last_exc" is + * set to the printed exception. For backwards compatibility, the + * deprecated variables "sys.last_type", "sys.last_value" and + * "sys.last_traceback" are also set to the type, value and traceback + * of this exception, respectively. + * + * Changed in version 3.12: The setting of "sys.last_exc" was added. + */ +expect inline fun PyErr_PrintEx(set_sys_last_vars: Int) + +/** + * *Part of the Stable ABI.* + * + * Alias for "PyErr_PrintEx(1)". + */ +expect inline fun PyErr_Print() + +/** + * *Part of the Stable ABI.* + * + * Call "sys.unraisablehook()" using the current exception and *obj* + * argument. + * + * This utility function prints a warning message to "sys.stderr" when + * an exception has been set but it is impossible for the interpreter + * to actually raise the exception. It is used, for example, when an + * exception occurs in an "__del__()" method. + * + * The function is called with a single argument *obj* that identifies + * the context in which the unraisable exception occurred. If + * possible, the repr of *obj* will be printed in the warning message. + * If *obj* is "NULL", only the traceback is printed. + * + * An exception must be set when calling this function. + * + * Changed in version 3.4: Print a traceback. Print only traceback if + * *obj* is "NULL". + * + * Changed in version 3.8: Use "sys.unraisablehook()". + */ +expect inline fun PyErr_WriteUnraisable(obj: NativePointer) + +/** + * *Part of the Stable ABI since version 3.12.* + * + * Print the standard traceback display of "exc" to "sys.stderr", + * including chained exceptions and notes. + * + * Added in version 3.12. + */ +expect inline fun PyErr_DisplayException(exc: NativePointer) + +/** + * *Part of the Stable ABI.* + * + * This is the most common way to set the error indicator. The first + * argument specifies the exception type; it is normally one of the + * standard exceptions, e.g. "PyExc_RuntimeError". You need not + * create a new *strong reference* to it (e.g. with "Py_INCREF()"). + * The second argument is an error message; it is decoded from + * "'utf-8'". + */ +expect inline fun PyErr_SetString(type: NativePointer, message: String) + +/** + * *Part of the Stable ABI.* + * + * This function is similar to "PyErr_SetString()" but lets you + * specify an arbitrary Python object for the “value” of the + * exception. + */ +expect inline fun PyErr_SetObject(type: NativePointer, value: NativePointer) + +/** + * *Part of the Stable ABI.* + * + * This is a shorthand for "PyErr_SetObject(type, Py_None)". + */ +expect inline fun PyErr_SetNone(type: NativePointer) + +/** + * *Part of the Stable ABI.* + * + * This is a shorthand for "PyErr_SetString(PyExc_TypeError, + * message)", where *message* indicates that a built-in operation was + * invoked with an illegal argument. It is mostly for internal use. + */ +expect inline fun PyErr_BadArgument(): Int + +/** + * *Return value: Always NULL.* + * *Part of the Stable ABI.* + * + * This is a shorthand for "PyErr_SetNone(PyExc_MemoryError)"; it + * returns "NULL" so an object allocation function can write "return + * PyErr_NoMemory();" when it runs out of memory. + */ +expect fun PyErr_NoMemory(): NativePointer? + +/** + * *Return value: Always NULL.* + * *Part of the Stable ABI.* + * + * This is a convenience function to raise an exception when a C + * library function has returned an error and set the C variable + * "errno". It constructs a tuple object whose first item is the + * integer "errno" value and whose second item is the corresponding + * error message (gotten from "strerror()"), and then calls + * "PyErr_SetObject(type, object)". On Unix, when the "errno" value + * is "EINTR", indicating an interrupted system call, this calls + * "PyErr_CheckSignals()", and if that set the error indicator, leaves + * it set to that. The function always returns "NULL", so a wrapper + * function around a system call can write "return + * PyErr_SetFromErrno(type);" when the system call returns an error. + */ +expect fun PyErr_SetFromErrno(type: NativePointer): NativePointer? + +/** + * *Return value: Always NULL.* + * *Part of the Stable ABI.* + * + * Similar to "PyErr_SetFromErrno()", with the additional behavior + * that if *filenameObject* is not "NULL", it is passed to the + * constructor of *type* as a third parameter. In the case of + * "OSError" exception, this is used to define the "filename" + * attribute of the exception instance. + */ +expect fun PyErr_SetFromErrnoWithFilenameObject(type: NativePointer, filenameObject: NativePointer): NativePointer? + +/** + * *Return value: Always NULL.* + * *Part of the Stable ABI since version 3.7.* + * + * Similar to "PyErr_SetFromErrnoWithFilenameObject()", but takes a + * second filename object, for raising errors when a function that + * takes two filenames fails. + * + * Added in version 3.4. + */ +expect fun PyErr_SetFromErrnoWithFilenameObjects(type: NativePointer, filenameObject: NativePointer, filenameObject2: NativePointer): NativePointer? + +/** + * *Return value: Always NULL.* + * *Part of the Stable ABI.* + * + * Similar to "PyErr_SetFromErrnoWithFilenameObject()", but the + * filename is given as a C string. *filename* is decoded from the + * *filesystem encoding and error handler*. + */ +expect fun PyErr_SetFromErrnoWithFilename(type: NativePointer, filename: String): NativePointer? + +/** + * *Return value: Always NULL.* + * *Part of the Stable ABI since version 3.7.* + * + * This is a convenience function to raise "ImportError". *msg* will + * be set as the exception’s message string. *name* and *path*, both + * of which can be "NULL", will be set as the "ImportError"’s + * respective "name" and "path" attributes. + * + * Added in version 3.3. + */ +expect fun PyErr_SetImportError(msg: NativePointer, name: NativePointer, path: NativePointer): NativePointer? + +/** + * *Return value: Always NULL.* + * *Part of the Stable ABI since version 3.6.* + * + * Much like "PyErr_SetImportError()" but this function allows for + * specifying a subclass of "ImportError" to raise. + * + * Added in version 3.6. + */ +expect fun PyErr_SetImportErrorSubclass(exception: NativePointer, msg: NativePointer, name: NativePointer, path: NativePointer): NativePointer? + +/** + * *Part of the Stable ABI since version 3.7.* + * + * Like "PyErr_SyntaxLocationObject()", but *filename* is a byte + * string decoded from the *filesystem encoding and error handler*. + * + * Added in version 3.2. + */ +expect inline fun PyErr_SyntaxLocationEx(filename: String, lineno: Int, col_offset: Int) + +/** + * *Part of the Stable ABI.* + * + * Like "PyErr_SyntaxLocationEx()", but the *col_offset* parameter is + * omitted. + */ +expect inline fun PyErr_SyntaxLocation(filename: String, lineno: Int) + +/** + * *Part of the Stable ABI.* + * + * This is a shorthand for "PyErr_SetString(PyExc_SystemError, + * message)", where *message* indicates that an internal operation + * (e.g. a Python/C API function) was invoked with an illegal + * argument. It is mostly for internal use. + */ +expect inline fun PyErr_BadInternalCall() + +/** + * *Part of the Stable ABI.* + * + * Similar to "PyErr_WarnExplicitObject()" except that *message* and + * *module* are UTF-8 encoded strings, and *filename* is decoded from + * the *filesystem encoding and error handler*. + */ +expect inline fun PyErr_WarnExplicit(category: NativePointer, message: String, filename: String, lineno: Int, module: String, registry: NativePointer): Int + +/** + * *Return value: Borrowed reference.* + * *Part of the Stable ABI.* + * + * Test whether the error indicator is set. If set, return the + * exception *type* (the first argument to the last call to one of the + * "PyErr_Set*" functions or to "PyErr_Restore()"). If not set, + * return "NULL". You do not own a reference to the return value, so + * you do not need to "Py_DECREF()" it. + * + * The caller must hold the GIL. + * + * Note: + * + * Do not compare the return value to a specific exception; use + * "PyErr_ExceptionMatches()" instead, shown below. (The comparison + * could easily fail since the exception may be an instance instead + * of a class, in the case of a class exception, or it may be a + * subclass of the expected exception.) + */ +expect fun PyErr_Occurred(): NativePointer? + +/** + * *Part of the Stable ABI.* + * + * Equivalent to "PyErr_GivenExceptionMatches(PyErr_Occurred(), exc)". + * This should only be called when an exception is actually set; a + * memory access violation will occur if no exception has been raised. + */ +expect inline fun PyErr_ExceptionMatches(exc: NativePointer): Int + +/** + * *Part of the Stable ABI.* + * + * Return true if the *given* exception matches the exception type in + * *exc*. If *exc* is a class object, this also returns true when + * *given* is an instance of a subclass. If *exc* is a tuple, all + * exception types in the tuple (and recursively in subtuples) are + * searched for a match. + */ +expect inline fun PyErr_GivenExceptionMatches(given: NativePointer, exc: NativePointer): Int + +/** + * *Return value: New reference.* + * *Part of the Stable ABI since version 3.12.* + * + * Return the exception currently being raised, clearing the error + * indicator at the same time. Return "NULL" if the error indicator is + * not set. + * + * This function is used by code that needs to catch exceptions, or + * code that needs to save and restore the error indicator + * temporarily. + * + * For example: + * + * { + * PyObject *exc = PyErr_GetRaisedException(); + * + * /* ... code that might produce other errors ... */ + * + * PyErr_SetRaisedException(exc); + * } + * + * See also: + * + * "PyErr_GetHandledException()", to save the exception currently + * being handled. + * + * Added in version 3.12. + */ +expect fun PyErr_GetRaisedException(): NativePointer? + +/** + * *Part of the Stable ABI since version 3.12.* + * + * Set *exc* as the exception currently being raised, clearing the + * existing exception if one is set. + * + * Warning: + * + * This call steals a reference to *exc*, which must be a valid + * exception. + * + * Added in version 3.12. + */ +expect inline fun PyErr_SetRaisedException(exc: NativePointer) + +/** + * *Part of the Stable ABI.* + * + * Deprecated since version 3.12: Use "PyErr_SetRaisedException()" + * instead. + * + * Set the error indicator from the three objects, *type*, *value*, + * and *traceback*, clearing the existing exception if one is set. If + * the objects are "NULL", the error indicator is cleared. Do not + * pass a "NULL" type and non-"NULL" value or traceback. The + * exception type should be a class. Do not pass an invalid exception + * type or value. (Violating these rules will cause subtle problems + * later.) This call takes away a reference to each object: you must + * own a reference to each object before the call and after the call + * you no longer own these references. (If you don’t understand this, + * don’t use this function. I warned you.) + * + * Note: + * + * This function is normally only used by legacy code that needs to + * save and restore the error indicator temporarily. Use + * "PyErr_Fetch()" to save the current error indicator. + */ +expect inline fun PyErr_Restore(type: NativePointer, value: NativePointer, traceback: NativePointer) + +/** + * *Part of the Stable ABI since version 3.11.* + * + * Retrieve the active exception instance, as would be returned by + * "sys.exception()". This refers to an exception that was *already + * caught*, not to an exception that was freshly raised. Returns a new + * reference to the exception or "NULL". Does not modify the + * interpreter’s exception state. + * + * Note: + * + * This function is not normally used by code that wants to handle + * exceptions. Rather, it can be used when code needs to save and + * restore the exception state temporarily. Use + * "PyErr_SetHandledException()" to restore or clear the exception + * state. + * + * Added in version 3.11. + */ +expect fun PyErr_GetHandledException(): NativePointer? + +/** + * *Part of the Stable ABI since version 3.11.* + * + * Set the active exception, as known from "sys.exception()". This + * refers to an exception that was *already caught*, not to an + * exception that was freshly raised. To clear the exception state, + * pass "NULL". + * + * Note: + * + * This function is not normally used by code that wants to handle + * exceptions. Rather, it can be used when code needs to save and + * restore the exception state temporarily. Use + * "PyErr_GetHandledException()" to get the exception state. + * + * Added in version 3.11. + */ +expect inline fun PyErr_SetHandledException(exc: NativePointer) + +/** + * *Part of the Stable ABI since version 3.7.* + * + * Set the exception info, as known from "sys.exc_info()". This + * refers to an exception that was *already caught*, not to an + * exception that was freshly raised. This function steals the + * references of the arguments. To clear the exception state, pass + * "NULL" for all three arguments. This function is kept for backwards + * compatibility. Prefer using "PyErr_SetHandledException()". + * + * Note: + * + * This function is not normally used by code that wants to handle + * exceptions. Rather, it can be used when code needs to save and + * restore the exception state temporarily. Use + * "PyErr_GetExcInfo()" to read the exception state. + * + * Added in version 3.3. + * + * Changed in version 3.11: The "type" and "traceback" arguments are + * no longer used and can be NULL. The interpreter now derives them + * from the exception instance (the "value" argument). The function + * still steals references of all three arguments. + */ +expect inline fun PyErr_SetExcInfo(type: NativePointer, value: NativePointer, traceback: NativePointer) + +/** + * *Part of the Stable ABI.* + * + * This function interacts with Python’s signal handling. + * + * If the function is called from the main thread and under the main + * Python interpreter, it checks whether a signal has been sent to the + * processes and if so, invokes the corresponding signal handler. If + * the "signal" module is supported, this can invoke a signal handler + * written in Python. + * + * The function attempts to handle all pending signals, and then + * returns "0". However, if a Python signal handler raises an + * exception, the error indicator is set and the function returns "-1" + * immediately (such that other pending signals may not have been + * handled yet: they will be on the next "PyErr_CheckSignals()" + * invocation). + * + * If the function is called from a non-main thread, or under a non- + * main Python interpreter, it does nothing and returns "0". + * + * This function can be called by long-running C code that wants to be + * interruptible by user requests (such as by pressing Ctrl-C). + * + * Note: + * + * The default Python signal handler for "SIGINT" raises the + * "KeyboardInterrupt" exception. + */ +expect inline fun PyErr_CheckSignals(): Int + +/** + * *Part of the Stable ABI.* + * + * Simulate the effect of a "SIGINT" signal arriving. This is + * equivalent to "PyErr_SetInterruptEx(SIGINT)". + * + * Note: + * + * This function is async-signal-safe. It can be called without the + * *GIL* and from a C signal handler. + */ +expect inline fun PyErr_SetInterrupt() + +/** + * *Part of the Stable ABI since version 3.10.* + * + * Simulate the effect of a signal arriving. The next time + * "PyErr_CheckSignals()" is called, the Python signal handler for + * the given signal number will be called. + * + * This function can be called by C code that sets up its own signal + * handling and wants Python signal handlers to be invoked as expected + * when an interruption is requested (for example when the user + * presses Ctrl-C to interrupt an operation). + * + * If the given signal isn’t handled by Python (it was set to + * "signal.SIG_DFL" or "signal.SIG_IGN"), it will be ignored. + * + * If *signum* is outside of the allowed range of signal numbers, "-1" + * is returned. Otherwise, "0" is returned. The error indicator is + * never changed by this function. + * + * Note: + * + * This function is async-signal-safe. It can be called without the + * *GIL* and from a C signal handler. + * + * Added in version 3.10. + */ +expect inline fun PyErr_SetInterruptEx(signum: Int): Int + +/** + * *Return value: New reference.* + * *Part of the Stable ABI.* + * + * This utility function creates and returns a new exception class. + * The *name* argument must be the name of the new exception, a C + * string of the form "module.classname". The *base* and *dict* + * arguments are normally "NULL". This creates a class object derived + * from "Exception" (accessible in C as "PyExc_Exception"). + * + * The "__module__" attribute of the new class is set to the first + * part (up to the last dot) of the *name* argument, and the class + * name is set to the last part (after the last dot). The *base* + * argument can be used to specify alternate base classes; it can + * either be only one class or a tuple of classes. The *dict* argument + * can be used to specify a dictionary of class variables and methods. + */ +expect fun PyErr_NewException(name: String, base: NativePointer, dict: NativePointer): NativePointer? + +/** + * *Return value: New reference.* + * *Part of the Stable ABI.* + * + * Same as "PyErr_NewException()", except that the new exception class + * can easily be given a docstring: If *doc* is non-"NULL", it will be + * used as the docstring for the exception class. + * + * Added in version 3.2. + */ +expect fun PyErr_NewExceptionWithDoc(name: String, doc: String, base: NativePointer, dict: NativePointer): NativePointer? + +/** + * *Return value: New reference.* + * *Part of the Stable ABI.* + * + * Return the traceback associated with the exception as a new + * reference, as accessible from Python through the "__traceback__" + * attribute. If there is no traceback associated, this returns + * "NULL". + */ +expect fun PyException_GetTraceback(ex: NativePointer): NativePointer? + +/** + * *Part of the Stable ABI.* + * + * Set the traceback associated with the exception to *tb*. Use + * "Py_None" to clear it. + */ +expect inline fun PyException_SetTraceback(ex: NativePointer, tb: NativePointer): Int + +/** + * *Return value: New reference.* + * *Part of the Stable ABI.* + * + * Return the context (another exception instance during whose + * handling *ex* was raised) associated with the exception as a new + * reference, as accessible from Python through the "__context__" + * attribute. If there is no context associated, this returns "NULL". + */ +expect fun PyException_GetContext(ex: NativePointer): NativePointer? + +/** + * *Part of the Stable ABI.* + * + * Set the context associated with the exception to *ctx*. Use "NULL" + * to clear it. There is no type check to make sure that *ctx* is an + * exception instance. This steals a reference to *ctx*. + */ +expect inline fun PyException_SetContext(ex: NativePointer, ctx: NativePointer) + +/** + * *Return value: New reference.* + * *Part of the Stable ABI.* + * + * Return the cause (either an exception instance, or "None", set by + * "raise ... from ...") associated with the exception as a new + * reference, as accessible from Python through the "__cause__" + * attribute. + */ +expect fun PyException_GetCause(ex: NativePointer): NativePointer? + +/** + * *Part of the Stable ABI.* + * + * Set the cause associated with the exception to *cause*. Use "NULL" + * to clear it. There is no type check to make sure that *cause* is + * either an exception instance or "None". This steals a reference to + * *cause*. + * + * The "__suppress_context__" attribute is implicitly set to "True" by + * this function. + */ +expect inline fun PyException_SetCause(ex: NativePointer, cause: NativePointer) + +/** + * *Return value: New reference.* + * *Part of the Stable ABI since version 3.12.* + * + * Return "args" of exception *ex*. + */ +expect fun PyException_GetArgs(ex: NativePointer): NativePointer? + +/** + * *Part of the Stable ABI since version 3.12.* + * + * Set "args" of exception *ex* to *args*. + */ +expect inline fun PyException_SetArgs(ex: NativePointer, args: NativePointer) + +/** + * *Return value: New reference.* + * *Part of the Stable ABI.* + * + * Return the *encoding* attribute of the given exception object. + */ +expect fun PyUnicodeEncodeError_GetEncoding(exc: NativePointer): NativePointer? + +/** + * *Return value: New reference.* + * *Part of the Stable ABI.* + * + * Return the *object* attribute of the given exception object. + */ +expect fun PyUnicodeTranslateError_GetObject(exc: NativePointer): NativePointer? + +/** + * *Return value: New reference.* + * *Part of the Stable ABI.* + * + * Return the *reason* attribute of the given exception object. + */ +expect fun PyUnicodeTranslateError_GetReason(exc: NativePointer): NativePointer? + +/** + * *Part of the Stable ABI.* + * + * Set the *reason* attribute of the given exception object to + * *reason*. Return "0" on success, "-1" on failure. + */ +expect inline fun PyUnicodeTranslateError_SetReason(exc: NativePointer, reason: String): Int + +/** + * *Part of the Stable ABI since version 3.9.* + * + * Marks a point where a recursive C-level call is about to be + * performed. + * + * If "USE_STACKCHECK" is defined, this function checks if the OS + * stack overflowed using "PyOS_CheckStack()". If this is the case, + * it sets a "MemoryError" and returns a nonzero value. + * + * The function then checks if the recursion limit is reached. If + * this is the case, a "RecursionError" is set and a nonzero value is + * returned. Otherwise, zero is returned. + * + * *where* should be a UTF-8 encoded string such as "" in instance + * check"" to be concatenated to the "RecursionError" message caused + * by the recursion depth limit. + * + * Changed in version 3.9: This function is now also available in the + * limited API. + */ +expect inline fun Py_EnterRecursiveCall(where: String): Int + +/** + * *Part of the Stable ABI since version 3.9.* + * + * Ends a "Py_EnterRecursiveCall()". Must be called once for each + * *successful* invocation of "Py_EnterRecursiveCall()". + * + * Changed in version 3.9: This function is now also available in the + * limited API. + */ +expect inline fun Py_LeaveRecursiveCall() + +/** + * *Part of the Stable ABI.* + * + * Called at the beginning of the "tp_repr" implementation to detect + * cycles. + * + * If the object has already been processed, the function returns a + * positive integer. In that case the "tp_repr" implementation should + * return a string object indicating a cycle. As examples, "dict" + * objects return "{...}" and "list" objects return "[...]". + * + * The function will return a negative integer if the recursion limit + * is reached. In that case the "tp_repr" implementation should + * typically return "NULL". + * + * Otherwise, the function returns zero and the "tp_repr" + * implementation can continue normally. + */ +expect inline fun Py_ReprEnter(o: NativePointer): Int + +/** + * *Part of the Stable ABI.* + * + * Ends a "Py_ReprEnter()". Must be called once for each invocation + */ +expect inline fun Py_ReprLeave(o: NativePointer) + + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// Section 4 +// Reference Counting +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/** + * *Part of the Stable ABI since version 3.10.* + * + * Create a new *strong reference* to an object: call "Py_INCREF()" on + * *o* and return the object *o*. + * + * When the *strong reference* is no longer needed, "Py_DECREF()" + * should be called on it to release the reference. + * + * The object *o* must not be "NULL"; use "Py_XNewRef()" if *o* can be + * "NULL". + * + * For example: + * + * Py_INCREF(obj); + * self->attr = obj; + * + * can be written as: + * + * self->attr = Py_NewRef(obj); + * + * See also "Py_INCREF()". + * + * Added in version 3.10. + */ +expect fun Py_NewRef(o: NativePointer): NativePointer? + +/** + * *Part of the Stable ABI since version 3.10.* + * + * Similar to "Py_NewRef()", but the object *o* can be NULL. + * + * If the object *o* is "NULL", the function just returns "NULL". + * + * Added in version 3.10. + */ +expect fun Py_XNewRef(o: NativePointer): NativePointer? + +/** + * *Part of the Stable ABI.* + * + * Indicate taking a new *strong reference* to object *o*. A function + * version of "Py_XINCREF()". It can be used for runtime dynamic + * embedding of Python. + */ +expect inline fun Py_IncRef(o: NativePointer) + +/** + * *Part of the Stable ABI.* + * + * Release a *strong reference* to object *o*. A function version of + * "Py_XDECREF()". It can be used for runtime dynamic embedding of + */ +expect inline fun Py_DecRef(o: NativePointer) + + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// Section 5 +// Operating System Utilities +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/** + * *Return value: New reference.* + * *Part of the Stable ABI since version 3.6.* + * + * Return the file system representation for *path*. If the object is + * a "str" or "bytes" object, then a new *strong reference* is + * returned. If the object implements the "os.PathLike" interface, + * then "__fspath__()" is returned as long as it is a "str" or "bytes" + * object. Otherwise "TypeError" is raised and "NULL" is returned. + * + * Added in version 3.6. + */ +expect fun PyOS_FSPath(path: NativePointer): NativePointer? + + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// Section 6 +// System Functions +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/** + * *Return value: Borrowed reference.* + * *Part of the Stable ABI.* + * + * Return the object *name* from the "sys" module or "NULL" if it does + * not exist, without setting an exception. + */ +expect fun PySys_GetObject(name: String): NativePointer? + +/** + * *Part of the Stable ABI.* + * + * Set *name* in the "sys" module to *v* unless *v* is "NULL", in + * which case *name* is deleted from the sys module. Returns "0" on + * success, "-1" on error. + */ +expect inline fun PySys_SetObject(name: String, v: NativePointer): Int + +/** + * *Part of the Stable ABI.* + * + * Reset "sys.warnoptions" to an empty list. This function may be + * called prior to "Py_Initialize()". + * + * Deprecated since version 3.13, will be removed in version 3.15: + * Clear "sys.warnoptions" and "warnings.filters" instead. + */ +expect inline fun PySys_ResetWarnOptions() + +/** + * *Return value: Borrowed reference.* + * *Part of the Stable ABI since version 3.7.* + * + * Return the current dictionary of "-X" options, similarly to + * "sys._xoptions". On error, "NULL" is returned and an exception is + * set. + * + * Added in version 3.2. + */ +expect fun PySys_GetXOptions(): NativePointer? + +/** + * *Part of the Stable ABI since version 3.13.* + * + * Similar to "PySys_Audit()", but pass arguments as a Python object. + * *args* must be a "tuple". To pass no arguments, *args* can be + * *NULL*. + * + * Added in version 3.13. + */ +expect inline fun PySys_AuditTuple(event: String, args: NativePointer): Int + + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// Section 7 +// Process Control +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/** + * *Part of the Stable ABI.* + * + * Print a fatal error message and kill the process. No cleanup is + * performed. This function should only be invoked when a condition is + * detected that would make it dangerous to continue using the Python + * interpreter; e.g., when the object administration appears to be + * corrupted. On Unix, the standard C library function "abort()" is + * called which will attempt to produce a "core" file. + * + * The "Py_FatalError()" function is replaced with a macro which logs + * automatically the name of the current function, unless the + * "Py_LIMITED_API" macro is defined. + * + * Changed in version 3.9: Log the function name automatically. + */ +expect inline fun Py_FatalError(message: String) + +/** + * *Part of the Stable ABI.* + * + * Exit the current process. This calls "Py_FinalizeEx()" and then + * calls the standard C library function "exit(status)". If + * "Py_FinalizeEx()" indicates an error, the exit status is set to + * 120. + * + * Changed in version 3.6: Errors from finalization no longer ignored. + */ +expect inline fun Py_Exit(status: Int) + + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// Section 8 +// Importing Modules +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/** + * *Return value: New reference.* + * *Part of the Stable ABI.* + * + * This is a wrapper around "PyImport_Import()" which takes a const + * char* as an argument instead of a PyObject*. + */ +expect fun PyImport_ImportModule(name: String): NativePointer? + +/** + * *Return value: New reference.* + * *Part of the Stable ABI.* + * + * This function is a deprecated alias of "PyImport_ImportModule()". + * + * Changed in version 3.3: This function used to fail immediately when + * the import lock was held by another thread. In Python 3.3 though, + * the locking scheme switched to per-module locks for most purposes, + * so this function’s special behaviour isn’t needed anymore. + * + * Deprecated since version 3.13, will be removed in version 3.15: Use + * "PyImport_ImportModule()" instead. + */ +expect fun PyImport_ImportModuleNoBlock(name: String): NativePointer? + +/** + * *Return value: New reference.* + * *Part of the Stable ABI since version 3.7.* + * + * Import a module. This is best described by referring to the built- + * in Python function "__import__()", as the standard "__import__()" + * function calls this function directly. + * + * The return value is a new reference to the imported module or top- + * level package, or "NULL" with an exception set on failure. Like + * for "__import__()", the return value when a submodule of a package + * was requested is normally the top-level package, unless a non-empty + * *fromlist* was given. + * + * Added in version 3.3. + */ +expect fun PyImport_ImportModuleLevelObject(name: NativePointer, globals: NativePointer, locals: NativePointer, fromlist: NativePointer, level: Int): NativePointer? + +/** + * *Return value: New reference.* + * *Part of the Stable ABI.* + * + * Similar to "PyImport_ImportModuleLevelObject()", but the name is a + * UTF-8 encoded string instead of a Unicode object. + * + * Changed in version 3.3: Negative values for *level* are no longer + * accepted. + */ +expect fun PyImport_ImportModuleLevel(name: String, globals: NativePointer, locals: NativePointer, fromlist: NativePointer, level: Int): NativePointer? + +/** + * *Return value: New reference.* + * *Part of the Stable ABI.* + * + * This is a higher-level interface that calls the current “import + * hook function” (with an explicit *level* of 0, meaning absolute + * import). It invokes the "__import__()" function from the + * "__builtins__" of the current globals. This means that the import + * is done using whatever import hooks are installed in the current + * environment. + * + * This function always uses absolute imports. + */ +expect fun PyImport_Import(name: NativePointer): NativePointer? + +/** + * *Return value: New reference.* + * *Part of the Stable ABI.* + * + * Reload a module. Return a new reference to the reloaded module, or + * "NULL" with an exception set on failure (the module still exists in + * this case). + */ +expect fun PyImport_ReloadModule(m: NativePointer): NativePointer? + +/** + * *Return value: New reference.* + * *Part of the Stable ABI since version 3.13.* + * + * Return the module object corresponding to a module name. + * + * The *name* argument may be of the form "package.module". First + * check the modules dictionary if there’s one there, and if not, + * create a new one and insert it in the modules dictionary. + * + * Return a *strong reference* to the module on success. Return "NULL" + * with an exception set on failure. + * + * The module name *name* is decoded from UTF-8. + * + * This function does not load or import the module; if the module + * wasn’t already loaded, you will get an empty module object. Use + * "PyImport_ImportModule()" or one of its variants to import a + * module. Package structures implied by a dotted name for *name* are + * not created if not already present. + * + * Added in version 3.13. + */ +expect fun PyImport_AddModuleRef(name: String): NativePointer? + +/** + * *Return value: Borrowed reference.* + * *Part of the Stable ABI since version 3.7.* + * + * Similar to "PyImport_AddModuleRef()", but return a *borrowed + * reference* and *name* is a Python "str" object. + * + * Added in version 3.3. + */ +expect fun PyImport_AddModuleObject(name: NativePointer): NativePointer? + +/** + * *Return value: Borrowed reference.* + * *Part of the Stable ABI.* + * + * Similar to "PyImport_AddModuleRef()", but return a *borrowed + * reference*. + */ +expect fun PyImport_AddModule(name: String): NativePointer? + +/** + * *Return value: New reference.* + * *Part of the Stable ABI.* + * + * Given a module name (possibly of the form "package.module") and a + * code object read from a Python bytecode file or obtained from the + * built-in function "compile()", load the module. Return a new + * reference to the module object, or "NULL" with an exception set if + * an error occurred. *name* is removed from "sys.modules" in error + * cases, even if *name* was already in "sys.modules" on entry to + * "PyImport_ExecCodeModule()". Leaving incompletely initialized + * modules in "sys.modules" is dangerous, as imports of such modules + * have no way to know that the module object is an unknown (and + * probably damaged with respect to the module author’s intents) + * state. + * + * The module’s "__spec__" and "__loader__" will be set, if not set + * already, with the appropriate values. The spec’s loader will be + * set to the module’s "__loader__" (if set) and to an instance of + * "SourceFileLoader" otherwise. + * + * The module’s "__file__" attribute will be set to the code object’s + * "co_filename". If applicable, "__cached__" will also be set. + * + * This function will reload the module if it was already imported. + * See "PyImport_ReloadModule()" for the intended way to reload a + * module. + * + * If *name* points to a dotted name of the form "package.module", any + * package structures not already created will still not be created. + * + * See also "PyImport_ExecCodeModuleEx()" and + * "PyImport_ExecCodeModuleWithPathnames()". + * + * Changed in version 3.12: The setting of "__cached__" and + * "__loader__" is deprecated. See "ModuleSpec" for alternatives. + */ +expect fun PyImport_ExecCodeModule(name: String, co: NativePointer): NativePointer? + +/** + * *Return value: New reference.* + * *Part of the Stable ABI.* + * + * Like "PyImport_ExecCodeModule()", but the "__file__" attribute of + * the module object is set to *pathname* if it is non-"NULL". + * + * See also "PyImport_ExecCodeModuleWithPathnames()". + */ +expect fun PyImport_ExecCodeModuleEx(name: String, co: NativePointer, pathname: String): NativePointer? + +/** + * *Return value: New reference.* + * *Part of the Stable ABI since version 3.7.* + * + * Like "PyImport_ExecCodeModuleEx()", but the "__cached__" attribute + * of the module object is set to *cpathname* if it is non-"NULL". Of + * the three functions, this is the preferred one to use. + * + * Added in version 3.3. + * + * Changed in version 3.12: Setting "__cached__" is deprecated. See + * "ModuleSpec" for alternatives. + */ +expect fun PyImport_ExecCodeModuleObject(name: NativePointer, co: NativePointer, pathname: NativePointer, cpathname: NativePointer): NativePointer? + +/** + * *Return value: New reference.* + * *Part of the Stable ABI.* + * + * Like "PyImport_ExecCodeModuleObject()", but *name*, *pathname* and + * *cpathname* are UTF-8 encoded strings. Attempts are also made to + * figure out what the value for *pathname* should be from *cpathname* + * if the former is set to "NULL". + * + * Added in version 3.2. + * + * Changed in version 3.3: Uses "imp.source_from_cache()" in + * calculating the source path if only the bytecode path is provided. + * + * Changed in version 3.12: No longer uses the removed "imp" module. + */ +expect fun PyImport_ExecCodeModuleWithPathnames(name: String, co: NativePointer, pathname: String, cpathname: String): NativePointer? + +/** + * *Part of the Stable ABI.* + * + * Return the magic tag string for **PEP 3147** format Python bytecode + * file names. Keep in mind that the value at + * "sys.implementation.cache_tag" is authoritative and should be used + * instead of this function. + * + * Added in version 3.2. + */ +expect inline fun PyImport_GetMagicTag(): String? + +/** + * *Return value: Borrowed reference.* + * *Part of the Stable ABI.* + * + * Return the dictionary used for the module administration (a.k.a. + * "sys.modules"). Note that this is a per-interpreter variable. + */ +expect fun PyImport_GetModuleDict(): NativePointer? + +/** + * *Return value: New reference.* + * *Part of the Stable ABI since version 3.8.* + * + * Return the already imported module with the given name. If the + * module has not been imported yet then returns "NULL" but does not + * set an error. Returns "NULL" and sets an error if the lookup + * failed. + * + * Added in version 3.7. + */ +expect fun PyImport_GetModule(name: NativePointer): NativePointer? + +/** + * *Return value: New reference.* + * *Part of the Stable ABI.* + * + * Return a finder object for a "sys.path"/"pkg.__path__" item *path*, + * possibly by fetching it from the "sys.path_importer_cache" dict. + * If it wasn’t yet cached, traverse "sys.path_hooks" until a hook is + * found that can handle the path item. Return "None" if no hook + * could; this tells our caller that the *path based finder* could not + * find a finder for this path item. Cache the result in + * "sys.path_importer_cache". Return a new reference to the finder + * object. + */ +expect fun PyImport_GetImporter(path: NativePointer): NativePointer? + +/** + * *Part of the Stable ABI since version 3.7.* + * + * Load a frozen module named *name*. Return "1" for success, "0" if + * the module is not found, and "-1" with an exception set if the + * initialization failed. To access the imported module on a + * successful load, use "PyImport_ImportModule()". (Note the misnomer + * — this function would reload the module if it was already + * imported.) + * + * Added in version 3.3. + * + * Changed in version 3.4: The "__file__" attribute is no longer set + * on the module. + */ +expect inline fun PyImport_ImportFrozenModuleObject(name: NativePointer): Int + +/** + * *Part of the Stable ABI.* + * + * Similar to "PyImport_ImportFrozenModuleObject()", but the name is a + * UTF-8 encoded string instead of a Unicode object. + */ +expect inline fun PyImport_ImportFrozenModule(name: String): Int + + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// Section 9 +// Reflection +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/** + * *Return value: Borrowed reference.* + * *Part of the Stable ABI.* + * + * Deprecated since version 3.13: Use "PyEval_GetFrameBuiltins()" + * instead. + * + * Return a dictionary of the builtins in the current execution frame, + * or the interpreter of the thread state if no frame is currently + * executing. + */ +expect fun PyEval_GetBuiltins(): NativePointer? + +/** + * *Return value: Borrowed reference.* + * *Part of the Stable ABI.* + * + * Deprecated since version 3.13: Use either "PyEval_GetFrameLocals()" + * to obtain the same behaviour as calling "locals()" in Python code, + * or else call "PyFrame_GetLocals()" on the result of + * "PyEval_GetFrame()" to access the "f_locals" attribute of the + * currently executing frame. + * + * Return a mapping providing access to the local variables in the + * current execution frame, or "NULL" if no frame is currently + * executing. + * + * Refer to "locals()" for details of the mapping returned at + * different scopes. + * + * As this function returns a *borrowed reference*, the dictionary + * returned for *optimized scopes* is cached on the frame object and + * will remain alive as long as the frame object does. Unlike + * "PyEval_GetFrameLocals()" and "locals()", subsequent calls to this + * function in the same frame will update the contents of the cached + * dictionary to reflect changes in the state of the local variables + * rather than returning a new snapshot. + * + * Changed in version 3.13: As part of **PEP 667**, + * "PyFrame_GetLocals()", "locals()", and "FrameType.f_locals" no + * longer make use of the shared cache dictionary. Refer to the What’s + * New entry for additional details. + */ +expect fun PyEval_GetLocals(): NativePointer? + +/** + * *Return value: Borrowed reference.* + * *Part of the Stable ABI.* + * + * Deprecated since version 3.13: Use "PyEval_GetFrameGlobals()" + * instead. + * + * Return a dictionary of the global variables in the current + * execution frame, or "NULL" if no frame is currently executing. + */ +expect fun PyEval_GetGlobals(): NativePointer? + +/** + * *Return value: New reference.* + * *Part of the Stable ABI since version 3.13.* + * + * Return a dictionary of the builtins in the current execution frame, + * or the interpreter of the thread state if no frame is currently + * executing. + * + * Added in version 3.13. + */ +expect fun PyEval_GetFrameBuiltins(): NativePointer? + +/** + * *Return value: New reference.* + * *Part of the Stable ABI since version 3.13.* + * + * Return a dictionary of the local variables in the current execution + * frame, or "NULL" if no frame is currently executing. Equivalent to + * calling "locals()" in Python code. + * + * To access "f_locals" on the current frame without making an + * independent snapshot in *optimized scopes*, call + * "PyFrame_GetLocals()" on the result of "PyEval_GetFrame()". + * + * Added in version 3.13. + */ +expect fun PyEval_GetFrameLocals(): NativePointer? + +/** + * *Return value: New reference.* + * *Part of the Stable ABI since version 3.13.* + * + * Return a dictionary of the global variables in the current + * execution frame, or "NULL" if no frame is currently executing. + * Equivalent to calling "globals()" in Python code. + * + * Added in version 3.13. + */ +expect fun PyEval_GetFrameGlobals(): NativePointer? + +/** + * *Part of the Stable ABI.* + * + * Return the name of *func* if it is a function, class or instance + * object, else the name of *func*s type. + */ +expect inline fun PyEval_GetFuncName(func: NativePointer): String? + +/** + * *Part of the Stable ABI.* + * + * Return a description string, depending on the type of *func*. + * Return values include “()” for functions and methods, “ + * constructor”, “ instance”, and “ object”. Concatenated with the + * result of "PyEval_GetFuncName()", the result will be a description + */ +expect inline fun PyEval_GetFuncDesc(func: NativePointer): String? + + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// Section 10 +// Object Protocol +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/** + * *Part of the Stable ABI since version 3.13.* + * + * Returns "1" if *o* has the attribute *attr_name*, and "0" + * otherwise. This is equivalent to the Python expression "hasattr(o, + * attr_name)". On failure, return "-1". + * + * Added in version 3.13. + */ +expect inline fun PyObject_HasAttrWithError(o: NativePointer, attr_name: NativePointer): Int + +/** + * *Part of the Stable ABI since version 3.13.* + * + * This is the same as "PyObject_HasAttrWithError()", but *attr_name* + * is specified as a const char* UTF-8 encoded bytes string, rather + * than a PyObject*. + * + * Added in version 3.13. + */ +expect inline fun PyObject_HasAttrStringWithError(o: NativePointer, attr_name: String): Int + +/** + * *Part of the Stable ABI.* + * + * Returns "1" if *o* has the attribute *attr_name*, and "0" + * otherwise. This function always succeeds. + * + * Note: + * + * Exceptions that occur when this calls "__getattr__()" and + * "__getattribute__()" methods are silently ignored. For proper + * error handling, use "PyObject_HasAttrWithError()", + * "PyObject_GetOptionalAttr()" or "PyObject_GetAttr()" instead. + */ +expect inline fun PyObject_HasAttr(o: NativePointer, attr_name: NativePointer): Int + +/** + * *Part of the Stable ABI.* + * + * This is the same as "PyObject_HasAttr()", but *attr_name* is + * specified as a const char* UTF-8 encoded bytes string, rather than + * a PyObject*. + * + * Note: + * + * Exceptions that occur when this calls "__getattr__()" and + * "__getattribute__()" methods or while creating the temporary + * "str" object are silently ignored. For proper error handling, use + * "PyObject_HasAttrStringWithError()", + * "PyObject_GetOptionalAttrString()" or "PyObject_GetAttrString()" + * instead. + */ +expect inline fun PyObject_HasAttrString(o: NativePointer, attr_name: String): Int + +/** + * *Return value: New reference.* + * *Part of the Stable ABI.* + * + * Retrieve an attribute named *attr_name* from object *o*. Returns + * the attribute value on success, or "NULL" on failure. This is the + * equivalent of the Python expression "o.attr_name". + * + * If the missing attribute should not be treated as a failure, you + * can use "PyObject_GetOptionalAttr()" instead. + */ +expect fun PyObject_GetAttr(o: NativePointer, attr_name: NativePointer): NativePointer? + +/** + * *Return value: New reference.* + * *Part of the Stable ABI.* + * + * This is the same as "PyObject_GetAttr()", but *attr_name* is + * specified as a const char* UTF-8 encoded bytes string, rather than + * a PyObject*. + * + * If the missing attribute should not be treated as a failure, you + * can use "PyObject_GetOptionalAttrString()" instead. + */ +expect fun PyObject_GetAttrString(o: NativePointer, attr_name: String): NativePointer? + +/** + * *Return value: New reference.* + * *Part of the Stable ABI.* + * + * Generic attribute getter function that is meant to be put into a + * type object’s "tp_getattro" slot. It looks for a descriptor in the + * dictionary of classes in the object’s MRO as well as an attribute + * in the object’s "__dict__" (if present). As outlined in + * Implementing Descriptors, data descriptors take preference over + * instance attributes, while non-data descriptors don’t. Otherwise, + * an "AttributeError" is raised. + */ +expect fun PyObject_GenericGetAttr(o: NativePointer, name: NativePointer): NativePointer? + +/** + * *Part of the Stable ABI.* + * + * Set the value of the attribute named *attr_name*, for object *o*, + * to the value *v*. Raise an exception and return "-1" on failure; + * return "0" on success. This is the equivalent of the Python + * statement "o.attr_name = v". + * + * If *v* is "NULL", the attribute is deleted. This behaviour is + * deprecated in favour of using "PyObject_DelAttr()", but there are + * currently no plans to remove it. + */ +expect inline fun PyObject_SetAttr(o: NativePointer, attr_name: NativePointer, v: NativePointer): Int + +/** + * *Part of the Stable ABI.* + * + * This is the same as "PyObject_SetAttr()", but *attr_name* is + * specified as a const char* UTF-8 encoded bytes string, rather than + * a PyObject*. + * + * If *v* is "NULL", the attribute is deleted, but this feature is + * deprecated in favour of using "PyObject_DelAttrString()". + * + * The number of different attribute names passed to this function + * should be kept small, usually by using a statically allocated + * string as *attr_name*. For attribute names that aren’t known at + * compile time, prefer calling "PyUnicode_FromString()" and + * "PyObject_SetAttr()" directly. For more details, see + * "PyUnicode_InternFromString()", which may be used internally to + * create a key object. + */ +expect inline fun PyObject_SetAttrString(o: NativePointer, attr_name: String, v: NativePointer): Int + +/** + * *Part of the Stable ABI.* + * + * Generic attribute setter and deleter function that is meant to be + * put into a type object’s "tp_setattro" slot. It looks for a data + * descriptor in the dictionary of classes in the object’s MRO, and if + * found it takes preference over setting or deleting the attribute in + * the instance dictionary. Otherwise, the attribute is set or deleted + * in the object’s "__dict__" (if present). On success, "0" is + * returned, otherwise an "AttributeError" is raised and "-1" is + * returned. + */ +expect inline fun PyObject_GenericSetAttr(o: NativePointer, name: NativePointer, value: NativePointer): Int + +/** + * *Part of the Stable ABI since version 3.13.* + * + * Delete attribute named *attr_name*, for object *o*. Returns "-1" on + * failure. This is the equivalent of the Python statement "del + * o.attr_name". + */ +expect inline fun PyObject_DelAttr(o: NativePointer, attr_name: NativePointer): Int + +/** + * *Part of the Stable ABI since version 3.13.* + * + * This is the same as "PyObject_DelAttr()", but *attr_name* is + * specified as a const char* UTF-8 encoded bytes string, rather than + * a PyObject*. + * + * The number of different attribute names passed to this function + * should be kept small, usually by using a statically allocated + * string as *attr_name*. For attribute names that aren’t known at + * compile time, prefer calling "PyUnicode_FromString()" and + * "PyObject_DelAttr()" directly. For more details, see + * "PyUnicode_InternFromString()", which may be used internally to + * create a key object for lookup. + */ +expect inline fun PyObject_DelAttrString(o: NativePointer, attr_name: String): Int + +/** + * *Return value: New reference.* + * *Part of the Stable ABI.* + * + * Compare the values of *o1* and *o2* using the operation specified + * by *opid*, which must be one of "Py_LT", "Py_LE", "Py_EQ", "Py_NE", + * "Py_GT", or "Py_GE", corresponding to "<", "<=", "==", "!=", ">", + * or ">=" respectively. This is the equivalent of the Python + * expression "o1 op o2", where "op" is the operator corresponding to + * *opid*. Returns the value of the comparison on success, or "NULL" + * on failure. + */ +expect fun PyObject_RichCompare(o1: NativePointer, o2: NativePointer, opid: Int): NativePointer? + +/** + * *Part of the Stable ABI.* + * + * Compare the values of *o1* and *o2* using the operation specified + * by *opid*, like "PyObject_RichCompare()", but returns "-1" on + * error, "0" if the result is false, "1" otherwise. + */ +expect inline fun PyObject_RichCompareBool(o1: NativePointer, o2: NativePointer, opid: Int): Int + +/** + * *Part of the Stable ABI.* + * + * Format *obj* using *format_spec*. This is equivalent to the Python + * expression "format(obj, format_spec)". + * + * *format_spec* may be "NULL". In this case the call is equivalent to + * "format(obj)". Returns the formatted string on success, "NULL" on + * failure. + */ +expect fun PyObject_Format(obj: NativePointer, format_spec: NativePointer): NativePointer? + +/** + * *Return value: New reference.* + * *Part of the Stable ABI.* + * + * Compute a string representation of object *o*. Returns the string + * representation on success, "NULL" on failure. This is the + * equivalent of the Python expression "repr(o)". Called by the + * "repr()" built-in function. + * + * Changed in version 3.4: This function now includes a debug + * assertion to help ensure that it does not silently discard an + * active exception. + */ +expect fun PyObject_Repr(o: NativePointer): NativePointer? + +/** + * *Return value: New reference.* + * *Part of the Stable ABI.* + * + * As "PyObject_Repr()", compute a string representation of object + * *o*, but escape the non-ASCII characters in the string returned by + * "PyObject_Repr()" with "\x", "\u" or "\U" escapes. This generates + * a string similar to that returned by "PyObject_Repr()" in Python 2. + * Called by the "ascii()" built-in function. + */ +expect fun PyObject_ASCII(o: NativePointer): NativePointer? + +/** + * *Return value: New reference.* + * *Part of the Stable ABI.* + * + * Compute a string representation of object *o*. Returns the string + * representation on success, "NULL" on failure. This is the + * equivalent of the Python expression "str(o)". Called by the + * "str()" built-in function and, therefore, by the "print()" + * function. + * + * Changed in version 3.4: This function now includes a debug + * assertion to help ensure that it does not silently discard an + * active exception. + */ +expect fun PyObject_Str(o: NativePointer): NativePointer? + +/** + * *Return value: New reference.* + * *Part of the Stable ABI.* + * + * Compute a bytes representation of object *o*. "NULL" is returned + * on failure and a bytes object on success. This is equivalent to + * the Python expression "bytes(o)", when *o* is not an integer. + * Unlike "bytes(o)", a TypeError is raised when *o* is an integer + * instead of a zero-initialized bytes object. + */ +expect fun PyObject_Bytes(o: NativePointer): NativePointer? + +/** + * *Part of the Stable ABI.* + * + * Return "1" if the class *derived* is identical to or derived from + * the class *cls*, otherwise return "0". In case of an error, return + * "-1". + * + * If *cls* is a tuple, the check will be done against every entry in + * *cls*. The result will be "1" when at least one of the checks + * returns "1", otherwise it will be "0". + * + * If *cls* has a "__subclasscheck__()" method, it will be called to + * determine the subclass status as described in **PEP 3119**. + * Otherwise, *derived* is a subclass of *cls* if it is a direct or + * indirect subclass, i.e. contained in "cls.__mro__". + * + * Normally only class objects, i.e. instances of "type" or a derived + * class, are considered classes. However, objects can override this + * by having a "__bases__" attribute (which must be a tuple of base + * classes). + */ +expect inline fun PyObject_IsSubclass(derived: NativePointer, cls: NativePointer): Int + +/** + * *Part of the Stable ABI.* + * + * Return "1" if *inst* is an instance of the class *cls* or a + * subclass of *cls*, or "0" if not. On error, returns "-1" and sets + * an exception. + * + * If *cls* is a tuple, the check will be done against every entry in + * *cls*. The result will be "1" when at least one of the checks + * returns "1", otherwise it will be "0". + * + * If *cls* has a "__instancecheck__()" method, it will be called to + * determine the subclass status as described in **PEP 3119**. + * Otherwise, *inst* is an instance of *cls* if its class is a + * subclass of *cls*. + * + * An instance *inst* can override what is considered its class by + * having a "__class__" attribute. + * + * An object *cls* can override if it is considered a class, and what + * its base classes are, by having a "__bases__" attribute (which must + * be a tuple of base classes). + */ +expect inline fun PyObject_IsInstance(inst: NativePointer, cls: NativePointer): Int + +/** + * *Part of the Stable ABI.* + * + * Returns "1" if the object *o* is considered to be true, and "0" + * otherwise. This is equivalent to the Python expression "not not o". + * On failure, return "-1". + */ +expect inline fun PyObject_IsTrue(o: NativePointer): Int + +/** + * *Part of the Stable ABI.* + * + * Returns "0" if the object *o* is considered to be true, and "1" + * otherwise. This is equivalent to the Python expression "not o". On + * failure, return "-1". + */ +expect inline fun PyObject_Not(o: NativePointer): Int + +/** + * *Return value: New reference.* + * *Part of the Stable ABI.* + * + * When *o* is non-"NULL", returns a type object corresponding to the + * object type of object *o*. On failure, raises "SystemError" and + * returns "NULL". This is equivalent to the Python expression + * "type(o)". This function creates a new *strong reference* to the + * return value. There’s really no reason to use this function instead + * of the "Py_TYPE()" function, which returns a pointer of type + * PyTypeObject*, except when a new *strong reference* is needed. + */ +expect fun PyObject_Type(o: NativePointer): NativePointer? + +/** + * *Return value: New reference.* + * *Part of the Stable ABI.* + * + * Return element of *o* corresponding to the object *key* or "NULL" + * on failure. This is the equivalent of the Python expression + * "o[key]". + */ +expect fun PyObject_GetItem(o: NativePointer, key: NativePointer): NativePointer? + +/** + * *Part of the Stable ABI.* + * + * Map the object *key* to the value *v*. Raise an exception and + * return "-1" on failure; return "0" on success. This is the + * equivalent of the Python statement "o[key] = v". This function + * *does not* steal a reference to *v*. + */ +expect inline fun PyObject_SetItem(o: NativePointer, key: NativePointer, v: NativePointer): Int + +/** + * *Part of the Stable ABI.* + * + * Remove the mapping for the object *key* from the object *o*. + * Return "-1" on failure. This is equivalent to the Python statement + * "del o[key]". + */ +expect inline fun PyObject_DelItem(o: NativePointer, key: NativePointer): Int + +/** + * *Return value: New reference.* + * *Part of the Stable ABI.* + * + * This is equivalent to the Python expression "dir(o)", returning a + * (possibly empty) list of strings appropriate for the object + * argument, or "NULL" if there was an error. If the argument is + * "NULL", this is like the Python "dir()", returning the names of the + * current locals; in this case, if no execution frame is active then + * "NULL" is returned but "PyErr_Occurred()" will return false. + */ +expect fun PyObject_Dir(o: NativePointer): NativePointer? + +/** + * *Return value: New reference.* + * *Part of the Stable ABI.* + * + * This is equivalent to the Python expression "iter(o)". It returns a + * new iterator for the object argument, or the object itself if the + * object is already an iterator. Raises "TypeError" and returns + * "NULL" if the object cannot be iterated. + */ +expect fun PyObject_GetIter(o: NativePointer): NativePointer? + +/** + * *Return value: New reference.* + * *Part of the Stable ABI since version 3.10.* + * + * This is the equivalent to the Python expression "aiter(o)". Takes + * an "AsyncIterable" object and returns an "AsyncIterator" for it. + * This is typically a new iterator but if the argument is an + * "AsyncIterator", this returns itself. Raises "TypeError" and + * returns "NULL" if the object cannot be iterated. + * + * Added in version 3.10. + */ +expect fun PyObject_GetAIter(o: NativePointer): NativePointer? + + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// Section 11 +// Call Protocol +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/** + * *Part of the Stable ABI since version 3.12.* + * + * Call *callable*’s "vectorcallfunc" with positional and keyword + * arguments given in a tuple and dict, respectively. + * + * This is a specialized function, intended to be put in the "tp_call" + * slot or be used in an implementation of "tp_call". It does not + * check the "Py_TPFLAGS_HAVE_VECTORCALL" flag and it does not fall + * back to "tp_call". + * + * Added in version 3.8. + */ +expect fun PyVectorcall_Call(callable: NativePointer, tuple: NativePointer, dict: NativePointer): NativePointer? + +/** + * *Return value: New reference.* + * *Part of the Stable ABI.* + * + * Call a callable Python object *callable*, with arguments given by + * the tuple *args*, and named arguments given by the dictionary + * *kwargs*. + * + * *args* must not be *NULL*; use an empty tuple if no arguments are + * needed. If no named arguments are needed, *kwargs* can be *NULL*. + * + * Return the result of the call on success, or raise an exception and + * return *NULL* on failure. + * + * This is the equivalent of the Python expression: "callable(*args, + * **kwargs)". + */ +expect fun PyObject_Call(callable: NativePointer, args: NativePointer, kwargs: NativePointer): NativePointer? + +/** + * *Return value: New reference.* + * *Part of the Stable ABI since version 3.10.* + * + * Call a callable Python object *callable* without any arguments. It + * is the most efficient way to call a callable Python object without + * any argument. + * + * Return the result of the call on success, or raise an exception and + * return *NULL* on failure. + * + * Added in version 3.9. + */ +expect fun PyObject_CallNoArgs(callable: NativePointer): NativePointer? + +/** + * *Return value: New reference.* + * *Part of the Stable ABI.* + * + * Call a callable Python object *callable*, with arguments given by + * the tuple *args*. If no arguments are needed, then *args* can be + * *NULL*. + * + * Return the result of the call on success, or raise an exception and + * return *NULL* on failure. + * + * This is the equivalent of the Python expression: "callable(*args)". + */ +expect fun PyObject_CallObject(callable: NativePointer, args: NativePointer): NativePointer? + +/** + * *Part of the Stable ABI.* + * + * Determine if the object *o* is callable. Return "1" if the object + */ +expect inline fun PyCallable_Check(o: NativePointer): Int + + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// Section 12 +// Number Protocol +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/** + * *Part of the Stable ABI.* + * + * Returns "1" if the object *o* provides numeric protocols, and false + * otherwise. This function always succeeds. + * + * Changed in version 3.8: Returns "1" if *o* is an index integer. + */ +expect inline fun PyNumber_Check(o: NativePointer): Int + +/** + * *Return value: New reference.* + * *Part of the Stable ABI.* + * + * Returns the result of adding *o1* and *o2*, or "NULL" on failure. + * This is the equivalent of the Python expression "o1 + o2". + */ +expect fun PyNumber_Add(o1: NativePointer, o2: NativePointer): NativePointer? + +/** + * *Return value: New reference.* + * *Part of the Stable ABI.* + * + * Returns the result of subtracting *o2* from *o1*, or "NULL" on + * failure. This is the equivalent of the Python expression "o1 - + * o2". + */ +expect fun PyNumber_Subtract(o1: NativePointer, o2: NativePointer): NativePointer? + +/** + * *Return value: New reference.* + * *Part of the Stable ABI.* + * + * Returns the result of multiplying *o1* and *o2*, or "NULL" on + * failure. This is the equivalent of the Python expression "o1 * + * o2". + */ +expect fun PyNumber_Multiply(o1: NativePointer, o2: NativePointer): NativePointer? + +/** + * *Return value: New reference.* + * *Part of the Stable ABI since version 3.7.* + * + * Returns the result of matrix multiplication on *o1* and *o2*, or + * "NULL" on failure. This is the equivalent of the Python expression + * "o1 @ o2". + * + * Added in version 3.5. + */ +expect fun PyNumber_MatrixMultiply(o1: NativePointer, o2: NativePointer): NativePointer? + +/** + * *Return value: New reference.* + * *Part of the Stable ABI.* + * + * Return the floor of *o1* divided by *o2*, or "NULL" on failure. + * This is the equivalent of the Python expression "o1 // o2". + */ +expect fun PyNumber_FloorDivide(o1: NativePointer, o2: NativePointer): NativePointer? + +/** + * *Return value: New reference.* + * *Part of the Stable ABI.* + * + * Return a reasonable approximation for the mathematical value of + * *o1* divided by *o2*, or "NULL" on failure. The return value is + * “approximate” because binary floating-point numbers are + * approximate; it is not possible to represent all real numbers in + * base two. This function can return a floating-point value when + * passed two integers. This is the equivalent of the Python + * expression "o1 / o2". + */ +expect fun PyNumber_TrueDivide(o1: NativePointer, o2: NativePointer): NativePointer? + +/** + * *Return value: New reference.* + * *Part of the Stable ABI.* + * + * Returns the remainder of dividing *o1* by *o2*, or "NULL" on + * failure. This is the equivalent of the Python expression "o1 % + * o2". + */ +expect fun PyNumber_Remainder(o1: NativePointer, o2: NativePointer): NativePointer? + +/** + * *Return value: New reference.* + * *Part of the Stable ABI.* + * + * See the built-in function "divmod()". Returns "NULL" on failure. + * This is the equivalent of the Python expression "divmod(o1, o2)". + */ +expect fun PyNumber_Divmod(o1: NativePointer, o2: NativePointer): NativePointer? + +/** + * *Return value: New reference.* + * *Part of the Stable ABI.* + * + * See the built-in function "pow()". Returns "NULL" on failure. This + * is the equivalent of the Python expression "pow(o1, o2, o3)", where + * *o3* is optional. If *o3* is to be ignored, pass "Py_None" in its + * place (passing "NULL" for *o3* would cause an illegal memory + * access). + */ +expect fun PyNumber_Power(o1: NativePointer, o2: NativePointer, o3: NativePointer): NativePointer? + +/** + * *Return value: New reference.* + * *Part of the Stable ABI.* + * + * Returns the negation of *o* on success, or "NULL" on failure. This + * is the equivalent of the Python expression "-o". + */ +expect fun PyNumber_Negative(o: NativePointer): NativePointer? + +/** + * *Return value: New reference.* + * *Part of the Stable ABI.* + * + * Returns *o* on success, or "NULL" on failure. This is the + * equivalent of the Python expression "+o". + */ +expect fun PyNumber_Positive(o: NativePointer): NativePointer? + +/** + * *Return value: New reference.* + * *Part of the Stable ABI.* + * + * Returns the absolute value of *o*, or "NULL" on failure. This is + * the equivalent of the Python expression "abs(o)". + */ +expect fun PyNumber_Absolute(o: NativePointer): NativePointer? + +/** + * *Return value: New reference.* + * *Part of the Stable ABI.* + * + * Returns the bitwise negation of *o* on success, or "NULL" on + * failure. This is the equivalent of the Python expression "~o". + */ +expect fun PyNumber_Invert(o: NativePointer): NativePointer? + +/** + * *Return value: New reference.* + * *Part of the Stable ABI.* + * + * Returns the result of left shifting *o1* by *o2* on success, or + * "NULL" on failure. This is the equivalent of the Python expression + * "o1 << o2". + */ +expect fun PyNumber_Lshift(o1: NativePointer, o2: NativePointer): NativePointer? + +/** + * *Return value: New reference.* + * *Part of the Stable ABI.* + * + * Returns the result of right shifting *o1* by *o2* on success, or + * "NULL" on failure. This is the equivalent of the Python expression + * "o1 >> o2". + */ +expect fun PyNumber_Rshift(o1: NativePointer, o2: NativePointer): NativePointer? + +/** + * *Return value: New reference.* + * *Part of the Stable ABI.* + * + * Returns the “bitwise and” of *o1* and *o2* on success and "NULL" on + * failure. This is the equivalent of the Python expression "o1 & o2". + */ +expect fun PyNumber_And(o1: NativePointer, o2: NativePointer): NativePointer? + +/** + * *Return value: New reference.* + * *Part of the Stable ABI.* + * + * Returns the “bitwise exclusive or” of *o1* by *o2* on success, or + * "NULL" on failure. This is the equivalent of the Python expression + * "o1 ^ o2". + */ +expect fun PyNumber_Xor(o1: NativePointer, o2: NativePointer): NativePointer? + +/** + * *Return value: New reference.* + * *Part of the Stable ABI.* + * + * Returns the “bitwise or” of *o1* and *o2* on success, or "NULL" on + * failure. This is the equivalent of the Python expression "o1 | o2". + */ +expect fun PyNumber_Or(o1: NativePointer, o2: NativePointer): NativePointer? + +/** + * *Return value: New reference.* + * *Part of the Stable ABI.* + * + * Returns the result of adding *o1* and *o2*, or "NULL" on failure. + * The operation is done *in-place* when *o1* supports it. This is + * the equivalent of the Python statement "o1 += o2". + */ +expect fun PyNumber_InPlaceAdd(o1: NativePointer, o2: NativePointer): NativePointer? + +/** + * *Return value: New reference.* + * *Part of the Stable ABI.* + * + * Returns the result of subtracting *o2* from *o1*, or "NULL" on + * failure. The operation is done *in-place* when *o1* supports it. + * This is the equivalent of the Python statement "o1 -= o2". + */ +expect fun PyNumber_InPlaceSubtract(o1: NativePointer, o2: NativePointer): NativePointer? + +/** + * *Return value: New reference.* + * *Part of the Stable ABI.* + * + * Returns the result of multiplying *o1* and *o2*, or "NULL" on + * failure. The operation is done *in-place* when *o1* supports it. + * This is the equivalent of the Python statement "o1 *= o2". + */ +expect fun PyNumber_InPlaceMultiply(o1: NativePointer, o2: NativePointer): NativePointer? + +/** + * *Return value: New reference.* + * *Part of the Stable ABI since version 3.7.* + * + * Returns the result of matrix multiplication on *o1* and *o2*, or + * "NULL" on failure. The operation is done *in-place* when *o1* + * supports it. This is the equivalent of the Python statement "o1 @= + * o2". + * + * Added in version 3.5. + */ +expect fun PyNumber_InPlaceMatrixMultiply(o1: NativePointer, o2: NativePointer): NativePointer? + +/** + * *Return value: New reference.* + * *Part of the Stable ABI.* + * + * Returns the mathematical floor of dividing *o1* by *o2*, or "NULL" + * on failure. The operation is done *in-place* when *o1* supports it. + * This is the equivalent of the Python statement "o1 //= o2". + */ +expect fun PyNumber_InPlaceFloorDivide(o1: NativePointer, o2: NativePointer): NativePointer? + +/** + * *Return value: New reference.* + * *Part of the Stable ABI.* + * + * Return a reasonable approximation for the mathematical value of + * *o1* divided by *o2*, or "NULL" on failure. The return value is + * “approximate” because binary floating-point numbers are + * approximate; it is not possible to represent all real numbers in + * base two. This function can return a floating-point value when + * passed two integers. The operation is done *in-place* when *o1* + * supports it. This is the equivalent of the Python statement "o1 /= + * o2". + */ +expect fun PyNumber_InPlaceTrueDivide(o1: NativePointer, o2: NativePointer): NativePointer? + +/** + * *Return value: New reference.* + * *Part of the Stable ABI.* + * + * Returns the remainder of dividing *o1* by *o2*, or "NULL" on + * failure. The operation is done *in-place* when *o1* supports it. + * This is the equivalent of the Python statement "o1 %= o2". + */ +expect fun PyNumber_InPlaceRemainder(o1: NativePointer, o2: NativePointer): NativePointer? + +/** + * *Return value: New reference.* + * *Part of the Stable ABI.* + * + * See the built-in function "pow()". Returns "NULL" on failure. The + * operation is done *in-place* when *o1* supports it. This is the + * equivalent of the Python statement "o1 **= o2" when o3 is + * "Py_None", or an in-place variant of "pow(o1, o2, o3)" otherwise. + * If *o3* is to be ignored, pass "Py_None" in its place (passing + * "NULL" for *o3* would cause an illegal memory access). + */ +expect fun PyNumber_InPlacePower(o1: NativePointer, o2: NativePointer, o3: NativePointer): NativePointer? + +/** + * *Return value: New reference.* + * *Part of the Stable ABI.* + * + * Returns the result of left shifting *o1* by *o2* on success, or + * "NULL" on failure. The operation is done *in-place* when *o1* + * supports it. This is the equivalent of the Python statement "o1 + * <<= o2". + */ +expect fun PyNumber_InPlaceLshift(o1: NativePointer, o2: NativePointer): NativePointer? + +/** + * *Return value: New reference.* + * *Part of the Stable ABI.* + * + * Returns the result of right shifting *o1* by *o2* on success, or + * "NULL" on failure. The operation is done *in-place* when *o1* + * supports it. This is the equivalent of the Python statement "o1 + * >>= o2". + */ +expect fun PyNumber_InPlaceRshift(o1: NativePointer, o2: NativePointer): NativePointer? + +/** + * *Return value: New reference.* + * *Part of the Stable ABI.* + * + * Returns the “bitwise and” of *o1* and *o2* on success and "NULL" on + * failure. The operation is done *in-place* when *o1* supports it. + * This is the equivalent of the Python statement "o1 &= o2". + */ +expect fun PyNumber_InPlaceAnd(o1: NativePointer, o2: NativePointer): NativePointer? + +/** + * *Return value: New reference.* + * *Part of the Stable ABI.* + * + * Returns the “bitwise exclusive or” of *o1* by *o2* on success, or + * "NULL" on failure. The operation is done *in-place* when *o1* + * supports it. This is the equivalent of the Python statement "o1 ^= + * o2". + */ +expect fun PyNumber_InPlaceXor(o1: NativePointer, o2: NativePointer): NativePointer? + +/** + * *Return value: New reference.* + * *Part of the Stable ABI.* + * + * Returns the “bitwise or” of *o1* and *o2* on success, or "NULL" on + * failure. The operation is done *in-place* when *o1* supports it. + * This is the equivalent of the Python statement "o1 |= o2". + */ +expect fun PyNumber_InPlaceOr(o1: NativePointer, o2: NativePointer): NativePointer? + +/** + * *Return value: New reference.* + * *Part of the Stable ABI.* + * + * Returns the *o* converted to an integer object on success, or + * "NULL" on failure. This is the equivalent of the Python expression + * "int(o)". + */ +expect fun PyNumber_Long(o: NativePointer): NativePointer? + +/** + * *Return value: New reference.* + * *Part of the Stable ABI.* + * + * Returns the *o* converted to a float object on success, or "NULL" + * on failure. This is the equivalent of the Python expression + * "float(o)". + */ +expect fun PyNumber_Float(o: NativePointer): NativePointer? + +/** + * *Return value: New reference.* + * *Part of the Stable ABI.* + * + * Returns the *o* converted to a Python int on success or "NULL" with + * a "TypeError" exception raised on failure. + * + * Changed in version 3.10: The result always has exact type "int". + * Previously, the result could have been an instance of a subclass of + * "int". + */ +expect fun PyNumber_Index(o: NativePointer): NativePointer? + +/** + * *Return value: New reference.* + * *Part of the Stable ABI.* + * + * Returns the integer *n* converted to base *base* as a string. The + * *base* argument must be one of 2, 8, 10, or 16. For base 2, 8, or + * 16, the returned string is prefixed with a base marker of "'0b'", + * "'0o'", or "'0x'", respectively. If *n* is not a Python int, it is + * converted with "PyNumber_Index()" first. + */ +expect fun PyNumber_ToBase(n: NativePointer, base: Int): NativePointer? + +/** + * *Part of the Stable ABI since version 3.8.* + * + * Returns "1" if *o* is an index integer (has the "nb_index" slot of + * the "tp_as_number" structure filled in), and "0" otherwise. This + */ +expect inline fun PyIndex_Check(o: NativePointer): Int + + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// Section 13 +// Sequence Protocol +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/** + * *Part of the Stable ABI.* + * + * Return "1" if the object provides the sequence protocol, and "0" + * otherwise. Note that it returns "1" for Python classes with a + * "__getitem__()" method, unless they are "dict" subclasses, since in + * general it is impossible to determine what type of keys the class + * supports. This function always succeeds. + */ +expect inline fun PySequence_Check(o: NativePointer): Int + +/** + * *Return value: New reference.* + * *Part of the Stable ABI.* + * + * Return the concatenation of *o1* and *o2* on success, and "NULL" on + * failure. This is the equivalent of the Python expression "o1 + o2". + */ +expect fun PySequence_Concat(o1: NativePointer, o2: NativePointer): NativePointer? + +/** + * *Return value: New reference.* + * *Part of the Stable ABI.* + * + * Return the concatenation of *o1* and *o2* on success, and "NULL" on + * failure. The operation is done *in-place* when *o1* supports it. + * This is the equivalent of the Python expression "o1 += o2". + */ +expect fun PySequence_InPlaceConcat(o1: NativePointer, o2: NativePointer): NativePointer? + +/** + * *Part of the Stable ABI.* + * + * Determine if *o* contains *value*. If an item in *o* is equal to + * *value*, return "1", otherwise return "0". On error, return "-1". + * This is equivalent to the Python expression "value in o". + */ +expect inline fun PySequence_Contains(o: NativePointer, value: NativePointer): Int + +/** + * *Return value: New reference.* + * *Part of the Stable ABI.* + * + * Return a list object with the same contents as the sequence or + * iterable *o*, or "NULL" on failure. The returned list is + * guaranteed to be new. This is equivalent to the Python expression + * "list(o)". + */ +expect fun PySequence_List(o: NativePointer): NativePointer? + +/** + * *Return value: New reference.* + * *Part of the Stable ABI.* + * + * Return a tuple object with the same contents as the sequence or + * iterable *o*, or "NULL" on failure. If *o* is a tuple, a new + * reference will be returned, otherwise a tuple will be constructed + * with the appropriate contents. This is equivalent to the Python + * expression "tuple(o)". + */ +expect fun PySequence_Tuple(o: NativePointer): NativePointer? + +/** + * *Return value: New reference.* + * *Part of the Stable ABI.* + * + * Return the sequence or iterable *o* as an object usable by the + * other "PySequence_Fast*" family of functions. If the object is not + * a sequence or iterable, raises "TypeError" with *m* as the message + * text. Returns "NULL" on failure. + * + * The "PySequence_Fast*" functions are thus named because they assume + * *o* is a "PyTupleObject" or a "PyListObject" and access the data + * fields of *o* directly. + * + * As a CPython implementation detail, if *o* is already a sequence or + * list, it will be returned. + */ +expect fun PySequence_Fast(o: NativePointer, m: String): NativePointer? + + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// Section 14 +// Mapping Protocol +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/** + * *Part of the Stable ABI.* + * + * Return "1" if the object provides the mapping protocol or supports + * slicing, and "0" otherwise. Note that it returns "1" for Python + * classes with a "__getitem__()" method, since in general it is + * impossible to determine what type of keys the class supports. This + * function always succeeds. + */ +expect inline fun PyMapping_Check(o: NativePointer): Int + +/** + * *Return value: New reference.* + * *Part of the Stable ABI.* + * + * This is the same as "PyObject_GetItem()", but *key* is specified as + * a const char* UTF-8 encoded bytes string, rather than a PyObject*. + */ +expect fun PyMapping_GetItemString(o: NativePointer, key: String): NativePointer? + +/** + * *Part of the Stable ABI.* + * + * This is the same as "PyObject_SetItem()", but *key* is specified as + * a const char* UTF-8 encoded bytes string, rather than a PyObject*. + */ +expect inline fun PyMapping_SetItemString(o: NativePointer, key: String, v: NativePointer): Int + +/** + * *Part of the Stable ABI since version 3.13.* + * + * Return "1" if the mapping object has the key *key* and "0" + * otherwise. This is equivalent to the Python expression "key in o". + * On failure, return "-1". + * + * Added in version 3.13. + */ +expect inline fun PyMapping_HasKeyWithError(o: NativePointer, key: NativePointer): Int + +/** + * *Part of the Stable ABI since version 3.13.* + * + * This is the same as "PyMapping_HasKeyWithError()", but *key* is + * specified as a const char* UTF-8 encoded bytes string, rather than + * a PyObject*. + * + * Added in version 3.13. + */ +expect inline fun PyMapping_HasKeyStringWithError(o: NativePointer, key: String): Int + +/** + * *Part of the Stable ABI.* + * + * Return "1" if the mapping object has the key *key* and "0" + * otherwise. This is equivalent to the Python expression "key in o". + * This function always succeeds. + * + * Note: + * + * Exceptions which occur when this calls "__getitem__()" method are + * silently ignored. For proper error handling, use + * "PyMapping_HasKeyWithError()", "PyMapping_GetOptionalItem()" or + * "PyObject_GetItem()" instead. + */ +expect inline fun PyMapping_HasKey(o: NativePointer, key: NativePointer): Int + +/** + * *Part of the Stable ABI.* + * + * This is the same as "PyMapping_HasKey()", but *key* is specified as + * a const char* UTF-8 encoded bytes string, rather than a PyObject*. + * + * Note: + * + * Exceptions that occur when this calls "__getitem__()" method or + * while creating the temporary "str" object are silently ignored. + * For proper error handling, use + * "PyMapping_HasKeyStringWithError()", + * "PyMapping_GetOptionalItemString()" or + * "PyMapping_GetItemString()" instead. + */ +expect inline fun PyMapping_HasKeyString(o: NativePointer, key: String): Int + +/** + * *Return value: New reference.* + * *Part of the Stable ABI.* + * + * On success, return a list of the keys in object *o*. On failure, + * return "NULL". + * + * Changed in version 3.7: Previously, the function returned a list or + * a tuple. + */ +expect fun PyMapping_Keys(o: NativePointer): NativePointer? + +/** + * *Return value: New reference.* + * *Part of the Stable ABI.* + * + * On success, return a list of the values in object *o*. On failure, + * return "NULL". + * + * Changed in version 3.7: Previously, the function returned a list or + * a tuple. + */ +expect fun PyMapping_Values(o: NativePointer): NativePointer? + +/** + * *Return value: New reference.* + * *Part of the Stable ABI.* + * + * On success, return a list of the items in object *o*, where each + * item is a tuple containing a key-value pair. On failure, return + * "NULL". + * + * Changed in version 3.7: Previously, the function returned a list or + */ +expect fun PyMapping_Items(o: NativePointer): NativePointer? + + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// Section 15 +// Iterator Protocol +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/** + * *Part of the Stable ABI since version 3.8.* + * + * Return non-zero if the object *o* can be safely passed to + * "PyIter_Next()", and "0" otherwise. This function always succeeds. + */ +expect inline fun PyIter_Check(o: NativePointer): Int + +/** + * *Part of the Stable ABI since version 3.10.* + * + * Return non-zero if the object *o* provides the "AsyncIterator" + * protocol, and "0" otherwise. This function always succeeds. + * + * Added in version 3.10. + */ +expect inline fun PyAIter_Check(o: NativePointer): Int + +/** + * *Return value: New reference.* + * *Part of the Stable ABI.* + * + * Return the next value from the iterator *o*. The object must be an + * iterator according to "PyIter_Check()" (it is up to the caller to + * check this). If there are no remaining values, returns "NULL" with + * no exception set. If an error occurs while retrieving the item, + * returns "NULL" and passes along the exception. + */ +expect fun PyIter_Next(o: NativePointer): NativePointer? + + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// Section 16 +// Integer Objects +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/** + * *Return value: New reference.* + * *Part of the Stable ABI.* + * + * Return a new "PyLongObject" object from a C long long, or "NULL" on + * failure. + */ +expect fun PyLong_FromLongLong(v: Long): NativePointer? + +/** + * *Return value: New reference.* + * *Part of the Stable ABI.* + * + * Return a new "PyLongObject" object from the integer part of *v*, or + * "NULL" on failure. + */ +expect fun PyLong_FromDouble(v: Double): NativePointer? + +/** + * *Part of the Stable ABI since version 3.13.* + * + * Similar to "PyLong_AsLong()", but store the result in a C int + * instead of a C long. + * + * Added in version 3.13. + */ +expect inline fun PyLong_AsInt(obj: NativePointer): Int + +/** + * *Part of the Stable ABI.* + * + * Return a C long long representation of *obj*. If *obj* is not an + * instance of "PyLongObject", first call its "__index__()" method (if + * present) to convert it to a "PyLongObject". + * + * Raise "OverflowError" if the value of *obj* is out of range for a + * long long. + * + * Returns "-1" on error. Use "PyErr_Occurred()" to disambiguate. + * + * Changed in version 3.8: Use "__index__()" if available. + * + * Changed in version 3.10: This function will no longer use + * "__int__()". + */ +expect inline fun PyLong_AsLongLong(obj: NativePointer): Long + +/** + * *Part of the Stable ABI.* + * + * Return a C double representation of *pylong*. *pylong* must be an + * instance of "PyLongObject". + * + * Raise "OverflowError" if the value of *pylong* is out of range for + * a double. + * + * Returns "-1.0" on error. Use "PyErr_Occurred()" to disambiguate. + */ +expect inline fun PyLong_AsDouble(pylong: NativePointer): Double + +/** + * *Part of the Stable ABI.* + * + * On success, return a read only *named tuple*, that holds + * information about Python’s internal representation of integers. See + * "sys.int_info" for description of individual fields. + * + * On failure, return "NULL" with an exception set. + * + * Added in version 3.1. + */ +expect fun PyLong_GetInfo(): NativePointer? + + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// Section 17 +// Boolean Objects +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/** + * *Return value: New reference.* + * *Part of the Stable ABI.* + * + * Return "Py_True" or "Py_False", depending on the truth value of + */ +expect fun PyBool_FromLong(v: Int): NativePointer? + + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// Section 18 +// Floating-Point Objects +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/** + * *Return value: New reference.* + * *Part of the Stable ABI.* + * + * Create a "PyFloatObject" object based on the string value in *str*, + * or "NULL" on failure. + */ +expect fun PyFloat_FromString(str: NativePointer): NativePointer? + +/** + * *Return value: New reference.* + * *Part of the Stable ABI.* + * + * Create a "PyFloatObject" object from *v*, or "NULL" on failure. + */ +expect fun PyFloat_FromDouble(v: Double): NativePointer? + +/** + * *Part of the Stable ABI.* + * + * Return a C double representation of the contents of *pyfloat*. If + * *pyfloat* is not a Python floating-point object but has a + * "__float__()" method, this method will first be called to convert + * *pyfloat* into a float. If "__float__()" is not defined then it + * falls back to "__index__()". This method returns "-1.0" upon + * failure, so one should call "PyErr_Occurred()" to check for errors. + * + * Changed in version 3.8: Use "__index__()" if available. + */ +expect inline fun PyFloat_AsDouble(pyfloat: NativePointer): Double + +/** + * *Return value: New reference.* + * *Part of the Stable ABI.* + * + * Return a structseq instance which contains information about the + * precision, minimum and maximum values of a float. It’s a thin + * wrapper around the header file "float.h". + */ +expect fun PyFloat_GetInfo(): NativePointer? + +/** + * *Part of the Stable ABI.* + * + * Return the maximum representable finite float *DBL_MAX* as C + * double. + */ +expect inline fun PyFloat_GetMax(): Double + +/** + * *Part of the Stable ABI.* + * + * Return the minimum normalized positive float *DBL_MIN* as C double. + */ +expect inline fun PyFloat_GetMin(): Double + + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// Section 19 +// Bytes Objects +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/** + * *Return value: New reference.* + * *Part of the Stable ABI.* + * + * Return a new bytes object with a copy of the string *v* as value on + * success, and "NULL" on failure. The parameter *v* must not be + * "NULL"; it will not be checked. + */ +expect fun PyBytes_FromString(v: String): NativePointer? + +/** + * *Return value: New reference.* + * *Part of the Stable ABI.* + * + * Return the bytes representation of object *o* that implements the + * buffer protocol. + */ +expect fun PyBytes_FromObject(o: NativePointer): NativePointer? + +/** + * *Part of the Stable ABI.* + * + * Return a pointer to the contents of *o*. The pointer refers to the + * internal buffer of *o*, which consists of "len(o) + 1" bytes. The + * last byte in the buffer is always null, regardless of whether there + * are any other null bytes. The data must not be modified in any + * way, unless the object was just created using + * "PyBytes_FromStringAndSize(NULL, size)". It must not be + * deallocated. If *o* is not a bytes object at all, + * "PyBytes_AsString()" returns "NULL" and raises "TypeError". + */ +expect inline fun PyBytes_AsString(o: NativePointer): String? + + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// Section 20 +// Byte Array Objects +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/** + * *Return value: New reference.* + * *Part of the Stable ABI.* + * + * Return a new bytearray object from any object, *o*, that implements + * the buffer protocol. + * + * On failure, return "NULL" with an exception set. + */ +expect fun PyByteArray_FromObject(o: NativePointer): NativePointer? + +/** + * *Return value: New reference.* + * *Part of the Stable ABI.* + * + * Concat bytearrays *a* and *b* and return a new bytearray with the + * result. + * + * On failure, return "NULL" with an exception set. + */ +expect fun PyByteArray_Concat(a: NativePointer, b: NativePointer): NativePointer? + +/** + * *Part of the Stable ABI.* + * + * Return the contents of *bytearray* as a char array after checking + * for a "NULL" pointer. The returned array always has an extra null + * byte appended. + */ +expect inline fun PyByteArray_AsString(bytearray: NativePointer): String? + + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// Section 21 +// Unicode Objects and Codecs +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/** + * *Part of the Stable ABI.* + * + * Return "1" if the string is a valid identifier according to the + * language definition, section Identifiers and keywords. Return "0" + * otherwise. + * + * Changed in version 3.9: The function does not call + * "Py_FatalError()" anymore if the string is not ready. + */ +expect inline fun PyUnicode_IsIdentifier(unicode: NativePointer): Int + +/** + * *Return value: New reference.* + * *Part of the Stable ABI.* + * + * Create a Unicode object from a UTF-8 encoded null-terminated char + * buffer *str*. + */ +expect fun PyUnicode_FromString(str: String): NativePointer? + +/** + * *Return value: New reference.* + * *Part of the Stable ABI.* + * + * Copy an instance of a Unicode subtype to a new true Unicode object + * if necessary. If *obj* is already a true Unicode object (not a + * subtype), return a new *strong reference* to the object. + * + * Objects other than Unicode or its subtypes will cause a + * "TypeError". + */ +expect fun PyUnicode_FromObject(obj: NativePointer): NativePointer? + +/** + * *Return value: New reference.* + * *Part of the Stable ABI.* + * + * Decode an encoded object *obj* to a Unicode object. + * + * "bytes", "bytearray" and other *bytes-like objects* are decoded + * according to the given *encoding* and using the error handling + * defined by *errors*. Both can be "NULL" to have the interface use + * the default values (see Built-in Codecs for details). + * + * All other objects, including Unicode objects, cause a "TypeError" + * to be set. + * + * The API returns "NULL" if there was an error. The caller is + * responsible for decref’ing the returned objects. + */ +expect fun PyUnicode_FromEncodedObject(obj: NativePointer, encoding: String, errors: String): NativePointer? + +/** + * *Return value: New reference.* + * *Part of the Stable ABI since version 3.7.* + * + * Similar to "PyUnicode_DecodeLocaleAndSize()", but compute the + * string length using "strlen()". + * + * Added in version 3.3. + */ +expect fun PyUnicode_DecodeLocale(str: String, errors: String): NativePointer? + +/** + * *Return value: New reference.* + * *Part of the Stable ABI since version 3.7.* + * + * Encode a Unicode object to UTF-8 on Android and VxWorks, or to the + * current locale encoding on other platforms. The supported error + * handlers are ""strict"" and ""surrogateescape"" (**PEP 383**). The + * encoder uses ""strict"" error handler if *errors* is "NULL". Return + * a "bytes" object. *unicode* cannot contain embedded null + * characters. + * + * Use "PyUnicode_EncodeFSDefault()" to encode a string to the + * *filesystem encoding and error handler*. + * + * This function ignores the Python UTF-8 Mode. + * + * See also: The "Py_EncodeLocale()" function. + * + * Added in version 3.3. + * + * Changed in version 3.7: The function now also uses the current + * locale encoding for the "surrogateescape" error handler, except on + * Android. Previously, "Py_EncodeLocale()" was used for the + * "surrogateescape", and the current locale encoding was used for + * "strict". + */ +expect fun PyUnicode_EncodeLocale(unicode: NativePointer, errors: String): NativePointer? + +/** + * *Return value: New reference.* + * *Part of the Stable ABI.* + * + * Decode a null-terminated string from the *filesystem encoding and + * error handler*. + * + * If the string length is known, use + * "PyUnicode_DecodeFSDefaultAndSize()". + * + * Changed in version 3.6: The *filesystem error handler* is now used. + */ +expect fun PyUnicode_DecodeFSDefault(str: String): NativePointer? + +/** + * *Return value: New reference.* + * *Part of the Stable ABI.* + * + * Encode a Unicode object to the *filesystem encoding and error + * handler*, and return "bytes". Note that the resulting "bytes" + * object can contain null bytes. + * + * If you need to encode a string to the current locale encoding, use + * "PyUnicode_EncodeLocale()". + * + * See also: The "Py_EncodeLocale()" function. + * + * Added in version 3.2. + * + * Changed in version 3.6: The *filesystem error handler* is now used. + */ +expect fun PyUnicode_EncodeFSDefault(unicode: NativePointer): NativePointer? + +/** + * *Return value: New reference.* + * *Part of the Stable ABI.* + * + * Encode a Unicode object and return the result as Python bytes + * object. *encoding* and *errors* have the same meaning as the + * parameters of the same name in the Unicode "encode()" method. The + * codec to be used is looked up using the Python codec registry. + * Return "NULL" if an exception was raised by the codec. + */ +expect fun PyUnicode_AsEncodedString(unicode: NativePointer, encoding: String, errors: String): NativePointer? + +/** + * *Return value: New reference.* + * *Part of the Stable ABI.* + * + * Encode a Unicode object using UTF-8 and return the result as Python + * bytes object. Error handling is “strict”. Return "NULL" if an + * exception was raised by the codec. + * + * The function fails if the string contains surrogate code points + * ("U+D800" - "U+DFFF"). + */ +expect fun PyUnicode_AsUTF8String(unicode: NativePointer): NativePointer? + +/** + * As "PyUnicode_AsUTF8AndSize()", but does not store the size. + * + * Added in version 3.3. + * + * Changed in version 3.7: The return type is now "const char *" + * rather of "char *". + */ +expect inline fun PyUnicode_AsUTF8(unicode: NativePointer): String? // 수동 추가 + +/** + * *Return value: New reference.* + * *Part of the Stable ABI.* + * + * Return a Python byte string using the UTF-32 encoding in native + * byte order. The string always starts with a BOM mark. Error + * handling is “strict”. Return "NULL" if an exception was raised by + * the codec. + */ +expect fun PyUnicode_AsUTF32String(unicode: NativePointer): NativePointer? + +/** + * *Return value: New reference.* + * *Part of the Stable ABI.* + * + * Return a Python byte string using the UTF-16 encoding in native + * byte order. The string always starts with a BOM mark. Error + * handling is “strict”. Return "NULL" if an exception was raised by + * the codec. + */ +expect fun PyUnicode_AsUTF16String(unicode: NativePointer): NativePointer? + +/** + * *Return value: New reference.* + * *Part of the Stable ABI.* + * + * Encode a Unicode object using Unicode-Escape and return the result + * as a bytes object. Error handling is “strict”. Return "NULL" if + * an exception was raised by the codec. + */ +expect fun PyUnicode_AsUnicodeEscapeString(unicode: NativePointer): NativePointer? + +/** + * *Return value: New reference.* + * *Part of the Stable ABI.* + * + * Encode a Unicode object using Raw-Unicode-Escape and return the + * result as a bytes object. Error handling is “strict”. Return + * "NULL" if an exception was raised by the codec. + */ +expect fun PyUnicode_AsRawUnicodeEscapeString(unicode: NativePointer): NativePointer? + +/** + * *Return value: New reference.* + * *Part of the Stable ABI.* + * + * Encode a Unicode object using Latin-1 and return the result as + * Python bytes object. Error handling is “strict”. Return "NULL" if + * an exception was raised by the codec. + */ +expect fun PyUnicode_AsLatin1String(unicode: NativePointer): NativePointer? + +/** + * *Return value: New reference.* + * *Part of the Stable ABI.* + * + * Encode a Unicode object using ASCII and return the result as Python + * bytes object. Error handling is “strict”. Return "NULL" if an + * exception was raised by the codec. + */ +expect fun PyUnicode_AsASCIIString(unicode: NativePointer): NativePointer? + +/** + * *Return value: New reference.* + * *Part of the Stable ABI.* + * + * Encode a Unicode object using the given *mapping* object and return + * the result as a bytes object. Error handling is “strict”. Return + * "NULL" if an exception was raised by the codec. + * + * The *mapping* object must map Unicode ordinal integers to bytes + * objects, integers in the range from 0 to 255 or "None". Unmapped + * character ordinals (ones which cause a "LookupError") as well as + * mapped to "None" are treated as “undefined mapping” and cause an + * error. + */ +expect fun PyUnicode_AsCharmapString(unicode: NativePointer, mapping: NativePointer): NativePointer? + +/** + * *Return value: New reference.* + * *Part of the Stable ABI.* + * + * Translate a string by applying a character mapping table to it and + * return the resulting Unicode object. Return "NULL" if an exception + * was raised by the codec. + * + * The mapping table must map Unicode ordinal integers to Unicode + * ordinal integers or "None" (causing deletion of the character). + * + * Mapping tables need only provide the "__getitem__()" interface; + * dictionaries and sequences work well. Unmapped character ordinals + * (ones which cause a "LookupError") are left untouched and are + * copied as-is. + * + * *errors* has the usual meaning for codecs. It may be "NULL" which + * indicates to use the default error handling. + */ +expect fun PyUnicode_Translate(unicode: NativePointer, table: NativePointer, errors: String): NativePointer? + +/** + * *Return value: New reference.* + * *Part of the Stable ABI.* + * + * Concat two strings giving a new Unicode string. + */ +expect fun PyUnicode_Concat(left: NativePointer, right: NativePointer): NativePointer? + +/** + * *Return value: New reference.* + * *Part of the Stable ABI.* + * + * Split a Unicode string at line breaks, returning a list of Unicode + * strings. CRLF is considered to be one line break. If *keepends* is + * "0", the Line break characters are not included in the resulting + * strings. + */ +expect fun PyUnicode_Splitlines(unicode: NativePointer, keepends: Int): NativePointer? + +/** + * *Return value: New reference.* + * *Part of the Stable ABI.* + * + * Join a sequence of strings using the given *separator* and return + * the resulting Unicode string. + */ +expect fun PyUnicode_Join(separator: NativePointer, seq: NativePointer): NativePointer? + +/** + * *Part of the Stable ABI.* + * + * Compare two strings and return "-1", "0", "1" for less than, equal, + * and greater than, respectively. + * + * This function returns "-1" upon failure, so one should call + * "PyErr_Occurred()" to check for errors. + */ +expect inline fun PyUnicode_Compare(left: NativePointer, right: NativePointer): Int + +/** + * *Part of the Stable ABI since version 3.13.* + * + * Similar to "PyUnicode_EqualToUTF8AndSize()", but compute *string* + * length using "strlen()". If the Unicode object contains null + * characters, false ("0") is returned. + * + * Added in version 3.13. + */ +expect inline fun PyUnicode_EqualToUTF8(unicode: NativePointer, string: String): Int + +/** + * *Part of the Stable ABI.* + * + * Compare a Unicode object, *unicode*, with *string* and return "-1", + * "0", "1" for less than, equal, and greater than, respectively. It + * is best to pass only ASCII-encoded strings, but the function + * interprets the input string as ISO-8859-1 if it contains non-ASCII + * characters. + * + * This function does not raise exceptions. + */ +expect inline fun PyUnicode_CompareWithASCIIString(unicode: NativePointer, string: String): Int + +/** + * *Return value: New reference.* + * *Part of the Stable ABI.* + * + * Rich compare two Unicode strings and return one of the following: + * + * * "NULL" in case an exception was raised + * + * * "Py_True" or "Py_False" for successful comparisons + * + * * "Py_NotImplemented" in case the type combination is unknown + * + * Possible values for *op* are "Py_GT", "Py_GE", "Py_EQ", "Py_NE", + * "Py_LT", and "Py_LE". + */ +expect fun PyUnicode_RichCompare(left: NativePointer, right: NativePointer, op: Int): NativePointer? + +/** + * *Return value: New reference.* + * *Part of the Stable ABI.* + * + * Return a new string object from *format* and *args*; this is + * analogous to "format % args". + */ +expect fun PyUnicode_Format(format: NativePointer, args: NativePointer): NativePointer? + +/** + * *Part of the Stable ABI.* + * + * Check whether *substr* is contained in *unicode* and return true or + * false accordingly. + * + * *substr* has to coerce to a one element Unicode string. "-1" is + * returned if there was an error. + */ +expect inline fun PyUnicode_Contains(unicode: NativePointer, substr: NativePointer): Int + +/** + * *Return value: New reference.* + * *Part of the Stable ABI.* + * + * A combination of "PyUnicode_FromString()" and + * "PyUnicode_InternInPlace()", meant for statically allocated + * strings. + * + * Return a new (“owned”) reference to either a new Unicode string + * object that has been interned, or an earlier interned string object + * with the same value. + * + * Python may keep a reference to the result, or make it *immortal*, + * preventing it from being garbage-collected promptly. For interning + * an unbounded number of different strings, such as ones coming from + * user input, prefer calling "PyUnicode_FromString()" and + * "PyUnicode_InternInPlace()" directly. + * + * **CPython implementation detail:** Strings interned this way are + */ +expect fun PyUnicode_InternFromString(str: String): NativePointer? + + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// Section 22 +// List Objects +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/** + * *Part of the Stable ABI.* + * + * Append the object *item* at the end of list *list*. Return "0" if + * successful; return "-1" and set an exception if unsuccessful. + * Analogous to "list.append(item)". + */ +expect inline fun PyList_Append(list: NativePointer, item: NativePointer): Int + +/** + * *Part of the Stable ABI.* + * + * Sort the items of *list* in place. Return "0" on success, "-1" on + * failure. This is equivalent to "list.sort()". + */ +expect inline fun PyList_Sort(list: NativePointer): Int + +/** + * *Part of the Stable ABI.* + * + * Reverse the items of *list* in place. Return "0" on success, "-1" + * on failure. This is the equivalent of "list.reverse()". + */ +expect inline fun PyList_Reverse(list: NativePointer): Int + +/** + * *Return value: New reference.* + * *Part of the Stable ABI.* + * + * Return a new tuple object containing the contents of *list*; + */ +expect fun PyList_AsTuple(list: NativePointer): NativePointer? + + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// Section 23 +// Dictionary Objects +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/** + * *Return value: New reference.* + * *Part of the Stable ABI.* + * + * Return a new empty dictionary, or "NULL" on failure. + */ +expect fun PyDict_New(): NativePointer? + +/** + * *Return value: New reference.* + * *Part of the Stable ABI.* + * + * Return a "types.MappingProxyType" object for a mapping which + * enforces read-only behavior. This is normally used to create a + * view to prevent modification of the dictionary for non-dynamic + * class types. + */ +expect fun PyDictProxy_New(mapping: NativePointer): NativePointer? + +/** + * *Part of the Stable ABI.* + * + * Empty an existing dictionary of all key-value pairs. + */ +expect inline fun PyDict_Clear(p: NativePointer) + +/** + * *Part of the Stable ABI.* + * + * Determine if dictionary *p* contains *key*. If an item in *p* is + * matches *key*, return "1", otherwise return "0". On error, return + * "-1". This is equivalent to the Python expression "key in p". + */ +expect inline fun PyDict_Contains(p: NativePointer, key: NativePointer): Int + +/** + * *Return value: New reference.* + * *Part of the Stable ABI.* + * + * Return a new dictionary that contains the same key-value pairs as + * *p*. + */ +expect fun PyDict_Copy(p: NativePointer): NativePointer? + +/** + * *Part of the Stable ABI.* + * + * Insert *val* into the dictionary *p* with a key of *key*. *key* + * must be *hashable*; if it isn’t, "TypeError" will be raised. Return + * "0" on success or "-1" on failure. This function *does not* steal + * a reference to *val*. + */ +expect inline fun PyDict_SetItem(p: NativePointer, key: NativePointer, v: NativePointer): Int + +/** + * *Part of the Stable ABI.* + * + * This is the same as "PyDict_SetItem()", but *key* is specified as a + * const char* UTF-8 encoded bytes string, rather than a PyObject*. + */ +expect inline fun PyDict_SetItemString(p: NativePointer, key: String, v: NativePointer): Int + +/** + * *Part of the Stable ABI.* + * + * Remove the entry in dictionary *p* with key *key*. *key* must be + * *hashable*; if it isn’t, "TypeError" is raised. If *key* is not in + * the dictionary, "KeyError" is raised. Return "0" on success or "-1" + * on failure. + */ +expect inline fun PyDict_DelItem(p: NativePointer, key: NativePointer): Int + +/** + * *Part of the Stable ABI.* + * + * This is the same as "PyDict_DelItem()", but *key* is specified as a + * const char* UTF-8 encoded bytes string, rather than a PyObject*. + */ +expect inline fun PyDict_DelItemString(p: NativePointer, key: String): Int + +/** + * *Return value: Borrowed reference.* + * *Part of the Stable ABI.* + * + * Return a *borrowed reference* to the object from dictionary *p* + * which has a key *key*. Return "NULL" if the key *key* is missing + * *without* setting an exception. + * + * Note: + * + * Exceptions that occur while this calls "__hash__()" and + * "__eq__()" methods are silently ignored. Prefer the + * "PyDict_GetItemWithError()" function instead. + * + * Changed in version 3.10: Calling this API without *GIL* held had + * been allowed for historical reason. It is no longer allowed. + */ +expect fun PyDict_GetItem(p: NativePointer, key: NativePointer): NativePointer? + +/** + * *Return value: Borrowed reference.* + * *Part of the Stable ABI.* + * + * Variant of "PyDict_GetItem()" that does not suppress exceptions. + * Return "NULL" **with** an exception set if an exception occurred. + * Return "NULL" **without** an exception set if the key wasn’t + * present. + */ +expect fun PyDict_GetItemWithError(p: NativePointer, key: NativePointer): NativePointer? + +/** + * *Return value: Borrowed reference.* + * *Part of the Stable ABI.* + * + * This is the same as "PyDict_GetItem()", but *key* is specified as a + * const char* UTF-8 encoded bytes string, rather than a PyObject*. + * + * Note: + * + * Exceptions that occur while this calls "__hash__()" and + * "__eq__()" methods or while creating the temporary "str" object + * are silently ignored. Prefer using the + * "PyDict_GetItemWithError()" function with your own + * "PyUnicode_FromString()" *key* instead. + */ +expect fun PyDict_GetItemString(p: NativePointer, key: String): NativePointer? + +/** + * *Return value: New reference.* + * *Part of the Stable ABI.* + * + * Return a "PyListObject" containing all the items from the + * dictionary. + */ +expect fun PyDict_Items(p: NativePointer): NativePointer? + +/** + * *Return value: New reference.* + * *Part of the Stable ABI.* + * + * Return a "PyListObject" containing all the keys from the + * dictionary. + */ +expect fun PyDict_Keys(p: NativePointer): NativePointer? + +/** + * *Return value: New reference.* + * *Part of the Stable ABI.* + * + * Return a "PyListObject" containing all the values from the + * dictionary *p*. + */ +expect fun PyDict_Values(p: NativePointer): NativePointer? + +/** + * *Part of the Stable ABI.* + * + * Iterate over mapping object *b* adding key-value pairs to + * dictionary *a*. *b* may be a dictionary, or any object supporting + * "PyMapping_Keys()" and "PyObject_GetItem()". If *override* is true, + * existing pairs in *a* will be replaced if a matching key is found + * in *b*, otherwise pairs will only be added if there is not a + * matching key in *a*. Return "0" on success or "-1" if an exception + * was raised. + */ +expect inline fun PyDict_Merge(a: NativePointer, b: NativePointer, override: Int): Int + +/** + * *Part of the Stable ABI.* + * + * This is the same as "PyDict_Merge(a, b, 1)" in C, and is similar to + * "a.update(b)" in Python except that "PyDict_Update()" doesn’t fall + * back to the iterating over a sequence of key value pairs if the + * second argument has no “keys” attribute. Return "0" on success or + * "-1" if an exception was raised. + */ +expect inline fun PyDict_Update(a: NativePointer, b: NativePointer): Int + +/** + * *Part of the Stable ABI.* + * + * Update or merge into dictionary *a*, from the key-value pairs in + * *seq2*. *seq2* must be an iterable object producing iterable + * objects of length 2, viewed as key-value pairs. In case of + * duplicate keys, the last wins if *override* is true, else the first + * wins. Return "0" on success or "-1" if an exception was raised. + * Equivalent Python (except for the return value): + * + * def PyDict_MergeFromSeq2(a, seq2, override): + * for key, value in seq2: + * if override or key not in a: + * a[key] = value + */ +expect inline fun PyDict_MergeFromSeq2(a: NativePointer, seq2: NativePointer, override: Int): Int + + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// Section 24 +// Set Objects +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/** + * *Return value: New reference.* + * *Part of the Stable ABI.* + * + * Return a new "set" containing objects returned by the *iterable*. + * The *iterable* may be "NULL" to create a new empty set. Return the + * new set on success or "NULL" on failure. Raise "TypeError" if + * *iterable* is not actually iterable. The constructor is also + * useful for copying a set ("c=set(s)"). + */ +expect fun PySet_New(iterable: NativePointer): NativePointer? + +/** + * *Return value: New reference.* + * *Part of the Stable ABI.* + * + * Return a new "frozenset" containing objects returned by the + * *iterable*. The *iterable* may be "NULL" to create a new empty + * frozenset. Return the new set on success or "NULL" on failure. + * Raise "TypeError" if *iterable* is not actually iterable. + */ +expect fun PyFrozenSet_New(iterable: NativePointer): NativePointer? + +/** + * *Part of the Stable ABI.* + * + * Return "1" if found, "0" if not found, and "-1" if an error is + * encountered. Unlike the Python "__contains__()" method, this + * function does not automatically convert unhashable sets into + * temporary frozensets. Raise a "TypeError" if the *key* is + * unhashable. Raise "SystemError" if *anyset* is not a "set", + * "frozenset", or an instance of a subtype. + */ +expect inline fun PySet_Contains(anyset: NativePointer, key: NativePointer): Int + +/** + * *Part of the Stable ABI.* + * + * Add *key* to a "set" instance. Also works with "frozenset" + * instances (like "PyTuple_SetItem()" it can be used to fill in the + * values of brand new frozensets before they are exposed to other + * code). Return "0" on success or "-1" on failure. Raise a + * "TypeError" if the *key* is unhashable. Raise a "MemoryError" if + * there is no room to grow. Raise a "SystemError" if *set* is not an + * instance of "set" or its subtype. + */ +expect inline fun PySet_Add(set: NativePointer, key: NativePointer): Int + +/** + * *Part of the Stable ABI.* + * + * Return "1" if found and removed, "0" if not found (no action + * taken), and "-1" if an error is encountered. Does not raise + * "KeyError" for missing keys. Raise a "TypeError" if the *key* is + * unhashable. Unlike the Python "discard()" method, this function + * does not automatically convert unhashable sets into temporary + * frozensets. Raise "SystemError" if *set* is not an instance of + * "set" or its subtype. + */ +expect inline fun PySet_Discard(set: NativePointer, key: NativePointer): Int + +/** + * *Return value: New reference.* + * *Part of the Stable ABI.* + * + * Return a new reference to an arbitrary object in the *set*, and + * removes the object from the *set*. Return "NULL" on failure. + * Raise "KeyError" if the set is empty. Raise a "SystemError" if + * *set* is not an instance of "set" or its subtype. + */ +expect fun PySet_Pop(set: NativePointer): NativePointer? + +/** + * *Part of the Stable ABI.* + * + * Empty an existing set of all elements. Return "0" on success. + * Return "-1" and raise "SystemError" if *set* is not an instance of + */ +expect inline fun PySet_Clear(set: NativePointer): Int + + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// Section 25 +// Iterator Objects +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/** + * *Return value: New reference.* + * *Part of the Stable ABI.* + * + * Return an iterator that works with a general sequence object, + * *seq*. The iteration ends when the sequence raises "IndexError" + * for the subscripting operation. + */ +expect fun PySeqIter_New(seq: NativePointer): NativePointer? + +/** + * *Return value: New reference.* + * *Part of the Stable ABI.* + * + * Return a new iterator. The first parameter, *callable*, can be any + * Python callable object that can be called with no parameters; each + * call to it should return the next item in the iteration. When + * *callable* returns a value equal to *sentinel*, the iteration will + */ +expect fun PyCallIter_New(callable: NativePointer, sentinel: NativePointer): NativePointer? + + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// Section 26 +// Weak Reference Objects +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/** + * *Return value: New reference.* + * *Part of the Stable ABI.* + * + * Return a weak reference object for the object *ob*. This will + * always return a new reference, but is not guaranteed to create a + * new object; an existing reference object may be returned. The + * second parameter, *callback*, can be a callable object that + * receives notification when *ob* is garbage collected; it should + * accept a single parameter, which will be the weak reference object + * itself. *callback* may also be "None" or "NULL". If *ob* is not a + * weakly referenceable object, or if *callback* is not callable, + * "None", or "NULL", this will return "NULL" and raise "TypeError". + */ +expect fun PyWeakref_NewRef(ob: NativePointer, callback: NativePointer): NativePointer? + +/** + * *Return value: New reference.* + * *Part of the Stable ABI.* + * + * Return a weak reference proxy object for the object *ob*. This + * will always return a new reference, but is not guaranteed to create + * a new object; an existing proxy object may be returned. The second + * parameter, *callback*, can be a callable object that receives + * notification when *ob* is garbage collected; it should accept a + * single parameter, which will be the weak reference object itself. + * *callback* may also be "None" or "NULL". If *ob* is not a weakly + * referenceable object, or if *callback* is not callable, "None", or + * "NULL", this will return "NULL" and raise "TypeError". + */ +expect fun PyWeakref_NewProxy(ob: NativePointer, callback: NativePointer): NativePointer? + +/** + * *Return value: Borrowed reference.* + * *Part of the Stable ABI.* + * + * Return a *borrowed reference* to the referenced object from a weak + * reference, *ref*. If the referent is no longer live, returns + * "Py_None". + * + * Note: + * + * This function returns a *borrowed reference* to the referenced + * object. This means that you should always call "Py_INCREF()" on + * the object except when it cannot be destroyed before the last + * usage of the borrowed reference. + * + * Deprecated since version 3.13, will be removed in version 3.15: Use + * "PyWeakref_GetRef()" instead. + */ +expect fun PyWeakref_GetObject(ref: NativePointer): NativePointer? + +/** + * *Part of the Stable ABI.* + * + * This function is called by the "tp_dealloc" handler to clear weak + * references. + * + * This iterates through the weak references for *object* and calls + * callbacks for those references which have one. It returns when all + * callbacks have been attempted. + */ +expect inline fun PyObject_ClearWeakRefs(o: NativePointer) + + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// Section 27 +// Type Objects +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/** + * *Part of the Stable ABI.* + * + * Return true if *a* is a subtype of *b*. + * + * This function only checks for actual subtypes, which means that + * "__subclasscheck__()" is not called on *b*. Call + * "PyObject_IsSubclass()" to do the same check that "issubclass()" + * would do. + */ +expect inline fun PyType_IsSubtype(a: NativePointer, b: NativePointer): Int + +/** + * *Part of the Stable ABI.* + * + * Finalize a type object. This should be called on all type objects + * to finish their initialization. This function is responsible for + * adding inherited slots from a type’s base class. Return "0" on + * success, or return "-1" and sets an exception on error. + * + * Note: + * + * If some of the base classes implements the GC protocol and the + * provided type does not include the "Py_TPFLAGS_HAVE_GC" in its + * flags, then the GC protocol will be automatically implemented + * from its parents. On the contrary, if the type being created does + * include "Py_TPFLAGS_HAVE_GC" in its flags then it **must** + * implement the GC protocol itself by at least implementing the + * "tp_traverse" handle. +*/ +expect inline fun PyType_Ready(type: NativePointer): Int + +/** + * *Return value: New reference.* + * *Part of the Stable ABI since version 3.11.* + * + * Return the type’s name. Equivalent to getting the type’s "__name__" + * attribute. + * + * Added in version 3.11. + */ +expect fun PyType_GetName(type: NativePointer): NativePointer? + +/** + * *Part of the Stable ABI since version 3.13.* + * + * Return the type’s fully qualified name. Equivalent to + * "f"{type.__module__}.{type.__qualname__}"", or "type.__qualname__" + * if "type.__module__" is not a string or is equal to ""builtins"". + * + * Added in version 3.13. + */ +expect fun PyType_GetFullyQualifiedName(type: NativePointer): NativePointer? + +/** + * *Part of the Stable ABI since version 3.13.* + * + * Return the type’s module name. Equivalent to getting the + * "type.__module__" attribute. + * + * Added in version 3.13. + */ +expect fun PyType_GetModuleName(type: NativePointer): NativePointer? + +/** + * *Part of the Stable ABI since version 3.10.* + * + * Return the module object associated with the given type when the + * type was created using "PyType_FromModuleAndSpec()". + * + * If no module is associated with the given type, sets "TypeError" + * and returns "NULL". + * + * This function is usually used to get the module in which a method + * is defined. Note that in such a method, + * "PyType_GetModule(Py_TYPE(self))" may not return the intended + * result. "Py_TYPE(self)" may be a *subclass* of the intended class, + * and subclasses are not necessarily defined in the same module as + * their superclass. See "PyCMethod" to get the class that defines the + * method. See "PyType_GetModuleByDef()" for cases when "PyCMethod" + * cannot be used. + * + * Added in version 3.9. + */ +expect fun PyType_GetModule(type: NativePointer): NativePointer? + + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// Section 28 +// Tuple Objects +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// TODO: Section 27, 28은 필요에 의해 추가된 Section이므로 순서 재정렬 하기 +expect fun PyTuple_New(len: Long): NativePointer? +expect inline fun PyTuple_Size(p: NativePointer): Long +expect fun PyTuple_GetItem(p: NativePointer, pos: Long): NativePointer? +expect fun PyTuple_GetSlice(p: NativePointer, low: Long, high: Long): NativePointer? +expect inline fun PyTuple_SetItem(p: NativePointer, pos: Long, o: NativePointer): Int // diff --git a/python-multiplatform/src/desktopMain/kotlin/python/multiplatform/ffi/PyObject.desktop.kt b/python-multiplatform/src/desktopMain/kotlin/python/multiplatform/ffi/PyObject.desktop.kt deleted file mode 100644 index 902bd053..00000000 --- a/python-multiplatform/src/desktopMain/kotlin/python/multiplatform/ffi/PyObject.desktop.kt +++ /dev/null @@ -1,6 +0,0 @@ -package python.multiplatform.ffi - -import python.native.ffi.NativePointer - - -actual open class PyObject actual constructor(actual override val pointer: NativePointer, borrowed: Boolean): PyObjectAutoCloseable(pointer, borrowed) diff --git a/python-multiplatform/src/jvmMain/kotlin/python/multiplatform/ffi/PyObject.jvm.kt b/python-multiplatform/src/desktopMain/kotlin/python/multiplatform/ref/PyAutoCloseable.desktop.kt similarity index 58% rename from python-multiplatform/src/jvmMain/kotlin/python/multiplatform/ffi/PyObject.jvm.kt rename to python-multiplatform/src/desktopMain/kotlin/python/multiplatform/ref/PyAutoCloseable.desktop.kt index 4d8c22f8..c50e63b1 100644 --- a/python-multiplatform/src/jvmMain/kotlin/python/multiplatform/ffi/PyObject.jvm.kt +++ b/python-multiplatform/src/desktopMain/kotlin/python/multiplatform/ref/PyAutoCloseable.desktop.kt @@ -1,15 +1,17 @@ -package python.multiplatform.ffi +package python.multiplatform.ref import python.native.ffi.NativePointer import java.lang.ref.Cleaner -abstract class PyObjectAutoCloseable(open val pointer: NativePointer, borrowed: Boolean): AutoCloseable { +actual abstract class PyAutoCloseable actual constructor(pointer: NativePointer): AutoCloseable { private val cleaner = Cleaner.create() private val cleanable: Cleaner.Cleanable = cleaner.register(this) { - //PyDecRef(this.pointer) + clean() } + actual abstract fun clean() + override fun close() { cleanable.clean() } diff --git a/python-multiplatform/src/desktopMain/kotlin/python/native/ffi/EmbedAPI.desktop.kt b/python-multiplatform/src/desktopMain/kotlin/python/native/ffi/EmbedAPI.desktop.kt index 0ad4a925..f44d98a5 100644 --- a/python-multiplatform/src/desktopMain/kotlin/python/native/ffi/EmbedAPI.desktop.kt +++ b/python-multiplatform/src/desktopMain/kotlin/python/native/ffi/EmbedAPI.desktop.kt @@ -29,6 +29,7 @@ actual fun Long.toNativePointer(): NativePointer? = MemoryAddress.ofLong(this).t internal inline fun MemoryAddress?.toNativePointer(): NativePointer? = this?.let { NativePointer(it) } +/** // Section 1 actual inline fun Py_Initialize() = python.native.ffi.bindings.Py_Initialize() actual inline fun Py_InitializeEx(initsigs: Int) = python.native.ffi.bindings.Py_InitializeEx(initsigs) @@ -68,3 +69,383 @@ actual fun PyUnicode_FromString(str: String): NativePointer? = python.native.ffi.bindings.PyUnicode_FromString(str).toNativePointer() actual inline fun PyUnicode_AsUTF8(unicode: NativePointer): String? = python.native.ffi.bindings.PyUnicode_AsUTF8(unicode.toPlatformPointer()) +*/ + + +//************************************************** +// Section 1 +actual inline fun Py_Initialize() = python.native.ffi.bindings.Py_Initialize() +actual inline fun Py_InitializeEx(initsigs: Int) = python.native.ffi.bindings.Py_InitializeEx(initsigs) +actual inline fun Py_IsInitialized(): Int = python.native.ffi.bindings.Py_IsInitialized() +actual inline fun Py_IsFinalizing(): Int = python.native.ffi.bindings.Py_IsFinalizing() +actual inline fun Py_FinalizeEx(): Int = python.native.ffi.bindings.Py_FinalizeEx() +actual inline fun Py_Finalize() = python.native.ffi.bindings.Py_Finalize() +// actual inline fun Py_BytesMain(argc: Int, argv: List): Int // 수동 추가 +actual inline fun Py_RunMain(): Int = python.native.ffi.bindings.Py_RunMain() // 수동 추가 +actual inline fun Py_GetVersion(): String? = python.native.ffi.bindings.Py_GetVersion() +actual inline fun Py_GetPlatform(): String? = python.native.ffi.bindings.Py_GetPlatform() +actual inline fun Py_GetCopyright(): String? = python.native.ffi.bindings.Py_GetCopyright() +actual inline fun Py_GetCompiler(): String? = python.native.ffi.bindings.Py_GetCompiler() +actual inline fun Py_GetBuildInfo(): String? = python.native.ffi.bindings.Py_GetBuildInfo() +actual inline fun PyEval_InitThreads() = python.native.ffi.bindings.PyEval_InitThreads() +actual fun PyThreadState_GetDict(): NativePointer? = python.native.ffi.bindings.PyThreadState_GetDict().toNativePointer() + + +// Section 2 +actual inline fun PyRun_SimpleString(command: String): Int = python.native.ffi.bindings.PyRun_SimpleString(command) // 수동 추가 +actual fun PyRun_String(str: String, start: Int, globals: NativePointer, locals: NativePointer): NativePointer? = python.native.ffi.bindings.PyRun_String(str, start, globals.toPlatformPointer(), locals.toPlatformPointer()).toNativePointer() // 수동 추가 +actual fun Py_CompileString(str: String, filename: String, start: Int): NativePointer? = python.native.ffi.bindings.Py_CompileString(str, filename, start).toNativePointer() +actual fun PyEval_EvalCode(co: NativePointer, globals: NativePointer, locals: NativePointer): NativePointer? = python.native.ffi.bindings.PyEval_EvalCode(co.toPlatformPointer(), globals.toPlatformPointer(), locals.toPlatformPointer()).toNativePointer() + + +// Section 3 +actual inline fun PyErr_Clear() = python.native.ffi.bindings.PyErr_Clear() +actual inline fun PyErr_PrintEx(set_sys_last_vars: Int) = python.native.ffi.bindings.PyErr_PrintEx(set_sys_last_vars) +actual inline fun PyErr_Print() = python.native.ffi.bindings.PyErr_Print() +actual inline fun PyErr_WriteUnraisable(obj: NativePointer) = python.native.ffi.bindings.PyErr_WriteUnraisable(obj.toPlatformPointer()) +actual inline fun PyErr_DisplayException(exc: NativePointer) = python.native.ffi.bindings.PyErr_DisplayException(exc.toPlatformPointer()) +actual inline fun PyErr_SetString(type: NativePointer, message: String) = python.native.ffi.bindings.PyErr_SetString(type.toPlatformPointer(), message) +actual inline fun PyErr_SetObject(type: NativePointer, value: NativePointer) = python.native.ffi.bindings.PyErr_SetObject(type.toPlatformPointer(), value.toPlatformPointer()) +actual inline fun PyErr_SetNone(type: NativePointer) = python.native.ffi.bindings.PyErr_SetNone(type.toPlatformPointer()) +actual inline fun PyErr_BadArgument(): Int = python.native.ffi.bindings.PyErr_BadArgument() +actual fun PyErr_NoMemory(): NativePointer? = python.native.ffi.bindings.PyErr_NoMemory().toNativePointer() +actual fun PyErr_SetFromErrno(type: NativePointer): NativePointer? = python.native.ffi.bindings.PyErr_SetFromErrno(type.toPlatformPointer()).toNativePointer() +actual fun PyErr_SetFromErrnoWithFilenameObject(type: NativePointer, filenameObject: NativePointer): NativePointer? = python.native.ffi.bindings.PyErr_SetFromErrnoWithFilenameObject(type.toPlatformPointer(), filenameObject.toPlatformPointer()).toNativePointer() +actual fun PyErr_SetFromErrnoWithFilenameObjects(type: NativePointer, filenameObject: NativePointer, filenameObject2: NativePointer): NativePointer? = python.native.ffi.bindings.PyErr_SetFromErrnoWithFilenameObjects(type.toPlatformPointer(), filenameObject.toPlatformPointer(), filenameObject2.toPlatformPointer()).toNativePointer() +actual fun PyErr_SetFromErrnoWithFilename(type: NativePointer, filename: String): NativePointer? = python.native.ffi.bindings.PyErr_SetFromErrnoWithFilename(type.toPlatformPointer(), filename).toNativePointer() +actual fun PyErr_SetImportError(msg: NativePointer, name: NativePointer, path: NativePointer): NativePointer? = python.native.ffi.bindings.PyErr_SetImportError(msg.toPlatformPointer(), name.toPlatformPointer(), path.toPlatformPointer()).toNativePointer() +actual fun PyErr_SetImportErrorSubclass(exception: NativePointer, msg: NativePointer, name: NativePointer, path: NativePointer): NativePointer? = python.native.ffi.bindings.PyErr_SetImportErrorSubclass(exception.toPlatformPointer(), msg.toPlatformPointer(), name.toPlatformPointer(), path.toPlatformPointer()).toNativePointer() +actual inline fun PyErr_SyntaxLocationEx(filename: String, lineno: Int, col_offset: Int) = python.native.ffi.bindings.PyErr_SyntaxLocationEx(filename, lineno, col_offset) +actual inline fun PyErr_SyntaxLocation(filename: String, lineno: Int) = python.native.ffi.bindings.PyErr_SyntaxLocation(filename, lineno) +actual inline fun PyErr_BadInternalCall() = python.native.ffi.bindings.PyErr_BadInternalCall() +actual inline fun PyErr_WarnExplicit(category: NativePointer, message: String, filename: String, lineno: Int, module: String, registry: NativePointer): Int = python.native.ffi.bindings.PyErr_WarnExplicit(category.toPlatformPointer(), message, filename, lineno, module, registry.toPlatformPointer()) +actual fun PyErr_Occurred(): NativePointer? = python.native.ffi.bindings.PyErr_Occurred().toNativePointer() +actual inline fun PyErr_ExceptionMatches(exc: NativePointer): Int = python.native.ffi.bindings.PyErr_ExceptionMatches(exc.toPlatformPointer()) +actual inline fun PyErr_GivenExceptionMatches(given: NativePointer, exc: NativePointer): Int = python.native.ffi.bindings.PyErr_GivenExceptionMatches(given.toPlatformPointer(), exc.toPlatformPointer()) +actual fun PyErr_GetRaisedException(): NativePointer? = python.native.ffi.bindings.PyErr_GetRaisedException().toNativePointer() +actual inline fun PyErr_SetRaisedException(exc: NativePointer) = python.native.ffi.bindings.PyErr_SetRaisedException(exc.toPlatformPointer()) +actual inline fun PyErr_Restore(type: NativePointer, value: NativePointer, traceback: NativePointer) = python.native.ffi.bindings.PyErr_Restore(type.toPlatformPointer(), value.toPlatformPointer(), traceback.toPlatformPointer()) +actual fun PyErr_GetHandledException(): NativePointer? = python.native.ffi.bindings.PyErr_GetHandledException().toNativePointer() +actual inline fun PyErr_SetHandledException(exc: NativePointer) = python.native.ffi.bindings.PyErr_SetHandledException(exc.toPlatformPointer()) +actual inline fun PyErr_SetExcInfo(type: NativePointer, value: NativePointer, traceback: NativePointer) = python.native.ffi.bindings.PyErr_SetExcInfo(type.toPlatformPointer(), value.toPlatformPointer(), traceback.toPlatformPointer()) +actual inline fun PyErr_CheckSignals(): Int = python.native.ffi.bindings.PyErr_CheckSignals() +actual inline fun PyErr_SetInterrupt() = python.native.ffi.bindings.PyErr_SetInterrupt() +actual inline fun PyErr_SetInterruptEx(signum: Int): Int = python.native.ffi.bindings.PyErr_SetInterruptEx(signum) +actual fun PyErr_NewException(name: String, base: NativePointer, dict: NativePointer): NativePointer? = python.native.ffi.bindings.PyErr_NewException(name, base.toPlatformPointer(), dict.toPlatformPointer()).toNativePointer() +actual fun PyErr_NewExceptionWithDoc(name: String, doc: String, base: NativePointer, dict: NativePointer): NativePointer? = python.native.ffi.bindings.PyErr_NewExceptionWithDoc(name, doc, base.toPlatformPointer(), dict.toPlatformPointer()).toNativePointer() +actual fun PyException_GetTraceback(ex: NativePointer): NativePointer? = python.native.ffi.bindings.PyException_GetTraceback(ex.toPlatformPointer()).toNativePointer() +actual inline fun PyException_SetTraceback(ex: NativePointer, tb: NativePointer): Int = python.native.ffi.bindings.PyException_SetTraceback(ex.toPlatformPointer(), tb.toPlatformPointer()) +actual fun PyException_GetContext(ex: NativePointer): NativePointer? = python.native.ffi.bindings.PyException_GetContext(ex.toPlatformPointer()).toNativePointer() +actual inline fun PyException_SetContext(ex: NativePointer, ctx: NativePointer) = python.native.ffi.bindings.PyException_SetContext(ex.toPlatformPointer(), ctx.toPlatformPointer()) +actual fun PyException_GetCause(ex: NativePointer): NativePointer? = python.native.ffi.bindings.PyException_GetCause(ex.toPlatformPointer()).toNativePointer() +actual inline fun PyException_SetCause(ex: NativePointer, cause: NativePointer) = python.native.ffi.bindings.PyException_SetCause(ex.toPlatformPointer(), cause.toPlatformPointer()) +actual fun PyException_GetArgs(ex: NativePointer): NativePointer? = python.native.ffi.bindings.PyException_GetArgs(ex.toPlatformPointer()).toNativePointer() +actual inline fun PyException_SetArgs(ex: NativePointer, args: NativePointer) = python.native.ffi.bindings.PyException_SetArgs(ex.toPlatformPointer(), args.toPlatformPointer()) +actual fun PyUnicodeEncodeError_GetEncoding(exc: NativePointer): NativePointer? = python.native.ffi.bindings.PyUnicodeEncodeError_GetEncoding(exc.toPlatformPointer()).toNativePointer() +actual fun PyUnicodeTranslateError_GetObject(exc: NativePointer): NativePointer? = python.native.ffi.bindings.PyUnicodeTranslateError_GetObject(exc.toPlatformPointer()).toNativePointer() +actual fun PyUnicodeTranslateError_GetReason(exc: NativePointer): NativePointer? = python.native.ffi.bindings.PyUnicodeTranslateError_GetReason(exc.toPlatformPointer()).toNativePointer() +actual inline fun PyUnicodeTranslateError_SetReason(exc: NativePointer, reason: String): Int = python.native.ffi.bindings.PyUnicodeTranslateError_SetReason(exc.toPlatformPointer(), reason) +actual inline fun Py_EnterRecursiveCall(where: String): Int = python.native.ffi.bindings.Py_EnterRecursiveCall(where) +actual inline fun Py_LeaveRecursiveCall() = python.native.ffi.bindings.Py_LeaveRecursiveCall() +actual inline fun Py_ReprEnter(o: NativePointer): Int = python.native.ffi.bindings.Py_ReprEnter(o.toPlatformPointer()) +actual inline fun Py_ReprLeave(o: NativePointer) = python.native.ffi.bindings.Py_ReprLeave(o.toPlatformPointer()) + + +// Section 4 +actual fun Py_NewRef(o: NativePointer): NativePointer? = python.native.ffi.bindings.Py_NewRef(o.toPlatformPointer()).toNativePointer() +actual fun Py_XNewRef(o: NativePointer): NativePointer? = python.native.ffi.bindings.Py_XNewRef(o.toPlatformPointer()).toNativePointer() +actual inline fun Py_IncRef(o: NativePointer) = python.native.ffi.bindings.Py_IncRef(o.toPlatformPointer()) +actual inline fun Py_DecRef(o: NativePointer) = python.native.ffi.bindings.Py_DecRef(o.toPlatformPointer()) + + +// Section 5 +actual fun PyOS_FSPath(path: NativePointer): NativePointer? = python.native.ffi.bindings.PyOS_FSPath(path.toPlatformPointer()).toNativePointer() + + +// Section 6 +actual fun PySys_GetObject(name: String): NativePointer? = python.native.ffi.bindings.PySys_GetObject(name).toNativePointer() +actual inline fun PySys_SetObject(name: String, v: NativePointer): Int = python.native.ffi.bindings.PySys_SetObject(name, v.toPlatformPointer()) +actual inline fun PySys_ResetWarnOptions() = python.native.ffi.bindings.PySys_ResetWarnOptions() +actual fun PySys_GetXOptions(): NativePointer? = python.native.ffi.bindings.PySys_GetXOptions().toNativePointer() +actual inline fun PySys_AuditTuple(event: String, args: NativePointer): Int = python.native.ffi.bindings.PySys_AuditTuple(event, args.toPlatformPointer()) + + +// Section 7 +actual inline fun Py_FatalError(message: String) = python.native.ffi.bindings.Py_FatalError(message) +actual inline fun Py_Exit(status: Int) = python.native.ffi.bindings.Py_Exit(status) + + +// Section 8 +actual fun PyImport_ImportModule(name: String): NativePointer? = python.native.ffi.bindings.PyImport_ImportModule(name).toNativePointer() +actual fun PyImport_ImportModuleNoBlock(name: String): NativePointer? = python.native.ffi.bindings.PyImport_ImportModuleNoBlock(name).toNativePointer() +actual fun PyImport_ImportModuleLevelObject(name: NativePointer, globals: NativePointer, locals: NativePointer, fromlist: NativePointer, level: Int): NativePointer? = python.native.ffi.bindings.PyImport_ImportModuleLevelObject(name.toPlatformPointer(), globals.toPlatformPointer(), locals.toPlatformPointer(), fromlist.toPlatformPointer(), level).toNativePointer() +actual fun PyImport_ImportModuleLevel(name: String, globals: NativePointer, locals: NativePointer, fromlist: NativePointer, level: Int): NativePointer? = python.native.ffi.bindings.PyImport_ImportModuleLevel(name, globals.toPlatformPointer(), locals.toPlatformPointer(), fromlist.toPlatformPointer(), level).toNativePointer() +actual fun PyImport_Import(name: NativePointer): NativePointer? = python.native.ffi.bindings.PyImport_Import(name.toPlatformPointer()).toNativePointer() +actual fun PyImport_ReloadModule(m: NativePointer): NativePointer? = python.native.ffi.bindings.PyImport_ReloadModule(m.toPlatformPointer()).toNativePointer() +actual fun PyImport_AddModuleRef(name: String): NativePointer? = python.native.ffi.bindings.PyImport_AddModuleRef(name).toNativePointer() +actual fun PyImport_AddModuleObject(name: NativePointer): NativePointer? = python.native.ffi.bindings.PyImport_AddModuleObject(name.toPlatformPointer()).toNativePointer() +actual fun PyImport_AddModule(name: String): NativePointer? = python.native.ffi.bindings.PyImport_AddModule(name).toNativePointer() +actual fun PyImport_ExecCodeModule(name: String, co: NativePointer): NativePointer? = python.native.ffi.bindings.PyImport_ExecCodeModule(name, co.toPlatformPointer()).toNativePointer() +actual fun PyImport_ExecCodeModuleEx(name: String, co: NativePointer, pathname: String): NativePointer? = python.native.ffi.bindings.PyImport_ExecCodeModuleEx(name, co.toPlatformPointer(), pathname).toNativePointer() +actual fun PyImport_ExecCodeModuleObject(name: NativePointer, co: NativePointer, pathname: NativePointer, cpathname: NativePointer): NativePointer? = python.native.ffi.bindings.PyImport_ExecCodeModuleObject(name.toPlatformPointer(), co.toPlatformPointer(), pathname.toPlatformPointer(), cpathname.toPlatformPointer()).toNativePointer() +actual fun PyImport_ExecCodeModuleWithPathnames(name: String, co: NativePointer, pathname: String, cpathname: String): NativePointer? = python.native.ffi.bindings.PyImport_ExecCodeModuleWithPathnames(name, co.toPlatformPointer(), pathname, cpathname).toNativePointer() +actual inline fun PyImport_GetMagicTag(): String? = python.native.ffi.bindings.PyImport_GetMagicTag() +actual fun PyImport_GetModuleDict(): NativePointer? = python.native.ffi.bindings.PyImport_GetModuleDict().toNativePointer() +actual fun PyImport_GetModule(name: NativePointer): NativePointer? = python.native.ffi.bindings.PyImport_GetModule(name.toPlatformPointer()).toNativePointer() +actual fun PyImport_GetImporter(path: NativePointer): NativePointer? = python.native.ffi.bindings.PyImport_GetImporter(path.toPlatformPointer()).toNativePointer() +actual inline fun PyImport_ImportFrozenModuleObject(name: NativePointer): Int = python.native.ffi.bindings.PyImport_ImportFrozenModuleObject(name.toPlatformPointer()) +actual inline fun PyImport_ImportFrozenModule(name: String): Int = python.native.ffi.bindings.PyImport_ImportFrozenModule(name) + + +// Section 9 +actual fun PyEval_GetBuiltins(): NativePointer? = python.native.ffi.bindings.PyEval_GetBuiltins().toNativePointer() +actual fun PyEval_GetLocals(): NativePointer? = python.native.ffi.bindings.PyEval_GetLocals().toNativePointer() +actual fun PyEval_GetGlobals(): NativePointer? = python.native.ffi.bindings.PyEval_GetGlobals().toNativePointer() +actual fun PyEval_GetFrameBuiltins(): NativePointer? = python.native.ffi.bindings.PyEval_GetFrameBuiltins().toNativePointer() +actual fun PyEval_GetFrameLocals(): NativePointer? = python.native.ffi.bindings.PyEval_GetFrameLocals().toNativePointer() +actual fun PyEval_GetFrameGlobals(): NativePointer? = python.native.ffi.bindings.PyEval_GetFrameGlobals().toNativePointer() +actual inline fun PyEval_GetFuncName(func: NativePointer): String? = python.native.ffi.bindings.PyEval_GetFuncName(func.toPlatformPointer()) +actual inline fun PyEval_GetFuncDesc(func: NativePointer): String? = python.native.ffi.bindings.PyEval_GetFuncDesc(func.toPlatformPointer()) + + +// Section 10 +actual inline fun PyObject_HasAttrWithError(o: NativePointer, attr_name: NativePointer): Int = python.native.ffi.bindings.PyObject_HasAttrWithError(o.toPlatformPointer(), attr_name.toPlatformPointer()) +actual inline fun PyObject_HasAttrStringWithError(o: NativePointer, attr_name: String): Int = python.native.ffi.bindings.PyObject_HasAttrStringWithError(o.toPlatformPointer(), attr_name) +actual inline fun PyObject_HasAttr(o: NativePointer, attr_name: NativePointer): Int = python.native.ffi.bindings.PyObject_HasAttr(o.toPlatformPointer(), attr_name.toPlatformPointer()) +actual inline fun PyObject_HasAttrString(o: NativePointer, attr_name: String): Int = python.native.ffi.bindings.PyObject_HasAttrString(o.toPlatformPointer(), attr_name) +actual fun PyObject_GetAttr(o: NativePointer, attr_name: NativePointer): NativePointer? = python.native.ffi.bindings.PyObject_GetAttr(o.toPlatformPointer(), attr_name.toPlatformPointer()).toNativePointer() +actual fun PyObject_GetAttrString(o: NativePointer, attr_name: String): NativePointer? = python.native.ffi.bindings.PyObject_GetAttrString(o.toPlatformPointer(), attr_name).toNativePointer() +actual fun PyObject_GenericGetAttr(o: NativePointer, name: NativePointer): NativePointer? = python.native.ffi.bindings.PyObject_GenericGetAttr(o.toPlatformPointer(), name.toPlatformPointer()).toNativePointer() +actual inline fun PyObject_SetAttr(o: NativePointer, attr_name: NativePointer, v: NativePointer): Int = python.native.ffi.bindings.PyObject_SetAttr(o.toPlatformPointer(), attr_name.toPlatformPointer(), v.toPlatformPointer()) +actual inline fun PyObject_SetAttrString(o: NativePointer, attr_name: String, v: NativePointer): Int = python.native.ffi.bindings.PyObject_SetAttrString(o.toPlatformPointer(), attr_name, v.toPlatformPointer()) +actual inline fun PyObject_GenericSetAttr(o: NativePointer, name: NativePointer, value: NativePointer): Int = python.native.ffi.bindings.PyObject_GenericSetAttr(o.toPlatformPointer(), name.toPlatformPointer(), value.toPlatformPointer()) +actual inline fun PyObject_DelAttr(o: NativePointer, attr_name: NativePointer): Int = python.native.ffi.bindings.PyObject_DelAttr(o.toPlatformPointer(), attr_name.toPlatformPointer()) +actual inline fun PyObject_DelAttrString(o: NativePointer, attr_name: String): Int = python.native.ffi.bindings.PyObject_DelAttrString(o.toPlatformPointer(), attr_name) +actual fun PyObject_RichCompare(o1: NativePointer, o2: NativePointer, opid: Int): NativePointer? = python.native.ffi.bindings.PyObject_RichCompare(o1.toPlatformPointer(), o2.toPlatformPointer(), opid).toNativePointer() +actual inline fun PyObject_RichCompareBool(o1: NativePointer, o2: NativePointer, opid: Int): Int = python.native.ffi.bindings.PyObject_RichCompareBool(o1.toPlatformPointer(), o2.toPlatformPointer(), opid) +actual fun PyObject_Format(obj: NativePointer, format_spec: NativePointer): NativePointer? = python.native.ffi.bindings.PyObject_Format(obj.toPlatformPointer(), format_spec.toPlatformPointer()).toNativePointer() +actual fun PyObject_Repr(o: NativePointer): NativePointer? = python.native.ffi.bindings.PyObject_Repr(o.toPlatformPointer()).toNativePointer() +actual fun PyObject_ASCII(o: NativePointer): NativePointer? = python.native.ffi.bindings.PyObject_ASCII(o.toPlatformPointer()).toNativePointer() +actual fun PyObject_Str(o: NativePointer): NativePointer? = python.native.ffi.bindings.PyObject_Str(o.toPlatformPointer()).toNativePointer() +actual fun PyObject_Bytes(o: NativePointer): NativePointer? = python.native.ffi.bindings.PyObject_Bytes(o.toPlatformPointer()).toNativePointer() +actual inline fun PyObject_IsSubclass(derived: NativePointer, cls: NativePointer): Int = python.native.ffi.bindings.PyObject_IsSubclass(derived.toPlatformPointer(), cls.toPlatformPointer()) +actual inline fun PyObject_IsInstance(inst: NativePointer, cls: NativePointer): Int = python.native.ffi.bindings.PyObject_IsInstance(inst.toPlatformPointer(), cls.toPlatformPointer()) +actual inline fun PyObject_IsTrue(o: NativePointer): Int = python.native.ffi.bindings.PyObject_IsTrue(o.toPlatformPointer()) +actual inline fun PyObject_Not(o: NativePointer): Int = python.native.ffi.bindings.PyObject_Not(o.toPlatformPointer()) +actual fun PyObject_Type(o: NativePointer): NativePointer? = python.native.ffi.bindings.PyObject_Type(o.toPlatformPointer()).toNativePointer() +actual fun PyObject_GetItem(o: NativePointer, key: NativePointer): NativePointer? = python.native.ffi.bindings.PyObject_GetItem(o.toPlatformPointer(), key.toPlatformPointer()).toNativePointer() +actual inline fun PyObject_SetItem(o: NativePointer, key: NativePointer, v: NativePointer): Int = python.native.ffi.bindings.PyObject_SetItem(o.toPlatformPointer(), key.toPlatformPointer(), v.toPlatformPointer()) +actual inline fun PyObject_DelItem(o: NativePointer, key: NativePointer): Int = python.native.ffi.bindings.PyObject_DelItem(o.toPlatformPointer(), key.toPlatformPointer()) +actual fun PyObject_Dir(o: NativePointer): NativePointer? = python.native.ffi.bindings.PyObject_Dir(o.toPlatformPointer()).toNativePointer() +actual fun PyObject_GetIter(o: NativePointer): NativePointer? = python.native.ffi.bindings.PyObject_GetIter(o.toPlatformPointer()).toNativePointer() +actual fun PyObject_GetAIter(o: NativePointer): NativePointer? = python.native.ffi.bindings.PyObject_GetAIter(o.toPlatformPointer()).toNativePointer() + + +// Section 11 +actual fun PyVectorcall_Call(callable: NativePointer, tuple: NativePointer, dict: NativePointer): NativePointer? = python.native.ffi.bindings.PyVectorcall_Call(callable.toPlatformPointer(), tuple.toPlatformPointer(), dict.toPlatformPointer()).toNativePointer() +actual fun PyObject_Call(callable: NativePointer, args: NativePointer, kwargs: NativePointer): NativePointer? = python.native.ffi.bindings.PyObject_Call(callable.toPlatformPointer(), args.toPlatformPointer(), kwargs.toPlatformPointer()).toNativePointer() +actual fun PyObject_CallNoArgs(callable: NativePointer): NativePointer? = python.native.ffi.bindings.PyObject_CallNoArgs(callable.toPlatformPointer()).toNativePointer() +actual fun PyObject_CallObject(callable: NativePointer, args: NativePointer): NativePointer? = python.native.ffi.bindings.PyObject_CallObject(callable.toPlatformPointer(), args.toPlatformPointer()).toNativePointer() +actual inline fun PyCallable_Check(o: NativePointer): Int = python.native.ffi.bindings.PyCallable_Check(o.toPlatformPointer()) + + +// Section 12 +actual inline fun PyNumber_Check(o: NativePointer): Int = python.native.ffi.bindings.PyNumber_Check(o.toPlatformPointer()) +actual fun PyNumber_Add(o1: NativePointer, o2: NativePointer): NativePointer? = python.native.ffi.bindings.PyNumber_Add(o1.toPlatformPointer(), o2.toPlatformPointer()).toNativePointer() +actual fun PyNumber_Subtract(o1: NativePointer, o2: NativePointer): NativePointer? = python.native.ffi.bindings.PyNumber_Subtract(o1.toPlatformPointer(), o2.toPlatformPointer()).toNativePointer() +actual fun PyNumber_Multiply(o1: NativePointer, o2: NativePointer): NativePointer? = python.native.ffi.bindings.PyNumber_Multiply(o1.toPlatformPointer(), o2.toPlatformPointer()).toNativePointer() +actual fun PyNumber_MatrixMultiply(o1: NativePointer, o2: NativePointer): NativePointer? = python.native.ffi.bindings.PyNumber_MatrixMultiply(o1.toPlatformPointer(), o2.toPlatformPointer()).toNativePointer() +actual fun PyNumber_FloorDivide(o1: NativePointer, o2: NativePointer): NativePointer? = python.native.ffi.bindings.PyNumber_FloorDivide(o1.toPlatformPointer(), o2.toPlatformPointer()).toNativePointer() +actual fun PyNumber_TrueDivide(o1: NativePointer, o2: NativePointer): NativePointer? = python.native.ffi.bindings.PyNumber_TrueDivide(o1.toPlatformPointer(), o2.toPlatformPointer()).toNativePointer() +actual fun PyNumber_Remainder(o1: NativePointer, o2: NativePointer): NativePointer? = python.native.ffi.bindings.PyNumber_Remainder(o1.toPlatformPointer(), o2.toPlatformPointer()).toNativePointer() +actual fun PyNumber_Divmod(o1: NativePointer, o2: NativePointer): NativePointer? = python.native.ffi.bindings.PyNumber_Divmod(o1.toPlatformPointer(), o2.toPlatformPointer()).toNativePointer() +actual fun PyNumber_Power(o1: NativePointer, o2: NativePointer, o3: NativePointer): NativePointer? = python.native.ffi.bindings.PyNumber_Power(o1.toPlatformPointer(), o2.toPlatformPointer(), o3.toPlatformPointer()).toNativePointer() +actual fun PyNumber_Negative(o: NativePointer): NativePointer? = python.native.ffi.bindings.PyNumber_Negative(o.toPlatformPointer()).toNativePointer() +actual fun PyNumber_Positive(o: NativePointer): NativePointer? = python.native.ffi.bindings.PyNumber_Positive(o.toPlatformPointer()).toNativePointer() +actual fun PyNumber_Absolute(o: NativePointer): NativePointer? = python.native.ffi.bindings.PyNumber_Absolute(o.toPlatformPointer()).toNativePointer() +actual fun PyNumber_Invert(o: NativePointer): NativePointer? = python.native.ffi.bindings.PyNumber_Invert(o.toPlatformPointer()).toNativePointer() +actual fun PyNumber_Lshift(o1: NativePointer, o2: NativePointer): NativePointer? = python.native.ffi.bindings.PyNumber_Lshift(o1.toPlatformPointer(), o2.toPlatformPointer()).toNativePointer() +actual fun PyNumber_Rshift(o1: NativePointer, o2: NativePointer): NativePointer? = python.native.ffi.bindings.PyNumber_Rshift(o1.toPlatformPointer(), o2.toPlatformPointer()).toNativePointer() +actual fun PyNumber_And(o1: NativePointer, o2: NativePointer): NativePointer? = python.native.ffi.bindings.PyNumber_And(o1.toPlatformPointer(), o2.toPlatformPointer()).toNativePointer() +actual fun PyNumber_Xor(o1: NativePointer, o2: NativePointer): NativePointer? = python.native.ffi.bindings.PyNumber_Xor(o1.toPlatformPointer(), o2.toPlatformPointer()).toNativePointer() +actual fun PyNumber_Or(o1: NativePointer, o2: NativePointer): NativePointer? = python.native.ffi.bindings.PyNumber_Or(o1.toPlatformPointer(), o2.toPlatformPointer()).toNativePointer() +actual fun PyNumber_InPlaceAdd(o1: NativePointer, o2: NativePointer): NativePointer? = python.native.ffi.bindings.PyNumber_InPlaceAdd(o1.toPlatformPointer(), o2.toPlatformPointer()).toNativePointer() +actual fun PyNumber_InPlaceSubtract(o1: NativePointer, o2: NativePointer): NativePointer? = python.native.ffi.bindings.PyNumber_InPlaceSubtract(o1.toPlatformPointer(), o2.toPlatformPointer()).toNativePointer() +actual fun PyNumber_InPlaceMultiply(o1: NativePointer, o2: NativePointer): NativePointer? = python.native.ffi.bindings.PyNumber_InPlaceMultiply(o1.toPlatformPointer(), o2.toPlatformPointer()).toNativePointer() +actual fun PyNumber_InPlaceMatrixMultiply(o1: NativePointer, o2: NativePointer): NativePointer? = python.native.ffi.bindings.PyNumber_InPlaceMatrixMultiply(o1.toPlatformPointer(), o2.toPlatformPointer()).toNativePointer() +actual fun PyNumber_InPlaceFloorDivide(o1: NativePointer, o2: NativePointer): NativePointer? = python.native.ffi.bindings.PyNumber_InPlaceFloorDivide(o1.toPlatformPointer(), o2.toPlatformPointer()).toNativePointer() +actual fun PyNumber_InPlaceTrueDivide(o1: NativePointer, o2: NativePointer): NativePointer? = python.native.ffi.bindings.PyNumber_InPlaceTrueDivide(o1.toPlatformPointer(), o2.toPlatformPointer()).toNativePointer() +actual fun PyNumber_InPlaceRemainder(o1: NativePointer, o2: NativePointer): NativePointer? = python.native.ffi.bindings.PyNumber_InPlaceRemainder(o1.toPlatformPointer(), o2.toPlatformPointer()).toNativePointer() +actual fun PyNumber_InPlacePower(o1: NativePointer, o2: NativePointer, o3: NativePointer): NativePointer? = python.native.ffi.bindings.PyNumber_InPlacePower(o1.toPlatformPointer(), o2.toPlatformPointer(), o3.toPlatformPointer()).toNativePointer() +actual fun PyNumber_InPlaceLshift(o1: NativePointer, o2: NativePointer): NativePointer? = python.native.ffi.bindings.PyNumber_InPlaceLshift(o1.toPlatformPointer(), o2.toPlatformPointer()).toNativePointer() +actual fun PyNumber_InPlaceRshift(o1: NativePointer, o2: NativePointer): NativePointer? = python.native.ffi.bindings.PyNumber_InPlaceRshift(o1.toPlatformPointer(), o2.toPlatformPointer()).toNativePointer() +actual fun PyNumber_InPlaceAnd(o1: NativePointer, o2: NativePointer): NativePointer? = python.native.ffi.bindings.PyNumber_InPlaceAnd(o1.toPlatformPointer(), o2.toPlatformPointer()).toNativePointer() +actual fun PyNumber_InPlaceXor(o1: NativePointer, o2: NativePointer): NativePointer? = python.native.ffi.bindings.PyNumber_InPlaceXor(o1.toPlatformPointer(), o2.toPlatformPointer()).toNativePointer() +actual fun PyNumber_InPlaceOr(o1: NativePointer, o2: NativePointer): NativePointer? = python.native.ffi.bindings.PyNumber_InPlaceOr(o1.toPlatformPointer(), o2.toPlatformPointer()).toNativePointer() +actual fun PyNumber_Long(o: NativePointer): NativePointer? = python.native.ffi.bindings.PyNumber_Long(o.toPlatformPointer()).toNativePointer() +actual fun PyNumber_Float(o: NativePointer): NativePointer? = python.native.ffi.bindings.PyNumber_Float(o.toPlatformPointer()).toNativePointer() +actual fun PyNumber_Index(o: NativePointer): NativePointer? = python.native.ffi.bindings.PyNumber_Index(o.toPlatformPointer()).toNativePointer() +actual fun PyNumber_ToBase(n: NativePointer, base: Int): NativePointer? = python.native.ffi.bindings.PyNumber_ToBase(n.toPlatformPointer(), base).toNativePointer() +actual inline fun PyIndex_Check(o: NativePointer): Int = python.native.ffi.bindings.PyIndex_Check(o.toPlatformPointer()) + + +// Section 13 +actual inline fun PySequence_Check(o: NativePointer): Int = python.native.ffi.bindings.PySequence_Check(o.toPlatformPointer()) +actual fun PySequence_Concat(o1: NativePointer, o2: NativePointer): NativePointer? = python.native.ffi.bindings.PySequence_Concat(o1.toPlatformPointer(), o2.toPlatformPointer()).toNativePointer() +actual fun PySequence_InPlaceConcat(o1: NativePointer, o2: NativePointer): NativePointer? = python.native.ffi.bindings.PySequence_InPlaceConcat(o1.toPlatformPointer(), o2.toPlatformPointer()).toNativePointer() +actual inline fun PySequence_Contains(o: NativePointer, value: NativePointer): Int = python.native.ffi.bindings.PySequence_Contains(o.toPlatformPointer(), value.toPlatformPointer()) +actual fun PySequence_List(o: NativePointer): NativePointer? = python.native.ffi.bindings.PySequence_List(o.toPlatformPointer()).toNativePointer() +actual fun PySequence_Tuple(o: NativePointer): NativePointer? = python.native.ffi.bindings.PySequence_Tuple(o.toPlatformPointer()).toNativePointer() +actual fun PySequence_Fast(o: NativePointer, m: String): NativePointer? = python.native.ffi.bindings.PySequence_Fast(o.toPlatformPointer(), m).toNativePointer() + + +// Section 14 +actual inline fun PyMapping_Check(o: NativePointer): Int = python.native.ffi.bindings.PyMapping_Check(o.toPlatformPointer()) +actual fun PyMapping_GetItemString(o: NativePointer, key: String): NativePointer? = python.native.ffi.bindings.PyMapping_GetItemString(o.toPlatformPointer(), key).toNativePointer() +actual inline fun PyMapping_SetItemString(o: NativePointer, key: String, v: NativePointer): Int = python.native.ffi.bindings.PyMapping_SetItemString(o.toPlatformPointer(), key, v.toPlatformPointer()) +actual inline fun PyMapping_HasKeyWithError(o: NativePointer, key: NativePointer): Int = python.native.ffi.bindings.PyMapping_HasKeyWithError(o.toPlatformPointer(), key.toPlatformPointer()) +actual inline fun PyMapping_HasKeyStringWithError(o: NativePointer, key: String): Int = python.native.ffi.bindings.PyMapping_HasKeyStringWithError(o.toPlatformPointer(), key) +actual inline fun PyMapping_HasKey(o: NativePointer, key: NativePointer): Int = python.native.ffi.bindings.PyMapping_HasKey(o.toPlatformPointer(), key.toPlatformPointer()) +actual inline fun PyMapping_HasKeyString(o: NativePointer, key: String): Int = python.native.ffi.bindings.PyMapping_HasKeyString(o.toPlatformPointer(), key) +actual fun PyMapping_Keys(o: NativePointer): NativePointer? = python.native.ffi.bindings.PyMapping_Keys(o.toPlatformPointer()).toNativePointer() +actual fun PyMapping_Values(o: NativePointer): NativePointer? = python.native.ffi.bindings.PyMapping_Values(o.toPlatformPointer()).toNativePointer() +actual fun PyMapping_Items(o: NativePointer): NativePointer? = python.native.ffi.bindings.PyMapping_Items(o.toPlatformPointer()).toNativePointer() + + +// Section 15 +actual inline fun PyIter_Check(o: NativePointer): Int = python.native.ffi.bindings.PyIter_Check(o.toPlatformPointer()) +actual inline fun PyAIter_Check(o: NativePointer): Int = python.native.ffi.bindings.PyAIter_Check(o.toPlatformPointer()) +actual fun PyIter_Next(o: NativePointer): NativePointer? = python.native.ffi.bindings.PyIter_Next(o.toPlatformPointer()).toNativePointer() + + +// Section 16 +actual fun PyLong_FromLongLong(v: Long): NativePointer? = python.native.ffi.bindings.PyLong_FromLongLong(v).toNativePointer() +actual fun PyLong_FromDouble(v: Double): NativePointer? = python.native.ffi.bindings.PyLong_FromDouble(v).toNativePointer() +actual inline fun PyLong_AsInt(obj: NativePointer): Int = python.native.ffi.bindings.PyLong_AsInt(obj.toPlatformPointer()) +actual inline fun PyLong_AsLongLong(obj: NativePointer): Long = python.native.ffi.bindings.PyLong_AsLongLong(obj.toPlatformPointer()) +actual inline fun PyLong_AsDouble(pylong: NativePointer): Double = python.native.ffi.bindings.PyLong_AsDouble(pylong.toPlatformPointer()) +actual fun PyLong_GetInfo(): NativePointer? = python.native.ffi.bindings.PyLong_GetInfo().toNativePointer() + + +// Section 17 +actual fun PyBool_FromLong(v: Int): NativePointer? = python.native.ffi.bindings.PyBool_FromLong(v.toLong()).toNativePointer() + + +// Section 18 +actual fun PyFloat_FromString(str: NativePointer): NativePointer? = python.native.ffi.bindings.PyFloat_FromString(str.toPlatformPointer()).toNativePointer() +actual fun PyFloat_FromDouble(v: Double): NativePointer? = python.native.ffi.bindings.PyFloat_FromDouble(v).toNativePointer() +actual inline fun PyFloat_AsDouble(pyfloat: NativePointer): Double = python.native.ffi.bindings.PyFloat_AsDouble(pyfloat.toPlatformPointer()) +actual fun PyFloat_GetInfo(): NativePointer? = python.native.ffi.bindings.PyFloat_GetInfo().toNativePointer() +actual inline fun PyFloat_GetMax(): Double = python.native.ffi.bindings.PyFloat_GetMax() +actual inline fun PyFloat_GetMin(): Double = python.native.ffi.bindings.PyFloat_GetMin() + + +// Section 19 +actual fun PyBytes_FromString(v: String): NativePointer? = python.native.ffi.bindings.PyBytes_FromString(v).toNativePointer() +actual fun PyBytes_FromObject(o: NativePointer): NativePointer? = python.native.ffi.bindings.PyBytes_FromObject(o.toPlatformPointer()).toNativePointer() +actual inline fun PyBytes_AsString(o: NativePointer): String? = python.native.ffi.bindings.PyBytes_AsString(o.toPlatformPointer()) + + +// Section 20 +actual fun PyByteArray_FromObject(o: NativePointer): NativePointer? = python.native.ffi.bindings.PyByteArray_FromObject(o.toPlatformPointer()).toNativePointer() +actual fun PyByteArray_Concat(a: NativePointer, b: NativePointer): NativePointer? = python.native.ffi.bindings.PyByteArray_Concat(a.toPlatformPointer(), b.toPlatformPointer()).toNativePointer() +actual inline fun PyByteArray_AsString(bytearray: NativePointer): String? = python.native.ffi.bindings.PyByteArray_AsString(bytearray.toPlatformPointer()) + + +// Section 21 +actual inline fun PyUnicode_IsIdentifier(unicode: NativePointer): Int = python.native.ffi.bindings.PyUnicode_IsIdentifier(unicode.toPlatformPointer()) +actual fun PyUnicode_FromString(str: String): NativePointer? = python.native.ffi.bindings.PyUnicode_FromString(str).toNativePointer() +actual fun PyUnicode_FromObject(obj: NativePointer): NativePointer? = python.native.ffi.bindings.PyUnicode_FromObject(obj.toPlatformPointer()).toNativePointer() +actual fun PyUnicode_FromEncodedObject(obj: NativePointer, encoding: String, errors: String): NativePointer? = python.native.ffi.bindings.PyUnicode_FromEncodedObject(obj.toPlatformPointer(), encoding, errors).toNativePointer() +actual fun PyUnicode_DecodeLocale(str: String, errors: String): NativePointer? = python.native.ffi.bindings.PyUnicode_DecodeLocale(str, errors).toNativePointer() +actual fun PyUnicode_EncodeLocale(unicode: NativePointer, errors: String): NativePointer? = python.native.ffi.bindings.PyUnicode_EncodeLocale(unicode.toPlatformPointer(), errors).toNativePointer() +actual fun PyUnicode_DecodeFSDefault(str: String): NativePointer? = python.native.ffi.bindings.PyUnicode_DecodeFSDefault(str).toNativePointer() +actual fun PyUnicode_EncodeFSDefault(unicode: NativePointer): NativePointer? = python.native.ffi.bindings.PyUnicode_EncodeFSDefault(unicode.toPlatformPointer()).toNativePointer() +actual fun PyUnicode_AsEncodedString(unicode: NativePointer, encoding: String, errors: String): NativePointer? = python.native.ffi.bindings.PyUnicode_AsEncodedString(unicode.toPlatformPointer(), encoding, errors).toNativePointer() +actual fun PyUnicode_AsUTF8String(unicode: NativePointer): NativePointer? = python.native.ffi.bindings.PyUnicode_AsUTF8String(unicode.toPlatformPointer()).toNativePointer() +actual inline fun PyUnicode_AsUTF8(unicode: NativePointer): String? = python.native.ffi.bindings.PyUnicode_AsUTF8(unicode.toPlatformPointer()) // 수동 추가 +actual fun PyUnicode_AsUTF32String(unicode: NativePointer): NativePointer? = python.native.ffi.bindings.PyUnicode_AsUTF32String(unicode.toPlatformPointer()).toNativePointer() +actual fun PyUnicode_AsUTF16String(unicode: NativePointer): NativePointer? = python.native.ffi.bindings.PyUnicode_AsUTF16String(unicode.toPlatformPointer()).toNativePointer() +actual fun PyUnicode_AsUnicodeEscapeString(unicode: NativePointer): NativePointer? = python.native.ffi.bindings.PyUnicode_AsUnicodeEscapeString(unicode.toPlatformPointer()).toNativePointer() +actual fun PyUnicode_AsRawUnicodeEscapeString(unicode: NativePointer): NativePointer? = python.native.ffi.bindings.PyUnicode_AsRawUnicodeEscapeString(unicode.toPlatformPointer()).toNativePointer() +actual fun PyUnicode_AsLatin1String(unicode: NativePointer): NativePointer? = python.native.ffi.bindings.PyUnicode_AsLatin1String(unicode.toPlatformPointer()).toNativePointer() +actual fun PyUnicode_AsASCIIString(unicode: NativePointer): NativePointer? = python.native.ffi.bindings.PyUnicode_AsASCIIString(unicode.toPlatformPointer()).toNativePointer() +actual fun PyUnicode_AsCharmapString(unicode: NativePointer, mapping: NativePointer): NativePointer? = python.native.ffi.bindings.PyUnicode_AsCharmapString(unicode.toPlatformPointer(), mapping.toPlatformPointer()).toNativePointer() +actual fun PyUnicode_Translate(unicode: NativePointer, table: NativePointer, errors: String): NativePointer? = python.native.ffi.bindings.PyUnicode_Translate(unicode.toPlatformPointer(), table.toPlatformPointer(), errors).toNativePointer() +actual fun PyUnicode_Concat(left: NativePointer, right: NativePointer): NativePointer? = python.native.ffi.bindings.PyUnicode_Concat(left.toPlatformPointer(), right.toPlatformPointer()).toNativePointer() +actual fun PyUnicode_Splitlines(unicode: NativePointer, keepends: Int): NativePointer? = python.native.ffi.bindings.PyUnicode_Splitlines(unicode.toPlatformPointer(), keepends).toNativePointer() +actual fun PyUnicode_Join(separator: NativePointer, seq: NativePointer): NativePointer? = python.native.ffi.bindings.PyUnicode_Join(separator.toPlatformPointer(), seq.toPlatformPointer()).toNativePointer() +actual inline fun PyUnicode_Compare(left: NativePointer, right: NativePointer): Int = python.native.ffi.bindings.PyUnicode_Compare(left.toPlatformPointer(), right.toPlatformPointer()) +actual inline fun PyUnicode_EqualToUTF8(unicode: NativePointer, string: String): Int = python.native.ffi.bindings.PyUnicode_EqualToUTF8(unicode.toPlatformPointer(), string) +actual inline fun PyUnicode_CompareWithASCIIString(unicode: NativePointer, string: String): Int = python.native.ffi.bindings.PyUnicode_CompareWithASCIIString(unicode.toPlatformPointer(), string) +actual fun PyUnicode_RichCompare(left: NativePointer, right: NativePointer, op: Int): NativePointer? = python.native.ffi.bindings.PyUnicode_RichCompare(left.toPlatformPointer(), right.toPlatformPointer(), op).toNativePointer() +actual fun PyUnicode_Format(format: NativePointer, args: NativePointer): NativePointer? = python.native.ffi.bindings.PyUnicode_Format(format.toPlatformPointer(), args.toPlatformPointer()).toNativePointer() +actual inline fun PyUnicode_Contains(unicode: NativePointer, substr: NativePointer): Int = python.native.ffi.bindings.PyUnicode_Contains(unicode.toPlatformPointer(), substr.toPlatformPointer()) +actual fun PyUnicode_InternFromString(str: String): NativePointer? = python.native.ffi.bindings.PyUnicode_InternFromString(str).toNativePointer() + + +// Section 22 +actual inline fun PyList_Append(list: NativePointer, item: NativePointer): Int = python.native.ffi.bindings.PyList_Append(list.toPlatformPointer(), item.toPlatformPointer()) +actual inline fun PyList_Sort(list: NativePointer): Int = python.native.ffi.bindings.PyList_Sort(list.toPlatformPointer()) +actual inline fun PyList_Reverse(list: NativePointer): Int = python.native.ffi.bindings.PyList_Reverse(list.toPlatformPointer()) +actual fun PyList_AsTuple(list: NativePointer): NativePointer? = python.native.ffi.bindings.PyList_AsTuple(list.toPlatformPointer()).toNativePointer() + + +// Section 23 +actual fun PyDict_New(): NativePointer? = python.native.ffi.bindings.PyDict_New().toNativePointer() +actual fun PyDictProxy_New(mapping: NativePointer): NativePointer? = python.native.ffi.bindings.PyDictProxy_New(mapping.toPlatformPointer()).toNativePointer() +actual inline fun PyDict_Clear(p: NativePointer) = python.native.ffi.bindings.PyDict_Clear(p.toPlatformPointer()) +actual inline fun PyDict_Contains(p: NativePointer, key: NativePointer): Int = python.native.ffi.bindings.PyDict_Contains(p.toPlatformPointer(), key.toPlatformPointer()) +actual fun PyDict_Copy(p: NativePointer): NativePointer? = python.native.ffi.bindings.PyDict_Copy(p.toPlatformPointer()).toNativePointer() +actual inline fun PyDict_SetItem(p: NativePointer, key: NativePointer, v: NativePointer): Int = python.native.ffi.bindings.PyDict_SetItem(p.toPlatformPointer(), key.toPlatformPointer(), v.toPlatformPointer()) +actual inline fun PyDict_SetItemString(p: NativePointer, key: String, v: NativePointer): Int = python.native.ffi.bindings.PyDict_SetItemString(p.toPlatformPointer(), key, v.toPlatformPointer()) +actual inline fun PyDict_DelItem(p: NativePointer, key: NativePointer): Int = python.native.ffi.bindings.PyDict_DelItem(p.toPlatformPointer(), key.toPlatformPointer()) +actual inline fun PyDict_DelItemString(p: NativePointer, key: String): Int = python.native.ffi.bindings.PyDict_DelItemString(p.toPlatformPointer(), key) +actual fun PyDict_GetItem(p: NativePointer, key: NativePointer): NativePointer? = python.native.ffi.bindings.PyDict_GetItem(p.toPlatformPointer(), key.toPlatformPointer()).toNativePointer() +actual fun PyDict_GetItemWithError(p: NativePointer, key: NativePointer): NativePointer? = python.native.ffi.bindings.PyDict_GetItemWithError(p.toPlatformPointer(), key.toPlatformPointer()).toNativePointer() +actual fun PyDict_GetItemString(p: NativePointer, key: String): NativePointer? = python.native.ffi.bindings.PyDict_GetItemString(p.toPlatformPointer(), key).toNativePointer() +actual fun PyDict_Items(p: NativePointer): NativePointer? = python.native.ffi.bindings.PyDict_Items(p.toPlatformPointer()).toNativePointer() +actual fun PyDict_Keys(p: NativePointer): NativePointer? = python.native.ffi.bindings.PyDict_Keys(p.toPlatformPointer()).toNativePointer() +actual fun PyDict_Values(p: NativePointer): NativePointer? = python.native.ffi.bindings.PyDict_Values(p.toPlatformPointer()).toNativePointer() +actual inline fun PyDict_Merge(a: NativePointer, b: NativePointer, override: Int): Int = python.native.ffi.bindings.PyDict_Merge(a.toPlatformPointer(), b.toPlatformPointer(), override) +actual inline fun PyDict_Update(a: NativePointer, b: NativePointer): Int = python.native.ffi.bindings.PyDict_Update(a.toPlatformPointer(), b.toPlatformPointer()) +actual inline fun PyDict_MergeFromSeq2(a: NativePointer, seq2: NativePointer, override: Int): Int = python.native.ffi.bindings.PyDict_MergeFromSeq2(a.toPlatformPointer(), seq2.toPlatformPointer(), override) + + +// Section 24 +actual fun PySet_New(iterable: NativePointer): NativePointer? = python.native.ffi.bindings.PySet_New(iterable.toPlatformPointer()).toNativePointer() +actual fun PyFrozenSet_New(iterable: NativePointer): NativePointer? = python.native.ffi.bindings.PyFrozenSet_New(iterable.toPlatformPointer()).toNativePointer() +actual inline fun PySet_Contains(anyset: NativePointer, key: NativePointer): Int = python.native.ffi.bindings.PySet_Contains(anyset.toPlatformPointer(), key.toPlatformPointer()) +actual inline fun PySet_Add(set: NativePointer, key: NativePointer): Int = python.native.ffi.bindings.PySet_Add(set.toPlatformPointer(), key.toPlatformPointer()) +actual inline fun PySet_Discard(set: NativePointer, key: NativePointer): Int = python.native.ffi.bindings.PySet_Discard(set.toPlatformPointer(), key.toPlatformPointer()) +actual fun PySet_Pop(set: NativePointer): NativePointer? = python.native.ffi.bindings.PySet_Pop(set.toPlatformPointer()).toNativePointer() +actual inline fun PySet_Clear(set: NativePointer): Int = python.native.ffi.bindings.PySet_Clear(set.toPlatformPointer()) + + +// Section 25 +actual fun PySeqIter_New(seq: NativePointer): NativePointer? = python.native.ffi.bindings.PySeqIter_New(seq.toPlatformPointer()).toNativePointer() +actual fun PyCallIter_New(callable: NativePointer, sentinel: NativePointer): NativePointer? = python.native.ffi.bindings.PyCallIter_New(callable.toPlatformPointer(), sentinel.toPlatformPointer()).toNativePointer() + + +// Section 26 +actual fun PyWeakref_NewRef(ob: NativePointer, callback: NativePointer): NativePointer? = python.native.ffi.bindings.PyWeakref_NewRef(ob.toPlatformPointer(), callback.toPlatformPointer()).toNativePointer() +actual fun PyWeakref_NewProxy(ob: NativePointer, callback: NativePointer): NativePointer? = python.native.ffi.bindings.PyWeakref_NewProxy(ob.toPlatformPointer(), callback.toPlatformPointer()).toNativePointer() +actual fun PyWeakref_GetObject(ref: NativePointer): NativePointer? = python.native.ffi.bindings.PyWeakref_GetObject(ref.toPlatformPointer()).toNativePointer() +actual inline fun PyObject_ClearWeakRefs(o: NativePointer) = python.native.ffi.bindings.PyObject_ClearWeakRefs(o.toPlatformPointer()) + + +// Section 27 +actual inline fun PyType_IsSubtype(a: NativePointer, b: NativePointer): Int = python.native.ffi.bindings.PyType_IsSubtype(a.toPlatformPointer(), b.toPlatformPointer()) +actual inline fun PyType_Ready(type: NativePointer): Int = python.native.ffi.bindings.PyType_Ready(type.toPlatformPointer()) +actual fun PyType_GetName(type: NativePointer): NativePointer? = python.native.ffi.bindings.PyType_GetName(type.toPlatformPointer()).toNativePointer() +actual fun PyType_GetFullyQualifiedName(type: NativePointer): NativePointer? = python.native.ffi.bindings.PyType_GetFullyQualifiedName(type.toPlatformPointer()).toNativePointer() +actual fun PyType_GetModuleName(type: NativePointer): NativePointer? = python.native.ffi.bindings.PyType_GetModuleName(type.toPlatformPointer()).toNativePointer() +actual fun PyType_GetModule(type: NativePointer): NativePointer? = python.native.ffi.bindings.PyType_GetModule(type.toPlatformPointer()).toNativePointer() + + +// Section 28 +actual fun PyTuple_New(len: Long): NativePointer? = python.native.ffi.bindings.PyTuple_New(len).toNativePointer() +actual inline fun PyTuple_Size(p: NativePointer): Long = python.native.ffi.bindings.PyTuple_Size(p.toPlatformPointer()) +actual fun PyTuple_GetItem(p: NativePointer, pos: Long): NativePointer? = python.native.ffi.bindings.PyTuple_GetItem(p.toPlatformPointer(), pos).toNativePointer() +actual fun PyTuple_GetSlice(p: NativePointer, low: Long, high: Long): NativePointer? = python.native.ffi.bindings.PyTuple_GetSlice(p.toPlatformPointer(), low, high).toNativePointer() +actual inline fun PyTuple_SetItem(p: NativePointer, pos: Long, o: NativePointer): Int = python.native.ffi.bindings.PyTuple_SetItem(p.toPlatformPointer(), pos, o.toPlatformPointer()) diff --git a/python-multiplatform/src/desktopMain/kotlin/python/native/ffi/bindings.kt b/python-multiplatform/src/desktopMain/kotlin/python/native/ffi/bindings.kt index c4d19c75..bd06fd4f 100644 --- a/python-multiplatform/src/desktopMain/kotlin/python/native/ffi/bindings.kt +++ b/python-multiplatform/src/desktopMain/kotlin/python/native/ffi/bindings.kt @@ -4,9 +4,11 @@ import jdk.incubator.foreign.* import java.lang.invoke.MethodHandle import java.lang.invoke.MethodType import java.lang.Long as LongLong +import java.lang.Double as Double object bindings { + /** val Py_InitializeHandle: MethodHandle inline fun Py_Initialize() = Py_InitializeHandle.invoke() as Unit val Py_InitializeExHandle: MethodHandle @@ -73,12 +75,684 @@ object bindings { val PyUnicode_AsUTF8Handle: MethodHandle inline fun PyUnicode_AsUTF8(unicode: MemoryAddress): String? = CLinker.toJavaString(PyUnicode_AsUTF8Handle.invoke(unicode) as MemoryAddress?) + */ + //************************************************** + // Section 1 + val Py_InitializeHandle: MethodHandle + inline fun Py_Initialize() = Py_InitializeHandle.invoke() as Unit + val Py_InitializeExHandle: MethodHandle + inline fun Py_InitializeEx(initsigs: Int) = Py_InitializeExHandle.invoke(initsigs) as Unit + val Py_IsInitializedHandle: MethodHandle + inline fun Py_IsInitialized(): Int = Py_IsInitializedHandle.invoke() as Int + val Py_IsFinalizingHandle: MethodHandle + inline fun Py_IsFinalizing(): Int = Py_IsFinalizingHandle.invoke() as Int + val Py_FinalizeExHandle: MethodHandle + inline fun Py_FinalizeEx(): Int = Py_FinalizeExHandle.invoke() as Int + val Py_FinalizeHandle: MethodHandle + inline fun Py_Finalize() = Py_FinalizeHandle.invoke() as Unit + val Py_GetVersionHandle: MethodHandle + val Py_RunMainHandle: MethodHandle // 수동 추가 + inline fun Py_RunMain(): Int = Py_RunMainHandle.invoke() as Int + inline fun Py_GetVersion(): String? = CLinker.toJavaString(Py_GetVersionHandle.invoke() as MemoryAddress?) + val Py_GetPlatformHandle: MethodHandle + inline fun Py_GetPlatform(): String? = CLinker.toJavaString(Py_GetPlatformHandle.invoke() as MemoryAddress?) + val Py_GetCopyrightHandle: MethodHandle + inline fun Py_GetCopyright(): String? = CLinker.toJavaString(Py_GetCopyrightHandle.invoke() as MemoryAddress?) + val Py_GetCompilerHandle: MethodHandle + inline fun Py_GetCompiler(): String? = CLinker.toJavaString(Py_GetCompilerHandle.invoke() as MemoryAddress?) + val Py_GetBuildInfoHandle: MethodHandle + inline fun Py_GetBuildInfo(): String? = CLinker.toJavaString(Py_GetBuildInfoHandle.invoke() as MemoryAddress?) + val PyEval_InitThreadsHandle: MethodHandle + inline fun PyEval_InitThreads() = PyEval_InitThreadsHandle.invoke() as Unit + val PyThreadState_GetDictHandle: MethodHandle + inline fun PyThreadState_GetDict(): MemoryAddress? = PyThreadState_GetDictHandle.invoke() as MemoryAddress? + + + // Section 2 + val PyRun_SimpleStringHandle: MethodHandle // 수동 추가 + inline fun PyRun_SimpleString(command: String): Int = PyRun_SimpleStringHandle.invoke(CLinker.toCString(command, ResourceScope.newConfinedScope()).address()) as Int + val PyRun_StringHandle: MethodHandle // 수동 추가 + inline fun PyRun_String(str: String, start: Int, globals: MemoryAddress, locals: MemoryAddress): MemoryAddress? = PyRun_StringHandle.invoke(CLinker.toCString(str, ResourceScope.newConfinedScope()).address(),start,globals,locals) as MemoryAddress? + val Py_CompileStringHandle: MethodHandle + inline fun Py_CompileString(str: String, filename: String, start: Int): MemoryAddress? = Py_CompileStringHandle.invoke(CLinker.toCString(str, ResourceScope.newConfinedScope()).address(), CLinker.toCString(filename, ResourceScope.newConfinedScope()).address(), start) as MemoryAddress? + val PyEval_EvalCodeHandle: MethodHandle + inline fun PyEval_EvalCode(co: MemoryAddress, globals: MemoryAddress, locals: MemoryAddress): MemoryAddress? = PyEval_EvalCodeHandle.invoke(co, globals, locals) as MemoryAddress? + + + // Section 3 + val PyErr_ClearHandle: MethodHandle + inline fun PyErr_Clear() = PyErr_ClearHandle.invoke() as Unit + val PyErr_PrintExHandle: MethodHandle + inline fun PyErr_PrintEx(set_sys_last_vars: Int) = PyErr_PrintExHandle.invoke(set_sys_last_vars) as Unit + val PyErr_PrintHandle: MethodHandle + inline fun PyErr_Print() = PyErr_PrintHandle.invoke() as Unit + val PyErr_WriteUnraisableHandle: MethodHandle + inline fun PyErr_WriteUnraisable(obj: MemoryAddress) = PyErr_WriteUnraisableHandle.invoke(obj) as Unit + val PyErr_DisplayExceptionHandle: MethodHandle + inline fun PyErr_DisplayException(exc: MemoryAddress) = PyErr_DisplayExceptionHandle.invoke(exc) as Unit + val PyErr_SetStringHandle: MethodHandle + inline fun PyErr_SetString(type: MemoryAddress, message: String) = PyErr_SetStringHandle.invoke(type, CLinker.toCString(message, ResourceScope.newConfinedScope()).address()) as Unit + val PyErr_SetObjectHandle: MethodHandle + inline fun PyErr_SetObject(type: MemoryAddress, value: MemoryAddress) = PyErr_SetObjectHandle.invoke(type, value) as Unit + val PyErr_SetNoneHandle: MethodHandle + inline fun PyErr_SetNone(type: MemoryAddress) = PyErr_SetNoneHandle.invoke(type) as Unit + val PyErr_BadArgumentHandle: MethodHandle + inline fun PyErr_BadArgument(): Int = PyErr_BadArgumentHandle.invoke() as Int + val PyErr_NoMemoryHandle: MethodHandle + inline fun PyErr_NoMemory(): MemoryAddress? = PyErr_NoMemoryHandle.invoke() as MemoryAddress? + val PyErr_SetFromErrnoHandle: MethodHandle + inline fun PyErr_SetFromErrno(type: MemoryAddress): MemoryAddress? = PyErr_SetFromErrnoHandle.invoke(type) as MemoryAddress? + val PyErr_SetFromErrnoWithFilenameObjectHandle: MethodHandle + inline fun PyErr_SetFromErrnoWithFilenameObject(type: MemoryAddress, filenameObject: MemoryAddress): MemoryAddress? = PyErr_SetFromErrnoWithFilenameObjectHandle.invoke(type, filenameObject) as MemoryAddress? + val PyErr_SetFromErrnoWithFilenameObjectsHandle: MethodHandle + inline fun PyErr_SetFromErrnoWithFilenameObjects(type: MemoryAddress, filenameObject: MemoryAddress, filenameObject2: MemoryAddress): MemoryAddress? = PyErr_SetFromErrnoWithFilenameObjectsHandle.invoke(type, filenameObject, filenameObject2) as MemoryAddress? + val PyErr_SetFromErrnoWithFilenameHandle: MethodHandle + inline fun PyErr_SetFromErrnoWithFilename(type: MemoryAddress, filename: String): MemoryAddress? = PyErr_SetFromErrnoWithFilenameHandle.invoke(type, CLinker.toCString(filename, ResourceScope.newConfinedScope()).address()) as MemoryAddress? + val PyErr_SetImportErrorHandle: MethodHandle + inline fun PyErr_SetImportError(msg: MemoryAddress, name: MemoryAddress, path: MemoryAddress): MemoryAddress? = PyErr_SetImportErrorHandle.invoke(msg, name, path) as MemoryAddress? + val PyErr_SetImportErrorSubclassHandle: MethodHandle + inline fun PyErr_SetImportErrorSubclass(exception: MemoryAddress, msg: MemoryAddress, name: MemoryAddress, path: MemoryAddress): MemoryAddress? = PyErr_SetImportErrorSubclassHandle.invoke(exception, msg, name, path) as MemoryAddress? + val PyErr_SyntaxLocationExHandle: MethodHandle + inline fun PyErr_SyntaxLocationEx(filename: String, lineno: Int, col_offset: Int) = PyErr_SyntaxLocationExHandle.invoke(CLinker.toCString(filename, ResourceScope.newConfinedScope()).address(), lineno, col_offset) as Unit + val PyErr_SyntaxLocationHandle: MethodHandle + inline fun PyErr_SyntaxLocation(filename: String, lineno: Int) = PyErr_SyntaxLocationHandle.invoke(CLinker.toCString(filename, ResourceScope.newConfinedScope()).address(), lineno) as Unit + val PyErr_BadInternalCallHandle: MethodHandle + inline fun PyErr_BadInternalCall() = PyErr_BadInternalCallHandle.invoke() as Unit + val PyErr_WarnExplicitHandle: MethodHandle + inline fun PyErr_WarnExplicit(category: MemoryAddress, message: String, filename: String, lineno: Int, module: String, registry: MemoryAddress): Int = PyErr_WarnExplicitHandle.invoke(category, CLinker.toCString(message, ResourceScope.newConfinedScope()).address(), CLinker.toCString(filename, ResourceScope.newConfinedScope()).address(), lineno, CLinker.toCString(module, ResourceScope.newConfinedScope()).address(), registry) as Int + val PyErr_OccurredHandle: MethodHandle + inline fun PyErr_Occurred(): MemoryAddress? = PyErr_OccurredHandle.invoke() as MemoryAddress? + val PyErr_ExceptionMatchesHandle: MethodHandle + inline fun PyErr_ExceptionMatches(exc: MemoryAddress): Int = PyErr_ExceptionMatchesHandle.invoke(exc) as Int + val PyErr_GivenExceptionMatchesHandle: MethodHandle + inline fun PyErr_GivenExceptionMatches(given: MemoryAddress, exc: MemoryAddress): Int = PyErr_GivenExceptionMatchesHandle.invoke(given, exc) as Int + val PyErr_GetRaisedExceptionHandle: MethodHandle + inline fun PyErr_GetRaisedException(): MemoryAddress? = PyErr_GetRaisedExceptionHandle.invoke() as MemoryAddress? + val PyErr_SetRaisedExceptionHandle: MethodHandle + inline fun PyErr_SetRaisedException(exc: MemoryAddress) = PyErr_SetRaisedExceptionHandle.invoke(exc) as Unit + val PyErr_RestoreHandle: MethodHandle + inline fun PyErr_Restore(type: MemoryAddress, value: MemoryAddress, traceback: MemoryAddress) = PyErr_RestoreHandle.invoke(type, value, traceback) as Unit + val PyErr_GetHandledExceptionHandle: MethodHandle + inline fun PyErr_GetHandledException(): MemoryAddress? = PyErr_GetHandledExceptionHandle.invoke() as MemoryAddress? + val PyErr_SetHandledExceptionHandle: MethodHandle + inline fun PyErr_SetHandledException(exc: MemoryAddress) = PyErr_SetHandledExceptionHandle.invoke(exc) as Unit + val PyErr_SetExcInfoHandle: MethodHandle + inline fun PyErr_SetExcInfo(type: MemoryAddress, value: MemoryAddress, traceback: MemoryAddress) = PyErr_SetExcInfoHandle.invoke(type, value, traceback) as Unit + val PyErr_CheckSignalsHandle: MethodHandle + inline fun PyErr_CheckSignals(): Int = PyErr_CheckSignalsHandle.invoke() as Int + val PyErr_SetInterruptHandle: MethodHandle + inline fun PyErr_SetInterrupt() = PyErr_SetInterruptHandle.invoke() as Unit + val PyErr_SetInterruptExHandle: MethodHandle + inline fun PyErr_SetInterruptEx(signum: Int): Int = PyErr_SetInterruptExHandle.invoke(signum) as Int + val PyErr_NewExceptionHandle: MethodHandle + inline fun PyErr_NewException(name: String, base: MemoryAddress, dict: MemoryAddress): MemoryAddress? = PyErr_NewExceptionHandle.invoke(CLinker.toCString(name, ResourceScope.newConfinedScope()).address(), base, dict) as MemoryAddress? + val PyErr_NewExceptionWithDocHandle: MethodHandle + inline fun PyErr_NewExceptionWithDoc(name: String, doc: String, base: MemoryAddress, dict: MemoryAddress): MemoryAddress? = PyErr_NewExceptionWithDocHandle.invoke(CLinker.toCString(name, ResourceScope.newConfinedScope()).address(), CLinker.toCString(doc, ResourceScope.newConfinedScope()).address(), base, dict) as MemoryAddress? + val PyException_GetTracebackHandle: MethodHandle + inline fun PyException_GetTraceback(ex: MemoryAddress): MemoryAddress? = PyException_GetTracebackHandle.invoke(ex) as MemoryAddress? + val PyException_SetTracebackHandle: MethodHandle + inline fun PyException_SetTraceback(ex: MemoryAddress, tb: MemoryAddress): Int = PyException_SetTracebackHandle.invoke(ex, tb) as Int + val PyException_GetContextHandle: MethodHandle + inline fun PyException_GetContext(ex: MemoryAddress): MemoryAddress? = PyException_GetContextHandle.invoke(ex) as MemoryAddress? + val PyException_SetContextHandle: MethodHandle + inline fun PyException_SetContext(ex: MemoryAddress, ctx: MemoryAddress) = PyException_SetContextHandle.invoke(ex, ctx) as Unit + val PyException_GetCauseHandle: MethodHandle + inline fun PyException_GetCause(ex: MemoryAddress): MemoryAddress? = PyException_GetCauseHandle.invoke(ex) as MemoryAddress? + val PyException_SetCauseHandle: MethodHandle + inline fun PyException_SetCause(ex: MemoryAddress, cause: MemoryAddress) = PyException_SetCauseHandle.invoke(ex, cause) as Unit + val PyException_GetArgsHandle: MethodHandle + inline fun PyException_GetArgs(ex: MemoryAddress): MemoryAddress? = PyException_GetArgsHandle.invoke(ex) as MemoryAddress? + val PyException_SetArgsHandle: MethodHandle + inline fun PyException_SetArgs(ex: MemoryAddress, args: MemoryAddress) = PyException_SetArgsHandle.invoke(ex, args) as Unit + val PyUnicodeEncodeError_GetEncodingHandle: MethodHandle + inline fun PyUnicodeEncodeError_GetEncoding(exc: MemoryAddress): MemoryAddress? = PyUnicodeEncodeError_GetEncodingHandle.invoke(exc) as MemoryAddress? + val PyUnicodeTranslateError_GetObjectHandle: MethodHandle + inline fun PyUnicodeTranslateError_GetObject(exc: MemoryAddress): MemoryAddress? = PyUnicodeTranslateError_GetObjectHandle.invoke(exc) as MemoryAddress? + val PyUnicodeTranslateError_GetReasonHandle: MethodHandle + inline fun PyUnicodeTranslateError_GetReason(exc: MemoryAddress): MemoryAddress? = PyUnicodeTranslateError_GetReasonHandle.invoke(exc) as MemoryAddress? + val PyUnicodeTranslateError_SetReasonHandle: MethodHandle + inline fun PyUnicodeTranslateError_SetReason(exc: MemoryAddress, reason: String): Int = PyUnicodeTranslateError_SetReasonHandle.invoke(exc, CLinker.toCString(reason, ResourceScope.newConfinedScope()).address()) as Int + val Py_EnterRecursiveCallHandle: MethodHandle + inline fun Py_EnterRecursiveCall(where: String): Int = Py_EnterRecursiveCallHandle.invoke(CLinker.toCString(where, ResourceScope.newConfinedScope()).address()) as Int + val Py_LeaveRecursiveCallHandle: MethodHandle + inline fun Py_LeaveRecursiveCall() = Py_LeaveRecursiveCallHandle.invoke() as Unit + val Py_ReprEnterHandle: MethodHandle + inline fun Py_ReprEnter(o: MemoryAddress): Int = Py_ReprEnterHandle.invoke(o) as Int + val Py_ReprLeaveHandle: MethodHandle + inline fun Py_ReprLeave(o: MemoryAddress) = Py_ReprLeaveHandle.invoke(o) as Unit + + + // Section 4 + val Py_NewRefHandle: MethodHandle + inline fun Py_NewRef(o: MemoryAddress): MemoryAddress? = Py_NewRefHandle.invoke(o) as MemoryAddress? + val Py_XNewRefHandle: MethodHandle + inline fun Py_XNewRef(o: MemoryAddress): MemoryAddress? = Py_XNewRefHandle.invoke(o) as MemoryAddress? + val Py_IncRefHandle: MethodHandle + inline fun Py_IncRef(o: MemoryAddress) = Py_IncRefHandle.invoke(o) as Unit + val Py_DecRefHandle: MethodHandle + inline fun Py_DecRef(o: MemoryAddress) = Py_DecRefHandle.invoke(o) as Unit + + + // Section 5 + val PyOS_FSPathHandle: MethodHandle + inline fun PyOS_FSPath(path: MemoryAddress): MemoryAddress? = PyOS_FSPathHandle.invoke(path) as MemoryAddress? + + + // Section 6 + val PySys_GetObjectHandle: MethodHandle + inline fun PySys_GetObject(name: String): MemoryAddress? = PySys_GetObjectHandle.invoke(CLinker.toCString(name, ResourceScope.newConfinedScope()).address()) as MemoryAddress? + val PySys_SetObjectHandle: MethodHandle + inline fun PySys_SetObject(name: String, v: MemoryAddress): Int = PySys_SetObjectHandle.invoke(CLinker.toCString(name, ResourceScope.newConfinedScope()).address(), v) as Int + val PySys_ResetWarnOptionsHandle: MethodHandle + inline fun PySys_ResetWarnOptions() = PySys_ResetWarnOptionsHandle.invoke() as Unit + val PySys_GetXOptionsHandle: MethodHandle + inline fun PySys_GetXOptions(): MemoryAddress? = PySys_GetXOptionsHandle.invoke() as MemoryAddress? + val PySys_AuditTupleHandle: MethodHandle + inline fun PySys_AuditTuple(event: String, args: MemoryAddress): Int = PySys_AuditTupleHandle.invoke(CLinker.toCString(event, ResourceScope.newConfinedScope()).address(), args) as Int + + + // Section 7 + val Py_FatalErrorHandle: MethodHandle + inline fun Py_FatalError(message: String) = Py_FatalErrorHandle.invoke(CLinker.toCString(message, ResourceScope.newConfinedScope()).address()) as Unit + val Py_ExitHandle: MethodHandle + inline fun Py_Exit(status: Int) = Py_ExitHandle.invoke(status) as Unit + + + // Section 8 + val PyImport_ImportModuleHandle: MethodHandle + inline fun PyImport_ImportModule(name: String): MemoryAddress? = PyImport_ImportModuleHandle.invoke(CLinker.toCString(name, ResourceScope.newConfinedScope()).address()) as MemoryAddress? + val PyImport_ImportModuleNoBlockHandle: MethodHandle + inline fun PyImport_ImportModuleNoBlock(name: String): MemoryAddress? = PyImport_ImportModuleNoBlockHandle.invoke(CLinker.toCString(name, ResourceScope.newConfinedScope()).address()) as MemoryAddress? + val PyImport_ImportModuleLevelObjectHandle: MethodHandle + inline fun PyImport_ImportModuleLevelObject(name: MemoryAddress, globals: MemoryAddress, locals: MemoryAddress, fromlist: MemoryAddress, level: Int): MemoryAddress? = PyImport_ImportModuleLevelObjectHandle.invoke(name, globals, locals, fromlist, level) as MemoryAddress? + val PyImport_ImportModuleLevelHandle: MethodHandle + inline fun PyImport_ImportModuleLevel(name: String, globals: MemoryAddress, locals: MemoryAddress, fromlist: MemoryAddress, level: Int): MemoryAddress? = PyImport_ImportModuleLevelHandle.invoke(CLinker.toCString(name, ResourceScope.newConfinedScope()).address(), globals, locals, fromlist, level) as MemoryAddress? + val PyImport_ImportHandle: MethodHandle + inline fun PyImport_Import(name: MemoryAddress): MemoryAddress? = PyImport_ImportHandle.invoke(name) as MemoryAddress? + val PyImport_ReloadModuleHandle: MethodHandle + inline fun PyImport_ReloadModule(m: MemoryAddress): MemoryAddress? = PyImport_ReloadModuleHandle.invoke(m) as MemoryAddress? + val PyImport_AddModuleRefHandle: MethodHandle + inline fun PyImport_AddModuleRef(name: String): MemoryAddress? = PyImport_AddModuleRefHandle.invoke(CLinker.toCString(name, ResourceScope.newConfinedScope()).address()) as MemoryAddress? + val PyImport_AddModuleObjectHandle: MethodHandle + inline fun PyImport_AddModuleObject(name: MemoryAddress): MemoryAddress? = PyImport_AddModuleObjectHandle.invoke(name) as MemoryAddress? + val PyImport_AddModuleHandle: MethodHandle + inline fun PyImport_AddModule(name: String): MemoryAddress? = PyImport_AddModuleHandle.invoke(CLinker.toCString(name, ResourceScope.newConfinedScope()).address()) as MemoryAddress? + val PyImport_ExecCodeModuleHandle: MethodHandle + inline fun PyImport_ExecCodeModule(name: String, co: MemoryAddress): MemoryAddress? = PyImport_ExecCodeModuleHandle.invoke(CLinker.toCString(name, ResourceScope.newConfinedScope()).address(), co) as MemoryAddress? + val PyImport_ExecCodeModuleExHandle: MethodHandle + inline fun PyImport_ExecCodeModuleEx(name: String, co: MemoryAddress, pathname: String): MemoryAddress? = PyImport_ExecCodeModuleExHandle.invoke(CLinker.toCString(name, ResourceScope.newConfinedScope()).address(), co, CLinker.toCString(pathname, ResourceScope.newConfinedScope()).address()) as MemoryAddress? + val PyImport_ExecCodeModuleObjectHandle: MethodHandle + inline fun PyImport_ExecCodeModuleObject(name: MemoryAddress, co: MemoryAddress, pathname: MemoryAddress, cpathname: MemoryAddress): MemoryAddress? = PyImport_ExecCodeModuleObjectHandle.invoke(name, co, pathname, cpathname) as MemoryAddress? + val PyImport_ExecCodeModuleWithPathnamesHandle: MethodHandle + inline fun PyImport_ExecCodeModuleWithPathnames(name: String, co: MemoryAddress, pathname: String, cpathname: String): MemoryAddress? = PyImport_ExecCodeModuleWithPathnamesHandle.invoke(CLinker.toCString(name, ResourceScope.newConfinedScope()).address(), co, CLinker.toCString(pathname, ResourceScope.newConfinedScope()).address(), CLinker.toCString(cpathname, ResourceScope.newConfinedScope()).address()) as MemoryAddress? + val PyImport_GetMagicTagHandle: MethodHandle + inline fun PyImport_GetMagicTag(): String? = CLinker.toJavaString(PyImport_GetMagicTagHandle.invoke() as MemoryAddress?) + val PyImport_GetModuleDictHandle: MethodHandle + inline fun PyImport_GetModuleDict(): MemoryAddress? = PyImport_GetModuleDictHandle.invoke() as MemoryAddress? + val PyImport_GetModuleHandle: MethodHandle + inline fun PyImport_GetModule(name: MemoryAddress): MemoryAddress? = PyImport_GetModuleHandle.invoke(name) as MemoryAddress? + val PyImport_GetImporterHandle: MethodHandle + inline fun PyImport_GetImporter(path: MemoryAddress): MemoryAddress? = PyImport_GetImporterHandle.invoke(path) as MemoryAddress? + val PyImport_ImportFrozenModuleObjectHandle: MethodHandle + inline fun PyImport_ImportFrozenModuleObject(name: MemoryAddress): Int = PyImport_ImportFrozenModuleObjectHandle.invoke(name) as Int + val PyImport_ImportFrozenModuleHandle: MethodHandle + inline fun PyImport_ImportFrozenModule(name: String): Int = PyImport_ImportFrozenModuleHandle.invoke(CLinker.toCString(name, ResourceScope.newConfinedScope()).address()) as Int + + + // Section 9 + val PyEval_GetBuiltinsHandle: MethodHandle + inline fun PyEval_GetBuiltins(): MemoryAddress? = PyEval_GetBuiltinsHandle.invoke() as MemoryAddress? + val PyEval_GetLocalsHandle: MethodHandle + inline fun PyEval_GetLocals(): MemoryAddress? = PyEval_GetLocalsHandle.invoke() as MemoryAddress? + val PyEval_GetGlobalsHandle: MethodHandle + inline fun PyEval_GetGlobals(): MemoryAddress? = PyEval_GetGlobalsHandle.invoke() as MemoryAddress? + val PyEval_GetFrameBuiltinsHandle: MethodHandle + inline fun PyEval_GetFrameBuiltins(): MemoryAddress? = PyEval_GetFrameBuiltinsHandle.invoke() as MemoryAddress? + val PyEval_GetFrameLocalsHandle: MethodHandle + inline fun PyEval_GetFrameLocals(): MemoryAddress? = PyEval_GetFrameLocalsHandle.invoke() as MemoryAddress? + val PyEval_GetFrameGlobalsHandle: MethodHandle + inline fun PyEval_GetFrameGlobals(): MemoryAddress? = PyEval_GetFrameGlobalsHandle.invoke() as MemoryAddress? + val PyEval_GetFuncNameHandle: MethodHandle + inline fun PyEval_GetFuncName(func: MemoryAddress): String? = CLinker.toJavaString(PyEval_GetFuncNameHandle.invoke(func) as MemoryAddress?) + val PyEval_GetFuncDescHandle: MethodHandle + inline fun PyEval_GetFuncDesc(func: MemoryAddress): String? = CLinker.toJavaString(PyEval_GetFuncDescHandle.invoke(func) as MemoryAddress?) + + + // Section 10 + val PyObject_HasAttrWithErrorHandle: MethodHandle + inline fun PyObject_HasAttrWithError(o: MemoryAddress, attr_name: MemoryAddress): Int = PyObject_HasAttrWithErrorHandle.invoke(o, attr_name) as Int + val PyObject_HasAttrStringWithErrorHandle: MethodHandle + inline fun PyObject_HasAttrStringWithError(o: MemoryAddress, attr_name: String): Int = PyObject_HasAttrStringWithErrorHandle.invoke(o, CLinker.toCString(attr_name, ResourceScope.newConfinedScope()).address()) as Int + val PyObject_HasAttrHandle: MethodHandle + inline fun PyObject_HasAttr(o: MemoryAddress, attr_name: MemoryAddress): Int = PyObject_HasAttrHandle.invoke(o, attr_name) as Int + val PyObject_HasAttrStringHandle: MethodHandle + inline fun PyObject_HasAttrString(o: MemoryAddress, attr_name: String): Int = PyObject_HasAttrStringHandle.invoke(o, CLinker.toCString(attr_name, ResourceScope.newConfinedScope()).address()) as Int + val PyObject_GetAttrHandle: MethodHandle + inline fun PyObject_GetAttr(o: MemoryAddress, attr_name: MemoryAddress): MemoryAddress? = PyObject_GetAttrHandle.invoke(o, attr_name) as MemoryAddress? + val PyObject_GetAttrStringHandle: MethodHandle + inline fun PyObject_GetAttrString(o: MemoryAddress, attr_name: String): MemoryAddress? = PyObject_GetAttrStringHandle.invoke(o, CLinker.toCString(attr_name, ResourceScope.newConfinedScope()).address()) as MemoryAddress? + val PyObject_GenericGetAttrHandle: MethodHandle + inline fun PyObject_GenericGetAttr(o: MemoryAddress, name: MemoryAddress): MemoryAddress? = PyObject_GenericGetAttrHandle.invoke(o, name) as MemoryAddress? + val PyObject_SetAttrHandle: MethodHandle + inline fun PyObject_SetAttr(o: MemoryAddress, attr_name: MemoryAddress, v: MemoryAddress): Int = PyObject_SetAttrHandle.invoke(o, attr_name, v) as Int + val PyObject_SetAttrStringHandle: MethodHandle + inline fun PyObject_SetAttrString(o: MemoryAddress, attr_name: String, v: MemoryAddress): Int = PyObject_SetAttrStringHandle.invoke(o, CLinker.toCString(attr_name, ResourceScope.newConfinedScope()).address(), v) as Int + val PyObject_GenericSetAttrHandle: MethodHandle + inline fun PyObject_GenericSetAttr(o: MemoryAddress, name: MemoryAddress, value: MemoryAddress): Int = PyObject_GenericSetAttrHandle.invoke(o, name, value) as Int + val PyObject_DelAttrHandle: MethodHandle + inline fun PyObject_DelAttr(o: MemoryAddress, attr_name: MemoryAddress): Int = PyObject_DelAttrHandle.invoke(o, attr_name) as Int + val PyObject_DelAttrStringHandle: MethodHandle + inline fun PyObject_DelAttrString(o: MemoryAddress, attr_name: String): Int = PyObject_DelAttrStringHandle.invoke(o, CLinker.toCString(attr_name, ResourceScope.newConfinedScope()).address()) as Int + val PyObject_RichCompareHandle: MethodHandle + inline fun PyObject_RichCompare(o1: MemoryAddress, o2: MemoryAddress, opid: Int): MemoryAddress? = PyObject_RichCompareHandle.invoke(o1, o2, opid) as MemoryAddress? + val PyObject_RichCompareBoolHandle: MethodHandle + inline fun PyObject_RichCompareBool(o1: MemoryAddress, o2: MemoryAddress, opid: Int): Int = PyObject_RichCompareBoolHandle.invoke(o1, o2, opid) as Int + val PyObject_FormatHandle: MethodHandle + inline fun PyObject_Format(obj: MemoryAddress, format_spec: MemoryAddress): MemoryAddress? = PyObject_FormatHandle.invoke(obj, format_spec) as MemoryAddress? + val PyObject_ReprHandle: MethodHandle + inline fun PyObject_Repr(o: MemoryAddress): MemoryAddress? = PyObject_ReprHandle.invoke(o) as MemoryAddress? + val PyObject_ASCIIHandle: MethodHandle + inline fun PyObject_ASCII(o: MemoryAddress): MemoryAddress? = PyObject_ASCIIHandle.invoke(o) as MemoryAddress? + val PyObject_StrHandle: MethodHandle + inline fun PyObject_Str(o: MemoryAddress): MemoryAddress? = PyObject_StrHandle.invoke(o) as MemoryAddress? + val PyObject_BytesHandle: MethodHandle + inline fun PyObject_Bytes(o: MemoryAddress): MemoryAddress? = PyObject_BytesHandle.invoke(o) as MemoryAddress? + val PyObject_IsSubclassHandle: MethodHandle + inline fun PyObject_IsSubclass(derived: MemoryAddress, cls: MemoryAddress): Int = PyObject_IsSubclassHandle.invoke(derived, cls) as Int + val PyObject_IsInstanceHandle: MethodHandle + inline fun PyObject_IsInstance(inst: MemoryAddress, cls: MemoryAddress): Int = PyObject_IsInstanceHandle.invoke(inst, cls) as Int + val PyObject_IsTrueHandle: MethodHandle + inline fun PyObject_IsTrue(o: MemoryAddress): Int = PyObject_IsTrueHandle.invoke(o) as Int + val PyObject_NotHandle: MethodHandle + inline fun PyObject_Not(o: MemoryAddress): Int = PyObject_NotHandle.invoke(o) as Int + val PyObject_TypeHandle: MethodHandle + inline fun PyObject_Type(o: MemoryAddress): MemoryAddress? = PyObject_TypeHandle.invoke(o) as MemoryAddress? + val PyObject_GetItemHandle: MethodHandle + inline fun PyObject_GetItem(o: MemoryAddress, key: MemoryAddress): MemoryAddress? = PyObject_GetItemHandle.invoke(o, key) as MemoryAddress? + val PyObject_SetItemHandle: MethodHandle + inline fun PyObject_SetItem(o: MemoryAddress, key: MemoryAddress, v: MemoryAddress): Int = PyObject_SetItemHandle.invoke(o, key, v) as Int + val PyObject_DelItemHandle: MethodHandle + inline fun PyObject_DelItem(o: MemoryAddress, key: MemoryAddress): Int = PyObject_DelItemHandle.invoke(o, key) as Int + val PyObject_DirHandle: MethodHandle + inline fun PyObject_Dir(o: MemoryAddress): MemoryAddress? = PyObject_DirHandle.invoke(o) as MemoryAddress? + val PyObject_GetIterHandle: MethodHandle + inline fun PyObject_GetIter(o: MemoryAddress): MemoryAddress? = PyObject_GetIterHandle.invoke(o) as MemoryAddress? + val PyObject_GetAIterHandle: MethodHandle + inline fun PyObject_GetAIter(o: MemoryAddress): MemoryAddress? = PyObject_GetAIterHandle.invoke(o) as MemoryAddress? + + + // Section 11 + val PyVectorcall_CallHandle: MethodHandle + inline fun PyVectorcall_Call(callable: MemoryAddress, tuple: MemoryAddress, dict: MemoryAddress): MemoryAddress? = PyVectorcall_CallHandle.invoke(callable, tuple, dict) as MemoryAddress? + val PyObject_CallHandle: MethodHandle + inline fun PyObject_Call(callable: MemoryAddress, args: MemoryAddress, kwargs: MemoryAddress): MemoryAddress? = PyObject_CallHandle.invoke(callable, args, kwargs) as MemoryAddress? + val PyObject_CallNoArgsHandle: MethodHandle + inline fun PyObject_CallNoArgs(callable: MemoryAddress): MemoryAddress? = PyObject_CallNoArgsHandle.invoke(callable) as MemoryAddress? + val PyObject_CallObjectHandle: MethodHandle + inline fun PyObject_CallObject(callable: MemoryAddress, args: MemoryAddress): MemoryAddress? = PyObject_CallObjectHandle.invoke(callable, args) as MemoryAddress? + val PyCallable_CheckHandle: MethodHandle + inline fun PyCallable_Check(o: MemoryAddress): Int = PyCallable_CheckHandle.invoke(o) as Int + + + // Section 12 + val PyNumber_CheckHandle: MethodHandle + inline fun PyNumber_Check(o: MemoryAddress): Int = PyNumber_CheckHandle.invoke(o) as Int + val PyNumber_AddHandle: MethodHandle + inline fun PyNumber_Add(o1: MemoryAddress, o2: MemoryAddress): MemoryAddress? = PyNumber_AddHandle.invoke(o1, o2) as MemoryAddress? + val PyNumber_SubtractHandle: MethodHandle + inline fun PyNumber_Subtract(o1: MemoryAddress, o2: MemoryAddress): MemoryAddress? = PyNumber_SubtractHandle.invoke(o1, o2) as MemoryAddress? + val PyNumber_MultiplyHandle: MethodHandle + inline fun PyNumber_Multiply(o1: MemoryAddress, o2: MemoryAddress): MemoryAddress? = PyNumber_MultiplyHandle.invoke(o1, o2) as MemoryAddress? + val PyNumber_MatrixMultiplyHandle: MethodHandle + inline fun PyNumber_MatrixMultiply(o1: MemoryAddress, o2: MemoryAddress): MemoryAddress? = PyNumber_MatrixMultiplyHandle.invoke(o1, o2) as MemoryAddress? + val PyNumber_FloorDivideHandle: MethodHandle + inline fun PyNumber_FloorDivide(o1: MemoryAddress, o2: MemoryAddress): MemoryAddress? = PyNumber_FloorDivideHandle.invoke(o1, o2) as MemoryAddress? + val PyNumber_TrueDivideHandle: MethodHandle + inline fun PyNumber_TrueDivide(o1: MemoryAddress, o2: MemoryAddress): MemoryAddress? = PyNumber_TrueDivideHandle.invoke(o1, o2) as MemoryAddress? + val PyNumber_RemainderHandle: MethodHandle + inline fun PyNumber_Remainder(o1: MemoryAddress, o2: MemoryAddress): MemoryAddress? = PyNumber_RemainderHandle.invoke(o1, o2) as MemoryAddress? + val PyNumber_DivmodHandle: MethodHandle + inline fun PyNumber_Divmod(o1: MemoryAddress, o2: MemoryAddress): MemoryAddress? = PyNumber_DivmodHandle.invoke(o1, o2) as MemoryAddress? + val PyNumber_PowerHandle: MethodHandle + inline fun PyNumber_Power(o1: MemoryAddress, o2: MemoryAddress, o3: MemoryAddress): MemoryAddress? = PyNumber_PowerHandle.invoke(o1, o2, o3) as MemoryAddress? + val PyNumber_NegativeHandle: MethodHandle + inline fun PyNumber_Negative(o: MemoryAddress): MemoryAddress? = PyNumber_NegativeHandle.invoke(o) as MemoryAddress? + val PyNumber_PositiveHandle: MethodHandle + inline fun PyNumber_Positive(o: MemoryAddress): MemoryAddress? = PyNumber_PositiveHandle.invoke(o) as MemoryAddress? + val PyNumber_AbsoluteHandle: MethodHandle + inline fun PyNumber_Absolute(o: MemoryAddress): MemoryAddress? = PyNumber_AbsoluteHandle.invoke(o) as MemoryAddress? + val PyNumber_InvertHandle: MethodHandle + inline fun PyNumber_Invert(o: MemoryAddress): MemoryAddress? = PyNumber_InvertHandle.invoke(o) as MemoryAddress? + val PyNumber_LshiftHandle: MethodHandle + inline fun PyNumber_Lshift(o1: MemoryAddress, o2: MemoryAddress): MemoryAddress? = PyNumber_LshiftHandle.invoke(o1, o2) as MemoryAddress? + val PyNumber_RshiftHandle: MethodHandle + inline fun PyNumber_Rshift(o1: MemoryAddress, o2: MemoryAddress): MemoryAddress? = PyNumber_RshiftHandle.invoke(o1, o2) as MemoryAddress? + val PyNumber_AndHandle: MethodHandle + inline fun PyNumber_And(o1: MemoryAddress, o2: MemoryAddress): MemoryAddress? = PyNumber_AndHandle.invoke(o1, o2) as MemoryAddress? + val PyNumber_XorHandle: MethodHandle + inline fun PyNumber_Xor(o1: MemoryAddress, o2: MemoryAddress): MemoryAddress? = PyNumber_XorHandle.invoke(o1, o2) as MemoryAddress? + val PyNumber_OrHandle: MethodHandle + inline fun PyNumber_Or(o1: MemoryAddress, o2: MemoryAddress): MemoryAddress? = PyNumber_OrHandle.invoke(o1, o2) as MemoryAddress? + val PyNumber_InPlaceAddHandle: MethodHandle + inline fun PyNumber_InPlaceAdd(o1: MemoryAddress, o2: MemoryAddress): MemoryAddress? = PyNumber_InPlaceAddHandle.invoke(o1, o2) as MemoryAddress? + val PyNumber_InPlaceSubtractHandle: MethodHandle + inline fun PyNumber_InPlaceSubtract(o1: MemoryAddress, o2: MemoryAddress): MemoryAddress? = PyNumber_InPlaceSubtractHandle.invoke(o1, o2) as MemoryAddress? + val PyNumber_InPlaceMultiplyHandle: MethodHandle + inline fun PyNumber_InPlaceMultiply(o1: MemoryAddress, o2: MemoryAddress): MemoryAddress? = PyNumber_InPlaceMultiplyHandle.invoke(o1, o2) as MemoryAddress? + val PyNumber_InPlaceMatrixMultiplyHandle: MethodHandle + inline fun PyNumber_InPlaceMatrixMultiply(o1: MemoryAddress, o2: MemoryAddress): MemoryAddress? = PyNumber_InPlaceMatrixMultiplyHandle.invoke(o1, o2) as MemoryAddress? + val PyNumber_InPlaceFloorDivideHandle: MethodHandle + inline fun PyNumber_InPlaceFloorDivide(o1: MemoryAddress, o2: MemoryAddress): MemoryAddress? = PyNumber_InPlaceFloorDivideHandle.invoke(o1, o2) as MemoryAddress? + val PyNumber_InPlaceTrueDivideHandle: MethodHandle + inline fun PyNumber_InPlaceTrueDivide(o1: MemoryAddress, o2: MemoryAddress): MemoryAddress? = PyNumber_InPlaceTrueDivideHandle.invoke(o1, o2) as MemoryAddress? + val PyNumber_InPlaceRemainderHandle: MethodHandle + inline fun PyNumber_InPlaceRemainder(o1: MemoryAddress, o2: MemoryAddress): MemoryAddress? = PyNumber_InPlaceRemainderHandle.invoke(o1, o2) as MemoryAddress? + val PyNumber_InPlacePowerHandle: MethodHandle + inline fun PyNumber_InPlacePower(o1: MemoryAddress, o2: MemoryAddress, o3: MemoryAddress): MemoryAddress? = PyNumber_InPlacePowerHandle.invoke(o1, o2, o3) as MemoryAddress? + val PyNumber_InPlaceLshiftHandle: MethodHandle + inline fun PyNumber_InPlaceLshift(o1: MemoryAddress, o2: MemoryAddress): MemoryAddress? = PyNumber_InPlaceLshiftHandle.invoke(o1, o2) as MemoryAddress? + val PyNumber_InPlaceRshiftHandle: MethodHandle + inline fun PyNumber_InPlaceRshift(o1: MemoryAddress, o2: MemoryAddress): MemoryAddress? = PyNumber_InPlaceRshiftHandle.invoke(o1, o2) as MemoryAddress? + val PyNumber_InPlaceAndHandle: MethodHandle + inline fun PyNumber_InPlaceAnd(o1: MemoryAddress, o2: MemoryAddress): MemoryAddress? = PyNumber_InPlaceAndHandle.invoke(o1, o2) as MemoryAddress? + val PyNumber_InPlaceXorHandle: MethodHandle + inline fun PyNumber_InPlaceXor(o1: MemoryAddress, o2: MemoryAddress): MemoryAddress? = PyNumber_InPlaceXorHandle.invoke(o1, o2) as MemoryAddress? + val PyNumber_InPlaceOrHandle: MethodHandle + inline fun PyNumber_InPlaceOr(o1: MemoryAddress, o2: MemoryAddress): MemoryAddress? = PyNumber_InPlaceOrHandle.invoke(o1, o2) as MemoryAddress? + val PyNumber_LongHandle: MethodHandle + inline fun PyNumber_Long(o: MemoryAddress): MemoryAddress? = PyNumber_LongHandle.invoke(o) as MemoryAddress? + val PyNumber_FloatHandle: MethodHandle + inline fun PyNumber_Float(o: MemoryAddress): MemoryAddress? = PyNumber_FloatHandle.invoke(o) as MemoryAddress? + val PyNumber_IndexHandle: MethodHandle + inline fun PyNumber_Index(o: MemoryAddress): MemoryAddress? = PyNumber_IndexHandle.invoke(o) as MemoryAddress? + val PyNumber_ToBaseHandle: MethodHandle + inline fun PyNumber_ToBase(n: MemoryAddress, base: Int): MemoryAddress? = PyNumber_ToBaseHandle.invoke(n, base) as MemoryAddress? + val PyIndex_CheckHandle: MethodHandle + inline fun PyIndex_Check(o: MemoryAddress): Int = PyIndex_CheckHandle.invoke(o) as Int + + + // Section 13 + val PySequence_CheckHandle: MethodHandle + inline fun PySequence_Check(o: MemoryAddress): Int = PySequence_CheckHandle.invoke(o) as Int + val PySequence_ConcatHandle: MethodHandle + inline fun PySequence_Concat(o1: MemoryAddress, o2: MemoryAddress): MemoryAddress? = PySequence_ConcatHandle.invoke(o1, o2) as MemoryAddress? + val PySequence_InPlaceConcatHandle: MethodHandle + inline fun PySequence_InPlaceConcat(o1: MemoryAddress, o2: MemoryAddress): MemoryAddress? = PySequence_InPlaceConcatHandle.invoke(o1, o2) as MemoryAddress? + val PySequence_ContainsHandle: MethodHandle + inline fun PySequence_Contains(o: MemoryAddress, value: MemoryAddress): Int = PySequence_ContainsHandle.invoke(o, value) as Int + val PySequence_ListHandle: MethodHandle + inline fun PySequence_List(o: MemoryAddress): MemoryAddress? = PySequence_ListHandle.invoke(o) as MemoryAddress? + val PySequence_TupleHandle: MethodHandle + inline fun PySequence_Tuple(o: MemoryAddress): MemoryAddress? = PySequence_TupleHandle.invoke(o) as MemoryAddress? + val PySequence_FastHandle: MethodHandle + inline fun PySequence_Fast(o: MemoryAddress, m: String): MemoryAddress? = PySequence_FastHandle.invoke(o, CLinker.toCString(m, ResourceScope.newConfinedScope()).address()) as MemoryAddress? + + + // Section 14 + val PyMapping_CheckHandle: MethodHandle + inline fun PyMapping_Check(o: MemoryAddress): Int = PyMapping_CheckHandle.invoke(o) as Int + val PyMapping_GetItemStringHandle: MethodHandle + inline fun PyMapping_GetItemString(o: MemoryAddress, key: String): MemoryAddress? = PyMapping_GetItemStringHandle.invoke(o, CLinker.toCString(key, ResourceScope.newConfinedScope()).address()) as MemoryAddress? + val PyMapping_SetItemStringHandle: MethodHandle + inline fun PyMapping_SetItemString(o: MemoryAddress, key: String, v: MemoryAddress): Int = PyMapping_SetItemStringHandle.invoke(o, CLinker.toCString(key, ResourceScope.newConfinedScope()).address(), v) as Int + val PyMapping_HasKeyWithErrorHandle: MethodHandle + inline fun PyMapping_HasKeyWithError(o: MemoryAddress, key: MemoryAddress): Int = PyMapping_HasKeyWithErrorHandle.invoke(o, key) as Int + val PyMapping_HasKeyStringWithErrorHandle: MethodHandle + inline fun PyMapping_HasKeyStringWithError(o: MemoryAddress, key: String): Int = PyMapping_HasKeyStringWithErrorHandle.invoke(o, CLinker.toCString(key, ResourceScope.newConfinedScope()).address()) as Int + val PyMapping_HasKeyHandle: MethodHandle + inline fun PyMapping_HasKey(o: MemoryAddress, key: MemoryAddress): Int = PyMapping_HasKeyHandle.invoke(o, key) as Int + val PyMapping_HasKeyStringHandle: MethodHandle + inline fun PyMapping_HasKeyString(o: MemoryAddress, key: String): Int = PyMapping_HasKeyStringHandle.invoke(o, CLinker.toCString(key, ResourceScope.newConfinedScope()).address()) as Int + val PyMapping_KeysHandle: MethodHandle + inline fun PyMapping_Keys(o: MemoryAddress): MemoryAddress? = PyMapping_KeysHandle.invoke(o) as MemoryAddress? + val PyMapping_ValuesHandle: MethodHandle + inline fun PyMapping_Values(o: MemoryAddress): MemoryAddress? = PyMapping_ValuesHandle.invoke(o) as MemoryAddress? + val PyMapping_ItemsHandle: MethodHandle + inline fun PyMapping_Items(o: MemoryAddress): MemoryAddress? = PyMapping_ItemsHandle.invoke(o) as MemoryAddress? + + + // Section 15 + val PyIter_CheckHandle: MethodHandle + inline fun PyIter_Check(o: MemoryAddress): Int = PyIter_CheckHandle.invoke(o) as Int + val PyAIter_CheckHandle: MethodHandle + inline fun PyAIter_Check(o: MemoryAddress): Int = PyAIter_CheckHandle.invoke(o) as Int + val PyIter_NextHandle: MethodHandle + inline fun PyIter_Next(o: MemoryAddress): MemoryAddress? = PyIter_NextHandle.invoke(o) as MemoryAddress? + + + // Section 16 + val PyLong_FromLongLongHandle: MethodHandle + inline fun PyLong_FromLongLong(v: Long): MemoryAddress? = PyLong_FromLongLongHandle.invoke(v) as MemoryAddress? + val PyLong_FromDoubleHandle: MethodHandle + inline fun PyLong_FromDouble(v: kotlin.Double): MemoryAddress? = PyLong_FromDoubleHandle.invoke(v) as MemoryAddress? + val PyLong_AsIntHandle: MethodHandle + inline fun PyLong_AsInt(obj: MemoryAddress): Int = PyLong_AsIntHandle.invoke(obj) as Int + val PyLong_AsLongLongHandle: MethodHandle + inline fun PyLong_AsLongLong(obj: MemoryAddress): Long = PyLong_AsLongLongHandle.invoke(obj) as Long + val PyLong_AsDoubleHandle: MethodHandle + inline fun PyLong_AsDouble(pylong: MemoryAddress): kotlin.Double = PyLong_AsDoubleHandle.invoke(pylong) as kotlin.Double + val PyLong_GetInfoHandle: MethodHandle + inline fun PyLong_GetInfo(): MemoryAddress? = PyLong_GetInfoHandle.invoke() as MemoryAddress? + + + // Section 17 + val PyBool_FromLongHandle: MethodHandle + inline fun PyBool_FromLong(v: Long): MemoryAddress? = PyBool_FromLongHandle.invoke(v) as MemoryAddress? + + + // Section 18 + val PyFloat_FromStringHandle: MethodHandle + inline fun PyFloat_FromString(str: MemoryAddress): MemoryAddress? = PyFloat_FromStringHandle.invoke(str) as MemoryAddress? + val PyFloat_FromDoubleHandle: MethodHandle + inline fun PyFloat_FromDouble(v: kotlin.Double): MemoryAddress? = PyFloat_FromDoubleHandle.invoke(v) as MemoryAddress? + val PyFloat_AsDoubleHandle: MethodHandle + inline fun PyFloat_AsDouble(pyfloat: MemoryAddress): kotlin.Double = PyFloat_AsDoubleHandle.invoke(pyfloat) as kotlin.Double + val PyFloat_GetInfoHandle: MethodHandle + inline fun PyFloat_GetInfo(): MemoryAddress? = PyFloat_GetInfoHandle.invoke() as MemoryAddress? + val PyFloat_GetMaxHandle: MethodHandle + inline fun PyFloat_GetMax(): kotlin.Double = PyFloat_GetMaxHandle.invoke() as kotlin.Double + val PyFloat_GetMinHandle: MethodHandle + inline fun PyFloat_GetMin(): kotlin.Double = PyFloat_GetMinHandle.invoke() as kotlin.Double + + + // Section 19 + val PyBytes_FromStringHandle: MethodHandle + inline fun PyBytes_FromString(v: String): MemoryAddress? = PyBytes_FromStringHandle.invoke(CLinker.toCString(v, ResourceScope.newConfinedScope()).address()) as MemoryAddress? + val PyBytes_FromObjectHandle: MethodHandle + inline fun PyBytes_FromObject(o: MemoryAddress): MemoryAddress? = PyBytes_FromObjectHandle.invoke(o) as MemoryAddress? + val PyBytes_AsStringHandle: MethodHandle + inline fun PyBytes_AsString(o: MemoryAddress): String? = CLinker.toJavaString(PyBytes_AsStringHandle.invoke(o) as MemoryAddress?) + + + // Section 20 + val PyByteArray_FromObjectHandle: MethodHandle + inline fun PyByteArray_FromObject(o: MemoryAddress): MemoryAddress? = PyByteArray_FromObjectHandle.invoke(o) as MemoryAddress? + val PyByteArray_ConcatHandle: MethodHandle + inline fun PyByteArray_Concat(a: MemoryAddress, b: MemoryAddress): MemoryAddress? = PyByteArray_ConcatHandle.invoke(a, b) as MemoryAddress? + val PyByteArray_AsStringHandle: MethodHandle + inline fun PyByteArray_AsString(bytearray: MemoryAddress): String? = CLinker.toJavaString(PyByteArray_AsStringHandle.invoke(bytearray) as MemoryAddress?) + + + // Section 21 + val PyUnicode_IsIdentifierHandle: MethodHandle + inline fun PyUnicode_IsIdentifier(unicode: MemoryAddress): Int = PyUnicode_IsIdentifierHandle.invoke(unicode) as Int + val PyUnicode_FromStringHandle: MethodHandle + inline fun PyUnicode_FromString(str: String): MemoryAddress? = PyUnicode_FromStringHandle.invoke(CLinker.toCString(str, ResourceScope.newConfinedScope()).address()) as MemoryAddress? + val PyUnicode_FromObjectHandle: MethodHandle + inline fun PyUnicode_FromObject(obj: MemoryAddress): MemoryAddress? = PyUnicode_FromObjectHandle.invoke(obj) as MemoryAddress? + val PyUnicode_FromEncodedObjectHandle: MethodHandle + inline fun PyUnicode_FromEncodedObject(obj: MemoryAddress, encoding: String, errors: String): MemoryAddress? = PyUnicode_FromEncodedObjectHandle.invoke(obj, CLinker.toCString(encoding, ResourceScope.newConfinedScope()).address(), CLinker.toCString(errors, ResourceScope.newConfinedScope()).address()) as MemoryAddress? + val PyUnicode_DecodeLocaleHandle: MethodHandle + inline fun PyUnicode_DecodeLocale(str: String, errors: String): MemoryAddress? = PyUnicode_DecodeLocaleHandle.invoke(CLinker.toCString(str, ResourceScope.newConfinedScope()).address(), CLinker.toCString(errors, ResourceScope.newConfinedScope()).address()) as MemoryAddress? + val PyUnicode_EncodeLocaleHandle: MethodHandle + inline fun PyUnicode_EncodeLocale(unicode: MemoryAddress, errors: String): MemoryAddress? = PyUnicode_EncodeLocaleHandle.invoke(unicode, CLinker.toCString(errors, ResourceScope.newConfinedScope()).address()) as MemoryAddress? + val PyUnicode_DecodeFSDefaultHandle: MethodHandle + inline fun PyUnicode_DecodeFSDefault(str: String): MemoryAddress? = PyUnicode_DecodeFSDefaultHandle.invoke(CLinker.toCString(str, ResourceScope.newConfinedScope()).address()) as MemoryAddress? + val PyUnicode_EncodeFSDefaultHandle: MethodHandle + inline fun PyUnicode_EncodeFSDefault(unicode: MemoryAddress): MemoryAddress? = PyUnicode_EncodeFSDefaultHandle.invoke(unicode) as MemoryAddress? + val PyUnicode_AsEncodedStringHandle: MethodHandle + inline fun PyUnicode_AsEncodedString(unicode: MemoryAddress, encoding: String, errors: String): MemoryAddress? = PyUnicode_AsEncodedStringHandle.invoke(unicode, CLinker.toCString(encoding, ResourceScope.newConfinedScope()).address(), CLinker.toCString(errors, ResourceScope.newConfinedScope()).address()) as MemoryAddress? + val PyUnicode_AsUTF8StringHandle: MethodHandle + inline fun PyUnicode_AsUTF8String(unicode: MemoryAddress): MemoryAddress? = PyUnicode_AsUTF8StringHandle.invoke(unicode) as MemoryAddress? + val PyUnicode_AsUTF8Handle: MethodHandle // 수동 추가 + inline fun PyUnicode_AsUTF8(unicode: MemoryAddress): String? = CLinker.toJavaString(PyUnicode_AsUTF8Handle.invoke(unicode) as MemoryAddress?) + val PyUnicode_AsUTF32StringHandle: MethodHandle + inline fun PyUnicode_AsUTF32String(unicode: MemoryAddress): MemoryAddress? = PyUnicode_AsUTF32StringHandle.invoke(unicode) as MemoryAddress? + val PyUnicode_AsUTF16StringHandle: MethodHandle + inline fun PyUnicode_AsUTF16String(unicode: MemoryAddress): MemoryAddress? = PyUnicode_AsUTF16StringHandle.invoke(unicode) as MemoryAddress? + val PyUnicode_AsUnicodeEscapeStringHandle: MethodHandle + inline fun PyUnicode_AsUnicodeEscapeString(unicode: MemoryAddress): MemoryAddress? = PyUnicode_AsUnicodeEscapeStringHandle.invoke(unicode) as MemoryAddress? + val PyUnicode_AsRawUnicodeEscapeStringHandle: MethodHandle + inline fun PyUnicode_AsRawUnicodeEscapeString(unicode: MemoryAddress): MemoryAddress? = PyUnicode_AsRawUnicodeEscapeStringHandle.invoke(unicode) as MemoryAddress? + val PyUnicode_AsLatin1StringHandle: MethodHandle + inline fun PyUnicode_AsLatin1String(unicode: MemoryAddress): MemoryAddress? = PyUnicode_AsLatin1StringHandle.invoke(unicode) as MemoryAddress? + val PyUnicode_AsASCIIStringHandle: MethodHandle + inline fun PyUnicode_AsASCIIString(unicode: MemoryAddress): MemoryAddress? = PyUnicode_AsASCIIStringHandle.invoke(unicode) as MemoryAddress? + val PyUnicode_AsCharmapStringHandle: MethodHandle + inline fun PyUnicode_AsCharmapString(unicode: MemoryAddress, mapping: MemoryAddress): MemoryAddress? = PyUnicode_AsCharmapStringHandle.invoke(unicode, mapping) as MemoryAddress? + val PyUnicode_TranslateHandle: MethodHandle + inline fun PyUnicode_Translate(unicode: MemoryAddress, table: MemoryAddress, errors: String): MemoryAddress? = PyUnicode_TranslateHandle.invoke(unicode, table, CLinker.toCString(errors, ResourceScope.newConfinedScope()).address()) as MemoryAddress? + val PyUnicode_ConcatHandle: MethodHandle + inline fun PyUnicode_Concat(left: MemoryAddress, right: MemoryAddress): MemoryAddress? = PyUnicode_ConcatHandle.invoke(left, right) as MemoryAddress? + val PyUnicode_SplitlinesHandle: MethodHandle + inline fun PyUnicode_Splitlines(unicode: MemoryAddress, keepends: Int): MemoryAddress? = PyUnicode_SplitlinesHandle.invoke(unicode, keepends) as MemoryAddress? + val PyUnicode_JoinHandle: MethodHandle + inline fun PyUnicode_Join(separator: MemoryAddress, seq: MemoryAddress): MemoryAddress? = PyUnicode_JoinHandle.invoke(separator, seq) as MemoryAddress? + val PyUnicode_CompareHandle: MethodHandle + inline fun PyUnicode_Compare(left: MemoryAddress, right: MemoryAddress): Int = PyUnicode_CompareHandle.invoke(left, right) as Int + val PyUnicode_EqualToUTF8Handle: MethodHandle + inline fun PyUnicode_EqualToUTF8(unicode: MemoryAddress, string: String): Int = PyUnicode_EqualToUTF8Handle.invoke(unicode, CLinker.toCString(string, ResourceScope.newConfinedScope()).address()) as Int + val PyUnicode_CompareWithASCIIStringHandle: MethodHandle + inline fun PyUnicode_CompareWithASCIIString(unicode: MemoryAddress, string: String): Int = PyUnicode_CompareWithASCIIStringHandle.invoke(unicode, CLinker.toCString(string, ResourceScope.newConfinedScope()).address()) as Int + val PyUnicode_RichCompareHandle: MethodHandle + inline fun PyUnicode_RichCompare(left: MemoryAddress, right: MemoryAddress, op: Int): MemoryAddress? = PyUnicode_RichCompareHandle.invoke(left, right, op) as MemoryAddress? + val PyUnicode_FormatHandle: MethodHandle + inline fun PyUnicode_Format(format: MemoryAddress, args: MemoryAddress): MemoryAddress? = PyUnicode_FormatHandle.invoke(format, args) as MemoryAddress? + val PyUnicode_ContainsHandle: MethodHandle + inline fun PyUnicode_Contains(unicode: MemoryAddress, substr: MemoryAddress): Int = PyUnicode_ContainsHandle.invoke(unicode, substr) as Int + val PyUnicode_InternFromStringHandle: MethodHandle + inline fun PyUnicode_InternFromString(str: String): MemoryAddress? = PyUnicode_InternFromStringHandle.invoke(CLinker.toCString(str, ResourceScope.newConfinedScope()).address()) as MemoryAddress? + + + // Section 22 + val PyList_AppendHandle: MethodHandle + inline fun PyList_Append(list: MemoryAddress, item: MemoryAddress): Int = PyList_AppendHandle.invoke(list, item) as Int + val PyList_SortHandle: MethodHandle + inline fun PyList_Sort(list: MemoryAddress): Int = PyList_SortHandle.invoke(list) as Int + val PyList_ReverseHandle: MethodHandle + inline fun PyList_Reverse(list: MemoryAddress): Int = PyList_ReverseHandle.invoke(list) as Int + val PyList_AsTupleHandle: MethodHandle + inline fun PyList_AsTuple(list: MemoryAddress): MemoryAddress? = PyList_AsTupleHandle.invoke(list) as MemoryAddress? + + + // Section 23 + val PyDict_NewHandle: MethodHandle + inline fun PyDict_New(): MemoryAddress? = PyDict_NewHandle.invoke() as MemoryAddress? + val PyDictProxy_NewHandle: MethodHandle + inline fun PyDictProxy_New(mapping: MemoryAddress): MemoryAddress? = PyDictProxy_NewHandle.invoke(mapping) as MemoryAddress? + val PyDict_ClearHandle: MethodHandle + inline fun PyDict_Clear(p: MemoryAddress) = PyDict_ClearHandle.invoke(p) as Unit + val PyDict_ContainsHandle: MethodHandle + inline fun PyDict_Contains(p: MemoryAddress, key: MemoryAddress): Int = PyDict_ContainsHandle.invoke(p, key) as Int + val PyDict_CopyHandle: MethodHandle + inline fun PyDict_Copy(p: MemoryAddress): MemoryAddress? = PyDict_CopyHandle.invoke(p) as MemoryAddress? + val PyDict_SetItemHandle: MethodHandle + inline fun PyDict_SetItem(p: MemoryAddress, key: MemoryAddress, v: MemoryAddress): Int = PyDict_SetItemHandle.invoke(p, key, v) as Int + val PyDict_SetItemStringHandle: MethodHandle + inline fun PyDict_SetItemString(p: MemoryAddress, key: String, v: MemoryAddress): Int = PyDict_SetItemStringHandle.invoke(p, CLinker.toCString(key, ResourceScope.newConfinedScope()).address(), v) as Int + val PyDict_DelItemHandle: MethodHandle + inline fun PyDict_DelItem(p: MemoryAddress, key: MemoryAddress): Int = PyDict_DelItemHandle.invoke(p, key) as Int + val PyDict_DelItemStringHandle: MethodHandle + inline fun PyDict_DelItemString(p: MemoryAddress, key: String): Int = PyDict_DelItemStringHandle.invoke(p, CLinker.toCString(key, ResourceScope.newConfinedScope()).address()) as Int + val PyDict_GetItemHandle: MethodHandle + inline fun PyDict_GetItem(p: MemoryAddress, key: MemoryAddress): MemoryAddress? = PyDict_GetItemHandle.invoke(p, key) as MemoryAddress? + val PyDict_GetItemWithErrorHandle: MethodHandle + inline fun PyDict_GetItemWithError(p: MemoryAddress, key: MemoryAddress): MemoryAddress? = PyDict_GetItemWithErrorHandle.invoke(p, key) as MemoryAddress? + val PyDict_GetItemStringHandle: MethodHandle + inline fun PyDict_GetItemString(p: MemoryAddress, key: String): MemoryAddress? = PyDict_GetItemStringHandle.invoke(p, CLinker.toCString(key, ResourceScope.newConfinedScope()).address()) as MemoryAddress? + val PyDict_ItemsHandle: MethodHandle + inline fun PyDict_Items(p: MemoryAddress): MemoryAddress? = PyDict_ItemsHandle.invoke(p) as MemoryAddress? + val PyDict_KeysHandle: MethodHandle + inline fun PyDict_Keys(p: MemoryAddress): MemoryAddress? = PyDict_KeysHandle.invoke(p) as MemoryAddress? + val PyDict_ValuesHandle: MethodHandle + inline fun PyDict_Values(p: MemoryAddress): MemoryAddress? = PyDict_ValuesHandle.invoke(p) as MemoryAddress? + val PyDict_MergeHandle: MethodHandle + inline fun PyDict_Merge(a: MemoryAddress, b: MemoryAddress, override: Int): Int = PyDict_MergeHandle.invoke(a, b, override) as Int + val PyDict_UpdateHandle: MethodHandle + inline fun PyDict_Update(a: MemoryAddress, b: MemoryAddress): Int = PyDict_UpdateHandle.invoke(a, b) as Int + val PyDict_MergeFromSeq2Handle: MethodHandle + inline fun PyDict_MergeFromSeq2(a: MemoryAddress, seq2: MemoryAddress, override: Int): Int = PyDict_MergeFromSeq2Handle.invoke(a, seq2, override) as Int + + + // Section 24 + val PySet_NewHandle: MethodHandle + inline fun PySet_New(iterable: MemoryAddress): MemoryAddress? = PySet_NewHandle.invoke(iterable) as MemoryAddress? + val PyFrozenSet_NewHandle: MethodHandle + inline fun PyFrozenSet_New(iterable: MemoryAddress): MemoryAddress? = PyFrozenSet_NewHandle.invoke(iterable) as MemoryAddress? + val PySet_ContainsHandle: MethodHandle + inline fun PySet_Contains(anyset: MemoryAddress, key: MemoryAddress): Int = PySet_ContainsHandle.invoke(anyset, key) as Int + val PySet_AddHandle: MethodHandle + inline fun PySet_Add(set: MemoryAddress, key: MemoryAddress): Int = PySet_AddHandle.invoke(set, key) as Int + val PySet_DiscardHandle: MethodHandle + inline fun PySet_Discard(set: MemoryAddress, key: MemoryAddress): Int = PySet_DiscardHandle.invoke(set, key) as Int + val PySet_PopHandle: MethodHandle + inline fun PySet_Pop(set: MemoryAddress): MemoryAddress? = PySet_PopHandle.invoke(set) as MemoryAddress? + val PySet_ClearHandle: MethodHandle + inline fun PySet_Clear(set: MemoryAddress): Int = PySet_ClearHandle.invoke(set) as Int + + + // Section 25 + val PySeqIter_NewHandle: MethodHandle + inline fun PySeqIter_New(seq: MemoryAddress): MemoryAddress? = PySeqIter_NewHandle.invoke(seq) as MemoryAddress? + val PyCallIter_NewHandle: MethodHandle + inline fun PyCallIter_New(callable: MemoryAddress, sentinel: MemoryAddress): MemoryAddress? = PyCallIter_NewHandle.invoke(callable, sentinel) as MemoryAddress? + + + // Section 26 + val PyWeakref_NewRefHandle: MethodHandle + inline fun PyWeakref_NewRef(ob: MemoryAddress, callback: MemoryAddress): MemoryAddress? = PyWeakref_NewRefHandle.invoke(ob, callback) as MemoryAddress? + val PyWeakref_NewProxyHandle: MethodHandle + inline fun PyWeakref_NewProxy(ob: MemoryAddress, callback: MemoryAddress): MemoryAddress? = PyWeakref_NewProxyHandle.invoke(ob, callback) as MemoryAddress? + val PyWeakref_GetObjectHandle: MethodHandle + inline fun PyWeakref_GetObject(ref: MemoryAddress): MemoryAddress? = PyWeakref_GetObjectHandle.invoke(ref) as MemoryAddress? + val PyObject_ClearWeakRefsHandle: MethodHandle + inline fun PyObject_ClearWeakRefs(o: MemoryAddress) = PyObject_ClearWeakRefsHandle.invoke(o) as Unit + + + // Section 27 + val PyType_IsSubtypeHandle: MethodHandle + inline fun PyType_IsSubtype(a: MemoryAddress, b: MemoryAddress): Int = PyType_IsSubtypeHandle.invoke(a, b) as Int + val PyType_ReadyHandle: MethodHandle + inline fun PyType_Ready(type: MemoryAddress): Int = PyType_ReadyHandle.invoke(type) as Int + val PyType_GetNameHandle: MethodHandle + inline fun PyType_GetName(type: MemoryAddress): MemoryAddress? = PyType_GetNameHandle.invoke(type) as MemoryAddress? + val PyType_GetFullyQualifiedName: MethodHandle + inline fun PyType_GetFullyQualifiedName(type: MemoryAddress): MemoryAddress? = PyType_GetFullyQualifiedName.invoke(type) as MemoryAddress? + val PyType_GetModuleNameHandle: MethodHandle + inline fun PyType_GetModuleName(type: MemoryAddress): MemoryAddress? = PyType_GetModuleNameHandle.invoke(type) as MemoryAddress? + val PyType_GetModuleHandle: MethodHandle + inline fun PyType_GetModule(type: MemoryAddress): MemoryAddress? = PyType_GetModuleHandle.invoke(type) as MemoryAddress? + + + // Section 28 + val PyTuple_NewHandle: MethodHandle + fun PyTuple_New(len: Long): MemoryAddress? = PyTuple_NewHandle.invoke(len) as MemoryAddress? + val PyTuple_SizeHandle: MethodHandle + inline fun PyTuple_Size(p: MemoryAddress): Long = PyTuple_SizeHandle.invoke(p) as Long + val PyTuple_GetItemHandle: MethodHandle + fun PyTuple_GetItem(p: MemoryAddress, pos: Long): MemoryAddress? = PyTuple_GetItemHandle.invoke(p, pos) as MemoryAddress? + val PyTuple_GetSliceHandle: MethodHandle + fun PyTuple_GetSlice(p: MemoryAddress, low: Long, high: Long): MemoryAddress? = PyTuple_GetSliceHandle.invoke(p, low, high) as MemoryAddress? + val PyTuple_SetItemHandle: MethodHandle + inline fun PyTuple_SetItem(p: MemoryAddress, pos: Long, o: MemoryAddress): Int = PyTuple_SetItemHandle.invoke(p, pos, o) as Int + init { ResourceScope.newConfinedScope().run { val lookup = MethodLookup(manager::loadLibPython) + /** Py_InitializeHandle = lookup.find("Py_Initialize", Void.TYPE) Py_InitializeExHandle = lookup.find("Py_InitializeEx", Void.TYPE, Integer.TYPE) //Py_InitializeFromConfigHandle = lookup.find("Py_InitializeFromConfig", Void.TYPE) @@ -110,6 +784,385 @@ object bindings { PyUnicode_FromStringHandle = lookup.find("PyUnicode_FromString", MemoryAddress::class.java, MemoryAddress::class.java) PyUnicode_AsUTF8Handle = lookup.find("PyUnicode_AsUTF8", MemoryAddress::class.java, MemoryAddress::class.java) + */ + + + //************************************************** + // Section 1 + Py_InitializeHandle = lookup.find("Py_Initialize", Void.TYPE) + Py_InitializeExHandle = lookup.find("Py_InitializeEx", Void.TYPE, Integer.TYPE) + Py_IsInitializedHandle = lookup.find("Py_IsInitialized", Integer.TYPE) + Py_IsFinalizingHandle = lookup.find("Py_IsFinalizing", Integer.TYPE) + Py_FinalizeExHandle = lookup.find("Py_FinalizeEx", Integer.TYPE) + Py_FinalizeHandle = lookup.find("Py_Finalize", Void.TYPE) + Py_RunMainHandle = lookup.find("Py_FinalizeEx", Integer.TYPE) // TODO: Fix this // 수동 추가 + Py_GetVersionHandle = lookup.find("Py_GetVersion", MemoryAddress::class.java) + Py_GetPlatformHandle = lookup.find("Py_GetPlatform", MemoryAddress::class.java) + Py_GetCopyrightHandle = lookup.find("Py_GetCopyright", MemoryAddress::class.java) + Py_GetCompilerHandle = lookup.find("Py_GetCompiler", MemoryAddress::class.java) + Py_GetBuildInfoHandle = lookup.find("Py_GetBuildInfo", MemoryAddress::class.java) + PyEval_InitThreadsHandle = lookup.find("PyEval_InitThreads", Void.TYPE) + PyThreadState_GetDictHandle = lookup.find("PyThreadState_GetDict", MemoryAddress::class.java) + + + // Section 2 + PyRun_SimpleStringHandle = lookup.find("PyRun_SimpleString", Integer.TYPE, MemoryAddress::class.java) // 수동 추가 + PyRun_StringHandle = lookup.find("PyRun_String", MemoryAddress::class.java, MemoryAddress::class.java, Integer.TYPE, MemoryAddress::class.java, MemoryAddress::class.java) // 수동 추가 + Py_CompileStringHandle = lookup.find("Py_CompileString", MemoryAddress::class.java, MemoryAddress::class.java, MemoryAddress::class.java, Integer.TYPE) + PyEval_EvalCodeHandle = lookup.find("PyEval_EvalCode", MemoryAddress::class.java, MemoryAddress::class.java, MemoryAddress::class.java, MemoryAddress::class.java) + + + // Section 3 + PyErr_ClearHandle = lookup.find("PyErr_Clear", Void.TYPE) + PyErr_PrintExHandle = lookup.find("PyErr_PrintEx", Void.TYPE, Integer.TYPE) + PyErr_PrintHandle = lookup.find("PyErr_Print", Void.TYPE) + PyErr_WriteUnraisableHandle = lookup.find("PyErr_WriteUnraisable", Void.TYPE, MemoryAddress::class.java) + PyErr_DisplayExceptionHandle = lookup.find("PyErr_DisplayException", Void.TYPE, MemoryAddress::class.java) + PyErr_SetStringHandle = lookup.find("PyErr_SetString", Void.TYPE, MemoryAddress::class.java, MemoryAddress::class.java) + PyErr_SetObjectHandle = lookup.find("PyErr_SetObject", Void.TYPE, MemoryAddress::class.java, MemoryAddress::class.java) + PyErr_SetNoneHandle = lookup.find("PyErr_SetNone", Void.TYPE, MemoryAddress::class.java) + PyErr_BadArgumentHandle = lookup.find("PyErr_BadArgument", Integer.TYPE) + PyErr_NoMemoryHandle = lookup.find("PyErr_NoMemory", MemoryAddress::class.java) + PyErr_SetFromErrnoHandle = lookup.find("PyErr_SetFromErrno", MemoryAddress::class.java, MemoryAddress::class.java) + PyErr_SetFromErrnoWithFilenameObjectHandle = lookup.find("PyErr_SetFromErrnoWithFilenameObject", MemoryAddress::class.java, MemoryAddress::class.java, MemoryAddress::class.java) + PyErr_SetFromErrnoWithFilenameObjectsHandle = lookup.find("PyErr_SetFromErrnoWithFilenameObjects", MemoryAddress::class.java, MemoryAddress::class.java, MemoryAddress::class.java, MemoryAddress::class.java) + PyErr_SetFromErrnoWithFilenameHandle = lookup.find("PyErr_SetFromErrnoWithFilename", MemoryAddress::class.java, MemoryAddress::class.java, MemoryAddress::class.java) + PyErr_SetImportErrorHandle = lookup.find("PyErr_SetImportError", MemoryAddress::class.java, MemoryAddress::class.java, MemoryAddress::class.java, MemoryAddress::class.java) + PyErr_SetImportErrorSubclassHandle = lookup.find("PyErr_SetImportErrorSubclass", MemoryAddress::class.java, MemoryAddress::class.java, MemoryAddress::class.java, MemoryAddress::class.java, MemoryAddress::class.java) + PyErr_SyntaxLocationExHandle = lookup.find("PyErr_SyntaxLocationEx", Void.TYPE, MemoryAddress::class.java, Integer.TYPE, Integer.TYPE) + PyErr_SyntaxLocationHandle = lookup.find("PyErr_SyntaxLocation", Void.TYPE, MemoryAddress::class.java, Integer.TYPE) + PyErr_BadInternalCallHandle = lookup.find("PyErr_BadInternalCall", Void.TYPE) + PyErr_WarnExplicitHandle = lookup.find("PyErr_WarnExplicit", Integer.TYPE, MemoryAddress::class.java, MemoryAddress::class.java, MemoryAddress::class.java, Integer.TYPE, MemoryAddress::class.java, MemoryAddress::class.java) + PyErr_OccurredHandle = lookup.find("PyErr_Occurred", MemoryAddress::class.java) + PyErr_ExceptionMatchesHandle = lookup.find("PyErr_ExceptionMatches", Integer.TYPE, MemoryAddress::class.java) + PyErr_GivenExceptionMatchesHandle = lookup.find("PyErr_GivenExceptionMatches", Integer.TYPE, MemoryAddress::class.java, MemoryAddress::class.java) + PyErr_GetRaisedExceptionHandle = lookup.find("PyErr_GetRaisedException", MemoryAddress::class.java) + PyErr_SetRaisedExceptionHandle = lookup.find("PyErr_SetRaisedException", Void.TYPE, MemoryAddress::class.java) + PyErr_RestoreHandle = lookup.find("PyErr_Restore", Void.TYPE, MemoryAddress::class.java, MemoryAddress::class.java, MemoryAddress::class.java) + PyErr_GetHandledExceptionHandle = lookup.find("PyErr_GetHandledException", MemoryAddress::class.java) + PyErr_SetHandledExceptionHandle = lookup.find("PyErr_SetHandledException", Void.TYPE, MemoryAddress::class.java) + PyErr_SetExcInfoHandle = lookup.find("PyErr_SetExcInfo", Void.TYPE, MemoryAddress::class.java, MemoryAddress::class.java, MemoryAddress::class.java) + PyErr_CheckSignalsHandle = lookup.find("PyErr_CheckSignals", Integer.TYPE) + PyErr_SetInterruptHandle = lookup.find("PyErr_SetInterrupt", Void.TYPE) + PyErr_SetInterruptExHandle = lookup.find("PyErr_SetInterruptEx", Integer.TYPE, Integer.TYPE) + PyErr_NewExceptionHandle = lookup.find("PyErr_NewException", MemoryAddress::class.java, MemoryAddress::class.java, MemoryAddress::class.java, MemoryAddress::class.java) + PyErr_NewExceptionWithDocHandle = lookup.find("PyErr_NewExceptionWithDoc", MemoryAddress::class.java, MemoryAddress::class.java, MemoryAddress::class.java, MemoryAddress::class.java, MemoryAddress::class.java) + PyException_GetTracebackHandle = lookup.find("PyException_GetTraceback", MemoryAddress::class.java, MemoryAddress::class.java) + PyException_SetTracebackHandle = lookup.find("PyException_SetTraceback", Integer.TYPE, MemoryAddress::class.java, MemoryAddress::class.java) + PyException_GetContextHandle = lookup.find("PyException_GetContext", MemoryAddress::class.java, MemoryAddress::class.java) + PyException_SetContextHandle = lookup.find("PyException_SetContext", Void.TYPE, MemoryAddress::class.java, MemoryAddress::class.java) + PyException_GetCauseHandle = lookup.find("PyException_GetCause", MemoryAddress::class.java, MemoryAddress::class.java) + PyException_SetCauseHandle = lookup.find("PyException_SetCause", Void.TYPE, MemoryAddress::class.java, MemoryAddress::class.java) + PyException_GetArgsHandle = lookup.find("PyException_GetArgs", MemoryAddress::class.java, MemoryAddress::class.java) + PyException_SetArgsHandle = lookup.find("PyException_SetArgs", Void.TYPE, MemoryAddress::class.java, MemoryAddress::class.java) + PyUnicodeEncodeError_GetEncodingHandle = lookup.find("PyUnicodeEncodeError_GetEncoding", MemoryAddress::class.java, MemoryAddress::class.java) + PyUnicodeTranslateError_GetObjectHandle = lookup.find("PyUnicodeTranslateError_GetObject", MemoryAddress::class.java, MemoryAddress::class.java) + PyUnicodeTranslateError_GetReasonHandle = lookup.find("PyUnicodeTranslateError_GetReason", MemoryAddress::class.java, MemoryAddress::class.java) + PyUnicodeTranslateError_SetReasonHandle = lookup.find("PyUnicodeTranslateError_SetReason", Integer.TYPE, MemoryAddress::class.java, MemoryAddress::class.java) + Py_EnterRecursiveCallHandle = lookup.find("Py_EnterRecursiveCall", Integer.TYPE, MemoryAddress::class.java) + Py_LeaveRecursiveCallHandle = lookup.find("Py_LeaveRecursiveCall", Void.TYPE) + Py_ReprEnterHandle = lookup.find("Py_ReprEnter", Integer.TYPE, MemoryAddress::class.java) + Py_ReprLeaveHandle = lookup.find("Py_ReprLeave", Void.TYPE, MemoryAddress::class.java) + + + // Section 4 + Py_NewRefHandle = lookup.find("Py_NewRef", MemoryAddress::class.java, MemoryAddress::class.java) + Py_XNewRefHandle = lookup.find("Py_XNewRef", MemoryAddress::class.java, MemoryAddress::class.java) + Py_IncRefHandle = lookup.find("Py_IncRef", Void.TYPE, MemoryAddress::class.java) + Py_DecRefHandle = lookup.find("Py_DecRef", Void.TYPE, MemoryAddress::class.java) + + + // Section 5 + PyOS_FSPathHandle = lookup.find("PyOS_FSPath", MemoryAddress::class.java, MemoryAddress::class.java) + + + // Section 6 + PySys_GetObjectHandle = lookup.find("PySys_GetObject", MemoryAddress::class.java, MemoryAddress::class.java) + PySys_SetObjectHandle = lookup.find("PySys_SetObject", Integer.TYPE, MemoryAddress::class.java, MemoryAddress::class.java) + PySys_ResetWarnOptionsHandle = lookup.find("PySys_ResetWarnOptions", Void.TYPE) + PySys_GetXOptionsHandle = lookup.find("PySys_GetXOptions", MemoryAddress::class.java) + PySys_AuditTupleHandle = lookup.find("PySys_AuditTuple", Integer.TYPE, MemoryAddress::class.java, MemoryAddress::class.java) + + + // Section 7 + Py_FatalErrorHandle = lookup.find("Py_FatalError", Void.TYPE, MemoryAddress::class.java) + Py_ExitHandle = lookup.find("Py_Exit", Void.TYPE, Integer.TYPE) + + + // Section 8 + PyImport_ImportModuleHandle = lookup.find("PyImport_ImportModule", MemoryAddress::class.java, MemoryAddress::class.java) + PyImport_ImportModuleNoBlockHandle = lookup.find("PyImport_ImportModuleNoBlock", MemoryAddress::class.java, MemoryAddress::class.java) + PyImport_ImportModuleLevelObjectHandle = lookup.find("PyImport_ImportModuleLevelObject", MemoryAddress::class.java, MemoryAddress::class.java, MemoryAddress::class.java, MemoryAddress::class.java, MemoryAddress::class.java, Integer.TYPE) + PyImport_ImportModuleLevelHandle = lookup.find("PyImport_ImportModuleLevel", MemoryAddress::class.java, MemoryAddress::class.java, MemoryAddress::class.java, MemoryAddress::class.java, MemoryAddress::class.java, Integer.TYPE) + PyImport_ImportHandle = lookup.find("PyImport_Import", MemoryAddress::class.java, MemoryAddress::class.java) + PyImport_ReloadModuleHandle = lookup.find("PyImport_ReloadModule", MemoryAddress::class.java, MemoryAddress::class.java) + PyImport_AddModuleRefHandle = lookup.find("PyImport_AddModuleRef", MemoryAddress::class.java, MemoryAddress::class.java) + PyImport_AddModuleObjectHandle = lookup.find("PyImport_AddModuleObject", MemoryAddress::class.java, MemoryAddress::class.java) + PyImport_AddModuleHandle = lookup.find("PyImport_AddModule", MemoryAddress::class.java, MemoryAddress::class.java) + PyImport_ExecCodeModuleHandle = lookup.find("PyImport_ExecCodeModule", MemoryAddress::class.java, MemoryAddress::class.java, MemoryAddress::class.java) + PyImport_ExecCodeModuleExHandle = lookup.find("PyImport_ExecCodeModuleEx", MemoryAddress::class.java, MemoryAddress::class.java, MemoryAddress::class.java, MemoryAddress::class.java) + PyImport_ExecCodeModuleObjectHandle = lookup.find("PyImport_ExecCodeModuleObject", MemoryAddress::class.java, MemoryAddress::class.java, MemoryAddress::class.java, MemoryAddress::class.java, MemoryAddress::class.java) + PyImport_ExecCodeModuleWithPathnamesHandle = lookup.find("PyImport_ExecCodeModuleWithPathnames", MemoryAddress::class.java, MemoryAddress::class.java, MemoryAddress::class.java, MemoryAddress::class.java, MemoryAddress::class.java) + PyImport_GetMagicTagHandle = lookup.find("PyImport_GetMagicTag", MemoryAddress::class.java) + PyImport_GetModuleDictHandle = lookup.find("PyImport_GetModuleDict", MemoryAddress::class.java) + PyImport_GetModuleHandle = lookup.find("PyImport_GetModule", MemoryAddress::class.java, MemoryAddress::class.java) + PyImport_GetImporterHandle = lookup.find("PyImport_GetImporter", MemoryAddress::class.java, MemoryAddress::class.java) + PyImport_ImportFrozenModuleObjectHandle = lookup.find("PyImport_ImportFrozenModuleObject", Integer.TYPE, MemoryAddress::class.java) + PyImport_ImportFrozenModuleHandle = lookup.find("PyImport_ImportFrozenModule", Integer.TYPE, MemoryAddress::class.java) + + + // Section 9 + PyEval_GetBuiltinsHandle = lookup.find("PyEval_GetBuiltins", MemoryAddress::class.java) + PyEval_GetLocalsHandle = lookup.find("PyEval_GetLocals", MemoryAddress::class.java) + PyEval_GetGlobalsHandle = lookup.find("PyEval_GetGlobals", MemoryAddress::class.java) + PyEval_GetFrameBuiltinsHandle = lookup.find("PyEval_GetFrameBuiltins", MemoryAddress::class.java) + PyEval_GetFrameLocalsHandle = lookup.find("PyEval_GetFrameLocals", MemoryAddress::class.java) + PyEval_GetFrameGlobalsHandle = lookup.find("PyEval_GetFrameGlobals", MemoryAddress::class.java) + PyEval_GetFuncNameHandle = lookup.find("PyEval_GetFuncName", MemoryAddress::class.java, MemoryAddress::class.java) + PyEval_GetFuncDescHandle = lookup.find("PyEval_GetFuncDesc", MemoryAddress::class.java, MemoryAddress::class.java) + + + // Section 10 + PyObject_HasAttrWithErrorHandle = lookup.find("PyObject_HasAttrWithError", Integer.TYPE, MemoryAddress::class.java, MemoryAddress::class.java) + PyObject_HasAttrStringWithErrorHandle = lookup.find("PyObject_HasAttrStringWithError", Integer.TYPE, MemoryAddress::class.java, MemoryAddress::class.java) + PyObject_HasAttrHandle = lookup.find("PyObject_HasAttr", Integer.TYPE, MemoryAddress::class.java, MemoryAddress::class.java) + PyObject_HasAttrStringHandle = lookup.find("PyObject_HasAttrString", Integer.TYPE, MemoryAddress::class.java, MemoryAddress::class.java) + PyObject_GetAttrHandle = lookup.find("PyObject_GetAttr", MemoryAddress::class.java, MemoryAddress::class.java, MemoryAddress::class.java) + PyObject_GetAttrStringHandle = lookup.find("PyObject_GetAttrString", MemoryAddress::class.java, MemoryAddress::class.java, MemoryAddress::class.java) + PyObject_GenericGetAttrHandle = lookup.find("PyObject_GenericGetAttr", MemoryAddress::class.java, MemoryAddress::class.java, MemoryAddress::class.java) + PyObject_SetAttrHandle = lookup.find("PyObject_SetAttr", Integer.TYPE, MemoryAddress::class.java, MemoryAddress::class.java, MemoryAddress::class.java) + PyObject_SetAttrStringHandle = lookup.find("PyObject_SetAttrString", Integer.TYPE, MemoryAddress::class.java, MemoryAddress::class.java, MemoryAddress::class.java) + PyObject_GenericSetAttrHandle = lookup.find("PyObject_GenericSetAttr", Integer.TYPE, MemoryAddress::class.java, MemoryAddress::class.java, MemoryAddress::class.java) + PyObject_DelAttrHandle = lookup.find("PyObject_DelAttr", Integer.TYPE, MemoryAddress::class.java, MemoryAddress::class.java) + PyObject_DelAttrStringHandle = lookup.find("PyObject_DelAttrString", Integer.TYPE, MemoryAddress::class.java, MemoryAddress::class.java) + PyObject_RichCompareHandle = lookup.find("PyObject_RichCompare", MemoryAddress::class.java, MemoryAddress::class.java, MemoryAddress::class.java, Integer.TYPE) + PyObject_RichCompareBoolHandle = lookup.find("PyObject_RichCompareBool", Integer.TYPE, MemoryAddress::class.java, MemoryAddress::class.java, Integer.TYPE) + PyObject_FormatHandle = lookup.find("PyObject_Format", MemoryAddress::class.java, MemoryAddress::class.java, MemoryAddress::class.java) + PyObject_ReprHandle = lookup.find("PyObject_Repr", MemoryAddress::class.java, MemoryAddress::class.java) + PyObject_ASCIIHandle = lookup.find("PyObject_ASCII", MemoryAddress::class.java, MemoryAddress::class.java) + PyObject_StrHandle = lookup.find("PyObject_Str", MemoryAddress::class.java, MemoryAddress::class.java) + PyObject_BytesHandle = lookup.find("PyObject_Bytes", MemoryAddress::class.java, MemoryAddress::class.java) + PyObject_IsSubclassHandle = lookup.find("PyObject_IsSubclass", Integer.TYPE, MemoryAddress::class.java, MemoryAddress::class.java) + PyObject_IsInstanceHandle = lookup.find("PyObject_IsInstance", Integer.TYPE, MemoryAddress::class.java, MemoryAddress::class.java) + PyObject_IsTrueHandle = lookup.find("PyObject_IsTrue", Integer.TYPE, MemoryAddress::class.java) + PyObject_NotHandle = lookup.find("PyObject_Not", Integer.TYPE, MemoryAddress::class.java) + PyObject_TypeHandle = lookup.find("PyObject_Type", MemoryAddress::class.java, MemoryAddress::class.java) + PyObject_GetItemHandle = lookup.find("PyObject_GetItem", MemoryAddress::class.java, MemoryAddress::class.java, MemoryAddress::class.java) + PyObject_SetItemHandle = lookup.find("PyObject_SetItem", Integer.TYPE, MemoryAddress::class.java, MemoryAddress::class.java, MemoryAddress::class.java) + PyObject_DelItemHandle = lookup.find("PyObject_DelItem", Integer.TYPE, MemoryAddress::class.java, MemoryAddress::class.java) + PyObject_DirHandle = lookup.find("PyObject_Dir", MemoryAddress::class.java, MemoryAddress::class.java) + PyObject_GetIterHandle = lookup.find("PyObject_GetIter", MemoryAddress::class.java, MemoryAddress::class.java) + PyObject_GetAIterHandle = lookup.find("PyObject_GetAIter", MemoryAddress::class.java, MemoryAddress::class.java) + + + // Section 11 + PyVectorcall_CallHandle = lookup.find("PyVectorcall_Call", MemoryAddress::class.java, MemoryAddress::class.java, MemoryAddress::class.java, MemoryAddress::class.java) + PyObject_CallHandle = lookup.find("PyObject_Call", MemoryAddress::class.java, MemoryAddress::class.java, MemoryAddress::class.java, MemoryAddress::class.java) + PyObject_CallNoArgsHandle = lookup.find("PyObject_CallNoArgs", MemoryAddress::class.java, MemoryAddress::class.java) + PyObject_CallObjectHandle = lookup.find("PyObject_CallObject", MemoryAddress::class.java, MemoryAddress::class.java, MemoryAddress::class.java) + PyCallable_CheckHandle = lookup.find("PyCallable_Check", Integer.TYPE, MemoryAddress::class.java) + + + // Section 12 + PyNumber_CheckHandle = lookup.find("PyNumber_Check", Integer.TYPE, MemoryAddress::class.java) + PyNumber_AddHandle = lookup.find("PyNumber_Add", MemoryAddress::class.java, MemoryAddress::class.java, MemoryAddress::class.java) + PyNumber_SubtractHandle = lookup.find("PyNumber_Subtract", MemoryAddress::class.java, MemoryAddress::class.java, MemoryAddress::class.java) + PyNumber_MultiplyHandle = lookup.find("PyNumber_Multiply", MemoryAddress::class.java, MemoryAddress::class.java, MemoryAddress::class.java) + PyNumber_MatrixMultiplyHandle = lookup.find("PyNumber_MatrixMultiply", MemoryAddress::class.java, MemoryAddress::class.java, MemoryAddress::class.java) + PyNumber_FloorDivideHandle = lookup.find("PyNumber_FloorDivide", MemoryAddress::class.java, MemoryAddress::class.java, MemoryAddress::class.java) + PyNumber_TrueDivideHandle = lookup.find("PyNumber_TrueDivide", MemoryAddress::class.java, MemoryAddress::class.java, MemoryAddress::class.java) + PyNumber_RemainderHandle = lookup.find("PyNumber_Remainder", MemoryAddress::class.java, MemoryAddress::class.java, MemoryAddress::class.java) + PyNumber_DivmodHandle = lookup.find("PyNumber_Divmod", MemoryAddress::class.java, MemoryAddress::class.java, MemoryAddress::class.java) + PyNumber_PowerHandle = lookup.find("PyNumber_Power", MemoryAddress::class.java, MemoryAddress::class.java, MemoryAddress::class.java, MemoryAddress::class.java) + PyNumber_NegativeHandle = lookup.find("PyNumber_Negative", MemoryAddress::class.java, MemoryAddress::class.java) + PyNumber_PositiveHandle = lookup.find("PyNumber_Positive", MemoryAddress::class.java, MemoryAddress::class.java) + PyNumber_AbsoluteHandle = lookup.find("PyNumber_Absolute", MemoryAddress::class.java, MemoryAddress::class.java) + PyNumber_InvertHandle = lookup.find("PyNumber_Invert", MemoryAddress::class.java, MemoryAddress::class.java) + PyNumber_LshiftHandle = lookup.find("PyNumber_Lshift", MemoryAddress::class.java, MemoryAddress::class.java, MemoryAddress::class.java) + PyNumber_RshiftHandle = lookup.find("PyNumber_Rshift", MemoryAddress::class.java, MemoryAddress::class.java, MemoryAddress::class.java) + PyNumber_AndHandle = lookup.find("PyNumber_And", MemoryAddress::class.java, MemoryAddress::class.java, MemoryAddress::class.java) + PyNumber_XorHandle = lookup.find("PyNumber_Xor", MemoryAddress::class.java, MemoryAddress::class.java, MemoryAddress::class.java) + PyNumber_OrHandle = lookup.find("PyNumber_Or", MemoryAddress::class.java, MemoryAddress::class.java, MemoryAddress::class.java) + PyNumber_InPlaceAddHandle = lookup.find("PyNumber_InPlaceAdd", MemoryAddress::class.java, MemoryAddress::class.java, MemoryAddress::class.java) + PyNumber_InPlaceSubtractHandle = lookup.find("PyNumber_InPlaceSubtract", MemoryAddress::class.java, MemoryAddress::class.java, MemoryAddress::class.java) + PyNumber_InPlaceMultiplyHandle = lookup.find("PyNumber_InPlaceMultiply", MemoryAddress::class.java, MemoryAddress::class.java, MemoryAddress::class.java) + PyNumber_InPlaceMatrixMultiplyHandle = lookup.find("PyNumber_InPlaceMatrixMultiply", MemoryAddress::class.java, MemoryAddress::class.java, MemoryAddress::class.java) + PyNumber_InPlaceFloorDivideHandle = lookup.find("PyNumber_InPlaceFloorDivide", MemoryAddress::class.java, MemoryAddress::class.java, MemoryAddress::class.java) + PyNumber_InPlaceTrueDivideHandle = lookup.find("PyNumber_InPlaceTrueDivide", MemoryAddress::class.java, MemoryAddress::class.java, MemoryAddress::class.java) + PyNumber_InPlaceRemainderHandle = lookup.find("PyNumber_InPlaceRemainder", MemoryAddress::class.java, MemoryAddress::class.java, MemoryAddress::class.java) + PyNumber_InPlacePowerHandle = lookup.find("PyNumber_InPlacePower", MemoryAddress::class.java, MemoryAddress::class.java, MemoryAddress::class.java, MemoryAddress::class.java) + PyNumber_InPlaceLshiftHandle = lookup.find("PyNumber_InPlaceLshift", MemoryAddress::class.java, MemoryAddress::class.java, MemoryAddress::class.java) + PyNumber_InPlaceRshiftHandle = lookup.find("PyNumber_InPlaceRshift", MemoryAddress::class.java, MemoryAddress::class.java, MemoryAddress::class.java) + PyNumber_InPlaceAndHandle = lookup.find("PyNumber_InPlaceAnd", MemoryAddress::class.java, MemoryAddress::class.java, MemoryAddress::class.java) + PyNumber_InPlaceXorHandle = lookup.find("PyNumber_InPlaceXor", MemoryAddress::class.java, MemoryAddress::class.java, MemoryAddress::class.java) + PyNumber_InPlaceOrHandle = lookup.find("PyNumber_InPlaceOr", MemoryAddress::class.java, MemoryAddress::class.java, MemoryAddress::class.java) + PyNumber_LongHandle = lookup.find("PyNumber_Long", MemoryAddress::class.java, MemoryAddress::class.java) + PyNumber_FloatHandle = lookup.find("PyNumber_Float", MemoryAddress::class.java, MemoryAddress::class.java) + PyNumber_IndexHandle = lookup.find("PyNumber_Index", MemoryAddress::class.java, MemoryAddress::class.java) + PyNumber_ToBaseHandle = lookup.find("PyNumber_ToBase", MemoryAddress::class.java, MemoryAddress::class.java, Integer.TYPE) + PyIndex_CheckHandle = lookup.find("PyIndex_Check", Integer.TYPE, MemoryAddress::class.java) + + + // Section 13 + PySequence_CheckHandle = lookup.find("PySequence_Check", Integer.TYPE, MemoryAddress::class.java) + PySequence_ConcatHandle = lookup.find("PySequence_Concat", MemoryAddress::class.java, MemoryAddress::class.java, MemoryAddress::class.java) + PySequence_InPlaceConcatHandle = lookup.find("PySequence_InPlaceConcat", MemoryAddress::class.java, MemoryAddress::class.java, MemoryAddress::class.java) + PySequence_ContainsHandle = lookup.find("PySequence_Contains", Integer.TYPE, MemoryAddress::class.java, MemoryAddress::class.java) + PySequence_ListHandle = lookup.find("PySequence_List", MemoryAddress::class.java, MemoryAddress::class.java) + PySequence_TupleHandle = lookup.find("PySequence_Tuple", MemoryAddress::class.java, MemoryAddress::class.java) + PySequence_FastHandle = lookup.find("PySequence_Fast", MemoryAddress::class.java, MemoryAddress::class.java, MemoryAddress::class.java) + + + // Section 14 + PyMapping_CheckHandle = lookup.find("PyMapping_Check", Integer.TYPE, MemoryAddress::class.java) + PyMapping_GetItemStringHandle = lookup.find("PyMapping_GetItemString", MemoryAddress::class.java, MemoryAddress::class.java, MemoryAddress::class.java) + PyMapping_SetItemStringHandle = lookup.find("PyMapping_SetItemString", Integer.TYPE, MemoryAddress::class.java, MemoryAddress::class.java, MemoryAddress::class.java) + PyMapping_HasKeyWithErrorHandle = lookup.find("PyMapping_HasKeyWithError", Integer.TYPE, MemoryAddress::class.java, MemoryAddress::class.java) + PyMapping_HasKeyStringWithErrorHandle = lookup.find("PyMapping_HasKeyStringWithError", Integer.TYPE, MemoryAddress::class.java, MemoryAddress::class.java) + PyMapping_HasKeyHandle = lookup.find("PyMapping_HasKey", Integer.TYPE, MemoryAddress::class.java, MemoryAddress::class.java) + PyMapping_HasKeyStringHandle = lookup.find("PyMapping_HasKeyString", Integer.TYPE, MemoryAddress::class.java, MemoryAddress::class.java) + PyMapping_KeysHandle = lookup.find("PyMapping_Keys", MemoryAddress::class.java, MemoryAddress::class.java) + PyMapping_ValuesHandle = lookup.find("PyMapping_Values", MemoryAddress::class.java, MemoryAddress::class.java) + PyMapping_ItemsHandle = lookup.find("PyMapping_Items", MemoryAddress::class.java, MemoryAddress::class.java) + + + // Section 15 + PyIter_CheckHandle = lookup.find("PyIter_Check", Integer.TYPE, MemoryAddress::class.java) + PyAIter_CheckHandle = lookup.find("PyAIter_Check", Integer.TYPE, MemoryAddress::class.java) + PyIter_NextHandle = lookup.find("PyIter_Next", MemoryAddress::class.java, MemoryAddress::class.java) + + + // Section 16 + PyLong_FromLongLongHandle = lookup.find("PyLong_FromLongLong", MemoryAddress::class.java, LongLong.TYPE) + PyLong_FromDoubleHandle = lookup.find("PyLong_FromDouble", MemoryAddress::class.java, Double.TYPE) + PyLong_AsIntHandle = lookup.find("PyLong_AsInt", Integer.TYPE, MemoryAddress::class.java) + PyLong_AsLongLongHandle = lookup.find("PyLong_AsLongLong", LongLong.TYPE, MemoryAddress::class.java) + PyLong_AsDoubleHandle = lookup.find("PyLong_AsDouble", Double.TYPE, MemoryAddress::class.java) + PyLong_GetInfoHandle = lookup.find("PyLong_GetInfo", MemoryAddress::class.java) + + + // Section 17 + PyBool_FromLongHandle = lookup.find("PyBool_FromLong", MemoryAddress::class.java, Integer.TYPE) + + + // Section 18 + PyFloat_FromStringHandle = lookup.find("PyFloat_FromString", MemoryAddress::class.java, MemoryAddress::class.java) + PyFloat_FromDoubleHandle = lookup.find("PyFloat_FromDouble", MemoryAddress::class.java, Double.TYPE) + PyFloat_AsDoubleHandle = lookup.find("PyFloat_AsDouble", Double.TYPE, MemoryAddress::class.java) + PyFloat_GetInfoHandle = lookup.find("PyFloat_GetInfo", MemoryAddress::class.java) + PyFloat_GetMaxHandle = lookup.find("PyFloat_GetMax", Double.TYPE) + PyFloat_GetMinHandle = lookup.find("PyFloat_GetMin", Double.TYPE) + + + // Section 19 + PyBytes_FromStringHandle = lookup.find("PyBytes_FromString", MemoryAddress::class.java, MemoryAddress::class.java) + PyBytes_FromObjectHandle = lookup.find("PyBytes_FromObject", MemoryAddress::class.java, MemoryAddress::class.java) + PyBytes_AsStringHandle = lookup.find("PyBytes_AsString", MemoryAddress::class.java, MemoryAddress::class.java) + + + // Section 20 + PyByteArray_FromObjectHandle = lookup.find("PyByteArray_FromObject", MemoryAddress::class.java, MemoryAddress::class.java) + PyByteArray_ConcatHandle = lookup.find("PyByteArray_Concat", MemoryAddress::class.java, MemoryAddress::class.java, MemoryAddress::class.java) + PyByteArray_AsStringHandle = lookup.find("PyByteArray_AsString", MemoryAddress::class.java, MemoryAddress::class.java) + + + // Section 21 + PyUnicode_IsIdentifierHandle = lookup.find("PyUnicode_IsIdentifier", Integer.TYPE, MemoryAddress::class.java) + PyUnicode_FromStringHandle = lookup.find("PyUnicode_FromString", MemoryAddress::class.java, MemoryAddress::class.java) + PyUnicode_FromObjectHandle = lookup.find("PyUnicode_FromObject", MemoryAddress::class.java, MemoryAddress::class.java) + PyUnicode_FromEncodedObjectHandle = lookup.find("PyUnicode_FromEncodedObject", MemoryAddress::class.java, MemoryAddress::class.java, MemoryAddress::class.java, MemoryAddress::class.java) + PyUnicode_DecodeLocaleHandle = lookup.find("PyUnicode_DecodeLocale", MemoryAddress::class.java, MemoryAddress::class.java, MemoryAddress::class.java) + PyUnicode_EncodeLocaleHandle = lookup.find("PyUnicode_EncodeLocale", MemoryAddress::class.java, MemoryAddress::class.java, MemoryAddress::class.java) + PyUnicode_DecodeFSDefaultHandle = lookup.find("PyUnicode_DecodeFSDefault", MemoryAddress::class.java, MemoryAddress::class.java) + PyUnicode_EncodeFSDefaultHandle = lookup.find("PyUnicode_EncodeFSDefault", MemoryAddress::class.java, MemoryAddress::class.java) + PyUnicode_AsEncodedStringHandle = lookup.find("PyUnicode_AsEncodedString", MemoryAddress::class.java, MemoryAddress::class.java, MemoryAddress::class.java, MemoryAddress::class.java) + PyUnicode_AsUTF8StringHandle = lookup.find("PyUnicode_AsUTF8String", MemoryAddress::class.java, MemoryAddress::class.java) + PyUnicode_AsUTF8Handle = lookup.find("PyUnicode_AsUTF8", MemoryAddress::class.java, MemoryAddress::class.java) // 수동 추가 + PyUnicode_AsUTF32StringHandle = lookup.find("PyUnicode_AsUTF32String", MemoryAddress::class.java, MemoryAddress::class.java) + PyUnicode_AsUTF16StringHandle = lookup.find("PyUnicode_AsUTF16String", MemoryAddress::class.java, MemoryAddress::class.java) + PyUnicode_AsUnicodeEscapeStringHandle = lookup.find("PyUnicode_AsUnicodeEscapeString", MemoryAddress::class.java, MemoryAddress::class.java) + PyUnicode_AsRawUnicodeEscapeStringHandle = lookup.find("PyUnicode_AsRawUnicodeEscapeString", MemoryAddress::class.java, MemoryAddress::class.java) + PyUnicode_AsLatin1StringHandle = lookup.find("PyUnicode_AsLatin1String", MemoryAddress::class.java, MemoryAddress::class.java) + PyUnicode_AsASCIIStringHandle = lookup.find("PyUnicode_AsASCIIString", MemoryAddress::class.java, MemoryAddress::class.java) + PyUnicode_AsCharmapStringHandle = lookup.find("PyUnicode_AsCharmapString", MemoryAddress::class.java, MemoryAddress::class.java, MemoryAddress::class.java) + PyUnicode_TranslateHandle = lookup.find("PyUnicode_Translate", MemoryAddress::class.java, MemoryAddress::class.java, MemoryAddress::class.java, MemoryAddress::class.java) + PyUnicode_ConcatHandle = lookup.find("PyUnicode_Concat", MemoryAddress::class.java, MemoryAddress::class.java, MemoryAddress::class.java) + PyUnicode_SplitlinesHandle = lookup.find("PyUnicode_Splitlines", MemoryAddress::class.java, MemoryAddress::class.java, Integer.TYPE) + PyUnicode_JoinHandle = lookup.find("PyUnicode_Join", MemoryAddress::class.java, MemoryAddress::class.java, MemoryAddress::class.java) + PyUnicode_CompareHandle = lookup.find("PyUnicode_Compare", Integer.TYPE, MemoryAddress::class.java, MemoryAddress::class.java) + PyUnicode_EqualToUTF8Handle = lookup.find("PyUnicode_EqualToUTF8", Integer.TYPE, MemoryAddress::class.java, MemoryAddress::class.java) + PyUnicode_CompareWithASCIIStringHandle = lookup.find("PyUnicode_CompareWithASCIIString", Integer.TYPE, MemoryAddress::class.java, MemoryAddress::class.java) + PyUnicode_RichCompareHandle = lookup.find("PyUnicode_RichCompare", MemoryAddress::class.java, MemoryAddress::class.java, MemoryAddress::class.java, Integer.TYPE) + PyUnicode_FormatHandle = lookup.find("PyUnicode_Format", MemoryAddress::class.java, MemoryAddress::class.java, MemoryAddress::class.java) + PyUnicode_ContainsHandle = lookup.find("PyUnicode_Contains", Integer.TYPE, MemoryAddress::class.java, MemoryAddress::class.java) + PyUnicode_InternFromStringHandle = lookup.find("PyUnicode_InternFromString", MemoryAddress::class.java, MemoryAddress::class.java) + + + // Section 22 + PyList_AppendHandle = lookup.find("PyList_Append", Integer.TYPE, MemoryAddress::class.java, MemoryAddress::class.java) + PyList_SortHandle = lookup.find("PyList_Sort", Integer.TYPE, MemoryAddress::class.java) + PyList_ReverseHandle = lookup.find("PyList_Reverse", Integer.TYPE, MemoryAddress::class.java) + PyList_AsTupleHandle = lookup.find("PyList_AsTuple", MemoryAddress::class.java, MemoryAddress::class.java) + + + // Section 23 + PyDict_NewHandle = lookup.find("PyDict_New", MemoryAddress::class.java) + PyDictProxy_NewHandle = lookup.find("PyDictProxy_New", MemoryAddress::class.java, MemoryAddress::class.java) + PyDict_ClearHandle = lookup.find("PyDict_Clear", Void.TYPE, MemoryAddress::class.java) + PyDict_ContainsHandle = lookup.find("PyDict_Contains", Integer.TYPE, MemoryAddress::class.java, MemoryAddress::class.java) + PyDict_CopyHandle = lookup.find("PyDict_Copy", MemoryAddress::class.java, MemoryAddress::class.java) + PyDict_SetItemHandle = lookup.find("PyDict_SetItem", Integer.TYPE, MemoryAddress::class.java, MemoryAddress::class.java, MemoryAddress::class.java) + PyDict_SetItemStringHandle = lookup.find("PyDict_SetItemString", Integer.TYPE, MemoryAddress::class.java, MemoryAddress::class.java, MemoryAddress::class.java) + PyDict_DelItemHandle = lookup.find("PyDict_DelItem", Integer.TYPE, MemoryAddress::class.java, MemoryAddress::class.java) + PyDict_DelItemStringHandle = lookup.find("PyDict_DelItemString", Integer.TYPE, MemoryAddress::class.java, MemoryAddress::class.java) + PyDict_GetItemHandle = lookup.find("PyDict_GetItem", MemoryAddress::class.java, MemoryAddress::class.java, MemoryAddress::class.java) + PyDict_GetItemWithErrorHandle = lookup.find("PyDict_GetItemWithError", MemoryAddress::class.java, MemoryAddress::class.java, MemoryAddress::class.java) + PyDict_GetItemStringHandle = lookup.find("PyDict_GetItemString", MemoryAddress::class.java, MemoryAddress::class.java, MemoryAddress::class.java) + PyDict_ItemsHandle = lookup.find("PyDict_Items", MemoryAddress::class.java, MemoryAddress::class.java) + PyDict_KeysHandle = lookup.find("PyDict_Keys", MemoryAddress::class.java, MemoryAddress::class.java) + PyDict_ValuesHandle = lookup.find("PyDict_Values", MemoryAddress::class.java, MemoryAddress::class.java) + PyDict_MergeHandle = lookup.find("PyDict_Merge", Integer.TYPE, MemoryAddress::class.java, MemoryAddress::class.java, Integer.TYPE) + PyDict_UpdateHandle = lookup.find("PyDict_Update", Integer.TYPE, MemoryAddress::class.java, MemoryAddress::class.java) + PyDict_MergeFromSeq2Handle = lookup.find("PyDict_MergeFromSeq2", Integer.TYPE, MemoryAddress::class.java, MemoryAddress::class.java, Integer.TYPE) + + + // Section 24 + PySet_NewHandle = lookup.find("PySet_New", MemoryAddress::class.java, MemoryAddress::class.java) + PyFrozenSet_NewHandle = lookup.find("PyFrozenSet_New", MemoryAddress::class.java, MemoryAddress::class.java) + PySet_ContainsHandle = lookup.find("PySet_Contains", Integer.TYPE, MemoryAddress::class.java, MemoryAddress::class.java) + PySet_AddHandle = lookup.find("PySet_Add", Integer.TYPE, MemoryAddress::class.java, MemoryAddress::class.java) + PySet_DiscardHandle = lookup.find("PySet_Discard", Integer.TYPE, MemoryAddress::class.java, MemoryAddress::class.java) + PySet_PopHandle = lookup.find("PySet_Pop", MemoryAddress::class.java, MemoryAddress::class.java) + PySet_ClearHandle = lookup.find("PySet_Clear", Integer.TYPE, MemoryAddress::class.java) + + + // Section 25 + PySeqIter_NewHandle = lookup.find("PySeqIter_New", MemoryAddress::class.java, MemoryAddress::class.java) + PyCallIter_NewHandle = lookup.find("PyCallIter_New", MemoryAddress::class.java, MemoryAddress::class.java, MemoryAddress::class.java) + + + // Section 26 + PyWeakref_NewRefHandle = lookup.find("PyWeakref_NewRef", MemoryAddress::class.java, MemoryAddress::class.java, MemoryAddress::class.java) + PyWeakref_NewProxyHandle = lookup.find("PyWeakref_NewProxy", MemoryAddress::class.java, MemoryAddress::class.java, MemoryAddress::class.java) + PyWeakref_GetObjectHandle = lookup.find("PyWeakref_GetObject", MemoryAddress::class.java, MemoryAddress::class.java) + PyObject_ClearWeakRefsHandle = lookup.find("PyObject_ClearWeakRefs", Void.TYPE, MemoryAddress::class.java) + + + // Section 27 + PyType_IsSubtypeHandle = lookup.find("PyType_IsSubtype", Integer.TYPE, MemoryAddress::class.java, MemoryAddress::class.java) + PyType_ReadyHandle = lookup.find("PyType_Ready", Integer.TYPE, MemoryAddress::class.java) + PyType_GetNameHandle = lookup.find("PyType_GetName", MemoryAddress::class.java, MemoryAddress::class.java) + PyType_GetFullyQualifiedName = lookup.find("PyType_GetFullyQualifiedName", MemoryAddress::class.java, MemoryAddress::class.java) + PyType_GetModuleNameHandle = lookup.find("PyType_GetModuleName", MemoryAddress::class.java, MemoryAddress::class.java) + PyType_GetModuleHandle = lookup.find("PyType_GetModule", MemoryAddress::class.java, MemoryAddress::class.java) + + + // Section 28 + PyTuple_NewHandle = lookup.find("PyTuple_New", MemoryAddress::class.java, LongLong.TYPE) + PyTuple_SizeHandle = lookup.find("PyTuple_Size", LongLong.TYPE, MemoryAddress::class.java) + PyTuple_GetItemHandle = lookup.find("PyTuple_GetItem", MemoryAddress::class.java, MemoryAddress::class.java, LongLong.TYPE) + PyTuple_GetSliceHandle = lookup.find("PyTuple_GetSlice", MemoryAddress::class.java, MemoryAddress::class.java, LongLong.TYPE, LongLong.TYPE) + PyTuple_SetItemHandle = lookup.find("PyTuple_SetItem", Integer.TYPE, MemoryAddress::class.java, LongLong.TYPE, MemoryAddress::class.java) } } } diff --git a/python-multiplatform/src/nativeMain/kotlin/python/multiplatform/ffi/PyObject.native.kt b/python-multiplatform/src/nativeMain/kotlin/python/multiplatform/ffi/PyObject.native.kt deleted file mode 100644 index 4cdd3729..00000000 --- a/python-multiplatform/src/nativeMain/kotlin/python/multiplatform/ffi/PyObject.native.kt +++ /dev/null @@ -1,20 +0,0 @@ -package python.multiplatform.ffi - -import python.native.ffi.NativePointer -import kotlin.experimental.ExperimentalNativeApi -import kotlin.native.ref.createCleaner - - -actual open class PyObject actual constructor(actual val pointer: NativePointer, borrowed: Boolean): AutoCloseable { - @OptIn(ExperimentalNativeApi::class) - //private val cleaner = createCleaner(this) { clean() } - // TODO: Fix this top-level function error - - private fun clean() { - //PyDecRef(this.pointer) - } - - override fun close() { - clean() - } -} diff --git a/python-multiplatform/src/nativeMain/kotlin/python/multiplatform/ref/PyAutoCloseable.native.kt b/python-multiplatform/src/nativeMain/kotlin/python/multiplatform/ref/PyAutoCloseable.native.kt new file mode 100644 index 00000000..5ff987cc --- /dev/null +++ b/python-multiplatform/src/nativeMain/kotlin/python/multiplatform/ref/PyAutoCloseable.native.kt @@ -0,0 +1,12 @@ +package python.multiplatform.ref + +import python.native.ffi.NativePointer + + +actual abstract class PyAutoCloseable actual constructor(pointer: NativePointer): AutoCloseable { + actual abstract fun clean() + + override fun close() { + clean() + } +} diff --git a/python-multiplatform/src/nativeMain/kotlin/python/native/ffi/EmbedAPI.native.kt b/python-multiplatform/src/nativeMain/kotlin/python/native/ffi/EmbedAPI.native.kt index e2c3b284..bf7b143b 100644 --- a/python-multiplatform/src/nativeMain/kotlin/python/native/ffi/EmbedAPI.native.kt +++ b/python-multiplatform/src/nativeMain/kotlin/python/native/ffi/EmbedAPI.native.kt @@ -6,6 +6,7 @@ import platform.posix.getenv import platform.posix.setenv import python.native.ffi.bindings.PyObject import kotlin.experimental.ExperimentalNativeApi +import python.native.ffi.bindings.PyTuple_GetItem @OptIn(ExperimentalForeignApi::class) @@ -42,6 +43,7 @@ private const val exportClassName = "bindings" private const val namePrefix = "Java_${packageName}_${exportClassName}_" +/** // Section 1 @CName("${namePrefix}Py_1Initialize") @OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) @@ -128,3 +130,982 @@ actual fun PyUnicode_FromString(str: String): NativePointer? = actual inline fun PyUnicode_AsUTF8(unicode: NativePointer): String? = python.native.ffi.bindings.PyUnicode_AsUTF8(unicode.toPlatformPointer())?.toKString() + + */ + + +//************************************************** +// Section 1 +@CName("${namePrefix}Py_1Initialize") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual inline fun Py_Initialize() = python.native.ffi.bindings.Py_Initialize() +@CName("${namePrefix}Py_1InitializeEx") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual inline fun Py_InitializeEx(initsigs: Int) = python.native.ffi.bindings.Py_InitializeEx(initsigs) +@CName("${namePrefix}Py_1IsInitialized") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual inline fun Py_IsInitialized(): Int = python.native.ffi.bindings.Py_IsInitialized() +@CName("${namePrefix}Py_1IsFinalizing") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual inline fun Py_IsFinalizing(): Int = python.native.ffi.bindings.Py_IsFinalizing() +@CName("${namePrefix}Py_1FinalizeEx") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual inline fun Py_FinalizeEx(): Int = python.native.ffi.bindings.Py_FinalizeEx() +@CName("${namePrefix}Py_1Finalize") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual inline fun Py_Finalize() = python.native.ffi.bindings.Py_Finalize() +//@CName("${namePrefix}Py_1BytesMain") +//@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +//actual inline fun Py_BytesMain(args: Array) = memScoped { +// val cArgs = allocArray>(args.size + 1) +// args.forEachIndexed { index, arg -> cArgs[index] = arg.cstr.ptr } +// cArgs[args.size] = null +// python.native.ffi.bindings.Py_BytesMain(args.size, cArgs) +//} // 수동 추가 +@CName("${namePrefix}Py_1RunMain") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual inline fun Py_RunMain() = python.native.ffi.bindings.Py_RunMain() // 수동 추가 +@CName("${namePrefix}Py_1GetVersion") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual inline fun Py_GetVersion(): String? = python.native.ffi.bindings.Py_GetVersion()?.toKString() +@CName("${namePrefix}Py_1GetPlatform") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual inline fun Py_GetPlatform(): String? = python.native.ffi.bindings.Py_GetPlatform()?.toKString() +@CName("${namePrefix}Py_1GetCopyright") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual inline fun Py_GetCopyright(): String? = python.native.ffi.bindings.Py_GetCopyright()?.toKString() +@CName("${namePrefix}Py_1GetCompiler") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual inline fun Py_GetCompiler(): String? = python.native.ffi.bindings.Py_GetCompiler()?.toKString() +@CName("${namePrefix}Py_1GetBuildInfo") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual inline fun Py_GetBuildInfo(): String? = python.native.ffi.bindings.Py_GetBuildInfo()?.toKString() +@CName("${namePrefix}PyEval_1InitThreads") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual inline fun PyEval_InitThreads() = python.native.ffi.bindings.PyEval_InitThreads() +@CName("${namePrefix}PyThreadState_1GetDict") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyThreadState_GetDict(): NativePointer? = python.native.ffi.bindings.PyThreadState_GetDict().toNativePointer() + + +// Section 2 +@CName("${namePrefix}PyRun_1SimpleString") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual inline fun PyRun_SimpleString(command: String): Int = python.native.ffi.bindings.PyRun_SimpleString(command) // 수동 추가 +@CName("${namePrefix}PyRun_1String") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyRun_String( + str: String, start: Int, globals: NativePointer, locals: NativePointer +): NativePointer? = python.native.ffi.bindings.PyRun_String( + str, start, globals.toPlatformPointer(), locals.toPlatformPointer() +).toNativePointer() // 수동 추가 +@CName("${namePrefix}Py_1CompileString") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun Py_CompileString(str: String, filename: String, start: Int): NativePointer? = python.native.ffi.bindings.Py_CompileString(str, filename, start).toNativePointer() +@CName("${namePrefix}PyEval_1EvalCode") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyEval_EvalCode(co: NativePointer, globals: NativePointer, locals: NativePointer): NativePointer? = python.native.ffi.bindings.PyEval_EvalCode(co.toPlatformPointer(), globals.toPlatformPointer(), locals.toPlatformPointer()).toNativePointer() + + +// Section 3 +@CName("${namePrefix}PyErr_1Clear") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual inline fun PyErr_Clear() = python.native.ffi.bindings.PyErr_Clear() +@CName("${namePrefix}PyErr_1PrintEx") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual inline fun PyErr_PrintEx(set_sys_last_vars: Int) = python.native.ffi.bindings.PyErr_PrintEx(set_sys_last_vars) +@CName("${namePrefix}PyErr_1Print") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual inline fun PyErr_Print() = python.native.ffi.bindings.PyErr_Print() +@CName("${namePrefix}PyErr_1WriteUnraisable") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual inline fun PyErr_WriteUnraisable(obj: NativePointer) = python.native.ffi.bindings.PyErr_WriteUnraisable(obj.toPlatformPointer()) +@CName("${namePrefix}PyErr_1DisplayException") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual inline fun PyErr_DisplayException(exc: NativePointer) = python.native.ffi.bindings.PyErr_DisplayException(exc.toPlatformPointer()) +@CName("${namePrefix}PyErr_1SetString") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual inline fun PyErr_SetString(type: NativePointer, message: String) = python.native.ffi.bindings.PyErr_SetString(type.toPlatformPointer(), message) +@CName("${namePrefix}PyErr_1SetObject") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual inline fun PyErr_SetObject(type: NativePointer, value: NativePointer) = python.native.ffi.bindings.PyErr_SetObject(type.toPlatformPointer(), value.toPlatformPointer()) +@CName("${namePrefix}PyErr_1SetNone") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual inline fun PyErr_SetNone(type: NativePointer) = python.native.ffi.bindings.PyErr_SetNone(type.toPlatformPointer()) +@CName("${namePrefix}PyErr_1BadArgument") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual inline fun PyErr_BadArgument(): Int = python.native.ffi.bindings.PyErr_BadArgument() +@CName("${namePrefix}PyErr_1NoMemory") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyErr_NoMemory(): NativePointer? = python.native.ffi.bindings.PyErr_NoMemory().toNativePointer() +@CName("${namePrefix}PyErr_1SetFromErrno") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyErr_SetFromErrno(type: NativePointer): NativePointer? = python.native.ffi.bindings.PyErr_SetFromErrno(type.toPlatformPointer()).toNativePointer() +@CName("${namePrefix}PyErr_1SetFromErrnoWithFilenameObject") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyErr_SetFromErrnoWithFilenameObject(type: NativePointer, filenameObject: NativePointer): NativePointer? = python.native.ffi.bindings.PyErr_SetFromErrnoWithFilenameObject(type.toPlatformPointer(), filenameObject.toPlatformPointer()).toNativePointer() +@CName("${namePrefix}PyErr_1SetFromErrnoWithFilenameObjects") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyErr_SetFromErrnoWithFilenameObjects(type: NativePointer, filenameObject: NativePointer, filenameObject2: NativePointer): NativePointer? = python.native.ffi.bindings.PyErr_SetFromErrnoWithFilenameObjects(type.toPlatformPointer(), filenameObject.toPlatformPointer(), filenameObject2.toPlatformPointer()).toNativePointer() +@CName("${namePrefix}PyErr_1SetFromErrnoWithFilename") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyErr_SetFromErrnoWithFilename(type: NativePointer, filename: String): NativePointer? = python.native.ffi.bindings.PyErr_SetFromErrnoWithFilename(type.toPlatformPointer(), filename).toNativePointer() +@CName("${namePrefix}PyErr_1SetImportError") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyErr_SetImportError(msg: NativePointer, name: NativePointer, path: NativePointer): NativePointer? = python.native.ffi.bindings.PyErr_SetImportError(msg.toPlatformPointer(), name.toPlatformPointer(), path.toPlatformPointer()).toNativePointer() +@CName("${namePrefix}PyErr_1SetImportErrorSubclass") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyErr_SetImportErrorSubclass(exception: NativePointer, msg: NativePointer, name: NativePointer, path: NativePointer): NativePointer? = python.native.ffi.bindings.PyErr_SetImportErrorSubclass(exception.toPlatformPointer(), msg.toPlatformPointer(), name.toPlatformPointer(), path.toPlatformPointer()).toNativePointer() +@CName("${namePrefix}PyErr_1SyntaxLocationEx") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual inline fun PyErr_SyntaxLocationEx(filename: String, lineno: Int, col_offset: Int) = python.native.ffi.bindings.PyErr_SyntaxLocationEx(filename, lineno, col_offset) +@CName("${namePrefix}PyErr_1SyntaxLocation") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual inline fun PyErr_SyntaxLocation(filename: String, lineno: Int) = python.native.ffi.bindings.PyErr_SyntaxLocation(filename, lineno) +@CName("${namePrefix}PyErr_1BadInternalCall") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual inline fun PyErr_BadInternalCall() = python.native.ffi.bindings.PyErr_BadInternalCall() +@CName("${namePrefix}PyErr_1WarnExplicit") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual inline fun PyErr_WarnExplicit(category: NativePointer, message: String, filename: String, lineno: Int, module: String, registry: NativePointer): Int = python.native.ffi.bindings.PyErr_WarnExplicit(category.toPlatformPointer(), message, filename, lineno, module, registry.toPlatformPointer()) +@CName("${namePrefix}PyErr_1Occurred") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyErr_Occurred(): NativePointer? = python.native.ffi.bindings.PyErr_Occurred().toNativePointer() +@CName("${namePrefix}PyErr_1ExceptionMatches") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual inline fun PyErr_ExceptionMatches(exc: NativePointer): Int = python.native.ffi.bindings.PyErr_ExceptionMatches(exc.toPlatformPointer()) +@CName("${namePrefix}PyErr_1GivenExceptionMatches") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual inline fun PyErr_GivenExceptionMatches(given: NativePointer, exc: NativePointer): Int = python.native.ffi.bindings.PyErr_GivenExceptionMatches(given.toPlatformPointer(), exc.toPlatformPointer()) +@CName("${namePrefix}PyErr_1GetRaisedException") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyErr_GetRaisedException(): NativePointer? = python.native.ffi.bindings.PyErr_GetRaisedException().toNativePointer() +@CName("${namePrefix}PyErr_1SetRaisedException") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual inline fun PyErr_SetRaisedException(exc: NativePointer) = python.native.ffi.bindings.PyErr_SetRaisedException(exc.toPlatformPointer()) +@CName("${namePrefix}PyErr_1Restore") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual inline fun PyErr_Restore(type: NativePointer, value: NativePointer, traceback: NativePointer) = python.native.ffi.bindings.PyErr_Restore(type.toPlatformPointer(), value.toPlatformPointer(), traceback.toPlatformPointer()) +@CName("${namePrefix}PyErr_1GetHandledException") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyErr_GetHandledException(): NativePointer? = python.native.ffi.bindings.PyErr_GetHandledException().toNativePointer() +@CName("${namePrefix}PyErr_1SetHandledException") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual inline fun PyErr_SetHandledException(exc: NativePointer) = python.native.ffi.bindings.PyErr_SetHandledException(exc.toPlatformPointer()) +@CName("${namePrefix}PyErr_1SetExcInfo") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual inline fun PyErr_SetExcInfo(type: NativePointer, value: NativePointer, traceback: NativePointer) = python.native.ffi.bindings.PyErr_SetExcInfo(type.toPlatformPointer(), value.toPlatformPointer(), traceback.toPlatformPointer()) +@CName("${namePrefix}PyErr_1CheckSignals") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual inline fun PyErr_CheckSignals(): Int = python.native.ffi.bindings.PyErr_CheckSignals() +@CName("${namePrefix}PyErr_1SetInterrupt") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual inline fun PyErr_SetInterrupt() = python.native.ffi.bindings.PyErr_SetInterrupt() +@CName("${namePrefix}PyErr_1SetInterruptEx") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual inline fun PyErr_SetInterruptEx(signum: Int): Int = python.native.ffi.bindings.PyErr_SetInterruptEx(signum) +@CName("${namePrefix}PyErr_1NewException") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyErr_NewException(name: String, base: NativePointer, dict: NativePointer): NativePointer? = python.native.ffi.bindings.PyErr_NewException(name, base.toPlatformPointer(), dict.toPlatformPointer()).toNativePointer() +@CName("${namePrefix}PyErr_1NewExceptionWithDoc") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyErr_NewExceptionWithDoc(name: String, doc: String, base: NativePointer, dict: NativePointer): NativePointer? = python.native.ffi.bindings.PyErr_NewExceptionWithDoc(name, doc, base.toPlatformPointer(), dict.toPlatformPointer()).toNativePointer() +@CName("${namePrefix}PyException_1GetTraceback") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyException_GetTraceback(ex: NativePointer): NativePointer? = python.native.ffi.bindings.PyException_GetTraceback(ex.toPlatformPointer()).toNativePointer() +@CName("${namePrefix}PyException_1SetTraceback") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual inline fun PyException_SetTraceback(ex: NativePointer, tb: NativePointer): Int = python.native.ffi.bindings.PyException_SetTraceback(ex.toPlatformPointer(), tb.toPlatformPointer()) +@CName("${namePrefix}PyException_1GetContext") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyException_GetContext(ex: NativePointer): NativePointer? = python.native.ffi.bindings.PyException_GetContext(ex.toPlatformPointer()).toNativePointer() +@CName("${namePrefix}PyException_1SetContext") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual inline fun PyException_SetContext(ex: NativePointer, ctx: NativePointer) = python.native.ffi.bindings.PyException_SetContext(ex.toPlatformPointer(), ctx.toPlatformPointer()) +@CName("${namePrefix}PyException_1GetCause") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyException_GetCause(ex: NativePointer): NativePointer? = python.native.ffi.bindings.PyException_GetCause(ex.toPlatformPointer()).toNativePointer() +@CName("${namePrefix}PyException_1SetCause") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual inline fun PyException_SetCause(ex: NativePointer, cause: NativePointer) = python.native.ffi.bindings.PyException_SetCause(ex.toPlatformPointer(), cause.toPlatformPointer()) +@CName("${namePrefix}PyException_1GetArgs") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyException_GetArgs(ex: NativePointer): NativePointer? = python.native.ffi.bindings.PyException_GetArgs(ex.toPlatformPointer()).toNativePointer() +@CName("${namePrefix}PyException_1SetArgs") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual inline fun PyException_SetArgs(ex: NativePointer, args: NativePointer) = python.native.ffi.bindings.PyException_SetArgs(ex.toPlatformPointer(), args.toPlatformPointer()) +@CName("${namePrefix}PyUnicodeEncodeError_1GetEncoding") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyUnicodeEncodeError_GetEncoding(exc: NativePointer): NativePointer? = python.native.ffi.bindings.PyUnicodeEncodeError_GetEncoding(exc.toPlatformPointer()).toNativePointer() +@CName("${namePrefix}PyUnicodeTranslateError_1GetObject") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyUnicodeTranslateError_GetObject(exc: NativePointer): NativePointer? = python.native.ffi.bindings.PyUnicodeTranslateError_GetObject(exc.toPlatformPointer()).toNativePointer() +@CName("${namePrefix}PyUnicodeTranslateError_1GetReason") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyUnicodeTranslateError_GetReason(exc: NativePointer): NativePointer? = python.native.ffi.bindings.PyUnicodeTranslateError_GetReason(exc.toPlatformPointer()).toNativePointer() +@CName("${namePrefix}PyUnicodeTranslateError_1SetReason") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual inline fun PyUnicodeTranslateError_SetReason(exc: NativePointer, reason: String): Int = python.native.ffi.bindings.PyUnicodeTranslateError_SetReason(exc.toPlatformPointer(), reason) +@CName("${namePrefix}Py_1EnterRecursiveCall") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual inline fun Py_EnterRecursiveCall(where: String): Int = python.native.ffi.bindings.Py_EnterRecursiveCall(where) +@CName("${namePrefix}Py_1LeaveRecursiveCall") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual inline fun Py_LeaveRecursiveCall() = python.native.ffi.bindings.Py_LeaveRecursiveCall() +@CName("${namePrefix}Py_1ReprEnter") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual inline fun Py_ReprEnter(o: NativePointer): Int = python.native.ffi.bindings.Py_ReprEnter(o.toPlatformPointer()) +@CName("${namePrefix}Py_1ReprLeave") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual inline fun Py_ReprLeave(o: NativePointer) = python.native.ffi.bindings.Py_ReprLeave(o.toPlatformPointer()) + + +// Section 4 +@CName("${namePrefix}Py_1NewRef") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun Py_NewRef(o: NativePointer): NativePointer? = python.native.ffi.bindings.Py_NewRef(o.toPlatformPointer()).toNativePointer() +@CName("${namePrefix}Py_1XNewRef") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun Py_XNewRef(o: NativePointer): NativePointer? = python.native.ffi.bindings.Py_XNewRef(o.toPlatformPointer()).toNativePointer() +@CName("${namePrefix}Py_1IncRef") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual inline fun Py_IncRef(o: NativePointer) = python.native.ffi.bindings.Py_IncRef(o.toPlatformPointer()) +@CName("${namePrefix}Py_1DecRef") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual inline fun Py_DecRef(o: NativePointer) = python.native.ffi.bindings.Py_DecRef(o.toPlatformPointer()) + + +// Section 5 +@CName("${namePrefix}PyOS_1FSPath") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyOS_FSPath(path: NativePointer): NativePointer? = python.native.ffi.bindings.PyOS_FSPath(path.toPlatformPointer()).toNativePointer() + + +// Section 6 +@CName("${namePrefix}PySys_1GetObject") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PySys_GetObject(name: String): NativePointer? = python.native.ffi.bindings.PySys_GetObject(name).toNativePointer() +@CName("${namePrefix}PySys_1SetObject") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual inline fun PySys_SetObject(name: String, v: NativePointer): Int = python.native.ffi.bindings.PySys_SetObject(name, v.toPlatformPointer()) +@CName("${namePrefix}PySys_1ResetWarnOptions") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual inline fun PySys_ResetWarnOptions() = python.native.ffi.bindings.PySys_ResetWarnOptions() +@CName("${namePrefix}PySys_1GetXOptions") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PySys_GetXOptions(): NativePointer? = python.native.ffi.bindings.PySys_GetXOptions().toNativePointer() +@CName("${namePrefix}PySys_1AuditTuple") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual inline fun PySys_AuditTuple(event: String, args: NativePointer): Int = python.native.ffi.bindings.PySys_AuditTuple(event, args.toPlatformPointer()) + + +// Section 7 +@CName("${namePrefix}Py_1FatalError") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual inline fun Py_FatalError(message: String) = python.native.ffi.bindings.Py_FatalError(message) +@CName("${namePrefix}Py_1Exit") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual inline fun Py_Exit(status: Int) = python.native.ffi.bindings.Py_Exit(status) + + +// Section 8 +@CName("${namePrefix}PyImport_1ImportModule") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyImport_ImportModule(name: String): NativePointer? = python.native.ffi.bindings.PyImport_ImportModule(name).toNativePointer() +@CName("${namePrefix}PyImport_1ImportModuleNoBlock") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyImport_ImportModuleNoBlock(name: String): NativePointer? = python.native.ffi.bindings.PyImport_ImportModuleNoBlock(name).toNativePointer() +@CName("${namePrefix}PyImport_1ImportModuleLevelObject") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyImport_ImportModuleLevelObject(name: NativePointer, globals: NativePointer, locals: NativePointer, fromlist: NativePointer, level: Int): NativePointer? = python.native.ffi.bindings.PyImport_ImportModuleLevelObject(name.toPlatformPointer(), globals.toPlatformPointer(), locals.toPlatformPointer(), fromlist.toPlatformPointer(), level).toNativePointer() +@CName("${namePrefix}PyImport_1ImportModuleLevel") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyImport_ImportModuleLevel(name: String, globals: NativePointer, locals: NativePointer, fromlist: NativePointer, level: Int): NativePointer? = python.native.ffi.bindings.PyImport_ImportModuleLevel(name, globals.toPlatformPointer(), locals.toPlatformPointer(), fromlist.toPlatformPointer(), level).toNativePointer() +@CName("${namePrefix}PyImport_1Import") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyImport_Import(name: NativePointer): NativePointer? = python.native.ffi.bindings.PyImport_Import(name.toPlatformPointer()).toNativePointer() +@CName("${namePrefix}PyImport_1ReloadModule") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyImport_ReloadModule(m: NativePointer): NativePointer? = python.native.ffi.bindings.PyImport_ReloadModule(m.toPlatformPointer()).toNativePointer() +@CName("${namePrefix}PyImport_1AddModuleRef") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyImport_AddModuleRef(name: String): NativePointer? = python.native.ffi.bindings.PyImport_AddModuleRef(name).toNativePointer() +@CName("${namePrefix}PyImport_1AddModuleObject") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyImport_AddModuleObject(name: NativePointer): NativePointer? = python.native.ffi.bindings.PyImport_AddModuleObject(name.toPlatformPointer()).toNativePointer() +@CName("${namePrefix}PyImport_1AddModule") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyImport_AddModule(name: String): NativePointer? = python.native.ffi.bindings.PyImport_AddModule(name).toNativePointer() +@CName("${namePrefix}PyImport_1ExecCodeModule") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyImport_ExecCodeModule(name: String, co: NativePointer): NativePointer? = python.native.ffi.bindings.PyImport_ExecCodeModule(name, co.toPlatformPointer()).toNativePointer() +@CName("${namePrefix}PyImport_1ExecCodeModuleEx") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyImport_ExecCodeModuleEx(name: String, co: NativePointer, pathname: String): NativePointer? = python.native.ffi.bindings.PyImport_ExecCodeModuleEx(name, co.toPlatformPointer(), pathname).toNativePointer() +@CName("${namePrefix}PyImport_1ExecCodeModuleObject") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyImport_ExecCodeModuleObject(name: NativePointer, co: NativePointer, pathname: NativePointer, cpathname: NativePointer): NativePointer? = python.native.ffi.bindings.PyImport_ExecCodeModuleObject(name.toPlatformPointer(), co.toPlatformPointer(), pathname.toPlatformPointer(), cpathname.toPlatformPointer()).toNativePointer() +@CName("${namePrefix}PyImport_1ExecCodeModuleWithPathnames") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyImport_ExecCodeModuleWithPathnames(name: String, co: NativePointer, pathname: String, cpathname: String): NativePointer? = python.native.ffi.bindings.PyImport_ExecCodeModuleWithPathnames(name, co.toPlatformPointer(), pathname, cpathname).toNativePointer() +@CName("${namePrefix}PyImport_1GetMagicTag") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual inline fun PyImport_GetMagicTag(): String? = python.native.ffi.bindings.PyImport_GetMagicTag()?.toKString() +@CName("${namePrefix}PyImport_1GetModuleDict") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyImport_GetModuleDict(): NativePointer? = python.native.ffi.bindings.PyImport_GetModuleDict().toNativePointer() +@CName("${namePrefix}PyImport_1GetModule") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyImport_GetModule(name: NativePointer): NativePointer? = python.native.ffi.bindings.PyImport_GetModule(name.toPlatformPointer()).toNativePointer() +@CName("${namePrefix}PyImport_1GetImporter") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyImport_GetImporter(path: NativePointer): NativePointer? = python.native.ffi.bindings.PyImport_GetImporter(path.toPlatformPointer()).toNativePointer() +@CName("${namePrefix}PyImport_1ImportFrozenModuleObject") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual inline fun PyImport_ImportFrozenModuleObject(name: NativePointer): Int = python.native.ffi.bindings.PyImport_ImportFrozenModuleObject(name.toPlatformPointer()) +@CName("${namePrefix}PyImport_1ImportFrozenModule") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual inline fun PyImport_ImportFrozenModule(name: String): Int = python.native.ffi.bindings.PyImport_ImportFrozenModule(name) + + +// Section 9 +@CName("${namePrefix}PyEval_1GetBuiltins") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyEval_GetBuiltins(): NativePointer? = python.native.ffi.bindings.PyEval_GetBuiltins().toNativePointer() +@CName("${namePrefix}PyEval_1GetLocals") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyEval_GetLocals(): NativePointer? = python.native.ffi.bindings.PyEval_GetLocals().toNativePointer() +@CName("${namePrefix}PyEval_1GetGlobals") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyEval_GetGlobals(): NativePointer? = python.native.ffi.bindings.PyEval_GetGlobals().toNativePointer() +@CName("${namePrefix}PyEval_1GetFrameBuiltins") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyEval_GetFrameBuiltins(): NativePointer? = python.native.ffi.bindings.PyEval_GetFrameBuiltins().toNativePointer() +@CName("${namePrefix}PyEval_1GetFrameLocals") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyEval_GetFrameLocals(): NativePointer? = python.native.ffi.bindings.PyEval_GetFrameLocals().toNativePointer() +@CName("${namePrefix}PyEval_1GetFrameGlobals") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyEval_GetFrameGlobals(): NativePointer? = python.native.ffi.bindings.PyEval_GetFrameGlobals().toNativePointer() +@CName("${namePrefix}PyEval_1GetFuncName") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual inline fun PyEval_GetFuncName(func: NativePointer): String? = python.native.ffi.bindings.PyEval_GetFuncName(func.toPlatformPointer())?.toKString() +@CName("${namePrefix}PyEval_1GetFuncDesc") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual inline fun PyEval_GetFuncDesc(func: NativePointer): String? = python.native.ffi.bindings.PyEval_GetFuncDesc(func.toPlatformPointer())?.toKString() + + +// Section 10 +@CName("${namePrefix}PyObject_1HasAttrWithError") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual inline fun PyObject_HasAttrWithError(o: NativePointer, attr_name: NativePointer): Int = python.native.ffi.bindings.PyObject_HasAttrWithError(o.toPlatformPointer(), attr_name.toPlatformPointer()) +@CName("${namePrefix}PyObject_1HasAttrStringWithError") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual inline fun PyObject_HasAttrStringWithError(o: NativePointer, attr_name: String): Int = python.native.ffi.bindings.PyObject_HasAttrStringWithError(o.toPlatformPointer(), attr_name) +@CName("${namePrefix}PyObject_1HasAttr") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual inline fun PyObject_HasAttr(o: NativePointer, attr_name: NativePointer): Int = python.native.ffi.bindings.PyObject_HasAttr(o.toPlatformPointer(), attr_name.toPlatformPointer()) +@CName("${namePrefix}PyObject_1HasAttrString") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual inline fun PyObject_HasAttrString(o: NativePointer, attr_name: String): Int = python.native.ffi.bindings.PyObject_HasAttrString(o.toPlatformPointer(), attr_name) +@CName("${namePrefix}PyObject_1GetAttr") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyObject_GetAttr(o: NativePointer, attr_name: NativePointer): NativePointer? = python.native.ffi.bindings.PyObject_GetAttr(o.toPlatformPointer(), attr_name.toPlatformPointer()).toNativePointer() +@CName("${namePrefix}PyObject_1GetAttrString") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyObject_GetAttrString(o: NativePointer, attr_name: String): NativePointer? = python.native.ffi.bindings.PyObject_GetAttrString(o.toPlatformPointer(), attr_name).toNativePointer() +@CName("${namePrefix}PyObject_1GenericGetAttr") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyObject_GenericGetAttr(o: NativePointer, name: NativePointer): NativePointer? = python.native.ffi.bindings.PyObject_GenericGetAttr(o.toPlatformPointer(), name.toPlatformPointer()).toNativePointer() +@CName("${namePrefix}PyObject_1SetAttr") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual inline fun PyObject_SetAttr(o: NativePointer, attr_name: NativePointer, v: NativePointer): Int = python.native.ffi.bindings.PyObject_SetAttr(o.toPlatformPointer(), attr_name.toPlatformPointer(), v.toPlatformPointer()) +@CName("${namePrefix}PyObject_1SetAttrString") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual inline fun PyObject_SetAttrString(o: NativePointer, attr_name: String, v: NativePointer): Int = python.native.ffi.bindings.PyObject_SetAttrString(o.toPlatformPointer(), attr_name, v.toPlatformPointer()) +@CName("${namePrefix}PyObject_1GenericSetAttr") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual inline fun PyObject_GenericSetAttr(o: NativePointer, name: NativePointer, value: NativePointer): Int = python.native.ffi.bindings.PyObject_GenericSetAttr(o.toPlatformPointer(), name.toPlatformPointer(), value.toPlatformPointer()) +@CName("${namePrefix}PyObject_1DelAttr") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual inline fun PyObject_DelAttr(o: NativePointer, attr_name: NativePointer): Int = python.native.ffi.bindings.PyObject_DelAttr(o.toPlatformPointer(), attr_name.toPlatformPointer()) +@CName("${namePrefix}PyObject_1DelAttrString") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual inline fun PyObject_DelAttrString(o: NativePointer, attr_name: String): Int = python.native.ffi.bindings.PyObject_DelAttrString(o.toPlatformPointer(), attr_name) +@CName("${namePrefix}PyObject_1RichCompare") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyObject_RichCompare(o1: NativePointer, o2: NativePointer, opid: Int): NativePointer? = python.native.ffi.bindings.PyObject_RichCompare(o1.toPlatformPointer(), o2.toPlatformPointer(), opid).toNativePointer() +@CName("${namePrefix}PyObject_1RichCompareBool") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual inline fun PyObject_RichCompareBool(o1: NativePointer, o2: NativePointer, opid: Int): Int = python.native.ffi.bindings.PyObject_RichCompareBool(o1.toPlatformPointer(), o2.toPlatformPointer(), opid) +@CName("${namePrefix}PyObject_1Format") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyObject_Format(obj: NativePointer, format_spec: NativePointer): NativePointer? = python.native.ffi.bindings.PyObject_Format(obj.toPlatformPointer(), format_spec.toPlatformPointer()).toNativePointer() +@CName("${namePrefix}PyObject_1Repr") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyObject_Repr(o: NativePointer): NativePointer? = python.native.ffi.bindings.PyObject_Repr(o.toPlatformPointer()).toNativePointer() +@CName("${namePrefix}PyObject_1ASCII") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyObject_ASCII(o: NativePointer): NativePointer? = python.native.ffi.bindings.PyObject_ASCII(o.toPlatformPointer()).toNativePointer() +@CName("${namePrefix}PyObject_1Str") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyObject_Str(o: NativePointer): NativePointer? = python.native.ffi.bindings.PyObject_Str(o.toPlatformPointer()).toNativePointer() +@CName("${namePrefix}PyObject_1Bytes") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyObject_Bytes(o: NativePointer): NativePointer? = python.native.ffi.bindings.PyObject_Bytes(o.toPlatformPointer()).toNativePointer() +@CName("${namePrefix}PyObject_1IsSubclass") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual inline fun PyObject_IsSubclass(derived: NativePointer, cls: NativePointer): Int = python.native.ffi.bindings.PyObject_IsSubclass(derived.toPlatformPointer(), cls.toPlatformPointer()) +@CName("${namePrefix}PyObject_1IsInstance") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual inline fun PyObject_IsInstance(inst: NativePointer, cls: NativePointer): Int = python.native.ffi.bindings.PyObject_IsInstance(inst.toPlatformPointer(), cls.toPlatformPointer()) +@CName("${namePrefix}PyObject_1IsTrue") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual inline fun PyObject_IsTrue(o: NativePointer): Int = python.native.ffi.bindings.PyObject_IsTrue(o.toPlatformPointer()) +@CName("${namePrefix}PyObject_1Not") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual inline fun PyObject_Not(o: NativePointer): Int = python.native.ffi.bindings.PyObject_Not(o.toPlatformPointer()) +@CName("${namePrefix}PyObject_1Type") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyObject_Type(o: NativePointer): NativePointer? = python.native.ffi.bindings.PyObject_Type(o.toPlatformPointer()).toNativePointer() +@CName("${namePrefix}PyObject_1GetItem") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyObject_GetItem(o: NativePointer, key: NativePointer): NativePointer? = python.native.ffi.bindings.PyObject_GetItem(o.toPlatformPointer(), key.toPlatformPointer()).toNativePointer() +@CName("${namePrefix}PyObject_1SetItem") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual inline fun PyObject_SetItem(o: NativePointer, key: NativePointer, v: NativePointer): Int = python.native.ffi.bindings.PyObject_SetItem(o.toPlatformPointer(), key.toPlatformPointer(), v.toPlatformPointer()) +@CName("${namePrefix}PyObject_1DelItem") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual inline fun PyObject_DelItem(o: NativePointer, key: NativePointer): Int = python.native.ffi.bindings.PyObject_DelItem(o.toPlatformPointer(), key.toPlatformPointer()) +@CName("${namePrefix}PyObject_1Dir") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyObject_Dir(o: NativePointer): NativePointer? = python.native.ffi.bindings.PyObject_Dir(o.toPlatformPointer()).toNativePointer() +@CName("${namePrefix}PyObject_1GetIter") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyObject_GetIter(o: NativePointer): NativePointer? = python.native.ffi.bindings.PyObject_GetIter(o.toPlatformPointer()).toNativePointer() +@CName("${namePrefix}PyObject_1GetAIter") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyObject_GetAIter(o: NativePointer): NativePointer? = python.native.ffi.bindings.PyObject_GetAIter(o.toPlatformPointer()).toNativePointer() + + +// Section 11 +@CName("${namePrefix}PyVectorcall_1Call") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyVectorcall_Call(callable: NativePointer, tuple: NativePointer, dict: NativePointer): NativePointer? = python.native.ffi.bindings.PyVectorcall_Call(callable.toPlatformPointer(), tuple.toPlatformPointer(), dict.toPlatformPointer()).toNativePointer() +@CName("${namePrefix}PyObject_1Call") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyObject_Call(callable: NativePointer, args: NativePointer, kwargs: NativePointer): NativePointer? = python.native.ffi.bindings.PyObject_Call(callable.toPlatformPointer(), args.toPlatformPointer(), kwargs.toPlatformPointer()).toNativePointer() +@CName("${namePrefix}PyObject_1CallNoArgs") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyObject_CallNoArgs(callable: NativePointer): NativePointer? = python.native.ffi.bindings.PyObject_CallNoArgs(callable.toPlatformPointer()).toNativePointer() +@CName("${namePrefix}PyObject_1CallObject") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyObject_CallObject(callable: NativePointer, args: NativePointer): NativePointer? = python.native.ffi.bindings.PyObject_CallObject(callable.toPlatformPointer(), args.toPlatformPointer()).toNativePointer() +@CName("${namePrefix}PyCallable_1Check") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual inline fun PyCallable_Check(o: NativePointer): Int = python.native.ffi.bindings.PyCallable_Check(o.toPlatformPointer()) + + +// Section 12 +@CName("${namePrefix}PyNumber_1Check") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual inline fun PyNumber_Check(o: NativePointer): Int = python.native.ffi.bindings.PyNumber_Check(o.toPlatformPointer()) +@CName("${namePrefix}PyNumber_1Add") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyNumber_Add(o1: NativePointer, o2: NativePointer): NativePointer? = python.native.ffi.bindings.PyNumber_Add(o1.toPlatformPointer(), o2.toPlatformPointer()).toNativePointer() +@CName("${namePrefix}PyNumber_1Subtract") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyNumber_Subtract(o1: NativePointer, o2: NativePointer): NativePointer? = python.native.ffi.bindings.PyNumber_Subtract(o1.toPlatformPointer(), o2.toPlatformPointer()).toNativePointer() +@CName("${namePrefix}PyNumber_1Multiply") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyNumber_Multiply(o1: NativePointer, o2: NativePointer): NativePointer? = python.native.ffi.bindings.PyNumber_Multiply(o1.toPlatformPointer(), o2.toPlatformPointer()).toNativePointer() +@CName("${namePrefix}PyNumber_1MatrixMultiply") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyNumber_MatrixMultiply(o1: NativePointer, o2: NativePointer): NativePointer? = python.native.ffi.bindings.PyNumber_MatrixMultiply(o1.toPlatformPointer(), o2.toPlatformPointer()).toNativePointer() +@CName("${namePrefix}PyNumber_1FloorDivide") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyNumber_FloorDivide(o1: NativePointer, o2: NativePointer): NativePointer? = python.native.ffi.bindings.PyNumber_FloorDivide(o1.toPlatformPointer(), o2.toPlatformPointer()).toNativePointer() +@CName("${namePrefix}PyNumber_1TrueDivide") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyNumber_TrueDivide(o1: NativePointer, o2: NativePointer): NativePointer? = python.native.ffi.bindings.PyNumber_TrueDivide(o1.toPlatformPointer(), o2.toPlatformPointer()).toNativePointer() +@CName("${namePrefix}PyNumber_1Remainder") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyNumber_Remainder(o1: NativePointer, o2: NativePointer): NativePointer? = python.native.ffi.bindings.PyNumber_Remainder(o1.toPlatformPointer(), o2.toPlatformPointer()).toNativePointer() +@CName("${namePrefix}PyNumber_1Divmod") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyNumber_Divmod(o1: NativePointer, o2: NativePointer): NativePointer? = python.native.ffi.bindings.PyNumber_Divmod(o1.toPlatformPointer(), o2.toPlatformPointer()).toNativePointer() +@CName("${namePrefix}PyNumber_1Power") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyNumber_Power(o1: NativePointer, o2: NativePointer, o3: NativePointer): NativePointer? = python.native.ffi.bindings.PyNumber_Power(o1.toPlatformPointer(), o2.toPlatformPointer(), o3.toPlatformPointer()).toNativePointer() +@CName("${namePrefix}PyNumber_1Negative") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyNumber_Negative(o: NativePointer): NativePointer? = python.native.ffi.bindings.PyNumber_Negative(o.toPlatformPointer()).toNativePointer() +@CName("${namePrefix}PyNumber_1Positive") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyNumber_Positive(o: NativePointer): NativePointer? = python.native.ffi.bindings.PyNumber_Positive(o.toPlatformPointer()).toNativePointer() +@CName("${namePrefix}PyNumber_1Absolute") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyNumber_Absolute(o: NativePointer): NativePointer? = python.native.ffi.bindings.PyNumber_Absolute(o.toPlatformPointer()).toNativePointer() +@CName("${namePrefix}PyNumber_1Invert") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyNumber_Invert(o: NativePointer): NativePointer? = python.native.ffi.bindings.PyNumber_Invert(o.toPlatformPointer()).toNativePointer() +@CName("${namePrefix}PyNumber_1Lshift") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyNumber_Lshift(o1: NativePointer, o2: NativePointer): NativePointer? = python.native.ffi.bindings.PyNumber_Lshift(o1.toPlatformPointer(), o2.toPlatformPointer()).toNativePointer() +@CName("${namePrefix}PyNumber_1Rshift") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyNumber_Rshift(o1: NativePointer, o2: NativePointer): NativePointer? = python.native.ffi.bindings.PyNumber_Rshift(o1.toPlatformPointer(), o2.toPlatformPointer()).toNativePointer() +@CName("${namePrefix}PyNumber_1And") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyNumber_And(o1: NativePointer, o2: NativePointer): NativePointer? = python.native.ffi.bindings.PyNumber_And(o1.toPlatformPointer(), o2.toPlatformPointer()).toNativePointer() +@CName("${namePrefix}PyNumber_1Xor") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyNumber_Xor(o1: NativePointer, o2: NativePointer): NativePointer? = python.native.ffi.bindings.PyNumber_Xor(o1.toPlatformPointer(), o2.toPlatformPointer()).toNativePointer() +@CName("${namePrefix}PyNumber_1Or") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyNumber_Or(o1: NativePointer, o2: NativePointer): NativePointer? = python.native.ffi.bindings.PyNumber_Or(o1.toPlatformPointer(), o2.toPlatformPointer()).toNativePointer() +@CName("${namePrefix}PyNumber_1InPlaceAdd") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyNumber_InPlaceAdd(o1: NativePointer, o2: NativePointer): NativePointer? = python.native.ffi.bindings.PyNumber_InPlaceAdd(o1.toPlatformPointer(), o2.toPlatformPointer()).toNativePointer() +@CName("${namePrefix}PyNumber_1InPlaceSubtract") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyNumber_InPlaceSubtract(o1: NativePointer, o2: NativePointer): NativePointer? = python.native.ffi.bindings.PyNumber_InPlaceSubtract(o1.toPlatformPointer(), o2.toPlatformPointer()).toNativePointer() +@CName("${namePrefix}PyNumber_1InPlaceMultiply") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyNumber_InPlaceMultiply(o1: NativePointer, o2: NativePointer): NativePointer? = python.native.ffi.bindings.PyNumber_InPlaceMultiply(o1.toPlatformPointer(), o2.toPlatformPointer()).toNativePointer() +@CName("${namePrefix}PyNumber_1InPlaceMatrixMultiply") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyNumber_InPlaceMatrixMultiply(o1: NativePointer, o2: NativePointer): NativePointer? = python.native.ffi.bindings.PyNumber_InPlaceMatrixMultiply(o1.toPlatformPointer(), o2.toPlatformPointer()).toNativePointer() +@CName("${namePrefix}PyNumber_1InPlaceFloorDivide") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyNumber_InPlaceFloorDivide(o1: NativePointer, o2: NativePointer): NativePointer? = python.native.ffi.bindings.PyNumber_InPlaceFloorDivide(o1.toPlatformPointer(), o2.toPlatformPointer()).toNativePointer() +@CName("${namePrefix}PyNumber_1InPlaceTrueDivide") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyNumber_InPlaceTrueDivide(o1: NativePointer, o2: NativePointer): NativePointer? = python.native.ffi.bindings.PyNumber_InPlaceTrueDivide(o1.toPlatformPointer(), o2.toPlatformPointer()).toNativePointer() +@CName("${namePrefix}PyNumber_1InPlaceRemainder") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyNumber_InPlaceRemainder(o1: NativePointer, o2: NativePointer): NativePointer? = python.native.ffi.bindings.PyNumber_InPlaceRemainder(o1.toPlatformPointer(), o2.toPlatformPointer()).toNativePointer() +@CName("${namePrefix}PyNumber_1InPlacePower") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyNumber_InPlacePower(o1: NativePointer, o2: NativePointer, o3: NativePointer): NativePointer? = python.native.ffi.bindings.PyNumber_InPlacePower(o1.toPlatformPointer(), o2.toPlatformPointer(), o3.toPlatformPointer()).toNativePointer() +@CName("${namePrefix}PyNumber_1InPlaceLshift") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyNumber_InPlaceLshift(o1: NativePointer, o2: NativePointer): NativePointer? = python.native.ffi.bindings.PyNumber_InPlaceLshift(o1.toPlatformPointer(), o2.toPlatformPointer()).toNativePointer() +@CName("${namePrefix}PyNumber_1InPlaceRshift") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyNumber_InPlaceRshift(o1: NativePointer, o2: NativePointer): NativePointer? = python.native.ffi.bindings.PyNumber_InPlaceRshift(o1.toPlatformPointer(), o2.toPlatformPointer()).toNativePointer() +@CName("${namePrefix}PyNumber_1InPlaceAnd") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyNumber_InPlaceAnd(o1: NativePointer, o2: NativePointer): NativePointer? = python.native.ffi.bindings.PyNumber_InPlaceAnd(o1.toPlatformPointer(), o2.toPlatformPointer()).toNativePointer() +@CName("${namePrefix}PyNumber_1InPlaceXor") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyNumber_InPlaceXor(o1: NativePointer, o2: NativePointer): NativePointer? = python.native.ffi.bindings.PyNumber_InPlaceXor(o1.toPlatformPointer(), o2.toPlatformPointer()).toNativePointer() +@CName("${namePrefix}PyNumber_1InPlaceOr") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyNumber_InPlaceOr(o1: NativePointer, o2: NativePointer): NativePointer? = python.native.ffi.bindings.PyNumber_InPlaceOr(o1.toPlatformPointer(), o2.toPlatformPointer()).toNativePointer() +@CName("${namePrefix}PyNumber_1Long") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyNumber_Long(o: NativePointer): NativePointer? = python.native.ffi.bindings.PyNumber_Long(o.toPlatformPointer()).toNativePointer() +@CName("${namePrefix}PyNumber_1Float") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyNumber_Float(o: NativePointer): NativePointer? = python.native.ffi.bindings.PyNumber_Float(o.toPlatformPointer()).toNativePointer() +@CName("${namePrefix}PyNumber_1Index") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyNumber_Index(o: NativePointer): NativePointer? = python.native.ffi.bindings.PyNumber_Index(o.toPlatformPointer()).toNativePointer() +@CName("${namePrefix}PyNumber_1ToBase") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyNumber_ToBase(n: NativePointer, base: Int): NativePointer? = python.native.ffi.bindings.PyNumber_ToBase(n.toPlatformPointer(), base).toNativePointer() +@CName("${namePrefix}PyIndex_1Check") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual inline fun PyIndex_Check(o: NativePointer): Int = python.native.ffi.bindings.PyIndex_Check(o.toPlatformPointer()) + + +// Section 13 +@CName("${namePrefix}PySequence_1Check") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual inline fun PySequence_Check(o: NativePointer): Int = python.native.ffi.bindings.PySequence_Check(o.toPlatformPointer()) +@CName("${namePrefix}PySequence_1Concat") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PySequence_Concat(o1: NativePointer, o2: NativePointer): NativePointer? = python.native.ffi.bindings.PySequence_Concat(o1.toPlatformPointer(), o2.toPlatformPointer()).toNativePointer() +@CName("${namePrefix}PySequence_1InPlaceConcat") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PySequence_InPlaceConcat(o1: NativePointer, o2: NativePointer): NativePointer? = python.native.ffi.bindings.PySequence_InPlaceConcat(o1.toPlatformPointer(), o2.toPlatformPointer()).toNativePointer() +@CName("${namePrefix}PySequence_1Contains") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual inline fun PySequence_Contains(o: NativePointer, value: NativePointer): Int = python.native.ffi.bindings.PySequence_Contains(o.toPlatformPointer(), value.toPlatformPointer()) +@CName("${namePrefix}PySequence_1List") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PySequence_List(o: NativePointer): NativePointer? = python.native.ffi.bindings.PySequence_List(o.toPlatformPointer()).toNativePointer() +@CName("${namePrefix}PySequence_1Tuple") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PySequence_Tuple(o: NativePointer): NativePointer? = python.native.ffi.bindings.PySequence_Tuple(o.toPlatformPointer()).toNativePointer() +@CName("${namePrefix}PySequence_1Fast") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PySequence_Fast(o: NativePointer, m: String): NativePointer? = python.native.ffi.bindings.PySequence_Fast(o.toPlatformPointer(), m).toNativePointer() + + +// Section 14 +@CName("${namePrefix}PyMapping_1Check") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual inline fun PyMapping_Check(o: NativePointer): Int = python.native.ffi.bindings.PyMapping_Check(o.toPlatformPointer()) +@CName("${namePrefix}PyMapping_1GetItemString") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyMapping_GetItemString(o: NativePointer, key: String): NativePointer? = python.native.ffi.bindings.PyMapping_GetItemString(o.toPlatformPointer(), key).toNativePointer() +@CName("${namePrefix}PyMapping_1SetItemString") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual inline fun PyMapping_SetItemString(o: NativePointer, key: String, v: NativePointer): Int = python.native.ffi.bindings.PyMapping_SetItemString(o.toPlatformPointer(), key, v.toPlatformPointer()) +@CName("${namePrefix}PyMapping_1HasKeyWithError") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual inline fun PyMapping_HasKeyWithError(o: NativePointer, key: NativePointer): Int = python.native.ffi.bindings.PyMapping_HasKeyWithError(o.toPlatformPointer(), key.toPlatformPointer()) +@CName("${namePrefix}PyMapping_1HasKeyStringWithError") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual inline fun PyMapping_HasKeyStringWithError(o: NativePointer, key: String): Int = python.native.ffi.bindings.PyMapping_HasKeyStringWithError(o.toPlatformPointer(), key) +@CName("${namePrefix}PyMapping_1HasKey") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual inline fun PyMapping_HasKey(o: NativePointer, key: NativePointer): Int = python.native.ffi.bindings.PyMapping_HasKey(o.toPlatformPointer(), key.toPlatformPointer()) +@CName("${namePrefix}PyMapping_1HasKeyString") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual inline fun PyMapping_HasKeyString(o: NativePointer, key: String): Int = python.native.ffi.bindings.PyMapping_HasKeyString(o.toPlatformPointer(), key) +@CName("${namePrefix}PyMapping_1Keys") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyMapping_Keys(o: NativePointer): NativePointer? = python.native.ffi.bindings.PyMapping_Keys(o.toPlatformPointer()).toNativePointer() +@CName("${namePrefix}PyMapping_1Values") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyMapping_Values(o: NativePointer): NativePointer? = python.native.ffi.bindings.PyMapping_Values(o.toPlatformPointer()).toNativePointer() +@CName("${namePrefix}PyMapping_1Items") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyMapping_Items(o: NativePointer): NativePointer? = python.native.ffi.bindings.PyMapping_Items(o.toPlatformPointer()).toNativePointer() + + +// Section 15 +@CName("${namePrefix}PyIter_1Check") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual inline fun PyIter_Check(o: NativePointer): Int = python.native.ffi.bindings.PyIter_Check(o.toPlatformPointer()) +@CName("${namePrefix}PyAIter_1Check") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual inline fun PyAIter_Check(o: NativePointer): Int = python.native.ffi.bindings.PyAIter_Check(o.toPlatformPointer()) +@CName("${namePrefix}PyIter_1Next") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyIter_Next(o: NativePointer): NativePointer? = python.native.ffi.bindings.PyIter_Next(o.toPlatformPointer()).toNativePointer() + + +// Section 16 +@CName("${namePrefix}PyLong_1FromLongLong") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyLong_FromLongLong(v: Long): NativePointer? = python.native.ffi.bindings.PyLong_FromLongLong(v).toNativePointer() +@CName("${namePrefix}PyLong_1FromDouble") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyLong_FromDouble(v: Double): NativePointer? = python.native.ffi.bindings.PyLong_FromDouble(v).toNativePointer() +@CName("${namePrefix}PyLong_1AsInt") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual inline fun PyLong_AsInt(obj: NativePointer): Int = python.native.ffi.bindings.PyLong_AsInt(obj.toPlatformPointer()) +@CName("${namePrefix}PyLong_1AsLongLong") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual inline fun PyLong_AsLongLong(obj: NativePointer): Long = python.native.ffi.bindings.PyLong_AsLongLong(obj.toPlatformPointer()) +@CName("${namePrefix}PyLong_1AsDouble") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual inline fun PyLong_AsDouble(pylong: NativePointer): Double = python.native.ffi.bindings.PyLong_AsDouble(pylong.toPlatformPointer()) +@CName("${namePrefix}PyLong_1GetInfo") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyLong_GetInfo(): NativePointer? = python.native.ffi.bindings.PyLong_GetInfo().toNativePointer() + + +// Section 17 +@CName("${namePrefix}PyBool_1FromLong") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyBool_FromLong(v: Int): NativePointer? = python.native.ffi.bindings.PyBool_FromLong(v.toLong()).toNativePointer() + + +// Section 18 +@CName("${namePrefix}PyFloat_1FromString") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyFloat_FromString(str: NativePointer): NativePointer? = python.native.ffi.bindings.PyFloat_FromString(str.toPlatformPointer()).toNativePointer() +@CName("${namePrefix}PyFloat_1FromDouble") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyFloat_FromDouble(v: Double): NativePointer? = python.native.ffi.bindings.PyFloat_FromDouble(v).toNativePointer() +@CName("${namePrefix}PyFloat_1AsDouble") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual inline fun PyFloat_AsDouble(pyfloat: NativePointer): Double = python.native.ffi.bindings.PyFloat_AsDouble(pyfloat.toPlatformPointer()) +@CName("${namePrefix}PyFloat_1GetInfo") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyFloat_GetInfo(): NativePointer? = python.native.ffi.bindings.PyFloat_GetInfo().toNativePointer() +@CName("${namePrefix}PyFloat_1GetMax") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual inline fun PyFloat_GetMax(): Double = python.native.ffi.bindings.PyFloat_GetMax() +@CName("${namePrefix}PyFloat_1GetMin") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual inline fun PyFloat_GetMin(): Double = python.native.ffi.bindings.PyFloat_GetMin() + + +// Section 19 +@CName("${namePrefix}PyBytes_1FromString") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyBytes_FromString(v: String): NativePointer? = python.native.ffi.bindings.PyBytes_FromString(v).toNativePointer() +@CName("${namePrefix}PyBytes_1FromObject") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyBytes_FromObject(o: NativePointer): NativePointer? = python.native.ffi.bindings.PyBytes_FromObject(o.toPlatformPointer()).toNativePointer() +@CName("${namePrefix}PyBytes_1AsString") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual inline fun PyBytes_AsString(o: NativePointer): String? = python.native.ffi.bindings.PyBytes_AsString(o.toPlatformPointer())?.toKString() + + +// Section 20 +@CName("${namePrefix}PyByteArray_1FromObject") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyByteArray_FromObject(o: NativePointer): NativePointer? = python.native.ffi.bindings.PyByteArray_FromObject(o.toPlatformPointer()).toNativePointer() +@CName("${namePrefix}PyByteArray_1Concat") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyByteArray_Concat(a: NativePointer, b: NativePointer): NativePointer? = python.native.ffi.bindings.PyByteArray_Concat(a.toPlatformPointer(), b.toPlatformPointer()).toNativePointer() +@CName("${namePrefix}PyByteArray_1AsString") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual inline fun PyByteArray_AsString(bytearray: NativePointer): String? = python.native.ffi.bindings.PyByteArray_AsString(bytearray.toPlatformPointer())?.toKString() + + +// Section 21 +@CName("${namePrefix}PyUnicode_1IsIdentifier") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual inline fun PyUnicode_IsIdentifier(unicode: NativePointer): Int = python.native.ffi.bindings.PyUnicode_IsIdentifier(unicode.toPlatformPointer()) +@CName("${namePrefix}PyUnicode_1FromString") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyUnicode_FromString(str: String): NativePointer? = python.native.ffi.bindings.PyUnicode_FromString(str).toNativePointer() +@CName("${namePrefix}PyUnicode_1FromObject") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyUnicode_FromObject(obj: NativePointer): NativePointer? = python.native.ffi.bindings.PyUnicode_FromObject(obj.toPlatformPointer()).toNativePointer() +@CName("${namePrefix}PyUnicode_1FromEncodedObject") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyUnicode_FromEncodedObject(obj: NativePointer, encoding: String, errors: String): NativePointer? = python.native.ffi.bindings.PyUnicode_FromEncodedObject(obj.toPlatformPointer(), encoding, errors).toNativePointer() +@CName("${namePrefix}PyUnicode_1DecodeLocale") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyUnicode_DecodeLocale(str: String, errors: String): NativePointer? = python.native.ffi.bindings.PyUnicode_DecodeLocale(str, errors).toNativePointer() +@CName("${namePrefix}PyUnicode_1EncodeLocale") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyUnicode_EncodeLocale(unicode: NativePointer, errors: String): NativePointer? = python.native.ffi.bindings.PyUnicode_EncodeLocale(unicode.toPlatformPointer(), errors).toNativePointer() +@CName("${namePrefix}PyUnicode_1DecodeFSDefault") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyUnicode_DecodeFSDefault(str: String): NativePointer? = python.native.ffi.bindings.PyUnicode_DecodeFSDefault(str).toNativePointer() +@CName("${namePrefix}PyUnicode_1EncodeFSDefault") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyUnicode_EncodeFSDefault(unicode: NativePointer): NativePointer? = python.native.ffi.bindings.PyUnicode_EncodeFSDefault(unicode.toPlatformPointer()).toNativePointer() +@CName("${namePrefix}PyUnicode_1AsEncodedString") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyUnicode_AsEncodedString(unicode: NativePointer, encoding: String, errors: String): NativePointer? = python.native.ffi.bindings.PyUnicode_AsEncodedString(unicode.toPlatformPointer(), encoding, errors).toNativePointer() +@CName("${namePrefix}PyUnicode_1AsUTF8String") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyUnicode_AsUTF8String(unicode: NativePointer): NativePointer? = python.native.ffi.bindings.PyUnicode_AsUTF8String(unicode.toPlatformPointer()).toNativePointer() +@CName("${namePrefix}PyUnicode_1AsUTF8") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual inline fun PyUnicode_AsUTF8(unicode: NativePointer): String? = + python.native.ffi.bindings.PyUnicode_AsUTF8(unicode.toPlatformPointer())?.toKString() // 수동 추가 +@CName("${namePrefix}PyUnicode_1AsUTF32String") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyUnicode_AsUTF32String(unicode: NativePointer): NativePointer? = python.native.ffi.bindings.PyUnicode_AsUTF32String(unicode.toPlatformPointer()).toNativePointer() +@CName("${namePrefix}PyUnicode_1AsUTF16String") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyUnicode_AsUTF16String(unicode: NativePointer): NativePointer? = python.native.ffi.bindings.PyUnicode_AsUTF16String(unicode.toPlatformPointer()).toNativePointer() +@CName("${namePrefix}PyUnicode_1AsUnicodeEscapeString") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyUnicode_AsUnicodeEscapeString(unicode: NativePointer): NativePointer? = python.native.ffi.bindings.PyUnicode_AsUnicodeEscapeString(unicode.toPlatformPointer()).toNativePointer() +@CName("${namePrefix}PyUnicode_1AsRawUnicodeEscapeString") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyUnicode_AsRawUnicodeEscapeString(unicode: NativePointer): NativePointer? = python.native.ffi.bindings.PyUnicode_AsRawUnicodeEscapeString(unicode.toPlatformPointer()).toNativePointer() +@CName("${namePrefix}PyUnicode_1AsLatin1String") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyUnicode_AsLatin1String(unicode: NativePointer): NativePointer? = python.native.ffi.bindings.PyUnicode_AsLatin1String(unicode.toPlatformPointer()).toNativePointer() +@CName("${namePrefix}PyUnicode_1AsASCIIString") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyUnicode_AsASCIIString(unicode: NativePointer): NativePointer? = python.native.ffi.bindings.PyUnicode_AsASCIIString(unicode.toPlatformPointer()).toNativePointer() +@CName("${namePrefix}PyUnicode_1AsCharmapString") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyUnicode_AsCharmapString(unicode: NativePointer, mapping: NativePointer): NativePointer? = python.native.ffi.bindings.PyUnicode_AsCharmapString(unicode.toPlatformPointer(), mapping.toPlatformPointer()).toNativePointer() +@CName("${namePrefix}PyUnicode_1Translate") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyUnicode_Translate(unicode: NativePointer, table: NativePointer, errors: String): NativePointer? = python.native.ffi.bindings.PyUnicode_Translate(unicode.toPlatformPointer(), table.toPlatformPointer(), errors).toNativePointer() +@CName("${namePrefix}PyUnicode_1Concat") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyUnicode_Concat(left: NativePointer, right: NativePointer): NativePointer? = python.native.ffi.bindings.PyUnicode_Concat(left.toPlatformPointer(), right.toPlatformPointer()).toNativePointer() +@CName("${namePrefix}PyUnicode_1Splitlines") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyUnicode_Splitlines(unicode: NativePointer, keepends: Int): NativePointer? = python.native.ffi.bindings.PyUnicode_Splitlines(unicode.toPlatformPointer(), keepends).toNativePointer() +@CName("${namePrefix}PyUnicode_1Join") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyUnicode_Join(separator: NativePointer, seq: NativePointer): NativePointer? = python.native.ffi.bindings.PyUnicode_Join(separator.toPlatformPointer(), seq.toPlatformPointer()).toNativePointer() +@CName("${namePrefix}PyUnicode_1Compare") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual inline fun PyUnicode_Compare(left: NativePointer, right: NativePointer): Int = python.native.ffi.bindings.PyUnicode_Compare(left.toPlatformPointer(), right.toPlatformPointer()) +@CName("${namePrefix}PyUnicode_1EqualToUTF8") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual inline fun PyUnicode_EqualToUTF8(unicode: NativePointer, string: String): Int = python.native.ffi.bindings.PyUnicode_EqualToUTF8(unicode.toPlatformPointer(), string) +@CName("${namePrefix}PyUnicode_1CompareWithASCIIString") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual inline fun PyUnicode_CompareWithASCIIString(unicode: NativePointer, string: String): Int = python.native.ffi.bindings.PyUnicode_CompareWithASCIIString(unicode.toPlatformPointer(), string) +@CName("${namePrefix}PyUnicode_1RichCompare") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyUnicode_RichCompare(left: NativePointer, right: NativePointer, op: Int): NativePointer? = python.native.ffi.bindings.PyUnicode_RichCompare(left.toPlatformPointer(), right.toPlatformPointer(), op).toNativePointer() +@CName("${namePrefix}PyUnicode_1Format") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyUnicode_Format(format: NativePointer, args: NativePointer): NativePointer? = python.native.ffi.bindings.PyUnicode_Format(format.toPlatformPointer(), args.toPlatformPointer()).toNativePointer() +@CName("${namePrefix}PyUnicode_1Contains") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual inline fun PyUnicode_Contains(unicode: NativePointer, substr: NativePointer): Int = python.native.ffi.bindings.PyUnicode_Contains(unicode.toPlatformPointer(), substr.toPlatformPointer()) +@CName("${namePrefix}PyUnicode_1InternFromString") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyUnicode_InternFromString(str: String): NativePointer? = python.native.ffi.bindings.PyUnicode_InternFromString(str).toNativePointer() + + +// Section 22 +@CName("${namePrefix}PyList_1Append") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual inline fun PyList_Append(list: NativePointer, item: NativePointer): Int = python.native.ffi.bindings.PyList_Append(list.toPlatformPointer(), item.toPlatformPointer()) +@CName("${namePrefix}PyList_1Sort") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual inline fun PyList_Sort(list: NativePointer): Int = python.native.ffi.bindings.PyList_Sort(list.toPlatformPointer()) +@CName("${namePrefix}PyList_1Reverse") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual inline fun PyList_Reverse(list: NativePointer): Int = python.native.ffi.bindings.PyList_Reverse(list.toPlatformPointer()) +@CName("${namePrefix}PyList_1AsTuple") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyList_AsTuple(list: NativePointer): NativePointer? = python.native.ffi.bindings.PyList_AsTuple(list.toPlatformPointer()).toNativePointer() + + +// Section 23 +@CName("${namePrefix}PyDict_1New") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyDict_New(): NativePointer? = python.native.ffi.bindings.PyDict_New().toNativePointer() +@CName("${namePrefix}PyDictProxy_1New") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyDictProxy_New(mapping: NativePointer): NativePointer? = python.native.ffi.bindings.PyDictProxy_New(mapping.toPlatformPointer()).toNativePointer() +@CName("${namePrefix}PyDict_1Clear") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual inline fun PyDict_Clear(p: NativePointer) = python.native.ffi.bindings.PyDict_Clear(p.toPlatformPointer()) +@CName("${namePrefix}PyDict_1Contains") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual inline fun PyDict_Contains(p: NativePointer, key: NativePointer): Int = python.native.ffi.bindings.PyDict_Contains(p.toPlatformPointer(), key.toPlatformPointer()) +@CName("${namePrefix}PyDict_1Copy") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyDict_Copy(p: NativePointer): NativePointer? = python.native.ffi.bindings.PyDict_Copy(p.toPlatformPointer()).toNativePointer() +@CName("${namePrefix}PyDict_1SetItem") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual inline fun PyDict_SetItem(p: NativePointer, key: NativePointer, v: NativePointer): Int = python.native.ffi.bindings.PyDict_SetItem(p.toPlatformPointer(), key.toPlatformPointer(), v.toPlatformPointer()) +@CName("${namePrefix}PyDict_1SetItemString") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual inline fun PyDict_SetItemString(p: NativePointer, key: String, v: NativePointer): Int = python.native.ffi.bindings.PyDict_SetItemString(p.toPlatformPointer(), key, v.toPlatformPointer()) +@CName("${namePrefix}PyDict_1DelItem") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual inline fun PyDict_DelItem(p: NativePointer, key: NativePointer): Int = python.native.ffi.bindings.PyDict_DelItem(p.toPlatformPointer(), key.toPlatformPointer()) +@CName("${namePrefix}PyDict_1DelItemString") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual inline fun PyDict_DelItemString(p: NativePointer, key: String): Int = python.native.ffi.bindings.PyDict_DelItemString(p.toPlatformPointer(), key) +@CName("${namePrefix}PyDict_1GetItem") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyDict_GetItem(p: NativePointer, key: NativePointer): NativePointer? = python.native.ffi.bindings.PyDict_GetItem(p.toPlatformPointer(), key.toPlatformPointer()).toNativePointer() +@CName("${namePrefix}PyDict_1GetItemWithError") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyDict_GetItemWithError(p: NativePointer, key: NativePointer): NativePointer? = python.native.ffi.bindings.PyDict_GetItemWithError(p.toPlatformPointer(), key.toPlatformPointer()).toNativePointer() +@CName("${namePrefix}PyDict_1GetItemString") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyDict_GetItemString(p: NativePointer, key: String): NativePointer? = python.native.ffi.bindings.PyDict_GetItemString(p.toPlatformPointer(), key).toNativePointer() +@CName("${namePrefix}PyDict_1Items") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyDict_Items(p: NativePointer): NativePointer? = python.native.ffi.bindings.PyDict_Items(p.toPlatformPointer()).toNativePointer() +@CName("${namePrefix}PyDict_1Keys") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyDict_Keys(p: NativePointer): NativePointer? = python.native.ffi.bindings.PyDict_Keys(p.toPlatformPointer()).toNativePointer() +@CName("${namePrefix}PyDict_1Values") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyDict_Values(p: NativePointer): NativePointer? = python.native.ffi.bindings.PyDict_Values(p.toPlatformPointer()).toNativePointer() +@CName("${namePrefix}PyDict_1Merge") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual inline fun PyDict_Merge(a: NativePointer, b: NativePointer, override: Int): Int = python.native.ffi.bindings.PyDict_Merge(a.toPlatformPointer(), b.toPlatformPointer(), override) +@CName("${namePrefix}PyDict_1Update") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual inline fun PyDict_Update(a: NativePointer, b: NativePointer): Int = python.native.ffi.bindings.PyDict_Update(a.toPlatformPointer(), b.toPlatformPointer()) +@CName("${namePrefix}PyDict_1MergeFromSeq2") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual inline fun PyDict_MergeFromSeq2(a: NativePointer, seq2: NativePointer, override: Int): Int = python.native.ffi.bindings.PyDict_MergeFromSeq2(a.toPlatformPointer(), seq2.toPlatformPointer(), override) + + +// Section 24 +@CName("${namePrefix}PySet_1New") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PySet_New(iterable: NativePointer): NativePointer? = python.native.ffi.bindings.PySet_New(iterable.toPlatformPointer()).toNativePointer() +@CName("${namePrefix}PyFrozenSet_1New") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyFrozenSet_New(iterable: NativePointer): NativePointer? = python.native.ffi.bindings.PyFrozenSet_New(iterable.toPlatformPointer()).toNativePointer() +@CName("${namePrefix}PySet_1Contains") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual inline fun PySet_Contains(anyset: NativePointer, key: NativePointer): Int = python.native.ffi.bindings.PySet_Contains(anyset.toPlatformPointer(), key.toPlatformPointer()) +@CName("${namePrefix}PySet_1Add") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual inline fun PySet_Add(set: NativePointer, key: NativePointer): Int = python.native.ffi.bindings.PySet_Add(set.toPlatformPointer(), key.toPlatformPointer()) +@CName("${namePrefix}PySet_1Discard") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual inline fun PySet_Discard(set: NativePointer, key: NativePointer): Int = python.native.ffi.bindings.PySet_Discard(set.toPlatformPointer(), key.toPlatformPointer()) +@CName("${namePrefix}PySet_1Pop") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PySet_Pop(set: NativePointer): NativePointer? = python.native.ffi.bindings.PySet_Pop(set.toPlatformPointer()).toNativePointer() +@CName("${namePrefix}PySet_1Clear") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual inline fun PySet_Clear(set: NativePointer): Int = python.native.ffi.bindings.PySet_Clear(set.toPlatformPointer()) + + +// Section 25 +@CName("${namePrefix}PySeqIter_1New") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PySeqIter_New(seq: NativePointer): NativePointer? = python.native.ffi.bindings.PySeqIter_New(seq.toPlatformPointer()).toNativePointer() +@CName("${namePrefix}PyCallIter_1New") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyCallIter_New(callable: NativePointer, sentinel: NativePointer): NativePointer? = python.native.ffi.bindings.PyCallIter_New(callable.toPlatformPointer(), sentinel.toPlatformPointer()).toNativePointer() + + +// Section 26 +@CName("${namePrefix}PyWeakref_1NewRef") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyWeakref_NewRef(ob: NativePointer, callback: NativePointer): NativePointer? = python.native.ffi.bindings.PyWeakref_NewRef(ob.toPlatformPointer(), callback.toPlatformPointer()).toNativePointer() +@CName("${namePrefix}PyWeakref_1NewProxy") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyWeakref_NewProxy(ob: NativePointer, callback: NativePointer): NativePointer? = python.native.ffi.bindings.PyWeakref_NewProxy(ob.toPlatformPointer(), callback.toPlatformPointer()).toNativePointer() +@CName("${namePrefix}PyWeakref_1GetObject") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyWeakref_GetObject(ref: NativePointer): NativePointer? = python.native.ffi.bindings.PyWeakref_GetObject(ref.toPlatformPointer()).toNativePointer() +@CName("${namePrefix}PyObject_1ClearWeakRefs") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual inline fun PyObject_ClearWeakRefs(o: NativePointer) = python.native.ffi.bindings.PyObject_ClearWeakRefs(o.toPlatformPointer()) + + +// Section 27 +@CName("${namePrefix}PyType_1IsSubtype") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual inline fun PyType_IsSubtype(a: NativePointer, b: NativePointer): Int = python.native.ffi.bindings.PyType_IsSubtype(a.toPlatformPointer(), b.toPlatformPointer()) +@CName("${namePrefix}PyType_1Ready") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual inline fun PyType_Ready(type: NativePointer): Int = python.native.ffi.bindings.PyType_Ready(type.toPlatformPointer()) +@CName("${namePrefix}PyType_1GetName") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyType_GetName(type: NativePointer): NativePointer? = python.native.ffi.bindings.PyType_GetName(type.toPlatformPointer()).toNativePointer() +@CName("${namePrefix}PyType_1GetFullyQualifiedName") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyType_GetFullyQualifiedName(type: NativePointer): NativePointer? = python.native.ffi.bindings.PyType_GetFullyQualifiedName(type.toPlatformPointer()).toNativePointer() +@CName("${namePrefix}PyType_1GetModuleName") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyType_GetModuleName(type: NativePointer): NativePointer? = python.native.ffi.bindings.PyType_GetModuleName(type.toPlatformPointer()).toNativePointer() +@CName("${namePrefix}PyType_1GetModule") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyType_GetModule(type: NativePointer): NativePointer? = python.native.ffi.bindings.PyType_GetModule(type.toPlatformPointer()).toNativePointer() + + +// Section 28 +@CName("${namePrefix}PyTuple_1New") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyTuple_New(len: Long): NativePointer? = python.native.ffi.bindings.PyTuple_New(len).toNativePointer() +@CName("${namePrefix}PyTuple_1Size") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual inline fun PyTuple_Size(p: NativePointer): Long = python.native.ffi.bindings.PyTuple_Size(p.toPlatformPointer()) +@CName("${namePrefix}PyTuple_1GetItem") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyTuple_GetItem(p: NativePointer, pos: Long): NativePointer? = python.native.ffi.bindings.PyTuple_GetItem(p.toPlatformPointer(), pos).toNativePointer() +@CName("${namePrefix}PyTuple_1GetSlice") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual fun PyTuple_GetSlice(p: NativePointer, low: Long, high: Long): NativePointer? = python.native.ffi.bindings.PyTuple_GetSlice(p.toPlatformPointer(), low, high).toNativePointer() +@CName("${namePrefix}PyTuple_1SetItem") +@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) +actual inline fun PyTuple_SetItem(p: NativePointer, pos: Long, o: NativePointer): Int = python.native.ffi.bindings.PyTuple_SetItem(p.toPlatformPointer(), pos, o.toPlatformPointer())