summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2013-11-27 17:46:38 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2013-11-27 17:46:38 +0100
commit746222bf34211e4d7fd1a8c804fea82fe6041bff (patch)
tree0c6d598a22fb4dd9375c6f3aa8d384b8bd0416f2
parentfeb319cf7f627986032e3f70e2f1c35aac645346 (diff)
downloadeo_tokenizer-746222bf34211e4d7fd1a8c804fea82fe6041bff.zip
eo_tokenizer-746222bf34211e4d7fd1a8c804fea82fe6041bff.tar.gz
extract eo_definitionts from eo_tokenizer
-rw-r--r--eo_definitions.c100
-rw-r--r--eo_definitions.h91
-rw-r--r--eo_tokenizer.h72
-rw-r--r--eo_tokenizer.rl98
4 files changed, 194 insertions, 167 deletions
diff --git a/eo_definitions.c b/eo_definitions.c
new file mode 100644
index 0000000..760337f
--- /dev/null
+++ b/eo_definitions.c
@@ -0,0 +1,100 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "eo_definitions.h"
+
+void
+eo_definitions_ret_free(Eo_Ret_Def *ret)
+{
+ if (ret->type) eina_stringshare_del(ret->type);
+ if (ret->comment) eina_stringshare_del(ret->comment);
+ /* do not free */
+}
+
+void
+eo_definitions_param_free(Eo_Param_Def *param)
+{
+ if (param->type) eina_stringshare_del(param->type);
+ if (param->name) eina_stringshare_del(param->name);
+ if (param->comment) eina_stringshare_del(param->comment);
+ free(param);
+}
+
+void
+eo_definitions_accessor_free(Eo_Accessor_Def *accessor)
+{
+ const char *s;
+ Eina_List *l;
+
+ if (accessor->comment)
+ eina_stringshare_del(accessor->comment);
+
+ EINA_LIST_FOREACH(accessor->legacies, l, s)
+ if (s) eina_stringshare_del(s);
+
+ eo_definitions_ret_free(&accessor->ret);
+
+ free(accessor);
+}
+
+void
+eo_definitions_property_def_free(Eo_Property_Def *prop)
+{
+ Eo_Param_Def *param;
+ Eo_Accessor_Def *accessor;
+
+ if (prop->name)
+ eina_stringshare_del(prop->name);
+
+ EINA_LIST_FREE(prop->params, param)
+ eo_definitions_param_free(param);
+
+ EINA_LIST_FREE(prop->accessors, accessor)
+ eo_definitions_accessor_free(accessor);
+
+ free(prop);
+}
+
+void
+eo_definitions_method_def_free(Eo_Method_Def *meth)
+{
+ Eo_Param_Def *param;
+
+ eo_definitions_ret_free(&meth->ret);
+
+ if (meth->name)
+ eina_stringshare_del(meth->name);
+ if (meth->comment)
+ eina_stringshare_del(meth->comment);
+
+ EINA_LIST_FREE(meth->params, param)
+ eo_definitions_param_free(param);
+
+ free(meth);
+}
+
+void
+eo_definitions_class_def_free(Eo_Class_Def *kls)
+{
+ const char *s;
+ Eina_List *l;
+ Eo_Property_Def *prop;
+ Eo_Method_Def *meth;
+
+ if (kls->name)
+ eina_stringshare_del(kls->name);
+ if (kls->comment)
+ eina_stringshare_del(kls->comment);
+
+ EINA_LIST_FOREACH(kls->inherits, l, s)
+ if (s) eina_stringshare_del(s);
+
+ EINA_LIST_FREE(kls->properties, prop)
+ eo_definitions_property_def_free(prop);
+
+ EINA_LIST_FREE(kls->methods, meth)
+ eo_definitions_method_def_free(meth);
+
+ free(kls);
+}
+
diff --git a/eo_definitions.h b/eo_definitions.h
new file mode 100644
index 0000000..844717e
--- /dev/null
+++ b/eo_definitions.h
@@ -0,0 +1,91 @@
+#ifndef __EO_DEFINITIONS_H__
+#define __EO_DEFINITIONS_H__
+
+#include <Eina.h>
+
+/* RET */
+
+typedef struct _eo_ret_def
+{
+ const char *type;
+ const char *comment;
+} Eo_Ret_Def;
+
+/* PARAM */
+
+typedef enum _param_way
+{
+ IN,
+ OUT,
+ INOUT,
+ PARAM_WAY_LAST
+} Param_Way;
+
+typedef struct _eo_param_def
+{
+ Param_Way way;
+ const char *type;
+ const char *name;
+ const char *comment;
+} Eo_Param_Def;
+
+/* ACCESSOR */
+
+typedef enum _eo_accessor_type
+{
+ SETTER,
+ GETTER,
+ ACCESSOR_TYPE_LAST
+} Eo_Accessor_Type;
+
+typedef struct _eo_accessor_def
+{
+ Eo_Accessor_Type type;
+ Eo_Ret_Def ret;
+ const char *comment;
+ Eina_List *legacies;
+} Eo_Accessor_Def;
+
+/* PROPERTY */
+
+typedef struct _eo_property_def
+{
+ const char *name;
+ Eina_List *params;
+ Eina_List *accessors;
+} Eo_Property_Def;
+
+/* METHOD */
+
+typedef struct _eo_method_def
+{
+ Eo_Ret_Def ret;
+ const char *name;
+ const char *comment;
+ Eina_List *params;
+} Eo_Method_Def;
+
+/* CLASS */
+
+typedef struct _eo_class_def
+{
+ const char *name;
+ const char *comment;
+ Eina_List *inherits;
+ Eina_List *properties;
+ Eina_List *methods;
+} Eo_Class_Def;
+
+void eo_definitions_ret_free(Eo_Ret_Def *ret);
+
+void eo_definitions_param_free(Eo_Param_Def *param);
+
+void eo_definitions_accessor_free(Eo_Accessor_Def *accessor);
+
+void eo_definitions_property_def_free(Eo_Property_Def *prop);
+
+void eo_definitions_method_def_free(Eo_Method_Def *prop);
+
+void eo_definitions_class_def_free(Eo_Class_Def *kls);
+
+#endif /* __EO_DEFINITIONS_H__ */
diff --git a/eo_tokenizer.h b/eo_tokenizer.h
index 6efd2d6..c349a6d 100644
--- a/eo_tokenizer.h
+++ b/eo_tokenizer.h
@@ -2,6 +2,7 @@
#define __EO_TOKENIZER_H__
#include <Eina.h>
+#include "eo_definitions.h"
extern int _eo_tokenizer_log_dom;
#undef EINA_LOG_DOMAIN_DEFAULT
@@ -32,77 +33,6 @@ extern int _eo_tokenizer_log_dom;
#endif
#define DBG(...) EINA_LOG_DOM_DBG(_eo_tokenizer_log_dom, __VA_ARGS__)
-/* RET */
-
-typedef struct _eo_ret_def
-{
- const char *type;
- const char *comment;
-} Eo_Ret_Def;
-
-/* PARAMS */
-
-typedef enum _param_way
-{
- IN,
- OUT,
- INOUT,
- PARAM_WAY_LAST
-} Param_Way;
-
-typedef struct _eo_param_def
-{
- Param_Way way;
- const char *type;
- const char *name;
- const char *comment;
-} Eo_Param_Def;
-
-/* PROPERTIES */
-
-typedef enum _eo_accessor_type
-{
- SETTER,
- GETTER,
- ACCESSOR_TYPE_LAST
-} Eo_Accessor_Type;
-
-typedef struct _eo_accessor_def
-{
- Eo_Accessor_Type type;
- Eo_Ret_Def ret;
- const char *comment;
- Eina_List *legacies;
-} Eo_Accessor_Def;
-
-typedef struct _eo_property_def
-{
- const char *name;
- Eina_List *params;
- Eina_List *accessors;
-} Eo_Property_Def;
-
-/* METHODS */
-
-typedef struct _eo_method_def
-{
- Eo_Ret_Def ret;
- const char *name;
- const char *comment;
- Eina_List *params;
-} Eo_Method_Def;
-
-/* CLASSES */
-
-typedef struct _eo_class_def
-{
- const char *name;
- const char *comment;
- Eina_List *inherits;
- Eina_List *properties;
- Eina_List *methods;
-} Eo_Class_Def;
-
/* TOKENIZER */
#define BUFSIZE 256
diff --git a/eo_tokenizer.rl b/eo_tokenizer.rl
index a80dfc5..7235c0e 100644
--- a/eo_tokenizer.rl
+++ b/eo_tokenizer.rl
@@ -565,103 +565,9 @@ eo_tokenizer_dump(Eo_Tokenizer *toknz)
printf("\n");
}
}
- }
-
-}
-
-static void
-_eo_tokenizer_ret_free(Eo_Ret_Def *ret)
-{
- if (ret->type) eina_stringshare_del(ret->type);
- if (ret->comment) eina_stringshare_del(ret->comment);
- /* do not free */
-}
-
-static void
-_eo_tokenizer_param_free(Eo_Param_Def *param)
-{
- if (param->type) eina_stringshare_del(param->type);
- if (param->name) eina_stringshare_del(param->name);
- if (param->comment) eina_stringshare_del(param->comment);
- free(param);
-}
-
-static void
-_eo_tokenizer_accessor_free(Eo_Accessor_Def *accessor)
-{
- const char *s;
- Eina_List *l;
-
- if (accessor->comment)
- eina_stringshare_del(accessor->comment);
-
- EINA_LIST_FOREACH(accessor->legacies, l, s)
- if (s) eina_stringshare_del(s);
-
- _eo_tokenizer_ret_free(&accessor->ret);
-
- free(accessor);
-}
-
-static void
-_eo_tokenizer_property_def_free(Eo_Property_Def *prop)
-{
- Eo_Param_Def *param;
- Eo_Accessor_Def *accessor;
-
- if (prop->name)
- eina_stringshare_del(prop->name);
-
- EINA_LIST_FREE(prop->params, param)
- _eo_tokenizer_param_free(param);
-
- EINA_LIST_FREE(prop->accessors, accessor)
- _eo_tokenizer_accessor_free(accessor);
-
- free(prop);
-}
-
-static void
-_eo_tokenizer_method_def_free(Eo_Method_Def *meth)
-{
- Eo_Param_Def *param;
-
- _eo_tokenizer_ret_free(&meth->ret);
-
- if (meth->name)
- eina_stringshare_del(meth->name);
- if (meth->comment)
- eina_stringshare_del(meth->comment);
- EINA_LIST_FREE(meth->params, param)
- _eo_tokenizer_param_free(param);
-
- free(meth);
-}
-
-static void
-_eo_tokenizer_class_def_free(Eo_Class_Def *kls)
-{
- const char *s;
- Eina_List *l;
- Eo_Property_Def *prop;
- Eo_Method_Def *meth;
-
- if (kls->name)
- eina_stringshare_del(kls->name);
- if (kls->comment)
- eina_stringshare_del(kls->comment);
-
- EINA_LIST_FOREACH(kls->inherits, l, s)
- if (s) eina_stringshare_del(s);
-
- EINA_LIST_FREE(kls->properties, prop)
- _eo_tokenizer_property_def_free(prop);
-
- EINA_LIST_FREE(kls->methods, meth)
- _eo_tokenizer_method_def_free(meth);
+ }
- free(kls);
}
void
@@ -673,7 +579,7 @@ eo_tokenizer_free(Eo_Tokenizer *toknz)
eina_stringshare_del(toknz->source);
EINA_LIST_FREE(toknz->classes, kls)
- _eo_tokenizer_class_def_free(kls);
+ eo_definitions_class_def_free(kls);
free(toknz);
}