Archived
1
0
Fork 0

Pass $ref to functions

This commit is contained in:
Mercier Pierre-Olivier 2013-09-26 01:38:05 +02:00
commit 5257595639

View file

@ -239,13 +239,13 @@ sub compute ($$$;$$$)
{
$grade = $doc->createElement("grade");
$grade->addChild( $doc->createAttribute("factor", $self->{factor}) );
$grade->addChild( $doc->createAttribute("name", $self->{title}) );
$grade->addChild( $doc->createAttribute("name", $self->{title}) ) if ($self->{title});
$parent->appendChild( $grade );
}
for my $node (@{ $self->{tree} })
{
my $t = $node->compute($operators, $ids, $doc, $grade);
my $t = $node->compute($operators, $ids, $login, $doc, $grade);
push @current, $t if (defined $t);
}
@ -315,16 +315,17 @@ sub toString ($$$)
$parent->appendChild($point);
}
sub getValue ($$)
sub getValue ($$$)
{
my $self = shift;
my $ids = shift;
my $ref = shift;
# Return the point node value if exists
return $self->{value} if ($self->{value} ne "");
# Else return pointed ref value
return $ids->{ $self->{ref} };
return $ids->{ $ref };
}
sub compute ($$$;$$$)
@ -352,15 +353,15 @@ sub compute ($$$;$$$)
$result = !$result if ($self->{not});
# ret is valued only if all conditions passed
$ret = $self->getValue( $ids ) if ($result);
$ret = $self->getValue( $ids, $ref ) if ($result);
if ($main::debug)
{
my $str = "not=".($self->{not}//0).", qversion".($self->{qversion}//"*").", ref=".($ref//"").",\tvalue=".($ids->{ $ref//"" } // "undef").", ";
my $str = "not=".($self->{not}//0).", qversion".($self->{qversion}//"*").", ref=".($ref//"").",\tvalue=".($ids->{ $ref//"" } // "undef");
if ($result) {
say GREEN, ">>>", RESET, " Matching point: ", $str, BOLD, "got=".($ret // 0), RESET;
say GREEN, ">>>", RESET, " Matching point: ", $str, ", ", BOLD, "got=".($ret // 0), RESET;
} else {
say RED, " * ", RESET, " Skipped point: ", $str, BOLD, "got=".($ret // 0), RESET;
say RED, " * ", RESET, " Skipped point: ", $str;
}
}