MCPcopy Create free account
hub / github.com/Redot-Engine/redot-engine / get_api_hash

Method get_api_hash

core/object/class_db.cpp:389–536  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

387}
388
389uint32_t ClassDB::get_api_hash(APIType p_api) {
390#ifdef DEBUG_ENABLED
391 Locker::Lock lock(Locker::STATE_WRITE);
392
393 if (api_hashes_cache.has(p_api)) {
394 return api_hashes_cache[p_api];
395 }
396
397 uint64_t hash = hash_murmur3_one_64(HashMapHasherDefault::hash(REDOT_VERSION_FULL_CONFIG));
398
399 List<StringName> class_list;
400 for (const KeyValue<StringName, ClassInfo> &E : classes) {
401 class_list.push_back(E.key);
402 }
403 // Must be alphabetically sorted for hash to compute.
404 class_list.sort_custom<StringName::AlphCompare>();
405
406 for (const StringName &E : class_list) {
407 ClassInfo *t = classes.getptr(E);
408 ERR_FAIL_NULL_V_MSG(t, 0, vformat("Cannot get class '%s'.", String(E)));
409 if (t->api != p_api || !t->exposed) {
410 continue;
411 }
412 hash = hash_murmur3_one_64(t->name.hash(), hash);
413 hash = hash_murmur3_one_64(t->inherits.hash(), hash);
414
415 { //methods
416
417 List<StringName> snames;
418
419 for (const KeyValue<StringName, MethodBind *> &F : t->method_map) {
420 String name = F.key.operator String();
421
422 ERR_CONTINUE(name.is_empty());
423
424 if (name[0] == '_') {
425 continue; // Ignore non-virtual methods that start with an underscore
426 }
427
428 snames.push_back(F.key);
429 }
430
431 snames.sort_custom<StringName::AlphCompare>();
432
433 for (const StringName &F : snames) {
434 MethodBind *mb = t->method_map[F];
435 hash = hash_murmur3_one_64(mb->get_name().hash(), hash);
436 hash = hash_murmur3_one_64(mb->get_argument_count(), hash);
437 hash = hash_murmur3_one_64(mb->get_argument_type(-1), hash); //return
438
439 for (int i = 0; i < mb->get_argument_count(); i++) {
440 const PropertyInfo info = mb->get_argument_info(i);
441 hash = hash_murmur3_one_64(info.type, hash);
442 hash = hash_murmur3_one_64(info.name.hash(), hash);
443 hash = hash_murmur3_one_64(info.hint, hash);
444 hash = hash_murmur3_one_64(info.hint_string.hash(), hash);
445 }
446

Callers

nothing calls this directly

Calls 15

hash_murmur3_one_64Function · 0.85
hashFunction · 0.85
vformatFunction · 0.85
hash_fmix32Function · 0.85
get_argument_infoMethod · 0.80
has_default_argumentMethod · 0.80
get_default_argumentMethod · 0.80
StringClass · 0.50
hasMethod · 0.45
push_backMethod · 0.45
getptrMethod · 0.45

Tested by

no test coverage detected