y-rb 0.3.2-aarch64-linux → 0.4.0-aarch64-linux
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 +5 -5
- data/ext/yrb/src/awareness.rs +5 -5
- data/ext/yrb/src/lib.rs +81 -35
- data/ext/yrb/src/yarray.rs +68 -33
- data/ext/yrb/src/ydoc.rs +53 -10
- data/ext/yrb/src/ymap.rs +47 -24
- data/ext/yrb/src/ytext.rs +55 -60
- data/ext/yrb/src/ytransaction.rs +71 -23
- data/ext/yrb/src/yvalue.rs +26 -7
- data/ext/yrb/src/yxml_element.rs +133 -72
- data/ext/yrb/src/yxml_fragment.rs +16 -0
- data/ext/yrb/src/yxml_text.rs +96 -56
- data/lib/2.7/yrb.so +0 -0
- data/lib/3.0/yrb.so +0 -0
- data/lib/3.1/yrb.so +0 -0
- data/lib/y/array.rb +114 -100
- data/lib/y/awareness.rb +40 -14
- data/lib/y/doc.rb +77 -71
- data/lib/y/map.rb +39 -42
- data/lib/y/text.rb +92 -96
- data/lib/y/transaction.rb +31 -13
- data/lib/y/version.rb +1 -1
- data/lib/y/xml.rb +259 -227
- data/lib/y-rb.rb +1 -1
- metadata +5 -4
data/ext/yrb/src/yxml_element.rs
CHANGED
@@ -1,33 +1,51 @@
|
|
1
1
|
use crate::yvalue::YValue;
|
2
|
+
use crate::yxml_fragment::YXmlFragment;
|
2
3
|
use crate::yxml_text::YXmlText;
|
3
4
|
use crate::YTransaction;
|
4
5
|
use magnus::block::Proc;
|
5
6
|
use magnus::{Error, RArray, RHash, Symbol, Value};
|
6
7
|
use std::cell::RefCell;
|
7
8
|
use yrs::types::Change;
|
8
|
-
use yrs::{
|
9
|
+
use yrs::{
|
10
|
+
GetString, Observable, Xml, XmlElementPrelim, XmlElementRef, XmlFragment, XmlNode,
|
11
|
+
XmlTextPrelim,
|
12
|
+
};
|
9
13
|
|
10
14
|
#[magnus::wrap(class = "Y::XMLElement")]
|
11
|
-
pub(crate) struct YXmlElement(pub(crate) RefCell<
|
15
|
+
pub(crate) struct YXmlElement(pub(crate) RefCell<XmlElementRef>);
|
12
16
|
|
13
17
|
/// SAFETY: This is safe because we only access this data when the GVL is held.
|
14
18
|
unsafe impl Send for YXmlElement {}
|
15
19
|
|
16
20
|
impl YXmlElement {
|
17
|
-
pub(crate) fn yxml_element_attributes(&self) -> RHash {
|
18
|
-
|
21
|
+
pub(crate) fn yxml_element_attributes(&self, transaction: &YTransaction) -> RHash {
|
22
|
+
let tx = transaction.transaction();
|
23
|
+
let tx = tx.as_ref().unwrap();
|
24
|
+
|
25
|
+
RHash::from_iter(self.0.borrow().attributes(tx))
|
19
26
|
}
|
20
|
-
pub(crate) fn yxml_element_first_child(&self) -> Option<Value> {
|
21
|
-
self.yxml_element_get(0)
|
27
|
+
pub(crate) fn yxml_element_first_child(&self, transaction: &YTransaction) -> Option<Value> {
|
28
|
+
self.yxml_element_get(transaction, 0)
|
22
29
|
}
|
23
|
-
pub(crate) fn yxml_element_get(&self, index: u32) -> Option<Value> {
|
24
|
-
|
25
|
-
|
26
|
-
|
30
|
+
pub(crate) fn yxml_element_get(&self, transaction: &YTransaction, index: u32) -> Option<Value> {
|
31
|
+
let tx = transaction.transaction();
|
32
|
+
let tx = tx.as_ref().unwrap();
|
33
|
+
|
34
|
+
self.0.borrow().get(tx, index).map(|node| match node {
|
35
|
+
XmlNode::Element(element) => Value::from(YXmlElement::from(element)),
|
36
|
+
XmlNode::Fragment(fragment) => Value::from(YXmlFragment::from(fragment)),
|
37
|
+
XmlNode::Text(text) => Value::from(YXmlText::from(text)),
|
27
38
|
})
|
28
39
|
}
|
29
|
-
pub(crate) fn yxml_element_get_attribute(
|
30
|
-
self
|
40
|
+
pub(crate) fn yxml_element_get_attribute(
|
41
|
+
&self,
|
42
|
+
transaction: &YTransaction,
|
43
|
+
name: String,
|
44
|
+
) -> Option<String> {
|
45
|
+
let tx = transaction.transaction();
|
46
|
+
let tx = tx.as_ref().unwrap();
|
47
|
+
|
48
|
+
self.0.borrow().get_attribute(tx, name.as_str())
|
31
49
|
}
|
32
50
|
pub(crate) fn yxml_element_insert_attribute(
|
33
51
|
&self,
|
@@ -35,39 +53,43 @@ impl YXmlElement {
|
|
35
53
|
name: String,
|
36
54
|
value: String,
|
37
55
|
) {
|
38
|
-
|
39
|
-
|
40
|
-
|
56
|
+
let mut tx = transaction.transaction();
|
57
|
+
let tx = tx.as_mut().unwrap();
|
58
|
+
|
59
|
+
self.0.borrow_mut().insert_attribute(tx, name, value)
|
41
60
|
}
|
42
61
|
pub(crate) fn yxml_element_insert_element(
|
43
62
|
&self,
|
44
63
|
transaction: &YTransaction,
|
45
64
|
index: u32,
|
46
|
-
|
65
|
+
tag: String,
|
47
66
|
) -> YXmlElement {
|
48
|
-
let
|
49
|
-
|
50
|
-
.borrow_mut()
|
51
|
-
.insert_elem(&mut *transaction.0.borrow_mut(), index, name);
|
67
|
+
let mut tx = transaction.transaction();
|
68
|
+
let tx = tx.as_mut().unwrap();
|
52
69
|
|
53
|
-
|
70
|
+
let node = XmlElementPrelim::empty(tag);
|
71
|
+
YXmlElement::from(self.0.borrow_mut().insert(tx, index, node))
|
54
72
|
}
|
55
73
|
pub(crate) fn yxml_element_insert_text(
|
56
74
|
&self,
|
57
75
|
transaction: &YTransaction,
|
58
76
|
index: u32,
|
77
|
+
content: String,
|
59
78
|
) -> YXmlText {
|
60
|
-
let text =
|
61
|
-
|
62
|
-
|
63
|
-
.insert_text(&mut *transaction.0.borrow_mut(), index);
|
79
|
+
let text = XmlTextPrelim(content.as_str());
|
80
|
+
let mut tx = transaction.transaction();
|
81
|
+
let tx = tx.as_mut().unwrap();
|
64
82
|
|
65
|
-
YXmlText
|
83
|
+
YXmlText::from(self.0.borrow_mut().insert(tx, index, text))
|
66
84
|
}
|
67
|
-
pub(crate) fn yxml_element_next_sibling(&self) -> Option<Value> {
|
68
|
-
|
69
|
-
|
70
|
-
|
85
|
+
pub(crate) fn yxml_element_next_sibling(&self, transaction: &YTransaction) -> Option<Value> {
|
86
|
+
let tx = transaction.transaction();
|
87
|
+
let tx = tx.as_ref().unwrap();
|
88
|
+
|
89
|
+
self.0.borrow().siblings(tx).next().map(|item| match item {
|
90
|
+
XmlNode::Element(el) => Value::from(YXmlElement::from(el)),
|
91
|
+
XmlNode::Fragment(fragment) => Value::from(YXmlFragment::from(fragment)),
|
92
|
+
XmlNode::Text(text) => Value::from(YXmlText::from(text)),
|
71
93
|
})
|
72
94
|
}
|
73
95
|
pub(crate) fn yxml_element_observe(&self, block: Proc) -> Result<u32, Error> {
|
@@ -131,61 +153,75 @@ impl YXmlElement {
|
|
131
153
|
Ok(subscription_id.into())
|
132
154
|
}
|
133
155
|
pub(crate) fn yxml_element_parent(&self) -> Option<Value> {
|
156
|
+
self.0.borrow().parent().map(|item| match item {
|
157
|
+
XmlNode::Element(el) => Value::from(YXmlElement::from(el)),
|
158
|
+
XmlNode::Fragment(fragment) => Value::from(YXmlFragment::from(fragment)),
|
159
|
+
XmlNode::Text(text) => Value::from(YXmlText::from(text)),
|
160
|
+
})
|
161
|
+
}
|
162
|
+
pub(crate) fn yxml_element_prev_sibling(&self, transaction: &YTransaction) -> Option<Value> {
|
163
|
+
let tx = transaction.transaction();
|
164
|
+
let tx = tx.as_ref().unwrap();
|
165
|
+
|
134
166
|
self.0
|
135
167
|
.borrow()
|
136
|
-
.
|
137
|
-
.
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
})
|
168
|
+
.siblings(tx)
|
169
|
+
.next_back()
|
170
|
+
.map(|item| match item {
|
171
|
+
XmlNode::Element(el) => Value::from(YXmlElement::from(el)),
|
172
|
+
XmlNode::Fragment(fragment) => Value::from(YXmlFragment::from(fragment)),
|
173
|
+
XmlNode::Text(text) => Value::from(YXmlText::from(text)),
|
174
|
+
})
|
144
175
|
}
|
145
176
|
pub(crate) fn yxml_element_push_element_back(
|
146
177
|
&self,
|
147
178
|
transaction: &YTransaction,
|
148
|
-
|
179
|
+
tag: String,
|
149
180
|
) -> YXmlElement {
|
150
|
-
let
|
151
|
-
|
152
|
-
.borrow_mut()
|
153
|
-
.push_elem_back(&mut *transaction.0.borrow_mut(), name);
|
181
|
+
let mut tx = transaction.transaction();
|
182
|
+
let tx = tx.as_mut().unwrap();
|
154
183
|
|
155
|
-
|
184
|
+
let node = XmlElementPrelim::empty(tag);
|
185
|
+
YXmlElement::from(self.0.borrow_mut().push_back(tx, node))
|
156
186
|
}
|
157
187
|
pub(crate) fn yxml_element_push_element_front(
|
158
188
|
&self,
|
159
189
|
transaction: &YTransaction,
|
160
|
-
|
190
|
+
tag: String,
|
161
191
|
) -> YXmlElement {
|
162
|
-
let
|
163
|
-
|
164
|
-
.borrow_mut()
|
165
|
-
.push_elem_front(&mut *transaction.0.borrow_mut(), name);
|
192
|
+
let mut tx = transaction.transaction();
|
193
|
+
let tx = tx.as_mut().unwrap();
|
166
194
|
|
167
|
-
|
195
|
+
let node = XmlElementPrelim::empty(tag);
|
196
|
+
YXmlElement::from(self.0.borrow_mut().push_front(tx, node))
|
168
197
|
}
|
169
|
-
pub(crate) fn yxml_element_push_text_back(
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
198
|
+
pub(crate) fn yxml_element_push_text_back(
|
199
|
+
&self,
|
200
|
+
transaction: &YTransaction,
|
201
|
+
content: String,
|
202
|
+
) -> YXmlText {
|
203
|
+
let mut tx = transaction.transaction();
|
204
|
+
let tx = tx.as_mut().unwrap();
|
174
205
|
|
175
|
-
|
206
|
+
let text = XmlTextPrelim(content.as_str());
|
207
|
+
YXmlText::from(self.0.borrow_mut().push_back(tx, text))
|
176
208
|
}
|
177
|
-
pub(crate) fn yxml_element_push_text_front(
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
209
|
+
pub(crate) fn yxml_element_push_text_front(
|
210
|
+
&self,
|
211
|
+
transaction: &YTransaction,
|
212
|
+
content: String,
|
213
|
+
) -> YXmlText {
|
214
|
+
let mut tx = transaction.transaction();
|
215
|
+
let tx = tx.as_mut().unwrap();
|
182
216
|
|
183
|
-
|
217
|
+
let text = XmlTextPrelim(content.as_str());
|
218
|
+
YXmlText::from(self.0.borrow_mut().push_front(tx, text))
|
184
219
|
}
|
185
220
|
pub(crate) fn yxml_element_remove_attribute(&self, transaction: &YTransaction, name: String) {
|
186
|
-
|
187
|
-
|
188
|
-
|
221
|
+
let mut tx = transaction.transaction();
|
222
|
+
let tx = tx.as_mut().unwrap();
|
223
|
+
|
224
|
+
self.0.borrow_mut().remove_attribute(tx, &name)
|
189
225
|
}
|
190
226
|
pub(crate) fn yxml_element_remove_range(
|
191
227
|
&self,
|
@@ -193,20 +229,45 @@ impl YXmlElement {
|
|
193
229
|
index: u32,
|
194
230
|
length: u32,
|
195
231
|
) {
|
196
|
-
|
197
|
-
|
198
|
-
|
232
|
+
let mut tx = transaction.transaction();
|
233
|
+
let tx = tx.as_mut().unwrap();
|
234
|
+
|
235
|
+
self.0.borrow_mut().remove_range(tx, index, length)
|
236
|
+
}
|
237
|
+
pub(crate) fn yxml_element_siblings(&self, transaction: &YTransaction) -> RArray {
|
238
|
+
let tx = transaction.transaction();
|
239
|
+
let tx = tx.as_ref().unwrap();
|
240
|
+
|
241
|
+
let siblings = self.0.borrow().siblings(tx).map(|item| match item {
|
242
|
+
XmlNode::Element(el) => Value::from(YXmlElement::from(el)),
|
243
|
+
XmlNode::Fragment(fragment) => Value::from(YXmlFragment::from(fragment)),
|
244
|
+
XmlNode::Text(text) => Value::from(YXmlText::from(text)),
|
245
|
+
});
|
246
|
+
|
247
|
+
RArray::from_iter(siblings)
|
199
248
|
}
|
200
|
-
pub(crate) fn yxml_element_size(&self) -> u32 {
|
201
|
-
|
249
|
+
pub(crate) fn yxml_element_size(&self, transaction: &YTransaction) -> u32 {
|
250
|
+
let tx = transaction.transaction();
|
251
|
+
let tx = tx.as_ref().unwrap();
|
252
|
+
|
253
|
+
self.0.borrow().len(tx)
|
202
254
|
}
|
203
255
|
pub(crate) fn yxml_element_tag(&self) -> String {
|
204
256
|
self.0.borrow().tag().to_string()
|
205
257
|
}
|
206
|
-
pub(crate) fn yxml_element_to_s(&self) -> String {
|
207
|
-
|
258
|
+
pub(crate) fn yxml_element_to_s(&self, transaction: &YTransaction) -> String {
|
259
|
+
let tx = transaction.transaction();
|
260
|
+
let tx = tx.as_ref().unwrap();
|
261
|
+
|
262
|
+
self.0.borrow().get_string(tx)
|
208
263
|
}
|
209
264
|
pub(crate) fn yxml_element_unobserve(&self, subscription_id: u32) {
|
210
265
|
self.0.borrow_mut().unobserve(subscription_id);
|
211
266
|
}
|
212
267
|
}
|
268
|
+
|
269
|
+
impl From<XmlElementRef> for YXmlElement {
|
270
|
+
fn from(v: XmlElementRef) -> Self {
|
271
|
+
YXmlElement(RefCell::from(v))
|
272
|
+
}
|
273
|
+
}
|
@@ -0,0 +1,16 @@
|
|
1
|
+
use std::cell::RefCell;
|
2
|
+
use yrs::XmlFragmentRef;
|
3
|
+
|
4
|
+
#[magnus::wrap(class = "Y::XMLFragment")]
|
5
|
+
pub(crate) struct YXmlFragment(pub(crate) RefCell<XmlFragmentRef>);
|
6
|
+
|
7
|
+
/// SAFETY: This is safe because we only access this data when the GVL is held.
|
8
|
+
unsafe impl Send for YXmlFragment {}
|
9
|
+
|
10
|
+
impl YXmlFragment {}
|
11
|
+
|
12
|
+
impl From<XmlFragmentRef> for YXmlFragment {
|
13
|
+
fn from(v: XmlFragmentRef) -> Self {
|
14
|
+
YXmlFragment(RefCell::from(v))
|
15
|
+
}
|
16
|
+
}
|
data/ext/yrb/src/yxml_text.rs
CHANGED
@@ -1,20 +1,24 @@
|
|
1
1
|
use crate::utils::map_rhash_to_attrs;
|
2
2
|
use crate::yvalue::YValue;
|
3
|
+
use crate::yxml_fragment::YXmlFragment;
|
3
4
|
use crate::{YTransaction, YXmlElement};
|
4
5
|
use lib0::any::Any;
|
5
6
|
use magnus::{Error, RHash, Value};
|
6
7
|
use std::cell::RefCell;
|
7
|
-
use yrs::{Xml,
|
8
|
+
use yrs::{GetString, Text, Xml, XmlNode, XmlTextRef};
|
8
9
|
|
9
10
|
#[magnus::wrap(class = "Y::XMLText")]
|
10
|
-
pub(crate) struct YXmlText(pub(crate) RefCell<
|
11
|
+
pub(crate) struct YXmlText(pub(crate) RefCell<XmlTextRef>);
|
11
12
|
|
12
13
|
/// SAFETY: This is safe because we only access this data when the GVL is held.
|
13
14
|
unsafe impl Send for YXmlText {}
|
14
15
|
|
15
16
|
impl YXmlText {
|
16
|
-
pub(crate) fn yxml_text_attributes(&self) -> RHash {
|
17
|
-
|
17
|
+
pub(crate) fn yxml_text_attributes(&self, transaction: &YTransaction) -> RHash {
|
18
|
+
let tx = transaction.transaction();
|
19
|
+
let tx = tx.as_ref().unwrap();
|
20
|
+
|
21
|
+
RHash::from_iter(self.0.borrow().attributes(tx))
|
18
22
|
}
|
19
23
|
pub(crate) fn yxml_text_format(
|
20
24
|
&self,
|
@@ -23,19 +27,26 @@ impl YXmlText {
|
|
23
27
|
length: u32,
|
24
28
|
attrs: RHash,
|
25
29
|
) -> Result<(), Error> {
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
})
|
30
|
+
let mut tx = transaction.transaction();
|
31
|
+
let tx = tx.as_mut().unwrap();
|
32
|
+
|
33
|
+
map_rhash_to_attrs(attrs).map(|a| self.0.borrow_mut().format(tx, index, length, a))
|
31
34
|
}
|
32
|
-
pub(crate) fn yxml_text_get_attribute(
|
33
|
-
self
|
35
|
+
pub(crate) fn yxml_text_get_attribute(
|
36
|
+
&self,
|
37
|
+
transaction: &YTransaction,
|
38
|
+
name: String,
|
39
|
+
) -> Option<String> {
|
40
|
+
let tx = transaction.transaction();
|
41
|
+
let tx = tx.as_ref().unwrap();
|
42
|
+
|
43
|
+
self.0.borrow().get_attribute(tx, name.as_str())
|
34
44
|
}
|
35
45
|
pub(crate) fn yxml_text_insert(&self, transaction: &YTransaction, index: u32, content: String) {
|
36
|
-
|
37
|
-
|
38
|
-
|
46
|
+
let mut tx = transaction.transaction();
|
47
|
+
let tx = tx.as_mut().unwrap();
|
48
|
+
|
49
|
+
self.0.borrow_mut().insert(tx, index, content.as_str())
|
39
50
|
}
|
40
51
|
pub(crate) fn yxml_text_insert_attribute(
|
41
52
|
&self,
|
@@ -43,9 +54,10 @@ impl YXmlText {
|
|
43
54
|
name: String,
|
44
55
|
value: String,
|
45
56
|
) {
|
46
|
-
|
47
|
-
|
48
|
-
|
57
|
+
let mut tx = transaction.transaction();
|
58
|
+
let tx = tx.as_mut().unwrap();
|
59
|
+
|
60
|
+
self.0.borrow_mut().insert_attribute(tx, name, value)
|
49
61
|
}
|
50
62
|
pub(crate) fn yxml_text_insert_embed_with_attributes(
|
51
63
|
&self,
|
@@ -54,16 +66,16 @@ impl YXmlText {
|
|
54
66
|
content: Value,
|
55
67
|
attrs: RHash,
|
56
68
|
) -> Result<(), Error> {
|
69
|
+
let mut tx = transaction.transaction();
|
70
|
+
let tx = tx.as_mut().unwrap();
|
71
|
+
|
57
72
|
let yvalue = YValue::from(content);
|
58
73
|
let avalue = Any::from(yvalue);
|
59
74
|
|
60
75
|
map_rhash_to_attrs(attrs).map(|a| {
|
61
|
-
self.0
|
62
|
-
|
63
|
-
index,
|
64
|
-
avalue,
|
65
|
-
a,
|
66
|
-
);
|
76
|
+
self.0
|
77
|
+
.borrow_mut()
|
78
|
+
.insert_embed_with_attributes(tx, index, avalue, a)
|
67
79
|
})
|
68
80
|
}
|
69
81
|
pub(crate) fn yxml_text_insert_embed(
|
@@ -72,11 +84,12 @@ impl YXmlText {
|
|
72
84
|
index: u32,
|
73
85
|
embed: Value,
|
74
86
|
) {
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
87
|
+
let mut tx = transaction.transaction();
|
88
|
+
let tx = tx.as_mut().unwrap();
|
89
|
+
|
90
|
+
self.0
|
91
|
+
.borrow_mut()
|
92
|
+
.insert_embed(tx, index, Any::from(YValue::from(embed)))
|
80
93
|
}
|
81
94
|
pub(crate) fn yxml_text_insert_with_attributes(
|
82
95
|
&self,
|
@@ -85,40 +98,57 @@ impl YXmlText {
|
|
85
98
|
content: String,
|
86
99
|
attrs: RHash,
|
87
100
|
) -> Result<(), Error> {
|
101
|
+
let mut tx = transaction.transaction();
|
102
|
+
let tx = tx.as_mut().unwrap();
|
103
|
+
|
88
104
|
map_rhash_to_attrs(attrs).map(|a| {
|
89
|
-
self.0
|
90
|
-
|
91
|
-
index,
|
92
|
-
&*content,
|
93
|
-
a,
|
94
|
-
);
|
105
|
+
self.0
|
106
|
+
.borrow_mut()
|
107
|
+
.insert_with_attributes(tx, index, content.as_str(), a);
|
95
108
|
})
|
96
109
|
}
|
97
|
-
pub(crate) fn yxml_text_length(&self) -> u32 {
|
98
|
-
|
110
|
+
pub(crate) fn yxml_text_length(&self, transaction: &YTransaction) -> u32 {
|
111
|
+
let tx = transaction.transaction();
|
112
|
+
let tx = tx.as_ref().unwrap();
|
113
|
+
|
114
|
+
self.0.borrow().len(tx)
|
99
115
|
}
|
100
|
-
pub(crate) fn yxml_text_next_sibling(&self) -> Option<Value> {
|
101
|
-
|
102
|
-
|
103
|
-
|
116
|
+
pub(crate) fn yxml_text_next_sibling(&self, transaction: &YTransaction) -> Option<Value> {
|
117
|
+
let tx = transaction.transaction();
|
118
|
+
let tx = tx.as_ref().unwrap();
|
119
|
+
|
120
|
+
self.0.borrow().siblings(tx).next().map(|item| match item {
|
121
|
+
XmlNode::Element(el) => Value::from(YXmlElement(RefCell::from(el))),
|
122
|
+
XmlNode::Fragment(fragment) => Value::from(YXmlFragment(RefCell::from(fragment))),
|
123
|
+
XmlNode::Text(text) => Value::from(YXmlText(RefCell::from(text))),
|
104
124
|
})
|
105
125
|
}
|
106
126
|
pub(crate) fn yxml_text_parent(&self) -> Option<Value> {
|
127
|
+
self.0.borrow().parent().map(|item| match item {
|
128
|
+
XmlNode::Element(el) => Value::from(YXmlElement(RefCell::from(el))),
|
129
|
+
XmlNode::Fragment(fragment) => Value::from(YXmlFragment(RefCell::from(fragment))),
|
130
|
+
XmlNode::Text(text) => Value::from(YXmlText(RefCell::from(text))),
|
131
|
+
})
|
132
|
+
}
|
133
|
+
pub(crate) fn yxml_text_prev_sibling(&self, transaction: &YTransaction) -> Option<Value> {
|
134
|
+
let tx = transaction.transaction();
|
135
|
+
let tx = tx.as_ref().unwrap();
|
136
|
+
|
107
137
|
self.0
|
108
138
|
.borrow()
|
109
|
-
.
|
110
|
-
.
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
})
|
139
|
+
.siblings(tx)
|
140
|
+
.next_back()
|
141
|
+
.map(|item| match item {
|
142
|
+
XmlNode::Element(el) => Value::from(YXmlElement(RefCell::from(el))),
|
143
|
+
XmlNode::Fragment(fragment) => Value::from(YXmlFragment(RefCell::from(fragment))),
|
144
|
+
XmlNode::Text(text) => Value::from(YXmlText(RefCell::from(text))),
|
145
|
+
})
|
117
146
|
}
|
118
147
|
pub(crate) fn yxml_text_push(&self, transaction: &YTransaction, content: String) {
|
119
|
-
|
120
|
-
|
121
|
-
|
148
|
+
let mut tx = transaction.transaction();
|
149
|
+
let tx = tx.as_mut().unwrap();
|
150
|
+
|
151
|
+
self.0.borrow_mut().push(tx, content.as_str())
|
122
152
|
}
|
123
153
|
pub(crate) fn yxml_text_remove_range(
|
124
154
|
&self,
|
@@ -126,11 +156,21 @@ impl YXmlText {
|
|
126
156
|
index: u32,
|
127
157
|
length: u32,
|
128
158
|
) {
|
129
|
-
|
130
|
-
|
131
|
-
|
159
|
+
let mut tx = transaction.transaction();
|
160
|
+
let tx = tx.as_mut().unwrap();
|
161
|
+
|
162
|
+
self.0.borrow_mut().remove_range(tx, index, length)
|
163
|
+
}
|
164
|
+
pub(crate) fn yxml_text_to_s(&self, transaction: &YTransaction) -> String {
|
165
|
+
let tx = transaction.transaction();
|
166
|
+
let tx = tx.as_ref().unwrap();
|
167
|
+
|
168
|
+
self.0.borrow().get_string(tx)
|
132
169
|
}
|
133
|
-
|
134
|
-
|
170
|
+
}
|
171
|
+
|
172
|
+
impl From<XmlTextRef> for YXmlText {
|
173
|
+
fn from(v: XmlTextRef) -> Self {
|
174
|
+
YXmlText(RefCell::from(v))
|
135
175
|
}
|
136
176
|
}
|
data/lib/2.7/yrb.so
CHANGED
Binary file
|
data/lib/3.0/yrb.so
CHANGED
Binary file
|
data/lib/3.1/yrb.so
CHANGED
Binary file
|