summaryrefslogtreecommitdiff
path: root/src/lib/ecore/ecore_internal.h
blob: 32a947218848b33b7e14718ef293468b0d75addb (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
// Internal header are to be used only inside efl itself.
#ifndef _ECORE_INTERNAL_H
#define _ECORE_INTERNAL_H

#ifdef EAPI
# undef EAPI
#endif

#ifdef _WIN32
# ifdef EFL_BUILD
#  ifdef DLL_EXPORT
#   define EAPI __declspec(dllexport)
#  else
#   define EAPI
#  endif
# else
#  define EAPI __declspec(dllimport)
# endif
#else
# ifdef __GNUC__
#  if __GNUC__ >= 4
#   define EAPI __attribute__ ((visibility("default")))
#  else
#   define EAPI
#  endif
# else
#  define EAPI
# endif
#endif

EAPI void ecore_loop_arguments_send(int argc, const char **argv);
EAPI Eina_Bool efl_loop_message_process(Eo *obj);

static inline Eina_Value
efl_model_list_value_get(Eina_List *childrens,
                         unsigned int start,
                         unsigned int count)
{
   Eina_Value v = EINA_VALUE_EMPTY;
   Eina_List *l;
   Eo *child;

   if (eina_list_count(childrens) < start + count)
     return eina_value_error_init(EFL_MODEL_ERROR_INCORRECT_VALUE);

   eina_value_array_setup(&v, EINA_VALUE_TYPE_OBJECT, 4);

   childrens = eina_list_nth_list(childrens, start);

   EINA_LIST_FOREACH(childrens, l, child)
     {
        if (count == 0)
          break;
        count--;

        eina_value_array_append(&v, child);
     }

   return v;
}

#define EFL_COMPOSITE_MODEL_CHILD_INDEX "child.index"

#define EFL_COMPOSITE_MODEL_PROPERTIES(name, dyn, sta, ...) \
  EFL_COMPOSITE_MODEL_PROPERTIES_SUPER(name, NULL, NULL, (dyn), sta, ##__VA_ARGS__)

#define EFL_COMPOSITE_MODEL_PROPERTIES_SUPER(name, obj, klass, dyn, ...)       \
  Eina_Iterator *name;                                                         \
  do                                                                           \
    {                                                                          \
       static const char *static_props__[] = {                                 \
         __VA_ARGS__                                                           \
       };                                                                      \
       name = _efl_composite_model_properties_mix(                             \
         ((obj) ? efl_model_properties_get(efl_super((obj), (klass))) : NULL), \
         (dyn),                                                                \
         EINA_C_ARRAY_ITERATOR_NEW(static_props__));                           \
    }                                                                          \
  while (0)


static inline Eina_Iterator *
_efl_composite_model_properties_mix(Eina_Iterator *super, Eina_Iterator *dyn, Eina_Iterator *sta)
{
   Eina_Iterator *its[3];
   int i = 0;

   if (sta)   its[i++] = sta;
   if (dyn)   its[i++] = dyn;
   if (super) its[i++] = super;

   switch (i)
     {
      case 1: return its[0];
      case 2: return eina_multi_iterator_new(its[0], its[1]);
      case 3: return eina_multi_iterator_new(its[0], its[1], its[2]);
      default: return NULL;
     };
}

#define EFL_COMPOSITE_LOOKUP_RETURN(Remember, Parent, View, Base)       \
  Efl_Model *Remember;                                                  \
  char buf[1024];                                                       \
                                                                        \
  snprintf(buf, sizeof (buf), Base"-%p", Parent);                       \
  Remember = efl_key_wref_get(View, buf);                               \
  if (Remember)                                                         \
    {                                                                   \
       efl_ref(Remember);                                               \
       return Remember;                                                 \
    }

#define EFL_COMPOSITE_REMEMBER_RETURN(Remember, View)  \
  efl_key_wref_set(View, buf, Remember);               \
  return Remember;


static inline Efl_Model *
_efl_composite_lookup(const Efl_Class *self, Eo *parent, Efl_Model *view, unsigned int index)
{
   EFL_COMPOSITE_LOOKUP_RETURN(remember, parent, view, "_efl.composite_model");

   remember = efl_add_ref(self, parent,
                          efl_ui_view_model_set(efl_added, view),
                          efl_composite_model_index_set(efl_added, index),
                          efl_loop_model_volatile_make(efl_added));
   if (!remember) return NULL;

   EFL_COMPOSITE_REMEMBER_RETURN(remember, view);
}

#undef EAPI
#define EAPI

#endif