Discussion:
[Swig-devel] [MATLAB] memberconstantHandler problem
Kris Thielemans
2015-05-31 23:16:15 UTC
Permalink
Dear Joel et al

I’m trying Joel’s updates to the matlab code. It seems that the recent refactoring of constant lookup (commit c8eafe02c0612da32acbdb13e1e8f0294718bef5) breaks things in enums in a class. A test case is as follows:
-------------
%module test
%{
%}
class Succeeded
{
public:
enum value { yes, no };
};
----------

The problem seems to be that memberconstantHandler still has the old convention of only passing the name to the wrapper (as opposed to passing the id as well).

I think this needs to be fixed by modifying constantWrapper to not emit anything when not in a class, and leave it for memberconstantHandler. (I tried the alternative, i.e. let constWrapper handle the memberconstant case as well but can’t get that to work because sym:name seems to include the class name then).

I am quite confused when constantWrapper is called and what it should handle (is there any documentation for that?). I think I could fix this by copying most of the code in constantWrapper to memberconstantHandler, but that’d be a terrible idea. So I’m afraid I can’t give you a patch…

Can anyone help?

Kris






PS: I didn’t file this as a github bug in your fork as I’m guessing that William et al wouldn’t see that.
PS: This would have been caught by the enums test-case. we clearly need to get the test-suite working... I'm trying to get some help for that.





------------------------------------------------------------------------------
Joel Andersson
2015-06-02 09:49:35 UTC
Permalink
Hi Kris, all,

I'll have a look at this asap. You're right that this is a typical thing
that wouldn't have happened if we have had a working testing framework.
Keep us informed if you make progress on testing. I'm going to check a
collegue also - he just migrated out tool (CasADi) to Travis.

Joel
Post by Kris Thielemans
Dear Joel et al
I’m trying Joel’s updates to the matlab code. It seems that the recent
refactoring of constant lookup (commit
c8eafe02c0612da32acbdb13e1e8f0294718bef5) breaks things in enums in a
-------------
%module test
%{
%}
class Succeeded
{
enum value { yes, no };
};
----------
The problem seems to be that memberconstantHandler still has the old
convention of only passing the name to the wrapper (as opposed to passing
the id as well).
I think this needs to be fixed by modifying constantWrapper to not emit
anything when not in a class, and leave it for memberconstantHandler. (I
tried the alternative, i.e. let constWrapper handle the memberconstant case
as well but can’t get that to work because sym:name seems to include the
class name then).
I am quite confused when constantWrapper is called and what it should
handle (is there any documentation for that?). I think I could fix this by
copying most of the code in constantWrapper to memberconstantHandler, but
that’d be a terrible idea. So I’m afraid I can’t give you a patch

Can anyone help?
Kris
PS: I didn’t file this as a github bug in your fork as I’m guessing that
William et al wouldn’t see that.
PS: This would have been caught by the enums test-case. we clearly need to
get the test-suite working... I'm trying to get some help for that.
--
--
Joel Andersson, PhD
Ptge. Busquets 11-13, atico 3
E-08940 Cornella de Llobregat (Barcelona), Spain
Home: +34-93-6034011
Mobile: +34-63-4408800 (in Sweden also +46-707-360512)
William S Fulton
2015-06-04 06:32:46 UTC
Permalink
Post by Kris Thielemans
I am quite confused when constantWrapper is called and what it should handle
(is there any documentation for that?).
I can't think of any, so I'll try...

%constant
Simple #define constants such as: #define A 1
Inline integral static member initialization such as: static const int a = 1;
%callback
enum items in global enums

Hope that helps
William

------------------------------------------------------------------------------
Loading...