MixinSpec API
This commit is contained in:
10 files changed
+656
No files matched your search
@@ -0,0 +1,62 @@
|
||||
#pragma once
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
#include <functional>
|
||||
#include <cstdint>
|
||||
|
||||
namespace vl::mixin {
|
||||
|
||||
enum class At : std::uint8_t { HEAD, RETURN, INVOKE, FIELD_GET, FIELD_PUT };
|
||||
enum class Side: std::uint8_t { Before, After };
|
||||
|
||||
using CallbackId = std::size_t;
|
||||
|
||||
// Erased ABI for callbacks: Core marshals args and provides a CallbackInfo*.
|
||||
using ErasedCallback = std::function<void*(void** args, int argc, void* cbinfo)>;
|
||||
|
||||
struct InjectionSpec {
|
||||
std::string_view owner; // internal name from generator
|
||||
std::string_view methodName; // "tick"
|
||||
std::string_view methodDesc; // "()V"
|
||||
At at;
|
||||
Side when{Side::Before};
|
||||
CallbackId cb{};
|
||||
};
|
||||
|
||||
struct RedirectSpec {
|
||||
std::string_view owner;
|
||||
std::string_view methodName;
|
||||
std::string_view methodDesc;
|
||||
CallbackId cb{};
|
||||
};
|
||||
|
||||
struct ModifyConstSpec {
|
||||
std::string_view owner;
|
||||
std::string_view methodName;
|
||||
std::string_view methodDesc;
|
||||
enum { Int, Long, Float, Double, String } kind;
|
||||
long long i64{};
|
||||
double fp{};
|
||||
std::string_view str{};
|
||||
CallbackId cb{}; // optional dynamic replacement
|
||||
};
|
||||
|
||||
struct ModifyVarSpec {
|
||||
std::string_view owner;
|
||||
std::string_view methodName;
|
||||
std::string_view methodDesc;
|
||||
int varIndex{};
|
||||
CallbackId cb{};
|
||||
};
|
||||
|
||||
struct MixinSpec {
|
||||
std::string_view owner; // target class internal name
|
||||
std::vector<InjectionSpec> injections;
|
||||
std::vector<RedirectSpec> redirects;
|
||||
std::vector<ModifyConstSpec> constants;
|
||||
std::vector<ModifyVarSpec> vars;
|
||||
bool replaceWholeClass{false};
|
||||
CallbackId classBodyProvider{}; // if replaceWholeClass
|
||||
};
|
||||
|
||||
} // namespace vl::mixin
|
||||
Reference in new issue
Block a user