diff --git a/Nuake/Source/Nuake/Scripting/NetModules/ModulesAPI.cpp b/Nuake/Source/Nuake/Scripting/NetModules/ModulesAPI.cpp index b4d78e73..5687e7d0 100644 --- a/Nuake/Source/Nuake/Scripting/NetModules/ModulesAPI.cpp +++ b/Nuake/Source/Nuake/Scripting/NetModules/ModulesAPI.cpp @@ -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()->c_str(); + const std::string& fullName = modulePrefix + funcNameStd; + + auto funcPtrMeta = func.prop(HashedUserValue::FuncPtr); + auto funcPtr = funcPtrMeta.value().try_cast(); - 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()->c_str(); - // const std::string& fullName = modulePrefix + funcNameStd; - // - // auto funcPtrMeta = func.prop(HashedUserValue::FuncPtr); - // auto funcPtr = funcPtrMeta.value().try_cast(); - // RegisterMethod(fullName, &SetVolume); - // } - //} + RegisterMethod(fullName + "ICall", *funcPtr); + } + } } } diff --git a/Nuake/Source/Nuake/Scripting/NetModules/NetAPIModule.h b/Nuake/Source/Nuake/Scripting/NetModules/NetAPIModule.h index 09d9fb09..50ac35ca 100644 --- a/Nuake/Source/Nuake/Scripting/NetModules/NetAPIModule.h +++ b/Nuake/Source/Nuake/Scripting/NetModules/NetAPIModule.h @@ -8,8 +8,6 @@ namespace Nuake { class NetAPIModule { public: - bool isModule = false; - using MethodMap = std::unordered_map; virtual const std::string GetModuleName() const = 0; diff --git a/Nuake/Source/Nuake/Scripting/ScriptingEngineNet.cpp b/Nuake/Source/Nuake/Scripting/ScriptingEngineNet.cpp index 1ef4e63f..9c7b22ba 100644 --- a/Nuake/Source/Nuake/Scripting/ScriptingEngineNet.cpp +++ b/Nuake/Source/Nuake/Scripting/ScriptingEngineNet.cpp @@ -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); } } diff --git a/NuakeNet/Source/Generated/AudioModule.cs b/NuakeNet/Source/Generated/AudioModule.cs index fbe8f8f4..f853bed3 100644 --- a/NuakeNet/Source/Generated/AudioModule.cs +++ b/NuakeNet/Source/Generated/AudioModule.cs @@ -7,7 +7,14 @@ namespace Nuake.Net { unsafe { - Internals.SetVolumeICall(volume); + Internals.AudioModuleSetVolumeICall(volume); + } + } + public static void SetMuted(bool muted) + { + unsafe + { + Internals.AudioModuleSetMutedICall(muted); } } } diff --git a/NuakeNet/Source/Generated/ExampleModule.cs b/NuakeNet/Source/Generated/ExampleModule.cs index 425cd06b..2b0ced88 100644 --- a/NuakeNet/Source/Generated/ExampleModule.cs +++ b/NuakeNet/Source/Generated/ExampleModule.cs @@ -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); + } + } + } } diff --git a/NuakeNet/Source/Generated/Internals.cs b/NuakeNet/Source/Generated/Internals.cs index 0198233e..5146440c 100644 --- a/NuakeNet/Source/Generated/Internals.cs +++ b/NuakeNet/Source/Generated/Internals.cs @@ -1,11 +1,15 @@ using Coral.Managed.Interop; namespace Nuake.Net { - public class Internals - { - // AudioModule - public static unsafe delegate* SetVolumeICall; - } +public class Internals +{ + // AudioModule + internal static unsafe delegate*AudioModuleSetVolumeICall; + internal static unsafe delegate*AudioModuleSetMutedICall; + + // ExampleModule + internal static unsafe delegate*ExampleModuleExampleFunctionICall; + internal static unsafe delegate*ExampleModuleExampleModuleLogICall; + +} } - - diff --git a/NuakeNetGenerator/Source/Generator.cs b/NuakeNetGenerator/Source/Generator.cs index 18226c9d..01c7329d 100644 --- a/NuakeNetGenerator/Source/Generator.cs +++ b/NuakeNetGenerator/Source/Generator.cs @@ -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)