indent_up();
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
indent(out) << "&" <<
- local_reflection_name("typespec", (*m_iter)->get_type()) << "," << endl;
+ local_reflection_name("typespec", (*m_iter)->get_type(), true) << "," << endl;
}
indent(out) << "&" <<
local_reflection_name("typespec", g_type_void) << "," << endl;
/**
* Returns the symbol name of the local reflection of a type.
*/
-string t_cpp_generator::local_reflection_name(const char* prefix, t_type* ttype) {
+string t_cpp_generator::local_reflection_name(const char* prefix, t_type* ttype, bool external) {
ttype = get_true_type(ttype);
// We have to use the program name as part of the identifier because
// trlo = Thrift Reflection LOcal.
string prog;
string name;
+ string nspace;
// TODO(dreiss): Would it be better to pregenerate the base types
// and put them in Thrift.{h,cpp} ?
name = ttype->get_ascii_fingerprint();
}
- return string() + "trlo_" + prefix + "_" + prog + "_" + name;
+ if (external &&
+ ttype->get_program() != NULL &&
+ ttype->get_program() != program_) {
+ nspace = namespace_prefix(ttype->get_program()->get_cpp_namespace());
+ }
+
+ return nspace + "trlo_" + prefix + "_" + prog + "_" + name;
}
string t_cpp_generator::get_include_prefix(const t_program& program) const {
std::string function_signature(t_function* tfunction, std::string prefix="", bool name_params=true);
std::string argument_list(t_struct* tstruct, bool name_params=true);
std::string type_to_enum(t_type* ttype);
- std::string local_reflection_name(const char*, t_type* ttype);
+ std::string local_reflection_name(const char*, t_type* ttype, bool external=false);
// These handles checking gen_dense_ and checking for duplicates.
void generate_local_reflection(std::ofstream& out, t_type* ttype, bool is_definition);