自动加载' d呼叫通过inline :: perl5在raku中失败

发布于 2025-01-25 00:15:38 字数 3026 浏览 4 评论 0 原文

我正在Raku中重写一些Perl/Charting软件,但通过Inline :: Perl5使用Chart -Director Perl5模块(下面的链接)遇到了问题。该模块基本上是DLL的Perl接口;使用模块通过INLINE :: PERL5似乎适用于代码中明确包含的方法调用 - 但是大多数方法调用都是通过PERL5中的自动加载“捕获所有”机制执行的。这些在我的Raku代码中不起作用。

我的问题是,我可以期望使用inline :: perl5使用这种应用程序吗? (也许没有办法“捕获”这些自动加载方法调用),如果是这样,则如何使其这样做。

感谢您的任何指示,建议。

WF


Chart -Director软件(出色的图形/图表软件 - 与Perl一起使用了将近20年):


引用Verbiage(简化),版本信息和代码,来自关于此的ChartDir论坛线程的开始:

我正在使用 inline :: perl5 使用我尝试过的所有其他模块。

我正在遇到问题,重现“ nofollow noreferrer”>“第一个项目”示例/a>。

使用ChartDir 6,FreeBSD 12.2(Intel Platform),Raku 2022.04,Perl 5.32.1。

#!/usr/bin/env raku

use lib:from<Perl5>  '/usr/local/lib/perl5/site_perl';
use Inline::Perl5;

my $p5 = Inline::Perl5.new;
$p5.use('perlchartdir') ;

my $data = [85, 156, 179.5, 211, 123];
my $labels = ["Mon", "Tue", "Wed", "Thu", "Fri"];

my $c = $p5.invoke( 'XYChart', 'new', 250, 250);

$c.setPlotArea(30, 20, 200, 200);

$c.addBarLayer($data);
$c.xAxis().setLabels($labels);
$c.xAxis().setLabels($labels);

$c.makeChart("simplebar.png");

一切似乎都很好(即,第8行后的数据倾角 $ c 显示了一个大/合理的结构),直到第9行,我收到“没有这样的方法 setplotarea 对于类型 XYCHART >“”。第10行似乎确实有效(没有投诉) - 剩下的3行不行(与第8行相同的错误类型)。


并引用了ChartDir的主要开发人员Peter Kwan给出的一些反馈:

我以前从未使用过Raku。对于您的情况,失败的方法似乎是自动加载方法。 ...我怀疑Raku可能不支持Perl Autoload,因此它报告了未定义的方法,而不是将其转发到“捕获所有”方法。或者可能需要进口一些其他事情才能使用自动加载。

正如下面的评论中逐渐减少的那样,Inline :: Perl5支持自动加载(并且拥有7年),所以也许这是一个红鲱鱼?


感激地回应P6Steve的响应,我提供了一些其他信息。.

此处包括$ c(xychart对象)的各种表示的完整输出: https://pastebin.com/gy2ibdam (希望可以使用pastebin(仍然可以通过StackoverFlow找到我的方式) - 输出长600行,我不确定我是什么可以有效编辑)。

虽然总结。DD

$ C返回零(尽管将相当于$ c.perl(以下)打印到stdout(不确定为什么))

说$ c.perl返回:

xychart.new(inline-perl5 =&gt; inline) perl5.new(thread-id =&gt; 1),包装 - perl5-object =&gt

;

:: new isa rakuseen defined getYCoor addHLOCLayer3 raku yZoneColor Numeric addLineLayer addAreaLayer DESTROY BUILDALL gist perl WHICH sink bless getYValue Str addBarLayer new_shadow_of_p5_object AT-KEY)

finally, say Dump $c (using Data::Dump module) yields about 600 lines of output (included in the Pastebin输出)。

I'm rewriting some perl/charting software in Raku but have run into an issue using the ChartDirector perl5 module (link below) via Inline::Perl5. The module is basically a perl interface to a DLL; using the module via Inline::Perl5 seems to work for method calls explicitly included in the code - but most of the method calls are executed via the autoload 'catch all' mechanism in perl5. These do not work in my raku code.

My question is can I expect this sort of application to work using Inline::Perl5? (perhaps there is no way to 'catch' these autoload'd method calls) and, if so, how to make it so.

Thanks for any pointers, suggestions.

wf


ChartDirector software (excellent graphics/charting software - have used it for nearly 2 decades with perl): https://www.advsofteng.com/index.html


Quoting verbiage (simplified), version info, and code from the start of a chartdir forum thread about this:

I'm using Inline::Perl5 which works with every other module I've tried.

I'm hitting problems reproducing the "first project" example on the chartdir site.

using chartdir 6, freebsd 12.2 (intel platform), raku 2022.04, perl 5.32.1.

#!/usr/bin/env raku

use lib:from<Perl5>  '/usr/local/lib/perl5/site_perl';
use Inline::Perl5;

my $p5 = Inline::Perl5.new;
$p5.use('perlchartdir') ;

my $data = [85, 156, 179.5, 211, 123];
my $labels = ["Mon", "Tue", "Wed", "Thu", "Fri"];

my $c = $p5.invoke( 'XYChart', 'new', 250, 250);

$c.setPlotArea(30, 20, 200, 200);

$c.addBarLayer($data);
$c.xAxis().setLabels($labels);
$c.xAxis().setLabels($labels);

$c.makeChart("simplebar.png");

All seems fine (i.e., data-dumping $c after line 8 shows a large/reasonable looking structure) until line 9 where I receive "No such method setPlotArea for invocant of type XYChart". Line 10 does appear to work (no complaints) - remaining 3 lines don't (same type of error as for line 8).


And quoting some feedback that was given by Peter Kwan, the primary dev of chartdir:

I have never used Raku before. For your case, the methods that fail seem to be AUTOLOAD methods. ... I suspect may be Raku does not support Perl AUTOLOAD, so it reports undefined methods as not found instead of forwarding it to the "catch all" method. Or may be some additional things need to be imported for it to use the AUTOLOAD.

As dwarring notes in the comments below this SO question, Inline::Perl5 does support autoload (and has for 7 years), so perhaps that aspect is a red herring?


gratefully responding to p6steve's response, I am providing some additional information ..

The full output from various representations of $c (the XYChart object) is included here: https://pastebin.com/gY2ibDaM (hope it's ok to use pastebin for this (still finding my way through stackoverflow)) - the output was 600+ lines long and wasn't sure what I could usefully edit out).

to summarize though ..

dd $c returns nil (although prints out the equivalent of $c.perl (below) to stdout (not sure why))

say $c.perl returns:

XYChart.new(inline-perl5 => Inline::Perl5.new(thread-id => 1), wrapped-perl5-object => NativeCall::Types::Pointer.new(34651088744))

say $c.^methods returns:

(WHERE addHLOCLayer ACCEPTS WHY can new isa rakuseen defined getYCoor addHLOCLayer3 raku yZoneColor Numeric addLineLayer addAreaLayer DESTROY BUILDALL gist perl WHICH sink bless getYValue Str addBarLayer new_shadow_of_p5_object AT-KEY)

finally, say Dump $c (using Data::Dump module) yields about 600 lines of output (included in the pastebin output).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

向日葵 2025-02-01 00:15:38

嗨,翅膀折,欢迎来到raku,所以标签!

我想知道您在 dd $ c; $ c.setplotarea(30、20、200、200); - eg是$ c真正的xychart之前,我想知道 dd $ c; 目的?

如果是这样,那么 $ c。^方法('^'表示元方法...在这种情况下,您应该获取可用方法的列表)。

请在此处发布结果,希望这将有助于诊断...


感谢您提供的信息!

看到$ c。^方法调用的输出后,很明显$ c没有方法 $ c.setplotarea (阅读错误消息说相同 - 也许我应该给予适当的权重!)

我不知道Inline :: Perl5模块,但是我已经看到了Inline :: Python的类似问题。

我在Python中的经验是,目标语言对象仅揭示其“直接”方法,并且不会自动攻入它们可以执行的所有组合方法。

我的解决方法一直在“评估”样式方法的线上,类似:

$p5.run( qq[$c.setPlotArea(30, 20, 200, 200);] );

希望这会有所帮助!

Hi wingfold and welcome to the raku SO tag!

I wonder what you get with dd $c; just before the line $c.setPlotArea(30, 20, 200, 200); - e.g. is $c truly an XYChart object?

If so then what does $c.^methods (the '^' indicates a meta method ... in this case you should get a list of the available methods).

Please do post the results here and hopefully that will help the diagnosis...


Thanks for the info!

Having seen the output of the $c.^methods call, it is clear that $c has no method $c.setPlotArea (reading the error message says the same - perhaps I should have given that due weight!)

I do not know the Inline::Perl5 module well, but I have seen similar issues with Inline::Python.

My experience in Python is that the target language objects only expose their "direct" methods and do not automatically pull in all the composed methods that they can perform.

My workaround has been on the lines of an "eval" style approach, something like:

$p5.run( qq[$c.setPlotArea(30, 20, 200, 200);] );

Hope this helps!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文