From dd7595a3475407a7fa96a97393bae8c5220e8762 Mon Sep 17 00:00:00 2001 From: David Walter Seikel Date: Wed, 4 Jan 2012 18:41:13 +1000 Subject: Add the base Enlightenment Foundation Libraries - eina, eet, evas, ecore, embryo, and edje. Note that embryo wont be used, but I'm not sure yet if you can build edje without it. --- libraries/evas/src/lib/main.c | 150 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 150 insertions(+) create mode 100644 libraries/evas/src/lib/main.c (limited to 'libraries/evas/src/lib/main.c') diff --git a/libraries/evas/src/lib/main.c b/libraries/evas/src/lib/main.c new file mode 100644 index 0000000..f999889 --- /dev/null +++ b/libraries/evas/src/lib/main.c @@ -0,0 +1,150 @@ +#include "evas_common.h" +#include "evas_private.h" + +static Evas_Version _version = { VMAJ, VMIN, VMIC, VREV }; +EAPI Evas_Version *evas_version = &_version; + +int _evas_alloc_error = 0; +static int _evas_debug_init = 0; +static int _evas_debug_show = 0; +static int _evas_debug_abort = 0; + +EAPI Evas_Alloc_Error +evas_alloc_error(void) +{ + return _evas_alloc_error; +} + +/* free cached items only in ram for speed reasons. return 0 if can't free */ +int +evas_mem_free(int mem_required __UNUSED__) +{ + return 0; +} + +/* start reducing quality of images etc. return 0 if can't free anything */ +int +evas_mem_degrade(int mem_required __UNUSED__) +{ + return 0; +} + +void * +evas_mem_calloc(int size) +{ + void *ptr; + + ptr = calloc(1, size); + if (ptr) return ptr; + MERR_BAD(); + while ((!ptr) && (evas_mem_free(size))) ptr = calloc(1, size); + if (ptr) return ptr; + while ((!ptr) && (evas_mem_degrade(size))) ptr = calloc(1, size); + if (ptr) return ptr; + MERR_FATAL(); + return NULL; +} + +void +evas_debug_error(void) +{ + if (!_evas_debug_init) + { + if (getenv("EVAS_DEBUG_SHOW")) _evas_debug_show = 1; + if (getenv("EVAS_DEBUG_ABORT")) _evas_debug_abort = 1; + _evas_debug_init = 1; + } + if (_evas_debug_show) + CRIT("Evas Magic Check Failed!!!"); +} + +void +evas_debug_input_null(void) +{ + if (!_evas_debug_init) + { + if (getenv("EVAS_DEBUG_SHOW")) _evas_debug_show = 1; + if (getenv("EVAS_DEBUG_ABORT")) _evas_debug_abort = 1; + _evas_debug_init = 1; + } + if (_evas_debug_show) + CRIT("Input object pointer is NULL!"); + if (_evas_debug_abort) abort(); +} + +void +evas_debug_magic_null(void) +{ + if (!_evas_debug_init) + { + if (getenv("EVAS_DEBUG_SHOW")) _evas_debug_show = 1; + if (getenv("EVAS_DEBUG_ABORT")) _evas_debug_abort = 1; + _evas_debug_init = 1; + } + if (_evas_debug_show) + CRIT("Input object is zero'ed out (maybe a freed object or zero-filled RAM)!"); + if (_evas_debug_abort) abort(); +} + +void +evas_debug_magic_wrong(DATA32 expected, DATA32 supplied) +{ + if (!_evas_debug_init) + { + if (getenv("EVAS_DEBUG_SHOW")) _evas_debug_show = 1; + if (getenv("EVAS_DEBUG_ABORT")) _evas_debug_abort = 1; + _evas_debug_init = 1; + } + if (_evas_debug_show) + CRIT("Input object is wrong type\n" + " Expected: %08x - %s\n" + " Supplied: %08x - %s", + expected, evas_debug_magic_string_get(expected), + supplied, evas_debug_magic_string_get(supplied)); + if (_evas_debug_abort) abort(); +} + +void +evas_debug_generic(const char *str) +{ + if (!_evas_debug_init) + { + if (getenv("EVAS_DEBUG_SHOW")) _evas_debug_show = 1; + if (getenv("EVAS_DEBUG_ABORT")) _evas_debug_abort = 1; + _evas_debug_init = 1; + } + if (_evas_debug_show) + CRIT("%s", str); + if (_evas_debug_abort) abort(); +} + +const char * +evas_debug_magic_string_get(DATA32 magic) +{ + switch (magic) + { + case MAGIC_EVAS: + return "Evas"; + case MAGIC_OBJ: + return "Evas_Object"; + case MAGIC_OBJ_RECTANGLE: + return "Evas_Object (Rectangle)"; + case MAGIC_OBJ_LINE: + return "Evas_Object (Line)"; + case MAGIC_OBJ_POLYGON: + return "Evas_Object (Polygon)"; + case MAGIC_OBJ_IMAGE: + return "Evas_Object (Image)"; + case MAGIC_OBJ_TEXT: + return "Evas_Object (Text)"; + case MAGIC_OBJ_SMART: + return "Evas_Object (Smart)"; + case MAGIC_EVAS_GL: + return "Evas_GL"; + case MAGIC_MAP: + return "Evas_Map"; + default: + return ""; + }; + return ""; +} -- cgit v1.1