eolian_gen: remove support for legacy header file generation

This commit is contained in:
Daniel Kolesa 2019-04-18 18:10:45 +02:00
parent e81ecf09cd
commit 7807f7750f
7 changed files with 56 additions and 76 deletions

View File

@ -19,8 +19,7 @@ _indent_line(Eina_Strbuf *buf, int ind)
: DOC_LINE_LIMIT)
static void
_generate_ref(const Eolian_State *state, const char *refn, Eina_Strbuf *wbuf,
Eina_Bool use_legacy)
_generate_ref(const Eolian_State *state, const char *refn, Eina_Strbuf *wbuf)
{
const Eolian_Object *decl = eolian_state_object_by_name_get(state, refn);
if (decl)
@ -54,7 +53,7 @@ _generate_ref(const Eolian_State *state, const char *refn, Eina_Strbuf *wbuf,
eina_stringshare_del(bname);
goto noref;
}
_generate_ref(state, bname, wbuf, use_legacy);
_generate_ref(state, bname, wbuf);
eina_strbuf_append(wbuf, sfx);
eina_stringshare_del(bname);
return;
@ -122,7 +121,7 @@ noref:
static int
_append_section(const Eolian_State *state, const char *desc, int ind, int curl,
Eina_Strbuf *buf, Eina_Strbuf *wbuf, Eina_Bool use_legacy)
Eina_Strbuf *buf, Eina_Strbuf *wbuf)
{
Eina_Bool try_note = EINA_TRUE;
while (*desc)
@ -173,7 +172,7 @@ _append_section(const Eolian_State *state, const char *desc, int ind, int curl,
++desc;
if (*(desc - 1) == '.') --desc;
Eina_Stringshare *refn = eina_stringshare_add_length(ref, desc - ref);
_generate_ref(state, refn, wbuf, use_legacy);
_generate_ref(state, refn, wbuf);
eina_stringshare_del(refn);
}
else
@ -278,8 +277,7 @@ _append_group(Eina_Strbuf *buf, char *sgrp, int indent)
static void
_gen_doc_brief(const Eolian_State *state, const char *summary, const char *since,
const char *group, const char *el, int indent, Eina_Strbuf *buf,
Eina_Bool use_legacy)
const char *group, const char *el, int indent, Eina_Strbuf *buf)
{
int curl = 4 + indent;
Eina_Strbuf *wbuf = eina_strbuf_new();
@ -287,7 +285,7 @@ _gen_doc_brief(const Eolian_State *state, const char *summary, const char *since
eina_strbuf_append(buf, "/**< ");
else
eina_strbuf_append(buf, "/** ");
curl = _append_section(state, summary, indent, curl, buf, wbuf, use_legacy);
curl = _append_section(state, summary, indent, curl, buf, wbuf);
eina_strbuf_free(wbuf);
curl = _append_extra(el, indent, curl, EINA_FALSE, buf);
curl = _append_since(since, indent, curl, buf);
@ -310,8 +308,7 @@ _gen_doc_brief(const Eolian_State *state, const char *summary, const char *since
static void
_gen_doc_full(const Eolian_State *state, const char *summary,
const char *description, const char *since,
const char *group, const char *el, int indent, Eina_Strbuf *buf,
Eina_Bool use_legacy)
const char *group, const char *el, int indent, Eina_Strbuf *buf)
{
int curl = 0;
Eina_Strbuf *wbuf = eina_strbuf_new();
@ -322,13 +319,13 @@ _gen_doc_full(const Eolian_State *state, const char *summary,
curl += _indent_line(buf, indent);
eina_strbuf_append(buf, " * @brief ");
curl += sizeof(" * @brief ") - 1;
_append_section(state, summary, indent, curl, buf, wbuf, use_legacy);
_append_section(state, summary, indent, curl, buf, wbuf);
eina_strbuf_append_char(buf, '\n');
_indent_line(buf, indent);
eina_strbuf_append(buf, " *\n");
curl = _indent_line(buf, indent);
eina_strbuf_append(buf, " * ");
_append_section(state, description, indent, curl + 3, buf, wbuf, use_legacy);
_append_section(state, description, indent, curl + 3, buf, wbuf);
curl = _append_extra(el, indent, curl, EINA_TRUE, buf);
curl = _append_since(since, indent, curl, buf);
eina_strbuf_append_char(buf, '\n');
@ -346,8 +343,7 @@ _gen_doc_full(const Eolian_State *state, const char *summary,
static Eina_Strbuf *
_gen_doc_buf(const Eolian_State *state, const Eolian_Documentation *doc,
const char *group, const char *el, int indent,
Eina_Bool use_legacy)
const char *group, const char *el, int indent)
{
if (!doc) return NULL;
@ -357,17 +353,17 @@ _gen_doc_buf(const Eolian_State *state, const Eolian_Documentation *doc,
Eina_Strbuf *buf = eina_strbuf_new();
if (!desc)
_gen_doc_brief(state, sum, since, group, el, indent, buf, use_legacy);
_gen_doc_brief(state, sum, since, group, el, indent, buf);
else
_gen_doc_full(state, sum, desc, since, group, el, indent, buf, use_legacy);
_gen_doc_full(state, sum, desc, since, group, el, indent, buf);
return buf;
}
Eina_Strbuf *
eo_gen_docs_full_gen(const Eolian_State *state, const Eolian_Documentation *doc,
const char *group, int indent, Eina_Bool use_legacy)
const char *group, int indent)
{
return _gen_doc_buf(state, doc, group, NULL, indent, use_legacy);
return _gen_doc_buf(state, doc, group, NULL, indent);
}
Eina_Strbuf *
@ -403,7 +399,7 @@ eo_gen_docs_event_gen(const Eolian_State *state, const Eolian_Event *ev,
return bufs;
}
return _gen_doc_buf(state, doc, group, p, 0, EINA_FALSE);
return _gen_doc_buf(state, doc, group, p, 0);
}
Eina_Strbuf *
@ -517,7 +513,7 @@ eo_gen_docs_func_gen(const Eolian_State *state, const Eolian_Function *fid,
if (!desc && !par && !vpar && !rdoc && (ftype == EOLIAN_METHOD || !pdoc))
{
_gen_doc_brief(state, sum ? sum : "No description supplied.", since, group,
NULL, indent, buf, EINA_FALSE);
NULL, indent, buf);
return buf;
}
@ -528,7 +524,7 @@ eo_gen_docs_func_gen(const Eolian_State *state, const Eolian_Function *fid,
eina_strbuf_append(buf, " * @brief ");
curl += sizeof(" * @brief ") - 1;
_append_section(state, sum ? sum : "No description supplied.",
indent, curl, buf, wbuf, EINA_FALSE);
indent, curl, buf, wbuf);
eina_strbuf_append_char(buf, '\n');
if (desc || since || par || rdoc || pdoc)
@ -541,7 +537,7 @@ eo_gen_docs_func_gen(const Eolian_State *state, const Eolian_Function *fid,
{
curl = _indent_line(buf, indent);
eina_strbuf_append(buf, " * ");
_append_section(state, desc, indent, curl + 3, buf, wbuf, EINA_FALSE);
_append_section(state, desc, indent, curl + 3, buf, wbuf);
eina_strbuf_append_char(buf, '\n');
if (par || rdoc || pdoc || since)
{
@ -556,7 +552,7 @@ eo_gen_docs_func_gen(const Eolian_State *state, const Eolian_Function *fid,
curl = _indent_line(buf, indent);
eina_strbuf_append(buf, " * ");
_append_section(state, eolian_documentation_summary_get(pdoc), indent,
curl + 3, buf, wbuf, EINA_FALSE);
curl + 3, buf, wbuf);
eina_strbuf_append_char(buf, '\n');
if (pdesc)
{
@ -564,7 +560,7 @@ eo_gen_docs_func_gen(const Eolian_State *state, const Eolian_Function *fid,
eina_strbuf_append(buf, " *\n");
curl = _indent_line(buf, indent);
eina_strbuf_append(buf, " * ");
_append_section(state, pdesc, indent, curl + 3, buf, wbuf, EINA_FALSE);
_append_section(state, pdesc, indent, curl + 3, buf, wbuf);
eina_strbuf_append_char(buf, '\n');
}
if (par || rdoc || since)
@ -619,7 +615,7 @@ eo_gen_docs_func_gen(const Eolian_State *state, const Eolian_Function *fid,
eina_strbuf_append_char(buf, ' ');
curl += 1;
_append_section(state, eolian_documentation_summary_get(adoc),
indent, curl, buf, wbuf, EINA_FALSE);
indent, curl, buf, wbuf);
}
eina_strbuf_append_char(buf, '\n');
@ -652,7 +648,7 @@ eo_gen_docs_func_gen(const Eolian_State *state, const Eolian_Function *fid,
eina_strbuf_append(buf, " * @return ");
curl += sizeof(" * @return ") - 1;
_append_section(state, eolian_documentation_summary_get(rdoc), indent,
curl, buf, wbuf, EINA_FALSE);
curl, buf, wbuf);
eina_strbuf_append_char(buf, '\n');
if (since)
{

View File

@ -9,12 +9,11 @@
* @param[in] doc the documentation
* @param[in] group the group to use (can be NULL)
* @param[in] indent by how many spaces to indent the comment from second line
* @param[in] use_legacy whether to use legacy names
*
* @return A documentation comment
*
*/
Eina_Strbuf *eo_gen_docs_full_gen(const Eolian_State *state, const Eolian_Documentation *doc, const char *group, int indent, Eina_Bool use_legacy);
Eina_Strbuf *eo_gen_docs_full_gen(const Eolian_State *state, const Eolian_Documentation *doc, const char *group, int indent);
/*
* @brief Generate function documentation

View File

@ -176,9 +176,9 @@ _gen_func(const Eolian_State *state, const Eolian_Function *fid,
void
eo_gen_header_gen(const Eolian_State *state, const Eolian_Class *cl,
Eina_Strbuf *buf, Eina_Bool legacy)
Eina_Strbuf *buf)
{
if (!cl || legacy)
if (!cl)
return;
Eina_Iterator *itr;
@ -196,7 +196,7 @@ eo_gen_header_gen(const Eolian_State *state, const Eolian_Class *cl,
if (doc)
{
Eina_Strbuf *cdoc = eo_gen_docs_full_gen(state, doc,
eolian_class_name_get(cl), 0, EINA_FALSE);
eolian_class_name_get(cl), 0);
if (cdoc)
{
eina_strbuf_append(buf, eina_strbuf_string_get(cdoc));

View File

@ -4,6 +4,6 @@
#include "main.h"
void eo_gen_params(Eina_Iterator *itr, Eina_Strbuf *buf, Eina_Strbuf **flagbuf, int *nidx, Eolian_Function_Type ftype);
void eo_gen_header_gen(const Eolian_State *state, const Eolian_Class *cl, Eina_Strbuf *buf, Eina_Bool legacy);
void eo_gen_header_gen(const Eolian_State *state, const Eolian_Class *cl, Eina_Strbuf *buf);
#endif

View File

@ -11,17 +11,16 @@ int _eolian_gen_log_dom = -1;
enum
{
GEN_H = 1 << 0,
GEN_H_LEGACY = 1 << 1,
GEN_H_STUB = 1 << 2,
GEN_C = 1 << 3,
GEN_C_IMPL = 1 << 4,
GEN_D = 1 << 5,
GEN_D_FULL = 1 << 6
GEN_H_STUB = 1 << 1,
GEN_C = 1 << 2,
GEN_C_IMPL = 1 << 3,
GEN_D = 1 << 4,
GEN_D_FULL = 1 << 5
};
static const char *_dexts[7] =
static const char *_dexts[6] =
{
".h", ".legacy.h", ".stub.h", ".c", ".c", ".d", ".d"
".h", ".stub.h", ".c", ".c", ".d", ".d"
};
static int
@ -48,7 +47,6 @@ _print_usage(const char *progn, FILE *outf)
"\n"
"Available types:\n"
" h: C header file (.eo.h/.eot.h)\n"
" l: Legacy C header file (.eo.legacy.h/.eot.legacy.h)\n"
" s: Stub C header file (.eo.stub.h/.eot.stub.h)\n"
" c: C source file (.eo.c)\n"
" i: Implementation file (.c, merged with existing)\n"
@ -86,10 +84,6 @@ _try_set_out(char t, char **outs, const char *val, int *what)
pos = _get_bit_pos(GEN_H);
*what |= GEN_H;
break;
case 'l':
pos = _get_bit_pos(GEN_H_LEGACY);
*what |= GEN_H_LEGACY;
break;
case 's':
pos = _get_bit_pos(GEN_H_STUB);
*what |= GEN_H_STUB;
@ -331,13 +325,13 @@ void eo_gen_class_names_get(const Eolian_Class *cl, char **cname,
static Eina_Bool
_write_header(const Eolian_State *eos, const Eolian_State *state, const char *ofname,
const char *ifname, Eina_Bool legacy)
const char *ifname)
{
INF("generating header: %s (legacy: %d)", ofname, legacy);
INF("generating header: %s", ofname);
Eina_Strbuf *buf = eina_strbuf_new();
eo_gen_types_header_gen(state, eolian_state_objects_by_file_get(eos, ifname),
buf, EINA_TRUE, legacy);
buf, EINA_TRUE);
buf = _include_guard(ifname, "TYPES", buf);
Eina_Strbuf *cltd = eo_gen_class_typedef_gen(eos, ifname);
@ -349,16 +343,13 @@ _write_header(const Eolian_State *eos, const Eolian_State *state, const char *of
eina_strbuf_free(cltd);
}
const Eolian_Class *cl = eolian_state_class_by_file_get(eos, ifname);
eo_gen_header_gen(state, cl, buf, legacy);
if (cl || !legacy)
eo_gen_header_gen(state, eolian_state_class_by_file_get(eos, ifname), buf);
buf = _include_guard(_get_filename(ofname), NULL, buf);
if (_write_file(ofname, buf))
{
buf = _include_guard(_get_filename(ofname), NULL, buf);
if (_write_file(ofname, buf))
{
eina_strbuf_free(buf);
return EINA_TRUE;
}
eina_strbuf_free(buf);
return EINA_TRUE;
}
eina_strbuf_free(buf);
@ -373,7 +364,7 @@ _write_stub_header(const Eolian_State *eos, const Eolian_State *state, const cha
Eina_Strbuf *buf = eina_strbuf_new();
eo_gen_types_header_gen(state, eolian_state_objects_by_file_get(eos, ifname),
buf, EINA_FALSE, EINA_FALSE);
buf, EINA_FALSE);
Eina_Strbuf *cltd = eo_gen_class_typedef_gen(eos, ifname);
if (cltd)
@ -476,7 +467,6 @@ _write_deps(const Eolian_State *eos, const char *ofname, const char *ifname,
eina_strbuf_append_char(dbuf, '\n');
_append_dep_line(buf, dbuf, outs, gen_what, GEN_H);
_append_dep_line(buf, dbuf, outs, gen_what, GEN_H_LEGACY);
_append_dep_line(buf, dbuf, outs, gen_what, GEN_H_STUB);
if (gen_what & GEN_D_FULL)
@ -498,7 +488,7 @@ main(int argc, char **argv)
int pret = 1;
char *outs[sizeof(_dexts) / sizeof(void *)] = {
NULL, NULL, NULL, NULL, NULL, NULL, NULL
NULL, NULL, NULL, NULL, NULL, NULL
};
char *basen = NULL;
Eina_List *includes = NULL;
@ -540,9 +530,6 @@ main(int argc, char **argv)
case 'h':
gen_what |= GEN_H;
break;
case 'l':
gen_what |= GEN_H_LEGACY;
break;
case 's':
gen_what |= GEN_H_STUB;
break;
@ -646,9 +633,7 @@ main(int argc, char **argv)
Eina_Bool succ = EINA_TRUE;
if (gen_what & GEN_H)
succ = _write_header(eos, eos, outs[_get_bit_pos(GEN_H)], eobn, EINA_FALSE);
if (succ && (gen_what & GEN_H_LEGACY))
succ = _write_header(eos, eos, outs[_get_bit_pos(GEN_H_LEGACY)], eobn, EINA_TRUE);
succ = _write_header(eos, eos, outs[_get_bit_pos(GEN_H)], eobn);
if (succ && (gen_what & GEN_H_STUB))
succ = _write_stub_header(eos, eos, outs[_get_bit_pos(GEN_H_STUB)], eobn);
if (succ && (gen_what & GEN_C))

View File

@ -4,13 +4,13 @@
static Eina_Strbuf *
_type_generate(const Eolian_State *state, const Eolian_Typedecl *tp,
Eina_Bool full, Eina_Bool legacy)
Eina_Bool full)
{
char *grp = strdup(eolian_typedecl_name_get(tp));
char *p = strrchr(grp, '.');
if (p) *p = '\0';
Eina_Strbuf *buf = eo_gen_docs_full_gen(state, eolian_typedecl_documentation_get(tp),
grp, 0, legacy);
grp, 0);
free(grp);
if (!buf) buf = eina_strbuf_new();
else eina_strbuf_append_char(buf, '\n');
@ -54,7 +54,7 @@ _type_generate(const Eolian_State *state, const Eolian_Typedecl *tp,
if (nl)
{
Eina_Strbuf *fbuf = eo_gen_docs_full_gen(state, fdoc, NULL,
strlen(nl), legacy);
strlen(nl));
if (fbuf)
eina_strbuf_append_printf(buf, " %s",
eina_strbuf_string_get(fbuf));
@ -108,7 +108,7 @@ _type_generate(const Eolian_State *state, const Eolian_Typedecl *tp,
if (nl)
{
Eina_Strbuf *fbuf = eo_gen_docs_full_gen(state, fdoc, NULL,
strlen(nl), legacy);
strlen(nl));
if (fbuf)
eina_strbuf_append_printf(buf, " %s",
eina_strbuf_string_get(fbuf));
@ -166,13 +166,13 @@ _type_generate(const Eolian_State *state, const Eolian_Typedecl *tp,
}
static Eina_Strbuf *
_var_generate(const Eolian_State *state, const Eolian_Variable *vr, Eina_Bool legacy)
_var_generate(const Eolian_State *state, const Eolian_Variable *vr)
{
char *fn = strdup(eolian_variable_name_get(vr));
char *p = strrchr(fn, '.');
if (p) *p = '\0';
Eina_Strbuf *buf = eo_gen_docs_full_gen(state, eolian_variable_documentation_get(vr),
fn, 0, legacy);
fn, 0);
if (p)
{
*p = '_';
@ -216,7 +216,7 @@ _var_generate(const Eolian_State *state, const Eolian_Variable *vr, Eina_Bool le
void eo_gen_types_header_gen(const Eolian_State *state,
Eina_Iterator *itr, Eina_Strbuf *buf,
Eina_Bool full, Eina_Bool legacy)
Eina_Bool full)
{
const Eolian_Object *decl;
EINA_ITERATOR_FOREACH(itr, decl)
@ -229,7 +229,7 @@ void eo_gen_types_header_gen(const Eolian_State *state,
if (!vr || eolian_variable_is_extern(vr))
continue;
Eina_Strbuf *vbuf = _var_generate(state, vr, legacy);
Eina_Strbuf *vbuf = _var_generate(state, vr);
if (vbuf)
{
eina_strbuf_append(buf, eina_strbuf_string_get(vbuf));
@ -259,7 +259,7 @@ void eo_gen_types_header_gen(const Eolian_State *state,
continue;
}
Eina_Strbuf *tbuf = _type_generate(state, tp, full, legacy);
Eina_Strbuf *tbuf = _type_generate(state, tp, full);
if (tbuf)
{
eina_strbuf_append(buf, eina_strbuf_string_get(tbuf));

View File

@ -1,7 +1,7 @@
#ifndef EOLIAN_GEN_TYPES_H
#define EOLIAN_GEN_TYPES_H
void eo_gen_types_header_gen(const Eolian_State *state, Eina_Iterator *itr, Eina_Strbuf *buf, Eina_Bool full, Eina_Bool legacy);
void eo_gen_types_header_gen(const Eolian_State *state, Eina_Iterator *itr, Eina_Strbuf *buf, Eina_Bool full);
void eo_gen_types_source_gen(Eina_Iterator *itr, Eina_Strbuf *buf);
Eina_Strbuf *eo_gen_class_typedef_gen(const Eolian_State *eos, const char *eof);