Added basics for automatic C# -> C++ Bindings

This commit is contained in:
antopilo
2025-04-04 00:17:07 -04:00
parent 2908429b68
commit 00367c37c9
10 changed files with 95 additions and 43 deletions

View File

@@ -0,0 +1,43 @@
#include "ModulesAPI.h"
#include "Nuake/Modules/ModuleDB.h"
#include <Coral/Array.hpp>
#include <Coral/String.hpp>
namespace Nuake
{
void SetVolume(float vol)
{
float myVolume = vol;
return;
}
void ModulesAPI::RegisterMethods()
{
isModule = true;
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);
// }
//}
}
}

View File

@@ -0,0 +1,14 @@
#pragma once
#include "NetAPIModule.h"
namespace Nuake {
class ModulesAPI : public NetAPIModule
{
public:
virtual const std::string GetModuleName() const override { return "Modules"; }
virtual void RegisterMethods() override;
};
}

View File

@@ -8,6 +8,8 @@ namespace Nuake {
class NetAPIModule
{
public:
bool isModule = false;
using MethodMap = std::unordered_map<std::string, void*>;
virtual const std::string GetModuleName() const = 0;