Add jlif::start_child() method

This commit is contained in:
Andrew Johnson
2018-06-01 23:23:54 -05:00
parent 3b89515664
commit fd30989f63
7 changed files with 28 additions and 16 deletions

View File

@@ -215,6 +215,7 @@ static int dbjl_map_key(void *ctx, const unsigned char *key, size_t len) {
char *link_name;
linkSup *linkSup;
jlif *pjlif;
jlink *child;
if (parser->dbfType == 0) {
if (!pjlink) {
@@ -260,31 +261,35 @@ static int dbjl_map_key(void *ctx, const unsigned char *key, size_t len) {
return dbjl_return(parser, jlif_stop);
}
pjlink = pjlif->alloc_jlink(parser->dbfType);
if (!pjlink) {
child = pjlif->alloc_jlink(parser->dbfType);
if (!child) {
errlogPrintf("dbJLinkInit: Link type '%s' allocation failed. \n",
link_name);
dbmfFree(link_name);
return dbjl_return(parser, jlif_stop);
}
pjlink->pif = pjlif;
pjlink->parseDepth = 0;
child->pif = pjlif;
child->parseDepth = 0;
child->debug = 0;
if (parser->pjlink) {
/* We're starting a child link, save its parent */
pjlink->parent = parser->pjlink;
child->parent = pjlink;
if (pjlink->pif->start_child)
pjlink->pif->start_child(pjlink, child);
}
else
pjlink->parent = NULL;
child->parent = NULL;
parser->pjlink = pjlink;
parser->pjlink = child;
parser->dbfType = 0;
dbmfFree(link_name);
IFDEBUG(8)
printf("dbjl_map_key: New %s@%p\n", pjlink ? pjlink->pif->name : "", pjlink);
printf("dbjl_map_key: New %s@%p\n", child ? child->pif->name : "", child);
return jlif_continue;
}

View File

@@ -90,7 +90,8 @@ typedef struct jlif {
void (*end_child)(jlink *parent, jlink *child);
/* Optional, called with pointer to the new child link after
* parse_start_map() returned jlif_key_child_link */
* the child link has finished parsing successfully
*/
struct lset* (*get_lset)(const jlink *);
/* Required, return lset for this link instance */
@@ -107,6 +108,12 @@ typedef struct jlif {
* Stop immediately and return status if non-zero.
*/
void (*start_child)(jlink *parent, jlink *child);
/* Optional, called with pointer to the new child link after
* parse_start_map() returned a jlif_key_child_link value and
* the child link has been allocated (but not parsed yet)
*/
/* Link types must NOT extend this table with their own routines,
* this space is reserved for extensions to the jlink interface.
*/

View File

@@ -246,7 +246,8 @@ static jlif jlifZ = {
NULL, /* end child */
&z_lset,
NULL, /* report */
NULL /* map child */
NULL, /* map child */
NULL /* start child */
};
epicsExportAddress(jlif, jlifZ);

View File

@@ -2,7 +2,7 @@
* Copyright (c) 2016 UChicago Argonne LLC, as Operator of Argonne
* National Laboratory.
* EPICS BASE is distributed subject to a Software License Agreement found
* in file LICENSE that is included with this distribution.
* in file LICENSE that is included with this distribution.
\*************************************************************************/
/* xLink.c */
@@ -82,7 +82,6 @@ static jlif xlinkIf = {
NULL, NULL, NULL,
NULL, NULL,
NULL, xlink_get_lset,
NULL, NULL
NULL, NULL, NULL
};
epicsExportAddress(jlif, xlinkIf);

View File

@@ -847,6 +847,6 @@ static jlif lnkCalcIf = {
lnkCalc_start_map, lnkCalc_map_key, lnkCalc_end_map,
lnkCalc_start_array, lnkCalc_end_array,
lnkCalc_end_child, lnkCalc_get_lset,
lnkCalc_report, lnkCalc_map_children
lnkCalc_report, lnkCalc_map_children, NULL
};
epicsExportAddress(jlif, lnkCalcIf);

View File

@@ -631,6 +631,6 @@ static jlif lnkConstIf = {
NULL, NULL, NULL,
lnkConst_start_array, lnkConst_end_array,
NULL, lnkConst_get_lset,
lnkConst_report, NULL
lnkConst_report, NULL, NULL
};
epicsExportAddress(jlif, lnkConstIf);

View File

@@ -280,6 +280,6 @@ static jlif lnkStateIf = {
NULL, NULL, NULL,
NULL, NULL,
NULL, lnkState_get_lset,
lnkState_report, NULL
lnkState_report, NULL, NULL
};
epicsExportAddress(jlif, lnkStateIf);