Revert "Hook class methods are now following to lowercase naming convention"

This reverts commit ed1903119acc68287964440f7d075d66faee1ff2.
This commit is contained in:
Mestima 2023-10-10 14:36:33 +03:00
parent adb93c170d
commit bab2506cc7
2 changed files with 12 additions and 12 deletions

View File

@ -2,17 +2,17 @@
#include "hook.h" #include "hook.h"
Dictionary Hook::getTable() { Dictionary Hook::GetTable() {
return table; return table;
} }
void Hook::add(String event, String uid, Callable function) { void Hook::Add(String event, String uid, Callable function) {
Dictionary tmp = table.get(event, Dictionary()); Dictionary tmp = table.get(event, Dictionary());
tmp[uid] = function; tmp[uid] = function;
table[event] = tmp; table[event] = tmp;
} }
void Hook::call(String event, Array args = Array(), bool defer = false) { void Hook::Call(String event, Array args = Array(), bool defer = false) {
const Variant **argptrs = nullptr; const Variant **argptrs = nullptr;
if (args.size() > 0) { if (args.size() > 0) {
argptrs = (const Variant **)alloca(sizeof(Variant *) * args.size()); argptrs = (const Variant **)alloca(sizeof(Variant *) * args.size());
@ -40,7 +40,7 @@ void Hook::call(String event, Array args = Array(), bool defer = false) {
} }
} }
void Hook::remove(String event, String uid) { void Hook::Remove(String event, String uid) {
Dictionary tmp = table.get(event, Dictionary()); Dictionary tmp = table.get(event, Dictionary());
if (!tmp.is_empty()) { if (!tmp.is_empty()) {
if (tmp.erase(uid)) { if (tmp.erase(uid)) {
@ -54,10 +54,10 @@ void Hook::remove(String event, String uid) {
} }
void Hook::_bind_methods() { void Hook::_bind_methods() {
ClassDB::bind_method(D_METHOD("getTable"), &Hook::getTable); ClassDB::bind_method(D_METHOD("GetTable"), &Hook::GetTable);
ClassDB::bind_method(D_METHOD("add", "event", "uid", "function"), &Hook::add); ClassDB::bind_method(D_METHOD("Add", "event", "uid", "function"), &Hook::Add);
ClassDB::bind_method(D_METHOD("call", "event", "args", "defer"), &Hook::call, DEFVAL(Array()), DEFVAL(false)); ClassDB::bind_method(D_METHOD("Call", "event", "args", "defer"), &Hook::Call, DEFVAL(Array()), DEFVAL(false));
ClassDB::bind_method(D_METHOD("remove", "event", "uid"), &Hook::remove); ClassDB::bind_method(D_METHOD("Remove", "event", "uid"), &Hook::Remove);
}; };
Hook::Hook() { Hook::Hook() {

8
hook.h
View File

@ -19,10 +19,10 @@ protected:
static void _bind_methods(); static void _bind_methods();
public: public:
Dictionary getTable(); Dictionary GetTable();
void add(String event, String uid, Callable function); void Add(String event, String uid, Callable function);
void call(String event, Array args, bool defer); void Call(String event, Array args, bool defer);
void remove(String event, String uid); void Remove(String event, String uid);
Hook(); Hook();
}; };