Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#1136 Strange behaviour on method names containing underscores (_)

open
Klaus Kämpf
ruby (61)
5
2012-12-10
2011-02-27
Volker Grabsch
No

This is a clarification for Bug 3086615 which has been prematurely closed. ( https://sourceforge.net/tracker/?func=detail&aid=3086615&group_id=1645&atid=101645 )

In that report, I forgot to mention one precondition for this issue: The class has to be named according to the stripped prefix. So the following "example.i" triggers the bug:

%module example
%inline %{
class Cool {
public:
int somethingCool_Fast() {
return 42;
}
};
%}

The "example.so" can be built with the following commands:

swig -ruby -c++ example.i
g++ -shared -fPIC -I"`ruby -r rbconfig -e 'puts(Config::CONFIG["archdir"] || "")'`" -o example.so example_wrap.cxx

Then, the following Ruby snippet fails:

require 'example'
c = Example::Cool.new
puts c.somethingCool_Fast() # fails, but shouldn't

However, the following Ruby code works, although it shouldn't:

require 'example'
c = Example::Cool.new
puts c.somethingFast() # outputs "42", but should fail as there is no such method

I confirmed that this issue still exists in the current SWIG 2.0.2 release.

Discussion

  • William Fulton
    William Fulton
    2012-12-10

    • assigned_to: gga73 --> kkaempf