[pygccxml-commit] SF.net SVN: pygccxml: [1259] pyplusplus_dev
Brought to you by:
mbaas,
roman_yakovenko
|
From: <rom...@us...> - 2008-02-25 07:25:25
|
Revision: 1259
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1259&view=rev
Author: roman_yakovenko
Date: 2008-02-24 23:25:27 -0800 (Sun, 24 Feb 2008)
Log Message:
-----------
adding new test case
Modified Paths:
--------------
pyplusplus_dev/docs/history/history.rest
pyplusplus_dev/unittests/data/override_bug_to_be_exported.hpp
pyplusplus_dev/unittests/override_bug_tester.py
Modified: pyplusplus_dev/docs/history/history.rest
===================================================================
--- pyplusplus_dev/docs/history/history.rest 2008-02-24 15:07:30 UTC (rev 1258)
+++ pyplusplus_dev/docs/history/history.rest 2008-02-25 07:25:27 UTC (rev 1259)
@@ -34,6 +34,99 @@
3. Users always changed the name of the projects. I saw at least 6 different names.
+-----------
+Version SVN
+-----------
+
+1. The algorithm, which calculates what member functions should be redefined in derived
+ class wrappers was improved. For example:
+
+ .. code-block:: C++
+
+ struct A{
+ virtual void foo() {}
+ };
+
+ class B: public A{
+ };
+
+ Previous version of `Py++`_ didn't generate wrapper for class ``B``, even
+ though ``B`` inherits ``A``'s virtual function. Now if you have the following
+ Python code:
+
+ .. code-block:: Python
+
+ class C(B):
+ def __init__( self ):
+ B.__init__(self)
+ def foo(self):
+ print "C.foo"
+
+ then when ``foo`` is invoked on this instance on the C++ side of things, the
+ Python code won't be executed as the wrapper is missing.
+
+ If you use "function transformation" functionality, than it is possible the
+ generated code will not compile. Consider next example:
+
+ .. code-block:: C++
+
+ struct A{
+ virtual void foo(int& i) {/*do smth*/}
+ };
+
+ class B: public A{
+ virtual void foo(int& i) {/*do smth else*/}
+ };
+
+ The `Py++`_ code:
+
+ .. code-block:: Python
+
+ from pyplusplus import module_builder
+ from pyplusplus import function_transformers as FT
+
+ mb = module_builder_t( ... )
+ foo = mb.mem_funs( 'foo' )
+ foo.add_transformation( FT.output(0) )
+
+ The generated code of wrapper class, for class ``B``, will contain next code:
+
+ .. code-block:: C++
+
+ virtual void foo() {
+ ...
+ }
+
+ static boost::python::tuple default_foo( ::B & inst ){
+ ...
+ }
+
+ virtual void foo() {
+ ...
+ }
+
+ static boost::python::tuple default_foo( ::B & inst ){
+ ...
+ }
+
+ Yes, the functions will be defined twice! In the previous version, the functions
+ were also defined twice but in the different classes. It was unclear, what
+ function will be called in this or that situation.
+
+ If you have such situation, I suggest you to give aliases to the functions:
+
+ .. code-block:: Python
+
+
+ from pyplusplus import module_builder
+ from pyplusplus import function_transformers as FT
+
+ mb = module_builder_t( ... )
+ for f in mb.mem_funs( 'foo' )
+ foo.add_transformation( FT.output(0), alias=f.name + '_' + f.parent.name )
+
+
+
-------------
Version 0.9.5
-------------
Modified: pyplusplus_dev/unittests/data/override_bug_to_be_exported.hpp
===================================================================
--- pyplusplus_dev/unittests/data/override_bug_to_be_exported.hpp 2008-02-24 15:07:30 UTC (rev 1258)
+++ pyplusplus_dev/unittests/data/override_bug_to_be_exported.hpp 2008-02-25 07:25:27 UTC (rev 1259)
@@ -60,6 +60,18 @@
}
+class AA
+{
+ public:
+ virtual void do_smth(int& i) const { i = 'a' ;}
+ virtual ~AA(){}
+};
+
+class BB: public AA
+{
+ virtual void do_smth(int& i) const { i = 'b' ;}
+};
+
}
#endif//__final_classes_to_be_exported_hpp__
Modified: pyplusplus_dev/unittests/override_bug_tester.py
===================================================================
--- pyplusplus_dev/unittests/override_bug_tester.py 2008-02-24 15:07:30 UTC (rev 1258)
+++ pyplusplus_dev/unittests/override_bug_tester.py 2008-02-25 07:25:27 UTC (rev 1259)
@@ -7,6 +7,7 @@
import sys
import unittest
import fundamental_tester_base
+from pyplusplus import function_transformers as FT
class tester_t(fundamental_tester_base.fundamental_tester_base_t):
EXTENSION_NAME = 'override_bug'
@@ -19,6 +20,9 @@
def customize( self, mb ):
mb.class_("Derived2").member_functions("eval_c").exclude()
+ mb.class_( 'BB' ).include()
+ do_smth = mb.mem_funs( 'do_smth' )
+ do_smth.add_transformation( FT.output(0) )
def run_tests(self, module):
class C( module.B ):
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|