1 #include "evas_common.h"
2 #include "evas_private.h"
4 static Evas_Version _version = { VMAJ, VMIN, VMIC, VREV };
5 EAPI Evas_Version *evas_version = &_version;
7 int _evas_alloc_error = 0;
8 static int _evas_debug_init = 0;
13 } _evas_debug_show = _EVAS_DEBUG_DEFAULT;
14 static int _evas_debug_abort = 0;
17 evas_alloc_error(void)
19 return _evas_alloc_error;
22 /* free cached items only in ram for speed reasons. return 0 if can't free */
24 evas_mem_free(int mem_required __UNUSED__)
29 /* start reducing quality of images etc. return 0 if can't free anything */
31 evas_mem_degrade(int mem_required __UNUSED__)
37 evas_mem_calloc(int size)
41 ptr = calloc(1, size);
44 while ((!ptr) && (evas_mem_free(size))) ptr = calloc(1, size);
46 while ((!ptr) && (evas_mem_degrade(size))) ptr = calloc(1, size);
53 _evas_debug_init_from_env()
55 const char *tmp = getenv("EVAS_DEBUG_SHOW");
58 int dbgshow = atoi(tmp);
59 _evas_debug_show = (dbgshow) ? _EVAS_DEBUG_SHOW : _EVAS_DEBUG_HIDE;
61 if (getenv("EVAS_DEBUG_ABORT")) _evas_debug_abort = 1;
66 evas_debug_error(void)
68 if (!_evas_debug_init)
70 _evas_debug_init_from_env();
72 if (_evas_debug_show == _EVAS_DEBUG_SHOW)
73 CRIT("Evas Magic Check Failed!!!");
77 evas_debug_input_null(void)
79 if (!_evas_debug_init)
81 _evas_debug_init_from_env();
83 if (_evas_debug_show == _EVAS_DEBUG_SHOW)
84 CRIT("Input object pointer is NULL!");
85 if (_evas_debug_abort) abort();
89 evas_debug_magic_null(void)
91 if (!_evas_debug_init)
93 _evas_debug_init_from_env();
95 if ((_evas_debug_show == _EVAS_DEBUG_SHOW) ||
96 (_evas_debug_show == _EVAS_DEBUG_DEFAULT))
97 CRIT("Input object is zero'ed out (maybe a freed object or zero-filled RAM)!");
98 if (_evas_debug_abort) abort();
102 evas_debug_magic_wrong(DATA32 expected, DATA32 supplied)
104 if (!_evas_debug_init)
106 _evas_debug_init_from_env();
108 if ((_evas_debug_show == _EVAS_DEBUG_SHOW) ||
109 (_evas_debug_show == _EVAS_DEBUG_DEFAULT))
110 CRIT("Input object is wrong type\n"
111 " Expected: %08x - %s\n"
112 " Supplied: %08x - %s",
113 expected, evas_debug_magic_string_get(expected),
114 supplied, evas_debug_magic_string_get(supplied));
115 if (_evas_debug_abort) abort();
119 evas_debug_generic(const char *str)
121 if (!_evas_debug_init)
123 _evas_debug_init_from_env();
125 if ((_evas_debug_show == _EVAS_DEBUG_SHOW) ||
126 (_evas_debug_show == _EVAS_DEBUG_DEFAULT))
128 if (_evas_debug_abort) abort();
132 evas_debug_magic_string_get(DATA32 magic)
139 return "Evas_Object";
140 case MAGIC_OBJ_RECTANGLE:
141 return "Evas_Object (Rectangle)";
143 return "Evas_Object (Line)";
144 case MAGIC_OBJ_POLYGON:
145 return "Evas_Object (Polygon)";
146 case MAGIC_OBJ_IMAGE:
147 return "Evas_Object (Image)";
149 return "Evas_Object (Text)";
150 case MAGIC_OBJ_SMART:
151 return "Evas_Object (Smart)";