pygccxml-commit Mailing List for C++ Python language bindings (Page 49)
Brought to you by:
mbaas,
roman_yakovenko
You can subscribe to this list here.
2006 |
Jan
|
Feb
|
Mar
(190) |
Apr
(166) |
May
(170) |
Jun
(75) |
Jul
(105) |
Aug
(131) |
Sep
(99) |
Oct
(84) |
Nov
(67) |
Dec
(54) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2007 |
Jan
(66) |
Feb
(49) |
Mar
(25) |
Apr
(62) |
May
(21) |
Jun
(34) |
Jul
(9) |
Aug
(21) |
Sep
(5) |
Oct
|
Nov
(63) |
Dec
(34) |
2008 |
Jan
(10) |
Feb
(42) |
Mar
(26) |
Apr
(25) |
May
(6) |
Jun
(40) |
Jul
(18) |
Aug
(29) |
Sep
(6) |
Oct
(32) |
Nov
(14) |
Dec
(56) |
2009 |
Jan
(127) |
Feb
(52) |
Mar
(2) |
Apr
(10) |
May
(29) |
Jun
(3) |
Jul
|
Aug
(16) |
Sep
(4) |
Oct
(11) |
Nov
(8) |
Dec
(14) |
2010 |
Jan
(31) |
Feb
(1) |
Mar
(7) |
Apr
(9) |
May
(1) |
Jun
|
Jul
(2) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2011 |
Jan
|
Feb
(8) |
Mar
(4) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2014 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <rom...@us...> - 2006-10-11 12:51:05
|
Revision: 647 http://svn.sourceforge.net/pygccxml/?rev=647&view=rev Author: roman_yakovenko Date: 2006-10-11 05:50:41 -0700 (Wed, 11 Oct 2006) Log Message: ----------- rename files + configure what is (not) shown Modified Paths: -------------- pyplusplus_dev/docs/bpl_lessons_learned/smart_ptrs/smart_ptr.h Added Paths: ----------- pyplusplus_dev/docs/bpl_lessons_learned/smart_ptrs/bindings.cpp.rest pyplusplus_dev/docs/bpl_lessons_learned/smart_ptrs/classes.hpp.rest pyplusplus_dev/docs/bpl_lessons_learned/smart_ptrs/smart_ptr.h.rest pyplusplus_dev/docs/bpl_lessons_learned/smart_ptrs/test.py.rest pyplusplus_dev/docs/bpl_lessons_learned/smart_ptrs/www_configuration.py Removed Paths: ------------- pyplusplus_dev/docs/bpl_lessons_learned/smart_ptrs/bindings.rest pyplusplus_dev/docs/bpl_lessons_learned/smart_ptrs/classes.rest pyplusplus_dev/docs/bpl_lessons_learned/smart_ptrs/smart_ptr.rest pyplusplus_dev/docs/bpl_lessons_learned/smart_ptrs/test.rest Copied: pyplusplus_dev/docs/bpl_lessons_learned/smart_ptrs/bindings.cpp.rest (from rev 646, pyplusplus_dev/docs/bpl_lessons_learned/smart_ptrs/bindings.rest) =================================================================== --- pyplusplus_dev/docs/bpl_lessons_learned/smart_ptrs/bindings.cpp.rest (rev 0) +++ pyplusplus_dev/docs/bpl_lessons_learned/smart_ptrs/bindings.cpp.rest 2006-10-11 12:50:41 UTC (rev 647) @@ -0,0 +1,3 @@ +.. code-block:: + :language: C++ + :source-file: ./bindings.cpp Deleted: pyplusplus_dev/docs/bpl_lessons_learned/smart_ptrs/bindings.rest =================================================================== --- pyplusplus_dev/docs/bpl_lessons_learned/smart_ptrs/bindings.rest 2006-10-11 12:11:40 UTC (rev 646) +++ pyplusplus_dev/docs/bpl_lessons_learned/smart_ptrs/bindings.rest 2006-10-11 12:50:41 UTC (rev 647) @@ -1,3 +0,0 @@ -.. code-block:: - :language: C++ - :source-file: ./bindings.cpp Copied: pyplusplus_dev/docs/bpl_lessons_learned/smart_ptrs/classes.hpp.rest (from rev 646, pyplusplus_dev/docs/bpl_lessons_learned/smart_ptrs/classes.rest) =================================================================== --- pyplusplus_dev/docs/bpl_lessons_learned/smart_ptrs/classes.hpp.rest (rev 0) +++ pyplusplus_dev/docs/bpl_lessons_learned/smart_ptrs/classes.hpp.rest 2006-10-11 12:50:41 UTC (rev 647) @@ -0,0 +1,3 @@ +.. code-block:: + :language: C++ + :source-file: ./classes.hpp Deleted: pyplusplus_dev/docs/bpl_lessons_learned/smart_ptrs/classes.rest =================================================================== --- pyplusplus_dev/docs/bpl_lessons_learned/smart_ptrs/classes.rest 2006-10-11 12:11:40 UTC (rev 646) +++ pyplusplus_dev/docs/bpl_lessons_learned/smart_ptrs/classes.rest 2006-10-11 12:50:41 UTC (rev 647) @@ -1,3 +0,0 @@ -.. code-block:: - :language: C++ - :source-file: ./classes.hpp Modified: pyplusplus_dev/docs/bpl_lessons_learned/smart_ptrs/smart_ptr.h =================================================================== --- pyplusplus_dev/docs/bpl_lessons_learned/smart_ptrs/smart_ptr.h 2006-10-11 12:11:40 UTC (rev 646) +++ pyplusplus_dev/docs/bpl_lessons_learned/smart_ptrs/smart_ptr.h 2006-10-11 12:50:41 UTC (rev 647) @@ -25,6 +25,7 @@ //Every custom smart pointer class should have copy constructor and //assignment operator. Probably you smart pointer class already has this //functionality. + smart_ptr_t(const smart_ptr_t& r) : m_managed(0), m_use_count(0) { Copied: pyplusplus_dev/docs/bpl_lessons_learned/smart_ptrs/smart_ptr.h.rest (from rev 646, pyplusplus_dev/docs/bpl_lessons_learned/smart_ptrs/smart_ptr.rest) =================================================================== --- pyplusplus_dev/docs/bpl_lessons_learned/smart_ptrs/smart_ptr.h.rest (rev 0) +++ pyplusplus_dev/docs/bpl_lessons_learned/smart_ptrs/smart_ptr.h.rest 2006-10-11 12:50:41 UTC (rev 647) @@ -0,0 +1,3 @@ +.. code-block:: + :language: C++ + :source-file: ./smart_ptr.h Deleted: pyplusplus_dev/docs/bpl_lessons_learned/smart_ptrs/smart_ptr.rest =================================================================== --- pyplusplus_dev/docs/bpl_lessons_learned/smart_ptrs/smart_ptr.rest 2006-10-11 12:11:40 UTC (rev 646) +++ pyplusplus_dev/docs/bpl_lessons_learned/smart_ptrs/smart_ptr.rest 2006-10-11 12:50:41 UTC (rev 647) @@ -1,3 +0,0 @@ -.. code-block:: - :language: C++ - :source-file: ./smart_ptr.h Copied: pyplusplus_dev/docs/bpl_lessons_learned/smart_ptrs/test.py.rest (from rev 646, pyplusplus_dev/docs/bpl_lessons_learned/smart_ptrs/test.rest) =================================================================== --- pyplusplus_dev/docs/bpl_lessons_learned/smart_ptrs/test.py.rest (rev 0) +++ pyplusplus_dev/docs/bpl_lessons_learned/smart_ptrs/test.py.rest 2006-10-11 12:50:41 UTC (rev 647) @@ -0,0 +1,3 @@ +.. code-block:: + :language: Python + :source-file: ./test.py Deleted: pyplusplus_dev/docs/bpl_lessons_learned/smart_ptrs/test.rest =================================================================== --- pyplusplus_dev/docs/bpl_lessons_learned/smart_ptrs/test.rest 2006-10-11 12:11:40 UTC (rev 646) +++ pyplusplus_dev/docs/bpl_lessons_learned/smart_ptrs/test.rest 2006-10-11 12:50:41 UTC (rev 647) @@ -1,3 +0,0 @@ -.. code-block:: - :language: Python - :source-file: ./test.py Added: pyplusplus_dev/docs/bpl_lessons_learned/smart_ptrs/www_configuration.py =================================================================== --- pyplusplus_dev/docs/bpl_lessons_learned/smart_ptrs/www_configuration.py (rev 0) +++ pyplusplus_dev/docs/bpl_lessons_learned/smart_ptrs/www_configuration.py 2006-10-11 12:50:41 UTC (rev 647) @@ -0,0 +1,3 @@ +name = 'Custom smart pointer' +files_to_skip = ['definition.rest'] +names = {} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2006-10-11 12:12:00
|
Revision: 646 http://svn.sourceforge.net/pygccxml/?rev=646&view=rev Author: roman_yakovenko Date: 2006-10-11 05:11:40 -0700 (Wed, 11 Oct 2006) Log Message: ----------- exposing source code of smart_ptr to web Modified Paths: -------------- pyplusplus_dev/docs/bpl_lessons_learned/lessons_learned.rest Added Paths: ----------- pyplusplus_dev/docs/bpl_lessons_learned/smart_ptrs/bindings.rest pyplusplus_dev/docs/bpl_lessons_learned/smart_ptrs/classes.rest pyplusplus_dev/docs/bpl_lessons_learned/smart_ptrs/definition.rest pyplusplus_dev/docs/bpl_lessons_learned/smart_ptrs/sconstruct.rest pyplusplus_dev/docs/bpl_lessons_learned/smart_ptrs/smart_ptr.rest pyplusplus_dev/docs/bpl_lessons_learned/smart_ptrs/smart_ptrs.rest pyplusplus_dev/docs/bpl_lessons_learned/smart_ptrs/test.rest Modified: pyplusplus_dev/docs/bpl_lessons_learned/lessons_learned.rest =================================================================== --- pyplusplus_dev/docs/bpl_lessons_learned/lessons_learned.rest 2006-10-11 11:45:34 UTC (rev 645) +++ pyplusplus_dev/docs/bpl_lessons_learned/lessons_learned.rest 2006-10-11 12:11:40 UTC (rev 646) @@ -16,11 +16,8 @@ `Custom smart pointer class`_ - There are projects, which use custom smart pointer(s). For majority of the - projects, it is not an option to switch to ``boost::shared_ptr``. The - solution contains source code and comprehensive unit test for the problem. + .. include:: ./smart_ptrs/definition.rest - .. _`Custom smart pointer class` : ./smart_ptrs/smart_ptrs.html Added: pyplusplus_dev/docs/bpl_lessons_learned/smart_ptrs/bindings.rest =================================================================== --- pyplusplus_dev/docs/bpl_lessons_learned/smart_ptrs/bindings.rest (rev 0) +++ pyplusplus_dev/docs/bpl_lessons_learned/smart_ptrs/bindings.rest 2006-10-11 12:11:40 UTC (rev 646) @@ -0,0 +1,3 @@ +.. code-block:: + :language: C++ + :source-file: ./bindings.cpp Added: pyplusplus_dev/docs/bpl_lessons_learned/smart_ptrs/classes.rest =================================================================== --- pyplusplus_dev/docs/bpl_lessons_learned/smart_ptrs/classes.rest (rev 0) +++ pyplusplus_dev/docs/bpl_lessons_learned/smart_ptrs/classes.rest 2006-10-11 12:11:40 UTC (rev 646) @@ -0,0 +1,3 @@ +.. code-block:: + :language: C++ + :source-file: ./classes.hpp Added: pyplusplus_dev/docs/bpl_lessons_learned/smart_ptrs/definition.rest =================================================================== --- pyplusplus_dev/docs/bpl_lessons_learned/smart_ptrs/definition.rest (rev 0) +++ pyplusplus_dev/docs/bpl_lessons_learned/smart_ptrs/definition.rest 2006-10-11 12:11:40 UTC (rev 646) @@ -0,0 +1,3 @@ +There are projects, which use custom smart pointer(s). For majority of the +projects, it is not an option to switch to ``boost::shared_ptr``. The +solution contains source code and comprehensive unit test for the problem. Added: pyplusplus_dev/docs/bpl_lessons_learned/smart_ptrs/sconstruct.rest =================================================================== --- pyplusplus_dev/docs/bpl_lessons_learned/smart_ptrs/sconstruct.rest (rev 0) +++ pyplusplus_dev/docs/bpl_lessons_learned/smart_ptrs/sconstruct.rest 2006-10-11 12:11:40 UTC (rev 646) @@ -0,0 +1,3 @@ +.. code-block:: + :language: Python + :source-file: ./sconstruct Added: pyplusplus_dev/docs/bpl_lessons_learned/smart_ptrs/smart_ptr.rest =================================================================== --- pyplusplus_dev/docs/bpl_lessons_learned/smart_ptrs/smart_ptr.rest (rev 0) +++ pyplusplus_dev/docs/bpl_lessons_learned/smart_ptrs/smart_ptr.rest 2006-10-11 12:11:40 UTC (rev 646) @@ -0,0 +1,3 @@ +.. code-block:: + :language: C++ + :source-file: ./smart_ptr.h Added: pyplusplus_dev/docs/bpl_lessons_learned/smart_ptrs/smart_ptrs.rest =================================================================== --- pyplusplus_dev/docs/bpl_lessons_learned/smart_ptrs/smart_ptrs.rest (rev 0) +++ pyplusplus_dev/docs/bpl_lessons_learned/smart_ptrs/smart_ptrs.rest 2006-10-11 12:11:40 UTC (rev 646) @@ -0,0 +1,32 @@ +=================================== +How to expose custom smart pointer? +=================================== + +.. contents:: Table of contents + +------------ +Introduction +------------ + +.. include:: ./definition.rest + + +-------- +Download +-------- + +https://sourceforge.net/project/showfiles.php?group_id=118209 + + +.. _`Py++` : ./../pyplusplus.html +.. _`pygccxml` : http://www.language-binding.net/pygccxml/pygccxml.html +.. _`SourceForge`: http://sourceforge.net/index.php + +.. + Local Variables: + mode: indented-text + indent-tabs-mode: nil + sentence-end-double-space: t + fill-column: 70 + End: + Added: pyplusplus_dev/docs/bpl_lessons_learned/smart_ptrs/test.rest =================================================================== --- pyplusplus_dev/docs/bpl_lessons_learned/smart_ptrs/test.rest (rev 0) +++ pyplusplus_dev/docs/bpl_lessons_learned/smart_ptrs/test.rest 2006-10-11 12:11:40 UTC (rev 646) @@ -0,0 +1,3 @@ +.. code-block:: + :language: Python + :source-file: ./test.py This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2006-10-11 11:45:43
|
Revision: 645 http://svn.sourceforge.net/pygccxml/?rev=645&view=rev Author: roman_yakovenko Date: 2006-10-11 04:45:34 -0700 (Wed, 11 Oct 2006) Log Message: ----------- small fix in documentation formatting Modified Paths: -------------- pygccxml_dev/docs/query_interface.rest Modified: pygccxml_dev/docs/query_interface.rest =================================================================== --- pygccxml_dev/docs/query_interface.rest 2006-10-11 10:43:41 UTC (rev 644) +++ pygccxml_dev/docs/query_interface.rest 2006-10-11 11:45:34 UTC (rev 645) @@ -15,6 +15,7 @@ I don't care about first argument type, but I do want second argument type to be a reference to an integer. More over, I want those functions names to end with "impl" string and they should be protected or private. + .. code-block:: Python #global_ns is the reference to an instance of namespace_t object, that @@ -26,6 +27,7 @@ The example is complex, but still readable. In many cases you will find your self looking for one or many declarations using one or two properties of that declaration(s). For example: + .. code-block:: Python global_ns.namespaces( 'details' ) @@ -53,6 +55,7 @@ I will explain the usage of ``member_function`` and ``member_functions`` methods. The usage of other methods is very similar to them. Here is definition of those methods: + .. code-block:: Python def member_function( self, @@ -63,8 +66,8 @@ header_dir=None, header_file=None, recursive=None ) - - + + def member_functions( self, name=None, function=None, @@ -93,10 +96,11 @@ build custom query. This object will be called with one argument - declaration, and it should return ``True`` or ``False``. - .. code-block:: Python + .. code-block:: Python impls = my_class.member_functions( lambda decl: decl.name.endswith( 'impl' ) ) + ``impls`` will contain all member functions, that their name ends with "impl". * ``return_type`` @@ -121,9 +125,9 @@ to skip some argument type from within comparison, you put ``None``, into relevant position within the list. - .. code-block:: Python + .. code-block:: Python - mem_funcs = my_class.member_functions( arg_types=[ None, 'int'] ) + mem_funcs = my_class.member_functions( arg_types=[ None, 'int'] ) ``mem_funcs`` will contain all member functions, that have two arguments and type of second argument is ``int``. @@ -218,6 +222,7 @@ class you don't have to write loops. If will do it for you. Also if you insist to write loops, ``mdecl_wrapper_t`` class implements ``__len__``, ``__getitem__`` and ``__iter__`` methods. So you can write next code: + .. code-block:: Python for clone in global_ns.member_functions( 'clone' ): @@ -238,7 +243,7 @@ Data structures ~~~~~~~~~~~~~~~ -Here is a short explanation of what data structures is initialized. +Here is a short explanation of what data structures is initialized. * ``scopedef_t._type2decls``, ``scopedef_t._type2decls_nr`` This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2006-10-11 10:44:22
|
Revision: 644 http://svn.sourceforge.net/pygccxml/?rev=644&view=rev Author: roman_yakovenko Date: 2006-10-11 03:43:41 -0700 (Wed, 11 Oct 2006) Log Message: ----------- switching from :: ( rest preformated block ) to .. code-block:: Modified Paths: -------------- pygccxml_dev/docs/design.rest pygccxml_dev/docs/history/history.rest pygccxml_dev/docs/pygccxml.rest pygccxml_dev/docs/query_interface.rest pyplusplus_dev/docs/comparisons/pyste.rest pyplusplus_dev/docs/documentation/architecture.rest pyplusplus_dev/docs/documentation/best_practices.rest pyplusplus_dev/docs/documentation/containers.rest pyplusplus_dev/docs/documentation/doc_string.rest pyplusplus_dev/docs/documentation/feedback.rest pyplusplus_dev/docs/documentation/hints.rest pyplusplus_dev/docs/documentation/how_to.rest pyplusplus_dev/docs/documentation/inserting_code.rest pyplusplus_dev/docs/documentation/properties.rest pyplusplus_dev/docs/documentation/tutorials/module_builder/module_builder.rest pyplusplus_dev/docs/examples/boost/boost.rest pyplusplus_dev/docs/history/history.rest pyplusplus_dev/docs/peps/dsl_challenge.rest pyplusplus_dev/docs/peps/function_transformation.rest pyplusplus_dev/docs/peps/peps_index.rest pyplusplus_dev/docs/pyplusplus.rest Modified: pygccxml_dev/docs/design.rest =================================================================== --- pygccxml_dev/docs/design.rest 2006-10-10 22:06:12 UTC (rev 643) +++ pygccxml_dev/docs/design.rest 2006-10-11 10:43:41 UTC (rev 644) @@ -255,12 +255,15 @@ -------- Well, `GCC-XML`_ has few bugs, which could not be fixed from it. For example -:: +.. code-block:: C++ + namespace ns1{ namespace ns2{ enum fruit{ apple, orange }; } } +.. code-block:: C++ + void fix_enum( ns1::ns2::fruit arg=ns1::ns2::apple ); `GCC-XML`_ will report the default value of ``arg`` as ``apple``. Obviously Modified: pygccxml_dev/docs/history/history.rest =================================================================== --- pygccxml_dev/docs/history/history.rest 2006-10-10 22:06:12 UTC (rev 643) +++ pygccxml_dev/docs/history/history.rest 2006-10-11 10:43:41 UTC (rev 644) @@ -122,8 +122,9 @@ This has been done in order to provide stable order of enumeration values. 4. Now you can pass operator symbol, as a name to query functions: - :: + .. code-block:: Python + cls = global_namespace.class_( 'my_class' ) op = cls.operator( '<' ) #instead of @@ -154,8 +155,9 @@ of the same name in the decl interface from ``declarations.scopedef_t`` class. So for example: - :: + .. code-block:: Python + classes = ns.decls("class") classes.decls("method") Modified: pygccxml_dev/docs/pygccxml.rest =================================================================== --- pygccxml_dev/docs/pygccxml.rest 2006-10-10 22:06:12 UTC (rev 643) +++ pygccxml_dev/docs/pygccxml.rest 2006-10-11 10:43:41 UTC (rev 644) @@ -89,8 +89,9 @@ try to give small example, that will prove my point. If you want to know more about provided API please read `query interface`__ document or API documentation. Examples: -:: +.. code-block:: Python + #global_ns is the reference to declarations that describes C++ namespace. #In our case, instance of that declarations describes global ( :: ) namespace. global_ns.free_functions( "do_smth", return_type='void', arg_types=[None,'int'] ) @@ -98,14 +99,15 @@ Small explanation. Assume that ``None`` means "any type". Now the code is pretty readable: + :: - select all free functions - where - name equal to "do_smth" - return type is void - function has two arguments - second argument type is int + select all free functions from the project + where + name equal to "do_smth" + return type is void + function has two arguments + second argument type is int .. __: ./query_interface.html Modified: pygccxml_dev/docs/query_interface.rest =================================================================== --- pygccxml_dev/docs/query_interface.rest 2006-10-10 22:06:12 UTC (rev 643) +++ pygccxml_dev/docs/query_interface.rest 2006-10-11 10:43:41 UTC (rev 644) @@ -15,7 +15,7 @@ I don't care about first argument type, but I do want second argument type to be a reference to an integer. More over, I want those functions names to end with "impl" string and they should be protected or private. -:: +.. code-block:: Python #global_ns is the reference to an instance of namespace_t object, that #represents global namespace @@ -26,7 +26,7 @@ The example is complex, but still readable. In many cases you will find your self looking for one or many declarations using one or two properties of that declaration(s). For example: -:: +.. code-block:: Python global_ns.namespaces( 'details' ) @@ -53,7 +53,7 @@ I will explain the usage of ``member_function`` and ``member_functions`` methods. The usage of other methods is very similar to them. Here is definition of those methods: -:: +.. code-block:: Python def member_function( self, name=None, @@ -81,8 +81,9 @@ * ``name`` Python string, that contains member function name or full name. - :: + .. code-block:: Python + do_smth = my_class.member_function( 'do_smth' ) do_smth = my_class.member_function( 'my_namespace::my_class::do_smth' ) @@ -91,8 +92,9 @@ Python callable object. You would use this functionality, if you need to build custom query. This object will be called with one argument - declaration, and it should return ``True`` or ``False``. - :: + .. code-block:: Python + impls = my_class.member_functions( lambda decl: decl.name.endswith( 'impl' ) ) ``impls`` will contain all member functions, that their name ends with "impl". @@ -101,8 +103,9 @@ Function return type. This argument can be Python string or an object that describes C++ type. - :: + .. code-block:: Python + mem_funcs = my_class.member_functions( return_type='int' ) i = declarations.int_t() @@ -117,8 +120,9 @@ type. Size of list says how many arguments function should have. If you want to skip some argument type from within comparison, you put ``None``, into relevant position within the list. - :: + .. code-block:: Python + mem_funcs = my_class.member_functions( arg_types=[ None, 'int'] ) ``mem_funcs`` will contain all member functions, that have two arguments @@ -178,13 +182,16 @@ objects at once. I will give an example from another project - `Py++`_. In order to help `Boost.Python`_ to manage objects life time, all functions should have `call policies`_. For example: -:: +.. code-block:: C++ + struct A{ A* clone() const { return new A(); } ... }; +.. code-block:: C++ + struct B{ B* clone() const { return new B(); } ... @@ -193,8 +200,9 @@ `Call policies`_ of the member function ``clone`` is ``return_value_policy<manage_new_object>()``. Next code applies `call policies`_ on all ``clone`` member functions within the project. -:: +.. code-block:: Python + #global_ns - instance of namespace_t class, that contains reference to global namespace clone = global_ns.member_functions( 'clone' ) clone.call_policies = return_value_policy( manage_new_object ) @@ -210,7 +218,7 @@ class you don't have to write loops. If will do it for you. Also if you insist to write loops, ``mdecl_wrapper_t`` class implements ``__len__``, ``__getitem__`` and ``__iter__`` methods. So you can write next code: -:: +.. code-block:: Python for clone in global_ns.member_functions( 'clone' ): print clone.parent.name Modified: pyplusplus_dev/docs/comparisons/pyste.rest =================================================================== --- pyplusplus_dev/docs/comparisons/pyste.rest 2006-10-10 22:06:12 UTC (rev 643) +++ pyplusplus_dev/docs/comparisons/pyste.rest 2006-10-11 10:43:41 UTC (rev 644) @@ -185,12 +185,17 @@ * identify "call policies" algorithm * code creator that generates body of "overridden" virtual functions: - :: + .. code-block:: C++ + struct expensive_to_copy{...}; + .. code-block:: C++ + void do_smth( expensive_to_copy* x, const expensive_to_copy& y ){...} + .. code-block:: C++ + void do_smth(expensive_to_copy* x, const expensive_to_copy& y){ //Pyste generates next code @@ -326,16 +331,18 @@ those directories into account. * To define namespace alias. - :: + .. code-block:: C++ + namespace dt = boost::date_time; All code, which is generated after this statement, will use ``dt`` instead of ``boost::date_time``. This allows `Py++`_ to create user-friendly code. * Classes and functions support 2 modes of code generation. Example: - :: + .. code-block:: C++ + struct world{ void set(std::string msg) { this->msg = msg; } std::string greet() { return msg; } @@ -343,8 +350,9 @@ }; First mode: - :: + .. code-block:: C++ + class_<world>("world") .def("greet", &world::greet) .def("set", &world::set) @@ -352,8 +360,9 @@ Second mode: - :: + .. code-block:: C++ + if( true ){ typedef class_<world> world_exposer_t; world_exposer_t world_exposer; Modified: pyplusplus_dev/docs/documentation/architecture.rest =================================================================== --- pyplusplus_dev/docs/documentation/architecture.rest 2006-10-10 22:06:12 UTC (rev 643) +++ pyplusplus_dev/docs/documentation/architecture.rest 2006-10-11 10:43:41 UTC (rev 644) @@ -85,16 +85,16 @@ Before I explain how these services are integrated, take a look on next source code: -:: +.. code-block:: Python mb = module_builder_t( ... ) -:: +.. code-block:: Python details = mb.namespace( 'details' ) details.exclude() -:: +.. code-block:: Python my_class = mb.class_( 'my_class' ) my_class.rename("MyClass") @@ -229,7 +229,7 @@ Here is "cut & paste" of the relevant code from the source file: - :: + .. code-block:: Python def _create_impl(self): result = [] Modified: pyplusplus_dev/docs/documentation/best_practices.rest =================================================================== --- pyplusplus_dev/docs/documentation/best_practices.rest 2006-10-10 22:06:12 UTC (rev 643) +++ pyplusplus_dev/docs/documentation/best_practices.rest 2006-10-11 10:43:41 UTC (rev 644) @@ -41,7 +41,7 @@ ``module_builder_t.__init__`` methods takes reference to an instance of cache class or ``None``: - :: + .. code-block:: Python from module_builder import * mb = module_builder_t( ..., cache=file_cache_t( path to project cache file ), ... ) @@ -60,13 +60,12 @@ implemented an initial version of the functionality. After small discussion, we agreed on next interface: - :: + .. code-block:: Python class module_builder_t( ... ): ... def split_module( self, directory_path, huge_classes=None, precompiled_header=None ): ... - ... ``precompiled_header`` argument could be ``None`` or string, that contains name of precompiled header file, which will be created in the directory. @@ -78,7 +77,7 @@ `this error`_. `Py++`_ will automatically split generated code for the huge classes to few files: - :: + .. code-block:: Python mb = module_builder_t( ... ) ... Modified: pyplusplus_dev/docs/documentation/containers.rest =================================================================== --- pyplusplus_dev/docs/documentation/containers.rest 2006-10-10 22:06:12 UTC (rev 643) +++ pyplusplus_dev/docs/documentation/containers.rest 2006-10-11 10:43:41 UTC (rev 644) @@ -77,8 +77,9 @@ By default, `Py++`_ works with built-in indexing suite. If you want to use next version of indexing suite, you should tell this to the ``module_builder_t.__init__`` method: -:: +.. code-block:: Python + mb = module_builder_t( ..., indexing_suite_version=2 ) Every declared class has ``indexing_suite`` property. If the class is an @@ -121,8 +122,9 @@ In this case there is no single place, where you can configure exported container functionality. Please take a look on next C++ code: -:: +.. code-block:: C++ + struct item{ ... private: Modified: pyplusplus_dev/docs/documentation/doc_string.rest =================================================================== --- pyplusplus_dev/docs/documentation/doc_string.rest 2006-10-10 22:06:12 UTC (rev 643) +++ pyplusplus_dev/docs/documentation/doc_string.rest 2006-10-11 10:43:41 UTC (rev 644) @@ -15,7 +15,7 @@ API description --------------- -:: +.. code-block:: Python mb = module_builder_t( ... ) my_class = mb.class_( 'my_class' ) @@ -37,7 +37,7 @@ ``doc_extractor`` is a callable object, which takes one argument - reference to declaration. -:: +.. code-block:: Python def doc_extractor( decl ): ... Modified: pyplusplus_dev/docs/documentation/feedback.rest =================================================================== --- pyplusplus_dev/docs/documentation/feedback.rest 2006-10-10 22:06:12 UTC (rev 643) +++ pyplusplus_dev/docs/documentation/feedback.rest 2006-10-11 10:43:41 UTC (rev 644) @@ -24,27 +24,27 @@ them and in some cases provide hints about how to resolve the problem. Few examples: * - :: + .. code-block:: C++ - struct Y{ ... }; - + struct Y{ ... }; + + .. code-block:: C++ + struct X{ ... virtual Y& do_smth(); - ... }; Member function ``do_smth`` can not be overridden in Python because... [FILL IN HERE]. * - :: + .. code-block:: C++ struct window{ ... void get_size( int& heght, int& widht ) const; - ... }; - + Member function ``get_size`` can be exposed to Python, but it will not be callable because [FILL IN HERE]. * In order to expose free/member function that takes more than 10 arguments user @@ -80,12 +80,12 @@ 1. If you simply want to change the logging message level: - :: + .. code-block:: Python import logging from pyplusplus import module_builder - :: + .. code-block:: Python module_builder.set_logger_level( logging.DEBUG ) @@ -101,20 +101,15 @@ Both packages define a ``loggers`` class. Those classes keep references to different loggers. The ``loggers`` classes look very similar to the next class: - :: + .. code-block:: Python import logging #standard Python package - - :: - + def _create_logger_( name ): logger = logging.getLogger(name) ... return logger - - - :: - + class loggers: file_writer = _create_logger_( 'pyplusplus.file_writer' ) declarations = _create_logger_( 'pyplusplus.declarations' ) Modified: pyplusplus_dev/docs/documentation/hints.rest =================================================================== --- pyplusplus_dev/docs/documentation/hints.rest 2006-10-10 22:06:12 UTC (rev 643) +++ pyplusplus_dev/docs/documentation/hints.rest 2006-10-11 10:43:41 UTC (rev 644) @@ -12,23 +12,18 @@ template, than `Py++`_ will use it as a `Python`_ class name. For example: -:: - #include <vector> +.. code-block:: C++ -:: - + #include <vector> typedef std::vector< int > numbers; - -:: - numbers generate_n(){ ... } `Py++`_ will use "numbers" as Python class name: -:: +.. code-block:: C++ using boost::python; class_< std::vector< int > >( "numbers" ) Modified: pyplusplus_dev/docs/documentation/how_to.rest =================================================================== --- pyplusplus_dev/docs/documentation/how_to.rest 2006-10-10 22:06:12 UTC (rev 643) +++ pyplusplus_dev/docs/documentation/how_to.rest 2006-10-11 10:43:41 UTC (rev 644) @@ -7,17 +7,17 @@ ---------------------------------------- How to add custom exception translation? ---------------------------------------- -:: +.. code-block:: C++ + struct my_exception{ ... const std::string& error() const; - ... } First of all lets define ``translate`` function: -:: +.. code-block:: Python translate_code = \ """ @@ -26,14 +26,14 @@ } """ -:: +.. code-block:: Python mb.add_declaration_code( translate_code ) Now we should register it: -:: +.. code-block:: Python registration_code = "boost::python::register_exception_translator<my_exception>(&translate);" mb.add_registration_code( registration_code ) @@ -43,7 +43,7 @@ `Py++`_ allows you to define a query that will return you all exception classes: -:: +.. code-block:: Python mb = module_builder_t( ... ) exception_classes = mb.decls( lambda decl: decl.name.endswith( 'exception' ) ) @@ -56,25 +56,25 @@ ------------------------------------------------------- How to expose function, which has hand-written wrapper? ------------------------------------------------------- -:: +.. code-block:: C++ struct window_t{ ... void get_size( int& height, int& widht ) const; - ... }; You can not expose ``get_size`` function as is - ``int`` is immutable type in Python. So, we need to create a wrapper to the function: -:: +.. code-block:: C++ + boost::python::tuple get_size_wrapper( const window_t& win ){ int height(0), width( 0 ); win.get_size( height, widht ); return boost::python::make_tuple( height, width ); } -:: +.. code-block:: C++ class_<window_t>( ... ) .def( "get_size", &get_size_wrapper ) @@ -84,9 +84,8 @@ Now, after you know how this problem is solved. I will show how this solution could be integrated with `Py++`_. +.. code-block:: Python -:: - wrapper_code = \ """ static boost::python::tuple get_size( const window_t& win ){ @@ -96,11 +95,11 @@ } """ -:: +.. code-block:: Python registration_code = 'def( "get_size", &%s::get_size )' % window.wrapper_alias -:: +.. code-block:: Python mb = module_builder_t( ... ) window = mb.class_( "window_t" ) @@ -132,33 +131,21 @@ ------------------------------------------------------ Lets say you have next C++ function: -:: - //file point.h +.. code-block:: C++ -:: - + // file point.h namespace geometry{ - -:: - - template< class T> - struct point_t{ - T x, y; - }; - -:: - - template <class T> - double distance( const point_t<T>& point ){ - return sqrt( point.x * point.x + point.y*point.y ); - } - -:: - + template< class T> + struct point_t{ + T x, y; + }; + template <class T> + double distance( const point_t<T>& point ){ + return sqrt( point.x * point.x + point.y*point.y ); + } } //namespace geometry - You should understand, that you can not export template itself, but only its instantiations. The solution is built using next facts: @@ -174,11 +161,11 @@ Open your favorite editor and create a header file with the content: -:: +.. code-block:: C++ #include "point.h" -:: +.. code-block:: C++ namespace py_details{ inline void instantiate(){ @@ -194,7 +181,7 @@ ``module_builder_t.__init__`` method and excludes the ``py_details`` namespace declarations from being exported: -:: +.. code-block:: Python mb = module_builder_t( [..., just created file ], ... ) mb.namespace( 'py_details' ).exclude() @@ -207,20 +194,20 @@ The solution is to build your own code generator, which will generate code similar to the one, in the previous paragraph. -:: +.. code-block:: Python from module_builder import module_builder_t, create_text_fc -:: +.. code-block:: Python def generate_instantiations_string( ... ): ... -:: +.. code-block:: Python code = generate_instantiations_string( ... ) -:: +.. code-block:: Python mb = module_builder_t( [ ..., create_text_fc( code ) ], ... ) mb.namespace( 'py_details' ).exclude() @@ -246,7 +233,7 @@ --------------------------------------------------- How to deal with template on return type functions? --------------------------------------------------- -:: +.. code-block:: C++ struct environment_t{ ... @@ -269,8 +256,9 @@ Otherwise, you will discover the errors while testing the bindings. Generated code: -:: +.. code-block:: C++ + bp::class_< environment_t >( "environment_t" ) ... .def( "get_value" @@ -279,8 +267,9 @@ , (::std::string ( ::environment_t::* )( ::std::string const & ) )( &::environment_t::get_value ) ); The correct code: -:: +.. code-block:: C++ + bp::class_< environment_t >( "environment_t" ) .def( "get_value" , (int ( ::environment_t::* )( ::std::string const & ) )( &::environment_t::get_value< int > ) ) @@ -290,8 +279,9 @@ //------------------------------------------------------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^ The perfect one: -:: +.. code-block:: C++ + bp::class_< environment_t >( "environment_t" ) ... .def( "get_value", &::environment_t::get_value< int > ) @@ -299,7 +289,7 @@ Solution -------- -:: +.. code-block:: Python mb = module_builder_t( ..., optimize_queries=False, ... ) environment = mb.class_( "environment_t" ) Modified: pyplusplus_dev/docs/documentation/inserting_code.rest =================================================================== --- pyplusplus_dev/docs/documentation/inserting_code.rest 2006-10-10 22:06:12 UTC (rev 643) +++ pyplusplus_dev/docs/documentation/inserting_code.rest 2006-10-11 10:43:41 UTC (rev 644) @@ -18,7 +18,7 @@ Almost every ``Boost.Python`` module has next structure: -:: +.. code-block:: C++ //declarations code ... @@ -45,7 +45,7 @@ Example ------- -:: +.. code-block:: Python mb = module_builder_t( ... ) mb.build_code_creator( ... ) @@ -60,7 +60,7 @@ ``class_t`` declaration defines few methods, which add user code to the generated one. Lets take a look on next use case: -:: +.. code-block:: C++ struct window_t{ ... @@ -74,7 +74,7 @@ In the near future `Py++`_ will eliminate the need of creating hand written wrapper for this use case. -:: +.. code-block:: C++ boost::python::tuple get_window_size( const window_t& win ){ int h(0), w(0); @@ -84,7 +84,7 @@ Now you have to register it: -:: +.. code-block:: C++ using boost::python; class_< window_t >( ... ) @@ -112,15 +112,17 @@ What is ``works_on_instance`` argument for? In our case, we added new method to the class. The first argument of the call will be ``self``. - :: + .. code-block:: Python + #From Python user can call this method like this: win = window_t( ) height, width = win.get_size() If you will pass ``works_on_instance=False`` next code will be generated: - :: + .. code-block:: C++ + { class_< window_t > window_exporter( "window_t" ); scope window_scope( window_exporter ); @@ -129,16 +131,17 @@ } And in this case, user will be forced to pass reference to ``window_t`` object: - - :: + .. code-block:: C++ + win = window_t() height, width = window_t.get_size( win ) Example ------- -:: +.. code-block:: Python + mb = module_builder_t( ... ) window = mb.class_( 'window_t' ) window.add_declaration_code( get_window_size definition ) @@ -174,7 +177,7 @@ Solution -------- -:: +.. code-block:: Python def inject_code( cls ): constructors = cls.constructors() @@ -184,9 +187,9 @@ cls.add_wrapper_code( destructor declaration and definition code ) cls.add_wrapper_code( the new class variable definition code ) - -:: +.. code-block:: Python + mb = module_builder_t( ... ) for cls in mb.classes( relevant classes only ): inject_code( cls ) Modified: pyplusplus_dev/docs/documentation/properties.rest =================================================================== --- pyplusplus_dev/docs/documentation/properties.rest 2006-10-10 22:06:12 UTC (rev 643) +++ pyplusplus_dev/docs/documentation/properties.rest 2006-10-11 10:43:41 UTC (rev 644) @@ -18,8 +18,9 @@ ------------- Usage example ------------- -:: +.. code-block:: C++ + struct number{ ... float value() const; @@ -29,7 +30,7 @@ float m_value; } -:: +.. code-block:: Python mb = module_builder_t( ... ) number = mb.class_( 'number' ) @@ -41,8 +42,9 @@ This is rather the hard way to add properties to the class. `Py++`_ comes with built-in algorithm, which automaticly recognizes properties and adds them to the class: -:: +.. code-block:: Python + mb = module_builder_t( ... ) number = mb.class_( 'number' ) number.add_properties( exclude_accessors=False ) #accessors will be exposed @@ -61,10 +63,12 @@ Consider next use case: -:: +.. code-block:: C++ struct nested{ ... }; +.. code-block:: C++ + struct data{ ... const nested& get_nested() const @@ -78,7 +82,7 @@ `call policies`_. Same precondition holds for exposing member function as property: -:: +.. code-block:: Python mb = module_builder_t( ... ) get_nested = mb.member_function( 'get_nested' ) Modified: pyplusplus_dev/docs/documentation/tutorials/module_builder/module_builder.rest =================================================================== --- pyplusplus_dev/docs/documentation/tutorials/module_builder/module_builder.rest 2006-10-10 22:06:12 UTC (rev 643) +++ pyplusplus_dev/docs/documentation/tutorials/module_builder/module_builder.rest 2006-10-11 10:43:41 UTC (rev 644) @@ -118,7 +118,7 @@ open source projects it to have license text within every source file. You can do it with one line of code only: -:: +.. code-block:: Python mb.code_creator.license = your license text Modified: pyplusplus_dev/docs/examples/boost/boost.rest =================================================================== --- pyplusplus_dev/docs/examples/boost/boost.rest 2006-10-10 22:06:12 UTC (rev 643) +++ pyplusplus_dev/docs/examples/boost/boost.rest 2006-10-11 10:43:41 UTC (rev 644) @@ -85,19 +85,15 @@ * Python code: - :: + .. code-block:: Python import time from pyboost import boost_random - - :: - + rng = boost_random.mt19937( int( time.time() ) ) #setting initial seed six = boost_random.uniform_int(1,6) die = boost_random.variate_generator( rng, six ) - - :: - + print die() date_time @@ -107,7 +103,7 @@ * Python code: - :: + .. code-block:: Python import os from pyboost import date_time @@ -115,75 +111,53 @@ from pyboost.date_time import posix_time from pyboost.date_time import local_time from pyboost.date_time import to_simple_string - - :: - - # + #Date programming - # + weekstart = gregorian.date(2002, date_time.Feb,1) print 'weekstart: ', to_simple_string( weekstart ) - - :: - + weekend = weekstart + gregorian.weeks(1) print 'weekend: ', to_simple_string( weekend ) - - :: - + today = gregorian.day_clock.local_day() d2 = weekstart + gregorian.days(5) if d2 >= today: #comparison operator pass - - :: - + thisWeek = gregorian.date_period(today,d2) if thisWeek.contains(today): pass - - :: - + #date generator functions + d5 = gregorian.next_weekday(today, date_time.Sunday); #calculate Sunday following d4 print 'd5: ', to_simple_string( d5 ) - - :: - + #US labor day is first Monday in Sept first = gregorian.nth_day_of_the_week_in_month.first labor_day = gregorian.nth_day_of_the_week_in_month(first, date_time.Monday, date_time.Sep) #calculate a specific date for 2004 from functor print 'labor day 2004: ', to_simple_string( labor_day.get_date(2004) ) - - :: - - # + #Time programming: - # + d = gregorian.date(2002,date_time.Feb,1)#an arbitrary date t1 = posix_time.ptime(d, posix_time.hours(5) + posix_time.millisec(100)); #date + time of day offset print 't1: ', to_simple_string( t1 ) - - :: - + t2 = t1 - posix_time.minutes(4) + posix_time.seconds(2) print 't2: ', to_simple_string( t2 ) - - :: - + now = posix_time.second_clock.local_time(); #use the clock print 'now: ', to_simple_string( now ) today = now.date() #Get the date part out of the time print 'today: ', to_simple_string( today ) tomorrow = today + gregorian.date_duration(1) print 'tomorrow: ', to_simple_string( tomorrow ) - - :: - - # + #Local time programming: - # + #setup some timezones for creating and adjusting times #first time zone uses the time zone file for regional timezone definitions tz_db = local_time.time_zone_database() @@ -191,9 +165,7 @@ nyc_tz = tz_db.time_zone_from_region("America/New_York") #This timezone uses a posix time zone string definition to create a time zone phx_tz = local_time.posix_time_zone("MST-07:00:00") - - :: - + #local departure time in phoenix is 11 pm on April 2 2005 #Note that New York changes to daylight savings on Apr 3 at 2 am) phx_departure = local_time.local_date_time( @@ -201,16 +173,13 @@ , posix_time.hours(23) , phx_tz , local_time.local_date_time.NOT_DATE_TIME_ON_ERROR) - - :: - + flight_length = posix_time.hours(4) + posix_time.minutes(30) phx_arrival = phx_departure + flight_length #convert the phx time to a nyz time nyc_arrival = phx_arrival.local_time_in(nyc_tz, posix_time.time_duration() ) print "New York arrival: ", nyc_arrival.to_string() #//2005-Apr-03 06:30:00 EDT - rational ~~~~~~~~ @@ -218,33 +187,26 @@ * Python code: - :: + .. code-block:: Python import unittest from pyboost import rational - - :: - + half = rational.rational( 1, 2 ) one = rational.rational( 1 ) two = rational.rational( 2 ) - - :: - + #Some basic checks assert half.numerator() == 1 assert half.denominator() == 2 assert float(half) == 0.5 - - :: - + #Arithmetic assert half + half == one == 1 assert one - half == half assert two * half == one == 1 assert one / half == two == 2 - crc ~~~ @@ -252,20 +214,18 @@ * Python code: - :: + .. code-block:: Python import os import sys from pyboost import crc - - :: - + if __name__ == '__main__': if sys.argv: files = sys.argv else: files = [ sys.executable ] - + try: result = crc.crc_32_type() for file_name in files: Modified: pyplusplus_dev/docs/history/history.rest =================================================================== --- pyplusplus_dev/docs/history/history.rest 2006-10-10 22:06:12 UTC (rev 643) +++ pyplusplus_dev/docs/history/history.rest 2006-10-11 10:43:41 UTC (rev 644) @@ -198,16 +198,17 @@ a default argument. 8. `Py++`_ now generates correct code for hierarchy of abstract classes: - :: + .. code-block:: C++ + struct abstract1{ virtual void do_smth() = 0; } - + struct abstract2 : public abstract1{ virtual void do_smth_else() = 0; } - + struct concrete : public abstract2{ virtual void do_smth(){}; virtual void do_smth_else(){}; Modified: pyplusplus_dev/docs/peps/dsl_challenge.rest =================================================================== --- pyplusplus_dev/docs/peps/dsl_challenge.rest 2006-10-10 22:06:12 UTC (rev 643) +++ pyplusplus_dev/docs/peps/dsl_challenge.rest 2006-10-11 10:43:41 UTC (rev 644) @@ -16,7 +16,7 @@ I will use next C++ code as an example: -:: +.. code-block:: C++ namespace geometry{ struct Point{ @@ -40,8 +40,9 @@ 3. to rename ``x`` and ``y`` to ``X`` and ``Y`` Today, in order to configure this class, the user has to write next code: -:: +.. code-block:: Python + mb = module_builder_t( ... ) Point = mb.class_( 'Point' ) Point.member_function( 'create_new' ).call_policies = ... @@ -54,8 +55,9 @@ If class ``Point`` is not unique, than user will have to write a little bit different code: -:: +.. code-block:: Python + Point = mb.global_ns.namespace('geometry').class( 'Point' ) The current approach is pretty readable and simple. The drawbacks of this approach @@ -68,8 +70,9 @@ --------------------------- Better user interface (BUI) --------------------------- -:: +.. code-block:: Python + mb = module_builder_t( ... ) Point = mb.module.geometry.Point Point.create_new.call_policies = ... @@ -102,27 +105,29 @@ BUI does not work for template instantiated classes and functions. If we change class ``Point`` to be template, the special syntax should be introduced: - :: + .. code-block:: C++ template < class Numeric > struct Point{ ... }; - :: +.. code-block:: Python PointTmpl = mb.module.template('Point') Point = PointTmpl( 'int' ) This is a trivial example, that is why it looks grate. Consider next class: - :: +. code-block:: C++ + template< class String, class Allocator > class regex{ ... } The code the user will need to write is: - :: + .. code-block:: Python + regex_tmpl = mb.module.geometry.template( 'regex' ) #white spaces and scope resolution( :: ) are important regex_std_string = regex_tmpl( @@ -131,11 +136,12 @@ Using current `Py++`_ interface the user can get reference to the class instantiation in one line of code: - :: - regex_std_string = mb.class_( - lambda decl: decl.name.startswith( 'regex' ) and 'wchar_t' not in decl.name ) +.. code-block:: Python + regex_std_string = mb.class_( + lambda decl: decl.name.startswith( 'regex' ) and 'wchar_t' not in decl.name ) + * overloaded functions resolution There are use cases, when overloaded functions should be treated differently. @@ -158,8 +164,9 @@ Using BUI the user is forced to write full declaration name, otherwise he faces next problem: -:: +.. code-block:: Python + Point = mb.module.Point Lets analyze what the ``Point`` value: @@ -173,7 +180,7 @@ There are a lot of use cases, when the user has to add some code to the class: - :: + .. code-block:: Python Point.add_registration_code( ... ) Modified: pyplusplus_dev/docs/peps/function_transformation.rest =================================================================== --- pyplusplus_dev/docs/peps/function_transformation.rest 2006-10-10 22:06:12 UTC (rev 643) +++ pyplusplus_dev/docs/peps/function_transformation.rest 2006-10-11 10:43:41 UTC (rev 644) @@ -46,8 +46,9 @@ ft = int get_last_error(); The definition of ``ft`` could look like: -:: +.. code-block:: C++ + int get_last_error_transformed(){ int error(0); get_last_error( error ); @@ -92,29 +93,37 @@ In an ideal world we would have 2 classes, one class - one responsibility. In `Py++`_ it means that we would have ``transformation_t`` class: -:: +.. code-block:: Python + class transformation_t( object ): def __init__( self ): pass +.. code-block:: Python + def check( self, function ): "checks whether the transformation could be applied on the function or not" raise NotImplementedError() +.. code-block:: Python + def signature_changes( self, function ): "returns a list of changes that should be done on function signature" raise NotImplementedError() The class logically belongs to the ``decl_wrappers`` package. The ``transformer_t`` is the second class, which logically belongs to ``code_creators`` package: -:: +.. code-block:: Python + class transformer_t( ast_visitor_t ): def __init__( self, function, transformation ): function is a reference to the declaration we want to apply transformation on transformation is an instance of "concrete" transformation +.. code-block:: Python + def apply( self, function_body_as_tree ): "integrates transformation code to function body" raise NotImplementedError() @@ -146,21 +155,28 @@ Small re-factoring is needed. I don't expect changes in the user code. Proposed class: -:: +.. code-block:: Python + class transformer_t( object ): "base class for all transformation classes" def __init__( self ): pass +.. code-block:: Python + def check( self, function ): "checks whether the transformation could be applied on the function or not" raise NotImplementedError() +.. code-block:: Python + def signature_changes( self, function ): "returns a list of changes that should be done on function signature" raise NotImplementedError() +.. code-block:: Python + def apply( self, sm ): #sm is an instance of the substitution manager "integrates transformation code into function transformation body" raise NotImplementedError() @@ -197,12 +213,15 @@ ------------------------------------- output_arg transformation example ------------------------------------- -:: +.. code-block:: Python + class output_arg_t( transformer_t ): def __init__( self, ordinal ): self.ordinal = ordinal +.. code-block:: Python + def check( self, decl ): if len( decl.arguments ) <= self.ordinal: return user message @@ -210,11 +229,15 @@ if not reference to immutable type: raise user message +.. code-block:: Python + def signature_changes( self, decl ): assert not self.check( decl ) return [ remove_arg( self.ordinal ) , add_var_to_return_value( decl.arguments[ self.ordinal ].name ] - + +.. code-block:: Python + def apply( self, sm ): if sm is wrapper around C++ function: sm. add declaration of variable type = decl.arguments[ self.ordinal ].type @@ -223,6 +246,8 @@ else: #sm is a wrapper around Python function sm. extract value from the tuple and assign it to the argument +.. code-block:: Python + def output_arg( ordinal ): return output_arg_t( ordinal ) @@ -237,8 +262,9 @@ I am going to change a little an example, from `Boost.Python`_ tutorials: http://www.boost.org/libs/python/doc/tutorial/doc/html/python/functions.html#python.call_policies -:: +.. code-block:: C++ + //C++ code struct Y { @@ -246,12 +272,16 @@ int z_value() { return z->value(); } }; +.. code-block:: C++ + X& f(Y& y, Z* z, int& error) { y.z = z; return y.x; } +.. code-block:: C++ + //Boost.Python code def("f", f, return_internal_reference<1, with_custodian_and_ward<1, 2> >() ); @@ -265,8 +295,9 @@ 1. May be it is possible with `Boost.Python`_ library to set call policies on the part of the return value? - :: + .. code-block:: C++ + boost::tuple f_wrapper( Y& y, Z* z ){ int error(0); X& x = f( y, z, error ); @@ -277,8 +308,9 @@ 2. May be it is possible to create Boost.Python ``object`` with life-time management hint? - :: + .. code-block:: C++ + boost::python::tuple f_wrapper( Y& y, Z* z ){ int error(0); X& x = f( y, z, error ); Modified: pyplusplus_dev/docs/peps/peps_index.rest =================================================================== --- pyplusplus_dev/docs/peps/peps_index.rest 2006-10-10 22:06:12 UTC (rev 643) +++ pyplusplus_dev/docs/peps/peps_index.rest 2006-10-11 10:43:41 UTC (rev 644) @@ -21,7 +21,7 @@ by `Py++`_: -:: +.. code-block:: C++ class Foo{ union { Modified: pyplusplus_dev/docs/pyplusplus.rest =================================================================== --- pyplusplus_dev/docs/pyplusplus.rest 2006-10-10 22:06:12 UTC (rev 643) +++ pyplusplus_dev/docs/pyplusplus.rest 2006-10-11 10:43:41 UTC (rev 644) @@ -67,27 +67,29 @@ simple query interface. For example in one line of code you can select all free functions that have two arguments, where the first argument has type ``int &`` and the type of the second argument is any: -:: +.. code-block:: Python + mb = module_builder_t( ... ) #module_builder_t is the main class that #will help you with code generation process mb.free_functions( arg_types=[ 'int &', None ] ) An other example - the developer wants to exclude all protected functions from being exported: -:: +.. code-block:: Python + mb = module_builder_t( ... ) mb.calldefs( access_type_matcher_t( 'protected' ) ).exclude() The developer can create custom criteria, for example exclude all declarations that have 'impl' ( implementation ) string within the name. -:: +.. code-block:: Python + mb = module_builder_t( ... ) mb.decls( lambda decl: 'impl' in decl.name ).exclude() - Please, note the way queries were built. You can think about those queries as the rules, which will continue to work even after exported C++ code was changed. It means that you don't have to change code generator source code every time. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2006-10-10 22:06:21
|
Revision: 643 http://svn.sourceforge.net/pygccxml/?rev=643&view=rev Author: roman_yakovenko Date: 2006-10-10 15:06:12 -0700 (Tue, 10 Oct 2006) Log Message: ----------- adding comments to the smart pointer example Modified Paths: -------------- pyplusplus_dev/docs/bpl_lessons_learned/smart_ptrs/bindings.cpp pyplusplus_dev/docs/bpl_lessons_learned/smart_ptrs/classes.hpp pyplusplus_dev/docs/bpl_lessons_learned/smart_ptrs/smart_ptr.h pyplusplus_dev/docs/bpl_lessons_learned/smart_ptrs/test.py Modified: pyplusplus_dev/docs/bpl_lessons_learned/smart_ptrs/bindings.cpp =================================================================== --- pyplusplus_dev/docs/bpl_lessons_learned/smart_ptrs/bindings.cpp 2006-10-10 20:53:26 UTC (rev 642) +++ pyplusplus_dev/docs/bpl_lessons_learned/smart_ptrs/bindings.cpp 2006-10-10 22:06:12 UTC (rev 643) @@ -10,6 +10,12 @@ namespace boost{ namespace python{ + //We need to tell Boost.Python how to work with your smart pointer. + //You can read more about this functionality in the reference manual: + //http://boost.org/libs/python/doc/v2/pointee.html . + //In general + // get_pointer extracts the pointer to the object it manages. + // pointee extracts the type of the object smart pointer manages. template<class T> inline T * get_pointer(smart_ptr_t<T> const& p){ return p.get(); @@ -20,7 +26,6 @@ typedef T type; }; - inline derived_t * get_pointer(derived_ptr_t const& p){ return p.get(); } @@ -32,7 +37,6 @@ } } - struct base_wrapper_t : base_i, bp::wrapper< base_i > { base_wrapper_t() @@ -75,14 +79,31 @@ BOOST_PYTHON_MODULE( custom_sptr ){ bp::class_< base_wrapper_t, boost::noncopyable, smart_ptr_t< base_wrapper_t > >( "base_i" ) + //----------------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + //HeldType of the abstract class, which is managed by custom smart pointer + //should be smart_ptr_t< base_wrapper_t >. .def( "get_value", bp::pure_virtual( &base_i::get_value ) ); + //Register implicit conversion between smart pointers. Boost.Python library + //can not discover relationship between classes.This will allow Boost.Python + //to treat right functions, which expect to get as argument smart_ptr_t< base_i > + //class instance. + //For more information about implicitly_convertible see the documentation: + //http://boost.org/libs/python/doc/v2/implicit.html . bp::implicitly_convertible< smart_ptr_t< base_wrapper_t >, smart_ptr_t< base_i > >(); + + //The register_ptr_to_python functionality is explaned very well in the + //documentation: + //http://boost.org/libs/python/doc/v2/register_ptr_to_python.html . bp::register_ptr_to_python< smart_ptr_t< base_i > >(); bp::class_< derived_wrapper_t, bp::bases< base_i >, smart_ptr_t<derived_wrapper_t> >( "derived_t" ) + //--------------------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + //Pay attention on the class HeldType. It will allow us to create new classes + //in Python, which derive from the derived_t class. .def( "get_value", &derived_t::get_value, &derived_wrapper_t::default_get_value ); + //Nothing special, just registering all existing conversion. bp::implicitly_convertible< smart_ptr_t< derived_wrapper_t >, smart_ptr_t< derived_t > >(); bp::implicitly_convertible< smart_ptr_t< derived_t >, smart_ptr_t< base_i > >(); bp::implicitly_convertible< derived_ptr_t, smart_ptr_t< derived_t > >(); Modified: pyplusplus_dev/docs/bpl_lessons_learned/smart_ptrs/classes.hpp =================================================================== --- pyplusplus_dev/docs/bpl_lessons_learned/smart_ptrs/classes.hpp 2006-10-10 20:53:26 UTC (rev 642) +++ pyplusplus_dev/docs/bpl_lessons_learned/smart_ptrs/classes.hpp 2006-10-10 22:06:12 UTC (rev 643) @@ -1,3 +1,7 @@ +#ifndef classes_11_11_2006 +#define classes_11_11_2006 + + #include "smart_ptr.h" struct base_i{ @@ -2,16 +6,13 @@ public: - virtual ~base_i() { } + virtual ~base_i() {} virtual int get_value() const = 0; }; - struct derived_t : base_i{ - derived_t() - {} - - virtual int get_value() const{ - return 11; - } + derived_t(){} + virtual int get_value() const{ return 0xD; } }; +//Small convenience class. Actually it is defined here, because this is a pattern +//Ogre project uses. struct derived_ptr_t : public smart_ptr_t< derived_t >{ @@ -32,31 +33,32 @@ derived_ptr_t( const smart_ptr_t< base_i >& r) : smart_ptr_t<derived_t>() { - pRep = static_cast<derived_t*>(r.getPointer()); - pUseCount = r.useCountPointer(); - if (pUseCount) + m_managed = static_cast<derived_t*>(r.get()); + m_use_count = r.use_count_ptr(); + if (m_use_count) { - ++(*pUseCount); + ++(*m_use_count); } } derived_ptr_t& operator=(const smart_ptr_t< base_i >& r) { - if (pRep == static_cast<derived_t*>(r.getPointer())) + if (m_managed == static_cast<derived_t*>(r.get())) return *this; release(); - pRep = static_cast<derived_t*>(r.getPointer()); - pUseCount = r.useCountPointer(); - if (pUseCount) + m_managed = static_cast<derived_t*>(r.get()); + m_use_count = r.use_count_ptr(); + if (m_use_count) { - ++(*pUseCount); + ++(*m_use_count); } - + return *this; } }; - +//Few functions that will be used to test custom smart pointer functionality +//from Python. derived_ptr_t create_derived(){ return derived_ptr_t( new derived_t() ); } @@ -71,8 +73,8 @@ //Naturally; there is no instance of smart_ptr_t<base_i> anywhere in the //Python object for the reference to bind to. The rules are the same as in C++: // -// int f(smart_ptr_t<base_i>& x) { return 0; } -// smart_ptr_t<base_wrapper_t> y; +// int f(smart_ptr_t<base>& x) { return 0; } +// smart_ptr_t<derived> y; // int z = f(y); // fails to compile inline int @@ -89,3 +91,6 @@ const_ref_get_value( const smart_ptr_t< base_i >& a ){ return a->get_value(); } + +#endif//classes_11_11_2006 + Modified: pyplusplus_dev/docs/bpl_lessons_learned/smart_ptrs/smart_ptr.h =================================================================== --- pyplusplus_dev/docs/bpl_lessons_learned/smart_ptrs/smart_ptr.h 2006-10-10 20:53:26 UTC (rev 642) +++ pyplusplus_dev/docs/bpl_lessons_learned/smart_ptrs/smart_ptr.h 2006-10-10 22:06:12 UTC (rev 643) @@ -3,70 +3,84 @@ #include <assert.h> -template<class T> class smart_ptr_t { +//The smart_ptr_t class has been created based on Ogre::SharedPtr class +//http://www.ogre3d.org/docs/api/html/OgreSharedPtr_8h-source.html + +template<class T> +class smart_ptr_t { protected: - T* pRep; - unsigned int* pUseCount; + T* m_managed; + unsigned int* m_use_count; public: smart_ptr_t() - : pRep(0), pUseCount(0) + : m_managed(0), m_use_count(0) {} - //What will happen if rep is NULL? -> bug + //rep should not be NULL explicit smart_ptr_t(T* rep) - : pRep(rep), pUseCount( new unsigned int(1) ) + : m_managed(rep), m_use_count( new unsigned int(1) ) {} + //Every custom smart pointer class should have copy constructor and + //assignment operator. Probably you smart pointer class already has this + //functionality. smart_ptr_t(const smart_ptr_t& r) - : pRep(0), pUseCount(0) + : m_managed(0), m_use_count(0) { - pRep = r.get(); - pUseCount = r.useCountPointer(); - if(pUseCount){ - ++(*pUseCount); + m_managed = r.get(); + m_use_count = r.use_count_ptr(); + if(m_use_count){ + ++(*m_use_count); } } smart_ptr_t& operator=(const smart_ptr_t& r){ - if( pRep == r.pRep ){ + if( m_managed == r.m_managed ){ return *this; } - release(); - - pRep = r.get(); - pUseCount = r.useCountPointer(); - if(pUseCount){ - ++(*pUseCount); + + m_managed = r.get(); + m_use_count = r.use_count_ptr(); + if(m_use_count){ + ++(*m_use_count); } return *this; } - + //Next two functions allows to construct smart pointer from an existing one, + //which manages object with a different type. + //For example: + // struct base{...}; + // struct derived : base { ... }; + // smart_ptr_t< base > b( smart_ptr_t<derived>() ); + // + //This functionality is very important for C++ Python bindings. It will allow + //us to register smart pointer conversion: + // boost::python::implicitly_convertible< smart_ptr_t< derived >, smart_ptr_t< base > >(); template<class Y> smart_ptr_t(const smart_ptr_t<Y>& r) - : pRep(0), pUseCount(0) + : m_managed(0), m_use_count(0) { - pRep = r.get(); - pUseCount = r.useCountPointer(); - if(pUseCount){ - ++(*pUseCount); + m_managed = r.get(); + m_use_count = r.use_count_ptr(); + if(m_use_count){ + ++(*m_use_count); } } template< class Y> smart_ptr_t& operator=(const smart_ptr_t<Y>& r){ - if( pRep == r.pRep ){ + if( m_managed == r.m_managed ){ return *this; } - release(); - - pRep = r.get(); - pUseCount = r.useCountPointer(); - if(pUseCount){ - ++(*pUseCount); + + m_managed = r.get(); + m_use_count = r.use_count_ptr(); + if(m_use_count){ + ++(*m_use_count); } return *this; } @@ -76,43 +90,39 @@ } inline T& operator*() const { - assert(pRep); return *pRep; + assert(m_managed); return *m_managed; } inline T* operator->() const { - assert(pRep); return pRep; + assert(m_managed); return m_managed; } inline T* get() const { - return pRep; + return m_managed; } - inline unsigned int* useCountPointer() const { - return pUseCount; + inline unsigned int* use_count_ptr() const { + return m_use_count; } - inline T* getPointer() const { - return pRep; - } - protected: inline void release(void){ - bool destroyThis = false; + bool destroy_this = false; - if( pUseCount ){ - if( --(*pUseCount) == 0){ - destroyThis = true; + if( m_use_count ){ + if( --(*m_use_count) == 0){ + destroy_this = true; } } - if (destroyThis){ + if (destroy_this){ destroy(); } } virtual void destroy(void){ - delete pRep; - delete pUseCount; + delete m_managed; + delete m_use_count; } }; Modified: pyplusplus_dev/docs/bpl_lessons_learned/smart_ptrs/test.py =================================================================== --- pyplusplus_dev/docs/bpl_lessons_learned/smart_ptrs/test.py 2006-10-10 20:53:26 UTC (rev 642) +++ pyplusplus_dev/docs/bpl_lessons_learned/smart_ptrs/test.py 2006-10-10 22:06:12 UTC (rev 643) @@ -13,7 +13,7 @@ custom_sptr.derived_t.__init__( self ) def get_value( self ): - return 31 + return 0xDD class tester_t( unittest.TestCase ): def __init__( self, *args ): @@ -41,20 +41,20 @@ self.__test_const_ref( inst, val ) def test_derived( self ): - self.__test_impl( custom_sptr.derived_t(), 11 ) + self.__test_impl( custom_sptr.derived_t(), 0xD ) def test_py_derived( self ): self.__test_impl( py_derived_t(), 28 ) def test_py_double_derived( self ): - self.__test_impl( py_double_derived_t(), 31 ) + self.__test_impl( py_double_derived_t(), 0xDD ) def test_created_derived( self ): - self.__test_impl( custom_sptr.create_derived(), 11 ) + self.__test_impl( custom_sptr.create_derived(), 0xD ) def test_created_base( self ): inst = custom_sptr.create_base() - val = 11 + val = 0xD self.__test_ref_fine( inst, val ) self.__test_val( inst, val ) self.__test_const_ref( inst, val ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2006-10-10 20:53:41
|
Revision: 642 http://svn.sourceforge.net/pygccxml/?rev=642&view=rev Author: roman_yakovenko Date: 2006-10-10 13:53:26 -0700 (Tue, 10 Oct 2006) Log Message: ----------- adding properties to the examples Modified Paths: -------------- pyplusplus_dev/examples/pyboost_dev/dev/boost_random/generate_code.py pyplusplus_dev/examples/pyboost_dev/dev/date_time/generate_code.py pyplusplus_dev/examples/pyboost_dev/dev/date_time/include/date_time.pypp.xml pyplusplus_dev/examples/pyboost_dev/pyboost/date_time/__init__.py Modified: pyplusplus_dev/examples/pyboost_dev/dev/boost_random/generate_code.py =================================================================== --- pyplusplus_dev/examples/pyboost_dev/dev/boost_random/generate_code.py 2006-10-10 20:47:48 UTC (rev 641) +++ pyplusplus_dev/examples/pyboost_dev/dev/boost_random/generate_code.py 2006-10-10 20:53:26 UTC (rev 642) @@ -116,6 +116,7 @@ var_gen_cls.alias = var_gen_typedef.name + '__' + distrib_cls.alias self.set_call_policies() + boost_ns.classes().add_properties( exclude_accessors=True ) def set_call_policies( self ): boost_ns = self.__mb.namespace( 'boost' ) Modified: pyplusplus_dev/examples/pyboost_dev/dev/date_time/generate_code.py =================================================================== --- pyplusplus_dev/examples/pyboost_dev/dev/date_time/generate_code.py 2006-10-10 20:47:48 UTC (rev 641) +++ pyplusplus_dev/examples/pyboost_dev/dev/date_time/generate_code.py 2006-10-10 20:53:26 UTC (rev 642) @@ -55,7 +55,12 @@ f_decl.alias = f_decl.name f_decl.name = f_decl.demangled_name #f_decl.create_with_signature = True - + + local_date_time = mb.class_( lambda decl: decl.name.startswith( 'local_date_time_base<' ) ) + for c in local_date_time.constructors(): + if not c.is_copy_constructor: + local_date_time.remove_declaration( c ) + mb.run_query_optimizer() for name, alias in customization_data.name2alias.items(): @@ -75,7 +80,6 @@ boost_ns.namespace( 'gregorian', recursive=False ).include() boost_ns.namespace( 'local_time', recursive=False ).include() boost_ns.classes( lambda decl: decl.name.startswith( 'constrained_value<' ) ).include() - ## Exclude protected and private that are not pure virtual query = ~declarations.access_type_matcher_t( 'public' ) \ & ~declarations.virtuality_type_matcher_t( declarations.VIRTUALITY_TYPES.PURE_VIRTUAL ) @@ -138,6 +142,8 @@ tz_db_base.member_functions( 'split_rule_spec' ).exclude() def add_code( self, mb ): + mb.classes().add_properties( exclude_accessors=True ) + as_number_template = 'def( "as_number", &%(class_def)s::operator %(class_def)s::value_type, bp::default_call_policies() )' classes = mb.classes() Modified: pyplusplus_dev/examples/pyboost_dev/dev/date_time/include/date_time.pypp.xml =================================================================== --- pyplusplus_dev/examples/pyboost_dev/dev/date_time/include/date_time.pypp.xml 2006-10-10 20:47:48 UTC (rev 641) +++ pyplusplus_dev/examples/pyboost_dev/dev/date_time/include/date_time.pypp.xml 2006-10-10 20:53:26 UTC (rev 642) @@ -2,8 +2,8 @@ <GCC_XML cvs_revision="1.113"> <Namespace id="_1" name="::" members="_3 _4 _5 _6 _7 _8 _9 _10 _11 _12 _13 _14 _15 _16 _17 _18 _19 _20 _21 _22 _23 _24 _25 _26 _27 _28 _29 _30 _31 _32 _33 _34 _35 _36 _37 _38 _39 _40 _41 _42 _43 _44 _45 _46 _47 _48 _49 _50 _51 _52 _53 _54 _55 _56 _57 _58 _59 _60 _61 _62 _63 _64 _65 _66 _67 _68 _69 _70 _71 _72 _73 _74 _75 _76 _77 _78 _79 _80 _81 _82 _83 _84 _85 _86 _87 _88 _89 _90 _91 _92 _93 _94 _95 _96 _97 _98 _99 _100 _101 _102 _103 _104 _105 _106 _107 _108 _109 _110 _111 _112 _113 _114 _115 _116 _117 _118 _119 _120 _121 _122 _123 _124 _125 _126 _127 _128 _129 _130 _131 _132 _133 _134 _135 _136 _137 _138 _139 _140 _141 _142 _143 _144 _145 _146 _147 _148 _149 _150 _151 _152 _153 _154 _155 _156 _157 _158 _159 _160 _161 _162 _163 _164 _165 _166 _167 _168 _169 _170 _171 _172 _173 _174 _175 _176 _177 _178 _179 _180 _181 _182 _183 _184 _185 _186 _187 _188 _189 _190 _191 _192 _193 _194 _195 _196 _197 _198 _199 _200 _201 _202 _203 _204 _205 _206 _207 _208 _209 _210 _211 _212 _213 _214 _215 _216 _217 _218 _219 _220 _221 _222 _223 _224 _225 _226 _227 _228 _229 _230 _231 _232 _233 _234 _235 _236 _237 _238 _239 _240 _241 _242 _243 _244 _245 _246 _247 _248 _249 _250 _251 _252 _253 _254 _255 _256 _257 _258 _259 _260 _261 _262 _263 _264 _265 _266 _267 _268 _269 _270 _271 _272 _273 _274 _275 _276 _277 _278 _279 _280 _281 _282 _283 _284 _285 _286 _287 _288 _289 _290 _291 _292 _293 _294 _295 _296 _297 _298 _299 _300 _301 _302 _303 _304 _305 _306 _307 _308 _309 _310 _311 _312 _313 _314 _315 _316 _317 _318 _319 _320 _321 _322 _323 _324 _325 _326 _327 _328 _329 _330 _331 _332 _333 _334 _335 _336 _337 _338 _339 _340 _341 _342 _343 _344 _345 _346 _347 _348 _349 _350 _351 _352 _353 _354 _355 _356 _357 _358 _359 _360 _361 _362 _363 _364 _365 _366 _367 _368 _369 _370 _371 _372 _373 _374 _375 _376 _377 _378 _379 _380 _381 _382 _383 _384 _385 _386 _387 _388 _389 _390 _391 _392 _393 _394 _395 _396 _397 _398 _399 _400 _401 _402 _403 _404 _405 _406 _407 _408 _409 _410 _411 _412 _413 _414 _415 _416 _417 _418 _419 _420 _421 _422 _423 _424 _425 _426 _427 _428 _429 _430 _431 _432 _433 _434 _435 _436 _437 _438 _439 _440 _441 _442 _443 _444 _445 _446 _447 _448 _449 _450 _451 _452 _453 _454 _455 _456 _457 _458 _459 _460 _461 _462 _463 _464 _465 _466 _467 _468 _469 _470 _471 _472 _473 _474 _475 _476 _477 _478 _479 _480 _481 _483 _484 _485 _486 _487 _488 _489 _490 _491 _492 _493 _494 _495 _496 _497 _498 _499 _500 _502 _503 _504 _505 _506 _507 _509 _510 _511 _512 _513 _514 _515 _516 _517 _518 _519 _520 _521 _522 _523 _524 _525 _526 _527 _528 _529 _530 _531 _532 _533 _534 _535 _536 _537 _538 _539 _540 _541 _542 _543 _544 _545 _546 _547 _548 _549 _550 _551 _552 _553 _554 _555 _556 _557 _558 _559 _560 _561 _562 _563 _564 _565 _566 _567 _568 _569 _570 _571 _572 _573 _574 _575 _576 _577 _578 _579 _580 _581 _582 _583 _584 _585 _586 _587 _588 _589 _590 _591 _592 _593 _594 _595 _596 _597 _598 _599 _600 _601 _602 _603 _604 _605 _606 _607 _608 _609 _610 _611 _612 _613 _614 _615 _616 _617 _618 _619 _620 _622 _623 _624 _625 _626 _627 _628 _629 _630 _631 _632 _633 _634 _635 _636 _637 _639 _640 _641 _642 _643 _644 _645 _646 _647 _648 _649 _650 _651 _652 _653 _654 _655 _656 _657 _658 _659 _660 _661 _662 _663 _664 _665 _666 _667 _668 _669 _670 _671 _672 _673 _674 _675 _676 _677 _678 _679 _680 _681 _682 _683 _684 _685 _686 _687 _688 _689 _690 _691 _692 _693 _694 _695 _696 _697 _698 _699 _700 _701 _702 _703 _704 _705 _706 _707 _708 _709 _710 _711 _712 _713 _714 _715 _716 _717 _718 _719 _720 _721 _722 _723 _724 _725 _726 _727 _728 _729 _730 _731 _732 _733 _734 _735 _736 _737 _738 _739 _740 _741 _742 _743 _744 _745 _746 _747 _748 _749 _750 _751 _752 _753 _754 _755 _756 _757 _758 _759 _760 _761 _762 _763 _764 _765 _767 _768 _769 _770 _771 _772 _773 _774 _775 _776 _777 _778 _779 _780 _781 _782 _783 _784 _785 _786 _787 _788 _789 _790 _791 _792 _793 _794 _795 _796 _797 _798 _799 _800 _801 _802 _803 _804 _805 _806 _807 _808 _809 _810 _811 _812 _813 _814 _815 _816 _817 _818 _820 _821 _822 _824 _825 _826 _827 _828 _829 _830 _831 _832 _833 _834 _835 _836 _837 _838 _839 _840 _841 _842 _843 _844 _845 _846 _847 _848 _849 _850 _851 _852 _853 _854 _855 _856 _857 _858 _859 _860 _861 _862 _863 _864 _865 _866 _867 _868 _869 _870 _871 _872 _873 _874 _875 _876 _877 _878 _879 _880 _881 _882 _883 _884 _885 _886 _887 _888 _889 _890 _891 _892 _893 _894 _895 _896 _897 _898 _899 _900 _901 _902 _903 _904 _905 _906 _907 _908 _909 _910 _911 _912 _913 _914 _915 _916 _917 _918 _919 _920 _921 _922 _923 _924 _925 _926 _927 _928 _929 _930 _931 _932 _933 _934 _935 _936 _937 _938 _939 _940 _941 _942 _943 _944 _945 _946 _947 _948 _949 _950 _951 _952 _953 _954 _955 _956 _957 _958 _959 _960 _961 _962 _963 _964 _965 _966 _967 _968 _969 _970 _971 _972 _973 _974 _975 _976 _977 _978 _979 _980 _981 _982 _983 _984 _985 _986 _987 _988 _989 _990 _991 _992 _993 _994 _995 _996 _997 _998 _999 _1000 _1001 _1002 _1003 _1004 _1006 _1007 _1008 _1009 _1010 _1011 _1012 _1013 _1014 _1015 _1016 _1017 _1018 _1019 _1020 _1021 _1022 _1023 _1024 _1025 _1026 _1027 _1028 _1029 _1030 _1031 _1032 _1033 _1034 _1035 _1036 _1037 _1038 _1039 _1040 _1041 _1042 _1043 _1044 _1045 _1046 _1047 _1048 _1049 _1050 _1051 _1052 _1053 _1054 _1055 _1056 _1057 _1058 _1059 _1060 _1061 _1062 _1063 _1064 _1065 _1066 _1067 _1068 _1069 _1070 _1071 _1072 _1073 _1074 _1075 _1076 _1077 _1078 _1079 _1080 _1081 _1082 _1083 _1084 _1085 _1086 _1087 _1088 _1089 _1090 _1091 _1092 _1093 _1094 _1095 _1096 _1097 _1098 _1099 _1100 _1101 _1102 _1103 _1104 _1105 _1107 _1109 _1111 _1112 _1113 _1114 _1115 _1116 _1117 _1118 _1119 _1120 _1121 _1122 _1123 _1124 _1125 _1126 _1127 _1128 _1129 _1130 _1131 _1132 _1133 _1134 _1136 _1135 _1138 _1140 _1142 _1144 _1145 _1146 _1147 _1148 _1149 _1150 _1151 _1152 _1153 _1154 _1156 _1157 _1158 _1159 _1161 _1162 _1164 _1165 _1167 _1168 _1170 _1172 _1174 _1176 _1178 _1180 _1182 _1184 _1186 _1187 _1188 _1189 _1190 _1191 _1192 _1106 _1108 _766 _1193 _1195 _1196 _1194 _1197 _1198 _1199 _1200 _1201 _1202 _1203 _1204 _1205 _1206 _1207 _1208 _1209 _1210 _1211 _1212 _1213 _1214 _1215 _1216 _1217 _1218 _1219 _1220 _1221 _1222 _1223 _1224 _1225 _1226 _1227 _1228 _1229 _1230 _1231 _1232 _1233 _1234 _1235 _1236 _1237 _1238 _1239 _1240 _1242 _1243 _1244 _1245 _1246 _1248 _1250 _1251 _1252 _1253 _1254 _1256 _1257 _1258 _1259 _1261 _1262 _1263 _1264 _1265 _1266 _1267 _1268 _1269 _1270 _1271 _1272 _1273 _1274 _1275 _1276 _1277 _1278 _1279 _1280 _1281 _1282 _1283 _1284 _1285 _1286 _1287 _1288 _1289 _1290 _1291 _1292 _1293 _1294 _1295 _1296 _1297 _1298 _1299 _1300 _1301 _1302 _1303 _1304 _1305 _1306 _1307 _1308 _1309 _1310 _1311 _1312 _1313 _1314 _1315 _1316 _1317 _1318 _1319 _1320 _1321 _1322 _1323 _1324 _1325 _1326 _1327 _1328 _1329 _1330 _1331 _1332 _1333 _1334 _1335 _1336 _1337 _1338 _1339 _1340 _1341 _1342 _1343 _1344 _1345 _1346 _1347 _1348 _1349 _1350 _1351 _1352 _1353 _1354 _1355 _1356 _1357 _1358 _1359 _1360 _1361 _1362 _1363 _1364 _1365 _1366 _1367 _1368 _1369 _1370 _1371 _1372 _1373 _1374 _1375 _1376 _1377 _1378 _1379 _1380 _1381 _1382 _1383 _1384 _1385 _1386 _1387 _1388 _1389 _1390 _1391 _1392 _1393 _1394 _1395 _1396 _1397 _1398 _1399 _1400 _1401 _1402 _1403 _1404 _1405 _1406 _1407 _1408 _1409 _1410 _1411 _1412 _1413 _1414 _1415 _1416 _1417 _1418 _1419 _1420 _1421 _1422 _1423 _1424 _1425 _1426 _1427 _1428 _1429 _1431 _1432 _1433 _1434 _1435 _1436 _1437 _1438 _1439 _1440 _1441 _1442 _1443 _1444 _1445 _1446 _1447 _1448 _1449 _1450 _1451 _1452 _1453 _1454 _1455 _1456 _1457 _1458 _1459 _1460 _1461 _1462 _1463 _1464 _1465 _1466 _1467 _1468 _1469 _1470 _1471 _1472 _1473 _1474 _1475 _1476 _1477 _1478 _1479 _1480 _1481 _1482 _1483 _1484 _1485 _1486 _1487 _1488 _1489 _1490 _1492 _1491 _1493 _1494 _819 _1495 _1496 _1497 _1498 _1500 _1499 _1502 _1503 _1504 _1505 _1506 _1507 _1508 _1509 _1510 _1511 _1513 _1514 _1515 _1516 _1517 _1518 _1519 _1520 _1521 _1522 _1523 _1524 _1526 _1525 _1527 _1528 _1529 _1530 _1531 _1532 _1533 _1534 _1535 _1536 _1537 _1538 _1539 _1540 _1541 _1542 _1543 _1544 _1545 _1546 _1547 _1548 _1549 _1550 _1551 _1552 _1553 _1554 _1555 _1556 _1557 _1558 _1559 _1560 _1561 _1563 _1564 _1565 _1566 _1567 _1568 _1569 _1570 _1571 _1572 _1574 _1575 _1576 _1577 _1578 _1579 _1580 _1581 _1582 _1583 _1584 _1585 _1586 _1587 _1588 _1589 _1590 _1591 _1592 _1593 _1594 _1595 _1562 _1596 _1597 _1598 _1599 _1600 _1601 _1602 _1603 _1604 _1605 _1606 _1607 _1608 _1609 _1610 _1611 _1612 _1613 _1614 _1615 _1616 _1617 _1618 _1619 _1620 _1621 _1622 _1623 _1624 _1625 _1626 _1627 _1628 _1629 _1630 _1631 _1632 _1633 _1634 _1635 _1636 _1637 _1638 _1639 _1640 _1641 _1642 _1643 _1644 _1645 _1646 _1647 _1648 _1649 _1650 _1651 _1652 _1653 _1654 _1655 _1656 _1657 _1658 _1659 _1660 _1661 _1662 _1663 _1664 _1665 _1666 _1667 _1668 _1669 _1670 _1671 _1672 _1673 _1674 _1675 _1676 _1677 _1678 _1679 _1680 _1681 _1682 _1683 _1684 _1685 _1686 _1687 _1688 _1689 _1690 _1691 _1692 _1693 _1694 _1695 _1696 _1697 _1698 _1699 _1700 _1701 _1702 _1703 _1704 _1705 _1706 _1707 _1708 _1709 _1710 _1711 _1712 _1713 _1714 _1715 _1716 _1717 _1718 _1719 _1720 _1721 _1722 _1723 _1724 _1725 _1726 _1727 _1728 _1729 _1730 _1731 _1732 _1733 _1734 _1735 _1736 _1737 _1738 _1739 _1740 _1741 _1742 _1743 _1744 _1745 _1746 _1747 _1748 _1749 _1750 _1751 _1752 _1753 _1754 _1755 _1756 _1757 _1758 _1759 _1760 _1761 _1762 _1763 _1764 _1765 _1766 _1767 _1768 _1769 _1770 _1771 _1772 _1773 _1774 _1775 _1776 _1777 _1778 _1779 _1780 _1781 _1782 _1783 _1784 _1785 _1786 _1787 _1788 _1789 _1790 _1791 _1792 _1793 _1794 _1795 _1796 _1797 _1798 _1799 _1800 _1801 _1802 _1803 _1804 _1805 _1806 _1807 _1808 _1809 _1810 _1811 _1812 _1813 _1814 _1815 _1816 _1817 _1818 _1819 _1820 _1821 _1822 _1823 _1824 _1825 _1826 _1827 _1828 _1829 _1830 _1831 _1832 _1833 _1834 _1835 _1836 _1837 _1838 _1839 _1840 _1841 _1842 _1843 _1844 _1845 _1846 _1847 _1848 _1849 _1850 _1851 " mangled="_Z2::" demangled="::"/> <Namespace id="_2" name="std" context="_1" members="_1853 _1854 _1855 _1856 _1857 _1858 _1859 _1860 _1861 _1862 _1863 _1864 _1865 _1866 _1867 _1868 _1869 _1870 _1871 _1872 _1873 _1874 _1875 _1876 _1877 _1878 _1879 _1880 _1881 _1882 _1883 _1884 _1885 _1886 _1887 _1888 _1889 _1890 _1891 _1892 _1893 _1894 _1895 _1896 _1897 _1898 _1899 _1900 _1901 _1902 _1907 _1908 _1913 _1914 _1927 _1928 _1933 _1934 _1939 _1940 _1941 _1942 _1943 _1944 _1945 _1946 _1947 _1948 _1949 _1963 _1964 _1965 _1966 _1967 _1968 _1969 _1970 _1971 _1972 _1975 _1980 _1981 _1982 _1983 _1988 _1989 _1990 _1991 _1994 _1995 _1996 _1997 _1998 _1999 _2000 _2001 _2002 _2003 _2004 _2013 _2014 _2015 _2046 _2055 _2056 _2057 _2058 _2059 _2060 _2061 _2062 _2063 _2064 _2065 _2066 _2067 _2068 _2069 _2070 _2071 _2072 _2073 _2074 _2075 _2076 _2077 _2078 _2079 _2080 _2081 _2082 _2083 _2084 _2085 _2086 _2087 _2088 _2089 _2090 _2091 _2092 _2093 _2094 _2095 _2096 _2097 _2098 _2099 _2100 _2101 _2107 _2108 _2148 _2149 _2150 _2168 _2169 _2209 _2211 _2212 _2213 _2274 _2287 _2296 _2313 _2314 _2319 _2321 _2322 _2323 _2330 _2331 _2332 _2455 _2456 _2457 _2458 _2459 _2460 _2461 _2462 _2463 _2465 _2467 _2469 _2471 _2473 _2475 _2477 _2479 _2481 _2483 _2485 _2487 _2489 _2491 _2493 _2495 _2497 _2499 _2501 _2503 _2505 _2507 _2509 _2511 _2513 _2515 _2516 _2521 _2522 _2523 _2524 _2525 _2526 _2527 _2528 _2529 _2530 _2531 _2532 _2533 _2534 _2536 _2537 _2538 _2539 _2540 _2541 _2542 _2543 _2544 _2546 _2548 _2567 _2568 _2569 _2570 _2571 _2572 _2573 _2574 _2575 _2638 _2639 _2640 _2641 _2642 _2643 _2644 _2653 _2654 _2655 " mangled="_Z3std" demangled="std"/> - <Function id="_3" name="_GLOBAL__D__home_roman_pygccxml_sources_sources_pyplusplus_dev_examples_pyboost_dev_dev_date_time_include_date_time.pypp.hppNOCqrd" returns="_1155" context="_1" location="f0:131" file="f0" line="131" endline="131"/> - <Function id="_4" name="_GLOBAL__I__home_roman_pygccxml_sources_sources_pyplusplus_dev_examples_pyboost_dev_dev_date_time_include_date_time.pypp.hppNOCqrd" returns="_1155" context="_1" location="f0:131" file="f0" line="131" endline="131"/> + <Function id="_3" name="_GLOBAL__D__home_roman_pygccxml_sources_sources_pyplusplus_dev_examples_pyboost_dev_dev_date_time_include_date_time.pypp.hppstnHfb" returns="_1155" context="_1" location="f0:131" file="f0" line="131" endline="131"/> + <Function id="_4" name="_GLOBAL__I__home_roman_pygccxml_sources_sources_pyplusplus_dev_examples_pyboost_dev_dev_date_time_include_date_time.pypp.hppstnHfb" returns="_1155" context="_1" location="f0:131" file="f0" line="131" endline="131"/> <Variable id="_5" name="_ZGVN5boost9date_time10date_facetINS_9gregorian4dateEcSt19ostreambuf_iteratorIcSt11char_traitsIcEEE2idE" type="_1249" context="_1" location="f1:372" file="f1" line="372" artificial="1"/> <Function id="_6" name="__static_initialization_and_destruction_0" returns="_1155" context="_1" mangled="_Z41__static_initialization_and_destruction_0ii" demangled="__static_initialization_and_destruction_0(int, int)" location="f0:131" file="f0" line="131" endline="76"> <Argument name="__initialize_p" type="_501" location="f0:131" file="f0" line="131"/> Modified: pyplusplus_dev/examples/pyboost_dev/pyboost/date_time/__init__.py =================================================================== --- pyplusplus_dev/examples/pyboost_dev/pyboost/date_time/__init__.py 2006-10-10 20:47:48 UTC (rev 641) +++ pyplusplus_dev/examples/pyboost_dev/pyboost/date_time/__init__.py 2006-10-10 20:53:26 UTC (rev 642) @@ -215,7 +215,7 @@ class local_time: dst_calc_rule = _date_time_.dst_calc_rule - local_date_time = _date_time_.local_date_time + #local_date_time = _date_time_.local_date_time custom_time_zone = _date_time_.custom_time_zone posix_time_zone = _date_time_.posix_time_zone time_zone_base = _date_time_.time_zone_base This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2006-10-10 20:47:54
|
Revision: 641 http://svn.sourceforge.net/pygccxml/?rev=641&view=rev Author: roman_yakovenko Date: 2006-10-10 13:47:48 -0700 (Tue, 10 Oct 2006) Log Message: ----------- removing smart_ptrs from the unittests directory Removed Paths: ------------- pyplusplus_dev/unittests/smart_ptrs/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2006-10-10 19:31:26
|
Revision: 640 http://svn.sourceforge.net/pygccxml/?rev=640&view=rev Author: roman_yakovenko Date: 2006-10-10 12:31:17 -0700 (Tue, 10 Oct 2006) Log Message: ----------- updating unit tests to reflect "template on return type" FAQ Modified Paths: -------------- pyplusplus_dev/unittests/data/member_functions_to_be_exported.cpp pyplusplus_dev/unittests/data/member_functions_to_be_exported.hpp pyplusplus_dev/unittests/data/pointer_as_arg_to_be_exported.hpp pyplusplus_dev/unittests/member_functions_tester.py Modified: pyplusplus_dev/unittests/data/member_functions_to_be_exported.cpp =================================================================== --- pyplusplus_dev/unittests/data/member_functions_to_be_exported.cpp 2006-10-10 13:26:42 UTC (rev 639) +++ pyplusplus_dev/unittests/data/member_functions_to_be_exported.cpp 2006-10-10 19:31:17 UTC (rev 640) @@ -1,10 +1,9 @@ -// Copyright 2004 Roman Yakovenko. -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#include "member_functions_to_be_exported.hpp" - -namespace member_functions{ -} - +// Copyright 2004 Roman Yakovenko. +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include "member_functions_to_be_exported.hpp" + +namespace member_functions{ +} Modified: pyplusplus_dev/unittests/data/member_functions_to_be_exported.hpp =================================================================== --- pyplusplus_dev/unittests/data/member_functions_to_be_exported.hpp 2006-10-10 13:26:42 UTC (rev 639) +++ pyplusplus_dev/unittests/data/member_functions_to_be_exported.hpp 2006-10-10 19:31:17 UTC (rev 640) @@ -166,7 +166,17 @@ } }; + +struct mem_fun_environment_t{ + template< class T> + T get_value(const std::string& x){ return T(); } +}; + +inline void instantiate_mem_fun_environment(){ + mem_fun_environment_t env; + int i = env.get_value<int>(""); } +} #endif//__member_functions_to_be_exported_hpp__ Modified: pyplusplus_dev/unittests/data/pointer_as_arg_to_be_exported.hpp =================================================================== --- pyplusplus_dev/unittests/data/pointer_as_arg_to_be_exported.hpp 2006-10-10 13:26:42 UTC (rev 639) +++ pyplusplus_dev/unittests/data/pointer_as_arg_to_be_exported.hpp 2006-10-10 19:31:17 UTC (rev 640) @@ -1,22 +1,22 @@ -// Copyright 2004 Roman Yakovenko. -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#ifndef __pointer_as_arg_to_be_exported_hpp__ -#define __pointer_as_arg_to_be_exported_hpp__ - -#include <string> - -namespace pointer_as_arg{ - +// Copyright 2004 Roman Yakovenko. +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef __pointer_as_arg_to_be_exported_hpp__ +#define __pointer_as_arg_to_be_exported_hpp__ + +#include <string> + +namespace pointer_as_arg{ + struct data{}; inline int test_for_null( data* d=0 ){ return d ? 1 : 0; -} - -} - -#endif//__pointer_as_arg_to_be_exported_hpp__ +} + +} + +#endif//__pointer_as_arg_to_be_exported_hpp__ \ No newline at end of file Modified: pyplusplus_dev/unittests/member_functions_tester.py =================================================================== --- pyplusplus_dev/unittests/member_functions_tester.py 2006-10-10 13:26:42 UTC (rev 639) +++ pyplusplus_dev/unittests/member_functions_tester.py 2006-10-10 19:31:17 UTC (rev 640) @@ -33,7 +33,15 @@ #will reporoduce bug mb.class_('callable_t').always_expose_using_scope = True mb.BOOST_PYTHON_MAX_ARITY = 1 - + mb.free_function( 'instantiate_mem_fun_environment' ).exclude() + + env = mb.class_( 'mem_fun_environment_t' ) + get_value = env.member_function( 'get_value', return_type='int' ) + get_value.alias = 'get_value_int' + get_value.name = get_value.demangled_name + + mb.run_query_optimizer() + def create_py_immutable_by_ref( self, module ): class py_immutable_by_ref( module.immutable_by_ref_t ): def __init__( self ): @@ -120,7 +128,10 @@ x = self.create_py_immutable_by_ref(module) self.failUnless( x.identity( '11' ) == '1111' ) self.failUnless( module.immutable_by_ref_t.call_identity(x, '11') == '1111' ) - + + env = module.mem_fun_environment_t() + env.get_value_int("xxx") + def create_suite(): suite = unittest.TestSuite() suite.addTest( unittest.makeSuite(tester_t)) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2006-10-10 13:27:00
|
Revision: 639 http://svn.sourceforge.net/pygccxml/?rev=639&view=rev Author: roman_yakovenko Date: 2006-10-10 06:26:42 -0700 (Tue, 10 Oct 2006) Log Message: ----------- moving smart_ptrs from unittests directory to documentation Modified Paths: -------------- pyplusplus_dev/docs/bpl_lessons_learned/lessons_learned.rest Added Paths: ----------- pyplusplus_dev/docs/bpl_lessons_learned/smart_ptrs/ pyplusplus_dev/docs/bpl_lessons_learned/smart_ptrs/bindings.cpp pyplusplus_dev/docs/bpl_lessons_learned/smart_ptrs/classes.hpp pyplusplus_dev/docs/bpl_lessons_learned/smart_ptrs/smart_ptr.h Removed Paths: ------------- pyplusplus_dev/docs/bpl_lessons_learned/smart_ptrs/bindings.cpp pyplusplus_dev/docs/bpl_lessons_learned/smart_ptrs/classes.hpp pyplusplus_dev/docs/bpl_lessons_learned/smart_ptrs/smart_ptr.h Modified: pyplusplus_dev/docs/bpl_lessons_learned/lessons_learned.rest =================================================================== --- pyplusplus_dev/docs/bpl_lessons_learned/lessons_learned.rest 2006-10-10 13:18:29 UTC (rev 638) +++ pyplusplus_dev/docs/bpl_lessons_learned/lessons_learned.rest 2006-10-10 13:26:42 UTC (rev 639) @@ -21,7 +21,7 @@ solution contains source code and comprehensive unit test for the problem. -.. _`Custom smart pointer class` : ./smart_ptr/smart_ptr.html +.. _`Custom smart pointer class` : ./smart_ptrs/smart_ptrs.html .. _`Py++` : ./../pyplusplus.html Copied: pyplusplus_dev/docs/bpl_lessons_learned/smart_ptrs (from rev 635, pyplusplus_dev/unittests/smart_ptrs) Deleted: pyplusplus_dev/docs/bpl_lessons_learned/smart_ptrs/bindings.cpp =================================================================== --- pyplusplus_dev/unittests/smart_ptrs/bindings.cpp 2006-10-09 21:44:47 UTC (rev 635) +++ pyplusplus_dev/docs/bpl_lessons_learned/smart_ptrs/bindings.cpp 2006-10-10 13:26:42 UTC (rev 639) @@ -1,98 +0,0 @@ -// This file has been generated by Py++. - -// Copyright 2004 Roman Yakovenko. -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#include "boost/python.hpp" -#include "classes.hpp" - -namespace bp = boost::python; - -namespace boost{ namespace python{ - - template<class T> - inline T * get_pointer(smart_ptr_t<T> const& p){ - return p.get(); - } - - template <class T> - struct pointee< smart_ptr_t<T> >{ - typedef T type; - }; - - - inline derived_t * get_pointer(derived_ptr_t const& p){ - return p.get(); - } - - template<> - struct pointee< derived_ptr_t >{ - typedef derived_t type; - }; - -} } - - -struct base_wrapper_t : base_i, bp::wrapper< base_i > { - - base_wrapper_t() - : base_i(), bp::wrapper< base_i >() - {} - - virtual int get_value( ) const { - bp::override func_get_value = this->get_override( "get_value" ); - return func_get_value( ); - } - -}; - -struct derived_wrapper_t : derived_t, bp::wrapper< derived_t > { - - derived_wrapper_t() - : derived_t(), bp::wrapper< derived_t >() - {} - - derived_wrapper_t(const derived_t& d) - : derived_t(d), bp::wrapper< derived_t >() - {} - - derived_wrapper_t(const derived_wrapper_t&) - : derived_t(), bp::wrapper< derived_t >() - {} - - virtual int get_value() const { - if( bp::override func_get_value = this->get_override( "get_value" ) ) - return func_get_value( ); - else - return derived_t::get_value( ); - } - - int default_get_value() const { - return derived_t::get_value( ); - } - -}; - -BOOST_PYTHON_MODULE( custom_sptr ){ - bp::class_< base_wrapper_t, boost::noncopyable, smart_ptr_t< base_wrapper_t > >( "base_i" ) - .def( "get_value", bp::pure_virtual( &base_i::get_value ) ); - - bp::implicitly_convertible< smart_ptr_t< base_wrapper_t >, smart_ptr_t< base_i > >(); - bp::register_ptr_to_python< smart_ptr_t< base_i > >(); - - bp::class_< derived_wrapper_t, bp::bases< base_i >, smart_ptr_t<derived_wrapper_t> >( "derived_t" ) - .def( "get_value", &derived_t::get_value, &derived_wrapper_t::default_get_value ); - - bp::implicitly_convertible< smart_ptr_t< derived_wrapper_t >, smart_ptr_t< derived_t > >(); - bp::implicitly_convertible< smart_ptr_t< derived_t >, smart_ptr_t< base_i > >(); - bp::implicitly_convertible< derived_ptr_t, smart_ptr_t< derived_t > >(); - bp::register_ptr_to_python< derived_ptr_t >(); - - bp::def( "const_ref_get_value", &::const_ref_get_value ); - bp::def( "ref_get_value", &::ref_get_value ); - bp::def( "val_get_value", &::val_get_value ); - bp::def( "create_derived", &::create_derived ); - bp::def( "create_base", &::create_base ); -} Copied: pyplusplus_dev/docs/bpl_lessons_learned/smart_ptrs/bindings.cpp (from rev 637, pyplusplus_dev/unittests/smart_ptrs/bindings.cpp) =================================================================== --- pyplusplus_dev/docs/bpl_lessons_learned/smart_ptrs/bindings.cpp (rev 0) +++ pyplusplus_dev/docs/bpl_lessons_learned/smart_ptrs/bindings.cpp 2006-10-10 13:26:42 UTC (rev 639) @@ -0,0 +1,96 @@ +// Copyright 2004 Roman Yakovenko. +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include "boost/python.hpp" +#include "classes.hpp" + +namespace bp = boost::python; + +namespace boost{ namespace python{ + + template<class T> + inline T * get_pointer(smart_ptr_t<T> const& p){ + return p.get(); + } + + template <class T> + struct pointee< smart_ptr_t<T> >{ + typedef T type; + }; + + + inline derived_t * get_pointer(derived_ptr_t const& p){ + return p.get(); + } + + template<> + struct pointee< derived_ptr_t >{ + typedef derived_t type; + }; + +} } + + +struct base_wrapper_t : base_i, bp::wrapper< base_i > { + + base_wrapper_t() + : base_i(), bp::wrapper< base_i >() + {} + + virtual int get_value( ) const { + bp::override func_get_value = this->get_override( "get_value" ); + return func_get_value( ); + } + +}; + +struct derived_wrapper_t : derived_t, bp::wrapper< derived_t > { + + derived_wrapper_t() + : derived_t(), bp::wrapper< derived_t >() + {} + + derived_wrapper_t(const derived_t& d) + : derived_t(d), bp::wrapper< derived_t >() + {} + + derived_wrapper_t(const derived_wrapper_t&) + : derived_t(), bp::wrapper< derived_t >() + {} + + virtual int get_value() const { + if( bp::override func_get_value = this->get_override( "get_value" ) ) + return func_get_value( ); + else + return derived_t::get_value( ); + } + + int default_get_value() const { + return derived_t::get_value( ); + } + +}; + +BOOST_PYTHON_MODULE( custom_sptr ){ + bp::class_< base_wrapper_t, boost::noncopyable, smart_ptr_t< base_wrapper_t > >( "base_i" ) + .def( "get_value", bp::pure_virtual( &base_i::get_value ) ); + + bp::implicitly_convertible< smart_ptr_t< base_wrapper_t >, smart_ptr_t< base_i > >(); + bp::register_ptr_to_python< smart_ptr_t< base_i > >(); + + bp::class_< derived_wrapper_t, bp::bases< base_i >, smart_ptr_t<derived_wrapper_t> >( "derived_t" ) + .def( "get_value", &derived_t::get_value, &derived_wrapper_t::default_get_value ); + + bp::implicitly_convertible< smart_ptr_t< derived_wrapper_t >, smart_ptr_t< derived_t > >(); + bp::implicitly_convertible< smart_ptr_t< derived_t >, smart_ptr_t< base_i > >(); + bp::implicitly_convertible< derived_ptr_t, smart_ptr_t< derived_t > >(); + bp::register_ptr_to_python< derived_ptr_t >(); + + bp::def( "const_ref_get_value", &::const_ref_get_value ); + bp::def( "ref_get_value", &::ref_get_value ); + bp::def( "val_get_value", &::val_get_value ); + bp::def( "create_derived", &::create_derived ); + bp::def( "create_base", &::create_base ); +} Deleted: pyplusplus_dev/docs/bpl_lessons_learned/smart_ptrs/classes.hpp =================================================================== --- pyplusplus_dev/unittests/smart_ptrs/classes.hpp 2006-10-09 21:44:47 UTC (rev 635) +++ pyplusplus_dev/docs/bpl_lessons_learned/smart_ptrs/classes.hpp 2006-10-10 13:26:42 UTC (rev 639) @@ -1,91 +0,0 @@ -#include "smart_ptr.h" - -struct base_i{ -public: - virtual ~base_i() { } - virtual int get_value() const = 0; -}; - - -struct derived_t : base_i{ - derived_t() - {} - - virtual int get_value() const{ - return 11; - } -}; - -struct derived_ptr_t : public smart_ptr_t< derived_t >{ - - derived_ptr_t() - : smart_ptr_t< derived_t >() - {} - - explicit derived_ptr_t(derived_t* rep) - : smart_ptr_t<derived_t>(rep) - {} - - derived_ptr_t(const derived_ptr_t& r) - : smart_ptr_t<derived_t>(r) {} - - derived_ptr_t( const smart_ptr_t< base_i >& r) - : smart_ptr_t<derived_t>() - { - pRep = static_cast<derived_t*>(r.getPointer()); - pUseCount = r.useCountPointer(); - if (pUseCount) - { - ++(*pUseCount); - } - } - - derived_ptr_t& operator=(const smart_ptr_t< base_i >& r) - { - if (pRep == static_cast<derived_t*>(r.getPointer())) - return *this; - release(); - pRep = static_cast<derived_t*>(r.getPointer()); - pUseCount = r.useCountPointer(); - if (pUseCount) - { - ++(*pUseCount); - } - - return *this; - } -}; - - -derived_ptr_t create_derived(){ - return derived_ptr_t( new derived_t() ); -} - -smart_ptr_t< base_i > create_base(){ - return smart_ptr_t< base_i >( new derived_t() ); -} - - -//Next function could be exposed, but it could not be solved -//This is the explanation David Abrahams gave: -//Naturally; there is no instance of smart_ptr_t<base_i> anywhere in the -//Python object for the reference to bind to. The rules are the same as in C++: -// -// int f(smart_ptr_t<base_i>& x) { return 0; } -// smart_ptr_t<base_wrapper_t> y; -// int z = f(y); // fails to compile - -inline int -ref_get_value( smart_ptr_t< base_i >& a ){ - return a->get_value(); -} - -inline int -val_get_value( smart_ptr_t< base_i > a ){ - return a->get_value(); -} - -inline int -const_ref_get_value( const smart_ptr_t< base_i >& a ){ - return a->get_value(); -} Copied: pyplusplus_dev/docs/bpl_lessons_learned/smart_ptrs/classes.hpp (from rev 637, pyplusplus_dev/unittests/smart_ptrs/classes.hpp) =================================================================== --- pyplusplus_dev/docs/bpl_lessons_learned/smart_ptrs/classes.hpp (rev 0) +++ pyplusplus_dev/docs/bpl_lessons_learned/smart_ptrs/classes.hpp 2006-10-10 13:26:42 UTC (rev 639) @@ -0,0 +1,91 @@ +#include "smart_ptr.h" + +struct base_i{ +public: + virtual ~base_i() { } + virtual int get_value() const = 0; +}; + + +struct derived_t : base_i{ + derived_t() + {} + + virtual int get_value() const{ + return 11; + } +}; + +struct derived_ptr_t : public smart_ptr_t< derived_t >{ + + derived_ptr_t() + : smart_ptr_t< derived_t >() + {} + + explicit derived_ptr_t(derived_t* rep) + : smart_ptr_t<derived_t>(rep) + {} + + derived_ptr_t(const derived_ptr_t& r) + : smart_ptr_t<derived_t>(r) {} + + derived_ptr_t( const smart_ptr_t< base_i >& r) + : smart_ptr_t<derived_t>() + { + pRep = static_cast<derived_t*>(r.getPointer()); + pUseCount = r.useCountPointer(); + if (pUseCount) + { + ++(*pUseCount); + } + } + + derived_ptr_t& operator=(const smart_ptr_t< base_i >& r) + { + if (pRep == static_cast<derived_t*>(r.getPointer())) + return *this; + release(); + pRep = static_cast<derived_t*>(r.getPointer()); + pUseCount = r.useCountPointer(); + if (pUseCount) + { + ++(*pUseCount); + } + + return *this; + } +}; + + +derived_ptr_t create_derived(){ + return derived_ptr_t( new derived_t() ); +} + +smart_ptr_t< base_i > create_base(){ + return smart_ptr_t< base_i >( new derived_t() ); +} + + +//Next function could be exposed, but it could not be solved +//This is the explanation David Abrahams gave: +//Naturally; there is no instance of smart_ptr_t<base_i> anywhere in the +//Python object for the reference to bind to. The rules are the same as in C++: +// +// int f(smart_ptr_t<base_i>& x) { return 0; } +// smart_ptr_t<base_wrapper_t> y; +// int z = f(y); // fails to compile + +inline int +ref_get_value( smart_ptr_t< base_i >& a ){ + return a->get_value(); +} + +inline int +val_get_value( smart_ptr_t< base_i > a ){ + return a->get_value(); +} + +inline int +const_ref_get_value( const smart_ptr_t< base_i >& a ){ + return a->get_value(); +} Deleted: pyplusplus_dev/docs/bpl_lessons_learned/smart_ptrs/smart_ptr.h =================================================================== --- pyplusplus_dev/unittests/smart_ptrs/smart_ptr.h 2006-10-09 21:44:47 UTC (rev 635) +++ pyplusplus_dev/docs/bpl_lessons_learned/smart_ptrs/smart_ptr.h 2006-10-10 13:26:42 UTC (rev 639) @@ -1,121 +0,0 @@ -#ifndef smart_ptr_t_19_09_2006 -#define smart_ptr_t_19_09_2006 - -#include <assert.h> - -template<class T> class smart_ptr_t { -protected: - T* pRep; - unsigned int* pUseCount; -public: - - smart_ptr_t() - : pRep(0), pUseCount(0) - {} - - //What will happen if rep is NULL? -> bug - explicit smart_ptr_t(T* rep) - : pRep(rep), pUseCount( new unsigned int(1) ) - {} - - smart_ptr_t(const smart_ptr_t& r) - : pRep(0), pUseCount(0) - { - pRep = r.get(); - pUseCount = r.useCountPointer(); - if(pUseCount){ - ++(*pUseCount); - } - } - - smart_ptr_t& operator=(const smart_ptr_t& r){ - if( pRep == r.pRep ){ - return *this; - } - - release(); - - pRep = r.get(); - pUseCount = r.useCountPointer(); - if(pUseCount){ - ++(*pUseCount); - } - return *this; - } - - - template<class Y> - smart_ptr_t(const smart_ptr_t<Y>& r) - : pRep(0), pUseCount(0) - { - pRep = r.get(); - pUseCount = r.useCountPointer(); - if(pUseCount){ - ++(*pUseCount); - } - } - - template< class Y> - smart_ptr_t& operator=(const smart_ptr_t<Y>& r){ - if( pRep == r.pRep ){ - return *this; - } - - release(); - - pRep = r.get(); - pUseCount = r.useCountPointer(); - if(pUseCount){ - ++(*pUseCount); - } - return *this; - } - - virtual ~smart_ptr_t() { - release(); - } - - inline T& operator*() const { - assert(pRep); return *pRep; - } - - inline T* operator->() const { - assert(pRep); return pRep; - } - - inline T* get() const { - return pRep; - } - - inline unsigned int* useCountPointer() const { - return pUseCount; - } - - inline T* getPointer() const { - return pRep; - } - -protected: - - inline void release(void){ - bool destroyThis = false; - - if( pUseCount ){ - if( --(*pUseCount) == 0){ - destroyThis = true; - } - } - if (destroyThis){ - destroy(); - } - } - - virtual void destroy(void){ - delete pRep; - delete pUseCount; - } -}; - - -#endif //smart_ptr_t_19_09_2006 - Copied: pyplusplus_dev/docs/bpl_lessons_learned/smart_ptrs/smart_ptr.h (from rev 637, pyplusplus_dev/unittests/smart_ptrs/smart_ptr.h) =================================================================== --- pyplusplus_dev/docs/bpl_lessons_learned/smart_ptrs/smart_ptr.h (rev 0) +++ pyplusplus_dev/docs/bpl_lessons_learned/smart_ptrs/smart_ptr.h 2006-10-10 13:26:42 UTC (rev 639) @@ -0,0 +1,121 @@ +#ifndef smart_ptr_t_19_09_2006 +#define smart_ptr_t_19_09_2006 + +#include <assert.h> + +template<class T> class smart_ptr_t { +protected: + T* pRep; + unsigned int* pUseCount; +public: + + smart_ptr_t() + : pRep(0), pUseCount(0) + {} + + //What will happen if rep is NULL? -> bug + explicit smart_ptr_t(T* rep) + : pRep(rep), pUseCount( new unsigned int(1) ) + {} + + smart_ptr_t(const smart_ptr_t& r) + : pRep(0), pUseCount(0) + { + pRep = r.get(); + pUseCount = r.useCountPointer(); + if(pUseCount){ + ++(*pUseCount); + } + } + + smart_ptr_t& operator=(const smart_ptr_t& r){ + if( pRep == r.pRep ){ + return *this; + } + + release(); + + pRep = r.get(); + pUseCount = r.useCountPointer(); + if(pUseCount){ + ++(*pUseCount); + } + return *this; + } + + + template<class Y> + smart_ptr_t(const smart_ptr_t<Y>& r) + : pRep(0), pUseCount(0) + { + pRep = r.get(); + pUseCount = r.useCountPointer(); + if(pUseCount){ + ++(*pUseCount); + } + } + + template< class Y> + smart_ptr_t& operator=(const smart_ptr_t<Y>& r){ + if( pRep == r.pRep ){ + return *this; + } + + release(); + + pRep = r.get(); + pUseCount = r.useCountPointer(); + if(pUseCount){ + ++(*pUseCount); + } + return *this; + } + + virtual ~smart_ptr_t() { + release(); + } + + inline T& operator*() const { + assert(pRep); return *pRep; + } + + inline T* operator->() const { + assert(pRep); return pRep; + } + + inline T* get() const { + return pRep; + } + + inline unsigned int* useCountPointer() const { + return pUseCount; + } + + inline T* getPointer() const { + return pRep; + } + +protected: + + inline void release(void){ + bool destroyThis = false; + + if( pUseCount ){ + if( --(*pUseCount) == 0){ + destroyThis = true; + } + } + if (destroyThis){ + destroy(); + } + } + + virtual void destroy(void){ + delete pRep; + delete pUseCount; + } +}; + + +#endif //smart_ptr_t_19_09_2006 + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2006-10-10 13:18:37
|
Revision: 638 http://svn.sourceforge.net/pygccxml/?rev=638&view=rev Author: roman_yakovenko Date: 2006-10-10 06:18:29 -0700 (Tue, 10 Oct 2006) Log Message: ----------- adding new directory that will contain ready-to-learn solutions Added Paths: ----------- pyplusplus_dev/docs/bpl_lessons_learned/ pyplusplus_dev/docs/bpl_lessons_learned/lessons_learned.rest pyplusplus_dev/docs/bpl_lessons_learned/www_configuration.py Added: pyplusplus_dev/docs/bpl_lessons_learned/lessons_learned.rest =================================================================== --- pyplusplus_dev/docs/bpl_lessons_learned/lessons_learned.rest (rev 0) +++ pyplusplus_dev/docs/bpl_lessons_learned/lessons_learned.rest 2006-10-10 13:18:29 UTC (rev 638) @@ -0,0 +1,38 @@ +============================== +Boost.Python - lessons learned +============================== + +.. contents:: Table of contents + +-------- +Preamble +-------- + +Software development is an interactrive process. During `Py++`_ development +I see many interesting problems and even more interesting solutions. + +On this page you will find my collection of the solutions to some of the problems. + + +`Custom smart pointer class`_ + + There are projects, which use custom smart pointer(s). For majority of the + projects, it is not an option to switch to ``boost::shared_ptr``. The + solution contains source code and comprehensive unit test for the problem. + + +.. _`Custom smart pointer class` : ./smart_ptr/smart_ptr.html + + +.. _`Py++` : ./../pyplusplus.html +.. _`pygccxml` : http://www.language-binding.net/pygccxml/pygccxml.html +.. _`SourceForge`: http://sourceforge.net/index.php + +.. + Local Variables: + mode: indented-text + indent-tabs-mode: nil + sentence-end-double-space: t + fill-column: 70 + End: + Added: pyplusplus_dev/docs/bpl_lessons_learned/www_configuration.py =================================================================== --- pyplusplus_dev/docs/bpl_lessons_learned/www_configuration.py (rev 0) +++ pyplusplus_dev/docs/bpl_lessons_learned/www_configuration.py 2006-10-10 13:18:29 UTC (rev 638) @@ -0,0 +1,3 @@ +name = 'Boost.Python - lessons learned' +main_html_file = 'lessons_learned.html' +names = { 'lessons_learned' : 'Boost.Python - lessons learned' } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2006-10-10 13:15:37
|
Revision: 637 http://svn.sourceforge.net/pygccxml/?rev=637&view=rev Author: roman_yakovenko Date: 2006-10-10 06:15:25 -0700 (Tue, 10 Oct 2006) Log Message: ----------- changing tabs to spaces Modified Paths: -------------- pyplusplus_dev/unittests/smart_ptrs/bindings.cpp pyplusplus_dev/unittests/smart_ptrs/classes.hpp pyplusplus_dev/unittests/smart_ptrs/smart_ptr.h Modified: pyplusplus_dev/unittests/smart_ptrs/bindings.cpp =================================================================== --- pyplusplus_dev/unittests/smart_ptrs/bindings.cpp 2006-10-10 07:42:21 UTC (rev 636) +++ pyplusplus_dev/unittests/smart_ptrs/bindings.cpp 2006-10-10 13:15:25 UTC (rev 637) @@ -1,5 +1,3 @@ -// This file has been generated by Py++. - // Copyright 2004 Roman Yakovenko. // Distributed under the Boost Software License, Version 1.0. (See // accompanying file LICENSE_1_0.txt or copy at Modified: pyplusplus_dev/unittests/smart_ptrs/classes.hpp =================================================================== --- pyplusplus_dev/unittests/smart_ptrs/classes.hpp 2006-10-10 07:42:21 UTC (rev 636) +++ pyplusplus_dev/unittests/smart_ptrs/classes.hpp 2006-10-10 13:15:25 UTC (rev 637) @@ -31,7 +31,7 @@ derived_ptr_t( const smart_ptr_t< base_i >& r) : smart_ptr_t<derived_t>() - { + { pRep = static_cast<derived_t*>(r.getPointer()); pUseCount = r.useCountPointer(); if (pUseCount) @@ -41,18 +41,18 @@ } derived_ptr_t& operator=(const smart_ptr_t< base_i >& r) - { - if (pRep == static_cast<derived_t*>(r.getPointer())) - return *this; + { + if (pRep == static_cast<derived_t*>(r.getPointer())) + return *this; release(); - pRep = static_cast<derived_t*>(r.getPointer()); - pUseCount = r.useCountPointer(); - if (pUseCount) - { - ++(*pUseCount); + pRep = static_cast<derived_t*>(r.getPointer()); + pUseCount = r.useCountPointer(); + if (pUseCount) + { + ++(*pUseCount); } - return *this; + return *this; } }; Modified: pyplusplus_dev/unittests/smart_ptrs/smart_ptr.h =================================================================== --- pyplusplus_dev/unittests/smart_ptrs/smart_ptr.h 2006-10-10 07:42:21 UTC (rev 636) +++ pyplusplus_dev/unittests/smart_ptrs/smart_ptr.h 2006-10-10 13:15:25 UTC (rev 637) @@ -5,109 +5,109 @@ template<class T> class smart_ptr_t { protected: - T* pRep; - unsigned int* pUseCount; + T* pRep; + unsigned int* pUseCount; public: - smart_ptr_t() + smart_ptr_t() : pRep(0), pUseCount(0) {} //What will happen if rep is NULL? -> bug - explicit smart_ptr_t(T* rep) + explicit smart_ptr_t(T* rep) : pRep(rep), pUseCount( new unsigned int(1) ) - {} + {} - smart_ptr_t(const smart_ptr_t& r) + smart_ptr_t(const smart_ptr_t& r) : pRep(0), pUseCount(0) { - pRep = r.get(); - pUseCount = r.useCountPointer(); - if(pUseCount){ - ++(*pUseCount); - } + pRep = r.get(); + pUseCount = r.useCountPointer(); + if(pUseCount){ + ++(*pUseCount); + } } - smart_ptr_t& operator=(const smart_ptr_t& r){ - if( pRep == r.pRep ){ - return *this; - } + smart_ptr_t& operator=(const smart_ptr_t& r){ + if( pRep == r.pRep ){ + return *this; + } - release(); + release(); - pRep = r.get(); - pUseCount = r.useCountPointer(); - if(pUseCount){ - ++(*pUseCount); - } - return *this; - } + pRep = r.get(); + pUseCount = r.useCountPointer(); + if(pUseCount){ + ++(*pUseCount); + } + return *this; + } template<class Y> - smart_ptr_t(const smart_ptr_t<Y>& r) + smart_ptr_t(const smart_ptr_t<Y>& r) : pRep(0), pUseCount(0) { - pRep = r.get(); - pUseCount = r.useCountPointer(); - if(pUseCount){ - ++(*pUseCount); - } + pRep = r.get(); + pUseCount = r.useCountPointer(); + if(pUseCount){ + ++(*pUseCount); + } } template< class Y> - smart_ptr_t& operator=(const smart_ptr_t<Y>& r){ - if( pRep == r.pRep ){ - return *this; - } + smart_ptr_t& operator=(const smart_ptr_t<Y>& r){ + if( pRep == r.pRep ){ + return *this; + } - release(); + release(); - pRep = r.get(); - pUseCount = r.useCountPointer(); - if(pUseCount){ - ++(*pUseCount); - } - return *this; - } + pRep = r.get(); + pUseCount = r.useCountPointer(); + if(pUseCount){ + ++(*pUseCount); + } + return *this; + } - virtual ~smart_ptr_t() { + virtual ~smart_ptr_t() { release(); - } + } - inline T& operator*() const { - assert(pRep); return *pRep; - } + inline T& operator*() const { + assert(pRep); return *pRep; + } - inline T* operator->() const { - assert(pRep); return pRep; - } + inline T* operator->() const { + assert(pRep); return pRep; + } - inline T* get() const { - return pRep; - } + inline T* get() const { + return pRep; + } - inline unsigned int* useCountPointer() const { - return pUseCount; - } + inline unsigned int* useCountPointer() const { + return pUseCount; + } - inline T* getPointer() const { - return pRep; - } + inline T* getPointer() const { + return pRep; + } protected: inline void release(void){ - bool destroyThis = false; + bool destroyThis = false; - if( pUseCount ){ - if( --(*pUseCount) == 0){ - destroyThis = true; - } - } - if (destroyThis){ - destroy(); - } + if( pUseCount ){ + if( --(*pUseCount) == 0){ + destroyThis = true; + } + } + if (destroyThis){ + destroy(); + } } virtual void destroy(void){ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2006-10-10 07:42:29
|
Revision: 636 http://svn.sourceforge.net/pygccxml/?rev=636&view=rev Author: roman_yakovenko Date: 2006-10-10 00:42:21 -0700 (Tue, 10 Oct 2006) Log Message: ----------- adding new FAQ Modified Paths: -------------- pyplusplus_dev/docs/documentation/how_to.rest Modified: pyplusplus_dev/docs/documentation/how_to.rest =================================================================== --- pyplusplus_dev/docs/documentation/how_to.rest 2006-10-09 21:44:47 UTC (rev 635) +++ pyplusplus_dev/docs/documentation/how_to.rest 2006-10-10 07:42:21 UTC (rev 636) @@ -243,8 +243,93 @@ .. _`wiki page` : https://realityforge.vrsource.org/view/PyppApi/TemplateSupport +--------------------------------------------------- +How to deal with template on return type functions? +--------------------------------------------------- +:: + struct environment_t{ + ... + template< class T> + T get_value(const std::string& name); + ... + }; + //Somewhere in your code + environment_t env; + std::string path = env.get_value< std::string >( "PATH" ); + int version = env.get_value< int >( "VERSION" ); + +`GCC-XML`_ will see both instantiations, ``get_value<int>`` and ``get_value< std::string >``, +and will provide information about them. The name of both member functions, +reported by `GCC-XML`_ is "**get_value**". + +In this case, `Py++`_ generates a code, which contains few errors and if your are +lucky, depends on the compiler you use, the generated code will not compile. +Otherwise, you will discover the errors while testing the bindings. + +Generated code: +:: + + bp::class_< environment_t >( "environment_t" ) + ... + .def( "get_value" + , (int ( ::environment_t::* )( ::std::string const & ) )( &::environment_t::get_value ) ) + .def( "get_value" + , (::std::string ( ::environment_t::* )( ::std::string const & ) )( &::environment_t::get_value ) ); + +The correct code: +:: + + bp::class_< environment_t >( "environment_t" ) + .def( "get_value" + , (int ( ::environment_t::* )( ::std::string const & ) )( &::environment_t::get_value< int > ) ) + //--------------------------------------------------------------------------^^^^^^^^^^^^^^^^ + .def( "get_value" + , (::std::string ( ::environment_t::* )( ::std::string const & ) )( &::environment_t::get_value< std::string > ) ); + //------------------------------------------------------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^ + +The perfect one: +:: + + bp::class_< environment_t >( "environment_t" ) + ... + .def( "get_value", &::environment_t::get_value< int > ) + .def( "get_value", &::environment_t::get_value< std::string > ); + +Solution +-------- +:: + + mb = module_builder_t( ..., optimize_queries=False, ... ) + environment = mb.class_( "environment_t" ) + for f in environment.member_functions( "get_value" ): + f.alias = f.name + "_" + f.return_type.decl_string #create new function alias + f.name = f.demangled_name + mb.run_query_optimizer() + +Before you read the rest of the answer, you should understand what is "name mangling" +means. If you don't, consider reading about it on `Wikipedia`__. + +.. __ : http://en.wikipedia.org/wiki/Name_mangling + + +The solution is pretty simple. `GCC-XML`_ reports mangled and demangled function +names. The demangled function name contains "real" function name: +``get_value< used type >``. You only have to instruct `Py++`_ to use it. + +`Py++`_ does not use by default demangled function name for mainly one reason. +Demangled function name is a string that contains a lot of information. `Py++`_ +implements a parser, which extracts the only relevant one. The parser +implementation is a little bit complex and was not heavily tested. By "heavily" I +mean that I tested it on a lot of crazy use cases and on a real project, but +there is always some new use case out there. I am almost sure it will work for +you. The problem, we deal with, is rare, so by default "demangled_name" +feature is turned off. + +By the way, almost the same problem exists for template classes. But, in the +classes use case `Py++`_ uses demangled name by default. + .. _`Py++` : ./../pyplusplus.html .. _`Boost.Python`: http://www.boost.org/libs/python/doc/index.html .. _`Python`: http://www.python.org This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2006-10-09 21:44:54
|
Revision: 635 http://svn.sourceforge.net/pygccxml/?rev=635&view=rev Author: allenb Date: 2006-10-09 14:44:47 -0700 (Mon, 09 Oct 2006) Log Message: ----------- Add some changes I have had sitting around for a long time and need to get in. Modified Paths: -------------- pyplusplus_dev/contrib/goodies/__init__.py pyplusplus_dev/contrib/goodies/goodie_utils.py Modified: pyplusplus_dev/contrib/goodies/__init__.py =================================================================== --- pyplusplus_dev/contrib/goodies/__init__.py 2006-10-09 20:37:05 UTC (rev 634) +++ pyplusplus_dev/contrib/goodies/__init__.py 2006-10-09 21:44:47 UTC (rev 635) @@ -11,7 +11,8 @@ import goodie_overrides from goodie_utils import (set_recursive_default, set_allow_empty_mdecl_default, - finalize, add_member_function, wrap_method, add_method, + finalize, decl_from_typedef, + add_member_function, wrap_method, add_method, is_const_ref, exclude_protected, wrap_const_ref_params, TemplateBuilder) Modified: pyplusplus_dev/contrib/goodies/goodie_utils.py =================================================================== --- pyplusplus_dev/contrib/goodies/goodie_utils.py 2006-10-09 20:37:05 UTC (rev 634) +++ pyplusplus_dev/contrib/goodies/goodie_utils.py 2006-10-09 21:44:47 UTC (rev 635) @@ -16,6 +16,8 @@ import copy import re +# TODO: +# - extend add_member_function to include method to add def set_recursive_default(val): pd.scopedef_t.RECURSIVE_DEFAULT = val @@ -23,6 +25,16 @@ def set_allow_empty_mdecl_default(val): pd.scopedef_t.ALLOW_EMPTY_MDECL_WRAPPER = val + +def decl_from_typedef(decl): + """ decl: decl or mdecl with typedef. Return the "real" decl. """ + typedef_decl = decl + if isinstance(typedef_decl, pd.mdecl_wrapper_t): + typedef_decl = decl[0] + assert isinstance(typedef_decl, pd.typedef_t) + return typedef_decl.type.declaration + + def finalize(cls): """ Attempt to finalize a class by not exposing virtual methods. Still exposes in the case of pure virtuals otherwise the class @@ -54,7 +66,6 @@ code_text = 'boost::python::def("%s",%s);'%(methodName, method) moduleBuilder.add_registration_code(code_text) - def is_const_ref(type): """ Extra trait tester method to check if something is a const reference. """ is_const = tt.is_const(type) or (hasattr(type,'base') and tt.is_const(type.base)) @@ -139,13 +150,13 @@ to allow access to the template at a later time. TODO: If used a form that allowed multiple templates to be specified - ex: TemplateWrapper("osg::vector", arguments=[["float","3"],["int","4"]] + ex: TemplateWrapper("OSG::vector", arguments=[["float","3"],["int","4"]] then how would we handle naming? Automatic or must be specified? """ def __init__(self, templateType, finalName = None): #, arguments=None): """ - templateType: Either a base type ("osg::vector") or a full template - type ("osg::vector<float>") + templateType: Either a base type ("OSG::vector") or a full template + type ("OSG::vector<float>") finalName: Name to rename the decl to after finding it. """ self.mTemplateType = templateType @@ -187,7 +198,7 @@ Usage: tb = TemplateBuilder() - vec3f_t = tb.Template("osg::vector<float,3>") + vec3f_t = tb.Template("OSG::vector<float,3>") # Add autogen code to a header that is included mb = moduble_builder_t([myheaders]) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2006-10-09 20:37:18
|
Revision: 634 http://svn.sourceforge.net/pygccxml/?rev=634&view=rev Author: roman_yakovenko Date: 2006-10-09 13:37:05 -0700 (Mon, 09 Oct 2006) Log Message: ----------- fixing bug in find properties algorithm Modified Paths: -------------- pyplusplus_dev/pyplusplus/decl_wrappers/properties.py pyplusplus_dev/unittests/data/properties_to_be_exported.hpp Modified: pyplusplus_dev/pyplusplus/decl_wrappers/properties.py =================================================================== --- pyplusplus_dev/pyplusplus/decl_wrappers/properties.py 2006-10-09 12:32:44 UTC (rev 633) +++ pyplusplus_dev/pyplusplus/decl_wrappers/properties.py 2006-10-09 20:37:05 UTC (rev 634) @@ -65,10 +65,10 @@ , ( '', 'set' ) ) def check_prefix( self, name, prefix ): - if len( prefix ) >= len( name ): - return False if not name.startswith( prefix ): return False + if len( name ) < len( prefix ): + return False return True def check_name_compatibility( self, gname, sname, gprefix, sprefix ): Modified: pyplusplus_dev/unittests/data/properties_to_be_exported.hpp =================================================================== --- pyplusplus_dev/unittests/data/properties_to_be_exported.hpp 2006-10-09 12:32:44 UTC (rev 633) +++ pyplusplus_dev/unittests/data/properties_to_be_exported.hpp 2006-10-09 20:37:05 UTC (rev 634) @@ -50,8 +50,8 @@ int GetType() const { return 0; } - float get() const; - void set(float); + float get() const{ return 0.1; } + void set(float){} }; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2006-10-09 12:32:52
|
Revision: 633 http://svn.sourceforge.net/pygccxml/?rev=633&view=rev Author: roman_yakovenko Date: 2006-10-09 05:32:44 -0700 (Mon, 09 Oct 2006) Log Message: ----------- adding properties documentation Added Paths: ----------- pyplusplus_dev/docs/documentation/properties.rest Added: pyplusplus_dev/docs/documentation/properties.rest =================================================================== --- pyplusplus_dev/docs/documentation/properties.rest (rev 0) +++ pyplusplus_dev/docs/documentation/properties.rest 2006-10-09 12:32:44 UTC (rev 633) @@ -0,0 +1,162 @@ +========== +Properties +========== + +.. contents:: Table of contents + +------------ +Introduction +------------ + +`Boost.Python`_ allows users to specify class properties. You can read about +this functionality in the `tutorials`_ or in the `reference manual`_. Since +version 0.8.2 `Py++`_ provides a convenient API to specify class properties. + +.. _`tutorials` : http://boost.org/libs/python/doc/tutorial/doc/html/python/exposing.html#python.class_properties +.. _`reference manual` : http://boost.org/libs/python/doc/v2/class.html + +------------- +Usage example +------------- +:: + + struct number{ + ... + float value() const; + void set_value( float ); + ... + private: + float m_value; + } + +:: + + mb = module_builder_t( ... ) + number = mb.class_( 'number' ) + number.add_property( 'ro_value', number.member_function( 'value' ) ) + number.add_property( 'value' + , number.member_function( 'value' ) + , number.member_function( 'set_value' ) ) + +This is rather the hard way to add properties to the class. `Py++`_ comes with +built-in algorithm, which automaticly recognizes properties and adds them to the +class: +:: + + mb = module_builder_t( ... ) + number = mb.class_( 'number' ) + number.add_properties( exclude_accessors=False ) #accessors will be exposed + +Small advise to you: try ``add_properties`` algorithm first, it should work. +If it doesn't than: + +* Please, bring your use case to the developers of `Py++`_, so we could improve + it + +* Switch to the ``add_property`` method for a while + +------------- +Call policies +------------- + +Consider next use case: + +:: + + struct nested{ ... }; + + struct data{ + ... + const nested& get_nested() const + { return m_nested; } + ... + private: + nested m_nested; + }; + +In order to expose ``get_nested`` member function you have to specify its +`call policies`_. Same precondition holds for exposing member function as +property: + +:: + + mb = module_builder_t( ... ) + get_nested = mb.member_function( 'get_nested' ) + get_nested.call_policies = call_policies.return_internal_reference() + mb.class_( 'data' ).add_properties() + +`Py++`_ will take the `call policies`_ information from the relevant accessor. + +.. _`call policies` : http://boost.org/libs/python/doc/tutorial/doc/html/python/functions.html#python.call_policies + +------------------------------ +Property recognition algorithm +------------------------------ + +Description +----------- + +In general the algorithm is very simple. `Py++`_ understands few coding +conventions. It is aware of few widely used get\\set prefixes. It scans the class +and its base classes for accessors and after this it tries to match between +"get" and "set" accessors. If there is "set" accessors, but there is no "get" +accessor, property will not be constructed. At least one accessor should belong +to the class. + +Find accessors +-------------- + +This part of the algorithm is responcible for finding all functions, which meet +get\\set accessors criteria. + +"get" accessor criteria +~~~~~~~~~~~~~~~~~~~~~~~ + +1. It does not have arguments. +2. It has return other than ``void``. +3. It does not modify the instance - has ``const`` attribute. + +"set" accessor criteria +~~~~~~~~~~~~~~~~~~~~~~~ + +1. It has only 1 argument. +2. Its return type is ``void``. +3. It do modify the instance - doesn't have ``const`` attribute. + +There are also few rules that applies on both accessor types: + +1. Accessor should be **included**. +2. Accessor should be "public". +3. It should not be static. +4. It should not be pure virtual. + + +Recognize property +------------------ + +This part of the algorithm is responcible to recognize the pair of "get" and "set" +accessors, which constructs the property. `Py++`_ does it by analizing name and +type of the accessors. + +`Py++`_ understands next coding conventions: + +* lowercase_with_underscors +* UpperCamel +* lowCamel + +It is also aware of few common prefixes for set\\get accessors: get, is, has, set, +<<empty prefix for get accessor>>. + +.. _`Py++` : ./../pyplusplus.html +.. _`Boost.Python`: http://www.boost.org/libs/python/doc/index.html +.. _`Python`: http://www.python.org +.. _`GCC-XML`: http://www.gccxml.org + +.. + Local Variables: + mode: indented-text + indent-tabs-mode: nil + sentence-end-double-space: t + fill-column: 70 + End: + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2006-10-09 08:51:32
|
Revision: 632 http://svn.sourceforge.net/pygccxml/?rev=632&view=rev Author: roman_yakovenko Date: 2006-10-09 01:51:10 -0700 (Mon, 09 Oct 2006) Log Message: ----------- adding new test cases for properties tester Modified Paths: -------------- pyplusplus_dev/pyplusplus/decl_wrappers/properties.py pyplusplus_dev/unittests/data/properties_to_be_exported.hpp pyplusplus_dev/unittests/properties_tester.py Modified: pyplusplus_dev/pyplusplus/decl_wrappers/properties.py =================================================================== --- pyplusplus_dev/pyplusplus/decl_wrappers/properties.py 2006-10-09 07:15:51 UTC (rev 631) +++ pyplusplus_dev/pyplusplus/decl_wrappers/properties.py 2006-10-09 08:51:10 UTC (rev 632) @@ -5,6 +5,7 @@ "defines property_t helper class" +import algorithm from pygccxml import declarations class property_t( object ): @@ -143,20 +144,27 @@ else: return False + def find_out_property_name( self, fget, prefix ): + if fget.name == prefix: + #use class name for property name + return algorithm.create_valid_name( fget.parent.name ) + else: + return fget.name[len(prefix):] + def create_property( self, fget, fset ): if not self.check_type_compatibility( fget, fset ): return None found = self.find_out_prefixes( fget.name, fset.name ) if not found: return None - return property_t( fget.name[len(found[0]):], fget, fset ) + return property_t( self.find_out_property_name( fget, found[0] ), fget, fset ) def create_read_only_property( self, fget ): found = self.find_out_ro_prefixes( fget.name ) if None is found: return None else: - return property_t( fget.name[len(found):], fget ) + return property_t( self.find_out_property_name( fget, found ), fget ) class properties_finder_t: def __init__( self, cls, recognizer=None, exclude_accessors=False ): Modified: pyplusplus_dev/unittests/data/properties_to_be_exported.hpp =================================================================== --- pyplusplus_dev/unittests/data/properties_to_be_exported.hpp 2006-10-09 07:15:51 UTC (rev 631) +++ pyplusplus_dev/unittests/data/properties_to_be_exported.hpp 2006-10-09 08:51:10 UTC (rev 632) @@ -50,6 +50,9 @@ int GetType() const { return 0; } + float get() const; + void set(float); + }; } Modified: pyplusplus_dev/unittests/properties_tester.py =================================================================== --- pyplusplus_dev/unittests/properties_tester.py 2006-10-09 07:15:51 UTC (rev 631) +++ pyplusplus_dev/unittests/properties_tester.py 2006-10-09 08:51:10 UTC (rev 632) @@ -36,8 +36,8 @@ cls = mb.class_( 'properties_finder_tester_t' ) cls.add_properties( exclude_accessors=True ) - print len( cls.properties ) - self.failUnless( 5 == len( cls.properties ) ) + self.failUnless( 6 == len( cls.properties ) ) + self.failUnless( cls.name in map( lambda pr: pr.name, cls.properties ) ) def run_tests(self, module): pt = module.properties_tester_t() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2006-10-09 07:15:57
|
Revision: 631 http://svn.sourceforge.net/pygccxml/?rev=631&view=rev Author: roman_yakovenko Date: 2006-10-09 00:15:51 -0700 (Mon, 09 Oct 2006) Log Message: ----------- removing commented code Modified Paths: -------------- pyplusplus_dev/pyplusplus/function_transformers/arg_policies.py Modified: pyplusplus_dev/pyplusplus/function_transformers/arg_policies.py =================================================================== --- pyplusplus_dev/pyplusplus/function_transformers/arg_policies.py 2006-10-09 06:59:23 UTC (rev 630) +++ pyplusplus_dev/pyplusplus/function_transformers/arg_policies.py 2006-10-09 07:15:51 UTC (rev 631) @@ -347,23 +347,3 @@ , 'ivar' : self.virtual_ivar , 'array_name' : self.argname } - - #~ res = "" - #~ res += "// Assert that the Python object corresponding to output\n" - #~ res += "// argument '%s' is really a sequence.\n"%self.argname - #~ res += "%s = %s;\n"%(self.virtual_pyval, sm.py_result_expr(self.argname)) - #~ res += "if (!PySequence_Check(%s.ptr()))\n"%self.virtual_pyval - #~ res += "{\n" - #~ res += ' PyErr_SetString(PyExc_ValueError, "%s: sequence expected as return value for output array \'%s\'");\n'%(sm.decl.name, self.argname) - #~ res += ' boost::python::throw_error_already_set();\n' - #~ res += "}\n" - #~ res += "// Assert that the sequence has the correct size\n" - #~ res += "if (PySequence_Length(%s.ptr())!=%s)\n"%(self.virtual_pyval, self.size) - #~ res += "{\n" - #~ res += ' PyErr_SetString(PyExc_ValueError, "%s: sequence with %s values expected as return value for output array \'%s\'");\n'%(sm.decl.name, self.size, self.argname) - #~ res += ' boost::python::throw_error_already_set();\n' - #~ res += "}\n" - #~ res += "// Copy the Python sequence into '%s'\n"%self.argname - #~ res += "for(%s=0; %s<%d; %s++)\n"%(self.virtual_ivar, self.virtual_ivar, self.size, self.virtual_ivar) - #~ res += " %s[%s] = boost::python::extract<%s>(%s[%s]);"%(self.argname, self.virtual_ivar, self.basetype, self.virtual_pyval, self.virtual_ivar) - #~ return res This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2006-10-09 06:59:35
|
Revision: 630 http://svn.sourceforge.net/pygccxml/?rev=630&view=rev Author: roman_yakovenko Date: 2006-10-08 23:59:23 -0700 (Sun, 08 Oct 2006) Log Message: ----------- switching to convenient API Modified Paths: -------------- pyplusplus_dev/pyplusplus/function_transformers/arg_policies.py pyplusplus_dev/unittests/function_transformations_tester.py Modified: pyplusplus_dev/pyplusplus/function_transformers/arg_policies.py =================================================================== --- pyplusplus_dev/pyplusplus/function_transformers/arg_policies.py 2006-10-09 06:46:30 UTC (rev 629) +++ pyplusplus_dev/pyplusplus/function_transformers/arg_policies.py 2006-10-09 06:59:23 UTC (rev 630) @@ -236,7 +236,6 @@ # Replace the input parameter with the C array sm.wrapper_func.input_params[self.idx-1] = self.carray - def wrapper_pre_call(self, sm): """Wrapper function code. """ @@ -252,7 +251,6 @@ , 'ivar' : self.wrapper_ivar , 'array_name' : self.carray } - return res def virtual_pre_call(self, sm): """Virtual function code. @@ -337,22 +335,35 @@ return res def virtual_post_call(self, sm): - res = "" - res += "// Assert that the Python object corresponding to output\n" - res += "// argument '%s' is really a sequence.\n"%self.argname - res += "%s = %s;\n"%(self.virtual_pyval, sm.py_result_expr(self.argname)) - res += "if (!PySequence_Check(%s.ptr()))\n"%self.virtual_pyval - res += "{\n" - res += ' PyErr_SetString(PyExc_ValueError, "%s: sequence expected as return value for output array \'%s\'");\n'%(sm.decl.name, self.argname) - res += ' boost::python::throw_error_already_set();\n' - res += "}\n" - res += "// Assert that the sequence has the correct size\n" - res += "if (PySequence_Length(%s.ptr())!=%s)\n"%(self.virtual_pyval, self.size) - res += "{\n" - res += ' PyErr_SetString(PyExc_ValueError, "%s: sequence with %s values expected as return value for output array \'%s\'");\n'%(sm.decl.name, self.size, self.argname) - res += ' boost::python::throw_error_already_set();\n' - res += "}\n" - res += "// Copy the Python sequence into '%s'\n"%self.argname - res += "for(%s=0; %s<%d; %s++)\n"%(self.virtual_ivar, self.virtual_ivar, self.size, self.virtual_ivar) - res += " %s[%s] = boost::python::extract<%s>(%s[%s]);"%(self.argname, self.virtual_ivar, self.basetype, self.virtual_pyval, self.virtual_ivar) - return res + tmpl = [] + tmpl.append( 'pyplusplus::convenience::ensure_uniform_sequence< %(type)s >( %(argname)s, %(size)d );' ) + tmpl.append( 'for(%(ivar)s=0; %(ivar)s<%(size)d; ++%(ivar)s){' ) + tmpl.append( ' %(array_name)s[ %(ivar)s ] = boost::python::extract< %(type)s >( %(argname)s[%(ivar)s] );' ) + tmpl.append( '}' ) + return os.linesep.join( tmpl ) % { + 'type' : self.basetype + , 'argname' : sm.py_result_expr(self.argname) + , 'size' : self.size + , 'ivar' : self.virtual_ivar + , 'array_name' : self.argname + } + + #~ res = "" + #~ res += "// Assert that the Python object corresponding to output\n" + #~ res += "// argument '%s' is really a sequence.\n"%self.argname + #~ res += "%s = %s;\n"%(self.virtual_pyval, sm.py_result_expr(self.argname)) + #~ res += "if (!PySequence_Check(%s.ptr()))\n"%self.virtual_pyval + #~ res += "{\n" + #~ res += ' PyErr_SetString(PyExc_ValueError, "%s: sequence expected as return value for output array \'%s\'");\n'%(sm.decl.name, self.argname) + #~ res += ' boost::python::throw_error_already_set();\n' + #~ res += "}\n" + #~ res += "// Assert that the sequence has the correct size\n" + #~ res += "if (PySequence_Length(%s.ptr())!=%s)\n"%(self.virtual_pyval, self.size) + #~ res += "{\n" + #~ res += ' PyErr_SetString(PyExc_ValueError, "%s: sequence with %s values expected as return value for output array \'%s\'");\n'%(sm.decl.name, self.size, self.argname) + #~ res += ' boost::python::throw_error_already_set();\n' + #~ res += "}\n" + #~ res += "// Copy the Python sequence into '%s'\n"%self.argname + #~ res += "for(%s=0; %s<%d; %s++)\n"%(self.virtual_ivar, self.virtual_ivar, self.size, self.virtual_ivar) + #~ res += " %s[%s] = boost::python::extract<%s>(%s[%s]);"%(self.argname, self.virtual_ivar, self.basetype, self.virtual_pyval, self.virtual_ivar) + #~ return res Modified: pyplusplus_dev/unittests/function_transformations_tester.py =================================================================== --- pyplusplus_dev/unittests/function_transformations_tester.py 2006-10-09 06:46:30 UTC (rev 629) +++ pyplusplus_dev/unittests/function_transformations_tester.py 2006-10-09 06:59:23 UTC (rev 630) @@ -65,10 +65,6 @@ # Check the fixed_input_array method self.assertEqual(img.fixed_input_array([1,2,3]), 6) self.assertEqual(img.fixed_input_array((1,2,3)), 6) - self.assertRaises(ValueError, lambda : img.fixed_input_array([1,2,3,4])) - self.assertRaises(ValueError, lambda : img.fixed_input_array([1,2])) - self.assertRaises(TypeError, lambda : img.fixed_input_array(1)) - self.assertRaises(TypeError, lambda : img.fixed_input_array(None)) # Check the fixed_output_array method self.assertEqual(img.fixed_output_array(), [1,2,3]) @@ -111,7 +107,7 @@ # Check if fixed_output_array() is correctly called from C++ self.assertEqual(module.image_fixed_output_array(pyimg1), 14) pyimg1.fixed_output_array_mode = 1 - self.assertRaises(ValueError, lambda : module.image_fixed_output_array(pyimg1)) + self.assertRaises(TypeError, lambda : module.image_fixed_output_array(pyimg1)) pyimg1.fixed_output_array_mode = 2 self.assertRaises(ValueError, lambda : module.image_fixed_output_array(pyimg1)) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2006-10-09 06:46:41
|
Revision: 629 http://svn.sourceforge.net/pygccxml/?rev=629&view=rev Author: roman_yakovenko Date: 2006-10-08 23:46:30 -0700 (Sun, 08 Oct 2006) Log Message: ----------- switching to convenient API Modified Paths: -------------- pyplusplus_dev/pyplusplus/code_creators/calldef_transformed.py pyplusplus_dev/pyplusplus/function_transformers/arg_policies.py pyplusplus_dev/unittests/function_transformations_tester.py Modified: pyplusplus_dev/pyplusplus/code_creators/calldef_transformed.py =================================================================== --- pyplusplus_dev/pyplusplus/code_creators/calldef_transformed.py 2006-10-08 11:30:57 UTC (rev 628) +++ pyplusplus_dev/pyplusplus/code_creators/calldef_transformed.py 2006-10-09 06:46:30 UTC (rev 629) @@ -17,7 +17,7 @@ class mem_fun_transformed_t( calldef_t ): """Creates code for public non-virtual member functions. """ - + def __init__( self, function, wrapper=None ): calldef_t.__init__( self, function=function, wrapper=wrapper ) @@ -34,7 +34,7 @@ full_name = self.wrapper.full_name() else: full_name = declarations.full_name( self.declaration ) - + if use_function_alias: return '%s( &%s )' \ % ( self.function_type_alias, full_name ) @@ -93,7 +93,7 @@ """Return the name of the wrapper function. This is just the local name without any scope information. - + """ # A list with the individual components of the name components = ["_py"] @@ -103,7 +103,7 @@ components.append(self.declaration.parent.name) components.append(self.declaration.alias) return "_".join(components) - + def full_name(self): """Return the full name of the wrapper function. @@ -143,11 +143,11 @@ $DECLARATIONS $PRE_CALL - + $RESULT_VAR_ASSIGNMENT$CALL_FUNC_NAME($INPUT_PARAMS); - + $POST_CALL - + $RETURN_STMT """ @@ -170,7 +170,7 @@ return os.linesep.join( answer ) def _create_impl(self): - + answer = self.create_function() # Replace the argument list of the declaration so that in the @@ -186,7 +186,7 @@ class mem_fun_v_transformed_t( calldef_t ): """Creates code for (public) virtual member functions. """ - + def __init__( self, function, wrapper=None ): calldef_t.__init__( self, function=function, wrapper=wrapper ) self.default_function_type_alias = 'default_' + self.function_type_alias @@ -340,7 +340,7 @@ def create_virtual_body(self): thread_safe = getattr(self.declaration, "thread_safe", False) - + if thread_safe: body = """ pyplusplus::threading::gil_guard_t %(gstate_var)s; @@ -356,14 +356,14 @@ $DECLARATIONS - try { + try { $PRE_CALL - + ${RESULT_VAR_ASSIGNMENT}boost::python::call<$RESULT_TYPE>($INPUT_PARAMS); - - $POST_CALL - $RETURN_STMT + $POST_CALL + + $RETURN_STMT } catch(...) { @@ -371,9 +371,9 @@ { PyErr_Print(); } - + $CLEANUP - + $EXCEPTION_HANDLER_EXIT } } @@ -390,7 +390,7 @@ if( %(override_var)s ) { $DECLARATIONS - + $PRE_CALL ${RESULT_VAR_ASSIGNMENT}boost::python::call<$RESULT_TYPE>($INPUT_PARAMS); @@ -436,7 +436,7 @@ cls_wrapper = self._subst_manager.wrapper_func.declare_local("cls_wrapper", cls_wrapper_type); # The name of the 'self' variable (i.e. first argument) selfname = self._subst_manager.wrapper_func.arg_list[0].name - + body = """$DECLARATIONS $PRE_CALL @@ -468,7 +468,7 @@ "cls_wrapper" : cls_wrapper, "self" : selfname, "base_name" : self.base_name() } - + # function_call = declarations.call_invocation.join( self.declaration.name # , [ self.function_call_args() ] ) # body = self.wrapped_class_identifier() + '::' + function_call + ';' @@ -493,7 +493,7 @@ header = 'static $RET_TYPE %s( $ARG_LIST_DEF ) {'%self.default_name() header = self._subst_manager.subst_wrapper(header) - + answer = [ header ] answer.append( self.indent( self.create_default_body() ) ) answer.append( '}' ) @@ -501,13 +501,13 @@ def get_required_headers(self): """Return a list of required header file names.""" - res = [code_repository.gil_guard.file_name] + res = [code_repository.gil_guard.file_name, code_repository.convenience.file_name ] res += self._subst_manager.virtual_func.get_required_headers() res += self._subst_manager.wrapper_func.get_required_headers() return res def _create_impl(self): - + answer = [ self.create_function() ] answer.append( os.linesep ) answer.append( self.create_base_function() ) Modified: pyplusplus_dev/pyplusplus/function_transformers/arg_policies.py =================================================================== --- pyplusplus_dev/pyplusplus/function_transformers/arg_policies.py 2006-10-08 11:30:57 UTC (rev 628) +++ pyplusplus_dev/pyplusplus/function_transformers/arg_policies.py 2006-10-09 06:46:30 UTC (rev 629) @@ -15,7 +15,7 @@ - L{input_array_t} - L{output_array_t} """ - +import os from pygccxml import declarations # output_t @@ -27,7 +27,7 @@ void getValue(int& v) -> v = getValue() """ - + def __init__(self, idx): """Constructor. @@ -64,7 +64,7 @@ else: sm.wrapper_func.input_params[self.idx-1] = self.local_var - + def virtual_post_call(self, sm): """Extract the C++ value after the call to the Python function. """ @@ -84,7 +84,7 @@ void setValue(int& v) -> setValue(v) """ - + def __init__(self, idx): """Constructor. @@ -101,7 +101,7 @@ def init_funcs(self, sm): # Remove the specified input argument from the wrapper function arg = sm.remove_arg(self.idx) - + # Do some checks (the arg has to be a reference or a pointer) reftype = arg.type if not (isinstance(reftype, declarations.reference_t) or @@ -119,7 +119,7 @@ void foo(int& v) -> v = foo(v) """ - + def __init__(self, idx): """Constructor. @@ -137,7 +137,7 @@ def init_funcs(self, sm): # Remove the specified input argument from the wrapper function arg = sm.remove_arg(self.idx) - + # Do some checks (the arg has to be a reference or a pointer) reftype = arg.type if not (isinstance(reftype, declarations.reference_t) or @@ -160,7 +160,7 @@ else: sm.wrapper_func.input_params[self.idx-1] = self.local_var - + def virtual_post_call(self, sm): """Extract the C++ value after the call to the Python function. """ @@ -182,9 +182,9 @@ TODO: Error handling (in the wrapper function)! - + """ - + def __init__(self, idx, size): """Constructor. @@ -205,12 +205,12 @@ def __str__(self): return "InputArray(%d,%d)"%(self.idx, self.size) - + def init_funcs(self, sm): # Remove the original argument... arg = sm.remove_arg(self.idx) - + if not (isinstance(arg.type, declarations.pointer_t) or isinstance(arg.type, declarations.array_t)): raise ValueError, "%s\nArgument %d (%s) must be a pointer."%(sm.decl, self.idx, arg.name) @@ -240,21 +240,18 @@ def wrapper_pre_call(self, sm): """Wrapper function code. """ - res = "" - res += "// Assert that '%s' is really a sequence...\n"%self.argname - res += "if (!PySequence_Check(%s.ptr()))\n"%self.argname - res += "{\n" - res += ' PyErr_SetString(PyExc_ValueError, "Argument %s: sequence expected");\n'%self.argname - res += ' boost::python::throw_error_already_set();\n' - res += "}\n" - res += "// Copy the sequence '%s' into '%s'...\n"%(self.argname, self.carray) - res += 'if (%s.attr("__len__")()!=%d)\n'%(self.argname, self.size) - res += '{\n' - res += ' PyErr_SetString(PyExc_ValueError, "Invalid sequence size (expected %d)");\n'%self.size - res += ' boost::python::throw_error_already_set();\n' - res += '}\n' - res += "for(%s=0; %s<%d; %s++)\n"%(self.wrapper_ivar, self.wrapper_ivar, self.size, self.wrapper_ivar) - res += " %s[%s] = boost::python::extract< %s >(%s[%s]);"%(self.carray, self.wrapper_ivar, self.basetype, self.argname , self.wrapper_ivar) + tmpl = [] + tmpl.append( 'pyplusplus::convenience::ensure_uniform_sequence< %(type)s >( %(argname)s, %(size)d );' ) + tmpl.append( 'for(%(ivar)s=0; %(ivar)s<%(size)d; ++%(ivar)s){' ) + tmpl.append( ' %(array_name)s[ %(ivar)s ] = boost::python::extract< %(type)s >( %(argname)s[%(ivar)s] );' ) + tmpl.append( '}' ) + return os.linesep.join( tmpl ) % { + 'type' : self.basetype + , 'argname' : self.argname + , 'size' : self.size + , 'ivar' : self.wrapper_ivar + , 'array_name' : self.carray + } return res def virtual_pre_call(self, sm): @@ -272,12 +269,12 @@ """Handles an output array of a fixed size. void getVec3(double* v) -> v = getVec3() - # v will be a list with 3 floats + # v will be a list with 3 floats TODO: Error handling (in the virtual function)! - + """ - + def __init__(self, idx, size): """Constructor. @@ -289,7 +286,7 @@ self.idx = idx self.size = size - + self.argname = None self.basetype = None self.pyval = None @@ -302,7 +299,7 @@ def init_funcs(self, sm): # Remove the original argument... arg = sm.remove_arg(self.idx) - + if not (isinstance(arg.type, declarations.pointer_t) or isinstance(arg.type, declarations.array_t)): raise ValueError, "%s\nArgument %d (%s) must be a pointer."%(sm.decl, self.idx, arg.name) @@ -328,7 +325,7 @@ # Declare a variable that will receive the Python list self.virtual_pyval = sm.virtual_func.declare_local("py_"+self.argname, "boost::python::object") - + # Declare an int which is used for the loop self.virtual_ivar = sm.virtual_func.declare_local("i", "int", default=0) Modified: pyplusplus_dev/unittests/function_transformations_tester.py =================================================================== --- pyplusplus_dev/unittests/function_transformations_tester.py 2006-10-08 11:30:57 UTC (rev 628) +++ pyplusplus_dev/unittests/function_transformations_tester.py 2006-10-09 06:46:30 UTC (rev 629) @@ -67,8 +67,8 @@ self.assertEqual(img.fixed_input_array((1,2,3)), 6) self.assertRaises(ValueError, lambda : img.fixed_input_array([1,2,3,4])) self.assertRaises(ValueError, lambda : img.fixed_input_array([1,2])) - self.assertRaises(ValueError, lambda : img.fixed_input_array(1)) - self.assertRaises(ValueError, lambda : img.fixed_input_array(None)) + self.assertRaises(TypeError, lambda : img.fixed_input_array(1)) + self.assertRaises(TypeError, lambda : img.fixed_input_array(None)) # Check the fixed_output_array method self.assertEqual(img.fixed_output_array(), [1,2,3]) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mb...@us...> - 2006-10-08 11:31:25
|
Revision: 628 http://svn.sourceforge.net/pygccxml/?rev=628&view=rev Author: mbaas Date: 2006-10-08 04:30:57 -0700 (Sun, 08 Oct 2006) Log Message: ----------- Added a new filter to filter by virtuality. Modified Paths: -------------- pyplusplus_dev/contrib/pypp_api/pypp_api/__init__.py pyplusplus_dev/contrib/pypp_api/pypp_api/decltypes.py pyplusplus_dev/contrib/pypp_api/pypp_api/declwrapper.py pyplusplus_dev/contrib/pypp_api/pypp_api/filters.py Modified: pyplusplus_dev/contrib/pypp_api/pypp_api/__init__.py =================================================================== --- pyplusplus_dev/contrib/pypp_api/pypp_api/__init__.py 2006-10-08 08:08:28 UTC (rev 627) +++ pyplusplus_dev/contrib/pypp_api/pypp_api/__init__.py 2006-10-08 11:30:57 UTC (rev 628) @@ -67,7 +67,7 @@ PROTECTED = ACCESS_TYPES.PROTECTED PRIVATE = ACCESS_TYPES.PRIVATE -from decltypes import arg, cpp +from decltypes import * #from argpolicy import * from pyplusplus.function_transformers.arg_policies import output_t as Output from pyplusplus.function_transformers.arg_policies import input_t as Input Modified: pyplusplus_dev/contrib/pypp_api/pypp_api/decltypes.py =================================================================== --- pyplusplus_dev/contrib/pypp_api/pypp_api/decltypes.py 2006-10-08 08:08:28 UTC (rev 627) +++ pyplusplus_dev/contrib/pypp_api/pypp_api/decltypes.py 2006-10-08 11:30:57 UTC (rev 628) @@ -21,6 +21,11 @@ CALLABLE = METHOD | FUNCTION | CONSTRUCTOR CLASS_MEMBER = METHOD | CONSTRUCTOR | VARIABLE | ENUM +NON_VIRTUAL = 0x01 +NON_PURE_VIRTUAL = 0x02 +PURE_VIRTUAL = 0x04 +VIRTUAL = NON_PURE_VIRTUAL | PURE_VIRTUAL + # cpp class cpp: """This class wraps C++ source code for default values. Modified: pyplusplus_dev/contrib/pypp_api/pypp_api/declwrapper.py =================================================================== --- pyplusplus_dev/contrib/pypp_api/pypp_api/declwrapper.py 2006-10-08 08:08:28 UTC (rev 627) +++ pyplusplus_dev/contrib/pypp_api/pypp_api/declwrapper.py 2006-10-08 11:30:57 UTC (rev 628) @@ -417,6 +417,7 @@ headerdir=None, accesstype=None, const=None, + virtuality=None, filter=None, recursive=None, allow_empty=None, @@ -471,6 +472,8 @@ @param accesstype: Access type (PUBLIC or PROTECTED). This implies the type flags CLASS_MEMBER. @param const: Select declarations by their constness. @type const: bool + @param virtuality: Select declarations by their virtuality. This implies the type flags CLASS_MEMBER: + @type virtuality: Virtuality flags @param filter: User defined filter function @type callable @param recursive: Extend the search to grandchildren? If not specified, a global (customizable) default value is used. @@ -529,6 +532,10 @@ # const filter if const!=None: addFilter(const, ConstFilter) + # virtuality filter + if virtuality!=None: + addFilter(virtuality, VirtualityFilter) + itype |= CLASS_MEMBER # custom filters if filter!=None: if _type(filter)==list: Modified: pyplusplus_dev/contrib/pypp_api/pypp_api/filters.py =================================================================== --- pyplusplus_dev/contrib/pypp_api/pypp_api/filters.py 2006-10-08 08:08:28 UTC (rev 627) +++ pyplusplus_dev/contrib/pypp_api/pypp_api/filters.py 2006-10-08 11:30:57 UTC (rev 628) @@ -461,6 +461,45 @@ const = bool(getattr(decl, "has_const", False)) return const==self.constness +# VirtualityFilter +class VirtualityFilter(FilterBase): + """Filter by virtuality. + """ + + def __init__(self, virtuality_flags): + """Constructor. + + virtuality_flags is a combination of the flags NON_VIRTUAL, + NON_PURE_VIRTUAL, PURE_VIRTUAL and VIRTUAL. + """ + FilterBase.__init__(self) + self.virtuality_flags = virtuality_flags + + def __str__(self): + f = [] + if self.virtuality_flags & NON_VIRTUAL: + f.append("non-virtual") + if self.virtuality_flags & NON_PURE_VIRTUAL: + f.append("non-pure virtual") + if self.virtuality_flags & PURE_VIRTUAL: + f.append("pure virtual") + + v = "|".join(f) + return "virtuality==%s"%v + + def __call__(self, decl): + v = getattr(decl, "virtuality", None) + if v==None: + return False + vf = self.virtuality_flags + if vf&NON_VIRTUAL and v==VIRTUALITY_TYPES.NOT_VIRTUAL: + return True + elif vf&NON_PURE_VIRTUAL and v==VIRTUALITY_TYPES.VIRTUAL: + return True + elif vf&PURE_VIRTUAL and v==VIRTUALITY_TYPES.PURE_VIRTUAL: + return True + return False + # CustomFilter class CustomFilter(FilterBase): """Filter by user defined function. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2006-10-08 08:08:38
|
Revision: 627 http://svn.sourceforge.net/pygccxml/?rev=627&view=rev Author: roman_yakovenko Date: 2006-10-08 01:08:28 -0700 (Sun, 08 Oct 2006) Log Message: ----------- updating history Modified Paths: -------------- pyplusplus_dev/docs/history/history.rest pyplusplus_dev/pyplusplus/module_builder/builder.py Modified: pyplusplus_dev/docs/history/history.rest =================================================================== --- pyplusplus_dev/docs/history/history.rest 2006-10-08 07:03:05 UTC (rev 626) +++ pyplusplus_dev/docs/history/history.rest 2006-10-08 08:08:28 UTC (rev 627) @@ -36,18 +36,44 @@ Version 0.8.* ------------- -1. Performance improvments. In some cases you can get x10 performance boost. - Many thanks to Allen Bierbaum! +1. Interface changes: -2. Convinience API for registering exception translator was introduced. + * ``module_builder.module_builder_t.build_code_creator`` method: + argument ``create_castinig_constructor`` was removed and deprecation warning + was introduced. -3. `Py++`_ can generate code that uses ``BOOST_PYTHON_FUNCTION_OVERLOADS`` and +2. Performance improvments. In some cases you can get x10 performance boost. + Many thanks to Allen Bierbaum! This was achieved by saving and reusing results + of different `pygccxml`_ algorithms and type traits functions. + +3. Convinience API for registering exception translator was introduced. + +4. `Py++`_ can generate code that uses ``BOOST_PYTHON_FUNCTION_OVERLOADS`` and ``BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS`` macros. -4. Treatment to previously generated and no more in-use files was added. By +5. Treatment to previously generated and no more in-use files was added. By default `Py++`_ will delete these files, but of course you can redefine this behaviour. +6. Generated code changes: + + * ``default_call_policies`` should not be generated any more. + + * For functions that have ``return_value_policy< return_opaque_pointer >`` + call policy, `Py++`_ will automaticly generate ``BOOST_PYTHON_OPAQUE_SPECIALIZED_TYPE_ID`` + macro. Thank you very much for Gottfried Ganssauge for this idea. + +7. Support for Boost.Python properties was introduced. `Py++`_ implements small + algorithm, that will automaticly discover properties, base on naming conventions. + +8. ``decl_wrappers.class_t`` has new function: ``is_wrapper_needed``. This + function explains why `Py++`_ creates class wrapper for exposed class. + +9. Python type traits module was introduce. Today it contains only single function: + + * ``is_immutable`` - returns ``True`` if exposed type is Python immutable type + + ------------- Version 0.8.1 ------------- Modified: pyplusplus_dev/pyplusplus/module_builder/builder.py =================================================================== --- pyplusplus_dev/pyplusplus/module_builder/builder.py 2006-10-08 07:03:05 UTC (rev 626) +++ pyplusplus_dev/pyplusplus/module_builder/builder.py 2006-10-08 08:08:28 UTC (rev 627) @@ -226,15 +226,15 @@ and returns documentation string @type doc_extractor: callable or None """ - msg = os.linesep.join([ - "create_casting_constructor argument is deprecated and should not be used." - , "If you still want Py++ to generate implicitly_convertible code, consider to use allow_implicit_conversion constructor property" - , "mb = module_builder_t(...)" - , "mb.constructors().allow_implicit_conversion = True"]) - warnings.warn(msg, DeprecationWarning, stacklevel=2) + if not create_casting_constructor: + msg = os.linesep.join([ + "create_casting_constructor argument is deprecated." + , "If want to disable boost::python::implicitly_convertible code generation, consider to use allow_implicit_conversion constructor property" + , ">>> mb = module_builder_t(...)" + , ">>> mb.constructors().allow_implicit_conversion = False"]) + warnings.warn(msg, DeprecationWarning, stacklevel=2) - if create_casting_constructor: - self.global_ns.constructors(allow_empty=True).allow_implicit_conversion = True + self.global_ns.constructors(allow_empty=True).allow_implicit_conversion = False creator = mcreator_package.creator_t( self.global_ns , module_name This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2006-10-08 07:03:15
|
Revision: 626 http://svn.sourceforge.net/pygccxml/?rev=626&view=rev Author: roman_yakovenko Date: 2006-10-08 00:03:05 -0700 (Sun, 08 Oct 2006) Log Message: ----------- updating history Modified Paths: -------------- pygccxml_dev/docs/history/history.rest Modified: pygccxml_dev/docs/history/history.rest =================================================================== --- pygccxml_dev/docs/history/history.rest 2006-10-08 07:02:35 UTC (rev 625) +++ pygccxml_dev/docs/history/history.rest 2006-10-08 07:03:05 UTC (rev 626) @@ -27,6 +27,37 @@ some important bug in ``type_traits.__remove_alias`` function, by introducing small example that reproduced the error. +2. Huge speed improvment has been achieved( x10 ). Allen Bierbaum suggested to + save and reuse results of different `pygccxml`_ algorithms: + + * ``declarations.remove_alias`` + * ``declarations.full_name`` + * ``declarations.access_type`` + * ``declarations.demangled_name`` + * ``declarations.declaration_path`` + +3. Interface changes: + + * ``declarations.class_t``: + + + ``set_members`` method was removed + + + ``adopt_declaration`` method was introduced, instead of ``set_members`` + + * ``declarations.array_t`` class "set" accessor for size property was added. + + * ``declarations.namespace_t.adopt_declaration`` method was added. + + * ``declarations.variable_t.access_type`` property was added. + +4. New type traits have been added: + + * ``is_same_function`` + +5. Few bug were fixed. + +6. Documentation was improved. + ------------- Version 0.8.1 ------------- This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2006-10-08 07:02:43
|
Revision: 625 http://svn.sourceforge.net/pygccxml/?rev=625&view=rev Author: roman_yakovenko Date: 2006-10-08 00:02:35 -0700 (Sun, 08 Oct 2006) Log Message: ----------- removing dead code Modified Paths: -------------- pygccxml_dev/pygccxml/declarations/declaration.py Modified: pygccxml_dev/pygccxml/declarations/declaration.py =================================================================== --- pygccxml_dev/pygccxml/declarations/declaration.py 2006-10-05 07:43:48 UTC (rev 624) +++ pygccxml_dev/pygccxml/declarations/declaration.py 2006-10-08 07:02:35 UTC (rev 625) @@ -150,12 +150,6 @@ return self._name def _get_name( self ): - #if self._cached_name: - # assert self._get_name_impl() == self._cached_name - # return self._cached_name - #else: - # self._cached_name = self._get_name_impl() - # return self._cached_name return self._get_name_impl() def _on_rename( self ): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2006-10-05 07:43:54
|
Revision: 624 http://svn.sourceforge.net/pygccxml/?rev=624&view=rev Author: roman_yakovenko Date: 2006-10-05 00:43:48 -0700 (Thu, 05 Oct 2006) Log Message: ----------- replace Py_size_t with ssize_t Modified Paths: -------------- pyplusplus_dev/pyplusplus/code_repository/convenience.py Modified: pyplusplus_dev/pyplusplus/code_repository/convenience.py =================================================================== --- pyplusplus_dev/pyplusplus/code_repository/convenience.py 2006-10-05 07:17:04 UTC (rev 623) +++ pyplusplus_dev/pyplusplus/code_repository/convenience.py 2006-10-05 07:43:48 UTC (rev 624) @@ -32,14 +32,14 @@ } inline void -ensure_sequence( boost::python::object seq, Py_ssize_t expected_length=-1 ){ +ensure_sequence( boost::python::object seq, boost::python::ssize_t expected_length=-1 ){ PyObject* seq_impl = seq.ptr(); if( !PySequence_Check( seq_impl ) ){ raise_error( PyExc_TypeError, "Sequence expected" ); } - Py_ssize_t length = PySequence_Length( seq_impl ); + boost::python::ssize_t length = PySequence_Length( seq_impl ); if( expected_length != -1 && length != expected_length ){ std::stringstream err; err << "Expected sequence length is " << expected_length << ". " @@ -49,11 +49,11 @@ } template< class ExpectedType > -void ensure_uniform_sequence( boost::python::object seq, Py_ssize_t expected_length=-1 ){ +void ensure_uniform_sequence( boost::python::object seq, boost::python::ssize_t expected_length=-1 ){ ensure_sequence( seq, expected_length ); - Py_ssize_t length = boost::python::len( seq ); - for( Py_ssize_t index = 0; index < length; ++index ){ + boost::python::ssize_t length = boost::python::len( seq ); + for( boost::python::ssize_t index = 0; index < length; ++index ){ boost::python::object item = seq[index]; boost::python::extract<ExpectedType> type_checker( item ); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2006-10-05 07:17:19
|
Revision: 623 http://svn.sourceforge.net/pygccxml/?rev=623&view=rev Author: roman_yakovenko Date: 2006-10-05 00:17:04 -0700 (Thu, 05 Oct 2006) Log Message: ----------- adding unit tests for convenience functions improving convenience functions error reporting Modified Paths: -------------- pyplusplus_dev/pyplusplus/code_repository/convenience.py pyplusplus_dev/unittests/test_all.py Added Paths: ----------- pyplusplus_dev/unittests/convenience_tester.py pyplusplus_dev/unittests/data/convenience_to_be_exported.hpp Modified: pyplusplus_dev/pyplusplus/code_repository/convenience.py =================================================================== --- pyplusplus_dev/pyplusplus/code_repository/convenience.py 2006-10-05 06:23:06 UTC (rev 622) +++ pyplusplus_dev/pyplusplus/code_repository/convenience.py 2006-10-05 07:17:04 UTC (rev 623) @@ -23,18 +23,16 @@ #include "boost/python.hpp" -//1 - dimension namespace pyplusplus{ namespace convenience{ -void raise_error( PyObject *exception, const char *message ){ - +inline void +raise_error( PyObject *exception, const char *message ){ PyErr_SetString(exception, message); boost::python::throw_error_already_set(); - } -void ensure_sequence( boost::python::object seq, Py_ssize_t expected_length=-1 ){ - +inline void +ensure_sequence( boost::python::object seq, Py_ssize_t expected_length=-1 ){ PyObject* seq_impl = seq.ptr(); if( !PySequence_Check( seq_impl ) ){ @@ -48,27 +46,32 @@ << "Actual sequence length is " << length << "."; raise_error( PyExc_ValueError, err.str().c_str() ); } - } template< class ExpectedType > void ensure_uniform_sequence( boost::python::object seq, Py_ssize_t expected_length=-1 ){ + ensure_sequence( seq, expected_length ); - ensure_sequence( seq, expected_length ); Py_ssize_t length = boost::python::len( seq ); for( Py_ssize_t index = 0; index < length; ++index ){ boost::python::object item = seq[index]; + boost::python::extract<ExpectedType> type_checker( item ); - if( type_checker.check() ){ - const boost::python::type_info expected_type_info( boost::python::type_id<ExpectedType>() ); - //TODO: How to extract type_info from PyObject? + if( !type_checker.check() ){ + std::string expected_type_name( boost::python::type_id<ExpectedType>().name() ); + + std::string item_type_name("different"); + PyObject* item_impl = item.ptr(); + if( item_impl && item_impl->ob_type && item_impl->ob_type->tp_name ){ + item_type_name = std::string( item_impl->ob_type->tp_name ); + } + std::stringstream err; - err << "Sequence should contain only items with type \"" << expected_type_info.name() << "\". " - << "Item at position " << index << " has different type."; + err << "Sequence should contain only items with type \\"" << expected_type_name << "\\". " + << "Item at position " << index << " has \\"" << item_type_name << "\\" type."; raise_error( PyExc_ValueError, err.str().c_str() ); } } - } } /*pyplusplus*/ } /*convenience*/ Added: pyplusplus_dev/unittests/convenience_tester.py =================================================================== --- pyplusplus_dev/unittests/convenience_tester.py (rev 0) +++ pyplusplus_dev/unittests/convenience_tester.py 2006-10-05 07:17:04 UTC (rev 623) @@ -0,0 +1,48 @@ +# Copyright 2004 Roman Yakovenko. +# Distributed under the Boost Software License, Version 1.0. (See +# accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) + +import os +import sys +import unittest +import fundamental_tester_base + +from pyplusplus import code_repository + +class tester_t(fundamental_tester_base.fundamental_tester_base_t): + EXTENSION_NAME = 'convenience' + + def __init__( self, *args ): + fundamental_tester_base.fundamental_tester_base_t.__init__( + self + , tester_t.EXTENSION_NAME + , *args ) + + def customize(self, mb ): + mb.add_registration_code( 'bp::def( "ensure_sequence", &pyplusplus::convenience::ensure_sequence );' ) + mb.add_registration_code( 'bp::def( "ensure_int_sequence", &pyplusplus::convenience::ensure_uniform_sequence<int> );' ) + mb.build_code_creator( self.EXTENSION_NAME ) + + mb.code_creator.add_include( "__convenience.pypp.hpp" ) + mb.code_creator.add_system_header( code_repository.convenience.file_name ) + + def run_tests(self, module): + self.failIfRaisesAny( module.ensure_sequence, [1,2,3], -1 ) + self.failIfRaisesAny( module.ensure_sequence, [1,2,3], 3 ) + self.failIfNotRaisesAny( module.ensure_sequence, self, 1 ) + self.failIfRaisesAny( module.ensure_int_sequence, [1,2,3], -1 ) + self.failIfRaisesAny( module.ensure_int_sequence, [1,2,3], 3 ) + self.failIfNotRaisesAny( module.ensure_int_sequence, [self], 1 ) + self.failIfNotRaisesAny( module.ensure_int_sequence, [1,2.1,3] , 3 ) + +def create_suite(): + suite = unittest.TestSuite() + suite.addTest( unittest.makeSuite(tester_t)) + return suite + +def run_suite(): + unittest.TextTestRunner(verbosity=2).run( create_suite() ) + +if __name__ == "__main__": + run_suite() Added: pyplusplus_dev/unittests/data/convenience_to_be_exported.hpp =================================================================== --- pyplusplus_dev/unittests/data/convenience_to_be_exported.hpp (rev 0) +++ pyplusplus_dev/unittests/data/convenience_to_be_exported.hpp 2006-10-05 07:17:04 UTC (rev 623) @@ -0,0 +1,10 @@ +// Copyright 2004 Roman Yakovenko. +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef __convenience_to_be_exported_hpp__ +#define __convenience_to_be_exported_hpp__ + + +#endif//__convenience_to_be_exported_hpp__ Modified: pyplusplus_dev/unittests/test_all.py =================================================================== --- pyplusplus_dev/unittests/test_all.py 2006-10-05 06:23:06 UTC (rev 622) +++ pyplusplus_dev/unittests/test_all.py 2006-10-05 07:17:04 UTC (rev 623) @@ -64,6 +64,7 @@ import split_module_tester import properties_tester import arrays_bug_tester +import convenience_tester def create_suite(times): testers = [ @@ -124,6 +125,7 @@ , split_module_tester , properties_tester , arrays_bug_tester + , convenience_tester ] main_suite = unittest.TestSuite() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |