Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re^2: Exporter Problem

by osler (Sexton)
on Feb 17, 2013 at 16:44 UTC ( #1019163=note: print w/ replies, xml ) Need Help??


in reply to Re: Exporter Problem
in thread Exporter Problem

This is definitely related to Inline not Exporter which is what I originally thought. I see now that the subclasses are defined by Inline. So I need to understand how Inline exports into the calling class' namespace.


Comment on Re^2: Exporter Problem
Re^3: Exporter Problem
by syphilis (Canon) on Feb 18, 2013 at 07:31 UTC
    This is definitely related to Inline not Exporter

    It's interesting that Inline::Java can have such an effect.

    Try starting another perlmonks thread under a more appropriate title. That might flush out someone who has an understanding of Inline::Java (and perhaps even a solution for you.)
    Also, you could try a post to the Inline mailing list. I think the Inline::Java author is subscribed to that mailing list, but you could cc him just in case he's not. (You'll find an email address for him here).

    Cheers,
    Rob

      Thanks for the recommendation. I think the issue is that Lingua::StanfordCoreNLP has the java code in the __DATA__ section of the PM file. My understanding is that the __DATA__ section is not read until runtime so the perl bindings to the java classes and methods can't happen until runtime. I was trying to create a Lingua::StanfordCoreNLP::Pipeline object in my package to store it as a package global. Doing this at that time, the Pipeline object is not defined yet.

      My work around is to create the pipeline object at runtime and pass it along to the new method of my package.

      I am also having trouble with using inline::java in a mod_perl environment -- there is information about this problem in the docs. I will pursue an Inline::Java thread if I run into more problems.

      Thanks for your help!

        I think the issue is that Lingua::StanfordCoreNLP has the java code in the __DATA__ section of the PM file

        Doesn't seem to be an issue with Inline::C - though, faik, that might be quite irrelevant wrt Inline::Java.

        With a site/lib/FOO/Soldier.pm that contains:
        package FOO::Soldier; use warnings; use strict; use Inline 'C'; 1; __DATA__ __C__ typedef struct { char* name; char* rank; long serial; } Soldier; SV* new(char* class, char* name, char* rank, long serial) { Soldier* soldier; SV* obj_ref = newSViv(0); SV* obj = newSVrv(obj_ref, class); New(42, soldier, 1, Soldier); soldier->name = savepv(name); soldier->rank = savepv(rank); soldier->serial = serial; sv_setiv(obj, (IV)soldier); SvREADONLY_on(obj); return obj_ref; } char* get_name(SV* obj) { return ((Soldier*)SvIV(SvRV(obj)))->name; } char* get_rank(SV* obj) { return ((Soldier*)SvIV(SvRV(obj)))->rank; } long get_serial(SV* obj) { return ((Soldier*)SvIV(SvRV(obj)))->serial; } void DESTROY(SV* obj) { printf("Destroy called\n"); Soldier* soldier = (Soldier*)SvIV(SvRV(obj)); Safefree(soldier->name); Safefree(soldier->rank); Safefree(soldier); }
        I can run the following script without any trouble:
        package MyPackage; use warnings; use strict; use FOO::Soldier; my $obj1 = FOO::Soldier->new('Benjamin', 'Private', 11111); my $obj2 = FOO::Soldier->new('Sanders', 'Colonel', 22222); my $obj3 = FOO::Soldier->new('Matt', 'Sergeant', 33333); for my $obj ($obj1, $obj2, $obj3) { print $obj->get_serial, ") ", $obj->get_name, " is a ", $obj->get_rank, "\n"; }
        which outputs (as expected):
        11111) Benjamin is a Private 22222) Sanders is a Colonel 33333) Matt is a Sergeant Destroy called Destroy called Destroy called
        Good luck with it!

        Cheers,
        Rob

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1019163]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (5)
As of 2014-07-23 02:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (131 votes), past polls