Mif编辑器:
Mif 是相当于brew模块上的容器,该容器可以装载多个小程序。Mif上的每个小程序必须为它制定ID号,也即ClassID,其在本mif中具有唯一性。ClassID对应一个程序名。每个小程序会生成一个bid文件。编辑mif的最后需要进行编译,会生成mif、mfx文件。
Resource编辑器:
实际上,其包含编辑器,编译器。编辑器内可以对字符串、文件、对话框等等资源进行编辑。在编辑后保存会生成中间文件bri,经编译后,会生成bar以及brh(一说是_res.h)文件。
Emulator:
其上可以选择模拟器的设备,以及需要模拟的最小程序目录。
从HELLO WORLD看BREW的程序基本运行机制
AEEClsCreateInstance算是程序的入口函数。必须传入classID去验证。以下截取关键代码分析。
int AEEClsCreateInstance(AEECLSID ClsId, IShell *pIShell, IModule *po, void **ppObj)
{
*ppObj = NULL;
if( ClsId == AEECLSID_TEST1 )
{
// Create the applet and make room for the applet structure
if( AEEApplet_New(sizeof(Test1),
ClsId,
pIShell,
po,
(IApplet**)ppObj,
(AEEHANDLER)Test1_HandleEvent,
(PFNFREEAPPDATA)Test1_FreeAppData) ) // the FreeAppData function is called after sending EVT_APP_STOP to the HandleEvent function
{
//Initialize applet data, this is called before sending EVT_APP_START
// to the HandleEvent function
if(Test1_InitAppData((Test1*)*ppObj))
{
//Data initialized successfully
return(AEE_SUCCESS);
}
else
{
//Release the applet. This will free the memory allocated for the applet when
// AEEApplet_New was called.
IAPPLET_Release((IApplet*)*ppObj);
return EFAILED;
}
} // end AEEApplet_New
}
return(EFAILED);
}
If即为检验classID。
AEEApplet_New()用于调用相应的程序,这里Test1_HandleEvent()即为所调函数。Test1_InitAppData()初始化程序所用数据,IAPPLET_Release()用于在call了AEEApplet_New()后将applet释放,Test1_FreeAppData()则是将数据释放。