Skip to content

Commit

Permalink
new fixtures
Browse files Browse the repository at this point in the history
Summary: For the differences between this and the next item

Reviewed By: yfeldblum

Differential Revision: D14111355

fbshipit-source-id: d4750c416f35447dd6269e1e1535e606bdda97db
  • Loading branch information
DavidSnider authored and facebook-github-bot committed Feb 16, 2019
1 parent adacc59 commit 66b50e6
Show file tree
Hide file tree
Showing 4 changed files with 424 additions and 0 deletions.
1 change: 1 addition & 0 deletions thrift/compiler/test/fixtures/hack-struct-keys/cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
hack src/module.thrift
294 changes: 294 additions & 0 deletions thrift/compiler/test/fixtures/hack-struct-keys/gen-hack/Baz.php
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';
}

}

Loading

0 comments on commit 66b50e6

Please sign in to comment.