Commit 093e367e authored by Botond Baranyi's avatar Botond Baranyi
Browse files

OOP: code generated for 'finally' now only uses C++11 if it is supported by...


OOP: code generated for 'finally' now only uses C++11 if it is supported by the C++ compiler (Bug 568899)
Signed-off-by: Botond Baranyi's avatarBotond Baranyi <botond.baranyi@ericsson.com>
Change-Id: I75568c10eae09937187317bb6d03cac2e0cfe636
parent cfb8ff06
...@@ -518,12 +518,12 @@ namespace Ttcn { ...@@ -518,12 +518,12 @@ namespace Ttcn {
} }
if (finally_block != NULL) { if (finally_block != NULL) {
string tmp_id = get_scope_mod_gen()->get_temporary_id(); string tmp_id = get_scope_mod_gen()->get_temporary_id();
/*str = mputprintf(str, #if __cplusplus < 201103L
str = mputprintf(str,
"class %s_finally {\n" "class %s_finally {\n"
"public:\n", tmp_id.c_str()); "public:\n", tmp_id.c_str());
// TODO: all local declarations (or those referenced in the 'finally' block) need to // TODO: all local declarations (or those referenced in the 'finally' block) need to
// be added as members of this class, so the destructor can reach them // be added as members of this class, so the destructor can reach them
// or the C++11 code could be used...
if (include_location_info) { if (include_location_info) {
str = mputprintf(str, str = mputprintf(str,
"TTCN_Location& current_location;\n" "TTCN_Location& current_location;\n"
...@@ -538,12 +538,14 @@ namespace Ttcn { ...@@ -538,12 +538,14 @@ namespace Ttcn {
"};\n" "};\n"
"%s_finally %s%s;\n", "%s_finally %s%s;\n",
tmp_id.c_str(), tmp_id.c_str(), tmp_id.c_str(), tmp_id.c_str(),
include_location_info ? "(current_location)" : "");*/ include_location_info ? "(current_location)" : "");
#else
// C++11 version: // C++11 version:
str = mputprintf(str, str = mputprintf(str,
"FINALLY %s([&] {\n", tmp_id.c_str()); "FINALLY %s([&] {\n", tmp_id.c_str());
str = finally_block->generate_code(str, def_glob_vars, src_glob_vars); str = finally_block->generate_code(str, def_glob_vars, src_glob_vars);
str = mputstr(str, "});\n"); str = mputstr(str, "});\n");
#endif
} }
if (catch_blocks.size() > 0) { if (catch_blocks.size() > 0) {
str = mputstr(str, "try {\n"); str = mputstr(str, "try {\n");
......
...@@ -284,6 +284,7 @@ public: ...@@ -284,6 +284,7 @@ public:
T& operator()() { return *exc_ptr->val_ptr; } T& operator()() { return *exc_ptr->val_ptr; }
}; };
#if __cplusplus >= 201103L
class FINALLY class FINALLY
{ {
std::function<void(void)> functor; std::function<void(void)> functor;
...@@ -294,6 +295,7 @@ public: ...@@ -294,6 +295,7 @@ public:
functor(); functor();
} }
}; };
#endif // C++11
#endif /* OOP_HH */ #endif /* OOP_HH */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment