ik3210 / pb4php

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

sint32 type encoding is not working #11

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. my.proto
message my_test {
    required sint32 id = 1;
} 
2. generate php-class:
$test = new PBParser();
$test->parse('./my.proto'); 
3. php-code  
----
<?
require_once('../message/pb_message.php');
require_once('./pb_proto_my.php');
error_reporting(E_ALL);
ini_set('display_errors','On');
$A = new my_test();
$A->set_id(123);

$str = $A->SerializeToString();

$B = new my_test();
$B->parseFromString($str);
echo $B->id();
?>

What is the expected output? What do you see instead?
123

Notice: Object of class PBSignedInt could not be converted to int in 
/Users/max_m/Downloads/protocolbuf/message/type/pb_signed_int.php on line 19

Call Stack:
    0.0005     328212   1. {main}() /Users/max_m/Downloads/protocolbuf/example/test_my.php:0
    0.0052     541284   2. PBMessage->ParseFromString() 
/Users/max_m/Downloads/protocolbuf/example/test_my.php:13
    0.0052     541856   3. PBMessage->_ParseFromArray() 
/Users/max_m/Downloads/protocolbuf/message/pb_message.php:148
    0.0054     542952   4. PBSignedInt->ParseFromArray() 
/Users/max_m/Downloads/protocolbuf/message/pb_message.php:223

What version of the product are you using? On what operating system?
[18:37:48] max_m: ~/Downloads/protocolbuf/example> uname -v
Darwin Kernel Version 9.8.0: Wed Jul 15 16:55:01 PDT 2009; root:xnu-
1228.15.4~1/RELEASE_I386
[18:37:50] max_m: ~/Downloads/protocolbuf/example> php -v
PHP 5.3.0 (cli) (built: Jul  5 2009 23:21:56) 
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2009 Zend Technologies
    with Xdebug v2.0.5, Copyright (c) 2002-2008, by Derick Rethans

Please provide any additional information below.
I think PBSignedInt should be inherited from  PBInt (now it inherited from 
PBScalar)
That's solved my problem

Original issue reported on code.google.com by max...@gmail.com on 2 Oct 2009 at 2:38