Hook class methods are now following to lowercase naming convention

This commit is contained in:
Mestima 2023-10-10 13:05:16 +03:00
parent 18a42c61d3
commit ed1903119a
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();
}; };