y-rb 0.5.2-x64-mingw-ucrt → 0.5.3-x64-mingw-ucrt
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/yrb/Cargo.toml +8 -8
- data/ext/yrb/src/lib.rs +11 -11
- data/ext/yrb/src/utils.rs +30 -2
- data/ext/yrb/src/yany.rs +11 -10
- data/ext/yrb/src/yarray.rs +8 -6
- data/ext/yrb/src/ymap.rs +5 -4
- data/ext/yrb/src/yvalue.rs +25 -22
- data/ext/yrb/src/yxml_element.rs +16 -16
- data/ext/yrb/src/yxml_fragment.rs +13 -13
- data/ext/yrb/src/yxml_text.rs +10 -10
- data/lib/3.1/yrb.so +0 -0
- data/lib/3.2/yrb.so +0 -0
- data/lib/y/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7ddc46c1292b5d7fbe597a5ae623c32f6917aae909e1d2e34b447cc452d0eff8
|
4
|
+
data.tar.gz: b2a5902c89aadd5d3ebb5fda5be24f51e9185fd366fc5104bf4cecd010988aee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b88834c3ce6763b1984360f28fbc5e4b96d9a74628b3dd8db41767b8fa21e2a8a666f9cc49110fdb0703f3b05f10abe3bf311cc16794087a1bbe10eddbb867ba
|
7
|
+
data.tar.gz: bccc0c328ca21ecabea95f3bcbf3d312bcf5863f8f67e3ccaf7d06389e758eb6e2757a998a51a0d08097c15c9956cd3be93f4979c026b80500c739599228a8cb
|
data/ext/yrb/Cargo.toml
CHANGED
@@ -1,21 +1,21 @@
|
|
1
1
|
[package]
|
2
2
|
name = "yrb"
|
3
|
-
version = "0.5.
|
4
|
-
authors = ["Hannes Moser <box@hannesmoser.at>"
|
3
|
+
version = "0.5.3"
|
4
|
+
authors = ["Hannes Moser <box@hannesmoser.at>"]
|
5
5
|
edition = "2021"
|
6
6
|
homepage = "https://github.com/y-crdt/yrb"
|
7
7
|
repository = "https://github.com/y-crdt/yrb"
|
8
8
|
|
9
9
|
[dependencies]
|
10
|
-
lib0 = "0.16.
|
11
|
-
magnus = "0.
|
12
|
-
thiserror = "1.0.
|
13
|
-
yrs = "=0.16.
|
10
|
+
lib0 = "0.16.10" # must match yrs version
|
11
|
+
magnus = "0.6.2"
|
12
|
+
thiserror = "1.0.50"
|
13
|
+
yrs = "=0.16.10"
|
14
14
|
y-sync = "=0.3.1"
|
15
|
-
rb-sys = "0.9.
|
15
|
+
rb-sys = "0.9.82"
|
16
16
|
|
17
17
|
[dev-dependencies]
|
18
|
-
magnus = { version = "0.
|
18
|
+
magnus = { version = "0.6.2", features = ["embed"] }
|
19
19
|
|
20
20
|
[lib]
|
21
21
|
name = "yrb"
|
data/ext/yrb/src/lib.rs
CHANGED
@@ -9,7 +9,7 @@ use crate::ytransaction::YTransaction;
|
|
9
9
|
use crate::yxml_element::YXmlElement;
|
10
10
|
use crate::yxml_fragment::YXmlFragment;
|
11
11
|
use crate::yxml_text::YXmlText;
|
12
|
-
use magnus::{define_module, function, method, Error, Module, Object};
|
12
|
+
use magnus::{class, define_module, function, method, Error, Module, Object};
|
13
13
|
|
14
14
|
mod utils;
|
15
15
|
mod yany;
|
@@ -30,7 +30,7 @@ fn init() -> Result<(), Error> {
|
|
30
30
|
let module = define_module("Y").expect("cannot define ::Y module");
|
31
31
|
|
32
32
|
let yarray = module
|
33
|
-
.define_class("Array",
|
33
|
+
.define_class("Array", class::object())
|
34
34
|
.expect("cannot find class Y::Array");
|
35
35
|
|
36
36
|
yarray
|
@@ -77,7 +77,7 @@ fn init() -> Result<(), Error> {
|
|
77
77
|
.expect("cannot define private method: yarray_unobserve");
|
78
78
|
|
79
79
|
let ydoc = module
|
80
|
-
.define_class("Doc",
|
80
|
+
.define_class("Doc", class::object())
|
81
81
|
.expect("cannot define class Y::Doc");
|
82
82
|
ydoc.define_singleton_method("new", function!(YDoc::ydoc_new, -1))
|
83
83
|
.expect("cannot define singleton method: ydoc_new");
|
@@ -122,7 +122,7 @@ fn init() -> Result<(), Error> {
|
|
122
122
|
.expect("cannot define private method: ydoc_observe_update");
|
123
123
|
|
124
124
|
let ymap = module
|
125
|
-
.define_class("Map",
|
125
|
+
.define_class("Map", class::object())
|
126
126
|
.expect("cannot define class Y::Map");
|
127
127
|
|
128
128
|
ymap.define_private_method("ymap_clear", method!(YMap::ymap_clear, 1))
|
@@ -147,7 +147,7 @@ fn init() -> Result<(), Error> {
|
|
147
147
|
.expect("cannot define private method: ymap_unobserve");
|
148
148
|
|
149
149
|
let ytransaction = module
|
150
|
-
.define_class("Transaction",
|
150
|
+
.define_class("Transaction", class::object())
|
151
151
|
.expect("cannot define class Y::Transaction");
|
152
152
|
|
153
153
|
ytransaction
|
@@ -221,7 +221,7 @@ fn init() -> Result<(), Error> {
|
|
221
221
|
.expect("cannot define private method: ytransaction_state_vector_v2");
|
222
222
|
|
223
223
|
let ytext = module
|
224
|
-
.define_class("Text",
|
224
|
+
.define_class("Text", class::object())
|
225
225
|
.expect("cannot define class Y::Text");
|
226
226
|
|
227
227
|
ytext
|
@@ -265,7 +265,7 @@ fn init() -> Result<(), Error> {
|
|
265
265
|
.expect("cannot define private method: ytext_unobserve");
|
266
266
|
|
267
267
|
let yxml_element = module
|
268
|
-
.define_class("XMLElement",
|
268
|
+
.define_class("XMLElement", class::object())
|
269
269
|
.expect("cannot define class Y::XMLElement");
|
270
270
|
|
271
271
|
yxml_element
|
@@ -408,7 +408,7 @@ fn init() -> Result<(), Error> {
|
|
408
408
|
.expect("cannot define private method: yxml_element_unobserve");
|
409
409
|
|
410
410
|
let yxml_fragment = module
|
411
|
-
.define_class("XMLFragment",
|
411
|
+
.define_class("XMLFragment", class::object())
|
412
412
|
.expect("cannot define class: Y::XMLFragment");
|
413
413
|
|
414
414
|
yxml_fragment
|
@@ -473,7 +473,7 @@ fn init() -> Result<(), Error> {
|
|
473
473
|
.expect("cannot define private method: yxml_fragment_to_s");
|
474
474
|
|
475
475
|
let yxml_text = module
|
476
|
-
.define_class("XMLText",
|
476
|
+
.define_class("XMLText", class::object())
|
477
477
|
.expect("cannot define class Y::XMLText");
|
478
478
|
|
479
479
|
yxml_text
|
@@ -550,7 +550,7 @@ fn init() -> Result<(), Error> {
|
|
550
550
|
.expect("cannot define private method: yxml_text_to_s");
|
551
551
|
|
552
552
|
let yawareness = module
|
553
|
-
.define_class("Awareness",
|
553
|
+
.define_class("Awareness", class::object())
|
554
554
|
.expect("cannot define class Y::Awareness");
|
555
555
|
yawareness
|
556
556
|
.define_singleton_method("new", function!(YAwareness::yawareness_new, 0))
|
@@ -617,7 +617,7 @@ fn init() -> Result<(), Error> {
|
|
617
617
|
.expect("cannot define private method: yawareness_update_with_clients");
|
618
618
|
|
619
619
|
let yawareness_event = module
|
620
|
-
.define_class("AwarenessEvent",
|
620
|
+
.define_class("AwarenessEvent", class::object())
|
621
621
|
.expect("cannot define class Y:AwarenessEvent");
|
622
622
|
yawareness_event
|
623
623
|
.define_method("added", method!(YAwarenessEvent::added, 0))
|
data/ext/yrb/src/utils.rs
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
use crate::yvalue::YValue;
|
2
2
|
use lib0::any::Any;
|
3
3
|
use magnus::r_hash::ForEach::Continue;
|
4
|
-
use magnus::{exception, Error, RHash, RString, Symbol, Value};
|
4
|
+
use magnus::{exception, Error, RArray, RHash, RString, Symbol, Value};
|
5
5
|
use std::sync::Arc;
|
6
|
-
use yrs::types::Attrs;
|
6
|
+
use yrs::types::{Attrs, Value as YrsValue};
|
7
|
+
use yrs::{Array, Map, TransactionMut};
|
7
8
|
|
8
9
|
#[derive(Debug, Clone)]
|
9
10
|
pub(crate) struct TypeConversionError;
|
@@ -35,3 +36,30 @@ pub(crate) fn map_rhash_to_attrs(hash: RHash) -> Result<Attrs, Error> {
|
|
35
36
|
|
36
37
|
Ok(a)
|
37
38
|
}
|
39
|
+
|
40
|
+
pub(crate) fn convert_yvalue_to_ruby_value(value: YrsValue, tx: &TransactionMut) -> YValue {
|
41
|
+
match value {
|
42
|
+
YrsValue::Any(val) => YValue::from(val),
|
43
|
+
YrsValue::YText(text) => YValue::from(text),
|
44
|
+
YrsValue::YXmlElement(el) => YValue::from(el),
|
45
|
+
YrsValue::YXmlText(text) => YValue::from(text),
|
46
|
+
YrsValue::YArray(val) => {
|
47
|
+
let arr = RArray::new();
|
48
|
+
for item in val.iter(tx) {
|
49
|
+
let val = convert_yvalue_to_ruby_value(item.clone(), tx);
|
50
|
+
let val = *val.0.borrow();
|
51
|
+
arr.push(val).expect("cannot push item event to array");
|
52
|
+
}
|
53
|
+
YValue::from(arr)
|
54
|
+
}
|
55
|
+
YrsValue::YMap(val) => {
|
56
|
+
let iter = val.iter(tx).map(|(key, val)| {
|
57
|
+
let val = convert_yvalue_to_ruby_value(val.clone(), tx);
|
58
|
+
let val = val.0.into_inner();
|
59
|
+
(key, val)
|
60
|
+
});
|
61
|
+
YValue::from(RHash::from_iter(iter))
|
62
|
+
}
|
63
|
+
v => panic!("cannot map given yrs values to yvalue: {:?}", v),
|
64
|
+
}
|
65
|
+
}
|
data/ext/yrb/src/yany.rs
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
use lib0::any::Any;
|
2
2
|
use magnus::r_string::IntoRString;
|
3
|
-
use magnus::
|
3
|
+
use magnus::value::ReprValue;
|
4
|
+
use magnus::{value, IntoValue, RArray, RHash, RString, Value};
|
4
5
|
use std::borrow::Borrow;
|
5
6
|
use std::ops::{Deref, DerefMut};
|
6
7
|
|
@@ -27,19 +28,19 @@ impl TryInto<Value> for YAny {
|
|
27
28
|
return match self.0 {
|
28
29
|
Any::Array(_v) => {
|
29
30
|
let arr = RArray::new();
|
30
|
-
Ok(
|
31
|
+
Ok(arr.as_value())
|
31
32
|
}
|
32
33
|
Any::Map(_v) => {
|
33
34
|
let hash = RHash::new();
|
34
|
-
Ok(
|
35
|
+
Ok(hash.as_value())
|
35
36
|
}
|
36
|
-
Any::Null => Ok(
|
37
|
-
Any::Undefined => Ok(Value::from(
|
38
|
-
Any::Bool(v) => Ok(
|
39
|
-
Any::Number(v) => Ok(Value::from(v)),
|
40
|
-
Any::BigInt(v) => Ok(Value::from(v)),
|
41
|
-
Any::String(v) => Ok(
|
42
|
-
Any::Buffer(v) => Ok(
|
37
|
+
Any::Null => Ok(value::qnil().as_value()),
|
38
|
+
Any::Undefined => Ok(Value::from(value::qnil().as_value())),
|
39
|
+
Any::Bool(v) => Ok(v.into_value()),
|
40
|
+
Any::Number(v) => Ok(Value::from(v.into_value())),
|
41
|
+
Any::BigInt(v) => Ok(Value::from(v.into_value())),
|
42
|
+
Any::String(v) => Ok(RString::from(v.into_r_string()).as_value()),
|
43
|
+
Any::Buffer(v) => Ok(RString::from_slice(v.borrow()).as_value()),
|
43
44
|
};
|
44
45
|
}
|
45
46
|
}
|
data/ext/yrb/src/yarray.rs
CHANGED
@@ -1,9 +1,10 @@
|
|
1
|
+
use crate::utils::convert_yvalue_to_ruby_value;
|
1
2
|
use crate::ytransaction::YTransaction;
|
2
3
|
use crate::yvalue::YValue;
|
3
4
|
use lib0::any::Any;
|
4
5
|
use magnus::block::Proc;
|
5
6
|
use magnus::value::Qnil;
|
6
|
-
use magnus::{Error, RArray, RHash, Symbol, Value};
|
7
|
+
use magnus::{Error, IntoValue, RArray, RHash, Symbol, Value};
|
7
8
|
use std::borrow::Borrow;
|
8
9
|
use std::cell::RefCell;
|
9
10
|
use yrs::types::Change;
|
@@ -22,20 +23,21 @@ impl YArray {
|
|
22
23
|
|
23
24
|
let arr = self.0.borrow();
|
24
25
|
arr.iter(tx).for_each(|val| {
|
25
|
-
let yvalue =
|
26
|
-
let args = (yvalue
|
26
|
+
let yvalue = *convert_yvalue_to_ruby_value(val, tx).0.borrow();
|
27
|
+
let args = (yvalue,);
|
27
28
|
let _ = block.call::<(Value,), Qnil>(args);
|
28
29
|
});
|
29
30
|
|
30
31
|
Ok(())
|
31
32
|
}
|
33
|
+
|
32
34
|
pub(crate) fn yarray_get(&self, transaction: &YTransaction, index: u32) -> Value {
|
33
35
|
let tx = transaction.transaction();
|
34
36
|
let tx = tx.as_ref().unwrap();
|
35
37
|
|
36
38
|
let arr = self.0.borrow();
|
37
39
|
let v = arr.get(tx, index).unwrap();
|
38
|
-
|
40
|
+
*convert_yvalue_to_ruby_value(v, tx).0.borrow()
|
39
41
|
}
|
40
42
|
pub(crate) fn yarray_insert(&self, transaction: &YTransaction, index: u32, value: Value) {
|
41
43
|
let yvalue = YValue::from(value);
|
@@ -98,10 +100,10 @@ impl YArray {
|
|
98
100
|
payload.aset(change_added, values)
|
99
101
|
}
|
100
102
|
Change::Retain(position) => {
|
101
|
-
payload.aset(change_retain,
|
103
|
+
payload.aset(change_retain, (*position).into_value())
|
102
104
|
}
|
103
105
|
Change::Removed(position) => {
|
104
|
-
payload.aset(change_removed,
|
106
|
+
payload.aset(change_removed, (*position).into_value())
|
105
107
|
}
|
106
108
|
};
|
107
109
|
|
data/ext/yrb/src/ymap.rs
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
use crate::utils::indifferent_hash_key;
|
1
|
+
use crate::utils::{convert_yvalue_to_ruby_value, indifferent_hash_key};
|
2
2
|
use crate::yvalue::YValue;
|
3
3
|
use crate::YTransaction;
|
4
4
|
use lib0::any::Any;
|
@@ -30,17 +30,18 @@ impl YMap {
|
|
30
30
|
Some(k) => self.0.borrow().contains_key(tx, k.as_str()),
|
31
31
|
}
|
32
32
|
}
|
33
|
+
|
33
34
|
pub(crate) fn ymap_each(&self, transaction: &YTransaction, proc: Proc) {
|
34
35
|
let tx = transaction.transaction();
|
35
36
|
let tx = tx.as_ref().unwrap();
|
36
|
-
|
37
37
|
self.0.borrow().iter(tx).for_each(|(key, val)| {
|
38
38
|
let k = key.to_string();
|
39
|
-
let v = *
|
39
|
+
let v = *convert_yvalue_to_ruby_value(val, tx).0.borrow();
|
40
40
|
proc.call::<(String, Value), Value>((k, v))
|
41
41
|
.expect("cannot iterate map");
|
42
42
|
})
|
43
43
|
}
|
44
|
+
|
44
45
|
pub(crate) fn ymap_get(&self, transaction: &YTransaction, key: Value) -> Option<Value> {
|
45
46
|
let tx = transaction.transaction();
|
46
47
|
let tx = tx.as_ref().unwrap();
|
@@ -48,7 +49,7 @@ impl YMap {
|
|
48
49
|
indifferent_hash_key(key)
|
49
50
|
.map(|k| self.0.borrow().get(tx, k.as_str()))
|
50
51
|
.map(|v| v.unwrap_or(YrsValue::Any(Any::Undefined)))
|
51
|
-
.map(|v| *
|
52
|
+
.map(|v| *convert_yvalue_to_ruby_value(v, tx).0.borrow())
|
52
53
|
}
|
53
54
|
pub(crate) fn ymap_insert(
|
54
55
|
&self,
|
data/ext/yrb/src/yvalue.rs
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
use crate::{YText, YXmlElement, YXmlText};
|
2
2
|
use lib0::any::Any;
|
3
3
|
use magnus::r_hash::ForEach::Continue;
|
4
|
-
use magnus::value::Qnil;
|
5
|
-
use magnus::{class, Float, Integer, RArray, RHash, RString, Symbol, Value
|
4
|
+
use magnus::value::{Qnil, ReprValue};
|
5
|
+
use magnus::{class, value, Float, Integer, IntoValue, RArray, RHash, RString, Symbol, Value};
|
6
6
|
use std::cell::RefCell;
|
7
7
|
use std::collections::HashMap;
|
8
8
|
use yrs::types::Value as YrsValue;
|
@@ -21,100 +21,100 @@ impl From<Value> for YValue {
|
|
21
21
|
|
22
22
|
impl From<Qnil> for YValue {
|
23
23
|
fn from(value: Qnil) -> Self {
|
24
|
-
YValue(RefCell::from(
|
24
|
+
YValue(RefCell::from(value.into_value()))
|
25
25
|
}
|
26
26
|
}
|
27
27
|
|
28
28
|
impl From<bool> for YValue {
|
29
29
|
fn from(value: bool) -> Self {
|
30
|
-
YValue(RefCell::from(
|
30
|
+
YValue(RefCell::from(value.into_value()))
|
31
31
|
}
|
32
32
|
}
|
33
33
|
|
34
34
|
impl From<f64> for YValue {
|
35
35
|
fn from(value: f64) -> Self {
|
36
|
-
YValue(RefCell::from(
|
36
|
+
YValue(RefCell::from(value.into_value()))
|
37
37
|
}
|
38
38
|
}
|
39
39
|
|
40
40
|
impl From<i64> for YValue {
|
41
41
|
fn from(value: i64) -> Self {
|
42
|
-
YValue(RefCell::from(
|
42
|
+
YValue(RefCell::from(value.into_value()))
|
43
43
|
}
|
44
44
|
}
|
45
45
|
|
46
46
|
impl From<u32> for YValue {
|
47
47
|
fn from(value: u32) -> Self {
|
48
|
-
YValue(RefCell::from(
|
48
|
+
YValue(RefCell::from(value.into_value()))
|
49
49
|
}
|
50
50
|
}
|
51
51
|
|
52
52
|
impl From<String> for YValue {
|
53
53
|
fn from(value: String) -> Self {
|
54
|
-
YValue(RefCell::from(
|
54
|
+
YValue(RefCell::from(value.into_value()))
|
55
55
|
}
|
56
56
|
}
|
57
57
|
|
58
58
|
impl From<RArray> for YValue {
|
59
59
|
fn from(value: RArray) -> Self {
|
60
|
-
YValue(RefCell::from(
|
60
|
+
YValue(RefCell::from(value.into_value()))
|
61
61
|
}
|
62
62
|
}
|
63
63
|
|
64
64
|
impl From<RHash> for YValue {
|
65
65
|
fn from(value: RHash) -> Self {
|
66
|
-
YValue(RefCell::from(
|
66
|
+
YValue(RefCell::from(value.into_value()))
|
67
67
|
}
|
68
68
|
}
|
69
69
|
|
70
70
|
impl From<YrsText> for YValue {
|
71
71
|
fn from(value: YrsText) -> Self {
|
72
|
-
YValue(RefCell::from(
|
72
|
+
YValue(RefCell::from(YText(RefCell::from(value)).into_value()))
|
73
73
|
}
|
74
74
|
}
|
75
75
|
|
76
76
|
impl From<YrsXmlElement> for YValue {
|
77
77
|
fn from(value: YrsXmlElement) -> Self {
|
78
|
-
YValue(RefCell::from(
|
79
|
-
value,
|
80
|
-
))
|
78
|
+
YValue(RefCell::from(
|
79
|
+
YXmlElement(RefCell::from(value)).into_value(),
|
80
|
+
))
|
81
81
|
}
|
82
82
|
}
|
83
83
|
|
84
84
|
impl From<YrsXmlText> for YValue {
|
85
85
|
fn from(value: YrsXmlText) -> Self {
|
86
|
-
YValue(RefCell::from(
|
86
|
+
YValue(RefCell::from(YXmlText(RefCell::from(value)).into_value()))
|
87
87
|
}
|
88
88
|
}
|
89
89
|
|
90
90
|
impl From<YText> for YValue {
|
91
91
|
fn from(value: YText) -> Self {
|
92
|
-
YValue(RefCell::from(
|
92
|
+
YValue(RefCell::from(value.into_value()))
|
93
93
|
}
|
94
94
|
}
|
95
95
|
|
96
96
|
impl From<YXmlElement> for YValue {
|
97
97
|
fn from(value: YXmlElement) -> Self {
|
98
|
-
YValue(RefCell::from(
|
98
|
+
YValue(RefCell::from(value.into_value()))
|
99
99
|
}
|
100
100
|
}
|
101
101
|
|
102
102
|
impl From<YXmlText> for YValue {
|
103
103
|
fn from(value: YXmlText) -> Self {
|
104
|
-
YValue(RefCell::from(
|
104
|
+
YValue(RefCell::from(value.into_value()))
|
105
105
|
}
|
106
106
|
}
|
107
107
|
|
108
108
|
impl From<Any> for YValue {
|
109
109
|
fn from(value: Any) -> Self {
|
110
110
|
match value {
|
111
|
-
Any::Null => YValue::from(
|
112
|
-
Any::Undefined => YValue::from(
|
111
|
+
Any::Null => YValue::from(value::qnil()),
|
112
|
+
Any::Undefined => YValue::from(value::qnil()),
|
113
113
|
Any::Bool(v) => YValue::from(v),
|
114
114
|
Any::Number(v) => YValue::from(v),
|
115
115
|
Any::BigInt(v) => YValue::from(v),
|
116
116
|
Any::String(v) => YValue::from(v.into_string()),
|
117
|
-
Any::Buffer(v) => YValue::from(
|
117
|
+
Any::Buffer(v) => YValue::from(v.into_vec().into_value()),
|
118
118
|
Any::Array(v) => {
|
119
119
|
let arr = RArray::new();
|
120
120
|
for item in v.iter() {
|
@@ -146,16 +146,18 @@ impl From<YrsValue> for YValue {
|
|
146
146
|
YrsValue::YXmlElement(el) => YValue::from(el),
|
147
147
|
YrsValue::YXmlText(text) => YValue::from(text),
|
148
148
|
YrsValue::YArray(val) => {
|
149
|
+
print!("try to acquire transaction");
|
149
150
|
let tx = val.transact();
|
150
151
|
let arr = RArray::new();
|
151
152
|
for item in val.iter(&tx) {
|
152
153
|
let val = YValue::from(item.clone());
|
153
|
-
let val = val.0.borrow()
|
154
|
+
let val = *val.0.borrow();
|
154
155
|
arr.push(val).expect("cannot push item event to array");
|
155
156
|
}
|
156
157
|
YValue::from(arr)
|
157
158
|
}
|
158
159
|
YrsValue::YMap(val) => {
|
160
|
+
print!("try to acquire transaction");
|
159
161
|
let tx = val.transact();
|
160
162
|
let iter = val.iter(&tx).map(|(key, val)| {
|
161
163
|
let val = YValue::from(val);
|
@@ -237,6 +239,7 @@ impl Into<Value> for YValue {
|
|
237
239
|
mod tests {
|
238
240
|
use crate::yvalue::YValue;
|
239
241
|
use lib0::any::Any;
|
242
|
+
use magnus::value::ReprValue;
|
240
243
|
|
241
244
|
#[test]
|
242
245
|
fn convert_any_to_yvalue() {
|
data/ext/yrb/src/yxml_element.rs
CHANGED
@@ -3,7 +3,7 @@ use crate::yxml_fragment::YXmlFragment;
|
|
3
3
|
use crate::yxml_text::YXmlText;
|
4
4
|
use crate::YTransaction;
|
5
5
|
use magnus::block::Proc;
|
6
|
-
use magnus::{Error, RArray, RHash, Symbol, Value};
|
6
|
+
use magnus::{Error, IntoValue, RArray, RHash, Symbol, Value};
|
7
7
|
use std::cell::RefCell;
|
8
8
|
use yrs::types::Change;
|
9
9
|
use yrs::{
|
@@ -32,9 +32,9 @@ impl YXmlElement {
|
|
32
32
|
let tx = tx.as_ref().unwrap();
|
33
33
|
|
34
34
|
self.0.borrow().get(tx, index).map(|node| match node {
|
35
|
-
XmlNode::Element(element) =>
|
36
|
-
XmlNode::Fragment(fragment) =>
|
37
|
-
XmlNode::Text(text) =>
|
35
|
+
XmlNode::Element(element) => YXmlElement::from(element).into_value(),
|
36
|
+
XmlNode::Fragment(fragment) => YXmlFragment::from(fragment).into_value(),
|
37
|
+
XmlNode::Text(text) => YXmlText::from(text).into_value(),
|
38
38
|
})
|
39
39
|
}
|
40
40
|
pub(crate) fn yxml_element_get_attribute(
|
@@ -93,9 +93,9 @@ impl YXmlElement {
|
|
93
93
|
let tx = tx.as_ref().unwrap();
|
94
94
|
|
95
95
|
self.0.borrow().siblings(tx).next().map(|item| match item {
|
96
|
-
XmlNode::Element(el) =>
|
97
|
-
XmlNode::Fragment(fragment) =>
|
98
|
-
XmlNode::Text(text) =>
|
96
|
+
XmlNode::Element(el) => YXmlElement::from(el).into_value(),
|
97
|
+
XmlNode::Fragment(fragment) => YXmlFragment::from(fragment).into_value(),
|
98
|
+
XmlNode::Text(text) => YXmlText::from(text).into_value(),
|
99
99
|
})
|
100
100
|
}
|
101
101
|
pub(crate) fn yxml_element_observe(&self, block: Proc) -> Result<u32, Error> {
|
@@ -161,9 +161,9 @@ impl YXmlElement {
|
|
161
161
|
}
|
162
162
|
pub(crate) fn yxml_element_parent(&self) -> Option<Value> {
|
163
163
|
self.0.borrow().parent().map(|item| match item {
|
164
|
-
XmlNode::Element(el) =>
|
165
|
-
XmlNode::Fragment(fragment) =>
|
166
|
-
XmlNode::Text(text) =>
|
164
|
+
XmlNode::Element(el) => YXmlElement::from(el).into_value(),
|
165
|
+
XmlNode::Fragment(fragment) => YXmlFragment::from(fragment).into_value(),
|
166
|
+
XmlNode::Text(text) => YXmlText::from(text).into_value(),
|
167
167
|
})
|
168
168
|
}
|
169
169
|
pub(crate) fn yxml_element_prev_sibling(&self, transaction: &YTransaction) -> Option<Value> {
|
@@ -175,9 +175,9 @@ impl YXmlElement {
|
|
175
175
|
.siblings(tx)
|
176
176
|
.next_back()
|
177
177
|
.map(|item| match item {
|
178
|
-
XmlNode::Element(el) =>
|
179
|
-
XmlNode::Fragment(fragment) =>
|
180
|
-
XmlNode::Text(text) =>
|
178
|
+
XmlNode::Element(el) => YXmlElement::from(el).into_value(),
|
179
|
+
XmlNode::Fragment(fragment) => YXmlFragment::from(fragment).into_value(),
|
180
|
+
XmlNode::Text(text) => YXmlText::from(text).into_value(),
|
181
181
|
})
|
182
182
|
}
|
183
183
|
pub(crate) fn yxml_element_push_element_back(
|
@@ -246,9 +246,9 @@ impl YXmlElement {
|
|
246
246
|
let tx = tx.as_ref().unwrap();
|
247
247
|
|
248
248
|
let siblings = self.0.borrow().siblings(tx).map(|item| match item {
|
249
|
-
XmlNode::Element(el) =>
|
250
|
-
XmlNode::Fragment(fragment) =>
|
251
|
-
XmlNode::Text(text) =>
|
249
|
+
XmlNode::Element(el) => YXmlElement::from(el).into_value(),
|
250
|
+
XmlNode::Fragment(fragment) => YXmlFragment::from(fragment).into_value(),
|
251
|
+
XmlNode::Text(text) => YXmlText::from(text).into_value(),
|
252
252
|
});
|
253
253
|
|
254
254
|
RArray::from_iter(siblings)
|
@@ -1,7 +1,7 @@
|
|
1
1
|
use crate::ytransaction::YTransaction;
|
2
2
|
use crate::yxml_element::YXmlElement;
|
3
3
|
use crate::yxml_text::YXmlText;
|
4
|
-
use magnus::{RArray, Value};
|
4
|
+
use magnus::{IntoValue, RArray, Value};
|
5
5
|
use std::cell::RefCell;
|
6
6
|
use yrs::{GetString, XmlElementPrelim, XmlFragment, XmlFragmentRef, XmlNode};
|
7
7
|
|
@@ -14,9 +14,9 @@ unsafe impl Send for YXmlFragment {}
|
|
14
14
|
impl YXmlFragment {
|
15
15
|
pub(crate) fn yxml_fragment_first_child(&self) -> Option<Value> {
|
16
16
|
self.0.borrow().first_child().map(|node| match node {
|
17
|
-
XmlNode::Element(element) =>
|
18
|
-
XmlNode::Fragment(fragment) =>
|
19
|
-
XmlNode::Text(text) =>
|
17
|
+
XmlNode::Element(element) => YXmlElement::from(element).into_value(),
|
18
|
+
XmlNode::Fragment(fragment) => YXmlFragment::from(fragment).into_value(),
|
19
|
+
XmlNode::Text(text) => YXmlText::from(text).into_value(),
|
20
20
|
})
|
21
21
|
}
|
22
22
|
|
@@ -29,9 +29,9 @@ impl YXmlFragment {
|
|
29
29
|
let tx = tx.as_ref().unwrap();
|
30
30
|
|
31
31
|
self.0.borrow().get(tx, index).map(|node| match node {
|
32
|
-
XmlNode::Element(element) =>
|
33
|
-
XmlNode::Fragment(fragment) =>
|
34
|
-
XmlNode::Text(text) =>
|
32
|
+
XmlNode::Element(element) => YXmlElement::from(element).into_value(),
|
33
|
+
XmlNode::Fragment(fragment) => YXmlFragment::from(fragment).into_value(),
|
34
|
+
XmlNode::Text(text) => YXmlText::from(text).into_value(),
|
35
35
|
})
|
36
36
|
}
|
37
37
|
|
@@ -57,9 +57,9 @@ impl YXmlFragment {
|
|
57
57
|
|
58
58
|
pub(crate) fn yxml_fragment_parent(&self) -> Option<Value> {
|
59
59
|
self.0.borrow().parent().map(|item| match item {
|
60
|
-
XmlNode::Element(el) =>
|
61
|
-
XmlNode::Fragment(fragment) =>
|
62
|
-
XmlNode::Text(text) =>
|
60
|
+
XmlNode::Element(el) => YXmlElement::from(el).into_value(),
|
61
|
+
XmlNode::Fragment(fragment) => YXmlFragment::from(fragment).into_value(),
|
62
|
+
XmlNode::Text(text) => YXmlText::from(text).into_value(),
|
63
63
|
})
|
64
64
|
}
|
65
65
|
|
@@ -106,9 +106,9 @@ impl YXmlFragment {
|
|
106
106
|
let fragment = self.0.borrow();
|
107
107
|
|
108
108
|
let result = fragment.successors(tx).map(|item| match item {
|
109
|
-
XmlNode::Element(el) =>
|
110
|
-
XmlNode::Fragment(fragment) =>
|
111
|
-
XmlNode::Text(text) =>
|
109
|
+
XmlNode::Element(el) => YXmlElement::from(el).into_value(),
|
110
|
+
XmlNode::Fragment(fragment) => YXmlFragment::from(fragment).into_value(),
|
111
|
+
XmlNode::Text(text) => YXmlText::from(text).into_value(),
|
112
112
|
});
|
113
113
|
|
114
114
|
RArray::from_iter(result)
|
data/ext/yrb/src/yxml_text.rs
CHANGED
@@ -3,7 +3,7 @@ use crate::yvalue::YValue;
|
|
3
3
|
use crate::yxml_fragment::YXmlFragment;
|
4
4
|
use crate::{YTransaction, YXmlElement};
|
5
5
|
use lib0::any::Any;
|
6
|
-
use magnus::{Error, RHash, Value};
|
6
|
+
use magnus::{Error, IntoValue, RHash, Value};
|
7
7
|
use std::cell::RefCell;
|
8
8
|
use yrs::{GetString, Text, Xml, XmlNode, XmlTextRef};
|
9
9
|
|
@@ -120,16 +120,16 @@ impl YXmlText {
|
|
120
120
|
let tx = tx.as_ref().unwrap();
|
121
121
|
|
122
122
|
self.0.borrow().siblings(tx).next().map(|item| match item {
|
123
|
-
XmlNode::Element(el) =>
|
124
|
-
XmlNode::Fragment(fragment) =>
|
125
|
-
XmlNode::Text(text) =>
|
123
|
+
XmlNode::Element(el) => YXmlElement(RefCell::from(el)).into_value(),
|
124
|
+
XmlNode::Fragment(fragment) => YXmlFragment(RefCell::from(fragment)).into_value(),
|
125
|
+
XmlNode::Text(text) => YXmlText(RefCell::from(text)).into_value(),
|
126
126
|
})
|
127
127
|
}
|
128
128
|
pub(crate) fn yxml_text_parent(&self) -> Option<Value> {
|
129
129
|
self.0.borrow().parent().map(|item| match item {
|
130
|
-
XmlNode::Element(el) =>
|
131
|
-
XmlNode::Fragment(fragment) =>
|
132
|
-
XmlNode::Text(text) =>
|
130
|
+
XmlNode::Element(el) => YXmlElement(RefCell::from(el)).into_value(),
|
131
|
+
XmlNode::Fragment(fragment) => YXmlFragment(RefCell::from(fragment)).into_value(),
|
132
|
+
XmlNode::Text(text) => YXmlText(RefCell::from(text)).into_value(),
|
133
133
|
})
|
134
134
|
}
|
135
135
|
pub(crate) fn yxml_text_prev_sibling(&self, transaction: &YTransaction) -> Option<Value> {
|
@@ -141,9 +141,9 @@ impl YXmlText {
|
|
141
141
|
.siblings(tx)
|
142
142
|
.next_back()
|
143
143
|
.map(|item| match item {
|
144
|
-
XmlNode::Element(el) =>
|
145
|
-
XmlNode::Fragment(fragment) =>
|
146
|
-
XmlNode::Text(text) =>
|
144
|
+
XmlNode::Element(el) => YXmlElement(RefCell::from(el)).into_value(),
|
145
|
+
XmlNode::Fragment(fragment) => YXmlFragment(RefCell::from(fragment)).into_value(),
|
146
|
+
XmlNode::Text(text) => YXmlText(RefCell::from(text)).into_value(),
|
147
147
|
})
|
148
148
|
}
|
149
149
|
pub(crate) fn yxml_text_push(&self, transaction: &YTransaction, content: String) {
|
data/lib/3.1/yrb.so
CHANGED
Binary file
|
data/lib/3.2/yrb.so
CHANGED
Binary file
|
data/lib/y/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: y-rb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.3
|
5
5
|
platform: x64-mingw-ucrt
|
6
6
|
authors:
|
7
7
|
- Hannes Moser
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-11-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|