Skip to content

Commit 4ca440b

Browse files
author
Tarik Eshaq
authored
Cuts v90 for rust-components-swift (#34)
* Upgrades Package.swift * Version 90.0.0 * remove protobuf from CI and package.swift
1 parent fd708cf commit 4ca440b

File tree

28 files changed

+3155
-2438
lines changed

28 files changed

+3155
-2438
lines changed

.github/workflows/update-as.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,6 @@ jobs:
6262
if: env.ALREADY_CREATED == 'false'
6363
run: |
6464
brew install swiftformat
65-
brew install protobuf
66-
brew install swift-protobuf
6765
# We strip away the `v` in the AS Version and run the make_tag
6866
# script, which will generate all the code that needs to be generated
6967
# Note that the tag argument isn't useful here, since we will

Package.swift

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// swift-tools-version:5.4
22
import PackageDescription
33

4-
let checksum = "f23a1eb4bcb2d5493c4a5d445bf35af41b1a78f201f539edaed4cc2ca990a8f6"
5-
let version = "v87.2.0"
4+
let checksum = "397f09236f031fe614bfdbc5ba4b8953bfd98e1df640e442962a5d7e2b96d006"
5+
let version = "v90.0.0"
66
let url = "https://github.com/mozilla/application-services/releases/download/\(version)/MozillaRustComponents.xcframework.zip"
77

88
let package = Package(
@@ -24,7 +24,6 @@ let package = Package(
2424
// TODO: ship Glean via this same bundle?
2525
.package(name: "Glean", url: "https://github.com/mozilla/glean-swift", from: "43.0.2"),
2626
.package(name: "SwiftKeychainWrapper", url: "https://github.com/jrendel/SwiftKeychainWrapper", from: "4.0.1"),
27-
.package(name: "SwiftProtobuf", url: "https://github.com/apple/swift-protobuf", from: "1.18.0")
2827
],
2928
targets: [
3029
/*
@@ -104,7 +103,7 @@ let package = Package(
104103
),
105104
.target(
106105
name: "Places",
107-
dependencies: ["MozillaRustComponentsWrapper", "Sync15", "SwiftProtobuf"],
106+
dependencies: ["MozillaRustComponentsWrapper", "Sync15"],
108107
path: "generated/places"
109108
)
110109
]

generate.sh

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,6 @@ rm -rf "$PLACES_DIR" && mkdir -p "$PLACES_DIR"
122122
# UniFFI bindings.
123123
"${UNIFFI_BINDGEN[@]}" generate -l swift -o "$PLACES_DIR/Generated" "$APP_SERVICES_DIR/components/places/src/places.udl"
124124

125-
## We need to build the protobuf files and copy them over to the places generated section
126-
protoc --proto_path="$APP_SERVICES_DIR/components/places/src" --swift_out="$PLACES_DIR/Generated" "places_msg_types.proto"
127-
128125
# Copy the hand-written Swift, since it all needs to be together in one directory.
129126
cp -r "$APP_SERVICES_DIR/components/places/ios/Places" "$PLACES_DIR/Places"
130127

generated/autofill/Generated/autofill.swift

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ private extension RustBuffer {
1919
}
2020

2121
static func from(_ ptr: UnsafeBufferPointer<UInt8>) -> RustBuffer {
22-
try! rustCall { ffi_autofill_b5da_rustbuffer_from_bytes(ForeignBytes(bufferPointer: ptr), $0) }
22+
try! rustCall { ffi_autofill_8c34_rustbuffer_from_bytes(ForeignBytes(bufferPointer: ptr), $0) }
2323
}
2424

2525
// Frees the buffer in place.
2626
// The buffer must not be used after this is called.
2727
func deallocate() {
28-
try! rustCall { ffi_autofill_b5da_rustbuffer_free(self, $0) }
28+
try! rustCall { ffi_autofill_8c34_rustbuffer_free(self, $0) }
2929
}
3030
}
3131

@@ -385,7 +385,7 @@ public func createKey() throws -> String {
385385
let _retval = try
386386

387387
rustCallWithError(AutofillError.self) {
388-
autofill_b5da_create_key($0)
388+
autofill_8c34_create_key($0)
389389
}
390390
return try String.lift(_retval)
391391
}
@@ -394,7 +394,7 @@ public func encryptString(key: String, cleartext: String) throws -> String {
394394
let _retval = try
395395

396396
rustCallWithError(AutofillError.self) {
397-
autofill_b5da_encrypt_string(key.lower(), cleartext.lower(), $0)
397+
autofill_8c34_encrypt_string(key.lower(), cleartext.lower(), $0)
398398
}
399399
return try String.lift(_retval)
400400
}
@@ -403,7 +403,7 @@ public func decryptString(key: String, ciphertext: String) throws -> String {
403403
let _retval = try
404404

405405
rustCallWithError(AutofillError.self) {
406-
autofill_b5da_decrypt_string(key.lower(), ciphertext.lower(), $0)
406+
autofill_8c34_decrypt_string(key.lower(), ciphertext.lower(), $0)
407407
}
408408
return try String.lift(_retval)
409409
}
@@ -439,117 +439,117 @@ public class Store: StoreProtocol {
439439
self.init(unsafeFromRawPointer: try
440440

441441
rustCallWithError(AutofillError.self) {
442-
autofill_b5da_Store_new(dbpath.lower(), $0)
442+
autofill_8c34_Store_new(dbpath.lower(), $0)
443443
})
444444
}
445445

446446
deinit {
447-
try! rustCall { ffi_autofill_b5da_Store_object_free(pointer, $0) }
447+
try! rustCall { ffi_autofill_8c34_Store_object_free(pointer, $0) }
448448
}
449449

450450
public func addCreditCard(cc: UpdatableCreditCardFields) throws -> CreditCard {
451451
let _retval = try
452452
rustCallWithError(AutofillError.self) {
453-
autofill_b5da_Store_add_credit_card(self.pointer, cc.lower(), $0)
453+
autofill_8c34_Store_add_credit_card(self.pointer, cc.lower(), $0)
454454
}
455455
return try CreditCard.lift(_retval)
456456
}
457457

458458
public func getCreditCard(guid: String) throws -> CreditCard {
459459
let _retval = try
460460
rustCallWithError(AutofillError.self) {
461-
autofill_b5da_Store_get_credit_card(self.pointer, guid.lower(), $0)
461+
autofill_8c34_Store_get_credit_card(self.pointer, guid.lower(), $0)
462462
}
463463
return try CreditCard.lift(_retval)
464464
}
465465

466466
public func getAllCreditCards() throws -> [CreditCard] {
467467
let _retval = try
468468
rustCallWithError(AutofillError.self) {
469-
autofill_b5da_Store_get_all_credit_cards(self.pointer, $0)
469+
autofill_8c34_Store_get_all_credit_cards(self.pointer, $0)
470470
}
471471
return try FfiConverterSequenceRecordCreditCard.lift(_retval)
472472
}
473473

474474
public func updateCreditCard(guid: String, cc: UpdatableCreditCardFields) throws {
475475
try
476476
rustCallWithError(AutofillError.self) {
477-
autofill_b5da_Store_update_credit_card(self.pointer, guid.lower(), cc.lower(), $0)
477+
autofill_8c34_Store_update_credit_card(self.pointer, guid.lower(), cc.lower(), $0)
478478
}
479479
}
480480

481481
public func deleteCreditCard(guid: String) throws -> Bool {
482482
let _retval = try
483483
rustCallWithError(AutofillError.self) {
484-
autofill_b5da_Store_delete_credit_card(self.pointer, guid.lower(), $0)
484+
autofill_8c34_Store_delete_credit_card(self.pointer, guid.lower(), $0)
485485
}
486486
return try Bool.lift(_retval)
487487
}
488488

489489
public func touchCreditCard(guid: String) throws {
490490
try
491491
rustCallWithError(AutofillError.self) {
492-
autofill_b5da_Store_touch_credit_card(self.pointer, guid.lower(), $0)
492+
autofill_8c34_Store_touch_credit_card(self.pointer, guid.lower(), $0)
493493
}
494494
}
495495

496496
public func addAddress(a: UpdatableAddressFields) throws -> Address {
497497
let _retval = try
498498
rustCallWithError(AutofillError.self) {
499-
autofill_b5da_Store_add_address(self.pointer, a.lower(), $0)
499+
autofill_8c34_Store_add_address(self.pointer, a.lower(), $0)
500500
}
501501
return try Address.lift(_retval)
502502
}
503503

504504
public func getAddress(guid: String) throws -> Address {
505505
let _retval = try
506506
rustCallWithError(AutofillError.self) {
507-
autofill_b5da_Store_get_address(self.pointer, guid.lower(), $0)
507+
autofill_8c34_Store_get_address(self.pointer, guid.lower(), $0)
508508
}
509509
return try Address.lift(_retval)
510510
}
511511

512512
public func getAllAddresses() throws -> [Address] {
513513
let _retval = try
514514
rustCallWithError(AutofillError.self) {
515-
autofill_b5da_Store_get_all_addresses(self.pointer, $0)
515+
autofill_8c34_Store_get_all_addresses(self.pointer, $0)
516516
}
517517
return try FfiConverterSequenceRecordAddress.lift(_retval)
518518
}
519519

520520
public func updateAddress(guid: String, a: UpdatableAddressFields) throws {
521521
try
522522
rustCallWithError(AutofillError.self) {
523-
autofill_b5da_Store_update_address(self.pointer, guid.lower(), a.lower(), $0)
523+
autofill_8c34_Store_update_address(self.pointer, guid.lower(), a.lower(), $0)
524524
}
525525
}
526526

527527
public func deleteAddress(guid: String) throws -> Bool {
528528
let _retval = try
529529
rustCallWithError(AutofillError.self) {
530-
autofill_b5da_Store_delete_address(self.pointer, guid.lower(), $0)
530+
autofill_8c34_Store_delete_address(self.pointer, guid.lower(), $0)
531531
}
532532
return try Bool.lift(_retval)
533533
}
534534

535535
public func touchAddress(guid: String) throws {
536536
try
537537
rustCallWithError(AutofillError.self) {
538-
autofill_b5da_Store_touch_address(self.pointer, guid.lower(), $0)
538+
autofill_8c34_Store_touch_address(self.pointer, guid.lower(), $0)
539539
}
540540
}
541541

542542
public func scrubEncryptedData() throws {
543543
try
544544
rustCallWithError(AutofillError.self) {
545-
autofill_b5da_Store_scrub_encrypted_data(self.pointer, $0)
545+
autofill_8c34_Store_scrub_encrypted_data(self.pointer, $0)
546546
}
547547
}
548548

549549
public func registerWithSyncManager() {
550550
try!
551551
rustCall {
552-
autofill_b5da_Store_register_with_sync_manager(self.pointer, $0)
552+
autofill_8c34_Store_register_with_sync_manager(self.pointer, $0)
553553
}
554554
}
555555
}

generated/autofill/Generated/autofillFFI.h

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@
1111
// We ensure they are declared exactly once, with a header guard, UNIFFI_SHARED_H.
1212
#ifdef UNIFFI_SHARED_H
1313
// We also try to prevent mixing versions of shared uniffi header structs.
14-
// If you add anything to the #else block, you must increment the version suffix in UNIFFI_SHARED_HEADER_V3
15-
#ifndef UNIFFI_SHARED_HEADER_V3
14+
// If you add anything to the #else block, you must increment the version suffix in UNIFFI_SHARED_HEADER_V4
15+
#ifndef UNIFFI_SHARED_HEADER_V4
1616
#error Combining helper code from multiple versions of uniffi is not supported
17-
#endif // ndef UNIFFI_SHARED_HEADER_V3
17+
#endif // ndef UNIFFI_SHARED_HEADER_V4
1818
#else
1919
#define UNIFFI_SHARED_H
20-
#define UNIFFI_SHARED_HEADER_V3
20+
#define UNIFFI_SHARED_HEADER_V4
2121
// ⚠️ Attention: If you change this #else block (ending in `#endif // def UNIFFI_SHARED_H`) you *must* ⚠️
22-
// ⚠️ increment the version suffix in all instances of UNIFFI_SHARED_HEADER_V3 in this file. ⚠️
22+
// ⚠️ increment the version suffix in all instances of UNIFFI_SHARED_HEADER_V4 in this file. ⚠️
2323

2424
typedef struct RustBuffer
2525
{
@@ -28,7 +28,7 @@ typedef struct RustBuffer
2828
uint8_t *_Nullable data;
2929
} RustBuffer;
3030

31-
typedef RustBuffer (*ForeignCallback)(uint64_t, int32_t, RustBuffer);
31+
typedef int32_t (*ForeignCallback)(uint64_t, int32_t, RustBuffer, RustBuffer *_Nonnull);
3232

3333
typedef struct ForeignBytes
3434
{
@@ -43,98 +43,98 @@ typedef struct RustCallStatus {
4343
} RustCallStatus;
4444

4545
// ⚠️ Attention: If you change this #else block (ending in `#endif // def UNIFFI_SHARED_H`) you *must* ⚠️
46-
// ⚠️ increment the version suffix in all instances of UNIFFI_SHARED_HEADER_V3 in this file. ⚠️
46+
// ⚠️ increment the version suffix in all instances of UNIFFI_SHARED_HEADER_V4 in this file. ⚠️
4747
#endif // def UNIFFI_SHARED_H
4848

49-
void ffi_autofill_b5da_Store_object_free(
49+
void ffi_autofill_8c34_Store_object_free(
5050
void*_Nonnull ptr,
5151
RustCallStatus *_Nonnull out_status
5252
);
53-
void*_Nonnull autofill_b5da_Store_new(
53+
void*_Nonnull autofill_8c34_Store_new(
5454
RustBuffer dbpath,
5555
RustCallStatus *_Nonnull out_status
5656
);
57-
RustBuffer autofill_b5da_Store_add_credit_card(
57+
RustBuffer autofill_8c34_Store_add_credit_card(
5858
void*_Nonnull ptr,RustBuffer cc,
5959
RustCallStatus *_Nonnull out_status
6060
);
61-
RustBuffer autofill_b5da_Store_get_credit_card(
61+
RustBuffer autofill_8c34_Store_get_credit_card(
6262
void*_Nonnull ptr,RustBuffer guid,
6363
RustCallStatus *_Nonnull out_status
6464
);
65-
RustBuffer autofill_b5da_Store_get_all_credit_cards(
65+
RustBuffer autofill_8c34_Store_get_all_credit_cards(
6666
void*_Nonnull ptr,
6767
RustCallStatus *_Nonnull out_status
6868
);
69-
void autofill_b5da_Store_update_credit_card(
69+
void autofill_8c34_Store_update_credit_card(
7070
void*_Nonnull ptr,RustBuffer guid,RustBuffer cc,
7171
RustCallStatus *_Nonnull out_status
7272
);
73-
int8_t autofill_b5da_Store_delete_credit_card(
73+
int8_t autofill_8c34_Store_delete_credit_card(
7474
void*_Nonnull ptr,RustBuffer guid,
7575
RustCallStatus *_Nonnull out_status
7676
);
77-
void autofill_b5da_Store_touch_credit_card(
77+
void autofill_8c34_Store_touch_credit_card(
7878
void*_Nonnull ptr,RustBuffer guid,
7979
RustCallStatus *_Nonnull out_status
8080
);
81-
RustBuffer autofill_b5da_Store_add_address(
81+
RustBuffer autofill_8c34_Store_add_address(
8282
void*_Nonnull ptr,RustBuffer a,
8383
RustCallStatus *_Nonnull out_status
8484
);
85-
RustBuffer autofill_b5da_Store_get_address(
85+
RustBuffer autofill_8c34_Store_get_address(
8686
void*_Nonnull ptr,RustBuffer guid,
8787
RustCallStatus *_Nonnull out_status
8888
);
89-
RustBuffer autofill_b5da_Store_get_all_addresses(
89+
RustBuffer autofill_8c34_Store_get_all_addresses(
9090
void*_Nonnull ptr,
9191
RustCallStatus *_Nonnull out_status
9292
);
93-
void autofill_b5da_Store_update_address(
93+
void autofill_8c34_Store_update_address(
9494
void*_Nonnull ptr,RustBuffer guid,RustBuffer a,
9595
RustCallStatus *_Nonnull out_status
9696
);
97-
int8_t autofill_b5da_Store_delete_address(
97+
int8_t autofill_8c34_Store_delete_address(
9898
void*_Nonnull ptr,RustBuffer guid,
9999
RustCallStatus *_Nonnull out_status
100100
);
101-
void autofill_b5da_Store_touch_address(
101+
void autofill_8c34_Store_touch_address(
102102
void*_Nonnull ptr,RustBuffer guid,
103103
RustCallStatus *_Nonnull out_status
104104
);
105-
void autofill_b5da_Store_scrub_encrypted_data(
105+
void autofill_8c34_Store_scrub_encrypted_data(
106106
void*_Nonnull ptr,
107107
RustCallStatus *_Nonnull out_status
108108
);
109-
void autofill_b5da_Store_register_with_sync_manager(
109+
void autofill_8c34_Store_register_with_sync_manager(
110110
void*_Nonnull ptr,
111111
RustCallStatus *_Nonnull out_status
112112
);
113-
RustBuffer autofill_b5da_create_key(
113+
RustBuffer autofill_8c34_create_key(
114114

115115
RustCallStatus *_Nonnull out_status
116116
);
117-
RustBuffer autofill_b5da_encrypt_string(
117+
RustBuffer autofill_8c34_encrypt_string(
118118
RustBuffer key,RustBuffer cleartext,
119119
RustCallStatus *_Nonnull out_status
120120
);
121-
RustBuffer autofill_b5da_decrypt_string(
121+
RustBuffer autofill_8c34_decrypt_string(
122122
RustBuffer key,RustBuffer ciphertext,
123123
RustCallStatus *_Nonnull out_status
124124
);
125-
RustBuffer ffi_autofill_b5da_rustbuffer_alloc(
125+
RustBuffer ffi_autofill_8c34_rustbuffer_alloc(
126126
int32_t size,
127127
RustCallStatus *_Nonnull out_status
128128
);
129-
RustBuffer ffi_autofill_b5da_rustbuffer_from_bytes(
129+
RustBuffer ffi_autofill_8c34_rustbuffer_from_bytes(
130130
ForeignBytes bytes,
131131
RustCallStatus *_Nonnull out_status
132132
);
133-
void ffi_autofill_b5da_rustbuffer_free(
133+
void ffi_autofill_8c34_rustbuffer_free(
134134
RustBuffer buf,
135135
RustCallStatus *_Nonnull out_status
136136
);
137-
RustBuffer ffi_autofill_b5da_rustbuffer_reserve(
137+
RustBuffer ffi_autofill_8c34_rustbuffer_reserve(
138138
RustBuffer buf,int32_t additional,
139139
RustCallStatus *_Nonnull out_status
140140
);

0 commit comments

Comments
 (0)