removed temporary code
This commit is contained in:
parent
71f77ce89c
commit
e71a6b71fe
18
src-csharp/A.cs
Normal file
18
src-csharp/A.cs
Normal file
@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
11
src-csharp/Ougge.csproj
Normal file
11
src-csharp/Ougge.csproj
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>netstandard2.1</TargetFramework>
|
||||||
|
<LangVersion>latest</LangVersion>
|
||||||
|
<RootNamespace>Ougge</RootNamespace>
|
||||||
|
<ImplicitUsings>disable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
14
src-csharp/Script.cs
Normal file
14
src-csharp/Script.cs
Normal file
@ -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()
|
||||||
|
}
|
||||||
|
}
|
||||||
22
src-csharp/src-csharp.sln
Normal file
22
src-csharp/src-csharp.sln
Normal file
@ -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
|
||||||
@ -68,9 +68,10 @@ class Method<ReturnT(ArgTypes...)>
|
|||||||
public:
|
public:
|
||||||
ReturnT operator()(MonoObject* class_instance, ArgTypes... args) {
|
ReturnT operator()(MonoObject* class_instance, ArgTypes... args) {
|
||||||
void* arg_array[] = { valueToVoidPtr(args)..., nullptr };
|
void* arg_array[] = { valueToVoidPtr(args)..., nullptr };
|
||||||
// TODO: exception catch
|
MonoObject* ex = nullptr;
|
||||||
// MonoException* ex = nullptr;
|
MonoObject* result = mono_runtime_invoke(method_ptr, class_instance, arg_array, &ex);
|
||||||
MonoObject* result = mono_runtime_invoke(method_ptr, class_instance, arg_array, nullptr);
|
if(ex) //TODO: call mono_trace_set_printerr_handler from mono/mono/utils/mono-logger.h
|
||||||
|
mono_print_unhandled_exception(ex);
|
||||||
return valueFromMonoObject<ReturnT>(result);
|
return valueFromMonoObject<ReturnT>(result);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
29
src/main.cpp
29
src/main.cpp
@ -9,30 +9,29 @@
|
|||||||
|
|
||||||
using namespace ougge;
|
using namespace ougge;
|
||||||
|
|
||||||
|
std::vector<GUI::UpdatingFunc> updateCallbacks;
|
||||||
|
|
||||||
void update(f64 deltaTime){
|
void update(f64 deltaTime){
|
||||||
// std::cout<<"deltaTime: "<<deltaTime<<std::endl;
|
for(auto upd : updateCallbacks){
|
||||||
|
upd(deltaTime);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, const char** argv){
|
int main(int argc, const char** argv){
|
||||||
try {
|
try {
|
||||||
// Resources::init();
|
Resources::init();
|
||||||
// std::cout<<"initialized resource loader"<<std::endl;
|
std::cout<<"initialized resource loader"<<std::endl;
|
||||||
|
|
||||||
Mono::RuntimeJIT mono;
|
Mono::RuntimeJIT mono;
|
||||||
auto a = mono.loadAssembly("app.exe");
|
|
||||||
auto c = a->getClass("", "A");
|
|
||||||
auto m = Mono::Method<Mono::Int(Mono::Byte, Mono::Float)>(c, "Method");
|
|
||||||
std::cout<<"method has been found"<<std::endl;
|
|
||||||
Mono::Int r = m(nullptr, 16, 0.32);
|
|
||||||
std::cout<<"result: "<<r<<std::endl;
|
|
||||||
return 0;
|
|
||||||
std::cout<<"initialized mono jit runtime"<<std::endl;
|
std::cout<<"initialized mono jit runtime"<<std::endl;
|
||||||
|
|
||||||
// GUI::MainWindow w;
|
updateCallbacks.push_back([](f64 deltaTime) -> void { std::cout<<"deltaTime: "<<deltaTime<<std::endl; });
|
||||||
// w.open("ougge", update);
|
|
||||||
// std::cout<<"created sdl window"<<std::endl;
|
GUI::MainWindow w;
|
||||||
// w.startUpdateLoop();
|
w.open("ougge", update);
|
||||||
// std::cout<<"sdl window has been cosed"<<std::endl;
|
std::cout<<"created sdl window"<<std::endl;
|
||||||
|
w.startUpdateLoop();
|
||||||
|
std::cout<<"sdl window has been cosed"<<std::endl;
|
||||||
}
|
}
|
||||||
catch(const std::exception& e){
|
catch(const std::exception& e){
|
||||||
std::cerr<<"Catched exception: "<<e.what()<<std::endl;
|
std::cerr<<"Catched exception: "<<e.what()<<std::endl;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user