Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
thrift
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
tufengqi
thrift
Commits
bbe21d02
Commit
bbe21d02
authored
Apr 19, 2018
by
tufengqi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
finish
parent
94250140
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
1450 additions
and
1 deletion
+1450
-1
.gitignore
.gitignore
+0
-1
SharedService.php
tutorial/gen-php/shared/SharedService.php
+250
-0
Types.php
tutorial/gen-php/shared/Types.php
+119
-0
Calculator.php
tutorial/gen-php/tutorial/Calculator.php
+766
-0
Types.php
tutorial/gen-php/tutorial/Types.php
+315
-0
No files found.
.gitignore
View file @
bbe21d02
...
@@ -32,7 +32,6 @@ junit*.properties
...
@@ -32,7 +32,6 @@ junit*.properties
*.iml
*.iml
*.ipr
*.ipr
*.iws
*.iws
gen-*
Makefile
Makefile
Makefile.in
Makefile.in
aclocal.m4
aclocal.m4
...
...
tutorial/gen-php/shared/SharedService.php
0 → 100644
View file @
bbe21d02
<?php
namespace
shared
;
/**
* Autogenerated by Thrift Compiler (0.11.0)
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
* @generated
*/
use
Thrift\Base\TBase
;
use
Thrift\Type\TType
;
use
Thrift\Type\TMessageType
;
use
Thrift\Exception\TException
;
use
Thrift\Exception\TProtocolException
;
use
Thrift\Protocol\TProtocol
;
use
Thrift\Protocol\TBinaryProtocolAccelerated
;
use
Thrift\Exception\TApplicationException
;
interface
SharedServiceIf
{
/**
* @param int $key
* @return \shared\SharedStruct
*/
public
function
getStruct
(
$key
);
}
class
SharedServiceClient
implements
\shared\SharedServiceIf
{
protected
$input_
=
null
;
protected
$output_
=
null
;
protected
$seqid_
=
0
;
public
function
__construct
(
$input
,
$output
=
null
)
{
$this
->
input_
=
$input
;
$this
->
output_
=
$output
?
$output
:
$input
;
}
public
function
getStruct
(
$key
)
{
$this
->
send_getStruct
(
$key
);
return
$this
->
recv_getStruct
();
}
public
function
send_getStruct
(
$key
)
{
$args
=
new
\shared\SharedService_getStruct_args
();
$args
->
key
=
$key
;
$bin_accel
=
(
$this
->
output_
instanceof
TBinaryProtocolAccelerated
)
&&
function_exists
(
'thrift_protocol_write_binary'
);
if
(
$bin_accel
)
{
thrift_protocol_write_binary
(
$this
->
output_
,
'getStruct'
,
TMessageType
::
CALL
,
$args
,
$this
->
seqid_
,
$this
->
output_
->
isStrictWrite
());
}
else
{
$this
->
output_
->
writeMessageBegin
(
'getStruct'
,
TMessageType
::
CALL
,
$this
->
seqid_
);
$args
->
write
(
$this
->
output_
);
$this
->
output_
->
writeMessageEnd
();
$this
->
output_
->
getTransport
()
->
flush
();
}
}
public
function
recv_getStruct
()
{
$bin_accel
=
(
$this
->
input_
instanceof
TBinaryProtocolAccelerated
)
&&
function_exists
(
'thrift_protocol_read_binary'
);
if
(
$bin_accel
)
$result
=
thrift_protocol_read_binary
(
$this
->
input_
,
'\shared\SharedService_getStruct_result'
,
$this
->
input_
->
isStrictRead
());
else
{
$rseqid
=
0
;
$fname
=
null
;
$mtype
=
0
;
$this
->
input_
->
readMessageBegin
(
$fname
,
$mtype
,
$rseqid
);
if
(
$mtype
==
TMessageType
::
EXCEPTION
)
{
$x
=
new
TApplicationException
();
$x
->
read
(
$this
->
input_
);
$this
->
input_
->
readMessageEnd
();
throw
$x
;
}
$result
=
new
\shared\SharedService_getStruct_result
();
$result
->
read
(
$this
->
input_
);
$this
->
input_
->
readMessageEnd
();
}
if
(
$result
->
success
!==
null
)
{
return
$result
->
success
;
}
throw
new
\Exception
(
"getStruct failed: unknown result"
);
}
}
// HELPER FUNCTIONS AND STRUCTURES
class
SharedService_getStruct_args
{
static
$isValidate
=
false
;
static
$_TSPEC
=
array
(
1
=>
array
(
'var'
=>
'key'
,
'isRequired'
=>
false
,
'type'
=>
TType
::
I32
,
),
);
/**
* @var int
*/
public
$key
=
null
;
public
function
__construct
(
$vals
=
null
)
{
if
(
is_array
(
$vals
))
{
if
(
isset
(
$vals
[
'key'
]))
{
$this
->
key
=
$vals
[
'key'
];
}
}
}
public
function
getName
()
{
return
'SharedService_getStruct_args'
;
}
public
function
read
(
$input
)
{
$xfer
=
0
;
$fname
=
null
;
$ftype
=
0
;
$fid
=
0
;
$xfer
+=
$input
->
readStructBegin
(
$fname
);
while
(
true
)
{
$xfer
+=
$input
->
readFieldBegin
(
$fname
,
$ftype
,
$fid
);
if
(
$ftype
==
TType
::
STOP
)
{
break
;
}
switch
(
$fid
)
{
case
1
:
if
(
$ftype
==
TType
::
I32
)
{
$xfer
+=
$input
->
readI32
(
$this
->
key
);
}
else
{
$xfer
+=
$input
->
skip
(
$ftype
);
}
break
;
default
:
$xfer
+=
$input
->
skip
(
$ftype
);
break
;
}
$xfer
+=
$input
->
readFieldEnd
();
}
$xfer
+=
$input
->
readStructEnd
();
return
$xfer
;
}
public
function
write
(
$output
)
{
$xfer
=
0
;
$xfer
+=
$output
->
writeStructBegin
(
'SharedService_getStruct_args'
);
if
(
$this
->
key
!==
null
)
{
$xfer
+=
$output
->
writeFieldBegin
(
'key'
,
TType
::
I32
,
1
);
$xfer
+=
$output
->
writeI32
(
$this
->
key
);
$xfer
+=
$output
->
writeFieldEnd
();
}
$xfer
+=
$output
->
writeFieldStop
();
$xfer
+=
$output
->
writeStructEnd
();
return
$xfer
;
}
}
class
SharedService_getStruct_result
{
static
$isValidate
=
false
;
static
$_TSPEC
=
array
(
0
=>
array
(
'var'
=>
'success'
,
'isRequired'
=>
false
,
'type'
=>
TType
::
STRUCT
,
'class'
=>
'\shared\SharedStruct'
,
),
);
/**
* @var \shared\SharedStruct
*/
public
$success
=
null
;
public
function
__construct
(
$vals
=
null
)
{
if
(
is_array
(
$vals
))
{
if
(
isset
(
$vals
[
'success'
]))
{
$this
->
success
=
$vals
[
'success'
];
}
}
}
public
function
getName
()
{
return
'SharedService_getStruct_result'
;
}
public
function
read
(
$input
)
{
$xfer
=
0
;
$fname
=
null
;
$ftype
=
0
;
$fid
=
0
;
$xfer
+=
$input
->
readStructBegin
(
$fname
);
while
(
true
)
{
$xfer
+=
$input
->
readFieldBegin
(
$fname
,
$ftype
,
$fid
);
if
(
$ftype
==
TType
::
STOP
)
{
break
;
}
switch
(
$fid
)
{
case
0
:
if
(
$ftype
==
TType
::
STRUCT
)
{
$this
->
success
=
new
\shared\SharedStruct
();
$xfer
+=
$this
->
success
->
read
(
$input
);
}
else
{
$xfer
+=
$input
->
skip
(
$ftype
);
}
break
;
default
:
$xfer
+=
$input
->
skip
(
$ftype
);
break
;
}
$xfer
+=
$input
->
readFieldEnd
();
}
$xfer
+=
$input
->
readStructEnd
();
return
$xfer
;
}
public
function
write
(
$output
)
{
$xfer
=
0
;
$xfer
+=
$output
->
writeStructBegin
(
'SharedService_getStruct_result'
);
if
(
$this
->
success
!==
null
)
{
if
(
!
is_object
(
$this
->
success
))
{
throw
new
TProtocolException
(
'Bad type in structure.'
,
TProtocolException
::
INVALID_DATA
);
}
$xfer
+=
$output
->
writeFieldBegin
(
'success'
,
TType
::
STRUCT
,
0
);
$xfer
+=
$this
->
success
->
write
(
$output
);
$xfer
+=
$output
->
writeFieldEnd
();
}
$xfer
+=
$output
->
writeFieldStop
();
$xfer
+=
$output
->
writeStructEnd
();
return
$xfer
;
}
}
tutorial/gen-php/shared/Types.php
0 → 100644
View file @
bbe21d02
<?php
namespace
shared
;
/**
* Autogenerated by Thrift Compiler (0.11.0)
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
* @generated
*/
use
Thrift\Base\TBase
;
use
Thrift\Type\TType
;
use
Thrift\Type\TMessageType
;
use
Thrift\Exception\TException
;
use
Thrift\Exception\TProtocolException
;
use
Thrift\Protocol\TProtocol
;
use
Thrift\Protocol\TBinaryProtocolAccelerated
;
use
Thrift\Exception\TApplicationException
;
class
SharedStruct
{
static
$isValidate
=
false
;
static
$_TSPEC
=
array
(
1
=>
array
(
'var'
=>
'key'
,
'isRequired'
=>
false
,
'type'
=>
TType
::
I32
,
),
2
=>
array
(
'var'
=>
'value'
,
'isRequired'
=>
false
,
'type'
=>
TType
::
STRING
,
),
);
/**
* @var int
*/
public
$key
=
null
;
/**
* @var string
*/
public
$value
=
null
;
public
function
__construct
(
$vals
=
null
)
{
if
(
is_array
(
$vals
))
{
if
(
isset
(
$vals
[
'key'
]))
{
$this
->
key
=
$vals
[
'key'
];
}
if
(
isset
(
$vals
[
'value'
]))
{
$this
->
value
=
$vals
[
'value'
];
}
}
}
public
function
getName
()
{
return
'SharedStruct'
;
}
public
function
read
(
$input
)
{
$xfer
=
0
;
$fname
=
null
;
$ftype
=
0
;
$fid
=
0
;
$xfer
+=
$input
->
readStructBegin
(
$fname
);
while
(
true
)
{
$xfer
+=
$input
->
readFieldBegin
(
$fname
,
$ftype
,
$fid
);
if
(
$ftype
==
TType
::
STOP
)
{
break
;
}
switch
(
$fid
)
{
case
1
:
if
(
$ftype
==
TType
::
I32
)
{
$xfer
+=
$input
->
readI32
(
$this
->
key
);
}
else
{
$xfer
+=
$input
->
skip
(
$ftype
);
}
break
;
case
2
:
if
(
$ftype
==
TType
::
STRING
)
{
$xfer
+=
$input
->
readString
(
$this
->
value
);
}
else
{
$xfer
+=
$input
->
skip
(
$ftype
);
}
break
;
default
:
$xfer
+=
$input
->
skip
(
$ftype
);
break
;
}
$xfer
+=
$input
->
readFieldEnd
();
}
$xfer
+=
$input
->
readStructEnd
();
return
$xfer
;
}
public
function
write
(
$output
)
{
$xfer
=
0
;
$xfer
+=
$output
->
writeStructBegin
(
'SharedStruct'
);
if
(
$this
->
key
!==
null
)
{
$xfer
+=
$output
->
writeFieldBegin
(
'key'
,
TType
::
I32
,
1
);
$xfer
+=
$output
->
writeI32
(
$this
->
key
);
$xfer
+=
$output
->
writeFieldEnd
();
}
if
(
$this
->
value
!==
null
)
{
$xfer
+=
$output
->
writeFieldBegin
(
'value'
,
TType
::
STRING
,
2
);
$xfer
+=
$output
->
writeString
(
$this
->
value
);
$xfer
+=
$output
->
writeFieldEnd
();
}
$xfer
+=
$output
->
writeFieldStop
();
$xfer
+=
$output
->
writeStructEnd
();
return
$xfer
;
}
}
tutorial/gen-php/tutorial/Calculator.php
0 → 100644
View file @
bbe21d02
<?php
namespace
tutorial
;
/**
* Autogenerated by Thrift Compiler (0.11.0)
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
* @generated
*/
use
Thrift\Base\TBase
;
use
Thrift\Type\TType
;
use
Thrift\Type\TMessageType
;
use
Thrift\Exception\TException
;
use
Thrift\Exception\TProtocolException
;
use
Thrift\Protocol\TProtocol
;
use
Thrift\Protocol\TBinaryProtocolAccelerated
;
use
Thrift\Exception\TApplicationException
;
/**
* Ahh, now onto the cool part, defining a service. Services just need a name
* and can optionally inherit from another service using the extends keyword.
*/
interface
CalculatorIf
extends
\shared\SharedServiceIf
{
/**
* A method definition looks like C code. It has a return type, arguments,
* and optionally a list of exceptions that it may throw. Note that argument
* lists and exception lists are specified using the exact same syntax as
* field lists in struct or exception definitions.
*
*/
public
function
ping
();
/**
* @param int $num1
* @param int $num2
* @return int
*/
public
function
add
(
$num1
,
$num2
);
/**
* @param int $logid
* @param \tutorial\Work $w
* @return int
* @throws \tutorial\InvalidOperation
*/
public
function
calculate
(
$logid
,
\tutorial\Work
$w
);
/**
* This method has a oneway modifier. That means the client only makes
* a request and does not listen for any response at all. Oneway methods
* must be void.
*
*/
public
function
zip
();
}
class
CalculatorClient
extends
\shared\SharedServiceClient
implements
\tutorial\CalculatorIf
{
public
function
__construct
(
$input
,
$output
=
null
)
{
parent
::
__construct
(
$input
,
$output
);
}
public
function
ping
()
{
$this
->
send_ping
();
$this
->
recv_ping
();
}
public
function
send_ping
()
{
$args
=
new
\tutorial\Calculator_ping_args
();
$bin_accel
=
(
$this
->
output_
instanceof
TBinaryProtocolAccelerated
)
&&
function_exists
(
'thrift_protocol_write_binary'
);
if
(
$bin_accel
)
{
thrift_protocol_write_binary
(
$this
->
output_
,
'ping'
,
TMessageType
::
CALL
,
$args
,
$this
->
seqid_
,
$this
->
output_
->
isStrictWrite
());
}
else
{
$this
->
output_
->
writeMessageBegin
(
'ping'
,
TMessageType
::
CALL
,
$this
->
seqid_
);
$args
->
write
(
$this
->
output_
);
$this
->
output_
->
writeMessageEnd
();
$this
->
output_
->
getTransport
()
->
flush
();
}
}
public
function
recv_ping
()
{
$bin_accel
=
(
$this
->
input_
instanceof
TBinaryProtocolAccelerated
)
&&
function_exists
(
'thrift_protocol_read_binary'
);
if
(
$bin_accel
)
$result
=
thrift_protocol_read_binary
(
$this
->
input_
,
'\tutorial\Calculator_ping_result'
,
$this
->
input_
->
isStrictRead
());
else
{
$rseqid
=
0
;
$fname
=
null
;
$mtype
=
0
;
$this
->
input_
->
readMessageBegin
(
$fname
,
$mtype
,
$rseqid
);
if
(
$mtype
==
TMessageType
::
EXCEPTION
)
{
$x
=
new
TApplicationException
();
$x
->
read
(
$this
->
input_
);
$this
->
input_
->
readMessageEnd
();
throw
$x
;
}
$result
=
new
\tutorial\Calculator_ping_result
();
$result
->
read
(
$this
->
input_
);
$this
->
input_
->
readMessageEnd
();
}
return
;
}
public
function
add
(
$num1
,
$num2
)
{
$this
->
send_add
(
$num1
,
$num2
);
return
$this
->
recv_add
();
}
public
function
send_add
(
$num1
,
$num2
)
{
$args
=
new
\tutorial\Calculator_add_args
();
$args
->
num1
=
$num1
;
$args
->
num2
=
$num2
;
$bin_accel
=
(
$this
->
output_
instanceof
TBinaryProtocolAccelerated
)
&&
function_exists
(
'thrift_protocol_write_binary'
);
if
(
$bin_accel
)
{
thrift_protocol_write_binary
(
$this
->
output_
,
'add'
,
TMessageType
::
CALL
,
$args
,
$this
->
seqid_
,
$this
->
output_
->
isStrictWrite
());
}
else
{
$this
->
output_
->
writeMessageBegin
(
'add'
,
TMessageType
::
CALL
,
$this
->
seqid_
);
$args
->
write
(
$this
->
output_
);
$this
->
output_
->
writeMessageEnd
();
$this
->
output_
->
getTransport
()
->
flush
();
}
}
public
function
recv_add
()
{
$bin_accel
=
(
$this
->
input_
instanceof
TBinaryProtocolAccelerated
)
&&
function_exists
(
'thrift_protocol_read_binary'
);
if
(
$bin_accel
)
$result
=
thrift_protocol_read_binary
(
$this
->
input_
,
'\tutorial\Calculator_add_result'
,
$this
->
input_
->
isStrictRead
());
else
{
$rseqid
=
0
;
$fname
=
null
;
$mtype
=
0
;
$this
->
input_
->
readMessageBegin
(
$fname
,
$mtype
,
$rseqid
);
if
(
$mtype
==
TMessageType
::
EXCEPTION
)
{
$x
=
new
TApplicationException
();
$x
->
read
(
$this
->
input_
);
$this
->
input_
->
readMessageEnd
();
throw
$x
;
}
$result
=
new
\tutorial\Calculator_add_result
();
$result
->
read
(
$this
->
input_
);
$this
->
input_
->
readMessageEnd
();
}
if
(
$result
->
success
!==
null
)
{
return
$result
->
success
;
}
throw
new
\Exception
(
"add failed: unknown result"
);
}
public
function
calculate
(
$logid
,
\tutorial\Work
$w
)
{
$this
->
send_calculate
(
$logid
,
$w
);
return
$this
->
recv_calculate
();
}
public
function
send_calculate
(
$logid
,
\tutorial\Work
$w
)
{
$args
=
new
\tutorial\Calculator_calculate_args
();
$args
->
logid
=
$logid
;
$args
->
w
=
$w
;
$bin_accel
=
(
$this
->
output_
instanceof
TBinaryProtocolAccelerated
)
&&
function_exists
(
'thrift_protocol_write_binary'
);
if
(
$bin_accel
)
{
thrift_protocol_write_binary
(
$this
->
output_
,
'calculate'
,
TMessageType
::
CALL
,
$args
,
$this
->
seqid_
,
$this
->
output_
->
isStrictWrite
());
}
else
{
$this
->
output_
->
writeMessageBegin
(
'calculate'
,
TMessageType
::
CALL
,
$this
->
seqid_
);
$args
->
write
(
$this
->
output_
);
$this
->
output_
->
writeMessageEnd
();
$this
->
output_
->
getTransport
()
->
flush
();
}
}
public
function
recv_calculate
()
{
$bin_accel
=
(
$this
->
input_
instanceof
TBinaryProtocolAccelerated
)
&&
function_exists
(
'thrift_protocol_read_binary'
);
if
(
$bin_accel
)
$result
=
thrift_protocol_read_binary
(
$this
->
input_
,
'\tutorial\Calculator_calculate_result'
,
$this
->
input_
->
isStrictRead
());
else
{
$rseqid
=
0
;
$fname
=
null
;
$mtype
=
0
;
$this
->
input_
->
readMessageBegin
(
$fname
,
$mtype
,
$rseqid
);
if
(
$mtype
==
TMessageType
::
EXCEPTION
)
{
$x
=
new
TApplicationException
();
$x
->
read
(
$this
->
input_
);
$this
->
input_
->
readMessageEnd
();
throw
$x
;
}
$result
=
new
\tutorial\Calculator_calculate_result
();
$result
->
read
(
$this
->
input_
);
$this
->
input_
->
readMessageEnd
();
}
if
(
$result
->
success
!==
null
)
{
return
$result
->
success
;
}
if
(
$result
->
ouch
!==
null
)
{
throw
$result
->
ouch
;
}
throw
new
\Exception
(
"calculate failed: unknown result"
);
}
public
function
zip
()
{
$this
->
send_zip
();
}
public
function
send_zip
()
{
$args
=
new
\tutorial\Calculator_zip_args
();
$bin_accel
=
(
$this
->
output_
instanceof
TBinaryProtocolAccelerated
)
&&
function_exists
(
'thrift_protocol_write_binary'
);
if
(
$bin_accel
)
{
thrift_protocol_write_binary
(
$this
->
output_
,
'zip'
,
TMessageType
::
ONEWAY
,
$args
,
$this
->
seqid_
,
$this
->
output_
->
isStrictWrite
());
}
else
{
$this
->
output_
->
writeMessageBegin
(
'zip'
,
TMessageType
::
ONEWAY
,
$this
->
seqid_
);
$args
->
write
(
$this
->
output_
);
$this
->
output_
->
writeMessageEnd
();
$this
->
output_
->
getTransport
()
->
flush
();
}
}
}
// HELPER FUNCTIONS AND STRUCTURES
class
Calculator_ping_args
{
static
$isValidate
=
false
;
static
$_TSPEC
=
array
(
);
public
function
__construct
()
{
}
public
function
getName
()
{
return
'Calculator_ping_args'
;
}
public
function
read
(
$input
)
{
$xfer
=
0
;
$fname
=
null
;
$ftype
=
0
;
$fid
=
0
;
$xfer
+=
$input
->
readStructBegin
(
$fname
);
while
(
true
)
{
$xfer
+=
$input
->
readFieldBegin
(
$fname
,
$ftype
,
$fid
);
if
(
$ftype
==
TType
::
STOP
)
{
break
;
}
switch
(
$fid
)
{
default
:
$xfer
+=
$input
->
skip
(
$ftype
);
break
;
}
$xfer
+=
$input
->
readFieldEnd
();
}
$xfer
+=
$input
->
readStructEnd
();
return
$xfer
;
}
public
function
write
(
$output
)
{
$xfer
=
0
;
$xfer
+=
$output
->
writeStructBegin
(
'Calculator_ping_args'
);
$xfer
+=
$output
->
writeFieldStop
();
$xfer
+=
$output
->
writeStructEnd
();
return
$xfer
;
}
}
class
Calculator_ping_result
{
static
$isValidate
=
false
;
static
$_TSPEC
=
array
(
);
public
function
__construct
()
{
}
public
function
getName
()
{
return
'Calculator_ping_result'
;
}
public
function
read
(
$input
)
{
$xfer
=
0
;
$fname
=
null
;
$ftype
=
0
;
$fid
=
0
;
$xfer
+=
$input
->
readStructBegin
(
$fname
);
while
(
true
)
{
$xfer
+=
$input
->
readFieldBegin
(
$fname
,
$ftype
,
$fid
);
if
(
$ftype
==
TType
::
STOP
)
{
break
;
}
switch
(
$fid
)
{
default
:
$xfer
+=
$input
->
skip
(
$ftype
);
break
;
}
$xfer
+=
$input
->
readFieldEnd
();
}
$xfer
+=
$input
->
readStructEnd
();
return
$xfer
;
}
public
function
write
(
$output
)
{
$xfer
=
0
;
$xfer
+=
$output
->
writeStructBegin
(
'Calculator_ping_result'
);
$xfer
+=
$output
->
writeFieldStop
();
$xfer
+=
$output
->
writeStructEnd
();
return
$xfer
;
}
}
class
Calculator_add_args
{
static
$isValidate
=
false
;
static
$_TSPEC
=
array
(
1
=>
array
(
'var'
=>
'num1'
,
'isRequired'
=>
false
,
'type'
=>
TType
::
I32
,
),
2
=>
array
(
'var'
=>
'num2'
,
'isRequired'
=>
false
,
'type'
=>
TType
::
I32
,
),
);
/**
* @var int
*/
public
$num1
=
null
;
/**
* @var int
*/
public
$num2
=
null
;
public
function
__construct
(
$vals
=
null
)
{
if
(
is_array
(
$vals
))
{
if
(
isset
(
$vals
[
'num1'
]))
{
$this
->
num1
=
$vals
[
'num1'
];
}
if
(
isset
(
$vals
[
'num2'
]))
{
$this
->
num2
=
$vals
[
'num2'
];
}
}
}
public
function
getName
()
{
return
'Calculator_add_args'
;
}
public
function
read
(
$input
)
{
$xfer
=
0
;
$fname
=
null
;
$ftype
=
0
;
$fid
=
0
;
$xfer
+=
$input
->
readStructBegin
(
$fname
);
while
(
true
)
{
$xfer
+=
$input
->
readFieldBegin
(
$fname
,
$ftype
,
$fid
);
if
(
$ftype
==
TType
::
STOP
)
{
break
;
}
switch
(
$fid
)
{
case
1
:
if
(
$ftype
==
TType
::
I32
)
{
$xfer
+=
$input
->
readI32
(
$this
->
num1
);
}
else
{
$xfer
+=
$input
->
skip
(
$ftype
);
}
break
;
case
2
:
if
(
$ftype
==
TType
::
I32
)
{
$xfer
+=
$input
->
readI32
(
$this
->
num2
);
}
else
{
$xfer
+=
$input
->
skip
(
$ftype
);
}
break
;
default
:
$xfer
+=
$input
->
skip
(
$ftype
);
break
;
}
$xfer
+=
$input
->
readFieldEnd
();
}
$xfer
+=
$input
->
readStructEnd
();
return
$xfer
;
}
public
function
write
(
$output
)
{
$xfer
=
0
;
$xfer
+=
$output
->
writeStructBegin
(
'Calculator_add_args'
);
if
(
$this
->
num1
!==
null
)
{
$xfer
+=
$output
->
writeFieldBegin
(
'num1'
,
TType
::
I32
,
1
);
$xfer
+=
$output
->
writeI32
(
$this
->
num1
);
$xfer
+=
$output
->
writeFieldEnd
();
}
if
(
$this
->
num2
!==
null
)
{
$xfer
+=
$output
->
writeFieldBegin
(
'num2'
,
TType
::
I32
,
2
);
$xfer
+=
$output
->
writeI32
(
$this
->
num2
);
$xfer
+=
$output
->
writeFieldEnd
();
}
$xfer
+=
$output
->
writeFieldStop
();
$xfer
+=
$output
->
writeStructEnd
();
return
$xfer
;
}
}
class
Calculator_add_result
{
static
$isValidate
=
false
;
static
$_TSPEC
=
array
(
0
=>
array
(
'var'
=>
'success'
,
'isRequired'
=>
false
,
'type'
=>
TType
::
I32
,
),
);
/**
* @var int
*/
public
$success
=
null
;
public
function
__construct
(
$vals
=
null
)
{
if
(
is_array
(
$vals
))
{
if
(
isset
(
$vals
[
'success'
]))
{
$this
->
success
=
$vals
[
'success'
];
}
}
}
public
function
getName
()
{
return
'Calculator_add_result'
;
}
public
function
read
(
$input
)
{
$xfer
=
0
;
$fname
=
null
;
$ftype
=
0
;
$fid
=
0
;
$xfer
+=
$input
->
readStructBegin
(
$fname
);
while
(
true
)
{
$xfer
+=
$input
->
readFieldBegin
(
$fname
,
$ftype
,
$fid
);
if
(
$ftype
==
TType
::
STOP
)
{
break
;
}
switch
(
$fid
)
{
case
0
:
if
(
$ftype
==
TType
::
I32
)
{
$xfer
+=
$input
->
readI32
(
$this
->
success
);
}
else
{
$xfer
+=
$input
->
skip
(
$ftype
);
}
break
;
default
:
$xfer
+=
$input
->
skip
(
$ftype
);
break
;
}
$xfer
+=
$input
->
readFieldEnd
();
}
$xfer
+=
$input
->
readStructEnd
();
return
$xfer
;
}
public
function
write
(
$output
)
{
$xfer
=
0
;
$xfer
+=
$output
->
writeStructBegin
(
'Calculator_add_result'
);
if
(
$this
->
success
!==
null
)
{
$xfer
+=
$output
->
writeFieldBegin
(
'success'
,
TType
::
I32
,
0
);
$xfer
+=
$output
->
writeI32
(
$this
->
success
);
$xfer
+=
$output
->
writeFieldEnd
();
}
$xfer
+=
$output
->
writeFieldStop
();
$xfer
+=
$output
->
writeStructEnd
();
return
$xfer
;
}
}
class
Calculator_calculate_args
{
static
$isValidate
=
false
;
static
$_TSPEC
=
array
(
1
=>
array
(
'var'
=>
'logid'
,
'isRequired'
=>
false
,
'type'
=>
TType
::
I32
,
),
2
=>
array
(
'var'
=>
'w'
,
'isRequired'
=>
false
,
'type'
=>
TType
::
STRUCT
,
'class'
=>
'\tutorial\Work'
,
),
);
/**
* @var int
*/
public
$logid
=
null
;
/**
* @var \tutorial\Work
*/
public
$w
=
null
;
public
function
__construct
(
$vals
=
null
)
{
if
(
is_array
(
$vals
))
{
if
(
isset
(
$vals
[
'logid'
]))
{
$this
->
logid
=
$vals
[
'logid'
];
}
if
(
isset
(
$vals
[
'w'
]))
{
$this
->
w
=
$vals
[
'w'
];
}
}
}
public
function
getName
()
{
return
'Calculator_calculate_args'
;
}
public
function
read
(
$input
)
{
$xfer
=
0
;
$fname
=
null
;
$ftype
=
0
;
$fid
=
0
;
$xfer
+=
$input
->
readStructBegin
(
$fname
);
while
(
true
)
{
$xfer
+=
$input
->
readFieldBegin
(
$fname
,
$ftype
,
$fid
);
if
(
$ftype
==
TType
::
STOP
)
{
break
;
}
switch
(
$fid
)
{
case
1
:
if
(
$ftype
==
TType
::
I32
)
{
$xfer
+=
$input
->
readI32
(
$this
->
logid
);
}
else
{
$xfer
+=
$input
->
skip
(
$ftype
);
}
break
;
case
2
:
if
(
$ftype
==
TType
::
STRUCT
)
{
$this
->
w
=
new
\tutorial\Work
();
$xfer
+=
$this
->
w
->
read
(
$input
);
}
else
{
$xfer
+=
$input
->
skip
(
$ftype
);
}
break
;
default
:
$xfer
+=
$input
->
skip
(
$ftype
);
break
;
}
$xfer
+=
$input
->
readFieldEnd
();
}
$xfer
+=
$input
->
readStructEnd
();
return
$xfer
;
}
public
function
write
(
$output
)
{
$xfer
=
0
;
$xfer
+=
$output
->
writeStructBegin
(
'Calculator_calculate_args'
);
if
(
$this
->
logid
!==
null
)
{
$xfer
+=
$output
->
writeFieldBegin
(
'logid'
,
TType
::
I32
,
1
);
$xfer
+=
$output
->
writeI32
(
$this
->
logid
);
$xfer
+=
$output
->
writeFieldEnd
();
}
if
(
$this
->
w
!==
null
)
{
if
(
!
is_object
(
$this
->
w
))
{
throw
new
TProtocolException
(
'Bad type in structure.'
,
TProtocolException
::
INVALID_DATA
);
}
$xfer
+=
$output
->
writeFieldBegin
(
'w'
,
TType
::
STRUCT
,
2
);
$xfer
+=
$this
->
w
->
write
(
$output
);
$xfer
+=
$output
->
writeFieldEnd
();
}
$xfer
+=
$output
->
writeFieldStop
();
$xfer
+=
$output
->
writeStructEnd
();
return
$xfer
;
}
}
class
Calculator_calculate_result
{
static
$isValidate
=
false
;
static
$_TSPEC
=
array
(
0
=>
array
(
'var'
=>
'success'
,
'isRequired'
=>
false
,
'type'
=>
TType
::
I32
,
),
1
=>
array
(
'var'
=>
'ouch'
,
'isRequired'
=>
false
,
'type'
=>
TType
::
STRUCT
,
'class'
=>
'\tutorial\InvalidOperation'
,
),
);
/**
* @var int
*/
public
$success
=
null
;
/**
* @var \tutorial\InvalidOperation
*/
public
$ouch
=
null
;
public
function
__construct
(
$vals
=
null
)
{
if
(
is_array
(
$vals
))
{
if
(
isset
(
$vals
[
'success'
]))
{
$this
->
success
=
$vals
[
'success'
];
}
if
(
isset
(
$vals
[
'ouch'
]))
{
$this
->
ouch
=
$vals
[
'ouch'
];
}
}
}
public
function
getName
()
{
return
'Calculator_calculate_result'
;
}
public
function
read
(
$input
)
{
$xfer
=
0
;
$fname
=
null
;
$ftype
=
0
;
$fid
=
0
;
$xfer
+=
$input
->
readStructBegin
(
$fname
);
while
(
true
)
{
$xfer
+=
$input
->
readFieldBegin
(
$fname
,
$ftype
,
$fid
);
if
(
$ftype
==
TType
::
STOP
)
{
break
;
}
switch
(
$fid
)
{
case
0
:
if
(
$ftype
==
TType
::
I32
)
{
$xfer
+=
$input
->
readI32
(
$this
->
success
);
}
else
{
$xfer
+=
$input
->
skip
(
$ftype
);
}
break
;
case
1
:
if
(
$ftype
==
TType
::
STRUCT
)
{
$this
->
ouch
=
new
\tutorial\InvalidOperation
();
$xfer
+=
$this
->
ouch
->
read
(
$input
);
}
else
{
$xfer
+=
$input
->
skip
(
$ftype
);
}
break
;
default
:
$xfer
+=
$input
->
skip
(
$ftype
);
break
;
}
$xfer
+=
$input
->
readFieldEnd
();
}
$xfer
+=
$input
->
readStructEnd
();
return
$xfer
;
}
public
function
write
(
$output
)
{
$xfer
=
0
;
$xfer
+=
$output
->
writeStructBegin
(
'Calculator_calculate_result'
);
if
(
$this
->
success
!==
null
)
{
$xfer
+=
$output
->
writeFieldBegin
(
'success'
,
TType
::
I32
,
0
);
$xfer
+=
$output
->
writeI32
(
$this
->
success
);
$xfer
+=
$output
->
writeFieldEnd
();
}
if
(
$this
->
ouch
!==
null
)
{
$xfer
+=
$output
->
writeFieldBegin
(
'ouch'
,
TType
::
STRUCT
,
1
);
$xfer
+=
$this
->
ouch
->
write
(
$output
);
$xfer
+=
$output
->
writeFieldEnd
();
}
$xfer
+=
$output
->
writeFieldStop
();
$xfer
+=
$output
->
writeStructEnd
();
return
$xfer
;
}
}
class
Calculator_zip_args
{
static
$isValidate
=
false
;
static
$_TSPEC
=
array
(
);
public
function
__construct
()
{
}
public
function
getName
()
{
return
'Calculator_zip_args'
;
}
public
function
read
(
$input
)
{
$xfer
=
0
;
$fname
=
null
;
$ftype
=
0
;
$fid
=
0
;
$xfer
+=
$input
->
readStructBegin
(
$fname
);
while
(
true
)
{
$xfer
+=
$input
->
readFieldBegin
(
$fname
,
$ftype
,
$fid
);
if
(
$ftype
==
TType
::
STOP
)
{
break
;
}
switch
(
$fid
)
{
default
:
$xfer
+=
$input
->
skip
(
$ftype
);
break
;
}
$xfer
+=
$input
->
readFieldEnd
();
}
$xfer
+=
$input
->
readStructEnd
();
return
$xfer
;
}
public
function
write
(
$output
)
{
$xfer
=
0
;
$xfer
+=
$output
->
writeStructBegin
(
'Calculator_zip_args'
);
$xfer
+=
$output
->
writeFieldStop
();
$xfer
+=
$output
->
writeStructEnd
();
return
$xfer
;
}
}
tutorial/gen-php/tutorial/Types.php
0 → 100644
View file @
bbe21d02
<?php
namespace
tutorial
;
/**
* Autogenerated by Thrift Compiler (0.11.0)
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
* @generated
*/
use
Thrift\Base\TBase
;
use
Thrift\Type\TType
;
use
Thrift\Type\TMessageType
;
use
Thrift\Exception\TException
;
use
Thrift\Exception\TProtocolException
;
use
Thrift\Protocol\TProtocol
;
use
Thrift\Protocol\TBinaryProtocolAccelerated
;
use
Thrift\Exception\TApplicationException
;
/**
* You can define enums, which are just 32 bit integers. Values are optional
* and start at 1 if not supplied, C style again.
*/
final
class
Operation
{
const
ADD
=
1
;
const
SUBTRACT
=
2
;
const
MULTIPLY
=
3
;
const
DIVIDE
=
4
;
static
public
$__names
=
array
(
1
=>
'ADD'
,
2
=>
'SUBTRACT'
,
3
=>
'MULTIPLY'
,
4
=>
'DIVIDE'
,
);
}
/**
* Structs are the basic complex data structures. They are comprised of fields
* which each have an integer identifier, a type, a symbolic name, and an
* optional default value.
*
* Fields can be declared "optional", which ensures they will not be included
* in the serialized output if they aren't set. Note that this requires some
* manual management in some languages.
*/
class
Work
{
static
$isValidate
=
false
;
static
$_TSPEC
=
array
(
1
=>
array
(
'var'
=>
'num1'
,
'isRequired'
=>
false
,
'type'
=>
TType
::
I32
,
),
2
=>
array
(
'var'
=>
'num2'
,
'isRequired'
=>
false
,
'type'
=>
TType
::
I32
,
),
3
=>
array
(
'var'
=>
'op'
,
'isRequired'
=>
false
,
'type'
=>
TType
::
I32
,
),
4
=>
array
(
'var'
=>
'comment'
,
'isRequired'
=>
false
,
'type'
=>
TType
::
STRING
,
),
);
/**
* @var int
*/
public
$num1
=
0
;
/**
* @var int
*/
public
$num2
=
null
;
/**
* @var int
*/
public
$op
=
null
;
/**
* @var string
*/
public
$comment
=
null
;
public
function
__construct
(
$vals
=
null
)
{
if
(
is_array
(
$vals
))
{
if
(
isset
(
$vals
[
'num1'
]))
{
$this
->
num1
=
$vals
[
'num1'
];
}
if
(
isset
(
$vals
[
'num2'
]))
{
$this
->
num2
=
$vals
[
'num2'
];
}
if
(
isset
(
$vals
[
'op'
]))
{
$this
->
op
=
$vals
[
'op'
];
}
if
(
isset
(
$vals
[
'comment'
]))
{
$this
->
comment
=
$vals
[
'comment'
];
}
}
}
public
function
getName
()
{
return
'Work'
;
}
public
function
read
(
$input
)
{
$xfer
=
0
;
$fname
=
null
;
$ftype
=
0
;
$fid
=
0
;
$xfer
+=
$input
->
readStructBegin
(
$fname
);
while
(
true
)
{
$xfer
+=
$input
->
readFieldBegin
(
$fname
,
$ftype
,
$fid
);
if
(
$ftype
==
TType
::
STOP
)
{
break
;
}
switch
(
$fid
)
{
case
1
:
if
(
$ftype
==
TType
::
I32
)
{
$xfer
+=
$input
->
readI32
(
$this
->
num1
);
}
else
{
$xfer
+=
$input
->
skip
(
$ftype
);
}
break
;
case
2
:
if
(
$ftype
==
TType
::
I32
)
{
$xfer
+=
$input
->
readI32
(
$this
->
num2
);
}
else
{
$xfer
+=
$input
->
skip
(
$ftype
);
}
break
;
case
3
:
if
(
$ftype
==
TType
::
I32
)
{
$xfer
+=
$input
->
readI32
(
$this
->
op
);
}
else
{
$xfer
+=
$input
->
skip
(
$ftype
);
}
break
;
case
4
:
if
(
$ftype
==
TType
::
STRING
)
{
$xfer
+=
$input
->
readString
(
$this
->
comment
);
}
else
{
$xfer
+=
$input
->
skip
(
$ftype
);
}
break
;
default
:
$xfer
+=
$input
->
skip
(
$ftype
);
break
;
}
$xfer
+=
$input
->
readFieldEnd
();
}
$xfer
+=
$input
->
readStructEnd
();
return
$xfer
;
}
public
function
write
(
$output
)
{
$xfer
=
0
;
$xfer
+=
$output
->
writeStructBegin
(
'Work'
);
if
(
$this
->
num1
!==
null
)
{
$xfer
+=
$output
->
writeFieldBegin
(
'num1'
,
TType
::
I32
,
1
);
$xfer
+=
$output
->
writeI32
(
$this
->
num1
);
$xfer
+=
$output
->
writeFieldEnd
();
}
if
(
$this
->
num2
!==
null
)
{
$xfer
+=
$output
->
writeFieldBegin
(
'num2'
,
TType
::
I32
,
2
);
$xfer
+=
$output
->
writeI32
(
$this
->
num2
);
$xfer
+=
$output
->
writeFieldEnd
();
}
if
(
$this
->
op
!==
null
)
{
$xfer
+=
$output
->
writeFieldBegin
(
'op'
,
TType
::
I32
,
3
);
$xfer
+=
$output
->
writeI32
(
$this
->
op
);
$xfer
+=
$output
->
writeFieldEnd
();
}
if
(
$this
->
comment
!==
null
)
{
$xfer
+=
$output
->
writeFieldBegin
(
'comment'
,
TType
::
STRING
,
4
);
$xfer
+=
$output
->
writeString
(
$this
->
comment
);
$xfer
+=
$output
->
writeFieldEnd
();
}
$xfer
+=
$output
->
writeFieldStop
();
$xfer
+=
$output
->
writeStructEnd
();
return
$xfer
;
}
}
/**
* Structs can also be exceptions, if they are nasty.
*/
class
InvalidOperation
extends
TException
{
static
$isValidate
=
false
;
static
$_TSPEC
=
array
(
1
=>
array
(
'var'
=>
'whatOp'
,
'isRequired'
=>
false
,
'type'
=>
TType
::
I32
,
),
2
=>
array
(
'var'
=>
'why'
,
'isRequired'
=>
false
,
'type'
=>
TType
::
STRING
,
),
);
/**
* @var int
*/
public
$whatOp
=
null
;
/**
* @var string
*/
public
$why
=
null
;
public
function
__construct
(
$vals
=
null
)
{
if
(
is_array
(
$vals
))
{
if
(
isset
(
$vals
[
'whatOp'
]))
{
$this
->
whatOp
=
$vals
[
'whatOp'
];
}
if
(
isset
(
$vals
[
'why'
]))
{
$this
->
why
=
$vals
[
'why'
];
}
}
}
public
function
getName
()
{
return
'InvalidOperation'
;
}
public
function
read
(
$input
)
{
$xfer
=
0
;
$fname
=
null
;
$ftype
=
0
;
$fid
=
0
;
$xfer
+=
$input
->
readStructBegin
(
$fname
);
while
(
true
)
{
$xfer
+=
$input
->
readFieldBegin
(
$fname
,
$ftype
,
$fid
);
if
(
$ftype
==
TType
::
STOP
)
{
break
;
}
switch
(
$fid
)
{
case
1
:
if
(
$ftype
==
TType
::
I32
)
{
$xfer
+=
$input
->
readI32
(
$this
->
whatOp
);
}
else
{
$xfer
+=
$input
->
skip
(
$ftype
);
}
break
;
case
2
:
if
(
$ftype
==
TType
::
STRING
)
{
$xfer
+=
$input
->
readString
(
$this
->
why
);
}
else
{
$xfer
+=
$input
->
skip
(
$ftype
);
}
break
;
default
:
$xfer
+=
$input
->
skip
(
$ftype
);
break
;
}
$xfer
+=
$input
->
readFieldEnd
();
}
$xfer
+=
$input
->
readStructEnd
();
return
$xfer
;
}
public
function
write
(
$output
)
{
$xfer
=
0
;
$xfer
+=
$output
->
writeStructBegin
(
'InvalidOperation'
);
if
(
$this
->
whatOp
!==
null
)
{
$xfer
+=
$output
->
writeFieldBegin
(
'whatOp'
,
TType
::
I32
,
1
);
$xfer
+=
$output
->
writeI32
(
$this
->
whatOp
);
$xfer
+=
$output
->
writeFieldEnd
();
}
if
(
$this
->
why
!==
null
)
{
$xfer
+=
$output
->
writeFieldBegin
(
'why'
,
TType
::
STRING
,
2
);
$xfer
+=
$output
->
writeString
(
$this
->
why
);
$xfer
+=
$output
->
writeFieldEnd
();
}
$xfer
+=
$output
->
writeFieldStop
();
$xfer
+=
$output
->
writeStructEnd
();
return
$xfer
;
}
}
final
class
Constant
extends
\Thrift\Type\TConstant
{
static
protected
$INT32CONSTANT
;
static
protected
$MAPCONSTANT
;
static
protected
function
init_INT32CONSTANT
()
{
return
/**
* Thrift also lets you define constants for use across languages. Complex
* types and structs are specified using JSON notation.
*/
9853
;
}
static
protected
function
init_MAPCONSTANT
()
{
return
array
(
"hello"
=>
"world"
,
"goodnight"
=>
"moon"
,
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment