14#include "plugify/global.h"
15#include "plugify/mem_addr.hpp"
16#include "plugify/method.hpp"
17#include "plugify/property.hpp"
18#include "plugify/signarure.hpp"
19#include "plugify/value_type.hpp"
20#include "plg/inplace_vector.hpp"
59 enum class WaitType { None, Breakpoint, Wait_Keypress };
62 using CallingFunc = void (*)(
const uint64_t* params,
const Return*);
91 WaitType waitType = WaitType::None,
115 std::string_view GetError() noexcept;
134 PLUGIFY_ACCESS : struct Impl;
135 PLUGIFY_NO_DLL_EXPORT_WARNING(std::unique_ptr<Impl> _impl;)
139 template <typename T>
141 && (std::is_arithmetic_v<T> || std::is_pointer_v<T> || std::is_enum_v<T>);
144 template <typename T>
148 template <typename T>
159 using SlotType = uint64_t;
160 static constexpr size_t SlotSize =
sizeof(SlotType);
167 _storage.reserve(slotCount);
176 template <SingleSlotType T>
178 SlotType& slot = _storage.emplace_back();
179 std::memcpy(&slot, &value,
sizeof(T));
189 template <MultiSlotType T>
191 constexpr size_t slotsNeeded = (
sizeof(T) + SlotSize - 1) / SlotSize;
192 size_t oldSize = _storage.size();
193 _storage.resize(oldSize + slotsNeeded);
194 std::memcpy(&_storage[oldSize], &value,
sizeof(T));
204 template <
typename... Args>
218 template <SingleSlotType T>
220 SlotType& slot = _storage.at(index);
222 std::memcpy(&slot, &value,
sizeof(T));
230 [[nodiscard]]
const SlotType*
Get() const noexcept {
231 return _storage.data();
238 [[nodiscard]] std::span<const SlotType>
GetSpan() const noexcept {
239 return { _storage.data(), _storage.size() };
247 return _storage.size();
255 return _storage.capacity();
270 [[nodiscard]]
bool HasSpace(
size_t slotsNeeded = 1) const noexcept {
271 return _storage.size() + slotsNeeded < _storage.capacity();
286 using SlotType = uint64_t;
287 static constexpr size_t MaxSize = 2 *
sizeof(SlotType);
294 template <
typename T,
typename... Args>
295 requires(
sizeof(T) <= MaxSize && std::is_trivially_destructible_v<T>)
296 void Construct(Args&&... args) noexcept(noexcept(T(std::forward<Args>(args)...))) {
297 std::construct_at(
reinterpret_cast<T*
>(_storage.data()), std::forward<Args>(args)...);
305 template <
typename T>
306 requires(
sizeof(T) <= MaxSize && std::is_trivially_copyable_v<T>)
307 void Set(T value)
noexcept {
309 std::memcpy(_storage.data(), &value,
sizeof(T));
317 template <
typename T>
318 requires(
sizeof(T) <= MaxSize && std::is_trivially_copyable_v<T>)
319 [[nodiscard]] T
Get() const noexcept {
321 std::memcpy(&result, _storage.data(),
sizeof(T));
333 alignas(
alignof(std::max_align_t))
334 std::array<std::byte, MaxSize> _storage{};
Class encapsulates architecture-, OS- and compiler-specific function call semantics in a virtual "bin...
JitCall(const JitCall &other)=delete
Copy constructor.
JitCall(JitCall &&other) noexcept
Move constructor.
MemAddr GetJitFunc(const Method &method, MemAddr target, WaitType waitType=WaitType::None, HiddenParam hidden=&ValueUtils::IsHiddenParam)
Get a dynamically created function based on the method reference.
MemAddr GetFunction() const noexcept
Get a dynamically created function.
bool(*)(ValueType) HiddenParam
HiddenParam is a predicate function pointer to determine if a ValueType should be passed as a hidden ...
MemAddr GetJitFunc(const Signature &sig, MemAddr target, WaitType waitType, bool hidden)
Get a dynamically created function based on the raw signature.
A wrapper class for memory addresses, providing utility functions for pointer manipulation.
Builder for function parameters to be passed to JIT code.
std::span< const SlotType > GetSpan() const noexcept
Get a span view of the parameters.
Parameters & SetAt(size_t index, T value)
Set argument at specific position (overwrites if exists).
bool HasSpace(size_t slotsNeeded=1) const noexcept
Check if there's room for more arguments.
size_t GetCapacity() const noexcept
Get the total capacity.
const SlotType * Get() const noexcept
Get pointer to the parameter data.
Parameters & AddLarge(const T &value)
Add a large argument that spans multiple slots.
void Reset() noexcept
Reset the builder to reuse it.
Parameters & Add(T value)
Add an argument at the next available position.
Parameters(size_t slotCount)
Constructor.
size_t GetUsedSlots() const noexcept
Get the number of slots used.
Wrapper for function return values.
void Clear() noexcept
Clear the return value storage.
T Get() const noexcept
Get the return value.
void Set(T value) noexcept
Set the return value.
Replacement for asmjit::FuncSignature using ValueType.