summaryrefslogtreecommitdiffstats
path: root/sca-cpp/trunk/modules/python/mod-python.cpp
diff options
context:
space:
mode:
authorjsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68>2012-12-11 04:03:29 +0000
committerjsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68>2012-12-11 04:03:29 +0000
commit86b1de85536e93c59a25702a5a2d3e384202ffd2 (patch)
treec61d91970980199c597304ddcb01919993fbeb82 /sca-cpp/trunk/modules/python/mod-python.cpp
parent5f29c3b769fcdb2532d4948aa1c649d4330304b9 (diff)
More changes to port to C++11, adjust to use the new JSON support, and cleanup rest of the modules.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1419987 13f79535-47bb-0310-9956-ffa450edef68
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);
}
}