-
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #86 from hadashiA/ku/custom-resolver
Update mruby build
- Loading branch information
Showing
23 changed files
with
150 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
+72 Bytes
(100%)
....Unity/Assets/VitalRouter.MRuby/Runtime/Plugins/android-arm64/VitalRouter.MRuby.Native.so
Binary file not shown.
Binary file modified
BIN
+80 Bytes
(100%)
...er.Unity/Assets/VitalRouter.MRuby/Runtime/Plugins/android-x64/VitalRouter.MRuby.Native.so
Binary file not shown.
Binary file modified
BIN
+256 Bytes
(100%)
...outer.Unity/Assets/VitalRouter.MRuby/Runtime/Plugins/ios-arm64/VitalRouter.MRuby.Native.a
Binary file not shown.
Binary file modified
BIN
+304 Bytes
(100%)
...lRouter.Unity/Assets/VitalRouter.MRuby/Runtime/Plugins/ios-x64/VitalRouter.MRuby.Native.a
Binary file not shown.
Binary file modified
BIN
+432 Bytes
(100%)
...er.Unity/Assets/VitalRouter.MRuby/Runtime/Plugins/linux-arm64/VitalRouter.MRuby.Native.so
Binary file not shown.
Binary file modified
BIN
+408 Bytes
(100%)
...uter.Unity/Assets/VitalRouter.MRuby/Runtime/Plugins/linux-x64/VitalRouter.MRuby.Native.so
Binary file not shown.
Binary file modified
BIN
+0 Bytes
(100%)
...Unity/Assets/VitalRouter.MRuby/Runtime/Plugins/macOS-arm64/VitalRouter.MRuby.Native.dylib
Binary file not shown.
Binary file modified
BIN
+0 Bytes
(100%)
...y/Assets/VitalRouter.MRuby/Runtime/Plugins/macOS-universal/VitalRouter.MRuby.Native.dylib
Binary file not shown.
Binary file modified
BIN
+0 Bytes
(100%)
...r.Unity/Assets/VitalRouter.MRuby/Runtime/Plugins/macOS-x64/VitalRouter.MRuby.Native.dylib
Binary file not shown.
Binary file modified
BIN
+248 Bytes
(100%)
....Unity/Assets/VitalRouter.MRuby/Runtime/Plugins/visionos-arm64/VitalRouter.MRuby.Native.a
Binary file not shown.
Binary file modified
BIN
+304 Bytes
(100%)
...er.Unity/Assets/VitalRouter.MRuby/Runtime/Plugins/visionos-x64/VitalRouter.MRuby.Native.a
Binary file not shown.
Binary file modified
BIN
+278 Bytes
(100%)
...italRouter.Unity/Assets/VitalRouter.MRuby/Runtime/Plugins/wasm/VitalRouter.MRuby.Native.a
Binary file not shown.
Binary file modified
BIN
+0 Bytes
(100%)
...r.Unity/Assets/VitalRouter.MRuby/Runtime/Plugins/windows-x64/VitalRouter.MRuby.Native.dll
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
src/VitalRouter.Unity/Assets/VitalRouter.MRuby/Runtime/Serialization/ByteArrayFormatter.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using System; | ||
|
||
namespace VitalRouter.MRuby | ||
{ | ||
public class ByteArrayFormatter : IMrbValueFormatter<byte[]?> | ||
{ | ||
public static readonly ByteArrayFormatter Instance = new(); | ||
|
||
public unsafe byte[]? Deserialize(MrbValue mrbValue, MRubyContext context, MrbValueSerializerOptions options) | ||
{ | ||
if (mrbValue.IsNil) return null; | ||
if (mrbValue.TT == MrbVtype.MRB_TT_ARRAY) | ||
{ | ||
return options.Resolver.GetFormatterWithVerify<byte[]>() | ||
.Deserialize(mrbValue, context, options); | ||
} | ||
|
||
var s = NativeMethods.MrbToString(context.DangerousGetPtr(), mrbValue); | ||
var result = new byte[s.Length]; | ||
var span = new Span<byte>(s.Bytes, s.Length); | ||
span.CopyTo(result); | ||
return result; | ||
} | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
...talRouter.Unity/Assets/VitalRouter.MRuby/Runtime/Serialization/ByteArrayFormatter.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
69 changes: 69 additions & 0 deletions
69
...talRouter.Unity/Assets/VitalRouter.MRuby/Runtime/Serialization/StaticCompositeResolver.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace VitalRouter.MRuby | ||
{ | ||
public class StaticCompositeResolver : IMrbValueFormatterResolver | ||
{ | ||
public static readonly StaticCompositeResolver Instance = new(); | ||
|
||
bool frozen; | ||
readonly List<IMrbValueFormatter> formatters = new(); | ||
readonly List<IMrbValueFormatterResolver> resolvers = new(); | ||
|
||
public StaticCompositeResolver AddFormatters(params IMrbValueFormatter[] formatters) | ||
{ | ||
if (frozen) | ||
{ | ||
throw new InvalidOperationException("Register must call on startup(before use GetFormatter<T>)."); | ||
} | ||
|
||
this.formatters.AddRange(formatters); | ||
return this; | ||
} | ||
|
||
public StaticCompositeResolver AddResolvers(params IMrbValueFormatterResolver[] resolvers) | ||
{ | ||
if (frozen) | ||
{ | ||
throw new InvalidOperationException("Register must call on startup(before use GetFormatter<T>)."); | ||
} | ||
|
||
this.resolvers.AddRange(resolvers); | ||
return this; | ||
} | ||
|
||
public IMrbValueFormatter<T>? GetFormatter<T>() | ||
{ | ||
return Cache<T>.Formatter; | ||
} | ||
|
||
static class Cache<T> | ||
{ | ||
public static readonly IMrbValueFormatter<T>? Formatter; | ||
|
||
static Cache() | ||
{ | ||
Instance.frozen = true; | ||
foreach (var item in Instance.formatters) | ||
{ | ||
if (item is IMrbValueFormatter<T> f) | ||
{ | ||
Formatter = f; | ||
return; | ||
} | ||
} | ||
|
||
foreach (var item in Instance.resolvers) | ||
{ | ||
var f = item.GetFormatter<T>(); | ||
if (f != null) | ||
{ | ||
Formatter = f; | ||
return; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
...uter.Unity/Assets/VitalRouter.MRuby/Runtime/Serialization/StaticCompositeResolver.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.