if (cf_symbol_is_local(conf, sym))
cf_error("Symbol '%s' already defined", sym->name);
- if (sym->class == SYM_KEYWORD)
- cf_warn("Symbol '%s' overrides existing keyword", sym->name);
-
/* Not allocated here yet, doing it now. */
cf_swap_soft_scope(conf);
return cf_new_symbol(conf->current_scope, conf->pool, conf->mem, sym->name);
* scope, it's the same @sym as passed to the function.
*/
#define cf_define_symbol(conf_, osym_, type_, var_, def_) ({ \
- struct symbol *sym_ = cf_localize_symbol(conf_, osym_); \
+ struct symbol *sym_ = osym_; \
+ if (sym_->class == SYM_KEYWORD) cf_warn("Symbol '%s' overrides existing keyword", sym_->name); \
+ sym_ = cf_localize_symbol(conf_, sym_); \
+ sym_->class = type_; \
+ sym_->var_ = def_; \
+ sym_; })
+
+#define cf_implicit_symbol(conf_, name_, type_, var_, def_) ({ \
+ struct symbol *sym_ = cf_get_symbol(conf_, name_); \
+ if (sym_->class && sym_->class != SYM_KEYWORD) bug("Implicit symbol '%s' overrides another one", sym_->name); \
+ sym_ = cf_localize_symbol(conf_, sym_); \
sym_->class = type_; \
sym_->var_ = def_; \
sym_; })
{
init_list(&c->tables);
- c->def_tables[NET_IP4] = cf_define_symbol(c, cf_get_symbol(c, "master4"), SYM_TABLE, table, NULL);
- c->def_tables[NET_IP6] = cf_define_symbol(c, cf_get_symbol(c, "master6"), SYM_TABLE, table, NULL);
+ c->def_tables[NET_IP4] = cf_implicit_symbol(c, "master4", SYM_TABLE, table, NULL);
+ c->def_tables[NET_IP6] = cf_implicit_symbol(c, "master6", SYM_TABLE, table, NULL);
}
void
thread_group_config_add_tail(&new_config->thread_group, tgc);
new_config->default_thread_group = tgc;
- tgc->symbol = cf_define_symbol(
- new_config, cf_get_symbol(new_config, "worker"),
+ tgc->symbol = cf_implicit_symbol(
+ new_config, "worker",
SYM_THREAD_GROUP, thread_group, tgc);
/* Default express thread group */
*tgc = thread_group_config_default_express;
thread_group_config_add_tail(&new_config->thread_group, tgc);
- tgc->symbol = cf_define_symbol(
- new_config, cf_get_symbol(new_config, "express"),
+ tgc->symbol = cf_implicit_symbol(
+ new_config, "express",
SYM_THREAD_GROUP, thread_group, tgc);
}