swig -version
SWIG Version 1.3.18
Copyright (c) 1995-1998
University of Utah and the Regents of the University of California
Copyright (c) 1998-2002
University of Chicago
Compiled with g++
I've not found 1.3.18, at sourceforge there is only .19, .17
pigeon% swig -version
SWIG Version 1.3.19
Copyright (c) 1995-1998
University of Utah and the Regents of the University of California
Copyright (c) 1998-2002
University of Chicago
Compiled with g++
Please see http://www.swig.org for reporting bugs and further information
pigeon%
the SWIG generated file is
rubyembed-0.1.tar.gz/source/redirect_wrap.cpp
SWIG doesn’t seem to use rb_define_alloc_func(), so allocator
of Object is used by rb_class_new_instance(). “new” works fine
because SWIG redefines Redirect.new (but it is deprecated now).
VALUE New(string klass) {
NewArguments arg(klass.c_str(), 0, 0);
int error = 0;
VALUE self = rb_protect(NewWrap, reinterpret_cast(&arg), &error);
if(error) {
std::ostringstream o;
o << "error creating " << klass;
throw RUBY_CPP::RubyError::Create(o.str());
}
return self;
}
} // end of namespace RUBY_CPP
swig -version
SWIG Version 1.3.19
Copyright (c) 1995-1998
University of Utah and the Regents of the University of California
Copyright (c) 1998-2002
University of Chicago
Compiled with g++
There is 2 binaries, I think you executed the wrong one.
pigeon% ./testswig
main: enter
test.rb: enter
test.rb: leave
aeditorlib: started (no-swig)
^^^^^^^
^^^^^^^
If you ran the “testswig” program, it should say “with-swig”…
I think you ran the “test” program
the SWIG generated file is
rubyembed-0.1.tar.gz/source/redirect_wrap.cpp
SWIG doesn’t seem to use rb_define_alloc_func(), so allocator
of Object is used by rb_class_new_instance(). “new” works fine
because SWIG redefines Redirect.new (but it is deprecated now).
At Wed, 16 Apr 2003 01:25:33 +0900, Simon Strandgaard wrote:
SWIG doesn’t seem to use rb_define_alloc_func(), so allocator
of Object is used by rb_class_new_instance(). “new” works fine
because SWIG redefines Redirect.new (but it is deprecated now).
Is this a problem SWIG ?
SWIG (1.3.19 at least) seems to not support ruby 1.8.
SWIG doesn’t seem to use rb_define_alloc_func(), so allocator
of Object is used by rb_class_new_instance(). “new” works fine
because SWIG redefines Redirect.new (but it is deprecated now).
[And then Simon responded:]
Is this a problem SWIG ?
Or is this a problem with RUBY ?
[And now Lyle says:]
So far, I’ve purposely avoided making any changes to support Ruby’s new
allocation scheme since (at least in its initial implementation in Ruby
1.7.x) there seemed to be some problems. There’s also the issue of
backwards compatibility with Ruby versions 1.6.x and earlier. If SWIG is
to generate code that will compile under both Ruby 1.6 and Ruby 1.8,
there will presumably need to be a compile-time check of the Ruby
version number.
Since, as Nobu notes, redefining ‘new’ works for both Ruby 1.6 and 1.8,
I’ve left it that way until now. If Matz, Nobu and others feel confident
about the new allocation implementation in 1.8 I can revisit the issue.
1.7.x) there seemed to be some problems. There’s also the issue of
backwards compatibility with Ruby versions 1.6.x and earlier. If SWIG is
to generate code that will compile under both Ruby 1.6 and Ruby 1.8,
there will presumably need to be a compile-time check of the Ruby
version number.
In message “Re: rb_class_new_instance behaves strange” on 03/04/16, Lyle Johnson lyle@users.sourceforge.net writes:
Since, as Nobu notes, redefining ‘new’ works for both Ruby 1.6 and 1.8,
I’ve left it that way until now. If Matz, Nobu and others feel confident
about the new allocation implementation in 1.8 I can revisit the issue.
I’m confident. Tell me if you see any problem that I don’t know.
So far, I’ve purposely avoided making any changes to support Ruby’s
new allocation scheme since (at least in its initial implementation in
Ruby 1.7.x) there seemed to be some problems. There’s also the issue
of backwards compatibility with Ruby versions 1.6.x and earlier. If
SWIG is to generate code that will compile under both Ruby 1.6 and
Ruby 1.8, there will presumably need to be a compile-time check of the
Ruby version number.
1.8 defines HAVE_RB_DEFINE_ALLOC_FUNC for that purpose.
SWIG doesn’t seem to use rb_define_alloc_func(), so allocator
of Object is used by rb_class_new_instance(). “new” works fine
because SWIG redefines Redirect.new (but it is deprecated now).
Is this a problem SWIG ?
SWIG (1.3.19 at least) seems to not support ruby 1.8.
And the practical upshot is?
Mind you, at least you guy’s got to look at simon’s tutorial. What do
you think. Any comments for us humble users
···
At Wed, 16 Apr 2003 01:25:33 +0900, > Simon Strandgaard wrote:
Thanks very much for the patches, Nobu; I’ve incorporated them into the
SWIG CVS and they should be available in SWIG 1.3.20.
One aspect of this change is still unclear to me: what is now the
correct way to indicate that an extension class is an abstract class?
Previously, SWIG was either redefining ‘new’ for concrete extension
classes, or undefining ‘new’ for abstract extension classes.
One aspect of this change is still unclear to me: what is now the
correct way to indicate that an extension class is an abstract class?
Previously, SWIG was either redefining ‘new’ for concrete extension
classes, or undefining ‘new’ for abstract extension classes.
Sorry, I missed it. You can make them abstract by undefining
allocator with rb_undef_alloc_func().
Please replace all STR2CSTR to StringValue, and apply this
patch.
Sorry, I missed it. You can make them abstract by undefining
allocator with rb_undef_alloc_func().
OK.
Please replace all STR2CSTR to StringValue, and apply this
patch.
Don’t you mean replace all STR2CSTR with StringValuePtr? I think
StringValue() returns a String object (a VALUE) while StringValuePtr()
returns the underlying C character array.