当前位置: 首页>>代码示例>>PHP>>正文


PHP FieldDescriptorProto::getExtendee方法代码示例

本文整理汇总了PHP中Google\Protobuf\FieldDescriptorProto::getExtendee方法的典型用法代码示例。如果您正苦于以下问题:PHP FieldDescriptorProto::getExtendee方法的具体用法?PHP FieldDescriptorProto::getExtendee怎么用?PHP FieldDescriptorProto::getExtendee使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Google\Protobuf\FieldDescriptorProto的用法示例。


在下文中一共展示了FieldDescriptorProto::getExtendee方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: generateBody

 /**
  * @param \Protobuf\Compiler\Entity             $entity
  * @param \google\protobuf\FieldDescriptorProto $field
  *
  * @return string[]
  */
 public function generateBody(Entity $entity, FieldDescriptorProto $field)
 {
     $name = $field->getName();
     $tag = $field->getNumber();
     $extEntity = $this->getEntity($field->getExtendee());
     $extendee = $extEntity->getNamespacedName();
     $nameQuoted = var_export($name, true);
     $extendeeQuoted = var_export($extendee, true);
     $sizeCallback = $this->generateSizeCallback($entity, $field);
     $readCallback = $this->generateReadCallback($entity, $field);
     $writeCallback = $this->generateWriteCallback($entity, $field);
     $callbacks = array_merge($readCallback, [null], $writeCallback, [null], $sizeCallback);
     $arguments = [$extendeeQuoted, $nameQuoted, $tag, '$readCallback', '$writeCallback', '$sizeCallback', '__METHOD__'];
     $body[] = 'if (self::$' . $name . ' !== null) {';
     $body[] = '    return self::$' . $name . ';';
     $body[] = '}';
     $body[] = null;
     $body = array_merge($body, $callbacks);
     $body[] = null;
     $body[] = 'return self::$' . $name . ' = new \\Protobuf\\Extension\\ExtensionField(' . implode(', ', $arguments) . ');';
     return $body;
 }
开发者ID:protobuf-php,项目名称:protobuf-plugin,代码行数:28,代码来源:ExtensionsGenerator.php

示例2: compileExtension

 protected function compileExtension(proto\FieldDescriptorProto $field, $ns, $indent)
 {
     $extendee = $this->normalizeNS($field->getExtendee());
     $name = $this->normalizeNS($ns . '.' . $field->getName());
     $field->setName($name);
     $s[] = "\\{$extendee}::extension(function(){";
     $s[] = $this->compileField($field, $ns, $indent . '  ');
     $s[] = '  // @@protoc_insertion_point(scope_extension)';
     $s[] = '  // @@protoc_insertion_point(extension_' . $ns . ':' . $field->getName() . ')';
     $s[] = '  return $f;';
     $s[] = "});";
     return $indent . implode(PHP_EOL . $indent, $s);
 }
开发者ID:stanley-cheung,项目名称:protobuf-php,代码行数:13,代码来源:PhpGenerator.php

示例3: printExtension

 public function printExtension(Printer $printer, FieldDescriptorProto $field)
 {
     if (ExtensionPool::has($field->getExtendee(), $field->getNumber())) {
         // NOTE: already registered.
         return;
     }
     ExtensionPool::register($field->getExtendee(), $field->getNumber(), $field);
     $printer->put("\$registry->add('`message`', `extension`, new \\ProtocolBuffers\\FieldDescriptor(array(\n", "message", Helper::getExtendeeClassName($field), "extension", $field->getNumber());
     $printer->indent();
     $printer->put("\"type\"     => `type`,\n", "type", Helper::getFieldTypeName($field));
     $printer->put("\"name\"     => \"`name`\",\n", "name", $field->getName());
     $printer->put("\"required\" => `required`,\n", "required", FieldDescriptorProto\Label::isRequired($field) ? "true" : "false");
     $printer->put("\"optional\" => `optional`,\n", "optional", FieldDescriptorProto\Label::isOptional($field) ? "true" : "false");
     $printer->put("\"repeated\" => `repeated`,\n", "repeated", FieldDescriptorProto\Label::isRepeated($field) ? "true" : "false");
     $printer->put("\"packable\" => `packable`,\n", "packable", FieldDescriptorProto\Label::isPacked($field) ? "true" : "false");
     $printer->put("\"default\"  => `value`,\n", "value", $this->defaultValueAsString($field));
     if (FieldDescriptorProto\Type::isMessage($field)) {
         $name = $field->getTypeName();
         $descriptor = MessagePool::get($name);
         $printer->put("\"message\" => '`message`',\n", "message", Helper::getClassName($descriptor, true));
     }
     $printer->outdent();
     $printer->put(")));\n");
 }
开发者ID:asamaru7,项目名称:protoc-gen-php,代码行数:24,代码来源:MessageGenerator.php

示例4: compileExtension

 public function compileExtension(proto\FieldDescriptorProto $field, $ns, $indent)
 {
     $extendee = $this->normalizeReference($field->getExtendee());
     $name = $field->getName();
     if ($ns) {
         $name = $ns . '.' . $name;
     }
     $field->setName($name);
     $s[] = "ProtoJson.extend({$extendee}, {";
     $s[] = "  {$field->number}: " . $this->generateField($field);
     $s[] = "});";
     $s[] = '';
     return $indent . implode("\n{$indent}", $s);
 }
开发者ID:JosephGarrone,项目名称:flerovium,代码行数:14,代码来源:JsonGenerator.php

示例5: getExtendeeClassName

 public static function getExtendeeClassName(FieldDescriptorProto $field)
 {
     if (getenv("PEAR_STYLE") || $field->file()->getOptions()->getExtension("php")->getStyle() == Style::PEAR) {
         return str_replace(".", "_", preg_replace("/^.+/", ".", $field->getExtendee()));
     } else {
         return str_replace(".", "\\", $field->getExtendee());
     }
 }
开发者ID:melanc,项目名称:devel,代码行数:8,代码来源:Helper.php

示例6: isProtobufExtension

 /**
  * @param \google\protobuf\FieldDescriptorProto $fieldDescriptor
  *
  * @return boolean
  */
 protected function isProtobufExtension(FieldDescriptorProto $fieldDescriptor)
 {
     if (!$fieldDescriptor->hasExtendee()) {
         return false;
     }
     $extendee = trim($fieldDescriptor->getExtendee(), '.');
     $package = 'google.protobuf';
     $length = strlen($package);
     return substr($extendee, 0, $length) === $package;
 }
开发者ID:protobuf-php,项目名称:protobuf-plugin,代码行数:15,代码来源:EntityBuilder.php

示例7: generateFieldBody

 /**
  * @param \google\protobuf\FieldDescriptorProto $field
  *
  * @return string[]
  */
 protected function generateFieldBody(FieldDescriptorProto $field)
 {
     $lines = [];
     $name = $field->getName();
     $number = $field->getNumber();
     $typeName = $field->getTypeName();
     $extendee = $field->getExtendee();
     $type = $field->getType()->name();
     $label = $field->getLabel()->name();
     $default = $this->getDefaultFieldValue($field);
     $values = ['number' => var_export($number, true), 'name' => var_export($name, true), 'type' => '\\google\\protobuf\\FieldDescriptorProto\\Type::' . $type . '()', 'label' => '\\google\\protobuf\\FieldDescriptorProto\\Label::' . $label . '()'];
     if ($extendee) {
         $values['extendee'] = var_export($extendee, true);
     }
     if ($typeName) {
         $values['type_name'] = var_export($typeName, true);
     }
     if ($field->hasDefaultValue()) {
         $values['default_value'] = $default;
     }
     $lines[] = '\\google\\protobuf\\FieldDescriptorProto::fromArray([';
     $lines = array_merge($lines, $this->generateArrayLines($values));
     $lines[] = ']),';
     return $lines;
 }
开发者ID:protobuf-php,项目名称:protobuf-plugin,代码行数:30,代码来源:DescriptorGenerator.php


注:本文中的Google\Protobuf\FieldDescriptorProto::getExtendee方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。