當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。