eolian: _CLASS -> _CLASS/INTERFACE/MIXIN

This commit is contained in:
Daniel Kolesa 2014-06-30 21:29:50 +01:00
parent c05493b480
commit 14a85859c5
6 changed files with 55 additions and 13 deletions

View File

@ -45,6 +45,26 @@ _class_env_create(const Eolian_Class class, const char *over_classname, _eolian_
eina_str_toupper(&p);
p = strncpy(env->lower_eo_prefix, eo_prefix, PATH_MAX - 1);
eina_str_tolower(&p);
/* classtype */
if (class) switch (eolian_class_type_get(class))
{
case EOLIAN_CLASS_REGULAR:
case EOLIAN_CLASS_ABSTRACT:
strcpy(env->lower_classtype, "class");
strcpy(env->upper_classtype, "CLASS");
break;
case EOLIAN_CLASS_MIXIN:
strcpy(env->lower_classtype, "mixin");
strcpy(env->upper_classtype, "MIXIN");
break;
case EOLIAN_CLASS_INTERFACE:
strcpy(env->lower_classtype, "interface");
strcpy(env->upper_classtype, "INTERFACE");
break;
default:
break;
}
}
void
@ -117,6 +137,8 @@ _template_fill(Eina_Strbuf *buf, const char *templ, const Eolian_Class class, co
eina_strbuf_replace_all(buf, "@#func", funcname);
eina_strbuf_replace_all(buf, "@#FUNC", tmp_func_env.upper_func);
}
eina_strbuf_replace_all(buf, "@#classtype", tmp_env.lower_classtype);
eina_strbuf_replace_all(buf, "@#CLASSTYPE", tmp_env.upper_classtype);
eina_strbuf_replace_all(buf, "@#Class", tmp_env.full_classname);
eina_strbuf_replace_all(buf, "@#class", tmp_env.lower_classname);
eina_strbuf_replace_all(buf, "@#CLASS", tmp_env.upper_classname);

View File

@ -42,6 +42,9 @@ typedef struct
char upper_classname[PATH_MAX];
char lower_classname[PATH_MAX];
char upper_classtype[PATH_MAX];
char lower_classtype[PATH_MAX];
}_eolian_class_vars;
typedef struct

View File

@ -48,14 +48,14 @@ static const Eo_Class_Description _@#class_class_desc = {\n\
@#dtor_name\n\
};\n\
\n\
EO_DEFINE_CLASS(@#class_class_get, &_@#class_class_desc, @#list_inheritNULL);\
EO_DEFINE_CLASS(@#class_@#classtype_get, &_@#class_class_desc, @#list_inheritNULL);\
";
static const char
tmpl_eo_obj_header[] = "\
#define @#CLASS_CLASS @#class_class_get()\n\
#define @#CLASS_@#CLASSTYPE @#class_@#classtype_get()\n\
\n\
const Eo_Class *@#class_class_get(void) EINA_CONST;\n\
const Eo_Class *@#class_@#classtype_get(void) EINA_CONST;\n\
\n\
";
@ -761,7 +761,8 @@ eo_source_end_generate(const Eolian_Class class, Eina_Strbuf *buf)
Eolian_Class inherit_class = eolian_class_find_by_name(inherit_name);
_eolian_class_vars inherit_env;
_class_env_create(inherit_class, NULL, &inherit_env);
eina_strbuf_append_printf(tmpbuf, "%s_CLASS, ", inherit_env.upper_classname);
eina_strbuf_append_printf(tmpbuf, "%s_%s, ", inherit_env.upper_classname,
inherit_env.upper_classtype);
}
if (eina_strbuf_length_get(tmpbuf) == 0) eina_strbuf_append(tmpbuf, "NULL, ");

View File

@ -164,8 +164,8 @@ _prototype_generate(Eolian_Function foo, Eolian_Function_Type ftype, Eina_Strbuf
if (impl_desc && ftype == EOLIAN_CTOR)
{
eina_strbuf_append_printf(super_invok,
" eo_do_super(obj, %s_CLASS, %s_%s(%s);\n",
class_env.upper_eo_prefix,
" eo_do_super(obj, %s_%s, %s_%s(%s);\n",
class_env.upper_eo_prefix, class_env.upper_classtype,
impl_env.lower_classname, eolian_function_name_get(foo),
eina_strbuf_string_get(short_params));
}

View File

@ -66,7 +66,23 @@ class_from_name(std::string const& classname)
inline std::string
class_eo_name(Eolian_Class const& klass)
{
std::string s = class_full_name(klass) + "_CLASS";
std::string suffix;
switch (eolian_class_type_get(klass))
{
case EOLIAN_CLASS_REGULAR:
case EOLIAN_CLASS_ABSTRACT:
suffix = "CLASS";
break;
case EOLIAN_CLASS_MIXIN:
suffix = "MIXIN";
break;
case EOLIAN_CLASS_INTERFACE:
suffix = "INTERFACE";
break;
default:
break;
}
std::string s = class_full_name(klass) + "_" + suffix;
std::transform(s.begin(), s.end(), s.begin(),
[](int c)
{

View File

@ -31,12 +31,12 @@ EAPI extern const Eo_Event_Description _EVAS_CANVAS_EVENT_RENDER_POST;
#include "canvas/evas_zoomable_interface.eo.h"
// Interface classes links
#define EVAS_SMART_SIGNAL_INTERFACE EVAS_SIGNAL_INTERFACE_CLASS
#define EVAS_SMART_CLICKABLE_INTERFACE EVAS_CLICKABLE_INTERFACE_CLASS
#define EVAS_SMART_SCROLLABLE_INTERFACE EVAS_SCROLLABLE_INTERFACE_CLASS
#define EVAS_SMART_DRAGGABLE_INTERFACE EVAS_DRAGGABLE_INTERFACE_CLASS
#define EVAS_SMART_SELECTABLE_INTERFACE EVAS_SELECTABLE_INTERFACE_CLASS
#define EVAS_SMART_ZOOMABLE_INTERFACE EVAS_ZOOMABLE_INTERFACE_CLASS
#define EVAS_SMART_SIGNAL_INTERFACE EVAS_SIGNAL_INTERFACE_INTERFACE
#define EVAS_SMART_CLICKABLE_INTERFACE EVAS_CLICKABLE_INTERFACE_INTERFACE
#define EVAS_SMART_SCROLLABLE_INTERFACE EVAS_SCROLLABLE_INTERFACE_INTERFACE
#define EVAS_SMART_DRAGGABLE_INTERFACE EVAS_DRAGGABLE_INTERFACE_INTERFACE
#define EVAS_SMART_SELECTABLE_INTERFACE EVAS_SELECTABLE_INTERFACE_INTERFACE
#define EVAS_SMART_ZOOMABLE_INTERFACE EVAS_ZOOMABLE_INTERFACE_INTERFACE
#include "canvas/evas_canvas.eo.h"