function replaced by registrar
This commit is contained in:
@@ -144,7 +144,7 @@ typedef struct dbBase {
|
||||
ELLLIST menuList;
|
||||
ELLLIST recordTypeList;
|
||||
ELLLIST drvList;
|
||||
ELLLIST funcList;
|
||||
ELLLIST registrarList;
|
||||
ELLLIST bptList; /*Break Point Table Head*/
|
||||
void *pathPvt;
|
||||
void *ppvd; /* pointer to process variable directory*/
|
||||
|
||||
@@ -88,7 +88,7 @@ int main(int argc,char **argv)
|
||||
dbWriteRecordTypeFP(pdbbase,stdout,0);
|
||||
dbWriteDeviceFP(pdbbase,stdout);
|
||||
dbWriteDriverFP(pdbbase,stdout);
|
||||
dbWriteFunctionFP(pdbbase,stdout);
|
||||
dbWriteRegistrarFP(pdbbase,stdout);
|
||||
dbWriteBreaktableFP(pdbbase,stdout);
|
||||
dbWriteRecordFP(pdbbase,stdout,0,0);
|
||||
free((void *)path);
|
||||
|
||||
@@ -31,7 +31,7 @@ static int yyreset(void)
|
||||
"record" return(tokenRECORD);
|
||||
"grecord" return(tokenGRECORD);
|
||||
"info" return(tokenINFO);
|
||||
"function" return(tokenFUNCTION);
|
||||
"registrar" return(tokenREGISTRAR);
|
||||
|
||||
[0-9]+ { /*integer number*/
|
||||
yylval.Str = (char *)dbmfMalloc(strlen(yytext)+1);
|
||||
|
||||
@@ -62,6 +62,7 @@ static void dbRecordtypeFieldItem(char *name,char *value);
|
||||
static void dbDevice(char *recordtype,char *linktype,
|
||||
char *dsetname,char *choicestring);
|
||||
static void dbDriver(char *name);
|
||||
static void dbRegistrar(char *name);
|
||||
|
||||
static void dbBreakHead(char *name);
|
||||
static void dbBreakItem(char *value);
|
||||
@@ -744,23 +745,23 @@ static void dbDriver(char *name)
|
||||
ellAdd(&pdbbase->drvList,&pdrvSup->node);
|
||||
}
|
||||
|
||||
static void dbFunction(char *name)
|
||||
static void dbRegistrar(char *name)
|
||||
{
|
||||
dbText *ptext;
|
||||
GPHENTRY *pgphentry;
|
||||
|
||||
pgphentry = gphFind(pdbbase->pgpHash,name,&pdbbase->funcList);
|
||||
pgphentry = gphFind(pdbbase->pgpHash,name,&pdbbase->registrarList);
|
||||
if(pgphentry) {
|
||||
return;
|
||||
}
|
||||
ptext = dbCalloc(1,sizeof(dbText));
|
||||
ptext->text = strduplicate(name);
|
||||
pgphentry = gphAdd(pdbbase->pgpHash,ptext->text,&pdbbase->funcList);
|
||||
pgphentry = gphAdd(pdbbase->pgpHash,ptext->text,&pdbbase->registrarList);
|
||||
if(!pgphentry) {
|
||||
yyerrorAbort("gphAdd failed");
|
||||
}
|
||||
pgphentry->userPvt = ptext;
|
||||
ellAdd(&pdbbase->funcList,&ptext->node);
|
||||
ellAdd(&pdbbase->registrarList,&ptext->node);
|
||||
}
|
||||
|
||||
static void dbBreakHead(char *name)
|
||||
|
||||
@@ -545,7 +545,7 @@ dbBase * epicsShareAPI dbAllocBase(void)
|
||||
ellInit(&pdbbase->menuList);
|
||||
ellInit(&pdbbase->recordTypeList);
|
||||
ellInit(&pdbbase->drvList);
|
||||
ellInit(&pdbbase->funcList);
|
||||
ellInit(&pdbbase->registrarList);
|
||||
ellInit(&pdbbase->bptList);
|
||||
gphInitPvt(&pdbbase->pgpHash,256);
|
||||
dbPvdInitPvt(pdbbase);
|
||||
@@ -665,10 +665,10 @@ void epicsShareAPI dbFreeBase(dbBase *pdbbase)
|
||||
free((void *)pdrvSup);
|
||||
pdrvSup = pdrvSupNext;
|
||||
}
|
||||
ptext = (dbText *)ellFirst(&pdbbase->funcList);
|
||||
ptext = (dbText *)ellFirst(&pdbbase->registrarList);
|
||||
while(ptext) {
|
||||
ptextNext = (dbText *)ellNext(&ptext->node);
|
||||
ellDelete(&pdbbase->funcList,&ptext->node);
|
||||
ellDelete(&pdbbase->registrarList,&ptext->node);
|
||||
free((void *)ptext->text);
|
||||
free((void *)ptext);
|
||||
ptext = ptextNext;
|
||||
@@ -1149,7 +1149,7 @@ long epicsShareAPI dbWriteDriverFP(DBBASE *pdbbase,FILE *fp)
|
||||
return(0);
|
||||
}
|
||||
|
||||
long epicsShareAPI dbWriteFunctionFP(DBBASE *pdbbase,FILE *fp)
|
||||
long epicsShareAPI dbWriteRegistrarFP(DBBASE *pdbbase,FILE *fp)
|
||||
{
|
||||
dbText *ptext;
|
||||
|
||||
@@ -1157,9 +1157,9 @@ long epicsShareAPI dbWriteFunctionFP(DBBASE *pdbbase,FILE *fp)
|
||||
fprintf(stderr,"pdbbase not specified\n");
|
||||
return(-1);
|
||||
}
|
||||
for(ptext = (dbText *)ellFirst(&pdbbase->funcList);
|
||||
for(ptext = (dbText *)ellFirst(&pdbbase->registrarList);
|
||||
ptext; ptext = (dbText *)ellNext(&ptext->node)) {
|
||||
fprintf(fp,"function(%s)\n",ptext->text);
|
||||
fprintf(fp,"registrar(%s)\n",ptext->text);
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
@@ -3769,13 +3769,13 @@ void epicsShareAPI dbDumpDriver(DBBASE *pdbbase)
|
||||
dbWriteDriverFP(pdbbase,stdout);
|
||||
}
|
||||
|
||||
void epicsShareAPI dbDumpFunction(DBBASE *pdbbase)
|
||||
void epicsShareAPI dbDumpRegistrar(DBBASE *pdbbase)
|
||||
{
|
||||
if(!pdbbase) {
|
||||
printf("pdbbase not specified\n");
|
||||
return;
|
||||
}
|
||||
dbWriteFunctionFP(pdbbase,stdout);
|
||||
dbWriteRegistrarFP(pdbbase,stdout);
|
||||
}
|
||||
|
||||
void epicsShareAPI dbDumpBreaktable(DBBASE *pdbbase,const char *name)
|
||||
|
||||
@@ -99,7 +99,7 @@ epicsShareFunc long epicsShareAPI dbWriteDeviceFP(DBBASE *pdbbase,FILE *fp);
|
||||
epicsShareFunc long epicsShareAPI dbWriteDriver(
|
||||
DBBASE *pdbbase,const char *filename);
|
||||
epicsShareFunc long epicsShareAPI dbWriteDriverFP(DBBASE *pdbbase,FILE *fp);
|
||||
epicsShareFunc long epicsShareAPI dbWriteFunctionFP(DBBASE *pdbbase,FILE *fp);
|
||||
epicsShareFunc long epicsShareAPI dbWriteRegistrarFP(DBBASE *pdbbase,FILE *fp);
|
||||
epicsShareFunc long epicsShareAPI dbWriteBreaktable(
|
||||
DBBASE *pdbbase,const char *filename);
|
||||
epicsShareFunc long epicsShareAPI dbWriteBreaktableFP(DBBASE *pdbbase,FILE *fp);
|
||||
@@ -214,7 +214,7 @@ epicsShareFunc void epicsShareAPI dbDumpField(
|
||||
epicsShareFunc void epicsShareAPI dbDumpDevice(
|
||||
DBBASE *pdbbase,const char *recordTypeName);
|
||||
epicsShareFunc void epicsShareAPI dbDumpDriver(DBBASE *pdbbase);
|
||||
epicsShareFunc void epicsShareAPI dbDumpFunction(DBBASE *pdbbase);
|
||||
epicsShareFunc void epicsShareAPI dbDumpRegistrar(DBBASE *pdbbase);
|
||||
epicsShareFunc void epicsShareAPI dbDumpBreaktable(
|
||||
DBBASE *pdbbase,const char *name);
|
||||
epicsShareFunc void epicsShareAPI dbPvdDump(DBBASE *pdbbase,int verbose);
|
||||
|
||||
@@ -11,7 +11,7 @@ static int yyAbort = 0;
|
||||
|
||||
%token tokenINCLUDE tokenPATH tokenADDPATH
|
||||
%token tokenMENU tokenCHOICE tokenRECORDTYPE
|
||||
%token tokenFIELD tokenINFO tokenFUNCTION
|
||||
%token tokenFIELD tokenINFO tokenREGISTRAR
|
||||
%token tokenDEVICE tokenDRIVER tokenBREAKTABLE
|
||||
%token tokenRECORD tokenGRECORD
|
||||
%token <Str> tokenSTRING tokenCDEFS
|
||||
@@ -32,7 +32,7 @@ database_item: include
|
||||
| tokenRECORDTYPE recordtype_head recordtype_body
|
||||
| device
|
||||
| driver
|
||||
| function
|
||||
| registrar
|
||||
| tokenBREAKTABLE break_head break_body
|
||||
| tokenRECORD record_head record_body
|
||||
| tokenGRECORD grecord_head record_body
|
||||
@@ -140,10 +140,10 @@ driver: tokenDRIVER '(' tokenSTRING ')'
|
||||
dbDriver($3); dbmfFree($3);
|
||||
};
|
||||
|
||||
function: tokenFUNCTION '(' tokenSTRING ')'
|
||||
registrar: tokenREGISTRAR '(' tokenSTRING ')'
|
||||
{
|
||||
if(dbStaticDebug>2) printf("function %s\n",$3);
|
||||
dbFunction($3); dbmfFree($3);
|
||||
if(dbStaticDebug>2) printf("registrar %s\n",$3);
|
||||
dbRegistrar($3); dbmfFree($3);
|
||||
};
|
||||
|
||||
break_head: '(' tokenSTRING ')'
|
||||
|
||||
@@ -97,13 +97,13 @@ static void dbDumpDriverCallFunc(const iocshArgBuf *args)
|
||||
dbDumpDriver(pdbbase);
|
||||
}
|
||||
|
||||
/* dbDumpFunction */
|
||||
static const iocshArg dbDumpFunctionArg0 = { "pdbbase",iocshArgPdbbase};
|
||||
static const iocshArg * const dbDumpFunctionArgs[1] = {&dbDumpFunctionArg0};
|
||||
static const iocshFuncDef dbDumpFunctionFuncDef = {"dbDumpFunction",1,dbDumpFunctionArgs};
|
||||
static void dbDumpFunctionCallFunc(const iocshArgBuf *args)
|
||||
/* dbDumpRegistrar */
|
||||
static const iocshArg dbDumpRegistrarArg0 = { "pdbbase",iocshArgPdbbase};
|
||||
static const iocshArg * const dbDumpRegistrarArgs[1] = {&dbDumpRegistrarArg0};
|
||||
static const iocshFuncDef dbDumpRegistrarFuncDef = {"dbDumpRegistrar",1,dbDumpRegistrarArgs};
|
||||
static void dbDumpRegistrarCallFunc(const iocshArgBuf *args)
|
||||
{
|
||||
dbDumpFunction(pdbbase);
|
||||
dbDumpRegistrar(pdbbase);
|
||||
}
|
||||
|
||||
/* dbDumpBreaktable */
|
||||
@@ -137,7 +137,7 @@ void epicsShareAPI dbStaticRegister(void)
|
||||
iocshRegister(&dbDumpFieldFuncDef,dbDumpFieldCallFunc);
|
||||
iocshRegister(&dbDumpDeviceFuncDef,dbDumpDeviceCallFunc);
|
||||
iocshRegister(&dbDumpDriverFuncDef,dbDumpDriverCallFunc);
|
||||
iocshRegister(&dbDumpFunctionFuncDef,dbDumpFunctionCallFunc);
|
||||
iocshRegister(&dbDumpRegistrarFuncDef,dbDumpRegistrarCallFunc);
|
||||
iocshRegister(&dbDumpBreaktableFuncDef,dbDumpBreaktableCallFunc);
|
||||
iocshRegister(&dbPvdDumpFuncDef,dbPvdDumpCallFunc);
|
||||
}
|
||||
|
||||
@@ -17,8 +17,9 @@ LIBRARY_IOC += _APPNAME_Ioc
|
||||
|
||||
_APPNAME_Ioc_SRCS += xxxRecord.c
|
||||
_APPNAME_Ioc_SRCS += devXxxSoft.c
|
||||
_APPNAME_Ioc_SRCS += dbSubExample.c
|
||||
|
||||
_APPNAME_Ioc_LIBS += $(EPICS_BASE_IOC_LIBRARIES)
|
||||
_APPNAME_Ioc_LIBS += $(EPICS_BASE_IOC_LIBS)
|
||||
_APPNAME_Ioc_SYS_LIBS_solaris += c
|
||||
|
||||
#=============================
|
||||
@@ -27,7 +28,6 @@ PROD_IOC = _APPNAME_
|
||||
|
||||
# <name>_registerRecordDeviceDriver.cpp will be created from <name>.dbd
|
||||
_APPNAME__SRCS += _APPNAME__registerRecordDeviceDriver.cpp
|
||||
_APPNAME__SRCS += dbSubExample.c
|
||||
_APPNAME__SRCS_DEFAULT += _APPNAME_Main.cpp
|
||||
_APPNAME__SRCS_vxWorks += -nil-
|
||||
|
||||
@@ -46,7 +46,7 @@ _APPNAME__LIBS += _APPNAME_Ioc
|
||||
#_APPNAME__LIBS += seq
|
||||
#_APPNAME__LIBS += pv
|
||||
|
||||
_APPNAME__LIBS += $(EPICS_BASE_IOC_LIBRARIES)
|
||||
_APPNAME__LIBS += $(EPICS_BASE_IOC_LIBS)
|
||||
|
||||
#The following builds sncExample as a standalone application
|
||||
#PROD_HOST += sncExample
|
||||
@@ -54,7 +54,7 @@ _APPNAME__LIBS += $(EPICS_BASE_IOC_LIBRARIES)
|
||||
#sncExample_SRCS += sncExample.stt
|
||||
#sncExample_LIBS += seq
|
||||
#sncExample_LIBS += pv
|
||||
#sncExample_LIBS += $(EPICS_BASE_IOC_LIBRARIES)
|
||||
#sncExample_LIBS += $(EPICS_BASE_HOST_LIBS)
|
||||
|
||||
#===========================
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
include "base.dbd"
|
||||
include "xxxRecord.dbd"
|
||||
device(xxx,CONSTANT,devXxxSoft,"SoftChannel")
|
||||
function("mySubInit")
|
||||
function("mySubProcess")
|
||||
registrar("mySub")
|
||||
|
||||
@@ -1,18 +1,33 @@
|
||||
#include <stdio.h>
|
||||
#include "subRecord.h"
|
||||
|
||||
#include <registryFunction.h>
|
||||
#include <subRecord.h>
|
||||
#define epicsExportSharedSymbols
|
||||
#include "shareLib.h"
|
||||
|
||||
typedef long (*processMethod)(subRecord *precord);
|
||||
|
||||
long mySubInit(subRecord *precord,processMethod process)
|
||||
static long mySubInit(subRecord *precord,processMethod process)
|
||||
{
|
||||
printf("Record %s called mySubInit(%p, %p)\n",
|
||||
precord->name, (void*) precord, (void*) process);
|
||||
return(0);
|
||||
}
|
||||
|
||||
long mySubProcess(subRecord *precord)
|
||||
static long mySubProcess(subRecord *precord)
|
||||
{
|
||||
printf("Record %s called mySubProcess(%p)\n",
|
||||
precord->name, (void*) precord);
|
||||
return(0);
|
||||
}
|
||||
|
||||
static registryFunctionRef mySubRef[] = {
|
||||
{"mySubInit",(REGISTRYFUNCTION)mySubInit},
|
||||
{"mySubProcess",(REGISTRYFUNCTION)mySubProcess}
|
||||
};
|
||||
|
||||
epicsShareFunc void epicsShareAPI mySub(void)
|
||||
{
|
||||
registryFunctionRefAdd(mySubRef,registryFunctionRefNumber(mySubRef));
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ $file = $ARGV[0];
|
||||
$numberRecordType = 0;
|
||||
$numberDeviceSupport = 0;
|
||||
$numberDriverSupport = 0;
|
||||
$numberFunctions = 0;
|
||||
$numberRegistrar = 0;
|
||||
|
||||
open(INP,"$file") or die "$! opening file";
|
||||
while(<INP>) {
|
||||
@@ -32,9 +32,9 @@ while(<INP>) {
|
||||
/driver\s*\(\s*(\w+)/;
|
||||
$driverSupport[$numberDriverSupport++] = $1;
|
||||
}
|
||||
if( /function/) {
|
||||
/function\s*\(\s*(\w+)/;
|
||||
$function[$numberFunctions++] = $1;
|
||||
if( /registrar/) {
|
||||
/registrar\s*\(\s*(\w+)/;
|
||||
$registrar[$numberRegistrar++] = $1;
|
||||
}
|
||||
}
|
||||
close(INP) or die "$! closing file";
|
||||
@@ -59,7 +59,6 @@ print << "END" ;
|
||||
#include "registryRecordType.h"
|
||||
#include "registryDeviceSupport.h"
|
||||
#include "registryDriverSupport.h"
|
||||
#include "registryFunction.h"
|
||||
#include "iocsh.h"
|
||||
#include "shareLib.h"
|
||||
END
|
||||
@@ -151,23 +150,19 @@ if($numberDriverSupport>0) {
|
||||
print "};\n\n";
|
||||
}
|
||||
|
||||
#definitions functions
|
||||
if($numberFunctions>0) {
|
||||
for ($i=0; $i<$numberFunctions; $i++) {
|
||||
print "extern \"C\" void $function[$i](void);\n";
|
||||
#definitions registrar
|
||||
if($numberRegistrar>0) {
|
||||
print "typedef void(*REGISTRARFUNC)(void);\n";
|
||||
print "extern \"C\" {\n";
|
||||
for ($i=0; $i<$numberRegistrar; $i++) {
|
||||
print "epicsShareFunc void epicsShareAPI $registrar[$i](void);\n";
|
||||
}
|
||||
print "\nstatic const char *functionNames[$numberFunctions] = {\n";
|
||||
for ($i=0; $i<$numberFunctions; $i++) {
|
||||
print " \"$function[$i]\"";
|
||||
if($i < $numberFunctions-1) { print ",";}
|
||||
print "\n";
|
||||
}
|
||||
print "};\n\n";
|
||||
print "}\n\n";
|
||||
|
||||
print "static REGISTRYFUNCTION fncsl[$i] = {\n";
|
||||
for ($i=0; $i<$numberFunctions; $i++) {
|
||||
print " $function[$i]";
|
||||
if($i < $numberFunctions-1) { print ",";}
|
||||
print "static REGISTRARFUNC registrarFunctions[$i] = {\n";
|
||||
for ($i=0; $i<$numberRegistrar; $i++) {
|
||||
print " &$registrar[$i]";
|
||||
if($i < $numberRegistrar-1) { print ",";}
|
||||
print "\n";
|
||||
}
|
||||
print "};\n\n";
|
||||
@@ -230,15 +225,10 @@ if($numberDriverSupport>0) {
|
||||
}
|
||||
END
|
||||
}
|
||||
if($numberFunctions>0) {
|
||||
if($numberRegistrar>0) {
|
||||
print << "END" ;
|
||||
for(i=0; i< $numberFunctions; i++ ) {
|
||||
if(registryFunctionFind(functionNames[i])) continue;
|
||||
if(!registryFunctionAdd(functionNames[i],fncsl[i])) {
|
||||
errlogPrintf(\"registryFunctionAdd failed %s\\n\",
|
||||
functionNames[i]);
|
||||
continue;
|
||||
}
|
||||
for(i=0; i< $numberRegistrar; i++ ) {
|
||||
registrarFunctions[i]();
|
||||
}
|
||||
END
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#define epicsExportSharedSymbols
|
||||
#include "registry.h"
|
||||
@@ -40,3 +41,18 @@ epicsShareFunc REGISTRYFUNCTION epicsShareAPI registryFunctionFind(
|
||||
}
|
||||
return(func);
|
||||
}
|
||||
|
||||
epicsShareFunc int epicsShareAPI registryFunctionRefAdd(
|
||||
registryFunctionRef ref[],int nfunctions)
|
||||
{
|
||||
int ind;
|
||||
|
||||
for(ind=0; ind<nfunctions; ind++) {
|
||||
if(!registryFunctionAdd(ref[ind].name,ref[ind].addr)) {
|
||||
printf("registryFunctionRefAdd: could not register %s\n",
|
||||
ref[ind].name);
|
||||
return(0);
|
||||
}
|
||||
}
|
||||
return(1);
|
||||
}
|
||||
|
||||
@@ -18,11 +18,20 @@ extern "C" {
|
||||
|
||||
typedef void (*REGISTRYFUNCTION)(void);
|
||||
|
||||
typedef struct registryFunctionRef {
|
||||
char *name;
|
||||
REGISTRYFUNCTION addr;
|
||||
}registryFunctionRef;
|
||||
#define registryFunctionRefNumber(functionRefArray) \
|
||||
(sizeof((functionRefArray))/sizeof(registryFunctionRef))
|
||||
|
||||
/* c interface definitions */
|
||||
epicsShareFunc int epicsShareAPI registryFunctionAdd(
|
||||
const char *name,REGISTRYFUNCTION func);
|
||||
epicsShareFunc REGISTRYFUNCTION epicsShareAPI registryFunctionFind(
|
||||
const char *name);
|
||||
epicsShareFunc int epicsShareAPI registryFunctionRefAdd(
|
||||
registryFunctionRef ref[],int nfunctions);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user