forked from facebook/fbthrift
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Summary: For the differences between this and the next item Reviewed By: yfeldblum Differential Revision: D14111355 fbshipit-source-id: d4750c416f35447dd6269e1e1535e606bdda97db
- Loading branch information
1 parent
adacc59
commit 66b50e6
Showing
4 changed files
with
424 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
hack src/module.thrift |
294 changes: 294 additions & 0 deletions
294
thrift/compiler/test/fixtures/hack-struct-keys/gen-hack/Baz.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,294 @@ | ||
<?hh // strict | ||
/** | ||
* Autogenerated by Thrift | ||
* | ||
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING | ||
* @generated | ||
*/ | ||
|
||
/** | ||
* Original thrift service:- | ||
* Baz | ||
*/ | ||
interface BazAsyncIf extends \IThriftAsyncIf { | ||
/** | ||
* Original thrift definition:- | ||
* string | ||
* qux(1: set<Foo> a, | ||
* 2: list<Bar> b, | ||
* 3: map<Foo, string> c); | ||
*/ | ||
public function qux(Set<Foo> $a, \HH\KeyedContainer<int, Bar> $b, \HH\KeyedContainer<Foo, string> $c): Awaitable<string>; | ||
} | ||
|
||
/** | ||
* Original thrift service:- | ||
* Baz | ||
*/ | ||
interface BazIf extends \IThriftSyncIf { | ||
/** | ||
* Original thrift definition:- | ||
* string | ||
* qux(1: set<Foo> a, | ||
* 2: list<Bar> b, | ||
* 3: map<Foo, string> c); | ||
*/ | ||
public function qux(Set<Foo> $a, \HH\KeyedContainer<int, Bar> $b, \HH\KeyedContainer<Foo, string> $c): string; | ||
} | ||
|
||
/** | ||
* Original thrift service:- | ||
* Baz | ||
*/ | ||
trait BazClientBase { | ||
require extends \ThriftClientBase; | ||
|
||
protected function sendImpl_qux(Set<Foo> $a, \HH\KeyedContainer<int, Bar> $b, \HH\KeyedContainer<Foo, string> $c): int { | ||
$currentseqid = $this->getNextSequenceID(); | ||
$args = new Baz_qux_args( | ||
$a, | ||
new Vector($b), | ||
new Map($c), | ||
); | ||
try { | ||
$this->eventHandler_->preSend('qux', $args, $currentseqid); | ||
if ($this->output_ is \TBinaryProtocolAccelerated) | ||
{ | ||
\thrift_protocol_write_binary($this->output_, 'qux', \TMessageType::CALL, $args, $currentseqid, $this->output_->isStrictWrite(), false); | ||
} | ||
else if ($this->output_ is \TCompactProtocolAccelerated) | ||
{ | ||
\thrift_protocol_write_compact($this->output_, 'qux', \TMessageType::CALL, $args, $currentseqid, false); | ||
} | ||
else | ||
{ | ||
$this->output_->writeMessageBegin('qux', \TMessageType::CALL, $currentseqid); | ||
$args->write($this->output_); | ||
$this->output_->writeMessageEnd(); | ||
$this->output_->getTransport()->flush(); | ||
} | ||
} catch (\THandlerShortCircuitException $ex) { | ||
switch ($ex->resultType) { | ||
case \THandlerShortCircuitException::R_EXPECTED_EX: | ||
case \THandlerShortCircuitException::R_UNEXPECTED_EX: | ||
$this->eventHandler_->sendError('qux', $args, $currentseqid, $ex->result); | ||
throw $ex->result; | ||
case \THandlerShortCircuitException::R_SUCCESS: | ||
default: | ||
$this->eventHandler_->postSend('qux', $args, $currentseqid); | ||
return $currentseqid; | ||
} | ||
} catch (\Exception $ex) { | ||
$this->eventHandler_->sendError('qux', $args, $currentseqid, $ex); | ||
throw $ex; | ||
} | ||
$this->eventHandler_->postSend('qux', $args, $currentseqid); | ||
return $currentseqid; | ||
} | ||
|
||
protected function recvImpl_qux(?int $expectedsequenceid = null): string { | ||
try { | ||
$this->eventHandler_->preRecv('qux', $expectedsequenceid); | ||
if ($this->input_ is \TBinaryProtocolAccelerated) { | ||
$result = \thrift_protocol_read_binary($this->input_, 'Baz_qux_result', $this->input_->isStrictRead()); | ||
} else if ($this->input_ is \TCompactProtocolAccelerated) | ||
{ | ||
$result = \thrift_protocol_read_compact($this->input_, 'Baz_qux_result'); | ||
} | ||
else | ||
{ | ||
$rseqid = 0; | ||
$fname = ''; | ||
$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 Baz_qux_result(); | ||
$result->read($this->input_); | ||
$this->input_->readMessageEnd(); | ||
if ($expectedsequenceid !== null && ($rseqid != $expectedsequenceid)) { | ||
throw new \TProtocolException("qux failed: sequence id is out of order"); | ||
} | ||
} | ||
} catch (\THandlerShortCircuitException $ex) { | ||
switch ($ex->resultType) { | ||
case \THandlerShortCircuitException::R_EXPECTED_EX: | ||
$this->eventHandler_->recvException('qux', $expectedsequenceid, $ex->result); | ||
throw $ex->result; | ||
case \THandlerShortCircuitException::R_UNEXPECTED_EX: | ||
$this->eventHandler_->recvError('qux', $expectedsequenceid, $ex->result); | ||
throw $ex->result; | ||
case \THandlerShortCircuitException::R_SUCCESS: | ||
default: | ||
$this->eventHandler_->postRecv('qux', $expectedsequenceid, $ex->result); | ||
return $ex->result; | ||
} | ||
} catch (\Exception $ex) { | ||
$this->eventHandler_->recvError('qux', $expectedsequenceid, $ex); | ||
throw $ex; | ||
} | ||
if ($result->success !== null) { | ||
$success = $result->success; | ||
$this->eventHandler_->postRecv('qux', $expectedsequenceid, $success); | ||
return $success; | ||
} | ||
$x = new \TApplicationException("qux failed: unknown result", \TApplicationException::MISSING_RESULT); | ||
$this->eventHandler_->recvError('qux', $expectedsequenceid, $x); | ||
throw $x; | ||
} | ||
|
||
} | ||
|
||
class BazAsyncClient extends \ThriftClientBase implements BazAsyncIf { | ||
use BazClientBase; | ||
|
||
/** | ||
* Original thrift definition:- | ||
* string | ||
* qux(1: set<Foo> a, | ||
* 2: list<Bar> b, | ||
* 3: map<Foo, string> c); | ||
*/ | ||
public async function qux(Set<Foo> $a, \HH\KeyedContainer<int, Bar> $b, \HH\KeyedContainer<Foo, string> $c): Awaitable<string> { | ||
$currentseqid = $this->sendImpl_qux($a, $b, $c); | ||
await $this->asyncHandler_->genWait($currentseqid); | ||
return $this->recvImpl_qux($currentseqid); | ||
} | ||
|
||
} | ||
|
||
class BazClient extends \ThriftClientBase implements BazIf { | ||
use BazClientBase; | ||
|
||
<<__Deprecated('use gen_qux()')>> | ||
public function qux(Set<Foo> $a, \HH\KeyedContainer<int, Bar> $b, \HH\KeyedContainer<Foo, string> $c): string { | ||
$currentseqid = $this->sendImpl_qux($a, $b, $c); | ||
return $this->recvImpl_qux($currentseqid); | ||
} | ||
|
||
/** | ||
* Original thrift definition:- | ||
* string | ||
* qux(1: set<Foo> a, | ||
* 2: list<Bar> b, | ||
* 3: map<Foo, string> c); | ||
*/ | ||
public async function gen_qux(Set<Foo> $a, \HH\KeyedContainer<int, Bar> $b, \HH\KeyedContainer<Foo, string> $c): Awaitable<string> { | ||
$currentseqid = $this->sendImpl_qux($a, $b, $c); | ||
await $this->asyncHandler_->genWait($currentseqid); | ||
return $this->recvImpl_qux($currentseqid); | ||
} | ||
|
||
/* send and recv functions */ | ||
public function send_qux(Set<Foo> $a, \HH\KeyedContainer<int, Bar> $b, \HH\KeyedContainer<Foo, string> $c): int { | ||
return $this->sendImpl_qux($a, $b, $c); | ||
} | ||
public function recv_qux(?int $expectedsequenceid = null): string { | ||
return $this->recvImpl_qux($expectedsequenceid); | ||
} | ||
} | ||
|
||
// HELPER FUNCTIONS AND STRUCTURES | ||
|
||
class Baz_qux_args implements \IThriftStruct { | ||
use \ThriftSerializationTrait; | ||
|
||
public static dict<int, dict<string, mixed>> $_TSPEC = dict[ | ||
1 => dict[ | ||
'var' => 'a', | ||
'type' => \TType::SET, | ||
'etype' => \TType::STRUCT, | ||
'elem' => dict[ | ||
'type' => \TType::STRUCT, | ||
'class' => 'Foo', | ||
], | ||
'format' => 'collection', | ||
], | ||
2 => dict[ | ||
'var' => 'b', | ||
'type' => \TType::LST, | ||
'etype' => \TType::STRUCT, | ||
'elem' => dict[ | ||
'type' => \TType::STRUCT, | ||
'class' => 'Bar', | ||
], | ||
'format' => 'collection', | ||
], | ||
3 => dict[ | ||
'var' => 'c', | ||
'type' => \TType::MAP, | ||
'ktype' => \TType::STRUCT, | ||
'vtype' => \TType::STRING, | ||
'key' => dict[ | ||
'type' => \TType::STRUCT, | ||
'class' => 'Foo', | ||
], | ||
'val' => dict[ | ||
'type' => \TType::STRING, | ||
], | ||
'format' => 'collection', | ||
], | ||
]; | ||
public static Map<string, int> $_TFIELDMAP = Map { | ||
'a' => 1, | ||
'b' => 2, | ||
'c' => 3, | ||
}; | ||
const int STRUCTURAL_ID = 1160460043765273624; | ||
public Set<Foo> $a; | ||
public Vector<Bar> $b; | ||
public Map<Foo, string> $c; | ||
|
||
public function __construct(?Set<Foo> $a = null, ?Vector<Bar> $b = null, ?Map<Foo, string> $c = null ) { | ||
if ($a === null) { | ||
$this->a = Set {}; | ||
} else { | ||
$this->a = $a; | ||
} | ||
if ($b === null) { | ||
$this->b = Vector {}; | ||
} else { | ||
$this->b = $b; | ||
} | ||
if ($c === null) { | ||
$this->c = Map {}; | ||
} else { | ||
$this->c = $c; | ||
} | ||
} | ||
|
||
public function getName(): string { | ||
return 'Baz_qux_args'; | ||
} | ||
|
||
} | ||
|
||
class Baz_qux_result implements \IThriftStruct { | ||
use \ThriftSerializationTrait; | ||
|
||
public static dict<int, dict<string, mixed>> $_TSPEC = dict[ | ||
0 => dict[ | ||
'var' => 'success', | ||
'type' => \TType::STRING, | ||
], | ||
]; | ||
public static Map<string, int> $_TFIELDMAP = Map { | ||
'success' => 0, | ||
}; | ||
const int STRUCTURAL_ID = 1365128170602685579; | ||
public ?string $success; | ||
|
||
public function __construct(?string $success = null ) { | ||
} | ||
|
||
public function getName(): string { | ||
return 'Baz_qux_result'; | ||
} | ||
|
||
} | ||
|
Oops, something went wrong.