X-Git-Url: http://developer.intra2net.com/git/?p=libt2n;a=blobdiff_plain;f=codegen%2Fmain.cpp;h=7271b228a93dc3246ccc07c6fd9b8fc1320d8acf;hp=75e58a05560100534522d1b8a5b3d6cb21a99a0b;hb=HEAD;hpb=19facd8558fe2e32ce843860b40631ebe03ff3cf diff --git a/codegen/main.cpp b/codegen/main.cpp index 75e58a0..7271b22 100644 --- a/codegen/main.cpp +++ b/codegen/main.cpp @@ -30,9 +30,10 @@ #include #include #include -#ifdef HAVE_CONFIG_H +#include + #include "config.h" -#endif + //! map group to class name @@ -142,6 +143,15 @@ struct parse_error : public std::runtime_error {} }; +struct error_name_too_long : public std::runtime_error +{ + error_name_too_long(const std::string &name) + : std::runtime_error("symbol name '" + name + "' too long for serialization (" + + boost::lexical_cast(name.length()) + ">" + + boost::lexical_cast(BOOST_SERIALIZATION_MAX_KEY_SIZE-1) + ")") + {} +}; + //! get type by id /*! \return type name or empty string on error @@ -224,11 +234,17 @@ struct t2n_procedure std::string ret_classname() const { - return name+mangled+"_res"; + std::string result = name+mangled+"_res"; + if (result.length() >= BOOST_SERIALIZATION_MAX_KEY_SIZE) + throw error_name_too_long(result); + return result; } std::string cmd_classname() const { - return name+mangled+"_cmd"; + std::string result = name+mangled+"_cmd"; + if (result.length() >= BOOST_SERIALIZATION_MAX_KEY_SIZE) + throw error_name_too_long(result); + return result; } bool hasReturn() const {return !ret_type.isVoid();} };