Inheirit from a swig-class

I want to inheirit from a SWIG-class, but I cannot. Why?
Can you help me with this inheiriting problem?

If I run the “a.rb” program I get this error message (don’t mind the
opfuscated bactrace format :slight_smile:

EXCEPTION (RUBY):
name=cannot invoke ruby-function
where=./a.rb:7
class=TypeError
message=wrong argument type RubyView (expected Data)
backtrace= from ./a.rb:7:in repaint' from ./a.rb:7:in insert’

cat a.rb
class RubyView < Embed::Redirect
def initialize
super
end
def insert
repaint
end
end

I made this “b.rb” workaround… and there is no problems.

cat b.rb
class RubyView
def initialize
@redir = Embed::Redirect.new
super
end
def insert
@redir.repaint
end
end

Thanks in advance
Simon Strandgaard

“Simon Strandgaard” 0bz63fz3m1qt3001@sneakemail.com wrote in message news:pan.2003.04.14.18.04.28.688118@sneakemail.com

I want to inheirit from a SWIG-class, but I cannot. Why?
Can you help me with this inheiriting problem?

If I run the “a.rb” program I get this error message (don’t mind the
opfuscated bactrace format :slight_smile:

EXCEPTION (RUBY):
name=cannot invoke ruby-function
where=./a.rb:7
class=TypeError
message=wrong argument type RubyView (expected Data)
backtrace= from ./a.rb:7:in repaint' from ./a.rb:7:in insert’

cat a.rb
class RubyView < Embed::Redirect
def initialize
super
end
def insert
repaint
end
end

I made this “b.rb” workaround… and there is no problems.

cat b.rb
class RubyView
def initialize
@redir = Embed::Redirect.new
super
end
def insert
@redir.repaint
end
end

Thanks in advance
Simon Strandgaard

Hi Simon,
I assumed this was prob with tutorial code. Had a look and got same
error. Found if I change the call in NewWrap from:

VALUE self = rb_class_new_instance(a.n, a.argv, klass);

to:

VALUE self = rb_funcall2(klass, rb_intern(“new”), a.n, a.argv);

it all works. I started looking thru the ruby code but then my brain
started to hurt. Would be intersted to know why?
Cheers
Steve

This modification makes it work like a dream, thanks :slight_smile:

This makes me wonder what the difference might be ???

Sorry, can someone explain this for us?

···

On Mon, 14 Apr 2003 18:57:47 +0000, Steve Hart wrote:

I assumed this was prob with tutorial code. Had a look and got same
error. Found if I change the call in NewWrap from:

VALUE self = rb_class_new_instance(a.n, a.argv, klass);

to:

VALUE self = rb_funcall2(klass, rb_intern(“new”), a.n, a.argv);

it all works. I started looking thru the ruby code but then my brain
started to hurt. Would be intersted to know why?


Simon Strandgaard

Answers: This is a SWIG issue, see
http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&threadm=pan.2003.04.15.11.55.50.67892%40sneakemail.com&rnum=15&prev=/groups%3Fq%3Dsimon%2Bstrandgaard%2Bruby%26hl%3Den%26lr%3D%26ie%3DUTF-8%26start%3D10%26sa%3DN

···

On Tue, 15 Apr 2003 04:21:30 +0200, Simon Strandgaard wrote:

On Mon, 14 Apr 2003 18:57:47 +0000, Steve Hart wrote:

it all works. I started looking thru the ruby code but then my brain
started to hurt. Would be intersted to know why?

This makes me wonder what the difference might be ???

Sorry, can someone explain this for us?


Simon Strandgaard