summaryrefslogtreecommitdiffstats
path: root/sca-cpp/trunk/modules/python/mod-python.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'sca-cpp/trunk/modules/python/mod-python.cpp')
-rw-r--r--sca-cpp/trunk/modules/python/mod-python.cpp27
1 files changed, 10 insertions, 17 deletions
diff --git a/sca-cpp/trunk/modules/python/mod-python.cpp b/sca-cpp/trunk/modules/python/mod-python.cpp
index 956edf1059..eaaeeb8e3e 100644
--- a/sca-cpp/trunk/modules/python/mod-python.cpp
+++ b/sca-cpp/trunk/modules/python/mod-python.cpp
@@ -40,42 +40,35 @@ namespace modeval {
/**
* Apply a lifecycle start or restart event.
*/
-struct pythonLifecycle {
- python::PythonRuntime& py;
- pythonLifecycle(python::PythonRuntime& py) : py(py) {
- }
- const value operator()(const list<value>& params) const {
- const value func = car(params);
- if (func == "pythonRuntime")
- return (gc_ptr<value>)(value*)&py;
- return lambda<value(const list<value>&)>();
- }
-};
-
const value applyLifecycle(unused const list<value>& params) {
// Create a Python runtime
python::PythonRuntime& py = *(new (gc_new<python::PythonRuntime>()) python::PythonRuntime());
// Return the function to invoke on subsequent events
- return failable<value>(lambda<value(const list<value>&)>(pythonLifecycle(py)));
+ return failable<value>(lvvlambda([&py](const list<value>& params) -> const value {
+ const value func = car(params);
+ if (func == "pythonRuntime")
+ return (gc_ptr<value>)(value*)&py;
+ return lvvlambda();
+ }));
}
/**
* Evaluate a Python component implementation and convert it to an applicable
* lambda function.
*/
-const failable<lambda<value(const list<value>&)> > evalImplementation(const string& path, const value& impl, const list<value>& px, const lambda<value(const list<value>&)>& lifecycle) {
+const failable<lvvlambda > evalImplementation(const string& path, const value& impl, const list<value>& px, const lvvlambda& lifecycle) {
const string itype(elementName(impl));
if (contains(itype, ".python")) {
- const value* p = (gc_ptr<value>)lifecycle(mklist<value>("pythonRuntime"));
+ const value* const p = (gc_ptr<value>)lifecycle(mklist<value>("pythonRuntime"));
return modpython::evalImplementation(path, impl, px, *(python::PythonRuntime*)p);
}
if (contains(itype, ".cpp"))
return modcpp::evalImplementation(path, impl, px);
if (contains(itype, ".widget"))
- return mkfailure<lambda<value(const list<value>&)> >(string("Unsupported implementation type: ") + itype, -1, false);
- return mkfailure<lambda<value(const list<value>&)> >(string("Unsupported implementation type: ") + itype);
+ return mkfailure<lvvlambda >(string("Unsupported implementation type: ") + itype, -1, false);
+ return mkfailure<lvvlambda >(string("Unsupported implementation type: ") + itype);
}
}