summaryrefslogtreecommitdiff
path: root/src/lib/evas/main.c
diff options
context:
space:
mode:
authorVincent Torri <vincent.torri@gmail.com>2012-11-04 11:51:42 +0000
committerVincent Torri <vincent.torri@gmail.com>2012-11-04 11:51:42 +0000
commitc15e9c6575c3b5f39ded167dda5259de3de96151 (patch)
tree5115d7ae3620af24c2bc094cd062575af7adeda9 /src/lib/evas/main.c
parenta5ac6a987caec5a7f7596a25d0a065b9cc94c50c (diff)
merge: and now Evas
I've tested make -j 3 install and it works nicely I've tested expedite with software and opengl xlib, and it works. Not tested other engines, so please report any problems (engines or other) on the ML. TODO: examples and tests, I'll add them later ISSUE: Eina_Unicode size check. It indirectly depends on eina_config.h, which is created at the end of the configure script. So its size is always 0. I don't know how that size is used, so I can't do a lot, for now. SVN revision: 78895
Diffstat (limited to 'src/lib/evas/main.c')
-rw-r--r--src/lib/evas/main.c160
1 files changed, 160 insertions, 0 deletions
diff --git a/src/lib/evas/main.c b/src/lib/evas/main.c
new file mode 100644
index 0000000000..604c14d996
--- /dev/null
+++ b/src/lib/evas/main.c
@@ -0,0 +1,160 @@
1#include "evas_common.h"
2#include "evas_private.h"
3
4static Evas_Version _version = { VMAJ, VMIN, VMIC, VREV };
5EAPI Evas_Version *evas_version = &_version;
6
7int _evas_alloc_error = 0;
8static int _evas_debug_init = 0;
9static enum {
10 _EVAS_DEBUG_DEFAULT,
11 _EVAS_DEBUG_HIDE,
12 _EVAS_DEBUG_SHOW
13} _evas_debug_show = _EVAS_DEBUG_DEFAULT;
14static int _evas_debug_abort = 0;
15
16EAPI Evas_Alloc_Error
17evas_alloc_error(void)
18{
19 return _evas_alloc_error;
20}
21
22/* free cached items only in ram for speed reasons. return 0 if can't free */
23int
24evas_mem_free(int mem_required EINA_UNUSED)
25{
26 return 0;
27}
28
29/* start reducing quality of images etc. return 0 if can't free anything */
30int
31evas_mem_degrade(int mem_required EINA_UNUSED)
32{
33 return 0;
34}
35
36void *
37evas_mem_calloc(int size)
38{
39 void *ptr;
40
41 ptr = calloc(1, size);
42 if (ptr) return ptr;
43 MERR_BAD();
44 while ((!ptr) && (evas_mem_free(size))) ptr = calloc(1, size);
45 if (ptr) return ptr;
46 while ((!ptr) && (evas_mem_degrade(size))) ptr = calloc(1, size);
47 if (ptr) return ptr;
48 MERR_FATAL();
49 return NULL;
50}
51
52static void
53_evas_debug_init_from_env()
54{
55 const char *tmp = getenv("EVAS_DEBUG_SHOW");
56 if (tmp)
57 {
58 int dbgshow = atoi(tmp);
59 _evas_debug_show = (dbgshow) ? _EVAS_DEBUG_SHOW : _EVAS_DEBUG_HIDE;
60 }
61 if (getenv("EVAS_DEBUG_ABORT")) _evas_debug_abort = 1;
62 _evas_debug_init = 1;
63}
64
65void
66evas_debug_error(void)
67{
68 if (!_evas_debug_init)
69 {
70 _evas_debug_init_from_env();
71 }
72 if (_evas_debug_show == _EVAS_DEBUG_SHOW)
73 CRIT("Evas Magic Check Failed!!!");
74}
75
76void
77evas_debug_input_null(void)
78{
79 if (!_evas_debug_init)
80 {
81 _evas_debug_init_from_env();
82 }
83 if (_evas_debug_show == _EVAS_DEBUG_SHOW)
84 CRIT("Input object pointer is NULL!");
85 if (_evas_debug_abort) abort();
86}
87
88void
89evas_debug_magic_null(void)
90{
91 if (!_evas_debug_init)
92 {
93 _evas_debug_init_from_env();
94 }
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();
99}
100
101void
102evas_debug_magic_wrong(DATA32 expected, DATA32 supplied)
103{
104 if (!_evas_debug_init)
105 {
106 _evas_debug_init_from_env();
107 }
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();
116}
117
118void
119evas_debug_generic(const char *str)
120{
121 if (!_evas_debug_init)
122 {
123 _evas_debug_init_from_env();
124 }
125 if ((_evas_debug_show == _EVAS_DEBUG_SHOW) ||
126 (_evas_debug_show == _EVAS_DEBUG_DEFAULT))
127 CRIT("%s", str);
128 if (_evas_debug_abort) abort();
129}
130
131const char *
132evas_debug_magic_string_get(DATA32 magic)
133{
134 switch (magic)
135 {
136 case MAGIC_EVAS:
137 return "Evas";
138 case MAGIC_OBJ:
139 return "Evas_Object";
140 case MAGIC_OBJ_RECTANGLE:
141 return "Evas_Object (Rectangle)";
142 case MAGIC_OBJ_LINE:
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)";
148 case MAGIC_OBJ_TEXT:
149 return "Evas_Object (Text)";
150 case MAGIC_OBJ_SMART:
151 return "Evas_Object (Smart)";
152 case MAGIC_EVAS_GL:
153 return "Evas_GL";
154 case MAGIC_MAP:
155 return "Evas_Map";
156 default:
157 return "<UNKNOWN>";
158 };
159 return "<UNKNOWN>";
160}