Naming conflict with generated "_get" functions in Lua

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Naming conflict with generated "_get" functions in Lua

Myria
I have a struct that looks like this:

%module badname;

struct BadName
{
        int a;
        int a_get() const;
};



The problem is that SWIG is generating two functions named
_wrap_BadName_a_get, causing a compile error in the badname_wrap.cxx
file.

Is there a way to work around this problem?  Note that there are
thousands of lines of existing Lua script code that we have that
expect both cases to work, so changing the Lua side isn't an option.

Thanks,

Melissa

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Swig-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/swig-user
Reply | Threaded
Open this post in threaded view
|

Re: Naming conflict with generated "_get" functions in Lua

William S Fulton
On 15 October 2016 at 00:36, Myria <[hidden email]> wrote:

> I have a struct that looks like this:
>
> %module badname;
>
> struct BadName
> {
>         int a;
>         int a_get() const;
> };
>
>
>
> The problem is that SWIG is generating two functions named
> _wrap_BadName_a_get, causing a compile error in the badname_wrap.cxx
> file.
>
> Is there a way to work around this problem?  Note that there are
> thousands of lines of existing Lua script code that we have that
> expect both cases to work, so changing the Lua side isn't an option.
>

Use the advanced renaming to ignore all methods ending in _get by
adding this at the top of your interface file:

%rename("$ignore", regexmatch$name="_get$") "";

See http://swig.org/Doc3.0/SWIG.html#SWIG_rename_ignore

William

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Swig-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/swig-user