Skip to content

Commit

Permalink
part1: new serialization impl in py
Browse files Browse the repository at this point in the history
  • Loading branch information
chaokunyang committed Dec 4, 2024
1 parent 3c0f316 commit d666140
Show file tree
Hide file tree
Showing 14 changed files with 1,022 additions and 1,294 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,20 @@ public Enum read(MemoryBuffer buffer) {
}
}

@Override
public void xwrite(MemoryBuffer buffer, Enum value) {
buffer.writeVarUint32Small7(value.ordinal());
}

@Override
public Enum xread(MemoryBuffer buffer) {
int value = buffer.readVarUint32Small7();
if (value >= enumConstants.length) {
return handleNonexistentEnumValue(value);
}
return enumConstants[value];
}

private Enum handleNonexistentEnumValue(int value) {
if (fury.getConfig().deserializeNonexistentEnumValueAsNull()) {
return null;
Expand Down
7 changes: 3 additions & 4 deletions python/pyfury/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
Language,
ClassInfo,
OpaqueObject,
ComplexObjectSerializer,
)
else:
from pyfury._fury import ( # noqa: F401,F403,F811 # pylint: disable=unused-import
Expand All @@ -42,9 +41,9 @@
ClassInfo,
OpaqueObject,
)
from pyfury._struct import ( # noqa: F401,F403,F811 # pylint: disable=unused-import
ComplexObjectSerializer,
)
from pyfury._struct import ( # noqa: F401,F403,F811 # pylint: disable=unused-import
ComplexObjectSerializer,
)
from pyfury.serializer import * # noqa: F401,F403 # pylint: disable=unused-import
from pyfury.type import ( # noqa: F401 # pylint: disable=unused-import
record_class_factory,
Expand Down
Loading

0 comments on commit d666140

Please sign in to comment.