- changed formatValue for custom formats
- SICSOBJs may now have a value in the root node
This commit is contained in:
26
sicsobj.c
26
sicsobj.c
@ -20,8 +20,9 @@ static void DefaultKill(void *data){
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
pSICSOBJ MakeSICSOBJ(char *name, char *class){
|
pSICSOBJ MakeSICSOBJv(char *name, char *class, int type, int priv){
|
||||||
pSICSOBJ pNew = NULL;
|
pSICSOBJ pNew = NULL;
|
||||||
|
hdbValue val;
|
||||||
|
|
||||||
pNew = (pSICSOBJ)malloc(sizeof(SICSOBJ));
|
pNew = (pSICSOBJ)malloc(sizeof(SICSOBJ));
|
||||||
if(pNew == NULL){
|
if(pNew == NULL){
|
||||||
@ -29,7 +30,13 @@ pSICSOBJ MakeSICSOBJ(char *name, char *class){
|
|||||||
}
|
}
|
||||||
memset(pNew,0,sizeof(SICSOBJ));
|
memset(pNew,0,sizeof(SICSOBJ));
|
||||||
pNew->pDes = CreateDescriptor(class);
|
pNew->pDes = CreateDescriptor(class);
|
||||||
pNew->objectNode = MakeHipadabaNode(name, HIPNONE, 1);
|
if (type == HIPNONE) {
|
||||||
|
pNew->objectNode = MakeHipadabaNode(name, HIPNONE, 1);
|
||||||
|
} else {
|
||||||
|
val = makeHdbValue(type,0);
|
||||||
|
pNew->objectNode = MakeSICSHdbPar(name, priv, val);
|
||||||
|
ReleaseHdbValue(&val);
|
||||||
|
}
|
||||||
if(pNew->pDes == NULL || pNew->objectNode == NULL){
|
if(pNew->pDes == NULL || pNew->objectNode == NULL){
|
||||||
free(pNew);
|
free(pNew);
|
||||||
return(NULL);
|
return(NULL);
|
||||||
@ -39,6 +46,10 @@ pSICSOBJ MakeSICSOBJ(char *name, char *class){
|
|||||||
return pNew;
|
return pNew;
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
|
pSICSOBJ MakeSICSOBJ(char *name, char *class){
|
||||||
|
return MakeSICSOBJv(name, class, HIPNONE, 0);
|
||||||
|
}
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
void KillSICSOBJ(void *data){
|
void KillSICSOBJ(void *data){
|
||||||
pSICSOBJ self = (pSICSOBJ)data;
|
pSICSOBJ self = (pSICSOBJ)data;
|
||||||
if(self == NULL){
|
if(self == NULL){
|
||||||
@ -126,7 +137,7 @@ static int ScriptObjFunc(pSICSOBJ obj, SConnection *pCon, pHdb commandNode,
|
|||||||
Tcl_DStringInit(&com);
|
Tcl_DStringInit(&com);
|
||||||
Tcl_DStringAppend(&com,value,strlen(value));
|
Tcl_DStringAppend(&com,value,strlen(value));
|
||||||
for(i = 0; i < nCount; i++){
|
for(i = 0; i < nCount; i++){
|
||||||
val = formatValue(par[i]->value);
|
val = formatValue(par[i]->value, par[i]);
|
||||||
if(val != NULL){
|
if(val != NULL){
|
||||||
Tcl_DStringAppend(&com," ", 1);
|
Tcl_DStringAppend(&com," ", 1);
|
||||||
pPtr = GetCharArray(val);
|
pPtr = GetCharArray(val);
|
||||||
@ -209,12 +220,15 @@ int InvokeSICSOBJ(SConnection *pCon, SicsInterp *pSics, void *pData,
|
|||||||
SCWrite(pCon,"ERROR: Nothing to process",eError);
|
SCWrite(pCon,"ERROR: Nothing to process",eError);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
parNode = GetHipadabaNode(self->objectNode,argv[1]);
|
if (argc == 1) {
|
||||||
|
parNode = self->objectNode;
|
||||||
|
} else {
|
||||||
|
parNode = GetHipadabaNode(self->objectNode,argv[1]);
|
||||||
|
}
|
||||||
if(parNode != NULL && parNode->value.dataType == HIPFUNC){
|
if(parNode != NULL && parNode->value.dataType == HIPFUNC){
|
||||||
status = invokeOBJFunction(self, parNode, pCon, argc-2, &argv[2]);
|
status = invokeOBJFunction(self, parNode, pCon, argc-2, &argv[2]);
|
||||||
} else {
|
} else {
|
||||||
strncpy(buffer,argv[0],130);
|
snprintf(buffer, sizeof buffer, "%s ", argv[0]);
|
||||||
strcat(buffer," ");
|
|
||||||
status = ProcessSICSHdbPar(self->objectNode,pCon, buffer,
|
status = ProcessSICSHdbPar(self->objectNode,pCon, buffer,
|
||||||
argc-1,&argv[1]);
|
argc-1,&argv[1]);
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,7 @@ typedef int (*SICSOBJFunc)(pSICSOBJ self, SConnection *pCon,
|
|||||||
pHdb commandNode, pHdb par[], int nPar);
|
pHdb commandNode, pHdb par[], int nPar);
|
||||||
/*======================= Live & Death =================================*/
|
/*======================= Live & Death =================================*/
|
||||||
pSICSOBJ MakeSICSOBJ(char *name, char *class);
|
pSICSOBJ MakeSICSOBJ(char *name, char *class);
|
||||||
|
pSICSOBJ MakeSICSOBJv(char *name, char *class, int type, int priv);
|
||||||
void KillSICSOBJ(void *data);
|
void KillSICSOBJ(void *data);
|
||||||
/**
|
/**
|
||||||
* This creates a new SICS object and installs it in the interpreter. It returns
|
* This creates a new SICS object and installs it in the interpreter. It returns
|
||||||
|
Reference in New Issue
Block a user