dfhack icon indicating copy to clipboard operation
dfhack copied to clipboard

`global_table_entry` name field is wrong type in lua

Open ab9rf opened this issue 1 year ago • 2 comments

this field is a ptr-string in structures and is a pointer to a null-terminated (C-style) string, but Lua interprets its as a pointer to a single character

ab9rf avatar Aug 14 '24 20:08 ab9rf

this appears to be because codegen generates lua metadata that identifies the field as a "pointer to a single character" instead of identifying it as a C-style string

ab9rf avatar Aug 14 '24 20:08 ab9rf

further research: codegen emits this as { FLD(POINTER, name), identity_traits<char >::get(), 0, 0 },. it should be { FLD(PRIMITIVE, name), TID(char*), 0, 0 }, which would result in it being mapped to ptr_string_identity. which is what identity_traits<char*>::get() returns, and is the desired type identity for a C-style string

ab9rf avatar Aug 14 '24 21:08 ab9rf