Bless, inheritance and swig
From: Xiaodong Huang (xhuang_at_yahoo.com)
Date: 03/31/04
- Next message: Bob Walton: "Re: validate links??"
- Previous message: Matthew Miller: "Re: perl modules -> RPM resources???"
- Next in thread: Brad Baxter: "Re: Bless, inheritance and swig"
- Reply: Brad Baxter: "Re: Bless, inheritance and swig"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 30 Mar 2004 16:17:13 -0800
I searched but could not find answer for this question on Internet or
in Newsgroups.
I have a class CObject in C++ which is wrapped by SWIG:
class CObject {
public:
CObject();
get();
}
I want to write a perl object that inherits from
CObject. So I wrote something like this (I used similar code
before in non-SWIG case):
Package MyPerlObject;
use Exporter;
use CObject;
our @ISA = qw(CObject Exporter);
sub new {
my $class = shift ;
$class = ref($class) || $class ;
my $self = CObject->new();
bless $self, $class;
return $self;
}
...
MyPerlObject does not have a method get(). When client of MyPerlObject
called MyPerlObject::get() at run-time, I got
"No matching function for overloaded CObject_get()".
So I tried to pinpoint where the problem was and found that it seemed
to have something to do with bless.
I modified the above new() subroutine by adding two lines:
sub new {
my $class = shift ;
$class = ref($class) || $class ;
my $self = CObject->new();
$self->get(); # works
bless $self, $class;
$self->get(); # does not work
return $self;
}
The line before "bless" statement works but the line after it gives me
the "No matching function .." error as before.
Could someone point to me what I did wrong or suggest a way to work around
the problem?
Thanks.
xh
- Next message: Bob Walton: "Re: validate links??"
- Previous message: Matthew Miller: "Re: perl modules -> RPM resources???"
- Next in thread: Brad Baxter: "Re: Bless, inheritance and swig"
- Reply: Brad Baxter: "Re: Bless, inheritance and swig"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]