Skip to content

Conversation

@ab9rf
Copy link
Member

@ab9rf ab9rf commented Nov 13, 2025

These changes allow codegen to produce properly typed C++ std::map and std::unordered_map objects in generated structures

@ab9rf ab9rf force-pushed the proper-maps branch 2 times, most recently from 5cda3b6 to 2a7ea79 Compare November 13, 2025 05:54
@ab9rf ab9rf marked this pull request as draft November 13, 2025 06:20
@ab9rf
Copy link
Member Author

ab9rf commented Nov 13, 2025

moving this to draft until i sort out the hashing stuff and add identity support for unordered_set

@dhthwy
Copy link

dhthwy commented Nov 13, 2025

wow. this is going to be a nightmare.

have to write hash functions for all the structs like df::labor_kitchen_interface_food_key huh?

@dhthwy
Copy link

dhthwy commented Nov 13, 2025

I believe these errors

error: ‘get’ is not a member of ‘df::identity_traits<std::unordered_set<std::shared_ptr<df::widget> > >’
  440 |     { FLD(CONTAINER, filtered_set), identity_traits<std::unordered_set<std::shared_ptr<df::widget > > >::get(), 0, 0 },

is due to failure from having no hash function. I manually patched labor_kitchen_interface_food_key to include a hash function and it seemed to compile without that error

Which you probably already know...so.

@dhthwy
Copy link

dhthwy commented Nov 13, 2025

library/include/df/custom/file_compressorst.methods.inc has a manual = operator for that one.

I guess the == operator could be done that way for now?

and I suppose could add hash specializations to std namespace so that unordered_map doesn't need a 3rd argument.

@ab9rf
Copy link
Member Author

ab9rf commented Nov 13, 2025

I believe these errors

error: ‘get’ is not a member of ‘df::identity_traits<std::unordered_set<std::shared_ptr<df::widget> > >’
  440 |     { FLD(CONTAINER, filtered_set), identity_traits<std::unordered_set<std::shared_ptr<df::widget > > >::get(), 0, 0 },

is due to failure from having no hash function. I manually patched labor_kitchen_interface_food_key to include a hash function and it seemed to compile without that error

Which you probably already know...so.

Yes, indeed. The issue is coming up with a way to get these to exist in a clean way via codegen. I have a kernel of an idea on how to do it, but I've already blown my peak programming time for today on other stuff, so I'm going to push this to tomorrow.

also the error above is actually because we don't have an identity_traits specialization for std::unordered_set and so it gets the generic template which is just an empty struct, which doesn't define get - hence, the error

ab9rf added a commit to ab9rf/dfhack that referenced this pull request Nov 18, 2025
@ab9rf ab9rf marked this pull request as ready for review November 18, 2025 07:41
@ab9rf ab9rf merged commit 40c9ae5 into DFHack:master Nov 18, 2025
9 of 14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants