|
| 1 | +// |
| 2 | +// Bindings.swift |
| 3 | +// LDKSwiftARC |
| 4 | +// |
| 5 | +// Created by Arik Sosman on 3/23/21. |
| 6 | +// |
| 7 | + |
| 8 | +import Foundation |
| 9 | + |
| 10 | +class Bindings{ |
| 11 | + |
| 12 | + /* VECTOR_METHODS_START */ |
| 13 | + |
| 14 | + static func new_LDKCVec_CVec_u8ZZ(array: [UInt8]) -> LDKCVec_CVec_u8ZZ { |
| 15 | + |
| 16 | + let dataContainer = array.withUnsafeBufferPointer { (pointer: UnsafeBufferPointer<UInt8>) -> UnsafeMutablePointer<UInt8> in |
| 17 | + let mutablePointer = UnsafeMutablePointer<UInt8>(mutating: pointer.baseAddress!) |
| 18 | + return mutablePointer |
| 19 | + } |
| 20 | + |
| 21 | + let vector = LDKCVec_CVec_u8ZZ(data: dataContainer, datalen: UInt(array.count)) |
| 22 | + return vector |
| 23 | + |
| 24 | + } |
| 25 | + |
| 26 | + static func LDKCVec_CVec_u8ZZ_to_array(vector: LDKCVec_CVec_u8ZZ) -> [UInt8] { |
| 27 | + var array = [UInt8]() |
| 28 | + for index in 0..<Int(vector.datalen) { |
| 29 | + array.append(vector.data[index]) |
| 30 | + } |
| 31 | + return array |
| 32 | + } |
| 33 | + |
| 34 | + static func new_LDKCVec_u8Z(array: [UInt8]) -> LDKCVec_u8Z { |
| 35 | + |
| 36 | + let dataContainer = array.withUnsafeBufferPointer { (pointer: UnsafeBufferPointer<UInt8>) -> UnsafeMutablePointer<UInt8> in |
| 37 | + let mutablePointer = UnsafeMutablePointer<UInt8>(mutating: pointer.baseAddress!) |
| 38 | + return mutablePointer |
| 39 | + } |
| 40 | + |
| 41 | + let vector = LDKCVec_u8Z(data: dataContainer, datalen: UInt(array.count)) |
| 42 | + return vector |
| 43 | + |
| 44 | + } |
| 45 | + |
| 46 | + static func LDKCVec_u8Z_to_array(vector: LDKCVec_u8Z) -> [UInt8] { |
| 47 | + var array = [UInt8]() |
| 48 | + for index in 0..<Int(vector.datalen) { |
| 49 | + array.append(vector.data[index]) |
| 50 | + } |
| 51 | + return array |
| 52 | + } |
| 53 | + |
| 54 | + static func new_LDKCVec_u64Z(array: [UInt64]) -> LDKCVec_u64Z { |
| 55 | + |
| 56 | + let dataContainer = array.withUnsafeBufferPointer { (pointer: UnsafeBufferPointer<UInt64>) -> UnsafeMutablePointer<UInt64> in |
| 57 | + let mutablePointer = UnsafeMutablePointer<UInt64>(mutating: pointer.baseAddress!) |
| 58 | + return mutablePointer |
| 59 | + } |
| 60 | + |
| 61 | + let vector = LDKCVec_u64Z(data: dataContainer, datalen: UInt(array.count)) |
| 62 | + return vector |
| 63 | + |
| 64 | + } |
| 65 | + |
| 66 | + static func LDKCVec_u64Z_to_array(vector: LDKCVec_u64Z) -> [UInt64] { |
| 67 | + var array = [UInt64]() |
| 68 | + for index in 0..<Int(vector.datalen) { |
| 69 | + array.append(vector.data[index]) |
| 70 | + } |
| 71 | + return array |
| 72 | + } |
| 73 | + |
| 74 | + /* VECTOR_METHODS_END */ |
| 75 | + |
| 76 | +} |
0 commit comments