]>
Commit | Line | Data |
---|---|---|
f67539c2 TL |
1 | /* |
2 | * Licensed to the Apache Software Foundation (ASF) under one | |
3 | * or more contributor license agreements. See the NOTICE file | |
4 | * distributed with this work for additional information | |
5 | * regarding copyright ownership. The ASF licenses this file | |
6 | * to you under the Apache License, Version 2.0 (the | |
7 | * "License"); you may not use this file except in compliance | |
8 | * with the License. You may obtain a copy of the License at | |
9 | * | |
10 | * http://www.apache.org/licenses/LICENSE-2.0 | |
11 | * | |
12 | * Unless required by applicable law or agreed to in writing, | |
13 | * software distributed under the License is distributed on an | |
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
15 | * KIND, either express or implied. See the License for the | |
16 | * specific language governing permissions and limitations | |
17 | * under the License. | |
18 | */ | |
19 | ||
20 | #include <string.h> | |
21 | #include <stdio.h> | |
22 | #include <glib.h> | |
23 | #include <glib-object.h> | |
24 | ||
25 | #include <thrift/c_glib/thrift.h> | |
26 | #include <thrift/c_glib/protocol/thrift_protocol.h> | |
27 | #include <thrift/c_glib/protocol/thrift_binary_protocol.h> | |
28 | #include <thrift/c_glib/protocol/thrift_protocol_decorator.h> | |
29 | ||
30 | G_DEFINE_TYPE(ThriftProtocolDecorator, thrift_protocol_decorator, THRIFT_TYPE_PROTOCOL) | |
31 | ||
32 | ||
33 | enum | |
34 | { | |
35 | PROP_THRIFT_TYPE_PROTOCOL_DECORATOR_CONCRETE_PROTOCOL = 1, | |
36 | PROP_THRIFT_TYPE_PROTOCOL_DECORATOR_END | |
37 | }; | |
38 | ||
39 | static GParamSpec *thrift_protocol_decorator_obj_properties[PROP_THRIFT_TYPE_PROTOCOL_DECORATOR_END] = { NULL, }; | |
40 | ||
41 | ||
42 | ||
43 | ||
44 | ||
45 | gint32 | |
46 | thrift_protocol_decorator_write_message_begin (ThriftProtocol *protocol, | |
47 | const gchar *name, | |
48 | const ThriftMessageType message_type, | |
49 | const gint32 seqid, GError **error) | |
50 | { | |
51 | ||
52 | ThriftProtocolDecorator *self = THRIFT_PROTOCOL_DECORATOR (protocol); | |
53 | ThriftProtocolClass *proto = THRIFT_PROTOCOL_GET_CLASS (self->concrete_protocol); | |
54 | ||
55 | g_debug("Concrete protocol %p | %p", (void *)self->concrete_protocol, (void *)proto); | |
56 | ||
57 | return proto->write_message_begin (self->concrete_protocol, name, | |
58 | message_type, seqid, | |
59 | error); | |
60 | } | |
61 | ||
62 | gint32 | |
63 | thrift_protocol_decorator_write_message_end (ThriftProtocol *protocol, GError **error) | |
64 | { | |
65 | ThriftProtocolDecorator *self = THRIFT_PROTOCOL_DECORATOR (protocol); | |
66 | ||
67 | return THRIFT_PROTOCOL_GET_CLASS (self->concrete_protocol)->write_message_end (self->concrete_protocol, | |
68 | error); | |
69 | } | |
70 | ||
71 | gint32 | |
72 | thrift_protocol_decorator_write_struct_begin (ThriftProtocol *protocol, const gchar *name, | |
73 | GError **error) | |
74 | { | |
75 | ThriftProtocolDecorator *self = THRIFT_PROTOCOL_DECORATOR (protocol); | |
76 | ||
77 | return THRIFT_PROTOCOL_GET_CLASS (self->concrete_protocol)->write_struct_begin (self->concrete_protocol, | |
78 | name, error); | |
79 | } | |
80 | ||
81 | gint32 | |
82 | thrift_protocol_decorator_write_struct_end (ThriftProtocol *protocol, GError **error) | |
83 | { | |
84 | ThriftProtocolDecorator *self = THRIFT_PROTOCOL_DECORATOR (protocol); | |
85 | ||
86 | return THRIFT_PROTOCOL_GET_CLASS (self->concrete_protocol)->write_struct_end (self->concrete_protocol, | |
87 | error); | |
88 | } | |
89 | ||
90 | gint32 | |
91 | thrift_protocol_decorator_write_field_begin (ThriftProtocol *protocol, | |
92 | const gchar *name, | |
93 | const ThriftType field_type, | |
94 | const gint16 field_id, | |
95 | GError **error) | |
96 | { | |
97 | ThriftProtocolDecorator *self = THRIFT_PROTOCOL_DECORATOR (protocol); | |
98 | return THRIFT_PROTOCOL_GET_CLASS (self->concrete_protocol)->write_field_begin (self->concrete_protocol, | |
99 | name, field_type, | |
100 | field_id, error); | |
101 | } | |
102 | ||
103 | gint32 | |
104 | thrift_protocol_decorator_write_field_end (ThriftProtocol *protocol, GError **error) | |
105 | { | |
106 | ThriftProtocolDecorator *self = THRIFT_PROTOCOL_DECORATOR (protocol); | |
107 | ||
108 | return THRIFT_PROTOCOL_GET_CLASS (self->concrete_protocol)->write_field_end (self->concrete_protocol, | |
109 | error); | |
110 | } | |
111 | ||
112 | gint32 | |
113 | thrift_protocol_decorator_write_field_stop (ThriftProtocol *protocol, GError **error) | |
114 | { | |
115 | ThriftProtocolDecorator *self = THRIFT_PROTOCOL_DECORATOR (protocol); | |
116 | ||
117 | return THRIFT_PROTOCOL_GET_CLASS (self->concrete_protocol)->write_field_stop (self->concrete_protocol, | |
118 | error); | |
119 | } | |
120 | ||
121 | gint32 | |
122 | thrift_protocol_decorator_write_map_begin (ThriftProtocol *protocol, | |
123 | const ThriftType key_type, | |
124 | const ThriftType value_type, | |
125 | const guint32 size, GError **error) | |
126 | { | |
127 | ThriftProtocolDecorator *self = THRIFT_PROTOCOL_DECORATOR (protocol); | |
128 | ||
129 | return THRIFT_PROTOCOL_GET_CLASS (self->concrete_protocol)->write_map_begin (self->concrete_protocol, | |
130 | key_type, value_type, | |
131 | size, error); | |
132 | } | |
133 | ||
134 | gint32 | |
135 | thrift_protocol_decorator_write_map_end (ThriftProtocol *protocol, GError **error) | |
136 | { | |
137 | ThriftProtocolDecorator *self = THRIFT_PROTOCOL_DECORATOR (protocol); | |
138 | ||
139 | return THRIFT_PROTOCOL_GET_CLASS (self->concrete_protocol)->write_map_end (self->concrete_protocol, | |
140 | error); | |
141 | } | |
142 | ||
143 | gint32 | |
144 | thrift_protocol_decorator_write_list_begin (ThriftProtocol *protocol, | |
145 | const ThriftType element_type, | |
146 | const guint32 size, GError **error) | |
147 | { | |
148 | ThriftProtocolDecorator *self = THRIFT_PROTOCOL_DECORATOR (protocol); | |
149 | ||
150 | return THRIFT_PROTOCOL_GET_CLASS (self->concrete_protocol)->write_list_begin (self->concrete_protocol, | |
151 | element_type, size, | |
152 | error); | |
153 | } | |
154 | ||
155 | gint32 | |
156 | thrift_protocol_decorator_write_list_end (ThriftProtocol *protocol, GError **error) | |
157 | { | |
158 | ThriftProtocolDecorator *self = THRIFT_PROTOCOL_DECORATOR (protocol); | |
159 | ||
160 | return THRIFT_PROTOCOL_GET_CLASS (self->concrete_protocol)->write_list_end (self->concrete_protocol, | |
161 | error); | |
162 | } | |
163 | ||
164 | gint32 | |
165 | thrift_protocol_decorator_write_set_begin (ThriftProtocol *protocol, | |
166 | const ThriftType element_type, | |
167 | const guint32 size, GError **error) | |
168 | { | |
169 | ThriftProtocolDecorator *self = THRIFT_PROTOCOL_DECORATOR (protocol); | |
170 | ||
171 | return THRIFT_PROTOCOL_GET_CLASS (self->concrete_protocol)->write_set_begin (self->concrete_protocol, | |
172 | element_type, size, | |
173 | error); | |
174 | } | |
175 | ||
176 | gint32 | |
177 | thrift_protocol_decorator_write_set_end (ThriftProtocol *protocol, GError **error) | |
178 | { | |
179 | ThriftProtocolDecorator *self = THRIFT_PROTOCOL_DECORATOR (protocol); | |
180 | ||
181 | return THRIFT_PROTOCOL_GET_CLASS (self->concrete_protocol)->write_set_end (self->concrete_protocol, | |
182 | error); | |
183 | } | |
184 | ||
185 | gint32 | |
186 | thrift_protocol_decorator_write_bool (ThriftProtocol *protocol, | |
187 | const gboolean value, GError **error) | |
188 | { | |
189 | ThriftProtocolDecorator *self = THRIFT_PROTOCOL_DECORATOR (protocol); | |
190 | ||
191 | return THRIFT_PROTOCOL_GET_CLASS (self->concrete_protocol)->write_bool (self->concrete_protocol, value, | |
192 | error); | |
193 | } | |
194 | ||
195 | gint32 | |
196 | thrift_protocol_decorator_write_byte (ThriftProtocol *protocol, const gint8 value, | |
197 | GError **error) | |
198 | { | |
199 | ThriftProtocolDecorator *self = THRIFT_PROTOCOL_DECORATOR (protocol); | |
200 | ||
201 | return THRIFT_PROTOCOL_GET_CLASS (self->concrete_protocol)->write_byte (self->concrete_protocol, value, | |
202 | error); | |
203 | } | |
204 | ||
205 | gint32 | |
206 | thrift_protocol_decorator_write_i16 (ThriftProtocol *protocol, const gint16 value, | |
207 | GError **error) | |
208 | { | |
209 | ThriftProtocolDecorator *self = THRIFT_PROTOCOL_DECORATOR (protocol); | |
210 | ||
211 | return THRIFT_PROTOCOL_GET_CLASS (self->concrete_protocol)->write_i16 (self->concrete_protocol, value, | |
212 | error); | |
213 | } | |
214 | ||
215 | gint32 | |
216 | thrift_protocol_decorator_write_i32 (ThriftProtocol *protocol, const gint32 value, | |
217 | GError **error) | |
218 | { | |
219 | ThriftProtocolDecorator *self = THRIFT_PROTOCOL_DECORATOR (protocol); | |
220 | ||
221 | return THRIFT_PROTOCOL_GET_CLASS (self->concrete_protocol)->write_i32 (self->concrete_protocol, value, | |
222 | error); | |
223 | } | |
224 | ||
225 | gint32 | |
226 | thrift_protocol_decorator_write_i64 (ThriftProtocol *protocol, const gint64 value, | |
227 | GError **error) | |
228 | { | |
229 | ThriftProtocolDecorator *self = THRIFT_PROTOCOL_DECORATOR (protocol); | |
230 | ||
231 | return THRIFT_PROTOCOL_GET_CLASS (self->concrete_protocol)->write_i64 (self->concrete_protocol, value, | |
232 | error); | |
233 | } | |
234 | ||
235 | gint32 | |
236 | thrift_protocol_decorator_write_double (ThriftProtocol *protocol, | |
237 | const gdouble value, GError **error) | |
238 | { | |
239 | ThriftProtocolDecorator *self = THRIFT_PROTOCOL_DECORATOR (protocol); | |
240 | ||
241 | return THRIFT_PROTOCOL_GET_CLASS (self->concrete_protocol)->write_double (self->concrete_protocol, | |
242 | value, error); | |
243 | } | |
244 | ||
245 | gint32 | |
246 | thrift_protocol_decorator_write_string (ThriftProtocol *protocol, | |
247 | const gchar *str, GError **error) | |
248 | { | |
249 | ThriftProtocolDecorator *self = THRIFT_PROTOCOL_DECORATOR (protocol); | |
250 | ||
251 | return THRIFT_PROTOCOL_GET_CLASS (self->concrete_protocol)->write_string (self->concrete_protocol, str, | |
252 | error); | |
253 | } | |
254 | ||
255 | gint32 | |
256 | thrift_protocol_decorator_write_binary (ThriftProtocol *protocol, const gpointer buf, | |
257 | const guint32 len, GError **error) | |
258 | { | |
259 | ThriftProtocolDecorator *self = THRIFT_PROTOCOL_DECORATOR (protocol); | |
260 | ||
261 | return THRIFT_PROTOCOL_GET_CLASS (self->concrete_protocol)->write_binary (self->concrete_protocol, buf, | |
262 | len, error); | |
263 | } | |
264 | ||
265 | gint32 | |
266 | thrift_protocol_decorator_read_message_begin (ThriftProtocol *protocol, | |
267 | gchar **name, | |
268 | ThriftMessageType *message_type, | |
269 | gint32 *seqid, GError **error) | |
270 | { | |
271 | ThriftProtocolDecorator *self = THRIFT_PROTOCOL_DECORATOR (protocol); | |
272 | ||
273 | return THRIFT_PROTOCOL_GET_CLASS (self->concrete_protocol)->read_message_begin (self->concrete_protocol, | |
274 | name, message_type, | |
275 | seqid, error); | |
276 | } | |
277 | ||
278 | gint32 | |
279 | thrift_protocol_decorator_read_message_end (ThriftProtocol *protocol, | |
280 | GError **error) | |
281 | { | |
282 | ThriftProtocolDecorator *self = THRIFT_PROTOCOL_DECORATOR (protocol); | |
283 | ||
284 | return THRIFT_PROTOCOL_GET_CLASS (self->concrete_protocol)->read_message_end (self->concrete_protocol, | |
285 | error); | |
286 | } | |
287 | ||
288 | gint32 | |
289 | thrift_protocol_decorator_read_struct_begin (ThriftProtocol *protocol, | |
290 | gchar **name, | |
291 | GError **error) | |
292 | { | |
293 | ThriftProtocolDecorator *self = THRIFT_PROTOCOL_DECORATOR (protocol); | |
294 | ||
295 | return THRIFT_PROTOCOL_GET_CLASS (self->concrete_protocol)->read_struct_begin (self->concrete_protocol, | |
296 | name, | |
297 | error); | |
298 | } | |
299 | ||
300 | gint32 | |
301 | thrift_protocol_decorator_read_struct_end (ThriftProtocol *protocol, GError **error) | |
302 | { | |
303 | ThriftProtocolDecorator *self = THRIFT_PROTOCOL_DECORATOR (protocol); | |
304 | ||
305 | return THRIFT_PROTOCOL_GET_CLASS (self->concrete_protocol)->read_struct_end (self->concrete_protocol, | |
306 | error); | |
307 | } | |
308 | ||
309 | gint32 | |
310 | thrift_protocol_decorator_read_field_begin (ThriftProtocol *protocol, | |
311 | gchar **name, | |
312 | ThriftType *field_type, | |
313 | gint16 *field_id, | |
314 | GError **error) | |
315 | { | |
316 | ThriftProtocolDecorator *self = THRIFT_PROTOCOL_DECORATOR (protocol); | |
317 | ||
318 | return THRIFT_PROTOCOL_GET_CLASS (self->concrete_protocol)->read_field_begin (self->concrete_protocol, | |
319 | name, | |
320 | field_type, | |
321 | field_id, | |
322 | error); | |
323 | } | |
324 | ||
325 | gint32 | |
326 | thrift_protocol_decorator_read_field_end (ThriftProtocol *protocol, | |
327 | GError **error) | |
328 | { | |
329 | ThriftProtocolDecorator *self = THRIFT_PROTOCOL_DECORATOR (protocol); | |
330 | ||
331 | return THRIFT_PROTOCOL_GET_CLASS (self->concrete_protocol)->read_field_end (self->concrete_protocol, | |
332 | error); | |
333 | } | |
334 | ||
335 | gint32 | |
336 | thrift_protocol_decorator_read_map_begin (ThriftProtocol *protocol, | |
337 | ThriftType *key_type, | |
338 | ThriftType *value_type, guint32 *size, | |
339 | GError **error) | |
340 | { | |
341 | ThriftProtocolDecorator *self = THRIFT_PROTOCOL_DECORATOR (protocol); | |
342 | ||
343 | return THRIFT_PROTOCOL_GET_CLASS (self->concrete_protocol)->read_map_begin (self->concrete_protocol, | |
344 | key_type, | |
345 | value_type, | |
346 | size, | |
347 | error); | |
348 | } | |
349 | ||
350 | gint32 | |
351 | thrift_protocol_decorator_read_map_end (ThriftProtocol *protocol, GError **error) | |
352 | { | |
353 | ThriftProtocolDecorator *self = THRIFT_PROTOCOL_DECORATOR (protocol); | |
354 | ||
355 | return THRIFT_PROTOCOL_GET_CLASS (self->concrete_protocol)->read_map_end (self->concrete_protocol, | |
356 | error); | |
357 | } | |
358 | ||
359 | gint32 | |
360 | thrift_protocol_decorator_read_list_begin (ThriftProtocol *protocol, | |
361 | ThriftType *element_type, | |
362 | guint32 *size, GError **error) | |
363 | { | |
364 | ThriftProtocolDecorator *self = THRIFT_PROTOCOL_DECORATOR (protocol); | |
365 | ||
366 | return THRIFT_PROTOCOL_GET_CLASS (self->concrete_protocol)->read_list_begin (self->concrete_protocol, | |
367 | element_type, | |
368 | size, error); | |
369 | } | |
370 | ||
371 | gint32 | |
372 | thrift_protocol_decorator_read_list_end (ThriftProtocol *protocol, GError **error) | |
373 | { | |
374 | ThriftProtocolDecorator *self = THRIFT_PROTOCOL_DECORATOR (protocol); | |
375 | ||
376 | return THRIFT_PROTOCOL_GET_CLASS (self->concrete_protocol)->read_list_end (self->concrete_protocol, | |
377 | error); | |
378 | } | |
379 | ||
380 | gint32 | |
381 | thrift_protocol_decorator_read_set_begin (ThriftProtocol *protocol, | |
382 | ThriftType *element_type, | |
383 | guint32 *size, GError **error) | |
384 | { | |
385 | ThriftProtocolDecorator *self = THRIFT_PROTOCOL_DECORATOR (protocol); | |
386 | ||
387 | return THRIFT_PROTOCOL_GET_CLASS (self->concrete_protocol)->read_set_begin (self->concrete_protocol, | |
388 | element_type, | |
389 | size, error); | |
390 | } | |
391 | ||
392 | gint32 | |
393 | thrift_protocol_decorator_read_set_end (ThriftProtocol *protocol, GError **error) | |
394 | { | |
395 | ThriftProtocolDecorator *self = THRIFT_PROTOCOL_DECORATOR (protocol); | |
396 | ||
397 | return THRIFT_PROTOCOL_GET_CLASS (self->concrete_protocol)->read_set_end (self->concrete_protocol, | |
398 | error); | |
399 | } | |
400 | ||
401 | gint32 | |
402 | thrift_protocol_decorator_read_bool (ThriftProtocol *protocol, gboolean *value, | |
403 | GError **error) | |
404 | { | |
405 | ThriftProtocolDecorator *self = THRIFT_PROTOCOL_DECORATOR (protocol); | |
406 | ||
407 | return THRIFT_PROTOCOL_GET_CLASS (self->concrete_protocol)->read_bool (self->concrete_protocol, value, | |
408 | error); | |
409 | } | |
410 | ||
411 | gint32 | |
412 | thrift_protocol_decorator_read_byte (ThriftProtocol *protocol, gint8 *value, | |
413 | GError **error) | |
414 | { | |
415 | ThriftProtocolDecorator *self = THRIFT_PROTOCOL_DECORATOR (protocol); | |
416 | ||
417 | return THRIFT_PROTOCOL_GET_CLASS (self->concrete_protocol)->read_byte (self->concrete_protocol, value, | |
418 | error); | |
419 | } | |
420 | ||
421 | gint32 | |
422 | thrift_protocol_decorator_read_i16 (ThriftProtocol *protocol, gint16 *value, | |
423 | GError **error) | |
424 | { | |
425 | ThriftProtocolDecorator *self = THRIFT_PROTOCOL_DECORATOR (protocol); | |
426 | ||
427 | return THRIFT_PROTOCOL_GET_CLASS (self->concrete_protocol)->read_i16 (self->concrete_protocol, value, | |
428 | error); | |
429 | } | |
430 | ||
431 | gint32 | |
432 | thrift_protocol_decorator_read_i32 (ThriftProtocol *protocol, gint32 *value, | |
433 | GError **error) | |
434 | { | |
435 | ThriftProtocolDecorator *self = THRIFT_PROTOCOL_DECORATOR (protocol); | |
436 | ||
437 | return THRIFT_PROTOCOL_GET_CLASS (self->concrete_protocol)->read_i32 (self->concrete_protocol, value, | |
438 | error); | |
439 | } | |
440 | ||
441 | gint32 | |
442 | thrift_protocol_decorator_read_i64 (ThriftProtocol *protocol, gint64 *value, | |
443 | GError **error) | |
444 | { | |
445 | ThriftProtocolDecorator *self = THRIFT_PROTOCOL_DECORATOR (protocol); | |
446 | ||
447 | return THRIFT_PROTOCOL_GET_CLASS (self->concrete_protocol)->read_i64 (self->concrete_protocol, value, | |
448 | error); | |
449 | } | |
450 | ||
451 | gint32 | |
452 | thrift_protocol_decorator_read_double (ThriftProtocol *protocol, | |
453 | gdouble *value, GError **error) | |
454 | { | |
455 | ThriftProtocolDecorator *self = THRIFT_PROTOCOL_DECORATOR (protocol); | |
456 | ||
457 | return THRIFT_PROTOCOL_GET_CLASS (self->concrete_protocol)->read_double (self->concrete_protocol, value, | |
458 | error); | |
459 | } | |
460 | ||
461 | gint32 | |
462 | thrift_protocol_decorator_read_string (ThriftProtocol *protocol, | |
463 | gchar **str, GError **error) | |
464 | { | |
465 | ThriftProtocolDecorator *self = THRIFT_PROTOCOL_DECORATOR (protocol); | |
466 | ||
467 | return THRIFT_PROTOCOL_GET_CLASS (self->concrete_protocol)->read_string (self->concrete_protocol, str, | |
468 | error); | |
469 | } | |
470 | ||
471 | gint32 | |
472 | thrift_protocol_decorator_read_binary (ThriftProtocol *protocol, gpointer *buf, | |
473 | guint32 *len, GError **error) | |
474 | { | |
475 | ThriftProtocolDecorator *self = THRIFT_PROTOCOL_DECORATOR (protocol); | |
476 | ||
477 | return THRIFT_PROTOCOL_GET_CLASS (self->concrete_protocol)->read_binary (self->concrete_protocol, buf, | |
478 | len, error); | |
479 | } | |
480 | ||
481 | ||
482 | static void | |
483 | thrift_protocol_decorator_set_property (GObject *object, | |
484 | guint property_id, | |
485 | const GValue *value, | |
486 | GParamSpec *pspec) | |
487 | { | |
488 | ThriftProtocolDecorator *self = THRIFT_PROTOCOL_DECORATOR (object); | |
489 | ||
490 | switch (property_id) | |
491 | { | |
492 | case PROP_THRIFT_TYPE_PROTOCOL_DECORATOR_CONCRETE_PROTOCOL: | |
493 | self->concrete_protocol = g_value_dup_object (value); | |
494 | break; | |
495 | ||
496 | default: | |
497 | /* We don't have any other property... */ | |
498 | G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); | |
499 | break; | |
500 | } | |
501 | } | |
502 | ||
503 | static void | |
504 | thrift_protocol_decorator_get_property (GObject *object, | |
505 | guint property_id, | |
506 | GValue *value, | |
507 | GParamSpec *pspec) | |
508 | { | |
509 | ThriftProtocolDecorator *self = THRIFT_PROTOCOL_DECORATOR (object); | |
510 | ||
511 | switch (property_id) | |
512 | { | |
513 | case PROP_THRIFT_TYPE_PROTOCOL_DECORATOR_CONCRETE_PROTOCOL: | |
514 | g_value_set_object (value, self->concrete_protocol); | |
515 | break; | |
516 | ||
517 | default: | |
518 | /* We don't have any other property... */ | |
519 | G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); | |
520 | break; | |
521 | } | |
522 | } | |
523 | ||
524 | ||
525 | ThriftProtocol * | |
526 | thrift_protocol_decorator_get_concrete_protocol(ThriftProtocolDecorator *protocol) | |
527 | { | |
528 | ThriftProtocol *retval = NULL; | |
529 | if(!THRIFT_IS_PROTOCOL_DECORATOR(protocol)){ | |
530 | g_warning("The type is not protocol decorator"); | |
531 | return NULL; | |
532 | } | |
533 | ThriftProtocolDecorator *self = THRIFT_PROTOCOL_DECORATOR(protocol); | |
534 | g_debug("Getting concrete protocol from %p -> %p", (void *)self, (void *)self->concrete_protocol); | |
535 | ||
536 | return retval; | |
537 | } | |
538 | ||
539 | ||
540 | static void | |
541 | thrift_protocol_decorator_init (ThriftProtocolDecorator *protocol) | |
542 | { | |
543 | protocol->concrete_protocol = NULL; | |
544 | } | |
545 | ||
546 | static void | |
547 | thrift_protocol_decorator_dispose (GObject *gobject) | |
548 | { | |
549 | ThriftProtocolDecorator *self = THRIFT_PROTOCOL_DECORATOR (gobject); | |
550 | ||
551 | g_clear_object(&self->concrete_protocol); | |
552 | ||
553 | /* Always chain up to the parent class; there is no need to check if | |
554 | * the parent class implements the dispose() virtual function: it is | |
555 | * always guaranteed to do so | |
556 | */ | |
557 | G_OBJECT_CLASS (thrift_protocol_decorator_parent_class)->dispose(gobject); | |
558 | } | |
559 | ||
560 | /* initialize the class */ | |
561 | static void | |
562 | thrift_protocol_decorator_class_init (ThriftProtocolDecoratorClass *klass) | |
563 | { | |
564 | ThriftProtocolClass *cls = THRIFT_PROTOCOL_CLASS (klass); | |
565 | GObjectClass *object_class = G_OBJECT_CLASS (klass); | |
566 | object_class->set_property = thrift_protocol_decorator_set_property; | |
567 | object_class->get_property = thrift_protocol_decorator_get_property; | |
568 | object_class->dispose = thrift_protocol_decorator_dispose; | |
569 | ||
570 | thrift_protocol_decorator_obj_properties[PROP_THRIFT_TYPE_PROTOCOL_DECORATOR_CONCRETE_PROTOCOL] = | |
571 | g_param_spec_object ("protocol", | |
572 | "Protocol", | |
573 | "Set the protocol to be implemented", THRIFT_TYPE_PROTOCOL, | |
574 | (G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE)); | |
575 | ||
576 | g_object_class_install_properties (object_class, | |
577 | PROP_THRIFT_TYPE_PROTOCOL_DECORATOR_END, | |
578 | thrift_protocol_decorator_obj_properties); | |
579 | ||
580 | g_debug("Current decorator write_message_begin addr %p, new %p", cls->write_message_begin, thrift_protocol_decorator_write_message_begin); | |
581 | ||
582 | cls->write_message_begin = thrift_protocol_decorator_write_message_begin; | |
583 | cls->write_message_end = thrift_protocol_decorator_write_message_end; | |
584 | cls->write_struct_begin = thrift_protocol_decorator_write_struct_begin; | |
585 | cls->write_struct_end = thrift_protocol_decorator_write_struct_end; | |
586 | cls->write_field_begin = thrift_protocol_decorator_write_field_begin; | |
587 | cls->write_field_end = thrift_protocol_decorator_write_field_end; | |
588 | cls->write_field_stop = thrift_protocol_decorator_write_field_stop; | |
589 | cls->write_map_begin = thrift_protocol_decorator_write_map_begin; | |
590 | cls->write_map_end = thrift_protocol_decorator_write_map_end; | |
591 | cls->write_list_begin = thrift_protocol_decorator_write_list_begin; | |
592 | cls->write_list_end = thrift_protocol_decorator_write_list_end; | |
593 | cls->write_set_begin = thrift_protocol_decorator_write_set_begin; | |
594 | cls->write_set_end = thrift_protocol_decorator_write_set_end; | |
595 | cls->write_bool = thrift_protocol_decorator_write_bool; | |
596 | cls->write_byte = thrift_protocol_decorator_write_byte; | |
597 | cls->write_i16 = thrift_protocol_decorator_write_i16; | |
598 | cls->write_i32 = thrift_protocol_decorator_write_i32; | |
599 | cls->write_i64 = thrift_protocol_decorator_write_i64; | |
600 | cls->write_double = thrift_protocol_decorator_write_double; | |
601 | cls->write_string = thrift_protocol_decorator_write_string; | |
602 | cls->write_binary = thrift_protocol_decorator_write_binary; | |
603 | cls->read_message_begin = thrift_protocol_decorator_read_message_begin; | |
604 | cls->read_message_end = thrift_protocol_decorator_read_message_end; | |
605 | cls->read_struct_begin = thrift_protocol_decorator_read_struct_begin; | |
606 | cls->read_struct_end = thrift_protocol_decorator_read_struct_end; | |
607 | cls->read_field_begin = thrift_protocol_decorator_read_field_begin; | |
608 | cls->read_field_end = thrift_protocol_decorator_read_field_end; | |
609 | cls->read_map_begin = thrift_protocol_decorator_read_map_begin; | |
610 | cls->read_map_end = thrift_protocol_decorator_read_map_end; | |
611 | cls->read_list_begin = thrift_protocol_decorator_read_list_begin; | |
612 | cls->read_list_end = thrift_protocol_decorator_read_list_end; | |
613 | cls->read_set_begin = thrift_protocol_decorator_read_set_begin; | |
614 | cls->read_set_end = thrift_protocol_decorator_read_set_end; | |
615 | cls->read_bool = thrift_protocol_decorator_read_bool; | |
616 | cls->read_byte = thrift_protocol_decorator_read_byte; | |
617 | cls->read_i16 = thrift_protocol_decorator_read_i16; | |
618 | cls->read_i32 = thrift_protocol_decorator_read_i32; | |
619 | cls->read_i64 = thrift_protocol_decorator_read_i64; | |
620 | cls->read_double = thrift_protocol_decorator_read_double; | |
621 | cls->read_string = thrift_protocol_decorator_read_string; | |
622 | cls->read_binary = thrift_protocol_decorator_read_binary; | |
623 | } |