#738 [ruby] autorename and std::vector

open
nobody
5
2007-05-05
2006-08-24
harprobey
No

SWIG renames std::vector functions push_back(), size()
with Ruby names push, length, clear etc. When
autorename is turned on, the names for std:vector
functions are not converted to Ruby conventions. There
are left as push_back, size etc.

Discussion

  • Olly Betts

    Olly Betts - 2006-09-26
    • labels: --> 379157
    • summary: autorename and std::vector --> [ruby] autorename and std::vector
     
  • Olly Betts

    Olly Betts - 2006-09-26

    Logged In: YES
    user_id=14972

    Setting the category to ruby.

     
  • Mark Donszelmann

    Logged In: YES
    user_id=800216

    Also applies to Java (methods push_back and empty should
    rename to add and isEmpty)

     
  • Gonzalo Garramuno

    Logged In: YES
    user_id=961712
    Originator: NO

    This problem is not related to the ruby module but it is a bug/misfeature of %rename that should effect several languages.

    Currently using:

    %rename("%(undercase)s", %isfunction, %$not $ismemberget, %$not %$ismemberset ) "";

    overrides ALL other %renames in other swig files.
    This prevents std:: methods from being renamed properly.

    Changing the category of the bug.

     
  • Gonzalo Garramuno

    • labels: 379157 --> preprocessor
     
  • Gonzalo Garramuno

    Logged In: YES
    user_id=961712
    Originator: NO

    I've looked into the problem. The problem can be summarized as an issue with templates.

    A rename inside a template declaration, like:

    %extend std::vector {
    %rename("sth") orig;
    }

    is not being applied at all. Its hash rename entry basically never matches the template function name.

    Templates only support global %renames of the form:

    %rename("sth") orig;
    or
    %rename("sth") *::orig;

    The ruby modules has now changed the STL renames to support that. That of, course, means that any other class that is not the STL and has push_back or similar methods will get renamed.

    The reason why an

    %extend std::vector {
    %rename("sth") orig;
    }

    WILL work without ruby's auto-rename is that SWIG's renaming code has a *huge* hack in it in that it uses a very hackish variable called oldname carries its "oldname" around... which is applied as a last resort. This oldname does not seem to come from a normal rename match. This "oldname" variable should really be killed and the hash matching should be fixed.

    Also, it would be benefitial to extend the %rename * functionality to allow for something like:

    %rename("push") std::*::push_back;

     
  • Gonzalo Garramuno

    • status: open --> closed
     
  • Gonzalo Garramuno

    Logged In: YES
    user_id=961712
    Originator: NO

    I've looked into the problem. The problem can be summarized as an issue with templates.

    A rename inside a template declaration, like:

    %extend std::vector {
    %rename("sth") orig;
    }

    is not being applied at all. Its hash rename entry basically never matches the template function name.

    Templates only support global %renames of the form:

    %rename("sth") orig;
    or
    %rename("sth") *::orig;

    The ruby modules has now changed the STL renames to support that. That of, course, means that any other class that is not the STL and has push_back or similar methods will get renamed.

    The reason why an

    %extend std::vector {
    %rename("sth") orig;
    }

    WILL work without ruby's auto-rename is that SWIG's renaming code has a *huge* hack in it in that it uses a very hackish variable called oldname carries its "oldname" around... which is applied as a last resort. This oldname does not seem to come from a normal rename match. This "oldname" variable should really be killed and the hash matching should be fixed.

    Also, it would be benefitial to extend the %rename * functionality to allow for something like:

    %rename("push") std::*::push_back;

     
  • Gonzalo Garramuno

    • status: closed --> open
     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks