From 022a24eec3f1167e75e534ea6685140ea03effcf Mon Sep 17 00:00:00 2001 From: PythonSwiftLink <107263226+PythonSwiftLink@users.noreply.github.com> Date: Thu, 27 Jul 2023 09:24:58 +0200 Subject: [PATCH 1/7] Testing (#27) * Delete PyEncodable.swift * pycall generics update --------- Co-authored-by: psychowaspx --- Package.swift | 2 + Sources/PyEncodable.swift | 365 ------ .../PythonSwiftCore/PyPointer+PyCall.swift | 1052 ++++++++++++++++- .../PythonObject+Attributes.swift | 0 .../PythonObject+Callable.swift | 0 .../PythonObject+Sequence.swift | 0 .../PythonObject+Subscript.swift | 0 .../{ => PythonObject}/PythonObject.swift | 0 .../PythonSwiftCore/PythonPointer+exec.swift | 34 +- 9 files changed, 1026 insertions(+), 427 deletions(-) delete mode 100644 Sources/PyEncodable.swift rename Sources/PythonSwiftCore/{ => PythonObject}/PythonObject+Attributes.swift (100%) rename Sources/PythonSwiftCore/{ => PythonObject}/PythonObject+Callable.swift (100%) rename Sources/PythonSwiftCore/{ => PythonObject}/PythonObject+Sequence.swift (100%) rename Sources/PythonSwiftCore/{ => PythonObject}/PythonObject+Subscript.swift (100%) rename Sources/PythonSwiftCore/{ => PythonObject}/PythonObject.swift (100%) diff --git a/Package.swift b/Package.swift index a57d40e..377eed6 100644 --- a/Package.swift +++ b/Package.swift @@ -24,6 +24,7 @@ let package = Package( //.package(path: "../PythonLib") //.package(url: "https://github.com/PythonSwiftLink/PythonLib-iOS", branch: "main") ], + targets: [ .target( name: "PythonSwiftCore", @@ -38,6 +39,7 @@ let package = Package( ], swiftSettings: [ .define("BEEWARE", nil)] ), + // .target( // name: "PythonSwiftCore-iOS", // dependencies: ["PythonLib-iOS"], diff --git a/Sources/PyEncodable.swift b/Sources/PyEncodable.swift deleted file mode 100644 index 34fe840..0000000 --- a/Sources/PyEncodable.swift +++ /dev/null @@ -1,365 +0,0 @@ -import Foundation -#if BEEWARE -import PythonLib -#endif - - - func optionalPyPointer(_ v: T?) -> PyPointer { - if let this = v { - return this.pyPointer - } - return .PyNone - } - - - -//@inlinable -//public func UnPackPyPointer(with check: PythonType, from self: PyPointer?) throws -> T? { -// guard -// let self = self, -// PythonObject_TypeCheck(self, check), -// let pointee = unsafeBitCast(self, to: PySwiftObjectPointer.self)?.pointee -// else { throw PythonError.attribute } -// return Unmanaged.fromOpaque(pointee.swift_ptr).takeUnretainedValue() -//} - -//@inlinable -//public func UnPackPyPointer(with check: PythonType, from self: PyPointer?) -> T { -// guard -// let self = self, -// PythonObject_TypeCheck(self, check), -// let pointee = unsafeBitCast(self, to: PySwiftObjectPointer.self)?.pointee -// else { fatalError("self is not a PySwiftObject") } -// return Unmanaged.fromOpaque(pointee.swift_ptr).takeUnretainedValue() -//} - - - -extension PythonObject : PyConvertible { - - - public var pyPointer: PyPointer { - ptr ?? .PyNone - } - - public var pyObject: PythonObject { - self - } - -} - -extension PyPointer : PyConvertible { - - - public var pyObject: PythonObject { - .init(getter: self) - } - - public var pyPointer: PyPointer { - xINCREF - } - -} - -//extension UnsafeMutablePointer<_object> : PyConvertible { -// public var pyObject: PythonObject { -// .init(getter: self) -// } -// -// public var pyPointer: PyPointer { -// self -// } -// -//} - -extension Data? { - public var pyPointer: PyPointer { - self?.pyPointer ?? .PyNone - } -} - -extension Data: PyConvertible { - public var pyObject: PythonObject { - .init(getter: nil) - } - - public var pyPointer: PyPointer { - var this = self - return this.withUnsafeMutableBytes { buffer -> PyPointer in - let size = self.count //* uint8_size - var pybuf = Py_buffer() - PyBuffer_FillInfo(&pybuf, nil, buffer.baseAddress, size , 0, PyBUF_WRITE) - let mem = PyMemoryView_FromBuffer(&pybuf) - let bytes = PyBytes_FromObject(mem) - Py_DecRef(mem) - return bytes ?? .PyNone - } - } - -} - -extension Bool : PyConvertible { - - - public var pyPointer: PyPointer { - if self { - return .True - } - return .False - } - - public var pyObject: PythonObject { - if self { - return .init(getter: .True) - } - return .init(getter: .False) - } - -} - -//extension String? { -// public var pyPointer: PyPointer { -// if let this = self { -// return this.withCString(PyUnicode_FromString) ?? .PyNone -// } -// return .PyNone -// } -//} - -extension String : PyConvertible { - - - public var pyPointer: PyPointer { - withCString(PyUnicode_FromString) ?? .PyNone - } - - public var pyObject: PythonObject { - .init(getter: withCString(PyUnicode_FromString) ) - } - -} - - -//extension URL? { -// public var pyPointer: PyPointer { -// if let this = self { -// return this.pyPointer -// } -// return .PyNone -// } -//} - -extension URL : PyConvertible { - public var pyObject: PythonObject { - .init(getter: path.withCString(PyUnicode_FromString)) - } - - public var pyPointer: PyPointer { - path.withCString(PyUnicode_FromString) ?? .PyNone - } - -} - -extension Int : PyConvertible { - - public var pyPointer: PyPointer { - PyLong_FromLong(self) - } - - public var pyObject: PythonObject { - .init(getter: PyLong_FromLong(self)) - } - -} - -extension UInt : PyConvertible { - - - public var pyPointer: PyPointer { - PyLong_FromUnsignedLong(self) - } - - public var pyObject: PythonObject { - .init(getter: PyLong_FromUnsignedLong(self)) - } - -} -extension Int64: PyConvertible { - - - public var pyPointer: PyPointer { - PyLong_FromLongLong(self) - } - - public var pyObject: PythonObject { - .init(getter: PyLong_FromLongLong(self)) - } - -} - -extension UInt64: PyConvertible { - - - public var pyPointer: PyPointer { - PyLong_FromUnsignedLongLong(self) - } - - public var pyObject: PythonObject { - .init(getter: PyLong_FromUnsignedLongLong(self)) - } - -} - -extension Int32: PyConvertible { - - - public var pyPointer: PyPointer { - PyLong_FromLong(Int(self)) - } - - public var pyObject: PythonObject { - .init(getter: PyLong_FromLong(Int(self))) - } - -} - -extension UInt32: PyConvertible { - - public var pyPointer: PyPointer { - PyLong_FromLong(Int(self)) - } - - public var pyObject: PythonObject { - .init(getter: PyLong_FromLong(Int(self))) - } - -} - -extension Int16: PyConvertible { - - - public var pyPointer: PyPointer { - PyLong_FromLong(Int(self)) - } - - public var pyObject: PythonObject { - .init(getter: PyLong_FromLong(Int(self))) - } - -} - -extension UInt16: PyConvertible { - - - public var pyPointer: PyPointer { - PyLong_FromUnsignedLong(UInt(self)) - } - - public var pyObject: PythonObject { - .init(getter: PyLong_FromUnsignedLong(UInt(self))) - } - -} - -extension Int8: PyConvertible { - - - public var pyPointer: PyPointer { - PyLong_FromLong(Int(self)) - } - - public var pyObject: PythonObject { - .init(getter: PyLong_FromLong(Int(self))) - } - -} - -extension UInt8: PyConvertible { - - - public var pyPointer: PyPointer { - PyLong_FromUnsignedLong(UInt(self)) - } - - public var pyObject: PythonObject { - .init(getter: PyLong_FromUnsignedLong(UInt(self))) - } - -} - -extension Double: PyConvertible { - - - public var pyPointer: PyPointer { - PyFloat_FromDouble(self) - } - - public var pyObject: PythonObject { - .init(getter: PyFloat_FromDouble(self)) - } - -} - -extension Float32: PyConvertible { - - public var pyPointer: PyPointer { - PyFloat_FromDouble(Double(self)) - } - - public var pyObject: PythonObject { - .init(getter: PyFloat_FromDouble(Double(self))) - } - -} - - -extension Array: PyConvertible where Element : PyConvertible { - - public var pyPointer: PyPointer { - let list = PyList_New(count) - var _count = 0 - for element in self { - // `PyList_SetItem` steals the reference of the object stored. dont DecRef - PyList_SetItem(list, _count, element.pyPointer) - _count += 1 - } - return list ?? .PyNone - } - - public var pyObject: PythonObject { - return .init(getter: pyPointer) - } - - @inlinable public var pythonTuple: PythonPointer { - let tuple = PyTuple_New(self.count) - for (i, element) in self.enumerated() { - PyTuple_SetItem(tuple, i, element.pyPointer) - } - return tuple ?? .PyNone - } - -} - - -extension Dictionary: PyConvertible where Key == StringLiteralType, Value == PyConvertible { - - - public var pyObject: PythonObject { - .init(getter: pyPointer) - } - - public var pyPointer: PyPointer { - let dict = PyDict_New() - for (key,value) in self { - let v = value.pyPointer - _ = key.withCString{PyDict_SetItemString(dict, $0, v)} - //Py_DecRef(v) - } - return dict ?? .PyNone - } - - -} - - - diff --git a/Sources/PythonSwiftCore/PyPointer+PyCall.swift b/Sources/PythonSwiftCore/PyPointer+PyCall.swift index ffe3027..60462d8 100644 --- a/Sources/PythonSwiftCore/PyPointer+PyCall.swift +++ b/Sources/PythonSwiftCore/PyPointer+PyCall.swift @@ -6,7 +6,7 @@ import PythonLib import Foundation extension PyPointer { - func callAsFunction() throws -> R where + public func callAsFunction() throws -> R where R: PyDecodable { guard let result = PyObject_CallNoArgs(self) else { PyErr_Print() @@ -17,7 +17,7 @@ extension PyPointer { return rtn } - func callAsFunction() throws -> PyPointer { + public func callAsFunction() throws -> PyPointer { guard let result = PyObject_CallNoArgs(self) else { PyErr_Print() throw PythonError.call @@ -25,7 +25,7 @@ extension PyPointer { return result } - func callAsFunction() throws { + public func callAsFunction() throws { guard let result = PyObject_CallNoArgs(self) else { PyErr_Print() throw PythonError.call @@ -33,7 +33,7 @@ extension PyPointer { Py_DecRef(result) } - func callAsFunction(_ a: A) throws -> R where + public func callAsFunction(_ a: A) throws -> R where A: PyEncodable, R: PyDecodable { let arg = a.pyPointer @@ -48,7 +48,7 @@ extension PyPointer { return rtn } - func callAsFunction(_ a: A) throws -> PyPointer where + public func callAsFunction(_ a: A) throws -> PyPointer where A: PyEncodable { let arg = a.pyPointer guard let result = PyObject_CallOneArg(self, arg) else { @@ -60,7 +60,7 @@ extension PyPointer { return result } - func callAsFunction(_ a: A) throws where + public func callAsFunction(_ a: A) throws where A: PyEncodable { let arg = a.pyPointer guard let result = PyObject_CallOneArg(self, arg) else { @@ -72,7 +72,7 @@ extension PyPointer { Py_DecRef(result) } - func callAsFunction(_ a: A, _ b: B) throws -> R where + public func callAsFunction(_ a: A, _ b: B) throws -> R where A: PyEncodable, B: PyEncodable, R: PyDecodable { @@ -94,7 +94,7 @@ extension PyPointer { return rtn } - func callAsFunction(_ a: A, _ b: B) throws -> PyPointer where + public func callAsFunction(_ a: A, _ b: B) throws -> PyPointer where A: PyEncodable, B: PyEncodable { let args = VectorCallArgs.allocate(capacity: 2) @@ -113,7 +113,7 @@ extension PyPointer { return result } - func callAsFunction(_ a: A, _ b: B) throws where + public func callAsFunction(_ a: A, _ b: B) throws where A: PyEncodable, B: PyEncodable { let args = VectorCallArgs.allocate(capacity: 2) @@ -132,7 +132,7 @@ extension PyPointer { Py_DecRef(result) } - func callAsFunction(_ a: A, _ b: B, _ c: C) throws -> R where + public func callAsFunction(_ a: A, _ b: B, _ c: C) throws -> R where A: PyEncodable, B: PyEncodable, C: PyEncodable, @@ -158,7 +158,7 @@ extension PyPointer { return rtn } - func callAsFunction(_ a: A, _ b: B, _ c: C) throws -> PyPointer where + public func callAsFunction(_ a: A, _ b: B, _ c: C) throws -> PyPointer where A: PyEncodable, B: PyEncodable, C: PyEncodable { @@ -181,7 +181,7 @@ extension PyPointer { return result } - func callAsFunction(_ a: A, _ b: B, _ c: C) throws where + public func callAsFunction(_ a: A, _ b: B, _ c: C) throws where A: PyEncodable, B: PyEncodable, C: PyEncodable { @@ -204,7 +204,7 @@ extension PyPointer { Py_DecRef(result) } - func callAsFunction(_ a: A, _ b: B, _ c: C, _ d: D) throws -> R where + public func callAsFunction(_ a: A, _ b: B, _ c: C, _ d: D) throws -> R where A: PyEncodable, B: PyEncodable, C: PyEncodable, @@ -234,7 +234,7 @@ extension PyPointer { return rtn } - func callAsFunction(_ a: A, _ b: B, _ c: C, _ d: D) throws -> PyPointer where + public func callAsFunction(_ a: A, _ b: B, _ c: C, _ d: D) throws -> PyPointer where A: PyEncodable, B: PyEncodable, C: PyEncodable, @@ -261,7 +261,7 @@ extension PyPointer { return result } - func callAsFunction(_ a: A, _ b: B, _ c: C, _ d: D) throws where + public func callAsFunction(_ a: A, _ b: B, _ c: C, _ d: D) throws where A: PyEncodable, B: PyEncodable, C: PyEncodable, @@ -288,7 +288,7 @@ extension PyPointer { Py_DecRef(result) } - func callAsFunction(_ a: A, _ b: B, _ c: C, _ d: D, _ e: E) throws -> R where + public func callAsFunction(_ a: A, _ b: B, _ c: C, _ d: D, _ e: E) throws -> R where A: PyEncodable, B: PyEncodable, C: PyEncodable, @@ -322,7 +322,7 @@ extension PyPointer { return rtn } - func callAsFunction(_ a: A, _ b: B, _ c: C, _ d: D, _ e: E) throws -> PyPointer where + public func callAsFunction(_ a: A, _ b: B, _ c: C, _ d: D, _ e: E) throws -> PyPointer where A: PyEncodable, B: PyEncodable, C: PyEncodable, @@ -353,7 +353,7 @@ extension PyPointer { return result } - func callAsFunction(_ a: A, _ b: B, _ c: C, _ d: D, _ e: E) throws where + public func callAsFunction(_ a: A, _ b: B, _ c: C, _ d: D, _ e: E) throws where A: PyEncodable, B: PyEncodable, C: PyEncodable, @@ -384,7 +384,7 @@ extension PyPointer { Py_DecRef(result) } - func callAsFunction(_ a: A, _ b: B, _ c: C, _ d: D, _ e: E, _ f: F) throws -> R where + public func callAsFunction(_ a: A, _ b: B, _ c: C, _ d: D, _ e: E, _ f: F) throws -> R where A: PyEncodable, B: PyEncodable, C: PyEncodable, @@ -422,7 +422,7 @@ extension PyPointer { return rtn } - func callAsFunction(_ a: A, _ b: B, _ c: C, _ d: D, _ e: E, _ f: F) throws -> PyPointer where + public func callAsFunction(_ a: A, _ b: B, _ c: C, _ d: D, _ e: E, _ f: F) throws -> PyPointer where A: PyEncodable, B: PyEncodable, C: PyEncodable, @@ -457,7 +457,7 @@ extension PyPointer { return result } - func callAsFunction(_ a: A, _ b: B, _ c: C, _ d: D, _ e: E, _ f: F) throws where + public func callAsFunction(_ a: A, _ b: B, _ c: C, _ d: D, _ e: E, _ f: F) throws where A: PyEncodable, B: PyEncodable, C: PyEncodable, @@ -492,7 +492,7 @@ extension PyPointer { Py_DecRef(result) } - func callAsFunction(_ a: A, _ b: B, _ c: C, _ d: D, _ e: E, _ f: F, _ g: G) throws -> R where + public func callAsFunction(_ a: A, _ b: B, _ c: C, _ d: D, _ e: E, _ f: F, _ g: G) throws -> R where A: PyEncodable, B: PyEncodable, C: PyEncodable, @@ -534,7 +534,7 @@ extension PyPointer { return rtn } - func callAsFunction(_ a: A, _ b: B, _ c: C, _ d: D, _ e: E, _ f: F, _ g: G) throws -> PyPointer where + public func callAsFunction(_ a: A, _ b: B, _ c: C, _ d: D, _ e: E, _ f: F, _ g: G) throws -> PyPointer where A: PyEncodable, B: PyEncodable, C: PyEncodable, @@ -573,7 +573,7 @@ extension PyPointer { return result } - func callAsFunction(_ a: A, _ b: B, _ c: C, _ d: D, _ e: E, _ f: F, _ g: G) throws where + public func callAsFunction(_ a: A, _ b: B, _ c: C, _ d: D, _ e: E, _ f: F, _ g: G) throws where A: PyEncodable, B: PyEncodable, C: PyEncodable, @@ -612,7 +612,7 @@ extension PyPointer { Py_DecRef(result) } - func callAsFunction(_ a: A, _ b: B, _ c: C, _ d: D, _ e: E, _ f: F, _ g: G, _ h: H) throws -> R where + public func callAsFunction(_ a: A, _ b: B, _ c: C, _ d: D, _ e: E, _ f: F, _ g: G, _ h: H) throws -> R where A: PyEncodable, B: PyEncodable, C: PyEncodable, @@ -658,7 +658,7 @@ extension PyPointer { return rtn } - func callAsFunction(_ a: A, _ b: B, _ c: C, _ d: D, _ e: E, _ f: F, _ g: G, _ h: H) throws -> PyPointer where + public func callAsFunction(_ a: A, _ b: B, _ c: C, _ d: D, _ e: E, _ f: F, _ g: G, _ h: H) throws -> PyPointer where A: PyEncodable, B: PyEncodable, C: PyEncodable, @@ -701,7 +701,7 @@ extension PyPointer { return result } - func callAsFunction(_ a: A, _ b: B, _ c: C, _ d: D, _ e: E, _ f: F, _ g: G, _ h: H) throws where + public func callAsFunction(_ a: A, _ b: B, _ c: C, _ d: D, _ e: E, _ f: F, _ g: G, _ h: H) throws where A: PyEncodable, B: PyEncodable, C: PyEncodable, @@ -744,7 +744,7 @@ extension PyPointer { Py_DecRef(result) } - func callAsFunction(_ a: A, _ b: B, _ c: C, _ d: D, _ e: E, _ f: F, _ g: G, _ h: H, _ i: I) throws -> R where + public func callAsFunction(_ a: A, _ b: B, _ c: C, _ d: D, _ e: E, _ f: F, _ g: G, _ h: H, _ i: I) throws -> R where A: PyEncodable, B: PyEncodable, C: PyEncodable, @@ -794,7 +794,7 @@ extension PyPointer { return rtn } - func callAsFunction(_ a: A, _ b: B, _ c: C, _ d: D, _ e: E, _ f: F, _ g: G, _ h: H, _ i: I) throws -> PyPointer where + public func callAsFunction(_ a: A, _ b: B, _ c: C, _ d: D, _ e: E, _ f: F, _ g: G, _ h: H, _ i: I) throws -> PyPointer where A: PyEncodable, B: PyEncodable, C: PyEncodable, @@ -841,7 +841,7 @@ extension PyPointer { return result } - func callAsFunction(_ a: A, _ b: B, _ c: C, _ d: D, _ e: E, _ f: F, _ g: G, _ h: H, _ i: I) throws where + public func callAsFunction(_ a: A, _ b: B, _ c: C, _ d: D, _ e: E, _ f: F, _ g: G, _ h: H, _ i: I) throws where A: PyEncodable, B: PyEncodable, C: PyEncodable, @@ -890,7 +890,7 @@ extension PyPointer { } -func PythonCall < R>(call: PyPointer) throws -> R where +public func PythonCall < R>(call: PyPointer) throws -> R where R: PyDecodable { guard let result = PyObject_CallNoArgs(call) else { PyErr_Print() @@ -901,7 +901,7 @@ func PythonCall < R>(call: PyPointer) throws -> R where return rtn } -func PythonCall(call: PyPointer) throws -> PyPointer { +public func PythonCall(call: PyPointer) throws -> PyPointer { guard let result = PyObject_CallNoArgs(call) else { PyErr_Print() throw PythonError.call @@ -909,7 +909,7 @@ func PythonCall(call: PyPointer) throws -> PyPointer { return result } -func PythonCall(call: PyPointer) throws { +public func PythonCall(call: PyPointer) throws { guard let result = PyObject_CallNoArgs(call) else { PyErr_Print() throw PythonError.call @@ -917,7 +917,7 @@ func PythonCall(call: PyPointer) throws { Py_DecRef(result) } -func PythonCall(call: PyPointer, _ a: A) throws -> R where +public func PythonCall(call: PyPointer, _ a: A) throws -> R where A: PyEncodable, R: PyDecodable { let arg = a.pyPointer @@ -932,7 +932,7 @@ func PythonCall(call: PyPointer, _ a: A) throws -> R where return rtn } -func PythonCall(call: PyPointer, _ a: A) throws -> PyPointer where +public func PythonCall(call: PyPointer, _ a: A) throws -> PyPointer where A: PyEncodable { let arg = a.pyPointer guard let result = PyObject_CallOneArg(call, arg) else { @@ -944,7 +944,7 @@ func PythonCall(call: PyPointer, _ a: A) throws -> PyPointer where return result } -func PythonCall(call: PyPointer, _ a: A) throws where +public func PythonCall(call: PyPointer, _ a: A) throws where A: PyEncodable { let arg = a.pyPointer guard let result = PyObject_CallOneArg(call, arg) else { @@ -956,7 +956,7 @@ func PythonCall(call: PyPointer, _ a: A) throws where Py_DecRef(result) } -func PythonCall(call: PyPointer, _ a: A, _ b: B) throws -> R where +public func PythonCall(call: PyPointer, _ a: A, _ b: B) throws -> R where A: PyEncodable, B: PyEncodable, R: PyDecodable { @@ -978,7 +978,7 @@ func PythonCall(call: PyPointer, _ a: A, _ b: B) throws -> R where return rtn } -func PythonCall(call: PyPointer, _ a: A, _ b: B) throws -> PyPointer where +public func PythonCall(call: PyPointer, _ a: A, _ b: B) throws -> PyPointer where A: PyEncodable, B: PyEncodable { let args = VectorCallArgs.allocate(capacity: 2) @@ -997,7 +997,7 @@ func PythonCall(call: PyPointer, _ a: A, _ b: B) throws -> PyPointer where return result } -func PythonCall(call: PyPointer, _ a: A, _ b: B) throws where +public func PythonCall(call: PyPointer, _ a: A, _ b: B) throws where A: PyEncodable, B: PyEncodable { let args = VectorCallArgs.allocate(capacity: 2) @@ -1016,7 +1016,7 @@ func PythonCall(call: PyPointer, _ a: A, _ b: B) throws where Py_DecRef(result) } -func PythonCall(call: PyPointer, _ a: A, _ b: B, _ c: C) throws -> R where +public func PythonCall(call: PyPointer, _ a: A, _ b: B, _ c: C) throws -> R where A: PyEncodable, B: PyEncodable, C: PyEncodable, @@ -1042,7 +1042,7 @@ func PythonCall(call: PyPointer, _ a: A, _ b: B, _ c: C) throws -> R return rtn } -func PythonCall(call: PyPointer, _ a: A, _ b: B, _ c: C) throws -> PyPointer where +public func PythonCall(call: PyPointer, _ a: A, _ b: B, _ c: C) throws -> PyPointer where A: PyEncodable, B: PyEncodable, C: PyEncodable { @@ -1065,7 +1065,7 @@ func PythonCall(call: PyPointer, _ a: A, _ b: B, _ c: C) throws -> PyPo return result } -func PythonCall(call: PyPointer, _ a: A, _ b: B, _ c: C) throws where +public func PythonCall(call: PyPointer, _ a: A, _ b: B, _ c: C) throws where A: PyEncodable, B: PyEncodable, C: PyEncodable { @@ -1088,7 +1088,7 @@ func PythonCall(call: PyPointer, _ a: A, _ b: B, _ c: C) throws where Py_DecRef(result) } -func PythonCall(call: PyPointer, _ a: A, _ b: B, _ c: C, _ d: D) throws -> R where +public func PythonCall(call: PyPointer, _ a: A, _ b: B, _ c: C, _ d: D) throws -> R where A: PyEncodable, B: PyEncodable, C: PyEncodable, @@ -1118,7 +1118,7 @@ func PythonCall(call: PyPointer, _ a: A, _ b: B, _ c: C, _ d: D) return rtn } -func PythonCall(call: PyPointer, _ a: A, _ b: B, _ c: C, _ d: D) throws -> PyPointer where +public func PythonCall(call: PyPointer, _ a: A, _ b: B, _ c: C, _ d: D) throws -> PyPointer where A: PyEncodable, B: PyEncodable, C: PyEncodable, @@ -1145,7 +1145,7 @@ func PythonCall(call: PyPointer, _ a: A, _ b: B, _ c: C, _ d: D) thr return result } -func PythonCall(call: PyPointer, _ a: A, _ b: B, _ c: C, _ d: D) throws where +public func PythonCall(call: PyPointer, _ a: A, _ b: B, _ c: C, _ d: D) throws where A: PyEncodable, B: PyEncodable, C: PyEncodable, @@ -1172,7 +1172,7 @@ func PythonCall(call: PyPointer, _ a: A, _ b: B, _ c: C, _ d: D) thr Py_DecRef(result) } -func PythonCall(call: PyPointer, _ a: A, _ b: B, _ c: C, _ d: D, _ e: E) throws -> R where +public func PythonCall(call: PyPointer, _ a: A, _ b: B, _ c: C, _ d: D, _ e: E) throws -> R where A: PyEncodable, B: PyEncodable, C: PyEncodable, @@ -1206,7 +1206,7 @@ func PythonCall(call: PyPointer, _ a: A, _ b: B, _ c: C, _ d: return rtn } -func PythonCall(call: PyPointer, _ a: A, _ b: B, _ c: C, _ d: D, _ e: E) throws -> PyPointer where +public func PythonCall(call: PyPointer, _ a: A, _ b: B, _ c: C, _ d: D, _ e: E) throws -> PyPointer where A: PyEncodable, B: PyEncodable, C: PyEncodable, @@ -1237,7 +1237,7 @@ func PythonCall(call: PyPointer, _ a: A, _ b: B, _ c: C, _ d: D, return result } -func PythonCall(call: PyPointer, _ a: A, _ b: B, _ c: C, _ d: D, _ e: E) throws where +public func PythonCall(call: PyPointer, _ a: A, _ b: B, _ c: C, _ d: D, _ e: E) throws where A: PyEncodable, B: PyEncodable, C: PyEncodable, @@ -1268,7 +1268,7 @@ func PythonCall(call: PyPointer, _ a: A, _ b: B, _ c: C, _ d: D, Py_DecRef(result) } -func PythonCall(call: PyPointer, _ a: A, _ b: B, _ c: C, _ d: D, _ e: E, _ f: F) throws -> R where +public func PythonCall(call: PyPointer, _ a: A, _ b: B, _ c: C, _ d: D, _ e: E, _ f: F) throws -> R where A: PyEncodable, B: PyEncodable, C: PyEncodable, @@ -1306,7 +1306,7 @@ func PythonCall(call: PyPointer, _ a: A, _ b: B, _ c: C, _ return rtn } -func PythonCall(call: PyPointer, _ a: A, _ b: B, _ c: C, _ d: D, _ e: E, _ f: F) throws -> PyPointer where +public func PythonCall(call: PyPointer, _ a: A, _ b: B, _ c: C, _ d: D, _ e: E, _ f: F) throws -> PyPointer where A: PyEncodable, B: PyEncodable, C: PyEncodable, @@ -1341,7 +1341,7 @@ func PythonCall(call: PyPointer, _ a: A, _ b: B, _ c: C, _ d: return result } -func PythonCall(call: PyPointer, _ a: A, _ b: B, _ c: C, _ d: D, _ e: E, _ f: F) throws where +public func PythonCall(call: PyPointer, _ a: A, _ b: B, _ c: C, _ d: D, _ e: E, _ f: F) throws where A: PyEncodable, B: PyEncodable, C: PyEncodable, @@ -1376,7 +1376,7 @@ func PythonCall(call: PyPointer, _ a: A, _ b: B, _ c: C, _ d: Py_DecRef(result) } -func PythonCall(call: PyPointer, _ a: A, _ b: B, _ c: C, _ d: D, _ e: E, _ f: F, _ g: G) throws -> R where +public func PythonCall(call: PyPointer, _ a: A, _ b: B, _ c: C, _ d: D, _ e: E, _ f: F, _ g: G) throws -> R where A: PyEncodable, B: PyEncodable, C: PyEncodable, @@ -1418,7 +1418,7 @@ func PythonCall(call: PyPointer, _ a: A, _ b: B, _ c: C, return rtn } -func PythonCall(call: PyPointer, _ a: A, _ b: B, _ c: C, _ d: D, _ e: E, _ f: F, _ g: G) throws -> PyPointer where +public func PythonCall(call: PyPointer, _ a: A, _ b: B, _ c: C, _ d: D, _ e: E, _ f: F, _ g: G) throws -> PyPointer where A: PyEncodable, B: PyEncodable, C: PyEncodable, @@ -1457,7 +1457,7 @@ func PythonCall(call: PyPointer, _ a: A, _ b: B, _ c: C, _ return result } -func PythonCall(call: PyPointer, _ a: A, _ b: B, _ c: C, _ d: D, _ e: E, _ f: F, _ g: G) throws where +public func PythonCall(call: PyPointer, _ a: A, _ b: B, _ c: C, _ d: D, _ e: E, _ f: F, _ g: G) throws where A: PyEncodable, B: PyEncodable, C: PyEncodable, @@ -1496,7 +1496,7 @@ func PythonCall(call: PyPointer, _ a: A, _ b: B, _ c: C, _ Py_DecRef(result) } -func PythonCall(call: PyPointer, _ a: A, _ b: B, _ c: C, _ d: D, _ e: E, _ f: F, _ g: G, _ h: H) throws -> R where +public func PythonCall(call: PyPointer, _ a: A, _ b: B, _ c: C, _ d: D, _ e: E, _ f: F, _ g: G, _ h: H) throws -> R where A: PyEncodable, B: PyEncodable, C: PyEncodable, @@ -1542,7 +1542,7 @@ func PythonCall(call: PyPointer, _ a: A, _ b: B, _ c: return rtn } -func PythonCall(call: PyPointer, _ a: A, _ b: B, _ c: C, _ d: D, _ e: E, _ f: F, _ g: G, _ h: H) throws -> PyPointer where +public func PythonCall(call: PyPointer, _ a: A, _ b: B, _ c: C, _ d: D, _ e: E, _ f: F, _ g: G, _ h: H) throws -> PyPointer where A: PyEncodable, B: PyEncodable, C: PyEncodable, @@ -1585,7 +1585,7 @@ func PythonCall(call: PyPointer, _ a: A, _ b: B, _ c: C, return result } -func PythonCall(call: PyPointer, _ a: A, _ b: B, _ c: C, _ d: D, _ e: E, _ f: F, _ g: G, _ h: H) throws where +public func PythonCall(call: PyPointer, _ a: A, _ b: B, _ c: C, _ d: D, _ e: E, _ f: F, _ g: G, _ h: H) throws where A: PyEncodable, B: PyEncodable, C: PyEncodable, @@ -1628,7 +1628,7 @@ func PythonCall(call: PyPointer, _ a: A, _ b: B, _ c: C, Py_DecRef(result) } -func PythonCall(call: PyPointer, _ a: A, _ b: B, _ c: C, _ d: D, _ e: E, _ f: F, _ g: G, _ h: H, _ i: I) throws -> R where +public func PythonCall(call: PyPointer, _ a: A, _ b: B, _ c: C, _ d: D, _ e: E, _ f: F, _ g: G, _ h: H, _ i: I) throws -> R where A: PyEncodable, B: PyEncodable, C: PyEncodable, @@ -1678,7 +1678,7 @@ func PythonCall(call: PyPointer, _ a: A, _ b: B, _ return rtn } -func PythonCall(call: PyPointer, _ a: A, _ b: B, _ c: C, _ d: D, _ e: E, _ f: F, _ g: G, _ h: H, _ i: I) throws -> PyPointer where +public func PythonCall(call: PyPointer, _ a: A, _ b: B, _ c: C, _ d: D, _ e: E, _ f: F, _ g: G, _ h: H, _ i: I) throws -> PyPointer where A: PyEncodable, B: PyEncodable, C: PyEncodable, @@ -1725,7 +1725,7 @@ func PythonCall(call: PyPointer, _ a: A, _ b: B, _ c: return result } -func PythonCall(call: PyPointer, _ a: A, _ b: B, _ c: C, _ d: D, _ e: E, _ f: F, _ g: G, _ h: H, _ i: I) throws where +public func PythonCall(call: PyPointer, _ a: A, _ b: B, _ c: C, _ d: D, _ e: E, _ f: F, _ g: G, _ h: H, _ i: I) throws where A: PyEncodable, B: PyEncodable, C: PyEncodable, @@ -1770,4 +1770,936 @@ func PythonCall(call: PyPointer, _ a: A, _ b: B, _ c: Py_DecRef(args[8]) args.deallocate() Py_DecRef(result) +} + +public func PythonCallWithGil < R>(call: PyPointer) throws -> R where + R: PyDecodable { + let gil = PyGILState_Ensure() + guard let result = PyObject_CallNoArgs(call) else { + PyErr_Print() + throw PythonError.call + } + let rtn = try R(object: result) + Py_DecRef(result) + PyGILState_Release(gil) + return rtn +} + +public func PythonCallWithGil(call: PyPointer) throws -> PyPointer { + _ = PyGILState_Ensure() + guard let result = PyObject_CallNoArgs(call) else { + PyErr_Print() + throw PythonError.call + } + return result +} + +public func PythonCallWithGil(call: PyPointer) throws { + let gil = PyGILState_Ensure() + guard let result = PyObject_CallNoArgs(call) else { + PyErr_Print() + throw PythonError.call + } + PyGILState_Release(gil) + Py_DecRef(result) +} + +public func PythonCallWithGil(call: PyPointer, _ a: A) throws -> R where + A: PyEncodable, + R: PyDecodable { + let gil = PyGILState_Ensure() + let arg = a.pyPointer + guard let result = PyObject_CallOneArg(call, arg) else { + PyErr_Print() + Py_DecRef(arg) + throw PythonError.call + } + Py_DecRef(arg) + let rtn = try R(object: result) + Py_DecRef(result) + PyGILState_Release(gil) + return rtn +} + +public func PythonCallWithGil(call: PyPointer, _ a: A) throws -> PyPointer where + A: PyEncodable { + _ = PyGILState_Ensure() + let arg = a.pyPointer + guard let result = PyObject_CallOneArg(call, arg) else { + PyErr_Print() + Py_DecRef(arg) + throw PythonError.call + } + Py_DecRef(arg) + return result +} + +public func PythonCallWithGil(call: PyPointer, _ a: A) throws where + A: PyEncodable { + let gil = PyGILState_Ensure() + let arg = a.pyPointer + guard let result = PyObject_CallOneArg(call, arg) else { + PyErr_Print() + Py_DecRef(arg) + throw PythonError.call + } + Py_DecRef(arg) + PyGILState_Release(gil) + Py_DecRef(result) +} + +public func PythonCallWithGil(call: PyPointer, _ a: A, _ b: B) throws -> R where + A: PyEncodable, + B: PyEncodable, + R: PyDecodable { + let gil = PyGILState_Ensure() + let args = VectorCallArgs.allocate(capacity: 2) + args[0] = a.pyPointer + args[1] = b.pyPointer + guard let result = PyObject_Vectorcall(call, args, 2, nil) else { + PyErr_Print() + Py_DecRef(args[0]) + Py_DecRef(args[1]) + args.deallocate() + throw PythonError.call + } + Py_DecRef(args[0]) + Py_DecRef(args[1]) + args.deallocate() + let rtn = try R(object: result) + Py_DecRef(result) + PyGILState_Release(gil) + return rtn +} + +public func PythonCallWithGil(call: PyPointer, _ a: A, _ b: B) throws -> PyPointer where + A: PyEncodable, + B: PyEncodable { + _ = PyGILState_Ensure() + let args = VectorCallArgs.allocate(capacity: 2) + args[0] = a.pyPointer + args[1] = b.pyPointer + guard let result = PyObject_Vectorcall(call, args, 2, nil) else { + PyErr_Print() + Py_DecRef(args[0]) + Py_DecRef(args[1]) + args.deallocate() + throw PythonError.call + } + Py_DecRef(args[0]) + Py_DecRef(args[1]) + args.deallocate() + return result +} + +public func PythonCallWithGil(call: PyPointer, _ a: A, _ b: B) throws where + A: PyEncodable, + B: PyEncodable { + let gil = PyGILState_Ensure() + let args = VectorCallArgs.allocate(capacity: 2) + args[0] = a.pyPointer + args[1] = b.pyPointer + guard let result = PyObject_Vectorcall(call, args, 2, nil) else { + PyErr_Print() + Py_DecRef(args[0]) + Py_DecRef(args[1]) + args.deallocate() + throw PythonError.call + } + Py_DecRef(args[0]) + Py_DecRef(args[1]) + args.deallocate() + PyGILState_Release(gil) + Py_DecRef(result) +} + +public func PythonCallWithGil(call: PyPointer, _ a: A, _ b: B, _ c: C) throws -> R where + A: PyEncodable, + B: PyEncodable, + C: PyEncodable, + R: PyDecodable { + let gil = PyGILState_Ensure() + let args = VectorCallArgs.allocate(capacity: 3) + args[0] = a.pyPointer + args[1] = b.pyPointer + args[2] = c.pyPointer + guard let result = PyObject_Vectorcall(call, args, 3, nil) else { + PyErr_Print() + Py_DecRef(args[0]) + Py_DecRef(args[1]) + Py_DecRef(args[2]) + args.deallocate() + throw PythonError.call + } + Py_DecRef(args[0]) + Py_DecRef(args[1]) + Py_DecRef(args[2]) + args.deallocate() + let rtn = try R(object: result) + Py_DecRef(result) + PyGILState_Release(gil) + return rtn +} + +public func PythonCallWithGil(call: PyPointer, _ a: A, _ b: B, _ c: C) throws -> PyPointer where + A: PyEncodable, + B: PyEncodable, + C: PyEncodable { + _ = PyGILState_Ensure() + let args = VectorCallArgs.allocate(capacity: 3) + args[0] = a.pyPointer + args[1] = b.pyPointer + args[2] = c.pyPointer + guard let result = PyObject_Vectorcall(call, args, 3, nil) else { + PyErr_Print() + Py_DecRef(args[0]) + Py_DecRef(args[1]) + Py_DecRef(args[2]) + args.deallocate() + throw PythonError.call + } + Py_DecRef(args[0]) + Py_DecRef(args[1]) + Py_DecRef(args[2]) + args.deallocate() + return result +} + +public func PythonCallWithGil(call: PyPointer, _ a: A, _ b: B, _ c: C) throws where + A: PyEncodable, + B: PyEncodable, + C: PyEncodable { + let gil = PyGILState_Ensure() + let args = VectorCallArgs.allocate(capacity: 3) + args[0] = a.pyPointer + args[1] = b.pyPointer + args[2] = c.pyPointer + guard let result = PyObject_Vectorcall(call, args, 3, nil) else { + PyErr_Print() + Py_DecRef(args[0]) + Py_DecRef(args[1]) + Py_DecRef(args[2]) + args.deallocate() + throw PythonError.call + } + Py_DecRef(args[0]) + Py_DecRef(args[1]) + Py_DecRef(args[2]) + args.deallocate() + PyGILState_Release(gil) + Py_DecRef(result) +} + +public func PythonCallWithGil(call: PyPointer, _ a: A, _ b: B, _ c: C, _ d: D) throws -> R where + A: PyEncodable, + B: PyEncodable, + C: PyEncodable, + D: PyEncodable, + R: PyDecodable { + let gil = PyGILState_Ensure() + let args = VectorCallArgs.allocate(capacity: 4) + args[0] = a.pyPointer + args[1] = b.pyPointer + args[2] = c.pyPointer + args[3] = d.pyPointer + guard let result = PyObject_Vectorcall(call, args, 4, nil) else { + PyErr_Print() + Py_DecRef(args[0]) + Py_DecRef(args[1]) + Py_DecRef(args[2]) + Py_DecRef(args[3]) + args.deallocate() + throw PythonError.call + } + Py_DecRef(args[0]) + Py_DecRef(args[1]) + Py_DecRef(args[2]) + Py_DecRef(args[3]) + args.deallocate() + let rtn = try R(object: result) + Py_DecRef(result) + PyGILState_Release(gil) + return rtn +} + +public func PythonCallWithGil(call: PyPointer, _ a: A, _ b: B, _ c: C, _ d: D) throws -> PyPointer where + A: PyEncodable, + B: PyEncodable, + C: PyEncodable, + D: PyEncodable { + _ = PyGILState_Ensure() + let args = VectorCallArgs.allocate(capacity: 4) + args[0] = a.pyPointer + args[1] = b.pyPointer + args[2] = c.pyPointer + args[3] = d.pyPointer + guard let result = PyObject_Vectorcall(call, args, 4, nil) else { + PyErr_Print() + Py_DecRef(args[0]) + Py_DecRef(args[1]) + Py_DecRef(args[2]) + Py_DecRef(args[3]) + args.deallocate() + throw PythonError.call + } + Py_DecRef(args[0]) + Py_DecRef(args[1]) + Py_DecRef(args[2]) + Py_DecRef(args[3]) + args.deallocate() + return result +} + +public func PythonCallWithGil(call: PyPointer, _ a: A, _ b: B, _ c: C, _ d: D) throws where + A: PyEncodable, + B: PyEncodable, + C: PyEncodable, + D: PyEncodable { + let gil = PyGILState_Ensure() + let args = VectorCallArgs.allocate(capacity: 4) + args[0] = a.pyPointer + args[1] = b.pyPointer + args[2] = c.pyPointer + args[3] = d.pyPointer + guard let result = PyObject_Vectorcall(call, args, 4, nil) else { + PyErr_Print() + Py_DecRef(args[0]) + Py_DecRef(args[1]) + Py_DecRef(args[2]) + Py_DecRef(args[3]) + args.deallocate() + throw PythonError.call + } + Py_DecRef(args[0]) + Py_DecRef(args[1]) + Py_DecRef(args[2]) + Py_DecRef(args[3]) + args.deallocate() + PyGILState_Release(gil) + Py_DecRef(result) +} + +public func PythonCallWithGil(call: PyPointer, _ a: A, _ b: B, _ c: C, _ d: D, _ e: E) throws -> R where + A: PyEncodable, + B: PyEncodable, + C: PyEncodable, + D: PyEncodable, + E: PyEncodable, + R: PyDecodable { + let gil = PyGILState_Ensure() + let args = VectorCallArgs.allocate(capacity: 5) + args[0] = a.pyPointer + args[1] = b.pyPointer + args[2] = c.pyPointer + args[3] = d.pyPointer + args[4] = e.pyPointer + guard let result = PyObject_Vectorcall(call, args, 5, nil) else { + PyErr_Print() + Py_DecRef(args[0]) + Py_DecRef(args[1]) + Py_DecRef(args[2]) + Py_DecRef(args[3]) + Py_DecRef(args[4]) + args.deallocate() + throw PythonError.call + } + Py_DecRef(args[0]) + Py_DecRef(args[1]) + Py_DecRef(args[2]) + Py_DecRef(args[3]) + Py_DecRef(args[4]) + args.deallocate() + let rtn = try R(object: result) + Py_DecRef(result) + PyGILState_Release(gil) + return rtn +} + +public func PythonCallWithGil(call: PyPointer, _ a: A, _ b: B, _ c: C, _ d: D, _ e: E) throws -> PyPointer where + A: PyEncodable, + B: PyEncodable, + C: PyEncodable, + D: PyEncodable, + E: PyEncodable { + _ = PyGILState_Ensure() + let args = VectorCallArgs.allocate(capacity: 5) + args[0] = a.pyPointer + args[1] = b.pyPointer + args[2] = c.pyPointer + args[3] = d.pyPointer + args[4] = e.pyPointer + guard let result = PyObject_Vectorcall(call, args, 5, nil) else { + PyErr_Print() + Py_DecRef(args[0]) + Py_DecRef(args[1]) + Py_DecRef(args[2]) + Py_DecRef(args[3]) + Py_DecRef(args[4]) + args.deallocate() + throw PythonError.call + } + Py_DecRef(args[0]) + Py_DecRef(args[1]) + Py_DecRef(args[2]) + Py_DecRef(args[3]) + Py_DecRef(args[4]) + args.deallocate() + return result +} + +public func PythonCallWithGil(call: PyPointer, _ a: A, _ b: B, _ c: C, _ d: D, _ e: E) throws where + A: PyEncodable, + B: PyEncodable, + C: PyEncodable, + D: PyEncodable, + E: PyEncodable { + let gil = PyGILState_Ensure() + let args = VectorCallArgs.allocate(capacity: 5) + args[0] = a.pyPointer + args[1] = b.pyPointer + args[2] = c.pyPointer + args[3] = d.pyPointer + args[4] = e.pyPointer + guard let result = PyObject_Vectorcall(call, args, 5, nil) else { + PyErr_Print() + Py_DecRef(args[0]) + Py_DecRef(args[1]) + Py_DecRef(args[2]) + Py_DecRef(args[3]) + Py_DecRef(args[4]) + args.deallocate() + throw PythonError.call + } + Py_DecRef(args[0]) + Py_DecRef(args[1]) + Py_DecRef(args[2]) + Py_DecRef(args[3]) + Py_DecRef(args[4]) + args.deallocate() + PyGILState_Release(gil) + Py_DecRef(result) +} + +public func PythonCallWithGil(call: PyPointer, _ a: A, _ b: B, _ c: C, _ d: D, _ e: E, _ f: F) throws -> R where + A: PyEncodable, + B: PyEncodable, + C: PyEncodable, + D: PyEncodable, + E: PyEncodable, + F: PyEncodable, + R: PyDecodable { + let gil = PyGILState_Ensure() + let args = VectorCallArgs.allocate(capacity: 6) + args[0] = a.pyPointer + args[1] = b.pyPointer + args[2] = c.pyPointer + args[3] = d.pyPointer + args[4] = e.pyPointer + args[5] = f.pyPointer + guard let result = PyObject_Vectorcall(call, args, 6, nil) else { + PyErr_Print() + Py_DecRef(args[0]) + Py_DecRef(args[1]) + Py_DecRef(args[2]) + Py_DecRef(args[3]) + Py_DecRef(args[4]) + Py_DecRef(args[5]) + args.deallocate() + throw PythonError.call + } + Py_DecRef(args[0]) + Py_DecRef(args[1]) + Py_DecRef(args[2]) + Py_DecRef(args[3]) + Py_DecRef(args[4]) + Py_DecRef(args[5]) + args.deallocate() + let rtn = try R(object: result) + Py_DecRef(result) + PyGILState_Release(gil) + return rtn +} + +public func PythonCallWithGil(call: PyPointer, _ a: A, _ b: B, _ c: C, _ d: D, _ e: E, _ f: F) throws -> PyPointer where + A: PyEncodable, + B: PyEncodable, + C: PyEncodable, + D: PyEncodable, + E: PyEncodable, + F: PyEncodable { + _ = PyGILState_Ensure() + let args = VectorCallArgs.allocate(capacity: 6) + args[0] = a.pyPointer + args[1] = b.pyPointer + args[2] = c.pyPointer + args[3] = d.pyPointer + args[4] = e.pyPointer + args[5] = f.pyPointer + guard let result = PyObject_Vectorcall(call, args, 6, nil) else { + PyErr_Print() + Py_DecRef(args[0]) + Py_DecRef(args[1]) + Py_DecRef(args[2]) + Py_DecRef(args[3]) + Py_DecRef(args[4]) + Py_DecRef(args[5]) + args.deallocate() + throw PythonError.call + } + Py_DecRef(args[0]) + Py_DecRef(args[1]) + Py_DecRef(args[2]) + Py_DecRef(args[3]) + Py_DecRef(args[4]) + Py_DecRef(args[5]) + args.deallocate() + return result +} + +public func PythonCallWithGil(call: PyPointer, _ a: A, _ b: B, _ c: C, _ d: D, _ e: E, _ f: F) throws where + A: PyEncodable, + B: PyEncodable, + C: PyEncodable, + D: PyEncodable, + E: PyEncodable, + F: PyEncodable { + let gil = PyGILState_Ensure() + let args = VectorCallArgs.allocate(capacity: 6) + args[0] = a.pyPointer + args[1] = b.pyPointer + args[2] = c.pyPointer + args[3] = d.pyPointer + args[4] = e.pyPointer + args[5] = f.pyPointer + guard let result = PyObject_Vectorcall(call, args, 6, nil) else { + PyErr_Print() + Py_DecRef(args[0]) + Py_DecRef(args[1]) + Py_DecRef(args[2]) + Py_DecRef(args[3]) + Py_DecRef(args[4]) + Py_DecRef(args[5]) + args.deallocate() + throw PythonError.call + } + Py_DecRef(args[0]) + Py_DecRef(args[1]) + Py_DecRef(args[2]) + Py_DecRef(args[3]) + Py_DecRef(args[4]) + Py_DecRef(args[5]) + args.deallocate() + PyGILState_Release(gil) + Py_DecRef(result) +} + +public func PythonCallWithGil(call: PyPointer, _ a: A, _ b: B, _ c: C, _ d: D, _ e: E, _ f: F, _ g: G) throws -> R where + A: PyEncodable, + B: PyEncodable, + C: PyEncodable, + D: PyEncodable, + E: PyEncodable, + F: PyEncodable, + G: PyEncodable, + R: PyDecodable { + let gil = PyGILState_Ensure() + let args = VectorCallArgs.allocate(capacity: 7) + args[0] = a.pyPointer + args[1] = b.pyPointer + args[2] = c.pyPointer + args[3] = d.pyPointer + args[4] = e.pyPointer + args[5] = f.pyPointer + args[6] = g.pyPointer + guard let result = PyObject_Vectorcall(call, args, 7, nil) else { + PyErr_Print() + Py_DecRef(args[0]) + Py_DecRef(args[1]) + Py_DecRef(args[2]) + Py_DecRef(args[3]) + Py_DecRef(args[4]) + Py_DecRef(args[5]) + Py_DecRef(args[6]) + args.deallocate() + throw PythonError.call + } + Py_DecRef(args[0]) + Py_DecRef(args[1]) + Py_DecRef(args[2]) + Py_DecRef(args[3]) + Py_DecRef(args[4]) + Py_DecRef(args[5]) + Py_DecRef(args[6]) + args.deallocate() + let rtn = try R(object: result) + Py_DecRef(result) + PyGILState_Release(gil) + return rtn +} + +public func PythonCallWithGil(call: PyPointer, _ a: A, _ b: B, _ c: C, _ d: D, _ e: E, _ f: F, _ g: G) throws -> PyPointer where + A: PyEncodable, + B: PyEncodable, + C: PyEncodable, + D: PyEncodable, + E: PyEncodable, + F: PyEncodable, + G: PyEncodable { + _ = PyGILState_Ensure() + let args = VectorCallArgs.allocate(capacity: 7) + args[0] = a.pyPointer + args[1] = b.pyPointer + args[2] = c.pyPointer + args[3] = d.pyPointer + args[4] = e.pyPointer + args[5] = f.pyPointer + args[6] = g.pyPointer + guard let result = PyObject_Vectorcall(call, args, 7, nil) else { + PyErr_Print() + Py_DecRef(args[0]) + Py_DecRef(args[1]) + Py_DecRef(args[2]) + Py_DecRef(args[3]) + Py_DecRef(args[4]) + Py_DecRef(args[5]) + Py_DecRef(args[6]) + args.deallocate() + throw PythonError.call + } + Py_DecRef(args[0]) + Py_DecRef(args[1]) + Py_DecRef(args[2]) + Py_DecRef(args[3]) + Py_DecRef(args[4]) + Py_DecRef(args[5]) + Py_DecRef(args[6]) + args.deallocate() + return result +} + +public func PythonCallWithGil(call: PyPointer, _ a: A, _ b: B, _ c: C, _ d: D, _ e: E, _ f: F, _ g: G) throws where + A: PyEncodable, + B: PyEncodable, + C: PyEncodable, + D: PyEncodable, + E: PyEncodable, + F: PyEncodable, + G: PyEncodable { + let gil = PyGILState_Ensure() + let args = VectorCallArgs.allocate(capacity: 7) + args[0] = a.pyPointer + args[1] = b.pyPointer + args[2] = c.pyPointer + args[3] = d.pyPointer + args[4] = e.pyPointer + args[5] = f.pyPointer + args[6] = g.pyPointer + guard let result = PyObject_Vectorcall(call, args, 7, nil) else { + PyErr_Print() + Py_DecRef(args[0]) + Py_DecRef(args[1]) + Py_DecRef(args[2]) + Py_DecRef(args[3]) + Py_DecRef(args[4]) + Py_DecRef(args[5]) + Py_DecRef(args[6]) + args.deallocate() + throw PythonError.call + } + Py_DecRef(args[0]) + Py_DecRef(args[1]) + Py_DecRef(args[2]) + Py_DecRef(args[3]) + Py_DecRef(args[4]) + Py_DecRef(args[5]) + Py_DecRef(args[6]) + args.deallocate() + PyGILState_Release(gil) + Py_DecRef(result) +} + +public func PythonCallWithGil(call: PyPointer, _ a: A, _ b: B, _ c: C, _ d: D, _ e: E, _ f: F, _ g: G, _ h: H) throws -> R where + A: PyEncodable, + B: PyEncodable, + C: PyEncodable, + D: PyEncodable, + E: PyEncodable, + F: PyEncodable, + G: PyEncodable, + H: PyEncodable, + R: PyDecodable { + let gil = PyGILState_Ensure() + let args = VectorCallArgs.allocate(capacity: 8) + args[0] = a.pyPointer + args[1] = b.pyPointer + args[2] = c.pyPointer + args[3] = d.pyPointer + args[4] = e.pyPointer + args[5] = f.pyPointer + args[6] = g.pyPointer + args[7] = h.pyPointer + guard let result = PyObject_Vectorcall(call, args, 8, nil) else { + PyErr_Print() + Py_DecRef(args[0]) + Py_DecRef(args[1]) + Py_DecRef(args[2]) + Py_DecRef(args[3]) + Py_DecRef(args[4]) + Py_DecRef(args[5]) + Py_DecRef(args[6]) + Py_DecRef(args[7]) + args.deallocate() + throw PythonError.call + } + Py_DecRef(args[0]) + Py_DecRef(args[1]) + Py_DecRef(args[2]) + Py_DecRef(args[3]) + Py_DecRef(args[4]) + Py_DecRef(args[5]) + Py_DecRef(args[6]) + Py_DecRef(args[7]) + args.deallocate() + let rtn = try R(object: result) + Py_DecRef(result) + PyGILState_Release(gil) + return rtn +} + +public func PythonCallWithGil(call: PyPointer, _ a: A, _ b: B, _ c: C, _ d: D, _ e: E, _ f: F, _ g: G, _ h: H) throws -> PyPointer where + A: PyEncodable, + B: PyEncodable, + C: PyEncodable, + D: PyEncodable, + E: PyEncodable, + F: PyEncodable, + G: PyEncodable, + H: PyEncodable { + _ = PyGILState_Ensure() + let args = VectorCallArgs.allocate(capacity: 8) + args[0] = a.pyPointer + args[1] = b.pyPointer + args[2] = c.pyPointer + args[3] = d.pyPointer + args[4] = e.pyPointer + args[5] = f.pyPointer + args[6] = g.pyPointer + args[7] = h.pyPointer + guard let result = PyObject_Vectorcall(call, args, 8, nil) else { + PyErr_Print() + Py_DecRef(args[0]) + Py_DecRef(args[1]) + Py_DecRef(args[2]) + Py_DecRef(args[3]) + Py_DecRef(args[4]) + Py_DecRef(args[5]) + Py_DecRef(args[6]) + Py_DecRef(args[7]) + args.deallocate() + throw PythonError.call + } + Py_DecRef(args[0]) + Py_DecRef(args[1]) + Py_DecRef(args[2]) + Py_DecRef(args[3]) + Py_DecRef(args[4]) + Py_DecRef(args[5]) + Py_DecRef(args[6]) + Py_DecRef(args[7]) + args.deallocate() + return result +} + +public func PythonCallWithGil(call: PyPointer, _ a: A, _ b: B, _ c: C, _ d: D, _ e: E, _ f: F, _ g: G, _ h: H) throws where + A: PyEncodable, + B: PyEncodable, + C: PyEncodable, + D: PyEncodable, + E: PyEncodable, + F: PyEncodable, + G: PyEncodable, + H: PyEncodable { + let gil = PyGILState_Ensure() + let args = VectorCallArgs.allocate(capacity: 8) + args[0] = a.pyPointer + args[1] = b.pyPointer + args[2] = c.pyPointer + args[3] = d.pyPointer + args[4] = e.pyPointer + args[5] = f.pyPointer + args[6] = g.pyPointer + args[7] = h.pyPointer + guard let result = PyObject_Vectorcall(call, args, 8, nil) else { + PyErr_Print() + Py_DecRef(args[0]) + Py_DecRef(args[1]) + Py_DecRef(args[2]) + Py_DecRef(args[3]) + Py_DecRef(args[4]) + Py_DecRef(args[5]) + Py_DecRef(args[6]) + Py_DecRef(args[7]) + args.deallocate() + throw PythonError.call + } + Py_DecRef(args[0]) + Py_DecRef(args[1]) + Py_DecRef(args[2]) + Py_DecRef(args[3]) + Py_DecRef(args[4]) + Py_DecRef(args[5]) + Py_DecRef(args[6]) + Py_DecRef(args[7]) + args.deallocate() + PyGILState_Release(gil) + Py_DecRef(result) +} + +public func PythonCallWithGil(call: PyPointer, _ a: A, _ b: B, _ c: C, _ d: D, _ e: E, _ f: F, _ g: G, _ h: H, _ i: I) throws -> R where + A: PyEncodable, + B: PyEncodable, + C: PyEncodable, + D: PyEncodable, + E: PyEncodable, + F: PyEncodable, + G: PyEncodable, + H: PyEncodable, + I: PyEncodable, + R: PyDecodable { + let gil = PyGILState_Ensure() + let args = VectorCallArgs.allocate(capacity: 9) + args[0] = a.pyPointer + args[1] = b.pyPointer + args[2] = c.pyPointer + args[3] = d.pyPointer + args[4] = e.pyPointer + args[5] = f.pyPointer + args[6] = g.pyPointer + args[7] = h.pyPointer + args[8] = i.pyPointer + guard let result = PyObject_Vectorcall(call, args, 9, nil) else { + PyErr_Print() + Py_DecRef(args[0]) + Py_DecRef(args[1]) + Py_DecRef(args[2]) + Py_DecRef(args[3]) + Py_DecRef(args[4]) + Py_DecRef(args[5]) + Py_DecRef(args[6]) + Py_DecRef(args[7]) + Py_DecRef(args[8]) + args.deallocate() + throw PythonError.call + } + Py_DecRef(args[0]) + Py_DecRef(args[1]) + Py_DecRef(args[2]) + Py_DecRef(args[3]) + Py_DecRef(args[4]) + Py_DecRef(args[5]) + Py_DecRef(args[6]) + Py_DecRef(args[7]) + Py_DecRef(args[8]) + args.deallocate() + let rtn = try R(object: result) + Py_DecRef(result) + PyGILState_Release(gil) + return rtn +} + +public func PythonCallWithGil(call: PyPointer, _ a: A, _ b: B, _ c: C, _ d: D, _ e: E, _ f: F, _ g: G, _ h: H, _ i: I) throws -> PyPointer where + A: PyEncodable, + B: PyEncodable, + C: PyEncodable, + D: PyEncodable, + E: PyEncodable, + F: PyEncodable, + G: PyEncodable, + H: PyEncodable, + I: PyEncodable { + _ = PyGILState_Ensure() + let args = VectorCallArgs.allocate(capacity: 9) + args[0] = a.pyPointer + args[1] = b.pyPointer + args[2] = c.pyPointer + args[3] = d.pyPointer + args[4] = e.pyPointer + args[5] = f.pyPointer + args[6] = g.pyPointer + args[7] = h.pyPointer + args[8] = i.pyPointer + guard let result = PyObject_Vectorcall(call, args, 9, nil) else { + PyErr_Print() + Py_DecRef(args[0]) + Py_DecRef(args[1]) + Py_DecRef(args[2]) + Py_DecRef(args[3]) + Py_DecRef(args[4]) + Py_DecRef(args[5]) + Py_DecRef(args[6]) + Py_DecRef(args[7]) + Py_DecRef(args[8]) + args.deallocate() + throw PythonError.call + } + Py_DecRef(args[0]) + Py_DecRef(args[1]) + Py_DecRef(args[2]) + Py_DecRef(args[3]) + Py_DecRef(args[4]) + Py_DecRef(args[5]) + Py_DecRef(args[6]) + Py_DecRef(args[7]) + Py_DecRef(args[8]) + args.deallocate() + return result +} + +public func PythonCallWithGil(call: PyPointer, _ a: A, _ b: B, _ c: C, _ d: D, _ e: E, _ f: F, _ g: G, _ h: H, _ i: I) throws where + A: PyEncodable, + B: PyEncodable, + C: PyEncodable, + D: PyEncodable, + E: PyEncodable, + F: PyEncodable, + G: PyEncodable, + H: PyEncodable, + I: PyEncodable { + let gil = PyGILState_Ensure() + let args = VectorCallArgs.allocate(capacity: 9) + args[0] = a.pyPointer + args[1] = b.pyPointer + args[2] = c.pyPointer + args[3] = d.pyPointer + args[4] = e.pyPointer + args[5] = f.pyPointer + args[6] = g.pyPointer + args[7] = h.pyPointer + args[8] = i.pyPointer + guard let result = PyObject_Vectorcall(call, args, 9, nil) else { + PyErr_Print() + Py_DecRef(args[0]) + Py_DecRef(args[1]) + Py_DecRef(args[2]) + Py_DecRef(args[3]) + Py_DecRef(args[4]) + Py_DecRef(args[5]) + Py_DecRef(args[6]) + Py_DecRef(args[7]) + Py_DecRef(args[8]) + args.deallocate() + throw PythonError.call + } + Py_DecRef(args[0]) + Py_DecRef(args[1]) + Py_DecRef(args[2]) + Py_DecRef(args[3]) + Py_DecRef(args[4]) + Py_DecRef(args[5]) + Py_DecRef(args[6]) + Py_DecRef(args[7]) + Py_DecRef(args[8]) + args.deallocate() + PyGILState_Release(gil) + Py_DecRef(result) } \ No newline at end of file diff --git a/Sources/PythonSwiftCore/PythonObject+Attributes.swift b/Sources/PythonSwiftCore/PythonObject/PythonObject+Attributes.swift similarity index 100% rename from Sources/PythonSwiftCore/PythonObject+Attributes.swift rename to Sources/PythonSwiftCore/PythonObject/PythonObject+Attributes.swift diff --git a/Sources/PythonSwiftCore/PythonObject+Callable.swift b/Sources/PythonSwiftCore/PythonObject/PythonObject+Callable.swift similarity index 100% rename from Sources/PythonSwiftCore/PythonObject+Callable.swift rename to Sources/PythonSwiftCore/PythonObject/PythonObject+Callable.swift diff --git a/Sources/PythonSwiftCore/PythonObject+Sequence.swift b/Sources/PythonSwiftCore/PythonObject/PythonObject+Sequence.swift similarity index 100% rename from Sources/PythonSwiftCore/PythonObject+Sequence.swift rename to Sources/PythonSwiftCore/PythonObject/PythonObject+Sequence.swift diff --git a/Sources/PythonSwiftCore/PythonObject+Subscript.swift b/Sources/PythonSwiftCore/PythonObject/PythonObject+Subscript.swift similarity index 100% rename from Sources/PythonSwiftCore/PythonObject+Subscript.swift rename to Sources/PythonSwiftCore/PythonObject/PythonObject+Subscript.swift diff --git a/Sources/PythonSwiftCore/PythonObject.swift b/Sources/PythonSwiftCore/PythonObject/PythonObject.swift similarity index 100% rename from Sources/PythonSwiftCore/PythonObject.swift rename to Sources/PythonSwiftCore/PythonObject/PythonObject.swift diff --git a/Sources/PythonSwiftCore/PythonPointer+exec.swift b/Sources/PythonSwiftCore/PythonPointer+exec.swift index a47e660..9aab145 100644 --- a/Sources/PythonSwiftCore/PythonPointer+exec.swift +++ b/Sources/PythonSwiftCore/PythonPointer+exec.swift @@ -21,9 +21,39 @@ public enum PyEvalFlag: Int32 { } #if BEEWARE + +public func Py_ValidateCode(code: String, filename: String, flag: PyEvalFlag) -> Bool { + print("Py_CompileString:\n", code) + PyErr_Clear() + return code.withCString { str in + //let gil = PyGILState_Ensure() + return true + + if let result = Py_CompileString(str, filename, flag.rawValue) { + print(result) + result.decref() + return true + } + + return false + //PyGILState_Release(gil) + + + //return result + } +} + public func Py_CompileString(code: String, filename: String, flag: PyEvalFlag) -> PyPointer? { - code.withCString { str in - Py_CompileString(str, filename, flag.rawValue) + print("Py_CompileString:\n\n", code) + PyErr_Clear() + return code.withCString { str in + //let gil = PyGILState_Ensure() + return .PyNone + + let result = Py_CompileString(str, filename, flag.rawValue) + //PyGILState_Release(gil) + print(result) + return result } } #endif From 6d8da4a63d553845a335fb11203c32d4d688d499 Mon Sep 17 00:00:00 2001 From: PythonSwiftLink <107263226+PythonSwiftLink@users.noreply.github.com> Date: Sat, 9 Sep 2023 16:36:16 +0200 Subject: [PATCH 2/7] Create swift.yml --- .github/workflows/swift.yml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 .github/workflows/swift.yml diff --git a/.github/workflows/swift.yml b/.github/workflows/swift.yml new file mode 100644 index 0000000..ba05bf6 --- /dev/null +++ b/.github/workflows/swift.yml @@ -0,0 +1,22 @@ +# This workflow will build a Swift project +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-swift + +name: Swift + +on: + push: + branches: [ "testing" ] + pull_request: + branches: [ "testing" ] + +jobs: + build: + + runs-on: macos-latest + + steps: + - uses: actions/checkout@v3 + - name: Build + run: swift build -v + - name: Run tests + run: swift test -v From da507a1bf74f6a52729105751abbd3789613e94a Mon Sep 17 00:00:00 2001 From: PythonSwiftLink <107263226+PythonSwiftLink@users.noreply.github.com> Date: Sat, 9 Sep 2023 16:39:58 +0200 Subject: [PATCH 3/7] Update swift.yml --- .github/workflows/swift.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/swift.yml b/.github/workflows/swift.yml index ba05bf6..cda61a2 100644 --- a/.github/workflows/swift.yml +++ b/.github/workflows/swift.yml @@ -5,9 +5,9 @@ name: Swift on: push: - branches: [ "testing" ] + branches: [ "main" ] pull_request: - branches: [ "testing" ] + branches: [ "main" ] jobs: build: From eb356a2c6e3fc378fb366ac8cfe6abcb9471f699 Mon Sep 17 00:00:00 2001 From: PythonSwiftLink <107263226+PythonSwiftLink@users.noreply.github.com> Date: Sat, 9 Sep 2023 18:28:10 +0200 Subject: [PATCH 4/7] Update swift.yml --- .github/workflows/swift.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/swift.yml b/.github/workflows/swift.yml index cda61a2..ba05bf6 100644 --- a/.github/workflows/swift.yml +++ b/.github/workflows/swift.yml @@ -5,9 +5,9 @@ name: Swift on: push: - branches: [ "main" ] + branches: [ "testing" ] pull_request: - branches: [ "main" ] + branches: [ "testing" ] jobs: build: From b5b1eec26b021792b860771bc1c4e8e821f5c070 Mon Sep 17 00:00:00 2001 From: PythonSwiftLink <107263226+PythonSwiftLink@users.noreply.github.com> Date: Sat, 9 Sep 2023 18:31:38 +0200 Subject: [PATCH 5/7] Delete .github/workflows directory --- .github/workflows/swift.yml | 22 ---------------------- 1 file changed, 22 deletions(-) delete mode 100644 .github/workflows/swift.yml diff --git a/.github/workflows/swift.yml b/.github/workflows/swift.yml deleted file mode 100644 index ba05bf6..0000000 --- a/.github/workflows/swift.yml +++ /dev/null @@ -1,22 +0,0 @@ -# This workflow will build a Swift project -# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-swift - -name: Swift - -on: - push: - branches: [ "testing" ] - pull_request: - branches: [ "testing" ] - -jobs: - build: - - runs-on: macos-latest - - steps: - - uses: actions/checkout@v3 - - name: Build - run: swift build -v - - name: Run tests - run: swift test -v From e60bd3de9b782ab64c59fae40cbc7843cbc44d35 Mon Sep 17 00:00:00 2001 From: PythonSwiftLink <107263226+PythonSwiftLink@users.noreply.github.com> Date: Sat, 9 Sep 2023 18:34:24 +0200 Subject: [PATCH 6/7] Create swift.yml --- .github/workflows/swift.yml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 .github/workflows/swift.yml diff --git a/.github/workflows/swift.yml b/.github/workflows/swift.yml new file mode 100644 index 0000000..921a41a --- /dev/null +++ b/.github/workflows/swift.yml @@ -0,0 +1,22 @@ +# This workflow will build a Swift project +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-swift + +name: Swift + +on: + push: + branches: [ "main" , "testing"] + pull_request: + branches: [ "main" , "testing" ] + +jobs: + build: + + runs-on: macos-latest + + steps: + - uses: actions/checkout@v3 + - name: Build + run: swift build -v + - name: Run tests + run: swift test -v From 43765d7a0dcaf289097e3bf98698ab6be4e4e023 Mon Sep 17 00:00:00 2001 From: PythonSwiftLink <107263226+PythonSwiftLink@users.noreply.github.com> Date: Sat, 9 Sep 2023 18:39:06 +0200 Subject: [PATCH 7/7] Update PyPointer+PyCall.swift --- .../PythonSwiftCore/PyPointer+PyCall.swift | 2704 ----------------- 1 file changed, 2704 deletions(-) diff --git a/Sources/PythonSwiftCore/PyPointer+PyCall.swift b/Sources/PythonSwiftCore/PyPointer+PyCall.swift index 60462d8..8b13789 100644 --- a/Sources/PythonSwiftCore/PyPointer+PyCall.swift +++ b/Sources/PythonSwiftCore/PyPointer+PyCall.swift @@ -1,2705 +1 @@ -#if BEEWARE -import PythonLib -#endif - -import Foundation -extension PyPointer { - - public func callAsFunction() throws -> R where - R: PyDecodable { - guard let result = PyObject_CallNoArgs(self) else { - PyErr_Print() - throw PythonError.call - } - let rtn = try R(object: result) - Py_DecRef(result) - return rtn - } - - public func callAsFunction() throws -> PyPointer { - guard let result = PyObject_CallNoArgs(self) else { - PyErr_Print() - throw PythonError.call - } - return result - } - - public func callAsFunction() throws { - guard let result = PyObject_CallNoArgs(self) else { - PyErr_Print() - throw PythonError.call - } - Py_DecRef(result) - } - - public func callAsFunction(_ a: A) throws -> R where - A: PyEncodable, - R: PyDecodable { - let arg = a.pyPointer - guard let result = PyObject_CallOneArg(self, arg) else { - PyErr_Print() - Py_DecRef(arg) - throw PythonError.call - } - Py_DecRef(arg) - let rtn = try R(object: result) - Py_DecRef(result) - return rtn - } - - public func callAsFunction(_ a: A) throws -> PyPointer where - A: PyEncodable { - let arg = a.pyPointer - guard let result = PyObject_CallOneArg(self, arg) else { - PyErr_Print() - Py_DecRef(arg) - throw PythonError.call - } - Py_DecRef(arg) - return result - } - - public func callAsFunction(_ a: A) throws where - A: PyEncodable { - let arg = a.pyPointer - guard let result = PyObject_CallOneArg(self, arg) else { - PyErr_Print() - Py_DecRef(arg) - throw PythonError.call - } - Py_DecRef(arg) - Py_DecRef(result) - } - - public func callAsFunction(_ a: A, _ b: B) throws -> R where - A: PyEncodable, - B: PyEncodable, - R: PyDecodable { - let args = VectorCallArgs.allocate(capacity: 2) - args[0] = a.pyPointer - args[1] = b.pyPointer - guard let result = PyObject_Vectorcall(self, args, 2, nil) else { - PyErr_Print() - Py_DecRef(args[0]) - Py_DecRef(args[1]) - args.deallocate() - throw PythonError.call - } - Py_DecRef(args[0]) - Py_DecRef(args[1]) - args.deallocate() - let rtn = try R(object: result) - Py_DecRef(result) - return rtn - } - - public func callAsFunction(_ a: A, _ b: B) throws -> PyPointer where - A: PyEncodable, - B: PyEncodable { - let args = VectorCallArgs.allocate(capacity: 2) - args[0] = a.pyPointer - args[1] = b.pyPointer - guard let result = PyObject_Vectorcall(self, args, 2, nil) else { - PyErr_Print() - Py_DecRef(args[0]) - Py_DecRef(args[1]) - args.deallocate() - throw PythonError.call - } - Py_DecRef(args[0]) - Py_DecRef(args[1]) - args.deallocate() - return result - } - - public func callAsFunction(_ a: A, _ b: B) throws where - A: PyEncodable, - B: PyEncodable { - let args = VectorCallArgs.allocate(capacity: 2) - args[0] = a.pyPointer - args[1] = b.pyPointer - guard let result = PyObject_Vectorcall(self, args, 2, nil) else { - PyErr_Print() - Py_DecRef(args[0]) - Py_DecRef(args[1]) - args.deallocate() - throw PythonError.call - } - Py_DecRef(args[0]) - Py_DecRef(args[1]) - args.deallocate() - Py_DecRef(result) - } - - public func callAsFunction(_ a: A, _ b: B, _ c: C) throws -> R where - A: PyEncodable, - B: PyEncodable, - C: PyEncodable, - R: PyDecodable { - let args = VectorCallArgs.allocate(capacity: 3) - args[0] = a.pyPointer - args[1] = b.pyPointer - args[2] = c.pyPointer - guard let result = PyObject_Vectorcall(self, args, 3, nil) else { - PyErr_Print() - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - args.deallocate() - throw PythonError.call - } - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - args.deallocate() - let rtn = try R(object: result) - Py_DecRef(result) - return rtn - } - - public func callAsFunction(_ a: A, _ b: B, _ c: C) throws -> PyPointer where - A: PyEncodable, - B: PyEncodable, - C: PyEncodable { - let args = VectorCallArgs.allocate(capacity: 3) - args[0] = a.pyPointer - args[1] = b.pyPointer - args[2] = c.pyPointer - guard let result = PyObject_Vectorcall(self, args, 3, nil) else { - PyErr_Print() - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - args.deallocate() - throw PythonError.call - } - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - args.deallocate() - return result - } - - public func callAsFunction(_ a: A, _ b: B, _ c: C) throws where - A: PyEncodable, - B: PyEncodable, - C: PyEncodable { - let args = VectorCallArgs.allocate(capacity: 3) - args[0] = a.pyPointer - args[1] = b.pyPointer - args[2] = c.pyPointer - guard let result = PyObject_Vectorcall(self, args, 3, nil) else { - PyErr_Print() - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - args.deallocate() - throw PythonError.call - } - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - args.deallocate() - Py_DecRef(result) - } - - public func callAsFunction(_ a: A, _ b: B, _ c: C, _ d: D) throws -> R where - A: PyEncodable, - B: PyEncodable, - C: PyEncodable, - D: PyEncodable, - R: PyDecodable { - let args = VectorCallArgs.allocate(capacity: 4) - args[0] = a.pyPointer - args[1] = b.pyPointer - args[2] = c.pyPointer - args[3] = d.pyPointer - guard let result = PyObject_Vectorcall(self, args, 4, nil) else { - PyErr_Print() - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - Py_DecRef(args[3]) - args.deallocate() - throw PythonError.call - } - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - Py_DecRef(args[3]) - args.deallocate() - let rtn = try R(object: result) - Py_DecRef(result) - return rtn - } - - public func callAsFunction(_ a: A, _ b: B, _ c: C, _ d: D) throws -> PyPointer where - A: PyEncodable, - B: PyEncodable, - C: PyEncodable, - D: PyEncodable { - let args = VectorCallArgs.allocate(capacity: 4) - args[0] = a.pyPointer - args[1] = b.pyPointer - args[2] = c.pyPointer - args[3] = d.pyPointer - guard let result = PyObject_Vectorcall(self, args, 4, nil) else { - PyErr_Print() - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - Py_DecRef(args[3]) - args.deallocate() - throw PythonError.call - } - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - Py_DecRef(args[3]) - args.deallocate() - return result - } - - public func callAsFunction(_ a: A, _ b: B, _ c: C, _ d: D) throws where - A: PyEncodable, - B: PyEncodable, - C: PyEncodable, - D: PyEncodable { - let args = VectorCallArgs.allocate(capacity: 4) - args[0] = a.pyPointer - args[1] = b.pyPointer - args[2] = c.pyPointer - args[3] = d.pyPointer - guard let result = PyObject_Vectorcall(self, args, 4, nil) else { - PyErr_Print() - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - Py_DecRef(args[3]) - args.deallocate() - throw PythonError.call - } - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - Py_DecRef(args[3]) - args.deallocate() - Py_DecRef(result) - } - - public func callAsFunction(_ a: A, _ b: B, _ c: C, _ d: D, _ e: E) throws -> R where - A: PyEncodable, - B: PyEncodable, - C: PyEncodable, - D: PyEncodable, - E: PyEncodable, - R: PyDecodable { - let args = VectorCallArgs.allocate(capacity: 5) - args[0] = a.pyPointer - args[1] = b.pyPointer - args[2] = c.pyPointer - args[3] = d.pyPointer - args[4] = e.pyPointer - guard let result = PyObject_Vectorcall(self, args, 5, nil) else { - PyErr_Print() - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - Py_DecRef(args[3]) - Py_DecRef(args[4]) - args.deallocate() - throw PythonError.call - } - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - Py_DecRef(args[3]) - Py_DecRef(args[4]) - args.deallocate() - let rtn = try R(object: result) - Py_DecRef(result) - return rtn - } - - public func callAsFunction(_ a: A, _ b: B, _ c: C, _ d: D, _ e: E) throws -> PyPointer where - A: PyEncodable, - B: PyEncodable, - C: PyEncodable, - D: PyEncodable, - E: PyEncodable { - let args = VectorCallArgs.allocate(capacity: 5) - args[0] = a.pyPointer - args[1] = b.pyPointer - args[2] = c.pyPointer - args[3] = d.pyPointer - args[4] = e.pyPointer - guard let result = PyObject_Vectorcall(self, args, 5, nil) else { - PyErr_Print() - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - Py_DecRef(args[3]) - Py_DecRef(args[4]) - args.deallocate() - throw PythonError.call - } - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - Py_DecRef(args[3]) - Py_DecRef(args[4]) - args.deallocate() - return result - } - - public func callAsFunction(_ a: A, _ b: B, _ c: C, _ d: D, _ e: E) throws where - A: PyEncodable, - B: PyEncodable, - C: PyEncodable, - D: PyEncodable, - E: PyEncodable { - let args = VectorCallArgs.allocate(capacity: 5) - args[0] = a.pyPointer - args[1] = b.pyPointer - args[2] = c.pyPointer - args[3] = d.pyPointer - args[4] = e.pyPointer - guard let result = PyObject_Vectorcall(self, args, 5, nil) else { - PyErr_Print() - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - Py_DecRef(args[3]) - Py_DecRef(args[4]) - args.deallocate() - throw PythonError.call - } - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - Py_DecRef(args[3]) - Py_DecRef(args[4]) - args.deallocate() - Py_DecRef(result) - } - - public func callAsFunction(_ a: A, _ b: B, _ c: C, _ d: D, _ e: E, _ f: F) throws -> R where - A: PyEncodable, - B: PyEncodable, - C: PyEncodable, - D: PyEncodable, - E: PyEncodable, - F: PyEncodable, - R: PyDecodable { - let args = VectorCallArgs.allocate(capacity: 6) - args[0] = a.pyPointer - args[1] = b.pyPointer - args[2] = c.pyPointer - args[3] = d.pyPointer - args[4] = e.pyPointer - args[5] = f.pyPointer - guard let result = PyObject_Vectorcall(self, args, 6, nil) else { - PyErr_Print() - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - Py_DecRef(args[3]) - Py_DecRef(args[4]) - Py_DecRef(args[5]) - args.deallocate() - throw PythonError.call - } - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - Py_DecRef(args[3]) - Py_DecRef(args[4]) - Py_DecRef(args[5]) - args.deallocate() - let rtn = try R(object: result) - Py_DecRef(result) - return rtn - } - - public func callAsFunction(_ a: A, _ b: B, _ c: C, _ d: D, _ e: E, _ f: F) throws -> PyPointer where - A: PyEncodable, - B: PyEncodable, - C: PyEncodable, - D: PyEncodable, - E: PyEncodable, - F: PyEncodable { - let args = VectorCallArgs.allocate(capacity: 6) - args[0] = a.pyPointer - args[1] = b.pyPointer - args[2] = c.pyPointer - args[3] = d.pyPointer - args[4] = e.pyPointer - args[5] = f.pyPointer - guard let result = PyObject_Vectorcall(self, args, 6, nil) else { - PyErr_Print() - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - Py_DecRef(args[3]) - Py_DecRef(args[4]) - Py_DecRef(args[5]) - args.deallocate() - throw PythonError.call - } - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - Py_DecRef(args[3]) - Py_DecRef(args[4]) - Py_DecRef(args[5]) - args.deallocate() - return result - } - - public func callAsFunction(_ a: A, _ b: B, _ c: C, _ d: D, _ e: E, _ f: F) throws where - A: PyEncodable, - B: PyEncodable, - C: PyEncodable, - D: PyEncodable, - E: PyEncodable, - F: PyEncodable { - let args = VectorCallArgs.allocate(capacity: 6) - args[0] = a.pyPointer - args[1] = b.pyPointer - args[2] = c.pyPointer - args[3] = d.pyPointer - args[4] = e.pyPointer - args[5] = f.pyPointer - guard let result = PyObject_Vectorcall(self, args, 6, nil) else { - PyErr_Print() - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - Py_DecRef(args[3]) - Py_DecRef(args[4]) - Py_DecRef(args[5]) - args.deallocate() - throw PythonError.call - } - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - Py_DecRef(args[3]) - Py_DecRef(args[4]) - Py_DecRef(args[5]) - args.deallocate() - Py_DecRef(result) - } - - public func callAsFunction(_ a: A, _ b: B, _ c: C, _ d: D, _ e: E, _ f: F, _ g: G) throws -> R where - A: PyEncodable, - B: PyEncodable, - C: PyEncodable, - D: PyEncodable, - E: PyEncodable, - F: PyEncodable, - G: PyEncodable, - R: PyDecodable { - let args = VectorCallArgs.allocate(capacity: 7) - args[0] = a.pyPointer - args[1] = b.pyPointer - args[2] = c.pyPointer - args[3] = d.pyPointer - args[4] = e.pyPointer - args[5] = f.pyPointer - args[6] = g.pyPointer - guard let result = PyObject_Vectorcall(self, args, 7, nil) else { - PyErr_Print() - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - Py_DecRef(args[3]) - Py_DecRef(args[4]) - Py_DecRef(args[5]) - Py_DecRef(args[6]) - args.deallocate() - throw PythonError.call - } - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - Py_DecRef(args[3]) - Py_DecRef(args[4]) - Py_DecRef(args[5]) - Py_DecRef(args[6]) - args.deallocate() - let rtn = try R(object: result) - Py_DecRef(result) - return rtn - } - - public func callAsFunction(_ a: A, _ b: B, _ c: C, _ d: D, _ e: E, _ f: F, _ g: G) throws -> PyPointer where - A: PyEncodable, - B: PyEncodable, - C: PyEncodable, - D: PyEncodable, - E: PyEncodable, - F: PyEncodable, - G: PyEncodable { - let args = VectorCallArgs.allocate(capacity: 7) - args[0] = a.pyPointer - args[1] = b.pyPointer - args[2] = c.pyPointer - args[3] = d.pyPointer - args[4] = e.pyPointer - args[5] = f.pyPointer - args[6] = g.pyPointer - guard let result = PyObject_Vectorcall(self, args, 7, nil) else { - PyErr_Print() - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - Py_DecRef(args[3]) - Py_DecRef(args[4]) - Py_DecRef(args[5]) - Py_DecRef(args[6]) - args.deallocate() - throw PythonError.call - } - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - Py_DecRef(args[3]) - Py_DecRef(args[4]) - Py_DecRef(args[5]) - Py_DecRef(args[6]) - args.deallocate() - return result - } - - public func callAsFunction(_ a: A, _ b: B, _ c: C, _ d: D, _ e: E, _ f: F, _ g: G) throws where - A: PyEncodable, - B: PyEncodable, - C: PyEncodable, - D: PyEncodable, - E: PyEncodable, - F: PyEncodable, - G: PyEncodable { - let args = VectorCallArgs.allocate(capacity: 7) - args[0] = a.pyPointer - args[1] = b.pyPointer - args[2] = c.pyPointer - args[3] = d.pyPointer - args[4] = e.pyPointer - args[5] = f.pyPointer - args[6] = g.pyPointer - guard let result = PyObject_Vectorcall(self, args, 7, nil) else { - PyErr_Print() - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - Py_DecRef(args[3]) - Py_DecRef(args[4]) - Py_DecRef(args[5]) - Py_DecRef(args[6]) - args.deallocate() - throw PythonError.call - } - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - Py_DecRef(args[3]) - Py_DecRef(args[4]) - Py_DecRef(args[5]) - Py_DecRef(args[6]) - args.deallocate() - Py_DecRef(result) - } - - public func callAsFunction(_ a: A, _ b: B, _ c: C, _ d: D, _ e: E, _ f: F, _ g: G, _ h: H) throws -> R where - A: PyEncodable, - B: PyEncodable, - C: PyEncodable, - D: PyEncodable, - E: PyEncodable, - F: PyEncodable, - G: PyEncodable, - H: PyEncodable, - R: PyDecodable { - let args = VectorCallArgs.allocate(capacity: 8) - args[0] = a.pyPointer - args[1] = b.pyPointer - args[2] = c.pyPointer - args[3] = d.pyPointer - args[4] = e.pyPointer - args[5] = f.pyPointer - args[6] = g.pyPointer - args[7] = h.pyPointer - guard let result = PyObject_Vectorcall(self, args, 8, nil) else { - PyErr_Print() - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - Py_DecRef(args[3]) - Py_DecRef(args[4]) - Py_DecRef(args[5]) - Py_DecRef(args[6]) - Py_DecRef(args[7]) - args.deallocate() - throw PythonError.call - } - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - Py_DecRef(args[3]) - Py_DecRef(args[4]) - Py_DecRef(args[5]) - Py_DecRef(args[6]) - Py_DecRef(args[7]) - args.deallocate() - let rtn = try R(object: result) - Py_DecRef(result) - return rtn - } - - public func callAsFunction(_ a: A, _ b: B, _ c: C, _ d: D, _ e: E, _ f: F, _ g: G, _ h: H) throws -> PyPointer where - A: PyEncodable, - B: PyEncodable, - C: PyEncodable, - D: PyEncodable, - E: PyEncodable, - F: PyEncodable, - G: PyEncodable, - H: PyEncodable { - let args = VectorCallArgs.allocate(capacity: 8) - args[0] = a.pyPointer - args[1] = b.pyPointer - args[2] = c.pyPointer - args[3] = d.pyPointer - args[4] = e.pyPointer - args[5] = f.pyPointer - args[6] = g.pyPointer - args[7] = h.pyPointer - guard let result = PyObject_Vectorcall(self, args, 8, nil) else { - PyErr_Print() - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - Py_DecRef(args[3]) - Py_DecRef(args[4]) - Py_DecRef(args[5]) - Py_DecRef(args[6]) - Py_DecRef(args[7]) - args.deallocate() - throw PythonError.call - } - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - Py_DecRef(args[3]) - Py_DecRef(args[4]) - Py_DecRef(args[5]) - Py_DecRef(args[6]) - Py_DecRef(args[7]) - args.deallocate() - return result - } - - public func callAsFunction(_ a: A, _ b: B, _ c: C, _ d: D, _ e: E, _ f: F, _ g: G, _ h: H) throws where - A: PyEncodable, - B: PyEncodable, - C: PyEncodable, - D: PyEncodable, - E: PyEncodable, - F: PyEncodable, - G: PyEncodable, - H: PyEncodable { - let args = VectorCallArgs.allocate(capacity: 8) - args[0] = a.pyPointer - args[1] = b.pyPointer - args[2] = c.pyPointer - args[3] = d.pyPointer - args[4] = e.pyPointer - args[5] = f.pyPointer - args[6] = g.pyPointer - args[7] = h.pyPointer - guard let result = PyObject_Vectorcall(self, args, 8, nil) else { - PyErr_Print() - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - Py_DecRef(args[3]) - Py_DecRef(args[4]) - Py_DecRef(args[5]) - Py_DecRef(args[6]) - Py_DecRef(args[7]) - args.deallocate() - throw PythonError.call - } - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - Py_DecRef(args[3]) - Py_DecRef(args[4]) - Py_DecRef(args[5]) - Py_DecRef(args[6]) - Py_DecRef(args[7]) - args.deallocate() - Py_DecRef(result) - } - - public func callAsFunction(_ a: A, _ b: B, _ c: C, _ d: D, _ e: E, _ f: F, _ g: G, _ h: H, _ i: I) throws -> R where - A: PyEncodable, - B: PyEncodable, - C: PyEncodable, - D: PyEncodable, - E: PyEncodable, - F: PyEncodable, - G: PyEncodable, - H: PyEncodable, - I: PyEncodable, - R: PyDecodable { - let args = VectorCallArgs.allocate(capacity: 9) - args[0] = a.pyPointer - args[1] = b.pyPointer - args[2] = c.pyPointer - args[3] = d.pyPointer - args[4] = e.pyPointer - args[5] = f.pyPointer - args[6] = g.pyPointer - args[7] = h.pyPointer - args[8] = i.pyPointer - guard let result = PyObject_Vectorcall(self, args, 9, nil) else { - PyErr_Print() - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - Py_DecRef(args[3]) - Py_DecRef(args[4]) - Py_DecRef(args[5]) - Py_DecRef(args[6]) - Py_DecRef(args[7]) - Py_DecRef(args[8]) - args.deallocate() - throw PythonError.call - } - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - Py_DecRef(args[3]) - Py_DecRef(args[4]) - Py_DecRef(args[5]) - Py_DecRef(args[6]) - Py_DecRef(args[7]) - Py_DecRef(args[8]) - args.deallocate() - let rtn = try R(object: result) - Py_DecRef(result) - return rtn - } - - public func callAsFunction(_ a: A, _ b: B, _ c: C, _ d: D, _ e: E, _ f: F, _ g: G, _ h: H, _ i: I) throws -> PyPointer where - A: PyEncodable, - B: PyEncodable, - C: PyEncodable, - D: PyEncodable, - E: PyEncodable, - F: PyEncodable, - G: PyEncodable, - H: PyEncodable, - I: PyEncodable { - let args = VectorCallArgs.allocate(capacity: 9) - args[0] = a.pyPointer - args[1] = b.pyPointer - args[2] = c.pyPointer - args[3] = d.pyPointer - args[4] = e.pyPointer - args[5] = f.pyPointer - args[6] = g.pyPointer - args[7] = h.pyPointer - args[8] = i.pyPointer - guard let result = PyObject_Vectorcall(self, args, 9, nil) else { - PyErr_Print() - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - Py_DecRef(args[3]) - Py_DecRef(args[4]) - Py_DecRef(args[5]) - Py_DecRef(args[6]) - Py_DecRef(args[7]) - Py_DecRef(args[8]) - args.deallocate() - throw PythonError.call - } - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - Py_DecRef(args[3]) - Py_DecRef(args[4]) - Py_DecRef(args[5]) - Py_DecRef(args[6]) - Py_DecRef(args[7]) - Py_DecRef(args[8]) - args.deallocate() - return result - } - - public func callAsFunction(_ a: A, _ b: B, _ c: C, _ d: D, _ e: E, _ f: F, _ g: G, _ h: H, _ i: I) throws where - A: PyEncodable, - B: PyEncodable, - C: PyEncodable, - D: PyEncodable, - E: PyEncodable, - F: PyEncodable, - G: PyEncodable, - H: PyEncodable, - I: PyEncodable { - let args = VectorCallArgs.allocate(capacity: 9) - args[0] = a.pyPointer - args[1] = b.pyPointer - args[2] = c.pyPointer - args[3] = d.pyPointer - args[4] = e.pyPointer - args[5] = f.pyPointer - args[6] = g.pyPointer - args[7] = h.pyPointer - args[8] = i.pyPointer - guard let result = PyObject_Vectorcall(self, args, 9, nil) else { - PyErr_Print() - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - Py_DecRef(args[3]) - Py_DecRef(args[4]) - Py_DecRef(args[5]) - Py_DecRef(args[6]) - Py_DecRef(args[7]) - Py_DecRef(args[8]) - args.deallocate() - throw PythonError.call - } - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - Py_DecRef(args[3]) - Py_DecRef(args[4]) - Py_DecRef(args[5]) - Py_DecRef(args[6]) - Py_DecRef(args[7]) - Py_DecRef(args[8]) - args.deallocate() - Py_DecRef(result) - } -} - - -public func PythonCall < R>(call: PyPointer) throws -> R where - R: PyDecodable { - guard let result = PyObject_CallNoArgs(call) else { - PyErr_Print() - throw PythonError.call - } - let rtn = try R(object: result) - Py_DecRef(result) - return rtn -} - -public func PythonCall(call: PyPointer) throws -> PyPointer { - guard let result = PyObject_CallNoArgs(call) else { - PyErr_Print() - throw PythonError.call - } - return result -} - -public func PythonCall(call: PyPointer) throws { - guard let result = PyObject_CallNoArgs(call) else { - PyErr_Print() - throw PythonError.call - } - Py_DecRef(result) -} - -public func PythonCall(call: PyPointer, _ a: A) throws -> R where - A: PyEncodable, - R: PyDecodable { - let arg = a.pyPointer - guard let result = PyObject_CallOneArg(call, arg) else { - PyErr_Print() - Py_DecRef(arg) - throw PythonError.call - } - Py_DecRef(arg) - let rtn = try R(object: result) - Py_DecRef(result) - return rtn -} - -public func PythonCall(call: PyPointer, _ a: A) throws -> PyPointer where - A: PyEncodable { - let arg = a.pyPointer - guard let result = PyObject_CallOneArg(call, arg) else { - PyErr_Print() - Py_DecRef(arg) - throw PythonError.call - } - Py_DecRef(arg) - return result -} - -public func PythonCall(call: PyPointer, _ a: A) throws where - A: PyEncodable { - let arg = a.pyPointer - guard let result = PyObject_CallOneArg(call, arg) else { - PyErr_Print() - Py_DecRef(arg) - throw PythonError.call - } - Py_DecRef(arg) - Py_DecRef(result) -} - -public func PythonCall(call: PyPointer, _ a: A, _ b: B) throws -> R where - A: PyEncodable, - B: PyEncodable, - R: PyDecodable { - let args = VectorCallArgs.allocate(capacity: 2) - args[0] = a.pyPointer - args[1] = b.pyPointer - guard let result = PyObject_Vectorcall(call, args, 2, nil) else { - PyErr_Print() - Py_DecRef(args[0]) - Py_DecRef(args[1]) - args.deallocate() - throw PythonError.call - } - Py_DecRef(args[0]) - Py_DecRef(args[1]) - args.deallocate() - let rtn = try R(object: result) - Py_DecRef(result) - return rtn -} - -public func PythonCall(call: PyPointer, _ a: A, _ b: B) throws -> PyPointer where - A: PyEncodable, - B: PyEncodable { - let args = VectorCallArgs.allocate(capacity: 2) - args[0] = a.pyPointer - args[1] = b.pyPointer - guard let result = PyObject_Vectorcall(call, args, 2, nil) else { - PyErr_Print() - Py_DecRef(args[0]) - Py_DecRef(args[1]) - args.deallocate() - throw PythonError.call - } - Py_DecRef(args[0]) - Py_DecRef(args[1]) - args.deallocate() - return result -} - -public func PythonCall(call: PyPointer, _ a: A, _ b: B) throws where - A: PyEncodable, - B: PyEncodable { - let args = VectorCallArgs.allocate(capacity: 2) - args[0] = a.pyPointer - args[1] = b.pyPointer - guard let result = PyObject_Vectorcall(call, args, 2, nil) else { - PyErr_Print() - Py_DecRef(args[0]) - Py_DecRef(args[1]) - args.deallocate() - throw PythonError.call - } - Py_DecRef(args[0]) - Py_DecRef(args[1]) - args.deallocate() - Py_DecRef(result) -} - -public func PythonCall(call: PyPointer, _ a: A, _ b: B, _ c: C) throws -> R where - A: PyEncodable, - B: PyEncodable, - C: PyEncodable, - R: PyDecodable { - let args = VectorCallArgs.allocate(capacity: 3) - args[0] = a.pyPointer - args[1] = b.pyPointer - args[2] = c.pyPointer - guard let result = PyObject_Vectorcall(call, args, 3, nil) else { - PyErr_Print() - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - args.deallocate() - throw PythonError.call - } - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - args.deallocate() - let rtn = try R(object: result) - Py_DecRef(result) - return rtn -} - -public func PythonCall(call: PyPointer, _ a: A, _ b: B, _ c: C) throws -> PyPointer where - A: PyEncodable, - B: PyEncodable, - C: PyEncodable { - let args = VectorCallArgs.allocate(capacity: 3) - args[0] = a.pyPointer - args[1] = b.pyPointer - args[2] = c.pyPointer - guard let result = PyObject_Vectorcall(call, args, 3, nil) else { - PyErr_Print() - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - args.deallocate() - throw PythonError.call - } - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - args.deallocate() - return result -} - -public func PythonCall(call: PyPointer, _ a: A, _ b: B, _ c: C) throws where - A: PyEncodable, - B: PyEncodable, - C: PyEncodable { - let args = VectorCallArgs.allocate(capacity: 3) - args[0] = a.pyPointer - args[1] = b.pyPointer - args[2] = c.pyPointer - guard let result = PyObject_Vectorcall(call, args, 3, nil) else { - PyErr_Print() - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - args.deallocate() - throw PythonError.call - } - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - args.deallocate() - Py_DecRef(result) -} - -public func PythonCall(call: PyPointer, _ a: A, _ b: B, _ c: C, _ d: D) throws -> R where - A: PyEncodable, - B: PyEncodable, - C: PyEncodable, - D: PyEncodable, - R: PyDecodable { - let args = VectorCallArgs.allocate(capacity: 4) - args[0] = a.pyPointer - args[1] = b.pyPointer - args[2] = c.pyPointer - args[3] = d.pyPointer - guard let result = PyObject_Vectorcall(call, args, 4, nil) else { - PyErr_Print() - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - Py_DecRef(args[3]) - args.deallocate() - throw PythonError.call - } - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - Py_DecRef(args[3]) - args.deallocate() - let rtn = try R(object: result) - Py_DecRef(result) - return rtn -} - -public func PythonCall(call: PyPointer, _ a: A, _ b: B, _ c: C, _ d: D) throws -> PyPointer where - A: PyEncodable, - B: PyEncodable, - C: PyEncodable, - D: PyEncodable { - let args = VectorCallArgs.allocate(capacity: 4) - args[0] = a.pyPointer - args[1] = b.pyPointer - args[2] = c.pyPointer - args[3] = d.pyPointer - guard let result = PyObject_Vectorcall(call, args, 4, nil) else { - PyErr_Print() - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - Py_DecRef(args[3]) - args.deallocate() - throw PythonError.call - } - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - Py_DecRef(args[3]) - args.deallocate() - return result -} - -public func PythonCall(call: PyPointer, _ a: A, _ b: B, _ c: C, _ d: D) throws where - A: PyEncodable, - B: PyEncodable, - C: PyEncodable, - D: PyEncodable { - let args = VectorCallArgs.allocate(capacity: 4) - args[0] = a.pyPointer - args[1] = b.pyPointer - args[2] = c.pyPointer - args[3] = d.pyPointer - guard let result = PyObject_Vectorcall(call, args, 4, nil) else { - PyErr_Print() - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - Py_DecRef(args[3]) - args.deallocate() - throw PythonError.call - } - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - Py_DecRef(args[3]) - args.deallocate() - Py_DecRef(result) -} - -public func PythonCall(call: PyPointer, _ a: A, _ b: B, _ c: C, _ d: D, _ e: E) throws -> R where - A: PyEncodable, - B: PyEncodable, - C: PyEncodable, - D: PyEncodable, - E: PyEncodable, - R: PyDecodable { - let args = VectorCallArgs.allocate(capacity: 5) - args[0] = a.pyPointer - args[1] = b.pyPointer - args[2] = c.pyPointer - args[3] = d.pyPointer - args[4] = e.pyPointer - guard let result = PyObject_Vectorcall(call, args, 5, nil) else { - PyErr_Print() - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - Py_DecRef(args[3]) - Py_DecRef(args[4]) - args.deallocate() - throw PythonError.call - } - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - Py_DecRef(args[3]) - Py_DecRef(args[4]) - args.deallocate() - let rtn = try R(object: result) - Py_DecRef(result) - return rtn -} - -public func PythonCall(call: PyPointer, _ a: A, _ b: B, _ c: C, _ d: D, _ e: E) throws -> PyPointer where - A: PyEncodable, - B: PyEncodable, - C: PyEncodable, - D: PyEncodable, - E: PyEncodable { - let args = VectorCallArgs.allocate(capacity: 5) - args[0] = a.pyPointer - args[1] = b.pyPointer - args[2] = c.pyPointer - args[3] = d.pyPointer - args[4] = e.pyPointer - guard let result = PyObject_Vectorcall(call, args, 5, nil) else { - PyErr_Print() - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - Py_DecRef(args[3]) - Py_DecRef(args[4]) - args.deallocate() - throw PythonError.call - } - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - Py_DecRef(args[3]) - Py_DecRef(args[4]) - args.deallocate() - return result -} - -public func PythonCall(call: PyPointer, _ a: A, _ b: B, _ c: C, _ d: D, _ e: E) throws where - A: PyEncodable, - B: PyEncodable, - C: PyEncodable, - D: PyEncodable, - E: PyEncodable { - let args = VectorCallArgs.allocate(capacity: 5) - args[0] = a.pyPointer - args[1] = b.pyPointer - args[2] = c.pyPointer - args[3] = d.pyPointer - args[4] = e.pyPointer - guard let result = PyObject_Vectorcall(call, args, 5, nil) else { - PyErr_Print() - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - Py_DecRef(args[3]) - Py_DecRef(args[4]) - args.deallocate() - throw PythonError.call - } - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - Py_DecRef(args[3]) - Py_DecRef(args[4]) - args.deallocate() - Py_DecRef(result) -} - -public func PythonCall(call: PyPointer, _ a: A, _ b: B, _ c: C, _ d: D, _ e: E, _ f: F) throws -> R where - A: PyEncodable, - B: PyEncodable, - C: PyEncodable, - D: PyEncodable, - E: PyEncodable, - F: PyEncodable, - R: PyDecodable { - let args = VectorCallArgs.allocate(capacity: 6) - args[0] = a.pyPointer - args[1] = b.pyPointer - args[2] = c.pyPointer - args[3] = d.pyPointer - args[4] = e.pyPointer - args[5] = f.pyPointer - guard let result = PyObject_Vectorcall(call, args, 6, nil) else { - PyErr_Print() - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - Py_DecRef(args[3]) - Py_DecRef(args[4]) - Py_DecRef(args[5]) - args.deallocate() - throw PythonError.call - } - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - Py_DecRef(args[3]) - Py_DecRef(args[4]) - Py_DecRef(args[5]) - args.deallocate() - let rtn = try R(object: result) - Py_DecRef(result) - return rtn -} - -public func PythonCall(call: PyPointer, _ a: A, _ b: B, _ c: C, _ d: D, _ e: E, _ f: F) throws -> PyPointer where - A: PyEncodable, - B: PyEncodable, - C: PyEncodable, - D: PyEncodable, - E: PyEncodable, - F: PyEncodable { - let args = VectorCallArgs.allocate(capacity: 6) - args[0] = a.pyPointer - args[1] = b.pyPointer - args[2] = c.pyPointer - args[3] = d.pyPointer - args[4] = e.pyPointer - args[5] = f.pyPointer - guard let result = PyObject_Vectorcall(call, args, 6, nil) else { - PyErr_Print() - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - Py_DecRef(args[3]) - Py_DecRef(args[4]) - Py_DecRef(args[5]) - args.deallocate() - throw PythonError.call - } - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - Py_DecRef(args[3]) - Py_DecRef(args[4]) - Py_DecRef(args[5]) - args.deallocate() - return result -} - -public func PythonCall(call: PyPointer, _ a: A, _ b: B, _ c: C, _ d: D, _ e: E, _ f: F) throws where - A: PyEncodable, - B: PyEncodable, - C: PyEncodable, - D: PyEncodable, - E: PyEncodable, - F: PyEncodable { - let args = VectorCallArgs.allocate(capacity: 6) - args[0] = a.pyPointer - args[1] = b.pyPointer - args[2] = c.pyPointer - args[3] = d.pyPointer - args[4] = e.pyPointer - args[5] = f.pyPointer - guard let result = PyObject_Vectorcall(call, args, 6, nil) else { - PyErr_Print() - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - Py_DecRef(args[3]) - Py_DecRef(args[4]) - Py_DecRef(args[5]) - args.deallocate() - throw PythonError.call - } - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - Py_DecRef(args[3]) - Py_DecRef(args[4]) - Py_DecRef(args[5]) - args.deallocate() - Py_DecRef(result) -} - -public func PythonCall(call: PyPointer, _ a: A, _ b: B, _ c: C, _ d: D, _ e: E, _ f: F, _ g: G) throws -> R where - A: PyEncodable, - B: PyEncodable, - C: PyEncodable, - D: PyEncodable, - E: PyEncodable, - F: PyEncodable, - G: PyEncodable, - R: PyDecodable { - let args = VectorCallArgs.allocate(capacity: 7) - args[0] = a.pyPointer - args[1] = b.pyPointer - args[2] = c.pyPointer - args[3] = d.pyPointer - args[4] = e.pyPointer - args[5] = f.pyPointer - args[6] = g.pyPointer - guard let result = PyObject_Vectorcall(call, args, 7, nil) else { - PyErr_Print() - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - Py_DecRef(args[3]) - Py_DecRef(args[4]) - Py_DecRef(args[5]) - Py_DecRef(args[6]) - args.deallocate() - throw PythonError.call - } - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - Py_DecRef(args[3]) - Py_DecRef(args[4]) - Py_DecRef(args[5]) - Py_DecRef(args[6]) - args.deallocate() - let rtn = try R(object: result) - Py_DecRef(result) - return rtn -} - -public func PythonCall(call: PyPointer, _ a: A, _ b: B, _ c: C, _ d: D, _ e: E, _ f: F, _ g: G) throws -> PyPointer where - A: PyEncodable, - B: PyEncodable, - C: PyEncodable, - D: PyEncodable, - E: PyEncodable, - F: PyEncodable, - G: PyEncodable { - let args = VectorCallArgs.allocate(capacity: 7) - args[0] = a.pyPointer - args[1] = b.pyPointer - args[2] = c.pyPointer - args[3] = d.pyPointer - args[4] = e.pyPointer - args[5] = f.pyPointer - args[6] = g.pyPointer - guard let result = PyObject_Vectorcall(call, args, 7, nil) else { - PyErr_Print() - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - Py_DecRef(args[3]) - Py_DecRef(args[4]) - Py_DecRef(args[5]) - Py_DecRef(args[6]) - args.deallocate() - throw PythonError.call - } - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - Py_DecRef(args[3]) - Py_DecRef(args[4]) - Py_DecRef(args[5]) - Py_DecRef(args[6]) - args.deallocate() - return result -} - -public func PythonCall(call: PyPointer, _ a: A, _ b: B, _ c: C, _ d: D, _ e: E, _ f: F, _ g: G) throws where - A: PyEncodable, - B: PyEncodable, - C: PyEncodable, - D: PyEncodable, - E: PyEncodable, - F: PyEncodable, - G: PyEncodable { - let args = VectorCallArgs.allocate(capacity: 7) - args[0] = a.pyPointer - args[1] = b.pyPointer - args[2] = c.pyPointer - args[3] = d.pyPointer - args[4] = e.pyPointer - args[5] = f.pyPointer - args[6] = g.pyPointer - guard let result = PyObject_Vectorcall(call, args, 7, nil) else { - PyErr_Print() - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - Py_DecRef(args[3]) - Py_DecRef(args[4]) - Py_DecRef(args[5]) - Py_DecRef(args[6]) - args.deallocate() - throw PythonError.call - } - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - Py_DecRef(args[3]) - Py_DecRef(args[4]) - Py_DecRef(args[5]) - Py_DecRef(args[6]) - args.deallocate() - Py_DecRef(result) -} - -public func PythonCall(call: PyPointer, _ a: A, _ b: B, _ c: C, _ d: D, _ e: E, _ f: F, _ g: G, _ h: H) throws -> R where - A: PyEncodable, - B: PyEncodable, - C: PyEncodable, - D: PyEncodable, - E: PyEncodable, - F: PyEncodable, - G: PyEncodable, - H: PyEncodable, - R: PyDecodable { - let args = VectorCallArgs.allocate(capacity: 8) - args[0] = a.pyPointer - args[1] = b.pyPointer - args[2] = c.pyPointer - args[3] = d.pyPointer - args[4] = e.pyPointer - args[5] = f.pyPointer - args[6] = g.pyPointer - args[7] = h.pyPointer - guard let result = PyObject_Vectorcall(call, args, 8, nil) else { - PyErr_Print() - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - Py_DecRef(args[3]) - Py_DecRef(args[4]) - Py_DecRef(args[5]) - Py_DecRef(args[6]) - Py_DecRef(args[7]) - args.deallocate() - throw PythonError.call - } - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - Py_DecRef(args[3]) - Py_DecRef(args[4]) - Py_DecRef(args[5]) - Py_DecRef(args[6]) - Py_DecRef(args[7]) - args.deallocate() - let rtn = try R(object: result) - Py_DecRef(result) - return rtn -} - -public func PythonCall(call: PyPointer, _ a: A, _ b: B, _ c: C, _ d: D, _ e: E, _ f: F, _ g: G, _ h: H) throws -> PyPointer where - A: PyEncodable, - B: PyEncodable, - C: PyEncodable, - D: PyEncodable, - E: PyEncodable, - F: PyEncodable, - G: PyEncodable, - H: PyEncodable { - let args = VectorCallArgs.allocate(capacity: 8) - args[0] = a.pyPointer - args[1] = b.pyPointer - args[2] = c.pyPointer - args[3] = d.pyPointer - args[4] = e.pyPointer - args[5] = f.pyPointer - args[6] = g.pyPointer - args[7] = h.pyPointer - guard let result = PyObject_Vectorcall(call, args, 8, nil) else { - PyErr_Print() - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - Py_DecRef(args[3]) - Py_DecRef(args[4]) - Py_DecRef(args[5]) - Py_DecRef(args[6]) - Py_DecRef(args[7]) - args.deallocate() - throw PythonError.call - } - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - Py_DecRef(args[3]) - Py_DecRef(args[4]) - Py_DecRef(args[5]) - Py_DecRef(args[6]) - Py_DecRef(args[7]) - args.deallocate() - return result -} - -public func PythonCall(call: PyPointer, _ a: A, _ b: B, _ c: C, _ d: D, _ e: E, _ f: F, _ g: G, _ h: H) throws where - A: PyEncodable, - B: PyEncodable, - C: PyEncodable, - D: PyEncodable, - E: PyEncodable, - F: PyEncodable, - G: PyEncodable, - H: PyEncodable { - let args = VectorCallArgs.allocate(capacity: 8) - args[0] = a.pyPointer - args[1] = b.pyPointer - args[2] = c.pyPointer - args[3] = d.pyPointer - args[4] = e.pyPointer - args[5] = f.pyPointer - args[6] = g.pyPointer - args[7] = h.pyPointer - guard let result = PyObject_Vectorcall(call, args, 8, nil) else { - PyErr_Print() - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - Py_DecRef(args[3]) - Py_DecRef(args[4]) - Py_DecRef(args[5]) - Py_DecRef(args[6]) - Py_DecRef(args[7]) - args.deallocate() - throw PythonError.call - } - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - Py_DecRef(args[3]) - Py_DecRef(args[4]) - Py_DecRef(args[5]) - Py_DecRef(args[6]) - Py_DecRef(args[7]) - args.deallocate() - Py_DecRef(result) -} - -public func PythonCall(call: PyPointer, _ a: A, _ b: B, _ c: C, _ d: D, _ e: E, _ f: F, _ g: G, _ h: H, _ i: I) throws -> R where - A: PyEncodable, - B: PyEncodable, - C: PyEncodable, - D: PyEncodable, - E: PyEncodable, - F: PyEncodable, - G: PyEncodable, - H: PyEncodable, - I: PyEncodable, - R: PyDecodable { - let args = VectorCallArgs.allocate(capacity: 9) - args[0] = a.pyPointer - args[1] = b.pyPointer - args[2] = c.pyPointer - args[3] = d.pyPointer - args[4] = e.pyPointer - args[5] = f.pyPointer - args[6] = g.pyPointer - args[7] = h.pyPointer - args[8] = i.pyPointer - guard let result = PyObject_Vectorcall(call, args, 9, nil) else { - PyErr_Print() - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - Py_DecRef(args[3]) - Py_DecRef(args[4]) - Py_DecRef(args[5]) - Py_DecRef(args[6]) - Py_DecRef(args[7]) - Py_DecRef(args[8]) - args.deallocate() - throw PythonError.call - } - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - Py_DecRef(args[3]) - Py_DecRef(args[4]) - Py_DecRef(args[5]) - Py_DecRef(args[6]) - Py_DecRef(args[7]) - Py_DecRef(args[8]) - args.deallocate() - let rtn = try R(object: result) - Py_DecRef(result) - return rtn -} - -public func PythonCall(call: PyPointer, _ a: A, _ b: B, _ c: C, _ d: D, _ e: E, _ f: F, _ g: G, _ h: H, _ i: I) throws -> PyPointer where - A: PyEncodable, - B: PyEncodable, - C: PyEncodable, - D: PyEncodable, - E: PyEncodable, - F: PyEncodable, - G: PyEncodable, - H: PyEncodable, - I: PyEncodable { - let args = VectorCallArgs.allocate(capacity: 9) - args[0] = a.pyPointer - args[1] = b.pyPointer - args[2] = c.pyPointer - args[3] = d.pyPointer - args[4] = e.pyPointer - args[5] = f.pyPointer - args[6] = g.pyPointer - args[7] = h.pyPointer - args[8] = i.pyPointer - guard let result = PyObject_Vectorcall(call, args, 9, nil) else { - PyErr_Print() - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - Py_DecRef(args[3]) - Py_DecRef(args[4]) - Py_DecRef(args[5]) - Py_DecRef(args[6]) - Py_DecRef(args[7]) - Py_DecRef(args[8]) - args.deallocate() - throw PythonError.call - } - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - Py_DecRef(args[3]) - Py_DecRef(args[4]) - Py_DecRef(args[5]) - Py_DecRef(args[6]) - Py_DecRef(args[7]) - Py_DecRef(args[8]) - args.deallocate() - return result -} - -public func PythonCall(call: PyPointer, _ a: A, _ b: B, _ c: C, _ d: D, _ e: E, _ f: F, _ g: G, _ h: H, _ i: I) throws where - A: PyEncodable, - B: PyEncodable, - C: PyEncodable, - D: PyEncodable, - E: PyEncodable, - F: PyEncodable, - G: PyEncodable, - H: PyEncodable, - I: PyEncodable { - let args = VectorCallArgs.allocate(capacity: 9) - args[0] = a.pyPointer - args[1] = b.pyPointer - args[2] = c.pyPointer - args[3] = d.pyPointer - args[4] = e.pyPointer - args[5] = f.pyPointer - args[6] = g.pyPointer - args[7] = h.pyPointer - args[8] = i.pyPointer - guard let result = PyObject_Vectorcall(call, args, 9, nil) else { - PyErr_Print() - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - Py_DecRef(args[3]) - Py_DecRef(args[4]) - Py_DecRef(args[5]) - Py_DecRef(args[6]) - Py_DecRef(args[7]) - Py_DecRef(args[8]) - args.deallocate() - throw PythonError.call - } - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - Py_DecRef(args[3]) - Py_DecRef(args[4]) - Py_DecRef(args[5]) - Py_DecRef(args[6]) - Py_DecRef(args[7]) - Py_DecRef(args[8]) - args.deallocate() - Py_DecRef(result) -} - -public func PythonCallWithGil < R>(call: PyPointer) throws -> R where - R: PyDecodable { - let gil = PyGILState_Ensure() - guard let result = PyObject_CallNoArgs(call) else { - PyErr_Print() - throw PythonError.call - } - let rtn = try R(object: result) - Py_DecRef(result) - PyGILState_Release(gil) - return rtn -} - -public func PythonCallWithGil(call: PyPointer) throws -> PyPointer { - _ = PyGILState_Ensure() - guard let result = PyObject_CallNoArgs(call) else { - PyErr_Print() - throw PythonError.call - } - return result -} - -public func PythonCallWithGil(call: PyPointer) throws { - let gil = PyGILState_Ensure() - guard let result = PyObject_CallNoArgs(call) else { - PyErr_Print() - throw PythonError.call - } - PyGILState_Release(gil) - Py_DecRef(result) -} - -public func PythonCallWithGil(call: PyPointer, _ a: A) throws -> R where - A: PyEncodable, - R: PyDecodable { - let gil = PyGILState_Ensure() - let arg = a.pyPointer - guard let result = PyObject_CallOneArg(call, arg) else { - PyErr_Print() - Py_DecRef(arg) - throw PythonError.call - } - Py_DecRef(arg) - let rtn = try R(object: result) - Py_DecRef(result) - PyGILState_Release(gil) - return rtn -} - -public func PythonCallWithGil(call: PyPointer, _ a: A) throws -> PyPointer where - A: PyEncodable { - _ = PyGILState_Ensure() - let arg = a.pyPointer - guard let result = PyObject_CallOneArg(call, arg) else { - PyErr_Print() - Py_DecRef(arg) - throw PythonError.call - } - Py_DecRef(arg) - return result -} - -public func PythonCallWithGil(call: PyPointer, _ a: A) throws where - A: PyEncodable { - let gil = PyGILState_Ensure() - let arg = a.pyPointer - guard let result = PyObject_CallOneArg(call, arg) else { - PyErr_Print() - Py_DecRef(arg) - throw PythonError.call - } - Py_DecRef(arg) - PyGILState_Release(gil) - Py_DecRef(result) -} - -public func PythonCallWithGil(call: PyPointer, _ a: A, _ b: B) throws -> R where - A: PyEncodable, - B: PyEncodable, - R: PyDecodable { - let gil = PyGILState_Ensure() - let args = VectorCallArgs.allocate(capacity: 2) - args[0] = a.pyPointer - args[1] = b.pyPointer - guard let result = PyObject_Vectorcall(call, args, 2, nil) else { - PyErr_Print() - Py_DecRef(args[0]) - Py_DecRef(args[1]) - args.deallocate() - throw PythonError.call - } - Py_DecRef(args[0]) - Py_DecRef(args[1]) - args.deallocate() - let rtn = try R(object: result) - Py_DecRef(result) - PyGILState_Release(gil) - return rtn -} - -public func PythonCallWithGil(call: PyPointer, _ a: A, _ b: B) throws -> PyPointer where - A: PyEncodable, - B: PyEncodable { - _ = PyGILState_Ensure() - let args = VectorCallArgs.allocate(capacity: 2) - args[0] = a.pyPointer - args[1] = b.pyPointer - guard let result = PyObject_Vectorcall(call, args, 2, nil) else { - PyErr_Print() - Py_DecRef(args[0]) - Py_DecRef(args[1]) - args.deallocate() - throw PythonError.call - } - Py_DecRef(args[0]) - Py_DecRef(args[1]) - args.deallocate() - return result -} - -public func PythonCallWithGil(call: PyPointer, _ a: A, _ b: B) throws where - A: PyEncodable, - B: PyEncodable { - let gil = PyGILState_Ensure() - let args = VectorCallArgs.allocate(capacity: 2) - args[0] = a.pyPointer - args[1] = b.pyPointer - guard let result = PyObject_Vectorcall(call, args, 2, nil) else { - PyErr_Print() - Py_DecRef(args[0]) - Py_DecRef(args[1]) - args.deallocate() - throw PythonError.call - } - Py_DecRef(args[0]) - Py_DecRef(args[1]) - args.deallocate() - PyGILState_Release(gil) - Py_DecRef(result) -} - -public func PythonCallWithGil(call: PyPointer, _ a: A, _ b: B, _ c: C) throws -> R where - A: PyEncodable, - B: PyEncodable, - C: PyEncodable, - R: PyDecodable { - let gil = PyGILState_Ensure() - let args = VectorCallArgs.allocate(capacity: 3) - args[0] = a.pyPointer - args[1] = b.pyPointer - args[2] = c.pyPointer - guard let result = PyObject_Vectorcall(call, args, 3, nil) else { - PyErr_Print() - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - args.deallocate() - throw PythonError.call - } - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - args.deallocate() - let rtn = try R(object: result) - Py_DecRef(result) - PyGILState_Release(gil) - return rtn -} - -public func PythonCallWithGil(call: PyPointer, _ a: A, _ b: B, _ c: C) throws -> PyPointer where - A: PyEncodable, - B: PyEncodable, - C: PyEncodable { - _ = PyGILState_Ensure() - let args = VectorCallArgs.allocate(capacity: 3) - args[0] = a.pyPointer - args[1] = b.pyPointer - args[2] = c.pyPointer - guard let result = PyObject_Vectorcall(call, args, 3, nil) else { - PyErr_Print() - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - args.deallocate() - throw PythonError.call - } - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - args.deallocate() - return result -} - -public func PythonCallWithGil(call: PyPointer, _ a: A, _ b: B, _ c: C) throws where - A: PyEncodable, - B: PyEncodable, - C: PyEncodable { - let gil = PyGILState_Ensure() - let args = VectorCallArgs.allocate(capacity: 3) - args[0] = a.pyPointer - args[1] = b.pyPointer - args[2] = c.pyPointer - guard let result = PyObject_Vectorcall(call, args, 3, nil) else { - PyErr_Print() - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - args.deallocate() - throw PythonError.call - } - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - args.deallocate() - PyGILState_Release(gil) - Py_DecRef(result) -} - -public func PythonCallWithGil(call: PyPointer, _ a: A, _ b: B, _ c: C, _ d: D) throws -> R where - A: PyEncodable, - B: PyEncodable, - C: PyEncodable, - D: PyEncodable, - R: PyDecodable { - let gil = PyGILState_Ensure() - let args = VectorCallArgs.allocate(capacity: 4) - args[0] = a.pyPointer - args[1] = b.pyPointer - args[2] = c.pyPointer - args[3] = d.pyPointer - guard let result = PyObject_Vectorcall(call, args, 4, nil) else { - PyErr_Print() - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - Py_DecRef(args[3]) - args.deallocate() - throw PythonError.call - } - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - Py_DecRef(args[3]) - args.deallocate() - let rtn = try R(object: result) - Py_DecRef(result) - PyGILState_Release(gil) - return rtn -} - -public func PythonCallWithGil(call: PyPointer, _ a: A, _ b: B, _ c: C, _ d: D) throws -> PyPointer where - A: PyEncodable, - B: PyEncodable, - C: PyEncodable, - D: PyEncodable { - _ = PyGILState_Ensure() - let args = VectorCallArgs.allocate(capacity: 4) - args[0] = a.pyPointer - args[1] = b.pyPointer - args[2] = c.pyPointer - args[3] = d.pyPointer - guard let result = PyObject_Vectorcall(call, args, 4, nil) else { - PyErr_Print() - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - Py_DecRef(args[3]) - args.deallocate() - throw PythonError.call - } - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - Py_DecRef(args[3]) - args.deallocate() - return result -} - -public func PythonCallWithGil(call: PyPointer, _ a: A, _ b: B, _ c: C, _ d: D) throws where - A: PyEncodable, - B: PyEncodable, - C: PyEncodable, - D: PyEncodable { - let gil = PyGILState_Ensure() - let args = VectorCallArgs.allocate(capacity: 4) - args[0] = a.pyPointer - args[1] = b.pyPointer - args[2] = c.pyPointer - args[3] = d.pyPointer - guard let result = PyObject_Vectorcall(call, args, 4, nil) else { - PyErr_Print() - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - Py_DecRef(args[3]) - args.deallocate() - throw PythonError.call - } - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - Py_DecRef(args[3]) - args.deallocate() - PyGILState_Release(gil) - Py_DecRef(result) -} - -public func PythonCallWithGil(call: PyPointer, _ a: A, _ b: B, _ c: C, _ d: D, _ e: E) throws -> R where - A: PyEncodable, - B: PyEncodable, - C: PyEncodable, - D: PyEncodable, - E: PyEncodable, - R: PyDecodable { - let gil = PyGILState_Ensure() - let args = VectorCallArgs.allocate(capacity: 5) - args[0] = a.pyPointer - args[1] = b.pyPointer - args[2] = c.pyPointer - args[3] = d.pyPointer - args[4] = e.pyPointer - guard let result = PyObject_Vectorcall(call, args, 5, nil) else { - PyErr_Print() - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - Py_DecRef(args[3]) - Py_DecRef(args[4]) - args.deallocate() - throw PythonError.call - } - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - Py_DecRef(args[3]) - Py_DecRef(args[4]) - args.deallocate() - let rtn = try R(object: result) - Py_DecRef(result) - PyGILState_Release(gil) - return rtn -} - -public func PythonCallWithGil(call: PyPointer, _ a: A, _ b: B, _ c: C, _ d: D, _ e: E) throws -> PyPointer where - A: PyEncodable, - B: PyEncodable, - C: PyEncodable, - D: PyEncodable, - E: PyEncodable { - _ = PyGILState_Ensure() - let args = VectorCallArgs.allocate(capacity: 5) - args[0] = a.pyPointer - args[1] = b.pyPointer - args[2] = c.pyPointer - args[3] = d.pyPointer - args[4] = e.pyPointer - guard let result = PyObject_Vectorcall(call, args, 5, nil) else { - PyErr_Print() - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - Py_DecRef(args[3]) - Py_DecRef(args[4]) - args.deallocate() - throw PythonError.call - } - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - Py_DecRef(args[3]) - Py_DecRef(args[4]) - args.deallocate() - return result -} - -public func PythonCallWithGil(call: PyPointer, _ a: A, _ b: B, _ c: C, _ d: D, _ e: E) throws where - A: PyEncodable, - B: PyEncodable, - C: PyEncodable, - D: PyEncodable, - E: PyEncodable { - let gil = PyGILState_Ensure() - let args = VectorCallArgs.allocate(capacity: 5) - args[0] = a.pyPointer - args[1] = b.pyPointer - args[2] = c.pyPointer - args[3] = d.pyPointer - args[4] = e.pyPointer - guard let result = PyObject_Vectorcall(call, args, 5, nil) else { - PyErr_Print() - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - Py_DecRef(args[3]) - Py_DecRef(args[4]) - args.deallocate() - throw PythonError.call - } - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - Py_DecRef(args[3]) - Py_DecRef(args[4]) - args.deallocate() - PyGILState_Release(gil) - Py_DecRef(result) -} - -public func PythonCallWithGil(call: PyPointer, _ a: A, _ b: B, _ c: C, _ d: D, _ e: E, _ f: F) throws -> R where - A: PyEncodable, - B: PyEncodable, - C: PyEncodable, - D: PyEncodable, - E: PyEncodable, - F: PyEncodable, - R: PyDecodable { - let gil = PyGILState_Ensure() - let args = VectorCallArgs.allocate(capacity: 6) - args[0] = a.pyPointer - args[1] = b.pyPointer - args[2] = c.pyPointer - args[3] = d.pyPointer - args[4] = e.pyPointer - args[5] = f.pyPointer - guard let result = PyObject_Vectorcall(call, args, 6, nil) else { - PyErr_Print() - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - Py_DecRef(args[3]) - Py_DecRef(args[4]) - Py_DecRef(args[5]) - args.deallocate() - throw PythonError.call - } - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - Py_DecRef(args[3]) - Py_DecRef(args[4]) - Py_DecRef(args[5]) - args.deallocate() - let rtn = try R(object: result) - Py_DecRef(result) - PyGILState_Release(gil) - return rtn -} - -public func PythonCallWithGil(call: PyPointer, _ a: A, _ b: B, _ c: C, _ d: D, _ e: E, _ f: F) throws -> PyPointer where - A: PyEncodable, - B: PyEncodable, - C: PyEncodable, - D: PyEncodable, - E: PyEncodable, - F: PyEncodable { - _ = PyGILState_Ensure() - let args = VectorCallArgs.allocate(capacity: 6) - args[0] = a.pyPointer - args[1] = b.pyPointer - args[2] = c.pyPointer - args[3] = d.pyPointer - args[4] = e.pyPointer - args[5] = f.pyPointer - guard let result = PyObject_Vectorcall(call, args, 6, nil) else { - PyErr_Print() - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - Py_DecRef(args[3]) - Py_DecRef(args[4]) - Py_DecRef(args[5]) - args.deallocate() - throw PythonError.call - } - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - Py_DecRef(args[3]) - Py_DecRef(args[4]) - Py_DecRef(args[5]) - args.deallocate() - return result -} - -public func PythonCallWithGil(call: PyPointer, _ a: A, _ b: B, _ c: C, _ d: D, _ e: E, _ f: F) throws where - A: PyEncodable, - B: PyEncodable, - C: PyEncodable, - D: PyEncodable, - E: PyEncodable, - F: PyEncodable { - let gil = PyGILState_Ensure() - let args = VectorCallArgs.allocate(capacity: 6) - args[0] = a.pyPointer - args[1] = b.pyPointer - args[2] = c.pyPointer - args[3] = d.pyPointer - args[4] = e.pyPointer - args[5] = f.pyPointer - guard let result = PyObject_Vectorcall(call, args, 6, nil) else { - PyErr_Print() - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - Py_DecRef(args[3]) - Py_DecRef(args[4]) - Py_DecRef(args[5]) - args.deallocate() - throw PythonError.call - } - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - Py_DecRef(args[3]) - Py_DecRef(args[4]) - Py_DecRef(args[5]) - args.deallocate() - PyGILState_Release(gil) - Py_DecRef(result) -} - -public func PythonCallWithGil(call: PyPointer, _ a: A, _ b: B, _ c: C, _ d: D, _ e: E, _ f: F, _ g: G) throws -> R where - A: PyEncodable, - B: PyEncodable, - C: PyEncodable, - D: PyEncodable, - E: PyEncodable, - F: PyEncodable, - G: PyEncodable, - R: PyDecodable { - let gil = PyGILState_Ensure() - let args = VectorCallArgs.allocate(capacity: 7) - args[0] = a.pyPointer - args[1] = b.pyPointer - args[2] = c.pyPointer - args[3] = d.pyPointer - args[4] = e.pyPointer - args[5] = f.pyPointer - args[6] = g.pyPointer - guard let result = PyObject_Vectorcall(call, args, 7, nil) else { - PyErr_Print() - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - Py_DecRef(args[3]) - Py_DecRef(args[4]) - Py_DecRef(args[5]) - Py_DecRef(args[6]) - args.deallocate() - throw PythonError.call - } - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - Py_DecRef(args[3]) - Py_DecRef(args[4]) - Py_DecRef(args[5]) - Py_DecRef(args[6]) - args.deallocate() - let rtn = try R(object: result) - Py_DecRef(result) - PyGILState_Release(gil) - return rtn -} - -public func PythonCallWithGil(call: PyPointer, _ a: A, _ b: B, _ c: C, _ d: D, _ e: E, _ f: F, _ g: G) throws -> PyPointer where - A: PyEncodable, - B: PyEncodable, - C: PyEncodable, - D: PyEncodable, - E: PyEncodable, - F: PyEncodable, - G: PyEncodable { - _ = PyGILState_Ensure() - let args = VectorCallArgs.allocate(capacity: 7) - args[0] = a.pyPointer - args[1] = b.pyPointer - args[2] = c.pyPointer - args[3] = d.pyPointer - args[4] = e.pyPointer - args[5] = f.pyPointer - args[6] = g.pyPointer - guard let result = PyObject_Vectorcall(call, args, 7, nil) else { - PyErr_Print() - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - Py_DecRef(args[3]) - Py_DecRef(args[4]) - Py_DecRef(args[5]) - Py_DecRef(args[6]) - args.deallocate() - throw PythonError.call - } - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - Py_DecRef(args[3]) - Py_DecRef(args[4]) - Py_DecRef(args[5]) - Py_DecRef(args[6]) - args.deallocate() - return result -} - -public func PythonCallWithGil(call: PyPointer, _ a: A, _ b: B, _ c: C, _ d: D, _ e: E, _ f: F, _ g: G) throws where - A: PyEncodable, - B: PyEncodable, - C: PyEncodable, - D: PyEncodable, - E: PyEncodable, - F: PyEncodable, - G: PyEncodable { - let gil = PyGILState_Ensure() - let args = VectorCallArgs.allocate(capacity: 7) - args[0] = a.pyPointer - args[1] = b.pyPointer - args[2] = c.pyPointer - args[3] = d.pyPointer - args[4] = e.pyPointer - args[5] = f.pyPointer - args[6] = g.pyPointer - guard let result = PyObject_Vectorcall(call, args, 7, nil) else { - PyErr_Print() - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - Py_DecRef(args[3]) - Py_DecRef(args[4]) - Py_DecRef(args[5]) - Py_DecRef(args[6]) - args.deallocate() - throw PythonError.call - } - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - Py_DecRef(args[3]) - Py_DecRef(args[4]) - Py_DecRef(args[5]) - Py_DecRef(args[6]) - args.deallocate() - PyGILState_Release(gil) - Py_DecRef(result) -} - -public func PythonCallWithGil(call: PyPointer, _ a: A, _ b: B, _ c: C, _ d: D, _ e: E, _ f: F, _ g: G, _ h: H) throws -> R where - A: PyEncodable, - B: PyEncodable, - C: PyEncodable, - D: PyEncodable, - E: PyEncodable, - F: PyEncodable, - G: PyEncodable, - H: PyEncodable, - R: PyDecodable { - let gil = PyGILState_Ensure() - let args = VectorCallArgs.allocate(capacity: 8) - args[0] = a.pyPointer - args[1] = b.pyPointer - args[2] = c.pyPointer - args[3] = d.pyPointer - args[4] = e.pyPointer - args[5] = f.pyPointer - args[6] = g.pyPointer - args[7] = h.pyPointer - guard let result = PyObject_Vectorcall(call, args, 8, nil) else { - PyErr_Print() - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - Py_DecRef(args[3]) - Py_DecRef(args[4]) - Py_DecRef(args[5]) - Py_DecRef(args[6]) - Py_DecRef(args[7]) - args.deallocate() - throw PythonError.call - } - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - Py_DecRef(args[3]) - Py_DecRef(args[4]) - Py_DecRef(args[5]) - Py_DecRef(args[6]) - Py_DecRef(args[7]) - args.deallocate() - let rtn = try R(object: result) - Py_DecRef(result) - PyGILState_Release(gil) - return rtn -} - -public func PythonCallWithGil(call: PyPointer, _ a: A, _ b: B, _ c: C, _ d: D, _ e: E, _ f: F, _ g: G, _ h: H) throws -> PyPointer where - A: PyEncodable, - B: PyEncodable, - C: PyEncodable, - D: PyEncodable, - E: PyEncodable, - F: PyEncodable, - G: PyEncodable, - H: PyEncodable { - _ = PyGILState_Ensure() - let args = VectorCallArgs.allocate(capacity: 8) - args[0] = a.pyPointer - args[1] = b.pyPointer - args[2] = c.pyPointer - args[3] = d.pyPointer - args[4] = e.pyPointer - args[5] = f.pyPointer - args[6] = g.pyPointer - args[7] = h.pyPointer - guard let result = PyObject_Vectorcall(call, args, 8, nil) else { - PyErr_Print() - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - Py_DecRef(args[3]) - Py_DecRef(args[4]) - Py_DecRef(args[5]) - Py_DecRef(args[6]) - Py_DecRef(args[7]) - args.deallocate() - throw PythonError.call - } - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - Py_DecRef(args[3]) - Py_DecRef(args[4]) - Py_DecRef(args[5]) - Py_DecRef(args[6]) - Py_DecRef(args[7]) - args.deallocate() - return result -} - -public func PythonCallWithGil(call: PyPointer, _ a: A, _ b: B, _ c: C, _ d: D, _ e: E, _ f: F, _ g: G, _ h: H) throws where - A: PyEncodable, - B: PyEncodable, - C: PyEncodable, - D: PyEncodable, - E: PyEncodable, - F: PyEncodable, - G: PyEncodable, - H: PyEncodable { - let gil = PyGILState_Ensure() - let args = VectorCallArgs.allocate(capacity: 8) - args[0] = a.pyPointer - args[1] = b.pyPointer - args[2] = c.pyPointer - args[3] = d.pyPointer - args[4] = e.pyPointer - args[5] = f.pyPointer - args[6] = g.pyPointer - args[7] = h.pyPointer - guard let result = PyObject_Vectorcall(call, args, 8, nil) else { - PyErr_Print() - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - Py_DecRef(args[3]) - Py_DecRef(args[4]) - Py_DecRef(args[5]) - Py_DecRef(args[6]) - Py_DecRef(args[7]) - args.deallocate() - throw PythonError.call - } - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - Py_DecRef(args[3]) - Py_DecRef(args[4]) - Py_DecRef(args[5]) - Py_DecRef(args[6]) - Py_DecRef(args[7]) - args.deallocate() - PyGILState_Release(gil) - Py_DecRef(result) -} - -public func PythonCallWithGil(call: PyPointer, _ a: A, _ b: B, _ c: C, _ d: D, _ e: E, _ f: F, _ g: G, _ h: H, _ i: I) throws -> R where - A: PyEncodable, - B: PyEncodable, - C: PyEncodable, - D: PyEncodable, - E: PyEncodable, - F: PyEncodable, - G: PyEncodable, - H: PyEncodable, - I: PyEncodable, - R: PyDecodable { - let gil = PyGILState_Ensure() - let args = VectorCallArgs.allocate(capacity: 9) - args[0] = a.pyPointer - args[1] = b.pyPointer - args[2] = c.pyPointer - args[3] = d.pyPointer - args[4] = e.pyPointer - args[5] = f.pyPointer - args[6] = g.pyPointer - args[7] = h.pyPointer - args[8] = i.pyPointer - guard let result = PyObject_Vectorcall(call, args, 9, nil) else { - PyErr_Print() - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - Py_DecRef(args[3]) - Py_DecRef(args[4]) - Py_DecRef(args[5]) - Py_DecRef(args[6]) - Py_DecRef(args[7]) - Py_DecRef(args[8]) - args.deallocate() - throw PythonError.call - } - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - Py_DecRef(args[3]) - Py_DecRef(args[4]) - Py_DecRef(args[5]) - Py_DecRef(args[6]) - Py_DecRef(args[7]) - Py_DecRef(args[8]) - args.deallocate() - let rtn = try R(object: result) - Py_DecRef(result) - PyGILState_Release(gil) - return rtn -} - -public func PythonCallWithGil(call: PyPointer, _ a: A, _ b: B, _ c: C, _ d: D, _ e: E, _ f: F, _ g: G, _ h: H, _ i: I) throws -> PyPointer where - A: PyEncodable, - B: PyEncodable, - C: PyEncodable, - D: PyEncodable, - E: PyEncodable, - F: PyEncodable, - G: PyEncodable, - H: PyEncodable, - I: PyEncodable { - _ = PyGILState_Ensure() - let args = VectorCallArgs.allocate(capacity: 9) - args[0] = a.pyPointer - args[1] = b.pyPointer - args[2] = c.pyPointer - args[3] = d.pyPointer - args[4] = e.pyPointer - args[5] = f.pyPointer - args[6] = g.pyPointer - args[7] = h.pyPointer - args[8] = i.pyPointer - guard let result = PyObject_Vectorcall(call, args, 9, nil) else { - PyErr_Print() - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - Py_DecRef(args[3]) - Py_DecRef(args[4]) - Py_DecRef(args[5]) - Py_DecRef(args[6]) - Py_DecRef(args[7]) - Py_DecRef(args[8]) - args.deallocate() - throw PythonError.call - } - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - Py_DecRef(args[3]) - Py_DecRef(args[4]) - Py_DecRef(args[5]) - Py_DecRef(args[6]) - Py_DecRef(args[7]) - Py_DecRef(args[8]) - args.deallocate() - return result -} - -public func PythonCallWithGil(call: PyPointer, _ a: A, _ b: B, _ c: C, _ d: D, _ e: E, _ f: F, _ g: G, _ h: H, _ i: I) throws where - A: PyEncodable, - B: PyEncodable, - C: PyEncodable, - D: PyEncodable, - E: PyEncodable, - F: PyEncodable, - G: PyEncodable, - H: PyEncodable, - I: PyEncodable { - let gil = PyGILState_Ensure() - let args = VectorCallArgs.allocate(capacity: 9) - args[0] = a.pyPointer - args[1] = b.pyPointer - args[2] = c.pyPointer - args[3] = d.pyPointer - args[4] = e.pyPointer - args[5] = f.pyPointer - args[6] = g.pyPointer - args[7] = h.pyPointer - args[8] = i.pyPointer - guard let result = PyObject_Vectorcall(call, args, 9, nil) else { - PyErr_Print() - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - Py_DecRef(args[3]) - Py_DecRef(args[4]) - Py_DecRef(args[5]) - Py_DecRef(args[6]) - Py_DecRef(args[7]) - Py_DecRef(args[8]) - args.deallocate() - throw PythonError.call - } - Py_DecRef(args[0]) - Py_DecRef(args[1]) - Py_DecRef(args[2]) - Py_DecRef(args[3]) - Py_DecRef(args[4]) - Py_DecRef(args[5]) - Py_DecRef(args[6]) - Py_DecRef(args[7]) - Py_DecRef(args[8]) - args.deallocate() - PyGILState_Release(gil) - Py_DecRef(result) -} \ No newline at end of file