DrewP has asked for the wisdom of the Perl Monks concerning the following question:
Hello Monks, I have need of some advice...
I am using a non-Moose object (Device::WH1091) which is mature code and works just fine. It uses Inline and has some c code in __DATA__ at the end of the module.
While attempting to debug the issue described below I also wrapped the object into a small Moose class which I named WH1091Moose so I can unambiguously make it an attribute of something else as in...
has 'weather' => (is => 'ro', isa => 'MyApp::WH1091Moose', required => + 1,default => sub {Myapp::WH1091Moose->new() } );
...and that works very nicely too. In both cases they create an _Inline directory in the current working directory and the compiled c is written to that directory.
I have written a monitoring system which allows me to plug in different roles (using with_traits) corresponding to the different hardware I wish to monitor and that has been working well with various different devices for a year or two. But this is the first time I have written a role for a device that includes an attribute that uses Inline and that is the only difference I can think of between working and non-working modules.
When I create the device using a line like this...
my $device = MyApp::Device->with_traits( $model )->new( $refParamsHash );...there is no error but the _Inline subdirectory is not created
When I use the role I get the error..
caught error: Undefined subroutine &Device::WH1091::getweather called +at /usr/local/share/perl5/Device/WH1091.pm line 71.
...where getweather is the c function called by the perl in Device::WH1091 module
I read somewhere that Moose implements traits by taking the module name and munging it to form a new, unique module name and also that Inline creates a directory tree that corresponds to the module name within the _Inline subdirectory .
I am wondering if the two different dependencies on the module's name are clashing and causing it to fail.
Much as I would like to include some simple code to demonstrate this I know the WH1091 module will fail unless the correct hardware is connected.
However, if in the Monks' opinion all should work I will try to write something simple that uses Inline and demonstrate it. Might take a week or several before I am confident I know how to write code for Inline
Thanks, Monks for any advice you can give
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Can code using Inline and Inline::C be used as a Role with_traits in Moose?
by Myrddin Wyllt (Hermit) on Sep 05, 2015 at 23:20 UTC | |
by DrewP (Initiate) on Sep 08, 2015 at 12:18 UTC | |
|
Re: Can code using Inline and Inline::C be used as a Role with_traits in Moose?
by Anonymous Monk on Sep 06, 2015 at 08:26 UTC | |
by DrewP (Initiate) on Sep 08, 2015 at 12:50 UTC | |
by syphilis (Archbishop) on Sep 08, 2015 at 13:29 UTC | |
by Anonymous Monk on Sep 08, 2015 at 23:47 UTC |