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
|
/*
* ion/ioncore/basicpholder.c
*
* Copyright (c) Tuomo Valkonen 2005-2007.
*
* See the included file LICENSE for details.
*/
#include <libtu/objp.h>
#include <libtu/obj.h>
#include <libtu/pointer.h>
#include "basicpholder.h"
/*{{{ Init/deinit */
static void basicpholder_watch_handler(Watch *watch, Obj *reg)
{
WBasicPHolder *ph=FIELD_TO_STRUCT(WBasicPHolder, reg_watch, watch);
pholder_redirect(&(ph->ph), (WRegion*)reg);
}
bool basicpholder_init(WBasicPHolder *ph, WRegion *reg,
WBasicPHolderHandler *hnd)
{
assert(reg!=NULL && hnd!=NULL);
pholder_init(&(ph->ph));
watch_init(&(ph->reg_watch));
if(!watch_setup(&(ph->reg_watch), (Obj*)reg, basicpholder_watch_handler)){
pholder_deinit(&(ph->ph));
return FALSE;
}
ph->hnd=hnd;
return TRUE;
}
WBasicPHolder *create_basicpholder(WRegion *reg,
WBasicPHolderHandler *hnd)
{
CREATEOBJ_IMPL(WBasicPHolder, basicpholder, (p, reg, hnd));
}
void basicpholder_deinit(WBasicPHolder *ph)
{
watch_reset(&(ph->reg_watch));
pholder_deinit(&(ph->ph));
}
/*}}}*/
/*{{{ Dynfuns */
WRegion *basicpholder_do_attach(WBasicPHolder *ph, int flags,
WRegionAttachData *data)
{
WRegion *reg=(WRegion*)ph->reg_watch.obj;
if(reg==NULL || ph->hnd==NULL)
return FALSE;
return ph->hnd(reg, flags, data);
}
bool basicpholder_do_goto(WBasicPHolder *ph)
{
WRegion *reg=(WRegion*)ph->reg_watch.obj;
if(reg!=NULL)
return region_goto((WRegion*)reg);
return FALSE;
}
WRegion *basicpholder_do_target(WBasicPHolder *ph)
{
return (WRegion*)ph->reg_watch.obj;
}
/*}}}*/
/*{{{ Class information */
static DynFunTab basicpholder_dynfuntab[]={
{(DynFun*)pholder_do_attach,
(DynFun*)basicpholder_do_attach},
{(DynFun*)pholder_do_goto,
(DynFun*)basicpholder_do_goto},
{(DynFun*)pholder_do_target,
(DynFun*)basicpholder_do_target},
END_DYNFUNTAB
};
IMPLCLASS(WBasicPHolder, WPHolder, basicpholder_deinit,
basicpholder_dynfuntab);
/*}}}*/
|