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
//! Port of `src/nvim/eval/typval_encode.h` (vendored at
//! `vendor/eval/typval_encode.h`) — the `MPConvStack` conversion-state types shared
//! by the `typval_encode.c.h` template, plus the minimal `klib/kvec.h`
//! (vendored at `vendor/klib/kvec.h`) vector this header instantiates.
//!
//! RUST-PORT NOTE: vimlrs's `encode.rs` renders values by direct recursion, so
//! nothing constructs an `MPConvStack` at runtime — these types exist as a
//! faithful reference so `conv_error()` (`encode.c:113`), which walks a stack to
//! build an object-path error message, can be ported verbatim. The pointer
//! fields of `MPConvStackVal` (`hashitem_T *hi`, `listitem_T *li`,
//! `typval_T *arg`/`*argv`, `dict_T **dictp`) become indices / owned handles
//! because the port's `list_T`/`dict_T` are `Vec`/`IndexMap`-backed rather than
//! intrusive linked structures (see `typval_defs_h`).
use RefCell;
use Rc;
use crate;
/// `kvec_withinit_t(type, INIT_SIZE)` from `klib/kvec.h:150` (vendored at
/// `vendor/klib/kvec.h`).
///
/// RUST-PORT NOTE: the C small-vector-optimized kvec (an `INIT_SIZE`-slot inline
/// array that spills to a heap `items` pointer once it grows) collapses to a
/// plain `Vec<T>` here — identical push / index / size semantics, no manual
/// `capacity`/`size` bookkeeping.
// A hand-written `Default` (the `derive` would spuriously require `T: Default`).
/// Port of the `kv_size(v)` macro from `klib/kvec.h:68` — number of elements.
/// Port of the `kv_A(v, i)` macro from `klib/kvec.h:66` — element access.
/// Port of the `kvi_push(v, x)` macro from `klib/kvec.h:253` — append an element.
/// Port of `MPConvStackValType` from `typval_encode.h:18` — type of a stack
/// entry.
/// Port of `MPConvPartialStage` from `typval_encode.h:27` — stage at which a
/// partial is being converted.
/// Port of the `union data` of `MPConvStackVal` (`typval_encode.h:38`).
///
/// RUST-PORT NOTE: the C `union` (a single overlaid storage read according to
/// the sibling `type` tag) becomes a Rust `enum` whose variants keep the C union
/// member names (`d`/`l`/`p`/`a`) and sub-field names verbatim.
/// Port of `MPConvStackVal` from `typval_encode.h:34` — one entry of the
/// Vimscript-to-messagepack conversion stack.
/// Port of `MPConvStack` from `typval_encode.h:64` — the stack used to convert
/// Vimscript values to messagepack (`kvec_withinit_t(MPConvStackVal, 8)`).
pub type MPConvStack = ;