Scope.zig: fix empty identifier output for opaque member - #212
Conversation
791c0e1 to
8212f13
Compare
|
this patch is specifically backwards-compatible. however, I'd personally prefer if the output was something like: const __MODULE__ = @This();
pub const struct_foo_quux = opaque {
pub const foo_quux_bar1 = __MODULE__.foo_quux_bar1;
pub const foo_quux_bar2_ = __MODULE__.foo_quux_bar2;
};this would prevent compiler errors in cases such as in the Lua API, which has the following declarations: // https://github.com/lua/lua/blob/fca974486d12aa29bb6d731fdb5b25055157ece8/lua.h#L203
LUA_API const char *(lua_tolstring) (lua_State *L, int idx, size_t *len);
// https://github.com/lua/lua/blob/fca974486d12aa29bb6d731fdb5b25055157ece8/lauxlib.h#L52
LUALIB_API const char *(luaL_tolstring) (lua_State *L, int idx, size_t *len);currently, pub const struct_lua_State = opaque {
pub const tolstring = lua_tolstring;
};however, users might want to have both declarations available, and not care about the naming. let me know if this change is agreeable, or if it's acceptable as an option to translate-c instead. i can work on such a patch in either case |
|
Looks like this is a better fix for #202
I mentioned doing that in the PR that implemented this feature but haven't gotten around to it yet #22 (comment) |
|
opened #215 which takes the alternate approach (don't demangle at all) |
d55761a to
2d9738a
Compare
Previously, the translated file would contain an empty identifier, which is a compiler error. For example, in test output I added, the result would be: