1 %module li_boost_shared_ptr_attribute 2 3 #if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGPYTHON) || defined(SWIGD) || defined(SWIGOCTAVE) || defined(SWIGRUBY) 4 #define SHARED_PTR_WRAPPERS_IMPLEMENTED 5 #endif 6 7 #if defined(SHARED_PTR_WRAPPERS_IMPLEMENTED) 8 9 %include "attribute.i" 10 %include "boost_shared_ptr.i" 11 12 %inline %{ 13 #include <boost/shared_ptr.hpp> 14 using namespace boost; 15 %} 16 %shared_ptr(GetMe); 17 %shared_ptr(GetSetMe); 18 %attributestring(GetterOnly, shared_ptr<GetMe>, AddedAttrib, GetIt) 19 %attributestring(GetterSetter, shared_ptr<GetSetMe>, AddedAttrib, GetIt, SetIt) 20 21 %inline %{ 22 struct GetMe { GetMeGetMe23 explicit GetMe(int n) : n(n) {} ~GetMeGetMe24 ~GetMe() {} 25 int n; 26 }; 27 struct GetSetMe { GetSetMeGetSetMe28 explicit GetSetMe(int n) : n(n) {} ~GetSetMeGetSetMe29 ~GetSetMe() {} 30 int n; 31 }; 32 33 struct GetterOnly { GetterOnlyGetterOnly34 explicit GetterOnly(int n) : myval(new GetMe(n*n)) {} GetItGetterOnly35 shared_ptr<GetMe> GetIt() const { return myval; } 36 shared_ptr<GetMe> myval; 37 }; 38 struct GetterSetter { GetterSetterGetterSetter39 explicit GetterSetter(int n) : myval(new GetSetMe(n*n)) {} GetItGetterSetter40 shared_ptr<GetSetMe> GetIt() const { return myval; } SetItGetterSetter41 void SetIt(shared_ptr<GetSetMe> newval) { myval = newval; } 42 shared_ptr<GetSetMe> myval; 43 }; 44 %} 45 46 #endif 47