exceptionstruct bremse raus
diff --git a/compiler/cpp/src/thrift/parse/t_function.h b/compiler/cpp/src/thrift/parse/t_function.h
index 57cf5ff..d2cb19b 100644
--- a/compiler/cpp/src/thrift/parse/t_function.h
+++ b/compiler/cpp/src/thrift/parse/t_function.h
@@ -85,17 +85,23 @@
void validate() const {
get_returntype()->validate();
+
+#ifndef ALLOW_EXCEPTIONS_AS_TYPE
if (get_returntype()->get_true_type()->is_xception()) {
failure("method %s(): exception type \"%s\" cannot be used as function return", get_name().c_str(), get_returntype()->get_name().c_str());
}
+#endif
std::vector<t_field*>::const_iterator it;
std::vector<t_field*> list = get_arglist()->get_members();
for(it=list.begin(); it != list.end(); ++it) {
(*it)->get_type()->validate();
+
+#ifndef ALLOW_EXCEPTIONS_AS_TYPE
if( (*it)->get_type()->get_true_type()->is_xception()) {
failure("method %s(): exception type \"%s\" cannot be used as function argument %s", get_name().c_str(), (*it)->get_type()->get_name().c_str(), (*it)->get_name().c_str());
}
+#endif
}
}
diff --git a/compiler/cpp/src/thrift/parse/t_list.h b/compiler/cpp/src/thrift/parse/t_list.h
index 5daa412..162281c 100644
--- a/compiler/cpp/src/thrift/parse/t_list.h
+++ b/compiler/cpp/src/thrift/parse/t_list.h
@@ -35,9 +35,11 @@
bool is_list() const override { return true; }
void validate() const {
+#ifndef ALLOW_EXCEPTIONS_AS_TYPE
if( get_elem_type()->get_true_type()->is_xception()) {
failure("exception type \"%s\" cannot be used inside a list", get_elem_type()->get_name().c_str());
}
+#endif
}
private:
diff --git a/compiler/cpp/src/thrift/parse/t_map.h b/compiler/cpp/src/thrift/parse/t_map.h
index 444fca7..30a8b06 100644
--- a/compiler/cpp/src/thrift/parse/t_map.h
+++ b/compiler/cpp/src/thrift/parse/t_map.h
@@ -38,12 +38,14 @@
bool is_map() const override { return true; }
void validate() const {
+#ifndef ALLOW_EXCEPTIONS_AS_TYPE
if( get_key_type()->get_true_type()->is_xception()) {
failure("exception type \"%s\" cannot be used inside a map", get_key_type()->get_name().c_str());
}
if( get_val_type()->get_true_type()->is_xception()) {
failure("exception type \"%s\" cannot be used inside a map", get_val_type()->get_name().c_str());
}
+#endif
}
private:
diff --git a/compiler/cpp/src/thrift/parse/t_set.h b/compiler/cpp/src/thrift/parse/t_set.h
index 4a02dcc..88de93f 100644
--- a/compiler/cpp/src/thrift/parse/t_set.h
+++ b/compiler/cpp/src/thrift/parse/t_set.h
@@ -37,9 +37,11 @@
bool is_set() const override { return true; }
void validate() const {
+#ifndef ALLOW_EXCEPTIONS_AS_TYPE
if( get_elem_type()->get_true_type()->is_xception()) {
failure("exception type \"%s\" cannot be used inside a set", get_elem_type()->get_name().c_str());
}
+#endif
}
private:
diff --git a/compiler/cpp/src/thrift/parse/t_struct.h b/compiler/cpp/src/thrift/parse/t_struct.h
index 941712d..3aa67c0 100644
--- a/compiler/cpp/src/thrift/parse/t_struct.h
+++ b/compiler/cpp/src/thrift/parse/t_struct.h
@@ -112,9 +112,8 @@
const members_type& get_sorted_members() const { return members_in_id_order_; }
bool is_struct() const override { return !is_xception_; }
-
bool is_xception() const override { return is_xception_; }
-
+ bool is_method_xcepts() const override { return is_method_xcepts_; }
bool is_union() const { return is_union_; }
t_field* get_field_by_name(std::string field_name) {
@@ -144,11 +143,14 @@
std::vector<t_field*> list = get_members();
for(it=list.begin(); it != list.end(); ++it) {
(*it)->get_type()->validate();
+
+#ifndef ALLOW_EXCEPTIONS_AS_TYPE
if (!is_method_xcepts_) { // this is in fact the only legal usage for any exception type
if( (*it)->get_type()->get_true_type()->is_xception()) {
failure("%s %s: exception type \"%s\" cannot be used as member field type %s", what.c_str(), get_name().c_str(), (*it)->get_type()->get_name().c_str(), (*it)->get_name().c_str());
}
}
+#endif
}
}
diff --git a/compiler/cpp/src/thrift/parse/t_type.h b/compiler/cpp/src/thrift/parse/t_type.h
index f408242..d087601 100644
--- a/compiler/cpp/src/thrift/parse/t_type.h
+++ b/compiler/cpp/src/thrift/parse/t_type.h
@@ -26,6 +26,8 @@
#include <stdint.h>
#include <string>
+#define ALLOW_EXCEPTIONS_AS_TYPE
+
class t_program;
/**
@@ -54,6 +56,7 @@
virtual bool is_enum() const { return false; }
virtual bool is_struct() const { return false; }
virtual bool is_xception() const { return false; }
+ virtual bool is_method_xcepts() const { return false; }
virtual bool is_container() const { return false; }
virtual bool is_list() const { return false; }
virtual bool is_set() const { return false; }