techy 0.1.3

A fast, extensible LaTeX parser for Rust
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
//! The capability traits: [`SerializableObject`] / [`DeserializableObject`] for objects
//! (table entries referred to by position), [`SerializableValue`] /
//! [`DeserializableValue`] for values (data embedded inline in an entry), and the
//! [`SerializableLang`] declaration that makes all four usable for a language.

use alloc::borrow::Cow;
use alloc::string::{String, ToString};
use alloc::vec::Vec;

use crate::state::{Lang, NodeExtTypes};

use super::engine::{DeserializeContext, SerializeContext};
use super::error::{DeserializeError, SerialValueError, SerializeError};
use super::value::{SerialEntry, SerialValue};
use super::wire::{FieldReader, FieldWriter};

/// A language that supports serialization.
///
/// Implementing this trait for a [`Lang`] is what makes serialization and
/// deserialization available for that language: a [`SerializeContext`] or
/// [`DeserializeContext`] can only exist for a `SerializableLang`, so the serialization
/// methods on the traits below — bounded `where L: SerializableLang` — can be called
/// exactly for such languages.
///
/// The trait has no items of its own, and an implementation of it is an empty block.
/// Its bounds require every type the language supplies to the parse — its closed
/// vocabularies ([`ModeId`](Lang::ModeId), [`CallableTypeId`](Lang::CallableTypeId),
/// [`GroupTypeId`](Lang::GroupTypeId), [`Event`](Lang::Event)), its extension types
/// ([`StateExt`](Lang::StateExt), [`SessionExt`](Lang::SessionExt), the node-ext bundle
/// [`NodeExts`](Lang::NodeExts)), its [`SourceOrigin`](Lang::SourceOrigin), and its
/// [`InvocationSyntax`](Lang::InvocationSyntax) — to implement [`SerializableValue`]
/// and [`DeserializableValue`] for the language. Those are the conversions the crate's
/// own serialization uses whenever such a value is embedded in an entry: a state's mode
/// and ext, a group rule's group type, a source's origin, and so on.
///
/// A language built on the crate's defaults (`()` for the exts and events, `u32` ids,
/// `Option<String>` origin — what [`TrivialLang`](crate::core::TrivialLang) supplies)
/// opts in with an empty impl block, because the crate's own impls already cover every
/// type. A language with its own vocabulary or extension types implements the two value
/// traits for those types first.
pub trait SerializableLang:
    Lang<
        ModeId: SerializableValue<Self> + DeserializableValue<Self>,
        CallableTypeId: SerializableValue<Self> + DeserializableValue<Self>,
        GroupTypeId: SerializableValue<Self> + DeserializableValue<Self>,
        Event: SerializableValue<Self> + DeserializableValue<Self>,
        StateExt: SerializableValue<Self> + DeserializableValue<Self>,
        SessionExt: SerializableValue<Self> + DeserializableValue<Self>,
        SourceOrigin: SerializableValue<Self> + DeserializableValue<Self>,
        NodeExts: NodeExtTypes<
            NodeExt: SerializableValue<Self> + DeserializableValue<Self>,
            ArgumentExt: SerializableValue<Self> + DeserializableValue<Self>,
            SlotExt: SerializableValue<Self> + DeserializableValue<Self>,
        >,
        InvocationSyntax: SerializableValue<Self> + DeserializableValue<Self>,
    >
{
}

/// The write side of the serialization capability: an object that can produce its
/// serialized form.
///
/// An *object* is a thing stored in a table and referred to by its position there — a
/// source, a parsing state, a callable spec, a provider (see the
/// [module documentation](crate::serialize)). This trait is what writes the objects of
/// a table whose entries are trait objects of several concrete types, the specs and
/// providers tables above all: that table's driver
/// ([`DispatchingSerdeDriver`](crate::serialize::DispatchingSerdeDriver)) writes each
/// object by calling [`serialize_object`](Self::serialize_object) on it. A table whose
/// objects all have one Rust type is written by its own
/// [`ObjectSerdeDriver`](crate::serialize::ObjectSerdeDriver) instead. The paired read
/// side is [`DeserializableObject`].
///
/// Every [`CallableSpec`](crate::core::specs::CallableSpec) and every
/// [`SpecsProvider`](crate::core::specs::SpecsProvider) implements this trait — it is a
/// supertrait of both, so that the method is callable through their trait objects
/// (`dyn CallableSpec<L>`, `dyn SpecsProvider<L>`), where the concrete type is
/// unknown. The method is defaulted to "unsupported", so a type that does not
/// participate in serialization writes exactly one line:
///
/// ```
/// use techy::core::specs::CallableSpec;
/// use techy::latexlike::Latexlike;
/// use techy::serialize::SerializableObject;
///
/// #[derive(Debug)]
/// struct MySpec;
///
/// // `MySpec` does not participate in serialization: the empty impl says so.
/// impl SerializableObject<Latexlike> for MySpec {}
///
/// impl CallableSpec<Latexlike> for MySpec {}
/// ```
///
/// A participating type overrides [`serialize_object`](Self::serialize_object): it
/// returns the identifier naming its kind together with its data, and interns through
/// the context every object it refers to. The method is available only when the
/// language is a [`SerializableLang`]: for any other language it cannot be called (and
/// no context value exists to call it with).
pub trait SerializableObject<L: Lang> {
    /// Produce this object's serialized form: its identifier and its data as a
    /// [`SerialEntry`].
    ///
    /// `cx` is the serialization in progress: an implementation interns through it
    /// every object this one refers to (a spec's provider, say), embedding the position
    /// it returns, and reads the session's user data through it.
    ///
    /// # Errors
    ///
    /// The default reports [`SerializeError::Unsupported`]: the type does not
    /// participate in serialization. An implementation returns an error when it
    /// cannot produce its serialized form.
    fn serialize_object(
        &self,
        cx: &mut SerializeContext<'_, L>,
    ) -> Result<SerialEntry, SerializeError>
    where
        L: SerializableLang,
    {
        let _ = cx;
        Err(SerializeError::unsupported())
    }
}

/// The read side of the serialization capability: a type that can rebuild an object
/// from its serialized data.
///
/// The trait is opt-in and implemented by concrete types only; a type that does not
/// participate implements nothing. It is never a supertrait: its associated type and
/// its constructor — a function without a `self` argument — would make the spec and
/// provider traits unusable as trait objects.
///
/// An implementation is put to work by registering it for one identifier on the table's
/// handle ([`TableHandle::register_type`](crate::serialize::TableHandle::register_type));
/// reading an entry that carries that identifier then calls
/// [`deserialize_object`](Self::deserialize_object). The paired write side is
/// [`SerializableObject`].
///
/// [`Output`](Self::Output) is what the read produces: the type itself for a type
/// rebuilt from a self-contained description, or a shared handle to an already
/// existing object (`Arc<dyn …>`) for a type that is looked up in the *reading
/// environment* — the live objects the deserializing program already holds (see the
/// [module documentation](crate::serialize)) — rather than rebuilt.
pub trait DeserializableObject<L: SerializableLang>: Sized {
    /// What [`deserialize_object`](Self::deserialize_object) produces.
    type Output;

    /// Rebuild an object from its serialized `value`.
    ///
    /// `cx` is the deserialization in progress: an implementation reads through it the
    /// objects this one refers to by position, and the session's user data — which is
    /// where the reading environment is found.
    ///
    /// # Errors
    ///
    /// `value` is untrusted input: a value of the wrong shape, an index out of range,
    /// or a reference to an object the reading environment (the live objects the
    /// deserializing program already holds) lacks is an error, never a panic.
    fn deserialize_object(
        value: &SerialValue,
        cx: &mut DeserializeContext<'_, L>,
    ) -> Result<Self::Output, DeserializeError>;
}

/// The write side of the serialization capability for *values*: data embedded in place
/// inside an entry.
///
/// A value is the counterpart of an *object*, which is a table entry referred to by
/// position (see the [module documentation](crate::serialize)). A language's mode, its
/// state ext, a group rule's group type, a source's origin are values: they are written
/// into the entry of the state or source that holds them, not interned in a table of
/// their own.
///
/// The trait is implemented by the owner of the type, for every language. The crate
/// implements it for `()`, `bool`, `char`, the integer types, `String`, `Option<T>` and
/// `Vec<T>` (over an implementing `T`), and for [`SerialValue`] itself (kept as it is) —
/// the types a language built on the crate's defaults supplies, and what a structure of
/// such fields is made of; the crate's own value types, spans above all, have their
/// impls next to the driver that writes them.
///
/// A language implements it for its own value and extension types, typically as
/// `impl<L: Lang> SerializableValue<L> for MyMode`, so that any language reusing the
/// type gets the conversion — or derives it with `#[derive(SerializableValue)]`.
/// [`SerializableLang`] requires it of every type the language supplies to the parse.
/// The methods are available only when the language is a [`SerializableLang`], like
/// [`SerializableObject::serialize_object`].
pub trait SerializableValue<L: Lang> {
    /// Produce this value's serialized form. `cx` gives the call access to the state
    /// of the serialization in progress — a value that refers to a table object
    /// (a span's source, say) interns it through `cx` and embeds the position.
    ///
    /// # Errors
    ///
    /// A [`SerializeError`] when the value cannot be represented in the serialized form
    /// (an integer outside `i64`, or an implementation's own reason).
    fn serialize_value(&self, cx: &mut SerializeContext<'_, L>) -> Result<SerialValue, SerializeError>
    where
        L: SerializableLang;

    /// Whether this value, as a field of a structure whose fields are written by name
    /// (a type with `#[derive(SerializableValue)]`), is left out of the structure's map
    /// entirely — no key at all, rather than a key with a `null` value. The default is
    /// `false`; `Option<T>` is absent when it is `None`.
    ///
    /// Only such structures consult this method. The slots the crate's own
    /// serialization fills with a language's value (a state's ext, a source's origin,
    /// …) always write their key, and a `None` there is written as `null`. A type that
    /// overrides this method also overrides
    /// [`DeserializableValue::deserialize_field`], so that the omitted key reads back.
    fn is_absent_field(&self) -> bool
    where
        L: SerializableLang,
    {
        false
    }
}

/// The read side of the serialization capability for *values*: rebuilding a value
/// embedded inline in an entry (see [`SerializableValue`] for what a value is, and
/// which types the crate implements this for).
pub trait DeserializableValue<L: Lang>: Sized {
    /// Rebuild the value from its serialized form. `cx` gives the call access to the
    /// state of the deserialization in progress.
    ///
    /// # Errors
    ///
    /// `value` is untrusted input: a value of the wrong kind or shape, an integer out
    /// of range, or a reference that cannot be read is an error, never a panic.
    fn deserialize_value(
        value: &SerialValue,
        cx: &mut DeserializeContext<'_, L>,
    ) -> Result<Self, DeserializeError>
    where
        L: SerializableLang;

    /// Rebuild this value as the field `name` of a structure whose fields are read by
    /// name (a type with `#[derive(DeserializableValue)]`): `value` is the field's
    /// value, or `None` when the key is missing from the map. The default requires
    /// the key and reads its value with [`deserialize_value`](Self::deserialize_value);
    /// `Option<T>` reads a missing key as `None`. The counterpart of
    /// [`SerializableValue::is_absent_field`]: a type overriding one overrides both.
    ///
    /// # Errors
    ///
    /// The key is missing and required ([`SerialValueError::MissingField`]), or the
    /// value is not of the expected kind or shape.
    fn deserialize_field(
        name: &'static str,
        value: Option<&SerialValue>,
        cx: &mut DeserializeContext<'_, L>,
    ) -> Result<Self, DeserializeError>
    where
        L: SerializableLang,
    {
        match value {
            Some(value) => Self::deserialize_value(value, cx),
            None => Err(DeserializeError::Value(SerialValueError::MissingField { name })),
        }
    }
}

// --- core value impls -----------------------------------------------------------------

fn value_mismatch(expected: &'static str, found: &SerialValue) -> DeserializeError {
    DeserializeError::Value(SerialValueError::TypeMismatch {
        expected: Cow::Borrowed(expected),
        found: found.kind_name(),
    })
}

/// `()` is [`Null`](SerialValue::Null).
impl<L: Lang> SerializableValue<L> for () {
    fn serialize_value(&self, _cx: &mut SerializeContext<'_, L>) -> Result<SerialValue, SerializeError>
    where
        L: SerializableLang,
    {
        Ok(SerialValue::Null)
    }
}

/// `()` is [`Null`](SerialValue::Null); any other value is an error.
impl<L: Lang> DeserializableValue<L> for () {
    fn deserialize_value(
        value: &SerialValue,
        _cx: &mut DeserializeContext<'_, L>,
    ) -> Result<Self, DeserializeError>
    where
        L: SerializableLang,
    {
        match value {
            SerialValue::Null => Ok(()),
            other => Err(value_mismatch("null (the unit value)", other)),
        }
    }
}

/// A `bool` is a [`Bool`](SerialValue::Bool).
impl<L: Lang> SerializableValue<L> for bool {
    fn serialize_value(&self, _cx: &mut SerializeContext<'_, L>) -> Result<SerialValue, SerializeError>
    where
        L: SerializableLang,
    {
        Ok(SerialValue::Bool(*self))
    }
}

/// A `bool` is a [`Bool`](SerialValue::Bool); any other value is an error.
impl<L: Lang> DeserializableValue<L> for bool {
    fn deserialize_value(
        value: &SerialValue,
        _cx: &mut DeserializeContext<'_, L>,
    ) -> Result<Self, DeserializeError>
    where
        L: SerializableLang,
    {
        match value {
            SerialValue::Bool(b) => Ok(*b),
            other => Err(value_mismatch("a boolean", other)),
        }
    }
}

/// Integers of every width are an [`Int`](SerialValue::Int): written when the value
/// fits `i64` (an error otherwise — never a truncation), read with a range check
/// against the target type.
macro_rules! int_value_impls {
    ($($t:ty),* $(,)?) => {$(
        impl<L: Lang> SerializableValue<L> for $t {
            fn serialize_value(
                &self,
                _cx: &mut SerializeContext<'_, L>,
            ) -> Result<SerialValue, SerializeError>
            where
                L: SerializableLang,
            {
                i64::try_from(*self).map(SerialValue::Int).map_err(|_| {
                    SerializeError::Value(SerialValueError::IntegerOutOfRange {
                        value: self.to_string(),
                        target: "i64",
                    })
                })
            }
        }

        impl<L: Lang> DeserializableValue<L> for $t {
            fn deserialize_value(
                value: &SerialValue,
                _cx: &mut DeserializeContext<'_, L>,
            ) -> Result<Self, DeserializeError>
            where
                L: SerializableLang,
            {
                match value {
                    SerialValue::Int(i) => <$t>::try_from(*i).map_err(|_| {
                        DeserializeError::Value(SerialValueError::IntegerOutOfRange {
                            value: i.to_string(),
                            target: stringify!($t),
                        })
                    }),
                    other => Err(value_mismatch("an integer", other)),
                }
            }
        }
    )*};
}
int_value_impls!(i8, i16, i32, i64, i128, isize, u8, u16, u32, u64, u128, usize);

/// A `char` is a one-character [`Str`](SerialValue::Str).
impl<L: Lang> SerializableValue<L> for char {
    fn serialize_value(&self, _cx: &mut SerializeContext<'_, L>) -> Result<SerialValue, SerializeError>
    where
        L: SerializableLang,
    {
        Ok(SerialValue::Str(String::from(*self)))
    }
}

/// A `char` is a one-character [`Str`](SerialValue::Str); any other value, including a
/// string of any other length, is an error.
impl<L: Lang> DeserializableValue<L> for char {
    fn deserialize_value(
        value: &SerialValue,
        _cx: &mut DeserializeContext<'_, L>,
    ) -> Result<Self, DeserializeError>
    where
        L: SerializableLang,
    {
        match value {
            SerialValue::Str(s) => {
                let mut chars = s.chars();
                match (chars.next(), chars.next()) {
                    (Some(c), None) => Ok(c),
                    _ => Err(value_mismatch("a one-character string", value)),
                }
            }
            other => Err(value_mismatch("a one-character string", other)),
        }
    }
}

/// A `String` is a [`Str`](SerialValue::Str).
impl<L: Lang> SerializableValue<L> for String {
    fn serialize_value(&self, _cx: &mut SerializeContext<'_, L>) -> Result<SerialValue, SerializeError>
    where
        L: SerializableLang,
    {
        Ok(SerialValue::Str(self.clone()))
    }
}

/// A `String` is a [`Str`](SerialValue::Str); any other value is an error.
impl<L: Lang> DeserializableValue<L> for String {
    fn deserialize_value(
        value: &SerialValue,
        _cx: &mut DeserializeContext<'_, L>,
    ) -> Result<Self, DeserializeError>
    where
        L: SerializableLang,
    {
        match value {
            SerialValue::Str(s) => Ok(s.clone()),
            other => Err(value_mismatch("a string", other)),
        }
    }
}

/// `None` is [`Null`](SerialValue::Null); `Some(value)` is the value's own form. (So
/// `Some(())` and `None` have the same form and read back as `None`; the same holds
/// for a `Some(None)`.) This is what serializes the default source origin,
/// `Option<String>`. As a field of a structure whose fields are written by name, a
/// `None` is absent: the key is left out ([`is_absent_field`](SerializableValue::is_absent_field)).
impl<L: Lang, T: SerializableValue<L>> SerializableValue<L> for Option<T> {
    fn serialize_value(&self, cx: &mut SerializeContext<'_, L>) -> Result<SerialValue, SerializeError>
    where
        L: SerializableLang,
    {
        match self {
            Some(value) => value.serialize_value(cx),
            None => Ok(SerialValue::Null),
        }
    }

    fn is_absent_field(&self) -> bool
    where
        L: SerializableLang,
    {
        self.is_none()
    }
}

/// [`Null`](SerialValue::Null) is `None`; any other value is read as `T`. As a field
/// of a structure whose fields are read by name, a missing key is `None` too
/// ([`deserialize_field`](DeserializableValue::deserialize_field)).
impl<L: Lang, T: DeserializableValue<L>> DeserializableValue<L> for Option<T> {
    fn deserialize_value(
        value: &SerialValue,
        cx: &mut DeserializeContext<'_, L>,
    ) -> Result<Self, DeserializeError>
    where
        L: SerializableLang,
    {
        match value {
            SerialValue::Null => Ok(None),
            other => T::deserialize_value(other, cx).map(Some),
        }
    }

    fn deserialize_field(
        _name: &'static str,
        value: Option<&SerialValue>,
        cx: &mut DeserializeContext<'_, L>,
    ) -> Result<Self, DeserializeError>
    where
        L: SerializableLang,
    {
        match value {
            Some(value) => Self::deserialize_value(value, cx),
            None => Ok(None),
        }
    }
}

/// A `Vec<T>` is a [`List`](SerialValue::List) of the elements' forms, in order.
impl<L: Lang, T: SerializableValue<L>> SerializableValue<L> for Vec<T> {
    fn serialize_value(&self, cx: &mut SerializeContext<'_, L>) -> Result<SerialValue, SerializeError>
    where
        L: SerializableLang,
    {
        self.iter()
            .map(|item| item.serialize_value(cx))
            .collect::<Result<Vec<_>, _>>()
            .map(SerialValue::List)
    }
}

/// A [`List`](SerialValue::List) is read element by element; any other value is an
/// error.
impl<L: Lang, T: DeserializableValue<L>> DeserializableValue<L> for Vec<T> {
    fn deserialize_value(
        value: &SerialValue,
        cx: &mut DeserializeContext<'_, L>,
    ) -> Result<Self, DeserializeError>
    where
        L: SerializableLang,
    {
        match value {
            SerialValue::List(items) => items.iter().map(|item| T::deserialize_value(item, cx)).collect(),
            other => Err(value_mismatch("a list", other)),
        }
    }
}

/// A [`SerialValue`] is itself a value, carried as it is: how a structure holds a part
/// that was converted elsewhere (a field a language's own conversion produced, kept
/// in a structure that converts the rest).
impl<L: Lang> SerializableValue<L> for SerialValue {
    fn serialize_value(&self, _cx: &mut SerializeContext<'_, L>) -> Result<SerialValue, SerializeError>
    where
        L: SerializableLang,
    {
        Ok(self.clone())
    }
}

/// A [`SerialValue`] is read as it is, whatever its kind.
impl<L: Lang> DeserializableValue<L> for SerialValue {
    fn deserialize_value(
        value: &SerialValue,
        _cx: &mut DeserializeContext<'_, L>,
    ) -> Result<Self, DeserializeError>
    where
        L: SerializableLang,
    {
        Ok(value.clone())
    }
}

// --- support for the derived code -----------------------------------------------------
//
// The field-by-name writer and reader of the wire layer, extended with the
// context-taking conversions the `SerializableValue` / `DeserializableValue` derives
// generate calls to. Reached through `techy::__private`; not public API.

impl FieldWriter {
    /// Append the field `name`, converted through [`SerializableValue`] with `cx`,
    /// unless the value is absent ([`SerializableValue::is_absent_field`]). Used by
    /// the derived `serialize_value`; not public API.
    ///
    /// # Errors
    ///
    /// The value's own conversion error.
    pub fn value_field<L: SerializableLang, T: SerializableValue<L> + ?Sized>(
        &mut self,
        name: &'static str,
        value: &T,
        cx: &mut SerializeContext<'_, L>,
    ) -> Result<(), SerializeError> {
        if value.is_absent_field() {
            return Ok(());
        }
        self.push(name, value.serialize_value(cx)?);
        Ok(())
    }
}

impl FieldReader<'_> {
    /// Read the field `name` (a declared one) through [`DeserializableValue`] with
    /// `cx`, a missing key handled by the type
    /// ([`DeserializableValue::deserialize_field`]). Used by the derived
    /// `deserialize_value`; not public API.
    ///
    /// # Errors
    ///
    /// The key is missing and the type requires it, or the value's own read error.
    pub fn value_field<L: SerializableLang, T: DeserializableValue<L>>(
        &self,
        name: &'static str,
        cx: &mut DeserializeContext<'_, L>,
    ) -> Result<T, DeserializeError> {
        T::deserialize_field(name, self.get(name), cx)
    }
}