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


In reply to Can code using Inline and Inline::C be used as a Role with_traits in Moose? by DrewP

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.