From af1eb85dcc7a91a6138f0dedcac974c30449d337 Mon Sep 17 00:00:00 2001 From: Yan Lin Date: Thu, 13 Nov 2014 17:37:04 +0800 Subject: [PATCH 1/4] Add support for fixed32 type and remove dependency of ez_setup --- setup.py | 3 ++- src/fastpb/generator.py | 1 + src/fastpb/template/module.jinjacc | 8 +++++++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 42064b1..50090e1 100644 --- a/setup.py +++ b/setup.py @@ -39,5 +39,6 @@ 'protoc-gen-fastpython = fastpb.generator:main' ] }, - install_requires=['ez-setup==0.9', 'protobuf >= 2.3.0', 'jinja2 >= 2.0'], +# install_requires=['ez-setup==0.9', 'protobuf >= 2.3.0', 'jinja2 >= 2.0'], + install_requires=['protobuf >= 2.3.0', 'jinja2 >= 2.0'], ) diff --git a/src/fastpb/generator.py b/src/fastpb/generator.py index 4b8f1b6..71d83fe 100755 --- a/src/fastpb/generator.py +++ b/src/fastpb/generator.py @@ -43,6 +43,7 @@ 'BYTES': descriptor_pb2.FieldDescriptorProto.TYPE_BYTES, 'BOOL': descriptor_pb2.FieldDescriptorProto.TYPE_BOOL, 'ENUM': descriptor_pb2.FieldDescriptorProto.TYPE_ENUM, + 'FIXED32': descriptor_pb2.FieldDescriptorProto.TYPE_FIXED32, # TODO(robbyw): More types. } diff --git a/src/fastpb/template/module.jinjacc b/src/fastpb/template/module.jinjacc index d54a482..8d1b711 100644 --- a/src/fastpb/template/module.jinjacc +++ b/src/fastpb/template/module.jinjacc @@ -43,6 +43,12 @@ fastpb_convert{{ TYPE.UINT32 }}(::google::protobuf::uint32 value) return PyLong_FromUnsignedLong(value); } +static PyObject * +fastpb_convert{{ TYPE.FIXED32 }}(::google::protobuf::int32 value) +{ + return PyLong_FromUnsignedLong(value); +} + static PyObject * fastpb_convert{{ TYPE.UINT64 }}(::google::protobuf::uint64 value) { @@ -413,7 +419,7 @@ namespace { return -1; } - {% elif member.type == TYPE.INT32 or member.type == TYPE.SINT32 %} + {% elif member.type == TYPE.INT32 or member.type == TYPE.SINT32 or member.type == TYPE.FIXED32%} ::google::protobuf::int32 protoValue; // int32 From 17bfb4fa8f41a67217542c0979f44f4f3b76f27c Mon Sep 17 00:00:00 2001 From: Yan Lin Date: Thu, 13 Nov 2014 17:39:52 +0800 Subject: [PATCH 2/4] Fix one potential bug when converting fixed32 type --- src/fastpb/template/module.jinjacc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fastpb/template/module.jinjacc b/src/fastpb/template/module.jinjacc index 8d1b711..eb51fbe 100644 --- a/src/fastpb/template/module.jinjacc +++ b/src/fastpb/template/module.jinjacc @@ -46,7 +46,7 @@ fastpb_convert{{ TYPE.UINT32 }}(::google::protobuf::uint32 value) static PyObject * fastpb_convert{{ TYPE.FIXED32 }}(::google::protobuf::int32 value) { - return PyLong_FromUnsignedLong(value); + return PyLong_FromLong(value); } static PyObject * From 1fb84d0522bd1668734e8c008537aadc5d3b4cdc Mon Sep 17 00:00:00 2001 From: Yan Lin Date: Mon, 17 Nov 2014 16:46:55 +0800 Subject: [PATCH 3/4] Revert remove dependency of ez_setup --- setup.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 50090e1..d22dd41 100644 --- a/setup.py +++ b/setup.py @@ -39,6 +39,6 @@ 'protoc-gen-fastpython = fastpb.generator:main' ] }, -# install_requires=['ez-setup==0.9', 'protobuf >= 2.3.0', 'jinja2 >= 2.0'], - install_requires=['protobuf >= 2.3.0', 'jinja2 >= 2.0'], + install_requires=['ez-setup==0.9', 'protobuf >= 2.3.0', 'jinja2 >= 2.0'], +# install_requires=['protobuf >= 2.3.0', 'jinja2 >= 2.0'], ) From 67996500d42cc4a4d6adbff3bc0a99e216694779 Mon Sep 17 00:00:00 2001 From: Yan Lin Date: Mon, 17 Nov 2014 16:48:11 +0800 Subject: [PATCH 4/4] Remove unused comments --- setup.py | 1 - 1 file changed, 1 deletion(-) diff --git a/setup.py b/setup.py index d22dd41..42064b1 100644 --- a/setup.py +++ b/setup.py @@ -40,5 +40,4 @@ ] }, install_requires=['ez-setup==0.9', 'protobuf >= 2.3.0', 'jinja2 >= 2.0'], -# install_requires=['protobuf >= 2.3.0', 'jinja2 >= 2.0'], )