"\n#endif /* _%s */\n"
#define C_HEADER \
- "#include <Edje.h>\n" \
- "#include <Evas.h>\n\n" \
- "#include <stdlib.h>\n\n"
+ "#include \"%s\"\n\n"
+
+#define C_CODEGEN_OBJECT_ADD \
+ "Evas_Object *\n" \
+ "%s_object_add(Evas *e, const char *file)\n" \
+ "{\n" \
+ " Evas_Object *o;\n\n" \
+ " o = edje_object_add(e);\n" \
+ " if (!o) return NULL;\n\n" \
+ " if (file)\n" \
+ " edje_object_file_set(o, file, \"%s\");\n" \
+ " else\n" \
+ " edje_object_file_set(o, \"%s\", \"%s\");\n\n" \
+ " return o;\n" \
+ "}\n\n"
+
+#define H_CODEGEN_OBJECT_ADD \
+ "/**\n * @brief Creates the Edje object and set the edj file\n" \
+ " * @param e The surface\n" \
+ " * @param file The path to edj, if NULL it's used the path given\n" \
+ " * to edje_codegen\n */\n" \
+ "Evas_Object * %s_object_add(Evas *e, const char *file);\n\n"
#define C_CODEGEN_PART_TEXT_SET \
"void\n" \
free(str);
- if (fwrite(C_HEADER, strlen(C_HEADER), 1, source_fd) != 1)
+ snprintf(buf, sizeof(buf), C_HEADER, filename);
+ if (fwrite(buf, strlen(buf), 1, source_fd) != 1)
return EINA_FALSE;
return EINA_TRUE;
}
static Eina_Bool
+_write_object_get(void)
+{
+ char buf[512];
+
+ snprintf(buf, sizeof(buf), H_CODEGEN_OBJECT_ADD, prefix);
+ if (fwrite(buf, strlen(buf), 1, header_fd) != 1)
+ return EINA_FALSE;
+
+ snprintf(buf, sizeof(buf), C_CODEGEN_OBJECT_ADD, prefix, group, file, group);
+ if (fwrite(buf, strlen(buf), 1, source_fd) != 1)
+ return EINA_FALSE;
+
+ return EINA_TRUE;
+}
+
+static Eina_Bool
_write_part(const char *apiname, const char *partname,
const char *parttype, const char *description)
{
{
Eina_Bool quit_option = EINA_FALSE;
char *source, *header;
- char aux[EINA_PATH_MAX];
int arg_index, ret = 0;
Ecore_Getopt_Value values[] = {
ECORE_GETOPT_VALUE_STR(prefix),
goto error_getopt;
}
+ if (!_write_object_get())
+ {
+ ERR("Could not write the object get, error %d (%s)",
+ errno, strerror(errno));
+ ret = 6;
+ goto error_getopt;
+ }
+
if (!_parse())
{
ERR("Could not parsing the EDJE");
- ret = 6;
+ ret = 7;
goto error_getopt;
}
{
ERR("Could not write the footer, error %d (%s)",
errno, strerror(errno));
- ret = 7;
+ ret = 8;
goto error_getopt;
}
{
ERR("Could not close the source files, error %d (%s)",
errno, strerror(errno));
- ret = 8;
+ ret = 9;
}
error_getopt: