mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-04-22 02:10:32 +00:00
fhem.pl: add CallInstanceFn (Forum #64741)
git-svn-id: https://svn.fhem.de/fhem/trunk@13053 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
2e5f616c19
commit
204e9c3c75
33
fhem/fhem.pl
33
fhem/fhem.pl
@ -3304,6 +3304,39 @@ CallFn(@)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#####################################
|
||||||
|
# Alternative to CallFn with optional functions in $defs, Forum #64741
|
||||||
|
sub
|
||||||
|
CallInstanceFn(@)
|
||||||
|
{
|
||||||
|
my $d = shift;
|
||||||
|
my $n = shift;
|
||||||
|
|
||||||
|
if(!$d || !$defs{$d}) {
|
||||||
|
$d = "<undefined>" if(!defined($d));
|
||||||
|
Log 0, "Strange call for nonexistent $d: $n";
|
||||||
|
return undef;
|
||||||
|
}
|
||||||
|
if(!$defs{$d}{TYPE}) {
|
||||||
|
Log 0, "Strange call for typeless $d: $n";
|
||||||
|
return undef;
|
||||||
|
}
|
||||||
|
my $fn = $defs{$d}{$n} ? $defs{$d}{$n} :
|
||||||
|
($defs{$d}{".$n"} ? $defs{$d}{".$n"} : $modules{$defs{$d}{TYPE}}{$n});
|
||||||
|
return "" if(!$fn);
|
||||||
|
if(wantarray) {
|
||||||
|
no strict "refs";
|
||||||
|
my @ret = &{$fn}(@_);
|
||||||
|
use strict "refs";
|
||||||
|
return @ret;
|
||||||
|
} else {
|
||||||
|
no strict "refs";
|
||||||
|
my $ret = &{$fn}(@_);
|
||||||
|
use strict "refs";
|
||||||
|
return $ret;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#####################################
|
#####################################
|
||||||
# Used from perl oneliners inside of scripts
|
# Used from perl oneliners inside of scripts
|
||||||
sub
|
sub
|
||||||
|
Loading…
x
Reference in New Issue
Block a user