Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inline::CPP fails to parse virtual string method #36

Closed
protoCall7 opened this issue Oct 8, 2015 · 2 comments
Closed

Inline::CPP fails to parse virtual string method #36

protoCall7 opened this issue Oct 8, 2015 · 2 comments

Comments

@protoCall7
Copy link

Hi all,

On Mac OS X with Perl 5.22.0, I have found that Inline::CPP fails to parse virtual string methods.

use warnings;
use strict;
use Inline 'CPP';

my $plane = new Airplane;
my $return = $plane->nonprint();
print $return . "\n";

__END__
__CPP__
#include <sstream>
using namespace std;
/*  Abstract class (interface) */
class Object {
public:
    virtual string nonprint()
    {
        ostringstream oretval;
        oretval << "Object (" << this << ")";
        string retval = oretval.str();
        return retval;
    }
};

class Airplane : public Object {
public:
    Airplane() {}
    ~Airplane() {}
};

results in the following error:

$ perl inlinecppdebug.pl
Can't locate object method "nonprint" via package "Airplane" at inlinecppdebug.pl line 6.

However the C++ itself compiles and behaves as expected:

#include <iostream>
#include <sstream>

using namespace std;

/*  Abstract class (interface) */
class Object {
public:
    virtual string nonprint()
    {
        ostringstream oretval;
        oretval << "Object (" << this << ")";
        string retval = oretval.str();
        return retval;
    }
};

class Airplane : public Object {
public:
    Airplane() {}
    ~Airplane() {}
};

int main(void)
{
    Airplane ap;
    string val = ap.nonprint();
    cout << val;
    return 0;
}

This returns:

$ ./main
Object (0x7fff5ebd75e0)
@wbraswell
Copy link
Contributor

@daoswald
If a solution to this issue can be found, then it will likely help us solve a bug affecting RPerl in Macintosh:
wbraswell/rperl#34

But either way I need to know...
Is it possible for I::CPP to support virtual string methods?
Thanks!

@mohawk2
Copy link
Collaborator

mohawk2 commented Mar 25, 2019

Yes, but you need to define a typemap. See updated docs.

mohawk2 added a commit that referenced this issue Mar 25, 2019
mohawk2 added a commit that referenced this issue Mar 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants