Created
May 1, 2009 19:08
-
-
Save aristidb/105192 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| g++ $(pkg-config flusspferd --libs --cflags) -I/usr/include/python2.6/ -Wall -W -std=c++98 -pedantic-errors -Wno-long-long flusspferd.cpp -lpython2.6 -lboost_python -shared -fPIC -o flusspferd.so |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import flusspferd | |
| scope = flusspferd.current_context_scope(flusspferd.context_create()) | |
| str = flusspferd.root_string("Hello, World!\n") | |
| flusspferd.gc() | |
| flusspferd.set_property(flusspferd.global_(), "str", str) | |
| v = flusspferd.evaluate("str.replace('World', 'Flusspferd')") | |
| print v.to_std_string() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <boost/python.hpp> | |
| #include <flusspferd.hpp> | |
| using namespace boost::python; | |
| using namespace flusspferd; | |
| namespace { | |
| void set_property(flusspferd::object &o, std::string const &str, root_string const &rs) { | |
| o.set_property(str, rs); | |
| } | |
| value evaluate_wrapper(std::string const &s) { | |
| return flusspferd::evaluate(s); | |
| } | |
| } | |
| BOOST_PYTHON_MODULE(flusspferd) { | |
| class_<value>("value") | |
| .def("to_std_string", &value::to_std_string); | |
| class_<context>("context"); | |
| def("context_create", &context::create); // maybe this should be a module flusspferd.context | |
| class_<current_context_scope>("current_context_scope", boost::python::init<context>()); | |
| def("gc", &flusspferd::gc); | |
| def("evaluate", &evaluate_wrapper); | |
| class_<flusspferd::root_string, boost::noncopyable>("root_string", boost::python::init<std::string>()); | |
| def("global_", &flusspferd::global); | |
| class_<flusspferd::object>("object"); | |
| def("set_property", &set_property); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment