attribute tidy up. %attributeref replaces %attribute_ref
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10000 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
4513953e96
commit
2a89d09add
5 changed files with 102 additions and 134 deletions
|
|
@ -1,75 +0,0 @@
|
|||
%module attributetest
|
||||
|
||||
%include attribute.i
|
||||
|
||||
%attribute(A, int, a, get_a, set_a);
|
||||
%attribute_ref(A, int, b);
|
||||
|
||||
%attribute_ref(Param<int>, int, value);
|
||||
|
||||
|
||||
%attribute(A, int, c, get_c); /* read-only */
|
||||
%attribute_ref(A, int, b, d); /* different attribute name 'd' */
|
||||
|
||||
%inline
|
||||
{
|
||||
struct A
|
||||
{
|
||||
A(int a, int b, int c) : _a(a), _b(b), _c(c)
|
||||
{
|
||||
}
|
||||
|
||||
int get_a() const
|
||||
{
|
||||
return _a;
|
||||
}
|
||||
|
||||
void set_a(int aa)
|
||||
{
|
||||
_a = aa;
|
||||
}
|
||||
|
||||
const int& b() const
|
||||
{
|
||||
return _b;
|
||||
}
|
||||
|
||||
int& b()
|
||||
{
|
||||
return _b;
|
||||
}
|
||||
|
||||
int get_c() const
|
||||
{
|
||||
return _c;
|
||||
}
|
||||
private:
|
||||
int _a;
|
||||
int _b;
|
||||
int _c;
|
||||
};
|
||||
|
||||
template <class C>
|
||||
struct Param
|
||||
{
|
||||
Param(C v) : _v(v)
|
||||
{
|
||||
}
|
||||
|
||||
const int& value() const
|
||||
{
|
||||
return _v;
|
||||
}
|
||||
|
||||
int& value()
|
||||
{
|
||||
return _v;
|
||||
}
|
||||
private:
|
||||
C _v;
|
||||
};
|
||||
}
|
||||
|
||||
%template(Param_i) Param<int>;
|
||||
|
||||
|
||||
|
|
@ -43,4 +43,10 @@ if b.a.c != 3:
|
|||
raise RuntimeError
|
||||
|
||||
|
||||
myFoo = li_attribute.MyFoo
|
||||
myFoo.x = 8
|
||||
myClass = li_attribute.MyClass
|
||||
myClass.Foo = myFoo
|
||||
if myClass.Foo.x != 8:
|
||||
raise RuntimeError
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue