diff --git a/src/gen/gen_options.lua b/src/gen/gen_options.lua index 49a18f4dbd..cc5de9fad2 100644 --- a/src/gen/gen_options.lua +++ b/src/gen/gen_options.lua @@ -729,19 +729,15 @@ local function gen_keysets(output_file) end write('} OptKeyDict;') - -- Dispatch from option index to its keyset handle (opt_dict_info); NULL for non-dict options. + -- Dispatch from option index to its dict schema (opt_dict_schema); NULL for non-dict options. write('') - write('static inline const OptDictInfo *opt_dict_info(OptIndex opt_idx)') + write('static inline const OptDictSchema *opt_dict_schema(OptIndex opt_idx)') write('{') write(' switch (opt_idx) {') for _, s in ipairs(struct_opts) do write((' case %s: {'):format(s.enum)) write( - (' static const OptDictInfo info = { %s_get_field, %s_table, opt_%s_schema,'):format( - s.kd, - s.abbr, - s.abbr - ) + (' static const OptDictSchema info = { %s_get_field, opt_%s_schema,'):format(s.kd, s.abbr) ) write((' sizeof(%s) };'):format(s.kd)) write(' return &info;') diff --git a/src/nvim/option.c b/src/nvim/option.c index fba6186ac9..6f147ee6cf 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -3340,7 +3340,7 @@ OptIndex find_option(const char *const name) /// canonical ":set" string; reified on-demand (`opt_keyset()`) for validation and applying. bool is_dict_option(OptIndex opt_idx) { - return opt_dict_info(opt_idx) != NULL; + return opt_dict_schema(opt_idx) != NULL; } /// Free an allocated OptVal. @@ -4144,7 +4144,7 @@ static const char *set_option(const OptIndex opt_idx, OptVal value, int opt_flag // Every set path for a dict option (":set", the API, Vimscript, a merge) funnels through here as a // ":set" string. Validate it once. if (value.type == kOptValTypeString && is_dict_option(opt_idx)) { - errmsg = opt_strings_check(value.data.string.data, opt_dict_info(opt_idx)->schema, errbuf, + errmsg = opt_strings_check(value.data.string.data, opt_dict_schema(opt_idx)->schema, errbuf, errbuflen); if (errmsg != NULL) { optval_free(value); diff --git a/src/nvim/option_defs.h b/src/nvim/option_defs.h index 11ad82384d..7d22165c0f 100644 --- a/src/nvim/option_defs.h +++ b/src/nvim/option_defs.h @@ -93,14 +93,12 @@ typedef struct { const char **enum_values; ///< kOptSchemaEnum: NULL-terminated valid values; else NULL } OptSchemaItem; -/// Per-option handle for a dict option ("schema" in options.lua), generated by -/// `opt_dict_info()`. NULL from `opt_dict_info()` means the option is not a dict option. +/// Schema for a dict option (`schema.dict` in options.lua). typedef struct { FieldHashfn get_field; ///< Keyset perfect-hash lookup, for opt_fill(). - const KeySetLink *table; ///< Field layout, for freeing a keyset's `String` fields. const OptSchemaItem *schema; ///< Grammar, for opt_strings_check() validation. - size_t size; ///< sizeof the keyset, for allocation. -} OptDictInfo; + size_t size; ///< sizeof the keyset, for opt_keyset() storage. +} OptDictSchema; /// :set operator types typedef enum { diff --git a/src/nvim/optionstr.c b/src/nvim/optionstr.c index 5da0e913bc..ed1670e1fe 100644 --- a/src/nvim/optionstr.c +++ b/src/nvim/optionstr.c @@ -2355,7 +2355,7 @@ void *opt_keyset(const char *value, OptIndex opt_idx, void *keyset) if (keyset == NULL) { keyset = &shared; } - const OptDictInfo *si = opt_dict_info(opt_idx); + const OptDictSchema *si = opt_dict_schema(opt_idx); memset(keyset, 0, si->size); if (value != NULL) { opt_fill(value, si->get_field, keyset);