summaryrefslogtreecommitdiff
path: root/src/lib/eo/eo_ptr_indirection.h
blob: 33dc709d42b4a8c608e4531d7bc9966571bf51fa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
#ifndef EO_PTR_INDIRECTION_H
#define EO_PTR_INDIRECTION_H

#include "Eo.h"
#include "eo_private.h"

/* Macro used to obtain the object pointer and return if fails. */

void _eo_pointer_error(const Eo *obj_id, const char *func_name, const char *file, int line, const char *fmt, ...);

#define _EO_POINTER_ERR(obj_id, fmt, ...) \
  _eo_pointer_error(obj_id, __FUNCTION__, __FILE__, __LINE__, fmt, __VA_ARGS__)

#define EO_OBJ_POINTER(obj_id, obj) \
   _Eo_Object *obj; \
   do { \
      obj = _eo_obj_pointer_get((Eo_Id)obj_id, __FUNCTION__, __FILE__, __LINE__); \
   } while (0)

#define EO_OBJ_POINTER_PROXY(obj_id, obj) \
   _Eo_Object *obj; \
   do { \
      obj = _eo_obj_pointer_get((Eo_Id)obj_id, func_name, file, line); \
   } while (0)

#define EO_OBJ_POINTER_RETURN_VAL(obj_id, obj, ret)  \
   _Eo_Object *obj; \
   do { \
      obj = _eo_obj_pointer_get((Eo_Id)obj_id, __FUNCTION__, __FILE__, __LINE__); \
      if (!obj) return (ret); \
   } while (0)

/* reports as another function using func_name, file and line variables */
#define EO_OBJ_POINTER_RETURN_VAL_PROXY(obj_id, obj, ret) \
   _Eo_Object *obj; \
   do { \
      obj = _eo_obj_pointer_get((Eo_Id)obj_id, func_name, file, line); \
      if (!obj) return (ret); \
   } while (0)

#define EO_OBJ_POINTER_RETURN(obj_id, obj) \
   _Eo_Object *obj; \
   do { \
      obj = _eo_obj_pointer_get((Eo_Id)obj_id, __FUNCTION__, __FILE__, __LINE__); \
      if (!obj) return; \
   } while (0)

#define EO_OBJ_POINTER_RETURN_PROXY(obj_id, obj) \
   _Eo_Object *obj; \
   do { \
      obj = _eo_obj_pointer_get((Eo_Id)obj_id, func_name, file, line); \
      if (!obj) return; \
   } while (0)

#define EO_OBJ_POINTER_GOTO(obj_id, obj, label) \
   _Eo_Object *obj; \
   do { \
      obj = _eo_obj_pointer_get((Eo_Id)obj_id, __FUNCTION__, __FILE__, __LINE__); \
      if (!obj) goto label; \
   } while (0)

#define EO_OBJ_POINTER_GOTO_PROXY(obj_id, obj, label) \
   _Eo_Object *obj; \
   do { \
      obj = _eo_obj_pointer_get((Eo_Id)obj_id, func_name, file, line); \
      if (!obj) goto label; \
   } while (0)

#define EO_CLASS_POINTER(klass_id, klass)   \
   _Efl_Class *klass; \
   do { \
      klass = _eo_class_pointer_get(klass_id); \
   } while (0)

#define EO_CLASS_POINTER_PROXY(klass_id, klass)   \
   _Efl_Class *klass; \
   do { \
      klass = _eo_class_pointer_get(klass_id); \
   } while (0)

#define EO_CLASS_POINTER_RETURN_VAL(klass_id, klass, ret) \
   _Efl_Class *klass; \
   do { \
      klass = _eo_class_pointer_get(klass_id); \
      if (!klass) { \
         _EO_POINTER_ERR(klass_id, "Class (%p) is an invalid ref.", klass_id); \
         return ret; \
      } \
   } while (0)

#define EO_CLASS_POINTER_RETURN_VAL_PROXY(klass_id, klass, ret) \
   _Efl_Class *klass; \
   do { \
      klass = _eo_class_pointer_get(klass_id); \
      if (!klass) { \
         _EO_POINTER_ERR(klass_id, "Class (%p) is an invalid ref.", klass_id); \
         return ret; \
      } \
   } while (0)

#define EO_CLASS_POINTER_RETURN(klass_id, klass)   \
   _Efl_Class *klass; \
   do { \
      klass = _eo_class_pointer_get(klass_id); \
      if (!klass) { \
         _EO_POINTER_ERR(klass_id, "Class (%p) is an invalid ref.", klass_id); \
         return; \
      } \
   } while (0)

#define EO_CLASS_POINTER_RETURN_PROXY(klass_id, klass) \
   _Efl_Class *klass; \
   do { \
      klass = _eo_class_pointer_get(klass_id); \
      if (!klass) { \
         _EO_POINTER_ERR(klass_id, "Class (%p) is an invalid ref.", klass_id); \
         return; \
      } \
   } while (0)

#define EO_CLASS_POINTER_GOTO(klass_id, klass, label) \
   _Efl_Class *klass; \
   do { \
      klass = _eo_class_pointer_get(klass_id); \
      if (!klass) goto label; \
   } while (0)

#define EO_CLASS_POINTER_GOTO_PROXY(klass_id, klass, label) \
   _Efl_Class *klass; \
   do { \
      klass = _eo_class_pointer_get(klass_id); \
      if (!klass) goto label; \
   } while (0)

#define EO_OBJ_DONE(obj_id) \
   _eo_obj_pointer_done((Eo_Id)obj_id)

#ifdef EFL_DEBUG
static inline void _eo_print(Eo_Id_Table_Data *tdata);
#endif

extern Eina_TLS _eo_table_data;

#include "eo_ptr_indirection.x"

extern Eo_Id_Data *_eo_table_data_shared;
extern Eo_Id_Table_Data *_eo_table_data_shared_data;

#endif