mirror of https://github.com/swig/swig
[Ruby] Fix remove of prefix from method name
The prefix is now only removed at the start. Fixes https://sourceforge.net/p/swig/bugs/1136/
This commit is contained in:
parent
27a3d16ac6
commit
2e98189564
|
@ -7,6 +7,10 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/
|
|||
Version 4.1.0 (in progress)
|
||||
===========================
|
||||
|
||||
2022-02-02: olly
|
||||
[Ruby] https://sourceforge.net/p/swig/bugs/1136/ Fix remove of prefix
|
||||
from method name to only remove it at the start.
|
||||
|
||||
2022-02-01: olly
|
||||
#231 Handle returning an object by reference in a C++ trailing
|
||||
return type.
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
#!/usr/bin/env ruby
|
||||
#
|
||||
# Regression tests for Ruby naming bugs
|
||||
#
|
||||
|
||||
require 'swig_assert'
|
||||
|
||||
require 'ruby_naming_bugs'
|
||||
|
||||
# Prior to SWIG 4.1.0 the "Cool_" here was overzealously removed
|
||||
# while trying to remove a class name prefix, so this method would be
|
||||
# named "somethingFast" in Ruby instead.
|
||||
c = Ruby_naming_bugs::Cool.new()
|
||||
if c.somethingCool_Fast != 42
|
||||
raise RuntimeError, "Incorrect value for somethingCool_Fast"
|
||||
end
|
|
@ -0,0 +1,9 @@
|
|||
%module ruby_naming_bugs
|
||||
|
||||
%inline %{
|
||||
// Prior to SWIG 4.1.0 the "Cool_" here was overzealously removed while
|
||||
// trying to remove a class name prefix.
|
||||
struct Cool {
|
||||
int somethingCool_Fast() { return 42; }
|
||||
};
|
||||
%}
|
|
@ -106,9 +106,10 @@ public:
|
|||
|
||||
char *strip(const_String_or_char_ptr s) {
|
||||
Clear(temp);
|
||||
Append(temp, s);
|
||||
if (Strncmp(s, prefix, Len(prefix)) == 0) {
|
||||
Replaceall(temp, prefix, "");
|
||||
Append(temp, Char(s) + Len(prefix));
|
||||
} else {
|
||||
Append(temp, s);
|
||||
}
|
||||
return Char(temp);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue