Last change
on this file since 29 was
29,
checked in by landauf, 17 years ago
|
updated boost from 1_33_1 to 1_34_1
|
File size:
849 bytes
|
Line | |
---|
1 | // Copyright Ralf W. Grosse-Kunstleve 2002-2004. Distributed under the Boost |
---|
2 | // Software License, Version 1.0. (See accompanying |
---|
3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) |
---|
4 | |
---|
5 | #include <boost/python/module.hpp> |
---|
6 | #include <boost/python/def.hpp> |
---|
7 | #include <string> |
---|
8 | |
---|
9 | namespace { // Avoid cluttering the global namespace. |
---|
10 | |
---|
11 | // A couple of simple C++ functions that we want to expose to Python. |
---|
12 | std::string greet() { return "hello, world"; } |
---|
13 | int square(int number) { return number * number; } |
---|
14 | } |
---|
15 | |
---|
16 | namespace python = boost::python; |
---|
17 | |
---|
18 | // Python requires an exported function called init<module-name> in every |
---|
19 | // extension module. This is where we build the module contents. |
---|
20 | BOOST_PYTHON_MODULE(getting_started1) |
---|
21 | { |
---|
22 | // Add regular functions to the module. |
---|
23 | python::def("greet", greet); |
---|
24 | python::def("square", square); |
---|
25 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.