Eobj

 view release on metacpan or  search on metacpan

Eobj.pm  view on Meta::CPAN

@Eobj::EXPORT = qw[&init &override &underride &inherit &inheritdir &definedclass &globalobj];
$Eobj::VERSION = '0.23';
$Eobj::STARTTIME = localtime();

$Eobj::eobjflag = 0;
$Eobj::globalobject=();

unless ($Eobj::eobjflag) {
  $Eobj::eobjflag = 1; # Indicate that this clause has been run once
  $Eobj::errorcrawl='system';
  $Eobj::callbacksdepth = 0; # This indicates when callbacks are going on.
  undef $Eobj::wrong_flag;

  #For unloaded classes: Value is [classfile, parent class, first-given classname].
  %Eobj::classes = ('PL_hardroot', 1);
  %Eobj::objects = ();
  $Eobj::objectcounter = 0;
  
  {
    my $home = $INC{'Eobj.pm'};
    ($home) = ($home =~ /^(.*)Eobj\.pm$/);

Eobj.pm  view on Meta::CPAN

=item *

The override() and underride() functions

=item *

Constant properties

=item *

Magic callbacks: How to make properties depend on each other.

=item *

Setting up properties during object creation with new()

=item *

List operations on properties: pshift(), punshift(), ppush() and ppop()

=item *

Eobj/PLroot.pl  view on Meta::CPAN

	my ($at, $hint) = &Eobj::PLerror::constdump();
	
	wrong("Attempt to change constant value of \'".
	      join(",",@path)."\' to another unequal value ".
	      "on ".$self->who." $at\n".
	      "Previous value was ".$self->prettyval(@pre).
	      " and the new value is ".$self->prettyval(@newval)."\n$hint\n");
      }
    }
  } else {
    if ($Eobj::callbacksdepth) {
      my $prop = join ",",@path;
      my $who = $self->who;
      hint("On $who: \'$prop\' = ".$self->prettyval(@newval)." due to magic property setting\n");
    }
    $self->domutate((bless \@newval, 'PL_const'), @path);

    my $cbref = $self->getraw('plMAGICS', @path);
    return unless (ref($cbref) eq 'PL_settable');
    my $subref;

    $Eobj::callbacksdepth++;
    while (ref($subref=shift @{$cbref}) eq 'CODE') {
      &{$subref}($self, @path);
    }
     $Eobj::callbacksdepth--;
  }
}

sub set {
  my $self = shift;
  my $prop = shift;

  my @path;
  @path = (ref($prop) eq 'ARRAY') ? @{$prop} : ($prop);

Eobj/PLroot.pl  view on Meta::CPAN


sub addmagic {
  my $self = shift;
  my $prop = shift;
  my @path = (ref($prop) eq 'ARRAY') ? @{$prop} : ($prop);
  my $callback = shift;

  unless (defined($self->get([@path]))) {   
    $self->punshift(['plMAGICS', @path], $callback);
  } else {
    $Eobj::callbacksdepth++;
    &{$callback}($self, @path);
    $Eobj::callbacksdepth--;
  }
}

sub pshift {
  my $self = shift;
  my $prop = shift;
  my @path = (ref($prop) eq 'ARRAY') ? @{$prop} : ($prop);
  my $pre = $self->getraw(@path);
  if (ref($pre) eq 'PL_settable') {
    return shift @{$pre}; 

eobj.pdf  view on Meta::CPAN

77 0 obj
<< /S /GoTo /D (subsubsection.3.3.5) >>
endobj
80 0 obj
(More about constant properties)
endobj
81 0 obj
<< /S /GoTo /D (subsubsection.3.3.6) >>
endobj
84 0 obj
(``Magic'' callbacks)
endobj
85 0 obj
<< /S /GoTo /D (subsubsection.3.3.7) >>
endobj
88 0 obj
(The property path)
endobj
89 0 obj
<< /S /GoTo /D (subsubsection.3.3.8) >>
endobj



( run in 3.172 seconds using v1.01-cache-2.11-cpan-9b1e4054eb1 )