static int KEY_WL_BUFFER = 0xabcdbeaf;
static int KEY_CLIENT = 0xdcbabeaf;
+static const char *
+_pui_magic_string_get(PUI_Magic m)
+{
+ switch (m)
+ {
+ case PUI_MAGIC_NONE:
+ return "None (Freed Object)";
+ break;
+
+ case PUI_MAGIC_PUI_M:
+ return "PUI MODULE (PUI_M)";
+ break;
+
+ case PUI_MAGIC_PUI_H:
+ return "PUI HANDLE (PUI_H)";
+ break;
+
+ case PUI_MAGIC_ANI_H:
+ return "PUI ANI HANDLE (ANI_H)";
+ break;
+
+ case PUI_MAGIC_ANI_T:
+ return "PUI ANI RUNTIME HANDLE (ANI_T)";
+ break;
+
+ default:
+ return "<Unknown>";
+ }
+}
+
+PUI_API void
+_pui_magic_fail(const void *p, PUI_Magic m, PUI_Magic req_m, const char *fname)
+{
+ pui_err(" ### PUI ERROR : PUI Magic Check Failed !!! in %s().\n", fname);
+
+ if (!p)
+ pui_err(" Given handle/pointer is NULL !\n");
+ else if (m == PUI_MAGIC_NONE)
+ pui_err(" Given handle/pointer has been freed !\n");
+ else if (m != req_m)
+ pui_err(" Given handle/pointer is wrong type\n"
+ " Expected: %08x - %s\n"
+ " Supplied: %08x - %s",
+ (unsigned int)req_m, _pui_magic_string_get(req_m),
+ (unsigned int)m, _pui_magic_string_get(m));
+
+ //if (getenv("ECORE_ERROR_ABORT"))
+ {
+ pui_err("### Abort ! ###\n");
+ abort();
+ }
+}
+
pui_error_string
pui_error_to_string(pui_error e)
{
tbm_surface_h surface;
pui_ani_control_buffer *buffer = NULL;
- if (!handle)
+ if (!PUI_MAGIC_CHECK(handle, PUI_MAGIC_PUI_H))
{
- pui_err("Error : PUI_INT_ERROR_INVALID_HANDLE\n");
+ PUI_MAGIC_FAIL(handle, PUI_MAGIC_PUI_H, __FUNCTION__);
return NULL;
}
pui_error
pui_display_set_buffer(pui_h handle, pui_ani_control_buffer *buffer)
{
- if (!handle)
+ if (!PUI_MAGIC_CHECK(handle, PUI_MAGIC_PUI_H))
{
- pui_err("Error : PUI_ERROR_INVALID_HANDLE\n");
+ PUI_MAGIC_FAIL(handle, PUI_MAGIC_PUI_H, __FUNCTION__);
return PUI_ERROR_INVALID_HANDLE;
}
tbm_surface_error_e ret;
struct wl_buffer *wl_buffer = NULL;
- if (!handle)
+ if (!PUI_MAGIC_CHECK(handle, PUI_MAGIC_PUI_H))
{
- pui_err("Error : PUI_ERROR_INVALID_HANDLE\n");
+ PUI_MAGIC_FAIL(handle, PUI_MAGIC_PUI_H, __FUNCTION__);
return PUI_ERROR_INVALID_HANDLE;
}
{
pui_ani_h ani_h = NULL;
- if (!handle)
+ if (!PUI_MAGIC_CHECK(pui_module, PUI_MAGIC_PUI_M))
{
- pui_err("Error : PUI_ERROR_INVALID_HANDLE\n");
+ PUI_MAGIC_FAIL(pui_module, PUI_MAGIC_PUI_M, __FUNCTION__);
return PUI_ERROR_INVALID_HANDLE;
}
pui_bool
pui_display_manual_render_get(pui_h handle)
{
- if (!handle)
+ if (!PUI_MAGIC_CHECK(handle, PUI_MAGIC_PUI_H))
{
- pui_err("Error : PUI_ERROR_INVALID_HANDLE\n");
+ PUI_MAGIC_FAIL(handle, PUI_MAGIC_PUI_H, __FUNCTION__);
return 0;
}
*width = 0;
*height = 0;
+ (void) handle;
+
+ if (!PUI_MAGIC_CHECK(pui_module, PUI_MAGIC_PUI_M))
+ {
+ PUI_MAGIC_FAIL(pui_module, PUI_MAGIC_PUI_M, __FUNCTION__);
+ return 0;
+ }
- if (!pui_module || !pui_module->backend_module_data) {
+ if (!pui_module->backend_module_data) {
pui_err("pui module data is not loaded\n");
return 0;
}
return NULL;
}
+ if (!PUI_MAGIC_CHECK(pui_module, PUI_MAGIC_PUI_M))
+ {
+ PUI_MAGIC_FAIL(pui_module, PUI_MAGIC_PUI_M, __FUNCTION__);
+ return NULL;
+ }
+
wl_tbm_client = wayland_tbm_client_init(ecore_wl2_display_get(ewd));
if (!wl_tbm_client)
goto err;
}
+ PUI_MAGIC_SET(handle, PUI_MAGIC_PUI_H);
return handle;
err:
{
pui_ani_h ani_h = NULL;
- if (!handle)
+ if (!PUI_MAGIC_CHECK(handle, PUI_MAGIC_PUI_H))
+ {
+ PUI_MAGIC_FAIL(handle, PUI_MAGIC_PUI_H, __FUNCTION__);
return;
+ }
EINA_LIST_FREE(handle->ani_handles, ani_h)
{
handle->wl_tbm_client = NULL;
}
+ PUI_MAGIC_SET(handle, PUI_MAGIC_NONE);
free(handle);
}
pui_backend_module_data *backend_module_data = NULL;
+ if (!PUI_MAGIC_CHECK(pui_module, PUI_MAGIC_PUI_M))
+ {
+ PUI_MAGIC_FAIL(pui_module, PUI_MAGIC_PUI_M, __FUNCTION__);
+ return;
+ }
module_info = dlopen(DEFAULT_LIB, RTLD_LAZY);
static void
_pui_unload_backend_module(void)
{
- if (!pui_module)
+ if (!PUI_MAGIC_CHECK(pui_module, PUI_MAGIC_PUI_M))
{
- pui_err("Invalid pui module !\n");
+ PUI_MAGIC_FAIL(pui_module, PUI_MAGIC_PUI_M, __FUNCTION__);
return;
}
{
pui_int_error ret;
- if (!pui_module || !pui_module->backend_module_data) {
+ if (!PUI_MAGIC_CHECK(pui_module, PUI_MAGIC_PUI_M))
+ {
+ PUI_MAGIC_FAIL(pui_module, PUI_MAGIC_PUI_M, __FUNCTION__);
+ return;
+ }
+
+ if (!pui_module->backend_module_data) {
pui_err("pui module data is not loaded\n");
return;
}
goto error;
}
+ PUI_MAGIC_SET(pui_module, PUI_MAGIC_PUI_M);
+
ecore_wl2_init();
_pui_event_init();
return 0;
}
- if (!pui_module)
+ if (!PUI_MAGIC_CHECK(pui_module, PUI_MAGIC_PUI_M))
{
- pui_err("Invalid pui module data !\n");
+ PUI_MAGIC_FAIL(pui_module, PUI_MAGIC_PUI_M, __FUNCTION__);
return _pui_init_count;
}
ecore_wl2_shutdown();
+ PUI_MAGIC_SET(pui_module, PUI_MAGIC_NONE);
free(pui_module);
return _pui_init_count;
pui_h handle = NULL;
pui_ani_control_buffer *buffer = NULL;
- if (!ani_h)
+ if (!PUI_MAGIC_CHECK(ani_h, PUI_MAGIC_ANI_H))
{
- pui_err("Invalid pui ani handle !\n");
+ PUI_MAGIC_FAIL(ani_h, PUI_MAGIC_ANI_H, __FUNCTION__);
return NULL;
}
pui_error e = PUI_ERROR_NONE;
pui_h handle = NULL;
+ if (!PUI_MAGIC_CHECK(ani_h, PUI_MAGIC_ANI_H))
+ {
+ PUI_MAGIC_FAIL(ani_h, PUI_MAGIC_ANI_H, __FUNCTION__);
+ return PUI_ERROR_INVALID_HANDLE;
+ }
+
handle = ani_h->pui_handle;
+
+ if (!PUI_MAGIC_CHECK(handle, PUI_MAGIC_PUI_H))
+ {
+ PUI_MAGIC_FAIL(handle, PUI_MAGIC_PUI_H, __FUNCTION__);
+ return PUI_ERROR_INVALID_HANDLE;
+ }
+
e = pui_display_set_buffer(handle, buffer);
return _pui_ani_error_to_int_error(e);
pui_ani_t *ani = (pui_ani_t *)data;
- if (!ani)
+ if (!PUI_MAGIC_CHECK(ani, PUI_MAGIC_ANI_T))
{
- pui_err("Invalid pui ani !\n");
+ PUI_MAGIC_FAIL(ani, PUI_MAGIC_ANI_T, __FUNCTION__);
return ECORE_CALLBACK_CANCEL;
}
{
Ecore_Timer *timer = NULL;
- if (!ani)
+ if (!PUI_MAGIC_CHECK(ani, PUI_MAGIC_ANI_T))
{
- pui_err("Invalid put ani !\n");
+ PUI_MAGIC_FAIL(ani, PUI_MAGIC_ANI_T, __FUNCTION__);
return 0;
}
void
pui_ani_remove_frame_cb(pui_ani_t *ani)
{
- if (!ani)
+ if (!PUI_MAGIC_CHECK(ani, PUI_MAGIC_ANI_T))
{
- pui_err("Invalid put ani !\n");
+ PUI_MAGIC_FAIL(ani, PUI_MAGIC_ANI_T, __FUNCTION__);
return;
}
pui_id
pui_ani_get_id(pui_ani_h ani_h)
{
- if (!ani_h || !ani_h->ani)
+ if (!PUI_MAGIC_CHECK(ani_h, PUI_MAGIC_ANI_H))
+ {
+ PUI_MAGIC_FAIL(ani_h, PUI_MAGIC_ANI_H, __FUNCTION__);
return NULL;
+ }
+
+ if (!PUI_MAGIC_CHECK(ani_h->ani, PUI_MAGIC_ANI_T))
+ {
+ PUI_MAGIC_FAIL(ani_h->ani, PUI_MAGIC_ANI_T, __FUNCTION__);
+ return NULL;
+ }
return ani_h->ani->id;
}
pui_ani_cmd
pui_ani_get_cmd(pui_ani_h ani_h)
{
- if (!ani_h || !ani_h->ani)
+ if (!PUI_MAGIC_CHECK(ani_h, PUI_MAGIC_ANI_H))
+ {
+ PUI_MAGIC_FAIL(ani_h, PUI_MAGIC_ANI_H, __FUNCTION__);
+ return PUI_ANI_CMD_NONE;
+ }
+
+ if (!PUI_MAGIC_CHECK(ani_h->ani, PUI_MAGIC_ANI_T))
+ {
+ PUI_MAGIC_FAIL(ani_h->ani, PUI_MAGIC_ANI_T, __FUNCTION__);
return PUI_ANI_CMD_NONE;
+ }
return ani_h->ani->cmd;
}
int
pui_ani_get_repeat(pui_ani_h ani_h)
{
- if (!ani_h || !ani_h->ani)
+ if (!PUI_MAGIC_CHECK(ani_h, PUI_MAGIC_ANI_H))
+ {
+ PUI_MAGIC_FAIL(ani_h, PUI_MAGIC_ANI_H, __FUNCTION__);
return 0;
+ }
+
+ if (!PUI_MAGIC_CHECK(ani_h->ani, PUI_MAGIC_ANI_T))
+ {
+ PUI_MAGIC_FAIL(ani_h->ani, PUI_MAGIC_ANI_T, __FUNCTION__);
+ return 0;
+ }
return ani_h->ani->repeat;
}
pui_backend_ani_data *
pui_ani_get_ani_data(pui_ani_t *ani)
{
- if (!ani)
+ if (!PUI_MAGIC_CHECK(ani, PUI_MAGIC_ANI_T))
+ {
+ PUI_MAGIC_FAIL(ani, PUI_MAGIC_ANI_T, __FUNCTION__);
return NULL;
+ }
return ani->ani_data;
}
pui_ani_h ani_h;
PUI_Event_Animation_Status *e = NULL;
- if (!ani)
+ if (!PUI_MAGIC_CHECK(ani, PUI_MAGIC_ANI_T))
{
- pui_err("Invalid pui ani !\n");
+ PUI_MAGIC_FAIL(ani, PUI_MAGIC_ANI_T, __FUNCTION__);
return;
}
{
pui_ani_status status = PUI_ANI_STATUS_UNKNOWN;
- if (!ani)
+ if (!PUI_MAGIC_CHECK(ani, PUI_MAGIC_ANI_T))
{
- pui_err("Invalid pui ani !\n");
+ PUI_MAGIC_FAIL(ani, PUI_MAGIC_ANI_T, __FUNCTION__);
return status;
}
pui_h handle = NULL;
pui_backend_ani_func *ani_func = NULL;
- if (!ani_h)
+ if (!PUI_MAGIC_CHECK(ani_h, PUI_MAGIC_ANI_H))
+ {
+ PUI_MAGIC_FAIL(ani_h, PUI_MAGIC_ANI_H, __FUNCTION__);
return PUI_ERROR_INVALID_ANI_HANDLE;
+ }
if (cmd < PUI_ANI_CMD_START || cmd >= PUI_ANI_CMD_LAST)
{
handle = ani_h->pui_handle;
ani = ani_h->ani;
- if (!ani || !ani->ani_data)
+ if (!PUI_MAGIC_CHECK(handle, PUI_MAGIC_PUI_H))
{
- pui_err("Invalid ani or ani_data !\n");
+ PUI_MAGIC_FAIL(handle, PUI_MAGIC_PUI_H, __FUNCTION__);
+ return PUI_ERROR_INTERNAL;
+ }
+
+ if (!PUI_MAGIC_CHECK(ani, PUI_MAGIC_ANI_T))
+ {
+ PUI_MAGIC_FAIL(ani, PUI_MAGIC_ANI_T, __FUNCTION__);
+ return PUI_ERROR_INTERNAL;
+ }
+
+ if (!ani->ani_data)
+ {
+ pui_err("Invalid ani_data !\n");
return PUI_ERROR_INTERNAL;
}
Ecore_Wl2_Event_Window_Visibility_Change *ev;
PUI_Event_Animation_Status *e = NULL;
+ if (!PUI_MAGIC_CHECK(ani_h, PUI_MAGIC_ANI_H))
+ {
+ PUI_MAGIC_FAIL(ani_h, PUI_MAGIC_ANI_H, __FUNCTION__);
+ return ECORE_CALLBACK_PASS_ON;
+ }
+
+ if (!PUI_MAGIC_CHECK(ani, PUI_MAGIC_ANI_T))
+ {
+ PUI_MAGIC_FAIL(ani, PUI_MAGIC_ANI_T, __FUNCTION__);
+ return ECORE_CALLBACK_PASS_ON;
+ }
+
+ if (!PUI_MAGIC_CHECK(ph, PUI_MAGIC_PUI_H))
+ {
+ PUI_MAGIC_FAIL(ph, PUI_MAGIC_PUI_H, __FUNCTION__);
+ return ECORE_CALLBACK_PASS_ON;
+ }
+
ev = event;
/* check if this is needed */
{
Ecore_Event_Handler *h = NULL;
- if (!ani_h)
+ if (!PUI_MAGIC_CHECK(ani_h, PUI_MAGIC_ANI_H))
{
- pui_err("Invalid handle !\n");
+ PUI_MAGIC_FAIL(ani_h, PUI_MAGIC_ANI_H, __FUNCTION__);
return;
}
static void
_pui_ani_event_handlers_shutdown(pui_ani_h ani_h)
{
- if (!ani_h)
+ if (!PUI_MAGIC_CHECK(ani_h, PUI_MAGIC_ANI_H))
{
- pui_err("Invalid handle !\n");
+ PUI_MAGIC_FAIL(ani_h, PUI_MAGIC_ANI_H, __FUNCTION__);
return;
}
pui_ani_t *ani = NULL;
pui_backend_ani_data *ani_data = NULL;
- if (!handle || !handle->backend_module_data)
+ if (!PUI_MAGIC_CHECK(handle, PUI_MAGIC_PUI_H))
{
- pui_err("Invalid pui handle or backend module data !\n");
+ PUI_MAGIC_FAIL(handle, PUI_MAGIC_PUI_H, __FUNCTION__);
+ return NULL;
+ }
+
+ if (!handle->backend_module_data)
+ {
+ pui_err("Invalid backend module data !\n");
return NULL;
}
ani_h->pui_handle = handle;
ani_h->ecore_event_hdls = NULL;
+ PUI_MAGIC_SET(ani_h, PUI_MAGIC_ANI_H);
+
_pui_ani_event_handlers_init(ani_h);
ani = (pui_ani_t *)calloc(1, sizeof(pui_ani_t));
handle->ani_handles = eina_list_append(handle->ani_handles, ani_h);
+ PUI_MAGIC_SET(ani, PUI_MAGIC_ANI_T);
+
return ani_h;
err:
}
if (ani_h)
+ {
+ PUI_MAGIC_SET(ani_h, PUI_MAGIC_NONE);
free(ani_h);
+ }
return NULL;
}
pui_ani_t *ani = NULL;
pui_backend_module_data *backend_module_data = NULL;
- if (!ani_h || !ani_h->pui_handle)
+ if (!PUI_MAGIC_CHECK(ani_h, PUI_MAGIC_ANI_H))
+ {
+ PUI_MAGIC_FAIL(ani_h, PUI_MAGIC_ANI_H, __FUNCTION__);
return;
+ }
handle = ani_h->pui_handle;
ani = ani_h->ani;
+ if (!PUI_MAGIC_CHECK(handle, PUI_MAGIC_PUI_H))
+ {
+ PUI_MAGIC_FAIL(handle, PUI_MAGIC_PUI_H, __FUNCTION__);
+ return;
+ }
+
+ if (!PUI_MAGIC_CHECK(ani, PUI_MAGIC_ANI_T))
+ {
+ PUI_MAGIC_FAIL(ani, PUI_MAGIC_ANI_T, __FUNCTION__);
+ return;
+ }
+
/* stop the animation being played already if any */
if (ani->status == PUI_ANI_STATUS_STARTED || ani->status == PUI_ANI_STATUS_RUNNING)
pui_ani_control(ani_h, PUI_ANI_CMD_STOP, 0);
ani->frame_cb_timer = NULL;
}
+ PUI_MAGIC_SET(ani_h->ani, PUI_MAGIC_NONE);
free(ani_h->ani);
_pui_ani_event_handlers_shutdown(ani_h);
handle->ani_handles = eina_list_remove(handle->ani_handles, ani_h);
+ PUI_MAGIC_SET(ani_h, PUI_MAGIC_NONE);
+
free(ani_h->id);
free(ani_h);
}