2 +----------------------------------------------------------------------+
4 +----------------------------------------------------------------------+
5 | Copyright (c) 2010-present Facebook, Inc. (http://www.facebook.com) |
6 | Copyright (c) 1997-2010 The PHP Group |
7 +----------------------------------------------------------------------+
8 | This source file is subject to version 3.01 of the PHP license, |
9 | that is bundled with this package in the file LICENSE, and is |
10 | available through the world-wide-web at the following url: |
11 | http://www.php.net/license/3_01.txt |
12 | If you did not receive a copy of the PHP license and are unable to |
13 | obtain it through the world-wide-web, please send a note to |
14 | license@php.net so we can mail you a copy immediately. |
15 +----------------------------------------------------------------------+
18 #include "hphp/runtime/ext/thrift/spec-holder.h"
20 #include "hphp/runtime/base/array-init.h"
22 namespace HPHP
{ namespace thrift
{
24 void thrift_error(const String
& what
, TError why
) {
25 throw_object(s_TProtocolException
, make_packed_array(what
, why
));
28 Array
get_tspec(const Class
* cls
) {
30 passing in cls will short-circuit the accessibility checks,
31 but does mean we'll allow a private or protected s_TSPEC.
32 passing in nullptr would do the correct checks. Not sure it matters
34 auto lookup
= cls
->getSProp(cls
, s_TSPEC
.get());
37 folly::sformat("Class {} does not have a property named {}",
38 cls
->name(), s_TSPEC
),
41 Variant structSpec
= tvAsVariant(lookup
.prop
);
42 if (!structSpec
.isArray()) {
43 thrift_error("invalid type of spec", ERR_INVALID_DATA
);
45 return structSpec
.toArray();
48 SpecCacheMap
SpecHolder::s_specCacheMap(1000);