You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
82 lines
2.4 KiB
82 lines
2.4 KiB
13 years ago
|
package TQt::isa;
|
||
13 years ago
|
use strict;
|
||
|
|
||
|
sub import {
|
||
|
no strict 'refs';
|
||
|
my $class = shift;
|
||
|
my $caller = (caller)[0];
|
||
|
|
||
|
# Trick 'use' into believing the file for this class has been read
|
||
|
my $pm = $caller . ".pm";
|
||
|
$pm =~ s!::!/!g;
|
||
|
unless(exists $::INC{$pm}) {
|
||
13 years ago
|
$::INC{$pm} = $::INC{"TQt/isa.pm"};
|
||
13 years ago
|
}
|
||
|
|
||
|
for my $super (@_) {
|
||
|
push @{ $caller . '::ISA' }, $super;
|
||
13 years ago
|
push @{ ${$caller . '::META'}{'superClass'} }, $super; # if isa(TQObject)?
|
||
13 years ago
|
}
|
||
|
|
||
|
*{ $caller . '::className' } = sub { # closure on $caller
|
||
|
return $caller;
|
||
|
};
|
||
|
|
||
|
${ $caller. '::_INTERNAL_STATIC_'}{'SUPER'} = bless {}, " $caller";
|
||
13 years ago
|
TQt::_internal::installsuper($caller) unless defined &{ $caller.'::SUPER' };
|
||
13 years ago
|
|
||
|
*{ $caller . '::metaObject' } = sub {
|
||
13 years ago
|
TQt::_internal::getMetaObject($caller);
|
||
13 years ago
|
};
|
||
|
|
||
|
*{ $caller . '::import' } = sub {
|
||
|
my $name = shift; # classname = function-name
|
||
|
my $incaller = (caller)[0];
|
||
|
$incaller = (caller(1))[0] if $incaller eq 'if'; # work-around bug in package 'if' pre 0.02
|
||
|
(my $cname = $name) =~ s/.*::// and do
|
||
|
{
|
||
|
*{ "$name" } = sub {
|
||
|
$name->new(@_);
|
||
|
} unless defined &{ "$name" };
|
||
|
};
|
||
|
my $p = defined $&? $&:'';
|
||
|
$p eq ($incaller=~/.*::/?($p?$&:''):'') and
|
||
|
*{ "$incaller\::$cname" } = sub {
|
||
|
$name->new(@_);
|
||
|
};
|
||
|
|
||
|
if(defined @{ ${$caller.'::META'}{'superClass'} } &&
|
||
|
@{ ${$caller.'::META'}{'superClass'} } )
|
||
|
{
|
||
|
# attributes inheritance
|
||
|
for my $attribute( keys %{ ${$caller.'::META'}{'attributes'} } )
|
||
|
{
|
||
|
if(! defined &{$incaller.'::'.$attribute })
|
||
|
{
|
||
13 years ago
|
TQt::_internal::installattribute($incaller, $attribute);
|
||
13 years ago
|
${ ${$incaller .'::META'}{'attributes'} }{$attribute} = 1;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
};
|
||
|
|
||
13 years ago
|
TQt::_internal::installautoload(" $caller");
|
||
|
TQt::_internal::installautoload(" $caller");
|
||
|
TQt::_internal::installautoload($caller);
|
||
13 years ago
|
{
|
||
13 years ago
|
package TQt::AutoLoad;
|
||
13 years ago
|
my $autosub = \&{ " $caller\::_UTOLOAD" };
|
||
|
*{ " $caller\::AUTOLOAD" } = sub { &$autosub };
|
||
|
$autosub = \&{ " $caller\::_UTOLOAD" };
|
||
|
*{ " $caller\::AUTOLOAD" } = sub { &$autosub };
|
||
|
$autosub = \&{ "$caller\::_UTOLOAD" };
|
||
|
*{ "$caller\::AUTOLOAD" } = sub { &$autosub };
|
||
|
}
|
||
13 years ago
|
TQt::_internal::installthis($caller);
|
||
13 years ago
|
|
||
|
# operator overloading
|
||
13 years ago
|
*{ " $caller\::ISA" } = ["TQt::base::_overload"];
|
||
13 years ago
|
}
|
||
|
|
||
|
1;
|