专注收集记录技术开发学习笔记、技术难点、解决方案
网站信息搜索 >> 请输入关键词:
您当前的位置: 首页 > Brew

VTBL(IWindow) vtbl;该如何解决

发布时间:2010-05-30 20:13:05 文章来源:www.iduyao.cn 采编人员:星星草
VTBL(IWindow) vtbl;
摘一段sample的代码:
/***********************************************************************************/
static IWindow * CFileListWin_New(CMediaPlayer * pOwner)
{
   CFileListWin *    pme;
   VTBL(IWindow)     vtbl;
   
   MP_IWINDOW_SETVTBL(&vtbl, CFileListWin_Enable, CFileListWin_Redraw, CFileListWin_HandleEvent, CFileListWin_Delete);
...
/***********************************************************************************/

麻烦解释一下这段code的意思.VTBL(IWindow)     vtbl;
还有我一直不太清楚VTBL 到底是什么, 这里的
#define VTBL(iname) iname##Vtbl

Brew/C 里面的继承有哪几种途径..

谢谢.
------解决方案--------------------
#define VTBL(iname) iname##Vtbl
VTBL就是一个宏定义而已,用来定义接口的。
面向对象设计中,接口定义很重要,接口就是定义了一系列的操作,在c为基础的brew中,就是表现为一个函数指针的结构体。下面的struct IWindowVtbl 就是例子,只有函数指针,没有其它数据了,因为 IWindow就是:
struct _IWindow {
   struct IWindowVtbl  *pvt; 
 };
就是函数指针堆在一起而已!!



VTBL(IWindow) vtbl;
展开后就是
IWindowVtbl vtbl


#define QINTERFACE(iname) struct _##iname {\
                             struct VTBL(iname)  *pvt; \
                           };\
                           typedef struct VTBL(iname) VTBL(iname); \
                           struct VTBL(iname)
IWindow的定义如下:
typedef struct _IWindow IWindow;

struct _IWindow {
   struct IWindowVtbl  *pvt; 
 };
typedef struct IWindowVtbl   IWindowVtbl ; 
struct IWindowVtbl 
{
  /*
   * Enables/Disables the window. Window controls will not process
   * events if the window is disabled.
   */
  void (*Enable)(IWindow *po, boolean bEnable);

  /*
   * Redraws the window if enabled
   */
  void (*Redraw)(IWindow *po);

  /*
   * Handles the events routed to the window
   */
  boolean (*HandleEvent)(IWindow *po, AEEEvent eCode, uint16 wParam,
                         uint32 dwParam);

  /*
   * Releases the window resources
   */
  void (*Delete)(IWindow *po);
};

------解决方案--------------------
这里的这个

VTBL(IWindow) vtbl;
#define VTBL(iname) iname##Vtbl

可以翻译成:
友情提示:
信息收集于互联网,如果您发现错误或造成侵权,请及时通知本站更正或删除,具体联系方式见页面底部联系我们,谢谢。

其他相似内容:

热门推荐: