[system] / trunk / pg / lib / Value / Context / Data.pm Repository:
ViewVC logotype

Diff of /trunk/pg/lib/Value/Context/Data.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 5508 Revision 5509
2# 2#
3# Implements base class for data list in Context objects. 3# Implements base class for data list in Context objects.
4# 4#
5package Value::Context::Data; 5package Value::Context::Data;
6use strict; 6use strict;
7use Scalar::Util;
7 8
8sub new { 9sub new {
9 my $self = shift; my $class = ref($self) || $self; 10 my $self = shift; my $class = ref($self) || $self;
10 my $parent = shift; 11 my $parent = shift;
11 my $data = bless { 12 my $data = bless {
15 patterns => {}, # hash of pattern => [type,precedence] specification for extra patterns 16 patterns => {}, # hash of pattern => [type,precedence] specification for extra patterns
16 tokenType => {}, # type of Parser token for these pattern 17 tokenType => {}, # type of Parser token for these pattern
17 namePattern => '', # pattern for allowed names for new items 18 namePattern => '', # pattern for allowed names for new items
18 name => '', Name => '', # lower- and upper-case names for the class of items 19 name => '', Name => '', # lower- and upper-case names for the class of items
19 }, $class; 20 }, $class;
21 $data->weaken;
20 $data->init(); 22 $data->init();
21 $parent->{$data->{dataName}} = {}; 23 $parent->{$data->{dataName}} = {};
22 push @{$parent->{data}{objects}},"_$data->{dataName}"; 24 push @{$parent->{data}{objects}},"_$data->{dataName}";
23 $data->add(@_); 25 $data->add(@_);
24 return $data; 26 return $data;
51 foreach my $p (keys %{$orig->{patterns}}) { 53 foreach my $p (keys %{$orig->{patterns}}) {
52 $self->{patterns}{$p} = 54 $self->{patterns}{$p} =
53 (ref($orig->{patterns}{$p}) ? [@{$orig->{patterns}{$p}}] : $orig->{patterns}{$p}); 55 (ref($orig->{patterns}{$p}) ? [@{$orig->{patterns}{$p}}] : $orig->{patterns}{$p});
54 } 56 }
55} 57}
58
59#
60# Make context pointer a weak pointer (avoids reference loops)
61#
62sub weaken {Scalar::Util::weaken((shift)->{context})}
56 63
57# 64#
58# Update the context patterns 65# Update the context patterns
59# 66#
60sub update {(shift)->{context}->update} 67sub update {(shift)->{context}->update}

Legend:
Removed from v.5508  
changed lines
  Added in v.5509

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9