- minor fixes in script context
This commit is contained in:
@ -28,7 +28,6 @@ typedef struct ScriptContext {
|
|||||||
ObjectDescriptor *desc;
|
ObjectDescriptor *desc;
|
||||||
ContextItem *nodes;
|
ContextItem *nodes;
|
||||||
ContextItem *trash;
|
ContextItem *trash;
|
||||||
ContextItem *base;
|
|
||||||
} ScriptContext;
|
} ScriptContext;
|
||||||
|
|
||||||
struct SctController {
|
struct SctController {
|
||||||
@ -127,7 +126,7 @@ static char *GetProp(Hdb *node, Hdb *cNode, char *key) {
|
|||||||
if (val != NULL) return val;
|
if (val != NULL) return val;
|
||||||
}
|
}
|
||||||
if (cNode != NULL) {
|
if (cNode != NULL) {
|
||||||
val = GetHdbProp(node, key);
|
val = GetHdbProp(cNode, key);
|
||||||
}
|
}
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
@ -140,12 +139,16 @@ int SctCommand(SConnection *con, SicsInterp *sics, void *object,
|
|||||||
static char value[1024];
|
static char value[1024];
|
||||||
char *val;
|
char *val;
|
||||||
char error[512];
|
char error[512];
|
||||||
Hdb *node = sct->nodes->node;
|
Hdb *node = NULL;
|
||||||
Hdb *cNode = sct->nodes->controllerNode;
|
Hdb *cNode = NULL;
|
||||||
hdbValue v;
|
hdbValue v;
|
||||||
double dtime;
|
double dtime;
|
||||||
|
|
||||||
assert(sct == object);
|
assert(sct == object);
|
||||||
|
if (sct->nodes != NULL) {
|
||||||
|
node = sct->nodes->node;
|
||||||
|
cNode = sct->nodes->controllerNode;
|
||||||
|
}
|
||||||
if (node == NULL && cNode == NULL) {
|
if (node == NULL && cNode == NULL) {
|
||||||
SCPrintf(con, eError, "ERROR: %s may be called only in proper context",
|
SCPrintf(con, eError, "ERROR: %s may be called only in proper context",
|
||||||
argv[0]);
|
argv[0]);
|
||||||
@ -603,7 +606,6 @@ static int SctPollCmd(pSICSOBJ ccmd, SConnection *con,
|
|||||||
"%s poll registered on %s (%g sec, %s prio)",
|
"%s poll registered on %s (%g sec, %s prio)",
|
||||||
action, path, interval, prioText);
|
action, path, interval, prioText);
|
||||||
}
|
}
|
||||||
sct->base->node = node;
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -725,7 +727,6 @@ static int SctWriteCmd(pSICSOBJ ccmd, SConnection *con,
|
|||||||
}
|
}
|
||||||
|
|
||||||
SCSendOK(con);
|
SCSendOK(con);
|
||||||
sct->base->node = node;
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -942,14 +943,14 @@ static int SctMakeController(SConnection *con, SicsInterp *sics,
|
|||||||
ccmd->pPrivate = controller;
|
ccmd->pPrivate = controller;
|
||||||
ccmd->KillPrivate = SctKillController;
|
ccmd->KillPrivate = SctKillController;
|
||||||
|
|
||||||
AddCommand(pServ->pSics, nodeName, InvokeSICSOBJ, KillSICSOBJ, ccmd);
|
|
||||||
SetDescriptorKey(ccmd->pDes, "creationCommand", "0");
|
|
||||||
|
|
||||||
AddHipadabaChild(parent, controller->node, con);
|
AddHipadabaChild(parent, controller->node, con);
|
||||||
|
|
||||||
controller->devser = DevMake(con, argc - 2, argv + 2);
|
controller->devser = DevMake(con, argc - 2, argv + 2);
|
||||||
if (!controller->devser) return 0;
|
if (!controller->devser) return 0;
|
||||||
|
|
||||||
|
AddCommand(pServ->pSics, nodeName, InvokeSICSOBJ, KillSICSOBJ, ccmd);
|
||||||
|
SetDescriptorKey(ccmd->pDes, "creationCommand", "0");
|
||||||
|
|
||||||
cmd = AddSICSHdbPar(controller->node,
|
cmd = AddSICSHdbPar(controller->node,
|
||||||
"poll", usMugger, MakeSICSFunc(SctPollCmd));
|
"poll", usMugger, MakeSICSFunc(SctPollCmd));
|
||||||
AddSICSHdbPar(cmd, "node", usMugger, MakeHdbText(""));
|
AddSICSHdbPar(cmd, "node", usMugger, MakeHdbText(""));
|
||||||
@ -991,9 +992,6 @@ static int SctMakeController(SConnection *con, SicsInterp *sics,
|
|||||||
cb = MakeHipadabaCallback(SctDebugCallback, controller, NULL);
|
cb = MakeHipadabaCallback(SctDebugCallback, controller, NULL);
|
||||||
if (cb) AppendHipadabaCallback(par, cb);
|
if (cb) AppendHipadabaCallback(par, cb);
|
||||||
|
|
||||||
sct->base->controllerNode = controller->node;
|
|
||||||
sct->base->node = NULL;
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1021,8 +1019,6 @@ void SctInit(void) {
|
|||||||
sct = calloc(1, sizeof(*sct));
|
sct = calloc(1, sizeof(*sct));
|
||||||
assert(sct);
|
assert(sct);
|
||||||
sct->desc = CreateDescriptor("ScriptContext");
|
sct->desc = CreateDescriptor("ScriptContext");
|
||||||
PushContext(NULL, NULL);
|
|
||||||
sct->base = sct->nodes;
|
|
||||||
AddCommand(pServ->pSics, "sct", SctCommand, SctKill, sct);
|
AddCommand(pServ->pSics, "sct", SctCommand, SctKill, sct);
|
||||||
AddCmd("makesctcontroller", SctMakeController);
|
AddCmd("makesctcontroller", SctMakeController);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user