Extensions | developer.brewmp.com Extensions | developer.brewmp.com

Developer

Extensions

Forums:

What header files should I use in an extension?

Kahlner wrote:What header files should I use in an extension?
I didn't use any special header files, just the standard BREW ones
as the example extension does.

Kahlner wrote:What header files should I use in an extension?
I didn't use any special header files, just the standard BREW ones
as the example extension does.

Ok...maybe I'm missing this...but where can I find the an example extension?

Ok...maybe I'm missing this...but where can I find the an example extension?

Ok...did that already...and it wouldn't compile....I'm lost...and I need to do this.......will it be affected because I am compiling in C and not C++?

Ok...did that already...and it wouldn't compile....I'm lost...and I need to do this.......will it be affected because I am compiling in C and not C++?

C or C++ should not matter.
What error are u getting ?

C or C++ should not matter.
What error are u getting ?

#ifndef EXTENSIONS_H
#define EXTENSIONS_H
#include "_extensions.bid"
#include "AEE.h"
#include "AEEShell.h"
typedef ext;
AEEINTERFACE(ext) {
INHERIT_IQueryInterface(ext);
;
#define MyExtension_AddRef(p) AEEGETPVTBL((p),IExtensionCls)->AddRef((p))
#define MyExtension_Release(p) AEEGETPVTBL((p),IExtensionCls)->Release((p))
#define MyExtension_QueryInterface(p) AEEGETPVTBL((p),IExtensionCls)-> QueryInterface((p),(clsid),(pp))
int MyExtension_New(int16 nSize, IShell *pIShell, IModule* pIModule, IModule ** ppMod);
/*static const AEEVTBL(IDemoExtension) gvtIDemoExtension = {
MyExtension_AddRef,
MyExtension_Release,
MyExtension_QueryInterface,
MyExtension_DisplayTime,
MyExtension_DisplayDate,
;*/
#include "_extensions.c"
#endif

#ifndef EXTENSIONS_H
#define EXTENSIONS_H
#include "_extensions.bid"
#include "AEE.h"
#include "AEEShell.h"
typedef ext;
AEEINTERFACE(ext) {
INHERIT_IQueryInterface(ext);
;
#define MyExtension_AddRef(p) AEEGETPVTBL((p),IExtensionCls)->AddRef((p))
#define MyExtension_Release(p) AEEGETPVTBL((p),IExtensionCls)->Release((p))
#define MyExtension_QueryInterface(p) AEEGETPVTBL((p),IExtensionCls)-> QueryInterface((p),(clsid),(pp))
int MyExtension_New(int16 nSize, IShell *pIShell, IModule* pIModule, IModule ** ppMod);
/*static const AEEVTBL(IDemoExtension) gvtIDemoExtension = {
MyExtension_AddRef,
MyExtension_Release,
MyExtension_QueryInterface,
MyExtension_DisplayTime,
MyExtension_DisplayDate,
;*/
#include "_extensions.c"
#endif

#include "_extensions.h"
#include "_extensions.bid"
#include "AEEModGen.h"
#include "AEEAppGen.h"
#include "AEEShell.h"
#include "AEEStdLib.h"
typedef struct ext {
// Declare our VTable
const AEEVTBL(ext) * pvt;
uint32 m_nRefs; // References count
IShell *m_pIShell;
IDisplay *m_pIDisplay;
IModule *m_pIModule;
};
int AEEClsCreateInstance(AEECLSID ClsId, IShell *pIShell, IModule *po, void **ppObj) {
*ppObj = NULL;
if( ClsId == AEECLSID__EXTENSIONS) {
return MyExtension_New(sizeof(ext), pIShell, po, (IModule **)ppObj);
}
return EFAILED;

int MyExtension_New(int16 nSize, IShell *pIShell, IModule* pIModule, IModule ** ppMod) {
ext* pMe = NULL;
VTBL(ext) * modFuncs;
if( !ppMod || !pIShell || !pIModule )
return EFAILED;
*ppMod = NULL;
if( nSize < sizeof(ext) )
nSize += sizeof(ext);
if( (pMe = (ext*)MALLOC(nSize + sizeof(VTBL(ext)))) == NULL )
return ENOMEMORY;
modFuncs = (VTBL(ext)*)((byte *)pMe + nSize);
modFuncs->AddRef = MyExtension_AddRef;
modFuncs->Release = MyExtension_Release;
modFuncs->QueryInterface = MyExtension_QueryInterace;
INIT_VTBL(pMe, IModule, *modFuncs);
pMe->m_nRefs = 1;
pMe->m_pIShell = pIShell;
pMe->m_pIModule = pIModule;
ISHELL_AddRef(pIShell);
IMODULE_AddRef(pIModule);
if( ISHELL_CreateInstance(pIShell, AEECLSID_DISPLAY,
(void **)&pMe->m_pIDisplay) != SUCCESS )
return EFAILED;
*ppMod = (IModule*)pMe;
return AEE_SUCCESS;

static uint32 MyExtension_AddRef(ext* pMe) {
return ++(pMe->m_nRefs);

static uint32 MyExtension_Release(ext* pMe) {
if( --pMe->m_nRefs != 0 )
return pMe->m_nRefs;
if( pMe->m_pIDisplay )
IDISPLAY_Release(pMe->m_pIDisplay);
ISHELL_Release(pMe->m_pIShell);
IMODULE_Release(pMe->m_pIModule);
FREE_VTBL(pMe, IModule);
FREE( pMe );
return 0;

static int MyExtension_QueryInterface(ext* me, AEECLSID class, void** ppo) {
switch (class) {
case AEECLSID_QUERYINTERFACE:
case AEECLSID_MYEXTENSION:
case AEECLSID_BASE:
*ppo = me;
MyExtension_AddRef(me);
return SUCCESS;
case AEECLSID_DISPLAY:
*ppo = me->m_pIDisplay;
return SUCCESS;
default:
*ppo = NULL;
return ECLASSNOTSUPPORT;
}

#include "_extensions.h"
#include "_extensions.bid"
#include "AEEModGen.h"
#include "AEEAppGen.h"
#include "AEEShell.h"
#include "AEEStdLib.h"
typedef struct ext {
// Declare our VTable
const AEEVTBL(ext) * pvt;
uint32 m_nRefs; // References count
IShell *m_pIShell;
IDisplay *m_pIDisplay;
IModule *m_pIModule;
};
int AEEClsCreateInstance(AEECLSID ClsId, IShell *pIShell, IModule *po, void **ppObj) {
*ppObj = NULL;
if( ClsId == AEECLSID__EXTENSIONS) {
return MyExtension_New(sizeof(ext), pIShell, po, (IModule **)ppObj);
}
return EFAILED;

int MyExtension_New(int16 nSize, IShell *pIShell, IModule* pIModule, IModule ** ppMod) {
ext* pMe = NULL;
VTBL(ext) * modFuncs;
if( !ppMod || !pIShell || !pIModule )
return EFAILED;
*ppMod = NULL;
if( nSize < sizeof(ext) )
nSize += sizeof(ext);
if( (pMe = (ext*)MALLOC(nSize + sizeof(VTBL(ext)))) == NULL )
return ENOMEMORY;
modFuncs = (VTBL(ext)*)((byte *)pMe + nSize);
modFuncs->AddRef = MyExtension_AddRef;
modFuncs->Release = MyExtension_Release;
modFuncs->QueryInterface = MyExtension_QueryInterace;
INIT_VTBL(pMe, IModule, *modFuncs);
pMe->m_nRefs = 1;
pMe->m_pIShell = pIShell;
pMe->m_pIModule = pIModule;
ISHELL_AddRef(pIShell);
IMODULE_AddRef(pIModule);
if( ISHELL_CreateInstance(pIShell, AEECLSID_DISPLAY,
(void **)&pMe->m_pIDisplay) != SUCCESS )
return EFAILED;
*ppMod = (IModule*)pMe;
return AEE_SUCCESS;

static uint32 MyExtension_AddRef(ext* pMe) {
return ++(pMe->m_nRefs);

static uint32 MyExtension_Release(ext* pMe) {
if( --pMe->m_nRefs != 0 )
return pMe->m_nRefs;
if( pMe->m_pIDisplay )
IDISPLAY_Release(pMe->m_pIDisplay);
ISHELL_Release(pMe->m_pIShell);
IMODULE_Release(pMe->m_pIModule);
FREE_VTBL(pMe, IModule);
FREE( pMe );
return 0;

static int MyExtension_QueryInterface(ext* me, AEECLSID class, void** ppo) {
switch (class) {
case AEECLSID_QUERYINTERFACE:
case AEECLSID_MYEXTENSION:
case AEECLSID_BASE:
*ppo = me;
MyExtension_AddRef(me);
return SUCCESS;
case AEECLSID_DISPLAY:
*ppo = me->m_pIDisplay;
return SUCCESS;
default:
*ppo = NULL;
return ECLASSNOTSUPPORT;
}

e:\work\brew\adclientutil\_extensions.h(11) : error C2143: syntax error : missing ')' before '*'

e:\work\brew\adclientutil\_extensions.h(11) : error C2143: syntax error : missing ')' before '*'

Check line 8 of the header.
prototype for typedef :
typedef type-declaration synonym;
Dont think the typedef you have would work.

Check line 8 of the header.
prototype for typedef :
typedef type-declaration synonym;
Dont think the typedef you have would work.

modFuncs->AddRef = MyExtension_AddRef;
e:\work\brew\adclientutil\_extensions.c(40) : error C2065: 'MyExtension_AddRef' : undeclared identifier
How did this one happen...it's the same code with the typedef thing fixed.

modFuncs->AddRef = MyExtension_AddRef;
e:\work\brew\adclientutil\_extensions.c(40) : error C2065: 'MyExtension_AddRef' : undeclared identifier
How did this one happen...it's the same code with the typedef thing fixed.

Did u check if you have declared the function prototypes ?

Did u check if you have declared the function prototypes ?

Ok....tried
static uint32 MyExtension_AddRef(IDemoExtension* pMe) ;
and
uint32 MyExtension_AddRef(IDemoExtension* pMe) ;
to declare it in the header file and they both caused errors....Am I doing this wrong?
I also updated the code above so it's current.

Ok....tried
static uint32 MyExtension_AddRef(IDemoExtension* pMe) ;
and
uint32 MyExtension_AddRef(IDemoExtension* pMe) ;
to declare it in the header file and they both caused errors....Am I doing this wrong?
I also updated the code above so it's current.

??????????

??????????

Hi mate,
Did not have time to look at the problem completely , but from what i glance at...just think that the basic problem you are facing is how to include the extension in your main program...this is why the error is occuring. Have you included the extension's class id in the dependencies tab of the mif of your main application?
Cheers !
Robin

Hi mate,
Did not have time to look at the problem completely , but from what i glance at...just think that the basic problem you are facing is how to include the extension in your main program...this is why the error is occuring. Have you included the extension's class id in the dependencies tab of the mif of your main application?
Cheers !
Robin

Umm...did that...my problem is that it won't compile....these are the errors when I comment the modfuncs line....what am I not getting here?
e:\work\brew\adclientutil\_extensions.c(45) : error C2223: left of '->m_nRefs' must point to struct/union
e:\work\brew\adclientutil\_extensions.c(46) : error C2223: left of '->m_pIShell' must point to struct/union
e:\work\brew\adclientutil\_extensions.c(47) : error C2223: left of '->m_pIModule' must point to struct/union
e:\work\brew\adclientutil\_extensions.c(52) : error C2223: left of '->m_pIDisplay' must point to struct/union
e:\work\brew\adclientutil\_extensions.c(52) : error C2198: 'function through pointer' : too few actual parameters
e:\work\brew\adclientutil\_extensions.c(58) : error C2143: syntax error : missing ')' before '*'
e:\work\brew\adclientutil\_extensions.c(62) : error C2143: syntax error : missing ')' before '*'
e:\work\brew\adclientutil\_extensions.c(75) : warning C4002: too many actual parameters for macro 'MyExtension_QueryInterface'
e:\work\brew\adclientutil\_extensions.c(75) : error C2143: syntax error : missing ')' before '*'
E:\WORK\BREW\adclientutil\adclientutil.c(56) : error C2084: function 'int __cdecl AEEClsCreateInstance(unsigned long ,struct _IShell *,struct _IModule *,void ** )' already has a body
_extensions.c
e:\work\brew\adclientutil\_extensions.c(45) : error C2223: left of '->m_nRefs' must point to struct/union
e:\work\brew\adclientutil\_extensions.c(46) : error C2223: left of '->m_pIShell' must point to struct/union
e:\work\brew\adclientutil\_extensions.c(47) : error C2223: left of '->m_pIModule' must point to struct/union
e:\work\brew\adclientutil\_extensions.c(52) : error C2223: left of '->m_pIDisplay' must point to struct/union
e:\work\brew\adclientutil\_extensions.c(52) : error C2198: 'function through pointer' : too few actual parameters
e:\work\brew\adclientutil\_extensions.c(58) : error C2143: syntax error : missing ')' before '*'
e:\work\brew\adclientutil\_extensions.c(62) : error C2143: syntax error : missing ')' before '*'
e:\work\brew\adclientutil\_extensions.c(75) : warning C4002: too many actual parameters for macro 'MyExtension_QueryInterface'
e:\work\brew\adclientutil\_extensions.c(75) : error C2143: syntax error : missing ')' before '*'
E:\WORK\BREW\adclientutil\_extensions.c(9) : error C2011: 'ext' : 'struct' type redefinition
E:\WORK\BREW\adclientutil\_extensions.c(21) : error C2084: function 'int __cdecl AEEClsCreateInstance(unsigned long ,struct _IShell *,struct _IModule *,void ** )' already has a body
E:\WORK\BREW\adclientutil\_extensions.c(29) : error C2084: function 'int __cdecl MyExtension_New(short ,struct _IShell *,struct _IModule *,struct _IModule ** )' already has a body
E:\WORK\BREW\adclientutil\_extensions.c(45) : error C2223: left of '->m_nRefs' must point to struct/union
E:\WORK\BREW\adclientutil\_extensions.c(46) : error C2223: left of '->m_pIShell' must point to struct/union
E:\WORK\BREW\adclientutil\_extensions.c(47) : error C2223: left of '->m_pIModule' must point to struct/union
E:\WORK\BREW\adclientutil\_extensions.c(52) : error C2223: left of '->m_pIDisplay' must point to struct/union
E:\WORK\BREW\adclientutil\_extensions.c(52) : error C2198: 'function through pointer' : too few actual parameters
E:\WORK\BREW\adclientutil\_extensions.c(58) : error C2143: syntax error : missing ')' before '*'
E:\WORK\BREW\adclientutil\_extensions.c(62) : error C2143: syntax error : missing ')' before '*'
E:\WORK\BREW\adclientutil\_extensions.c(75) : warning C4002: too many actual parameters for macro 'MyExtension_QueryInterface'
E:\WORK\BREW\adclientutil\_extensions.c(75) : error C2143: syntax error : missing ')' before '*'

Umm...did that...my problem is that it won't compile....these are the errors when I comment the modfuncs line....what am I not getting here?
e:\work\brew\adclientutil\_extensions.c(45) : error C2223: left of '->m_nRefs' must point to struct/union
e:\work\brew\adclientutil\_extensions.c(46) : error C2223: left of '->m_pIShell' must point to struct/union
e:\work\brew\adclientutil\_extensions.c(47) : error C2223: left of '->m_pIModule' must point to struct/union
e:\work\brew\adclientutil\_extensions.c(52) : error C2223: left of '->m_pIDisplay' must point to struct/union
e:\work\brew\adclientutil\_extensions.c(52) : error C2198: 'function through pointer' : too few actual parameters
e:\work\brew\adclientutil\_extensions.c(58) : error C2143: syntax error : missing ')' before '*'
e:\work\brew\adclientutil\_extensions.c(62) : error C2143: syntax error : missing ')' before '*'
e:\work\brew\adclientutil\_extensions.c(75) : warning C4002: too many actual parameters for macro 'MyExtension_QueryInterface'
e:\work\brew\adclientutil\_extensions.c(75) : error C2143: syntax error : missing ')' before '*'
E:\WORK\BREW\adclientutil\adclientutil.c(56) : error C2084: function 'int __cdecl AEEClsCreateInstance(unsigned long ,struct _IShell *,struct _IModule *,void ** )' already has a body
_extensions.c
e:\work\brew\adclientutil\_extensions.c(45) : error C2223: left of '->m_nRefs' must point to struct/union
e:\work\brew\adclientutil\_extensions.c(46) : error C2223: left of '->m_pIShell' must point to struct/union
e:\work\brew\adclientutil\_extensions.c(47) : error C2223: left of '->m_pIModule' must point to struct/union
e:\work\brew\adclientutil\_extensions.c(52) : error C2223: left of '->m_pIDisplay' must point to struct/union
e:\work\brew\adclientutil\_extensions.c(52) : error C2198: 'function through pointer' : too few actual parameters
e:\work\brew\adclientutil\_extensions.c(58) : error C2143: syntax error : missing ')' before '*'
e:\work\brew\adclientutil\_extensions.c(62) : error C2143: syntax error : missing ')' before '*'
e:\work\brew\adclientutil\_extensions.c(75) : warning C4002: too many actual parameters for macro 'MyExtension_QueryInterface'
e:\work\brew\adclientutil\_extensions.c(75) : error C2143: syntax error : missing ')' before '*'
E:\WORK\BREW\adclientutil\_extensions.c(9) : error C2011: 'ext' : 'struct' type redefinition
E:\WORK\BREW\adclientutil\_extensions.c(21) : error C2084: function 'int __cdecl AEEClsCreateInstance(unsigned long ,struct _IShell *,struct _IModule *,void ** )' already has a body
E:\WORK\BREW\adclientutil\_extensions.c(29) : error C2084: function 'int __cdecl MyExtension_New(short ,struct _IShell *,struct _IModule *,struct _IModule ** )' already has a body
E:\WORK\BREW\adclientutil\_extensions.c(45) : error C2223: left of '->m_nRefs' must point to struct/union
E:\WORK\BREW\adclientutil\_extensions.c(46) : error C2223: left of '->m_pIShell' must point to struct/union
E:\WORK\BREW\adclientutil\_extensions.c(47) : error C2223: left of '->m_pIModule' must point to struct/union
E:\WORK\BREW\adclientutil\_extensions.c(52) : error C2223: left of '->m_pIDisplay' must point to struct/union
E:\WORK\BREW\adclientutil\_extensions.c(52) : error C2198: 'function through pointer' : too few actual parameters
E:\WORK\BREW\adclientutil\_extensions.c(58) : error C2143: syntax error : missing ')' before '*'
E:\WORK\BREW\adclientutil\_extensions.c(62) : error C2143: syntax error : missing ')' before '*'
E:\WORK\BREW\adclientutil\_extensions.c(75) : warning C4002: too many actual parameters for macro 'MyExtension_QueryInterface'
E:\WORK\BREW\adclientutil\_extensions.c(75) : error C2143: syntax error : missing ')' before '*'

I'm guessing the problem is with:
typedef struct ext
{
.
.
;
This defines a type "struct ext", but you refer to plain old "ext" in your code. You want:
typdef struct
{
.
.
ext;
-Erik

I'm guessing the problem is with:
typedef struct ext
{
.
.
;
This defines a type "struct ext", but you refer to plain old "ext" in your code. You want:
typdef struct
{
.
.
ext;
-Erik

Why not use Extension with Extuse that comes with v101 download. It compiles and runs in simulator perfectly.
Adam

Why not use Extension with Extuse that comes with v101 download. It compiles and runs in simulator perfectly.
Adam

If your are using GNU compiler and lightblue (http://lightblue.tigris.org/)
Writing BREW extension will be much simplified:
Check following code and compare with the C implementation from above post:
=========================================================
#include "extension.h"
#include "brewpp_runtime/brewpp.hpp"
#include "AEEStdLib.h"
class CTestExtensionImp:public CBaseImp
{
public:
CTestExtensionImp(CDefaultBrewModule* pmod)
:m_pIModule(pmod)
{
if(m_pIModule)
{
m_pIModule->AddRef();
}
STRTOWSTR("!!! Hello extension !!!",m_Msg,sizeof(m_Msg));
}
override const AECHAR* BREW_CALL_CONV getString()
{
return m_Msg;
}
override ~CTestExtensionImp()
{
if(m_pIModule)
{
m_pIModule->Release();
}
}
private:
CDefaultBrewModule* m_pIModule;
AECHAR m_Msg[32];
;
extern "C" int AEEClsCreateInstance(AEECLSID ClsId,CDefaultBrewModule *pMod, void **ppobj)
{
*ppobj = NULL;
if(ClsId == CTestExtensionImp::CLS_ID)
{
*ppobj = (void**)new CTestExtensionImp(pMod);
return(AEE_SUCCESS);
}
return EFAILED;

==========================================================

If your are using GNU compiler and lightblue (http://lightblue.tigris.org/)
Writing BREW extension will be much simplified:
Check following code and compare with the C implementation from above post:
=========================================================
#include "extension.h"
#include "brewpp_runtime/brewpp.hpp"
#include "AEEStdLib.h"
class CTestExtensionImp:public CBaseImp
{
public:
CTestExtensionImp(CDefaultBrewModule* pmod)
:m_pIModule(pmod)
{
if(m_pIModule)
{
m_pIModule->AddRef();
}
STRTOWSTR("!!! Hello extension !!!",m_Msg,sizeof(m_Msg));
}
override const AECHAR* BREW_CALL_CONV getString()
{
return m_Msg;
}
override ~CTestExtensionImp()
{
if(m_pIModule)
{
m_pIModule->Release();
}
}
private:
CDefaultBrewModule* m_pIModule;
AECHAR m_Msg[32];
;
extern "C" int AEEClsCreateInstance(AEECLSID ClsId,CDefaultBrewModule *pMod, void **ppobj)
{
*ppobj = NULL;
if(ClsId == CTestExtensionImp::CLS_ID)
{
*ppobj = (void**)new CTestExtensionImp(pMod);
return(AEE_SUCCESS);
}
return EFAILED;

==========================================================