mirror of
https://github.com/antopilo/Nuake.git
synced 2026-09-15 20:08:54 +03:00
Now bindings between coral and and generatedC# correctly working
This commit is contained in:
@@ -15,28 +15,25 @@ namespace Nuake
|
||||
|
||||
void ModulesAPI::RegisterMethods()
|
||||
{
|
||||
isModule = true;
|
||||
const std::string& internalPrefix = "Internals";
|
||||
|
||||
for (auto& name : ModuleDB::Get().GetModules())
|
||||
{
|
||||
const std::string& modulePrefix = internalPrefix + "." + name;
|
||||
auto meta = entt::resolve(entt::hashed_string(("class " + name).c_str()));
|
||||
auto instance = ModuleDB::Get().GetBaseImpl(name).instance;
|
||||
for (auto [id, func] : meta.func())
|
||||
{
|
||||
auto funcName = func.prop(HashedName::DisplayName);
|
||||
const std::string funcNameStd = funcName.value().try_cast<std::string>()->c_str();
|
||||
const std::string& fullName = modulePrefix + funcNameStd;
|
||||
|
||||
auto funcPtrMeta = func.prop(HashedUserValue::FuncPtr);
|
||||
auto funcPtr = funcPtrMeta.value().try_cast<void*>();
|
||||
|
||||
RegisterMethod("Internals.SetVolumeICall", &SetVolume);
|
||||
|
||||
//const std::string& internalPrefix = "Internal";
|
||||
//
|
||||
//for (auto& name : ModuleDB::Get().GetModules())
|
||||
//{
|
||||
// const std::string& modulePrefix = internalPrefix + ".";
|
||||
// auto meta = entt::resolve(entt::hashed_string(("class " + name).c_str()));
|
||||
// auto instance = ModuleDB::Get().GetBaseImpl(name).instance;
|
||||
// for (auto [id, func] : meta.func())
|
||||
// {
|
||||
// auto funcName = func.prop(HashedName::DisplayName);
|
||||
// const std::string funcNameStd = funcName.value().try_cast<std::string>()->c_str();
|
||||
// const std::string& fullName = modulePrefix + funcNameStd;
|
||||
//
|
||||
// auto funcPtrMeta = func.prop(HashedUserValue::FuncPtr);
|
||||
// auto funcPtr = funcPtrMeta.value().try_cast<void*>();
|
||||
// RegisterMethod(fullName, &SetVolume);
|
||||
// }
|
||||
//}
|
||||
RegisterMethod(fullName + "ICall", *funcPtr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -8,8 +8,6 @@ namespace Nuake {
|
||||
class NetAPIModule
|
||||
{
|
||||
public:
|
||||
bool isModule = false;
|
||||
|
||||
using MethodMap = std::unordered_map<std::string, void*>;
|
||||
|
||||
virtual const std::string GetModuleName() const = 0;
|
||||
|
||||
@@ -167,16 +167,8 @@ namespace Nuake
|
||||
{
|
||||
for (const auto& [methodName, methodPtr] : netModule->GetMethods())
|
||||
{
|
||||
if(!netModule->isModule)
|
||||
{
|
||||
auto namespaceClassSplit = String::Split(methodName, '.');
|
||||
assembly.AddInternalCall(m_Scope + '.' + namespaceClassSplit[0], namespaceClassSplit[1], methodPtr);
|
||||
}
|
||||
else
|
||||
{
|
||||
auto namespaceClassSplit = String::Split(methodName, '.');
|
||||
assembly.AddInternalCall(m_Scope + '.' + namespaceClassSplit[0], namespaceClassSplit[1], methodPtr);
|
||||
}
|
||||
auto namespaceClassSplit = String::Split(methodName, '.');
|
||||
assembly.AddInternalCall(m_Scope + '.' + namespaceClassSplit[0], namespaceClassSplit[1], methodPtr);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,14 @@ namespace Nuake.Net
|
||||
{
|
||||
unsafe
|
||||
{
|
||||
Internals.SetVolumeICall(volume);
|
||||
Internals.AudioModuleSetVolumeICall(volume);
|
||||
}
|
||||
}
|
||||
public static void SetMuted(bool muted)
|
||||
{
|
||||
unsafe
|
||||
{
|
||||
Internals.AudioModuleSetMutedICall(muted);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,21 @@
|
||||
using System;
|
||||
namespace Nuake.Net
|
||||
{
|
||||
|
||||
public class ExampleModule
|
||||
{
|
||||
public static void ExampleFunction()
|
||||
{
|
||||
unsafe
|
||||
{
|
||||
Internals.ExampleModuleExampleFunctionICall();
|
||||
}
|
||||
}
|
||||
public static void ExampleModuleLog(string hi)
|
||||
{
|
||||
unsafe
|
||||
{
|
||||
Internals.ExampleModuleExampleModuleLogICall(hi);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
using Coral.Managed.Interop;
|
||||
namespace Nuake.Net
|
||||
{
|
||||
public class Internals
|
||||
{
|
||||
// AudioModule
|
||||
public static unsafe delegate*<float, void> SetVolumeICall;
|
||||
}
|
||||
public class Internals
|
||||
{
|
||||
// AudioModule
|
||||
internal static unsafe delegate*<float,void>AudioModuleSetVolumeICall;
|
||||
internal static unsafe delegate*<bool,void>AudioModuleSetMutedICall;
|
||||
|
||||
// ExampleModule
|
||||
internal static unsafe delegate*<void>ExampleModuleExampleFunctionICall;
|
||||
internal static unsafe delegate*<NativeString,void>ExampleModuleExampleModuleLogICall;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -48,6 +48,7 @@ class Generator
|
||||
string generatedInternals = string.Empty;
|
||||
|
||||
generatedInternals += "using Coral.Managed.Interop;\n";
|
||||
generatedInternals += "namespace Nuake.Net\r\n{\n";
|
||||
generatedInternals += "public class Internals\n";
|
||||
generatedInternals += "{\n";
|
||||
|
||||
@@ -56,7 +57,7 @@ class Generator
|
||||
generatedInternals += $" // {module.Name}\n";
|
||||
foreach (var function in module.Functions)
|
||||
{
|
||||
generatedInternals += $" public static unsafe delegate*<";
|
||||
generatedInternals += $" internal static unsafe delegate*<";
|
||||
|
||||
if (function.NumArgs > 0)
|
||||
{
|
||||
@@ -70,7 +71,7 @@ class Generator
|
||||
}
|
||||
|
||||
generatedInternals += "}\n";
|
||||
|
||||
generatedInternals += "}\n";
|
||||
return generatedInternals;
|
||||
}
|
||||
|
||||
@@ -78,9 +79,9 @@ class Generator
|
||||
{
|
||||
string moduleApi = string.Empty;
|
||||
moduleApi += "using System;\n";
|
||||
moduleApi += "namespace Nuake\n";
|
||||
moduleApi += "namespace Nuake.Net\n";
|
||||
moduleApi += "{\n";
|
||||
moduleApi += " public static class " + module.Name + "\n";
|
||||
moduleApi += " public class " + module.Name + "\n";
|
||||
moduleApi += " {\n";
|
||||
|
||||
foreach (Function func in module.Functions)
|
||||
|
||||
Reference in New Issue
Block a user