From: SourceForge.net <no...@so...> - 2008-12-22 23:47:03
|
Bugs item #2430654, was opened at 2008-12-15 17:21 Message generated for change (Comment added) made by boom5 You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=101645&aid=2430654&group_id=1645 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: python Group: None Status: Closed Resolution: Invalid Priority: 5 Private: No Submitted By: Yoonsik Oh (boom5) Assigned to: William Fulton (wsfulton) Summary: Wrong in another module, called the destructor Initial Comment: There are two modules to the class of the same name, called the destructor of other modules. == a.i == %module A %{ #include <iostream> struct test { ~test() { std::cout << "A.~test()" << std::endl; } }; %} struct test {}; == b.i == %module B %{ #include <iostream> struct test { ~test() { std::cout << "B.~test()" << std::endl; } }; %} struct test {}; == test.py == import A import B v = A.test() $ swig -python -c++ a.i $ g++ -shared a_wrap.cxx -o _A.so -I/usr/include/python2.5/ $ swig -python -c++ b.i $ g++ -shared b_wrap.cxx -o _B.so -I/usr/include/python2.5/ $ python test.py Expected Results: A.~test() But, Actual results: B.~test() <-- called wrong destructor It is always called, importing the future of the module. ---------------------------------------------------------------------- Comment By: Yoonsik Oh (boom5) Date: 2008-12-23 08:46 Message: I did not familiar with the use of import. Thanks a lot! ---------------------------------------------------------------------- Comment By: William Fulton (wsfulton) Date: 2008-12-23 07:44 Message: You've got two different proxy classes for your vector ... wrap it just once. Either: Put just one of the %template declarations in one of the modules and %import that module by the 2nd module, or create a third module for your vector %template declaration and %import that by both modules A and B. ---------------------------------------------------------------------- Comment By: Yoonsik Oh (boom5) Date: 2008-12-22 13:22 Message: No, This is just an example to explain this, This is intentionally made. A and B is the same as the name is different class in different module. In fact, I use the following code, my program had abnormal termination uncommonly. == a.i == %module A %{ #include <vector> void testA(const std::vector<int>& v) {} %} %include "std_vector.i" %template(VectorIntA) std::vector<int>; void testA(const std::vector<int>& v); == b.i == %module B %{ #include <vector> void testB(const std::vector<int>& v) {} %} %include "std_vector.i" %template(VectorIntB) std::vector<int>; void testB(const std::vector<int>& v); Because VectorIntA use destructor of VectorIntB. There is a lot of program using several modules. In this case, how can I do? ---------------------------------------------------------------------- Comment By: William Fulton (wsfulton) Date: 2008-12-21 09:28 Message: This is expected behaviour as you have explicitly provided two different implementations of one class. Use a .h and possibly a .cpp file instead for the implementation so that you have just one implementation. Then %include the appropriate .h file. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=101645&aid=2430654&group_id=1645 |