forked from qitab/cl-protobufs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpkgdcl.lisp
187 lines (163 loc) · 4.29 KB
/
pkgdcl.lisp
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
;;; Copyright 2012-2020 Google LLC
;;;
;;; Use of this source code is governed by an MIT-style
;;; license that can be found in the LICENSE file or at
;;; https://opensource.org/licenses/MIT.
(in-package "CL-USER")
(defpackage #:cl-protobufs
(:use)
(:export
;; Base type for all message instances.
#:message
;; Message field types and related definitions.
#:int32
#:int64
#:uint32
#:uint64
#:sint32
#:sint64
#:fixed32
#:fixed64
#:sfixed32
#:sfixed64
#:list-of
#:vector-of
#:byte-vector
#:make-byte-vector
;; Enumerations
#:enum-keywords
#:enum-int-to-keyword
#:enum-keyword-to-int
;; Serialization to/from various formats
;; Binary format
#:serialize-to-stream
#:serialize-to-bytes
#:deserialize-from-stream
#:deserialize-from-bytes
#:make-message-with-bytes
#:set-method-do-not-deserialize-input
;; JSON
#:parse-json
#:print-json
;; Text format - not well specified, prefer json or binary
#:parse-text-format
#:print-text-format
#:fmt
;; Descriptors -- descriptors contain all the information parsed from .proto
;; files and may be looked up by the symbol naming a protobuf message, enum,
;; etc. For most use cases it's not necessary to deal with descriptors
;; directly; just access the protos through the generated code APIs and a
;; few other generic APIs above. The descriptor APIs are mostly intended for
;; writing code that deals with arbitrary protos when the types aren't known
;; in advance.
#:abstract-descriptor
#:descriptor
#:enum-descriptor
#:enum-value-descriptor
#:extension-descriptor
#:field-descriptor
#:file-descriptor
#:map-descriptor
#:message-descriptor
#:method-descriptor
#:option-descriptor
#:service-descriptor
;; Descriptor lookup
#:find-enum-descriptor
#:find-field-descriptor
#:find-file-descriptor
#:find-map-descriptor
#:find-message-descriptor
#:find-method-descriptor
#:find-service-descriptor
;; descriptor accessors
#:enum-descriptor-class
#:enum-descriptor-name
#:enum-descriptor-values
;; The map-* versions are deprecated, to be removed in release 4.0.
#:proto-key-type #:map-key-type
#:proto-value-kind #:map-value-kind
#:proto-value-type #:map-value-type
#:oneof-descriptor-fields
#:oneof-descriptor-name
#:oneof-descriptor-synthetic-p
#:proto-class
#:proto-client-stub
#:proto-container
#:proto-default
#:proto-edition
#:proto-external-field-name
#:proto-fields
#:proto-imports
#:proto-index
#:proto-input-name
#:proto-input-streaming-p
#:proto-input-type
#:proto-internal-field-name
#:proto-kind
#:proto-label
#:proto-methods
#:proto-name
#:proto-oneofs
#:proto-options
#:proto-output-name
#:proto-output-streaming-p
#:proto-output-type
#:proto-package-name
#:proto-qualified-name
#:proto-server-stub
#:proto-old-server-stub
#:proto-service-name
#:proto-source-location
#:proto-streams-name
#:proto-streams-type
#:proto-type
#:proto-value
#:find-option ; finds an option, not a descriptor
;; Conditions
#:protobuf-error
#:unknown-type
#:unknown-field-type
;; Extensions
#:get-extension
#:set-extension
#:has-extension
#:clear-extension
;; The Python "compatibility" API
#:is-initialized
#:proto-equal
#:clear
#:has-field
#:proto-slot-value
#:encoded-field
#:merge-from
;; For RPC stubs
;; An RPC library supporting the client functions defined in
;; `define-service` should bind these.
#:*rpc-call-function*
#:*rpc-streaming-client-function*))
(defpackage #:cl-protobufs.implementation
(:use :common-lisp :cl-protobufs)
(:import-from :alexandria #:define-constant)
(:export
;; Exported for use by generated code. These shouldn't be called directly.
#:define-schema
#:define-enum
#:define-map
#:define-oneof
#:define-message
#:define-extend
#:define-extension
#:define-service
#:add-file-descriptor
;; TODO(cgay): These should be removed or moved to the interface package, as
;; appropriate.
#:encode-double
#:encode-string
#:encode-uint32
#:make-deserializer
#:make-serializer
#:make-tag
#:serialize-scalar
;; For ASDF
#:validate-imports))