Skip to content

Commit 1cfa795

Browse files
committed
Merge pull request #19 from skyan/master
Add support of fixed32 type (thanks to skyan)
2 parents ad95c59 + 6799650 commit 1cfa795

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/fastpb/generator.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
'BYTES': descriptor_pb2.FieldDescriptorProto.TYPE_BYTES,
4444
'BOOL': descriptor_pb2.FieldDescriptorProto.TYPE_BOOL,
4545
'ENUM': descriptor_pb2.FieldDescriptorProto.TYPE_ENUM,
46+
'FIXED32': descriptor_pb2.FieldDescriptorProto.TYPE_FIXED32,
4647
# TODO(robbyw): More types.
4748
}
4849

src/fastpb/template/module.jinjacc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@ fastpb_convert{{ TYPE.UINT32 }}(::google::protobuf::uint32 value)
4343
return PyLong_FromUnsignedLong(value);
4444
}
4545

46+
static PyObject *
47+
fastpb_convert{{ TYPE.FIXED32 }}(::google::protobuf::int32 value)
48+
{
49+
return PyLong_FromLong(value);
50+
}
51+
4652
static PyObject *
4753
fastpb_convert{{ TYPE.UINT64 }}(::google::protobuf::uint64 value)
4854
{
@@ -413,7 +419,7 @@ namespace {
413419
return -1;
414420
}
415421

416-
{% elif member.type == TYPE.INT32 or member.type == TYPE.SINT32 %}
422+
{% elif member.type == TYPE.INT32 or member.type == TYPE.SINT32 or member.type == TYPE.FIXED32%}
417423
::google::protobuf::int32 protoValue;
418424

419425
// int32

0 commit comments

Comments
 (0)