Update of /cvsroot/luabind/luabind/luabind/doc
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11169/doc
Modified Files:
Tag: beta7-devel2
docs.html docs.rst
Log Message:
added more documentation regarding overloaded member functions
Index: docs.html
===================================================================
RCS file: /cvsroot/luabind/luabind/luabind/doc/docs.html,v
retrieving revision 1.52.2.8
retrieving revision 1.52.2.9
diff -u -d -r1.52.2.8 -r1.52.2.9
--- docs.html 24 Oct 2005 22:24:54 -0000 1.52.2.8
+++ docs.html 24 Oct 2005 23:11:46 -0000 1.52.2.9
@@ -7,7 +7,7 @@
<title>luabind</title>
<meta name="author" content="Daniel Wallin, Arvid Norberg" />
<meta name="copyright" content="Copyright Daniel Wallin, Arvid Norberg 2003." />
-<meta name="date" content="2005-10-22" />
+<meta name="date" content="2005-10-24" />
<link rel="stylesheet" href="style.css" type="text/css" />
</head>
<body>
@@ -22,9 +22,9 @@
<tr><th class="docinfo-name">Copyright:</th>
<td>Copyright Daniel Wallin, Arvid Norberg 2003.</td></tr>
<tr><th class="docinfo-name">Date:</th>
-<td>2005-10-22</td></tr>
+<td>2005-10-24</td></tr>
<tr><th class="docinfo-name">Revision:</th>
-<td>1.25.2.9</td></tr>
+<td>1.25.2.10</td></tr>
<tr class="field"><th class="docinfo-name">License:</th><td class="field-body"><p class="first">Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
@@ -69,51 +69,52 @@
</ul>
</li>
<li><a class="reference" href="#binding-classes-to-lua" id="id56" name="id56">8 Binding classes to Lua</a><ul class="auto-toc">
-<li><a class="reference" href="#properties" id="id57" name="id57">8.1 Properties</a></li>
-<li><a class="reference" href="#enums" id="id58" name="id58">8.2 Enums</a></li>
-<li><a class="reference" href="#operators" id="id59" name="id59">8.3 Operators</a></li>
-<li><a class="reference" href="#nested-scopes-and-static-functions" id="id60" name="id60">8.4 Nested scopes and static functions</a></li>
-<li><a class="reference" href="#derived-classes" id="id61" name="id61">8.5 Derived classes</a></li>
-<li><a class="reference" href="#smart-pointers" id="id62" name="id62">8.6 Smart pointers</a></li>
-<li><a class="reference" href="#splitting-class-registrations" id="id63" name="id63">8.7 Splitting class registrations</a></li>
+<li><a class="reference" href="#overloaded-member-functions" id="id57" name="id57">8.1 Overloaded member functions</a></li>
+<li><a class="reference" href="#properties" id="id58" name="id58">8.2 Properties</a></li>
+<li><a class="reference" href="#enums" id="id59" name="id59">8.3 Enums</a></li>
+<li><a class="reference" href="#operators" id="id60" name="id60">8.4 Operators</a></li>
+<li><a class="reference" href="#nested-scopes-and-static-functions" id="id61" name="id61">8.5 Nested scopes and static functions</a></li>
+<li><a class="reference" href="#derived-classes" id="id62" name="id62">8.6 Derived classes</a></li>
+<li><a class="reference" href="#smart-pointers" id="id63" name="id63">8.7 Smart pointers</a></li>
+<li><a class="reference" href="#splitting-class-registrations" id="id64" name="id64">8.8 Splitting class registrations</a></li>
</ul>
</li>
-<li><a class="reference" href="#object" id="id64" name="id64">9 Object</a><ul class="auto-toc">
-<li><a class="reference" href="#iterators" id="id65" name="id65">9.1 Iterators</a></li>
-<li><a class="reference" href="#related-functions" id="id66" name="id66">9.2 Related functions</a></li>
+<li><a class="reference" href="#object" id="id65" name="id65">9 Object</a><ul class="auto-toc">
+<li><a class="reference" href="#iterators" id="id66" name="id66">9.1 Iterators</a></li>
+<li><a class="reference" href="#related-functions" id="id67" name="id67">9.2 Related functions</a></li>
</ul>
</li>
-<li><a class="reference" href="#defining-classes-in-lua" id="id67" name="id67">10 Defining classes in Lua</a><ul class="auto-toc">
-<li><a class="reference" href="#deriving-in-lua" id="id68" name="id68">10.1 Deriving in lua</a></li>
-<li><a class="reference" href="#overloading-operators" id="id69" name="id69">10.2 Overloading operators</a></li>
-<li><a class="reference" href="#finalizers" id="id70" name="id70">10.3 Finalizers</a></li>
-<li><a class="reference" href="#slicing" id="id71" name="id71">10.4 Slicing</a></li>
+<li><a class="reference" href="#defining-classes-in-lua" id="id68" name="id68">10 Defining classes in Lua</a><ul class="auto-toc">
+<li><a class="reference" href="#deriving-in-lua" id="id69" name="id69">10.1 Deriving in lua</a></li>
+<li><a class="reference" href="#overloading-operators" id="id70" name="id70">10.2 Overloading operators</a></li>
+<li><a class="reference" href="#finalizers" id="id71" name="id71">10.3 Finalizers</a></li>
+<li><a class="reference" href="#slicing" id="id72" name="id72">10.4 Slicing</a></li>
</ul>
</li>
-<li><a class="reference" href="#exceptions" id="id72" name="id72">11 Exceptions</a></li>
-<li><a class="reference" href="#policies" id="id73" name="id73">12 Policies</a><ul class="auto-toc">
-<li><a class="reference" href="#adopt" id="id74" name="id74">12.1 adopt</a></li>
-<li><a class="reference" href="#dependency" id="id75" name="id75">12.2 dependency</a></li>
-<li><a class="reference" href="#out-value" id="id76" name="id76">12.3 out_value</a></li>
-<li><a class="reference" href="#pure-out-value" id="id77" name="id77">12.4 pure_out_value</a></li>
-<li><a class="reference" href="#return-reference-to" id="id78" name="id78">12.5 return_reference_to</a></li>
-<li><a class="reference" href="#copy" id="id79" name="id79">12.6 copy</a></li>
-<li><a class="reference" href="#discard-result" id="id80" name="id80">12.7 discard_result</a></li>
-<li><a class="reference" href="#return-stl-iterator" id="id81" name="id81">12.8 return_stl_iterator</a></li>
-<li><a class="reference" href="#raw" id="id82" name="id82">12.9 raw</a></li>
-<li><a class="reference" href="#yield" id="id83" name="id83">12.10 yield</a></li>
+<li><a class="reference" href="#exceptions" id="id73" name="id73">11 Exceptions</a></li>
+<li><a class="reference" href="#policies" id="id74" name="id74">12 Policies</a><ul class="auto-toc">
+<li><a class="reference" href="#adopt" id="id75" name="id75">12.1 adopt</a></li>
+<li><a class="reference" href="#dependency" id="id76" name="id76">12.2 dependency</a></li>
+<li><a class="reference" href="#out-value" id="id77" name="id77">12.3 out_value</a></li>
+<li><a class="reference" href="#pure-out-value" id="id78" name="id78">12.4 pure_out_value</a></li>
+<li><a class="reference" href="#return-reference-to" id="id79" name="id79">12.5 return_reference_to</a></li>
+<li><a class="reference" href="#copy" id="id80" name="id80">12.6 copy</a></li>
+<li><a class="reference" href="#discard-result" id="id81" name="id81">12.7 discard_result</a></li>
+<li><a class="reference" href="#return-stl-iterator" id="id82" name="id82">12.8 return_stl_iterator</a></li>
+<li><a class="reference" href="#raw" id="id83" name="id83">12.9 raw</a></li>
+<li><a class="reference" href="#yield" id="id84" name="id84">12.10 yield</a></li>
</ul>
</li>
-<li><a class="reference" href="#splitting-up-the-registration" id="id84" name="id84">13 Splitting up the registration</a></li>
-<li><a class="reference" href="#configuration" id="id85" name="id85">14 Configuration</a><ul class="auto-toc">
-<li><a class="reference" href="#build-options" id="id86" name="id86">14.1 Build options</a></li>
+<li><a class="reference" href="#splitting-up-the-registration" id="id85" name="id85">13 Splitting up the registration</a></li>
+<li><a class="reference" href="#configuration" id="id86" name="id86">14 Configuration</a><ul class="auto-toc">
+<li><a class="reference" href="#build-options" id="id87" name="id87">14.1 Build options</a></li>
</ul>
</li>
-<li><a class="reference" href="#implementation-notes" id="id87" name="id87">15 Implementation notes</a></li>
-<li><a class="reference" href="#error-messages" id="id88" name="id88">16 Error messages</a></li>
-<li><a class="reference" href="#faq" id="id89" name="id89">17 FAQ</a></li>
-<li><a class="reference" href="#known-issues" id="id90" name="id90">18 Known issues</a></li>
-<li><a class="reference" href="#acknowledgments" id="id91" name="id91">19 Acknowledgments</a></li>
+<li><a class="reference" href="#implementation-notes" id="id88" name="id88">15 Implementation notes</a></li>
+<li><a class="reference" href="#error-messages" id="id89" name="id89">16 Error messages</a></li>
+<li><a class="reference" href="#faq" id="id90" name="id90">17 FAQ</a></li>
+<li><a class="reference" href="#known-issues" id="id91" name="id91">18 Known issues</a></li>
+<li><a class="reference" href="#acknowledgments" id="id92" name="id92">19 Acknowledgments</a></li>
</ul>
</div>
<div class="section" id="introduction">
@@ -174,6 +175,8 @@
<li>GCC 3.1 (SunOS 5.8)</li>
<li>GCC 3.2 (cygwin)</li>
<li>GCC 3.3.1 (cygwin)</li>
+<li>GCC 3.3 (Apple, MacOS X)</li>
+<li>GCC 4.0 (Apple, MacOS X)</li>
</ul>
</blockquote>
<p>It has been confirmed not to work with:</p>
@@ -193,8 +196,8 @@
<p>To keep down the compilation-time luabind is built as a library. This means you
have to either build it and link against it, or include its source files in
your project. You also have to make sure the luabind directory is somewhere in
-your compiler's include path. It requires <a class="reference" href="http://www.boost.org">Boost</a> 1.32.0 to be installed (only
-boost headers). It also requires that Lua is installed.</p>
+your compiler's include path. It requires <a class="reference" href="http://www.boost.org">Boost</a> 1.32.0 or 1.33.0 to be
+installed (only boost headers). It also requires that Lua is installed.</p>
<p>The official way of building luabind is with <a class="reference" href="http://www.boost.org/tools/build/v2/index_v2.html">Boost.Build V2</a>. To properly build
luabind with Boost.Build you need to set two environment variables:</p>
<dl class="docutils">
@@ -206,7 +209,7 @@
<tt class="docutils literal"><span class="pre">$(LUA_PATH)/lib/.</span></tt></dd>
</dl>
<p>For backward compatibility, there is also a makefile in the root-directory that
-will build the library and the test program. If you are using a UNIX-system (or
+will build the library and the test programs. If you are using a UNIX-system (or
cygwin) they will make it easy to build luabind as a static library. If you are
using Visual Studio it may be easier to include the files in the src directory
in your project.</p>
@@ -568,8 +571,35 @@
<p><tt class="docutils literal"><span class="pre">plus()</span></tt> can now be called as a member function on A with one parameter, int.
If the object pointer parameter is const, the function will act as if it was a
const member function (it can be called on const objects).</p>
+<div class="section" id="overloaded-member-functions">
+<h2><a name="overloaded-member-functions">8.1 Overloaded member functions</a></h2>
+<p>When binding more than one overloads of a member function, or just binding
+one overload of an overloaded member function, you have to disambiguate
+the member function pointer you pass to <tt class="docutils literal"><span class="pre">def</span></tt>. To do this, you can use an
+ordinary C-style cast, to cast it to the right overload. To do this, you have
+to know how to express member function types in C++, here's a short tutorial
+(for more info, refer to your favourite book on C++).</p>
+<p>The syntax for member function pointer follows:</p>
+<pre class="literal-block">
+<em>return-value</em> (<em>class-name</em>::*)(<em>arg1-type</em>, <em>arg2-type</em>, <em>...</em>)
+</pre>
+<p>Here's an example illlustrating this:</p>
+<pre class="literal-block">
+struct A
+{
+ void f(int);
+ void f(int, int);
+};
+</pre>
+<pre class="literal-block">
+class_<A>()
+ .def("f", (void(A::*)(int))&A::f)
+</pre>
+<p>This selects the first overload of the function <tt class="docutils literal"><span class="pre">f</span></tt> to bind. The second
+overload is not bound.</p>
+</div>
<div class="section" id="properties">
-<h2><a name="properties">8.1 Properties</a></h2>
+<h2><a name="properties">8.2 Properties</a></h2>
<p>To register a global data member with a class is easily done. Consider the
following class:</p>
<pre class="literal-block">
@@ -634,7 +664,7 @@
const</strong>, otherwise it won't compile. This seems to be a common source of errors.</p>
</div>
<div class="section" id="enums">
-<h2><a name="enums">8.2 Enums</a></h2>
+<h2><a name="enums">8.3 Enums</a></h2>
<p>If your class contains enumerated constants (enums), you can register them as
well to make them available in Lua. Note that they will not be type safe, all
enums are integers in Lua, and all functions that takes an enum, will accept
@@ -662,7 +692,7 @@
</pre>
</div>
<div class="section" id="operators">
-<h2><a name="operators">8.3 Operators</a></h2>
+<h2><a name="operators">8.4 Operators</a></h2>
<p>To bind operators you have to include <tt class="docutils literal"><span class="pre"><luabind/operator.hpp></span></tt>.</p>
<p>The mechanism for registering operators on your class is pretty simple. You use
a global name <tt class="docutils literal"><span class="pre">luabind::self</span></tt> to refer to the class itself and then you just
@@ -751,7 +781,7 @@
</pre>
</div>
<div class="section" id="nested-scopes-and-static-functions">
-<h2><a name="nested-scopes-and-static-functions">8.4 Nested scopes and static functions</a></h2>
+<h2><a name="nested-scopes-and-static-functions">8.5 Nested scopes and static functions</a></h2>
<p>It is possible to add nested scopes to a class. This is useful when you need
to wrap a nested class, or a static function.</p>
<pre class="literal-block">
@@ -763,10 +793,12 @@
def("f", &f)
]</strong>;
</pre>
+<p>In this example, <tt class="docutils literal"><span class="pre">f</span></tt> will behave like a static member function of the class
+<tt class="docutils literal"><span class="pre">foo</span></tt>, and the class <tt class="docutils literal"><span class="pre">nested</span></tt> will behave like a nested class of <tt class="docutils literal"><span class="pre">foo</span></tt>.</p>
<p>It's also possible to add namespace's to classes using the same syntax.</p>
</div>
<div class="section" id="derived-classes">
-<h2><a name="derived-classes">8.5 Derived classes</a></h2>
+<h2><a name="derived-classes">8.6 Derived classes</a></h2>
<p>If you want to register classes that derives from other classes, you can
specify a template parameter <tt class="docutils literal"><span class="pre">bases<></span></tt> to the <tt class="docutils literal"><span class="pre">class_</span></tt> instantiation. The
following hierarchy:</p>
@@ -798,7 +830,7 @@
</div>
</div>
<div class="section" id="smart-pointers">
-<h2><a name="smart-pointers">8.6 Smart pointers</a></h2>
+<h2><a name="smart-pointers">8.7 Smart pointers</a></h2>
<p>When you register a class you can tell luabind that all instances of that class
should be held by some kind of smart pointer (boost::shared_ptr for instance).
You do this by giving the holder type as an extra template parameter to
@@ -949,7 +981,7 @@
are first extracted from the holder type.</p>
</div>
<div class="section" id="splitting-class-registrations">
-<h2><a name="splitting-class-registrations">8.7 Splitting class registrations</a></h2>
+<h2><a name="splitting-class-registrations">8.8 Splitting class registrations</a></h2>
<p>In some situations it may be desirable to split a registration of a class
across different compilation units. Partly to save rebuild time when changing
in one part of the binding, and in some cases compiler limits may force you
@@ -1621,16 +1653,16 @@
<div class="contents topic" id="policies-currently-implemented">
<p class="topic-title first"><a name="policies-currently-implemented">Policies currently implemented</a></p>
<ul class="auto-toc simple">
-<li><a class="reference" href="#adopt" id="id92" name="id92">12.1 adopt</a></li>
-<li><a class="reference" href="#dependency" id="id93" name="id93">12.2 dependency</a></li>
-<li><a class="reference" href="#out-value" id="id94" name="id94">12.3 out_value</a></li>
-<li><a class="reference" href="#pure-out-value" id="id95" name="id95">12.4 pure_out_value</a></li>
-<li><a class="reference" href="#return-reference-to" id="id96" name="id96">12.5 return_reference_to</a></li>
-<li><a class="reference" href="#copy" id="id97" name="id97">12.6 copy</a></li>
-<li><a class="reference" href="#discard-result" id="id98" name="id98">12.7 discard_result</a></li>
-<li><a class="reference" href="#return-stl-iterator" id="id99" name="id99">12.8 return_stl_iterator</a></li>
-<li><a class="reference" href="#raw" id="id100" name="id100">12.9 raw</a></li>
-<li><a class="reference" href="#yield" id="id101" name="id101">12.10 yield</a></li>
+<li><a class="reference" href="#adopt" id="id93" name="id93">12.1 adopt</a></li>
+<li><a class="reference" href="#dependency" id="id94" name="id94">12.2 dependency</a></li>
+<li><a class="reference" href="#out-value" id="id95" name="id95">12.3 out_value</a></li>
+<li><a class="reference" href="#pure-out-value" id="id96" name="id96">12.4 pure_out_value</a></li>
+<li><a class="reference" href="#return-reference-to" id="id97" name="id97">12.5 return_reference_to</a></li>
+<li><a class="reference" href="#copy" id="id98" name="id98">12.6 copy</a></li>
+<li><a class="reference" href="#discard-result" id="id99" name="id99">12.7 discard_result</a></li>
+<li><a class="reference" href="#return-stl-iterator" id="id100" name="id100">12.8 return_stl_iterator</a></li>
+<li><a class="reference" href="#raw" id="id101" name="id101">12.9 raw</a></li>
+<li><a class="reference" href="#yield" id="id102" name="id102">12.10 yield</a></li>
</ul>
</div>
<div class="section" id="adopt">
Index: docs.rst
===================================================================
RCS file: /cvsroot/luabind/luabind/luabind/doc/docs.rst,v
retrieving revision 1.25.2.10
retrieving revision 1.25.2.11
diff -u -d -r1.25.2.10 -r1.25.2.11
--- docs.rst 24 Oct 2005 22:24:54 -0000 1.25.2.10
+++ docs.rst 24 Oct 2005 23:11:46 -0000 1.25.2.11
@@ -102,7 +102,9 @@
- GCC 3.0.4 (Debian/Linux)
- GCC 3.1 (SunOS 5.8)
- GCC 3.2 (cygwin)
- - GCC 3.3.1 (cygwin)
+ - GCC 3.3.1 (cygwin)
+ - GCC 3.3 (Apple, MacOS X)
+ - GCC 4.0 (Apple, MacOS X)
It has been confirmed not to work with:
@@ -122,8 +124,8 @@
To keep down the compilation-time luabind is built as a library. This means you
have to either build it and link against it, or include its source files in
your project. You also have to make sure the luabind directory is somewhere in
-your compiler's include path. It requires `Boost`_ 1.32.0 to be installed (only
-boost headers). It also requires that Lua is installed.
+your compiler's include path. It requires `Boost`_ 1.32.0 or 1.33.0 to be
+installed (only boost headers). It also requires that Lua is installed.
The official way of building luabind is with `Boost.Build V2`_. To properly build
luabind with Boost.Build you need to set two environment variables:
@@ -137,7 +139,7 @@
``$(LUA_PATH)/lib/.``
For backward compatibility, there is also a makefile in the root-directory that
-will build the library and the test program. If you are using a UNIX-system (or
+will build the library and the test programs. If you are using a UNIX-system (or
cygwin) they will make it easy to build luabind as a static library. If you are
using Visual Studio it may be easier to include the files in the src directory
in your project.
@@ -544,6 +546,39 @@
const member function (it can be called on const objects).
+Overloaded member functions
+---------------------------
+
+When binding more than one overloads of a member function, or just binding
+one overload of an overloaded member function, you have to disambiguate
+the member function pointer you pass to ``def``. To do this, you can use an
+ordinary C-style cast, to cast it to the right overload. To do this, you have
+to know how to express member function types in C++, here's a short tutorial
+(for more info, refer to your favourite book on C++).
+
+The syntax for member function pointer follows:
+
+.. parsed-literal::
+
+ *return-value* (*class-name*::\*)(*arg1-type*, *arg2-type*, *...*)
+
+Here's an example illlustrating this::
+
+ struct A
+ {
+ void f(int);
+ void f(int, int);
+ };
+
+::
+
+ class_<A>()
+ .def("f", (void(A::*)(int))&A::f)
+
+This selects the first overload of the function ``f`` to bind. The second
+overload is not bound.
+
+
Properties
----------
@@ -769,6 +804,9 @@
def("f", &f)
]**;
+In this example, ``f`` will behave like a static member function of the class
+``foo``, and the class ``nested`` will behave like a nested class of ``foo``.
+
It's also possible to add namespace's to classes using the same syntax.
|