-Subproject commit 91b3c4e658b095dc9784946bb2829e7bf5f28907
+Subproject commit 024e9cab0b87c5cbb105d757a82b5d18337c5e0d
#include "gwfmt.h"
#define gwiheader(a, ...) \
if (a->gwion->data->cdoc) do { \
- lint_nl(gwi->lint); \
- lint_indent(gwi->lint); \
- lint_util(gwi->lint, (m_str)"{-}#!+ {/}%s{0}\n", __VA_ARGS__); \
+ gwfmt_nl(gwi->gwfmt); \
+ gwfmt_indent(gwi->gwfmt); \
+ gwfmt_util(gwi->gwfmt, (m_str)"{-}#!+ {/}%s{0}\n", __VA_ARGS__); \
} while (0)
#define gwidoc(a, ...) \
if (a->gwion->data->cdoc) do { \
- lint_nl(a->lint); \
- lint_indent(a->lint); \
- lint_util(a->lint, (m_str)"{-}#!- {/}%s{0}\n", __VA_ARGS__); \
+ gwfmt_nl(a->gwfmt); \
+ gwfmt_indent(a->gwfmt); \
+ gwfmt_util(a->gwfmt, (m_str)"{-}#!- {/}%s{0}\n", __VA_ARGS__); \
} while (0)
#define gwinote(a, ...) \
if (a->gwion->data->cdoc) do { \
- lint_indent(a->lint); \
- lint_util(a->lint, (m_str)"{-}#!- {/}%s{0}\n", __VA_ARGS__); \
+ gwfmt_indent(a->gwfmt); \
+ gwfmt_util(a->gwfmt, (m_str)"{-}#!- {/}%s{0}\n", __VA_ARGS__); \
} while (0)
struct Gwi_ {
struct OperCK * oper; // _misc
struct Vector_ effects;
loc_t loc;
- Lint * lint;
+ Gwfmt * gwfmt;
uint8_t tmpls;
};
set_tflag(t, tflag_cdef);
}
if (gwi->gwion->data->cdoc && t->info->cdef) {
- lint_indent(gwi->lint);
- gwi->lint->indent++;
- lint_class_def(gwi->lint, t->info->cdef);
+ gwfmt_indent(gwi->gwfmt);
+ gwi->gwfmt->indent++;
+ gwfmt_class_def(gwi->gwfmt, t->info->cdef);
}
if(t->info->cdef && t->info->cdef->base.ext &&
t->info->cdef->base.ext->array)
ANN m_int gwi_class_end(const Gwi gwi) {
if (gwi->gwion->data->cdoc && gwi->gwion->env->class_def->info->cdef) {
- gwi->lint->indent--;
- lint_indent(gwi->lint);
- lint_rbrace(gwi->lint);
- lint_nl(gwi->lint);
+ gwi->gwfmt->indent--;
+ gwfmt_indent(gwi->gwfmt);
+ gwfmt_rbrace(gwi->gwfmt);
+ gwfmt_nl(gwi->gwfmt);
}
if (!gwi->gwion->env->class_def)
GWI_ERR_B(_("import: too many class_end called."))
const m_bool ret = traverse_enum_def(gwion->env, edef);
if (ret > 0) import_enum_end(gwi, &edef->values);
if (gwi->gwion->data->cdoc) {
- lint_indent(gwi->lint);
- lint_enum_def(gwi->lint, edef);
+ gwfmt_indent(gwi->gwfmt);
+ gwfmt_enum_def(gwi->gwfmt, edef);
}
const Type t = ret > 0 ? edef->type : NULL;
if (edef->values.ptr) vector_release(&edef->values);
Func_Base * base = gwi_func_base(gwi, ck);
const Func_Def fdef = new_func_def(gwi->gwion->mp, base, NULL);
if (gwi->gwion->data->cdoc) {
- lint_indent(gwi->lint);
- lint_func_def(gwi->lint, fdef);
+ gwfmt_indent(gwi->gwfmt);
+ gwfmt_func_def(gwi->gwfmt, fdef);
}
if (gwi->effects.ptr) {
vector_init(&fdef->base->effects);
DECL_OO(const Fptr_Def, fptr, = import_fptr(gwi));
fptr->base->flag |= flag;
if (gwi->gwion->data->cdoc) {
- lint_indent(gwi->lint);
- lint_fptr_def(gwi->lint, fptr);
+ gwfmt_indent(gwi->gwfmt);
+ gwfmt_fptr_def(gwi->gwfmt, fptr);
}
if (safe_tflag(gwi->gwion->env->class_def,
tflag_tmpl) /*&& !fptr->base->tmpl*/) {
}
ANN static m_bool run_with_doc(const Gwi gwi, m_bool (*f)(const Gwi)) {
- struct LintState ls = {.builtin = true, .nindent = 4};
+ struct GwfmtState ls = {.builtin = true, .nindent = 4};
text_init(&ls.text, gwi->gwion->mp);
- Lint linter = {.mp = gwi->gwion->mp, .ls = &ls };
- lint_indent(&linter);
- lint_util(&linter, "{-}#!+ %s{0}\n", gwi->gwion->env->name);
- gwi->lint = &linter;
+ Gwfmt gwfmter = {.mp = gwi->gwion->mp, .ls = &ls };
+ gwfmt_indent(&gwfmter);
+ gwfmt_util(&gwfmter, "{-}#!+ %s{0}\n", gwi->gwion->env->name);
+ gwi->gwfmt = &gwfmter;
const m_bool ret = f(gwi);
fprintf(stdout, "%s", ls.text.str);
return ret;
const Env env = gwi->gwion->env;
gwi->ck->exp->d.exp_decl.td->flag = flag;
if (gwi->gwion->data->cdoc) {
- lint_indent(gwi->lint);
- lint_exp(gwi->lint, gwi->ck->exp);
- lint_sc(gwi->lint);
- lint_nl(gwi->lint);
+ gwfmt_indent(gwi->gwfmt);
+ gwfmt_exp(gwi->gwfmt, gwi->ck->exp);
+ gwfmt_sc(gwi->gwfmt);
+ gwfmt_nl(gwi->gwfmt);
}
if (env->class_def && tflag(env->class_def, tflag_tmpl))
return gwi_item_tmpl(gwi);
ANN m_int gwi_oper_end(const Gwi gwi, const m_str op, const f_instr f) {
if (gwi->gwion->data->cdoc) {
- lint_indent(gwi->lint);
- lint_util(gwi->lint, "{+C}operator{0} ");
+ gwfmt_indent(gwi->gwfmt);
+ gwfmt_util(gwi->gwfmt, "{+C}operator{0} ");
if (gwi->oper->lhs && !gwi->oper->rhs) {
- lint_util(gwi->lint, "{+}%s{0}",
+ gwfmt_util(gwi->gwfmt, "{+}%s{0}",
gwi->oper->lhs != (m_str)1 ? gwi->oper->lhs : "@Any");
- lint_space(gwi->lint);
+ gwfmt_space(gwi->gwfmt);
}
if (gwi->oper->ret) {
- lint_util(gwi->lint, "{+}%s{0}",
+ gwfmt_util(gwi->gwfmt, "{+}%s{0}",
gwi->oper->ret != (m_str)1 ? gwi->oper->ret : "@Any");
- lint_space(gwi->lint);
+ gwfmt_space(gwi->gwfmt);
}
- lint_util(gwi->lint, "{/}%s{0}", op);
- lint_space(gwi->lint);
- lint_lparen(gwi->lint);
+ gwfmt_util(gwi->gwfmt, "{/}%s{0}", op);
+ gwfmt_space(gwi->gwfmt);
+ gwfmt_lparen(gwi->gwfmt);
if (gwi->oper->lhs && gwi->oper->rhs) {
- lint_util(gwi->lint, "{+}%s{0}",
+ gwfmt_util(gwi->gwfmt, "{+}%s{0}",
gwi->oper->lhs != (m_str)1 ? gwi->oper->lhs : "@Any");
- lint_comma(gwi->lint);
- lint_space(gwi->lint);
+ gwfmt_comma(gwi->gwfmt);
+ gwfmt_space(gwi->gwfmt);
}
if (gwi->oper->rhs)
- lint_util(gwi->lint, "{+}%s{0}",
+ gwfmt_util(gwi->gwfmt, "{+}%s{0}",
gwi->oper->rhs != (m_str)1 ? gwi->oper->rhs : "@Any");
- lint_rparen(gwi->lint);
- lint_sc(gwi->lint);
- lint_nl(gwi->lint);
+ gwfmt_rparen(gwi->gwfmt);
+ gwfmt_sc(gwi->gwfmt);
+ gwfmt_nl(gwi->gwfmt);
}
gwi->oper->sym = insert_symbol(gwi->gwion->st, op);
const m_bool ret = import_op(gwi, gwi->oper, f);
ANN m_bool gwi_primitive(const Gwi gwi, const m_str name, const m_uint size, const ae_flag flag) {
const Env env = gwi->gwion->env;
const Prim_Def pdef = new_prim_def(gwi->gwion->mp, insert_symbol(gwi->gwion->st, name), size, gwi->loc, flag);
- if(gwi->gwion->data->cdoc)lint_prim_def(gwi->lint, pdef);
+ if(gwi->gwion->data->cdoc)gwfmt_prim_def(gwi->gwfmt, pdef);
if(!env->class_def || !tflag(env->class_def, tflag_tmpl)) {
const m_bool ret = scan0_prim_def(gwi->gwion->env, pdef);
free_prim_def(gwi->gwion->mp, pdef);
ANN void gwi_specialid(const Gwi gwi, const m_str id, const SpecialId spid) {
if (gwi->gwion->data->cdoc)
- lint_util(gwi->lint, "{+C}specialid{0} %s{/}%s{0};\n",
+ gwfmt_util(gwi->gwfmt, "{+C}specialid{0} %s{/}%s{0};\n",
spid->is_const ? "{+G}const{0} " : "", id);
struct SpecialId_ *a = mp_calloc(gwi->gwion->mp, SpecialId);
memcpy(a, spid, sizeof(struct SpecialId_));
gwi->ck->tmpl = NULL;
const m_bool ret = traverse_type_def(gwi->gwion->env, tdef);
if (gwi->gwion->data->cdoc) {
- lint_indent(gwi->lint);
- lint_type_def(gwi->lint, tdef);
+ gwfmt_indent(gwi->gwfmt);
+ gwfmt_type_def(gwi->gwfmt, tdef);
}
const Type t = tdef->type;
if (ret > 0)
Type gwi_mk_type(const Gwi gwi, const m_str name, const m_uint size,
const m_str parent_name) {
if (gwi->gwion->data->cdoc) {
- lint_indent(gwi->lint);
- lint_util(gwi->lint, "{+C}primitive{0} {+}%s{0}", name);
- if (parent_name) lint_util(gwi->lint, " {+C}extends{0} {+}%s{0}", parent_name);
- lint_sc(gwi->lint);
- lint_nl(gwi->lint);
+ gwfmt_indent(gwi->gwfmt);
+ gwfmt_util(gwi->gwfmt, "{+C}primitive{0} {+}%s{0}", name);
+ if (parent_name) gwfmt_util(gwi->gwfmt, " {+C}extends{0} {+}%s{0}", parent_name);
+ gwfmt_sc(gwi->gwfmt);
+ gwfmt_nl(gwi->gwfmt);
}
CHECK_OO(gwi_str2sym(gwi, name));
const Type parent = get_parent(gwi, parent_name);
// const M_Object o = new_object(gwi->gwion->mp, udef->value->type);
// udef->value->d.ptr = (m_uint*)o;
if (gwi->gwion->data->cdoc) {
- lint_indent(gwi->lint);
- lint_union_def(gwi->lint, udef);
+ gwfmt_indent(gwi->gwfmt);
+ gwfmt_union_def(gwi->gwfmt, udef);
}
return udef->type;
}