diff --git a/src-csharp/A.cs b/src-csharp/A.cs new file mode 100644 index 0000000..48be58f --- /dev/null +++ b/src-csharp/A.cs @@ -0,0 +1,18 @@ +using System; + +class A { + public int a = 0; + public int b = 0; + public int c = 0; + + static public int Method(){ + return 0; + } + static public int Method(float f, byte b){ + return 1; + } + static public int Method(byte b, float f){ + Console.WriteLine($"Hello from C#! Received arguments: b={b} f={f}"); + return 2; + } +} \ No newline at end of file diff --git a/src-csharp/Ougge.csproj b/src-csharp/Ougge.csproj new file mode 100644 index 0000000..e5b3070 --- /dev/null +++ b/src-csharp/Ougge.csproj @@ -0,0 +1,11 @@ + + + + netstandard2.1 + latest + Ougge + disable + enable + + + diff --git a/src-csharp/Script.cs b/src-csharp/Script.cs new file mode 100644 index 0000000..cfddcb3 --- /dev/null +++ b/src-csharp/Script.cs @@ -0,0 +1,14 @@ +using System; +using System.Data; + +public abstract class ScriptBase { + public virtual void Update(double deltaTime) {} +} + +public class Script : ScriptBase +{ + public override void Update(double deltaTime) + { + Console.WriteLine() + } +} \ No newline at end of file diff --git a/src-csharp/src-csharp.sln b/src-csharp/src-csharp.sln new file mode 100644 index 0000000..859d950 --- /dev/null +++ b/src-csharp/src-csharp.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.0.31903.59 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ougge", "Ougge.csproj", "{6BB6FC40-E2E4-4CFA-8A46-B3D391A5ADC7}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {6BB6FC40-E2E4-4CFA-8A46-B3D391A5ADC7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6BB6FC40-E2E4-4CFA-8A46-B3D391A5ADC7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6BB6FC40-E2E4-4CFA-8A46-B3D391A5ADC7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6BB6FC40-E2E4-4CFA-8A46-B3D391A5ADC7}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection +EndGlobal diff --git a/src/Mono/Mono.hpp b/src/Mono/Mono.hpp index 021d0c6..2ee8144 100644 --- a/src/Mono/Mono.hpp +++ b/src/Mono/Mono.hpp @@ -68,9 +68,10 @@ class Method public: ReturnT operator()(MonoObject* class_instance, ArgTypes... args) { void* arg_array[] = { valueToVoidPtr(args)..., nullptr }; - // TODO: exception catch - // MonoException* ex = nullptr; - MonoObject* result = mono_runtime_invoke(method_ptr, class_instance, arg_array, nullptr); + MonoObject* ex = nullptr; + MonoObject* result = mono_runtime_invoke(method_ptr, class_instance, arg_array, &ex); + if(ex) //TODO: call mono_trace_set_printerr_handler from mono/mono/utils/mono-logger.h + mono_print_unhandled_exception(ex); return valueFromMonoObject(result); }; diff --git a/src/main.cpp b/src/main.cpp index 98e7068..9fa9db4 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -9,30 +9,29 @@ using namespace ougge; +std::vector updateCallbacks; + void update(f64 deltaTime){ - // std::cout<<"deltaTime: "<getClass("", "A"); - auto m = Mono::Method(c, "Method"); - std::cout<<"method has been found"< void { std::cout<<"deltaTime: "<