~bigbes/tarantool

tarantool-protobuf

ref: 5de883e9079faacdcdccb853011e52142cbb16b9 tarantool-protobuf/examples/expected/runtime/c_nested/c_nested_pb.lua -rw-r--r-- 5.6 KiB
5de883e9 — Eugene Blikh beads: close 4ql (ibuf encoder not viable) + memory note on FFI boundary tax 2 months ago
                                                                                
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
-- Code generated by protoc-gen-tarantool. DO NOT EDIT.
-- source: c_nested.proto
-- syntax: proto3
-- package: c_nested

local pb = require("pb")
local wire = pb.wire
local string_byte = string.byte
local utf8_len = require('utf8').len
local band = bit.band
local rshift = bit.rshift

local M = {}

M.options = {go_package = "tarantoolpb_synthetic/c_nested"}

-- Pre-declare message descriptors so cross-references resolve.
M.L1_descriptor = {name = "c_nested.L1"}
M.L2_descriptor = {name = "c_nested.L2"}
M.L3_descriptor = {name = "c_nested.L3"}
M.L4_descriptor = {name = "c_nested.L4"}
M.L5_descriptor = {name = "c_nested.L5"}

-- Message: c_nested.L1
M.L1_descriptor.fields = {
    {name="next", id=1, kind='message', message=M.L2_descriptor},
    {name="v", id=2, kind='scalar', proto_type="int32"},
}
pb.finalize_message(M.L1_descriptor)
M.L1_fields = pb.field_names({
    next = "next",
    v = "v",
})

-- Message: c_nested.L2
M.L2_descriptor.fields = {
    {name="next", id=1, kind='message', message=M.L3_descriptor},
    {name="v", id=2, kind='scalar', proto_type="int32"},
}
pb.finalize_message(M.L2_descriptor)
M.L2_fields = pb.field_names({
    next = "next",
    v = "v",
})

-- Message: c_nested.L3
M.L3_descriptor.fields = {
    {name="next", id=1, kind='message', message=M.L4_descriptor},
    {name="v", id=2, kind='scalar', proto_type="int32"},
}
pb.finalize_message(M.L3_descriptor)
M.L3_fields = pb.field_names({
    next = "next",
    v = "v",
})

-- Message: c_nested.L4
M.L4_descriptor.fields = {
    {name="next", id=1, kind='message', message=M.L5_descriptor},
    {name="v", id=2, kind='scalar', proto_type="int32"},
}
pb.finalize_message(M.L4_descriptor)
M.L4_fields = pb.field_names({
    next = "next",
    v = "v",
})

-- Message: c_nested.L5
M.L5_descriptor.fields = {
    {name="v", id=2, kind='scalar', proto_type="int32"},
}
pb.finalize_message(M.L5_descriptor)
M.L5_fields = pb.field_names({
    v = "v",
})

-- EmmyLua / lua-language-server type annotations.
-- These are comments — no runtime effect. They give editors
-- autocomplete and type-checking for the generated wrappers.
--- 5-level chain of singular sub-messages. Used by the bd-hwe (ra6 3d)
--- C-runtime tests to verify recursion across non-trivial depth. Each
--- level carries an int32 so the encoded body at each level is
--- non-empty (catches off-by-one bugs in the length-prefix path).
---@class c_nested.L1
---@field next c_nested.L2
---@field v integer

---@class c_nested.L2
---@field next c_nested.L3
---@field v integer

---@class c_nested.L3
---@field next c_nested.L4
---@field v integer

---@class c_nested.L4
---@field next c_nested.L5
---@field v integer

---@class c_nested.L5
---@field v integer

---@param t? c_nested.L1
---@return c_nested.L1
function M.L1_new(t) return t or {} end
---@param t c_nested.L1
---@return string
function M.L1_encode(t) return pb.encode(M.L1_descriptor, t) end
---@param b string
---@return c_nested.L1
function M.L1_decode(b) return pb.decode(M.L1_descriptor, b) end
---@param b string
---@return pb.MessageView
function M.L1_decode_lazy(b) return pb.decode_lazy(M.L1_descriptor, b) end
---@param t c_nested.L1
---@param opts? {single_line: boolean?, indent: string?}
---@return string
function M.L1_text(t, opts) return pb.text.encode(M.L1_descriptor, t, opts) end

---@param t? c_nested.L2
---@return c_nested.L2
function M.L2_new(t) return t or {} end
---@param t c_nested.L2
---@return string
function M.L2_encode(t) return pb.encode(M.L2_descriptor, t) end
---@param b string
---@return c_nested.L2
function M.L2_decode(b) return pb.decode(M.L2_descriptor, b) end
---@param b string
---@return pb.MessageView
function M.L2_decode_lazy(b) return pb.decode_lazy(M.L2_descriptor, b) end
---@param t c_nested.L2
---@param opts? {single_line: boolean?, indent: string?}
---@return string
function M.L2_text(t, opts) return pb.text.encode(M.L2_descriptor, t, opts) end

---@param t? c_nested.L3
---@return c_nested.L3
function M.L3_new(t) return t or {} end
---@param t c_nested.L3
---@return string
function M.L3_encode(t) return pb.encode(M.L3_descriptor, t) end
---@param b string
---@return c_nested.L3
function M.L3_decode(b) return pb.decode(M.L3_descriptor, b) end
---@param b string
---@return pb.MessageView
function M.L3_decode_lazy(b) return pb.decode_lazy(M.L3_descriptor, b) end
---@param t c_nested.L3
---@param opts? {single_line: boolean?, indent: string?}
---@return string
function M.L3_text(t, opts) return pb.text.encode(M.L3_descriptor, t, opts) end

---@param t? c_nested.L4
---@return c_nested.L4
function M.L4_new(t) return t or {} end
---@param t c_nested.L4
---@return string
function M.L4_encode(t) return pb.encode(M.L4_descriptor, t) end
---@param b string
---@return c_nested.L4
function M.L4_decode(b) return pb.decode(M.L4_descriptor, b) end
---@param b string
---@return pb.MessageView
function M.L4_decode_lazy(b) return pb.decode_lazy(M.L4_descriptor, b) end
---@param t c_nested.L4
---@param opts? {single_line: boolean?, indent: string?}
---@return string
function M.L4_text(t, opts) return pb.text.encode(M.L4_descriptor, t, opts) end

---@param t? c_nested.L5
---@return c_nested.L5
function M.L5_new(t) return t or {} end
---@param t c_nested.L5
---@return string
function M.L5_encode(t) return pb.encode(M.L5_descriptor, t) end
---@param b string
---@return c_nested.L5
function M.L5_decode(b) return pb.decode(M.L5_descriptor, b) end
---@param b string
---@return pb.MessageView
function M.L5_decode_lazy(b) return pb.decode_lazy(M.L5_descriptor, b) end
---@param t c_nested.L5
---@param opts? {single_line: boolean?, indent: string?}
---@return string
function M.L5_text(t, opts) return pb.text.encode(M.L5_descriptor, t, opts) end

return M