1 |
zoff99 |
8 |
/* --- protobuf-c-private.h: private structures and functions --- */
|
2 |
|
|
/*
|
3 |
|
|
* Copyright 2008, Dave Benson.
|
4 |
|
|
*
|
5 |
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
|
|
* you may not use this file except in compliance with
|
7 |
|
|
* the License. You may obtain a copy of the License
|
8 |
|
|
* at http://www.apache.org/licenses/LICENSE-2.0 Unless
|
9 |
|
|
* required by applicable law or agreed to in writing,
|
10 |
|
|
* software distributed under the License is distributed on
|
11 |
|
|
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
12 |
|
|
* KIND, either express or implied. See the License for the
|
13 |
|
|
* specific language governing permissions and limitations
|
14 |
|
|
* under the License.
|
15 |
|
|
*/
|
16 |
|
|
|
17 |
|
|
|
18 |
|
|
/* === needs to be declared for the PROTOBUF_C_BUFFER_SIMPLE_INIT macro === */
|
19 |
|
|
|
20 |
|
|
void protobuf_c_buffer_simple_append (ProtobufCBuffer *buffer,
|
21 |
|
|
size_t len,
|
22 |
|
|
const unsigned char *data);
|
23 |
|
|
|
24 |
|
|
/* === stuff which needs to be declared for use in the generated code === */
|
25 |
|
|
|
26 |
|
|
struct _ProtobufCEnumValueIndex
|
27 |
|
|
{
|
28 |
|
|
const char *name;
|
29 |
|
|
unsigned index; /* into values[] array */
|
30 |
|
|
};
|
31 |
|
|
|
32 |
|
|
/* IntRange: helper structure for optimizing
|
33 |
|
|
int => index lookups
|
34 |
|
|
in the case where the keys are mostly consecutive values,
|
35 |
|
|
as they presumably are for enums and fields.
|
36 |
|
|
|
37 |
|
|
The data structures assumes that the values in the original
|
38 |
|
|
array are sorted */
|
39 |
|
|
struct _ProtobufCIntRange
|
40 |
|
|
{
|
41 |
|
|
int start_value;
|
42 |
|
|
unsigned orig_index;
|
43 |
|
|
/* NOTE: the number of values in the range can
|
44 |
|
|
be inferred by looking at the next element's orig_index.
|
45 |
|
|
a dummy element is added to make this simple */
|
46 |
|
|
};
|
47 |
|
|
|
48 |
|
|
|
49 |
|
|
/* === declared for exposition on ProtobufCIntRange === */
|
50 |
|
|
/* note: ranges must have an extra sentinel IntRange at the end whose
|
51 |
|
|
orig_index is set to the number of actual values in the original array */
|
52 |
|
|
/* returns -1 if no orig_index found */
|
53 |
|
|
int protobuf_c_int_ranges_lookup (unsigned n_ranges,
|
54 |
|
|
ProtobufCIntRange *ranges);
|
55 |
|
|
|
56 |
|
|
#define PROTOBUF_C_SERVICE_DESCRIPTOR_MAGIC 0x14159bc3
|
57 |
|
|
#define PROTOBUF_C_MESSAGE_DESCRIPTOR_MAGIC 0x28aaeef9
|
58 |
|
|
#define PROTOBUF_C_ENUM_DESCRIPTOR_MAGIC 0x114315af
|
59 |
|
|
|
60 |
|
|
/* === behind the scenes on the generated service's __init functions */
|
61 |
|
|
typedef void (*ProtobufCServiceDestroy) (ProtobufCService *service);
|
62 |
|
|
void
|
63 |
|
|
protobuf_c_service_generated_init (ProtobufCService *service,
|
64 |
|
|
const ProtobufCServiceDescriptor *descriptor,
|
65 |
|
|
ProtobufCServiceDestroy destroy);
|
66 |
|
|
|
67 |
|
|
void
|
68 |
|
|
protobuf_c_service_invoke_internal(ProtobufCService *service,
|
69 |
|
|
unsigned method_index,
|
70 |
|
|
const ProtobufCMessage *input,
|
71 |
|
|
ProtobufCClosure closure,
|
72 |
|
|
void *closure_data);
|