コード例 #1
0
ファイル: FileGenerator.php プロジェクト: melanc/devel
 public function generateSiblings($package_name, GeneratorContext $context, &$file_list)
 {
     if ($this->file->getOptions()->getExtension("php")->getMultipleFiles()) {
         foreach ($this->file->getEnumType() as $enum) {
             $enum->full_name = Helper::getPackageName($this->file) . "." . $enum->getName();
             $path = $package_name . DIRECTORY_SEPARATOR . $enum->getName() . ".php";
             $output = $context->open($path);
             $file_list[] = $path;
             $printer = new Printer($output, "`");
             $gen = new EnumGenerator($context, $enum, $file_list);
             $gen->generate($printer);
         }
         foreach ($this->file->getMessageType() as $message) {
             $message->full_name = Helper::getPackageName($this->file) . "." . $message->getName();
             $path = $package_name . DIRECTORY_SEPARATOR . $message->getName() . ".php";
             $output = $context->open($path);
             $file_list[] = $path;
             $printer = new Printer($output, "`");
             $gen = new MessageGenerator($context, $message, $file_list);
             $gen->generate($printer);
         }
         /* TODO(chobie): add service here */
     }
 }
コード例 #2
0
ファイル: ProtocGenPhp.php プロジェクト: jakubkulhan/meta
 private function collectFile(FileDescriptorProto $file, $path)
 {
     $this->file = $file;
     $this->messages = array();
     $this->enums = array();
     $this->paths = array();
     $this->sourceCodeInfo = array();
     foreach ((array) $file->getMessageType() as $i => $nestedMessage) {
         $this->collectMessage($file->getPackage(), $nestedMessage, array_merge($path, array(FileDescriptorProtoMeta::MESSAGE_TYPE_PROTOBUF_FIELD, $i)));
     }
     foreach ((array) $file->getEnumType() as $i => $nestedEnum) {
         $this->collectEnum($file->getPackage(), $nestedEnum, array_merge($path, array(FileDescriptorProtoMeta::ENUM_TYPE_PROTOBUF_FIELD, $i)));
     }
 }