Skip to content

Sync a few templates with upstream Godot - #2039

Open
Togira123 wants to merge 1 commit into
godotengine:masterfrom
Togira123:sync_templates
Open

Sync a few templates with upstream Godot#2039
Togira123 wants to merge 1 commit into
godotengine:masterfrom
Togira123:sync_templates

Conversation

@Togira123

Copy link
Copy Markdown
Contributor

This syncs a few classes in the templates folder with godot upstream. Done by copy-pasting the code from upstream, then resolving the diffs. It looks like hashfuncs.cpp is the first .cpp file for templates, so had to also edit the godotcpp.py tool to include it in compilation. Also renamed sort_list.h to sort_list.hpp to match the other files. I will likely do a bunch more since there are more left but I thought I'd open a PR now since it is already a considerable number of changes.

@Togira123
Togira123 requested a review from a team as a code owner July 31, 2026 22:01
@dsnopek
dsnopek requested a review from Ivorforce August 1, 2026 11:00
@dsnopek dsnopek added the enhancement This is an enhancement on the current functionality label Aug 1, 2026
@dsnopek dsnopek added this to the 10.x milestone Aug 1, 2026

@Ivorforce Ivorforce left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks mostly good! Just the hashfuncs change is problematic.

Comment on lines -332 to -340
static _FORCE_INLINE_ uint32_t hash(const wchar_t p_wchar) { return hash_fmix32(uint32_t(p_wchar)); }
static _FORCE_INLINE_ uint32_t hash(const char16_t p_uchar) { return hash_fmix32(uint32_t(p_uchar)); }
static _FORCE_INLINE_ uint32_t hash(const char32_t p_uchar) { return hash_fmix32(uint32_t(p_uchar)); }
static _FORCE_INLINE_ uint32_t hash(const RID &p_rid) { return hash_one_uint64(p_rid.get_id()); }
static _FORCE_INLINE_ uint32_t hash(const CharString &p_char_string) { return hash_djb2(p_char_string.get_data()); }
static _FORCE_INLINE_ uint32_t hash(const StringName &p_string_name) { return p_string_name.hash(); }
static _FORCE_INLINE_ uint32_t hash(const NodePath &p_path) { return p_path.hash(); }
static _FORCE_INLINE_ uint32_t hash(const ObjectID &p_id) { return hash_one_uint64(p_id); }
static _FORCE_INLINE_ uint32_t hash(const Callable &p_callable) { return p_callable.hash(); }

@Ivorforce Ivorforce Aug 4, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can't remove all these methods from the file (above and below too) without also declaring hash() on the respective types. That's the new contract of HashMapHasherDefault.

Your options are to either not sync this part of the hashfuncs yet (which I'd recommend) or to patch every single type that holds hash() in upstream.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, missed that oops. I removed the HashMapHasherDefaultImpl struct now. There is some code that was only used for this struct, e.g. has_hash_method_v. I thought I'd still leave them in to deviate as little from upstream as possible but if you prefer I remove everything related to HashMapHasherDefaultImpl I can do that, just lmk

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, and HashMapComparatorDefault also has lots of methods removed but as far as I can tell this one's fine... but would be good if you confirm.

Comment thread include/godot_cpp/templates/hashfuncs.hpp Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement This is an enhancement on the current functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants