Skip to content

fixed Nino issue #31 #418

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README_zh_cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,11 @@ JEngine是针对Unity开发者设计的**开箱即用**的框架,封装了强

> 若您的项目使用了JEngine,欢迎联系作者,作者很乐意把您的作品展示出来~

| <img src="https://img.tapimg.com/market/lcs/b2d125432dffa4741c929ddceb3bf95f_360.png?imageMogr2/auto-orient/strip" alt="g1" width="128" height="128" /> | <img src="https://img.tapimg.com/market/lcs/378c87731ce06ab8338977c90761a187_360.png?imageMogr2/auto-orient/strip" alt="g2" width="128" height="128" /> | <img src="https://img.tapimg.com/market/lcs/0ac05aa58706032db05c5dbf1df77cf4_360.png?imageMogr2/auto-orient/strip" alt="g2" width="128" height="128" /> | <img src="https://img.tapimg.com/market/lcs/5c13a62dfeec50334f16e2f31db151e2_360.png?imageMogr2/auto-orient/strip" alt="g2" width="128" height="128" /> |
| <img src="https://img.tapimg.com/market/lcs/b2d125432dffa4741c929ddceb3bf95f_360.png?imageMogr2/auto-orient/strip" alt="g1" width="128" height="128" /> | <img src="https://img.tapimg.com/market/lcs/378c87731ce06ab8338977c90761a187_360.png?imageMogr2/auto-orient/strip" alt="g2" width="128" height="128" /> | <img src="https://img.tapimg.com/market/lcs/0ac05aa58706032db05c5dbf1df77cf4_360.png?imageMogr2/auto-orient/strip" alt="g3" width="128" height="128" /> | <img src="https://img.tapimg.com/market/lcs/5c13a62dfeec50334f16e2f31db151e2_360.png?imageMogr2/auto-orient/strip" alt="g4" width="128" height="128" /> |
| ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ |
| <p align="center">[爱丽丝造梦空间](https://www.taptap.com/app/224117)</p> | <p align="center">[肝到发慌](https://www.taptap.com/app/225175)</p> | <p align="center">[割韭菜](https://www.taptap.com/app/232558)</p> | <p align="center">[明明消消乐](https://www.taptap.com/app/233988)</p> |
| <img src="https://img.tapimg.com/market/lcs/d561f17020081307ff08366233070d88_360.png?imageMogr2/auto-orient/strip" alt="g2" width="128" height="128" /> | <img src="https://media.9game.cn/gamebase/2022/6/29/a2fabeb2e1f4c048b58a7861d60affc3.png?x-oss-process=image/resize,w_256,m_lfit" alt="hmsj" width="128" height="128" /> | <img src="https://img.tapimg.com/market/lcs/475635baa9a75856ea21a216a215f5b2_360.png?imageMogr2/auto-orient/strip" alt="g2" width="128" height="128" /> | |
| <p align="center">[兔子与餐厅](https://www.taptap.com/app/235127)</p> | <p align="center">[鸿蒙世界](https://www.9game.cn/hongmengshijie/)</p> | <p align="center">[Kz之灵](https://www.taptap.com/app/238569)</p> | |
| <img src="https://img.tapimg.com/market/lcs/d561f17020081307ff08366233070d88_360.png?imageMogr2/auto-orient/strip" alt="g5" width="128" height="128" /> | <img src="https://media.9game.cn/gamebase/2022/6/29/a2fabeb2e1f4c048b58a7861d60affc3.png?x-oss-process=image/resize,w_256,m_lfit" alt="hmsj" width="128" height="128" /> | <img src="https://img.tapimg.com/market/lcs/475635baa9a75856ea21a216a215f5b2_360.png?imageMogr2/auto-orient/strip" alt="g7" width="128" height="128" /> | <img src="https://github.com/kkmjnh11110/MyResouse/blob/master/icon.PNG?raw=true" alt="g8" width="128" height="128" /> |
| <p align="center">[兔子与餐厅](https://www.taptap.com/app/235127)</p> | <p align="center">[鸿蒙世界](https://www.9game.cn/hongmengshijie/)</p> | <p align="center">[Kz之灵](https://www.taptap.com/app/238569)</p> | <p align="center">[无界电影](https://apps.apple.com/us/app/无限生化/id1506237271)</p> |



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,43 @@ internal static object Deserialize(Type type, object val, byte[] data, Encoding
skipCodeGenCheck, skipGenericCheck, skipEnumCheck);
}

/// <summary>
/// Deserialize a NinoSerialize object
/// </summary>
/// <param name="type"></param>
/// <param name="val"></param>
/// <param name="data"></param>
/// <param name="encoding"></param>
/// <param name="reader"></param>
/// <param name="option"></param>
/// <param name="returnDispose"></param>
/// <param name="skipBasicCheck"></param>
/// <param name="skipCodeGenCheck"></param>
/// <param name="skipGenericCheck"></param>
/// <param name="skipEnumCheck"></param>
/// <returns></returns>
/// <exception cref="InvalidOperationException"></exception>
/// <exception cref="NullReferenceException"></exception>
// ReSharper disable CognitiveComplexity
internal static object Deserialize(Type type, object val, ArraySegment<byte> data, Encoding encoding, Reader reader,
CompressOption option = CompressOption.Zlib, bool returnDispose = true, bool skipBasicCheck = false,
bool skipCodeGenCheck = false, bool skipGenericCheck = false, bool skipEnumCheck = false)
// ReSharper restore CognitiveComplexity
{
//prevent null encoding
encoding = encoding ?? DefaultEncoding;

if (reader == null)
{
reader = ObjectPool<Reader>.Request();
reader.Init(data, data.Count, encoding ?? DefaultEncoding,
TypeModel.IsNonCompressibleType(type) ? CompressOption.NoCompression : option);
}

return Deserialize(type, val, data, encoding, reader, returnDispose, skipBasicCheck,
skipCodeGenCheck, skipGenericCheck, skipEnumCheck);
}

/// <summary>
/// Deserialize a NinoSerialize object
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,7 @@ public static unsafe void RegisterILRuntimeClrRedirection(ILRuntime.Runtime.Envi
intp.Free(ptrOfThisMethod);

ptrOfThisMethod = ILRuntime.Runtime.Intepreter.ILIntepreter.Minus(esp, 3);
var @data = (System.Byte[])ILRuntime.CLR.Utils.Extensions.CheckCLRTypes(typeof(System.Byte[]),
ILRuntime.Runtime.Stack.StackObject.ToObject(ptrOfThisMethod, domain, mStack),
0);
var @data = ILRuntime.Runtime.Stack.StackObject.ToObject(ptrOfThisMethod, domain, mStack);
intp.Free(ptrOfThisMethod);

//获取泛型参数<T>的实际类型
Expand All @@ -198,9 +196,19 @@ public static unsafe void RegisterILRuntimeClrRedirection(ILRuntime.Runtime.Envi
r = ((ILRuntime.CLR.TypeSystem.ILType)t).Instantiate();
}

var resultOfThisMethod =
Nino.Serialization.Deserializer.Deserialize(t.ReflectionType, r, @data,
@encoding ?? Encoding.UTF8, null, option);
object resultOfThisMethod = null;
if (@data is byte[] buf)
{
resultOfThisMethod =
Nino.Serialization.Deserializer.Deserialize(t.ReflectionType, r, buf,
@encoding ?? Encoding.UTF8, null, option);
}
else if (@data is ArraySegment<byte> seg)
{
resultOfThisMethod =
Nino.Serialization.Deserializer.Deserialize(t.ReflectionType, r, seg,
@encoding ?? Encoding.UTF8, null, option);
}

return ILRuntime.Runtime.Intepreter.ILIntepreter.PushObject(ret, mStack, resultOfThisMethod);
}
Expand Down