mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-07-19 08:41:49 -05:00
Merge pull request #734 from ousttrue/feature/simplify_unijson
Feature/simplify unijson
This commit is contained in:
commit
dcf9608e86
|
|
@ -86,7 +86,7 @@ namespace UniGLTF.JsonSchema
|
|||
}
|
||||
}
|
||||
|
||||
JsonSchemaSource Parse(ListTreeNode<JsonValue> json, string jsonPath)
|
||||
JsonSchemaSource Parse(JsonNode json, string jsonPath)
|
||||
{
|
||||
var source = new JsonSchemaSource
|
||||
{
|
||||
|
|
@ -294,13 +294,13 @@ namespace UniGLTF.JsonSchema
|
|||
return source;
|
||||
}
|
||||
|
||||
void ParseStringEnum(ref JsonSchemaSource source, ListTreeNode<JsonValue> json)
|
||||
void ParseStringEnum(ref JsonSchemaSource source, JsonNode json)
|
||||
{
|
||||
source.enumStringValues = json.ArrayItems().Select(x => x.GetString()).ToArray();
|
||||
source.type = JsonSchemaType.EnumString;
|
||||
}
|
||||
|
||||
void ParseAnyOfAsEnum(ref JsonSchemaSource source, ListTreeNode<JsonValue> json)
|
||||
void ParseAnyOfAsEnum(ref JsonSchemaSource source, JsonNode json)
|
||||
{
|
||||
List<int> values = new List<int>();
|
||||
List<string> stringValues = new List<string>();
|
||||
|
|
@ -378,7 +378,7 @@ namespace UniGLTF.JsonSchema
|
|||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
JsonSchemaSource AllOf(ListTreeNode<JsonValue> json, string jsonPath)
|
||||
JsonSchemaSource AllOf(JsonNode json, string jsonPath)
|
||||
{
|
||||
string refValue = null;
|
||||
int count = 0;
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ namespace UniGLTF.JsonSchema.Schemas
|
|||
{
|
||||
|
||||
writer.Write(@"
|
||||
public static $0 $2(ListTreeNode<JsonValue> parsed)
|
||||
public static $0 $2(JsonNode parsed)
|
||||
{
|
||||
var value = new $1[parsed.GetArrayCount()];
|
||||
int i=0;
|
||||
|
|
@ -81,7 +81,7 @@ public static $0 $2(ListTreeNode<JsonValue> parsed)
|
|||
else
|
||||
{
|
||||
writer.Write(@"
|
||||
public static $0 $2(ListTreeNode<JsonValue> parsed)
|
||||
public static $0 $2(JsonNode parsed)
|
||||
{
|
||||
var value = new $1();
|
||||
foreach(var x in parsed.ArrayItems())
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ namespace UniGLTF.JsonSchema.Schemas
|
|||
writer.Used.Add(callName);
|
||||
|
||||
writer.Write(@"
|
||||
public static $0 $2(ListTreeNode<JsonValue> parsed)
|
||||
public static $0 $2(JsonNode parsed)
|
||||
{
|
||||
var value = new $0();
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ namespace UniGLTF
|
|||
var itemCallName = callName + "_ITEM";
|
||||
|
||||
writer.Write(@"
|
||||
public static $0 $2(ListTreeNode<JsonValue> parsed)
|
||||
public static $0 $2(JsonNode parsed)
|
||||
{
|
||||
var value = new $1[parsed.GetArrayCount()];
|
||||
int i=0;
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ using UnityEngine;
|
|||
namespace UniGLTF
|
||||
{
|
||||
/// <summary>
|
||||
/// Generate deserializer from ListTreeNode<JsonValue> to glTF using type reflection
|
||||
/// Generate deserializer from JsonNode to glTF using type reflection
|
||||
/// </summary>
|
||||
public static class DeserializerGenerator
|
||||
{
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ namespace UniGLTF
|
|||
{
|
||||
var itemCallName = callName + "_ITEM";
|
||||
writer.Write(@"
|
||||
public static $0 $2(ListTreeNode<JsonValue> parsed)
|
||||
public static $0 $2(JsonNode parsed)
|
||||
{
|
||||
var value = new List<$1>();
|
||||
foreach(var x in parsed.ArrayItems())
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ namespace UniGLTF
|
|||
public override void GenerateDeserializer(StreamWriter writer, string parentName)
|
||||
{
|
||||
writer.Write(@"
|
||||
public static $0 $2(ListTreeNode<JsonValue> parsed)
|
||||
public static $0 $2(JsonNode parsed)
|
||||
{
|
||||
var value = new $0();
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ namespace UniGLTF
|
|||
var itemCallName = callName + "_ITEM";
|
||||
writer.Write(@"
|
||||
|
||||
public static $0 $2(ListTreeNode<JsonValue> parsed)
|
||||
public static $0 $2(JsonNode parsed)
|
||||
{
|
||||
var value = new Dictionary<string, $1>();
|
||||
foreach(var kv in parsed.ObjectItems())
|
||||
|
|
|
|||
|
|
@ -392,7 +392,7 @@ namespace UniGLTF
|
|||
return false;
|
||||
}
|
||||
|
||||
static void Traverse(this glTF self, ListTreeNode<JsonValue> node, JsonFormatter f, Utf8String parentKey)
|
||||
static void Traverse(this glTF self, JsonNode node, JsonFormatter f, Utf8String parentKey)
|
||||
{
|
||||
if (node.IsMap())
|
||||
{
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ namespace UniGLTF
|
|||
[ItemJsonSchema(Minimum = 0)]
|
||||
public int texCoord;
|
||||
|
||||
static IEnumerable<float> DeserializeFloat2(ListTreeNode<JsonValue> json)
|
||||
static IEnumerable<float> DeserializeFloat2(JsonNode json)
|
||||
{
|
||||
if (json.Value.ValueType == ValueNodeType.Array)
|
||||
{
|
||||
|
|
@ -35,7 +35,7 @@ namespace UniGLTF
|
|||
}
|
||||
}
|
||||
|
||||
static glTF_KHR_texture_transform Deserialize(ListTreeNode<JsonValue> json)
|
||||
static glTF_KHR_texture_transform Deserialize(JsonNode json)
|
||||
{
|
||||
var t = new glTF_KHR_texture_transform();
|
||||
|
||||
|
|
|
|||
|
|
@ -117,13 +117,13 @@ namespace UniGLTF
|
|||
///
|
||||
/// パース済みの JSONの部分 を保持する
|
||||
///
|
||||
/// ListTreeNode<JsonValue> がJsonの部分を参照できる。
|
||||
/// JsonNode がJsonの部分を参照できる。
|
||||
///
|
||||
/// </summary>
|
||||
public class glTFExtensionImport : glTFExtension
|
||||
{
|
||||
readonly ListTreeNode<JsonValue> m_json;
|
||||
public glTFExtensionImport(ListTreeNode<JsonValue> json)
|
||||
readonly JsonNode m_json;
|
||||
public glTFExtensionImport(JsonNode json)
|
||||
{
|
||||
m_json = json;
|
||||
}
|
||||
|
|
@ -134,7 +134,7 @@ namespace UniGLTF
|
|||
return "import: " + Encoding.UTF8.GetString(bytes.Array, bytes.Offset, bytes.Count);
|
||||
}
|
||||
|
||||
public IEnumerable<KeyValuePair<ListTreeNode<JsonValue>, ListTreeNode<JsonValue>>> ObjectItems()
|
||||
public IEnumerable<KeyValuePair<JsonNode, JsonNode>> ObjectItems()
|
||||
{
|
||||
if (m_json.Value.ValueType == ValueNodeType.Object)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ namespace UniGLTF
|
|||
|
||||
public static readonly Utf8String ExtraNameUtf8 = Utf8String.From(ExtraName);
|
||||
|
||||
static List<string> Deserialize(ListTreeNode<JsonValue> json)
|
||||
static List<string> Deserialize(JsonNode json)
|
||||
{
|
||||
var targetNames = new List<string>();
|
||||
if (json.Value.ValueType == ValueNodeType.Array)
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ public static class GltfDeserializer
|
|||
{
|
||||
|
||||
|
||||
public static glTF Deserialize(ListTreeNode<JsonValue> parsed)
|
||||
public static glTF Deserialize(JsonNode parsed)
|
||||
{
|
||||
var value = new glTF();
|
||||
|
||||
|
|
@ -116,7 +116,7 @@ public static glTF Deserialize(ListTreeNode<JsonValue> parsed)
|
|||
return value;
|
||||
}
|
||||
|
||||
public static glTFAssets Deserialize_gltf_asset(ListTreeNode<JsonValue> parsed)
|
||||
public static glTFAssets Deserialize_gltf_asset(JsonNode parsed)
|
||||
{
|
||||
var value = new glTFAssets();
|
||||
|
||||
|
|
@ -158,7 +158,7 @@ public static glTFAssets Deserialize_gltf_asset(ListTreeNode<JsonValue> parsed)
|
|||
return value;
|
||||
}
|
||||
|
||||
public static List<UniGLTF.glTFBuffer> Deserialize_gltf_buffers(ListTreeNode<JsonValue> parsed)
|
||||
public static List<UniGLTF.glTFBuffer> Deserialize_gltf_buffers(JsonNode parsed)
|
||||
{
|
||||
var value = new List<glTFBuffer>();
|
||||
foreach(var x in parsed.ArrayItems())
|
||||
|
|
@ -167,7 +167,7 @@ public static List<UniGLTF.glTFBuffer> Deserialize_gltf_buffers(ListTreeNode<Jso
|
|||
}
|
||||
return value;
|
||||
}
|
||||
public static glTFBuffer Deserialize_gltf_buffers_LIST(ListTreeNode<JsonValue> parsed)
|
||||
public static glTFBuffer Deserialize_gltf_buffers_LIST(JsonNode parsed)
|
||||
{
|
||||
var value = new glTFBuffer();
|
||||
|
||||
|
|
@ -204,7 +204,7 @@ public static glTFBuffer Deserialize_gltf_buffers_LIST(ListTreeNode<JsonValue> p
|
|||
return value;
|
||||
}
|
||||
|
||||
public static List<UniGLTF.glTFBufferView> Deserialize_gltf_bufferViews(ListTreeNode<JsonValue> parsed)
|
||||
public static List<UniGLTF.glTFBufferView> Deserialize_gltf_bufferViews(JsonNode parsed)
|
||||
{
|
||||
var value = new List<glTFBufferView>();
|
||||
foreach(var x in parsed.ArrayItems())
|
||||
|
|
@ -213,7 +213,7 @@ public static List<UniGLTF.glTFBufferView> Deserialize_gltf_bufferViews(ListTree
|
|||
}
|
||||
return value;
|
||||
}
|
||||
public static glTFBufferView Deserialize_gltf_bufferViews_LIST(ListTreeNode<JsonValue> parsed)
|
||||
public static glTFBufferView Deserialize_gltf_bufferViews_LIST(JsonNode parsed)
|
||||
{
|
||||
var value = new glTFBufferView();
|
||||
|
||||
|
|
@ -265,7 +265,7 @@ public static glTFBufferView Deserialize_gltf_bufferViews_LIST(ListTreeNode<Json
|
|||
return value;
|
||||
}
|
||||
|
||||
public static List<UniGLTF.glTFAccessor> Deserialize_gltf_accessors(ListTreeNode<JsonValue> parsed)
|
||||
public static List<UniGLTF.glTFAccessor> Deserialize_gltf_accessors(JsonNode parsed)
|
||||
{
|
||||
var value = new List<glTFAccessor>();
|
||||
foreach(var x in parsed.ArrayItems())
|
||||
|
|
@ -274,7 +274,7 @@ public static List<UniGLTF.glTFAccessor> Deserialize_gltf_accessors(ListTreeNode
|
|||
}
|
||||
return value;
|
||||
}
|
||||
public static glTFAccessor Deserialize_gltf_accessors_LIST(ListTreeNode<JsonValue> parsed)
|
||||
public static glTFAccessor Deserialize_gltf_accessors_LIST(JsonNode parsed)
|
||||
{
|
||||
var value = new glTFAccessor();
|
||||
|
||||
|
|
@ -346,7 +346,7 @@ public static glTFAccessor Deserialize_gltf_accessors_LIST(ListTreeNode<JsonValu
|
|||
return value;
|
||||
}
|
||||
|
||||
public static Single[] Deserialize_gltf_accessors__max(ListTreeNode<JsonValue> parsed)
|
||||
public static Single[] Deserialize_gltf_accessors__max(JsonNode parsed)
|
||||
{
|
||||
var value = new Single[parsed.GetArrayCount()];
|
||||
int i=0;
|
||||
|
|
@ -357,7 +357,7 @@ public static Single[] Deserialize_gltf_accessors__max(ListTreeNode<JsonValue> p
|
|||
return value;
|
||||
}
|
||||
|
||||
public static Single[] Deserialize_gltf_accessors__min(ListTreeNode<JsonValue> parsed)
|
||||
public static Single[] Deserialize_gltf_accessors__min(JsonNode parsed)
|
||||
{
|
||||
var value = new Single[parsed.GetArrayCount()];
|
||||
int i=0;
|
||||
|
|
@ -368,7 +368,7 @@ public static Single[] Deserialize_gltf_accessors__min(ListTreeNode<JsonValue> p
|
|||
return value;
|
||||
}
|
||||
|
||||
public static glTFSparse Deserialize_gltf_accessors__sparse(ListTreeNode<JsonValue> parsed)
|
||||
public static glTFSparse Deserialize_gltf_accessors__sparse(JsonNode parsed)
|
||||
{
|
||||
var value = new glTFSparse();
|
||||
|
||||
|
|
@ -405,7 +405,7 @@ public static glTFSparse Deserialize_gltf_accessors__sparse(ListTreeNode<JsonVal
|
|||
return value;
|
||||
}
|
||||
|
||||
public static glTFSparseIndices Deserialize_gltf_accessors__sparse_indices(ListTreeNode<JsonValue> parsed)
|
||||
public static glTFSparseIndices Deserialize_gltf_accessors__sparse_indices(JsonNode parsed)
|
||||
{
|
||||
var value = new glTFSparseIndices();
|
||||
|
||||
|
|
@ -442,7 +442,7 @@ public static glTFSparseIndices Deserialize_gltf_accessors__sparse_indices(ListT
|
|||
return value;
|
||||
}
|
||||
|
||||
public static glTFSparseValues Deserialize_gltf_accessors__sparse_values(ListTreeNode<JsonValue> parsed)
|
||||
public static glTFSparseValues Deserialize_gltf_accessors__sparse_values(JsonNode parsed)
|
||||
{
|
||||
var value = new glTFSparseValues();
|
||||
|
||||
|
|
@ -474,7 +474,7 @@ public static glTFSparseValues Deserialize_gltf_accessors__sparse_values(ListTre
|
|||
return value;
|
||||
}
|
||||
|
||||
public static List<UniGLTF.glTFTexture> Deserialize_gltf_textures(ListTreeNode<JsonValue> parsed)
|
||||
public static List<UniGLTF.glTFTexture> Deserialize_gltf_textures(JsonNode parsed)
|
||||
{
|
||||
var value = new List<glTFTexture>();
|
||||
foreach(var x in parsed.ArrayItems())
|
||||
|
|
@ -483,7 +483,7 @@ public static List<UniGLTF.glTFTexture> Deserialize_gltf_textures(ListTreeNode<J
|
|||
}
|
||||
return value;
|
||||
}
|
||||
public static glTFTexture Deserialize_gltf_textures_LIST(ListTreeNode<JsonValue> parsed)
|
||||
public static glTFTexture Deserialize_gltf_textures_LIST(JsonNode parsed)
|
||||
{
|
||||
var value = new glTFTexture();
|
||||
|
||||
|
|
@ -520,7 +520,7 @@ public static glTFTexture Deserialize_gltf_textures_LIST(ListTreeNode<JsonValue>
|
|||
return value;
|
||||
}
|
||||
|
||||
public static List<UniGLTF.glTFTextureSampler> Deserialize_gltf_samplers(ListTreeNode<JsonValue> parsed)
|
||||
public static List<UniGLTF.glTFTextureSampler> Deserialize_gltf_samplers(JsonNode parsed)
|
||||
{
|
||||
var value = new List<glTFTextureSampler>();
|
||||
foreach(var x in parsed.ArrayItems())
|
||||
|
|
@ -529,7 +529,7 @@ public static List<UniGLTF.glTFTextureSampler> Deserialize_gltf_samplers(ListTre
|
|||
}
|
||||
return value;
|
||||
}
|
||||
public static glTFTextureSampler Deserialize_gltf_samplers_LIST(ListTreeNode<JsonValue> parsed)
|
||||
public static glTFTextureSampler Deserialize_gltf_samplers_LIST(JsonNode parsed)
|
||||
{
|
||||
var value = new glTFTextureSampler();
|
||||
|
||||
|
|
@ -576,7 +576,7 @@ public static glTFTextureSampler Deserialize_gltf_samplers_LIST(ListTreeNode<Jso
|
|||
return value;
|
||||
}
|
||||
|
||||
public static List<UniGLTF.glTFImage> Deserialize_gltf_images(ListTreeNode<JsonValue> parsed)
|
||||
public static List<UniGLTF.glTFImage> Deserialize_gltf_images(JsonNode parsed)
|
||||
{
|
||||
var value = new List<glTFImage>();
|
||||
foreach(var x in parsed.ArrayItems())
|
||||
|
|
@ -585,7 +585,7 @@ public static List<UniGLTF.glTFImage> Deserialize_gltf_images(ListTreeNode<JsonV
|
|||
}
|
||||
return value;
|
||||
}
|
||||
public static glTFImage Deserialize_gltf_images_LIST(ListTreeNode<JsonValue> parsed)
|
||||
public static glTFImage Deserialize_gltf_images_LIST(JsonNode parsed)
|
||||
{
|
||||
var value = new glTFImage();
|
||||
|
||||
|
|
@ -627,7 +627,7 @@ public static glTFImage Deserialize_gltf_images_LIST(ListTreeNode<JsonValue> par
|
|||
return value;
|
||||
}
|
||||
|
||||
public static List<UniGLTF.glTFMaterial> Deserialize_gltf_materials(ListTreeNode<JsonValue> parsed)
|
||||
public static List<UniGLTF.glTFMaterial> Deserialize_gltf_materials(JsonNode parsed)
|
||||
{
|
||||
var value = new List<glTFMaterial>();
|
||||
foreach(var x in parsed.ArrayItems())
|
||||
|
|
@ -636,7 +636,7 @@ public static List<UniGLTF.glTFMaterial> Deserialize_gltf_materials(ListTreeNode
|
|||
}
|
||||
return value;
|
||||
}
|
||||
public static glTFMaterial Deserialize_gltf_materials_LIST(ListTreeNode<JsonValue> parsed)
|
||||
public static glTFMaterial Deserialize_gltf_materials_LIST(JsonNode parsed)
|
||||
{
|
||||
var value = new glTFMaterial();
|
||||
|
||||
|
|
@ -703,7 +703,7 @@ public static glTFMaterial Deserialize_gltf_materials_LIST(ListTreeNode<JsonValu
|
|||
return value;
|
||||
}
|
||||
|
||||
public static glTFPbrMetallicRoughness Deserialize_gltf_materials__pbrMetallicRoughness(ListTreeNode<JsonValue> parsed)
|
||||
public static glTFPbrMetallicRoughness Deserialize_gltf_materials__pbrMetallicRoughness(JsonNode parsed)
|
||||
{
|
||||
var value = new glTFPbrMetallicRoughness();
|
||||
|
||||
|
|
@ -750,7 +750,7 @@ public static glTFPbrMetallicRoughness Deserialize_gltf_materials__pbrMetallicRo
|
|||
return value;
|
||||
}
|
||||
|
||||
public static glTFMaterialBaseColorTextureInfo Deserialize_gltf_materials__pbrMetallicRoughness_baseColorTexture(ListTreeNode<JsonValue> parsed)
|
||||
public static glTFMaterialBaseColorTextureInfo Deserialize_gltf_materials__pbrMetallicRoughness_baseColorTexture(JsonNode parsed)
|
||||
{
|
||||
var value = new glTFMaterialBaseColorTextureInfo();
|
||||
|
||||
|
|
@ -782,7 +782,7 @@ public static glTFMaterialBaseColorTextureInfo Deserialize_gltf_materials__pbrMe
|
|||
return value;
|
||||
}
|
||||
|
||||
public static Single[] Deserialize_gltf_materials__pbrMetallicRoughness_baseColorFactor(ListTreeNode<JsonValue> parsed)
|
||||
public static Single[] Deserialize_gltf_materials__pbrMetallicRoughness_baseColorFactor(JsonNode parsed)
|
||||
{
|
||||
var value = new Single[parsed.GetArrayCount()];
|
||||
int i=0;
|
||||
|
|
@ -793,7 +793,7 @@ public static Single[] Deserialize_gltf_materials__pbrMetallicRoughness_baseColo
|
|||
return value;
|
||||
}
|
||||
|
||||
public static glTFMaterialMetallicRoughnessTextureInfo Deserialize_gltf_materials__pbrMetallicRoughness_metallicRoughnessTexture(ListTreeNode<JsonValue> parsed)
|
||||
public static glTFMaterialMetallicRoughnessTextureInfo Deserialize_gltf_materials__pbrMetallicRoughness_metallicRoughnessTexture(JsonNode parsed)
|
||||
{
|
||||
var value = new glTFMaterialMetallicRoughnessTextureInfo();
|
||||
|
||||
|
|
@ -825,7 +825,7 @@ public static glTFMaterialMetallicRoughnessTextureInfo Deserialize_gltf_material
|
|||
return value;
|
||||
}
|
||||
|
||||
public static glTFMaterialNormalTextureInfo Deserialize_gltf_materials__normalTexture(ListTreeNode<JsonValue> parsed)
|
||||
public static glTFMaterialNormalTextureInfo Deserialize_gltf_materials__normalTexture(JsonNode parsed)
|
||||
{
|
||||
var value = new glTFMaterialNormalTextureInfo();
|
||||
|
||||
|
|
@ -862,7 +862,7 @@ public static glTFMaterialNormalTextureInfo Deserialize_gltf_materials__normalTe
|
|||
return value;
|
||||
}
|
||||
|
||||
public static glTFMaterialOcclusionTextureInfo Deserialize_gltf_materials__occlusionTexture(ListTreeNode<JsonValue> parsed)
|
||||
public static glTFMaterialOcclusionTextureInfo Deserialize_gltf_materials__occlusionTexture(JsonNode parsed)
|
||||
{
|
||||
var value = new glTFMaterialOcclusionTextureInfo();
|
||||
|
||||
|
|
@ -899,7 +899,7 @@ public static glTFMaterialOcclusionTextureInfo Deserialize_gltf_materials__occlu
|
|||
return value;
|
||||
}
|
||||
|
||||
public static glTFMaterialEmissiveTextureInfo Deserialize_gltf_materials__emissiveTexture(ListTreeNode<JsonValue> parsed)
|
||||
public static glTFMaterialEmissiveTextureInfo Deserialize_gltf_materials__emissiveTexture(JsonNode parsed)
|
||||
{
|
||||
var value = new glTFMaterialEmissiveTextureInfo();
|
||||
|
||||
|
|
@ -931,7 +931,7 @@ public static glTFMaterialEmissiveTextureInfo Deserialize_gltf_materials__emissi
|
|||
return value;
|
||||
}
|
||||
|
||||
public static Single[] Deserialize_gltf_materials__emissiveFactor(ListTreeNode<JsonValue> parsed)
|
||||
public static Single[] Deserialize_gltf_materials__emissiveFactor(JsonNode parsed)
|
||||
{
|
||||
var value = new Single[parsed.GetArrayCount()];
|
||||
int i=0;
|
||||
|
|
@ -942,7 +942,7 @@ public static Single[] Deserialize_gltf_materials__emissiveFactor(ListTreeNode<J
|
|||
return value;
|
||||
}
|
||||
|
||||
public static List<UniGLTF.glTFMesh> Deserialize_gltf_meshes(ListTreeNode<JsonValue> parsed)
|
||||
public static List<UniGLTF.glTFMesh> Deserialize_gltf_meshes(JsonNode parsed)
|
||||
{
|
||||
var value = new List<glTFMesh>();
|
||||
foreach(var x in parsed.ArrayItems())
|
||||
|
|
@ -951,7 +951,7 @@ public static List<UniGLTF.glTFMesh> Deserialize_gltf_meshes(ListTreeNode<JsonVa
|
|||
}
|
||||
return value;
|
||||
}
|
||||
public static glTFMesh Deserialize_gltf_meshes_LIST(ListTreeNode<JsonValue> parsed)
|
||||
public static glTFMesh Deserialize_gltf_meshes_LIST(JsonNode parsed)
|
||||
{
|
||||
var value = new glTFMesh();
|
||||
|
||||
|
|
@ -988,7 +988,7 @@ public static glTFMesh Deserialize_gltf_meshes_LIST(ListTreeNode<JsonValue> pars
|
|||
return value;
|
||||
}
|
||||
|
||||
public static List<UniGLTF.glTFPrimitives> Deserialize_gltf_meshes__primitives(ListTreeNode<JsonValue> parsed)
|
||||
public static List<UniGLTF.glTFPrimitives> Deserialize_gltf_meshes__primitives(JsonNode parsed)
|
||||
{
|
||||
var value = new List<glTFPrimitives>();
|
||||
foreach(var x in parsed.ArrayItems())
|
||||
|
|
@ -997,7 +997,7 @@ public static List<UniGLTF.glTFPrimitives> Deserialize_gltf_meshes__primitives(L
|
|||
}
|
||||
return value;
|
||||
}
|
||||
public static glTFPrimitives Deserialize_gltf_meshes__primitives_LIST(ListTreeNode<JsonValue> parsed)
|
||||
public static glTFPrimitives Deserialize_gltf_meshes__primitives_LIST(JsonNode parsed)
|
||||
{
|
||||
var value = new glTFPrimitives();
|
||||
|
||||
|
|
@ -1044,7 +1044,7 @@ public static glTFPrimitives Deserialize_gltf_meshes__primitives_LIST(ListTreeNo
|
|||
return value;
|
||||
}
|
||||
|
||||
public static glTFAttributes Deserialize_gltf_meshes__primitives__attributes(ListTreeNode<JsonValue> parsed)
|
||||
public static glTFAttributes Deserialize_gltf_meshes__primitives__attributes(JsonNode parsed)
|
||||
{
|
||||
var value = new glTFAttributes();
|
||||
|
||||
|
|
@ -1096,7 +1096,7 @@ public static glTFAttributes Deserialize_gltf_meshes__primitives__attributes(Lis
|
|||
return value;
|
||||
}
|
||||
|
||||
public static List<UniGLTF.gltfMorphTarget> Deserialize_gltf_meshes__primitives__targets(ListTreeNode<JsonValue> parsed)
|
||||
public static List<UniGLTF.gltfMorphTarget> Deserialize_gltf_meshes__primitives__targets(JsonNode parsed)
|
||||
{
|
||||
var value = new List<gltfMorphTarget>();
|
||||
foreach(var x in parsed.ArrayItems())
|
||||
|
|
@ -1105,7 +1105,7 @@ public static List<UniGLTF.gltfMorphTarget> Deserialize_gltf_meshes__primitives_
|
|||
}
|
||||
return value;
|
||||
}
|
||||
public static gltfMorphTarget Deserialize_gltf_meshes__primitives__targets_LIST(ListTreeNode<JsonValue> parsed)
|
||||
public static gltfMorphTarget Deserialize_gltf_meshes__primitives__targets_LIST(JsonNode parsed)
|
||||
{
|
||||
var value = new gltfMorphTarget();
|
||||
|
||||
|
|
@ -1132,7 +1132,7 @@ public static gltfMorphTarget Deserialize_gltf_meshes__primitives__targets_LIST(
|
|||
return value;
|
||||
}
|
||||
|
||||
public static Single[] Deserialize_gltf_meshes__weights(ListTreeNode<JsonValue> parsed)
|
||||
public static Single[] Deserialize_gltf_meshes__weights(JsonNode parsed)
|
||||
{
|
||||
var value = new Single[parsed.GetArrayCount()];
|
||||
int i=0;
|
||||
|
|
@ -1143,7 +1143,7 @@ public static Single[] Deserialize_gltf_meshes__weights(ListTreeNode<JsonValue>
|
|||
return value;
|
||||
}
|
||||
|
||||
public static List<UniGLTF.glTFNode> Deserialize_gltf_nodes(ListTreeNode<JsonValue> parsed)
|
||||
public static List<UniGLTF.glTFNode> Deserialize_gltf_nodes(JsonNode parsed)
|
||||
{
|
||||
var value = new List<glTFNode>();
|
||||
foreach(var x in parsed.ArrayItems())
|
||||
|
|
@ -1152,7 +1152,7 @@ public static List<UniGLTF.glTFNode> Deserialize_gltf_nodes(ListTreeNode<JsonVal
|
|||
}
|
||||
return value;
|
||||
}
|
||||
public static glTFNode Deserialize_gltf_nodes_LIST(ListTreeNode<JsonValue> parsed)
|
||||
public static glTFNode Deserialize_gltf_nodes_LIST(JsonNode parsed)
|
||||
{
|
||||
var value = new glTFNode();
|
||||
|
||||
|
|
@ -1224,7 +1224,7 @@ public static glTFNode Deserialize_gltf_nodes_LIST(ListTreeNode<JsonValue> parse
|
|||
return value;
|
||||
}
|
||||
|
||||
public static Int32[] Deserialize_gltf_nodes__children(ListTreeNode<JsonValue> parsed)
|
||||
public static Int32[] Deserialize_gltf_nodes__children(JsonNode parsed)
|
||||
{
|
||||
var value = new Int32[parsed.GetArrayCount()];
|
||||
int i=0;
|
||||
|
|
@ -1235,7 +1235,7 @@ public static Int32[] Deserialize_gltf_nodes__children(ListTreeNode<JsonValue> p
|
|||
return value;
|
||||
}
|
||||
|
||||
public static Single[] Deserialize_gltf_nodes__matrix(ListTreeNode<JsonValue> parsed)
|
||||
public static Single[] Deserialize_gltf_nodes__matrix(JsonNode parsed)
|
||||
{
|
||||
var value = new Single[parsed.GetArrayCount()];
|
||||
int i=0;
|
||||
|
|
@ -1246,7 +1246,7 @@ public static Single[] Deserialize_gltf_nodes__matrix(ListTreeNode<JsonValue> pa
|
|||
return value;
|
||||
}
|
||||
|
||||
public static Single[] Deserialize_gltf_nodes__translation(ListTreeNode<JsonValue> parsed)
|
||||
public static Single[] Deserialize_gltf_nodes__translation(JsonNode parsed)
|
||||
{
|
||||
var value = new Single[parsed.GetArrayCount()];
|
||||
int i=0;
|
||||
|
|
@ -1257,7 +1257,7 @@ public static Single[] Deserialize_gltf_nodes__translation(ListTreeNode<JsonValu
|
|||
return value;
|
||||
}
|
||||
|
||||
public static Single[] Deserialize_gltf_nodes__rotation(ListTreeNode<JsonValue> parsed)
|
||||
public static Single[] Deserialize_gltf_nodes__rotation(JsonNode parsed)
|
||||
{
|
||||
var value = new Single[parsed.GetArrayCount()];
|
||||
int i=0;
|
||||
|
|
@ -1268,7 +1268,7 @@ public static Single[] Deserialize_gltf_nodes__rotation(ListTreeNode<JsonValue>
|
|||
return value;
|
||||
}
|
||||
|
||||
public static Single[] Deserialize_gltf_nodes__scale(ListTreeNode<JsonValue> parsed)
|
||||
public static Single[] Deserialize_gltf_nodes__scale(JsonNode parsed)
|
||||
{
|
||||
var value = new Single[parsed.GetArrayCount()];
|
||||
int i=0;
|
||||
|
|
@ -1279,7 +1279,7 @@ public static Single[] Deserialize_gltf_nodes__scale(ListTreeNode<JsonValue> par
|
|||
return value;
|
||||
}
|
||||
|
||||
public static Single[] Deserialize_gltf_nodes__weights(ListTreeNode<JsonValue> parsed)
|
||||
public static Single[] Deserialize_gltf_nodes__weights(JsonNode parsed)
|
||||
{
|
||||
var value = new Single[parsed.GetArrayCount()];
|
||||
int i=0;
|
||||
|
|
@ -1290,7 +1290,7 @@ public static Single[] Deserialize_gltf_nodes__weights(ListTreeNode<JsonValue> p
|
|||
return value;
|
||||
}
|
||||
|
||||
public static List<UniGLTF.glTFSkin> Deserialize_gltf_skins(ListTreeNode<JsonValue> parsed)
|
||||
public static List<UniGLTF.glTFSkin> Deserialize_gltf_skins(JsonNode parsed)
|
||||
{
|
||||
var value = new List<glTFSkin>();
|
||||
foreach(var x in parsed.ArrayItems())
|
||||
|
|
@ -1299,7 +1299,7 @@ public static List<UniGLTF.glTFSkin> Deserialize_gltf_skins(ListTreeNode<JsonVal
|
|||
}
|
||||
return value;
|
||||
}
|
||||
public static glTFSkin Deserialize_gltf_skins_LIST(ListTreeNode<JsonValue> parsed)
|
||||
public static glTFSkin Deserialize_gltf_skins_LIST(JsonNode parsed)
|
||||
{
|
||||
var value = new glTFSkin();
|
||||
|
||||
|
|
@ -1341,7 +1341,7 @@ public static glTFSkin Deserialize_gltf_skins_LIST(ListTreeNode<JsonValue> parse
|
|||
return value;
|
||||
}
|
||||
|
||||
public static Int32[] Deserialize_gltf_skins__joints(ListTreeNode<JsonValue> parsed)
|
||||
public static Int32[] Deserialize_gltf_skins__joints(JsonNode parsed)
|
||||
{
|
||||
var value = new Int32[parsed.GetArrayCount()];
|
||||
int i=0;
|
||||
|
|
@ -1352,7 +1352,7 @@ public static Int32[] Deserialize_gltf_skins__joints(ListTreeNode<JsonValue> par
|
|||
return value;
|
||||
}
|
||||
|
||||
public static List<UniGLTF.gltfScene> Deserialize_gltf_scenes(ListTreeNode<JsonValue> parsed)
|
||||
public static List<UniGLTF.gltfScene> Deserialize_gltf_scenes(JsonNode parsed)
|
||||
{
|
||||
var value = new List<gltfScene>();
|
||||
foreach(var x in parsed.ArrayItems())
|
||||
|
|
@ -1361,7 +1361,7 @@ public static List<UniGLTF.gltfScene> Deserialize_gltf_scenes(ListTreeNode<JsonV
|
|||
}
|
||||
return value;
|
||||
}
|
||||
public static gltfScene Deserialize_gltf_scenes_LIST(ListTreeNode<JsonValue> parsed)
|
||||
public static gltfScene Deserialize_gltf_scenes_LIST(JsonNode parsed)
|
||||
{
|
||||
var value = new gltfScene();
|
||||
|
||||
|
|
@ -1393,7 +1393,7 @@ public static gltfScene Deserialize_gltf_scenes_LIST(ListTreeNode<JsonValue> par
|
|||
return value;
|
||||
}
|
||||
|
||||
public static Int32[] Deserialize_gltf_scenes__nodes(ListTreeNode<JsonValue> parsed)
|
||||
public static Int32[] Deserialize_gltf_scenes__nodes(JsonNode parsed)
|
||||
{
|
||||
var value = new Int32[parsed.GetArrayCount()];
|
||||
int i=0;
|
||||
|
|
@ -1404,7 +1404,7 @@ public static Int32[] Deserialize_gltf_scenes__nodes(ListTreeNode<JsonValue> par
|
|||
return value;
|
||||
}
|
||||
|
||||
public static List<UniGLTF.glTFAnimation> Deserialize_gltf_animations(ListTreeNode<JsonValue> parsed)
|
||||
public static List<UniGLTF.glTFAnimation> Deserialize_gltf_animations(JsonNode parsed)
|
||||
{
|
||||
var value = new List<glTFAnimation>();
|
||||
foreach(var x in parsed.ArrayItems())
|
||||
|
|
@ -1413,7 +1413,7 @@ public static List<UniGLTF.glTFAnimation> Deserialize_gltf_animations(ListTreeNo
|
|||
}
|
||||
return value;
|
||||
}
|
||||
public static glTFAnimation Deserialize_gltf_animations_LIST(ListTreeNode<JsonValue> parsed)
|
||||
public static glTFAnimation Deserialize_gltf_animations_LIST(JsonNode parsed)
|
||||
{
|
||||
var value = new glTFAnimation();
|
||||
|
||||
|
|
@ -1450,7 +1450,7 @@ public static glTFAnimation Deserialize_gltf_animations_LIST(ListTreeNode<JsonVa
|
|||
return value;
|
||||
}
|
||||
|
||||
public static List<UniGLTF.glTFAnimationChannel> Deserialize_gltf_animations__channels(ListTreeNode<JsonValue> parsed)
|
||||
public static List<UniGLTF.glTFAnimationChannel> Deserialize_gltf_animations__channels(JsonNode parsed)
|
||||
{
|
||||
var value = new List<glTFAnimationChannel>();
|
||||
foreach(var x in parsed.ArrayItems())
|
||||
|
|
@ -1459,7 +1459,7 @@ public static List<UniGLTF.glTFAnimationChannel> Deserialize_gltf_animations__ch
|
|||
}
|
||||
return value;
|
||||
}
|
||||
public static glTFAnimationChannel Deserialize_gltf_animations__channels_LIST(ListTreeNode<JsonValue> parsed)
|
||||
public static glTFAnimationChannel Deserialize_gltf_animations__channels_LIST(JsonNode parsed)
|
||||
{
|
||||
var value = new glTFAnimationChannel();
|
||||
|
||||
|
|
@ -1491,7 +1491,7 @@ public static glTFAnimationChannel Deserialize_gltf_animations__channels_LIST(Li
|
|||
return value;
|
||||
}
|
||||
|
||||
public static glTFAnimationTarget Deserialize_gltf_animations__channels__target(ListTreeNode<JsonValue> parsed)
|
||||
public static glTFAnimationTarget Deserialize_gltf_animations__channels__target(JsonNode parsed)
|
||||
{
|
||||
var value = new glTFAnimationTarget();
|
||||
|
||||
|
|
@ -1523,7 +1523,7 @@ public static glTFAnimationTarget Deserialize_gltf_animations__channels__target(
|
|||
return value;
|
||||
}
|
||||
|
||||
public static List<UniGLTF.glTFAnimationSampler> Deserialize_gltf_animations__samplers(ListTreeNode<JsonValue> parsed)
|
||||
public static List<UniGLTF.glTFAnimationSampler> Deserialize_gltf_animations__samplers(JsonNode parsed)
|
||||
{
|
||||
var value = new List<glTFAnimationSampler>();
|
||||
foreach(var x in parsed.ArrayItems())
|
||||
|
|
@ -1532,7 +1532,7 @@ public static List<UniGLTF.glTFAnimationSampler> Deserialize_gltf_animations__sa
|
|||
}
|
||||
return value;
|
||||
}
|
||||
public static glTFAnimationSampler Deserialize_gltf_animations__samplers_LIST(ListTreeNode<JsonValue> parsed)
|
||||
public static glTFAnimationSampler Deserialize_gltf_animations__samplers_LIST(JsonNode parsed)
|
||||
{
|
||||
var value = new glTFAnimationSampler();
|
||||
|
||||
|
|
@ -1569,7 +1569,7 @@ public static glTFAnimationSampler Deserialize_gltf_animations__samplers_LIST(Li
|
|||
return value;
|
||||
}
|
||||
|
||||
public static List<UniGLTF.glTFCamera> Deserialize_gltf_cameras(ListTreeNode<JsonValue> parsed)
|
||||
public static List<UniGLTF.glTFCamera> Deserialize_gltf_cameras(JsonNode parsed)
|
||||
{
|
||||
var value = new List<glTFCamera>();
|
||||
foreach(var x in parsed.ArrayItems())
|
||||
|
|
@ -1578,7 +1578,7 @@ public static List<UniGLTF.glTFCamera> Deserialize_gltf_cameras(ListTreeNode<Jso
|
|||
}
|
||||
return value;
|
||||
}
|
||||
public static glTFCamera Deserialize_gltf_cameras_LIST(ListTreeNode<JsonValue> parsed)
|
||||
public static glTFCamera Deserialize_gltf_cameras_LIST(JsonNode parsed)
|
||||
{
|
||||
var value = new glTFCamera();
|
||||
|
||||
|
|
@ -1620,7 +1620,7 @@ public static glTFCamera Deserialize_gltf_cameras_LIST(ListTreeNode<JsonValue> p
|
|||
return value;
|
||||
}
|
||||
|
||||
public static glTFOrthographic Deserialize_gltf_cameras__orthographic(ListTreeNode<JsonValue> parsed)
|
||||
public static glTFOrthographic Deserialize_gltf_cameras__orthographic(JsonNode parsed)
|
||||
{
|
||||
var value = new glTFOrthographic();
|
||||
|
||||
|
|
@ -1662,7 +1662,7 @@ public static glTFOrthographic Deserialize_gltf_cameras__orthographic(ListTreeNo
|
|||
return value;
|
||||
}
|
||||
|
||||
public static glTFPerspective Deserialize_gltf_cameras__perspective(ListTreeNode<JsonValue> parsed)
|
||||
public static glTFPerspective Deserialize_gltf_cameras__perspective(JsonNode parsed)
|
||||
{
|
||||
var value = new glTFPerspective();
|
||||
|
||||
|
|
@ -1704,7 +1704,7 @@ public static glTFPerspective Deserialize_gltf_cameras__perspective(ListTreeNode
|
|||
return value;
|
||||
}
|
||||
|
||||
public static List<System.String> Deserialize_gltf_extensionsUsed(ListTreeNode<JsonValue> parsed)
|
||||
public static List<System.String> Deserialize_gltf_extensionsUsed(JsonNode parsed)
|
||||
{
|
||||
var value = new List<String>();
|
||||
foreach(var x in parsed.ArrayItems())
|
||||
|
|
@ -1713,7 +1713,7 @@ public static List<System.String> Deserialize_gltf_extensionsUsed(ListTreeNode<J
|
|||
}
|
||||
return value;
|
||||
}
|
||||
public static List<System.String> Deserialize_gltf_extensionsRequired(ListTreeNode<JsonValue> parsed)
|
||||
public static List<System.String> Deserialize_gltf_extensionsRequired(JsonNode parsed)
|
||||
{
|
||||
var value = new List<String>();
|
||||
foreach(var x in parsed.ArrayItems())
|
||||
|
|
|
|||
|
|
@ -1,63 +0,0 @@
|
|||
version: 2
|
||||
jobs:
|
||||
update_unity_repo:
|
||||
docker:
|
||||
- image: circleci/buildpack-deps:latest
|
||||
|
||||
working_directory: ~/repo
|
||||
|
||||
environment:
|
||||
UniJSON_unity_REPO: "git@github.com:ousttrue/UniJSON-unity.git"
|
||||
|
||||
steps:
|
||||
- add_ssh_keys:
|
||||
fingerprints:
|
||||
- "5b:16:4a:8a:c9:a5:2c:80:37:d4:a5:b8:1b:0d:60:27"
|
||||
- run:
|
||||
name: Avoid hosts unknown for github
|
||||
command: echo -e "Host github.com\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config
|
||||
|
||||
- run:
|
||||
name: Clone UniJSON-unity (NOT UniJSON)
|
||||
command: |
|
||||
git clone ${UniJSON_unity_REPO}
|
||||
cd UniJSON-unity
|
||||
git submodule update --init
|
||||
|
||||
- run:
|
||||
name: Update submodule(UniJSON) in UniJSON-unity
|
||||
command: |
|
||||
cd UniJSON-unity/Assets/UniJSON
|
||||
git fetch && git checkout --force ${CIRCLE_SHA1}
|
||||
|
||||
- run:
|
||||
command: |
|
||||
cd UniJSON-unity
|
||||
git config user.email "yutopp+unijson-unity@users.noreply.github.com"
|
||||
git config user.name "unijson-unity job"
|
||||
|
||||
- run:
|
||||
command: |
|
||||
cd UniJSON-unity
|
||||
git add Assets/UniJSON
|
||||
git commit -m "[skip ci] Checkout UniJSON (${CIRCLE_SHA1})"
|
||||
|
||||
- run:
|
||||
command: |
|
||||
cd UniJSON-unity
|
||||
git status
|
||||
when: on_fail
|
||||
|
||||
- run:
|
||||
command: |
|
||||
cd UniJSON-unity
|
||||
git push origin master
|
||||
|
||||
workflows:
|
||||
version: 2
|
||||
build_test_deploy:
|
||||
jobs:
|
||||
- update_unity_repo:
|
||||
filters:
|
||||
branches:
|
||||
only: master
|
||||
|
|
@ -5,48 +5,21 @@ namespace UniJSON
|
|||
{
|
||||
public static class StringExtensions
|
||||
{
|
||||
public static ListTreeNode<JsonValue> ParseAsJson(this string json)
|
||||
public static JsonNode ParseAsJson(this string json)
|
||||
{
|
||||
return JsonParser.Parse(json);
|
||||
}
|
||||
public static ListTreeNode<JsonValue> ParseAsJson(this Utf8String json)
|
||||
public static JsonNode ParseAsJson(this Utf8String json)
|
||||
{
|
||||
return JsonParser.Parse(json);
|
||||
}
|
||||
public static ListTreeNode<JsonValue> ParseAsJson(this byte[] bytes)
|
||||
public static JsonNode ParseAsJson(this byte[] bytes)
|
||||
{
|
||||
return JsonParser.Parse(new Utf8String(bytes));
|
||||
}
|
||||
public static ListTreeNode<JsonValue> ParseAsJson(this ArraySegment<byte> bytes)
|
||||
public static JsonNode ParseAsJson(this ArraySegment<byte> bytes)
|
||||
{
|
||||
return JsonParser.Parse(new Utf8String(bytes));
|
||||
}
|
||||
|
||||
public static ListTreeNode<MsgPackValue> ParseAsMsgPack(this byte[] bytes)
|
||||
{
|
||||
return MsgPackParser.Parse(bytes);
|
||||
}
|
||||
public static ListTreeNode<MsgPackValue> ParseAsMsgPack(this ArraySegment<byte> bytes)
|
||||
{
|
||||
return MsgPackParser.Parse(bytes);
|
||||
}
|
||||
|
||||
public static ListTreeNode<TomlValue> ParseAsToml(this string toml)
|
||||
{
|
||||
return TomlParser.Parse(toml);
|
||||
}
|
||||
public static ListTreeNode<TomlValue> ParseAsToml(this Utf8String toml)
|
||||
{
|
||||
return TomlParser.Parse(toml);
|
||||
}
|
||||
public static ListTreeNode<TomlValue> ParseAsToml(this byte[] bytes)
|
||||
{
|
||||
return TomlParser.Parse(new Utf8String(bytes));
|
||||
}
|
||||
public static ListTreeNode<TomlValue> ParseAsToml(this ArraySegment<byte> bytes)
|
||||
{
|
||||
return TomlParser.Parse(new Utf8String(bytes));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -66,50 +66,5 @@ namespace UniJSON
|
|||
var method = typeof(FormatterExtensions).GetMethod("Serialize");
|
||||
return method.MakeGenericMethod(typeof(T));
|
||||
}
|
||||
|
||||
//
|
||||
// https://stackoverflow.com/questions/238765/given-a-type-expressiontype-memberaccess-how-do-i-get-the-field-value
|
||||
//
|
||||
public static void KeyValue<T>(this IFormatter f, Expression<Func<T>> expression)
|
||||
{
|
||||
// lambda body
|
||||
var lambdaBody = (MemberExpression)expression.Body;
|
||||
|
||||
if (lambdaBody.Expression.NodeType == ExpressionType.Constant)
|
||||
{
|
||||
//
|
||||
// KeyValue(() => Field);
|
||||
//
|
||||
var constant = (ConstantExpression)lambdaBody.Expression;
|
||||
var field = (FieldInfo)lambdaBody.Member;
|
||||
var value = field.GetValue(constant.Value);
|
||||
if (value != null)
|
||||
{
|
||||
f.Key(lambdaBody.Member.Name);
|
||||
f.Serialize(value);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
// KeyValue(() => p.Field);
|
||||
//
|
||||
var capture = (MemberExpression)lambdaBody.Expression;
|
||||
|
||||
var captureVariable = (ConstantExpression)capture.Expression;
|
||||
var captureObj = captureVariable.Value;
|
||||
var captureField = (FieldInfo)capture.Member;
|
||||
var captureValue = captureField.GetValue(captureObj);
|
||||
|
||||
var field = (FieldInfo)lambdaBody.Member;
|
||||
|
||||
var value = field.GetValue(captureValue);
|
||||
if (value != null)
|
||||
{
|
||||
f.Key(field.Name);
|
||||
f.Serialize(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,162 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
|
||||
|
||||
namespace UniJSON
|
||||
{
|
||||
public static class FormatterExtensionsSerializer
|
||||
{
|
||||
public static void SerializeDictionary(this IFormatter f, IDictionary<string, object> dictionary)
|
||||
{
|
||||
f.BeginMap(dictionary.Count);
|
||||
foreach (var kv in dictionary)
|
||||
{
|
||||
f.Key(kv.Key);
|
||||
f.SerializeObject(kv.Value);
|
||||
}
|
||||
f.EndMap();
|
||||
}
|
||||
|
||||
public static void SerializeArray<T>(this IFormatter f, IEnumerable<T> values)
|
||||
{
|
||||
f.BeginList(values.Count());
|
||||
foreach (var value in values)
|
||||
{
|
||||
f.Serialize(value);
|
||||
}
|
||||
f.EndList();
|
||||
}
|
||||
|
||||
public static void SerializeObjectArray(this IFormatter f, object[] array)
|
||||
{
|
||||
f.BeginList(array.Length);
|
||||
foreach (var x in array)
|
||||
{
|
||||
f.SerializeObject(x);
|
||||
}
|
||||
f.EndList();
|
||||
}
|
||||
|
||||
public static void SerializeObject(this IFormatter f, object value)
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
f.Null();
|
||||
}
|
||||
else
|
||||
{
|
||||
typeof(FormatterExtensionsSerializer).GetMethod("Serialize")
|
||||
.MakeGenericMethod(value.GetType()).Invoke(null, new object[] { f, value });
|
||||
}
|
||||
}
|
||||
|
||||
public static void Serialize<T>(this IFormatter f, T arg)
|
||||
{
|
||||
if (arg == null)
|
||||
{
|
||||
f.Null();
|
||||
return;
|
||||
}
|
||||
|
||||
GenericSerializer<T>.Serialize(f, arg);
|
||||
}
|
||||
|
||||
public static void SetCustomSerializer<T>(Action<IFormatter, T> serializer)
|
||||
{
|
||||
GenericSerializer<T>.Set(serializer);
|
||||
}
|
||||
|
||||
public static MethodInfo GetMethod(string name)
|
||||
{
|
||||
return typeof(FormatterExtensionsSerializer).GetMethod(name);
|
||||
}
|
||||
}
|
||||
|
||||
static class GenericSerializer<T>
|
||||
{
|
||||
delegate void Serializer(IFormatter f, T t);
|
||||
|
||||
static Action<IFormatter, T> GetSerializer()
|
||||
{
|
||||
var t = typeof(T);
|
||||
|
||||
// object
|
||||
if (typeof(T) == typeof(object) && t.GetType() != typeof(object))
|
||||
{
|
||||
var mi = FormatterExtensionsSerializer.GetMethod("SerializeObject");
|
||||
return GenericInvokeCallFactory.StaticAction<IFormatter, T>(mi);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
// primitive
|
||||
var mi = typeof(IFormatter).GetMethod("Value", new Type[] { t });
|
||||
if (mi != null)
|
||||
{
|
||||
return GenericInvokeCallFactory.OpenAction<IFormatter, T>(mi);
|
||||
}
|
||||
}
|
||||
catch (AmbiguousMatchException)
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
{
|
||||
// dictionary
|
||||
var idictionary = t.GetInterfaces().FirstOrDefault(x =>
|
||||
x.IsGenericType
|
||||
&& x.GetGenericTypeDefinition() == typeof(IDictionary<,>)
|
||||
&& x.GetGenericArguments()[0] == typeof(string)
|
||||
);
|
||||
if (idictionary != null)
|
||||
{
|
||||
var mi = FormatterExtensionsSerializer.GetMethod("SerializeDictionary");
|
||||
return GenericInvokeCallFactory.StaticAction<IFormatter, T>(mi);
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
// object[]
|
||||
if (t == typeof(object[]))
|
||||
{
|
||||
var mi = FormatterExtensionsSerializer.GetMethod("SerializeObjectArray");
|
||||
return GenericInvokeCallFactory.StaticAction<IFormatter, T>(mi);
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
// list
|
||||
var ienumerable = t.GetInterfaces().FirstOrDefault(x =>
|
||||
x.IsGenericType
|
||||
&& x.GetGenericTypeDefinition() == typeof(IEnumerable<>)
|
||||
);
|
||||
if (ienumerable != null)
|
||||
{
|
||||
var g = FormatterExtensionsSerializer.GetMethod("SerializeArray");
|
||||
var mi = g.MakeGenericMethod(ienumerable.GetGenericArguments());
|
||||
return GenericInvokeCallFactory.StaticAction<IFormatter, T>(mi);
|
||||
}
|
||||
}
|
||||
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
static Serializer s_serializer;
|
||||
|
||||
public static void Set(Action<IFormatter, T> serializer)
|
||||
{
|
||||
s_serializer = new Serializer(serializer);
|
||||
}
|
||||
|
||||
public static void Serialize(IFormatter f, T t)
|
||||
{
|
||||
if (s_serializer == null)
|
||||
{
|
||||
s_serializer = new Serializer(GetSerializer());
|
||||
}
|
||||
s_serializer(f, t);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 11342b30ed6802d4ebccbcf85663c6a0
|
||||
timeCreated: 1543520703
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 1a508fceebf4ef64ca956059360b2467
|
||||
folderAsset: yes
|
||||
timeCreated: 1548656168
|
||||
licenseType: Free
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -1,119 +0,0 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
#endif
|
||||
|
||||
|
||||
namespace UniJSON
|
||||
{
|
||||
public static partial class GenericExpressionCallFactory
|
||||
{
|
||||
#if UNITY_EDITOR && VRM_DEVELOP
|
||||
const int NET35MAX = 4;
|
||||
const int ARGS = 6;
|
||||
const string GENERATE_PATH = "UniGLTF/UniJSON/Scripts/GenericCallUtility/GenericExpressionCallFactory.g.cs";
|
||||
|
||||
static System.Collections.Generic.IEnumerable<string> GetArgs(string prefix, int n)
|
||||
{
|
||||
for (int i = 0; i < n; ++i)
|
||||
{
|
||||
yield return prefix + i;
|
||||
}
|
||||
}
|
||||
|
||||
[MenuItem("UniGLTF/UniJSON/Generate GenericExpressionCallFactory")]
|
||||
static void Generate()
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
using (var w = new StringWriter(sb))
|
||||
{
|
||||
w.WriteLine(@"
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Reflection;
|
||||
|
||||
|
||||
namespace UniJSON
|
||||
{
|
||||
public static partial class GenericExpressionCallFactory
|
||||
{
|
||||
");
|
||||
// Create
|
||||
for (int i = 1; i <= ARGS && i<NET35MAX; ++i)
|
||||
{
|
||||
var g = String.Join(", ", GetArgs("A", i).ToArray());
|
||||
var a = String.Join(", ", GetArgs("a", i).ToArray());
|
||||
|
||||
var source = @"
|
||||
public static Action<S, $0> Create<S, $0>(MethodInfo m)
|
||||
{
|
||||
var self = Expression.Parameter(m.DeclaringType, m.Name);
|
||||
var args = m.GetParameters().Select(x => Expression.Parameter(x.ParameterType, x.Name)).ToArray();
|
||||
var call = Expression.Call(self, m, args);
|
||||
return
|
||||
(Action<S, $0>)Expression.Lambda(call, new[] { self }.Concat(args).ToArray()).Compile();
|
||||
}
|
||||
".Replace("$0", g).Replace("$1", a);
|
||||
|
||||
w.WriteLine(source);
|
||||
}
|
||||
|
||||
// CreateWithThis
|
||||
for (int i = 1; i <= ARGS && i<=NET35MAX; ++i)
|
||||
{
|
||||
var g = String.Join(", ", GetArgs("A", i).ToArray());
|
||||
|
||||
var source = @"
|
||||
public static Action<$0> CreateWithThis<S, $0>(MethodInfo m, S instance)
|
||||
{
|
||||
if (m.IsStatic)
|
||||
{
|
||||
if (instance != null)
|
||||
{
|
||||
throw new ArgumentException();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (instance == null)
|
||||
{
|
||||
throw new ArgumentNullException();
|
||||
}
|
||||
}
|
||||
|
||||
var self = Expression.Constant(instance, typeof(S)); // thisを定数化
|
||||
var args = m.GetParameters().Select(x => Expression.Parameter(x.ParameterType, x.Name)).ToArray();
|
||||
MethodCallExpression call;
|
||||
if (m.IsStatic)
|
||||
{
|
||||
call = Expression.Call(m, args);
|
||||
}
|
||||
else
|
||||
{
|
||||
call = Expression.Call(self, m, args);
|
||||
}
|
||||
return
|
||||
(Action<$0>)Expression.Lambda(call, args).Compile();
|
||||
}
|
||||
".Replace("$0", g);
|
||||
|
||||
w.WriteLine(source);
|
||||
}
|
||||
|
||||
w.WriteLine(@"
|
||||
}
|
||||
}
|
||||
");
|
||||
}
|
||||
|
||||
var path = Path.GetFullPath(Application.dataPath + GENERATE_PATH).Replace("\\", "/");
|
||||
File.WriteAllText(path, sb.ToString().Replace("\r\n", "\n"));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
|
@ -1,178 +0,0 @@
|
|||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Reflection;
|
||||
|
||||
|
||||
namespace UniJSON
|
||||
{
|
||||
public static partial class GenericExpressionCallFactory
|
||||
{
|
||||
|
||||
|
||||
public static Action<S, A0> Create<S, A0>(MethodInfo m)
|
||||
{
|
||||
var self = Expression.Parameter(m.DeclaringType, m.Name);
|
||||
var args = m.GetParameters().Select(x => Expression.Parameter(x.ParameterType, x.Name)).ToArray();
|
||||
var call = Expression.Call(self, m, args);
|
||||
return
|
||||
(Action<S, A0>)Expression.Lambda(call, new[] { self }.Concat(args).ToArray()).Compile();
|
||||
}
|
||||
|
||||
|
||||
public static Action<S, A0, A1> Create<S, A0, A1>(MethodInfo m)
|
||||
{
|
||||
var self = Expression.Parameter(m.DeclaringType, m.Name);
|
||||
var args = m.GetParameters().Select(x => Expression.Parameter(x.ParameterType, x.Name)).ToArray();
|
||||
var call = Expression.Call(self, m, args);
|
||||
return
|
||||
(Action<S, A0, A1>)Expression.Lambda(call, new[] { self }.Concat(args).ToArray()).Compile();
|
||||
}
|
||||
|
||||
|
||||
public static Action<S, A0, A1, A2> Create<S, A0, A1, A2>(MethodInfo m)
|
||||
{
|
||||
var self = Expression.Parameter(m.DeclaringType, m.Name);
|
||||
var args = m.GetParameters().Select(x => Expression.Parameter(x.ParameterType, x.Name)).ToArray();
|
||||
var call = Expression.Call(self, m, args);
|
||||
return
|
||||
(Action<S, A0, A1, A2>)Expression.Lambda(call, new[] { self }.Concat(args).ToArray()).Compile();
|
||||
}
|
||||
|
||||
|
||||
public static Action<A0> CreateWithThis<S, A0>(MethodInfo m, S instance)
|
||||
{
|
||||
if (m.IsStatic)
|
||||
{
|
||||
if (instance != null)
|
||||
{
|
||||
throw new ArgumentException();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (instance == null)
|
||||
{
|
||||
throw new ArgumentNullException();
|
||||
}
|
||||
}
|
||||
|
||||
var self = Expression.Constant(instance, typeof(S)); // thisを定数化
|
||||
var args = m.GetParameters().Select(x => Expression.Parameter(x.ParameterType, x.Name)).ToArray();
|
||||
MethodCallExpression call;
|
||||
if (m.IsStatic)
|
||||
{
|
||||
call = Expression.Call(m, args);
|
||||
}
|
||||
else
|
||||
{
|
||||
call = Expression.Call(self, m, args);
|
||||
}
|
||||
return
|
||||
(Action<A0>)Expression.Lambda(call, args).Compile();
|
||||
}
|
||||
|
||||
|
||||
public static Action<A0, A1> CreateWithThis<S, A0, A1>(MethodInfo m, S instance)
|
||||
{
|
||||
if (m.IsStatic)
|
||||
{
|
||||
if (instance != null)
|
||||
{
|
||||
throw new ArgumentException();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (instance == null)
|
||||
{
|
||||
throw new ArgumentNullException();
|
||||
}
|
||||
}
|
||||
|
||||
var self = Expression.Constant(instance, typeof(S)); // thisを定数化
|
||||
var args = m.GetParameters().Select(x => Expression.Parameter(x.ParameterType, x.Name)).ToArray();
|
||||
MethodCallExpression call;
|
||||
if (m.IsStatic)
|
||||
{
|
||||
call = Expression.Call(m, args);
|
||||
}
|
||||
else
|
||||
{
|
||||
call = Expression.Call(self, m, args);
|
||||
}
|
||||
return
|
||||
(Action<A0, A1>)Expression.Lambda(call, args).Compile();
|
||||
}
|
||||
|
||||
|
||||
public static Action<A0, A1, A2> CreateWithThis<S, A0, A1, A2>(MethodInfo m, S instance)
|
||||
{
|
||||
if (m.IsStatic)
|
||||
{
|
||||
if (instance != null)
|
||||
{
|
||||
throw new ArgumentException();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (instance == null)
|
||||
{
|
||||
throw new ArgumentNullException();
|
||||
}
|
||||
}
|
||||
|
||||
var self = Expression.Constant(instance, typeof(S)); // thisを定数化
|
||||
var args = m.GetParameters().Select(x => Expression.Parameter(x.ParameterType, x.Name)).ToArray();
|
||||
MethodCallExpression call;
|
||||
if (m.IsStatic)
|
||||
{
|
||||
call = Expression.Call(m, args);
|
||||
}
|
||||
else
|
||||
{
|
||||
call = Expression.Call(self, m, args);
|
||||
}
|
||||
return
|
||||
(Action<A0, A1, A2>)Expression.Lambda(call, args).Compile();
|
||||
}
|
||||
|
||||
|
||||
public static Action<A0, A1, A2, A3> CreateWithThis<S, A0, A1, A2, A3>(MethodInfo m, S instance)
|
||||
{
|
||||
if (m.IsStatic)
|
||||
{
|
||||
if (instance != null)
|
||||
{
|
||||
throw new ArgumentException();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (instance == null)
|
||||
{
|
||||
throw new ArgumentNullException();
|
||||
}
|
||||
}
|
||||
|
||||
var self = Expression.Constant(instance, typeof(S)); // thisを定数化
|
||||
var args = m.GetParameters().Select(x => Expression.Parameter(x.ParameterType, x.Name)).ToArray();
|
||||
MethodCallExpression call;
|
||||
if (m.IsStatic)
|
||||
{
|
||||
call = Expression.Call(m, args);
|
||||
}
|
||||
else
|
||||
{
|
||||
call = Expression.Call(self, m, args);
|
||||
}
|
||||
return
|
||||
(Action<A0, A1, A2, A3>)Expression.Lambda(call, args).Compile();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: cf88d89ec3acdbf4eb44842ed15aaff4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -1,274 +0,0 @@
|
|||
using System;
|
||||
using System.Reflection;
|
||||
#if UNITY_EDITOR && VRM_DEVELOP
|
||||
using UnityEngine;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using UnityEditor;
|
||||
#endif
|
||||
|
||||
|
||||
namespace UniJSON
|
||||
{
|
||||
/// <summary>
|
||||
/// MethodInfoからDelegateを作成する
|
||||
///
|
||||
/// * StaticAction/Func StaticMethod呼び出し
|
||||
/// * OpenAction/Func 第1引数にthisを受けるメソッド呼び出し
|
||||
/// * BindAction/Func thisを内部に保持したメソッド呼び出し
|
||||
///
|
||||
/// </summary>
|
||||
public static partial class GenericInvokeCallFactory
|
||||
{
|
||||
#if UNITY_EDITOR && VRM_DEVELOP
|
||||
const int NET35MAX = 4;
|
||||
const int ARGS = 6;
|
||||
const string GENERATE_PATH = "/UniGLTF/UniJSON/Scripts/GenericCallUtility/GenericInvokeCallFactory.g.cs";
|
||||
|
||||
static System.Collections.Generic.IEnumerable<string> GetArgs(string prefix, int n)
|
||||
{
|
||||
for (int i = 0; i < n; ++i)
|
||||
{
|
||||
yield return prefix + i;
|
||||
}
|
||||
}
|
||||
|
||||
[MenuItem("UniGLTF/UniJSON/Generate GenericInvokeCallFactory")]
|
||||
static void Generate()
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
using (var w = new StringWriter(sb))
|
||||
{
|
||||
w.WriteLine(@"
|
||||
using System;
|
||||
using System.Reflection;
|
||||
|
||||
|
||||
namespace UniJSON
|
||||
{
|
||||
public static partial class GenericInvokeCallFactory
|
||||
{
|
||||
");
|
||||
|
||||
// StaticAction
|
||||
w.WriteLine("//////////// StaticAction");
|
||||
for (int i = 1; i <= ARGS && i <= NET35MAX; ++i)
|
||||
{
|
||||
var g = String.Join(", ", GetArgs("A", i).ToArray());
|
||||
var a = String.Join(", ", GetArgs("a", i).ToArray());
|
||||
|
||||
var source = @"
|
||||
public static Action<$0> StaticAction<$0>(MethodInfo m)
|
||||
{
|
||||
if (!m.IsStatic)
|
||||
{
|
||||
throw new ArgumentException(string.Format(""{0} is not static"", m));
|
||||
}
|
||||
|
||||
return (Action<$0>)Delegate.CreateDelegate(typeof(Action<$0>), null, m);
|
||||
}
|
||||
".Replace("$0", g).Replace("$1", a);
|
||||
|
||||
w.WriteLine(source);
|
||||
|
||||
}
|
||||
|
||||
// OpenAction
|
||||
w.WriteLine("//////////// OpenAction");
|
||||
for (int i = 1; i <= ARGS && i < NET35MAX; ++i)
|
||||
{
|
||||
var g = String.Join(", ", GetArgs("A", i).ToArray());
|
||||
var a = String.Join(", ", GetArgs("a", i).ToArray());
|
||||
|
||||
var source = @"
|
||||
public static Action<S, $0> OpenAction<S, $0>(MethodInfo m)
|
||||
{
|
||||
if (m.IsStatic)
|
||||
{
|
||||
throw new ArgumentException(string.Format(""{0} is static"", m));
|
||||
}
|
||||
|
||||
return (Action<S, $0>)Delegate.CreateDelegate(typeof(Action<S, $0>), m);
|
||||
}
|
||||
".Replace("$0", g).Replace("$1", a);
|
||||
|
||||
w.WriteLine(source);
|
||||
|
||||
}
|
||||
|
||||
// BindAction
|
||||
w.WriteLine("//////////// BindAction");
|
||||
for (int i = 1; i <= ARGS && i <= NET35MAX; ++i)
|
||||
{
|
||||
var g = String.Join(", ", GetArgs("A", i).ToArray());
|
||||
var a = String.Join(", ", GetArgs("a", i).ToArray());
|
||||
|
||||
var source = @"
|
||||
public static Action<$0> BindAction<S, $0>(MethodInfo m, S instance)
|
||||
{
|
||||
if (m.IsStatic)
|
||||
{
|
||||
throw new ArgumentException(string.Format(""{0} is static"", m));
|
||||
}
|
||||
|
||||
return (Action<$0>)Delegate.CreateDelegate(typeof(Action<$0>), instance, m);
|
||||
}
|
||||
".Replace("$0", g).Replace("$1", a);
|
||||
|
||||
w.WriteLine(source);
|
||||
|
||||
}
|
||||
|
||||
// StaticFunc
|
||||
w.WriteLine("//////////// StaticFunc");
|
||||
for (int i = 1; i <= ARGS && i <= NET35MAX; ++i)
|
||||
{
|
||||
var g = String.Join(", ", GetArgs("A", i).ToArray());
|
||||
var a = String.Join(", ", GetArgs("a", i).ToArray());
|
||||
|
||||
var source = @"
|
||||
public static Func<$0, T> StaticFunc<$0, T>(MethodInfo m)
|
||||
{
|
||||
if (!m.IsStatic)
|
||||
{
|
||||
throw new ArgumentException(string.Format(""{0} is not static"", m));
|
||||
}
|
||||
|
||||
return (Func<$0, T>)Delegate.CreateDelegate(typeof(Func<$0, T>), null, m);
|
||||
}
|
||||
".Replace("$0", g).Replace("$1", a);
|
||||
|
||||
w.WriteLine(source);
|
||||
|
||||
}
|
||||
|
||||
// OpenFunc
|
||||
w.WriteLine("//////////// OpenFunc");
|
||||
for (int i = 1; i <= ARGS && i < NET35MAX; ++i)
|
||||
{
|
||||
var g = String.Join(", ", GetArgs("A", i).ToArray());
|
||||
var a = String.Join(", ", GetArgs("a", i).ToArray());
|
||||
|
||||
var source = @"
|
||||
public static Func<S, $0, T> OpenFunc<S, $0, T>(MethodInfo m)
|
||||
{
|
||||
if (m.IsStatic)
|
||||
{
|
||||
throw new ArgumentException(string.Format(""{0} is static"", m));
|
||||
}
|
||||
|
||||
return (Func<S, $0, T>)Delegate.CreateDelegate(typeof(Func<S, $0, T>), m);
|
||||
}
|
||||
".Replace("$0", g).Replace("$1", a);
|
||||
|
||||
w.WriteLine(source);
|
||||
|
||||
}
|
||||
|
||||
// BindFunc
|
||||
w.WriteLine("//////////// BindFunc");
|
||||
for (int i = 1; i <= ARGS && i <= NET35MAX; ++i)
|
||||
{
|
||||
var g = String.Join(", ", GetArgs("A", i).ToArray());
|
||||
var a = String.Join(", ", GetArgs("a", i).ToArray());
|
||||
|
||||
var source = @"
|
||||
public static Func<$0, T> BindFunc<S, $0, T>(MethodInfo m, S instance)
|
||||
{
|
||||
if (m.IsStatic)
|
||||
{
|
||||
throw new ArgumentException(string.Format(""{0} is static"", m));
|
||||
}
|
||||
|
||||
return (Func<$0, T>)Delegate.CreateDelegate(typeof(Func<$0, T>), instance, m);
|
||||
}
|
||||
".Replace("$0", g).Replace("$1", a);
|
||||
|
||||
w.WriteLine(source);
|
||||
|
||||
}
|
||||
|
||||
|
||||
w.WriteLine(@"
|
||||
}
|
||||
}
|
||||
");
|
||||
}
|
||||
|
||||
var path = Path.GetFullPath(Application.dataPath + GENERATE_PATH).Replace("\\", "/");
|
||||
File.WriteAllText(path, sb.ToString().Replace("\r\n", "\n"));
|
||||
}
|
||||
#endif
|
||||
|
||||
#region Action without arguments
|
||||
public static Action StaticAction(MethodInfo m)
|
||||
{
|
||||
if (!m.IsStatic)
|
||||
{
|
||||
throw new ArgumentException(string.Format("{0} is not static", m));
|
||||
}
|
||||
|
||||
return (Action)Delegate.CreateDelegate(typeof(Action), null, m);
|
||||
}
|
||||
|
||||
public static Action<S> OpenAction<S>(MethodInfo m)
|
||||
{
|
||||
if (m.IsStatic)
|
||||
{
|
||||
throw new ArgumentException(string.Format("{0} is static", m));
|
||||
}
|
||||
|
||||
return (s) =>
|
||||
{
|
||||
m.Invoke(s, new object[] { });
|
||||
};
|
||||
}
|
||||
|
||||
public static Action BindAction<S>(MethodInfo m, S instance)
|
||||
{
|
||||
if (m.IsStatic)
|
||||
{
|
||||
throw new ArgumentException(string.Format("{0} is static", m));
|
||||
}
|
||||
|
||||
return () =>
|
||||
{
|
||||
m.Invoke(instance, new object[] { });
|
||||
};
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Func without arguments
|
||||
public static Func<T> StaticFunc<T>(MethodInfo m)
|
||||
{
|
||||
if (!m.IsStatic)
|
||||
{
|
||||
throw new ArgumentException(string.Format("{0} is not static", m));
|
||||
}
|
||||
|
||||
return () => (T)m.Invoke(null, new object[] { });
|
||||
}
|
||||
|
||||
public static Func<S, T> OpenFunc<S, T>(MethodInfo m)
|
||||
{
|
||||
if (m.IsStatic)
|
||||
{
|
||||
throw new ArgumentException(string.Format("{0} is static", m));
|
||||
}
|
||||
|
||||
return (s) => (T)m.Invoke(s, new object[] { });
|
||||
}
|
||||
|
||||
public static Func<T> BindFunc<S, T>(MethodInfo m, S instance)
|
||||
{
|
||||
if (m.IsStatic)
|
||||
{
|
||||
throw new ArgumentException(string.Format("{0} is static", m));
|
||||
}
|
||||
|
||||
return () => (T)m.Invoke(instance, new object[] { });
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: b4bdb47bf29e1214a9e3da9b4ae9f31e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -1,262 +0,0 @@
|
|||
|
||||
using System;
|
||||
using System.Reflection;
|
||||
|
||||
|
||||
namespace UniJSON
|
||||
{
|
||||
public static partial class GenericInvokeCallFactory
|
||||
{
|
||||
|
||||
//////////// StaticAction
|
||||
|
||||
public static Action<A0> StaticAction<A0>(MethodInfo m)
|
||||
{
|
||||
if (!m.IsStatic)
|
||||
{
|
||||
throw new ArgumentException(string.Format("{0} is not static", m));
|
||||
}
|
||||
|
||||
return (Action<A0>)Delegate.CreateDelegate(typeof(Action<A0>), null, m);
|
||||
}
|
||||
|
||||
|
||||
public static Action<A0, A1> StaticAction<A0, A1>(MethodInfo m)
|
||||
{
|
||||
if (!m.IsStatic)
|
||||
{
|
||||
throw new ArgumentException(string.Format("{0} is not static", m));
|
||||
}
|
||||
|
||||
return (Action<A0, A1>)Delegate.CreateDelegate(typeof(Action<A0, A1>), null, m);
|
||||
}
|
||||
|
||||
|
||||
public static Action<A0, A1, A2> StaticAction<A0, A1, A2>(MethodInfo m)
|
||||
{
|
||||
if (!m.IsStatic)
|
||||
{
|
||||
throw new ArgumentException(string.Format("{0} is not static", m));
|
||||
}
|
||||
|
||||
return (Action<A0, A1, A2>)Delegate.CreateDelegate(typeof(Action<A0, A1, A2>), null, m);
|
||||
}
|
||||
|
||||
|
||||
public static Action<A0, A1, A2, A3> StaticAction<A0, A1, A2, A3>(MethodInfo m)
|
||||
{
|
||||
if (!m.IsStatic)
|
||||
{
|
||||
throw new ArgumentException(string.Format("{0} is not static", m));
|
||||
}
|
||||
|
||||
return (Action<A0, A1, A2, A3>)Delegate.CreateDelegate(typeof(Action<A0, A1, A2, A3>), null, m);
|
||||
}
|
||||
|
||||
//////////// OpenAction
|
||||
|
||||
public static Action<S, A0> OpenAction<S, A0>(MethodInfo m)
|
||||
{
|
||||
if (m.IsStatic)
|
||||
{
|
||||
throw new ArgumentException(string.Format("{0} is static", m));
|
||||
}
|
||||
|
||||
return (Action<S, A0>)Delegate.CreateDelegate(typeof(Action<S, A0>), m);
|
||||
}
|
||||
|
||||
|
||||
public static Action<S, A0, A1> OpenAction<S, A0, A1>(MethodInfo m)
|
||||
{
|
||||
if (m.IsStatic)
|
||||
{
|
||||
throw new ArgumentException(string.Format("{0} is static", m));
|
||||
}
|
||||
|
||||
return (Action<S, A0, A1>)Delegate.CreateDelegate(typeof(Action<S, A0, A1>), m);
|
||||
}
|
||||
|
||||
|
||||
public static Action<S, A0, A1, A2> OpenAction<S, A0, A1, A2>(MethodInfo m)
|
||||
{
|
||||
if (m.IsStatic)
|
||||
{
|
||||
throw new ArgumentException(string.Format("{0} is static", m));
|
||||
}
|
||||
|
||||
return (Action<S, A0, A1, A2>)Delegate.CreateDelegate(typeof(Action<S, A0, A1, A2>), m);
|
||||
}
|
||||
|
||||
//////////// BindAction
|
||||
|
||||
public static Action<A0> BindAction<S, A0>(MethodInfo m, S instance)
|
||||
{
|
||||
if (m.IsStatic)
|
||||
{
|
||||
throw new ArgumentException(string.Format("{0} is static", m));
|
||||
}
|
||||
|
||||
return (Action<A0>)Delegate.CreateDelegate(typeof(Action<A0>), instance, m);
|
||||
}
|
||||
|
||||
|
||||
public static Action<A0, A1> BindAction<S, A0, A1>(MethodInfo m, S instance)
|
||||
{
|
||||
if (m.IsStatic)
|
||||
{
|
||||
throw new ArgumentException(string.Format("{0} is static", m));
|
||||
}
|
||||
|
||||
return (Action<A0, A1>)Delegate.CreateDelegate(typeof(Action<A0, A1>), instance, m);
|
||||
}
|
||||
|
||||
|
||||
public static Action<A0, A1, A2> BindAction<S, A0, A1, A2>(MethodInfo m, S instance)
|
||||
{
|
||||
if (m.IsStatic)
|
||||
{
|
||||
throw new ArgumentException(string.Format("{0} is static", m));
|
||||
}
|
||||
|
||||
return (Action<A0, A1, A2>)Delegate.CreateDelegate(typeof(Action<A0, A1, A2>), instance, m);
|
||||
}
|
||||
|
||||
|
||||
public static Action<A0, A1, A2, A3> BindAction<S, A0, A1, A2, A3>(MethodInfo m, S instance)
|
||||
{
|
||||
if (m.IsStatic)
|
||||
{
|
||||
throw new ArgumentException(string.Format("{0} is static", m));
|
||||
}
|
||||
|
||||
return (Action<A0, A1, A2, A3>)Delegate.CreateDelegate(typeof(Action<A0, A1, A2, A3>), instance, m);
|
||||
}
|
||||
|
||||
//////////// StaticFunc
|
||||
|
||||
public static Func<A0, T> StaticFunc<A0, T>(MethodInfo m)
|
||||
{
|
||||
if (!m.IsStatic)
|
||||
{
|
||||
throw new ArgumentException(string.Format("{0} is not static", m));
|
||||
}
|
||||
|
||||
return (a0) => (T)m.Invoke(null, new object[] { a0 });
|
||||
}
|
||||
|
||||
|
||||
public static Func<A0, A1, T> StaticFunc<A0, A1, T>(MethodInfo m)
|
||||
{
|
||||
if (!m.IsStatic)
|
||||
{
|
||||
throw new ArgumentException(string.Format("{0} is not static", m));
|
||||
}
|
||||
|
||||
return (a0, a1) => (T)m.Invoke(null, new object[] { a0, a1 });
|
||||
}
|
||||
|
||||
|
||||
public static Func<A0, A1, A2, T> StaticFunc<A0, A1, A2, T>(MethodInfo m)
|
||||
{
|
||||
if (!m.IsStatic)
|
||||
{
|
||||
throw new ArgumentException(string.Format("{0} is not static", m));
|
||||
}
|
||||
|
||||
return (a0, a1, a2) => (T)m.Invoke(null, new object[] { a0, a1, a2 });
|
||||
}
|
||||
|
||||
|
||||
public static Func<A0, A1, A2, A3, T> StaticFunc<A0, A1, A2, A3, T>(MethodInfo m)
|
||||
{
|
||||
if (!m.IsStatic)
|
||||
{
|
||||
throw new ArgumentException(string.Format("{0} is not static", m));
|
||||
}
|
||||
|
||||
return (a0, a1, a2, a3) => (T)m.Invoke(null, new object[] { a0, a1, a2, a3 });
|
||||
}
|
||||
|
||||
//////////// OpenFunc
|
||||
|
||||
public static Func<S, A0, T> OpenFunc<S, A0, T>(MethodInfo m)
|
||||
{
|
||||
if (m.IsStatic)
|
||||
{
|
||||
throw new ArgumentException(string.Format("{0} is static", m));
|
||||
}
|
||||
|
||||
return (s, a0) => (T)m.Invoke(s, new object[] { a0 });
|
||||
}
|
||||
|
||||
|
||||
public static Func<S, A0, A1, T> OpenFunc<S, A0, A1, T>(MethodInfo m)
|
||||
{
|
||||
if (m.IsStatic)
|
||||
{
|
||||
throw new ArgumentException(string.Format("{0} is static", m));
|
||||
}
|
||||
|
||||
return (s, a0, a1) => (T)m.Invoke(s, new object[] { a0, a1 });
|
||||
}
|
||||
|
||||
|
||||
public static Func<S, A0, A1, A2, T> OpenFunc<S, A0, A1, A2, T>(MethodInfo m)
|
||||
{
|
||||
if (m.IsStatic)
|
||||
{
|
||||
throw new ArgumentException(string.Format("{0} is static", m));
|
||||
}
|
||||
|
||||
return (s, a0, a1, a2) => (T)m.Invoke(s, new object[] { a0, a1, a2 });
|
||||
}
|
||||
|
||||
//////////// BindFunc
|
||||
|
||||
public static Func<A0, T> BindFunc<S, A0, T>(MethodInfo m, S instance)
|
||||
{
|
||||
if (m.IsStatic)
|
||||
{
|
||||
throw new ArgumentException(string.Format("{0} is static", m));
|
||||
}
|
||||
|
||||
return (a0) => (T)m.Invoke(instance, new object[] { a0 });
|
||||
}
|
||||
|
||||
|
||||
public static Func<A0, A1, T> BindFunc<S, A0, A1, T>(MethodInfo m, S instance)
|
||||
{
|
||||
if (m.IsStatic)
|
||||
{
|
||||
throw new ArgumentException(string.Format("{0} is static", m));
|
||||
}
|
||||
|
||||
return (a0, a1) => (T)m.Invoke(instance, new object[] { a0, a1 });
|
||||
}
|
||||
|
||||
|
||||
public static Func<A0, A1, A2, T> BindFunc<S, A0, A1, A2, T>(MethodInfo m, S instance)
|
||||
{
|
||||
if (m.IsStatic)
|
||||
{
|
||||
throw new ArgumentException(string.Format("{0} is static", m));
|
||||
}
|
||||
|
||||
return (a0, a1, a2) => (T)m.Invoke(instance, new object[] { a0, a1, a2 });
|
||||
}
|
||||
|
||||
|
||||
public static Func<A0, A1, A2, A3, T> BindFunc<S, A0, A1, A2, A3, T>(MethodInfo m, S instance)
|
||||
{
|
||||
if (m.IsStatic)
|
||||
{
|
||||
throw new ArgumentException(string.Format("{0} is static", m));
|
||||
}
|
||||
|
||||
return (a0, a1, a2, a3) => (T)m.Invoke(instance, new object[] { a0, a1, a2, a3 });
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 56dfdc21f4d594143ab023e6bd171f91
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -1,72 +0,0 @@
|
|||
using System;
|
||||
|
||||
|
||||
namespace UniJSON
|
||||
{
|
||||
struct GenericCast<S, T>
|
||||
{
|
||||
public static T Null()
|
||||
{
|
||||
if (typeof(T).IsClass)
|
||||
{
|
||||
return default(T);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new MsgPackTypeException("can not null");
|
||||
}
|
||||
}
|
||||
|
||||
delegate T CastFunc(S value);
|
||||
static CastFunc s_cast;
|
||||
|
||||
delegate Func<T> ConstFuncCreator(S value);
|
||||
static ConstFuncCreator s_const;
|
||||
|
||||
public static Func<T> Const(S value)
|
||||
{
|
||||
if (s_const == null)
|
||||
{
|
||||
s_const = new ConstFuncCreator(GenericCast.CreateConst<S, T>());
|
||||
}
|
||||
return s_const(value);
|
||||
}
|
||||
|
||||
public static T Cast(S value)
|
||||
{
|
||||
if (s_cast == null)
|
||||
{
|
||||
s_cast = new CastFunc(GenericCast.CreateCast<S, T>());
|
||||
}
|
||||
return s_cast(value);
|
||||
}
|
||||
}
|
||||
|
||||
static partial class GenericCast
|
||||
{
|
||||
public static Func<S, T> CreateCast<S, T>()
|
||||
{
|
||||
var mi = ConcreteCast.GetMethod(typeof(S), typeof(T));
|
||||
if (mi == null)
|
||||
{
|
||||
return (Func<S, T>)((S s) =>
|
||||
{
|
||||
return (T)(object)s;
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
return GenericInvokeCallFactory.StaticFunc<S, T>(mi);
|
||||
}
|
||||
}
|
||||
|
||||
public static Func<S, Func<T>> CreateConst<S, T>()
|
||||
{
|
||||
var cast = CreateCast<S, T>();
|
||||
return (Func<S, Func<T>>)((S s) =>
|
||||
{
|
||||
return (Func<T>)(() => cast(s));
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 5e1cb5b0419b4a04da69e90f4890c349
|
||||
timeCreated: 1545134074
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -1,53 +0,0 @@
|
|||
using System;
|
||||
using System.Reflection;
|
||||
|
||||
|
||||
namespace UniJSON
|
||||
{
|
||||
struct GenericConstructor<T, U>
|
||||
where T : IListTreeItem, IValue<T>
|
||||
{
|
||||
static V[] ArrayCreator<V>(ListTreeNode<T> src)
|
||||
{
|
||||
if (!src.IsArray())
|
||||
{
|
||||
throw new ArgumentException("value is not array");
|
||||
}
|
||||
var count = src.GetArrayCount();
|
||||
return new V[count];
|
||||
}
|
||||
|
||||
static Func<ListTreeNode<T>, U> GetCreator()
|
||||
{
|
||||
var t = typeof(U);
|
||||
if (t.IsArray)
|
||||
{
|
||||
var mi = typeof(GenericConstructor<T, U>).GetMethod("ArrayCreator",
|
||||
BindingFlags.NonPublic | BindingFlags.Static);
|
||||
var g = mi.MakeGenericMethod(t.GetElementType());
|
||||
return GenericInvokeCallFactory.StaticFunc<ListTreeNode<T>, U>(g);
|
||||
}
|
||||
|
||||
{
|
||||
return _s =>
|
||||
{
|
||||
return Activator.CreateInstance<U>();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
delegate U Creator(ListTreeNode<T> src);
|
||||
|
||||
static Creator s_creator;
|
||||
|
||||
public U Create(ListTreeNode<T> src)
|
||||
{
|
||||
if (s_creator == null)
|
||||
{
|
||||
var d = GetCreator();
|
||||
s_creator = new Creator(d);
|
||||
}
|
||||
return s_creator(src);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 6121925cab5acc54bbb0e0e213783394
|
||||
timeCreated: 1549447177
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
|
||||
namespace UniJSON
|
||||
{
|
||||
public interface ITreeNode<T, U>
|
||||
where T : ITreeNode<T, U>
|
||||
{
|
||||
bool IsValid { get; }
|
||||
|
||||
bool HasParent { get; }
|
||||
T Parent { get; }
|
||||
IEnumerable<T> Children { get; }
|
||||
|
||||
int ValueIndex { get; }
|
||||
U Value { get; }
|
||||
void SetValue(U value);
|
||||
}
|
||||
|
||||
public interface IListTreeItem
|
||||
{
|
||||
int ParentIndex { get; }
|
||||
int ChildCount { get; }
|
||||
void SetChildCount(int count);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: baf3ade828d6e4c429d402b486911774
|
||||
timeCreated: 1545735557
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -1,43 +0,0 @@
|
|||
using System;
|
||||
|
||||
|
||||
namespace UniJSON
|
||||
{
|
||||
public enum ValueNodeType
|
||||
{
|
||||
Null,
|
||||
Boolean,
|
||||
String,
|
||||
Binary,
|
||||
Integer,
|
||||
Number,
|
||||
Array,
|
||||
Object,
|
||||
NaN,
|
||||
Infinity,
|
||||
MinusInfinity,
|
||||
}
|
||||
|
||||
public interface IValue<T>
|
||||
{
|
||||
T New(ArraySegment<byte> bytes, ValueNodeType valueType, int parentIndex);
|
||||
T Key(Utf8String key, int parentIndex);
|
||||
ValueNodeType ValueType { get; }
|
||||
ArraySegment<Byte> Bytes { get; }
|
||||
void SetBytesCount(int count);
|
||||
Boolean GetBoolean();
|
||||
String GetString();
|
||||
Utf8String GetUtf8String();
|
||||
SByte GetSByte();
|
||||
Int16 GetInt16();
|
||||
Int32 GetInt32();
|
||||
Int64 GetInt64();
|
||||
Byte GetByte();
|
||||
UInt16 GetUInt16();
|
||||
UInt32 GetUInt32();
|
||||
UInt64 GetUInt64();
|
||||
Single GetSingle();
|
||||
Double GetDouble();
|
||||
U GetValue<U>();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 4737055a37e47074e92e6fc03a96a9a5
|
||||
timeCreated: 1545735557
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -15,8 +15,7 @@ namespace UniJSON
|
|||
public JsonDiffType DiffType;
|
||||
public string Msg;
|
||||
|
||||
public static JsonDiff Create<T>(ListTreeNode<T> node, JsonDiffType diffType, string msg)
|
||||
where T: IListTreeItem, IValue<T>
|
||||
public static JsonDiff Create(JsonNode node, JsonDiffType diffType, string msg)
|
||||
{
|
||||
return new JsonDiff
|
||||
{
|
||||
|
|
|
|||
|
|
@ -278,275 +278,10 @@ namespace UniJSON
|
|||
Value(x.ToString("yyyy-MM-ddTHH:mm:ssZ"));
|
||||
}
|
||||
|
||||
public void Value(ListTreeNode<JsonValue> node)
|
||||
public void Value(JsonNode node)
|
||||
{
|
||||
CommaCheck();
|
||||
m_w.Write(node.Value.Bytes);
|
||||
}
|
||||
|
||||
#region IRpc
|
||||
int m_nextRequestId = 1;
|
||||
|
||||
static Utf8String s_jsonrpc = Utf8String.From("jsonrpc");
|
||||
static Utf8String s_20 = Utf8String.From("2.0");
|
||||
static Utf8String s_method = Utf8String.From("method");
|
||||
static Utf8String s_params = Utf8String.From("params");
|
||||
|
||||
public void Notify(Utf8String method)
|
||||
{
|
||||
BeginMap();
|
||||
Key(s_jsonrpc); Value(s_20);
|
||||
Key(s_method); Value(method);
|
||||
Key(s_params); BeginList();
|
||||
{
|
||||
}
|
||||
EndList();
|
||||
EndMap();
|
||||
}
|
||||
|
||||
public void Notify<A0>(Utf8String method, A0 a0)
|
||||
{
|
||||
BeginMap();
|
||||
Key(s_jsonrpc); Value(s_20);
|
||||
Key(s_method); Value(method);
|
||||
Key(s_params); BeginList();
|
||||
{
|
||||
this.Serialize(a0);
|
||||
}
|
||||
EndList();
|
||||
EndMap();
|
||||
}
|
||||
|
||||
public void Notify<A0, A1>(Utf8String method, A0 a0, A1 a1)
|
||||
{
|
||||
BeginMap();
|
||||
Key(s_jsonrpc); Value(s_20);
|
||||
Key(s_method); Value(method);
|
||||
Key(s_params); BeginList();
|
||||
{
|
||||
this.Serialize(a0);
|
||||
this.Serialize(a1);
|
||||
}
|
||||
EndList();
|
||||
EndMap();
|
||||
}
|
||||
|
||||
public void Notify<A0, A1, A2>(Utf8String method, A0 a0, A1 a1, A2 a2)
|
||||
{
|
||||
BeginMap();
|
||||
Key(s_jsonrpc); Value(s_20);
|
||||
Key(s_method); Value(method);
|
||||
Key(s_params); BeginList();
|
||||
{
|
||||
this.Serialize(a0);
|
||||
this.Serialize(a1);
|
||||
this.Serialize(a2);
|
||||
}
|
||||
EndList();
|
||||
EndMap();
|
||||
}
|
||||
|
||||
public void Notify<A0, A1, A2, A3>(Utf8String method, A0 a0, A1 a1, A2 a2, A3 a3)
|
||||
{
|
||||
BeginMap();
|
||||
Key(s_jsonrpc); Value(s_20);
|
||||
Key(s_method); Value(method);
|
||||
Key(s_params); BeginList();
|
||||
{
|
||||
this.Serialize(a0);
|
||||
this.Serialize(a1);
|
||||
this.Serialize(a2);
|
||||
this.Serialize(a3);
|
||||
}
|
||||
EndList();
|
||||
EndMap();
|
||||
}
|
||||
|
||||
public void Notify<A0, A1, A2, A3, A4>(Utf8String method, A0 a0, A1 a1, A2 a2, A3 a3, A4 a4)
|
||||
{
|
||||
BeginMap();
|
||||
Key(s_jsonrpc); Value(s_20);
|
||||
Key(s_method); Value(method);
|
||||
Key(s_params); BeginList();
|
||||
{
|
||||
this.Serialize(a0);
|
||||
this.Serialize(a1);
|
||||
this.Serialize(a2);
|
||||
this.Serialize(a3);
|
||||
this.Serialize(a4);
|
||||
}
|
||||
EndList();
|
||||
EndMap();
|
||||
}
|
||||
|
||||
public void Notify<A0, A1, A2, A3, A4, A5>(Utf8String method, A0 a0, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5)
|
||||
{
|
||||
BeginMap();
|
||||
Key(s_jsonrpc); Value(s_20);
|
||||
Key(s_method); Value(method);
|
||||
Key(s_params); BeginList();
|
||||
{
|
||||
this.Serialize(a0);
|
||||
this.Serialize(a1);
|
||||
this.Serialize(a2);
|
||||
this.Serialize(a3);
|
||||
this.Serialize(a4);
|
||||
this.Serialize(a5);
|
||||
}
|
||||
EndList();
|
||||
EndMap();
|
||||
}
|
||||
|
||||
static Utf8String s_id = Utf8String.From("id");
|
||||
|
||||
public void Request(Utf8String method)
|
||||
{
|
||||
BeginMap();
|
||||
Key(s_jsonrpc); Value(s_20);
|
||||
Key(s_id); Value(m_nextRequestId++);
|
||||
Key(s_method); Value(method);
|
||||
Key(s_params); BeginList();
|
||||
{
|
||||
}
|
||||
EndList();
|
||||
EndMap();
|
||||
}
|
||||
|
||||
public void Request<A0>(Utf8String method,
|
||||
A0 a0)
|
||||
{
|
||||
BeginMap();
|
||||
Key(s_jsonrpc); Value(s_20);
|
||||
Key(s_id); Value(m_nextRequestId++);
|
||||
Key(s_method); Value(method);
|
||||
Key(s_params); BeginList();
|
||||
{
|
||||
this.Serialize(a0);
|
||||
}
|
||||
EndList();
|
||||
EndMap();
|
||||
}
|
||||
|
||||
public void Request<A0, A1>(Utf8String method,
|
||||
A0 a0, A1 a1)
|
||||
{
|
||||
BeginMap();
|
||||
Key(s_jsonrpc); Value(s_20);
|
||||
Key(s_id); Value(m_nextRequestId++);
|
||||
Key(s_method); Value(method);
|
||||
Key(s_params); BeginList();
|
||||
{
|
||||
this.Serialize(a0);
|
||||
this.Serialize(a1);
|
||||
}
|
||||
EndList();
|
||||
EndMap();
|
||||
}
|
||||
|
||||
public void Request<A0, A1, A2>(Utf8String method,
|
||||
A0 a0, A1 a1, A2 a2)
|
||||
{
|
||||
BeginMap();
|
||||
Key(s_jsonrpc); Value(s_20);
|
||||
Key(s_id); Value(m_nextRequestId++);
|
||||
Key(s_method); Value(method);
|
||||
Key(s_params); BeginList();
|
||||
{
|
||||
this.Serialize(a0);
|
||||
this.Serialize(a1);
|
||||
this.Serialize(a2);
|
||||
}
|
||||
EndList();
|
||||
EndMap();
|
||||
}
|
||||
|
||||
public void Request<A0, A1, A2, A3>(Utf8String method,
|
||||
A0 a0, A1 a1, A2 a2, A3 a3)
|
||||
{
|
||||
BeginMap();
|
||||
Key(s_jsonrpc); Value(s_20);
|
||||
Key(s_id); Value(m_nextRequestId++);
|
||||
Key(s_method); Value(method);
|
||||
Key(s_params); BeginList();
|
||||
{
|
||||
this.Serialize(a0);
|
||||
this.Serialize(a1);
|
||||
this.Serialize(a2);
|
||||
this.Serialize(a3);
|
||||
}
|
||||
EndList();
|
||||
EndMap();
|
||||
}
|
||||
|
||||
public void Request<A0, A1, A2, A3, A4>(Utf8String method,
|
||||
A0 a0, A1 a1, A2 a2, A3 a3, A4 a4)
|
||||
{
|
||||
BeginMap();
|
||||
Key(s_jsonrpc); Value(s_20);
|
||||
Key(s_id); Value(m_nextRequestId++);
|
||||
Key(s_method); Value(method);
|
||||
Key(s_params); BeginList();
|
||||
{
|
||||
this.Serialize(a0);
|
||||
this.Serialize(a1);
|
||||
this.Serialize(a2);
|
||||
this.Serialize(a3);
|
||||
this.Serialize(a4);
|
||||
}
|
||||
EndList();
|
||||
EndMap();
|
||||
}
|
||||
|
||||
public void Request<A0, A1, A2, A3, A4, A5>(Utf8String method,
|
||||
A0 a0, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5)
|
||||
{
|
||||
BeginMap();
|
||||
Key(s_jsonrpc); Value(s_20);
|
||||
Key(s_id); Value(m_nextRequestId++);
|
||||
Key(s_method); Value(method);
|
||||
Key(s_params); BeginList();
|
||||
{
|
||||
this.Serialize(a0);
|
||||
this.Serialize(a1);
|
||||
this.Serialize(a2);
|
||||
this.Serialize(a3);
|
||||
this.Serialize(a4);
|
||||
this.Serialize(a5);
|
||||
}
|
||||
EndList();
|
||||
EndMap();
|
||||
}
|
||||
|
||||
static Utf8String s_error = Utf8String.From("error");
|
||||
|
||||
public void ResponseError(int id, Exception error)
|
||||
{
|
||||
BeginMap();
|
||||
Key(s_jsonrpc); Value(s_20);
|
||||
Key(s_id); Value(id);
|
||||
Key(s_error); this.Serialize(error);
|
||||
EndMap();
|
||||
}
|
||||
|
||||
static Utf8String s_result = Utf8String.From("result");
|
||||
|
||||
public void ResponseSuccess(int id)
|
||||
{
|
||||
BeginMap();
|
||||
Key(s_jsonrpc); Value(s_20);
|
||||
Key(s_id); Value(id);
|
||||
Key(s_result); Null();
|
||||
EndMap();
|
||||
}
|
||||
|
||||
public void ResponseSuccess<T>(int id, T result)
|
||||
{
|
||||
BeginMap();
|
||||
Key(s_jsonrpc); Value(s_20);
|
||||
Key(s_id); Value(id);
|
||||
Key(s_result); this.Serialize(result);
|
||||
EndMap();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ namespace UniJSON
|
|||
/// <param name="valueType"></param>
|
||||
/// <param name="parentIndex"></param>
|
||||
/// <returns></returns>
|
||||
static ListTreeNode<JsonValue> ParsePrimitive(ListTreeNode<JsonValue> tree, Utf8String segment, ValueNodeType valueType)
|
||||
static JsonNode ParsePrimitive(JsonNode tree, Utf8String segment, ValueNodeType valueType)
|
||||
{
|
||||
int i = 1;
|
||||
for (; i < segment.ByteLength; ++i)
|
||||
|
|
@ -82,7 +82,7 @@ namespace UniJSON
|
|||
return tree.AddValue(segment.Subbytes(0, i).Bytes, valueType);
|
||||
}
|
||||
|
||||
static ListTreeNode<JsonValue> ParseString(ListTreeNode<JsonValue> tree, Utf8String segment)
|
||||
static JsonNode ParseString(JsonNode tree, Utf8String segment)
|
||||
{
|
||||
int pos;
|
||||
if (segment.TrySearchAscii((Byte)'"', 1, out pos))
|
||||
|
|
@ -95,7 +95,7 @@ namespace UniJSON
|
|||
}
|
||||
}
|
||||
|
||||
static ListTreeNode<JsonValue> ParseArray(ListTreeNode<JsonValue> tree, Utf8String segment)
|
||||
static JsonNode ParseArray(JsonNode tree, Utf8String segment)
|
||||
{
|
||||
var array = tree.AddValue(segment.Bytes, ValueNodeType.Array);
|
||||
|
||||
|
|
@ -159,7 +159,7 @@ namespace UniJSON
|
|||
return array;
|
||||
}
|
||||
|
||||
static ListTreeNode<JsonValue> ParseObject(ListTreeNode<JsonValue> tree, Utf8String segment)
|
||||
static JsonNode ParseObject(JsonNode tree, Utf8String segment)
|
||||
{
|
||||
var obj = tree.AddValue(segment.Bytes, ValueNodeType.Object);
|
||||
|
||||
|
|
@ -248,7 +248,7 @@ namespace UniJSON
|
|||
return obj;
|
||||
}
|
||||
|
||||
public static ListTreeNode<JsonValue> Parse(ListTreeNode<JsonValue> tree, Utf8String segment)
|
||||
public static JsonNode Parse(JsonNode tree, Utf8String segment)
|
||||
{
|
||||
// skip white space
|
||||
int pos;
|
||||
|
|
@ -284,14 +284,14 @@ namespace UniJSON
|
|||
}
|
||||
}
|
||||
|
||||
public static ListTreeNode<JsonValue> Parse(String json)
|
||||
public static JsonNode Parse(String json)
|
||||
{
|
||||
return Parse(Utf8String.From(json));
|
||||
}
|
||||
|
||||
public static ListTreeNode<JsonValue> Parse(Utf8String json)
|
||||
public static JsonNode Parse(Utf8String json)
|
||||
{
|
||||
return Parse(default(ListTreeNode<JsonValue>), json);
|
||||
return Parse(default(JsonNode), json);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,8 +37,7 @@ namespace UniJSON
|
|||
};
|
||||
}
|
||||
|
||||
public static JsonPointer Create<T>(ListTreeNode<T> node)
|
||||
where T : IListTreeItem, IValue<T>
|
||||
public static JsonPointer Create(JsonNode node)
|
||||
{
|
||||
return new JsonPointer
|
||||
{
|
||||
|
|
@ -79,8 +78,7 @@ namespace UniJSON
|
|||
return sb.ToString();
|
||||
}
|
||||
|
||||
static Utf8String GetKeyFromParent<T>(ListTreeNode<T> json)
|
||||
where T : IListTreeItem, IValue<T>
|
||||
static Utf8String GetKeyFromParent(JsonNode json)
|
||||
{
|
||||
var parent = json.Parent;
|
||||
if (parent.IsArray())
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
namespace UniJSON
|
||||
{
|
||||
public struct JsonValue : IListTreeItem, IValue<JsonValue>
|
||||
public struct JsonValue
|
||||
{
|
||||
public Utf8String Segment;
|
||||
public ArraySegment<Byte> Bytes { get { return Segment.Bytes; } }
|
||||
|
|
@ -103,23 +103,5 @@ namespace UniJSON
|
|||
public Double GetDouble() { return Segment.ToDouble(); }
|
||||
public String GetString() { return JsonString.Unquote(Segment.ToString()); }
|
||||
public Utf8String GetUtf8String() { return JsonString.Unquote(Segment); }
|
||||
|
||||
public T GetValue<T>()
|
||||
{
|
||||
switch (ValueType)
|
||||
{
|
||||
case ValueNodeType.Null: return GenericCast<object, T>.Null();
|
||||
case ValueNodeType.Boolean: return GenericCast<bool, T>.Cast(GetBoolean());
|
||||
case ValueNodeType.Integer: return GenericCast<int, T>.Cast(GetInt32());
|
||||
case ValueNodeType.Number:
|
||||
case ValueNodeType.NaN:
|
||||
case ValueNodeType.Infinity:
|
||||
case ValueNodeType.MinusInfinity:
|
||||
return GenericCast<double, T>.Cast(GetDouble());
|
||||
case ValueNodeType.String: return GenericCast<string, T>.Cast(GetString());
|
||||
}
|
||||
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,8 +6,7 @@ using System.Text;
|
|||
|
||||
namespace UniJSON
|
||||
{
|
||||
public struct ListTreeNode<T> : ITreeNode<ListTreeNode<T>, T>
|
||||
where T : IListTreeItem, IValue<T>
|
||||
public struct JsonNode
|
||||
{
|
||||
public override int GetHashCode()
|
||||
{
|
||||
|
|
@ -16,12 +15,12 @@ namespace UniJSON
|
|||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (!(obj is ListTreeNode<T>))
|
||||
if (!(obj is JsonNode))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var rhs = (ListTreeNode<T>)obj;
|
||||
var rhs = (JsonNode)obj;
|
||||
|
||||
if ((Value.ValueType == ValueNodeType.Integer || Value.ValueType == ValueNodeType.Null)
|
||||
&& (rhs.Value.ValueType == ValueNodeType.Integer || rhs.Value.ValueType == ValueNodeType.Number))
|
||||
|
|
@ -198,7 +197,7 @@ namespace UniJSON
|
|||
return string.Join("", ToString(indent, 0).ToArray());
|
||||
}
|
||||
|
||||
public IEnumerable<JsonDiff> Diff(ListTreeNode<T> rhs, JsonPointer path = default(JsonPointer))
|
||||
public IEnumerable<JsonDiff> Diff(JsonNode rhs, JsonPointer path = default(JsonPointer))
|
||||
{
|
||||
switch (Value.ValueType)
|
||||
{
|
||||
|
|
@ -228,7 +227,7 @@ namespace UniJSON
|
|||
|
||||
foreach (var kv in l)
|
||||
{
|
||||
ListTreeNode<T> x;
|
||||
JsonNode x;
|
||||
if (r.TryGetValue(kv.Key, out x))
|
||||
{
|
||||
r.Remove(kv.Key);
|
||||
|
|
@ -291,7 +290,7 @@ namespace UniJSON
|
|||
/// <summary>
|
||||
/// Whole tree nodes
|
||||
/// </summary>
|
||||
List<T> m_Values;
|
||||
List<JsonValue> m_Values;
|
||||
public bool IsValid
|
||||
{
|
||||
get
|
||||
|
|
@ -313,26 +312,26 @@ namespace UniJSON
|
|||
}
|
||||
}
|
||||
|
||||
public ListTreeNode<T> Prev
|
||||
public JsonNode Prev
|
||||
{
|
||||
get
|
||||
{
|
||||
return new ListTreeNode<T>(m_Values, ValueIndex - 1);
|
||||
return new JsonNode(m_Values, ValueIndex - 1);
|
||||
}
|
||||
}
|
||||
|
||||
public T Value
|
||||
public JsonValue Value
|
||||
{
|
||||
get
|
||||
{
|
||||
if (m_Values == null)
|
||||
{
|
||||
return default(T);
|
||||
return default;
|
||||
}
|
||||
return m_Values[ValueIndex];
|
||||
}
|
||||
}
|
||||
public void SetValue(T value)
|
||||
public void SetValue(JsonValue value)
|
||||
{
|
||||
m_Values[ValueIndex] = value;
|
||||
}
|
||||
|
|
@ -343,7 +342,7 @@ namespace UniJSON
|
|||
get { return Value.ChildCount; }
|
||||
}
|
||||
|
||||
public IEnumerable<ListTreeNode<T>> Children
|
||||
public IEnumerable<JsonNode> Children
|
||||
{
|
||||
get
|
||||
{
|
||||
|
|
@ -353,13 +352,13 @@ namespace UniJSON
|
|||
if (m_Values[i].ParentIndex == ValueIndex)
|
||||
{
|
||||
++count;
|
||||
yield return new ListTreeNode<T>(m_Values, i);
|
||||
yield return new JsonNode(m_Values, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public ListTreeNode<T> this[String key]
|
||||
public JsonNode this[String key]
|
||||
{
|
||||
get
|
||||
{
|
||||
|
|
@ -367,7 +366,7 @@ namespace UniJSON
|
|||
}
|
||||
}
|
||||
|
||||
public ListTreeNode<T> this[Utf8String key]
|
||||
public JsonNode this[Utf8String key]
|
||||
{
|
||||
get
|
||||
{
|
||||
|
|
@ -375,7 +374,7 @@ namespace UniJSON
|
|||
}
|
||||
}
|
||||
|
||||
public ListTreeNode<T> this[int index]
|
||||
public JsonNode this[int index]
|
||||
{
|
||||
get
|
||||
{
|
||||
|
|
@ -390,7 +389,7 @@ namespace UniJSON
|
|||
return Value.ParentIndex >= 0 && Value.ParentIndex < m_Values.Count;
|
||||
}
|
||||
}
|
||||
public ListTreeNode<T> Parent
|
||||
public JsonNode Parent
|
||||
{
|
||||
get
|
||||
{
|
||||
|
|
@ -402,33 +401,33 @@ namespace UniJSON
|
|||
{
|
||||
throw new IndexOutOfRangeException();
|
||||
}
|
||||
return new ListTreeNode<T>(m_Values, Value.ParentIndex);
|
||||
return new JsonNode(m_Values, Value.ParentIndex);
|
||||
}
|
||||
}
|
||||
|
||||
public ListTreeNode(List<T> values, int index = 0) : this()
|
||||
public JsonNode(List<JsonValue> values, int index = 0) : this()
|
||||
{
|
||||
m_Values = values;
|
||||
_valueIndex = index;
|
||||
}
|
||||
|
||||
#region JsonPointer
|
||||
public ListTreeNode<T> AddKey(Utf8String key)
|
||||
public JsonNode AddKey(Utf8String key)
|
||||
{
|
||||
return AddValue(default(T).Key(key, ValueIndex));
|
||||
return AddValue(default(JsonValue).Key(key, ValueIndex));
|
||||
}
|
||||
|
||||
public ListTreeNode<T> AddValue(ArraySegment<byte> bytes, ValueNodeType valueType)
|
||||
public JsonNode AddValue(ArraySegment<byte> bytes, ValueNodeType valueType)
|
||||
{
|
||||
return AddValue(default(T).New(bytes, valueType, ValueIndex));
|
||||
return AddValue(default(JsonValue).New(bytes, valueType, ValueIndex));
|
||||
}
|
||||
|
||||
public ListTreeNode<T> AddValue(T value)
|
||||
public JsonNode AddValue(JsonValue value)
|
||||
{
|
||||
if (m_Values == null)
|
||||
{
|
||||
// initialize empty tree
|
||||
m_Values = new List<T>();
|
||||
m_Values = new List<JsonValue>();
|
||||
_valueIndex = -1;
|
||||
}
|
||||
else
|
||||
|
|
@ -437,7 +436,7 @@ namespace UniJSON
|
|||
}
|
||||
var index = m_Values.Count;
|
||||
m_Values.Add(value);
|
||||
return new ListTreeNode<T>(m_Values, index);
|
||||
return new JsonNode(m_Values, index);
|
||||
}
|
||||
|
||||
void IncrementChildCount()
|
||||
|
|
|
|||
|
|
@ -7,21 +7,19 @@ namespace UniJSON
|
|||
{
|
||||
public static class ListTreeNodeArrayExtensions
|
||||
{
|
||||
public static IEnumerable<ListTreeNode<T>> ArrayItems<T>(this ListTreeNode<T> self) where T : IListTreeItem, IValue<T>
|
||||
public static IEnumerable<JsonNode> ArrayItems(this JsonNode self)
|
||||
{
|
||||
if (!self.IsArray()) throw new DeserializationException("is not array");
|
||||
return self.Children;
|
||||
}
|
||||
|
||||
[Obsolete("Use GetArrayItem(index)")]
|
||||
public static ListTreeNode<T> GetArrrayItem<T>(this ListTreeNode<T> self, int index)
|
||||
where T : IListTreeItem, IValue<T>
|
||||
public static JsonNode GetArrrayItem(this JsonNode self, int index)
|
||||
{
|
||||
return GetArrayItem(self, index);
|
||||
}
|
||||
|
||||
public static ListTreeNode<T> GetArrayItem<T>(this ListTreeNode<T> self, int index)
|
||||
where T : IListTreeItem, IValue<T>
|
||||
public static JsonNode GetArrayItem(this JsonNode self, int index)
|
||||
{
|
||||
int i = 0;
|
||||
foreach (var v in self.ArrayItems())
|
||||
|
|
@ -34,15 +32,13 @@ namespace UniJSON
|
|||
throw new KeyNotFoundException();
|
||||
}
|
||||
|
||||
public static int GetArrayCount<T>(this ListTreeNode<T> self)
|
||||
where T : IListTreeItem, IValue<T>
|
||||
public static int GetArrayCount(this JsonNode self)
|
||||
{
|
||||
if (!self.IsArray()) throw new DeserializationException("is not array");
|
||||
return self.Children.Count();
|
||||
}
|
||||
|
||||
public static int IndexOf<T>(this ListTreeNode<T> self, ListTreeNode<T> child)
|
||||
where T : IListTreeItem, IValue<T>
|
||||
public static int IndexOf(this JsonNode self, JsonNode child)
|
||||
{
|
||||
int i = 0;
|
||||
foreach (var v in self.ArrayItems())
|
||||
|
|
|
|||
|
|
@ -6,27 +6,27 @@ namespace UniJSON
|
|||
public static class ListTreeNodeExtensions
|
||||
{
|
||||
#region IValue
|
||||
public static bool IsNull<T>(this ListTreeNode<T> self) where T : IListTreeItem, IValue<T>
|
||||
public static bool IsNull(this JsonNode self)
|
||||
{
|
||||
return self.Value.ValueType == ValueNodeType.Null;
|
||||
}
|
||||
|
||||
public static bool IsBoolean<T>(this ListTreeNode<T> self) where T : IListTreeItem, IValue<T>
|
||||
public static bool IsBoolean(this JsonNode self)
|
||||
{
|
||||
return self.Value.ValueType == ValueNodeType.Boolean;
|
||||
}
|
||||
|
||||
public static bool IsString<T>(this ListTreeNode<T> self) where T : IListTreeItem, IValue<T>
|
||||
public static bool IsString(this JsonNode self)
|
||||
{
|
||||
return self.Value.ValueType == ValueNodeType.String;
|
||||
}
|
||||
|
||||
public static bool IsInteger<T>(this ListTreeNode<T> self) where T : IListTreeItem, IValue<T>
|
||||
public static bool IsInteger(this JsonNode self)
|
||||
{
|
||||
return self.Value.ValueType == ValueNodeType.Integer;
|
||||
}
|
||||
|
||||
public static bool IsFloat<T>(this ListTreeNode<T> self) where T : IListTreeItem, IValue<T>
|
||||
public static bool IsFloat(this JsonNode self)
|
||||
{
|
||||
return self.Value.ValueType == ValueNodeType.Number
|
||||
|| self.Value.ValueType == ValueNodeType.NaN
|
||||
|
|
@ -34,41 +34,32 @@ namespace UniJSON
|
|||
|| self.Value.ValueType == ValueNodeType.MinusInfinity;
|
||||
}
|
||||
|
||||
public static bool IsArray<T>(this ListTreeNode<T> self) where T : IListTreeItem, IValue<T>
|
||||
public static bool IsArray(this JsonNode self)
|
||||
{
|
||||
return self.Value.ValueType == ValueNodeType.Array;
|
||||
}
|
||||
|
||||
public static bool IsMap<T>(this ListTreeNode<T> self) where T : IListTreeItem, IValue<T>
|
||||
public static bool IsMap(this JsonNode self)
|
||||
{
|
||||
return self.Value.ValueType == ValueNodeType.Object;
|
||||
}
|
||||
|
||||
public static bool GetBoolean<T>(this ListTreeNode<T> self) where T : IListTreeItem, IValue<T> { return self.Value.GetBoolean(); }
|
||||
public static string GetString<T>(this ListTreeNode<T> self) where T : IListTreeItem, IValue<T> { return self.Value.GetString(); }
|
||||
public static Utf8String GetUtf8String<T>(this ListTreeNode<T> self) where T : IListTreeItem, IValue<T> { return self.Value.GetUtf8String(); }
|
||||
public static sbyte GetSByte<T>(this ListTreeNode<T> self) where T : IListTreeItem, IValue<T> { return self.Value.GetSByte(); }
|
||||
public static short GetInt16<T>(this ListTreeNode<T> self) where T : IListTreeItem, IValue<T> { return self.Value.GetInt16(); }
|
||||
public static int GetInt32<T>(this ListTreeNode<T> self) where T : IListTreeItem, IValue<T> { return self.Value.GetInt32(); }
|
||||
public static long GetInt64<T>(this ListTreeNode<T> self) where T : IListTreeItem, IValue<T> { return self.Value.GetInt64(); }
|
||||
public static byte GetByte<T>(this ListTreeNode<T> self) where T : IListTreeItem, IValue<T> { return self.Value.GetByte(); }
|
||||
public static ushort GetUInt16<T>(this ListTreeNode<T> self) where T : IListTreeItem, IValue<T> { return self.Value.GetUInt16(); }
|
||||
public static uint GetUInt32<T>(this ListTreeNode<T> self) where T : IListTreeItem, IValue<T> { return self.Value.GetUInt32(); }
|
||||
public static ulong GetUInt64<T>(this ListTreeNode<T> self) where T : IListTreeItem, IValue<T> { return self.Value.GetUInt64(); }
|
||||
public static float GetSingle<T>(this ListTreeNode<T> self) where T : IListTreeItem, IValue<T> { return self.Value.GetSingle(); }
|
||||
public static double GetDouble<T>(this ListTreeNode<T> self) where T : IListTreeItem, IValue<T> { return self.Value.GetDouble(); }
|
||||
|
||||
/// <summary>
|
||||
/// for UnitTest. Use explicit GetT() or Deserialize(ref T)
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static object GetValue<T>(this ListTreeNode<T> self) where T : IListTreeItem, IValue<T>
|
||||
{
|
||||
return self.Value.GetValue<object>();
|
||||
}
|
||||
public static bool GetBoolean(this JsonNode self) { return self.Value.GetBoolean(); }
|
||||
public static string GetString(this JsonNode self) { return self.Value.GetString(); }
|
||||
public static Utf8String GetUtf8String(this JsonNode self) { return self.Value.GetUtf8String(); }
|
||||
public static sbyte GetSByte(this JsonNode self) { return self.Value.GetSByte(); }
|
||||
public static short GetInt16(this JsonNode self) { return self.Value.GetInt16(); }
|
||||
public static int GetInt32(this JsonNode self) { return self.Value.GetInt32(); }
|
||||
public static long GetInt64(this JsonNode self) { return self.Value.GetInt64(); }
|
||||
public static byte GetByte(this JsonNode self) { return self.Value.GetByte(); }
|
||||
public static ushort GetUInt16(this JsonNode self) { return self.Value.GetUInt16(); }
|
||||
public static uint GetUInt32(this JsonNode self) { return self.Value.GetUInt32(); }
|
||||
public static ulong GetUInt64(this JsonNode self) { return self.Value.GetUInt64(); }
|
||||
public static float GetSingle(this JsonNode self) { return self.Value.GetSingle(); }
|
||||
public static double GetDouble(this JsonNode self) { return self.Value.GetDouble(); }
|
||||
#endregion
|
||||
|
||||
public static IEnumerable<ListTreeNode<T>> Traverse<T>(this ListTreeNode<T> self) where T : IListTreeItem, IValue<T>
|
||||
public static IEnumerable<JsonNode> Traverse(this JsonNode self)
|
||||
{
|
||||
yield return self;
|
||||
if (self.IsArray())
|
||||
|
|
|
|||
|
|
@ -7,40 +7,36 @@ namespace UniJSON
|
|||
{
|
||||
public static class ListTreeNodeJsonPointerExtensions
|
||||
{
|
||||
public static void SetValue<T>(this ListTreeNode<T> self,
|
||||
public static void SetValue(this JsonNode self,
|
||||
Utf8String jsonPointer, ArraySegment<Byte> bytes)
|
||||
where T: IListTreeItem, IValue<T>
|
||||
{
|
||||
foreach (var node in self.GetNodes(jsonPointer))
|
||||
{
|
||||
node.SetValue(default(T).New(
|
||||
node.SetValue(default(JsonValue).New(
|
||||
bytes,
|
||||
ValueNodeType.Boolean,
|
||||
node.Value.ParentIndex));
|
||||
}
|
||||
}
|
||||
|
||||
public static void RemoveValue<T>(this ListTreeNode<T> self, Utf8String jsonPointer)
|
||||
where T : IListTreeItem, IValue<T>
|
||||
public static void RemoveValue(this JsonNode self, Utf8String jsonPointer)
|
||||
{
|
||||
foreach (var node in self.GetNodes(new JsonPointer(jsonPointer)))
|
||||
{
|
||||
if (node.Parent.IsMap())
|
||||
{
|
||||
node.Prev.SetValue(default(T)); // remove key
|
||||
node.Prev.SetValue(default(JsonValue)); // remove key
|
||||
}
|
||||
node.SetValue(default(T)); // remove
|
||||
node.SetValue(default(JsonValue)); // remove
|
||||
}
|
||||
}
|
||||
|
||||
public static JsonPointer Pointer<T>(this ListTreeNode<T> self)
|
||||
where T: IListTreeItem, IValue<T>
|
||||
public static JsonPointer Pointer(this JsonNode self)
|
||||
{
|
||||
return JsonPointer.Create(self);
|
||||
}
|
||||
|
||||
public static IEnumerable<ListTreeNode<T>> Path<T>(this ListTreeNode<T> self)
|
||||
where T : IListTreeItem, IValue<T>
|
||||
public static IEnumerable<JsonNode> Path(this JsonNode self)
|
||||
{
|
||||
if (self.HasParent)
|
||||
{
|
||||
|
|
@ -52,9 +48,8 @@ namespace UniJSON
|
|||
yield return self;
|
||||
}
|
||||
|
||||
public static IEnumerable<ListTreeNode<T>> GetNodes<T>(this ListTreeNode<T> self,
|
||||
public static IEnumerable<JsonNode> GetNodes(this JsonNode self,
|
||||
JsonPointer jsonPointer)
|
||||
where T : IListTreeItem, IValue<T>
|
||||
{
|
||||
if (jsonPointer.Path.Count == 0)
|
||||
{
|
||||
|
|
@ -102,7 +97,7 @@ namespace UniJSON
|
|||
}
|
||||
else
|
||||
{
|
||||
ListTreeNode<T> child;
|
||||
JsonNode child;
|
||||
try
|
||||
{
|
||||
child = self.ObjectItems().First(x => x.Key.GetUtf8String() == jsonPointer[0]).Value;
|
||||
|
|
@ -128,9 +123,8 @@ namespace UniJSON
|
|||
}
|
||||
}
|
||||
|
||||
public static IEnumerable<ListTreeNode<T>> GetNodes<T>(this ListTreeNode<T> self,
|
||||
Utf8String jsonPointer)
|
||||
where T : IListTreeItem, IValue<T>
|
||||
public static IEnumerable<JsonNode> GetNodes(this JsonNode self,
|
||||
Utf8String jsonPointer)
|
||||
{
|
||||
return self.GetNodes(new JsonPointer(jsonPointer));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,8 +7,7 @@ namespace UniJSON
|
|||
{
|
||||
public static class IValueNodeObjectExtensions
|
||||
{
|
||||
public static IEnumerable<KeyValuePair<ListTreeNode<T>, ListTreeNode<T>>> ObjectItems<T>(this ListTreeNode<T> self)
|
||||
where T : IListTreeItem, IValue<T>
|
||||
public static IEnumerable<KeyValuePair<JsonNode, JsonNode>> ObjectItems(this JsonNode self)
|
||||
{
|
||||
if (!self.IsMap()) throw new DeserializationException("is not object");
|
||||
var it = self.Children.GetEnumerator();
|
||||
|
|
@ -17,19 +16,17 @@ namespace UniJSON
|
|||
var key = it.Current;
|
||||
|
||||
it.MoveNext();
|
||||
yield return new KeyValuePair<ListTreeNode<T>, ListTreeNode<T>>(key, it.Current);
|
||||
yield return new KeyValuePair<JsonNode, JsonNode>(key, it.Current);
|
||||
}
|
||||
}
|
||||
|
||||
public static int GetObjectCount<T>(this ListTreeNode<T> self)
|
||||
where T : IListTreeItem, IValue<T>
|
||||
public static int GetObjectCount(this JsonNode self)
|
||||
{
|
||||
if (!self.IsMap()) throw new DeserializationException("is not object");
|
||||
return self.Children.Count() / 2;
|
||||
}
|
||||
|
||||
public static string GetObjectValueOrDefault<T>(this ListTreeNode<T> self, String key, string defualtValue)
|
||||
where T : IListTreeItem, IValue<T>
|
||||
public static string GetObjectValueOrDefault(this JsonNode self, String key, string defualtValue)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
@ -41,15 +38,12 @@ namespace UniJSON
|
|||
}
|
||||
}
|
||||
|
||||
public static ListTreeNode<T> GetObjectItem<T>(this ListTreeNode<T> self, String key)
|
||||
where T : IListTreeItem, IValue<T>
|
||||
public static JsonNode GetObjectItem(this JsonNode self, String key)
|
||||
{
|
||||
return self.GetObjectItem(Utf8String.From(key));
|
||||
}
|
||||
|
||||
public static ListTreeNode<T> GetObjectItem<T>(this ListTreeNode<T> self, Utf8String key)
|
||||
where T : IListTreeItem, IValue<T>
|
||||
|
||||
public static JsonNode GetObjectItem(this JsonNode self, Utf8String key)
|
||||
{
|
||||
foreach (var kv in self.ObjectItems())
|
||||
{
|
||||
|
|
@ -61,21 +55,18 @@ namespace UniJSON
|
|||
throw new KeyNotFoundException();
|
||||
}
|
||||
|
||||
public static bool ContainsKey<T>(this ListTreeNode<T> self, Utf8String key)
|
||||
where T : IListTreeItem, IValue<T>
|
||||
public static bool ContainsKey(this JsonNode self, Utf8String key)
|
||||
{
|
||||
return self.ObjectItems().Any(x => x.Key.GetUtf8String() == key);
|
||||
}
|
||||
|
||||
public static bool ContainsKey<T>(this ListTreeNode<T> self, String key)
|
||||
where T : IListTreeItem, IValue<T>
|
||||
public static bool ContainsKey(this JsonNode self, String key)
|
||||
{
|
||||
var ukey = Utf8String.From(key);
|
||||
return self.ContainsKey(ukey);
|
||||
}
|
||||
|
||||
public static Utf8String KeyOf<T>(this ListTreeNode<T> self, ListTreeNode<T> node)
|
||||
where T : IListTreeItem, IValue<T>
|
||||
public static Utf8String KeyOf(this JsonNode self, JsonNode node)
|
||||
{
|
||||
foreach (var kv in self.ObjectItems())
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,8 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 1cffddcba2f97d44589d1fe7e05dfc2d
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -1,434 +0,0 @@
|
|||
using System;
|
||||
using System.Net;
|
||||
|
||||
namespace UniJSON
|
||||
{
|
||||
public static class EndianConverter
|
||||
{
|
||||
#if false
|
||||
/*
|
||||
#region Converter
|
||||
/// <summary>
|
||||
/// Read Uint16 From NetworkBytesOrder to HostBytesOrder
|
||||
/// </summary>
|
||||
/// <param name="bytes"></param>
|
||||
/// <returns></returns>
|
||||
public static UInt16 N2H_UInt16(this ArraySegment<Byte> self)
|
||||
{
|
||||
if (BitConverter.IsLittleEndian)
|
||||
{
|
||||
return (UInt16)(self.Get(0) << 8 | self.Get(1));
|
||||
}
|
||||
else
|
||||
{
|
||||
return BitConverter.ToUInt16(self.Array, self.Offset);
|
||||
}
|
||||
}
|
||||
|
||||
public static UInt32 N2H_UInt32(this ArraySegment<Byte> self)
|
||||
{
|
||||
if (BitConverter.IsLittleEndian)
|
||||
{
|
||||
return (UInt32)(self.Get(0) << 24 | self.Get(1) << 16 | self.Get(2) << 8 | self.Get(3));
|
||||
}
|
||||
else
|
||||
{
|
||||
return BitConverter.ToUInt32(self.Array, self.Offset);
|
||||
}
|
||||
}
|
||||
|
||||
public static UInt64 N2H_UInt64(this ArraySegment<Byte> self)
|
||||
{
|
||||
var uvalue = BitConverter.ToUInt64(self.Array, self.Offset);
|
||||
if (BitConverter.IsLittleEndian)
|
||||
{
|
||||
ulong swapped =
|
||||
((0x00000000000000FF) & (uvalue >> 56)
|
||||
| (0x000000000000FF00) & (uvalue >> 40)
|
||||
| (0x0000000000FF0000) & (uvalue >> 24)
|
||||
| (0x00000000FF000000) & (uvalue >> 8)
|
||||
| (0x000000FF00000000) & (uvalue << 8)
|
||||
| (0x0000FF0000000000) & (uvalue << 24)
|
||||
| (0x00FF000000000000) & (uvalue << 40)
|
||||
| (0xFF00000000000000) & (uvalue << 56));
|
||||
return swapped;
|
||||
}
|
||||
else
|
||||
{
|
||||
return uvalue;
|
||||
}
|
||||
}
|
||||
|
||||
public static Int16 N2H_Int16(this ArraySegment<Byte> self)
|
||||
{
|
||||
if (BitConverter.IsLittleEndian)
|
||||
{
|
||||
return (Int16)(self.Get(0) << 8 | self.Get(1));
|
||||
}
|
||||
else
|
||||
{
|
||||
return BitConverter.ToInt16(self.Array, self.Offset);
|
||||
}
|
||||
}
|
||||
|
||||
public static Int32 N2H_Int32(this ArraySegment<Byte> self)
|
||||
{
|
||||
if (BitConverter.IsLittleEndian)
|
||||
{
|
||||
return (Int32)(self.Get(0) << 24 | self.Get(1) << 16 | self.Get(2) << 8 | self.Get(3));
|
||||
}
|
||||
else
|
||||
{
|
||||
return BitConverter.ToInt32(self.Array, self.Offset);
|
||||
}
|
||||
}
|
||||
|
||||
public static Int64 N2H_Int64(this ArraySegment<Byte> self)
|
||||
{
|
||||
var value = BitConverter.ToUInt64(self.Array, self.Offset);
|
||||
if (BitConverter.IsLittleEndian)
|
||||
{
|
||||
ulong swapped =
|
||||
((0x00000000000000FF) & (value >> 56)
|
||||
| (0x000000000000FF00) & (value >> 40)
|
||||
| (0x0000000000FF0000) & (value >> 24)
|
||||
| (0x00000000FF000000) & (value >> 8)
|
||||
| (0x000000FF00000000) & (value << 8)
|
||||
| (0x0000FF0000000000) & (value << 24)
|
||||
| (0x00FF000000000000) & (value << 40)
|
||||
| (0xFF00000000000000) & (value << 56));
|
||||
return (long)swapped;
|
||||
}
|
||||
else
|
||||
{
|
||||
return (long)value;
|
||||
}
|
||||
}
|
||||
|
||||
public static Single N2H_Single(this ArraySegment<Byte> self)
|
||||
{
|
||||
if (BitConverter.IsLittleEndian)
|
||||
{
|
||||
return BitConverter.ToSingle(self.TakeReversedArray(4), 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
return BitConverter.ToSingle(self.Array, self.Offset);
|
||||
}
|
||||
}
|
||||
|
||||
public static Double N2H_Double(this ArraySegment<Byte> self)
|
||||
{
|
||||
return BitConverter.Int64BitsToDouble(self.N2H_Int64());
|
||||
}
|
||||
|
||||
public static void N2H_CopyTo(this ArraySegment<Byte> self, Byte[] buffer, int elementSize)
|
||||
{
|
||||
if (buffer.Length < self.Count) throw new ArgumentException();
|
||||
|
||||
for (int i = 0; i < self.Count; i += elementSize)
|
||||
{
|
||||
for (int j = 0; j < elementSize; ++j)
|
||||
{
|
||||
buffer[i + j] = self.Get(i + elementSize - 1 - j);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void N2H_CopyTo(this ArraySegment<Byte> self, Array result, Byte[] buffer)
|
||||
{
|
||||
if (BitConverter.IsLittleEndian)
|
||||
{
|
||||
if (buffer.Length < self.Count)
|
||||
{
|
||||
throw new ArgumentException();
|
||||
}
|
||||
self.N2H_CopyTo(buffer, Marshal.SizeOf(result.GetType().GetElementType()));
|
||||
|
||||
Buffer.BlockCopy(buffer, 0, result, 0, self.Count);
|
||||
}
|
||||
else
|
||||
{
|
||||
Buffer.BlockCopy(self.Array, self.Offset, result, 0, self.Count);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
*/
|
||||
|
||||
#else
|
||||
#region Signed
|
||||
public static Int16 NetworkByteWordToSignedNativeByteOrder(ArraySegment<Byte> bytes)
|
||||
{
|
||||
if (BitConverter.IsLittleEndian)
|
||||
{
|
||||
// Network to Little
|
||||
var value = new ByteUnion.WordValue
|
||||
{
|
||||
Byte0 = bytes.Get(1),
|
||||
Byte1 = bytes.Get(0),
|
||||
};
|
||||
return value.Signed;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Network to Big
|
||||
var value = new ByteUnion.WordValue
|
||||
{
|
||||
Byte0 = bytes.Get(0),
|
||||
Byte1 = bytes.Get(1),
|
||||
};
|
||||
return value.Signed;
|
||||
}
|
||||
}
|
||||
public static Int32 NetworkByteDWordToSignedNativeByteOrder(ArraySegment<Byte> bytes)
|
||||
{
|
||||
if (BitConverter.IsLittleEndian)
|
||||
{
|
||||
// Network to Little
|
||||
var value = new ByteUnion.DWordValue
|
||||
{
|
||||
Byte0 = bytes.Get(3),
|
||||
Byte1 = bytes.Get(2),
|
||||
Byte2 = bytes.Get(1),
|
||||
Byte3 = bytes.Get(0),
|
||||
};
|
||||
return value.Signed;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Network to Big
|
||||
var value = new ByteUnion.DWordValue
|
||||
{
|
||||
Byte0 = bytes.Get(0),
|
||||
Byte1 = bytes.Get(1),
|
||||
Byte2 = bytes.Get(2),
|
||||
Byte3 = bytes.Get(3),
|
||||
};
|
||||
return value.Signed;
|
||||
}
|
||||
}
|
||||
public static Int64 NetworkByteQWordToSignedNativeByteOrder(ArraySegment<Byte> bytes)
|
||||
{
|
||||
if (BitConverter.IsLittleEndian)
|
||||
{
|
||||
// Network to Little
|
||||
var value = new ByteUnion.QWordValue
|
||||
{
|
||||
Byte0 = bytes.Get(7),
|
||||
Byte1 = bytes.Get(6),
|
||||
Byte2 = bytes.Get(5),
|
||||
Byte3 = bytes.Get(4),
|
||||
Byte4 = bytes.Get(3),
|
||||
Byte5 = bytes.Get(2),
|
||||
Byte6 = bytes.Get(1),
|
||||
Byte7 = bytes.Get(0),
|
||||
};
|
||||
return value.Signed;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Network to Big
|
||||
var value = new ByteUnion.QWordValue
|
||||
{
|
||||
Byte0 = bytes.Get(0),
|
||||
Byte1 = bytes.Get(1),
|
||||
Byte2 = bytes.Get(2),
|
||||
Byte3 = bytes.Get(3),
|
||||
Byte4 = bytes.Get(4),
|
||||
Byte5 = bytes.Get(5),
|
||||
Byte6 = bytes.Get(6),
|
||||
Byte7 = bytes.Get(7),
|
||||
};
|
||||
return value.Signed;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
#region Unsigned
|
||||
public static UInt16 NetworkByteWordToUnsignedNativeByteOrder(ArraySegment<Byte> bytes)
|
||||
{
|
||||
if (BitConverter.IsLittleEndian)
|
||||
{
|
||||
// Network to Little
|
||||
var value = new ByteUnion.WordValue
|
||||
{
|
||||
Byte0 = bytes.Get(1),
|
||||
Byte1 = bytes.Get(0),
|
||||
};
|
||||
return value.Unsigned;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Network to Big
|
||||
var value = new ByteUnion.WordValue
|
||||
{
|
||||
Byte0 = bytes.Get(0),
|
||||
Byte1 = bytes.Get(1),
|
||||
};
|
||||
return value.Unsigned;
|
||||
}
|
||||
}
|
||||
public static UInt32 NetworkByteDWordToUnsignedNativeByteOrder(ArraySegment<Byte> bytes)
|
||||
{
|
||||
if (BitConverter.IsLittleEndian)
|
||||
{
|
||||
// Network to Little
|
||||
var value = new ByteUnion.DWordValue
|
||||
{
|
||||
Byte0 = bytes.Get(3),
|
||||
Byte1 = bytes.Get(2),
|
||||
Byte2 = bytes.Get(1),
|
||||
Byte3 = bytes.Get(0),
|
||||
};
|
||||
return value.Unsigned;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Network to Big
|
||||
var value = new ByteUnion.DWordValue
|
||||
{
|
||||
Byte0 = bytes.Get(0),
|
||||
Byte1 = bytes.Get(1),
|
||||
Byte2 = bytes.Get(2),
|
||||
Byte3 = bytes.Get(3),
|
||||
};
|
||||
return value.Unsigned;
|
||||
}
|
||||
}
|
||||
public static UInt64 NetworkByteQWordToUnsignedNativeByteOrder(ArraySegment<Byte> bytes)
|
||||
{
|
||||
if (BitConverter.IsLittleEndian)
|
||||
{
|
||||
// Network to Little
|
||||
var value = new ByteUnion.QWordValue
|
||||
{
|
||||
Byte0 = bytes.Get(7),
|
||||
Byte1 = bytes.Get(6),
|
||||
Byte2 = bytes.Get(5),
|
||||
Byte3 = bytes.Get(4),
|
||||
Byte4 = bytes.Get(3),
|
||||
Byte5 = bytes.Get(2),
|
||||
Byte6 = bytes.Get(1),
|
||||
Byte7 = bytes.Get(0),
|
||||
};
|
||||
return value.Unsigned;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Network to Big
|
||||
var value = new ByteUnion.QWordValue
|
||||
{
|
||||
Byte0 = bytes.Get(0),
|
||||
Byte1 = bytes.Get(1),
|
||||
Byte2 = bytes.Get(2),
|
||||
Byte3 = bytes.Get(3),
|
||||
Byte4 = bytes.Get(4),
|
||||
Byte5 = bytes.Get(5),
|
||||
Byte6 = bytes.Get(6),
|
||||
Byte7 = bytes.Get(7),
|
||||
};
|
||||
return value.Unsigned;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
#region Floating
|
||||
public static Single NetworkByteDWordToFloatNativeByteOrder(ArraySegment<Byte> bytes)
|
||||
{
|
||||
if (BitConverter.IsLittleEndian)
|
||||
{
|
||||
// Network to Little
|
||||
var value = new ByteUnion.DWordValue
|
||||
{
|
||||
Byte0 = bytes.Get(3),
|
||||
Byte1 = bytes.Get(2),
|
||||
Byte2 = bytes.Get(1),
|
||||
Byte3 = bytes.Get(0),
|
||||
};
|
||||
return value.Float;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Network to Big
|
||||
var value = new ByteUnion.DWordValue
|
||||
{
|
||||
Byte0 = bytes.Get(0),
|
||||
Byte1 = bytes.Get(1),
|
||||
Byte2 = bytes.Get(2),
|
||||
Byte3 = bytes.Get(3),
|
||||
};
|
||||
return value.Float;
|
||||
}
|
||||
}
|
||||
public static Double NetworkByteQWordToFloatNativeByteOrder(ArraySegment<Byte> bytes)
|
||||
{
|
||||
if (BitConverter.IsLittleEndian)
|
||||
{
|
||||
// Network to Little
|
||||
var value = new ByteUnion.QWordValue
|
||||
{
|
||||
Byte0 = bytes.Get(7),
|
||||
Byte1 = bytes.Get(6),
|
||||
Byte2 = bytes.Get(5),
|
||||
Byte3 = bytes.Get(4),
|
||||
Byte4 = bytes.Get(3),
|
||||
Byte5 = bytes.Get(2),
|
||||
Byte6 = bytes.Get(1),
|
||||
Byte7 = bytes.Get(0),
|
||||
};
|
||||
return value.Float;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Network to Big
|
||||
var value = new ByteUnion.QWordValue
|
||||
{
|
||||
Byte0 = bytes.Get(0),
|
||||
Byte1 = bytes.Get(1),
|
||||
Byte2 = bytes.Get(2),
|
||||
Byte3 = bytes.Get(3),
|
||||
Byte4 = bytes.Get(4),
|
||||
Byte5 = bytes.Get(5),
|
||||
Byte6 = bytes.Get(6),
|
||||
Byte7 = bytes.Get(7),
|
||||
};
|
||||
return value.Float;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
#endif
|
||||
|
||||
public static Int16 ToNetworkByteOrder(this Int16 value)
|
||||
{
|
||||
return ByteUnion.WordValue.Create(value).HostToNetworkOrder().Signed;
|
||||
}
|
||||
public static UInt16 ToNetworkByteOrder(this UInt16 value)
|
||||
{
|
||||
return ByteUnion.WordValue.Create(value).HostToNetworkOrder().Unsigned;
|
||||
}
|
||||
|
||||
public static Int32 ToNetworkByteOrder(this Int32 value)
|
||||
{
|
||||
return ByteUnion.DWordValue.Create(value).HostToNetworkOrder().Signed;
|
||||
}
|
||||
public static UInt32 ToNetworkByteOrder(this UInt32 value)
|
||||
{
|
||||
return ByteUnion.DWordValue.Create(value).HostToNetworkOrder().Unsigned;
|
||||
}
|
||||
public static Single ToNetworkByteOrder(this Single value)
|
||||
{
|
||||
return ByteUnion.DWordValue.Create(value).HostToNetworkOrder().Float;
|
||||
}
|
||||
|
||||
public static Int64 ToNetworkByteOrder(this Int64 value)
|
||||
{
|
||||
return ByteUnion.QWordValue.Create(value).HostToNetworkOrder().Signed;
|
||||
}
|
||||
public static UInt64 ToNetworkByteOrder(this UInt64 value)
|
||||
{
|
||||
return ByteUnion.QWordValue.Create(value).HostToNetworkOrder().Unsigned;
|
||||
}
|
||||
public static Double ToNetworkByteOrder(this Double value)
|
||||
{
|
||||
return ByteUnion.QWordValue.Create(value).HostToNetworkOrder().Float;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 2d72520a65b562f4f862ac0760306215
|
||||
timeCreated: 1540879367
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
using System;
|
||||
|
||||
namespace UniJSON
|
||||
{
|
||||
|
||||
public class MsgPackTypeException : Exception
|
||||
{
|
||||
public MsgPackTypeException(string msg) : base(msg)
|
||||
{ }
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: bc09dae63ba521545a0b9a8ef120b95a
|
||||
timeCreated: 1540906879
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -1,609 +0,0 @@
|
|||
using System;
|
||||
|
||||
|
||||
namespace UniJSON
|
||||
{
|
||||
public class MsgPackFormatter : IFormatter
|
||||
{
|
||||
IStore m_store;
|
||||
public MsgPackFormatter(IStore store)
|
||||
{
|
||||
m_store = store;
|
||||
}
|
||||
|
||||
public MsgPackFormatter() : this(new BytesStore())
|
||||
{
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
m_store.Clear();
|
||||
}
|
||||
|
||||
#if false
|
||||
public bool MsgPack_Ext(IList list)
|
||||
{
|
||||
var t = list.GetType();
|
||||
var et = t.GetElementType();
|
||||
if (et.IsClass())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
m_store.Write((Byte)MsgPackType.EXT32);
|
||||
var itemSize = Marshal.SizeOf(et);
|
||||
WriteInt32_NBO(list.Count * itemSize);
|
||||
|
||||
Action<Object> pack;
|
||||
if (et == typeof(UInt16))
|
||||
{
|
||||
m_store.Write((Byte)ExtType.UINT16_BE);
|
||||
pack = o => WriteUInt16_NBO((UInt16)o);
|
||||
}
|
||||
else if (et == typeof(UInt32))
|
||||
{
|
||||
m_store.Write((Byte)ExtType.UINT32_BE);
|
||||
pack = o => WriteUInt32_NBO((UInt32)o);
|
||||
}
|
||||
else if (et == typeof(UInt64))
|
||||
{
|
||||
m_store.Write((Byte)ExtType.UINT64_BE);
|
||||
pack = o => WriteUInt64_NBO((UInt64)o);
|
||||
}
|
||||
else if (et == typeof(Int16))
|
||||
{
|
||||
m_store.Write((Byte)ExtType.INT16_BE);
|
||||
pack = o => WriteInt16_NBO((Int16)o);
|
||||
}
|
||||
else if (et == typeof(Int32))
|
||||
{
|
||||
m_store.Write((Byte)ExtType.INT32_BE);
|
||||
pack = o => WriteInt32_NBO((Int32)o);
|
||||
}
|
||||
else if (et == typeof(Int64))
|
||||
{
|
||||
m_store.Write((Byte)ExtType.INT64_BE);
|
||||
pack = o => WriteInt64_NBO((Int64)o);
|
||||
}
|
||||
else if (et == typeof(Single))
|
||||
{
|
||||
m_store.Write((Byte)ExtType.SINGLE_BE);
|
||||
pack = o => WriteSingle_NBO((Single)o);
|
||||
}
|
||||
else if (et == typeof(Double))
|
||||
{
|
||||
m_store.Write((Byte)ExtType.DOUBLE_BE);
|
||||
pack = o => WriteDouble_NBO((Double)o);
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach (var i in list)
|
||||
{
|
||||
pack(i);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
public void BeginList(int n)
|
||||
{
|
||||
if (n < 0x0F)
|
||||
{
|
||||
m_store.Write((Byte)((Byte)MsgPackType.FIX_ARRAY | n));
|
||||
}
|
||||
else if (n < 0xFFFF)
|
||||
{
|
||||
m_store.Write((Byte)MsgPackType.ARRAY16);
|
||||
m_store.WriteBigEndian((UInt16)n);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_store.Write((Byte)MsgPackType.ARRAY32);
|
||||
m_store.WriteBigEndian(n);
|
||||
}
|
||||
}
|
||||
|
||||
public void EndList()
|
||||
{
|
||||
}
|
||||
|
||||
public void BeginMap(int n)
|
||||
{
|
||||
if (n < 0x0F)
|
||||
{
|
||||
m_store.Write((Byte)((Byte)MsgPackType.FIX_MAP | n));
|
||||
}
|
||||
else if (n < 0xFFFF)
|
||||
{
|
||||
m_store.Write((Byte)MsgPackType.MAP16);
|
||||
m_store.WriteBigEndian((UInt16)n);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_store.Write((Byte)MsgPackType.MAP32);
|
||||
m_store.WriteBigEndian(n.ToNetworkByteOrder());
|
||||
}
|
||||
}
|
||||
|
||||
public void EndMap()
|
||||
{
|
||||
}
|
||||
|
||||
public void Null()
|
||||
{
|
||||
m_store.Write((Byte)MsgPackType.NIL);
|
||||
}
|
||||
|
||||
public void Key(Utf8String key)
|
||||
{
|
||||
Value(key);
|
||||
}
|
||||
|
||||
public void Value(String s)
|
||||
{
|
||||
Value(Utf8String.From(s));
|
||||
}
|
||||
|
||||
public void Value(Utf8String s)
|
||||
{
|
||||
var bytes = s.Bytes;
|
||||
int size = bytes.Count;
|
||||
if (size < 32)
|
||||
{
|
||||
m_store.Write((Byte)((Byte)MsgPackType.FIX_STR | size));
|
||||
m_store.Write(bytes);
|
||||
}
|
||||
else if (size < 0xFF)
|
||||
{
|
||||
m_store.Write((Byte)(MsgPackType.STR8));
|
||||
m_store.Write((Byte)(size));
|
||||
m_store.Write(bytes);
|
||||
}
|
||||
else if (size < 0xFFFF)
|
||||
{
|
||||
m_store.Write((Byte)MsgPackType.STR16);
|
||||
m_store.WriteBigEndian((UInt16)size);
|
||||
m_store.Write(bytes);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_store.Write((Byte)MsgPackType.STR32);
|
||||
m_store.WriteBigEndian(size);
|
||||
m_store.Write(bytes);
|
||||
}
|
||||
}
|
||||
|
||||
public void Value(bool value)
|
||||
{
|
||||
if (value)
|
||||
{
|
||||
m_store.Write((Byte)MsgPackType.TRUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_store.Write((Byte)MsgPackType.FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
#region Singed
|
||||
public void Value(sbyte n)
|
||||
{
|
||||
if (n >= 0)
|
||||
{
|
||||
// positive
|
||||
Value((Byte)n);
|
||||
}
|
||||
else if (n >= -32)
|
||||
{
|
||||
var value = (MsgPackType)((n + 32) + (Byte)MsgPackType.NEGATIVE_FIXNUM);
|
||||
m_store.Write((Byte)value);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_store.Write((Byte)MsgPackType.INT8);
|
||||
m_store.Write((Byte)n);
|
||||
}
|
||||
}
|
||||
|
||||
public void Value(short n)
|
||||
{
|
||||
if (n >= 0)
|
||||
{
|
||||
// positive
|
||||
if (n <= 0xFF)
|
||||
{
|
||||
Value((Byte)n);
|
||||
}
|
||||
else
|
||||
{
|
||||
Value((UInt16)n);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// negative
|
||||
if (n >= -128)
|
||||
{
|
||||
m_store.Write((SByte)n);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_store.Write((Byte)MsgPackType.INT16);
|
||||
m_store.WriteBigEndian(n);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Value(int n)
|
||||
{
|
||||
if (n >= 0)
|
||||
{
|
||||
// positive
|
||||
if (n <= 0xFF)
|
||||
{
|
||||
Value((Byte)n);
|
||||
}
|
||||
else if (n <= 0xFFFF)
|
||||
{
|
||||
Value((UInt16)n);
|
||||
}
|
||||
else
|
||||
{
|
||||
Value((UInt32)n);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// negative
|
||||
if (n >= -128)
|
||||
{
|
||||
Value((SByte)n);
|
||||
}
|
||||
else if (n >= -32768)
|
||||
{
|
||||
Value((Int16)n);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_store.Write((Byte)MsgPackType.INT32);
|
||||
m_store.WriteBigEndian(n);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Value(long n)
|
||||
{
|
||||
if (n >= 0)
|
||||
{
|
||||
// positive
|
||||
if (n <= 0xFF)
|
||||
{
|
||||
Value((Byte)n);
|
||||
}
|
||||
else if (n <= 0xFFFF)
|
||||
{
|
||||
Value((UInt16)n);
|
||||
}
|
||||
else if (n <= 0xFFFFFFFF)
|
||||
{
|
||||
Value((UInt32)n);
|
||||
}
|
||||
else
|
||||
{
|
||||
Value((UInt64)n);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// negative
|
||||
if (n >= -128)
|
||||
{
|
||||
Value((SByte)n);
|
||||
}
|
||||
else if (n >= -32768)
|
||||
{
|
||||
Value((Int16)n);
|
||||
}
|
||||
else if (n >= -2147483648)
|
||||
{
|
||||
Value((Int32)n);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_store.Write((Byte)MsgPackType.INT64);
|
||||
m_store.WriteBigEndian(n);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Unsigned
|
||||
public void Value(byte n)
|
||||
{
|
||||
if (n <= 0x7F)
|
||||
{
|
||||
// FormatType.POSITIVE_FIXNUM
|
||||
m_store.Write(n);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_store.Write((Byte)MsgPackType.UINT8);
|
||||
m_store.Write(n);
|
||||
}
|
||||
}
|
||||
|
||||
public void Value(ushort n)
|
||||
{
|
||||
if (n <= 0xFF)
|
||||
{
|
||||
Value((Byte)n);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_store.Write((Byte)MsgPackType.UINT16);
|
||||
m_store.WriteBigEndian(n);
|
||||
}
|
||||
}
|
||||
|
||||
public void Value(uint n)
|
||||
{
|
||||
if (n <= 0xFF)
|
||||
{
|
||||
Value((Byte)n);
|
||||
}
|
||||
else if (n <= 0xFFFF)
|
||||
{
|
||||
Value((UInt16)n);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_store.Write((Byte)MsgPackType.UINT32);
|
||||
m_store.WriteBigEndian(n);
|
||||
}
|
||||
}
|
||||
|
||||
public void Value(ulong n)
|
||||
{
|
||||
if (n <= 0xFF)
|
||||
{
|
||||
Value((Byte)n);
|
||||
}
|
||||
else if (n <= 0xFFFF)
|
||||
{
|
||||
Value((UInt16)n);
|
||||
}
|
||||
else if (n <= 0xFFFFFFFF)
|
||||
{
|
||||
Value((UInt32)n);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_store.Write((Byte)MsgPackType.UINT64);
|
||||
m_store.WriteBigEndian(n);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
public void Value(float value)
|
||||
{
|
||||
m_store.Write((Byte)MsgPackType.FLOAT);
|
||||
m_store.WriteBigEndian(value);
|
||||
}
|
||||
|
||||
public void Value(double value)
|
||||
{
|
||||
m_store.Write((Byte)MsgPackType.DOUBLE);
|
||||
m_store.WriteBigEndian(value);
|
||||
}
|
||||
|
||||
public void Value(ArraySegment<byte> bytes)
|
||||
{
|
||||
if (bytes.Count < 0xFF)
|
||||
{
|
||||
m_store.Write((Byte)(MsgPackType.BIN8));
|
||||
m_store.Write((Byte)(bytes.Count));
|
||||
m_store.Write(bytes);
|
||||
}
|
||||
else if (bytes.Count < 0xFFFF)
|
||||
{
|
||||
m_store.Write((Byte)MsgPackType.BIN16);
|
||||
m_store.WriteBigEndian((UInt16)bytes.Count);
|
||||
m_store.Write(bytes);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_store.Write((Byte)MsgPackType.BIN32);
|
||||
m_store.WriteBigEndian(bytes.Count);
|
||||
m_store.Write(bytes);
|
||||
}
|
||||
}
|
||||
|
||||
public void TimeStamp32(DateTimeOffset time)
|
||||
{
|
||||
// https://github.com/ousttrue/UniJSON/blob/1.2/Scripts/Extensions/DateTimeOffsetExtensions.cs#L13-L16
|
||||
if (time < DateTimeOffsetExtensions.EpochTime)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
m_store.Write((Byte)MsgPackType.FIX_EXT_4);
|
||||
m_store.Write((SByte)(-1));
|
||||
m_store.WriteBigEndian((uint)time.ToUnixTimeSeconds());
|
||||
}
|
||||
|
||||
public void Value(DateTimeOffset time)
|
||||
{
|
||||
TimeStamp32(time);
|
||||
}
|
||||
|
||||
public void Value(ListTreeNode<MsgPackValue> node)
|
||||
{
|
||||
m_store.Write(node.Value.Bytes);
|
||||
}
|
||||
|
||||
public IStore GetStore()
|
||||
{
|
||||
return m_store;
|
||||
}
|
||||
|
||||
#region IRpc
|
||||
public const int REQUEST_TYPE = 0;
|
||||
public const int RESPONSE_TYPE = 1;
|
||||
public const int NOTIFY_TYPE = 2;
|
||||
|
||||
int m_msgId = 1;
|
||||
|
||||
public void Request(Utf8String method)
|
||||
{
|
||||
BeginList(4);
|
||||
Value(REQUEST_TYPE);
|
||||
Value(m_msgId++);
|
||||
Value(method);
|
||||
BeginList(0); // params
|
||||
{
|
||||
}
|
||||
EndList();
|
||||
EndList();
|
||||
}
|
||||
|
||||
public void Request<A0>(Utf8String method, A0 a0)
|
||||
{
|
||||
BeginList(4);
|
||||
Value(REQUEST_TYPE);
|
||||
Value(m_msgId++);
|
||||
Value(method);
|
||||
BeginList(1); // params
|
||||
{
|
||||
this.Serialize(a0);
|
||||
}
|
||||
EndList();
|
||||
EndList();
|
||||
}
|
||||
|
||||
public void Request<A0, A1>(Utf8String method, A0 a0, A1 a1)
|
||||
{
|
||||
BeginList(4);
|
||||
Value(REQUEST_TYPE);
|
||||
Value(m_msgId++);
|
||||
Value(method);
|
||||
BeginList(2); // params
|
||||
{
|
||||
this.Serialize(a0);
|
||||
this.Serialize(a1);
|
||||
}
|
||||
EndList();
|
||||
EndList();
|
||||
}
|
||||
|
||||
public void Request<A0, A1, A2>(Utf8String method, A0 a0, A1 a1, A2 a2)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void Request<A0, A1, A2, A3>(Utf8String method, A0 a0, A1 a1, A2 a2, A3 a3)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void Request<A0, A1, A2, A3, A4>(Utf8String method, A0 a0, A1 a1, A2 a2, A3 a3, A4 a4)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void Request<A0, A1, A2, A3, A4, A5>(Utf8String method, A0 a0, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void ResponseSuccess(int id)
|
||||
{
|
||||
BeginList(4);
|
||||
Value(RESPONSE_TYPE);
|
||||
Value(id);
|
||||
Null();
|
||||
Null();
|
||||
EndList();
|
||||
}
|
||||
|
||||
public void ResponseSuccess<T>(int id, T result)
|
||||
{
|
||||
BeginList(4);
|
||||
Value(RESPONSE_TYPE);
|
||||
Value(id);
|
||||
Null();
|
||||
this.Serialize(result);
|
||||
EndList();
|
||||
}
|
||||
|
||||
public void ResponseError(int id, Exception error)
|
||||
{
|
||||
BeginList(4);
|
||||
Value(RESPONSE_TYPE);
|
||||
Value(id);
|
||||
this.Serialize(error);
|
||||
Null();
|
||||
EndList();
|
||||
}
|
||||
|
||||
public void Notify(Utf8String method)
|
||||
{
|
||||
BeginList(3);
|
||||
Value(NOTIFY_TYPE);
|
||||
Value(method);
|
||||
BeginList(0); // params
|
||||
{
|
||||
}
|
||||
EndList();
|
||||
EndList();
|
||||
}
|
||||
|
||||
public void Notify<A0>(Utf8String method, A0 a0)
|
||||
{
|
||||
BeginList(3);
|
||||
Value(NOTIFY_TYPE);
|
||||
Value(method);
|
||||
BeginList(1); // params
|
||||
{
|
||||
this.Serialize(a0);
|
||||
}
|
||||
EndList();
|
||||
EndList();
|
||||
}
|
||||
|
||||
public void Notify<A0, A1>(Utf8String method, A0 a0, A1 a1)
|
||||
{
|
||||
BeginList(3);
|
||||
Value(NOTIFY_TYPE);
|
||||
Value(method);
|
||||
BeginList(2); // params
|
||||
{
|
||||
this.Serialize(a0);
|
||||
this.Serialize(a1);
|
||||
}
|
||||
EndList();
|
||||
EndList();
|
||||
}
|
||||
|
||||
public void Notify<A0, A1, A2>(Utf8String method, A0 a0, A1 a1, A2 a2)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void Notify<A0, A1, A2, A3>(Utf8String method, A0 a0, A1 a1, A2 a2, A3 a3)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void Notify<A0, A1, A2, A3, A4>(Utf8String method, A0 a0, A1 a1, A2 a2, A3 a3, A4 a4)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void Notify<A0, A1, A2, A3, A4, A5>(Utf8String method, A0 a0, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 41153eff97391fd46a31361bac5804fb
|
||||
timeCreated: 1540879112
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -1,416 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace UniJSON
|
||||
{
|
||||
public static class MsgPackParser
|
||||
{
|
||||
public static ListTreeNode<MsgPackValue> Parse(Byte[] bytes)
|
||||
{
|
||||
return Parse(new ArraySegment<byte>(bytes));
|
||||
}
|
||||
|
||||
static MsgPackType GetFormat(ArraySegment<Byte> bytes)
|
||||
{
|
||||
return (MsgPackType)bytes.Get(0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Array又はMapの子要素の数を得る
|
||||
/// </summary>
|
||||
/// <param name="count"></param>
|
||||
/// <returns></returns>
|
||||
static ArraySegment<Byte> GetItemCount(ArraySegment<Byte> bytes, MsgPackType formatType, out UInt32 count)
|
||||
{
|
||||
switch (formatType)
|
||||
{
|
||||
case MsgPackType.FIX_ARRAY: count = 0; return bytes.Advance(1);
|
||||
case MsgPackType.FIX_ARRAY_0x1: count = 1; return bytes.Advance(1);
|
||||
case MsgPackType.FIX_ARRAY_0x2: count = 2; return bytes.Advance(1);
|
||||
case MsgPackType.FIX_ARRAY_0x3: count = 3; return bytes.Advance(1);
|
||||
case MsgPackType.FIX_ARRAY_0x4: count = 4; return bytes.Advance(1);
|
||||
case MsgPackType.FIX_ARRAY_0x5: count = 5; return bytes.Advance(1);
|
||||
case MsgPackType.FIX_ARRAY_0x6: count = 6; return bytes.Advance(1);
|
||||
case MsgPackType.FIX_ARRAY_0x7: count = 7; return bytes.Advance(1);
|
||||
case MsgPackType.FIX_ARRAY_0x8: count = 8; return bytes.Advance(1);
|
||||
case MsgPackType.FIX_ARRAY_0x9: count = 9; return bytes.Advance(1);
|
||||
case MsgPackType.FIX_ARRAY_0xA: count = 10; return bytes.Advance(1);
|
||||
case MsgPackType.FIX_ARRAY_0xB: count = 11; return bytes.Advance(1);
|
||||
case MsgPackType.FIX_ARRAY_0xC: count = 12; return bytes.Advance(1);
|
||||
case MsgPackType.FIX_ARRAY_0xD: count = 13; return bytes.Advance(1);
|
||||
case MsgPackType.FIX_ARRAY_0xE: count = 14; return bytes.Advance(1);
|
||||
case MsgPackType.FIX_ARRAY_0xF: count = 15; return bytes.Advance(1);
|
||||
|
||||
case MsgPackType.FIX_MAP: count = 0; return bytes.Advance(1);
|
||||
case MsgPackType.FIX_MAP_0x1: count = 1; return bytes.Advance(1);
|
||||
case MsgPackType.FIX_MAP_0x2: count = 2; return bytes.Advance(1);
|
||||
case MsgPackType.FIX_MAP_0x3: count = 3; return bytes.Advance(1);
|
||||
case MsgPackType.FIX_MAP_0x4: count = 4; return bytes.Advance(1);
|
||||
case MsgPackType.FIX_MAP_0x5: count = 5; return bytes.Advance(1);
|
||||
case MsgPackType.FIX_MAP_0x6: count = 6; return bytes.Advance(1);
|
||||
case MsgPackType.FIX_MAP_0x7: count = 7; return bytes.Advance(1);
|
||||
case MsgPackType.FIX_MAP_0x8: count = 8; return bytes.Advance(1);
|
||||
case MsgPackType.FIX_MAP_0x9: count = 9; return bytes.Advance(1);
|
||||
case MsgPackType.FIX_MAP_0xA: count = 10; return bytes.Advance(1);
|
||||
case MsgPackType.FIX_MAP_0xB: count = 11; return bytes.Advance(1);
|
||||
case MsgPackType.FIX_MAP_0xC: count = 12; return bytes.Advance(1);
|
||||
case MsgPackType.FIX_MAP_0xD: count = 13; return bytes.Advance(1);
|
||||
case MsgPackType.FIX_MAP_0xE: count = 14; return bytes.Advance(1);
|
||||
case MsgPackType.FIX_MAP_0xF: count = 15; return bytes.Advance(1);
|
||||
|
||||
case MsgPackType.ARRAY16:
|
||||
case MsgPackType.MAP16:
|
||||
count = EndianConverter.NetworkByteWordToUnsignedNativeByteOrder(bytes.Advance(1));
|
||||
return bytes.Advance(1 + 2);
|
||||
|
||||
case MsgPackType.ARRAY32:
|
||||
case MsgPackType.MAP32:
|
||||
count = EndianConverter.NetworkByteDWordToUnsignedNativeByteOrder(bytes.Advance(1));
|
||||
return bytes.Advance(1 + 4);
|
||||
|
||||
default:
|
||||
throw new ArgumentException("is not collection: " + formatType);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ArrayとMap以外のタイプのペイロードを得る
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
static ArraySegment<Byte> GetBody(ArraySegment<Byte> bytes, MsgPackType formatType)
|
||||
{
|
||||
switch (formatType)
|
||||
{
|
||||
case MsgPackType.FIX_STR: return bytes.Advance(1).Take(0);
|
||||
case MsgPackType.FIX_STR_0x01: return bytes.Advance(1).Take(1);
|
||||
case MsgPackType.FIX_STR_0x02: return bytes.Advance(1).Take(2);
|
||||
case MsgPackType.FIX_STR_0x03: return bytes.Advance(1).Take(3);
|
||||
case MsgPackType.FIX_STR_0x04: return bytes.Advance(1).Take(4);
|
||||
case MsgPackType.FIX_STR_0x05: return bytes.Advance(1).Take(5);
|
||||
case MsgPackType.FIX_STR_0x06: return bytes.Advance(1).Take(6);
|
||||
case MsgPackType.FIX_STR_0x07: return bytes.Advance(1).Take(7);
|
||||
case MsgPackType.FIX_STR_0x08: return bytes.Advance(1).Take(8);
|
||||
case MsgPackType.FIX_STR_0x09: return bytes.Advance(1).Take(9);
|
||||
case MsgPackType.FIX_STR_0x0A: return bytes.Advance(1).Take(10);
|
||||
case MsgPackType.FIX_STR_0x0B: return bytes.Advance(1).Take(11);
|
||||
case MsgPackType.FIX_STR_0x0C: return bytes.Advance(1).Take(12);
|
||||
case MsgPackType.FIX_STR_0x0D: return bytes.Advance(1).Take(13);
|
||||
case MsgPackType.FIX_STR_0x0E: return bytes.Advance(1).Take(14);
|
||||
case MsgPackType.FIX_STR_0x0F: return bytes.Advance(1).Take(15);
|
||||
|
||||
case MsgPackType.FIX_STR_0x10: return bytes.Advance(1).Take(16);
|
||||
case MsgPackType.FIX_STR_0x11: return bytes.Advance(1).Take(17);
|
||||
case MsgPackType.FIX_STR_0x12: return bytes.Advance(1).Take(18);
|
||||
case MsgPackType.FIX_STR_0x13: return bytes.Advance(1).Take(19);
|
||||
case MsgPackType.FIX_STR_0x14: return bytes.Advance(1).Take(20);
|
||||
case MsgPackType.FIX_STR_0x15: return bytes.Advance(1).Take(21);
|
||||
case MsgPackType.FIX_STR_0x16: return bytes.Advance(1).Take(22);
|
||||
case MsgPackType.FIX_STR_0x17: return bytes.Advance(1).Take(23);
|
||||
case MsgPackType.FIX_STR_0x18: return bytes.Advance(1).Take(24);
|
||||
case MsgPackType.FIX_STR_0x19: return bytes.Advance(1).Take(25);
|
||||
case MsgPackType.FIX_STR_0x1A: return bytes.Advance(1).Take(26);
|
||||
case MsgPackType.FIX_STR_0x1B: return bytes.Advance(1).Take(27);
|
||||
case MsgPackType.FIX_STR_0x1C: return bytes.Advance(1).Take(28);
|
||||
case MsgPackType.FIX_STR_0x1D: return bytes.Advance(1).Take(29);
|
||||
case MsgPackType.FIX_STR_0x1E: return bytes.Advance(1).Take(30);
|
||||
case MsgPackType.FIX_STR_0x1F: return bytes.Advance(1).Take(31);
|
||||
|
||||
case MsgPackType.STR8:
|
||||
case MsgPackType.BIN8:
|
||||
{
|
||||
var count = bytes.Get(1);
|
||||
return bytes.Advance(1 + 1).Take(count);
|
||||
}
|
||||
|
||||
case MsgPackType.STR16:
|
||||
case MsgPackType.BIN16:
|
||||
{
|
||||
var count = EndianConverter.NetworkByteWordToUnsignedNativeByteOrder(bytes.Advance(1));
|
||||
return bytes.Advance(1 + 2).Take(count);
|
||||
}
|
||||
|
||||
case MsgPackType.STR32:
|
||||
case MsgPackType.BIN32:
|
||||
{
|
||||
var count = EndianConverter.NetworkByteDWordToUnsignedNativeByteOrder(bytes.Advance(1));
|
||||
return bytes.Advance(1 + 4).Take((int)count);
|
||||
}
|
||||
|
||||
case MsgPackType.NIL:
|
||||
case MsgPackType.TRUE:
|
||||
case MsgPackType.FALSE:
|
||||
case MsgPackType.POSITIVE_FIXNUM:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x01:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x02:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x03:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x04:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x05:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x06:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x07:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x08:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x09:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x0A:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x0B:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x0C:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x0D:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x0E:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x0F:
|
||||
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x10:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x11:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x12:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x13:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x14:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x15:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x16:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x17:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x18:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x19:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x1A:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x1B:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x1C:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x1D:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x1E:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x1F:
|
||||
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x20:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x21:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x22:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x23:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x24:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x25:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x26:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x27:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x28:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x29:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x2A:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x2B:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x2C:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x2D:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x2E:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x2F:
|
||||
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x30:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x31:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x32:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x33:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x34:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x35:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x36:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x37:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x38:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x39:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x3A:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x3B:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x3C:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x3D:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x3E:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x3F:
|
||||
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x40:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x41:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x42:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x43:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x44:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x45:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x46:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x47:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x48:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x49:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x4A:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x4B:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x4C:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x4D:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x4E:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x4F:
|
||||
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x50:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x51:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x52:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x53:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x54:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x55:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x56:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x57:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x58:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x59:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x5A:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x5B:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x5C:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x5D:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x5E:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x5F:
|
||||
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x60:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x61:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x62:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x63:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x64:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x65:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x66:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x67:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x68:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x69:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x6A:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x6B:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x6C:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x6D:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x6E:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x6F:
|
||||
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x70:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x71:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x72:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x73:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x74:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x75:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x76:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x77:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x78:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x79:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x7A:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x7B:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x7C:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x7D:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x7E:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x7F:
|
||||
|
||||
case MsgPackType.NEGATIVE_FIXNUM:
|
||||
case MsgPackType.NEGATIVE_FIXNUM_0x01:
|
||||
case MsgPackType.NEGATIVE_FIXNUM_0x02:
|
||||
case MsgPackType.NEGATIVE_FIXNUM_0x03:
|
||||
case MsgPackType.NEGATIVE_FIXNUM_0x04:
|
||||
case MsgPackType.NEGATIVE_FIXNUM_0x05:
|
||||
case MsgPackType.NEGATIVE_FIXNUM_0x06:
|
||||
case MsgPackType.NEGATIVE_FIXNUM_0x07:
|
||||
case MsgPackType.NEGATIVE_FIXNUM_0x08:
|
||||
case MsgPackType.NEGATIVE_FIXNUM_0x09:
|
||||
case MsgPackType.NEGATIVE_FIXNUM_0x0A:
|
||||
case MsgPackType.NEGATIVE_FIXNUM_0x0B:
|
||||
case MsgPackType.NEGATIVE_FIXNUM_0x0C:
|
||||
case MsgPackType.NEGATIVE_FIXNUM_0x0D:
|
||||
case MsgPackType.NEGATIVE_FIXNUM_0x0E:
|
||||
case MsgPackType.NEGATIVE_FIXNUM_0x0F:
|
||||
case MsgPackType.NEGATIVE_FIXNUM_0x10:
|
||||
case MsgPackType.NEGATIVE_FIXNUM_0x11:
|
||||
case MsgPackType.NEGATIVE_FIXNUM_0x12:
|
||||
case MsgPackType.NEGATIVE_FIXNUM_0x13:
|
||||
case MsgPackType.NEGATIVE_FIXNUM_0x14:
|
||||
case MsgPackType.NEGATIVE_FIXNUM_0x15:
|
||||
case MsgPackType.NEGATIVE_FIXNUM_0x16:
|
||||
case MsgPackType.NEGATIVE_FIXNUM_0x17:
|
||||
case MsgPackType.NEGATIVE_FIXNUM_0x18:
|
||||
case MsgPackType.NEGATIVE_FIXNUM_0x19:
|
||||
case MsgPackType.NEGATIVE_FIXNUM_0x1A:
|
||||
case MsgPackType.NEGATIVE_FIXNUM_0x1B:
|
||||
case MsgPackType.NEGATIVE_FIXNUM_0x1C:
|
||||
case MsgPackType.NEGATIVE_FIXNUM_0x1D:
|
||||
case MsgPackType.NEGATIVE_FIXNUM_0x1E:
|
||||
case MsgPackType.NEGATIVE_FIXNUM_0x1F:
|
||||
return bytes.Advance(1).Take(0);
|
||||
|
||||
case MsgPackType.UINT8:
|
||||
case MsgPackType.INT8:
|
||||
return bytes.Advance(1).Take(1);
|
||||
|
||||
case MsgPackType.UINT16:
|
||||
case MsgPackType.INT16:
|
||||
return bytes.Advance(1).Take(2);
|
||||
|
||||
case MsgPackType.UINT32:
|
||||
case MsgPackType.INT32:
|
||||
case MsgPackType.FLOAT:
|
||||
return bytes.Advance(1).Take(4);
|
||||
|
||||
case MsgPackType.UINT64:
|
||||
case MsgPackType.INT64:
|
||||
case MsgPackType.DOUBLE:
|
||||
return bytes.Advance(1).Take(8);
|
||||
|
||||
case MsgPackType.FIX_EXT_1:
|
||||
return bytes.Advance(2).Take(1);
|
||||
case MsgPackType.FIX_EXT_2:
|
||||
return bytes.Advance(2).Take(2);
|
||||
case MsgPackType.FIX_EXT_4:
|
||||
return bytes.Advance(2).Take(4);
|
||||
case MsgPackType.FIX_EXT_8:
|
||||
return bytes.Advance(2).Take(8);
|
||||
case MsgPackType.FIX_EXT_16:
|
||||
return bytes.Advance(2).Take(16);
|
||||
case MsgPackType.EXT8:
|
||||
{
|
||||
var count = bytes.Get(1);
|
||||
return bytes.Advance(1 + 1 + 1).Take(count);
|
||||
}
|
||||
case MsgPackType.EXT16:
|
||||
{
|
||||
var count = EndianConverter.NetworkByteWordToUnsignedNativeByteOrder(bytes.Advance(1));
|
||||
return bytes.Advance(1 + 2 + 1).Take(count);
|
||||
}
|
||||
case MsgPackType.EXT32:
|
||||
{
|
||||
var count = EndianConverter.NetworkByteDWordToUnsignedNativeByteOrder(bytes.Advance(1));
|
||||
return bytes.Advance(1 + 4 + 1).Take((int)count);
|
||||
}
|
||||
default:
|
||||
throw new ArgumentException("unknown type: " + formatType);
|
||||
}
|
||||
}
|
||||
|
||||
static ListTreeNode<MsgPackValue> _Parse(ListTreeNode<MsgPackValue> tree, ArraySegment<Byte> bytes)
|
||||
{
|
||||
MsgPackType formatType = GetFormat(bytes);
|
||||
if (formatType.IsArray())
|
||||
{
|
||||
var array = tree.AddValue(bytes, ValueNodeType.Array);
|
||||
|
||||
uint count;
|
||||
bytes = GetItemCount(bytes, formatType, out count);
|
||||
for (var i = 0; i < count; ++i)
|
||||
{
|
||||
var child = _Parse(array, bytes);
|
||||
bytes = bytes.Advance(child.Value.Bytes.Count);
|
||||
}
|
||||
|
||||
array.SetValueBytesCount(bytes.Offset - array.Value.Bytes.Offset);
|
||||
|
||||
return array;
|
||||
}
|
||||
else if (formatType.IsMap())
|
||||
{
|
||||
var obj = tree.AddValue(bytes, ValueNodeType.Object);
|
||||
|
||||
uint count;
|
||||
bytes = GetItemCount(bytes, formatType, out count);
|
||||
for (var i = 0; i < count; ++i)
|
||||
{
|
||||
// key
|
||||
var key = _Parse(obj, bytes);
|
||||
bytes = bytes.Advance(key.Value.Bytes.Count);
|
||||
|
||||
// value
|
||||
var value = _Parse(obj, bytes);
|
||||
bytes = bytes.Advance(value.Value.Bytes.Count);
|
||||
}
|
||||
|
||||
obj.SetValueBytesCount(bytes.Offset - obj.Value.Bytes.Offset);
|
||||
|
||||
return obj;
|
||||
}
|
||||
else
|
||||
{
|
||||
var body = GetBody(bytes, formatType);
|
||||
var headerSize = body.Offset - bytes.Offset;
|
||||
var size = headerSize + body.Count;
|
||||
|
||||
var value = tree.AddValue(bytes.Take(size), ValueNodeType.Null);
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
public static ListTreeNode<MsgPackValue> Parse(ArraySegment<Byte> bytes)
|
||||
{
|
||||
return _Parse(default(ListTreeNode<MsgPackValue>), bytes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 96621564d26fc294291143738c163a3d
|
||||
timeCreated: 1540815282
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -1,313 +0,0 @@
|
|||
namespace UniJSON
|
||||
{
|
||||
public enum MsgPackType : byte
|
||||
{
|
||||
#region POSITIVE_FIXNUM 0x00-0x7F
|
||||
POSITIVE_FIXNUM = 0x00,
|
||||
POSITIVE_FIXNUM_0x01 = 0x01,
|
||||
POSITIVE_FIXNUM_0x02 = 0x02,
|
||||
POSITIVE_FIXNUM_0x03 = 0x03,
|
||||
POSITIVE_FIXNUM_0x04 = 0x04,
|
||||
POSITIVE_FIXNUM_0x05 = 0x05,
|
||||
POSITIVE_FIXNUM_0x06 = 0x06,
|
||||
POSITIVE_FIXNUM_0x07 = 0x07,
|
||||
POSITIVE_FIXNUM_0x08 = 0x08,
|
||||
POSITIVE_FIXNUM_0x09 = 0x09,
|
||||
POSITIVE_FIXNUM_0x0A = 0x0A,
|
||||
POSITIVE_FIXNUM_0x0B = 0x0B,
|
||||
POSITIVE_FIXNUM_0x0C = 0x0C,
|
||||
POSITIVE_FIXNUM_0x0D = 0x0D,
|
||||
POSITIVE_FIXNUM_0x0E = 0x0E,
|
||||
POSITIVE_FIXNUM_0x0F = 0x0F,
|
||||
|
||||
POSITIVE_FIXNUM_0x10 = 0x10,
|
||||
POSITIVE_FIXNUM_0x11 = 0x11,
|
||||
POSITIVE_FIXNUM_0x12 = 0x12,
|
||||
POSITIVE_FIXNUM_0x13 = 0x13,
|
||||
POSITIVE_FIXNUM_0x14 = 0x14,
|
||||
POSITIVE_FIXNUM_0x15 = 0x15,
|
||||
POSITIVE_FIXNUM_0x16 = 0x16,
|
||||
POSITIVE_FIXNUM_0x17 = 0x17,
|
||||
POSITIVE_FIXNUM_0x18 = 0x18,
|
||||
POSITIVE_FIXNUM_0x19 = 0x19,
|
||||
POSITIVE_FIXNUM_0x1A = 0x1A,
|
||||
POSITIVE_FIXNUM_0x1B = 0x1B,
|
||||
POSITIVE_FIXNUM_0x1C = 0x1C,
|
||||
POSITIVE_FIXNUM_0x1D = 0x1D,
|
||||
POSITIVE_FIXNUM_0x1E = 0x1E,
|
||||
POSITIVE_FIXNUM_0x1F = 0x1F,
|
||||
|
||||
POSITIVE_FIXNUM_0x20 = 0x20,
|
||||
POSITIVE_FIXNUM_0x21 = 0x21,
|
||||
POSITIVE_FIXNUM_0x22 = 0x22,
|
||||
POSITIVE_FIXNUM_0x23 = 0x23,
|
||||
POSITIVE_FIXNUM_0x24 = 0x24,
|
||||
POSITIVE_FIXNUM_0x25 = 0x25,
|
||||
POSITIVE_FIXNUM_0x26 = 0x26,
|
||||
POSITIVE_FIXNUM_0x27 = 0x27,
|
||||
POSITIVE_FIXNUM_0x28 = 0x28,
|
||||
POSITIVE_FIXNUM_0x29 = 0x29,
|
||||
POSITIVE_FIXNUM_0x2A = 0x2A,
|
||||
POSITIVE_FIXNUM_0x2B = 0x2B,
|
||||
POSITIVE_FIXNUM_0x2C = 0x2C,
|
||||
POSITIVE_FIXNUM_0x2D = 0x2D,
|
||||
POSITIVE_FIXNUM_0x2E = 0x2E,
|
||||
POSITIVE_FIXNUM_0x2F = 0x2F,
|
||||
|
||||
POSITIVE_FIXNUM_0x30 = 0x30,
|
||||
POSITIVE_FIXNUM_0x31 = 0x31,
|
||||
POSITIVE_FIXNUM_0x32 = 0x32,
|
||||
POSITIVE_FIXNUM_0x33 = 0x33,
|
||||
POSITIVE_FIXNUM_0x34 = 0x34,
|
||||
POSITIVE_FIXNUM_0x35 = 0x35,
|
||||
POSITIVE_FIXNUM_0x36 = 0x36,
|
||||
POSITIVE_FIXNUM_0x37 = 0x37,
|
||||
POSITIVE_FIXNUM_0x38 = 0x38,
|
||||
POSITIVE_FIXNUM_0x39 = 0x39,
|
||||
POSITIVE_FIXNUM_0x3A = 0x3A,
|
||||
POSITIVE_FIXNUM_0x3B = 0x3B,
|
||||
POSITIVE_FIXNUM_0x3C = 0x3C,
|
||||
POSITIVE_FIXNUM_0x3D = 0x3D,
|
||||
POSITIVE_FIXNUM_0x3E = 0x3E,
|
||||
POSITIVE_FIXNUM_0x3F = 0x3F,
|
||||
|
||||
POSITIVE_FIXNUM_0x40 = 0x40,
|
||||
POSITIVE_FIXNUM_0x41 = 0x41,
|
||||
POSITIVE_FIXNUM_0x42 = 0x42,
|
||||
POSITIVE_FIXNUM_0x43 = 0x43,
|
||||
POSITIVE_FIXNUM_0x44 = 0x44,
|
||||
POSITIVE_FIXNUM_0x45 = 0x45,
|
||||
POSITIVE_FIXNUM_0x46 = 0x46,
|
||||
POSITIVE_FIXNUM_0x47 = 0x47,
|
||||
POSITIVE_FIXNUM_0x48 = 0x48,
|
||||
POSITIVE_FIXNUM_0x49 = 0x49,
|
||||
POSITIVE_FIXNUM_0x4A = 0x4A,
|
||||
POSITIVE_FIXNUM_0x4B = 0x4B,
|
||||
POSITIVE_FIXNUM_0x4C = 0x4C,
|
||||
POSITIVE_FIXNUM_0x4D = 0x4D,
|
||||
POSITIVE_FIXNUM_0x4E = 0x4E,
|
||||
POSITIVE_FIXNUM_0x4F = 0x4F,
|
||||
|
||||
POSITIVE_FIXNUM_0x50 = 0x50,
|
||||
POSITIVE_FIXNUM_0x51 = 0x51,
|
||||
POSITIVE_FIXNUM_0x52 = 0x52,
|
||||
POSITIVE_FIXNUM_0x53 = 0x53,
|
||||
POSITIVE_FIXNUM_0x54 = 0x54,
|
||||
POSITIVE_FIXNUM_0x55 = 0x55,
|
||||
POSITIVE_FIXNUM_0x56 = 0x56,
|
||||
POSITIVE_FIXNUM_0x57 = 0x57,
|
||||
POSITIVE_FIXNUM_0x58 = 0x58,
|
||||
POSITIVE_FIXNUM_0x59 = 0x59,
|
||||
POSITIVE_FIXNUM_0x5A = 0x5A,
|
||||
POSITIVE_FIXNUM_0x5B = 0x5B,
|
||||
POSITIVE_FIXNUM_0x5C = 0x5C,
|
||||
POSITIVE_FIXNUM_0x5D = 0x5D,
|
||||
POSITIVE_FIXNUM_0x5E = 0x5E,
|
||||
POSITIVE_FIXNUM_0x5F = 0x5F,
|
||||
|
||||
POSITIVE_FIXNUM_0x60 = 0x60,
|
||||
POSITIVE_FIXNUM_0x61 = 0x61,
|
||||
POSITIVE_FIXNUM_0x62 = 0x62,
|
||||
POSITIVE_FIXNUM_0x63 = 0x63,
|
||||
POSITIVE_FIXNUM_0x64 = 0x64,
|
||||
POSITIVE_FIXNUM_0x65 = 0x65,
|
||||
POSITIVE_FIXNUM_0x66 = 0x66,
|
||||
POSITIVE_FIXNUM_0x67 = 0x67,
|
||||
POSITIVE_FIXNUM_0x68 = 0x68,
|
||||
POSITIVE_FIXNUM_0x69 = 0x69,
|
||||
POSITIVE_FIXNUM_0x6A = 0x6A,
|
||||
POSITIVE_FIXNUM_0x6B = 0x6B,
|
||||
POSITIVE_FIXNUM_0x6C = 0x6C,
|
||||
POSITIVE_FIXNUM_0x6D = 0x6D,
|
||||
POSITIVE_FIXNUM_0x6E = 0x6E,
|
||||
POSITIVE_FIXNUM_0x6F = 0x6F,
|
||||
|
||||
POSITIVE_FIXNUM_0x70 = 0x70,
|
||||
POSITIVE_FIXNUM_0x71 = 0x71,
|
||||
POSITIVE_FIXNUM_0x72 = 0x72,
|
||||
POSITIVE_FIXNUM_0x73 = 0x73,
|
||||
POSITIVE_FIXNUM_0x74 = 0x74,
|
||||
POSITIVE_FIXNUM_0x75 = 0x75,
|
||||
POSITIVE_FIXNUM_0x76 = 0x76,
|
||||
POSITIVE_FIXNUM_0x77 = 0x77,
|
||||
POSITIVE_FIXNUM_0x78 = 0x78,
|
||||
POSITIVE_FIXNUM_0x79 = 0x79,
|
||||
POSITIVE_FIXNUM_0x7A = 0x7A,
|
||||
POSITIVE_FIXNUM_0x7B = 0x7B,
|
||||
POSITIVE_FIXNUM_0x7C = 0x7C,
|
||||
POSITIVE_FIXNUM_0x7D = 0x7D,
|
||||
POSITIVE_FIXNUM_0x7E = 0x7E,
|
||||
POSITIVE_FIXNUM_0x7F = 0x7F,
|
||||
#endregion
|
||||
|
||||
#region FIX_MAP 0x80-0x8F
|
||||
FIX_MAP = 0x80,
|
||||
FIX_MAP_0x1 = 0x81,
|
||||
FIX_MAP_0x2 = 0x82,
|
||||
FIX_MAP_0x3 = 0x83,
|
||||
FIX_MAP_0x4 = 0x84,
|
||||
FIX_MAP_0x5 = 0x85,
|
||||
FIX_MAP_0x6 = 0x86,
|
||||
FIX_MAP_0x7 = 0x87,
|
||||
FIX_MAP_0x8 = 0x88,
|
||||
FIX_MAP_0x9 = 0x89,
|
||||
FIX_MAP_0xA = 0x8A,
|
||||
FIX_MAP_0xB = 0x8B,
|
||||
FIX_MAP_0xC = 0x8C,
|
||||
FIX_MAP_0xD = 0x8D,
|
||||
FIX_MAP_0xE = 0x8E,
|
||||
FIX_MAP_0xF = 0x8F,
|
||||
#endregion
|
||||
|
||||
#region FIX_ARRAY 0x90-0x9F
|
||||
FIX_ARRAY = 0x90,
|
||||
FIX_ARRAY_0x1 = 0x91,
|
||||
FIX_ARRAY_0x2 = 0x92,
|
||||
FIX_ARRAY_0x3 = 0x93,
|
||||
FIX_ARRAY_0x4 = 0x94,
|
||||
FIX_ARRAY_0x5 = 0x95,
|
||||
FIX_ARRAY_0x6 = 0x96,
|
||||
FIX_ARRAY_0x7 = 0x97,
|
||||
FIX_ARRAY_0x8 = 0x98,
|
||||
FIX_ARRAY_0x9 = 0x99,
|
||||
FIX_ARRAY_0xA = 0x9A,
|
||||
FIX_ARRAY_0xB = 0x9B,
|
||||
FIX_ARRAY_0xC = 0x9C,
|
||||
FIX_ARRAY_0xD = 0x9D,
|
||||
FIX_ARRAY_0xE = 0x9E,
|
||||
FIX_ARRAY_0xF = 0x9F,
|
||||
#endregion
|
||||
|
||||
#region FIX_STR 0xA0-0xBF
|
||||
FIX_STR = 0xA0,
|
||||
FIX_STR_0x01 = 0xA1,
|
||||
FIX_STR_0x02 = 0xA2,
|
||||
FIX_STR_0x03 = 0xA3,
|
||||
FIX_STR_0x04 = 0xA4,
|
||||
FIX_STR_0x05 = 0xA5,
|
||||
FIX_STR_0x06 = 0xA6,
|
||||
FIX_STR_0x07 = 0xA7,
|
||||
FIX_STR_0x08 = 0xA8,
|
||||
FIX_STR_0x09 = 0xA9,
|
||||
FIX_STR_0x0A = 0xAA,
|
||||
FIX_STR_0x0B = 0xAB,
|
||||
FIX_STR_0x0C = 0xAC,
|
||||
FIX_STR_0x0D = 0xAD,
|
||||
FIX_STR_0x0E = 0xAE,
|
||||
FIX_STR_0x0F = 0xAF,
|
||||
FIX_STR_0x10 = 0xB0,
|
||||
FIX_STR_0x11 = 0xB1,
|
||||
FIX_STR_0x12 = 0xB2,
|
||||
FIX_STR_0x13 = 0xB3,
|
||||
FIX_STR_0x14 = 0xB4,
|
||||
FIX_STR_0x15 = 0xB5,
|
||||
FIX_STR_0x16 = 0xB6,
|
||||
FIX_STR_0x17 = 0xB7,
|
||||
FIX_STR_0x18 = 0xB8,
|
||||
FIX_STR_0x19 = 0xB9,
|
||||
FIX_STR_0x1A = 0xBA,
|
||||
FIX_STR_0x1B = 0xBB,
|
||||
FIX_STR_0x1C = 0xBC,
|
||||
FIX_STR_0x1D = 0xBD,
|
||||
FIX_STR_0x1E = 0xBE,
|
||||
FIX_STR_0x1F = 0xBF,
|
||||
#endregion
|
||||
|
||||
NIL = 0xC0,
|
||||
NEVER_USED = 0xC1,
|
||||
FALSE = 0xC2,
|
||||
TRUE = 0xC3,
|
||||
|
||||
BIN8 = 0xC4,
|
||||
BIN16 = 0xC5,
|
||||
BIN32 = 0xC6,
|
||||
|
||||
EXT8 = 0xC7,
|
||||
EXT16 = 0xC8,
|
||||
EXT32 = 0xC9,
|
||||
|
||||
FLOAT = 0xCA,
|
||||
DOUBLE = 0xCB,
|
||||
UINT8 = 0xCC,
|
||||
UINT16 = 0xCD,
|
||||
UINT32 = 0xCE,
|
||||
UINT64 = 0xCF,
|
||||
INT8 = 0xD0,
|
||||
INT16 = 0xD1,
|
||||
INT32 = 0xD2,
|
||||
INT64 = 0xD3,
|
||||
|
||||
FIX_EXT_1 = 0xD4,
|
||||
FIX_EXT_2 = 0xD5,
|
||||
FIX_EXT_4 = 0xD6,
|
||||
FIX_EXT_8 = 0xD7,
|
||||
FIX_EXT_16 = 0xD8,
|
||||
|
||||
STR8 = 0xD9,
|
||||
STR16 = 0xDA,
|
||||
STR32 = 0xDB,
|
||||
|
||||
ARRAY16 = 0xDC,
|
||||
ARRAY32 = 0xDD,
|
||||
MAP16 = 0xDE,
|
||||
MAP32 = 0xDF,
|
||||
|
||||
#region NEGATIVE_FIXNUM 0xE0-0xFF
|
||||
NEGATIVE_FIXNUM = 0xE0, // 1110 0000 = -32
|
||||
NEGATIVE_FIXNUM_0x1F = 0xE1, // -31
|
||||
NEGATIVE_FIXNUM_0x1E = 0xE2,
|
||||
NEGATIVE_FIXNUM_0x1D = 0xE3,
|
||||
NEGATIVE_FIXNUM_0x1C = 0xE4,
|
||||
NEGATIVE_FIXNUM_0x1B = 0xE5,
|
||||
NEGATIVE_FIXNUM_0x1A = 0xE6,
|
||||
NEGATIVE_FIXNUM_0x19 = 0xE7,
|
||||
NEGATIVE_FIXNUM_0x18 = 0xE8,
|
||||
NEGATIVE_FIXNUM_0x17 = 0xE9,
|
||||
NEGATIVE_FIXNUM_0x16 = 0xEA,
|
||||
NEGATIVE_FIXNUM_0x15 = 0xEB,
|
||||
NEGATIVE_FIXNUM_0x14 = 0xEC,
|
||||
NEGATIVE_FIXNUM_0x13 = 0xED,
|
||||
NEGATIVE_FIXNUM_0x12 = 0xEE,
|
||||
NEGATIVE_FIXNUM_0x11 = 0xEF,
|
||||
NEGATIVE_FIXNUM_0x10 = 0xF0,
|
||||
NEGATIVE_FIXNUM_0x0F = 0xF1,
|
||||
NEGATIVE_FIXNUM_0x0E = 0xF2,
|
||||
NEGATIVE_FIXNUM_0x0D = 0xF3,
|
||||
NEGATIVE_FIXNUM_0x0C = 0xF4,
|
||||
NEGATIVE_FIXNUM_0x0B = 0xF5,
|
||||
NEGATIVE_FIXNUM_0x0A = 0xF6,
|
||||
NEGATIVE_FIXNUM_0x09 = 0xF7,
|
||||
NEGATIVE_FIXNUM_0x08 = 0xF8,
|
||||
NEGATIVE_FIXNUM_0x07 = 0xF9,
|
||||
NEGATIVE_FIXNUM_0x06 = 0xFA,
|
||||
NEGATIVE_FIXNUM_0x05 = 0xFB,
|
||||
NEGATIVE_FIXNUM_0x04 = 0xFC,
|
||||
NEGATIVE_FIXNUM_0x03 = 0xFD,
|
||||
NEGATIVE_FIXNUM_0x02 = 0xFE,
|
||||
NEGATIVE_FIXNUM_0x01 = 0xFF, // -1
|
||||
#endregion
|
||||
}
|
||||
|
||||
public enum ExtType : byte
|
||||
{
|
||||
UNKNOWN = 0x00,
|
||||
|
||||
UINT16_BE = 0x01,
|
||||
UINT32_BE = 0x02,
|
||||
UINT64_BE = 0x03,
|
||||
INT16_BE = 0x04,
|
||||
INT32_BE = 0x05,
|
||||
INT64_BE = 0x06,
|
||||
SINGLE_BE = 0x07,
|
||||
DOUBLE_BE = 0x08,
|
||||
|
||||
UINT16_LE = 0x09,
|
||||
UINT32_LE = 0x0A,
|
||||
UINT64_LE = 0x0B,
|
||||
INT16_LE = 0x0C,
|
||||
INT32_LE = 0x0D,
|
||||
INT64_LE = 0x0E,
|
||||
SINGLE_LE = 0x0F,
|
||||
DOUBLE_LE = 0x10,
|
||||
}
|
||||
}
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 4c6d91a562e590e438f0baa988389d61
|
||||
timeCreated: 1540814648
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -1,341 +0,0 @@
|
|||
namespace UniJSON
|
||||
{
|
||||
public static class MsgPackTypeExtensions
|
||||
{
|
||||
public static bool IsArray(this MsgPackType formatType)
|
||||
{
|
||||
switch (formatType)
|
||||
{
|
||||
case MsgPackType.FIX_ARRAY:
|
||||
case MsgPackType.FIX_ARRAY_0x1:
|
||||
case MsgPackType.FIX_ARRAY_0x2:
|
||||
case MsgPackType.FIX_ARRAY_0x3:
|
||||
case MsgPackType.FIX_ARRAY_0x4:
|
||||
case MsgPackType.FIX_ARRAY_0x5:
|
||||
case MsgPackType.FIX_ARRAY_0x6:
|
||||
case MsgPackType.FIX_ARRAY_0x7:
|
||||
case MsgPackType.FIX_ARRAY_0x8:
|
||||
case MsgPackType.FIX_ARRAY_0x9:
|
||||
case MsgPackType.FIX_ARRAY_0xA:
|
||||
case MsgPackType.FIX_ARRAY_0xB:
|
||||
case MsgPackType.FIX_ARRAY_0xC:
|
||||
case MsgPackType.FIX_ARRAY_0xD:
|
||||
case MsgPackType.FIX_ARRAY_0xE:
|
||||
case MsgPackType.FIX_ARRAY_0xF:
|
||||
case MsgPackType.ARRAY16:
|
||||
case MsgPackType.ARRAY32:
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool IsMap(this MsgPackType formatType)
|
||||
{
|
||||
switch (formatType)
|
||||
{
|
||||
case MsgPackType.FIX_MAP:
|
||||
case MsgPackType.FIX_MAP_0x1:
|
||||
case MsgPackType.FIX_MAP_0x2:
|
||||
case MsgPackType.FIX_MAP_0x3:
|
||||
case MsgPackType.FIX_MAP_0x4:
|
||||
case MsgPackType.FIX_MAP_0x5:
|
||||
case MsgPackType.FIX_MAP_0x6:
|
||||
case MsgPackType.FIX_MAP_0x7:
|
||||
case MsgPackType.FIX_MAP_0x8:
|
||||
case MsgPackType.FIX_MAP_0x9:
|
||||
case MsgPackType.FIX_MAP_0xA:
|
||||
case MsgPackType.FIX_MAP_0xB:
|
||||
case MsgPackType.FIX_MAP_0xC:
|
||||
case MsgPackType.FIX_MAP_0xD:
|
||||
case MsgPackType.FIX_MAP_0xE:
|
||||
case MsgPackType.FIX_MAP_0xF:
|
||||
case MsgPackType.MAP16:
|
||||
case MsgPackType.MAP32:
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool IsInteger(this MsgPackType formatType)
|
||||
{
|
||||
switch (formatType)
|
||||
{
|
||||
case MsgPackType.POSITIVE_FIXNUM:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x01:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x02:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x03:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x04:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x05:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x06:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x07:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x08:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x09:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x0A:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x0B:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x0C:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x0D:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x0E:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x0F:
|
||||
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x10:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x11:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x12:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x13:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x14:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x15:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x16:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x17:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x18:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x19:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x1A:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x1B:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x1C:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x1D:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x1E:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x1F:
|
||||
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x20:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x21:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x22:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x23:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x24:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x25:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x26:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x27:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x28:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x29:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x2A:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x2B:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x2C:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x2D:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x2E:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x2F:
|
||||
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x30:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x31:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x32:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x33:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x34:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x35:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x36:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x37:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x38:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x39:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x3A:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x3B:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x3C:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x3D:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x3E:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x3F:
|
||||
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x40:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x41:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x42:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x43:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x44:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x45:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x46:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x47:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x48:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x49:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x4A:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x4B:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x4C:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x4D:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x4E:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x4F:
|
||||
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x50:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x51:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x52:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x53:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x54:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x55:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x56:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x57:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x58:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x59:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x5A:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x5B:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x5C:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x5D:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x5E:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x5F:
|
||||
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x60:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x61:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x62:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x63:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x64:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x65:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x66:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x67:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x68:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x69:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x6A:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x6B:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x6C:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x6D:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x6E:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x6F:
|
||||
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x70:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x71:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x72:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x73:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x74:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x75:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x76:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x77:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x78:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x79:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x7A:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x7B:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x7C:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x7D:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x7E:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x7F:
|
||||
|
||||
case MsgPackType.NEGATIVE_FIXNUM:
|
||||
case MsgPackType.NEGATIVE_FIXNUM_0x01:
|
||||
case MsgPackType.NEGATIVE_FIXNUM_0x02:
|
||||
case MsgPackType.NEGATIVE_FIXNUM_0x03:
|
||||
case MsgPackType.NEGATIVE_FIXNUM_0x04:
|
||||
case MsgPackType.NEGATIVE_FIXNUM_0x05:
|
||||
case MsgPackType.NEGATIVE_FIXNUM_0x06:
|
||||
case MsgPackType.NEGATIVE_FIXNUM_0x07:
|
||||
case MsgPackType.NEGATIVE_FIXNUM_0x08:
|
||||
case MsgPackType.NEGATIVE_FIXNUM_0x09:
|
||||
case MsgPackType.NEGATIVE_FIXNUM_0x0A:
|
||||
case MsgPackType.NEGATIVE_FIXNUM_0x0B:
|
||||
case MsgPackType.NEGATIVE_FIXNUM_0x0C:
|
||||
case MsgPackType.NEGATIVE_FIXNUM_0x0D:
|
||||
case MsgPackType.NEGATIVE_FIXNUM_0x0E:
|
||||
case MsgPackType.NEGATIVE_FIXNUM_0x0F:
|
||||
case MsgPackType.NEGATIVE_FIXNUM_0x10:
|
||||
case MsgPackType.NEGATIVE_FIXNUM_0x11:
|
||||
case MsgPackType.NEGATIVE_FIXNUM_0x12:
|
||||
case MsgPackType.NEGATIVE_FIXNUM_0x13:
|
||||
case MsgPackType.NEGATIVE_FIXNUM_0x14:
|
||||
case MsgPackType.NEGATIVE_FIXNUM_0x15:
|
||||
case MsgPackType.NEGATIVE_FIXNUM_0x16:
|
||||
case MsgPackType.NEGATIVE_FIXNUM_0x17:
|
||||
case MsgPackType.NEGATIVE_FIXNUM_0x18:
|
||||
case MsgPackType.NEGATIVE_FIXNUM_0x19:
|
||||
case MsgPackType.NEGATIVE_FIXNUM_0x1A:
|
||||
case MsgPackType.NEGATIVE_FIXNUM_0x1B:
|
||||
case MsgPackType.NEGATIVE_FIXNUM_0x1C:
|
||||
case MsgPackType.NEGATIVE_FIXNUM_0x1D:
|
||||
case MsgPackType.NEGATIVE_FIXNUM_0x1E:
|
||||
case MsgPackType.NEGATIVE_FIXNUM_0x1F:
|
||||
|
||||
case MsgPackType.INT8:
|
||||
case MsgPackType.INT16:
|
||||
case MsgPackType.INT32:
|
||||
case MsgPackType.INT64:
|
||||
case MsgPackType.UINT8:
|
||||
case MsgPackType.UINT16:
|
||||
case MsgPackType.UINT32:
|
||||
case MsgPackType.UINT64:
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool IsFloat(this MsgPackType formatType)
|
||||
{
|
||||
switch (formatType)
|
||||
{
|
||||
case MsgPackType.FLOAT:
|
||||
case MsgPackType.DOUBLE:
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool IsString(this MsgPackType formatType)
|
||||
{
|
||||
switch (formatType)
|
||||
{
|
||||
case MsgPackType.FIX_STR:
|
||||
case MsgPackType.FIX_STR_0x01:
|
||||
case MsgPackType.FIX_STR_0x02:
|
||||
case MsgPackType.FIX_STR_0x03:
|
||||
case MsgPackType.FIX_STR_0x04:
|
||||
case MsgPackType.FIX_STR_0x05:
|
||||
case MsgPackType.FIX_STR_0x06:
|
||||
case MsgPackType.FIX_STR_0x07:
|
||||
case MsgPackType.FIX_STR_0x08:
|
||||
case MsgPackType.FIX_STR_0x09:
|
||||
case MsgPackType.FIX_STR_0x0A:
|
||||
case MsgPackType.FIX_STR_0x0B:
|
||||
case MsgPackType.FIX_STR_0x0C:
|
||||
case MsgPackType.FIX_STR_0x0D:
|
||||
case MsgPackType.FIX_STR_0x0E:
|
||||
case MsgPackType.FIX_STR_0x0F:
|
||||
case MsgPackType.FIX_STR_0x10:
|
||||
case MsgPackType.FIX_STR_0x11:
|
||||
case MsgPackType.FIX_STR_0x12:
|
||||
case MsgPackType.FIX_STR_0x13:
|
||||
case MsgPackType.FIX_STR_0x14:
|
||||
case MsgPackType.FIX_STR_0x15:
|
||||
case MsgPackType.FIX_STR_0x16:
|
||||
case MsgPackType.FIX_STR_0x17:
|
||||
case MsgPackType.FIX_STR_0x18:
|
||||
case MsgPackType.FIX_STR_0x19:
|
||||
case MsgPackType.FIX_STR_0x1A:
|
||||
case MsgPackType.FIX_STR_0x1B:
|
||||
case MsgPackType.FIX_STR_0x1C:
|
||||
case MsgPackType.FIX_STR_0x1D:
|
||||
case MsgPackType.FIX_STR_0x1E:
|
||||
case MsgPackType.FIX_STR_0x1F:
|
||||
case MsgPackType.STR8:
|
||||
case MsgPackType.STR16:
|
||||
case MsgPackType.STR32:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static bool IsExt(this MsgPackType formatType)
|
||||
{
|
||||
switch (formatType)
|
||||
{
|
||||
case MsgPackType.FIX_EXT_1:
|
||||
case MsgPackType.FIX_EXT_2:
|
||||
case MsgPackType.FIX_EXT_4:
|
||||
case MsgPackType.FIX_EXT_8:
|
||||
case MsgPackType.FIX_EXT_16:
|
||||
case MsgPackType.EXT8:
|
||||
case MsgPackType.EXT16:
|
||||
case MsgPackType.EXT32:
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool IsBinary(this MsgPackType formatType)
|
||||
{
|
||||
switch (formatType)
|
||||
{
|
||||
case MsgPackType.BIN8:
|
||||
case MsgPackType.BIN16:
|
||||
case MsgPackType.BIN32:
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 6e803181a063cd940b8272f45497b506
|
||||
timeCreated: 1540898737
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -1,767 +0,0 @@
|
|||
using System;
|
||||
using System.Text;
|
||||
|
||||
namespace UniJSON
|
||||
{
|
||||
public struct MsgPackValue: IListTreeItem, IValue<MsgPackValue>
|
||||
{
|
||||
public int ParentIndex
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public ArraySegment<Byte> Bytes
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
public void SetBytesCount(int count)
|
||||
{
|
||||
Bytes = new ArraySegment<byte>(Bytes.Array, Bytes.Offset, count);
|
||||
}
|
||||
|
||||
public MsgPackType Format
|
||||
{
|
||||
get
|
||||
{
|
||||
return (MsgPackType)Bytes.Get(0);
|
||||
}
|
||||
}
|
||||
|
||||
public ValueNodeType ValueType
|
||||
{
|
||||
get
|
||||
{
|
||||
switch (Format)
|
||||
{
|
||||
case MsgPackType.NIL:
|
||||
return ValueNodeType.Null;
|
||||
|
||||
case MsgPackType.TRUE:
|
||||
case MsgPackType.FALSE:
|
||||
return ValueNodeType.Boolean;
|
||||
|
||||
default:
|
||||
if (Format.IsArray())
|
||||
{
|
||||
return ValueNodeType.Array;
|
||||
}
|
||||
else if (Format.IsMap())
|
||||
{
|
||||
return ValueNodeType.Object;
|
||||
}
|
||||
else if (Format.IsInteger())
|
||||
{
|
||||
return ValueNodeType.Integer;
|
||||
}
|
||||
else if (Format.IsFloat())
|
||||
{
|
||||
return ValueNodeType.Number;
|
||||
}
|
||||
else if (Format.IsString())
|
||||
{
|
||||
return ValueNodeType.String;
|
||||
}
|
||||
else if (Format.IsBinary())
|
||||
{
|
||||
return ValueNodeType.Binary;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int _childCount;
|
||||
public int ChildCount
|
||||
{
|
||||
get { return _childCount; }
|
||||
}
|
||||
public void SetChildCount(int count)
|
||||
{
|
||||
_childCount = count;
|
||||
}
|
||||
|
||||
public MsgPackValue(ArraySegment<Byte> segment, int parentIndex) : this()
|
||||
{
|
||||
Bytes = segment;
|
||||
ParentIndex = parentIndex;
|
||||
}
|
||||
|
||||
public MsgPackValue New(ArraySegment<byte> bytes, ValueNodeType valueType, int parentIndex)
|
||||
{
|
||||
return new MsgPackValue(bytes, parentIndex);
|
||||
}
|
||||
|
||||
public MsgPackValue Key(Utf8String key, int parentIndex)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ArrayとMap以外のタイプのペイロードを得る
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public ArraySegment<Byte> GetBody()
|
||||
{
|
||||
var bytes = Bytes;
|
||||
var formatType = Format;
|
||||
switch (formatType)
|
||||
{
|
||||
case MsgPackType.FIX_STR: return bytes.Advance(1).Take(0);
|
||||
case MsgPackType.FIX_STR_0x01: return bytes.Advance(1).Take(1);
|
||||
case MsgPackType.FIX_STR_0x02: return bytes.Advance(1).Take(2);
|
||||
case MsgPackType.FIX_STR_0x03: return bytes.Advance(1).Take(3);
|
||||
case MsgPackType.FIX_STR_0x04: return bytes.Advance(1).Take(4);
|
||||
case MsgPackType.FIX_STR_0x05: return bytes.Advance(1).Take(5);
|
||||
case MsgPackType.FIX_STR_0x06: return bytes.Advance(1).Take(6);
|
||||
case MsgPackType.FIX_STR_0x07: return bytes.Advance(1).Take(7);
|
||||
case MsgPackType.FIX_STR_0x08: return bytes.Advance(1).Take(8);
|
||||
case MsgPackType.FIX_STR_0x09: return bytes.Advance(1).Take(9);
|
||||
case MsgPackType.FIX_STR_0x0A: return bytes.Advance(1).Take(10);
|
||||
case MsgPackType.FIX_STR_0x0B: return bytes.Advance(1).Take(11);
|
||||
case MsgPackType.FIX_STR_0x0C: return bytes.Advance(1).Take(12);
|
||||
case MsgPackType.FIX_STR_0x0D: return bytes.Advance(1).Take(13);
|
||||
case MsgPackType.FIX_STR_0x0E: return bytes.Advance(1).Take(14);
|
||||
case MsgPackType.FIX_STR_0x0F: return bytes.Advance(1).Take(15);
|
||||
|
||||
case MsgPackType.FIX_STR_0x10: return bytes.Advance(1).Take(16);
|
||||
case MsgPackType.FIX_STR_0x11: return bytes.Advance(1).Take(17);
|
||||
case MsgPackType.FIX_STR_0x12: return bytes.Advance(1).Take(18);
|
||||
case MsgPackType.FIX_STR_0x13: return bytes.Advance(1).Take(19);
|
||||
case MsgPackType.FIX_STR_0x14: return bytes.Advance(1).Take(20);
|
||||
case MsgPackType.FIX_STR_0x15: return bytes.Advance(1).Take(21);
|
||||
case MsgPackType.FIX_STR_0x16: return bytes.Advance(1).Take(22);
|
||||
case MsgPackType.FIX_STR_0x17: return bytes.Advance(1).Take(23);
|
||||
case MsgPackType.FIX_STR_0x18: return bytes.Advance(1).Take(24);
|
||||
case MsgPackType.FIX_STR_0x19: return bytes.Advance(1).Take(25);
|
||||
case MsgPackType.FIX_STR_0x1A: return bytes.Advance(1).Take(26);
|
||||
case MsgPackType.FIX_STR_0x1B: return bytes.Advance(1).Take(27);
|
||||
case MsgPackType.FIX_STR_0x1C: return bytes.Advance(1).Take(28);
|
||||
case MsgPackType.FIX_STR_0x1D: return bytes.Advance(1).Take(29);
|
||||
case MsgPackType.FIX_STR_0x1E: return bytes.Advance(1).Take(30);
|
||||
case MsgPackType.FIX_STR_0x1F: return bytes.Advance(1).Take(31);
|
||||
|
||||
case MsgPackType.STR8:
|
||||
case MsgPackType.BIN8:
|
||||
{
|
||||
var count = bytes.Get(1);
|
||||
return bytes.Advance(1 + 1).Take(count);
|
||||
}
|
||||
|
||||
case MsgPackType.STR16:
|
||||
case MsgPackType.BIN16:
|
||||
{
|
||||
var count = EndianConverter.NetworkByteWordToUnsignedNativeByteOrder(bytes.Advance(1));
|
||||
return bytes.Advance(1 + 2).Take(count);
|
||||
}
|
||||
|
||||
case MsgPackType.STR32:
|
||||
case MsgPackType.BIN32:
|
||||
{
|
||||
var count = EndianConverter.NetworkByteDWordToUnsignedNativeByteOrder(bytes.Advance(1));
|
||||
return bytes.Advance(1 + 4).Take((int)count);
|
||||
}
|
||||
|
||||
case MsgPackType.NIL:
|
||||
case MsgPackType.TRUE:
|
||||
case MsgPackType.FALSE:
|
||||
case MsgPackType.POSITIVE_FIXNUM:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x01:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x02:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x03:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x04:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x05:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x06:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x07:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x08:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x09:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x0A:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x0B:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x0C:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x0D:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x0E:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x0F:
|
||||
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x10:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x11:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x12:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x13:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x14:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x15:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x16:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x17:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x18:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x19:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x1A:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x1B:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x1C:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x1D:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x1E:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x1F:
|
||||
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x20:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x21:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x22:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x23:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x24:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x25:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x26:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x27:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x28:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x29:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x2A:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x2B:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x2C:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x2D:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x2E:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x2F:
|
||||
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x30:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x31:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x32:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x33:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x34:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x35:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x36:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x37:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x38:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x39:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x3A:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x3B:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x3C:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x3D:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x3E:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x3F:
|
||||
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x40:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x41:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x42:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x43:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x44:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x45:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x46:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x47:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x48:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x49:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x4A:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x4B:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x4C:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x4D:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x4E:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x4F:
|
||||
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x50:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x51:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x52:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x53:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x54:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x55:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x56:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x57:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x58:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x59:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x5A:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x5B:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x5C:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x5D:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x5E:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x5F:
|
||||
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x60:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x61:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x62:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x63:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x64:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x65:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x66:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x67:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x68:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x69:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x6A:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x6B:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x6C:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x6D:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x6E:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x6F:
|
||||
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x70:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x71:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x72:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x73:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x74:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x75:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x76:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x77:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x78:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x79:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x7A:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x7B:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x7C:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x7D:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x7E:
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x7F:
|
||||
|
||||
case MsgPackType.NEGATIVE_FIXNUM:
|
||||
case MsgPackType.NEGATIVE_FIXNUM_0x01:
|
||||
case MsgPackType.NEGATIVE_FIXNUM_0x02:
|
||||
case MsgPackType.NEGATIVE_FIXNUM_0x03:
|
||||
case MsgPackType.NEGATIVE_FIXNUM_0x04:
|
||||
case MsgPackType.NEGATIVE_FIXNUM_0x05:
|
||||
case MsgPackType.NEGATIVE_FIXNUM_0x06:
|
||||
case MsgPackType.NEGATIVE_FIXNUM_0x07:
|
||||
case MsgPackType.NEGATIVE_FIXNUM_0x08:
|
||||
case MsgPackType.NEGATIVE_FIXNUM_0x09:
|
||||
case MsgPackType.NEGATIVE_FIXNUM_0x0A:
|
||||
case MsgPackType.NEGATIVE_FIXNUM_0x0B:
|
||||
case MsgPackType.NEGATIVE_FIXNUM_0x0C:
|
||||
case MsgPackType.NEGATIVE_FIXNUM_0x0D:
|
||||
case MsgPackType.NEGATIVE_FIXNUM_0x0E:
|
||||
case MsgPackType.NEGATIVE_FIXNUM_0x0F:
|
||||
case MsgPackType.NEGATIVE_FIXNUM_0x10:
|
||||
case MsgPackType.NEGATIVE_FIXNUM_0x11:
|
||||
case MsgPackType.NEGATIVE_FIXNUM_0x12:
|
||||
case MsgPackType.NEGATIVE_FIXNUM_0x13:
|
||||
case MsgPackType.NEGATIVE_FIXNUM_0x14:
|
||||
case MsgPackType.NEGATIVE_FIXNUM_0x15:
|
||||
case MsgPackType.NEGATIVE_FIXNUM_0x16:
|
||||
case MsgPackType.NEGATIVE_FIXNUM_0x17:
|
||||
case MsgPackType.NEGATIVE_FIXNUM_0x18:
|
||||
case MsgPackType.NEGATIVE_FIXNUM_0x19:
|
||||
case MsgPackType.NEGATIVE_FIXNUM_0x1A:
|
||||
case MsgPackType.NEGATIVE_FIXNUM_0x1B:
|
||||
case MsgPackType.NEGATIVE_FIXNUM_0x1C:
|
||||
case MsgPackType.NEGATIVE_FIXNUM_0x1D:
|
||||
case MsgPackType.NEGATIVE_FIXNUM_0x1E:
|
||||
case MsgPackType.NEGATIVE_FIXNUM_0x1F:
|
||||
return bytes.Advance(1).Take(0);
|
||||
|
||||
case MsgPackType.UINT8:
|
||||
case MsgPackType.INT8:
|
||||
return bytes.Advance(1).Take(1);
|
||||
|
||||
case MsgPackType.UINT16:
|
||||
case MsgPackType.INT16:
|
||||
return bytes.Advance(1).Take(2);
|
||||
|
||||
case MsgPackType.UINT32:
|
||||
case MsgPackType.INT32:
|
||||
case MsgPackType.FLOAT:
|
||||
return bytes.Advance(1).Take(4);
|
||||
|
||||
case MsgPackType.UINT64:
|
||||
case MsgPackType.INT64:
|
||||
case MsgPackType.DOUBLE:
|
||||
return bytes.Advance(1).Take(8);
|
||||
|
||||
case MsgPackType.FIX_EXT_1:
|
||||
return bytes.Advance(2).Take(1);
|
||||
case MsgPackType.FIX_EXT_2:
|
||||
return bytes.Advance(2).Take(2);
|
||||
case MsgPackType.FIX_EXT_4:
|
||||
return bytes.Advance(2).Take(4);
|
||||
case MsgPackType.FIX_EXT_8:
|
||||
return bytes.Advance(2).Take(8);
|
||||
case MsgPackType.FIX_EXT_16:
|
||||
return bytes.Advance(2).Take(16);
|
||||
case MsgPackType.EXT8:
|
||||
{
|
||||
var count = bytes.Get(1);
|
||||
return bytes.Advance(1 + 1 + 1).Take(count);
|
||||
}
|
||||
case MsgPackType.EXT16:
|
||||
{
|
||||
var count = EndianConverter.NetworkByteWordToUnsignedNativeByteOrder(bytes.Advance(1));
|
||||
return bytes.Advance(1 + 2 + 1).Take(count);
|
||||
}
|
||||
case MsgPackType.EXT32:
|
||||
{
|
||||
var count = EndianConverter.NetworkByteDWordToUnsignedNativeByteOrder(bytes.Advance(1));
|
||||
return bytes.Advance(1 + 4 + 1).Take((int)count);
|
||||
}
|
||||
default:
|
||||
throw new ArgumentException("unknown type: " + formatType);
|
||||
}
|
||||
}
|
||||
|
||||
public SByte GetExtType()
|
||||
{
|
||||
var formatType = Format;
|
||||
switch (formatType)
|
||||
{
|
||||
case MsgPackType.FIX_EXT_4:
|
||||
return (SByte)Bytes.Get(1);
|
||||
}
|
||||
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ArrayとMap以外のタイプの値を得る
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public T GetValue<T>()
|
||||
{
|
||||
var formatType = Format;
|
||||
switch (formatType)
|
||||
{
|
||||
case MsgPackType.NIL: return GenericCast<object, T>.Null();
|
||||
case MsgPackType.TRUE: return GenericCast<bool, T>.Const(true)();
|
||||
case MsgPackType.FALSE: return GenericCast<bool, T>.Const(false)();
|
||||
case MsgPackType.POSITIVE_FIXNUM: return GenericCast<int, T>.Const(0)();
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x01: return GenericCast<int, T>.Const(1)();
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x02: return GenericCast<int, T>.Const(2)();
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x03: return GenericCast<int, T>.Const(3)();
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x04: return GenericCast<int, T>.Const(4)();
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x05: return GenericCast<int, T>.Const(5)();
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x06: return GenericCast<int, T>.Const(6)();
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x07: return GenericCast<int, T>.Const(7)();
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x08: return GenericCast<int, T>.Const(8)();
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x09: return GenericCast<int, T>.Const(9)();
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x0A: return GenericCast<int, T>.Const(10)();
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x0B: return GenericCast<int, T>.Const(11)();
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x0C: return GenericCast<int, T>.Const(12)();
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x0D: return GenericCast<int, T>.Const(13)();
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x0E: return GenericCast<int, T>.Const(14)();
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x0F: return GenericCast<int, T>.Const(15)();
|
||||
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x10: return GenericCast<int, T>.Const(16)();
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x11: return GenericCast<int, T>.Const(17)();
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x12: return GenericCast<int, T>.Const(18)();
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x13: return GenericCast<int, T>.Const(19)();
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x14: return GenericCast<int, T>.Const(20)();
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x15: return GenericCast<int, T>.Const(21)();
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x16: return GenericCast<int, T>.Const(22)();
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x17: return GenericCast<int, T>.Const(23)();
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x18: return GenericCast<int, T>.Const(24)();
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x19: return GenericCast<int, T>.Const(25)();
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x1A: return GenericCast<int, T>.Const(26)();
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x1B: return GenericCast<int, T>.Const(27)();
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x1C: return GenericCast<int, T>.Const(28)();
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x1D: return GenericCast<int, T>.Const(29)();
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x1E: return GenericCast<int, T>.Const(30)();
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x1F: return GenericCast<int, T>.Const(31)();
|
||||
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x20: return GenericCast<int, T>.Const(32)();
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x21: return GenericCast<int, T>.Const(33)();
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x22: return GenericCast<int, T>.Const(34)();
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x23: return GenericCast<int, T>.Const(35)();
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x24: return GenericCast<int, T>.Const(36)();
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x25: return GenericCast<int, T>.Const(37)();
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x26: return GenericCast<int, T>.Const(38)();
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x27: return GenericCast<int, T>.Const(39)();
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x28: return GenericCast<int, T>.Const(40)();
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x29: return GenericCast<int, T>.Const(41)();
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x2A: return GenericCast<int, T>.Const(42)();
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x2B: return GenericCast<int, T>.Const(43)();
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x2C: return GenericCast<int, T>.Const(44)();
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x2D: return GenericCast<int, T>.Const(45)();
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x2E: return GenericCast<int, T>.Const(46)();
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x2F: return GenericCast<int, T>.Const(47)();
|
||||
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x30: return GenericCast<int, T>.Const(48)();
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x31: return GenericCast<int, T>.Const(49)();
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x32: return GenericCast<int, T>.Const(50)();
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x33: return GenericCast<int, T>.Const(51)();
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x34: return GenericCast<int, T>.Const(52)();
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x35: return GenericCast<int, T>.Const(53)();
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x36: return GenericCast<int, T>.Const(54)();
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x37: return GenericCast<int, T>.Const(55)();
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x38: return GenericCast<int, T>.Const(56)();
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x39: return GenericCast<int, T>.Const(57)();
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x3A: return GenericCast<int, T>.Const(58)();
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x3B: return GenericCast<int, T>.Const(59)();
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x3C: return GenericCast<int, T>.Const(60)();
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x3D: return GenericCast<int, T>.Const(61)();
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x3E: return GenericCast<int, T>.Const(62)();
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x3F: return GenericCast<int, T>.Const(63)();
|
||||
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x40: return GenericCast<int, T>.Const(64)();
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x41: return GenericCast<int, T>.Const(65)();
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x42: return GenericCast<int, T>.Const(66)();
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x43: return GenericCast<int, T>.Const(67)();
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x44: return GenericCast<int, T>.Const(68)();
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x45: return GenericCast<int, T>.Const(69)();
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x46: return GenericCast<int, T>.Const(70)();
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x47: return GenericCast<int, T>.Const(71)();
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x48: return GenericCast<int, T>.Const(72)();
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x49: return GenericCast<int, T>.Const(73)();
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x4A: return GenericCast<int, T>.Const(74)();
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x4B: return GenericCast<int, T>.Const(75)();
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x4C: return GenericCast<int, T>.Const(76)();
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x4D: return GenericCast<int, T>.Const(77)();
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x4E: return GenericCast<int, T>.Const(78)();
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x4F: return GenericCast<int, T>.Const(79)();
|
||||
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x50: return GenericCast<int, T>.Const(80)();
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x51: return GenericCast<int, T>.Const(81)();
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x52: return GenericCast<int, T>.Const(82)();
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x53: return GenericCast<int, T>.Const(83)();
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x54: return GenericCast<int, T>.Const(84)();
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x55: return GenericCast<int, T>.Const(85)();
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x56: return GenericCast<int, T>.Const(86)();
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x57: return GenericCast<int, T>.Const(87)();
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x58: return GenericCast<int, T>.Const(88)();
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x59: return GenericCast<int, T>.Const(89)();
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x5A: return GenericCast<int, T>.Const(90)();
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x5B: return GenericCast<int, T>.Const(91)();
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x5C: return GenericCast<int, T>.Const(92)();
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x5D: return GenericCast<int, T>.Const(93)();
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x5E: return GenericCast<int, T>.Const(94)();
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x5F: return GenericCast<int, T>.Const(95)();
|
||||
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x60: return GenericCast<int, T>.Const(96)();
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x61: return GenericCast<int, T>.Const(97)();
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x62: return GenericCast<int, T>.Const(98)();
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x63: return GenericCast<int, T>.Const(99)();
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x64: return GenericCast<int, T>.Const(100)();
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x65: return GenericCast<int, T>.Const(101)();
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x66: return GenericCast<int, T>.Const(102)();
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x67: return GenericCast<int, T>.Const(103)();
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x68: return GenericCast<int, T>.Const(104)();
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x69: return GenericCast<int, T>.Const(105)();
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x6A: return GenericCast<int, T>.Const(106)();
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x6B: return GenericCast<int, T>.Const(107)();
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x6C: return GenericCast<int, T>.Const(108)();
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x6D: return GenericCast<int, T>.Const(109)();
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x6E: return GenericCast<int, T>.Const(110)();
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x6F: return GenericCast<int, T>.Const(111)();
|
||||
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x70: return GenericCast<int, T>.Const(112)();
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x71: return GenericCast<int, T>.Const(113)();
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x72: return GenericCast<int, T>.Const(114)();
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x73: return GenericCast<int, T>.Const(115)();
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x74: return GenericCast<int, T>.Const(116)();
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x75: return GenericCast<int, T>.Const(117)();
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x76: return GenericCast<int, T>.Const(118)();
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x77: return GenericCast<int, T>.Const(119)();
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x78: return GenericCast<int, T>.Const(120)();
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x79: return GenericCast<int, T>.Const(121)();
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x7A: return GenericCast<int, T>.Const(122)();
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x7B: return GenericCast<int, T>.Const(123)();
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x7C: return GenericCast<int, T>.Const(124)();
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x7D: return GenericCast<int, T>.Const(125)();
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x7E: return GenericCast<int, T>.Const(126)();
|
||||
case MsgPackType.POSITIVE_FIXNUM_0x7F: return GenericCast<int, T>.Const(127)();
|
||||
|
||||
case MsgPackType.NEGATIVE_FIXNUM: return GenericCast<int, T>.Const(-32)();
|
||||
case MsgPackType.NEGATIVE_FIXNUM_0x01: return GenericCast<int, T>.Const(-1)();
|
||||
case MsgPackType.NEGATIVE_FIXNUM_0x02: return GenericCast<int, T>.Const(-2)();
|
||||
case MsgPackType.NEGATIVE_FIXNUM_0x03: return GenericCast<int, T>.Const(-3)();
|
||||
case MsgPackType.NEGATIVE_FIXNUM_0x04: return GenericCast<int, T>.Const(-4)();
|
||||
case MsgPackType.NEGATIVE_FIXNUM_0x05: return GenericCast<int, T>.Const(-5)();
|
||||
case MsgPackType.NEGATIVE_FIXNUM_0x06: return GenericCast<int, T>.Const(-6)();
|
||||
case MsgPackType.NEGATIVE_FIXNUM_0x07: return GenericCast<int, T>.Const(-7)();
|
||||
case MsgPackType.NEGATIVE_FIXNUM_0x08: return GenericCast<int, T>.Const(-8)();
|
||||
case MsgPackType.NEGATIVE_FIXNUM_0x09: return GenericCast<int, T>.Const(-9)();
|
||||
case MsgPackType.NEGATIVE_FIXNUM_0x0A: return GenericCast<int, T>.Const(-10)();
|
||||
case MsgPackType.NEGATIVE_FIXNUM_0x0B: return GenericCast<int, T>.Const(-11)();
|
||||
case MsgPackType.NEGATIVE_FIXNUM_0x0C: return GenericCast<int, T>.Const(-12)();
|
||||
case MsgPackType.NEGATIVE_FIXNUM_0x0D: return GenericCast<int, T>.Const(-13)();
|
||||
case MsgPackType.NEGATIVE_FIXNUM_0x0E: return GenericCast<int, T>.Const(-14)();
|
||||
case MsgPackType.NEGATIVE_FIXNUM_0x0F: return GenericCast<int, T>.Const(-15)();
|
||||
case MsgPackType.NEGATIVE_FIXNUM_0x10: return GenericCast<int, T>.Const(-16)();
|
||||
case MsgPackType.NEGATIVE_FIXNUM_0x11: return GenericCast<int, T>.Const(-17)();
|
||||
case MsgPackType.NEGATIVE_FIXNUM_0x12: return GenericCast<int, T>.Const(-18)();
|
||||
case MsgPackType.NEGATIVE_FIXNUM_0x13: return GenericCast<int, T>.Const(-19)();
|
||||
case MsgPackType.NEGATIVE_FIXNUM_0x14: return GenericCast<int, T>.Const(-20)();
|
||||
case MsgPackType.NEGATIVE_FIXNUM_0x15: return GenericCast<int, T>.Const(-21)();
|
||||
case MsgPackType.NEGATIVE_FIXNUM_0x16: return GenericCast<int, T>.Const(-22)();
|
||||
case MsgPackType.NEGATIVE_FIXNUM_0x17: return GenericCast<int, T>.Const(-23)();
|
||||
case MsgPackType.NEGATIVE_FIXNUM_0x18: return GenericCast<int, T>.Const(-24)();
|
||||
case MsgPackType.NEGATIVE_FIXNUM_0x19: return GenericCast<int, T>.Const(-25)();
|
||||
case MsgPackType.NEGATIVE_FIXNUM_0x1A: return GenericCast<int, T>.Const(-26)();
|
||||
case MsgPackType.NEGATIVE_FIXNUM_0x1B: return GenericCast<int, T>.Const(-27)();
|
||||
case MsgPackType.NEGATIVE_FIXNUM_0x1C: return GenericCast<int, T>.Const(-28)();
|
||||
case MsgPackType.NEGATIVE_FIXNUM_0x1D: return GenericCast<int, T>.Const(-29)();
|
||||
case MsgPackType.NEGATIVE_FIXNUM_0x1E: return GenericCast<int, T>.Const(-30)();
|
||||
case MsgPackType.NEGATIVE_FIXNUM_0x1F: return GenericCast<int, T>.Const(-31)();
|
||||
|
||||
case MsgPackType.INT8: return GenericCast<SByte, T>.Cast((SByte)GetBody().Get(0));
|
||||
case MsgPackType.INT16: return GenericCast<short, T>.Cast(EndianConverter.NetworkByteWordToSignedNativeByteOrder(GetBody()));
|
||||
case MsgPackType.INT32: return GenericCast<int, T>.Cast(EndianConverter.NetworkByteDWordToSignedNativeByteOrder(GetBody()));
|
||||
case MsgPackType.INT64: return GenericCast<long, T>.Cast(EndianConverter.NetworkByteQWordToSignedNativeByteOrder(GetBody()));
|
||||
case MsgPackType.UINT8: return GenericCast<Byte, T>.Cast(GetBody().Get(0));
|
||||
case MsgPackType.UINT16: return GenericCast<ushort, T>.Cast(EndianConverter.NetworkByteWordToUnsignedNativeByteOrder(GetBody()));
|
||||
case MsgPackType.UINT32: return GenericCast<uint, T>.Cast(EndianConverter.NetworkByteDWordToUnsignedNativeByteOrder(GetBody()));
|
||||
case MsgPackType.UINT64: return GenericCast<ulong, T>.Cast(EndianConverter.NetworkByteQWordToUnsignedNativeByteOrder(GetBody()));
|
||||
case MsgPackType.FLOAT: return GenericCast<float, T>.Cast(EndianConverter.NetworkByteDWordToFloatNativeByteOrder(GetBody()));
|
||||
case MsgPackType.DOUBLE: return GenericCast<double, T>.Cast(EndianConverter.NetworkByteQWordToFloatNativeByteOrder(GetBody()));
|
||||
|
||||
case MsgPackType.FIX_STR: return GenericCast<string, T>.Const("")();
|
||||
case MsgPackType.FIX_STR_0x01:
|
||||
case MsgPackType.FIX_STR_0x02:
|
||||
case MsgPackType.FIX_STR_0x03:
|
||||
case MsgPackType.FIX_STR_0x04:
|
||||
case MsgPackType.FIX_STR_0x05:
|
||||
case MsgPackType.FIX_STR_0x06:
|
||||
case MsgPackType.FIX_STR_0x07:
|
||||
case MsgPackType.FIX_STR_0x08:
|
||||
case MsgPackType.FIX_STR_0x09:
|
||||
case MsgPackType.FIX_STR_0x0A:
|
||||
case MsgPackType.FIX_STR_0x0B:
|
||||
case MsgPackType.FIX_STR_0x0C:
|
||||
case MsgPackType.FIX_STR_0x0D:
|
||||
case MsgPackType.FIX_STR_0x0E:
|
||||
case MsgPackType.FIX_STR_0x0F:
|
||||
case MsgPackType.FIX_STR_0x10:
|
||||
case MsgPackType.FIX_STR_0x11:
|
||||
case MsgPackType.FIX_STR_0x12:
|
||||
case MsgPackType.FIX_STR_0x13:
|
||||
case MsgPackType.FIX_STR_0x14:
|
||||
case MsgPackType.FIX_STR_0x15:
|
||||
case MsgPackType.FIX_STR_0x16:
|
||||
case MsgPackType.FIX_STR_0x17:
|
||||
case MsgPackType.FIX_STR_0x18:
|
||||
case MsgPackType.FIX_STR_0x19:
|
||||
case MsgPackType.FIX_STR_0x1A:
|
||||
case MsgPackType.FIX_STR_0x1B:
|
||||
case MsgPackType.FIX_STR_0x1C:
|
||||
case MsgPackType.FIX_STR_0x1D:
|
||||
case MsgPackType.FIX_STR_0x1E:
|
||||
case MsgPackType.FIX_STR_0x1F:
|
||||
case MsgPackType.STR8:
|
||||
case MsgPackType.STR16:
|
||||
case MsgPackType.STR32:
|
||||
{
|
||||
var body = GetBody();
|
||||
var str = Encoding.UTF8.GetString(body.Array, body.Offset, body.Count);
|
||||
return GenericCast<string, T>.Cast(str);
|
||||
}
|
||||
|
||||
case MsgPackType.BIN8:
|
||||
case MsgPackType.BIN16:
|
||||
case MsgPackType.BIN32:
|
||||
{
|
||||
var body = GetBody();
|
||||
return GenericCast<ArraySegment<Byte>, T>.Cast(body);
|
||||
}
|
||||
|
||||
case MsgPackType.FIX_EXT_4:
|
||||
{
|
||||
if (GetExtType() == -1)
|
||||
{
|
||||
var unixtime = EndianConverter.NetworkByteDWordToUnsignedNativeByteOrder(GetBody());
|
||||
var dt = new DateTimeOffset(unixtime * DateTimeOffsetExtensions.TicksPerSecond + DateTimeOffsetExtensions.EpochTime.Ticks, TimeSpan.Zero);
|
||||
return GenericCast<DateTimeOffset, T>.Cast(dt);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
throw new ArgumentException("GetValue to array or map: " + formatType);
|
||||
}
|
||||
|
||||
public bool GetBoolean()
|
||||
{
|
||||
switch (Format)
|
||||
{
|
||||
case MsgPackType.TRUE: return true;
|
||||
case MsgPackType.FALSE: return false;
|
||||
default: throw new MsgPackTypeException("Not boolean");
|
||||
}
|
||||
}
|
||||
|
||||
public ArraySegment<Byte> GetBytes()
|
||||
{
|
||||
if (!Format.IsBinary())
|
||||
{
|
||||
throw new MsgPackTypeException("Not bin");
|
||||
}
|
||||
return GetBody();
|
||||
}
|
||||
|
||||
public string GetString()
|
||||
{
|
||||
if (!Format.IsString())
|
||||
{
|
||||
throw new MsgPackTypeException("Not str");
|
||||
}
|
||||
var bytes = GetBody();
|
||||
return Encoding.UTF8.GetString(bytes.Array, bytes.Offset, bytes.Count);
|
||||
}
|
||||
|
||||
public Utf8String GetUtf8String()
|
||||
{
|
||||
if (!Format.IsString())
|
||||
{
|
||||
throw new MsgPackTypeException("Not str");
|
||||
}
|
||||
var bytes = GetBody();
|
||||
return new Utf8String(bytes);
|
||||
}
|
||||
|
||||
public SByte GetSByte()
|
||||
{
|
||||
return GetValue<SByte>();
|
||||
}
|
||||
|
||||
public Int16 GetInt16()
|
||||
{
|
||||
return GetValue<Int16>();
|
||||
}
|
||||
|
||||
public Int32 GetInt32()
|
||||
{
|
||||
return GetValue<Int32>();
|
||||
}
|
||||
|
||||
public Int64 GetInt64()
|
||||
{
|
||||
return GetValue<Int64>();
|
||||
}
|
||||
|
||||
public Byte GetByte()
|
||||
{
|
||||
return GetValue<Byte>();
|
||||
}
|
||||
|
||||
public UInt16 GetUInt16()
|
||||
{
|
||||
return GetValue<UInt16>();
|
||||
}
|
||||
|
||||
public UInt32 GetUInt32()
|
||||
{
|
||||
return GetValue<UInt32>();
|
||||
}
|
||||
|
||||
public UInt64 GetUInt64()
|
||||
{
|
||||
return GetValue<UInt64>();
|
||||
}
|
||||
|
||||
public float GetSingle()
|
||||
{
|
||||
return GetValue<Single>();
|
||||
}
|
||||
|
||||
public double GetDouble()
|
||||
{
|
||||
return GetValue<Double>();
|
||||
}
|
||||
|
||||
public void SetValue<T>(Utf8String jsonPointer, T value)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void RemoveValue(Utf8String jsonPointer)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void AddKey(Utf8String key)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void AddValue(ArraySegment<byte> bytes, ValueNodeType valueType)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: e201eb676758d5d419ae0629fda171ac
|
||||
timeCreated: 1540904080
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 69e0a1360efdf0a4093b010d322bc05a
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -1,185 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
|
||||
namespace UniJSON
|
||||
{
|
||||
public static class TomlParser
|
||||
{
|
||||
static TomlValue ParseLHS(Utf8String segment, int parentIndex)
|
||||
{
|
||||
var it = segment.GetIterator();
|
||||
while (it.MoveNext())
|
||||
{
|
||||
if (it.Current == '"')
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
else if (it.Current == '.')
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
else if (it.Current == ' ' || it.Current == '\t' || it.Current == '=')
|
||||
{
|
||||
return new TomlValue(segment.Subbytes(0, it.BytePosition),
|
||||
TomlValueType.BareKey, parentIndex);
|
||||
}
|
||||
}
|
||||
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
static TomlValue ParseRHS(Utf8String segment, int parentIndex)
|
||||
{
|
||||
switch ((char)segment[0])
|
||||
{
|
||||
case '+':
|
||||
case '-':
|
||||
case '0':
|
||||
case '1':
|
||||
case '2':
|
||||
case '3':
|
||||
case '4':
|
||||
case '5':
|
||||
case '6':
|
||||
case '7':
|
||||
case '8':
|
||||
case '9':
|
||||
if (segment.IsInt)
|
||||
{
|
||||
return new TomlValue(segment.SplitInteger(), TomlValueType.Integer, parentIndex);
|
||||
}
|
||||
else
|
||||
{
|
||||
return new TomlValue(segment, TomlValueType.Float, parentIndex);
|
||||
}
|
||||
|
||||
case '"':
|
||||
{
|
||||
int pos;
|
||||
if (segment.TrySearchAscii((Byte)'"', 1, out pos))
|
||||
{
|
||||
return new TomlValue(segment.Subbytes(0, pos + 1), TomlValueType.BasicString, parentIndex);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new ParserException("no close string: " + segment);
|
||||
}
|
||||
}
|
||||
|
||||
case '[':
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public static ListTreeNode<TomlValue> Parse(Utf8String segment)
|
||||
{
|
||||
var values = new List<TomlValue>()
|
||||
{
|
||||
new TomlValue(segment, TomlValueType.Table, -1),
|
||||
};
|
||||
var current = 0;
|
||||
|
||||
while (!segment.IsEmpty)
|
||||
{
|
||||
segment = segment.TrimStart();
|
||||
if (segment.IsEmpty)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
if (segment[0] == '#')
|
||||
{
|
||||
// comment line
|
||||
// skip to line end
|
||||
segment = segment.Subbytes(segment.GetLine().ByteLength);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (segment.ByteLength>=4 && segment[0]=='[' && segment[1]=='[')
|
||||
{
|
||||
// [[array_name]]
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
else if (segment.ByteLength>=2 && segment[0]=='[')
|
||||
{
|
||||
// [table_name]
|
||||
int table_end;
|
||||
if (!segment.TrySearchByte(x => x == ']', out table_end))
|
||||
{
|
||||
throw new ParserException("] not found");
|
||||
}
|
||||
var table_name = segment.Subbytes(1, table_end-1).Trim();
|
||||
if (table_name.IsEmpty)
|
||||
{
|
||||
throw new ParserException("empty table name");
|
||||
}
|
||||
|
||||
// top level key
|
||||
values.Add(new TomlValue(table_name, TomlValueType.Table, 0));
|
||||
current = values.Count - 1;
|
||||
|
||||
// skip to line end
|
||||
segment = segment.Subbytes(segment.GetLine().ByteLength);
|
||||
}
|
||||
else
|
||||
{
|
||||
// key = value
|
||||
{
|
||||
var key = ParseLHS(segment, current);
|
||||
switch(key.TomlValueType)
|
||||
{
|
||||
case TomlValueType.BareKey:
|
||||
case TomlValueType.QuotedKey:
|
||||
{
|
||||
values.Add(key);
|
||||
|
||||
// skip key
|
||||
segment = segment.Subbytes(key.Bytes.Count);
|
||||
}
|
||||
break;
|
||||
|
||||
case TomlValueType.DottedKey:
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
// search and skip =
|
||||
int eq;
|
||||
if (!segment.TrySearchByte(x => x == '=', out eq))
|
||||
{
|
||||
throw new ParserException("= not found");
|
||||
}
|
||||
segment = segment.Subbytes(eq + 1);
|
||||
|
||||
// skip white space
|
||||
segment = segment.TrimStart();
|
||||
}
|
||||
|
||||
{
|
||||
var value = ParseRHS(segment, current);
|
||||
values.Add(value);
|
||||
|
||||
// skip value
|
||||
segment = segment.Subbytes(value.Bytes.Count);
|
||||
|
||||
// skip to line end
|
||||
segment = segment.Subbytes(segment.GetLine().ByteLength);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return new ListTreeNode<TomlValue>(values);
|
||||
}
|
||||
|
||||
public static ListTreeNode<TomlValue> Parse(String Toml)
|
||||
{
|
||||
return Parse(Utf8String.From(Toml));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 3fcee2cba67aa504a9385323813c07df
|
||||
timeCreated: 1545735557
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -1,171 +0,0 @@
|
|||
using System;
|
||||
|
||||
|
||||
namespace UniJSON
|
||||
{
|
||||
public enum TomlValueType
|
||||
{
|
||||
BareKey, // key
|
||||
QuotedKey, // "key"
|
||||
DottedKey, // key.nested
|
||||
BasicString, // "str"
|
||||
MultilineBasicString, // """str"""
|
||||
LiteralString, // 'str'
|
||||
MultilineLiteralString, // '''str'''
|
||||
Integer,
|
||||
Float,
|
||||
Boolean,
|
||||
OffsetDatetime,
|
||||
Array, // [1, 2, 3]
|
||||
Table, // [table_name]
|
||||
}
|
||||
|
||||
public struct TomlValue : IListTreeItem, IValue<TomlValue>
|
||||
{
|
||||
public override string ToString()
|
||||
{
|
||||
return m_segment.ToString();
|
||||
}
|
||||
|
||||
public int ParentIndex { get; private set; }
|
||||
|
||||
public TomlValueType TomlValueType
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public ValueNodeType ValueType
|
||||
{
|
||||
get
|
||||
{
|
||||
switch (TomlValueType)
|
||||
{
|
||||
case TomlValueType.Integer: return ValueNodeType.Integer;
|
||||
case TomlValueType.Float: return ValueNodeType.Number;
|
||||
case TomlValueType.Boolean: return ValueNodeType.Boolean;
|
||||
|
||||
case TomlValueType.BareKey: return ValueNodeType.String;
|
||||
case TomlValueType.QuotedKey: return ValueNodeType.String;
|
||||
case TomlValueType.DottedKey: return ValueNodeType.String;
|
||||
|
||||
case TomlValueType.BasicString: return ValueNodeType.String;
|
||||
case TomlValueType.MultilineBasicString: return ValueNodeType.String;
|
||||
case TomlValueType.LiteralString: return ValueNodeType.String;
|
||||
case TomlValueType.MultilineLiteralString: return ValueNodeType.String;
|
||||
|
||||
case TomlValueType.Table: return ValueNodeType.Object;
|
||||
case TomlValueType.Array: return ValueNodeType.Array;
|
||||
}
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
Utf8String m_segment;
|
||||
|
||||
public ArraySegment<byte> Bytes { get { return m_segment.Bytes; } }
|
||||
public void SetBytesCount(int count)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public int ChildCount
|
||||
{
|
||||
get
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
public void SetChildCount(int count)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public TomlValue(Utf8String segment, TomlValueType valueType, int parentIndex) : this()
|
||||
{
|
||||
ParentIndex = parentIndex;
|
||||
TomlValueType = valueType;
|
||||
m_segment = segment;
|
||||
}
|
||||
|
||||
public bool GetBoolean()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public byte GetByte()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public double GetDouble()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public short GetInt16()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public int GetInt32()
|
||||
{
|
||||
return m_segment.ToInt32();
|
||||
}
|
||||
|
||||
public long GetInt64()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public sbyte GetSByte()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public float GetSingle()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public string GetString()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public ushort GetUInt16()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public uint GetUInt32()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public ulong GetUInt64()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Utf8String GetUtf8String()
|
||||
{
|
||||
return m_segment;
|
||||
}
|
||||
|
||||
public U GetValue<U>()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public TomlValue Key(Utf8String key, int parentIndex)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public TomlValue New(ArraySegment<byte> bytes, ValueNodeType valueType, int parentIndex)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: e62dc750f570d764ab8c88742ceaa383
|
||||
timeCreated: 1545735558
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
20
Assets/UniGLTF/Runtime/UniJSON/ValueNodeType.cs
Normal file
20
Assets/UniGLTF/Runtime/UniJSON/ValueNodeType.cs
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
using System;
|
||||
|
||||
|
||||
namespace UniJSON
|
||||
{
|
||||
public enum ValueNodeType
|
||||
{
|
||||
Null,
|
||||
Boolean,
|
||||
String,
|
||||
Binary,
|
||||
Integer,
|
||||
Number,
|
||||
Array,
|
||||
Object,
|
||||
NaN,
|
||||
Infinity,
|
||||
MinusInfinity,
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 93b8e65929169944e823bc9a95c8a1ed
|
||||
guid: 66a8eb0c7cffd8849999e6e19ff45b3a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
|
|
@ -25,35 +25,5 @@ namespace UniJSON
|
|||
return Value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
[Test]
|
||||
public void GenericCallUtilityTestsSimplePasses()
|
||||
{
|
||||
var s = new Sample();
|
||||
|
||||
|
||||
{
|
||||
var mi = s.GetType().GetMethod("Set");
|
||||
var action = GenericInvokeCallFactory.OpenAction<Sample, int>(mi);
|
||||
action(s, 1);
|
||||
Assert.AreEqual(1, s.Value);
|
||||
}
|
||||
|
||||
{
|
||||
var mi = s.GetType().GetMethod("Get");
|
||||
var func = GenericInvokeCallFactory.OpenFunc<Sample, int, int>(mi);
|
||||
/*var value =*/ func(s, 1);
|
||||
Assert.AreEqual(1, s.Value);
|
||||
}
|
||||
|
||||
{
|
||||
var mi = s.GetType().GetMethod("Set");
|
||||
var action = GenericExpressionCallFactory.Create<Sample, int>(mi);
|
||||
action(s, 2);
|
||||
Assert.AreEqual(2, s.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ namespace UniJSON
|
|||
var it = root.Traverse().GetEnumerator();
|
||||
|
||||
var f = new JsonFormatter();
|
||||
f.Serialize("JsonPath");
|
||||
f.Value("JsonPath");
|
||||
|
||||
root.SetValue(Utf8String.From("/a"), f.GetStoreBytes());
|
||||
it.MoveNext(); Assert.AreEqual("/", it.Current.Pointer().ToString());
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ namespace UniJSON
|
|||
{
|
||||
public HogeFuga EnumDefault;
|
||||
|
||||
[JsonSchema(EnumSerializationType =EnumSerializationType.AsInt)]
|
||||
[JsonSchema(EnumSerializationType = EnumSerializationType.AsInt)]
|
||||
public HogeFuga EnumAsInt;
|
||||
|
||||
[JsonSchema(EnumSerializationType = EnumSerializationType.AsString)]
|
||||
|
|
@ -43,12 +43,50 @@ namespace UniJSON
|
|||
}
|
||||
|
||||
#region Serializer
|
||||
static void SerializeValue<T>(T value, string json)
|
||||
static void SerializeValue(float value, string json)
|
||||
{
|
||||
var b = new BytesStore();
|
||||
var f = new JsonFormatter(b);
|
||||
|
||||
f.Serialize(value);
|
||||
f.Value(value);
|
||||
Assert.AreEqual(json, new Utf8String(b.Bytes).ToString());
|
||||
}
|
||||
static void SerializeValue(double value, string json)
|
||||
{
|
||||
var b = new BytesStore();
|
||||
var f = new JsonFormatter(b);
|
||||
|
||||
f.Value(value);
|
||||
Assert.AreEqual(json, new Utf8String(b.Bytes).ToString());
|
||||
}
|
||||
static void SerializeValue(bool value, string json)
|
||||
{
|
||||
var b = new BytesStore();
|
||||
var f = new JsonFormatter(b);
|
||||
|
||||
f.Value(value);
|
||||
Assert.AreEqual(json, new Utf8String(b.Bytes).ToString());
|
||||
}
|
||||
static void SerializeValue(string value, string json)
|
||||
{
|
||||
var b = new BytesStore();
|
||||
var f = new JsonFormatter(b);
|
||||
|
||||
f.Value(value);
|
||||
Assert.AreEqual(json, new Utf8String(b.Bytes).ToString());
|
||||
}
|
||||
static void SerializeList<T>(IEnumerable<T> values, string json, Action<JsonFormatter, T> seri)
|
||||
{
|
||||
var b = new BytesStore();
|
||||
var f = new JsonFormatter(b);
|
||||
|
||||
f.BeginList();
|
||||
foreach (var value in values)
|
||||
{
|
||||
seri(f, value);
|
||||
}
|
||||
f.EndList();
|
||||
|
||||
Assert.AreEqual(json, new Utf8String(b.Bytes).ToString());
|
||||
}
|
||||
|
||||
|
|
@ -65,19 +103,19 @@ namespace UniJSON
|
|||
SerializeValue(false, "false");
|
||||
SerializeValue("ascii", "\"ascii\"");
|
||||
|
||||
SerializeValue(new[] { 1 }, "[1]");
|
||||
SerializeValue(new[] { 1.1f }, "[1.1]");
|
||||
SerializeValue(new[] { 1.2 }, "[1.2]");
|
||||
SerializeValue(new[] { true, false }, "[true,false]");
|
||||
SerializeValue(new[] { "ascii" }, "[\"ascii\"]");
|
||||
SerializeValue(new List<int> { 1 }, "[1]");
|
||||
SerializeList(new[] { 1 }, "[1]", (f, x) => f.Value(x));
|
||||
SerializeList(new[] { 1.1f }, "[1.1]", (f, x) => f.Value(x));
|
||||
SerializeList(new[] { 1.2 }, "[1.2]", (f, x) => f.Value(x));
|
||||
SerializeList(new[] { true, false }, "[true,false]", (f, x) => f.Value(x));
|
||||
SerializeList(new[] { "ascii" }, "[\"ascii\"]", (f, x) => f.Value(x));
|
||||
SerializeList(new List<int> { 1 }, "[1]", (f, x) => f.Value(x));
|
||||
//SerializeValue(new object[] { null, 1, "a" }, "[null,1,\"a\"]");
|
||||
|
||||
SerializeValue(new Dictionary<string, object> { }, "{}");
|
||||
SerializeValue(new Dictionary<string, object> { { "a", 1 } }, "{\"a\":1}");
|
||||
SerializeValue(new Dictionary<string, object> { { "a",
|
||||
new Dictionary<string, object>{
|
||||
} } }, "{\"a\":{}}");
|
||||
// SerializeValue(new Dictionary<string, object> { }, "{}");
|
||||
// SerializeValue(new Dictionary<string, object> { { "a", 1 } }, "{\"a\":1}");
|
||||
// SerializeValue(new Dictionary<string, object> { { "a",
|
||||
// new Dictionary<string, object>{
|
||||
// } } }, "{\"a\":{}}");
|
||||
|
||||
// SerializeValue(new Point { X = 1 }, "{\"X\":1,\"Y\":0}");
|
||||
|
||||
|
|
@ -99,7 +137,12 @@ namespace UniJSON
|
|||
|
||||
var f = new JsonFormatter();
|
||||
f.BeginMap();
|
||||
f.KeyValue(() => p.Vector);
|
||||
f.Key(nameof(p.Vector));
|
||||
f.BeginList();
|
||||
f.Value(p.Vector[0]);
|
||||
f.Value(p.Vector[1]);
|
||||
f.Value(p.Vector[2]);
|
||||
f.EndList();
|
||||
f.EndMap();
|
||||
|
||||
var json = JsonParser.Parse(new Utf8String(f.GetStoreBytes()));
|
||||
|
|
@ -146,7 +189,7 @@ namespace UniJSON
|
|||
// DeserializeValue(new EnumTest(), "{\"EnumDefault\":0,\"EnumAsInt\":0,\"EnumAsString\":\"Hoge\",\"EnumAsLowerString\":\"hoge\"}");
|
||||
// }
|
||||
|
||||
class DictionaryValue: IEquatable<DictionaryValue>
|
||||
class DictionaryValue : IEquatable<DictionaryValue>
|
||||
{
|
||||
public Dictionary<string, object> Dict = new Dictionary<string, object>();
|
||||
|
||||
|
|
@ -170,11 +213,11 @@ namespace UniJSON
|
|||
|
||||
public bool Equals(DictionaryValue other)
|
||||
{
|
||||
if(Dict==null && other.Dict == null)
|
||||
if (Dict == null && other.Dict == null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if(Dict==null || other.Dict==null)
|
||||
else if (Dict == null || other.Dict == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ namespace UniJSON
|
|||
{
|
||||
var v = new JsonValue(Utf8String.From("NaN"), ValueNodeType.NaN, -1);
|
||||
Assert.AreEqual("NaN", v.ToString());
|
||||
Assert.AreEqual(Double.NaN, v.GetValue<double>());
|
||||
Assert.AreEqual(Double.NaN, v.GetDouble());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -24,7 +24,7 @@ namespace UniJSON
|
|||
{
|
||||
var v = new JsonValue(Utf8String.From("Infinity"), ValueNodeType.Infinity, -1);
|
||||
Assert.AreEqual("Infinity", v.ToString());
|
||||
Assert.AreEqual(Double.PositiveInfinity, v.GetValue<double>());
|
||||
Assert.AreEqual(Double.PositiveInfinity, v.GetDouble());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -34,7 +34,7 @@ namespace UniJSON
|
|||
{
|
||||
var v = new JsonValue(Utf8String.From("-Infinity"), ValueNodeType.MinusInfinity, -1);
|
||||
Assert.AreEqual("-Infinity", v.ToString());
|
||||
Assert.AreEqual(Double.NegativeInfinity, v.GetValue<double>());
|
||||
Assert.AreEqual(Double.NegativeInfinity, v.GetDouble());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: a6fe9c2c8212b42459b037f4181cd3ae
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -1,92 +0,0 @@
|
|||
using NUnit.Framework;
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
namespace UniJSON.MsgPack
|
||||
{
|
||||
[TestFixture]
|
||||
public class ArrayTest
|
||||
{
|
||||
[Test]
|
||||
public void fix_array()
|
||||
{
|
||||
var f = new MsgPackFormatter();
|
||||
// Object[] not supported
|
||||
f.Serialize(new[] { 0, 1, false, (Object)null });
|
||||
var _bytes = f.GetStoreBytes();
|
||||
var bytes = _bytes.Array.Skip(_bytes.Offset).Take(_bytes.Count).ToArray();
|
||||
|
||||
Assert.AreEqual(new Byte[]{
|
||||
(Byte)MsgPackType.FIX_ARRAY_0x4,
|
||||
(Byte)MsgPackType.POSITIVE_FIXNUM,
|
||||
(Byte)MsgPackType.POSITIVE_FIXNUM_0x01,
|
||||
(Byte)MsgPackType.FALSE,
|
||||
(Byte)MsgPackType.NIL
|
||||
}, bytes);
|
||||
|
||||
var parsed = MsgPackParser.Parse(bytes);
|
||||
|
||||
Assert.AreEqual(4, parsed.GetArrayCount());
|
||||
Assert.AreEqual(0, parsed[0].GetValue());
|
||||
Assert.AreEqual(1, parsed[1].GetValue());
|
||||
Assert.False((Boolean)parsed[2].GetValue());
|
||||
Assert.AreEqual(null, parsed[3].GetValue());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void array16()
|
||||
{
|
||||
var f = new MsgPackFormatter();
|
||||
var data = Enumerable.Range(0, 20).Select(x => (Object)x).ToArray();
|
||||
f.Serialize(data);
|
||||
var bytes = f.GetStoreBytes();
|
||||
|
||||
var value = MsgPackParser.Parse(bytes);
|
||||
Assert.IsTrue(value.IsArray());
|
||||
Assert.AreEqual(20, value.GetArrayCount());
|
||||
for (int i = 0; i < 20; ++i)
|
||||
{
|
||||
Assert.AreEqual(i, value[i].GetValue());
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void array129()
|
||||
{
|
||||
{
|
||||
var i128 = Enumerable.Range(0, 128).ToArray();
|
||||
var f = new MsgPackFormatter();
|
||||
f.Serialize(i128);
|
||||
var bytes128 = f.GetStoreBytes();
|
||||
var deserialized = MsgPackParser.Parse(bytes128);
|
||||
Assert.AreEqual(128, deserialized.GetArrayCount());
|
||||
for (int i = 0; i < i128.Length; ++i)
|
||||
{
|
||||
Assert.AreEqual(i128[i], deserialized[i].GetValue());
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
var i129 = Enumerable.Range(0, 129).ToArray();
|
||||
var f = new MsgPackFormatter();
|
||||
f.Serialize(i129);
|
||||
var bytes129 = f.GetStoreBytes();
|
||||
var deserialized = MsgPackParser.Parse(bytes129);
|
||||
Assert.AreEqual(129, deserialized.GetArrayCount());
|
||||
for (int i = 0; i < i129.Length; ++i)
|
||||
{
|
||||
Assert.AreEqual(i129[i], deserialized[i].GetValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ReadTest()
|
||||
{
|
||||
var data = new int[] { -108, 0, 1, -90, 108, 111, 103, 103, 101, 114, -110, -91, 69, 114, 114, 111, 114, -94, 101, 50 }
|
||||
.Select(x => (Byte)x).ToArray();
|
||||
var parsed = MsgPackParser.Parse(data);
|
||||
Assert.True(parsed.IsArray());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 4b485b0360ebfd246ac90bbe8ad1895b
|
||||
timeCreated: 1540812276
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -1,50 +0,0 @@
|
|||
using NUnit.Framework;
|
||||
using System;
|
||||
|
||||
|
||||
namespace UniJSON.MsgPack
|
||||
{
|
||||
[TestFixture]
|
||||
public class BooleanTest
|
||||
{
|
||||
[Test]
|
||||
public void nil()
|
||||
{
|
||||
{
|
||||
var f = new MsgPackFormatter();
|
||||
f.Null();
|
||||
var bytes = f.GetStoreBytes();
|
||||
Assert.AreEqual(new Byte[] { 0xC0 }, bytes.ToEnumerable());
|
||||
|
||||
var parsed = MsgPackParser.Parse(bytes);
|
||||
Assert.True(parsed.IsNull());
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void True()
|
||||
{
|
||||
var f = new MsgPackFormatter();
|
||||
f.Value(true);
|
||||
var bytes = f.GetStoreBytes();
|
||||
Assert.AreEqual(new Byte[] { 0xC3 }, bytes.ToEnumerable());
|
||||
|
||||
var value = MsgPackParser.Parse(bytes);
|
||||
var j = value.GetBoolean();
|
||||
Assert.AreEqual(true, j);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void False()
|
||||
{
|
||||
var f = new MsgPackFormatter();
|
||||
f.Value(false);
|
||||
var bytes = f.GetStoreBytes();
|
||||
Assert.AreEqual(new Byte[] { 0xC2 }, bytes.ToEnumerable());
|
||||
|
||||
var value = MsgPackParser.Parse(bytes);
|
||||
var j = value.GetBoolean();
|
||||
Assert.AreEqual(false, j);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: d0f19e48b365cd446982ed0b7ba6251e
|
||||
timeCreated: 1540812276
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -1,50 +0,0 @@
|
|||
using NUnit.Framework;
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
|
||||
namespace UniJSON.MsgPack
|
||||
{
|
||||
[TestFixture]
|
||||
public class FloatTest
|
||||
{
|
||||
[Test]
|
||||
public void Float32()
|
||||
{
|
||||
var i = 1.1f;
|
||||
var float_be = new byte[]
|
||||
{
|
||||
(Byte)MsgPackType.FLOAT, 0x3f, 0x8c, 0xcc, 0xcd
|
||||
};
|
||||
|
||||
var f = new MsgPackFormatter();
|
||||
f.Value(i);
|
||||
var bytes = f.GetStoreBytes();
|
||||
|
||||
var value = MsgPackParser.Parse(bytes);
|
||||
var body = value.Value.Bytes;
|
||||
Assert.AreEqual(float_be, body.ToEnumerable().ToArray());
|
||||
|
||||
Assert.AreEqual(i, value.GetValue());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Float64()
|
||||
{
|
||||
var i = 1.1;
|
||||
var double_be = new Byte[]{
|
||||
(Byte)MsgPackType.DOUBLE, 0x3f, 0xf1, 0x99, 0x99, 0x99, 0x99, 0x99, 0x9a,
|
||||
};
|
||||
|
||||
var f = new MsgPackFormatter();
|
||||
f.Value(i);
|
||||
var bytes = f.GetStoreBytes();
|
||||
|
||||
var value = MsgPackParser.Parse(bytes);
|
||||
var body = value.Value.Bytes;
|
||||
Assert.AreEqual(double_be, body.ToEnumerable().ToArray());
|
||||
|
||||
Assert.AreEqual(i, value.GetValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 51cdc6be3b73a34429cae41cd020c71c
|
||||
timeCreated: 1540812276
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -1,220 +0,0 @@
|
|||
using NUnit.Framework;
|
||||
using System;
|
||||
|
||||
|
||||
namespace UniJSON.MsgPack
|
||||
{
|
||||
[TestFixture]
|
||||
public class IntTest
|
||||
{
|
||||
[Test]
|
||||
public void positive_fixnum()
|
||||
{
|
||||
for (Byte i = 0; i < 128; ++i)
|
||||
{
|
||||
var f = new MsgPackFormatter();
|
||||
f.Value(i);
|
||||
var bytes = f.GetStoreBytes();
|
||||
Assert.AreEqual(new Byte[] { i }, bytes.ToEnumerable());
|
||||
|
||||
var j = MsgPackParser.Parse(bytes).GetValue();
|
||||
Assert.AreEqual(i, j);
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void negative_fixnum()
|
||||
{
|
||||
for (SByte i = -32; i < 0; ++i)
|
||||
{
|
||||
var f = new MsgPackFormatter();
|
||||
f.Value(i);
|
||||
var bytes = f.GetStoreBytes();
|
||||
|
||||
var j = MsgPackParser.Parse(bytes).GetValue();
|
||||
Assert.AreEqual(i, j);
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void uint8()
|
||||
{
|
||||
{
|
||||
Byte i = 0x7F + 20;
|
||||
|
||||
var f = new MsgPackFormatter();
|
||||
f.Value(i);
|
||||
var bytes = f.GetStoreBytes();
|
||||
Assert.AreEqual(new Byte[]{
|
||||
0xcc, 0x93,
|
||||
}, bytes.ToEnumerable());
|
||||
|
||||
var j = MsgPackParser.Parse(bytes).GetValue();
|
||||
Assert.AreEqual(i, j);
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void cast_large_type()
|
||||
{
|
||||
{
|
||||
Byte i = 0x7F + 20;
|
||||
|
||||
var f = new MsgPackFormatter();
|
||||
f.Value(i);
|
||||
var bytes = f.GetStoreBytes();
|
||||
Assert.AreEqual(new Byte[]{
|
||||
0xcc, 0x93,
|
||||
}, bytes.ToEnumerable());
|
||||
|
||||
var j = MsgPackParser.Parse(bytes).GetValue();
|
||||
Assert.AreEqual(i, j);
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void uint16()
|
||||
{
|
||||
{
|
||||
UInt16 i = 0xFF + 20;
|
||||
|
||||
var f = new MsgPackFormatter();
|
||||
f.Value(i);
|
||||
var bytes = f.GetStoreBytes();
|
||||
Assert.AreEqual(new Byte[]{
|
||||
0xcd, 0x01, 0x13
|
||||
}, bytes.ToEnumerable());
|
||||
|
||||
var j = MsgPackParser.Parse(bytes).GetValue();
|
||||
Assert.AreEqual(i, j);
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void uint32()
|
||||
{
|
||||
{
|
||||
UInt32 i = 0xFFFF + 20;
|
||||
|
||||
var f = new MsgPackFormatter();
|
||||
f.Value(i);
|
||||
var bytes = f.GetStoreBytes();
|
||||
Assert.AreEqual(new Byte[]{
|
||||
0xce, 0x00, 0x01, 0x00, 0x13
|
||||
}, bytes.ToEnumerable());
|
||||
|
||||
var j = MsgPackParser.Parse(bytes).GetValue();
|
||||
Assert.AreEqual(i, j);
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void uint64()
|
||||
{
|
||||
{
|
||||
UInt64 i = 0xFFFFFFFF;
|
||||
i += 20;
|
||||
|
||||
var f = new MsgPackFormatter();
|
||||
f.Value(i);
|
||||
var bytes = f.GetStoreBytes();
|
||||
Assert.AreEqual(new Byte[]{
|
||||
0xcf, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x13
|
||||
}, bytes.ToEnumerable());
|
||||
|
||||
var j = MsgPackParser.Parse(bytes).GetValue();
|
||||
Assert.AreEqual(i, j);
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void int8()
|
||||
{
|
||||
{
|
||||
SByte i = -64;
|
||||
|
||||
var f = new MsgPackFormatter();
|
||||
f.Value(i);
|
||||
var bytes = f.GetStoreBytes();
|
||||
|
||||
Assert.AreEqual(new Byte[]{
|
||||
0xd0, 0xc0,
|
||||
}, bytes.ToEnumerable());
|
||||
|
||||
var j = MsgPackParser.Parse(bytes).GetValue();
|
||||
Assert.AreEqual(i, j);
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void int128Test()
|
||||
{
|
||||
int i = 128;
|
||||
var f = new MsgPackFormatter();
|
||||
f.Value(i);
|
||||
var bytes = f.GetStoreBytes();
|
||||
Assert.AreEqual(new Byte[]{
|
||||
0xcc, 0x80,
|
||||
}, bytes.ToEnumerable());
|
||||
var j = MsgPackParser.Parse(bytes).GetValue();
|
||||
Assert.AreEqual(i, j);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void int16()
|
||||
{
|
||||
{
|
||||
Int16 i = -150;
|
||||
|
||||
var f = new MsgPackFormatter();
|
||||
f.Value(i);
|
||||
var bytes = f.GetStoreBytes();
|
||||
|
||||
Assert.AreEqual(new Byte[]{
|
||||
0xd1, 0xFF, 0x6a
|
||||
}, bytes.ToEnumerable());
|
||||
|
||||
var j = MsgPackParser.Parse(bytes).GetValue();
|
||||
Assert.AreEqual(i, j);
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void int32()
|
||||
{
|
||||
{
|
||||
Int32 i = -35000;
|
||||
|
||||
var f = new MsgPackFormatter();
|
||||
f.Value(i);
|
||||
var bytes = f.GetStoreBytes();
|
||||
|
||||
Assert.AreEqual(new Byte[]{
|
||||
0xd2, 0xff, 0xff, 0x77, 0x48
|
||||
}, bytes.ToEnumerable());
|
||||
|
||||
var j = MsgPackParser.Parse(bytes).GetValue();
|
||||
Assert.AreEqual(i, j);
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void int64()
|
||||
{
|
||||
{
|
||||
Int64 i = -2147483650;
|
||||
|
||||
var f = new MsgPackFormatter();
|
||||
f.Value(i);
|
||||
var bytes = f.GetStoreBytes();
|
||||
|
||||
Assert.AreEqual(new Byte[]{
|
||||
0xd3, 0xff, 0xff, 0xff, 0xff, 0x7f, 0xff, 0xff, 0xfe
|
||||
}, bytes.ToEnumerable());
|
||||
|
||||
var j = MsgPackParser.Parse(bytes).GetValue();
|
||||
Assert.AreEqual(i, j);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 8d6f5e40bc0825b449887d877c0ad5c5
|
||||
timeCreated: 1540812276
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -1,120 +0,0 @@
|
|||
using NUnit.Framework;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
namespace UniJSON.MsgPack
|
||||
{
|
||||
[TestFixture]
|
||||
public class MapTest
|
||||
{
|
||||
[Test]
|
||||
public void fix_map()
|
||||
{
|
||||
var f = new MsgPackFormatter();
|
||||
f.BeginMap(2);
|
||||
f.Key("0"); f.Value(1);
|
||||
f.Key("2"); f.Value(3);
|
||||
f.EndMap();
|
||||
var bytes =
|
||||
f.GetStoreBytes();
|
||||
;
|
||||
|
||||
Assert.AreEqual(new Byte[]{
|
||||
0x82, // map2
|
||||
|
||||
0xa1, 0x30, // "0"
|
||||
0x01, // 1
|
||||
|
||||
0xa1, 0x32, // "2"
|
||||
0x03 // 3
|
||||
}, bytes.ToEnumerable());
|
||||
|
||||
var value = MsgPackParser.Parse(bytes);
|
||||
|
||||
Assert.AreEqual(2, value.GetObjectCount());
|
||||
Assert.AreEqual(1, value["0"].GetValue());
|
||||
Assert.AreEqual(3, value["2"].GetValue());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void map16()
|
||||
{
|
||||
var w = new MsgPackFormatter();
|
||||
int size = 18;
|
||||
w.BeginMap(size);
|
||||
for (int i = 0; i < size; ++i)
|
||||
{
|
||||
w.Value(i.ToString());
|
||||
w.Value(i + 5);
|
||||
}
|
||||
var bytes = w.GetStoreBytes().ToEnumerable().ToArray();
|
||||
|
||||
|
||||
var expected = new Byte[]{
|
||||
0xde, // map18
|
||||
0x0, 0x12, // 18
|
||||
|
||||
0xa1, 0x30, // "0"
|
||||
0x5,
|
||||
|
||||
0xa1, 0x31, // "1"
|
||||
0x6,
|
||||
|
||||
0xa1, 0x32, // "2"
|
||||
0x7,
|
||||
|
||||
0xa1, 0x33, // "3"
|
||||
0x8,
|
||||
|
||||
0xa1, 0x34, // "4"
|
||||
0x9,
|
||||
|
||||
0xa1, 0x35, // "5"
|
||||
0xa,
|
||||
|
||||
0xa1, 0x36, // "6"
|
||||
0xb,
|
||||
|
||||
0xa1, 0x37, // "7"
|
||||
0xc,
|
||||
|
||||
0xa1, 0x38, // "8"
|
||||
0xd,
|
||||
|
||||
0xa1, 0x39, // "9"
|
||||
0xe,
|
||||
|
||||
0xa2, 0x31, 0x30, // "10"
|
||||
0xf,
|
||||
|
||||
0xa2, 0x31, 0x31, // "11"
|
||||
0x10,
|
||||
|
||||
0xa2, 0x31, 0x32, // "12"
|
||||
0x11,
|
||||
|
||||
0xa2, 0x31, 0x33, // "13"
|
||||
0x12,
|
||||
|
||||
0xa2, 0x31, 0x34, // "14"
|
||||
0x13,
|
||||
|
||||
0xa2, 0x31, 0x35, // "15"
|
||||
0x14,
|
||||
|
||||
0xa2, 0x31, 0x36, // "16"
|
||||
0x15,
|
||||
|
||||
0xa2, 0x31, 0x37, // "17",
|
||||
0x16
|
||||
};
|
||||
|
||||
Assert.AreEqual(expected, bytes);
|
||||
|
||||
var value = MsgPackParser.Parse(bytes);
|
||||
|
||||
Assert.AreEqual(15, value["10"].GetValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 87a626e93589db14fbe4526c9880b110
|
||||
timeCreated: 1540812276
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -1,34 +0,0 @@
|
|||
using NUnit.Framework;
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
namespace UniJSON.MsgPack
|
||||
{
|
||||
[TestFixture]
|
||||
public class RawTest
|
||||
{
|
||||
[Test]
|
||||
public void fix_raw()
|
||||
{
|
||||
var src = new Byte[] { 0, 1, 2 };
|
||||
var f = new MsgPackFormatter();
|
||||
f.Value(src);
|
||||
var bytes = f.GetStoreBytes();
|
||||
|
||||
var v = MsgPackParser.Parse(bytes).Value.GetBody();
|
||||
Assert.True(src.SequenceEqual(v.ToEnumerable()));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void raw16()
|
||||
{
|
||||
var src = Enumerable.Range(0, 50).Select(x => (Byte)x).ToArray();
|
||||
var f = new MsgPackFormatter();
|
||||
f.Value(src);
|
||||
var bytes = f.GetStoreBytes();
|
||||
|
||||
var v = MsgPackParser.Parse(bytes).Value.GetBody();
|
||||
Assert.True(src.SequenceEqual(v.ToEnumerable()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 331bd613923afe5438ef4ff3a59fc5b3
|
||||
timeCreated: 1540812276
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -1,36 +0,0 @@
|
|||
using NUnit.Framework;
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
namespace UniJSON.MsgPack
|
||||
{
|
||||
[TestFixture]
|
||||
public class StringTest
|
||||
{
|
||||
[Test]
|
||||
public void str()
|
||||
{
|
||||
var f = new MsgPackFormatter();
|
||||
f.Value("文字列");
|
||||
var bytes = f.GetStoreBytes();
|
||||
|
||||
var v = MsgPackParser.Parse(bytes).GetValue();
|
||||
Assert.AreEqual("文字列", v);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void fix_str()
|
||||
{
|
||||
for (int i = 1; i < 32; ++i)
|
||||
{
|
||||
var str = String.Join("", Enumerable.Range(0, i).Select(_ => "0").ToArray());
|
||||
var f = new MsgPackFormatter();
|
||||
f.Value(str);
|
||||
var bytes = f.GetStoreBytes();
|
||||
|
||||
var value = MsgPackParser.Parse(bytes);
|
||||
Assert.AreEqual(i, ((String)value.GetValue()).Length);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 3942810073614d946a76d87cbbfb222c
|
||||
timeCreated: 1540812276
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -1,50 +0,0 @@
|
|||
using NUnit.Framework;
|
||||
using System;
|
||||
|
||||
|
||||
namespace UniJSON.MsgPack
|
||||
{
|
||||
public class TimeTests
|
||||
{
|
||||
[Test]
|
||||
public void TimeTest()
|
||||
{
|
||||
var f = new MsgPackFormatter();
|
||||
|
||||
{
|
||||
f.GetStore().Clear();
|
||||
var time = new DateTimeOffset(1970, 1, 1, 0, 0, 0, 0, TimeSpan.Zero);
|
||||
f.Value(time);
|
||||
|
||||
var bytes = f.GetStoreBytes().ArrayOrCopy();
|
||||
unchecked
|
||||
{
|
||||
Assert.AreEqual(new byte[]
|
||||
{
|
||||
(byte)MsgPackType.FIX_EXT_4, (byte)-1, 0, 0, 0, 0
|
||||
}, bytes);
|
||||
}
|
||||
var parsed = MsgPackParser.Parse(bytes).GetValue();
|
||||
Assert.AreEqual(time, parsed);
|
||||
}
|
||||
|
||||
{
|
||||
var time = new DateTimeOffset(2018, 12, 8, 2, 12, 15, TimeSpan.Zero);
|
||||
Assert.AreEqual(1544235135, time.ToUnixTimeSeconds());
|
||||
f.GetStore().Clear();
|
||||
f.Value(time);
|
||||
var bytes = f.GetStoreBytes().ArrayOrCopy();
|
||||
var parsed = MsgPackParser.Parse(bytes).GetValue();
|
||||
Assert.AreEqual(time, parsed);
|
||||
}
|
||||
|
||||
{
|
||||
f.GetStore().Clear();
|
||||
Assert.Catch(() =>
|
||||
{
|
||||
f.Value(new DateTimeOffset());
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 0a025b475357b4d4aa104e839e6791be
|
||||
timeCreated: 1544154226
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 8536361e247bd4b408d82604d3b16a10
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -1,128 +0,0 @@
|
|||
using NUnit.Framework;
|
||||
|
||||
|
||||
/*
|
||||
namespace UniJSON.Toml
|
||||
{
|
||||
class TomlParserTests
|
||||
{
|
||||
[Test]
|
||||
public void BareKeyTests()
|
||||
{
|
||||
{
|
||||
var result = TomlParser.Parse(@"
|
||||
value = 1
|
||||
");
|
||||
Assert.True(result.IsMap());
|
||||
Assert.AreEqual(1, result["value"].GetInt32());
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DottedKeyTests()
|
||||
{
|
||||
{
|
||||
var result = TomlParser.Parse(@"
|
||||
value.value2 = 1
|
||||
");
|
||||
Assert.True(result.IsMap());
|
||||
Assert.AreEqual(1, result["value"]["value2"].GetInt32());
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DuplicatedKey()
|
||||
{
|
||||
{
|
||||
Assert.Catch(() => TomlParser.Parse(@"
|
||||
value = 1
|
||||
value = 2
|
||||
"));
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void QuotedKeyTests()
|
||||
{
|
||||
{
|
||||
var result = TomlParser.Parse(@"
|
||||
""value"" = 1
|
||||
");
|
||||
Assert.True(result.IsMap());
|
||||
Assert.AreEqual(1, result["value"].GetInt32());
|
||||
}
|
||||
|
||||
{
|
||||
var result = TomlParser.Parse(@"
|
||||
""[key=value]"" = 1
|
||||
");
|
||||
Assert.True(result.IsMap());
|
||||
Assert.AreEqual(1, result["value"].GetInt32());
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TableTests()
|
||||
{
|
||||
{
|
||||
var result = @"
|
||||
[table]
|
||||
value = 1
|
||||
".ParseAsToml();
|
||||
Assert.True(result.IsMap());
|
||||
Assert.AreEqual(1, result["table"]["value"].GetInt32());
|
||||
}
|
||||
|
||||
{
|
||||
var result = @"
|
||||
[table.table2]
|
||||
value = 1
|
||||
".ParseAsToml();
|
||||
Assert.True(result.IsMap());
|
||||
Assert.AreEqual(1, result["table"]["table2"]["value"].GetInt32());
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TomlExample()
|
||||
{
|
||||
var result = @"
|
||||
# This is a TOML document.
|
||||
|
||||
title = ""TOML Example""
|
||||
|
||||
[owner]
|
||||
name = ""Tom Preston-Werner""
|
||||
dob = 1979 - 05 - 27T07: 32:00 - 08:00 # First class dates
|
||||
|
||||
[database]
|
||||
server = ""192.168.1.1""
|
||||
ports = [8001, 8001, 8002]
|
||||
connection_max = 5000
|
||||
enabled = true
|
||||
|
||||
[servers]
|
||||
|
||||
# Indentation (tabs and/or spaces) is allowed but not required
|
||||
[servers.alpha]
|
||||
ip = ""10.0.0.1""
|
||||
dc = ""eqdc10""
|
||||
|
||||
[servers.beta]
|
||||
ip = ""10.0.0.2""
|
||||
dc = ""eqdc10""
|
||||
|
||||
[clients]
|
||||
data = [ [""gamma"", ""delta""], [1, 2] ]
|
||||
|
||||
# Line breaks are OK when inside arrays
|
||||
hosts = [
|
||||
""alpha"",
|
||||
""omega""
|
||||
]
|
||||
".ParseAsToml();
|
||||
Assert.AreEqual("TOML Example", result["title"].GetString());
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 7959f4764f02c5e4d9f191e794bc6101
|
||||
timeCreated: 1545735557
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -4,15 +4,16 @@ using UniGLTF;
|
|||
using UniJSON;
|
||||
using UnityEngine;
|
||||
using MeshUtility;
|
||||
using System;
|
||||
|
||||
namespace VRM.Samples
|
||||
{
|
||||
public static class JsonExtensions
|
||||
{
|
||||
public static void SetValue<T>(this ListTreeNode<JsonValue> node, string key, T value)
|
||||
public static void SetValue<T>(this JsonNode node, string key, T value, Action<JsonFormatter, T> seri)
|
||||
{
|
||||
var f = new JsonFormatter();
|
||||
f.Serialize(value);
|
||||
seri(f, value);
|
||||
var p = Utf8String.From(key);
|
||||
var bytes = f.GetStoreBytes();
|
||||
node.SetValue(p, bytes);
|
||||
|
|
@ -50,13 +51,13 @@ namespace VRM.Samples
|
|||
using (new ActionDisposer(() => { GameObject.DestroyImmediate(context.Root); }))
|
||||
{
|
||||
var importedJson = JsonParser.Parse(context.Json);
|
||||
importedJson.SetValue("/extensions/VRM/exporterVersion", VRMVersion.VRM_VERSION);
|
||||
importedJson.SetValue("/asset/generator", UniGLTF.UniGLTFVersion.UNIGLTF_VERSION);
|
||||
importedJson.SetValue("/scene", 0);
|
||||
importedJson.SetValue("/materials/*/doubleSided", false);
|
||||
importedJson.SetValue("/extensions/VRM/exporterVersion", VRMVersion.VRM_VERSION, (f, x) => f.Value(x));
|
||||
importedJson.SetValue("/asset/generator", UniGLTF.UniGLTFVersion.UNIGLTF_VERSION, (f, x) => f.Value(x));
|
||||
importedJson.SetValue("/scene", 0, (f, x) => f.Value(x));
|
||||
importedJson.SetValue("/materials/*/doubleSided", false, (f, x) => f.Value(x));
|
||||
//importJson.SetValue("/materials/*/pbrMetallicRoughness/roughnessFactor", 0);
|
||||
//importJson.SetValue("/materials/*/pbrMetallicRoughness/baseColorFactor", new float[] { 1, 1, 1, 1 });
|
||||
importedJson.SetValue("/accessors/*/normalized", false);
|
||||
importedJson.SetValue("/accessors/*/normalized", false, (f, x) => f.Value(x));
|
||||
importedJson.RemoveValue(Utf8String.From("/nodes/*/extras"));
|
||||
/*
|
||||
importJson.SetValue("/bufferViews/12/byteStride", 4);
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ public static class VrmDeserializer
|
|||
{
|
||||
|
||||
|
||||
public static glTF_VRM_extensions Deserialize(ListTreeNode<JsonValue> parsed)
|
||||
public static glTF_VRM_extensions Deserialize(JsonNode parsed)
|
||||
{
|
||||
var value = new glTF_VRM_extensions();
|
||||
|
||||
|
|
@ -63,7 +63,7 @@ public static glTF_VRM_extensions Deserialize(ListTreeNode<JsonValue> parsed)
|
|||
return value;
|
||||
}
|
||||
|
||||
public static glTF_VRM_Meta Deserialize_vrm_meta(ListTreeNode<JsonValue> parsed)
|
||||
public static glTF_VRM_Meta Deserialize_vrm_meta(JsonNode parsed)
|
||||
{
|
||||
var value = new glTF_VRM_Meta();
|
||||
|
||||
|
|
@ -140,7 +140,7 @@ public static glTF_VRM_Meta Deserialize_vrm_meta(ListTreeNode<JsonValue> parsed)
|
|||
return value;
|
||||
}
|
||||
|
||||
public static glTF_VRM_Humanoid Deserialize_vrm_humanoid(ListTreeNode<JsonValue> parsed)
|
||||
public static glTF_VRM_Humanoid Deserialize_vrm_humanoid(JsonNode parsed)
|
||||
{
|
||||
var value = new glTF_VRM_Humanoid();
|
||||
|
||||
|
|
@ -197,7 +197,7 @@ public static glTF_VRM_Humanoid Deserialize_vrm_humanoid(ListTreeNode<JsonValue>
|
|||
return value;
|
||||
}
|
||||
|
||||
public static List<VRM.glTF_VRM_HumanoidBone> Deserialize_vrm_humanoid_humanBones(ListTreeNode<JsonValue> parsed)
|
||||
public static List<VRM.glTF_VRM_HumanoidBone> Deserialize_vrm_humanoid_humanBones(JsonNode parsed)
|
||||
{
|
||||
var value = new List<glTF_VRM_HumanoidBone>();
|
||||
foreach(var x in parsed.ArrayItems())
|
||||
|
|
@ -206,7 +206,7 @@ public static List<VRM.glTF_VRM_HumanoidBone> Deserialize_vrm_humanoid_humanBone
|
|||
}
|
||||
return value;
|
||||
}
|
||||
public static glTF_VRM_HumanoidBone Deserialize_vrm_humanoid_humanBones_LIST(ListTreeNode<JsonValue> parsed)
|
||||
public static glTF_VRM_HumanoidBone Deserialize_vrm_humanoid_humanBones_LIST(JsonNode parsed)
|
||||
{
|
||||
var value = new glTF_VRM_HumanoidBone();
|
||||
|
||||
|
|
@ -253,7 +253,7 @@ public static glTF_VRM_HumanoidBone Deserialize_vrm_humanoid_humanBones_LIST(Lis
|
|||
return value;
|
||||
}
|
||||
|
||||
public static Vector3 Deserialize_vrm_humanoid_humanBones__min(ListTreeNode<JsonValue> parsed)
|
||||
public static Vector3 Deserialize_vrm_humanoid_humanBones__min(JsonNode parsed)
|
||||
{
|
||||
var value = new Vector3();
|
||||
|
||||
|
|
@ -280,7 +280,7 @@ public static Vector3 Deserialize_vrm_humanoid_humanBones__min(ListTreeNode<Json
|
|||
return value;
|
||||
}
|
||||
|
||||
public static Vector3 Deserialize_vrm_humanoid_humanBones__max(ListTreeNode<JsonValue> parsed)
|
||||
public static Vector3 Deserialize_vrm_humanoid_humanBones__max(JsonNode parsed)
|
||||
{
|
||||
var value = new Vector3();
|
||||
|
||||
|
|
@ -307,7 +307,7 @@ public static Vector3 Deserialize_vrm_humanoid_humanBones__max(ListTreeNode<Json
|
|||
return value;
|
||||
}
|
||||
|
||||
public static Vector3 Deserialize_vrm_humanoid_humanBones__center(ListTreeNode<JsonValue> parsed)
|
||||
public static Vector3 Deserialize_vrm_humanoid_humanBones__center(JsonNode parsed)
|
||||
{
|
||||
var value = new Vector3();
|
||||
|
||||
|
|
@ -334,7 +334,7 @@ public static Vector3 Deserialize_vrm_humanoid_humanBones__center(ListTreeNode<J
|
|||
return value;
|
||||
}
|
||||
|
||||
public static glTF_VRM_Firstperson Deserialize_vrm_firstPerson(ListTreeNode<JsonValue> parsed)
|
||||
public static glTF_VRM_Firstperson Deserialize_vrm_firstPerson(JsonNode parsed)
|
||||
{
|
||||
var value = new glTF_VRM_Firstperson();
|
||||
|
||||
|
|
@ -386,7 +386,7 @@ public static glTF_VRM_Firstperson Deserialize_vrm_firstPerson(ListTreeNode<Json
|
|||
return value;
|
||||
}
|
||||
|
||||
public static Vector3 Deserialize_vrm_firstPerson_firstPersonBoneOffset(ListTreeNode<JsonValue> parsed)
|
||||
public static Vector3 Deserialize_vrm_firstPerson_firstPersonBoneOffset(JsonNode parsed)
|
||||
{
|
||||
var value = new Vector3();
|
||||
|
||||
|
|
@ -413,7 +413,7 @@ public static Vector3 Deserialize_vrm_firstPerson_firstPersonBoneOffset(ListTree
|
|||
return value;
|
||||
}
|
||||
|
||||
public static List<VRM.glTF_VRM_MeshAnnotation> Deserialize_vrm_firstPerson_meshAnnotations(ListTreeNode<JsonValue> parsed)
|
||||
public static List<VRM.glTF_VRM_MeshAnnotation> Deserialize_vrm_firstPerson_meshAnnotations(JsonNode parsed)
|
||||
{
|
||||
var value = new List<glTF_VRM_MeshAnnotation>();
|
||||
foreach(var x in parsed.ArrayItems())
|
||||
|
|
@ -422,7 +422,7 @@ public static List<VRM.glTF_VRM_MeshAnnotation> Deserialize_vrm_firstPerson_mesh
|
|||
}
|
||||
return value;
|
||||
}
|
||||
public static glTF_VRM_MeshAnnotation Deserialize_vrm_firstPerson_meshAnnotations_LIST(ListTreeNode<JsonValue> parsed)
|
||||
public static glTF_VRM_MeshAnnotation Deserialize_vrm_firstPerson_meshAnnotations_LIST(JsonNode parsed)
|
||||
{
|
||||
var value = new glTF_VRM_MeshAnnotation();
|
||||
|
||||
|
|
@ -444,7 +444,7 @@ public static glTF_VRM_MeshAnnotation Deserialize_vrm_firstPerson_meshAnnotation
|
|||
return value;
|
||||
}
|
||||
|
||||
public static glTF_VRM_DegreeMap Deserialize_vrm_firstPerson_lookAtHorizontalInner(ListTreeNode<JsonValue> parsed)
|
||||
public static glTF_VRM_DegreeMap Deserialize_vrm_firstPerson_lookAtHorizontalInner(JsonNode parsed)
|
||||
{
|
||||
var value = new glTF_VRM_DegreeMap();
|
||||
|
||||
|
|
@ -471,7 +471,7 @@ public static glTF_VRM_DegreeMap Deserialize_vrm_firstPerson_lookAtHorizontalInn
|
|||
return value;
|
||||
}
|
||||
|
||||
public static Single[] Deserialize_vrm_firstPerson_lookAtHorizontalInner_curve(ListTreeNode<JsonValue> parsed)
|
||||
public static Single[] Deserialize_vrm_firstPerson_lookAtHorizontalInner_curve(JsonNode parsed)
|
||||
{
|
||||
var value = new Single[parsed.GetArrayCount()];
|
||||
int i=0;
|
||||
|
|
@ -482,7 +482,7 @@ public static Single[] Deserialize_vrm_firstPerson_lookAtHorizontalInner_curve(L
|
|||
return value;
|
||||
}
|
||||
|
||||
public static glTF_VRM_DegreeMap Deserialize_vrm_firstPerson_lookAtHorizontalOuter(ListTreeNode<JsonValue> parsed)
|
||||
public static glTF_VRM_DegreeMap Deserialize_vrm_firstPerson_lookAtHorizontalOuter(JsonNode parsed)
|
||||
{
|
||||
var value = new glTF_VRM_DegreeMap();
|
||||
|
||||
|
|
@ -509,7 +509,7 @@ public static glTF_VRM_DegreeMap Deserialize_vrm_firstPerson_lookAtHorizontalOut
|
|||
return value;
|
||||
}
|
||||
|
||||
public static Single[] Deserialize_vrm_firstPerson_lookAtHorizontalOuter_curve(ListTreeNode<JsonValue> parsed)
|
||||
public static Single[] Deserialize_vrm_firstPerson_lookAtHorizontalOuter_curve(JsonNode parsed)
|
||||
{
|
||||
var value = new Single[parsed.GetArrayCount()];
|
||||
int i=0;
|
||||
|
|
@ -520,7 +520,7 @@ public static Single[] Deserialize_vrm_firstPerson_lookAtHorizontalOuter_curve(L
|
|||
return value;
|
||||
}
|
||||
|
||||
public static glTF_VRM_DegreeMap Deserialize_vrm_firstPerson_lookAtVerticalDown(ListTreeNode<JsonValue> parsed)
|
||||
public static glTF_VRM_DegreeMap Deserialize_vrm_firstPerson_lookAtVerticalDown(JsonNode parsed)
|
||||
{
|
||||
var value = new glTF_VRM_DegreeMap();
|
||||
|
||||
|
|
@ -547,7 +547,7 @@ public static glTF_VRM_DegreeMap Deserialize_vrm_firstPerson_lookAtVerticalDown(
|
|||
return value;
|
||||
}
|
||||
|
||||
public static Single[] Deserialize_vrm_firstPerson_lookAtVerticalDown_curve(ListTreeNode<JsonValue> parsed)
|
||||
public static Single[] Deserialize_vrm_firstPerson_lookAtVerticalDown_curve(JsonNode parsed)
|
||||
{
|
||||
var value = new Single[parsed.GetArrayCount()];
|
||||
int i=0;
|
||||
|
|
@ -558,7 +558,7 @@ public static Single[] Deserialize_vrm_firstPerson_lookAtVerticalDown_curve(List
|
|||
return value;
|
||||
}
|
||||
|
||||
public static glTF_VRM_DegreeMap Deserialize_vrm_firstPerson_lookAtVerticalUp(ListTreeNode<JsonValue> parsed)
|
||||
public static glTF_VRM_DegreeMap Deserialize_vrm_firstPerson_lookAtVerticalUp(JsonNode parsed)
|
||||
{
|
||||
var value = new glTF_VRM_DegreeMap();
|
||||
|
||||
|
|
@ -585,7 +585,7 @@ public static glTF_VRM_DegreeMap Deserialize_vrm_firstPerson_lookAtVerticalUp(Li
|
|||
return value;
|
||||
}
|
||||
|
||||
public static Single[] Deserialize_vrm_firstPerson_lookAtVerticalUp_curve(ListTreeNode<JsonValue> parsed)
|
||||
public static Single[] Deserialize_vrm_firstPerson_lookAtVerticalUp_curve(JsonNode parsed)
|
||||
{
|
||||
var value = new Single[parsed.GetArrayCount()];
|
||||
int i=0;
|
||||
|
|
@ -596,7 +596,7 @@ public static Single[] Deserialize_vrm_firstPerson_lookAtVerticalUp_curve(ListTr
|
|||
return value;
|
||||
}
|
||||
|
||||
public static glTF_VRM_BlendShapeMaster Deserialize_vrm_blendShapeMaster(ListTreeNode<JsonValue> parsed)
|
||||
public static glTF_VRM_BlendShapeMaster Deserialize_vrm_blendShapeMaster(JsonNode parsed)
|
||||
{
|
||||
var value = new glTF_VRM_BlendShapeMaster();
|
||||
|
||||
|
|
@ -613,7 +613,7 @@ public static glTF_VRM_BlendShapeMaster Deserialize_vrm_blendShapeMaster(ListTre
|
|||
return value;
|
||||
}
|
||||
|
||||
public static List<VRM.glTF_VRM_BlendShapeGroup> Deserialize_vrm_blendShapeMaster_blendShapeGroups(ListTreeNode<JsonValue> parsed)
|
||||
public static List<VRM.glTF_VRM_BlendShapeGroup> Deserialize_vrm_blendShapeMaster_blendShapeGroups(JsonNode parsed)
|
||||
{
|
||||
var value = new List<glTF_VRM_BlendShapeGroup>();
|
||||
foreach(var x in parsed.ArrayItems())
|
||||
|
|
@ -622,7 +622,7 @@ public static List<VRM.glTF_VRM_BlendShapeGroup> Deserialize_vrm_blendShapeMaste
|
|||
}
|
||||
return value;
|
||||
}
|
||||
public static glTF_VRM_BlendShapeGroup Deserialize_vrm_blendShapeMaster_blendShapeGroups_LIST(ListTreeNode<JsonValue> parsed)
|
||||
public static glTF_VRM_BlendShapeGroup Deserialize_vrm_blendShapeMaster_blendShapeGroups_LIST(JsonNode parsed)
|
||||
{
|
||||
var value = new glTF_VRM_BlendShapeGroup();
|
||||
|
||||
|
|
@ -659,7 +659,7 @@ public static glTF_VRM_BlendShapeGroup Deserialize_vrm_blendShapeMaster_blendSha
|
|||
return value;
|
||||
}
|
||||
|
||||
public static List<VRM.glTF_VRM_BlendShapeBind> Deserialize_vrm_blendShapeMaster_blendShapeGroups__binds(ListTreeNode<JsonValue> parsed)
|
||||
public static List<VRM.glTF_VRM_BlendShapeBind> Deserialize_vrm_blendShapeMaster_blendShapeGroups__binds(JsonNode parsed)
|
||||
{
|
||||
var value = new List<glTF_VRM_BlendShapeBind>();
|
||||
foreach(var x in parsed.ArrayItems())
|
||||
|
|
@ -668,7 +668,7 @@ public static List<VRM.glTF_VRM_BlendShapeBind> Deserialize_vrm_blendShapeMaster
|
|||
}
|
||||
return value;
|
||||
}
|
||||
public static glTF_VRM_BlendShapeBind Deserialize_vrm_blendShapeMaster_blendShapeGroups__binds_LIST(ListTreeNode<JsonValue> parsed)
|
||||
public static glTF_VRM_BlendShapeBind Deserialize_vrm_blendShapeMaster_blendShapeGroups__binds_LIST(JsonNode parsed)
|
||||
{
|
||||
var value = new glTF_VRM_BlendShapeBind();
|
||||
|
||||
|
|
@ -695,7 +695,7 @@ public static glTF_VRM_BlendShapeBind Deserialize_vrm_blendShapeMaster_blendShap
|
|||
return value;
|
||||
}
|
||||
|
||||
public static List<VRM.glTF_VRM_MaterialValueBind> Deserialize_vrm_blendShapeMaster_blendShapeGroups__materialValues(ListTreeNode<JsonValue> parsed)
|
||||
public static List<VRM.glTF_VRM_MaterialValueBind> Deserialize_vrm_blendShapeMaster_blendShapeGroups__materialValues(JsonNode parsed)
|
||||
{
|
||||
var value = new List<glTF_VRM_MaterialValueBind>();
|
||||
foreach(var x in parsed.ArrayItems())
|
||||
|
|
@ -704,7 +704,7 @@ public static List<VRM.glTF_VRM_MaterialValueBind> Deserialize_vrm_blendShapeMas
|
|||
}
|
||||
return value;
|
||||
}
|
||||
public static glTF_VRM_MaterialValueBind Deserialize_vrm_blendShapeMaster_blendShapeGroups__materialValues_LIST(ListTreeNode<JsonValue> parsed)
|
||||
public static glTF_VRM_MaterialValueBind Deserialize_vrm_blendShapeMaster_blendShapeGroups__materialValues_LIST(JsonNode parsed)
|
||||
{
|
||||
var value = new glTF_VRM_MaterialValueBind();
|
||||
|
||||
|
|
@ -731,7 +731,7 @@ public static glTF_VRM_MaterialValueBind Deserialize_vrm_blendShapeMaster_blendS
|
|||
return value;
|
||||
}
|
||||
|
||||
public static Single[] Deserialize_vrm_blendShapeMaster_blendShapeGroups__materialValues__targetValue(ListTreeNode<JsonValue> parsed)
|
||||
public static Single[] Deserialize_vrm_blendShapeMaster_blendShapeGroups__materialValues__targetValue(JsonNode parsed)
|
||||
{
|
||||
var value = new Single[parsed.GetArrayCount()];
|
||||
int i=0;
|
||||
|
|
@ -742,7 +742,7 @@ public static Single[] Deserialize_vrm_blendShapeMaster_blendShapeGroups__materi
|
|||
return value;
|
||||
}
|
||||
|
||||
public static glTF_VRM_SecondaryAnimation Deserialize_vrm_secondaryAnimation(ListTreeNode<JsonValue> parsed)
|
||||
public static glTF_VRM_SecondaryAnimation Deserialize_vrm_secondaryAnimation(JsonNode parsed)
|
||||
{
|
||||
var value = new glTF_VRM_SecondaryAnimation();
|
||||
|
||||
|
|
@ -764,7 +764,7 @@ public static glTF_VRM_SecondaryAnimation Deserialize_vrm_secondaryAnimation(Lis
|
|||
return value;
|
||||
}
|
||||
|
||||
public static List<VRM.glTF_VRM_SecondaryAnimationGroup> Deserialize_vrm_secondaryAnimation_boneGroups(ListTreeNode<JsonValue> parsed)
|
||||
public static List<VRM.glTF_VRM_SecondaryAnimationGroup> Deserialize_vrm_secondaryAnimation_boneGroups(JsonNode parsed)
|
||||
{
|
||||
var value = new List<glTF_VRM_SecondaryAnimationGroup>();
|
||||
foreach(var x in parsed.ArrayItems())
|
||||
|
|
@ -773,7 +773,7 @@ public static List<VRM.glTF_VRM_SecondaryAnimationGroup> Deserialize_vrm_seconda
|
|||
}
|
||||
return value;
|
||||
}
|
||||
public static glTF_VRM_SecondaryAnimationGroup Deserialize_vrm_secondaryAnimation_boneGroups_LIST(ListTreeNode<JsonValue> parsed)
|
||||
public static glTF_VRM_SecondaryAnimationGroup Deserialize_vrm_secondaryAnimation_boneGroups_LIST(JsonNode parsed)
|
||||
{
|
||||
var value = new glTF_VRM_SecondaryAnimationGroup();
|
||||
|
||||
|
|
@ -830,7 +830,7 @@ public static glTF_VRM_SecondaryAnimationGroup Deserialize_vrm_secondaryAnimatio
|
|||
return value;
|
||||
}
|
||||
|
||||
public static Vector3 Deserialize_vrm_secondaryAnimation_boneGroups__gravityDir(ListTreeNode<JsonValue> parsed)
|
||||
public static Vector3 Deserialize_vrm_secondaryAnimation_boneGroups__gravityDir(JsonNode parsed)
|
||||
{
|
||||
var value = new Vector3();
|
||||
|
||||
|
|
@ -857,7 +857,7 @@ public static Vector3 Deserialize_vrm_secondaryAnimation_boneGroups__gravityDir(
|
|||
return value;
|
||||
}
|
||||
|
||||
public static Int32[] Deserialize_vrm_secondaryAnimation_boneGroups__bones(ListTreeNode<JsonValue> parsed)
|
||||
public static Int32[] Deserialize_vrm_secondaryAnimation_boneGroups__bones(JsonNode parsed)
|
||||
{
|
||||
var value = new Int32[parsed.GetArrayCount()];
|
||||
int i=0;
|
||||
|
|
@ -868,7 +868,7 @@ public static Int32[] Deserialize_vrm_secondaryAnimation_boneGroups__bones(ListT
|
|||
return value;
|
||||
}
|
||||
|
||||
public static Int32[] Deserialize_vrm_secondaryAnimation_boneGroups__colliderGroups(ListTreeNode<JsonValue> parsed)
|
||||
public static Int32[] Deserialize_vrm_secondaryAnimation_boneGroups__colliderGroups(JsonNode parsed)
|
||||
{
|
||||
var value = new Int32[parsed.GetArrayCount()];
|
||||
int i=0;
|
||||
|
|
@ -879,7 +879,7 @@ public static Int32[] Deserialize_vrm_secondaryAnimation_boneGroups__colliderGro
|
|||
return value;
|
||||
}
|
||||
|
||||
public static List<VRM.glTF_VRM_SecondaryAnimationColliderGroup> Deserialize_vrm_secondaryAnimation_colliderGroups(ListTreeNode<JsonValue> parsed)
|
||||
public static List<VRM.glTF_VRM_SecondaryAnimationColliderGroup> Deserialize_vrm_secondaryAnimation_colliderGroups(JsonNode parsed)
|
||||
{
|
||||
var value = new List<glTF_VRM_SecondaryAnimationColliderGroup>();
|
||||
foreach(var x in parsed.ArrayItems())
|
||||
|
|
@ -888,7 +888,7 @@ public static List<VRM.glTF_VRM_SecondaryAnimationColliderGroup> Deserialize_vrm
|
|||
}
|
||||
return value;
|
||||
}
|
||||
public static glTF_VRM_SecondaryAnimationColliderGroup Deserialize_vrm_secondaryAnimation_colliderGroups_LIST(ListTreeNode<JsonValue> parsed)
|
||||
public static glTF_VRM_SecondaryAnimationColliderGroup Deserialize_vrm_secondaryAnimation_colliderGroups_LIST(JsonNode parsed)
|
||||
{
|
||||
var value = new glTF_VRM_SecondaryAnimationColliderGroup();
|
||||
|
||||
|
|
@ -910,7 +910,7 @@ public static glTF_VRM_SecondaryAnimationColliderGroup Deserialize_vrm_secondary
|
|||
return value;
|
||||
}
|
||||
|
||||
public static List<VRM.glTF_VRM_SecondaryAnimationCollider> Deserialize_vrm_secondaryAnimation_colliderGroups__colliders(ListTreeNode<JsonValue> parsed)
|
||||
public static List<VRM.glTF_VRM_SecondaryAnimationCollider> Deserialize_vrm_secondaryAnimation_colliderGroups__colliders(JsonNode parsed)
|
||||
{
|
||||
var value = new List<glTF_VRM_SecondaryAnimationCollider>();
|
||||
foreach(var x in parsed.ArrayItems())
|
||||
|
|
@ -919,7 +919,7 @@ public static List<VRM.glTF_VRM_SecondaryAnimationCollider> Deserialize_vrm_seco
|
|||
}
|
||||
return value;
|
||||
}
|
||||
public static glTF_VRM_SecondaryAnimationCollider Deserialize_vrm_secondaryAnimation_colliderGroups__colliders_LIST(ListTreeNode<JsonValue> parsed)
|
||||
public static glTF_VRM_SecondaryAnimationCollider Deserialize_vrm_secondaryAnimation_colliderGroups__colliders_LIST(JsonNode parsed)
|
||||
{
|
||||
var value = new glTF_VRM_SecondaryAnimationCollider();
|
||||
|
||||
|
|
@ -941,7 +941,7 @@ public static glTF_VRM_SecondaryAnimationCollider Deserialize_vrm_secondaryAnima
|
|||
return value;
|
||||
}
|
||||
|
||||
public static Vector3 Deserialize_vrm_secondaryAnimation_colliderGroups__colliders__offset(ListTreeNode<JsonValue> parsed)
|
||||
public static Vector3 Deserialize_vrm_secondaryAnimation_colliderGroups__colliders__offset(JsonNode parsed)
|
||||
{
|
||||
var value = new Vector3();
|
||||
|
||||
|
|
@ -968,7 +968,7 @@ public static Vector3 Deserialize_vrm_secondaryAnimation_colliderGroups__collide
|
|||
return value;
|
||||
}
|
||||
|
||||
public static List<VRM.glTF_VRM_Material> Deserialize_vrm_materialProperties(ListTreeNode<JsonValue> parsed)
|
||||
public static List<VRM.glTF_VRM_Material> Deserialize_vrm_materialProperties(JsonNode parsed)
|
||||
{
|
||||
var value = new List<glTF_VRM_Material>();
|
||||
foreach(var x in parsed.ArrayItems())
|
||||
|
|
@ -977,7 +977,7 @@ public static List<VRM.glTF_VRM_Material> Deserialize_vrm_materialProperties(Lis
|
|||
}
|
||||
return value;
|
||||
}
|
||||
public static glTF_VRM_Material Deserialize_vrm_materialProperties_LIST(ListTreeNode<JsonValue> parsed)
|
||||
public static glTF_VRM_Material Deserialize_vrm_materialProperties_LIST(JsonNode parsed)
|
||||
{
|
||||
var value = new glTF_VRM_Material();
|
||||
|
||||
|
|
@ -1030,7 +1030,7 @@ public static glTF_VRM_Material Deserialize_vrm_materialProperties_LIST(ListTree
|
|||
}
|
||||
|
||||
|
||||
public static Dictionary<String, Single> Deserialize_vrm_materialProperties__floatProperties(ListTreeNode<JsonValue> parsed)
|
||||
public static Dictionary<String, Single> Deserialize_vrm_materialProperties__floatProperties(JsonNode parsed)
|
||||
{
|
||||
var value = new Dictionary<string, Single>();
|
||||
foreach(var kv in parsed.ObjectItems())
|
||||
|
|
@ -1041,7 +1041,7 @@ public static Dictionary<String, Single> Deserialize_vrm_materialProperties__flo
|
|||
}
|
||||
|
||||
|
||||
public static Dictionary<String, Single[]> Deserialize_vrm_materialProperties__vectorProperties(ListTreeNode<JsonValue> parsed)
|
||||
public static Dictionary<String, Single[]> Deserialize_vrm_materialProperties__vectorProperties(JsonNode parsed)
|
||||
{
|
||||
var value = new Dictionary<string, Single[]>();
|
||||
foreach(var kv in parsed.ObjectItems())
|
||||
|
|
@ -1051,7 +1051,7 @@ public static Dictionary<String, Single[]> Deserialize_vrm_materialProperties__v
|
|||
return value;
|
||||
}
|
||||
|
||||
public static Single[] Deserialize_vrm_materialProperties__vectorProperties_DICT(ListTreeNode<JsonValue> parsed)
|
||||
public static Single[] Deserialize_vrm_materialProperties__vectorProperties_DICT(JsonNode parsed)
|
||||
{
|
||||
var value = new Single[parsed.GetArrayCount()];
|
||||
int i=0;
|
||||
|
|
@ -1063,7 +1063,7 @@ public static Single[] Deserialize_vrm_materialProperties__vectorProperties_DICT
|
|||
}
|
||||
|
||||
|
||||
public static Dictionary<String, Int32> Deserialize_vrm_materialProperties__textureProperties(ListTreeNode<JsonValue> parsed)
|
||||
public static Dictionary<String, Int32> Deserialize_vrm_materialProperties__textureProperties(JsonNode parsed)
|
||||
{
|
||||
var value = new Dictionary<string, Int32>();
|
||||
foreach(var kv in parsed.ObjectItems())
|
||||
|
|
@ -1074,7 +1074,7 @@ public static Dictionary<String, Int32> Deserialize_vrm_materialProperties__text
|
|||
}
|
||||
|
||||
|
||||
public static Dictionary<String, Boolean> Deserialize_vrm_materialProperties__keywordMap(ListTreeNode<JsonValue> parsed)
|
||||
public static Dictionary<String, Boolean> Deserialize_vrm_materialProperties__keywordMap(JsonNode parsed)
|
||||
{
|
||||
var value = new Dictionary<string, Boolean>();
|
||||
foreach(var kv in parsed.ObjectItems())
|
||||
|
|
@ -1085,7 +1085,7 @@ public static Dictionary<String, Boolean> Deserialize_vrm_materialProperties__ke
|
|||
}
|
||||
|
||||
|
||||
public static Dictionary<String, String> Deserialize_vrm_materialProperties__tagMap(ListTreeNode<JsonValue> parsed)
|
||||
public static Dictionary<String, String> Deserialize_vrm_materialProperties__tagMap(JsonNode parsed)
|
||||
{
|
||||
var value = new Dictionary<string, String>();
|
||||
foreach(var kv in parsed.ObjectItems())
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ public static bool TryGet(UniGLTF.glTFExtension src, out VRMC_constraints extens
|
|||
}
|
||||
|
||||
|
||||
public static VRMC_constraints Deserialize(ListTreeNode<JsonValue> parsed)
|
||||
public static VRMC_constraints Deserialize(JsonNode parsed)
|
||||
{
|
||||
var value = new VRMC_constraints();
|
||||
|
||||
|
|
@ -65,7 +65,7 @@ public static VRMC_constraints Deserialize(ListTreeNode<JsonValue> parsed)
|
|||
return value;
|
||||
}
|
||||
|
||||
public static PositionConstraint Deserialize_Position(ListTreeNode<JsonValue> parsed)
|
||||
public static PositionConstraint Deserialize_Position(JsonNode parsed)
|
||||
{
|
||||
var value = new PositionConstraint();
|
||||
|
||||
|
|
@ -117,7 +117,7 @@ public static PositionConstraint Deserialize_Position(ListTreeNode<JsonValue> pa
|
|||
return value;
|
||||
}
|
||||
|
||||
public static bool[] Deserialize_FreezeAxes(ListTreeNode<JsonValue> parsed)
|
||||
public static bool[] Deserialize_FreezeAxes(JsonNode parsed)
|
||||
{
|
||||
var value = new bool[parsed.GetArrayCount()];
|
||||
int i=0;
|
||||
|
|
@ -128,7 +128,7 @@ public static bool[] Deserialize_FreezeAxes(ListTreeNode<JsonValue> parsed)
|
|||
return value;
|
||||
}
|
||||
|
||||
public static RotationConstraint Deserialize_Rotation(ListTreeNode<JsonValue> parsed)
|
||||
public static RotationConstraint Deserialize_Rotation(JsonNode parsed)
|
||||
{
|
||||
var value = new RotationConstraint();
|
||||
|
||||
|
|
@ -180,7 +180,7 @@ public static RotationConstraint Deserialize_Rotation(ListTreeNode<JsonValue> pa
|
|||
return value;
|
||||
}
|
||||
|
||||
public static AimConstraint Deserialize_Aim(ListTreeNode<JsonValue> parsed)
|
||||
public static AimConstraint Deserialize_Aim(JsonNode parsed)
|
||||
{
|
||||
var value = new AimConstraint();
|
||||
|
||||
|
|
@ -242,7 +242,7 @@ public static AimConstraint Deserialize_Aim(ListTreeNode<JsonValue> parsed)
|
|||
return value;
|
||||
}
|
||||
|
||||
public static float[] Deserialize_AimVector(ListTreeNode<JsonValue> parsed)
|
||||
public static float[] Deserialize_AimVector(JsonNode parsed)
|
||||
{
|
||||
var value = new float[parsed.GetArrayCount()];
|
||||
int i=0;
|
||||
|
|
@ -253,7 +253,7 @@ public static float[] Deserialize_AimVector(ListTreeNode<JsonValue> parsed)
|
|||
return value;
|
||||
}
|
||||
|
||||
public static float[] Deserialize_UpVector(ListTreeNode<JsonValue> parsed)
|
||||
public static float[] Deserialize_UpVector(JsonNode parsed)
|
||||
{
|
||||
var value = new float[parsed.GetArrayCount()];
|
||||
int i=0;
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ public static bool TryGet(UniGLTF.glTFExtension src, out VRMC_materials_mtoon ex
|
|||
}
|
||||
|
||||
|
||||
public static VRMC_materials_mtoon Deserialize(ListTreeNode<JsonValue> parsed)
|
||||
public static VRMC_materials_mtoon Deserialize(JsonNode parsed)
|
||||
{
|
||||
var value = new VRMC_materials_mtoon();
|
||||
|
||||
|
|
@ -170,7 +170,7 @@ public static VRMC_materials_mtoon Deserialize(ListTreeNode<JsonValue> parsed)
|
|||
return value;
|
||||
}
|
||||
|
||||
public static float[] Deserialize_ShadeFactor(ListTreeNode<JsonValue> parsed)
|
||||
public static float[] Deserialize_ShadeFactor(JsonNode parsed)
|
||||
{
|
||||
var value = new float[parsed.GetArrayCount()];
|
||||
int i=0;
|
||||
|
|
@ -181,7 +181,7 @@ public static float[] Deserialize_ShadeFactor(ListTreeNode<JsonValue> parsed)
|
|||
return value;
|
||||
}
|
||||
|
||||
public static float[] Deserialize_RimFactor(ListTreeNode<JsonValue> parsed)
|
||||
public static float[] Deserialize_RimFactor(JsonNode parsed)
|
||||
{
|
||||
var value = new float[parsed.GetArrayCount()];
|
||||
int i=0;
|
||||
|
|
@ -192,7 +192,7 @@ public static float[] Deserialize_RimFactor(ListTreeNode<JsonValue> parsed)
|
|||
return value;
|
||||
}
|
||||
|
||||
public static float[] Deserialize_OutlineFactor(ListTreeNode<JsonValue> parsed)
|
||||
public static float[] Deserialize_OutlineFactor(JsonNode parsed)
|
||||
{
|
||||
var value = new float[parsed.GetArrayCount()];
|
||||
int i=0;
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ public static bool TryGet(UniGLTF.glTFExtension src, out VRMC_node_collider exte
|
|||
}
|
||||
|
||||
|
||||
public static VRMC_node_collider Deserialize(ListTreeNode<JsonValue> parsed)
|
||||
public static VRMC_node_collider Deserialize(JsonNode parsed)
|
||||
{
|
||||
var value = new VRMC_node_collider();
|
||||
|
||||
|
|
@ -55,7 +55,7 @@ public static VRMC_node_collider Deserialize(ListTreeNode<JsonValue> parsed)
|
|||
return value;
|
||||
}
|
||||
|
||||
public static List<ColliderShape> Deserialize_Shapes(ListTreeNode<JsonValue> parsed)
|
||||
public static List<ColliderShape> Deserialize_Shapes(JsonNode parsed)
|
||||
{
|
||||
var value = new List<ColliderShape>();
|
||||
foreach(var x in parsed.ArrayItems())
|
||||
|
|
@ -65,7 +65,7 @@ public static List<ColliderShape> Deserialize_Shapes(ListTreeNode<JsonValue> par
|
|||
return value;
|
||||
}
|
||||
|
||||
public static ColliderShape Deserialize_Shapes_ITEM(ListTreeNode<JsonValue> parsed)
|
||||
public static ColliderShape Deserialize_Shapes_ITEM(JsonNode parsed)
|
||||
{
|
||||
var value = new ColliderShape();
|
||||
|
||||
|
|
@ -97,7 +97,7 @@ public static ColliderShape Deserialize_Shapes_ITEM(ListTreeNode<JsonValue> pars
|
|||
return value;
|
||||
}
|
||||
|
||||
public static ColliderShapeSphere Deserialize_Sphere(ListTreeNode<JsonValue> parsed)
|
||||
public static ColliderShapeSphere Deserialize_Sphere(JsonNode parsed)
|
||||
{
|
||||
var value = new ColliderShapeSphere();
|
||||
|
||||
|
|
@ -119,7 +119,7 @@ public static ColliderShapeSphere Deserialize_Sphere(ListTreeNode<JsonValue> par
|
|||
return value;
|
||||
}
|
||||
|
||||
public static float[] Deserialize_Offset(ListTreeNode<JsonValue> parsed)
|
||||
public static float[] Deserialize_Offset(JsonNode parsed)
|
||||
{
|
||||
var value = new float[parsed.GetArrayCount()];
|
||||
int i=0;
|
||||
|
|
@ -130,7 +130,7 @@ public static float[] Deserialize_Offset(ListTreeNode<JsonValue> parsed)
|
|||
return value;
|
||||
}
|
||||
|
||||
public static ColliderShapeCapsule Deserialize_Capsule(ListTreeNode<JsonValue> parsed)
|
||||
public static ColliderShapeCapsule Deserialize_Capsule(JsonNode parsed)
|
||||
{
|
||||
var value = new ColliderShapeCapsule();
|
||||
|
||||
|
|
@ -157,7 +157,7 @@ public static ColliderShapeCapsule Deserialize_Capsule(ListTreeNode<JsonValue> p
|
|||
return value;
|
||||
}
|
||||
|
||||
public static float[] Deserialize_Tail(ListTreeNode<JsonValue> parsed)
|
||||
public static float[] Deserialize_Tail(JsonNode parsed)
|
||||
{
|
||||
var value = new float[parsed.GetArrayCount()];
|
||||
int i=0;
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ public static bool TryGet(UniGLTF.glTFExtension src, out VRMC_springBone extensi
|
|||
}
|
||||
|
||||
|
||||
public static VRMC_springBone Deserialize(ListTreeNode<JsonValue> parsed)
|
||||
public static VRMC_springBone Deserialize(JsonNode parsed)
|
||||
{
|
||||
var value = new VRMC_springBone();
|
||||
|
||||
|
|
@ -55,7 +55,7 @@ public static VRMC_springBone Deserialize(ListTreeNode<JsonValue> parsed)
|
|||
return value;
|
||||
}
|
||||
|
||||
public static List<Spring> Deserialize_Springs(ListTreeNode<JsonValue> parsed)
|
||||
public static List<Spring> Deserialize_Springs(JsonNode parsed)
|
||||
{
|
||||
var value = new List<Spring>();
|
||||
foreach(var x in parsed.ArrayItems())
|
||||
|
|
@ -65,7 +65,7 @@ public static List<Spring> Deserialize_Springs(ListTreeNode<JsonValue> parsed)
|
|||
return value;
|
||||
}
|
||||
|
||||
public static Spring Deserialize_Springs_ITEM(ListTreeNode<JsonValue> parsed)
|
||||
public static Spring Deserialize_Springs_ITEM(JsonNode parsed)
|
||||
{
|
||||
var value = new Spring();
|
||||
|
||||
|
|
@ -92,7 +92,7 @@ public static Spring Deserialize_Springs_ITEM(ListTreeNode<JsonValue> parsed)
|
|||
return value;
|
||||
}
|
||||
|
||||
public static List<SpringBoneJoint> Deserialize_Joints(ListTreeNode<JsonValue> parsed)
|
||||
public static List<SpringBoneJoint> Deserialize_Joints(JsonNode parsed)
|
||||
{
|
||||
var value = new List<SpringBoneJoint>();
|
||||
foreach(var x in parsed.ArrayItems())
|
||||
|
|
@ -102,7 +102,7 @@ public static List<SpringBoneJoint> Deserialize_Joints(ListTreeNode<JsonValue> p
|
|||
return value;
|
||||
}
|
||||
|
||||
public static SpringBoneJoint Deserialize_Joints_ITEM(ListTreeNode<JsonValue> parsed)
|
||||
public static SpringBoneJoint Deserialize_Joints_ITEM(JsonNode parsed)
|
||||
{
|
||||
var value = new SpringBoneJoint();
|
||||
|
||||
|
|
@ -159,7 +159,7 @@ public static SpringBoneJoint Deserialize_Joints_ITEM(ListTreeNode<JsonValue> pa
|
|||
return value;
|
||||
}
|
||||
|
||||
public static float[] Deserialize_GravityDir(ListTreeNode<JsonValue> parsed)
|
||||
public static float[] Deserialize_GravityDir(JsonNode parsed)
|
||||
{
|
||||
var value = new float[parsed.GetArrayCount()];
|
||||
int i=0;
|
||||
|
|
@ -170,7 +170,7 @@ public static float[] Deserialize_GravityDir(ListTreeNode<JsonValue> parsed)
|
|||
return value;
|
||||
}
|
||||
|
||||
public static int[] Deserialize_Colliders(ListTreeNode<JsonValue> parsed)
|
||||
public static int[] Deserialize_Colliders(JsonNode parsed)
|
||||
{
|
||||
var value = new int[parsed.GetArrayCount()];
|
||||
int i=0;
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ public static bool TryGet(UniGLTF.glTFExtension src, out VRMC_vrm extension)
|
|||
}
|
||||
|
||||
|
||||
public static VRMC_vrm Deserialize(ListTreeNode<JsonValue> parsed)
|
||||
public static VRMC_vrm Deserialize(JsonNode parsed)
|
||||
{
|
||||
var value = new VRMC_vrm();
|
||||
|
||||
|
|
@ -70,7 +70,7 @@ public static VRMC_vrm Deserialize(ListTreeNode<JsonValue> parsed)
|
|||
return value;
|
||||
}
|
||||
|
||||
public static Meta Deserialize_Meta(ListTreeNode<JsonValue> parsed)
|
||||
public static Meta Deserialize_Meta(JsonNode parsed)
|
||||
{
|
||||
var value = new Meta();
|
||||
|
||||
|
|
@ -167,7 +167,7 @@ public static Meta Deserialize_Meta(ListTreeNode<JsonValue> parsed)
|
|||
return value;
|
||||
}
|
||||
|
||||
public static List<string> Deserialize_Authors(ListTreeNode<JsonValue> parsed)
|
||||
public static List<string> Deserialize_Authors(JsonNode parsed)
|
||||
{
|
||||
var value = new List<string>();
|
||||
foreach(var x in parsed.ArrayItems())
|
||||
|
|
@ -177,7 +177,7 @@ public static List<string> Deserialize_Authors(ListTreeNode<JsonValue> parsed)
|
|||
return value;
|
||||
}
|
||||
|
||||
public static List<string> Deserialize_References(ListTreeNode<JsonValue> parsed)
|
||||
public static List<string> Deserialize_References(JsonNode parsed)
|
||||
{
|
||||
var value = new List<string>();
|
||||
foreach(var x in parsed.ArrayItems())
|
||||
|
|
@ -187,7 +187,7 @@ public static List<string> Deserialize_References(ListTreeNode<JsonValue> parsed
|
|||
return value;
|
||||
}
|
||||
|
||||
public static Humanoid Deserialize_Humanoid(ListTreeNode<JsonValue> parsed)
|
||||
public static Humanoid Deserialize_Humanoid(JsonNode parsed)
|
||||
{
|
||||
var value = new Humanoid();
|
||||
|
||||
|
|
@ -204,7 +204,7 @@ public static Humanoid Deserialize_Humanoid(ListTreeNode<JsonValue> parsed)
|
|||
return value;
|
||||
}
|
||||
|
||||
public static HumanBones Deserialize_HumanBones(ListTreeNode<JsonValue> parsed)
|
||||
public static HumanBones Deserialize_HumanBones(JsonNode parsed)
|
||||
{
|
||||
var value = new HumanBones();
|
||||
|
||||
|
|
@ -491,7 +491,7 @@ public static HumanBones Deserialize_HumanBones(ListTreeNode<JsonValue> parsed)
|
|||
return value;
|
||||
}
|
||||
|
||||
public static HumanBone Deserialize_Hips(ListTreeNode<JsonValue> parsed)
|
||||
public static HumanBone Deserialize_Hips(JsonNode parsed)
|
||||
{
|
||||
var value = new HumanBone();
|
||||
|
||||
|
|
@ -508,7 +508,7 @@ public static HumanBone Deserialize_Hips(ListTreeNode<JsonValue> parsed)
|
|||
return value;
|
||||
}
|
||||
|
||||
public static HumanBone Deserialize_Spine(ListTreeNode<JsonValue> parsed)
|
||||
public static HumanBone Deserialize_Spine(JsonNode parsed)
|
||||
{
|
||||
var value = new HumanBone();
|
||||
|
||||
|
|
@ -525,7 +525,7 @@ public static HumanBone Deserialize_Spine(ListTreeNode<JsonValue> parsed)
|
|||
return value;
|
||||
}
|
||||
|
||||
public static HumanBone Deserialize_Chest(ListTreeNode<JsonValue> parsed)
|
||||
public static HumanBone Deserialize_Chest(JsonNode parsed)
|
||||
{
|
||||
var value = new HumanBone();
|
||||
|
||||
|
|
@ -542,7 +542,7 @@ public static HumanBone Deserialize_Chest(ListTreeNode<JsonValue> parsed)
|
|||
return value;
|
||||
}
|
||||
|
||||
public static HumanBone Deserialize_UpperChest(ListTreeNode<JsonValue> parsed)
|
||||
public static HumanBone Deserialize_UpperChest(JsonNode parsed)
|
||||
{
|
||||
var value = new HumanBone();
|
||||
|
||||
|
|
@ -559,7 +559,7 @@ public static HumanBone Deserialize_UpperChest(ListTreeNode<JsonValue> parsed)
|
|||
return value;
|
||||
}
|
||||
|
||||
public static HumanBone Deserialize_Neck(ListTreeNode<JsonValue> parsed)
|
||||
public static HumanBone Deserialize_Neck(JsonNode parsed)
|
||||
{
|
||||
var value = new HumanBone();
|
||||
|
||||
|
|
@ -576,7 +576,7 @@ public static HumanBone Deserialize_Neck(ListTreeNode<JsonValue> parsed)
|
|||
return value;
|
||||
}
|
||||
|
||||
public static HumanBone Deserialize_Head(ListTreeNode<JsonValue> parsed)
|
||||
public static HumanBone Deserialize_Head(JsonNode parsed)
|
||||
{
|
||||
var value = new HumanBone();
|
||||
|
||||
|
|
@ -593,7 +593,7 @@ public static HumanBone Deserialize_Head(ListTreeNode<JsonValue> parsed)
|
|||
return value;
|
||||
}
|
||||
|
||||
public static HumanBone Deserialize_LeftEye(ListTreeNode<JsonValue> parsed)
|
||||
public static HumanBone Deserialize_LeftEye(JsonNode parsed)
|
||||
{
|
||||
var value = new HumanBone();
|
||||
|
||||
|
|
@ -610,7 +610,7 @@ public static HumanBone Deserialize_LeftEye(ListTreeNode<JsonValue> parsed)
|
|||
return value;
|
||||
}
|
||||
|
||||
public static HumanBone Deserialize_RightEye(ListTreeNode<JsonValue> parsed)
|
||||
public static HumanBone Deserialize_RightEye(JsonNode parsed)
|
||||
{
|
||||
var value = new HumanBone();
|
||||
|
||||
|
|
@ -627,7 +627,7 @@ public static HumanBone Deserialize_RightEye(ListTreeNode<JsonValue> parsed)
|
|||
return value;
|
||||
}
|
||||
|
||||
public static HumanBone Deserialize_Jaw(ListTreeNode<JsonValue> parsed)
|
||||
public static HumanBone Deserialize_Jaw(JsonNode parsed)
|
||||
{
|
||||
var value = new HumanBone();
|
||||
|
||||
|
|
@ -644,7 +644,7 @@ public static HumanBone Deserialize_Jaw(ListTreeNode<JsonValue> parsed)
|
|||
return value;
|
||||
}
|
||||
|
||||
public static HumanBone Deserialize_LeftUpperLeg(ListTreeNode<JsonValue> parsed)
|
||||
public static HumanBone Deserialize_LeftUpperLeg(JsonNode parsed)
|
||||
{
|
||||
var value = new HumanBone();
|
||||
|
||||
|
|
@ -661,7 +661,7 @@ public static HumanBone Deserialize_LeftUpperLeg(ListTreeNode<JsonValue> parsed)
|
|||
return value;
|
||||
}
|
||||
|
||||
public static HumanBone Deserialize_LeftLowerLeg(ListTreeNode<JsonValue> parsed)
|
||||
public static HumanBone Deserialize_LeftLowerLeg(JsonNode parsed)
|
||||
{
|
||||
var value = new HumanBone();
|
||||
|
||||
|
|
@ -678,7 +678,7 @@ public static HumanBone Deserialize_LeftLowerLeg(ListTreeNode<JsonValue> parsed)
|
|||
return value;
|
||||
}
|
||||
|
||||
public static HumanBone Deserialize_LeftFoot(ListTreeNode<JsonValue> parsed)
|
||||
public static HumanBone Deserialize_LeftFoot(JsonNode parsed)
|
||||
{
|
||||
var value = new HumanBone();
|
||||
|
||||
|
|
@ -695,7 +695,7 @@ public static HumanBone Deserialize_LeftFoot(ListTreeNode<JsonValue> parsed)
|
|||
return value;
|
||||
}
|
||||
|
||||
public static HumanBone Deserialize_LeftToes(ListTreeNode<JsonValue> parsed)
|
||||
public static HumanBone Deserialize_LeftToes(JsonNode parsed)
|
||||
{
|
||||
var value = new HumanBone();
|
||||
|
||||
|
|
@ -712,7 +712,7 @@ public static HumanBone Deserialize_LeftToes(ListTreeNode<JsonValue> parsed)
|
|||
return value;
|
||||
}
|
||||
|
||||
public static HumanBone Deserialize_RightUpperLeg(ListTreeNode<JsonValue> parsed)
|
||||
public static HumanBone Deserialize_RightUpperLeg(JsonNode parsed)
|
||||
{
|
||||
var value = new HumanBone();
|
||||
|
||||
|
|
@ -729,7 +729,7 @@ public static HumanBone Deserialize_RightUpperLeg(ListTreeNode<JsonValue> parsed
|
|||
return value;
|
||||
}
|
||||
|
||||
public static HumanBone Deserialize_RightLowerLeg(ListTreeNode<JsonValue> parsed)
|
||||
public static HumanBone Deserialize_RightLowerLeg(JsonNode parsed)
|
||||
{
|
||||
var value = new HumanBone();
|
||||
|
||||
|
|
@ -746,7 +746,7 @@ public static HumanBone Deserialize_RightLowerLeg(ListTreeNode<JsonValue> parsed
|
|||
return value;
|
||||
}
|
||||
|
||||
public static HumanBone Deserialize_RightFoot(ListTreeNode<JsonValue> parsed)
|
||||
public static HumanBone Deserialize_RightFoot(JsonNode parsed)
|
||||
{
|
||||
var value = new HumanBone();
|
||||
|
||||
|
|
@ -763,7 +763,7 @@ public static HumanBone Deserialize_RightFoot(ListTreeNode<JsonValue> parsed)
|
|||
return value;
|
||||
}
|
||||
|
||||
public static HumanBone Deserialize_RightToes(ListTreeNode<JsonValue> parsed)
|
||||
public static HumanBone Deserialize_RightToes(JsonNode parsed)
|
||||
{
|
||||
var value = new HumanBone();
|
||||
|
||||
|
|
@ -780,7 +780,7 @@ public static HumanBone Deserialize_RightToes(ListTreeNode<JsonValue> parsed)
|
|||
return value;
|
||||
}
|
||||
|
||||
public static HumanBone Deserialize_LeftShoulder(ListTreeNode<JsonValue> parsed)
|
||||
public static HumanBone Deserialize_LeftShoulder(JsonNode parsed)
|
||||
{
|
||||
var value = new HumanBone();
|
||||
|
||||
|
|
@ -797,7 +797,7 @@ public static HumanBone Deserialize_LeftShoulder(ListTreeNode<JsonValue> parsed)
|
|||
return value;
|
||||
}
|
||||
|
||||
public static HumanBone Deserialize_LeftUpperArm(ListTreeNode<JsonValue> parsed)
|
||||
public static HumanBone Deserialize_LeftUpperArm(JsonNode parsed)
|
||||
{
|
||||
var value = new HumanBone();
|
||||
|
||||
|
|
@ -814,7 +814,7 @@ public static HumanBone Deserialize_LeftUpperArm(ListTreeNode<JsonValue> parsed)
|
|||
return value;
|
||||
}
|
||||
|
||||
public static HumanBone Deserialize_LeftLowerArm(ListTreeNode<JsonValue> parsed)
|
||||
public static HumanBone Deserialize_LeftLowerArm(JsonNode parsed)
|
||||
{
|
||||
var value = new HumanBone();
|
||||
|
||||
|
|
@ -831,7 +831,7 @@ public static HumanBone Deserialize_LeftLowerArm(ListTreeNode<JsonValue> parsed)
|
|||
return value;
|
||||
}
|
||||
|
||||
public static HumanBone Deserialize_LeftHand(ListTreeNode<JsonValue> parsed)
|
||||
public static HumanBone Deserialize_LeftHand(JsonNode parsed)
|
||||
{
|
||||
var value = new HumanBone();
|
||||
|
||||
|
|
@ -848,7 +848,7 @@ public static HumanBone Deserialize_LeftHand(ListTreeNode<JsonValue> parsed)
|
|||
return value;
|
||||
}
|
||||
|
||||
public static HumanBone Deserialize_RightShoulder(ListTreeNode<JsonValue> parsed)
|
||||
public static HumanBone Deserialize_RightShoulder(JsonNode parsed)
|
||||
{
|
||||
var value = new HumanBone();
|
||||
|
||||
|
|
@ -865,7 +865,7 @@ public static HumanBone Deserialize_RightShoulder(ListTreeNode<JsonValue> parsed
|
|||
return value;
|
||||
}
|
||||
|
||||
public static HumanBone Deserialize_RightUpperArm(ListTreeNode<JsonValue> parsed)
|
||||
public static HumanBone Deserialize_RightUpperArm(JsonNode parsed)
|
||||
{
|
||||
var value = new HumanBone();
|
||||
|
||||
|
|
@ -882,7 +882,7 @@ public static HumanBone Deserialize_RightUpperArm(ListTreeNode<JsonValue> parsed
|
|||
return value;
|
||||
}
|
||||
|
||||
public static HumanBone Deserialize_RightLowerArm(ListTreeNode<JsonValue> parsed)
|
||||
public static HumanBone Deserialize_RightLowerArm(JsonNode parsed)
|
||||
{
|
||||
var value = new HumanBone();
|
||||
|
||||
|
|
@ -899,7 +899,7 @@ public static HumanBone Deserialize_RightLowerArm(ListTreeNode<JsonValue> parsed
|
|||
return value;
|
||||
}
|
||||
|
||||
public static HumanBone Deserialize_RightHand(ListTreeNode<JsonValue> parsed)
|
||||
public static HumanBone Deserialize_RightHand(JsonNode parsed)
|
||||
{
|
||||
var value = new HumanBone();
|
||||
|
||||
|
|
@ -916,7 +916,7 @@ public static HumanBone Deserialize_RightHand(ListTreeNode<JsonValue> parsed)
|
|||
return value;
|
||||
}
|
||||
|
||||
public static HumanBone Deserialize_LeftThumbProximal(ListTreeNode<JsonValue> parsed)
|
||||
public static HumanBone Deserialize_LeftThumbProximal(JsonNode parsed)
|
||||
{
|
||||
var value = new HumanBone();
|
||||
|
||||
|
|
@ -933,7 +933,7 @@ public static HumanBone Deserialize_LeftThumbProximal(ListTreeNode<JsonValue> pa
|
|||
return value;
|
||||
}
|
||||
|
||||
public static HumanBone Deserialize_LeftThumbIntermediate(ListTreeNode<JsonValue> parsed)
|
||||
public static HumanBone Deserialize_LeftThumbIntermediate(JsonNode parsed)
|
||||
{
|
||||
var value = new HumanBone();
|
||||
|
||||
|
|
@ -950,7 +950,7 @@ public static HumanBone Deserialize_LeftThumbIntermediate(ListTreeNode<JsonValue
|
|||
return value;
|
||||
}
|
||||
|
||||
public static HumanBone Deserialize_LeftThumbDistal(ListTreeNode<JsonValue> parsed)
|
||||
public static HumanBone Deserialize_LeftThumbDistal(JsonNode parsed)
|
||||
{
|
||||
var value = new HumanBone();
|
||||
|
||||
|
|
@ -967,7 +967,7 @@ public static HumanBone Deserialize_LeftThumbDistal(ListTreeNode<JsonValue> pars
|
|||
return value;
|
||||
}
|
||||
|
||||
public static HumanBone Deserialize_LeftIndexProximal(ListTreeNode<JsonValue> parsed)
|
||||
public static HumanBone Deserialize_LeftIndexProximal(JsonNode parsed)
|
||||
{
|
||||
var value = new HumanBone();
|
||||
|
||||
|
|
@ -984,7 +984,7 @@ public static HumanBone Deserialize_LeftIndexProximal(ListTreeNode<JsonValue> pa
|
|||
return value;
|
||||
}
|
||||
|
||||
public static HumanBone Deserialize_LeftIndexIntermediate(ListTreeNode<JsonValue> parsed)
|
||||
public static HumanBone Deserialize_LeftIndexIntermediate(JsonNode parsed)
|
||||
{
|
||||
var value = new HumanBone();
|
||||
|
||||
|
|
@ -1001,7 +1001,7 @@ public static HumanBone Deserialize_LeftIndexIntermediate(ListTreeNode<JsonValue
|
|||
return value;
|
||||
}
|
||||
|
||||
public static HumanBone Deserialize_LeftIndexDistal(ListTreeNode<JsonValue> parsed)
|
||||
public static HumanBone Deserialize_LeftIndexDistal(JsonNode parsed)
|
||||
{
|
||||
var value = new HumanBone();
|
||||
|
||||
|
|
@ -1018,7 +1018,7 @@ public static HumanBone Deserialize_LeftIndexDistal(ListTreeNode<JsonValue> pars
|
|||
return value;
|
||||
}
|
||||
|
||||
public static HumanBone Deserialize_LeftMiddleProximal(ListTreeNode<JsonValue> parsed)
|
||||
public static HumanBone Deserialize_LeftMiddleProximal(JsonNode parsed)
|
||||
{
|
||||
var value = new HumanBone();
|
||||
|
||||
|
|
@ -1035,7 +1035,7 @@ public static HumanBone Deserialize_LeftMiddleProximal(ListTreeNode<JsonValue> p
|
|||
return value;
|
||||
}
|
||||
|
||||
public static HumanBone Deserialize_LeftMiddleIntermediate(ListTreeNode<JsonValue> parsed)
|
||||
public static HumanBone Deserialize_LeftMiddleIntermediate(JsonNode parsed)
|
||||
{
|
||||
var value = new HumanBone();
|
||||
|
||||
|
|
@ -1052,7 +1052,7 @@ public static HumanBone Deserialize_LeftMiddleIntermediate(ListTreeNode<JsonValu
|
|||
return value;
|
||||
}
|
||||
|
||||
public static HumanBone Deserialize_LeftMiddleDistal(ListTreeNode<JsonValue> parsed)
|
||||
public static HumanBone Deserialize_LeftMiddleDistal(JsonNode parsed)
|
||||
{
|
||||
var value = new HumanBone();
|
||||
|
||||
|
|
@ -1069,7 +1069,7 @@ public static HumanBone Deserialize_LeftMiddleDistal(ListTreeNode<JsonValue> par
|
|||
return value;
|
||||
}
|
||||
|
||||
public static HumanBone Deserialize_LeftRingProximal(ListTreeNode<JsonValue> parsed)
|
||||
public static HumanBone Deserialize_LeftRingProximal(JsonNode parsed)
|
||||
{
|
||||
var value = new HumanBone();
|
||||
|
||||
|
|
@ -1086,7 +1086,7 @@ public static HumanBone Deserialize_LeftRingProximal(ListTreeNode<JsonValue> par
|
|||
return value;
|
||||
}
|
||||
|
||||
public static HumanBone Deserialize_LeftRingIntermediate(ListTreeNode<JsonValue> parsed)
|
||||
public static HumanBone Deserialize_LeftRingIntermediate(JsonNode parsed)
|
||||
{
|
||||
var value = new HumanBone();
|
||||
|
||||
|
|
@ -1103,7 +1103,7 @@ public static HumanBone Deserialize_LeftRingIntermediate(ListTreeNode<JsonValue>
|
|||
return value;
|
||||
}
|
||||
|
||||
public static HumanBone Deserialize_LeftRingDistal(ListTreeNode<JsonValue> parsed)
|
||||
public static HumanBone Deserialize_LeftRingDistal(JsonNode parsed)
|
||||
{
|
||||
var value = new HumanBone();
|
||||
|
||||
|
|
@ -1120,7 +1120,7 @@ public static HumanBone Deserialize_LeftRingDistal(ListTreeNode<JsonValue> parse
|
|||
return value;
|
||||
}
|
||||
|
||||
public static HumanBone Deserialize_LeftLittleProximal(ListTreeNode<JsonValue> parsed)
|
||||
public static HumanBone Deserialize_LeftLittleProximal(JsonNode parsed)
|
||||
{
|
||||
var value = new HumanBone();
|
||||
|
||||
|
|
@ -1137,7 +1137,7 @@ public static HumanBone Deserialize_LeftLittleProximal(ListTreeNode<JsonValue> p
|
|||
return value;
|
||||
}
|
||||
|
||||
public static HumanBone Deserialize_LeftLittleIntermediate(ListTreeNode<JsonValue> parsed)
|
||||
public static HumanBone Deserialize_LeftLittleIntermediate(JsonNode parsed)
|
||||
{
|
||||
var value = new HumanBone();
|
||||
|
||||
|
|
@ -1154,7 +1154,7 @@ public static HumanBone Deserialize_LeftLittleIntermediate(ListTreeNode<JsonValu
|
|||
return value;
|
||||
}
|
||||
|
||||
public static HumanBone Deserialize_LeftLittleDistal(ListTreeNode<JsonValue> parsed)
|
||||
public static HumanBone Deserialize_LeftLittleDistal(JsonNode parsed)
|
||||
{
|
||||
var value = new HumanBone();
|
||||
|
||||
|
|
@ -1171,7 +1171,7 @@ public static HumanBone Deserialize_LeftLittleDistal(ListTreeNode<JsonValue> par
|
|||
return value;
|
||||
}
|
||||
|
||||
public static HumanBone Deserialize_RightThumbProximal(ListTreeNode<JsonValue> parsed)
|
||||
public static HumanBone Deserialize_RightThumbProximal(JsonNode parsed)
|
||||
{
|
||||
var value = new HumanBone();
|
||||
|
||||
|
|
@ -1188,7 +1188,7 @@ public static HumanBone Deserialize_RightThumbProximal(ListTreeNode<JsonValue> p
|
|||
return value;
|
||||
}
|
||||
|
||||
public static HumanBone Deserialize_RightThumbIntermediate(ListTreeNode<JsonValue> parsed)
|
||||
public static HumanBone Deserialize_RightThumbIntermediate(JsonNode parsed)
|
||||
{
|
||||
var value = new HumanBone();
|
||||
|
||||
|
|
@ -1205,7 +1205,7 @@ public static HumanBone Deserialize_RightThumbIntermediate(ListTreeNode<JsonValu
|
|||
return value;
|
||||
}
|
||||
|
||||
public static HumanBone Deserialize_RightThumbDistal(ListTreeNode<JsonValue> parsed)
|
||||
public static HumanBone Deserialize_RightThumbDistal(JsonNode parsed)
|
||||
{
|
||||
var value = new HumanBone();
|
||||
|
||||
|
|
@ -1222,7 +1222,7 @@ public static HumanBone Deserialize_RightThumbDistal(ListTreeNode<JsonValue> par
|
|||
return value;
|
||||
}
|
||||
|
||||
public static HumanBone Deserialize_RightIndexProximal(ListTreeNode<JsonValue> parsed)
|
||||
public static HumanBone Deserialize_RightIndexProximal(JsonNode parsed)
|
||||
{
|
||||
var value = new HumanBone();
|
||||
|
||||
|
|
@ -1239,7 +1239,7 @@ public static HumanBone Deserialize_RightIndexProximal(ListTreeNode<JsonValue> p
|
|||
return value;
|
||||
}
|
||||
|
||||
public static HumanBone Deserialize_RightIndexIntermediate(ListTreeNode<JsonValue> parsed)
|
||||
public static HumanBone Deserialize_RightIndexIntermediate(JsonNode parsed)
|
||||
{
|
||||
var value = new HumanBone();
|
||||
|
||||
|
|
@ -1256,7 +1256,7 @@ public static HumanBone Deserialize_RightIndexIntermediate(ListTreeNode<JsonValu
|
|||
return value;
|
||||
}
|
||||
|
||||
public static HumanBone Deserialize_RightIndexDistal(ListTreeNode<JsonValue> parsed)
|
||||
public static HumanBone Deserialize_RightIndexDistal(JsonNode parsed)
|
||||
{
|
||||
var value = new HumanBone();
|
||||
|
||||
|
|
@ -1273,7 +1273,7 @@ public static HumanBone Deserialize_RightIndexDistal(ListTreeNode<JsonValue> par
|
|||
return value;
|
||||
}
|
||||
|
||||
public static HumanBone Deserialize_RightMiddleProximal(ListTreeNode<JsonValue> parsed)
|
||||
public static HumanBone Deserialize_RightMiddleProximal(JsonNode parsed)
|
||||
{
|
||||
var value = new HumanBone();
|
||||
|
||||
|
|
@ -1290,7 +1290,7 @@ public static HumanBone Deserialize_RightMiddleProximal(ListTreeNode<JsonValue>
|
|||
return value;
|
||||
}
|
||||
|
||||
public static HumanBone Deserialize_RightMiddleIntermediate(ListTreeNode<JsonValue> parsed)
|
||||
public static HumanBone Deserialize_RightMiddleIntermediate(JsonNode parsed)
|
||||
{
|
||||
var value = new HumanBone();
|
||||
|
||||
|
|
@ -1307,7 +1307,7 @@ public static HumanBone Deserialize_RightMiddleIntermediate(ListTreeNode<JsonVal
|
|||
return value;
|
||||
}
|
||||
|
||||
public static HumanBone Deserialize_RightMiddleDistal(ListTreeNode<JsonValue> parsed)
|
||||
public static HumanBone Deserialize_RightMiddleDistal(JsonNode parsed)
|
||||
{
|
||||
var value = new HumanBone();
|
||||
|
||||
|
|
@ -1324,7 +1324,7 @@ public static HumanBone Deserialize_RightMiddleDistal(ListTreeNode<JsonValue> pa
|
|||
return value;
|
||||
}
|
||||
|
||||
public static HumanBone Deserialize_RightRingProximal(ListTreeNode<JsonValue> parsed)
|
||||
public static HumanBone Deserialize_RightRingProximal(JsonNode parsed)
|
||||
{
|
||||
var value = new HumanBone();
|
||||
|
||||
|
|
@ -1341,7 +1341,7 @@ public static HumanBone Deserialize_RightRingProximal(ListTreeNode<JsonValue> pa
|
|||
return value;
|
||||
}
|
||||
|
||||
public static HumanBone Deserialize_RightRingIntermediate(ListTreeNode<JsonValue> parsed)
|
||||
public static HumanBone Deserialize_RightRingIntermediate(JsonNode parsed)
|
||||
{
|
||||
var value = new HumanBone();
|
||||
|
||||
|
|
@ -1358,7 +1358,7 @@ public static HumanBone Deserialize_RightRingIntermediate(ListTreeNode<JsonValue
|
|||
return value;
|
||||
}
|
||||
|
||||
public static HumanBone Deserialize_RightRingDistal(ListTreeNode<JsonValue> parsed)
|
||||
public static HumanBone Deserialize_RightRingDistal(JsonNode parsed)
|
||||
{
|
||||
var value = new HumanBone();
|
||||
|
||||
|
|
@ -1375,7 +1375,7 @@ public static HumanBone Deserialize_RightRingDistal(ListTreeNode<JsonValue> pars
|
|||
return value;
|
||||
}
|
||||
|
||||
public static HumanBone Deserialize_RightLittleProximal(ListTreeNode<JsonValue> parsed)
|
||||
public static HumanBone Deserialize_RightLittleProximal(JsonNode parsed)
|
||||
{
|
||||
var value = new HumanBone();
|
||||
|
||||
|
|
@ -1392,7 +1392,7 @@ public static HumanBone Deserialize_RightLittleProximal(ListTreeNode<JsonValue>
|
|||
return value;
|
||||
}
|
||||
|
||||
public static HumanBone Deserialize_RightLittleIntermediate(ListTreeNode<JsonValue> parsed)
|
||||
public static HumanBone Deserialize_RightLittleIntermediate(JsonNode parsed)
|
||||
{
|
||||
var value = new HumanBone();
|
||||
|
||||
|
|
@ -1409,7 +1409,7 @@ public static HumanBone Deserialize_RightLittleIntermediate(ListTreeNode<JsonVal
|
|||
return value;
|
||||
}
|
||||
|
||||
public static HumanBone Deserialize_RightLittleDistal(ListTreeNode<JsonValue> parsed)
|
||||
public static HumanBone Deserialize_RightLittleDistal(JsonNode parsed)
|
||||
{
|
||||
var value = new HumanBone();
|
||||
|
||||
|
|
@ -1426,7 +1426,7 @@ public static HumanBone Deserialize_RightLittleDistal(ListTreeNode<JsonValue> pa
|
|||
return value;
|
||||
}
|
||||
|
||||
public static FirstPerson Deserialize_FirstPerson(ListTreeNode<JsonValue> parsed)
|
||||
public static FirstPerson Deserialize_FirstPerson(JsonNode parsed)
|
||||
{
|
||||
var value = new FirstPerson();
|
||||
|
||||
|
|
@ -1443,7 +1443,7 @@ public static FirstPerson Deserialize_FirstPerson(ListTreeNode<JsonValue> parsed
|
|||
return value;
|
||||
}
|
||||
|
||||
public static List<MeshAnnotation> Deserialize_MeshAnnotations(ListTreeNode<JsonValue> parsed)
|
||||
public static List<MeshAnnotation> Deserialize_MeshAnnotations(JsonNode parsed)
|
||||
{
|
||||
var value = new List<MeshAnnotation>();
|
||||
foreach(var x in parsed.ArrayItems())
|
||||
|
|
@ -1453,7 +1453,7 @@ public static List<MeshAnnotation> Deserialize_MeshAnnotations(ListTreeNode<Json
|
|||
return value;
|
||||
}
|
||||
|
||||
public static MeshAnnotation Deserialize_MeshAnnotations_ITEM(ListTreeNode<JsonValue> parsed)
|
||||
public static MeshAnnotation Deserialize_MeshAnnotations_ITEM(JsonNode parsed)
|
||||
{
|
||||
var value = new MeshAnnotation();
|
||||
|
||||
|
|
@ -1475,7 +1475,7 @@ public static MeshAnnotation Deserialize_MeshAnnotations_ITEM(ListTreeNode<JsonV
|
|||
return value;
|
||||
}
|
||||
|
||||
public static LookAt Deserialize_LookAt(ListTreeNode<JsonValue> parsed)
|
||||
public static LookAt Deserialize_LookAt(JsonNode parsed)
|
||||
{
|
||||
var value = new LookAt();
|
||||
|
||||
|
|
@ -1517,7 +1517,7 @@ public static LookAt Deserialize_LookAt(ListTreeNode<JsonValue> parsed)
|
|||
return value;
|
||||
}
|
||||
|
||||
public static float[] Deserialize_OffsetFromHeadBone(ListTreeNode<JsonValue> parsed)
|
||||
public static float[] Deserialize_OffsetFromHeadBone(JsonNode parsed)
|
||||
{
|
||||
var value = new float[parsed.GetArrayCount()];
|
||||
int i=0;
|
||||
|
|
@ -1528,7 +1528,7 @@ public static float[] Deserialize_OffsetFromHeadBone(ListTreeNode<JsonValue> par
|
|||
return value;
|
||||
}
|
||||
|
||||
public static LookAtRangeMap Deserialize_LookAtHorizontalInner(ListTreeNode<JsonValue> parsed)
|
||||
public static LookAtRangeMap Deserialize_LookAtHorizontalInner(JsonNode parsed)
|
||||
{
|
||||
var value = new LookAtRangeMap();
|
||||
|
||||
|
|
@ -1550,7 +1550,7 @@ public static LookAtRangeMap Deserialize_LookAtHorizontalInner(ListTreeNode<Json
|
|||
return value;
|
||||
}
|
||||
|
||||
public static LookAtRangeMap Deserialize_LookAtHorizontalOuter(ListTreeNode<JsonValue> parsed)
|
||||
public static LookAtRangeMap Deserialize_LookAtHorizontalOuter(JsonNode parsed)
|
||||
{
|
||||
var value = new LookAtRangeMap();
|
||||
|
||||
|
|
@ -1572,7 +1572,7 @@ public static LookAtRangeMap Deserialize_LookAtHorizontalOuter(ListTreeNode<Json
|
|||
return value;
|
||||
}
|
||||
|
||||
public static LookAtRangeMap Deserialize_LookAtVerticalDown(ListTreeNode<JsonValue> parsed)
|
||||
public static LookAtRangeMap Deserialize_LookAtVerticalDown(JsonNode parsed)
|
||||
{
|
||||
var value = new LookAtRangeMap();
|
||||
|
||||
|
|
@ -1594,7 +1594,7 @@ public static LookAtRangeMap Deserialize_LookAtVerticalDown(ListTreeNode<JsonVal
|
|||
return value;
|
||||
}
|
||||
|
||||
public static LookAtRangeMap Deserialize_LookAtVerticalUp(ListTreeNode<JsonValue> parsed)
|
||||
public static LookAtRangeMap Deserialize_LookAtVerticalUp(JsonNode parsed)
|
||||
{
|
||||
var value = new LookAtRangeMap();
|
||||
|
||||
|
|
@ -1616,7 +1616,7 @@ public static LookAtRangeMap Deserialize_LookAtVerticalUp(ListTreeNode<JsonValue
|
|||
return value;
|
||||
}
|
||||
|
||||
public static List<Expression> Deserialize_Expressions(ListTreeNode<JsonValue> parsed)
|
||||
public static List<Expression> Deserialize_Expressions(JsonNode parsed)
|
||||
{
|
||||
var value = new List<Expression>();
|
||||
foreach(var x in parsed.ArrayItems())
|
||||
|
|
@ -1626,7 +1626,7 @@ public static List<Expression> Deserialize_Expressions(ListTreeNode<JsonValue> p
|
|||
return value;
|
||||
}
|
||||
|
||||
public static Expression Deserialize_Expressions_ITEM(ListTreeNode<JsonValue> parsed)
|
||||
public static Expression Deserialize_Expressions_ITEM(JsonNode parsed)
|
||||
{
|
||||
var value = new Expression();
|
||||
|
||||
|
|
@ -1693,7 +1693,7 @@ public static Expression Deserialize_Expressions_ITEM(ListTreeNode<JsonValue> pa
|
|||
return value;
|
||||
}
|
||||
|
||||
public static List<MorphTargetBind> Deserialize_MorphTargetBinds(ListTreeNode<JsonValue> parsed)
|
||||
public static List<MorphTargetBind> Deserialize_MorphTargetBinds(JsonNode parsed)
|
||||
{
|
||||
var value = new List<MorphTargetBind>();
|
||||
foreach(var x in parsed.ArrayItems())
|
||||
|
|
@ -1703,7 +1703,7 @@ public static List<MorphTargetBind> Deserialize_MorphTargetBinds(ListTreeNode<Js
|
|||
return value;
|
||||
}
|
||||
|
||||
public static MorphTargetBind Deserialize_MorphTargetBinds_ITEM(ListTreeNode<JsonValue> parsed)
|
||||
public static MorphTargetBind Deserialize_MorphTargetBinds_ITEM(JsonNode parsed)
|
||||
{
|
||||
var value = new MorphTargetBind();
|
||||
|
||||
|
|
@ -1740,7 +1740,7 @@ public static MorphTargetBind Deserialize_MorphTargetBinds_ITEM(ListTreeNode<Jso
|
|||
return value;
|
||||
}
|
||||
|
||||
public static List<MaterialColorBind> Deserialize_MaterialColorBinds(ListTreeNode<JsonValue> parsed)
|
||||
public static List<MaterialColorBind> Deserialize_MaterialColorBinds(JsonNode parsed)
|
||||
{
|
||||
var value = new List<MaterialColorBind>();
|
||||
foreach(var x in parsed.ArrayItems())
|
||||
|
|
@ -1750,7 +1750,7 @@ public static List<MaterialColorBind> Deserialize_MaterialColorBinds(ListTreeNod
|
|||
return value;
|
||||
}
|
||||
|
||||
public static MaterialColorBind Deserialize_MaterialColorBinds_ITEM(ListTreeNode<JsonValue> parsed)
|
||||
public static MaterialColorBind Deserialize_MaterialColorBinds_ITEM(JsonNode parsed)
|
||||
{
|
||||
var value = new MaterialColorBind();
|
||||
|
||||
|
|
@ -1787,7 +1787,7 @@ public static MaterialColorBind Deserialize_MaterialColorBinds_ITEM(ListTreeNode
|
|||
return value;
|
||||
}
|
||||
|
||||
public static float[] Deserialize_TargetValue(ListTreeNode<JsonValue> parsed)
|
||||
public static float[] Deserialize_TargetValue(JsonNode parsed)
|
||||
{
|
||||
var value = new float[parsed.GetArrayCount()];
|
||||
int i=0;
|
||||
|
|
@ -1798,7 +1798,7 @@ public static float[] Deserialize_TargetValue(ListTreeNode<JsonValue> parsed)
|
|||
return value;
|
||||
}
|
||||
|
||||
public static List<TextureTransformBind> Deserialize_TextureTransformBinds(ListTreeNode<JsonValue> parsed)
|
||||
public static List<TextureTransformBind> Deserialize_TextureTransformBinds(JsonNode parsed)
|
||||
{
|
||||
var value = new List<TextureTransformBind>();
|
||||
foreach(var x in parsed.ArrayItems())
|
||||
|
|
@ -1808,7 +1808,7 @@ public static List<TextureTransformBind> Deserialize_TextureTransformBinds(ListT
|
|||
return value;
|
||||
}
|
||||
|
||||
public static TextureTransformBind Deserialize_TextureTransformBinds_ITEM(ListTreeNode<JsonValue> parsed)
|
||||
public static TextureTransformBind Deserialize_TextureTransformBinds_ITEM(JsonNode parsed)
|
||||
{
|
||||
var value = new TextureTransformBind();
|
||||
|
||||
|
|
@ -1845,7 +1845,7 @@ public static TextureTransformBind Deserialize_TextureTransformBinds_ITEM(ListTr
|
|||
return value;
|
||||
}
|
||||
|
||||
public static float[] Deserialize_Scaling(ListTreeNode<JsonValue> parsed)
|
||||
public static float[] Deserialize_Scaling(JsonNode parsed)
|
||||
{
|
||||
var value = new float[parsed.GetArrayCount()];
|
||||
int i=0;
|
||||
|
|
@ -1856,7 +1856,7 @@ public static float[] Deserialize_Scaling(ListTreeNode<JsonValue> parsed)
|
|||
return value;
|
||||
}
|
||||
|
||||
public static float[] Deserialize_Offset(ListTreeNode<JsonValue> parsed)
|
||||
public static float[] Deserialize_Offset(JsonNode parsed)
|
||||
{
|
||||
var value = new float[parsed.GetArrayCount()];
|
||||
int i=0;
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ namespace UniVRM10
|
|||
/// </summary>
|
||||
public static class Migration
|
||||
{
|
||||
static bool TryGet(this UniGLTF.glTFExtensionImport extensions, string key, out ListTreeNode<JsonValue> value)
|
||||
static bool TryGet(this UniGLTF.glTFExtensionImport extensions, string key, out JsonNode value)
|
||||
{
|
||||
foreach (var kv in extensions.ObjectItems())
|
||||
{
|
||||
|
|
@ -46,7 +46,7 @@ namespace UniVRM10
|
|||
// },
|
||||
// "axisLength": 0
|
||||
// },
|
||||
static UniGLTF.Extensions.VRMC_vrm.HumanBone MigrateHumanoidBone(ListTreeNode<JsonValue> vrm0)
|
||||
static UniGLTF.Extensions.VRMC_vrm.HumanBone MigrateHumanoidBone(JsonNode vrm0)
|
||||
{
|
||||
return new UniGLTF.Extensions.VRMC_vrm.HumanBone
|
||||
{
|
||||
|
|
@ -54,7 +54,7 @@ namespace UniVRM10
|
|||
};
|
||||
}
|
||||
|
||||
static UniGLTF.Extensions.VRMC_vrm.Humanoid MigrateHumanoid(ListTreeNode<JsonValue> vrm0)
|
||||
static UniGLTF.Extensions.VRMC_vrm.Humanoid MigrateHumanoid(JsonNode vrm0)
|
||||
{
|
||||
var humanoid = new UniGLTF.Extensions.VRMC_vrm.Humanoid
|
||||
{
|
||||
|
|
@ -149,7 +149,7 @@ namespace UniVRM10
|
|||
// "licenseName": "Other",
|
||||
// "otherLicenseUrl": "https://3d.nicovideo.jp/alicia/rule.html"
|
||||
// },
|
||||
static UniGLTF.Extensions.VRMC_vrm.Meta MigrateMeta(ListTreeNode<JsonValue> vrm0)
|
||||
static UniGLTF.Extensions.VRMC_vrm.Meta MigrateMeta(JsonNode vrm0)
|
||||
{
|
||||
var meta = new UniGLTF.Extensions.VRMC_vrm.Meta
|
||||
{
|
||||
|
|
@ -274,7 +274,7 @@ namespace UniVRM10
|
|||
return meta;
|
||||
}
|
||||
|
||||
static string GetLicenseUrl(ListTreeNode<JsonValue> vrm0)
|
||||
static string GetLicenseUrl(JsonNode vrm0)
|
||||
{
|
||||
string l0 = default;
|
||||
string l1 = default;
|
||||
|
|
@ -302,7 +302,7 @@ namespace UniVRM10
|
|||
return "";
|
||||
}
|
||||
|
||||
static float[] ReverseZ(ListTreeNode<JsonValue> xyz)
|
||||
static float[] ReverseZ(JsonNode xyz)
|
||||
{
|
||||
return new float[]{
|
||||
xyz["x"].GetSingle(),
|
||||
|
|
@ -324,7 +324,7 @@ namespace UniVRM10
|
|||
}
|
||||
}
|
||||
|
||||
static UniGLTF.Extensions.VRMC_springBone.VRMC_springBone MigrateSpringBone(UniGLTF.glTF gltf, ListTreeNode<JsonValue> sa)
|
||||
static UniGLTF.Extensions.VRMC_springBone.VRMC_springBone MigrateSpringBone(UniGLTF.glTF gltf, JsonNode sa)
|
||||
{
|
||||
var colliderNodes = new List<int>();
|
||||
|
||||
|
|
@ -452,7 +452,7 @@ namespace UniVRM10
|
|||
return springBone;
|
||||
}
|
||||
|
||||
static UniGLTF.Extensions.VRMC_vrm.ExpressionPreset ToPreset(ListTreeNode<JsonValue> json)
|
||||
static UniGLTF.Extensions.VRMC_vrm.ExpressionPreset ToPreset(JsonNode json)
|
||||
{
|
||||
switch (json.GetString().ToLower())
|
||||
{
|
||||
|
|
@ -486,7 +486,7 @@ namespace UniVRM10
|
|||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
static IEnumerable<UniGLTF.Extensions.VRMC_vrm.MorphTargetBind> ToMorphTargetBinds(UniGLTF.glTF gltf, ListTreeNode<JsonValue> json)
|
||||
static IEnumerable<UniGLTF.Extensions.VRMC_vrm.MorphTargetBind> ToMorphTargetBinds(UniGLTF.glTF gltf, JsonNode json)
|
||||
{
|
||||
foreach (var x in json.ArrayItems())
|
||||
{
|
||||
|
|
@ -548,7 +548,7 @@ namespace UniVRM10
|
|||
/// <param name="gltf"></param>
|
||||
/// <param name="json"></param>
|
||||
/// <param name="expression"></param>
|
||||
static void ToMaterialColorBinds(UniGLTF.glTF gltf, ListTreeNode<JsonValue> json, UniGLTF.Extensions.VRMC_vrm.Expression expression)
|
||||
static void ToMaterialColorBinds(UniGLTF.glTF gltf, JsonNode json, UniGLTF.Extensions.VRMC_vrm.Expression expression)
|
||||
{
|
||||
foreach (var x in json.ArrayItems())
|
||||
{
|
||||
|
|
@ -596,7 +596,7 @@ namespace UniVRM10
|
|||
}
|
||||
}
|
||||
|
||||
static IEnumerable<UniGLTF.Extensions.VRMC_vrm.Expression> MigrateExpression(UniGLTF.glTF gltf, ListTreeNode<JsonValue> json)
|
||||
static IEnumerable<UniGLTF.Extensions.VRMC_vrm.Expression> MigrateExpression(UniGLTF.glTF gltf, JsonNode json)
|
||||
{
|
||||
foreach (var blendShapeClip in json["blendShapeGroups"].ArrayItems())
|
||||
{
|
||||
|
|
@ -670,7 +670,7 @@ namespace UniVRM10
|
|||
}
|
||||
}
|
||||
|
||||
public static void CheckBone(string bone, ListTreeNode<JsonValue> vrm0, UniGLTF.Extensions.VRMC_vrm.HumanBone vrm1)
|
||||
public static void CheckBone(string bone, JsonNode vrm0, UniGLTF.Extensions.VRMC_vrm.HumanBone vrm1)
|
||||
{
|
||||
var vrm0NodeIndex = vrm0["node"].GetInt32();
|
||||
if (vrm0NodeIndex != vrm1.Node)
|
||||
|
|
@ -679,7 +679,7 @@ namespace UniVRM10
|
|||
}
|
||||
}
|
||||
|
||||
public static void CheckHumanoid(ListTreeNode<JsonValue> vrm0, UniGLTF.Extensions.VRMC_vrm.Humanoid vrm1)
|
||||
public static void CheckHumanoid(JsonNode vrm0, UniGLTF.Extensions.VRMC_vrm.Humanoid vrm1)
|
||||
{
|
||||
foreach (var humanoidBone in vrm0["humanBones"].ArrayItems())
|
||||
{
|
||||
|
|
@ -763,7 +763,7 @@ namespace UniVRM10
|
|||
throw new MigrationException(key, $"{x}");
|
||||
}
|
||||
|
||||
public static void CheckMeta(ListTreeNode<JsonValue> vrm0, UniGLTF.Extensions.VRMC_vrm.Meta vrm1)
|
||||
public static void CheckMeta(JsonNode vrm0, UniGLTF.Extensions.VRMC_vrm.Meta vrm1)
|
||||
{
|
||||
if (vrm0["title"].GetString() != vrm1.Name) throw new MigrationException("meta.title", vrm1.Name);
|
||||
if (vrm0["version"].GetString() != vrm1.Version) throw new MigrationException("meta.version", vrm1.Version);
|
||||
|
|
@ -808,13 +808,13 @@ namespace UniVRM10
|
|||
}
|
||||
}
|
||||
|
||||
public static void Check(ListTreeNode<JsonValue> vrm0, UniGLTF.Extensions.VRMC_vrm.VRMC_vrm vrm1)
|
||||
public static void Check(JsonNode vrm0, UniGLTF.Extensions.VRMC_vrm.VRMC_vrm vrm1)
|
||||
{
|
||||
Migration.CheckMeta(vrm0["meta"], vrm1.Meta);
|
||||
Migration.CheckHumanoid(vrm0["humanoid"], vrm1.Humanoid);
|
||||
}
|
||||
|
||||
public static void Check(ListTreeNode<JsonValue> vrm0, UniGLTF.Extensions.VRMC_springBone.VRMC_springBone vrm1, List<UniGLTF.glTFNode> nodes)
|
||||
public static void Check(JsonNode vrm0, UniGLTF.Extensions.VRMC_springBone.VRMC_springBone vrm1, List<UniGLTF.glTFNode> nodes)
|
||||
{
|
||||
// Migration.CheckSpringBone(vrm0["secondaryAnimation"], vrm1.sp)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,14 +17,14 @@ namespace UniVRM10
|
|||
}
|
||||
}
|
||||
|
||||
static ListTreeNode<JsonValue> GetVRM0(byte[] bytes)
|
||||
static JsonNode GetVRM0(byte[] bytes)
|
||||
{
|
||||
var glb = UniGLTF.Glb.Parse(bytes);
|
||||
var json = glb.Json.Bytes.ParseAsJson();
|
||||
return json["extensions"]["VRM"];
|
||||
}
|
||||
|
||||
T GetExtension<T>(UniGLTF.glTFExtension extensions, UniJSON.Utf8String key, Func<ListTreeNode<JsonValue>, T> deserializer)
|
||||
T GetExtension<T>(UniGLTF.glTFExtension extensions, UniJSON.Utf8String key, Func<JsonNode, T> deserializer)
|
||||
{
|
||||
if (extensions is UniGLTF.glTFExtensionImport import)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user