Revision: 795
http://svn.sourceforge.net/pygccxml/?rev=795&view=rev
Author: roman_yakovenko
Date: 2006-12-11 00:19:39 -0800 (Mon, 11 Dec 2006)
Log Message:
-----------
updating documentation
Modified Paths:
--------------
pyplusplus_dev/docs/documentation/functions/transformation/built_in/built_in.rest
Added Paths:
-----------
pyplusplus_dev/docs/documentation/functions/transformation/built_in/input_static_array.rest
pyplusplus_dev/docs/documentation/functions/transformation/built_in/output_static_array.rest
Modified: pyplusplus_dev/docs/documentation/functions/transformation/built_in/built_in.rest
===================================================================
--- pyplusplus_dev/docs/documentation/functions/transformation/built_in/built_in.rest 2006-12-11 07:07:41 UTC (rev 794)
+++ pyplusplus_dev/docs/documentation/functions/transformation/built_in/built_in.rest 2006-12-11 08:19:39 UTC (rev 795)
@@ -29,8 +29,8 @@
.. _`output` : ./output.html
-All built-in transformers could be applied on any function, except constructors.
-The support for constructors will be added in future releases.
+All built-in transformers could be applied on any function, except constructors
+and pure virtual functions. The support for them be added in future releases.
You don't have to warry about call policies. You can set the call policy and
`Py++`_ will generate the correct code.
Added: pyplusplus_dev/docs/documentation/functions/transformation/built_in/input_static_array.rest
===================================================================
--- pyplusplus_dev/docs/documentation/functions/transformation/built_in/input_static_array.rest (rev 0)
+++ pyplusplus_dev/docs/documentation/functions/transformation/built_in/input_static_array.rest 2006-12-11 08:19:39 UTC (rev 795)
@@ -0,0 +1,85 @@
+==================================
+``input_static_array`` transformer
+==================================
+
+.. contents:: Table of contents
+
+----------
+Definition
+----------
+
+"input_static_array" transformer works on native static arrays. It handles the
+translation between `Python`_ object, passed as argument that represent a sequence,
+and the array. Size of array should be predefined.
+
+"input_static_array" transformer takes as first argument name or index of the
+original function argument. The argument should have "array" or "pointer" type.
+The second argument should an integer value, that represents array size.
+
+-------
+Example
+-------
+
+.. code-block:: C++
+
+ struct vector3{
+
+ void init( int values[3] ){
+ x = values[0];
+ y = values[1];
+ z = values[2];
+ }
+
+ int x,y,z;
+ };
+
+In order to expose ``init`` member function we need to create small wrapper:
+Next `Py++`_ code does it for you:
+
+ .. code-block:: Python
+
+ from pyplusplus import module_builder
+ from pyplusplus import function_transformers as FT
+
+ mb = module_builder.module_builder_t( ... )
+ v3 = mb.class_( 'vector3' )
+ v3.mem_fun( 'init' ).add_transformation( FT.input_static_array( 0, 3 ) )
+
+What you see below is the relevant pieces of generated code:
+
+ .. code-block:: C++
+
+ #include "__convenience.pypp.hpp" //Py++ header file, which contains few convenience function
+
+ namespace bp = boost::python;
+
+ static void init_418e52f4a347efa6b7e123b96f32a73c( ::ft::vector3 & inst, boost::python::object values ){
+ int native_values[3];
+ pyplus_conv::ensure_uniform_sequence< int >( values, 3 );
+ pyplus_conv::copy_sequence( values, pyplus_conv::array_inserter( native_values, 3 ) );
+ inst.init(native_values);
+ }
+
+ BOOST_PYTHON_MODULE(...){
+ ...
+ bp::class_< ft::vector3 >( "vector3", "documentation" )
+ .def( "init"
+ , &init_418e52f4a347efa6b7e123b96f32a73c
+ , ( bp::arg("inst"), bp::arg("values") ) )
+ .def_readwrite( "x", &ft::vector3::x )
+ .def_readwrite( "y", &ft::vector3::y )
+ .def_readwrite( "z", &ft::vector3::z );
+ }
+
+.. _`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:
Added: pyplusplus_dev/docs/documentation/functions/transformation/built_in/output_static_array.rest
===================================================================
--- pyplusplus_dev/docs/documentation/functions/transformation/built_in/output_static_array.rest (rev 0)
+++ pyplusplus_dev/docs/documentation/functions/transformation/built_in/output_static_array.rest 2006-12-11 08:19:39 UTC (rev 795)
@@ -0,0 +1,85 @@
+===================================
+``output_static_array`` transformer
+===================================
+
+.. contents:: Table of contents
+
+----------
+Definition
+----------
+
+"output_static_array" transformer works on native static arrays. It handles the
+translation between array and `Python`_ list object. Size of array should be predefined.
+
+"output_static_array" transformer takes as first argument name or index of the
+original function argument. The argument should have "array" or "pointer" type.
+The second argument should an integer value, that represents array size.
+
+-------
+Example
+-------
+
+.. code-block:: C++
+
+ struct vector3{
+
+ void get_values( int values[3] ){
+ values[0] = x;
+ values[1] = y;
+ values[2] = z;
+ }
+
+ int x,y,z;
+ };
+
+In order to expose ``get_values`` member function we need to create small wrapper:
+Next `Py++`_ code does it for you:
+
+ .. code-block:: Python
+
+ from pyplusplus import module_builder
+ from pyplusplus import function_transformers as FT
+
+ mb = module_builder.module_builder_t( ... )
+ v3 = mb.class_( 'vector3' )
+ v3.mem_fun( 'get_values' ).add_transformation( FT.output_static_array( 0, 3 ) )
+
+What you see below is the relevant pieces of generated code:
+
+ .. code-block:: C++
+
+ #include "__convenience.pypp.hpp" //Py++ header file, which contains few convenience function
+
+ namespace bp = boost::python;
+
+ static boost::python::object get_values_22786c66e5973b70f714e7662e2aecd2( ::ft::vector3 & inst ){
+ int native_values[3];
+ boost::python::list py_values;
+ inst.get_values(native_values);
+ pyplus_conv::copy_container( native_values, native_values + 3, pyplus_conv::list_inserter( py_values ) );
+ return bp::object( py_values );
+ }
+
+ BOOST_PYTHON_MODULE(...){
+ ...
+ bp::class_< ft::vector3 >( "vector3", "documentation" )
+ .def( "get_values"
+ , &get_values_22786c66e5973b70f714e7662e2aecd2
+ , ( bp::arg("inst") ) )
+ .def_readwrite( "x", &ft::vector3::x )
+ .def_readwrite( "y", &ft::vector3::y )
+ .def_readwrite( "z", &ft::vector3::z );
+ }
+
+.. _`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.
|