Revision: 651
http://svn.sourceforge.net/pygccxml/?rev=651&view=rev
Author: roman_yakovenko
Date: 2006-10-12 00:00:58 -0700 (Thu, 12 Oct 2006)
Log Message:
-----------
updating tutorials
Modified Paths:
--------------
pyplusplus_dev/docs/documentation/tutorials/module_builder/generate_code.py
pyplusplus_dev/docs/documentation/tutorials/module_builder/hello_world.hpp
pyplusplus_dev/docs/documentation/tutorials/module_builder/module_builder.rest
Added Paths:
-----------
pyplusplus_dev/docs/documentation/tutorials/module_builder/generated.cpp
Removed Paths:
-------------
pyplusplus_dev/docs/documentation/tutorials/module_builder/hello_world.py.cpp
Modified: pyplusplus_dev/docs/documentation/tutorials/module_builder/generate_code.py
===================================================================
--- pyplusplus_dev/docs/documentation/tutorials/module_builder/generate_code.py 2006-10-12 05:44:53 UTC (rev 650)
+++ pyplusplus_dev/docs/documentation/tutorials/module_builder/generate_code.py 2006-10-12 07:00:58 UTC (rev 651)
@@ -4,15 +4,9 @@
# accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
-#############################################################################
-## #
-## ANY CHANGE IN THIS FILE MUST BE REFLECTED IN docs/tutorials DIRECTORY #
-## #
-#############################################################################
-
import os
import sys
-sys.path.append( '../..' )
+sys.path.append( '../../../..' )
from environment import gccxml
from pyplusplus import module_builder
@@ -26,12 +20,12 @@
#Set call policies to animal::get_name_ptr
animal = mb.class_( 'animal' )
-get_name_ptr = animal.member_function( 'get_name_ptr', recursive=False )
-get_name_ptr.call_policies = module_builder.call_policies.return_internal_reference()
+genealogical_tree_ref = animal.member_function( 'genealogical_tree_ref', recursive=False )
+genealogical_tree_ref.call_policies = module_builder.call_policies.return_internal_reference()
#next code has same effect
-get_name_ptr = mb.member_function( 'get_name_ptr' )
-get_name_ptr.call_policies = module_builder.call_policies.return_internal_reference()
+genealogical_tree_ref = mb.member_function( 'genealogical_tree_ref' )
+genealogical_tree_ref.call_policies = module_builder.call_policies.return_internal_reference()
#I want to exclude all classes with name starts with impl
impl_classes = mb.classes( lambda decl: decl.name.startswith( 'impl' ) )
@@ -57,4 +51,4 @@
mb.code_creator.user_defined_directories.append( os.path.abspath('.') )
#And finally we can write code to the disk
-mb.write_module( os.path.join( os.path.abspath('.'), 'hello_world.py.cpp' ) )
\ No newline at end of file
+mb.write_module( os.path.join( os.path.abspath('.'), 'generated.cpp' ) )
Copied: pyplusplus_dev/docs/documentation/tutorials/module_builder/generated.cpp (from rev 649, pyplusplus_dev/docs/documentation/tutorials/module_builder/hello_world.py.cpp)
===================================================================
--- pyplusplus_dev/docs/documentation/tutorials/module_builder/generated.cpp (rev 0)
+++ pyplusplus_dev/docs/documentation/tutorials/module_builder/generated.cpp 2006-10-12 07:00:58 UTC (rev 651)
@@ -0,0 +1,31 @@
+// This file has been generated by Py++.
+
+//Boost Software License( http://boost.org/more/license_info.html )
+
+#include "boost/python.hpp"
+
+#include "hello_world.hpp"
+
+namespace bp = boost::python;
+
+BOOST_PYTHON_MODULE(hw){
+ bp::enum_< color>("Color")
+ .value("red", red)
+ .value("green", green)
+ .value("blue", blue)
+ .export_values()
+ ;
+
+ bp::class_< animal, boost::noncopyable >( "animal", bp::init< bp::optional< std::string const & > >(( bp::arg("name")="" )) )
+ .def(
+ "genealogical_tree_ref"
+ , &::animal::genealogical_tree_ref
+ , bp::return_internal_reference< 1, bp::default_call_policies >() )
+ .def(
+ "name"
+ , &::animal::name );
+
+ bp::implicitly_convertible< std::string const &, animal >();
+
+ bp::class_< genealogical_tree >( "genealogical_tree" );
+}
Modified: pyplusplus_dev/docs/documentation/tutorials/module_builder/hello_world.hpp
===================================================================
--- pyplusplus_dev/docs/documentation/tutorials/module_builder/hello_world.hpp 2006-10-12 05:44:53 UTC (rev 650)
+++ pyplusplus_dev/docs/documentation/tutorials/module_builder/hello_world.hpp 2006-10-12 07:00:58 UTC (rev 651)
@@ -1,38 +1,34 @@
-// 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)
+// Copyright 2004-2006 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)
-/******************************************************************************************
- * *
- * ANY CHANGE IN THIS FILE MUST BE REFLECTED IN docs/tutorials DIRECTORY *
- * *
- *****************************************************************************************/
-
-#ifndef __hello_world_hpp__
-#define __hello_world_hpp__
-
-#include <string>
+#ifndef __hello_world_hpp__
+#define __hello_world_hpp__
+#include <string>
+
//I want to rename color to Color
enum color{ red, green, blue };
-
+
+struct genealogical_tree{/*...*/};
+
struct animal{
-
- animal( const std::string& name="" )
+
+ explicit animal( const std::string& name="" )
: m_name( name )
{}
//I need to set call policies to the function
- const std::string* get_name_ptr() const
- { return &m_name; }
+ genealogical_tree& genealogical_tree_ref()
+ { return m_genealogical_tree; }
- const std::string& name() const
+ std::string name() const
{ return m_name; }
-
+
private:
std::string m_name;
-
+ genealogical_tree m_genealogical_tree;
};
//I want to exclude next declarations:
@@ -43,5 +39,5 @@
inline int* get_int_ptr(int){ return 0;}
inline int* get_int_ptr(double){ return 0;}
-#endif//__hello_world_hpp__
-
+#endif//__hello_world_hpp__
+
Deleted: pyplusplus_dev/docs/documentation/tutorials/module_builder/hello_world.py.cpp
===================================================================
--- pyplusplus_dev/docs/documentation/tutorials/module_builder/hello_world.py.cpp 2006-10-12 05:44:53 UTC (rev 650)
+++ pyplusplus_dev/docs/documentation/tutorials/module_builder/hello_world.py.cpp 2006-10-12 07:00:58 UTC (rev 651)
@@ -1,28 +0,0 @@
-// This file has been generated by pyplusplus.
-
-//Boost Software License( http://boost.org/more/license_info.html )
-
-#include "boost/python.hpp"
-
-#include "hello_world.hpp"
-
-namespace bp = boost::python;
-
-BOOST_PYTHON_MODULE(hw){
- bp::enum_<color>("Color")
- .value("blue", blue)
- .value("green", green)
- .value("red", red)
- .export_values()
- ;
-
- bp::class_< animal, boost::noncopyable >( "animal", bp::init< bp::optional< std::string const & > >(( bp::arg("name")="" )) )
- .def("get_name_ptr"
- , &::animal::get_name_ptr
- , bp::return_internal_reference< 1, bp::default_call_policies >() )
- .def("name"
- , &::animal::name
- , bp::return_value_policy< bp::copy_const_reference, bp::default_call_policies >() );
-
- bp::implicitly_convertible< std::string const &, animal >();
-}
Modified: pyplusplus_dev/docs/documentation/tutorials/module_builder/module_builder.rest
===================================================================
--- pyplusplus_dev/docs/documentation/tutorials/module_builder/module_builder.rest 2006-10-12 05:44:53 UTC (rev 650)
+++ pyplusplus_dev/docs/documentation/tutorials/module_builder/module_builder.rest 2006-10-12 07:00:58 UTC (rev 651)
@@ -24,8 +24,8 @@
* `generate_code.py`_ - Python code, that uses `Py++`_ to export
declarations from the source file
-.. _`hello_world.hpp` : ./hello_world.html
-.. _`generate_code.py` : ./generate_code.html
+.. _`hello_world.hpp` : ./hello_world.hpp.html
+.. _`generate_code.py` : ./generate_code.py.html
----------------
module_builder_t
@@ -35,8 +35,7 @@
should really to be familiar with - ``module_builder``. This package is some kind
of facade to low level API. It provides simple and intuitive API. The main
class within this package is ``module_builder_t``. The instance of this class will
-guide you through the whole process. Next few paragraphs will tell you more about
-this class.
+guide you through the whole process.
-------------------------
module_builder_t.__init__
@@ -50,27 +49,27 @@
to expose. This is the only required parameter.
2. ``gccxml_path`` - path to `GCC-XML`_ binary. If you don't supply this argument
- `pygccxml`_ will look for it using your environment variable ``PATH``.
+ `pygccxml`_ will look for it using ``PATH`` environment variable.
There are some other arguments:
-* additional include directories
+* additional include directories
* [un]defined symbols ( macros )
-* declarations cache
+* intermediate results cache strategy configuration
* ...
Parsing of source files is done within this method. Post condition of this
-method is - all declarations has been successfully extracted from the sources
-files.
+method is that all declarations has been successfully extracted from the sources
+files and you can start work on them.
--------------------------
Declarations customization
--------------------------
-Not all declarations should be exported! Not every declaration could be exported
-without human invocation! As you already saw from example, `Py++`_ provides
-simple and powerful declarations query interface. By default, only declarations
-that belongs to files, you have asked to parse, and to files, that lies in the same
-directories as parsed files, will be exported:
+There are always declarations, which should not be exported or could not be
+exported without human invocation. As you already saw from example, `Py++`_ provides
+simple and powerful declarations query interface. By default, only the declarations
+that belongs to the files, you have asked to parse, and to the files, that lies
+in the same directories as parsed files, will be exported:
::
project_root/
@@ -97,11 +96,18 @@
* to set call policies
* ...
-
I think it is critical for beginners to see what is going on, right?
``module_builder_t`` class has ``print_declarations`` method. You can print whole
-declarations tree or some specific declaration. Very convenient, very useful.
+declarations tree or some specific declaration. You will find a lot of useful
+information there:
+* whether the declaration is include\\excluded
+* call policies
+* warnings, `Py++`_ warns you about the declarations that have some "problems"
+* ...
+
+Very convenient, very useful.
+
-----------------------------------
module_builder_t.build_code_creator
-----------------------------------
@@ -151,7 +157,7 @@
`View generated file`_
-.. _`View generated file` : ./result.html
+.. _`View generated file` : ./generated.cpp.html
That's all. I hope you enjoyed.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|