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.
This commit is contained in:
@@ -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'");
|
||||
|
||||
Reference in New Issue
Block a user