Added C-style versions of SHLog functions and P/Invoke versions in SHADE_CSharp

This commit is contained in:
Kah Wei 2022-10-24 02:04:05 +08:00
parent 10a945a35d
commit 51c79d33d6
6 changed files with 113 additions and 31 deletions

View File

@ -35,6 +35,10 @@ project "SHADE_CSharp"
optimize "On"
defines{"_RELEASE"}
filter "configurations:Publish"
optimize "On"
defines{"_RELEASE"}
require "vstudio"
function platformsElement(cfg)

View File

@ -0,0 +1,37 @@
using System;
using System.Runtime.InteropServices;
namespace SHADE
{
internal static class Debug
{
[DllImport("SHADE_Engine.dll", EntryPoint = "SHLog_Info")]
public static extern void LogInfo([MarshalAs(UnmanagedType.LPStr)] string str);
[DllImport("SHADE_Engine.dll", EntryPoint = "SHLog_Warning")]
public static extern void LogWarning([MarshalAs(UnmanagedType.LPStr)] string str);
[DllImport("SHADE_Engine.dll", EntryPoint = "SHLog_Error")]
public static extern void LogError([MarshalAs(UnmanagedType.LPStr)] string str);
[DllImport("SHADE_Engine.dll", EntryPoint = "SHLog_Critical")]
public static extern void LogCritical([MarshalAs(UnmanagedType.LPStr)] string str);
public static void LogInfo(string msg, Object thrower)
{
LogInfo($"[{thrower.GetType().Name}] {msg}");
}
public static void LogWarning(string msg, Object thrower)
{
LogWarning($"[{thrower.GetType().Name}] {msg}");
}
public static void LogError(string msg, Object thrower)
{
LogError($"[{thrower.GetType().Name}] {msg}");
}
public static void LogCritical(string msg, Object thrower)
{
LogCritical($"[{thrower.GetType().Name}] {msg}");
}
public static void LogException(Exception exception, Object thrower)
{
LogError($"[{ thrower.GetType().Name }] Unhandled exception: { exception.ToString() }");
}
}
}

View File

@ -51,4 +51,24 @@ namespace SHADE
}
#endif
void SHLog_Info(const char* msg) noexcept
{
SHLOG_INFO(msg)
}
void SHLog_Warning(const char* msg) noexcept
{
SHLOG_WARNING(msg)
}
void SHLog_Error(const char* msg) noexcept
{
SHLOG_ERROR(msg)
}
void SHLog_Critical(const char* msg) noexcept
{
SHLOG_CRITICAL(msg)
}
}

View File

@ -45,4 +45,12 @@ namespace SHADE
static void Trace(const std::string& msg) noexcept;
#endif
};
extern "C"
{
static void SHLog_Info(const char* msg) noexcept;
static void SHLog_Warning(const char* msg) noexcept;
static void SHLog_Error(const char* msg) noexcept;
static void SHLog_Critical(const char* msg) noexcept;
}
}

View File

@ -45,7 +45,8 @@ project "SHADE_Managed"
{
"yaml-cpp",
"imgui",
"SHADE_Engine"
"SHADE_Engine",
"SHADE_CSharp"
}
disablewarnings

View File

@ -286,6 +286,18 @@ namespace SHADE
registerUndoAction(object, field, Convert::ToCLI(val), Convert::ToCLI(oldVal));
}
}
else if (field->FieldType->BaseType == ICallbackEvent::typeid)
{
// Needs to present
// - name and param list
// Needs to present for each callbackaction
// - object, methodinfo OR action
// - Ways to add or remove items
}
else
{
return;
}
// Check if the field has a specific attribute
TooltipAttribute^ toolTip = hasAttribute<TooltipAttribute^>(field);