#170 Fix bug outputing "<:" token

closed-accepted
None
5
2007-03-30
2007-03-29
No

Small tweak to the SwigValueWrapper, it could output types like:

SwigValueWrapper<::foo > bar;

The "<:" token annoys GCC.

I copied from similar code found in stype.c to create this patch.

Note: the SwigType_alttype function has two main branches that have similar code, in the first case it does:

if (use_wrapper) {
String *str = SwigType_str(td, 0);
w = NewStringf("SwigValueWrapper<%s >", str);
Delete(str);
}

and in the second case it does:

if (use_wrapper) {
w = NewStringf("SwigValueWrapper<%s >", td);
}

td is a SwigType* in both cases. The stringification of td in the second case seemed suspicious to me so in my patch I changed the code to match the use in the first case.

It looks like this function could be cleaned up further by pulling the now-identical use_wrapper blocks out of the main if/else.

Discussion

  • J Robert Ray

    J Robert Ray - 2007-03-29

    Fix "<:" is "[" warning

     
  • Olly Betts

    Olly Betts - 2007-03-29
    • assigned_to: nobody --> olly
     
  • Olly Betts

    Olly Betts - 2007-03-29

    Logged In: YES
    user_id=14972
    Originator: NO

    Thanks for the patch. I'm looking at applying it now...

     
  • Olly Betts

    Olly Betts - 2007-03-30

    Logged In: YES
    user_id=14972
    Originator: NO

    OK, applied.

    I went for just always inserting a space between "<" and the type which is simpler (it was actually me who changed stype.c - there I was concerned that changing the strings generated might cause problems if some other part of SWIG looked at the result - here it's more obvious that nothing does).

    I factored out some of the common code too.

    Using %s like this with a SwigType* is OK. If you look in Source/Swig/swig.h, SwigType is a typedef for DOH, and so it just magically gets converted to a string (see DohvPrintf() in Source/DOH/fio.c).

     
  • Olly Betts

    Olly Betts - 2007-03-30
    • status: open --> closed-accepted
     

Log in to post a comment.

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

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks