📄 inlinefunctions.pm
字号:
# vim:ts=4 sw=4
# ----------------------------------------------------------------------------------------------------
# Name : ETL::Pequel3::Type::InlineFunctions.pm
# Created : 13 June 2006
# Author : Mario Gaffiero (gaffie)
#
# Copyright 1999-2007 Mario Gaffiero.
#
# This file is part of Pequel(TM).
#
# Pequel is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# Pequel is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Pequel; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
# ----------------------------------------------------------------------------------------------------
# Modification History
# When Version Who What
# ----------------------------------------------------------------------------------------------------
package ETL::Pequel3::Type::InlineFunctions;
require 5.005_62;
use strict;
use warnings;
use ETL::Pequel3::CodeStyler;
# ----------------------------------------------------------------------------------------------------
{
package ETL::Pequel3::Type::InlineFunctions::Abstract;
use base qw(Class::STL::Element);
use Class::STL::ClassMembers qw( err function_name call_name datasource config package_name configuration );
use Class::STL::ClassMembers::Constructor;
sub new_extra
{
my $self = shift;
use ETL::Pequel3::Error;
$self->err(ETL::Pequel3::Error->new());
$self->package_name($self->datasource()->fdname() . '::'
. join('', map(ucfirst($_), split("[_]", $self->function_name()))));
$self->call_name($self->package_name() . '::' . $self->function_name());
$self->config(ETL::Pequel3::Type::InlineFunctions::Config::Catalogue->new(
configuration => $self->configuration()));
}
sub install
{
my $self = shift;
my $c = shift;
# virtual function
}
sub installed
{
my $self = shift;
my $c = shift;
if ($c->jump($self->function_name())) {
$c->return();
return 1;
}
$c->bookmark($self->function_name());
return 0;
}
sub code_inline_begin
{
my $self = shift;
my $c = shift || ETL::Pequel3::CodeStyler::Program::Perl->new();
$c->anchor_set();
$c->divider();
$c->comment("++++++ Function @{[ $self->function_name() ]} --> Type @{[ ref($self) ]} ++++++");
$c->open_block();
$c->code("package @{[ $self->package_name() ]};");
$c->newline_off();
$c->code("use Inline (C => Config => ");
$c->code(join(',', map($_->option_name().'=>'.$_->data(), grep(defined($_->data()),
$self->config()->to_array()))));
$c->newline_on();
$c->code(");");
$c->code("use Inline C => <<'END_@{[ uc($self->datasource()->fdname() . '_' . $self->function_name()) ]}'");
return $c;
}
sub code_inline_end
{
my $self = shift;
my $c = shift || ETL::Pequel3::CodeStyler::Program::Perl->new();
$c->indent_off();
$c->code("END_@{[ uc($self->datasource()->fdname() . '_' . $self->function_name()) ]}");
$c->code(";");
$c->indent_on();
$c->code();
$c->close_block();
$c->anchor_return();
return $c;
}
sub defined
{
my $self = shift;
my $defname = $self->package_name() . '::' . $self->function_name();
return defined(&{$defname}); # function may have been previously eval'd;
}
}
# ----------------------------------------------------------------------------------------------------
{
package ETL::Pequel3::Type::InlineFunctions::Config::Option;
use base qw(Class::STL::Element);
use Class::STL::ClassMembers qw( option_name );
use Class::STL::ClassMembers::Constructor;
}
{
#> package ETL::Pequel3::Type::Inline::Config::Catalogue;
package ETL::Pequel3::Type::InlineFunctions::Config::Catalogue;
use base qw(ETL::Pequel3::Type::Catalogue);
use Class::STL::ClassMembers qw( err configuration ),
Class::STL::ClassMembers::DataMember->new(name => 'target_mem_name', default => 'function_name'),
Class::STL::ClassMembers::DataMember->new(name => 'element_type', default => 'ETL::Pequel3::Type::InlineFunctions::Config::Option');
use Class::STL::ClassMembers::SingletonConstructor;
sub new_extra
{
my $self = shift;
use ETL::Pequel3::Error;
$self->err(ETL::Pequel3::Error->new());
$self->configuration(ETL::Pequel3::Type::Properties->new()) unless (defined($self->configuration()));
$self->push_back(
$self->factory( option_name => 'NAME', data => '__PACKAGE__'),
$self->factory( option_name => 'PRINT_INFO',
data => $self->configuration()->inline_print_info() || ($self->err()->debug_on() ? 1 : 0)),
$self->factory( option_name => 'BUILD_TIMERS',
data => $self->configuration()->inline_build_timers() || ($self->err()->debug_on() ? 1 : 0)),
$self->factory( option_name => 'BUILD_NOISY',
data => $self->configuration()->inline_build_noisy() || ($self->err()->debug_on() ? 1 : 0)),
$self->factory( option_name => 'CLEAN_BUILD_AREA',
data => $self->configuration()->inline_clean_build_area() || ($self->err()->debug_on() ? 0 : 1)),
$self->factory( option_name => 'CLEAN_AFTER_BUILD',
data => $self->configuration()->inline_clean_after_build() || ($self->err()->debug_on() ? 0 : 1)),
$self->factory( option_name => 'FORCE_BUILD',
data => $self->configuration()->inline_force_build() || undef),
$self->factory( option_name => 'DIRECTORY'),
$self->factory( option_name => 'CC'),
$self->factory( option_name => 'CCFLAGS'),
$self->factory( option_name => 'INC'),
$self->factory( option_name => 'LD'),
$self->factory( option_name => 'LDDLFLAGS'),
$self->factory( option_name => 'LIBS'),
$self->factory( option_name => 'MAKE'),
$self->factory( option_name => 'MYEXTLIB'),
$self->factory( option_name => 'OPTIMIZE'),
$self->factory( option_name => 'TYPEMAPS'),
);
return $self;
#> $self->initrc(ETL::Pequel3::Startup->new(@_)); # Singleton
#> $self->initrc()->inline_config($self->options());
#> Entries:
# inline-config-option:FORCE_BUILD(1)
}
}
# ----------------------------------------------------------------------------------------------------
1;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -