diff options
author | Přemysl Janouch <p.janouch@gmail.com> | 2016-10-27 19:10:35 +0200 |
---|---|---|
committer | Přemysl Janouch <p.janouch@gmail.com> | 2016-10-28 04:12:05 +0200 |
commit | cb5ad675a62323d5d8e24bf49aa6df4acad135a2 (patch) | |
tree | 7df62e4a8a4272d97a85727d0eebef39c088df66 /degesch.c | |
parent | 9408dfc67c8c68e2cbaa9f0658a740af5e588e8c (diff) | |
download | xK-cb5ad675a62323d5d8e24bf49aa6df4acad135a2.tar.gz xK-cb5ad675a62323d5d8e24bf49aa6df4acad135a2.tar.xz xK-cb5ad675a62323d5d8e24bf49aa6df4acad135a2.zip |
degesch: add introspection for "str" and "str_map"
Diffstat (limited to 'degesch.c')
-rw-r--r-- | degesch.c | 44 |
1 files changed, 32 insertions, 12 deletions
@@ -1247,14 +1247,14 @@ weak_unref (struct weak_ref_link **list, struct weak_ref_link **link) enum ispect_type { - ISPECT_BOOL, - ISPECT_INT, - ISPECT_UINT, - ISPECT_SIZE, - ISPECT_STRING, - ISPECT_REF, ///< Weakly referenced + ISPECT_BOOL, ISPECT_INT, ISPECT_UINT, ISPECT_SIZE, ISPECT_STRING, + + ISPECT_STR, ///< "struct str" + ISPECT_STR_MAP, ///< "struct str_map" + ISPECT_REF, ///< Weakly referenced object #if 0 - // TODO: also str_map, str_vector + // XXX: maybe just a PTR type that doesn't warrant weak_refs but is copied, + // LIST-ness seems to be more of a direct flag of a type ISPECT_LIST, ///< Typically copied, depending on type #endif }; @@ -1402,10 +1402,11 @@ struct channel static struct ispect_field g_channel_ispect_fields[] = { - ISPECT( channel, name, STRING ) - ISPECT( channel, topic, STRING ) - ISPECT( channel, users_len, SIZE ) - ISPECT( channel, left_manually, BOOL ) + ISPECT( channel, name, STRING ) + ISPECT( channel, topic, STRING ) + ISPECT( channel, no_param_modes, STR ) + ISPECT( channel, users_len, SIZE ) + ISPECT( channel, left_manually, BOOL ) {} }; @@ -1766,6 +1767,7 @@ static struct ispect_field g_server_ispect_fields[] = // TODO: either rename the underlying field or fix the plugins { "user", offsetof (struct server, irc_user), ISPECT_REF, &g_user_ispect }, + { "user_mode", offsetof (struct server, irc_user_mode), ISPECT_STR, NULL }, {} }; @@ -9802,6 +9804,24 @@ lua_plugin_property_get_ispect (lua_State *L, const char *property_name) case ISPECT_UINT: lua_pushinteger (L, *(unsigned *) p); return true; case ISPECT_SIZE: lua_pushinteger (L, *(size_t *) p); return true; case ISPECT_STRING: lua_pushstring (L, *(char **) p); return true; + case ISPECT_STR: + { + struct str *s = p; + lua_pushlstring (L, s->str, s->len); + return true; + } + case ISPECT_STR_MAP: + { + // FIXME: we should be able to support other things than strings + struct str_map_iter iter; + str_map_iter_init (&iter, p); + + char *s; + lua_newtable (L); + while ((s = str_map_iter_next (&iter))) + lua_plugin_kv (L, iter.link->key, s); + return true; + } case ISPECT_REF: { // TODO: we can definitely make a resolution table right in Lua, @@ -9816,7 +9836,7 @@ lua_plugin_property_get_ispect (lua_State *L, const char *property_name) } } } - return false; + return soft_assert (false); } static int |