1: <?php
2: 3: 4: 5: 6:
7: include_once $GLOBALS['THRIFT_ROOT'].'/Thrift.php';
8:
9:
10: $GLOBALS['E_TTypeTag'] = array(
11: 'T_VOID' => 1,
12: 'T_BOOL' => 2,
13: 'T_BYTE' => 3,
14: 'T_I16' => 6,
15: 'T_I32' => 8,
16: 'T_I64' => 10,
17: 'T_DOUBLE' => 4,
18: 'T_STRING' => 11,
19: 'T_STRUCT' => 12,
20: 'T_MAP' => 13,
21: 'T_SET' => 14,
22: 'T_LIST' => 15,
23: 'T_ENUM' => 101,
24: 'T_NOT_REFLECTED' => 102,
25: );
26:
27: final class TTypeTag {
28: const T_VOID = 1;
29: const T_BOOL = 2;
30: const T_BYTE = 3;
31: const T_I16 = 6;
32: const T_I32 = 8;
33: const T_I64 = 10;
34: const T_DOUBLE = 4;
35: const T_STRING = 11;
36: const T_STRUCT = 12;
37: const T_MAP = 13;
38: const T_SET = 14;
39: const T_LIST = 15;
40: const T_ENUM = 101;
41: const T_NOT_REFLECTED = 102;
42: static public $__names = array(
43: 1 => 'T_VOID',
44: 2 => 'T_BOOL',
45: 3 => 'T_BYTE',
46: 6 => 'T_I16',
47: 8 => 'T_I32',
48: 10 => 'T_I64',
49: 4 => 'T_DOUBLE',
50: 11 => 'T_STRING',
51: 12 => 'T_STRUCT',
52: 13 => 'T_MAP',
53: 14 => 'T_SET',
54: 15 => 'T_LIST',
55: 101 => 'T_ENUM',
56: 102 => 'T_NOT_REFLECTED',
57: );
58: }
59:
60: class SimpleType {
61: static $_TSPEC;
62:
63: public $ttype = null;
64: public $name = null;
65:
66: public function __construct($vals=null) {
67: if (!isset(self::$_TSPEC)) {
68: self::$_TSPEC = array(
69: 1 => array(
70: 'var' => 'ttype',
71: 'type' => TType::I32,
72: ),
73: 2 => array(
74: 'var' => 'name',
75: 'type' => TType::STRING,
76: ),
77: );
78: }
79: if (is_array($vals)) {
80: if (isset($vals['ttype'])) {
81: $this->ttype = $vals['ttype'];
82: }
83: if (isset($vals['name'])) {
84: $this->name = $vals['name'];
85: }
86: }
87: }
88:
89: public function getName() {
90: return 'SimpleType';
91: }
92:
93: public function read($input)
94: {
95: $xfer = 0;
96: $fname = null;
97: $ftype = 0;
98: $fid = 0;
99: $xfer += $input->readStructBegin($fname);
100: while (true)
101: {
102: $xfer += $input->readFieldBegin($fname, $ftype, $fid);
103: if ($ftype == TType::STOP) {
104: break;
105: }
106: switch ($fid)
107: {
108: case 1:
109: if ($ftype == TType::I32) {
110: $xfer += $input->readI32($this->ttype);
111: } else {
112: $xfer += $input->skip($ftype);
113: }
114: break;
115: case 2:
116: if ($ftype == TType::STRING) {
117: $xfer += $input->readString($this->name);
118: } else {
119: $xfer += $input->skip($ftype);
120: }
121: break;
122: default:
123: $xfer += $input->skip($ftype);
124: break;
125: }
126: $xfer += $input->readFieldEnd();
127: }
128: $xfer += $input->readStructEnd();
129: return $xfer;
130: }
131:
132: public function write($output) {
133: $xfer = 0;
134: $xfer += $output->writeStructBegin('SimpleType');
135: if ($this->ttype !== null) {
136: $xfer += $output->writeFieldBegin('ttype', TType::I32, 1);
137: $xfer += $output->writeI32($this->ttype);
138: $xfer += $output->writeFieldEnd();
139: }
140: if ($this->name !== null) {
141: $xfer += $output->writeFieldBegin('name', TType::STRING, 2);
142: $xfer += $output->writeString($this->name);
143: $xfer += $output->writeFieldEnd();
144: }
145: $xfer += $output->writeFieldStop();
146: $xfer += $output->writeStructEnd();
147: return $xfer;
148: }
149:
150: }
151:
152: class ContainerType {
153: static $_TSPEC;
154:
155: public $ttype = null;
156: public $subtype1 = null;
157: public $subtype2 = null;
158:
159: public function __construct($vals=null) {
160: if (!isset(self::$_TSPEC)) {
161: self::$_TSPEC = array(
162: 1 => array(
163: 'var' => 'ttype',
164: 'type' => TType::I32,
165: ),
166: 2 => array(
167: 'var' => 'subtype1',
168: 'type' => TType::STRUCT,
169: 'class' => 'SimpleType',
170: ),
171: 3 => array(
172: 'var' => 'subtype2',
173: 'type' => TType::STRUCT,
174: 'class' => 'SimpleType',
175: ),
176: );
177: }
178: if (is_array($vals)) {
179: if (isset($vals['ttype'])) {
180: $this->ttype = $vals['ttype'];
181: }
182: if (isset($vals['subtype1'])) {
183: $this->subtype1 = $vals['subtype1'];
184: }
185: if (isset($vals['subtype2'])) {
186: $this->subtype2 = $vals['subtype2'];
187: }
188: }
189: }
190:
191: public function getName() {
192: return 'ContainerType';
193: }
194:
195: public function read($input)
196: {
197: $xfer = 0;
198: $fname = null;
199: $ftype = 0;
200: $fid = 0;
201: $xfer += $input->readStructBegin($fname);
202: while (true)
203: {
204: $xfer += $input->readFieldBegin($fname, $ftype, $fid);
205: if ($ftype == TType::STOP) {
206: break;
207: }
208: switch ($fid)
209: {
210: case 1:
211: if ($ftype == TType::I32) {
212: $xfer += $input->readI32($this->ttype);
213: } else {
214: $xfer += $input->skip($ftype);
215: }
216: break;
217: case 2:
218: if ($ftype == TType::STRUCT) {
219: $this->subtype1 = new SimpleType();
220: $xfer += $this->subtype1->read($input);
221: } else {
222: $xfer += $input->skip($ftype);
223: }
224: break;
225: case 3:
226: if ($ftype == TType::STRUCT) {
227: $this->subtype2 = new SimpleType();
228: $xfer += $this->subtype2->read($input);
229: } else {
230: $xfer += $input->skip($ftype);
231: }
232: break;
233: default:
234: $xfer += $input->skip($ftype);
235: break;
236: }
237: $xfer += $input->readFieldEnd();
238: }
239: $xfer += $input->readStructEnd();
240: return $xfer;
241: }
242:
243: public function write($output) {
244: $xfer = 0;
245: $xfer += $output->writeStructBegin('ContainerType');
246: if ($this->ttype !== null) {
247: $xfer += $output->writeFieldBegin('ttype', TType::I32, 1);
248: $xfer += $output->writeI32($this->ttype);
249: $xfer += $output->writeFieldEnd();
250: }
251: if ($this->subtype1 !== null) {
252: if (!is_object($this->subtype1)) {
253: throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA);
254: }
255: $xfer += $output->writeFieldBegin('subtype1', TType::STRUCT, 2);
256: $xfer += $this->subtype1->write($output);
257: $xfer += $output->writeFieldEnd();
258: }
259: if ($this->subtype2 !== null) {
260: if (!is_object($this->subtype2)) {
261: throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA);
262: }
263: $xfer += $output->writeFieldBegin('subtype2', TType::STRUCT, 3);
264: $xfer += $this->subtype2->write($output);
265: $xfer += $output->writeFieldEnd();
266: }
267: $xfer += $output->writeFieldStop();
268: $xfer += $output->writeStructEnd();
269: return $xfer;
270: }
271:
272: }
273:
274: class ThriftType {
275: static $_TSPEC;
276:
277: public $is_container = null;
278: public $simple_type = null;
279: public $container_type = null;
280:
281: public function __construct($vals=null) {
282: if (!isset(self::$_TSPEC)) {
283: self::$_TSPEC = array(
284: 1 => array(
285: 'var' => 'is_container',
286: 'type' => TType::BOOL,
287: ),
288: 2 => array(
289: 'var' => 'simple_type',
290: 'type' => TType::STRUCT,
291: 'class' => 'SimpleType',
292: ),
293: 3 => array(
294: 'var' => 'container_type',
295: 'type' => TType::STRUCT,
296: 'class' => 'ContainerType',
297: ),
298: );
299: }
300: if (is_array($vals)) {
301: if (isset($vals['is_container'])) {
302: $this->is_container = $vals['is_container'];
303: }
304: if (isset($vals['simple_type'])) {
305: $this->simple_type = $vals['simple_type'];
306: }
307: if (isset($vals['container_type'])) {
308: $this->container_type = $vals['container_type'];
309: }
310: }
311: }
312:
313: public function getName() {
314: return 'ThriftType';
315: }
316:
317: public function read($input)
318: {
319: $xfer = 0;
320: $fname = null;
321: $ftype = 0;
322: $fid = 0;
323: $xfer += $input->readStructBegin($fname);
324: while (true)
325: {
326: $xfer += $input->readFieldBegin($fname, $ftype, $fid);
327: if ($ftype == TType::STOP) {
328: break;
329: }
330: switch ($fid)
331: {
332: case 1:
333: if ($ftype == TType::BOOL) {
334: $xfer += $input->readBool($this->is_container);
335: } else {
336: $xfer += $input->skip($ftype);
337: }
338: break;
339: case 2:
340: if ($ftype == TType::STRUCT) {
341: $this->simple_type = new SimpleType();
342: $xfer += $this->simple_type->read($input);
343: } else {
344: $xfer += $input->skip($ftype);
345: }
346: break;
347: case 3:
348: if ($ftype == TType::STRUCT) {
349: $this->container_type = new ContainerType();
350: $xfer += $this->container_type->read($input);
351: } else {
352: $xfer += $input->skip($ftype);
353: }
354: break;
355: default:
356: $xfer += $input->skip($ftype);
357: break;
358: }
359: $xfer += $input->readFieldEnd();
360: }
361: $xfer += $input->readStructEnd();
362: return $xfer;
363: }
364:
365: public function write($output) {
366: $xfer = 0;
367: $xfer += $output->writeStructBegin('ThriftType');
368: if ($this->is_container !== null) {
369: $xfer += $output->writeFieldBegin('is_container', TType::BOOL, 1);
370: $xfer += $output->writeBool($this->is_container);
371: $xfer += $output->writeFieldEnd();
372: }
373: if ($this->simple_type !== null) {
374: if (!is_object($this->simple_type)) {
375: throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA);
376: }
377: $xfer += $output->writeFieldBegin('simple_type', TType::STRUCT, 2);
378: $xfer += $this->simple_type->write($output);
379: $xfer += $output->writeFieldEnd();
380: }
381: if ($this->container_type !== null) {
382: if (!is_object($this->container_type)) {
383: throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA);
384: }
385: $xfer += $output->writeFieldBegin('container_type', TType::STRUCT, 3);
386: $xfer += $this->container_type->write($output);
387: $xfer += $output->writeFieldEnd();
388: }
389: $xfer += $output->writeFieldStop();
390: $xfer += $output->writeStructEnd();
391: return $xfer;
392: }
393:
394: }
395:
396: class Argument {
397: static $_TSPEC;
398:
399: public $key = null;
400: public $name = null;
401: public $type = null;
402:
403: public function __construct($vals=null) {
404: if (!isset(self::$_TSPEC)) {
405: self::$_TSPEC = array(
406: 1 => array(
407: 'var' => 'key',
408: 'type' => TType::I16,
409: ),
410: 2 => array(
411: 'var' => 'name',
412: 'type' => TType::STRING,
413: ),
414: 3 => array(
415: 'var' => 'type',
416: 'type' => TType::STRUCT,
417: 'class' => 'ThriftType',
418: ),
419: );
420: }
421: if (is_array($vals)) {
422: if (isset($vals['key'])) {
423: $this->key = $vals['key'];
424: }
425: if (isset($vals['name'])) {
426: $this->name = $vals['name'];
427: }
428: if (isset($vals['type'])) {
429: $this->type = $vals['type'];
430: }
431: }
432: }
433:
434: public function getName() {
435: return 'Argument';
436: }
437:
438: public function read($input)
439: {
440: $xfer = 0;
441: $fname = null;
442: $ftype = 0;
443: $fid = 0;
444: $xfer += $input->readStructBegin($fname);
445: while (true)
446: {
447: $xfer += $input->readFieldBegin($fname, $ftype, $fid);
448: if ($ftype == TType::STOP) {
449: break;
450: }
451: switch ($fid)
452: {
453: case 1:
454: if ($ftype == TType::I16) {
455: $xfer += $input->readI16($this->key);
456: } else {
457: $xfer += $input->skip($ftype);
458: }
459: break;
460: case 2:
461: if ($ftype == TType::STRING) {
462: $xfer += $input->readString($this->name);
463: } else {
464: $xfer += $input->skip($ftype);
465: }
466: break;
467: case 3:
468: if ($ftype == TType::STRUCT) {
469: $this->type = new ThriftType();
470: $xfer += $this->type->read($input);
471: } else {
472: $xfer += $input->skip($ftype);
473: }
474: break;
475: default:
476: $xfer += $input->skip($ftype);
477: break;
478: }
479: $xfer += $input->readFieldEnd();
480: }
481: $xfer += $input->readStructEnd();
482: return $xfer;
483: }
484:
485: public function write($output) {
486: $xfer = 0;
487: $xfer += $output->writeStructBegin('Argument');
488: if ($this->key !== null) {
489: $xfer += $output->writeFieldBegin('key', TType::I16, 1);
490: $xfer += $output->writeI16($this->key);
491: $xfer += $output->writeFieldEnd();
492: }
493: if ($this->name !== null) {
494: $xfer += $output->writeFieldBegin('name', TType::STRING, 2);
495: $xfer += $output->writeString($this->name);
496: $xfer += $output->writeFieldEnd();
497: }
498: if ($this->type !== null) {
499: if (!is_object($this->type)) {
500: throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA);
501: }
502: $xfer += $output->writeFieldBegin('type', TType::STRUCT, 3);
503: $xfer += $this->type->write($output);
504: $xfer += $output->writeFieldEnd();
505: }
506: $xfer += $output->writeFieldStop();
507: $xfer += $output->writeStructEnd();
508: return $xfer;
509: }
510:
511: }
512:
513: class Method {
514: static $_TSPEC;
515:
516: public $name = null;
517: public $return_type = null;
518: public $arguments = null;
519:
520: public function __construct($vals=null) {
521: if (!isset(self::$_TSPEC)) {
522: self::$_TSPEC = array(
523: 1 => array(
524: 'var' => 'name',
525: 'type' => TType::STRING,
526: ),
527: 2 => array(
528: 'var' => 'return_type',
529: 'type' => TType::STRUCT,
530: 'class' => 'ThriftType',
531: ),
532: 3 => array(
533: 'var' => 'arguments',
534: 'type' => TType::LST,
535: 'etype' => TType::STRUCT,
536: 'elem' => array(
537: 'type' => TType::STRUCT,
538: 'class' => 'Argument',
539: ),
540: ),
541: );
542: }
543: if (is_array($vals)) {
544: if (isset($vals['name'])) {
545: $this->name = $vals['name'];
546: }
547: if (isset($vals['return_type'])) {
548: $this->return_type = $vals['return_type'];
549: }
550: if (isset($vals['arguments'])) {
551: $this->arguments = $vals['arguments'];
552: }
553: }
554: }
555:
556: public function getName() {
557: return 'Method';
558: }
559:
560: public function read($input)
561: {
562: $xfer = 0;
563: $fname = null;
564: $ftype = 0;
565: $fid = 0;
566: $xfer += $input->readStructBegin($fname);
567: while (true)
568: {
569: $xfer += $input->readFieldBegin($fname, $ftype, $fid);
570: if ($ftype == TType::STOP) {
571: break;
572: }
573: switch ($fid)
574: {
575: case 1:
576: if ($ftype == TType::STRING) {
577: $xfer += $input->readString($this->name);
578: } else {
579: $xfer += $input->skip($ftype);
580: }
581: break;
582: case 2:
583: if ($ftype == TType::STRUCT) {
584: $this->return_type = new ThriftType();
585: $xfer += $this->return_type->read($input);
586: } else {
587: $xfer += $input->skip($ftype);
588: }
589: break;
590: case 3:
591: if ($ftype == TType::LST) {
592: $this->arguments = array();
593: $_size0 = 0;
594: $_etype3 = 0;
595: $xfer += $input->readListBegin($_etype3, $_size0);
596: for ($_i4 = 0; $_i4 < $_size0; ++$_i4)
597: {
598: $elem5 = null;
599: $elem5 = new Argument();
600: $xfer += $elem5->read($input);
601: $this->arguments []= $elem5;
602: }
603: $xfer += $input->readListEnd();
604: } else {
605: $xfer += $input->skip($ftype);
606: }
607: break;
608: default:
609: $xfer += $input->skip($ftype);
610: break;
611: }
612: $xfer += $input->readFieldEnd();
613: }
614: $xfer += $input->readStructEnd();
615: return $xfer;
616: }
617:
618: public function write($output) {
619: $xfer = 0;
620: $xfer += $output->writeStructBegin('Method');
621: if ($this->name !== null) {
622: $xfer += $output->writeFieldBegin('name', TType::STRING, 1);
623: $xfer += $output->writeString($this->name);
624: $xfer += $output->writeFieldEnd();
625: }
626: if ($this->return_type !== null) {
627: if (!is_object($this->return_type)) {
628: throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA);
629: }
630: $xfer += $output->writeFieldBegin('return_type', TType::STRUCT, 2);
631: $xfer += $this->return_type->write($output);
632: $xfer += $output->writeFieldEnd();
633: }
634: if ($this->arguments !== null) {
635: if (!is_array($this->arguments)) {
636: throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA);
637: }
638: $xfer += $output->writeFieldBegin('arguments', TType::LST, 3);
639: {
640: $output->writeListBegin(TType::STRUCT, count($this->arguments));
641: {
642: foreach ($this->arguments as $iter6)
643: {
644: $xfer += $iter6->write($output);
645: }
646: }
647: $output->writeListEnd();
648: }
649: $xfer += $output->writeFieldEnd();
650: }
651: $xfer += $output->writeFieldStop();
652: $xfer += $output->writeStructEnd();
653: return $xfer;
654: }
655:
656: }
657:
658: class Service {
659: static $_TSPEC;
660:
661: public $name = null;
662: public $methods = null;
663: public $fully_reflected = null;
664:
665: public function __construct($vals=null) {
666: if (!isset(self::$_TSPEC)) {
667: self::$_TSPEC = array(
668: 1 => array(
669: 'var' => 'name',
670: 'type' => TType::STRING,
671: ),
672: 2 => array(
673: 'var' => 'methods',
674: 'type' => TType::LST,
675: 'etype' => TType::STRUCT,
676: 'elem' => array(
677: 'type' => TType::STRUCT,
678: 'class' => 'Method',
679: ),
680: ),
681: 3 => array(
682: 'var' => 'fully_reflected',
683: 'type' => TType::BOOL,
684: ),
685: );
686: }
687: if (is_array($vals)) {
688: if (isset($vals['name'])) {
689: $this->name = $vals['name'];
690: }
691: if (isset($vals['methods'])) {
692: $this->methods = $vals['methods'];
693: }
694: if (isset($vals['fully_reflected'])) {
695: $this->fully_reflected = $vals['fully_reflected'];
696: }
697: }
698: }
699:
700: public function getName() {
701: return 'Service';
702: }
703:
704: public function read($input)
705: {
706: $xfer = 0;
707: $fname = null;
708: $ftype = 0;
709: $fid = 0;
710: $xfer += $input->readStructBegin($fname);
711: while (true)
712: {
713: $xfer += $input->readFieldBegin($fname, $ftype, $fid);
714: if ($ftype == TType::STOP) {
715: break;
716: }
717: switch ($fid)
718: {
719: case 1:
720: if ($ftype == TType::STRING) {
721: $xfer += $input->readString($this->name);
722: } else {
723: $xfer += $input->skip($ftype);
724: }
725: break;
726: case 2:
727: if ($ftype == TType::LST) {
728: $this->methods = array();
729: $_size7 = 0;
730: $_etype10 = 0;
731: $xfer += $input->readListBegin($_etype10, $_size7);
732: for ($_i11 = 0; $_i11 < $_size7; ++$_i11)
733: {
734: $elem12 = null;
735: $elem12 = new Method();
736: $xfer += $elem12->read($input);
737: $this->methods []= $elem12;
738: }
739: $xfer += $input->readListEnd();
740: } else {
741: $xfer += $input->skip($ftype);
742: }
743: break;
744: case 3:
745: if ($ftype == TType::BOOL) {
746: $xfer += $input->readBool($this->fully_reflected);
747: } else {
748: $xfer += $input->skip($ftype);
749: }
750: break;
751: default:
752: $xfer += $input->skip($ftype);
753: break;
754: }
755: $xfer += $input->readFieldEnd();
756: }
757: $xfer += $input->readStructEnd();
758: return $xfer;
759: }
760:
761: public function write($output) {
762: $xfer = 0;
763: $xfer += $output->writeStructBegin('Service');
764: if ($this->name !== null) {
765: $xfer += $output->writeFieldBegin('name', TType::STRING, 1);
766: $xfer += $output->writeString($this->name);
767: $xfer += $output->writeFieldEnd();
768: }
769: if ($this->methods !== null) {
770: if (!is_array($this->methods)) {
771: throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA);
772: }
773: $xfer += $output->writeFieldBegin('methods', TType::LST, 2);
774: {
775: $output->writeListBegin(TType::STRUCT, count($this->methods));
776: {
777: foreach ($this->methods as $iter13)
778: {
779: $xfer += $iter13->write($output);
780: }
781: }
782: $output->writeListEnd();
783: }
784: $xfer += $output->writeFieldEnd();
785: }
786: if ($this->fully_reflected !== null) {
787: $xfer += $output->writeFieldBegin('fully_reflected', TType::BOOL, 3);
788: $xfer += $output->writeBool($this->fully_reflected);
789: $xfer += $output->writeFieldEnd();
790: }
791: $xfer += $output->writeFieldStop();
792: $xfer += $output->writeStructEnd();
793: return $xfer;
794: }
795:
796: }
797:
798: ?>
799: