Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion modules/vms/angel/src/components/angelbehaviour.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ void AngelBehaviour::updateMeta() {
count = info->GetMethodCount();
for(uint32_t m = 0; m <= count; m++) {
if(m == count) {
m_methodTable.push_back({MetaMethod::Method, nullptr, nullptr, nullptr, 0, nullptr});
m_methodTable.push_back({MetaMethod::Method, nullptr, nullptr, nullptr, 0, 0, nullptr});
} else {
asIScriptFunction *method = info->GetMethodByIndex(m);
if(method) {
Expand Down
9 changes: 7 additions & 2 deletions thirdparty/next/inc/core/macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public: \
static const MetaMethod::Table *methods() { \
static const MetaMethod::Table table[] { \
__VA_ARGS__, \
{MetaMethod::Method, nullptr, nullptr, nullptr, 0, nullptr} \
{MetaMethod::Method, nullptr, nullptr, nullptr, 0, 0, nullptr} \
}; \
return table; \
}
Expand All @@ -136,7 +136,7 @@ public: \
public: \
static const MetaMethod::Table *methods() { \
static const MetaMethod::Table table[] { \
{MetaMethod::Method, nullptr, nullptr, nullptr, 0, nullptr} \
{MetaMethod::Method, nullptr, nullptr, nullptr, 0, 0, nullptr} \
}; \
return table; \
}
Expand All @@ -146,6 +146,7 @@ public: \
#m, \
(MetaMethod::Table::InvokeMem)&Invoker<decltype(&m)>::invoke<&m>, \
(MetaMethod::Table::AddressMem)&Invoker<decltype(&m)>::address<&m>, \
Invoker<decltype(&m)>::signature(#m), \
Invoker<decltype(&m)>::argCount(), \
Invoker<decltype(&m)>::types(#r), \
}
Expand All @@ -155,6 +156,7 @@ public: \
#m, \
(MetaMethod::Table::InvokeMem)&Invoker<decltype(&m)>::invoke<&m>, \
(MetaMethod::Table::AddressMem)&Invoker<decltype(&m)>::address<&m>, \
Invoker<decltype(&m)>::signature(#m), \
Invoker<decltype(&m)>::argCount(), \
Invoker<decltype(&m)>::types(#r), \
}
Expand All @@ -164,6 +166,7 @@ public: \
#m, \
nullptr, \
nullptr, \
Invoker<decltype(&m)>::signature(#m), \
Invoker<decltype(&m)>::argCount(), \
Invoker<decltype(&m)>::types("void"), \
}
Expand All @@ -173,6 +176,7 @@ public: \
#m, \
(MetaMethod::Table::InvokeMem)&Invoker<decltype(&m)>::invoke<&m>, \
(MetaMethod::Table::AddressMem)&Invoker<decltype(&m)>::address<&m>, \
Invoker<decltype(&m)>::signature(#m), \
Invoker<decltype(&m)>::argCount(), \
Invoker<decltype(&m)>::types("void"), \
}
Expand All @@ -182,6 +186,7 @@ public: \
n, \
(MetaMethod::Table::InvokeMem)&Invoker<decltype(&m)>::invoke<&m>, \
(MetaMethod::Table::AddressMem)&Invoker<decltype(&m)>::address<&m>, \
Invoker<decltype(&m)>::signature(#m), \
Invoker<decltype(&m)>::argCount(), \
Invoker<decltype(&m)>::types("void"), \
}
Expand Down
203 changes: 202 additions & 1 deletion thirdparty/next/inc/core/metamethod.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
You should have received a copy of the GNU Lesser General Public License
along with Thunder Next. If not, see <http://www.gnu.org/licenses/>.

Copyright: 2008-2023 Evgeniy Prikazchikov
Copyright: 2008-2025 Evgeniy Prikazchikov
*/

#ifndef METAMETHOD_H
Expand All @@ -26,6 +26,7 @@
#include "variant.h"
#include "metatype.h"
#include "event.h"
#include "amath.h"

class Object;

Expand All @@ -46,6 +47,7 @@ class NEXT_LIBRARY_EXPORT MetaMethod {
const char *name;
InvokeMem invoker;
AddressMem address;
int sign;
int argc;
const MetaType::Table **types;
};
Expand All @@ -57,6 +59,7 @@ class NEXT_LIBRARY_EXPORT MetaMethod {

const char *name() const;
std::string signature() const;
int hash() const;

MethodType type() const;
MetaType returnType() const;
Expand Down Expand Up @@ -111,6 +114,28 @@ struct Invoker<Return(*)(Args...)> {
// Workaround for the Visual Studio bug
typedef Return(*Fun)(Args...);

inline static int signature(const char *methodName) {
std::string sig(methodName);
int pos = sig.rfind(':');
if(pos != -1) {
sig = sig.substr(pos + 1, sig.size() - pos);
}
sig += '(';

static const MetaType::Table *staticTypes[] = {
getTable<std::remove_const_t<Args>>()...
};

for(int i = 0; i < argCount(); i++) {
const MetaType::Table *table = staticTypes[i];
sig += std::string(table->name) + ',';
}
sig.pop_back();
sig += ')';

return Mathf::hashString(sig);
}

inline static int argCount() {
return sizeof...(Args);
}
Expand Down Expand Up @@ -150,6 +175,17 @@ template<typename Return>
struct Invoker<Return(*)()> {
typedef Return(*Fun)();

inline static int signature(const char *methodName) {
std::string sig(methodName);
int pos = sig.rfind(':');
if(pos != -1) {
sig = sig.substr(pos + 1, sig.size() - pos);
}
sig += "()";

return Mathf::hashString(sig);
}

inline static int argCount() {
return 0;
}
Expand Down Expand Up @@ -188,6 +224,28 @@ template<typename... Args>
struct Invoker<void(*)(Args...)> {
typedef void(*Fun)(Args...);

inline static int signature(const char *methodName) {
std::string sig(methodName);
int pos = sig.rfind(':');
if(pos != -1) {
sig = sig.substr(pos + 1, sig.size() - pos);
}
sig += '(';

static const MetaType::Table *staticTypes[] = {
getTable<std::remove_const_t<Args>>()...
};

for(int i = 0; i < argCount(); i++) {
const MetaType::Table *table = staticTypes[i];
sig += std::string(table->name) + ',';
}
sig.pop_back();
sig += ')';

return Mathf::hashString(sig);
}

inline static int argCount() {
return sizeof...(Args);
}
Expand Down Expand Up @@ -229,6 +287,17 @@ template<>
struct Invoker<void(*)()> {
typedef void(*Fun)();

inline static int signature(const char *methodName) {
std::string sig(methodName);
int pos = sig.rfind(':');
if(pos != -1) {
sig = sig.substr(pos + 1, sig.size() - pos);
}
sig += "()";

return Mathf::hashString(sig);
}

inline static int argCount() {
return 0;
}
Expand Down Expand Up @@ -269,6 +338,28 @@ template<typename Class, typename Return, typename... Args>
struct Invoker<Return(Class::*)(Args...)> {
typedef Return(Class::*Fun)(Args...);

inline static int signature(const char *methodName) {
std::string sig(methodName);
int pos = sig.rfind(':');
if(pos != -1) {
sig = sig.substr(pos + 1, sig.size() - pos);
}
sig += '(';

static const MetaType::Table *staticTypes[] = {
getTable<std::remove_const_t<Args>>()...
};

for(int i = 0; i < argCount(); i++) {
const MetaType::Table *table = staticTypes[i];
sig += std::string(table->name) + ',';
}
sig.pop_back();
sig += ')';

return Mathf::hashString(sig);
}

inline static int argCount() {
return sizeof...(Args);
}
Expand Down Expand Up @@ -309,6 +400,17 @@ template<typename Class, typename Return>
struct Invoker<Return(Class::*)()> {
typedef Return(Class::*Fun)();

inline static int signature(const char *methodName) {
std::string sig(methodName);
int pos = sig.rfind(':');
if(pos != -1) {
sig = sig.substr(pos + 1, sig.size() - pos);
}
sig += "()";

return Mathf::hashString(sig);
}

inline static int argCount() {
return 0;
}
Expand Down Expand Up @@ -347,6 +449,28 @@ template<typename Class, typename... Args>
struct Invoker<void(Class::*)(Args...)> {
typedef void(Class::*Fun)(Args...);

inline static int signature(const char *methodName) {
std::string sig(methodName);
int pos = sig.rfind(':');
if(pos != -1) {
sig = sig.substr(pos + 1, sig.size() - pos);
}
sig += '(';

static const MetaType::Table *staticTypes[] = {
getTable<std::remove_const_t<Args>>()...
};

for(int i = 0; i < argCount(); i++) {
const MetaType::Table *table = staticTypes[i];
sig += std::string(table->name) + ',';
}
sig.pop_back();
sig += ')';

return Mathf::hashString(sig);
}

inline static int argCount() {
return sizeof...(Args);
}
Expand Down Expand Up @@ -388,6 +512,17 @@ template<typename Class>
struct Invoker<void(Class::*)()> {
typedef void(Class::*Fun)();

inline static int signature(const char *methodName) {
std::string sig(methodName);
int pos = sig.rfind(':');
if(pos != -1) {
sig = sig.substr(pos + 1, sig.size() - pos);
}
sig += "()";

return Mathf::hashString(sig);
}

inline static int argCount() {
return 0;
}
Expand Down Expand Up @@ -430,6 +565,28 @@ template<typename Class, typename Return, typename... Args>
struct Invoker<Return(Class::*)(Args...)const> {
typedef Return(Class::*Fun)(Args...)const;

inline static int signature(const char *methodName) {
std::string sig(methodName);
int pos = sig.rfind(':');
if(pos != -1) {
sig = sig.substr(pos + 1, sig.size() - pos);
}
sig += '(';

static const MetaType::Table *staticTypes[] = {
getTable<std::remove_const_t<Args>>()...
};

for(int i = 0; i < argCount(); i++) {
const MetaType::Table *table = staticTypes[i];
sig += std::string(table->name) + ',';
}
sig.pop_back();
sig += ')';

return Mathf::hashString(sig);
}

inline static int argCount() {
return sizeof...(Args);
}
Expand Down Expand Up @@ -470,6 +627,17 @@ template<typename Class, typename Return>
struct Invoker<Return(Class::*)()const> {
typedef Return(Class::*Fun)()const;

inline static int signature(const char *methodName) {
std::string sig(methodName);
int pos = sig.rfind(':');
if(pos != -1) {
sig = sig.substr(pos + 1, sig.size() - pos);
}
sig += "()";

return Mathf::hashString(sig);
}

inline static int argCount() {
return 0;
}
Expand Down Expand Up @@ -509,6 +677,28 @@ template<typename Class, typename... Args>
struct Invoker<void(Class::*)(Args...)const> {
typedef void(Class::*Fun)(Args...)const;

inline static int signature(const char *methodName) {
std::string sig(methodName);
int pos = sig.rfind(':');
if(pos != -1) {
sig = sig.substr(pos + 1, sig.size() - pos);
}
sig += '(';

static const MetaType::Table *staticTypes[] = {
getTable<std::remove_const_t<Args>>()...
};

for(int i = 0; i < argCount(); i++) {
const MetaType::Table *table = staticTypes[i];
sig += std::string(table->name) + ',';
}
sig.pop_back();
sig += ')';

return Mathf::hashString(sig);
}

inline static int argCount() {
return sizeof...(Args);
}
Expand Down Expand Up @@ -550,6 +740,17 @@ template<typename Class>
struct Invoker<void(Class::*)()const> {
typedef void(Class::*Fun)()const;

inline static int signature(const char *methodName) {
std::string sig(methodName);
int pos = sig.rfind(':');
if(pos != -1) {
sig = sig.substr(pos + 1, sig.size() - pos);
}
sig += "()";

return Mathf::hashString(sig);
}

inline static int argCount() {
return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion thirdparty/next/inc/math/amath.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class NEXT_LIBRARY_EXPORT Mathf {
seed ^= hash(v) + 0x9e3779b9 + (seed<<6) + (seed>>2);
}

static int hashString(const std::string &str) {
inline static int hashString(const std::string &str) {
int hash = 5381;
for(auto it : str) {
hash = ((hash << 5) + hash) + it;
Expand Down
Loading