diff --git a/doc/tutorial/doc/quickstart.txt b/doc/tutorial/doc/quickstart.txt index b6a7d12d..0e202c0b 100644 --- a/doc/tutorial/doc/quickstart.txt +++ b/doc/tutorial/doc/quickstart.txt @@ -1458,10 +1458,10 @@ The former returns a reference to an already imported module, the latter retrieves a module's namespace dictionary. Let's use them to retrieve the namespace of the [^__main__] module: - object main_module( - handle<>(borrowed(PyImport_AddModule("__main__")))); - object main_namespace = main_module.attr("__dict__"); + object main_module(( + handle<>(borrowed(PyImport_AddModule("__main__"))))); + object main_namespace = main_module.attr("__dict__"); For a function returning a ['new reference] we can just create a [^handle] out of the raw [^PyObject*] without wrapping it in a call to borrowed. One @@ -1510,12 +1510,12 @@ For most intents and purposes you can use the namespace dictionary of the We have already seen how to get the [^__main__] module's namespace so let's run some Python code in it: - object main_module( - handle<>(borrowed(PyImport_AddModule("__main__")))); + object main_module(( + handle<>(borrowed(PyImport_AddModule("__main__"))))); object main_namespace = main_module.attr("__dict__"); - handle<>(PyRun_String( + handle<> ignored((PyRun_String( "hello = file('hello.txt', 'w')\n" "hello.write('Hello world!')\n" @@ -1524,7 +1524,7 @@ run some Python code in it: , Py_file_input , main_namespace.ptr() , main_namespace.ptr()) - ); + )); Because the Python/C API doesn't know anything about [^object]s, we used the object's [^ptr] member function to retrieve the [^PyObject*]. @@ -1547,33 +1547,34 @@ named [^object] class and it's derivatives. We've already seen that they can be constructed from a [^handle]. The following examples should further illustrate this fact: - object main_module( - handle<>(borrowed(PyImport_AddModule("__main__")))); + object main_module(( + handle<>(borrowed(PyImport_AddModule("__main__"))))); object main_namespace = main_module.attr("__dict__"); - handle<>(PyRun_String( + handle<> ignored((PyRun_String( "result = 5 ** 2" , Py_file_input , main_namespace.ptr() , main_namespace.ptr()) - ); + )); - int five_squared = extract(main_namespace["result"] ); + int five_squared = extract(main_namespace["result"]); Here we create a dictionary object for the [^__main__] module's namespace. Then we assign 5 squared to the result variable and read this variable from the dictionary. Another way to achieve the same result is to let PyRun_String return the result directly with Py_eval_input: - object result(handle<>(PyRun_String( - "5 ** 2" - , Py_eval_input - , main_namespace.ptr() - , main_namespace.ptr())) - ); + object result((handle<>( + PyRun_String("5 ** 2" + , Py_eval_input + , main_namespace.ptr() + , main_namespace.ptr())) + )); + int five_squared = extract(result); __note__ [*Note] that [^object]'s member function to return the wrapped @@ -1587,12 +1588,12 @@ If an exception occurs in the execution of some Python code, the PyRun_String fu try { - object result(handle<>(PyRun_String( + object result((handle<>(PyRun_String( "5/0" , Py_eval_input , main_namespace.ptr() , main_namespace.ptr())) - ); + )); // execution will never get here: int five_divided_by_zero = extract(result); @@ -1621,11 +1622,11 @@ The [^error_already_set] exception class doesn't carry any information in itself If you'd rather not have [^handle] throw a C++ exception when it is constructed, you can use the [@../../v2/handle.html#allow_null-spec allow_null] function in the same way you'd use borrowed: - handle<> result(allow_null(PyRun_String( + handle<> result((allow_null(PyRun_String( "5/0" , Py_eval_input , main_namespace.ptr() - , main_namespace.ptr()))); + , main_namespace.ptr())))); if (!result) // Python exception occurred diff --git a/doc/tutorial/doc/using_the_interpreter.html b/doc/tutorial/doc/using_the_interpreter.html index a4a46e37..e39e8899 100644 --- a/doc/tutorial/doc/using_the_interpreter.html +++ b/doc/tutorial/doc/using_the_interpreter.html @@ -54,8 +54,9 @@ The former returns a reference to an already imported module, the latter retrieves a module's namespace dictionary. Let's use them to retrieve the namespace of the __main__ module:

-    object main_module(
-        handle<>(borrowed(PyImport_AddModule("__main__"))));
+    object main_module((
+        handle<>(borrowed(PyImport_AddModule("__main__")))));
+
     object main_namespace = main_module.attr("__dict__");
 

@@ -117,12 +118,12 @@ For most intents and purposes you can use the namespace dictionary of the We have already seen how to get the __main__ module's namespace so let's run some Python code in it:

-    object main_module(
-        handle<>(borrowed(PyImport_AddModule("__main__"))));
+    object main_module((
+        handle<>(borrowed(PyImport_AddModule("__main__")))));
 
     object main_namespace = main_module.attr("__dict__");
 
-    handle<>(PyRun_String(
+    handle<> ignored((PyRun_String(
 
         "hello = file('hello.txt', 'w')\n"
         "hello.write('Hello world!')\n"
@@ -131,7 +132,7 @@ run some Python code in it:

, Py_file_input , main_namespace.ptr() , main_namespace.ptr()) - ); + ));

Because the Python/C API doesn't know anything about objects, we used @@ -155,21 +156,21 @@ named object class and it's derivatives. We've already seen that they can be constructed from a handle. The following examples should further illustrate this fact:

-    object main_module(
-        handle<>(borrowed(PyImport_AddModule("__main__"))));
+    object main_module((
+         handle<>(borrowed(PyImport_AddModule("__main__")))));
 
     object main_namespace = main_module.attr("__dict__");
 
-    handle<>(PyRun_String(
+    handle<> ignored((PyRun_String(
 
         "result = 5 ** 2"
 
         , Py_file_input
         , main_namespace.ptr()
         , main_namespace.ptr())
-    );
+    ));
 
-    int five_squared = extract<int>(main_namespace["result"] );
+    int five_squared = extract<int>(main_namespace["result"]);
 

Here we create a dictionary object for the __main__ module's namespace. @@ -179,12 +180,13 @@ the dictionary. Another way to achieve the same result is to let PyRun_String return the result directly with Py_eval_input:

-    object result(handle<>(PyRun_String(
-        "5 ** 2"
-      , Py_eval_input
-      , main_namespace.ptr()
-      , main_namespace.ptr()))
-    );
+    object result((handle<>(
+        PyRun_String("5 ** 2"
+            , Py_eval_input
+            , main_namespace.ptr()
+            , main_namespace.ptr()))
+    ));
+
     int five_squared = extract<int>(result);
 

@@ -199,12 +201,12 @@ error_already_set, so basically, the Python exception is automatically trans

     try
     {
-        object result(handle<>(PyRun_String(
+        object result((handle<>(PyRun_String(
             "5/0"
           , Py_eval_input
           , main_namespace.ptr()
           , main_namespace.ptr()))
-        );
+        ));
 
         // execution will never get here:
         int five_divided_by_zero = extract<int>(result);
@@ -240,11 +242,11 @@ here.)

If you'd rather not have handle throw a C++ exception when it is constructed, you can use the allow_null function in the same way you'd use borrowed:

-    handle<> result(allow_null(PyRun_String(
+    handle<> result((allow_null(PyRun_String(
         "5/0"
        , Py_eval_input
        , main_namespace.ptr()
-       , main_namespace.ptr())));
+       , main_namespace.ptr()))));
 
     if (!result)
         // Python exception occurred
diff --git a/doc/tutorial/doc/virtual_functions_with_default_implementations.html b/doc/tutorial/doc/virtual_functions_with_default_implementations.html
index 6dbb6ff3..c1d28c33 100644
--- a/doc/tutorial/doc/virtual_functions_with_default_implementations.html
+++ b/doc/tutorial/doc/virtual_functions_with_default_implementations.html
@@ -22,7 +22,7 @@
     
     
     
-  
+   
 
 

Recall that in the @@ -63,12 +63,10 @@ Then, Boost.Python needs to keep track of 1) the dispatch function f an 2) the forwarding function to its default implementation default_f. There's a special def function for this purpose. Here's how it is applied to our example above:

- -
-    class_<Base, BaseWrap, boost::noncopyable>("Base")
+
+    class_<Base, BaseWrap, BaseWrap, boost::noncopyable>("Base")
         .def("f", &Base::f, &BaseWrap::default_f)
-
-
+

Note that we are allowing Base objects to be instantiated this time, unlike before where we specifically defined the class_<Base> with @@ -112,7 +110,7 @@ Calling call_f, passing in a derived object:

- +