efl: move mmap API to be part of Efl_File class.

This commit is contained in:
Cedric BAIL 2015-04-03 16:23:13 +02:00
parent 28257ec8fe
commit c2e75544e1
12 changed files with 204 additions and 120 deletions

View File

@ -212,5 +212,42 @@ Edje object
*/
EAPI void edje_object_file_get(const Eo *obj, const char **file, const char **group);
/**
*
* @brief Sets the @b EDJ file (and group within it) to load an Edje
* object's contents from
*
* @return @c EINA_TRUE, on success or @c EINA_FALSE, on errors (check
* edje_object_load_error_get() after this call to get errors causes)
*
* Edje expects EDJ files, which are theming objects' descriptions and
* resources packed together in an EET file, to read Edje object
* definitions from. They usually are created with the @c .edj
* extension. EDJ files, in turn, are assembled from @b textual object
* description files, where one describes Edje objects declaratively
* -- the EDC files (see @ref edcref "the syntax" for those files).
*
* Those description files were designed so that many Edje object
* definitions -- also called @b groups (or collections) -- could be
* packed together <b>in the same EDJ file</b>, so that a whole
* application's theme could be packed in one file only. This is the
* reason for the @p group argument.
*
* Use this function after you instantiate a new Edje object, so that
* you can "give him life", telling where to get its contents from.
*
* @see edje_object_add()
* @see edje_object_file_get()
* @see edje_object_mmap_set()
* @since 1.8
*
* @param[in] file The Eina.File pointing to the EDJ file to load @p from
* @param[in] group The name of the group, in @p file, which implements an
Edje object
*/
EAPI Eina_Bool edje_object_mmap_set(Eo *obj, const Eina_File *file, const char *group);
#include "edje_object.eo.legacy.h"
#include "edje_edit.eo.legacy.h"

View File

@ -182,43 +182,6 @@ class Edje.Object (Evas.Smart_Clipped, Efl.File)
that means the edc file is made based on scale 1.0. */
}
}
mmap {
set {
/*@
@brief Sets the @b EDJ file (and group within it) to load an Edje
object's contents from
@return @c EINA_TRUE, on success or @c EINA_FALSE, on errors (check
edje_object_load_error_get() after this call to get errors causes)
Edje expects EDJ files, which are theming objects' descriptions and
resources packed together in an EET file, to read Edje object
definitions from. They usually are created with the @c .edj
extension. EDJ files, in turn, are assembled from @b textual object
description files, where one describes Edje objects declaratively
-- the EDC files (see @ref edcref "the syntax" for those files).
Those description files were designed so that many Edje object
definitions -- also called @b groups (or collections) -- could be
packed together <b>in the same EDJ file</b>, so that a whole
application's theme could be packed in one file only. This is the
reason for the @p group argument.
Use this function after you instantiate a new Edje object, so that
you can "give him life", telling where to get its contents from.
@see edje_object_add()
@see edje_object_file_get()
@see edje_object_mmap_set()
@since 1.8 */
return: bool;
}
values {
const(Eina.File)* file; /*@ The Eina.File pointing to the EDJ file to load @p from */
const(char)* group; /*@ The name of the group, in @p file, which implements an
Edje object */
}
}
text_change_cb {
set {
/*@
@ -2414,5 +2377,7 @@ class Edje.Object (Evas.Smart_Clipped, Efl.File)
Evas.Object_Smart.resize;
Efl.File.file.set;
Efl.File.file.get;
Efl.File.mmap.set;
Efl.File.mmap.get;
}
}

View File

@ -337,7 +337,8 @@ _edje_object_efl_file_file_set(Eo *obj, Edje *_pd EINA_UNUSED, const char *file,
}
EOLIAN static Eina_Bool
_edje_object_mmap_set(Eo *obj, Edje *_pd EINA_UNUSED, const Eina_File *f, const char *group)
_edje_object_efl_file_mmap_set(Eo *obj, Edje *pd EINA_UNUSED,
const Eina_File *f, const char *key)
{
Eina_Bool ret;
Eina_Array *nested;
@ -346,7 +347,7 @@ _edje_object_mmap_set(Eo *obj, Edje *_pd EINA_UNUSED, const Eina_File *f, const
nested = eina_array_new(8);
if (_edje_object_file_set_internal(obj, f, group, NULL, NULL, nested))
if (_edje_object_file_set_internal(obj, f, key, NULL, NULL, nested))
ret = EINA_TRUE;
eina_array_free(nested);
@ -355,6 +356,22 @@ _edje_object_mmap_set(Eo *obj, Edje *_pd EINA_UNUSED, const Eina_File *f, const
return ret;
}
EOLIAN static void
_edje_object_efl_file_mmap_get(Eo *obj EINA_UNUSED, Edje *pd,
const Eina_File **f, const char **key)
{
if (f) *f = pd->file->f;
if (key) *key = pd->group;
}
EAPI Eina_Bool
edje_object_mmap_set(Edje_Object *obj, const Eina_File *file, const char *group)
{
Eina_Bool ret;
return eo_do_ret((Edje_Object *)obj, ret, efl_file_mmap_set(file, group));
}
EAPI Eina_Bool
edje_object_file_set(Eo *obj, const char *file, const char *group)
{
@ -370,4 +387,3 @@ edje_object_file_get(const Eo *obj, const char **file, const char **group)
}
#include "edje_object.eo.c"

View File

@ -1,6 +1,37 @@
interface Efl.File {
legacy_prefix: null;
properties {
mmap {
set {
/*@
Set the source mmaped file from where an image object must fetch the real
image data (it must be an Eina_File).
If the file supports multiple data stored in it (as Eet files do),
you can specify the key to be used as the index of the image in
this file.
@since 1.8 */
return: bool;
}
get {
/*@
Get the source mmaped file from where an image object must fetch the real
image data (it must be an Eina_File).
If the file supports multiple data stored in it (as Eet files do),
you can get the key to be used as the index of the image in
this file.
@since 1.10 */
}
values {
const(Eina.File)* f; /*@ The mmaped file */
const(char)* key; /*@ The image key in @p file (if its an Eet one), or @c
NULL, otherwise. */
}
}
file {
set {
/*@

View File

@ -1576,6 +1576,40 @@ NULL, otherwise.
*/
EAPI void evas_object_image_file_get(const Eo *obj, const char **file, const char **key);
/**
*
* Set the source mmaped file from where an image object must fetch the real
* image data (it must be an Eina_File).
*
* If the file supports multiple data stored in it (as Eet files do),
* you can specify the key to be used as the index of the image in
* this file.
*
* @since 1.8
*
* @param[in] f The mmaped file
* @param[in] key The image key in @p file (if its an Eet one), or @c
NULL, otherwise.
*/
EAPI void evas_object_image_mmap_set(Eo *obj, const Eina_File *f, const char *key);
/**
*
* Get the source mmaped file from where an image object must fetch the real
* image data (it must be an Eina_File).
*
* If the file supports multiple data stored in it (as Eet files do),
* you can get the key to be used as the index of the image in
* this file.
*
* @since 1.10
*
* @param[out] f The mmaped file
* @param[out] key The image key in @p file (if its an Eet one), or @c
NULL, otherwise.
*/
EAPI void evas_object_image_mmap_get(const Eo *obj, const Eina_File **f, const char **key);
/**
*
* Save the given image object's contents to an (image) file.

View File

@ -840,16 +840,39 @@ _evas_3d_mesh_alpha_test_enable_get(Eo *obj EINA_UNUSED, Evas_3D_Mesh_Data *pd)
return pd->alpha_test_enabled;
}
EOLIAN static void
_evas_3d_mesh_mmap_set(Eo *obj, Evas_3D_Mesh_Data *pd,
Eina_File *file, const char *key EINA_UNUSED)
EOLIAN static Eina_Bool
_evas_3d_mesh_efl_file_mmap_set(Eo *obj,
Evas_3D_Mesh_Data *pd,
const Eina_File *f, const char *key EINA_UNUSED)
{
_mesh_fini(pd);
_mesh_init(pd);
if (file == NULL) return;
if (f == NULL) return EINA_FALSE;
evas_common_load_model_from_eina_file(obj, file);
evas_common_load_model_from_eina_file(obj, f);
return EINA_TRUE;
}
EOLIAN static void
_evas_3d_mesh_efl_file_mmap_get(Eo *obj EINA_UNUSED,
Evas_3D_Mesh_Data *pd EINA_UNUSED,
const Eina_File **f EINA_UNUSED,
const char **key EINA_UNUSED)
{
#warning "mmap get is not implemented on Evas_3D_Mesh."
ERR("mmap get is not implemented !");
}
EOLIAN static void
_evas_3d_mesh_efl_file_file_get(Eo *obj EINA_UNUSED,
Evas_3D_Mesh_Data *pd EINA_UNUSED,
const char **file EINA_UNUSED,
const char **key EINA_UNUSED)
{
#warning "file get is not implemented on Evas_3D_Mesh."
ERR("file get is not implemented !");
}
EOLIAN static Eina_Bool

View File

@ -4,21 +4,6 @@ class Evas_3D_Mesh (Evas_3D_Object, Evas.Common_Interface, Efl.File)
data: Evas_3D_Mesh_Data;
methods {
mmap_set {
/**
* Load mesh data from Eina_File.
*
* Loading a mesh from existing Eina_File is supported. Currently, only MD2, OBJ,
* PLY and EET file formats are supported.
*
* @ingroup Evas_3D_Mesh
*/
params {
@in Eina_File* file; /*@ Eina_File with mesh data. */
@in const(char)* key; /*@ Key in the mesh file. */
}
}
frame_vertex_data_set {
/*@
Set the vertex data of the key frame of the given mesh.
@ -540,6 +525,9 @@ class Evas_3D_Mesh (Evas_3D_Object, Evas.Common_Interface, Efl.File)
Evas_3D_Object.update_notify;
Evas_3D_Object.change_notify;
Efl.File.file.set;
Efl.File.file.get;
Efl.File.mmap.set;
Efl.File.mmap.get;
Efl.File.save;
}

View File

@ -663,35 +663,6 @@ class Evas.Image (Evas.Object, Efl.File, Efl.Image)
void *data; /*@ The data pointer to be passed to @a func. */
}
}
mmap {
set {
/*@
Set the source mmaped file from where an image object must fetch the real
image data (it must be an Eina_File).
If the file supports multiple data stored in it (as Eet files do),
you can specify the key to be used as the index of the image in
this file.
@since 1.8 */
}
get {
/*@
Get the source mmaped file from where an image object must fetch the real
image data (it must be an Eina_File).
If the file supports multiple data stored in it (as Eet files do),
you can get the key to be used as the index of the image in
this file.
@since 1.10 */
}
values {
const(Eina.File)* f; /*@ The mmaped file */
const(char)* key; /*@ The image key in @p file (if its an Eet one), or @c
NULL, otherwise. */
}
}
data_copy {
set {
/*@
@ -1094,6 +1065,8 @@ class Evas.Image (Evas.Object, Efl.File, Efl.Image)
Eo.Base.dbg_info_get;
Efl.File.file.set;
Efl.File.file.get;
Efl.File.mmap.set;
Efl.File.mmap.get;
Efl.File.save;
Efl.Image.animated.get;
Efl.Image.load_size.set;

View File

@ -412,7 +412,7 @@ evas_object_image_memfile_set(Evas_Object *eo_obj, void *data, int size, char *f
f = eina_file_virtualize(NULL, data, size, EINA_TRUE);
if (!f) return ;
eo_do(eo_obj, evas_obj_image_mmap_set(f, key));
eo_do(eo_obj, efl_file_mmap_set(f, key));
eina_file_close(f);
}
@ -544,8 +544,10 @@ _image_done_set(Eo *eo_obj, Evas_Object_Protected_Data *obj, Evas_Image_Data *o)
evas_object_change(eo_obj, obj);
}
EOLIAN static void
_evas_image_mmap_set(Eo *eo_obj, Evas_Image_Data *o, const Eina_File *f, const char *key)
EOLIAN static Eina_Bool
_evas_image_efl_file_mmap_set(Eo *eo_obj,
Evas_Image_Data *o,
const Eina_File *f, const char *key)
{
Evas_Object_Protected_Data *obj = eo_data_scope_get(eo_obj, EVAS_OBJECT_CLASS);
Evas_Image_Load_Opts lo;
@ -553,18 +555,22 @@ _evas_image_mmap_set(Eo *eo_obj, Evas_Image_Data *o, const Eina_File *f, const c
if (o->cur->u.f == f)
{
if ((!o->cur->key) && (!key))
return;
return EINA_FALSE;
if ((o->cur->key) && (key) && (!strcmp(o->cur->key, key)))
return;
return EINA_FALSE;
}
evas_object_async_block(obj);
_image_init_set(f, NULL, key, eo_obj, obj, o, &lo);
o->engine_data = ENFN->image_mmap(ENDT, o->cur->u.f, o->cur->key, &o->load_error, &lo);
_image_done_set(eo_obj, obj, o);
return EINA_TRUE;
}
EOLIAN static void
_evas_image_mmap_get(Eo *eo_obj EINA_UNUSED, Evas_Image_Data *o, const Eina_File **f, const char **key)
_evas_image_efl_file_mmap_get(Eo *eo_obj EINA_UNUSED,
Evas_Image_Data *o,
const Eina_File **f, const char **key)
{
if (f)
*f = o->cur->mmaped_source ? o->cur->u.f : NULL;
@ -4915,6 +4921,17 @@ evas_object_image_file_get(const Eo *obj, const char **file, const char **key)
eo_do((Eo *) obj, efl_file_get(file, key));
}
EAPI void
evas_object_image_mmap_set(Evas_Image *obj, const Eina_File *f, const char *key)
{
eo_do((Evas_Image *)obj, efl_file_mmap_set(f, key));
}
EAPI void
evas_object_image_mmap_get(const Evas_Image *obj, const Eina_File **f, const char **key)
{
eo_do((Evas_Image *)obj, efl_file_mmap_get(f, key));
}
EAPI Eina_Bool
evas_object_image_save(const Eo *obj, const char *file, const char *key, const char *flags)

View File

@ -65,7 +65,7 @@ evas_common_load_model_from_file(Evas_3D_Mesh *model, const char *file)
}
void
evas_common_load_model_from_eina_file(Evas_3D_Mesh *model, Eina_File *file)
evas_common_load_model_from_eina_file(Evas_3D_Mesh *model, const Eina_File *file)
{
Eina_File *e_file = eina_file_dup(file);

View File

@ -1703,7 +1703,7 @@ void _evas_3d_eet_file_free(void);
/* Temporary save/load functions */
void evas_common_load_model_from_file(Evas_3D_Mesh *model, const char *file);
void evas_common_load_model_from_eina_file(Evas_3D_Mesh *model, Eina_File *file);
void evas_common_load_model_from_eina_file(Evas_3D_Mesh *model, const Eina_File *file);
void evas_common_save_model_to_file(Evas_3D_Mesh *model, const char *file, Evas_3D_Mesh_Frame *f);
void evas_model_load_file_eet(Evas_3D_Mesh *mesh, Eina_File *file);
void evas_model_load_file_md2(Evas_3D_Mesh *mesh, Eina_File *file);

View File

@ -34,29 +34,29 @@
src2 += f2->vertices[a].element_count; \
}
#define CHECK_MESHES_IN_FOLDER(folder, ext) \
it = eina_file_direct_ls(folder); \
EINA_ITERATOR_FOREACH(it, file) \
{ \
mesh = eo_add(EVAS_3D_MESH_CLASS, e); \
mesh2 = eo_add(EVAS_3D_MESH_CLASS, e); \
fail_if(mesh == NULL); \
fail_if(mesh2 == NULL); \
snprintf(buffer, PATH_MAX, "%s", ext); \
eo_do(mesh, efl_file_set(file->path, NULL), \
efl_file_save(buffer, NULL, NULL)); \
eo_do(mesh2, efl_file_set(buffer, NULL)); \
res = _compare_meshes(mesh, mesh2); \
fail_if(res == 1); \
eo_do(mesh, evas_3d_mesh_mmap_set(eina_file_open(file->path, 0), NULL), \
efl_file_save(buffer, NULL, NULL)); \
eo_do(mesh2, evas_3d_mesh_mmap_set(eina_file_open(buffer, 0), NULL)); \
res = _compare_meshes(mesh, mesh2); \
fail_if(res == 1); \
eo_del(mesh2); \
eo_del(mesh); \
unlink(buffer); \
}
#define CHECK_MESHES_IN_FOLDER(folder, ext) \
it = eina_file_direct_ls(folder); \
EINA_ITERATOR_FOREACH(it, file) \
{ \
mesh = eo_add(EVAS_3D_MESH_CLASS, e); \
mesh2 = eo_add(EVAS_3D_MESH_CLASS, e); \
fail_if(mesh == NULL); \
fail_if(mesh2 == NULL); \
snprintf(buffer, PATH_MAX, "%s", ext); \
eo_do(mesh, efl_file_set(file->path, NULL), \
efl_file_save(buffer, NULL, NULL)); \
eo_do(mesh2, efl_file_set(buffer, NULL)); \
res = _compare_meshes(mesh, mesh2); \
fail_if(res == 1); \
eo_do(mesh, efl_file_mmap_set(eina_file_open(file->path, 0), NULL), \
efl_file_save(buffer, NULL, NULL)); \
eo_do(mesh2, efl_file_mmap_set(eina_file_open(buffer, 0), NULL)); \
res = _compare_meshes(mesh, mesh2); \
fail_if(res == 1); \
eo_del(mesh2); \
eo_del(mesh); \
unlink(buffer); \
}
static Evas_3D_Mesh_Frame *
return_zero_frame(Evas_3D_Mesh_Data *pd)