Finality Engine
Loading...
Searching...
No Matches
ScriptModule.h
Go to the documentation of this file.
1
11#pragma once
12
13#include "ScriptRegistry.h"
14#include "ScriptReflection.h"
15#include <filesystem>
16
17namespace FINALITY
18{
19 inline constexpr uint64_t ScriptModuleABI()
20 {
21 uint64_t value = 0x46494e0600000000ull | (sizeof(ScriptValue) << 16) | sizeof(ScriptDefinition);
22#ifdef _MSC_VER
23 value ^= static_cast<uint64_t>(_MSC_VER) << 24;
24#endif
25#ifdef _ITERATOR_DEBUG_LEVEL
26 value ^= static_cast<uint64_t>(_ITERATOR_DEBUG_LEVEL) << 40;
27#endif
28 return value;
29 }
30
33 {
34 void* User = nullptr;
35 bool (*Register)(void*,const ScriptDefinition&) = nullptr;
36 bool Add(const ScriptDefinition& definition) const { return Register && Register(User,definition); }
37 };
38
49 {
50 public:
53 ScriptModule(const ScriptModule&) = delete;
65 bool Load(const std::filesystem::path& library, const std::filesystem::path& shadowDirectory, Scene* scene, std::string& error);
66 void Unload();
67 bool IsLoaded() const;
68 uint64_t GetGeneration() const;
69
70 private:
71 struct State;
72 std::unique_ptr<State> m_State;
73 };
74}
#define FAPI
Definition Core.h:22
Builds typed field metadata for native script registration.
Registers script factories and editable property descriptors.
Owns entities and dispatches script simulation.
Definition Scene.h:36
uint64_t GetGeneration() const
ScriptModule(const ScriptModule &)=delete
ScriptModule & operator=(const ScriptModule &)=delete
bool Load(const std::filesystem::path &library, const std::filesystem::path &shadowDirectory, Scene *scene, std::string &error)
Validates and loads a compiled native script module.
constexpr uint64_t ScriptModuleABI()
std::variant< bool, int, float, std::string, glm::vec3, ScriptAssetReference > ScriptValue
Registered script factory, source location and editable property descriptors with a module lease.
Module registration callback and caller-owned context passed across the native library boundary.
bool(*) Register(void *, const ScriptDefinition &)
bool Add(const ScriptDefinition &definition) const