REG_FUNC simplified

This commit is contained in:
Nekotekina 2017-02-13 14:54:58 +03:00
parent acd9d6ff24
commit 64ac6a59c4
5 changed files with 35 additions and 27 deletions

View file

@ -132,11 +132,11 @@ s32 cellVideoOutGetScreenSize(u32 videoOut, vm::ptr<float> screenSize)
DECLARE(ppu_module_manager::cellAvconfExt)("cellSysutilAvconfExt", []()
{
REG_VNID(cellSysutilAvconfExt, 0x00000000, g_gamma, []
REG_VNID(cellSysutilAvconfExt, 0x00000000, g_gamma).init = []
{
// Test
*g_gamma = 1.0f;
});
};
REG_FUNC(cellSysutilAvconfExt, cellAudioOutUnregisterDevice);
REG_FUNC(cellSysutilAvconfExt, cellAudioOutGetDeviceInfo2);

View file

@ -928,24 +928,24 @@ DECLARE(ppu_module_manager::cellFs)("sys_fs", []()
REG_FUNC(sys_fs, cellFsOpen);
REG_FUNC(sys_fs, cellFsSdataOpen);
REG_FUNC(sys_fs, cellFsSdataOpenByFd);
REG_FUNC(sys_fs, cellFsRead, MFF_PERFECT);
REG_FUNC(sys_fs, cellFsWrite, MFF_PERFECT);
REG_FUNC(sys_fs, cellFsClose, MFF_PERFECT);
REG_FUNC(sys_fs, cellFsRead).flags = MFF_PERFECT;
REG_FUNC(sys_fs, cellFsWrite).flags = MFF_PERFECT;
REG_FUNC(sys_fs, cellFsClose).flags = MFF_PERFECT;
REG_FUNC(sys_fs, cellFsOpendir);
REG_FUNC(sys_fs, cellFsReaddir, MFF_PERFECT);
REG_FUNC(sys_fs, cellFsClosedir, MFF_PERFECT);
REG_FUNC(sys_fs, cellFsReaddir).flags = MFF_PERFECT;
REG_FUNC(sys_fs, cellFsClosedir).flags = MFF_PERFECT;
REG_FUNC(sys_fs, cellFsStat);
REG_FUNC(sys_fs, cellFsFstat, MFF_PERFECT);
REG_FUNC(sys_fs, cellFsFstat).flags = MFF_PERFECT;
REG_FUNC(sys_fs, cellFsMkdir);
REG_FUNC(sys_fs, cellFsRename);
REG_FUNC(sys_fs, cellFsChmod);
REG_FUNC(sys_fs, cellFsFsync);
REG_FUNC(sys_fs, cellFsRmdir);
REG_FUNC(sys_fs, cellFsUnlink);
REG_FUNC(sys_fs, cellFsLseek, MFF_PERFECT);
REG_FUNC(sys_fs, cellFsFtruncate, MFF_PERFECT);
REG_FUNC(sys_fs, cellFsLseek).flags = MFF_PERFECT;
REG_FUNC(sys_fs, cellFsFtruncate).flags = MFF_PERFECT;
REG_FUNC(sys_fs, cellFsTruncate);
REG_FUNC(sys_fs, cellFsFGetBlockSize, MFF_PERFECT);
REG_FUNC(sys_fs, cellFsFGetBlockSize).flags = MFF_PERFECT;
REG_FUNC(sys_fs, cellFsAioInit);
REG_FUNC(sys_fs, cellFsAioFinish);
REG_FUNC(sys_fs, cellFsAioRead);
@ -978,7 +978,7 @@ DECLARE(ppu_module_manager::cellFs)("sys_fs", []()
REG_FUNC(sys_fs, cellFsAllocateFileAreaByFdWithInitialData);
REG_FUNC(sys_fs, cellFsTruncate2);
REG_FUNC(sys_fs, cellFsChangeFileSizeWithoutAllocation);
REG_FUNC(sys_fs, cellFsAllocateFileAreaWithoutZeroFill, MFF_FORCED_HLE);
REG_FUNC(sys_fs, cellFsAllocateFileAreaWithoutZeroFill).flags = MFF_FORCED_HLE;
REG_FUNC(sys_fs, cellFsChangeFileSizeByFdWithoutAllocation);
REG_FUNC(sys_fs, cellFsSetDiscReadRetrySetting);
REG_FUNC(sys_fs, cellFsRegisterConversionCallback);

View file

@ -258,7 +258,7 @@ s32 cellVideoOutUnregisterCallback(u32 slot)
void cellSysutil_VideoOut_init()
{
REG_FUNC(cellSysutil, cellVideoOutGetState);
REG_FUNC(cellSysutil, cellVideoOutGetResolution, MFF_PERFECT);
REG_FUNC(cellSysutil, cellVideoOutGetResolution).flags = MFF_PERFECT;
REG_FUNC(cellSysutil, cellVideoOutConfigure);
REG_FUNC(cellSysutil, cellVideoOutGetConfiguration);
REG_FUNC(cellSysutil, cellVideoOutGetDeviceInfo);

View file

@ -76,17 +76,19 @@ public:
static const ppu_static_module* get_module(const std::string& name);
template<typename T, T Func>
static void register_static_function(const char* module, const char* name, ppu_function_t func, u32 fnid, u32 flags)
static auto& register_static_function(const char* module, const char* name, ppu_function_t func, u32 fnid)
{
auto& info = access_static_function(module, fnid);
info.name = name;
info.index = ppu_function_manager::register_function<T, Func>(func);
info.flags = flags;
info.flags = 0;
return info;
}
template<typename T, T* Var>
static void register_static_variable(const char* module, const char* name, u32 vnid, void(*init)())
static auto& register_static_variable(const char* module, const char* name, u32 vnid)
{
static_assert(std::is_same<u32, std::decay_t<typename T::addr_type>>::value, "Static variable registration: vm::gvar<T> expected");
@ -94,9 +96,11 @@ public:
info.name = name;
info.var = reinterpret_cast<vm::ps3::gvar<void>*>(Var);
info.init = init ? init : [] {};
info.init = [] {};
info.size = SIZE_32(typename T::type);
info.align = ALIGN_32(typename T::type);
return info;
}
static const ppu_static_module cellAdec;
@ -202,12 +206,12 @@ inline RT ppu_execute_function_or_callback(const char* name, ppu_thread& ppu, Ar
#define CALL_FUNC(ppu, func, ...) ppu_execute_function_or_callback<decltype(&func), &func>(#func, ppu, __VA_ARGS__)
#define REG_FNID(module, nid, func, ...) ppu_module_manager::register_static_function<decltype(&func), &func>(#module, #func, BIND_FUNC(func), nid, {__VA_ARGS__})
#define REG_FNID(module, nid, func) ppu_module_manager::register_static_function<decltype(&func), &func>(#module, #func, BIND_FUNC(func), nid)
#define REG_FUNC(module, func, ...) REG_FNID(module, ppu_generate_id(#func), func, __VA_ARGS__)
#define REG_FUNC(module, func) REG_FNID(module, ppu_generate_id(#func), func)
#define REG_VNID(module, nid, var, ...) ppu_module_manager::register_static_variable<decltype(var), &var>(#module, #var, nid, {__VA_ARGS__})
#define REG_VNID(module, nid, var) ppu_module_manager::register_static_variable<decltype(var), &var>(#module, #var, nid)
#define REG_VAR(module, var, ...) REG_VNID(module, ppu_generate_id(#var), var, __VA_ARGS__)
#define REG_VAR(module, var) REG_VNID(module, ppu_generate_id(#var), var)
#define UNIMPLEMENTED_FUNC(module) module.todo("%s", __func__)

View file

@ -68,17 +68,19 @@ public:
static const arm_static_module* get_module(const std::string& name);
template<typename T, T Func>
static void register_static_function(const char* module, const char* name, arm_function_t func, u32 fnid, u32 flags)
static auto& register_static_function(const char* module, const char* name, arm_function_t func, u32 fnid)
{
auto& info = access_static_function(module, fnid);
info.name = name;
info.index = arm_function_manager::register_function<T, Func>(func);
info.flags = flags;
info.flags = 0;
return info;
}
template<typename T, T* Var>
static void register_static_variable(const char* module, const char* name, u32 vnid, void(*init)())
static auto& register_static_variable(const char* module, const char* name, u32 vnid)
{
static_assert(std::is_same<u32, typename T::addr_type>::value, "Static variable registration: vm::gvar<T> expected");
@ -86,9 +88,11 @@ public:
info.name = name;
info.var = reinterpret_cast<vm::gvar<void>*>(Var);
info.init = init ? init : [] {};
info.init = [] {};
info.size = SIZE_32(typename T::type);
info.align = ALIGN_32(typename T::type);
return info;
}
static const arm_static_module SceAppMgr;
@ -163,6 +167,6 @@ public:
static const arm_static_module SceVoiceQoS;
};
#define REG_FNID(module, nid, func, ...) arm_module_manager::register_static_function<decltype(&func), &func>(#module, #func, BIND_FUNC(func), nid, {__VA_ARGS__})
#define REG_FNID(module, nid, func) arm_module_manager::register_static_function<decltype(&func), &func>(#module, #func, BIND_FUNC(func), nid)
#define REG_VNID(module, nid, var, ...) arm_module_manager::register_static_variable<decltype(var), &var>(#module, #var, nid, {__VA_ARGS__})
#define REG_VNID(module, nid, var) arm_module_manager::register_static_variable<decltype(var), &var>(#module, #var, nid)