swig/swig — pull request #48 by v-for-vandal (2013-05-24 09:57:47+00:00)
Title: Attribute

Patch for SVN Patch ticket #338 - fixes to %attribute macroses.

There are 2 commits:
1) Fixes typemaps/attribute.swg - add %arg as promised
2) Second commit fixes problem with Lib/attribute.i . In this file %arg is defined incorrectly.
Some modules supply their own attribute.i in module-specific folder. ( Those custom attribute.i files usually have just one command - %include .
However some modules do not supply such "useless" file and rely on system-wide one (Lib/attribute.i). As was mentioned, Lib/attribute.i previously contained invalid %arg declaration.
The example of such language is lua.

Commits are independent from each other.

The test case is below:
```
%module attribute_error

%include

%inline {
class Foo {};

template
class C {
public:
int Val() const { return 5; }
const int& RefVal() const { return val1; }
Foo Class() const { return val2; }
const Foo& RefClass() const { return val2; }
private:
int val1;
Foo val2;
};
}

// Non-templated variant
%attribute( %arg(C), int, ValWrap, Val );
%attributeval( %arg(C), Foo, ClassWrap, Class );
%attributeref( %arg(C), int, RefValWrap, RefVal );
%attribute2( %arg(C), Foo, RefClassWrap, RefVal );
%template (CIntInt) C;

// templated variant. Used
#define SWIG_ATTRIBUTE_TEMPLATE

%attribute( %arg(C), double, ValWrap, Val );
%attributeval( %arg(C), Foo, ClassWrap, Class );
%attributeref( %arg(C), double, RefValWrap, RefVal );
%attribute2( %arg(C), Foo, RefClassWrap, RefVal );
%template (CDoubleDouble) C;
```