From 8eed4cdd8812dffe77b82501dc08e1ef96b32275 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Sun, 27 Jul 2014 23:37:58 -0500 Subject: [PATCH] Perl DBD Parser: Autovivify record types in device() entries If a record type named in a device() entry does not exist when the device is seen, the DBD parser will now print a warning and create an empty record type with that name to hold the device entry information. This will allow support modules to be built into libraries that include their own registerRecordDeviceDriver code, which was apparently possible with 3.14 although not officially supported. To avoid the warning message, the DBD file can declare each record type before the device statement that uses it. A record type declaration looks like this: recordtype(ao) {} device(ao, ....) An IOC will accept and ignore a record type declaration, but it must have loaded the full record type definition first. --- src/tools/DBD/Parser.pm | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/tools/DBD/Parser.pm b/src/tools/DBD/Parser.pm index 8cace9c17..b8cc82783 100644 --- a/src/tools/DBD/Parser.pm +++ b/src/tools/DBD/Parser.pm @@ -59,9 +59,12 @@ sub ParseDBD { \s* $RXstr \s* , \s*$RXstr \s* \)/oxgc) { print "Device: $1, $2, $3, $4\n" if $debug; my $rtyp = $dbd->recordtype($1); - dieContext("Unknown record type '$1'") - unless defined $rtyp; - $rtyp->add_device(DBD::Device->new($2, $3, $4)); + if (!defined $rtyp) { + $rtyp = DBD::Recordtype->new($1); + warn "Device using undefined record type '$1', place-holder created\n"; + $dbd->add($rtyp); + } + $rtyp->add_device(DBD::Device->new($2, $3, $4)); } else { last unless m/\G (.*) $/moxgc; dieContext("Syntax error in '$1'");