【发布时间】:2015-03-20 08:06:05
【问题描述】:
这里是相关的代码。
Slic3r::Print::Simple 的属性之一:
has '_print' => (
is => 'ro',
default => sub { Slic3r::Print->new },
handles => [qw(apply_config extruders expanded_output_filepath
total_used_filament total_extruded_volume
placeholder_parser process)],
);
相关子程序:
sub new {
# TODO: port PlaceholderParser methods to C++, then its own constructor
# can call them and no need for this new() method at all
my ($class) = @_;
my $self = $class->_new;
$self->placeholder_parser->apply_env_variables;
$self->placeholder_parser->update_timestamp;
return $self;
}
此代码有效,我在网上找不到任何解释它的内容。 几个问题:
- $class 分配了什么值?我猜它被分配了调用 Print::Simple 对象,但我无法用一个验证
- 我找不到 _new 的代码,但如果 $class 是 Simple 对象,那么它应该是 Moo::Object 的子类,但是我在包中找不到相关的子例程。
- 对 placeholder_parser 的调用似乎表明 $self 引用了一个 Simple 对象,但我不明白这个委托是如何被调用的。我认为调用委托将从 Slic3r::Print->new 返回的任何内容中调用相关方法,但这是在方法返回值之前调用委托。此外,我进行了搜索,在该程序的目录或 Perl 库中的任何地方都没有找到 placeholder_parser 子例程的定义。那么,它到底在做什么呢?
基本上我脑子里全是f%ck,我不知道发生了什么。还必须说明该程序 100% 有效。
【问题讨论】:
-
这是您正在使用的代码吗? slic3r.org
标签: perl