Hi Keith,

Very nice work there, thanks.  I've been looking at this too and had
an alternate solution to the nested union problem
(https://issues.apache.org/jira/secure/attachment/12574482/pn254-cj-0.patch).

It is based on the observation that there is nothing wrong with the
definition in codec.h that swig complains about to begin with.  That,
plus it irks me to change a public interface file just to satisfy the
one C99 unfriendly compiler in the world.  So I looked for a solution
that was specific to swig.

Sadly, swig handled this just fine in the 1.X series, precisely to
handle cases such as here.  However that apparently exacerbated
problems elsewhere and, as far as I can tell, their new fancy
%nestedworkaround fix in swig 2.X can't work in our case and leaves us
high and dry.

The patch I provided just restores the swig 1.X behaviour.  The
downside is the (twice) repeated re-definition of the union (bleh, my
swig knowledge could find no better solution).  Your patch is cleaner
in that respect.   If my patch seems distasteful in its foibles, I
would look to Rafi for his views on changing codec.h.  Let me know
what you think.

I had just got this working yesterday on Linux and was trying a
Windows build before posting a review.  It fails in cmake scripts
working with windows paths (and maybe other problems).  But it does
compile the swig part in Visual Studio.

Let me know if you wish to tackle the remaining windows build issues.

Cliff



On Tue, Mar 19, 2013 at 7:50 PM, Keith W <[email protected]> wrote:
> On 1 March 2013 16:15, Cliff Jansen <[email protected]> wrote:
>> I did all that and verified the c++ swig call was used and g++ on
>> javaJAVA_wrap.cxx.  I also needed the fix in PROTON-249 to progress on
>> Windows.
>>
>> Let me know if you have made further progress.  Otherwise, I will keep 
>> digging.
>>
>> Cliff
>
> Hi Cliff
>
> I made a commit under PROTON-254 that
>
> a) changes bindings/java/CMakeLists.txt to use CPLUSPLUS ON directive
> in the case where BUILD_WITH_CXX has been enabled
> b) resolves the compilation errors that resulted from compiling the
> swig generated C++ code.
>
> That leaves the problem with "Nested union not currently supported'
> reported by Swig.  You'll remember that Swig doesn't support nested
> types when operating in C++ mode, and so ignores the nested union
> within pn_atom_t.  This means swig fails to generate the pn_atom_t_u
> java class and so our hand-rolled java binding code (java) fails to
> compile.
>
> I've attached a patch to PROTON-254 that works around the issue by
> simply moving the union to the top level.  This seems to avoid the
> swig limitation seemingly without breaking anything else.  Do you see
> a problem with this approach?  Can you think of an neater alternative?
>
> The patch allows the JNI tests to pass under C++ on Ubuntu and MacOSX.
>  I'm yet to try on Windows.
>
> Kind regards, Keith.

Reply via email to