move attribute.i to the typemap library, now is usable from all the languages

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@7717 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Marcelo Matus 2005-10-25 13:20:50 +00:00
commit 1c529aa802
12 changed files with 251 additions and 159 deletions

View file

@ -0,0 +1,75 @@
%module li_attribute
%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>;

View file

@ -11,6 +11,7 @@ top_builddir = @top_builddir@
CPP_TEST_CASES += \
primitive_types \
li_attribute \
li_cstring \
C_TEST_CASES += \

View file

@ -1,7 +1,6 @@
*wrap* *.pyc *.so *.dll *.exp *.lib
Makefile
argcargvtest.py
attributetest.py
autodoc.py
callback.py
complextest.py
@ -459,3 +458,5 @@ inherit.py
empty.py
virtual_derivation.py
langobj.py
li_attribute.py
typedef_struct.py

View file

@ -13,7 +13,6 @@ top_builddir = @top_builddir@
CPP_TEST_CASES += \
argcargvtest \
attributetest \
autodoc \
callback \
complextest \
@ -25,6 +24,7 @@ CPP_TEST_CASES += \
input \
inplaceadd \
kwargs \
li_attribute \
li_cstring \
li_cwstring \
li_implicit \

View file

@ -1,6 +1,6 @@
import attributetest
import li_attribute
aa = attributetest.A(1,2,3)
aa = li_attribute.A(1,2,3)
if aa.a != 1:
raise RuntimeError
@ -28,7 +28,7 @@ if aa.c != 3:
#if aa.c != 3:
# raise RuntimeError
pi = attributetest.Param_i(7)
pi = li_attribute.Param_i(7)
if pi.value != 7:
raise RuntimeError

View file

@ -11,7 +11,13 @@ top_builddir = @top_builddir@
CPP_TEST_CASES = \
track_objects \
track_objects_directors
track_objects_directors \
primitive_types \
li_attribute \
li_cstring
C_TEST_CASES += \
li_cstring
include $(srcdir)/../common.mk
@ -43,6 +49,6 @@ run_testcase = \
# Clean
%.clean:
clean:
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile ruby_clean

View file

@ -11,6 +11,7 @@ top_builddir = @top_builddir@
CPP_TEST_CASES += \
primitive_types \
li_attribute \
li_cstring \
li_cwstring \
li_std_wstring