-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve binding generator to handle constraint clauses and generic ty…
…pes attribute, fix JSON nodes
- Loading branch information
Showing
24 changed files
with
300 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using System; | ||
using Newtonsoft.Json.Linq; | ||
using ProtoFlux.Core; | ||
using ProtoFlux.Runtimes.Execution; | ||
using Elements.Core; | ||
using FrooxEngine; | ||
using FrooxEngine.ProtoFlux; | ||
|
||
namespace ProtoFlux.Runtimes.Execution.Nodes.Obsidian.Json | ||
{ | ||
[NodeName("Add To Object")] | ||
[NodeCategory("Obsidian/Json")] | ||
[GenericTypes(typeof(byte), typeof(sbyte), typeof(short), typeof(ushort), typeof(int), typeof(uint), | ||
typeof(long), typeof(ulong), typeof(float), typeof(double))] | ||
public class JsonAddValueToJObject<T> : ObjectFunctionNode<FrooxEngineContext, JObject> where T : unmanaged | ||
{ | ||
public readonly ObjectInput<JObject> Input; | ||
public readonly ObjectInput<string> Tag; | ||
public readonly ValueInput<T> Value; | ||
|
||
protected override JObject Compute(FrooxEngineContext context) | ||
{ | ||
var input = Input.Evaluate(context); | ||
if (input == null) return null; | ||
|
||
var tag = Tag.Evaluate(context); | ||
var value = Value.Evaluate(context); | ||
if (string.IsNullOrEmpty(tag)) return input; | ||
|
||
var in2 = (JObject)input.DeepClone(); | ||
in2[tag] = new JValue(value); | ||
return in2; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using System; | ||
using Newtonsoft.Json.Linq; | ||
using ProtoFlux.Core; | ||
using ProtoFlux.Runtimes.Execution; | ||
using FrooxEngine; | ||
using Elements.Core; | ||
using FrooxEngine.ProtoFlux; | ||
|
||
namespace ProtoFlux.Runtimes.Execution.Nodes.Obsidian.Json | ||
{ | ||
[NodeCategory("Obsidian/Json")] | ||
[GenericTypes(typeof(byte), typeof(sbyte), typeof(short), typeof(ushort), typeof(int), typeof(uint), typeof(long), | ||
typeof(ulong), typeof(float), typeof(double))] | ||
public class JsonAppendValueToJArray<T> : ObjectFunctionNode<FrooxEngineContext, JArray> where T : unmanaged | ||
{ | ||
public readonly ObjectInput<JArray> Array; | ||
public readonly ValueInput<T> Value; | ||
protected override JArray Compute(FrooxEngineContext context) | ||
{ | ||
var array = Array.Evaluate(context); | ||
var value = Value.Evaluate(context); | ||
if (array == null) return null; | ||
|
||
try | ||
{ | ||
var output = (JArray)array.DeepClone(); | ||
output.Add(new JValue(value)); | ||
return output; | ||
} | ||
catch | ||
{ | ||
return null; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using FrooxEngine.ProtoFlux; | ||
using Newtonsoft.Json.Linq; | ||
using ProtoFlux.Core; | ||
using ProtoFlux.Runtimes.Execution; | ||
|
||
namespace ProtoFlux.Runtimes.Execution.Nodes.Obsidian.Json | ||
{ | ||
[NodeCategory("Obsidian/Json")] | ||
public class JsonEmptyJArray : ObjectFunctionNode<FrooxEngineContext, JArray> | ||
{ | ||
protected override JArray Compute(FrooxEngineContext context) | ||
{ | ||
return new JArray(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using FrooxEngine.ProtoFlux; | ||
using Newtonsoft.Json.Linq; | ||
using ProtoFlux.Core; | ||
using ProtoFlux.Runtimes.Execution; | ||
|
||
namespace ProtoFlux.Runtimes.Execution.Nodes.Obsidian.Json | ||
{ | ||
[NodeCategory("Obsidian/Json")] | ||
public class JsonEmptyJObject : ObjectFunctionNode<FrooxEngineContext, JObject> | ||
{ | ||
protected override JObject Compute(FrooxEngineContext context) | ||
{ | ||
return new JObject(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using System; | ||
using Newtonsoft.Json.Linq; | ||
using ProtoFlux.Core; | ||
using ProtoFlux.Runtimes.Execution; | ||
using Elements.Core; | ||
using FrooxEngine; | ||
using FrooxEngine.ProtoFlux; | ||
|
||
namespace ProtoFlux.Runtimes.Execution.Nodes.Obsidian.Json | ||
{ | ||
[NodeCategory("Obsidian/Json")] | ||
[GenericTypes(typeof(string), typeof(Uri), typeof(JToken), typeof(JObject), | ||
typeof(JArray))] | ||
public class JsonGetObjectFromJArray<T> : ObjectFunctionNode<FrooxEngineContext, T> | ||
{ | ||
public readonly ObjectInput<JArray> Input; | ||
public readonly ValueInput<int> Index; | ||
|
||
protected override T Compute(FrooxEngineContext context) | ||
{ | ||
var input = Input.Evaluate(context); | ||
var index = Index.Evaluate(context); | ||
if (input == null || index < 0 || index >= input.Count) | ||
return default; | ||
|
||
try | ||
{ | ||
return input[index].Value<T>(); | ||
} | ||
catch | ||
{ | ||
return default; | ||
} | ||
} | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
ProjectObsidian/ProtoFlux/JSON/JsonGetObjectFromJObject.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using System; | ||
using Newtonsoft.Json.Linq; | ||
using ProtoFlux.Core; | ||
using ProtoFlux.Runtimes.Execution; | ||
using Elements.Core; | ||
using FrooxEngine; | ||
using FrooxEngine.ProtoFlux; | ||
|
||
namespace ProtoFlux.Runtimes.Execution.Nodes.Obsidian.Json | ||
{ | ||
[NodeCategory("Obsidian/Json")] | ||
[GenericTypes(typeof(string), typeof(Uri), typeof(JToken), typeof(JObject), | ||
typeof(JArray))] | ||
public class JsonGetObjectFromJObject<T> : ObjectFunctionNode<FrooxEngineContext, T> | ||
{ | ||
public readonly ObjectInput<JObject> Input; | ||
public readonly ObjectInput<string> Tag; | ||
|
||
protected override T Compute(FrooxEngineContext context) | ||
{ | ||
var input = Input.Evaluate(context); | ||
var tag = Tag.Evaluate(context); | ||
if (input == null || string.IsNullOrEmpty(tag)) | ||
return default; | ||
|
||
try | ||
{ | ||
return input[tag].Value<T>(); | ||
} | ||
catch | ||
{ | ||
return default; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
using System; | ||
using Newtonsoft.Json.Linq; | ||
using ProtoFlux.Core; | ||
using ProtoFlux.Runtimes.Execution; | ||
using Elements.Core; | ||
using FrooxEngine; | ||
using FrooxEngine.ProtoFlux; | ||
|
||
namespace ProtoFlux.Runtimes.Execution.Nodes.Obsidian.Json | ||
{ | ||
[NodeCategory("Obsidian/Json")] | ||
[GenericTypes(typeof(byte), typeof(sbyte), typeof(short), typeof(ushort), typeof(int), typeof(uint), typeof(long), | ||
typeof(ulong), typeof(float), typeof(double))] | ||
public class JsonInsertValueToJArray<T> : ObjectFunctionNode<FrooxEngineContext, JArray> where T : unmanaged | ||
{ | ||
public readonly ObjectInput<JArray> Array; | ||
public readonly ValueInput<T> Value; | ||
public readonly ValueInput<int> Index; | ||
|
||
protected override JArray Compute(FrooxEngineContext context) | ||
{ | ||
var array = Array.Evaluate(context); | ||
var value = Value.Evaluate(context); | ||
var index = Index.Evaluate(context); | ||
if (array == null || index < 0 || index > array.Count) | ||
return null; | ||
|
||
try | ||
{ | ||
var output = (JArray)array.DeepClone(); | ||
var token = new JValue(value); | ||
output.Insert(index, token); | ||
return output; | ||
} | ||
catch | ||
{ | ||
return null; | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.