mirror of
https://github.com/godotengine/godot-cpp.git
synced 2026-01-06 06:10:06 +03:00
use typeid() for type tags now
This commit is contained in:
@@ -11,7 +11,7 @@ static GDCALLINGCONV void *wrapper_create(void *data, const void *type_tag, godo
|
||||
if (!wrapper_memory)
|
||||
return NULL;
|
||||
wrapper_memory->_owner = instance;
|
||||
wrapper_memory->_type_tag = type_tag;
|
||||
wrapper_memory->_type_tag = (size_t) type_tag;
|
||||
|
||||
return (void *) wrapper_memory;
|
||||
}
|
||||
|
||||
@@ -8,35 +8,38 @@ namespace godot {
|
||||
|
||||
namespace _TagDB {
|
||||
|
||||
std::unordered_map<const void *, const void *> parent_to;
|
||||
std::unordered_map<size_t, size_t> parent_to;
|
||||
|
||||
void register_type(const void *type_tag, const void *base_type_tag)
|
||||
void register_type(size_t type_tag, size_t base_type_tag)
|
||||
{
|
||||
if (type_tag == base_type_tag) {
|
||||
return;
|
||||
}
|
||||
parent_to[type_tag] = base_type_tag;
|
||||
}
|
||||
|
||||
bool is_type_known(const void *type_tag)
|
||||
bool is_type_known(size_t type_tag)
|
||||
{
|
||||
return parent_to.find(type_tag) != parent_to.end();
|
||||
}
|
||||
|
||||
void register_global_type(const char *name, const void *type_tag, const void *base_type_tag)
|
||||
void register_global_type(const char *name, size_t type_tag, size_t base_type_tag)
|
||||
{
|
||||
|
||||
godot::nativescript_1_1_api->godot_nativescript_set_global_type_tag(godot::_RegisterState::language_index, name, type_tag);
|
||||
godot::nativescript_1_1_api->godot_nativescript_set_global_type_tag(godot::_RegisterState::language_index, name, (const void *) type_tag);
|
||||
|
||||
register_type(type_tag, base_type_tag);
|
||||
}
|
||||
|
||||
bool is_type_compatible(const void *ask_tag, const void *have_tag)
|
||||
bool is_type_compatible(size_t ask_tag, size_t have_tag)
|
||||
{
|
||||
|
||||
if (have_tag == nullptr)
|
||||
if (have_tag == 0)
|
||||
return false;
|
||||
|
||||
const void *tag = have_tag;
|
||||
size_t tag = have_tag;
|
||||
|
||||
while (tag != nullptr) {
|
||||
while (tag != 0) {
|
||||
if (tag == ask_tag)
|
||||
return true;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user