aidemingsi / pb4php

Automatically exported from code.google.com/p/pb4php
0 stars 0 forks source link

Creation + Parsing error for repeated primitive types #1

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Hi,

The generatation of classes does not work if primitive type is repeated
instead of a message type.

message AddressBook {
  repeated string person = 1;
}

Code generated:

<?php
class AddressBook extends PBMessage
{
  var $wired_type = PBMessage::WIRED_STRING;
  public function __construct($reader=null)
  {
    parent::__construct($reader);
    $this->fields["1"] = "PBString";
    $this->values["1"] = array();
  }
  function person($offset)
  {
    return $this->_get_arr_value("1", $offset);
  }
  function add_person()
  {
    return $this->_add_arr_value("1");
  }
  function person_size()
  {
    return $this->_get_arr_size("1");
  }
}
?>

I can generate a person, but there is no way for me to set any data in it,
as no message object is returned.
Serializing that object will then fail.

I also suspect the same problem when parsing a file having the same kind of
definitions.

Original issue reported on code.google.com by adsen...@blue.lu on 20 Jan 2009 at 5:38

GoogleCodeExporter commented 9 years ago
Fixed it with the revision 15 - r15 - look at the folder primitive_rep in the 
example
folder.

Original comment by kordu...@googlemail.com on 20 Jan 2009 at 7:22