commit
5c028d6cf4
212 changed files with 9365 additions and 4095 deletions
@ -1,4 +1,2 @@ |
||||
Recommended.Proto2.JsonInput.FieldNameExtension.Validator |
||||
Recommended.Proto3.JsonInput.NullValueInOtherOneofNewFormat.Validator |
||||
Recommended.Proto3.JsonInput.NullValueInOtherOneofOldFormat.Validator |
||||
Required.Proto2.JsonInput.StoresDefaultPrimitive.Validator |
||||
|
@ -1,4 +0,0 @@ |
||||
Recommended.Proto2.JsonInput.FieldNameExtension.Validator |
||||
Recommended.Proto3.JsonInput.NullValueInOtherOneofNewFormat.Validator |
||||
Recommended.Proto3.JsonInput.NullValueInOtherOneofOldFormat.Validator |
||||
Required.Proto2.JsonInput.StoresDefaultPrimitive.Validator |
@ -0,0 +1,36 @@ |
||||
# This is the list of text format conformance tests that are known to fail right |
||||
# now. |
||||
# TODO: These should be fixed. |
||||
Required.Proto3.TextFormatInput.FloatFieldMaxValue.ProtobufOutput |
||||
Required.Proto3.TextFormatInput.FloatFieldMaxValue.TextFormatOutput |
||||
|
||||
Recommended.Proto3.TextFormatInput.StringLiteralLongUnicodeEscapeSurrogateFirstOnlyBytes |
||||
Recommended.Proto3.TextFormatInput.StringLiteralLongUnicodeEscapeSurrogateFirstOnlyString |
||||
Recommended.Proto3.TextFormatInput.StringLiteralLongUnicodeEscapeSurrogatePairBytes |
||||
Recommended.Proto3.TextFormatInput.StringLiteralLongUnicodeEscapeSurrogatePairString |
||||
Recommended.Proto3.TextFormatInput.StringLiteralLongUnicodeEscapeSurrogateSecondOnlyBytes |
||||
Recommended.Proto3.TextFormatInput.StringLiteralLongUnicodeEscapeSurrogateSecondOnlyString |
||||
Recommended.Proto3.TextFormatInput.StringLiteralLongUnicodeEscapesBytes.ProtobufOutput |
||||
Recommended.Proto3.TextFormatInput.StringLiteralLongUnicodeEscapesBytes.TextFormatOutput |
||||
Recommended.Proto3.TextFormatInput.StringLiteralLongUnicodeEscapesString.ProtobufOutput |
||||
Recommended.Proto3.TextFormatInput.StringLiteralLongUnicodeEscapesString.TextFormatOutput |
||||
Recommended.Proto3.TextFormatInput.StringLiteralShortUnicodeEscapeBytes.ProtobufOutput |
||||
Recommended.Proto3.TextFormatInput.StringLiteralShortUnicodeEscapeBytes.TextFormatOutput |
||||
Recommended.Proto3.TextFormatInput.StringLiteralShortUnicodeEscapeString.ProtobufOutput |
||||
Recommended.Proto3.TextFormatInput.StringLiteralShortUnicodeEscapeString.TextFormatOutput |
||||
Recommended.Proto3.TextFormatInput.StringLiteralShortUnicodeEscapeSurrogateFirstOnlyBytes |
||||
Recommended.Proto3.TextFormatInput.StringLiteralShortUnicodeEscapeSurrogateFirstOnlyString |
||||
Recommended.Proto3.TextFormatInput.StringLiteralShortUnicodeEscapeSurrogatePairBytes |
||||
Recommended.Proto3.TextFormatInput.StringLiteralShortUnicodeEscapeSurrogatePairString |
||||
Recommended.Proto3.TextFormatInput.StringLiteralShortUnicodeEscapeSurrogateSecondOnlyBytes |
||||
Recommended.Proto3.TextFormatInput.StringLiteralShortUnicodeEscapeSurrogateSecondOnlyString |
||||
Recommended.Proto3.TextFormatInput.StringLiteralUnicodeEscapeSurrogatePairLongShortBytes |
||||
Recommended.Proto3.TextFormatInput.StringLiteralUnicodeEscapeSurrogatePairLongShortString |
||||
Recommended.Proto3.TextFormatInput.StringLiteralUnicodeEscapeSurrogatePairShortLongBytes |
||||
Recommended.Proto3.TextFormatInput.StringLiteralUnicodeEscapeSurrogatePairShortLongString |
||||
Required.Proto3.TextFormatInput.StringLiteralBasicEscapesBytes.ProtobufOutput |
||||
Required.Proto3.TextFormatInput.StringLiteralBasicEscapesBytes.TextFormatOutput |
||||
Required.Proto3.TextFormatInput.StringLiteralBasicEscapesString.ProtobufOutput |
||||
Required.Proto3.TextFormatInput.StringLiteralBasicEscapesString.TextFormatOutput |
||||
Required.Proto3.TextFormatInput.StringLiteralLongUnicodeEscapeTooLargeBytes |
||||
Required.Proto3.TextFormatInput.StringLiteralLongUnicodeEscapeTooLargeString |
@ -0,0 +1,30 @@ |
||||
Recommended.Proto3.TextFormatInput.StringLiteralLongUnicodeEscapeSurrogateFirstOnlyBytes |
||||
Recommended.Proto3.TextFormatInput.StringLiteralLongUnicodeEscapeSurrogateFirstOnlyString |
||||
Recommended.Proto3.TextFormatInput.StringLiteralLongUnicodeEscapeSurrogatePairBytes |
||||
Recommended.Proto3.TextFormatInput.StringLiteralLongUnicodeEscapeSurrogatePairString |
||||
Recommended.Proto3.TextFormatInput.StringLiteralLongUnicodeEscapeSurrogateSecondOnlyBytes |
||||
Recommended.Proto3.TextFormatInput.StringLiteralLongUnicodeEscapeSurrogateSecondOnlyString |
||||
Recommended.Proto3.TextFormatInput.StringLiteralLongUnicodeEscapesBytes.ProtobufOutput |
||||
Recommended.Proto3.TextFormatInput.StringLiteralLongUnicodeEscapesBytes.TextFormatOutput |
||||
Recommended.Proto3.TextFormatInput.StringLiteralLongUnicodeEscapesString.ProtobufOutput |
||||
Recommended.Proto3.TextFormatInput.StringLiteralLongUnicodeEscapesString.TextFormatOutput |
||||
Recommended.Proto3.TextFormatInput.StringLiteralShortUnicodeEscapeBytes.ProtobufOutput |
||||
Recommended.Proto3.TextFormatInput.StringLiteralShortUnicodeEscapeBytes.TextFormatOutput |
||||
Recommended.Proto3.TextFormatInput.StringLiteralShortUnicodeEscapeString.ProtobufOutput |
||||
Recommended.Proto3.TextFormatInput.StringLiteralShortUnicodeEscapeString.TextFormatOutput |
||||
Recommended.Proto3.TextFormatInput.StringLiteralShortUnicodeEscapeSurrogateFirstOnlyBytes |
||||
Recommended.Proto3.TextFormatInput.StringLiteralShortUnicodeEscapeSurrogateFirstOnlyString |
||||
Recommended.Proto3.TextFormatInput.StringLiteralShortUnicodeEscapeSurrogatePairBytes |
||||
Recommended.Proto3.TextFormatInput.StringLiteralShortUnicodeEscapeSurrogatePairString |
||||
Recommended.Proto3.TextFormatInput.StringLiteralShortUnicodeEscapeSurrogateSecondOnlyBytes |
||||
Recommended.Proto3.TextFormatInput.StringLiteralShortUnicodeEscapeSurrogateSecondOnlyString |
||||
Recommended.Proto3.TextFormatInput.StringLiteralUnicodeEscapeSurrogatePairLongShortBytes |
||||
Recommended.Proto3.TextFormatInput.StringLiteralUnicodeEscapeSurrogatePairLongShortString |
||||
Recommended.Proto3.TextFormatInput.StringLiteralUnicodeEscapeSurrogatePairShortLongBytes |
||||
Recommended.Proto3.TextFormatInput.StringLiteralUnicodeEscapeSurrogatePairShortLongString |
||||
Required.Proto3.TextFormatInput.StringLiteralBasicEscapesBytes.ProtobufOutput |
||||
Required.Proto3.TextFormatInput.StringLiteralBasicEscapesBytes.TextFormatOutput |
||||
Required.Proto3.TextFormatInput.StringLiteralBasicEscapesString.ProtobufOutput |
||||
Required.Proto3.TextFormatInput.StringLiteralBasicEscapesString.TextFormatOutput |
||||
Required.Proto3.TextFormatInput.StringLiteralLongUnicodeEscapeTooLargeBytes |
||||
Required.Proto3.TextFormatInput.StringLiteralLongUnicodeEscapeTooLargeString |
@ -1,62 +0,0 @@ |
||||
<?php |
||||
|
||||
$cwd = dirname($argv[0]) . "/../../../src"; |
||||
chdir($cwd); |
||||
|
||||
$cmd = "grep -r -l 'Generated by the protocol buffer' * | grep 'php$' | grep -v Internal"; |
||||
$handle = popen($cmd, 'r'); |
||||
$filenames = explode("\n", stream_get_contents($handle)); |
||||
array_pop($filenames); // empty string after last '\n' |
||||
$filenames[] = "Google/Protobuf/DescriptorPool.php"; |
||||
$output = "../ext/google/protobuf/bundled_php.c"; |
||||
|
||||
function stripSuffix($str, $suffix) { |
||||
return substr($str, 0, strlen($str) - strlen($suffix)); |
||||
} |
||||
|
||||
function toClassName($filename) { |
||||
# Google/Protobuf/BoolValue.php -> Google\\Protobuf\\BoolValue |
||||
$ret = stripSuffix($filename, ".php"); |
||||
return str_replace("/", "\\\\", $ret); |
||||
} |
||||
|
||||
function toCSymbolName($filename) { |
||||
# Google/Protobuf/BoolValue.php -> Google__Protobuf__BoolValue |
||||
$ret = stripSuffix($filename, ".php"); |
||||
return str_replace("/", "__", $ret); |
||||
} |
||||
|
||||
$f = fopen($output, "w"); |
||||
|
||||
fwrite($f, "#include \"bundled_php.h\"\n"); |
||||
fwrite($f, "#include \"stdlib.h\"\n"); |
||||
|
||||
foreach ($filenames as $filename) { |
||||
print("Reading $filename...\n"); |
||||
$contents = file_get_contents($filename); |
||||
$contents = substr($contents, 5); // Strip <?php |
||||
$c_symbol_name = toCSymbolName($filename); |
||||
fwrite($f, "static const char {$c_symbol_name}[] = {"); |
||||
for ($i = 0; $i < strlen($contents); $i++) { |
||||
if ($i % 10 == 0) { |
||||
fwrite($f, "\n"); |
||||
} |
||||
fprintf($f, " 0x%02x,", ord($contents[$i])); |
||||
} |
||||
fwrite($f, "0};\n"); |
||||
} |
||||
|
||||
fwrite($f, "static BundledPhp_File php[] = {\n"); |
||||
foreach ($filenames as $filename) { |
||||
$class_name = toClassName($filename); |
||||
$c_symbol_name = toCSymbolName($filename); |
||||
fwrite($f, " {\"$class_name\", $c_symbol_name},\n"); |
||||
} |
||||
|
||||
fwrite($f, " {NULL, NULL}\n"); |
||||
fwrite($f, "};\n"); |
||||
fwrite($f, "BundledPhp_File *bundled_files = &php[0];\n"); |
||||
fclose($f); |
||||
|
||||
print("Wrote $output\n"); |
||||
?> |
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,6 @@ |
||||
|
||||
# wyhash has to live in the base third_party directory. |
||||
# We copy it into the ext/google/protobuf directory for the build |
||||
# (and for the release to PECL). |
||||
mkdir -p ../ext/google/protobuf/third_party/wyhash |
||||
cp ../../third_party/wyhash/* ../ext/google/protobuf/third_party/wyhash |
Binary file not shown.
Binary file not shown.
@ -0,0 +1,86 @@ |
||||
<?php |
||||
|
||||
namespace Google\Protobuf\Internal; |
||||
|
||||
/** |
||||
* Base class for Google\Protobuf\Any, this contains hand-written convenience |
||||
* methods like pack() and unpack(). |
||||
*/ |
||||
class AnyBase extends \Google\Protobuf\Internal\Message |
||||
{ |
||||
const TYPE_URL_PREFIX = 'type.googleapis.com/'; |
||||
|
||||
/** |
||||
* This method will try to resolve the type_url in Any message to get the |
||||
* targeted message type. If failed, an error will be thrown. Otherwise, |
||||
* the method will create a message of the targeted type and fill it with |
||||
* the decoded value in Any. |
||||
* @return Message unpacked message |
||||
* @throws \Exception Type url needs to be type.googleapis.com/fully-qualified. |
||||
* @throws \Exception Class hasn't been added to descriptor pool. |
||||
* @throws \Exception cannot decode data in value field. |
||||
*/ |
||||
public function unpack() |
||||
{ |
||||
// Get fully qualified name from type url. |
||||
$url_prifix_len = strlen(GPBUtil::TYPE_URL_PREFIX); |
||||
if (substr($this->type_url, 0, $url_prifix_len) != |
||||
GPBUtil::TYPE_URL_PREFIX) { |
||||
throw new \Exception( |
||||
"Type url needs to be type.googleapis.com/fully-qulified"); |
||||
} |
||||
$fully_qualifed_name = |
||||
substr($this->type_url, $url_prifix_len); |
||||
|
||||
// Create message according to fully qualified name. |
||||
$pool = \Google\Protobuf\Internal\DescriptorPool::getGeneratedPool(); |
||||
$desc = $pool->getDescriptorByProtoName($fully_qualifed_name); |
||||
if (is_null($desc)) { |
||||
throw new \Exception("Class ".$fully_qualifed_name |
||||
." hasn't been added to descriptor pool"); |
||||
} |
||||
$klass = $desc->getClass(); |
||||
$msg = new $klass(); |
||||
|
||||
// Merge data into message. |
||||
$msg->mergeFromString($this->value); |
||||
return $msg; |
||||
} |
||||
|
||||
/** |
||||
* The type_url will be created according to the given message’s type and |
||||
* the value is encoded data from the given message.. |
||||
* @param message: A proto message. |
||||
*/ |
||||
public function pack($msg) |
||||
{ |
||||
if (!$msg instanceof Message) { |
||||
trigger_error("Given parameter is not a message instance.", |
||||
E_USER_ERROR); |
||||
return; |
||||
} |
||||
|
||||
// Set value using serialized message. |
||||
$this->value = $msg->serializeToString(); |
||||
|
||||
// Set type url. |
||||
$pool = \Google\Protobuf\Internal\DescriptorPool::getGeneratedPool(); |
||||
$desc = $pool->getDescriptorByClassName(get_class($msg)); |
||||
$fully_qualifed_name = $desc->getFullName(); |
||||
$this->type_url = GPBUtil::TYPE_URL_PREFIX . $fully_qualifed_name; |
||||
} |
||||
|
||||
/** |
||||
* This method returns whether the type_url in any_message is corresponded |
||||
* to the given class. |
||||
* @param klass: The fully qualified PHP class name of a proto message type. |
||||
*/ |
||||
public function is($klass) |
||||
{ |
||||
$pool = \Google\Protobuf\Internal\DescriptorPool::getGeneratedPool(); |
||||
$desc = $pool->getDescriptorByClassName($klass); |
||||
$fully_qualifed_name = $desc->getFullName(); |
||||
$type_url = GPBUtil::TYPE_URL_PREFIX . $fully_qualifed_name; |
||||
return $this->type_url === $type_url; |
||||
} |
||||
} |
@ -0,0 +1,32 @@ |
||||
<?php |
||||
|
||||
namespace Google\Protobuf\Internal; |
||||
|
||||
/** |
||||
* Base class for Google\Protobuf\Timestamp, this contains hand-written |
||||
* convenience methods. |
||||
*/ |
||||
class TimestampBase extends \Google\Protobuf\Internal\Message |
||||
{ |
||||
/* |
||||
* Converts PHP DateTime to Timestamp. |
||||
* |
||||
* @param \DateTime $datetime |
||||
*/ |
||||
public function fromDateTime(\DateTime $datetime) |
||||
{ |
||||
$this->seconds = $datetime->getTimestamp(); |
||||
$this->nanos = 1000 * $datetime->format('u'); |
||||
} |
||||
|
||||
/** |
||||
* Converts Timestamp to PHP DateTime. |
||||
* |
||||
* @return \DateTime $datetime |
||||
*/ |
||||
public function toDateTime() |
||||
{ |
||||
$time = sprintf('%s.%06d', $this->seconds, $this->nanos / 1000); |
||||
return \DateTime::createFromFormat('U.u', $time); |
||||
} |
||||
} |
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue