mirror of
https://github.com/msgpack/msgpack-python.git
synced 2026-02-07 18:29:53 +00:00
add System.Reflection.Emit based CompiledPacker implementation
This commit is contained in:
parent
08974f00ed
commit
0812eb1c04
12 changed files with 1087 additions and 19 deletions
|
|
@ -83,7 +83,7 @@ namespace msgpack
|
|||
ReflectionCacheEntry entry = ReflectionCache.Lookup (t);
|
||||
writer.WriteMapHeader (entry.FieldMap.Count);
|
||||
foreach (KeyValuePair<string, FieldInfo> pair in entry.FieldMap) {
|
||||
writer.Write (pair.Key);
|
||||
writer.Write (pair.Key, _buf);
|
||||
object v = pair.Value.GetValue (o);
|
||||
if (pair.Value.FieldType.IsInterface && v != null) {
|
||||
writer.WriteArrayHeader (2);
|
||||
|
|
@ -145,8 +145,10 @@ namespace msgpack
|
|||
return unpacker (this, reader);
|
||||
|
||||
if (t.IsArray) {
|
||||
if (!reader.Read () || !reader.IsArray ())
|
||||
if (!reader.Read () || (!reader.IsArray () && reader.Type != TypePrefixes.Nil))
|
||||
throw new FormatException ();
|
||||
if (reader.Type == TypePrefixes.Nil)
|
||||
return null;
|
||||
Type et = t.GetElementType ();
|
||||
Array ary = Array.CreateInstance (et, (int)reader.Length);
|
||||
for (int i = 0; i < ary.Length; i ++)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue