Mercurial > MadButterfly
changeset 993:5b58e74988bc refine_backend_if
Use mb_backend_t::new instead of mb_backend_t::init
author | Thinker K.F. Li <thinker@codemud.net> |
---|---|
date | Mon, 22 Nov 2010 00:42:29 +0800 |
parents | 2cbe3721dc9a |
children | 5d9def42df12 |
files | include/mb_X_supp.h include/mb_af.h include/mb_backend.h src/mbaf/mbapp.c |
diffstat | 4 files changed, 17 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/include/mb_X_supp.h Mon Nov 22 00:42:29 2010 +0800 +++ b/include/mb_X_supp.h Mon Nov 22 00:42:29 2010 +0800 @@ -37,6 +37,6 @@ extern ob_factory_t *X_MB_ob_factory(void *xmb_rt); extern mb_img_ldr_t *X_MB_img_ldr(void *xmb_rt); -#define MBB_WINDOW Window +#define MB_WINDOW Window #endif
--- a/include/mb_af.h Mon Nov 22 00:42:29 2010 +0800 +++ b/include/mb_af.h Mon Nov 22 00:42:29 2010 +0800 @@ -3,9 +3,11 @@ #ifndef __APP_H #define __APP_H +#include "mb_backend.h" + typedef struct _mbapp mbaf_t; struct _mbapp { - void *rt; + mb_rt_t *rt; redraw_man_t *rdman; mb_sprite_t *rootsprite; mb_obj_t *root;
--- a/include/mb_backend.h Mon Nov 22 00:42:29 2010 +0800 +++ b/include/mb_backend.h Mon Nov 22 00:42:29 2010 +0800 @@ -16,9 +16,13 @@ #inclde "mb_dfb_supp.h" #endif -typedef void *MBB_WINDOW; typedef void mb_rt_t; +typedef struct _mb_timer_man mb_timer_man_t; +typedef struct _mb_timer_factory mb_timer_factory_t; +typedef struct _mb_IO_man mb_IO_man_t; +typedef struct _mb_IO_factory mb_IO_factory_t; + /*! \brief The backend engine mb_backend_t is used to define the * interface to realize the MB. * @@ -34,7 +38,7 @@ */ typedef struct { mb_rt_t *(*new)(const char *display, int w,int h); - mb_rt_t *(*new_with_win)(const char *display, MBB_WINDOW win, int w,int h); + mb_rt_t *(*new_with_win)(const char *display, MB_WINDOW win, int w,int h); void (*free)(mb_rt_t *rt); /*! \brief Request the backend to start monitoring a file descriptor. @@ -73,7 +77,8 @@ /*! \brief Type of IO that registered with an IO manager. */ -enum MB_IO_TYPE {MB_IO_DUMMY, MB_IO_R, MB_IO_W, MB_IO_RW}; +enum _MB_IO_TYPE {MB_IO_DUMMY, MB_IO_R, MB_IO_W, MB_IO_RW}; +typedef enum _MB_IO_TYPE MB_IO_TYPE; /*! \brief Function signature of callback functions for IO requests. */ @@ -84,10 +89,9 @@ struct _mb_IO_man { int (*reg)(struct _mb_IO_man *io_man, int fd, MB_IO_TYPE type, mb_IO_cb_t cb, void *data); - void (*unreg)(struct _mb_IO_Man *io_man, + void (*unreg)(struct _mb_IO_man *io_man, int io_hdl); }; -typedef struct _mb_IO_man mb_IO_man_t; /*! \brief Factory of IO managers. */ @@ -95,7 +99,6 @@ mb_IO_man_t *(*new)(void); void (*free)(mb_IO_man_t *io_man); }; -typedef struct _mb_IO_factory mb_IO_factory_t; /*! \brief Function signature of callback functions for timers. */ @@ -113,7 +116,7 @@ * \param tm_hdl is the handle returned by _mb_timer_man::timeout. */ void (*remove)(struct _mb_timer_man *tm_man, int tm_hdl); -} mb_timer_man_t; +}; /*! \brief Factory of timer manager. */ @@ -121,6 +124,5 @@ mb_timer_man_t *(*new)(void); void (*free)(mb_timer_man_t *timer_man); }; -typedef struct _mb_timer_factory mb_timer_factory_t; #endif /* __MB_BACKEND_H_ */
--- a/src/mbaf/mbapp.c Mon Nov 22 00:42:29 2010 +0800 +++ b/src/mbaf/mbapp.c Mon Nov 22 00:42:29 2010 +0800 @@ -2,13 +2,14 @@ // vim: sw=4:ts=8:sts=4 #include <mb.h> #include <mb_af.h> +#include <mb_backend.h> mbaf_t *mbaf_init(const char *module, const char *module_dir) { mbaf_t *app = (mbaf_t *) malloc(sizeof(mbaf_t)); - void *rt; + mb_rt_t *rt; - rt = backend.init(":0.0", 800, 600); + rt = backend.new(":0.0", 800, 600); if(rt == NULL) return NULL;