efl: Add Efl.Version struct and APIs

The original idea behind knowing the app's version of EFL is not
a great story. It comes from the fact that some bugs exist in
earlier versions of EFL, and some things need to be fixed. But
those fixes may break behaviour for older apps. This patch is
opening the way to the slippery slope of bug compatibility.

Unfortunately this is a requirement if we want to be able to move
forward and not break apps when we fix bugs (behaviour or ABI).

I hope we will not need to implement too many (if any) workaround
such issues. For now, this will only be used as debugging info.

EFL_MAIN() and ELM_MAIN() will both set the app's EFL version
automatically at startup time. Some internal helpers can be added
later to check how the app build-time and run-time version of
EFL differ.

@feature
This commit is contained in:
Jean-Philippe Andre 2016-06-29 11:49:24 +09:00
parent a73e51136f
commit 45cd0465a4
5 changed files with 90 additions and 0 deletions

View File

@ -50,6 +50,13 @@ EAPI int ecore_init(void);
*/
EAPI int ecore_shutdown(void);
/**
* @brief Inform EFL of the version this application was built for.
*
* This is transparently called from $EFL_MAIN().
*/
EWAPI void efl_build_version_set(int vmaj, int vmin, int vmic, int revision, const char *flavor, const char *build_id);
/**
* @}
*/

View File

@ -3033,4 +3033,44 @@ _efl_loop_unregister(Eo *obj EINA_UNUSED, Efl_Loop_Data *pd, const Eo_Class *kla
return eina_hash_del(pd->providers, &klass, provider);
}
Efl_Version _app_efl_version = { 0, 0, 0, 0, NULL, NULL };
EWAPI void
efl_build_version_set(int vmaj, int vmin, int vmic, int revision,
const char *flavor, const char *build_id)
{
// note: EFL has not been initialized yet at this point (ie. no eina call)
_app_efl_version.major = vmaj;
_app_efl_version.minor = vmin;
_app_efl_version.micro = vmic;
_app_efl_version.revision = revision;
free((char *) _app_efl_version.flavor);
free((char *) _app_efl_version.build_id);
_app_efl_version.flavor = flavor ? strdup(flavor) : NULL;
_app_efl_version.build_id = build_id ? strdup(build_id) : NULL;
}
EOLIAN static const Efl_Version *
_efl_loop_app_efl_version_get(Eo *obj EINA_UNUSED, Efl_Loop_Data *pd EINA_UNUSED)
{
return &_app_efl_version;
}
EOLIAN static const Efl_Version *
_efl_loop_efl_version_get(Eo *obj EINA_UNUSED, Efl_Loop_Data *pd EINA_UNUSED)
{
/* vanilla EFL: flavor = NULL */
static const Efl_Version version = {
.major = VMAJ,
.minor = VMIN,
.micro = VMIC,
.revision = VREV,
.build_id = EFL_BUILD_ID,
.flavor = NULL
};
return &version;
}
#include "efl_loop.eo.c"

View File

@ -365,6 +365,7 @@ GENERIC_ALLOC_FREE_HEADER(Ecore_Win32_Handler, ecore_win32_handler);
extern Eo *_mainloop_singleton;
extern Eo *_ecore_parent;
extern Efl_Version _app_efl_version;
#define ECORE_PARENT_CLASS ecore_parent_class_get()
EAPI const Eo_Class *ecore_parent_class_get(void) EINA_CONST;

View File

@ -1,3 +1,5 @@
import efl_types;
struct Efl.Loop.Arguments {
argv: const(array<const(stringshare)>);
}
@ -22,6 +24,26 @@ class Efl.Loop (Eo.Base)
main_loop: Efl.Loop;
}
}
@property app_efl_version {
[[Indicates the version of EFL with which this application was compiled.
This might differ from @.efl_version.
]]
get {}
values {
version: const(Efl.Version)*;
}
}
@property efl_version {
[[Indicates the currently running version of EFL.
This might differ from @.app_efl_version.
]]
get {}
values {
version: const(Efl.Version)*;
}
}
iterate {
[[Runs a single iteration of the main loop to process everything on the
queue.]]

View File

@ -18,3 +18,23 @@ struct @extern Efl.Time
tm_yday: int; [[Days in year.[0-365] ]]
tm_isdst: int; [[DST. [-1/0/1] ]]
}
struct Efl.Version
{
[[This type describes the version of EFL with an optional variant.
This may be used to query the current running version of EFL. Or it can
be passed by applications at startup time to inform EFL of the version
a certain application was built for.
@since 1.18
]]
major: int; [[Major component of the version (>= 1).]]
minor: int; [[Minor component of the version (>= 0).]]
micro: int; [[Micro component of the version (>= 0).]]
revision: int; [[Revision component of the version (>= 0).]]
flavor: string; [[Special version string for this build of EFL, $null for
vanilla (upstream) EFL. Contains $EFL_VERSION_FLAVOR.]]
build_id: string; [[Contains $EFL_BUILD_ID.]]
}