本文整理汇总了PHP中Google\Protobuf\DescriptorProto::hasNestedType方法的典型用法代码示例。如果您正苦于以下问题:PHP DescriptorProto::hasNestedType方法的具体用法?PHP DescriptorProto::hasNestedType怎么用?PHP DescriptorProto::hasNestedType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Google\Protobuf\DescriptorProto
的用法示例。
在下文中一共展示了DescriptorProto::hasNestedType方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: compileMessage
protected function compileMessage(proto\DescriptorProto $msg, $ns)
{
$s = array();
$s[] = "namespace " . $this->normalizeNS($ns) . " {";
$s[] = "";
$s[] = " // @@protoc_insertion_point(scope_namespace)";
$s[] = " // @@protoc_insertion_point(namespace_{$ns})";
$s[] = "";
$cmt = $this->compiler->getComment($ns . '.' . $msg->getName(), ' * ');
if ($cmt) {
$s[] = " /**";
$s[] = $cmt;
$s[] = " */";
}
// Compute a new namespace with the message name as suffix
$ns .= '.' . $msg->getName();
$s[] = ' class ' . $msg->getName() . ' extends \\DrSlump\\Protobuf\\Message {';
$s[] = '';
foreach ($msg->getField() as $field) {
$s[] = $this->generatePublicField($field, $ns, " ");
}
$s[] = '';
$s[] = ' /** @var \\Closure[] */';
$s[] = ' protected static $__extensions = array();';
$s[] = '';
$s[] = ' public static function descriptor()';
$s[] = ' {';
$s[] = ' $descriptor = new \\DrSlump\\Protobuf\\Descriptor(__CLASS__, \'' . $ns . '\');';
$s[] = '';
foreach ($msg->getField() as $field) {
$s[] = $this->compileField($field, $ns, " ");
$s[] = ' $descriptor->addField($f);';
$s[] = '';
}
$s[] = ' foreach (self::$__extensions as $cb) {';
$s[] = ' $descriptor->addField($cb(), true);';
$s[] = ' }';
$s[] = '';
$s[] = ' // @@protoc_insertion_point(scope_descriptor)';
$s[] = ' // @@protoc_insertion_point(descriptor_' . $ns . ')';
$s[] = '';
$s[] = ' return $descriptor;';
$s[] = ' }';
$s[] = '';
//$s[]= " protected static \$__exts = array(";
//foreach ($msg->getExtensionRange() as $range):
//$s[]= ' array(' . $range->getStart() . ', ' . ($range->getEnd()-1) . '),';
//endforeach;
//$s[]= " );";
//$s[]= "";
foreach ($msg->getField() as $field) {
$s[] = $this->generateAccessors($field, $ns, " ");
}
$s[] = "";
$s[] = " // @@protoc_insertion_point(scope_class)";
$s[] = ' // @@protoc_insertion_point(class_' . $ns . ')';
$s[] = " }";
$s[] = "}";
$s[] = "";
// Generate Enums
if ($msg->hasEnumType()) {
foreach ($msg->getEnumType() as $enum) {
$src = $this->compileEnum($enum, $ns);
$this->addComponent($ns, $enum->getName(), $src);
}
}
// Generate nested messages
if ($msg->hasNestedType()) {
foreach ($msg->getNestedType() as $msg) {
$src = $this->compileMessage($msg, $ns);
$this->addComponent($ns, $msg->getName(), $src);
}
}
// Collect extensions
if ($msg->hasExtension()) {
foreach ($msg->getExtensionList() as $field) {
$this->extensions[$field->getExtendee()][] = array($ns, $field);
}
}
return implode(PHP_EOL, $s) . PHP_EOL;
}