You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
lunarium_OLD/src/scripting/coreAPI.h

73 lines
1.9 KiB
C++

/******************************************************************************
* File - coreAPI.h
* Author - Joey Pollack
* Date - 2021/09/23 (y/m/d)
* Mod Date - 2021/09/23 (y/m/d)
* Description - class with all static methods that expose core functionality to LUA
* Need an init function that takes a reference to a LUA state so that it
* can expose the static functions to LUA.
******************************************************************************/
#ifndef CORE_API_H_
#define CORE_API_H_
#include <core/common_defs.h>
#include "wren_script.h"
#include <utils/op_res.h>
#include <input/input_manager.h>
#include <map>
struct WrenVM;
namespace lunarium
{
class WrenState;
class CoreAPI
{
public:
static CoreAPI& GetInstance();
static void FreeInstance();
OpRes Initialize(WrenState& state);
private:
static CoreAPI* mpInstance;
static WrenScript mScript;
u32 mCat;
typedef void (*ForeignMethod)(WrenVM*);
struct ForeignMethodID
{
std::string Module;
std::string Class;
bool IsStatic;
std::string Signature;
ForeignMethod FM;
bool operator==(const ForeignMethodID& rhs)
{
return (Module == rhs.Module && Class == rhs.Class && IsStatic == rhs.IsStatic && Signature == rhs.Signature);
}
};
static std::vector<ForeignMethodID> mForeignMethods;
private: // Helper methods
std::string GenerateWrenKeyCodes();
private: // Callbacks
static ForeignMethod ForeignMethodBinder(WrenVM* vm, const char* module, const char* className, bool isStatic, const char* signature);
public: // API
static void SetWindowSize(int w, int h);
static void Log(int level, const char* msg);
static bool IsKeyDown(WrenVM* vm);
};
}
#endif // CORE_API_H_