diff --git a/doc/tutorial/doc/html/index.html b/doc/tutorial/doc/html/index.html index 5f112309..d6365100 100644 --- a/doc/tutorial/doc/html/index.html +++ b/doc/tutorial/doc/html/index.html @@ -30,7 +30,7 @@
-

+

Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at @@ -96,7 +96,7 @@ metaprogramming techniques simplifies its syntax for users, so that wrapping code takes on the look of a kind of declarative interface definition language (IDL).

-Hello World

+Hello World

Following C/C++ tradition, let's start with the "hello, world". A C++ Function:

@@ -125,7 +125,7 @@ hello, world
- +

Last revised: May 02, 2005 at 15:44:52 GMT

Last revised: May 14, 2005 at 02:47:50 GMT


diff --git a/doc/tutorial/doc/html/python/embedding.html b/doc/tutorial/doc/html/python/embedding.html index 1c34f056..393db3d6 100644 --- a/doc/tutorial/doc/html/python/embedding.html +++ b/doc/tutorial/doc/html/python/embedding.html @@ -39,7 +39,7 @@ the gaps. However, Boost.Python already makes embedding a lot easier and, in a future version, it may become unnecessary to touch the Python/C API at all. So stay tuned...

-Building embedded programs

+Building embedded programs

To be able to use embedding in your programs, they have to be linked to both Boost.Python's and Python's static link library.

@@ -61,21 +61,21 @@ include path.

In a Jamfile, all the above boils down to:

projectroot c:\projects\embedded_program ; # location of the program
 
-    # bring in the rules for python
-    SEARCH on python.jam = $(BOOST_BUILD_PATH) ;
-    include python.jam ;
+# bring in the rules for python
+SEARCH on python.jam = $(BOOST_BUILD_PATH) ;
+include python.jam ;
 
-    exe embedded_program # name of the executable
-      : #sources
-         embedded_program.cpp
-      : # requirements
-         <find-library>boost_python <library-path>c:\boost\libs\python
-      $(PYTHON_PROPERTIES)
-        <library-path>$(PYTHON_LIB_PATH)
-        <find-library>$(PYTHON_EMBEDDED_LIBRARY) ;
+exe embedded_program # name of the executable
+  : #sources
+     embedded_program.cpp
+  : # requirements
+     <find-library>boost_python <library-path>c:\boost\libs\python
+  $(PYTHON_PROPERTIES)
+    <library-path>$(PYTHON_LIB_PATH)
+    <find-library>$(PYTHON_EMBEDDED_LIBRARY) ;
 

-Getting started

+Getting started

Being able to build is nice, but there is nothing to build yet. Embedding the Python interpreter into one of your C++ programs requires these 4 @@ -110,7 +110,7 @@ messy and especially hard to get right in the presence of C++ exceptions. Fortunately Boost.Python provides the handle and object class templates to automate the process.

-Reference-counting handles and objects

+Reference-counting handles and objects

There are two ways in which a function in the Python/C API can return a PyObject*: as a borrowed reference or as a new reference. Which of @@ -141,7 +141,7 @@ discuss in the next section.

-Running Python code

+Running Python code

To run Python code from C++ there is a family of functions in the API starting with the PyRun prefix. You can find the full list of these @@ -156,7 +156,7 @@ The start parameter is the start symbol from the Python for interpreting the code. The possible values are:

-Start symbols +Start symbols

@@ -224,7 +224,7 @@ containing a phrase that is well-known in programming circles.

-Beyond handles

+Beyond handles

It's nice that handle manages the reference counting details for us, but other than that it doesn't do much. Often we'd like to have a more useful @@ -271,7 +271,7 @@ int five_squared =<

-Exception handling

+Exception handling

If an exception occurs in the execution of some Python code, the PyRun_String function returns a null pointer. Constructing a handle out of this null diff --git a/doc/tutorial/doc/html/python/exposing.html b/doc/tutorial/doc/html/python/exposing.html index caac0e38..9e70ec41 100644 --- a/doc/tutorial/doc/html/python/exposing.html +++ b/doc/tutorial/doc/html/python/exposing.html @@ -396,7 +396,7 @@ Calling derived.f():

Class Operators/Special Functions

-Python Operators

+Python Operators

C is well known for the abundance of operators. C++ extends this to the extremes by allowing operator overloading. Boost.Python takes advantage of @@ -434,7 +434,7 @@ you might need to interact with in an operator expression is (cheaply) default-constructible. You can use other<T>() in place of an actual T instance when writing "self expressions".

-Special Methods

+Special Methods

Python has a few more Special Methods. Boost.Python supports all of the standard special method names supported by real Python class instances. A diff --git a/doc/tutorial/doc/html/python/functions.html b/doc/tutorial/doc/html/python/functions.html index 8c21cb5d..bea38eb8 100644 --- a/doc/tutorial/doc/html/python/functions.html +++ b/doc/tutorial/doc/html/python/functions.html @@ -43,26 +43,26 @@ overloading and default arguments.

But before you do, you might want to fire up Python 2.2 or later and type >>> import this.

>>> import this
-    The Zen of Python, by Tim Peters
-    Beautiful is better than ugly.
-    Explicit is better than implicit.
-    Simple is better than complex.
-    Complex is better than complicated.
-    Flat is better than nested.
-    Sparse is better than dense.
-    Readability counts.
-    Special cases aren't special enough to break the rules.
-    Although practicality beats purity.
-    Errors should never pass silently.
-    Unless explicitly silenced.
-    In the face of ambiguity, refuse the temptation to guess.
-    There should be one-- and preferably only one --obvious way to do it
-    Although that way may not be obvious at first unless you're Dutch.
-    Now is better than never.
-    Although never is often better than right now.
-    If the implementation is hard to explain, it's a bad idea.
-    If the implementation is easy to explain, it may be a good idea.
-    Namespaces are one honking great idea -- let's do more of those!
+The Zen of Python, by Tim Peters
+Beautiful is better than ugly.
+Explicit is better than implicit.
+Simple is better than complex.
+Complex is better than complicated.
+Flat is better than nested.
+Sparse is better than dense.
+Readability counts.
+Special cases aren't special enough to break the rules.
+Although practicality beats purity.
+Errors should never pass silently.
+Unless explicitly silenced.
+In the face of ambiguity, refuse the temptation to guess.
+There should be one-- and preferably only one --obvious way to do it
+Although that way may not be obvious at first unless you're Dutch.
+Now is better than never.
+Although never is often better than right now.
+If the implementation is hard to explain, it's a bad idea.
+If the implementation is easy to explain, it may be a good idea.
+Namespaces are one honking great idea -- let's do more of those!
 

@@ -174,7 +174,7 @@ A reference to y.x is returned
  • BOOM!
  • -Call Policies

    +Call Policies

    Call Policies may be used in situations such as the example detailed above. In our example, return_internal_reference and with_custodian_and_ward @@ -336,7 +336,7 @@ are overloaded with a common sequence of initial arguments

    -BOOST_PYTHON_FUNCTION_OVERLOADS

    +BOOST_PYTHON_FUNCTION_OVERLOADS

    Boost.Python now has a way to make it easier. For instance, given a function:

    int foo(int a, char b = 1, unsigned c = 2, double d = 3)
    @@ -355,7 +355,7 @@ and the maximum number of arguments is 4. The def(...)
     automatically add all the foo variants for us:

    def("foo", foo, foo_overloads());

    -BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS

    +BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS

    Objects here, objects there, objects here there everywhere. More frequently than anything else, we need to expose member functions of our classes to @@ -387,7 +387,7 @@ fourth macro argument). The thin wrappers are all enclosed in a class named See the overloads reference for details.

    -init and optional

    +init and optional

    A similar facility is provided for class constructors, again, with default arguments or a sequence of overloads. Remember init<...>? For example, @@ -442,7 +442,7 @@ Then...

    Notice though that we have a situation now where we have a minimum of zero (0) arguments and a maximum of 3 arguments.

    -Manual Wrapping

    +Manual Wrapping

    It is important to emphasize however that the overloaded functions must have a common sequence of initial arguments. Otherwise, our scheme above diff --git a/doc/tutorial/doc/html/python/hello.html b/doc/tutorial/doc/html/python/hello.html index a7d946c4..d27c5975 100644 --- a/doc/tutorial/doc/html/python/hello.html +++ b/doc/tutorial/doc/html/python/hello.html @@ -26,7 +26,7 @@

    Building Hello World

    -From Start To Finish

    +From Start To Finish

    Now the first thing you'd want to do is to build the Hello World module and try it for yourself in Python. In this section, we shall outline the steps @@ -93,55 +93,65 @@ the command line. Pre-built Boost.Jam executables are available for most platforms. The complete list of Bjam executables can be found here.

    -Let's Jam!

    +Let's Jam!

    Here is our minimalist Jamfile:

    -
    subproject libs/python/example/tutorial ;
    +
    # This is the top of our own project tree
    +project-root ;
     
    -    SEARCH on python.jam = $(BOOST_BUILD_PATH) ;
    -    include python.jam ;
    +import python ;
     
    -    extension hello                     # Declare a Python extension called hello
    -    :   hello.cpp                       # source
    -        <dll>../../build/boost_python   # dependencies
    -        ;
    +extension hello                     # Declare a Python extension called hello
    +:   hello.cpp                       # source
    +    # requirements and dependencies for Boost.Python extensions
    +    <template>@boost/libs/python/build/extension
    +    ;
     

    -First, we need to specify our location in the boost project hierarchy. -It so happens that the tutorial example is located in /libs/python/example/tutorial. -Thus:

    -
    subproject libs/python/example/tutorial ;
    +First, we need to specify our location. You may place your project anywhere.
    +project-root allows you to do that.

    +
    project-root ;
     

    -Then we will include the definitions needed by Python modules:

    -
    SEARCH on python.jam = $(BOOST_BUILD_PATH) ;
    -    include python.jam ;
    +By doing so, you'll need a Jamrules file. Simply copy the one in the 
    +example/tutorial directory and tweak 
    +the path-global BOOST_ROOT to where your boost root directory is. The file
    +has detailed instructions you can follow.

    +

    +Then we will import the definitions needed by Python modules:

    +
    import python ;
     

    Finally we declare our hello extension:

    extension hello                     # Declare a Python extension called hello
    -    :   hello.cpp                       # source
    -        <dll>../../build/boost_python   # dependencies
    -        ;
    +:   hello.cpp                       # source
    +
    +    # requirements and dependencies for Boost.Python extensions
    +    <template>@boost/libs/python/build/extension
    +    ;
     
    +

    +The last part tells BJam that we are depending on the Boost Python Library.

    -Running bjam

    +Running bjam

    bjam is run using your operating system's command line interpreter.

    Start it up.

    Make sure that the environment is set so that we can invoke the C++ compiler. With MSVC, that would mean running the Vcvars32.bat batch file. For instance:

    -
    C:\Program Files\Microsoft Visual Studio\VC98\bin\Vcvars32.bat
    +
    C:\Program Files\Microsoft Visual Studio .NET 2003\Common7\Tools\vsvars32.bat
    +

    Some environment variables will have to be setup for proper building of our Python modules. Example:

    -
    set PYTHON_ROOT=c:/dev/tools/python
    -set PYTHON_VERSION=2.2
    +
    set PYTHON_ROOT=c:/dev/tools/python
    +set PYTHON_VERSION=2.2
    +

    The above assumes that the Python installation is in c:/dev/tools/python -and that we are using Python version 2.2. You'll have to tweak this path +and that we are using Python version 2.2. You'll have to tweak these appropriately.

    @@ -150,36 +160,41 @@ appropriately.

    even if that's the version you have.

    +Take note that you may also do that through the Jamrules file we put in +our project as detailed above. The file +has detailed instructions you +can follow.

    +

    Now we are ready... Be sure to cd to libs/python/example/tutorial where the tutorial "hello.cpp" and the "Jamfile" is situated.

    Finally:

    -
    bjam -sTOOLS=msvc
    +
    bjam -sTOOLS=vc-7_1

    -We are again assuming that we are using Microsoft Visual C++ version 6. If +We are again assuming that we are using Microsoft Visual C++ version 7.1. If not, then you will have to specify the appropriate tool. See Building Boost Libraries for further details.

    It should be building now:

    cd C:\dev\boost\libs\python\example\tutorial
    -    bjam -sTOOLS=msvc
    -    ...patience...
    -    ...found 1703 targets...
    -    ...updating 40 targets...
    +bjam -sTOOLS=msvc
    +...patience...
    +...found 1703 targets...
    +...updating 40 targets...
     

    And so on... Finally:

    -
    vc-C++ ........\libs\python\example\tutorial\bin\hello.pyd\msvc\debug\
    -    runtime-link-dynamic\hello.obj
    -    hello.cpp
    -    vc-Link ........\libs\python\example\tutorial\bin\hello.pyd\msvc\debug\
    -    runtime-link-dynamic\hello.pyd ........\libs\python\example\tutorial\bin\
    -    hello.pyd\msvc\debug\runtime-link-dynamic\hello.lib
    -       Creating library ........\libs\python\example\tutorial\bin\hello.pyd\
    -       msvc\debug\runtime-link-dynamic\hello.lib and object ........\libs\python\
    -       example\tutorial\bin\hello.pyd\msvc\debug\runtime-link-dynamic\hello.exp
    -    ...updated 40 targets...
    +
    Creating library bin\boost\libs\python\build\boost_python.dll\vc-7_1\debug\th
    +reading-multi\boost_python.lib and object bin\boost\libs\python\build\boost_pyth
    +on.dll\vc-7_1\debug\threading-multi\boost_python.exp
    +vc-C++ bin\tutorial\hello.pyd\vc-7_1\debug\threading-multi\hello.obj
    +hello.cpp
    +vc-Link bin\tutorial\hello.pyd\vc-7_1\debug\threading-multi\hello.pyd bin\tutori
    +al\hello.pyd\vc-7_1\debug\threading-multi\hello.lib
    +   Creating library bin\tutorial\hello.pyd\vc-7_1\debug\threading-multi\hello.li
    +b and object bin\tutorial\hello.pyd\vc-7_1\debug\threading-multi\hello.exp
    +...updated 31 targets...
     

    If all is well, you should now have:

    @@ -203,12 +218,10 @@ hello.so

    if you are on Unix.

    -

    boost_python.dll can be found somewhere in libs\python\build\bin -while hello.pyd can be found somewhere in -libs\python\example\tutorial\bin. After a successful build, you can just -link in these DLLs with the Python interpreter. In Windows for example, you -can simply put these libraries inside the directory where the Python -executable is.

    +

    boost_python.dll and hello.pyd can be found somewhere in your project's +bin directory. After a successful build, you can just link in these DLLs with +the Python interpreter. In Windows for example, you can simply put these libraries +inside the directory where the Python executable is.

    You may now fire up Python and run our hello module:

    diff --git a/doc/tutorial/doc/html/python/object.html b/doc/tutorial/doc/html/python/object.html index ea66ed48..52b3a2c3 100644 --- a/doc/tutorial/doc/html/python/object.html +++ b/doc/tutorial/doc/html/python/object.html @@ -157,7 +157,7 @@ C++: d['whatever'] = 3; // modifies the copy

    -class_<T> as objects

    +class_<T> as objects

    Due to the dynamic nature of Boost.Python objects, any class_<T> may also be one of these types! The following code snippet wraps the class diff --git a/doc/tutorial/doc/html/python/techniques.html b/doc/tutorial/doc/html/python/techniques.html index 5fc5fbf7..7e6d7c6f 100644 --- a/doc/tutorial/doc/html/python/techniques.html +++ b/doc/tutorial/doc/html/python/techniques.html @@ -91,10 +91,10 @@ Unix and .dll for Windows, works just as well. Now, we create this directory structure for our Python package:

    sounds/
    -        _init_.py
    -        core.pyd
    -        filters.pyd
    -        io.pyd
    +    _init_.py
    +    core.pyd
    +    filters.pyd
    +    io.pyd
     

    The file _init_.py is what tells Python that the directory sounds/ is @@ -133,16 +133,16 @@ Note that we added an underscore to the module name. The filename will have to be changed to _core.pyd as well, and we do the same to the other extension modules. Now, we change our package hierarchy like so:

    sounds/
    +    _init_.py
    +    core/
             _init_.py
    -        core/
    -            _init_.py
    -            _core.pyd
    -        filters/
    -            _init_.py
    -            _filters.pyd
    -        io/
    -            _init_.py
    -            _io.pyd
    +        _core.pyd
    +    filters/
    +        _init_.py
    +        _filters.pyd
    +    io/
    +        _init_.py
    +        _io.pyd
     

    Note that we created a directory for each extension module, and added a diff --git a/doc/tutorial/doc/tutorial.qbk b/doc/tutorial/doc/tutorial.qbk index d1fed224..141a4ddb 100644 --- a/doc/tutorial/doc/tutorial.qbk +++ b/doc/tutorial/doc/tutorial.qbk @@ -125,41 +125,49 @@ __jam__ Here is our minimalist Jamfile: [pre - subproject libs/python/example/tutorial ; +# This is the top of our own project tree +project-root ; - SEARCH on python.jam = $(BOOST_BUILD_PATH) ; - include python.jam ; +import python ; - extension hello # Declare a Python extension called hello - : hello.cpp # source - ../../build/boost_python # dependencies - ; +extension hello # Declare a Python extension called hello +: hello.cpp # source + # requirements and dependencies for Boost.Python extensions +