Skip to content

Commit b020417

Browse files
committed
Make traits' array paremeters internal for C structs
1 parent 19581e1 commit b020417

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

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-
public override func transactions_confirmed(header: [UInt8]?, txdata: [LDKC2Tuple_usizeTransactionZ], height: UInt32) -> Void {
168+
internal 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/generators/opaque_struct_generator.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,12 @@ def generate_opaque_struct(self, struct_name, struct_details, all_type_details={
5555
cloneability_type_message = '; '.join(cloneability_types)
5656
print(f'(opaque_struct_generator.py#constructor, warned, deprecated) {cloneability_warning}: {constructor_native_name} [{cloneability_type_message}]')
5757

58+
5859
mutating_output_file_contents = mutating_output_file_contents.replace('public init', f'{deprecation_prefix}public init')
60+
61+
if constructor_prepared_arguments['has_unwrapped_arrays']:
62+
mutating_output_file_contents = mutating_output_file_contents.replace('public init(swift_constructor_arguments)', 'internal init(swift_constructor_arguments)')
63+
5964
mutating_output_file_contents = mutating_output_file_contents.replace('swift_constructor_arguments', ', '.join(constructor_swift_arguments))
6065
mutating_output_file_contents = mutating_output_file_contents.replace('OpaqueStructType(native_constructor_arguments)', constructor_native_call_prefix + 'OpaqueStructType(' + ', '.join(
6166
constructor_native_arguments) + ')' + constructor_native_call_suffix)
@@ -64,8 +69,6 @@ def generate_opaque_struct(self, struct_name, struct_details, all_type_details={
6469
mutating_output_file_contents = mutating_output_file_contents.replace('OpaqueStructType(', f'{constructor_native_name}(')
6570

6671
if constructor_prepared_arguments['has_unwrapped_arrays']:
67-
# only replace the default init, don't replace the others
68-
mutating_output_file_contents = mutating_output_file_contents.replace('public init', f'internal init', 1)
6972

7073
prepared_arguments = ConversionHelper.prepare_swift_to_native_arguments(constructor_details['argument_types'], array_unwrapping_preparation_only=True)
7174
current_addition = method_template

src/generators/trait_generator.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,9 @@ def generate_trait(self, struct_name, struct_details):
253253
current_default_callback_replacement = natively_implemented_callback_template
254254
current_default_callback_replacement = current_default_callback_replacement.replace('public_swift_argument_list', public_swift_argument_list)
255255
current_default_callback_replacement = current_default_callback_replacement.replace('-> Void {', f'-> {swift_return_type} {{')
256+
if default_callback_prepared_arguments['has_unwrapped_arrays']:
257+
current_default_callback_replacement = current_default_callback_replacement.replace('public override func', 'internal override func')
258+
256259
current_default_callback_replacement = current_default_callback_replacement.replace('func methodName(', f'func {current_lambda_name}(')
257260
default_native_call_arguments = default_callback_prepared_arguments['native_arguments']
258261

0 commit comments

Comments
 (0)