Skip to content

Commit bcfba40

Browse files
committed
Return swift-typed arrays outside of traits.
1 parent b020417 commit bcfba40

12 files changed

+134
-36
lines changed

bindings/LDK/Bindings.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
import Foundation
99

1010
public typealias LDKTransactionOutputs = LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ
11+
public typealias TransactionOutputs = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ
1112
public typealias LDKTxid = LDKThirtyTwoBytes
13+
public typealias Txid = [UInt8]
1214

1315
open class NativeTypeWrapper: Hashable {
1416

bindings/LDK/options/Event.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,8 +363,12 @@ Event_write(objPointer)
363363

364364

365365

366-
public func getOutputs() -> [LDKSpendableOutputDescriptor] {
366+
public func getOutputs() -> [SpendableOutputDescriptor] {
367367
return Bindings.LDKCVec_SpendableOutputDescriptorZ_to_array(nativeType: self.cOpaqueStruct!.outputs, deallocate: false)
368+
.map { (cOpaqueStruct) in
369+
SpendableOutputDescriptor(pointer: cOpaqueStruct).dangle()
370+
}
371+
368372
}
369373

370374

bindings/LDK/options/PaymentSendFailure.swift

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,25 +53,37 @@ public class PaymentSendFailure: NativeTypeWrapper {
5353
return APIError(pointer: self.cOpaqueStruct!.parameter_error, anchor: self)
5454
}
5555

56-
public func getValueAsPathParameterError() -> [LDKCResult_NoneAPIErrorZ]? {
56+
public func getValueAsPathParameterError() -> [Result_NoneAPIErrorZ]? {
5757
if self.cOpaqueStruct?.tag != LDKPaymentSendFailure_PathParameterError {
5858
return nil
5959
}
6060
return Bindings.LDKCVec_CResult_NoneAPIErrorZZ_to_array(nativeType: self.cOpaqueStruct!.path_parameter_error, deallocate: false)
61+
.map { (cOpaqueStruct) in
62+
Result_NoneAPIErrorZ(pointer: cOpaqueStruct).dangle()
63+
}
64+
6165
}
6266

63-
public func getValueAsAllFailedRetrySafe() -> [LDKAPIError]? {
67+
public func getValueAsAllFailedRetrySafe() -> [APIError]? {
6468
if self.cOpaqueStruct?.tag != LDKPaymentSendFailure_AllFailedRetrySafe {
6569
return nil
6670
}
6771
return Bindings.LDKCVec_APIErrorZ_to_array(nativeType: self.cOpaqueStruct!.all_failed_retry_safe, deallocate: false)
72+
.map { (cOpaqueStruct) in
73+
APIError(pointer: cOpaqueStruct).dangle()
74+
}
75+
6876
}
6977

70-
public func getValueAsPartialFailure() -> [LDKCResult_NoneAPIErrorZ]? {
78+
public func getValueAsPartialFailure() -> [Result_NoneAPIErrorZ]? {
7179
if self.cOpaqueStruct?.tag != LDKPaymentSendFailure_PartialFailure {
7280
return nil
7381
}
7482
return Bindings.LDKCVec_CResult_NoneAPIErrorZZ_to_array(nativeType: self.cOpaqueStruct!.partial_failure, deallocate: false)
83+
.map { (cOpaqueStruct) in
84+
Result_NoneAPIErrorZ(pointer: cOpaqueStruct).dangle()
85+
}
86+
7587
}
7688

7789

bindings/LDK/results/Result_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,13 @@ public class Result_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ: NativeTypeWrap
4545
return nil
4646
}
4747

48-
public func getValue() -> [LDKC2Tuple_BlockHashChannelMonitorZ]? {
48+
public func getValue() -> [C2Tuple_BlockHashChannelMonitorZ]? {
4949
if self.cOpaqueStruct?.result_ok == true {
5050
return Bindings.LDKCVec_C2Tuple_BlockHashChannelMonitorZZ_to_array(nativeType: self.cOpaqueStruct!.contents.result.pointee, deallocate: false)
51+
.map { (cOpaqueStruct) in
52+
C2Tuple_BlockHashChannelMonitorZ(pointer: cOpaqueStruct).dangle()
53+
}
54+
5155
}
5256
return nil
5357
}

bindings/LDK/structs/ChannelManager.swift

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,18 +48,26 @@ ChannelManager_create_channel(this_argPointer, Bindings.new_LDKPublicKey(array:
4848
});
4949
}
5050

51-
public func list_channels() -> [LDKChannelDetails] {
51+
public func list_channels() -> [ChannelDetails] {
5252

5353
return Bindings.LDKCVec_ChannelDetailsZ_to_array(nativeType: withUnsafePointer(to: self.cOpaqueStruct!) { (this_argPointer: UnsafePointer<LDKChannelManager>) in
5454
ChannelManager_list_channels(this_argPointer)
55-
});
55+
})
56+
.map { (cOpaqueStruct) in
57+
ChannelDetails(pointer: cOpaqueStruct)
58+
}
59+
;
5660
}
5761

58-
public func list_usable_channels() -> [LDKChannelDetails] {
62+
public func list_usable_channels() -> [ChannelDetails] {
5963

6064
return Bindings.LDKCVec_ChannelDetailsZ_to_array(nativeType: withUnsafePointer(to: self.cOpaqueStruct!) { (this_argPointer: UnsafePointer<LDKChannelManager>) in
6165
ChannelManager_list_usable_channels(this_argPointer)
62-
});
66+
})
67+
.map { (cOpaqueStruct) in
68+
ChannelDetails(pointer: cOpaqueStruct)
69+
}
70+
;
6371
}
6472

6573
public func close_channel(channel_id: [UInt8]) -> Result_NoneAPIErrorZ {

bindings/LDK/structs/ChannelMonitor.swift

Lines changed: 44 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,15 @@ ChannelMonitor_get_funding_txo(this_argPointer)
7676
});
7777
}
7878

79-
public func get_outputs_to_watch() -> [LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ] {
79+
public func get_outputs_to_watch() -> [C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ] {
8080

8181
return Bindings.LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_to_array(nativeType: withUnsafePointer(to: self.cOpaqueStruct!) { (this_argPointer: UnsafePointer<LDKChannelMonitor>) in
8282
ChannelMonitor_get_outputs_to_watch(this_argPointer)
83-
});
83+
})
84+
.map { (cOpaqueStruct) in
85+
C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ(pointer: cOpaqueStruct)
86+
}
87+
;
8488
}
8589

8690
public func load_outputs_to_watch(filter: Filter) -> Void {
@@ -92,18 +96,26 @@ ChannelMonitor_load_outputs_to_watch(this_argPointer, filterPointer)
9296
};
9397
}
9498

95-
public func get_and_clear_pending_monitor_events() -> [LDKMonitorEvent] {
99+
public func get_and_clear_pending_monitor_events() -> [MonitorEvent] {
96100

97101
return Bindings.LDKCVec_MonitorEventZ_to_array(nativeType: withUnsafePointer(to: self.cOpaqueStruct!) { (this_argPointer: UnsafePointer<LDKChannelMonitor>) in
98102
ChannelMonitor_get_and_clear_pending_monitor_events(this_argPointer)
99-
});
103+
})
104+
.map { (cOpaqueStruct) in
105+
MonitorEvent(pointer: cOpaqueStruct)
106+
}
107+
;
100108
}
101109

102-
public func get_and_clear_pending_events() -> [LDKEvent] {
110+
public func get_and_clear_pending_events() -> [Event] {
103111

104112
return Bindings.LDKCVec_EventZ_to_array(nativeType: withUnsafePointer(to: self.cOpaqueStruct!) { (this_argPointer: UnsafePointer<LDKChannelMonitor>) in
105113
ChannelMonitor_get_and_clear_pending_events(this_argPointer)
106-
});
114+
})
115+
.map { (cOpaqueStruct) in
116+
Event(pointer: cOpaqueStruct)
117+
}
118+
;
107119
}
108120

109121
public func get_latest_holder_commitment_txn(logger: Logger) -> [[UInt8]] {
@@ -115,7 +127,7 @@ ChannelMonitor_get_latest_holder_commitment_txn(this_argPointer, loggerPointer)
115127
});
116128
}
117129

118-
public func block_connected(header: [UInt8], txdata: [C2Tuple_usizeTransactionZ], height: UInt32, broadcaster: BroadcasterInterface, fee_estimator: FeeEstimator, logger: Logger) -> [LDKTransactionOutputs] {
130+
public func block_connected(header: [UInt8], txdata: [C2Tuple_usizeTransactionZ], height: UInt32, broadcaster: BroadcasterInterface, fee_estimator: FeeEstimator, logger: Logger) -> [TransactionOutputs] {
119131

120132
let txdataUnwrapped = txdata.map { (txdataCurrentValue) in
121133
txdataCurrentValue
@@ -125,7 +137,7 @@ ChannelMonitor_get_latest_holder_commitment_txn(this_argPointer, loggerPointer)
125137
return self.block_connected(header: header, txdata: txdataUnwrapped, height: height, broadcaster: broadcaster, fee_estimator: fee_estimator, logger: logger);
126138
}
127139

128-
internal func block_connected(header: [UInt8], txdata: [LDKC2Tuple_usizeTransactionZ], height: UInt32, broadcaster: BroadcasterInterface, fee_estimator: FeeEstimator, logger: Logger) -> [LDKTransactionOutputs] {
140+
internal func block_connected(header: [UInt8], txdata: [LDKC2Tuple_usizeTransactionZ], height: UInt32, broadcaster: BroadcasterInterface, fee_estimator: FeeEstimator, logger: Logger) -> [TransactionOutputs] {
129141

130142
let txdataWrapper = Bindings.new_LDKCVec_C2Tuple_usizeTransactionZZWrapper(array: txdata)
131143
defer {
@@ -136,7 +148,11 @@ ChannelMonitor_get_latest_holder_commitment_txn(this_argPointer, loggerPointer)
136148
withUnsafePointer(to: Bindings.array_to_tuple80(array: header)) { (headerPointer: UnsafePointer<(UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8)>) in
137149
ChannelMonitor_block_connected(this_argPointer, headerPointer, txdataWrapper.dangle().cOpaqueStruct!, height, broadcaster.cOpaqueStruct!, fee_estimator.cOpaqueStruct!, logger.cOpaqueStruct!)
138150
}
139-
});
151+
})
152+
.map { (cOpaqueStruct) in
153+
TransactionOutputs(pointer: cOpaqueStruct)
154+
}
155+
;
140156
}
141157

142158
public func block_disconnected(header: [UInt8], height: UInt32, broadcaster: BroadcasterInterface, fee_estimator: FeeEstimator, logger: Logger) -> Void {
@@ -148,7 +164,7 @@ ChannelMonitor_block_disconnected(this_argPointer, headerPointer, height, broadc
148164
};
149165
}
150166

151-
public func transactions_confirmed(header: [UInt8], txdata: [C2Tuple_usizeTransactionZ], height: UInt32, broadcaster: BroadcasterInterface, fee_estimator: FeeEstimator, logger: Logger) -> [LDKTransactionOutputs] {
167+
public func transactions_confirmed(header: [UInt8], txdata: [C2Tuple_usizeTransactionZ], height: UInt32, broadcaster: BroadcasterInterface, fee_estimator: FeeEstimator, logger: Logger) -> [TransactionOutputs] {
152168

153169
let txdataUnwrapped = txdata.map { (txdataCurrentValue) in
154170
txdataCurrentValue
@@ -158,7 +174,7 @@ ChannelMonitor_block_disconnected(this_argPointer, headerPointer, height, broadc
158174
return self.transactions_confirmed(header: header, txdata: txdataUnwrapped, height: height, broadcaster: broadcaster, fee_estimator: fee_estimator, logger: logger);
159175
}
160176

161-
internal func transactions_confirmed(header: [UInt8], txdata: [LDKC2Tuple_usizeTransactionZ], height: UInt32, broadcaster: BroadcasterInterface, fee_estimator: FeeEstimator, logger: Logger) -> [LDKTransactionOutputs] {
177+
internal func transactions_confirmed(header: [UInt8], txdata: [LDKC2Tuple_usizeTransactionZ], height: UInt32, broadcaster: BroadcasterInterface, fee_estimator: FeeEstimator, logger: Logger) -> [TransactionOutputs] {
162178

163179
let txdataWrapper = Bindings.new_LDKCVec_C2Tuple_usizeTransactionZZWrapper(array: txdata)
164180
defer {
@@ -169,7 +185,11 @@ ChannelMonitor_block_disconnected(this_argPointer, headerPointer, height, broadc
169185
withUnsafePointer(to: Bindings.array_to_tuple80(array: header)) { (headerPointer: UnsafePointer<(UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8)>) in
170186
ChannelMonitor_transactions_confirmed(this_argPointer, headerPointer, txdataWrapper.dangle().cOpaqueStruct!, height, broadcaster.cOpaqueStruct!, fee_estimator.cOpaqueStruct!, logger.cOpaqueStruct!)
171187
}
172-
});
188+
})
189+
.map { (cOpaqueStruct) in
190+
TransactionOutputs(pointer: cOpaqueStruct)
191+
}
192+
;
173193
}
174194

175195
public func transaction_unconfirmed(txid: [UInt8], broadcaster: BroadcasterInterface, fee_estimator: FeeEstimator, logger: Logger) -> Void {
@@ -181,20 +201,28 @@ ChannelMonitor_transaction_unconfirmed(this_argPointer, txidPointer, broadcaster
181201
};
182202
}
183203

184-
public func best_block_updated(header: [UInt8], height: UInt32, broadcaster: BroadcasterInterface, fee_estimator: FeeEstimator, logger: Logger) -> [LDKTransactionOutputs] {
204+
public func best_block_updated(header: [UInt8], height: UInt32, broadcaster: BroadcasterInterface, fee_estimator: FeeEstimator, logger: Logger) -> [TransactionOutputs] {
185205

186206
return Bindings.LDKCVec_TransactionOutputsZ_to_array(nativeType: withUnsafePointer(to: self.cOpaqueStruct!) { (this_argPointer: UnsafePointer<LDKChannelMonitor>) in
187207
withUnsafePointer(to: Bindings.array_to_tuple80(array: header)) { (headerPointer: UnsafePointer<(UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8)>) in
188208
ChannelMonitor_best_block_updated(this_argPointer, headerPointer, height, broadcaster.cOpaqueStruct!, fee_estimator.cOpaqueStruct!, logger.cOpaqueStruct!)
189209
}
190-
});
210+
})
211+
.map { (cOpaqueStruct) in
212+
TransactionOutputs(pointer: cOpaqueStruct)
213+
}
214+
;
191215
}
192216

193-
public func get_relevant_txids() -> [LDKTxid] {
217+
public func get_relevant_txids() -> [Txid] {
194218

195219
return Bindings.LDKCVec_TxidZ_to_array(nativeType: withUnsafePointer(to: self.cOpaqueStruct!) { (this_argPointer: UnsafePointer<LDKChannelMonitor>) in
196220
ChannelMonitor_get_relevant_txids(this_argPointer)
197-
});
221+
})
222+
.map { (bytes) in
223+
Bindings.LDKThirtyTwoBytes_to_array(nativeType: bytes)
224+
}
225+
;
198226
}
199227

200228
public func current_best_block() -> BestBlock {

bindings/LDK/structs/Invoice.swift

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,18 +122,26 @@ Invoice_min_final_cltv_expiry(this_argPointer)
122122
};
123123
}
124124

125-
public func private_routes() -> [LDKPrivateRoute] {
125+
public func private_routes() -> [PrivateRoute] {
126126

127127
return Bindings.LDKCVec_PrivateRouteZ_to_array(nativeType: withUnsafePointer(to: self.cOpaqueStruct!) { (this_argPointer: UnsafePointer<LDKInvoice>) in
128128
Invoice_private_routes(this_argPointer)
129-
});
129+
})
130+
.map { (cOpaqueStruct) in
131+
PrivateRoute(pointer: cOpaqueStruct)
132+
}
133+
;
130134
}
131135

132-
public func route_hints() -> [LDKRouteHint] {
136+
public func route_hints() -> [RouteHint] {
133137

134138
return Bindings.LDKCVec_RouteHintZ_to_array(nativeType: withUnsafePointer(to: self.cOpaqueStruct!) { (this_argPointer: UnsafePointer<LDKInvoice>) in
135139
Invoice_route_hints(this_argPointer)
136-
});
140+
})
141+
.map { (cOpaqueStruct) in
142+
RouteHint(pointer: cOpaqueStruct)
143+
}
144+
;
137145
}
138146

139147
public func currency() -> LDKCurrency {

bindings/LDK/structs/RawInvoice.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,11 +127,15 @@ RawInvoice_features(this_argPointer)
127127
});
128128
}
129129

130-
public func private_routes() -> [LDKPrivateRoute] {
130+
public func private_routes() -> [PrivateRoute] {
131131

132132
return Bindings.LDKCVec_PrivateRouteZ_to_array(nativeType: withUnsafePointer(to: self.cOpaqueStruct!) { (this_argPointer: UnsafePointer<LDKRawInvoice>) in
133133
RawInvoice_private_routes(this_argPointer)
134-
});
134+
})
135+
.map { (cOpaqueStruct) in
136+
PrivateRoute(pointer: cOpaqueStruct)
137+
}
138+
;
135139
}
136140

137141
public func amount_pico_btc() -> Option_u64Z {

bindings/LDK/traits/Confirm.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ public class NativelyImplementedConfirm: Confirm {
165165
}
166166

167167
@available(*, deprecated, message: "Use method taking Swift object array type instead.")
168-
internal override func transactions_confirmed(header: [UInt8]?, txdata: [LDKC2Tuple_usizeTransactionZ], height: UInt32) -> Void {
168+
public override func transactions_confirmed(header: [UInt8]?, txdata: [LDKC2Tuple_usizeTransactionZ], height: UInt32) -> Void {
169169

170170

171171
let txdataWrapper = Bindings.new_LDKCVec_C2Tuple_usizeTransactionZZWrapper(array: txdata)

src/conversion_helper.py

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ def prepare_native_to_swift_callback_arguments(cls, argument_types, array_unwrap
347347
'swift_callback_prep': swift_callback_prep}
348348

349349
@classmethod
350-
def prepare_return_value(cls, return_type, is_clone_method=False, is_trait_instantiator=False, is_raw_property_getter=False):
350+
def prepare_return_value(cls, return_type, is_clone_method=False, is_trait_instantiator=False, is_raw_property_getter=False, is_trait_callback=False):
351351
rust_return_type = return_type.rust_obj
352352
return_prefix = ''
353353
return_suffix = ''
@@ -360,8 +360,32 @@ def prepare_return_value(cls, return_type, is_clone_method=False, is_trait_insta
360360
if rust_return_type is not None and rust_return_type.startswith('LDK') and return_type_string.startswith('['):
361361
return_prefix = f'Bindings.{rust_return_type}_to_array(nativeType: '
362362
return_suffix = ')'
363+
map_suffix = ''
363364
if (rust_return_type.startswith('LDKCVec_') or rust_return_type == 'LDKTransaction') and is_raw_property_getter:
364365
return_suffix = ', deallocate: false)'
366+
map_suffix = '.dangle()'
367+
368+
if TypeParsingRegeces.WRAPPER_TYPE_ARRAY_BRACKET_REGEX.search(return_type_string) and not is_trait_callback:
369+
# replace the last [ with [LDK (in case
370+
constructor_type = return_type_string.lstrip('[').rstrip(']')
371+
# native_return_type_string = TypeParsingRegeces.WRAPPER_TYPE_ARRAY_BRACKET_REGEX.sub('[LDK', return_type_string)
372+
# native_return_type_string = return_type_string.replace('LDKResult_', 'LDKCResult_').replace('LDKTuple_', 'LDKCTuple_').replace('LDKVec_', 'LDKCVec_')
373+
374+
if constructor_type == 'Txid':
375+
return_suffix += f'''
376+
.map {{ (bytes) in
377+
Bindings.LDKThirtyTwoBytes_to_array(nativeType: bytes)
378+
}}
379+
'''
380+
else:
381+
return_suffix += f'''
382+
.map {{ (cOpaqueStruct) in
383+
{constructor_type}(pointer: cOpaqueStruct){map_suffix}
384+
}}
385+
'''
386+
387+
388+
365389
elif return_type.swift_raw_type.startswith('(UInt8'):
366390
# TODO: get array length
367391
array_length = return_type.arr_len
@@ -394,7 +418,7 @@ def prepare_return_value(cls, return_type, is_clone_method=False, is_trait_insta
394418
return_suffix = '.pointee)'
395419
pass
396420

397-
if TypeParsingRegeces.WRAPPER_TYPE_ARRAY_BRACKET_REGEX.search(return_type_string):
421+
if TypeParsingRegeces.WRAPPER_TYPE_ARRAY_BRACKET_REGEX.search(return_type_string) and is_trait_callback:
398422
# replace the last [ with [LDK (in case
399423
return_type_string = TypeParsingRegeces.WRAPPER_TYPE_ARRAY_BRACKET_REGEX.sub('[LDK', return_type_string)
400424
return_type_string = return_type_string.replace('LDKResult_', 'LDKCResult_').replace('LDKTuple_', 'LDKCTuple_').replace('LDKVec_', 'LDKCVec_')

0 commit comments

Comments
 (0)