2
0
mirror of https://github.com/boostorg/python.git synced 2026-01-24 18:12:43 +00:00

Remove Boost.Python v1 from main trunk

[SVN r15723]
This commit is contained in:
Dave Abrahams
2002-10-05 04:37:49 +00:00
parent 8207dc756a
commit 30d9331079
106 changed files with 88 additions and 20334 deletions

View File

@@ -21,25 +21,20 @@ namespace { // Avoid cluttering the global namespace.
}
}
#include <boost/python/class_builder.hpp>
namespace python = boost::python;
#include <boost/python/class.hpp>
#include <boost/python/module.hpp>
#include <boost/python/def.hpp>
BOOST_PYTHON_MODULE_INIT(getting_started2)
BOOST_PYTHON_MODULE(getting_started2)
{
// Create an object representing this extension module.
python::module_builder this_module("getting_started2");
// Create the Python type object for our extension class.
python::class_builder<hello> hello_class(this_module, "hello");
// Add the __init__ function.
hello_class.def(python::constructor<std::string>());
// Add a regular member function.
hello_class.def(&hello::greet, "greet");
// Add invite() as a regular function to the module.
this_module.def(invite, "invite");
// Even better, invite() can also be made a member of hello_class!!!
hello_class.def(invite, "invite");
using namespace boost::python;
class_<hello>("hello", init<std::string>())
// Add a regular member function.
.def("greet", &hello::greet)
// Add invite() as a member of hello!
.def("invite", invite)
;
// Also add invite() as a regular function to the module.
def("invite", invite);
}