This file is indexed.

/usr/share/perl5/Tangram/Schema/Node.pm is in libtangram-perl 2.10-2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
package Tangram::Schema::Node;

# base class for Tangram::Class in Tangram::Schema (now
# Tangram::Schema::Class) and Tangram::Relational::Engine::Class

use strict;
sub get_bases
  {
	@{ shift->{BASES} }
  }

*direct_bases = \&get_bases;

sub get_specs
  {
	@{ shift->{SPECS} }
  }

sub for_conforming
{
   my ($class, $fun, @args) = @_;
   my $done = Set::Object->new;

   my $traverse;

   $traverse = sub {
	 my $class = shift;
	 return if $done->includes($class);
	 $done->insert($class);
	 $fun->($class, @args);

	 foreach my $derived (@{ $class->{SPECS} }) {
	   $traverse->($derived);
	 }
   };

   $traverse->($class);
 }

#---------------------------------------------------------------------
#  Tangram::Node->for_composing($closure, @_)
#
# Runs the given closure once for this class, and all its superclasses
# listed in the schema as $class->{BASES}
#
#---------------------------------------------------------------------
sub for_composing
{
   my ($class, $fun, @args) = @_;
   my $done = Set::Object->new;

   my $traverse;

   $traverse = sub {
	 my $class = shift;
	 return if $done->includes($class);
	 $done->insert($class);

	 foreach my $base (@{ $class->{BASES} }) {
	   $traverse->($base);
	 }

	 $fun->($class, @args);
   };

   $traverse->($class);
 }

sub get_exporter {
  my ($self, $context) = @_;

  return $self->{EXPORTER} ||= do {

	my (@export_sources, @export_closures);

	$self->for_composing
	    ( sub {
		  my ($part) = @_;

		  $context->{class} = $part;

		  for my $field ($part->direct_fields()) {
		      if (my $exporter = $field->get_exporter($context)) {
			  if (ref $exporter) {
			      push @export_closures, $exporter;
			      push @export_sources, 'shift(@closures)->($obj, $context)';
			  } else {
			      push @export_sources, $exporter;
			  }
		      }
		  }
	      } );

	my $export_source = join ",\n", @export_sources;
	my $copy_closures =
	    ( @export_closures ? ' my @closures = @export_closures;' : '' );

	# $Tangram::TRACE = \*STDOUT;

	$export_source = ("sub { my (\$obj, \$context) = \@_;"
			  ."$copy_closures\n$export_source }");

	print $Tangram::TRACE "Compiling exporter for $self->{name}...\n".($Tangram::DEBUG_LEVEL > 1 ? "$export_source\n" : "")
	    if $Tangram::TRACE;

	eval $export_source or die;
    }
}

sub get_importer {
  my ($self, $context) = @_;

  return $self->{IMPORTER} ||= do {
	my (@import_sources, @import_closures);

	$self->for_composing
	    ( sub {
		  my ($part) = @_;

		  $context->{class} = $part;

		  for my $field ($part->get_direct_fields()) {

		      my $importer = $field->get_importer($context)
			  or next;

		      if (ref $importer) {
			  push @import_closures, $importer;
			  push @import_sources, 'shift(@closures)->($obj, $row, $context)';
		      } else {
			  push @import_sources, $importer;
		      }
		  }
	      } );

	my $import_source = join ";\n", @import_sources;
	my $copy_closures =
	    ( @import_closures ? ' my @closures = @import_closures;' : '' );

	# $Tangram::TRACE = \*STDOUT;

	$import_source = ( "sub { my (\$obj, \$row, \$context) = \@_;"
			   ."(ref(\$row) eq 'ARRAY') and (\@\$row) or Carp::confess('no row!');\n"
			   ."# line 1 'tangram-$self->{table}-to-$self->{name}.pl'\n"
			   ."$copy_closures\n$import_source }" );

	print $Tangram::TRACE "Compiling importer for $self->{name}...\n".($Tangram::DEBUG_LEVEL > 1 ? "$import_source\n" : "")."\n"
	  if $Tangram::TRACE;

	# use Data::Dumper; print Dumper \@cols;
	eval $import_source or die;
  };
}

1;