- Added a means to overload or define drivable interfaces in tcl
This commit is contained in:
23
tclintimpl.c
23
tclintimpl.c
@@ -19,6 +19,7 @@
|
||||
/*================== our data structure ===================================*/
|
||||
typedef struct {
|
||||
pObjectDescriptor pDes;
|
||||
pIDrivable pDriv;
|
||||
char *saveScript;
|
||||
FILE *fd;
|
||||
} tclInt, *pTclInt;
|
||||
@@ -48,6 +49,20 @@ static int TclSaveStatus(void *pData, char *name, FILE *fd){
|
||||
|
||||
return 1;
|
||||
}
|
||||
/*-----------------------------------------------------------------------*/
|
||||
static void *TclGetInterface(void *pData, int id){
|
||||
pTclInt self = NULL;
|
||||
self = (pTclInt)pData;
|
||||
if(self == NULL){
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(id == DRIVEID){
|
||||
return self->pDriv;
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
/*======================== data structure creation and deletion ==========*/
|
||||
static pTclInt MakeTclIntData(void){
|
||||
pTclInt pNew = NULL;
|
||||
@@ -59,7 +74,9 @@ static pTclInt MakeTclIntData(void){
|
||||
memset(pNew,0,sizeof(tclInt));
|
||||
pNew->pDes = CreateDescriptor("SICS Interfaces in Tcl");
|
||||
pNew->pDes->SaveStatus = TclSaveStatus;
|
||||
if(!pNew->pDes){
|
||||
pNew->pDes->GetInterface = TclGetInterface;
|
||||
pNew->pDriv = CreateDrivableInterface();
|
||||
if(!pNew->pDes || !pNew->pDriv){
|
||||
free(pNew);
|
||||
return NULL;
|
||||
}
|
||||
@@ -80,6 +97,9 @@ static void KillTclInt(void *pData){
|
||||
if(self->saveScript != NULL){
|
||||
free(self->saveScript);
|
||||
}
|
||||
if(self->pDriv){
|
||||
free(self->pDriv);
|
||||
}
|
||||
free(self);
|
||||
}
|
||||
/*=============== interpreter interface + helper functions =============*/
|
||||
@@ -154,3 +174,4 @@ int TclIntAction(SConnection *pCon, SicsInterp *pSics, void *pData,
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user