Skip to content

Commit 13b9117

Browse files
committed
fix: script and value or container
1 parent 40ac87f commit 13b9117

File tree

5 files changed

+220
-16
lines changed

5 files changed

+220
-16
lines changed

Sources/Loro/LoroFFI.swift

Lines changed: 200 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@ fileprivate struct FfiConverterData: FfiConverterRustBuffer {
537537

538538

539539

540-
public protocol ContainerIdLike : Any {
540+
public protocol ContainerIdLike: Any {
541541

542542
func asContainerId(ty: ContainerType) -> ContainerId
543543

@@ -4094,7 +4094,7 @@ public func FfiConverterTypeLoroUnknown_lower(_ value: LoroUnknown) -> UnsafeMut
40944094

40954095

40964096

4097-
public protocol LoroValueLike : Any {
4097+
public protocol LoroValueLike: Any {
40984098

40994099
func asLoroValue() -> LoroValue
41004100

@@ -4968,6 +4968,18 @@ public protocol ValueOrContainerProtocol : AnyObject {
49684968

49694969
func asContainer() -> ContainerId?
49704970

4971+
func asLoroCounter() -> LoroCounter?
4972+
4973+
func asLoroList() -> LoroList?
4974+
4975+
func asLoroMap() -> LoroMap?
4976+
4977+
func asLoroMovableList() -> LoroMovableList?
4978+
4979+
func asLoroText() -> LoroText?
4980+
4981+
func asLoroTree() -> LoroTree?
4982+
49714983
func asValue() -> LoroValue?
49724984

49734985
func isContainer() -> Bool
@@ -5024,6 +5036,48 @@ open func asContainer() -> ContainerId? {
50245036
})
50255037
}
50265038

5039+
open func asLoroCounter() -> LoroCounter? {
5040+
return try! FfiConverterOptionTypeLoroCounter.lift(try! rustCall() {
5041+
uniffi_loro_fn_method_valueorcontainer_as_loro_counter(self.uniffiClonePointer(),$0
5042+
)
5043+
})
5044+
}
5045+
5046+
open func asLoroList() -> LoroList? {
5047+
return try! FfiConverterOptionTypeLoroList.lift(try! rustCall() {
5048+
uniffi_loro_fn_method_valueorcontainer_as_loro_list(self.uniffiClonePointer(),$0
5049+
)
5050+
})
5051+
}
5052+
5053+
open func asLoroMap() -> LoroMap? {
5054+
return try! FfiConverterOptionTypeLoroMap.lift(try! rustCall() {
5055+
uniffi_loro_fn_method_valueorcontainer_as_loro_map(self.uniffiClonePointer(),$0
5056+
)
5057+
})
5058+
}
5059+
5060+
open func asLoroMovableList() -> LoroMovableList? {
5061+
return try! FfiConverterOptionTypeLoroMovableList.lift(try! rustCall() {
5062+
uniffi_loro_fn_method_valueorcontainer_as_loro_movable_list(self.uniffiClonePointer(),$0
5063+
)
5064+
})
5065+
}
5066+
5067+
open func asLoroText() -> LoroText? {
5068+
return try! FfiConverterOptionTypeLoroText.lift(try! rustCall() {
5069+
uniffi_loro_fn_method_valueorcontainer_as_loro_text(self.uniffiClonePointer(),$0
5070+
)
5071+
})
5072+
}
5073+
5074+
open func asLoroTree() -> LoroTree? {
5075+
return try! FfiConverterOptionTypeLoroTree.lift(try! rustCall() {
5076+
uniffi_loro_fn_method_valueorcontainer_as_loro_tree(self.uniffiClonePointer(),$0
5077+
)
5078+
})
5079+
}
5080+
50275081
open func asValue() -> LoroValue? {
50285082
return try! FfiConverterOptionTypeLoroValue.lift(try! rustCall() {
50295083
uniffi_loro_fn_method_valueorcontainer_as_value(self.uniffiClonePointer(),$0
@@ -7112,6 +7166,132 @@ fileprivate struct FfiConverterOptionTypeCursor: FfiConverterRustBuffer {
71127166
}
71137167
}
71147168

7169+
fileprivate struct FfiConverterOptionTypeLoroCounter: FfiConverterRustBuffer {
7170+
typealias SwiftType = LoroCounter?
7171+
7172+
public static func write(_ value: SwiftType, into buf: inout [UInt8]) {
7173+
guard let value = value else {
7174+
writeInt(&buf, Int8(0))
7175+
return
7176+
}
7177+
writeInt(&buf, Int8(1))
7178+
FfiConverterTypeLoroCounter.write(value, into: &buf)
7179+
}
7180+
7181+
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType {
7182+
switch try readInt(&buf) as Int8 {
7183+
case 0: return nil
7184+
case 1: return try FfiConverterTypeLoroCounter.read(from: &buf)
7185+
default: throw UniffiInternalError.unexpectedOptionalTag
7186+
}
7187+
}
7188+
}
7189+
7190+
fileprivate struct FfiConverterOptionTypeLoroList: FfiConverterRustBuffer {
7191+
typealias SwiftType = LoroList?
7192+
7193+
public static func write(_ value: SwiftType, into buf: inout [UInt8]) {
7194+
guard let value = value else {
7195+
writeInt(&buf, Int8(0))
7196+
return
7197+
}
7198+
writeInt(&buf, Int8(1))
7199+
FfiConverterTypeLoroList.write(value, into: &buf)
7200+
}
7201+
7202+
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType {
7203+
switch try readInt(&buf) as Int8 {
7204+
case 0: return nil
7205+
case 1: return try FfiConverterTypeLoroList.read(from: &buf)
7206+
default: throw UniffiInternalError.unexpectedOptionalTag
7207+
}
7208+
}
7209+
}
7210+
7211+
fileprivate struct FfiConverterOptionTypeLoroMap: FfiConverterRustBuffer {
7212+
typealias SwiftType = LoroMap?
7213+
7214+
public static func write(_ value: SwiftType, into buf: inout [UInt8]) {
7215+
guard let value = value else {
7216+
writeInt(&buf, Int8(0))
7217+
return
7218+
}
7219+
writeInt(&buf, Int8(1))
7220+
FfiConverterTypeLoroMap.write(value, into: &buf)
7221+
}
7222+
7223+
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType {
7224+
switch try readInt(&buf) as Int8 {
7225+
case 0: return nil
7226+
case 1: return try FfiConverterTypeLoroMap.read(from: &buf)
7227+
default: throw UniffiInternalError.unexpectedOptionalTag
7228+
}
7229+
}
7230+
}
7231+
7232+
fileprivate struct FfiConverterOptionTypeLoroMovableList: FfiConverterRustBuffer {
7233+
typealias SwiftType = LoroMovableList?
7234+
7235+
public static func write(_ value: SwiftType, into buf: inout [UInt8]) {
7236+
guard let value = value else {
7237+
writeInt(&buf, Int8(0))
7238+
return
7239+
}
7240+
writeInt(&buf, Int8(1))
7241+
FfiConverterTypeLoroMovableList.write(value, into: &buf)
7242+
}
7243+
7244+
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType {
7245+
switch try readInt(&buf) as Int8 {
7246+
case 0: return nil
7247+
case 1: return try FfiConverterTypeLoroMovableList.read(from: &buf)
7248+
default: throw UniffiInternalError.unexpectedOptionalTag
7249+
}
7250+
}
7251+
}
7252+
7253+
fileprivate struct FfiConverterOptionTypeLoroText: FfiConverterRustBuffer {
7254+
typealias SwiftType = LoroText?
7255+
7256+
public static func write(_ value: SwiftType, into buf: inout [UInt8]) {
7257+
guard let value = value else {
7258+
writeInt(&buf, Int8(0))
7259+
return
7260+
}
7261+
writeInt(&buf, Int8(1))
7262+
FfiConverterTypeLoroText.write(value, into: &buf)
7263+
}
7264+
7265+
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType {
7266+
switch try readInt(&buf) as Int8 {
7267+
case 0: return nil
7268+
case 1: return try FfiConverterTypeLoroText.read(from: &buf)
7269+
default: throw UniffiInternalError.unexpectedOptionalTag
7270+
}
7271+
}
7272+
}
7273+
7274+
fileprivate struct FfiConverterOptionTypeLoroTree: FfiConverterRustBuffer {
7275+
typealias SwiftType = LoroTree?
7276+
7277+
public static func write(_ value: SwiftType, into buf: inout [UInt8]) {
7278+
guard let value = value else {
7279+
writeInt(&buf, Int8(0))
7280+
return
7281+
}
7282+
writeInt(&buf, Int8(1))
7283+
FfiConverterTypeLoroTree.write(value, into: &buf)
7284+
}
7285+
7286+
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType {
7287+
switch try readInt(&buf) as Int8 {
7288+
case 0: return nil
7289+
case 1: return try FfiConverterTypeLoroTree.read(from: &buf)
7290+
default: throw UniffiInternalError.unexpectedOptionalTag
7291+
}
7292+
}
7293+
}
7294+
71157295
fileprivate struct FfiConverterOptionTypeOnPop: FfiConverterRustBuffer {
71167296
typealias SwiftType = OnPop?
71177297

@@ -8137,6 +8317,24 @@ private var initializationResult: InitializationResult = {
81378317
if (uniffi_loro_checksum_method_valueorcontainer_as_container() != 61163) {
81388318
return InitializationResult.apiChecksumMismatch
81398319
}
8320+
if (uniffi_loro_checksum_method_valueorcontainer_as_loro_counter() != 51072) {
8321+
return InitializationResult.apiChecksumMismatch
8322+
}
8323+
if (uniffi_loro_checksum_method_valueorcontainer_as_loro_list() != 16144) {
8324+
return InitializationResult.apiChecksumMismatch
8325+
}
8326+
if (uniffi_loro_checksum_method_valueorcontainer_as_loro_map() != 62391) {
8327+
return InitializationResult.apiChecksumMismatch
8328+
}
8329+
if (uniffi_loro_checksum_method_valueorcontainer_as_loro_movable_list() != 49359) {
8330+
return InitializationResult.apiChecksumMismatch
8331+
}
8332+
if (uniffi_loro_checksum_method_valueorcontainer_as_loro_text() != 8015) {
8333+
return InitializationResult.apiChecksumMismatch
8334+
}
8335+
if (uniffi_loro_checksum_method_valueorcontainer_as_loro_tree() != 39545) {
8336+
return InitializationResult.apiChecksumMismatch
8337+
}
81408338
if (uniffi_loro_checksum_method_valueorcontainer_as_value() != 9638) {
81418339
return InitializationResult.apiChecksumMismatch
81428340
}

loro-rs/Cargo.lock

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

loro-rs/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ path = "src/uniffi-bindgen.rs"
1515

1616
[dependencies]
1717
# loro-ffi = { path = "../../loro/crates/loro-ffi" }
18-
loro-ffi = { git = "https://github.com/loro-dev/loro.git", rev = "832bc6581b21efc2e6c7b46d2e3c78f85a128257" }
18+
loro-ffi = { git = "https://github.com/loro-dev/loro.git", rev = "a9f669d173807b80dde7ffef7f467c8a57fc5b1f" }
1919
uniffi = { version = "0.28" }
2020

2121
[build-dependencies]

loro-rs/src/loro.udl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ interface ValueOrContainer{
1010
boolean is_container();
1111
LoroValue? as_value();
1212
ContainerID? as_container();
13+
LoroText? as_loro_text();
14+
LoroList? as_loro_list();
15+
LoroMap? as_loro_map();
16+
LoroTree? as_loro_tree();
17+
LoroCounter? as_loro_counter();
18+
LoroMovableList? as_loro_movable_list();
1319
};
1420

1521
[Trait, WithForeign]

scripts/refine_trait.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ THIS_SCRIPT_DIR="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
55
SWIFT_FOLDER="$THIS_SCRIPT_DIR/../gen-swift"
66
file_path="$SWIFT_FOLDER/loro.swift"
77

8-
search_string="public protocol LoroValueLike : AnyObject {"
9-
replace_string="public protocol LoroValueLike : Any {"
8+
search_string="public protocol LoroValueLike[[:space:]]*:[[:space:]]*AnyObject {"
9+
replace_string="public protocol LoroValueLike: Any {"
1010

1111

12-
sed -i '' "s|$search_string|$replace_string|g" "$file_path"
12+
sed -i '' "s/$search_string/$replace_string/g" "$file_path"
1313

14-
search_string="public protocol ContainerIdLike : AnyObject {"
15-
replace_string="public protocol ContainerIdLike : Any {"
14+
search_string="public protocol ContainerIdLike[[:space:]]*:[[:space:]]*AnyObject {"
15+
replace_string="public protocol ContainerIdLike: Any {"
1616

17-
sed -i '' "s|$search_string|$replace_string|g" "$file_path"
17+
sed -i '' "s/$search_string/$replace_string/g" "$file_path"

0 commit comments

Comments
 (0)