return capitalize(program_name_);
}
+string t_st_generator::prefix(string class_name) {
+ string prefix = program_->get_smalltalk_prefix();
+ string name = capitalize(class_name);
+ name = prefix.empty() ? name : (prefix + name);
+ return name;
+}
+
string t_st_generator::client_class_name() {
return capitalize(service_name_) + "Client";
}
}
void t_st_generator::generate_force_consts() {
- f_ << class_name() << " enums keysAndValuesDo: [:k :v | " <<
- class_name() << " enums at: k put: v value].!" << endl;
+ f_ << prefix(class_name()) << " enums keysAndValuesDo: [:k :v | " <<
+ prefix(class_name()) << " enums at: k put: v value].!" << endl;
- f_ << class_name() << " constants keysAndValuesDo: [:k :v | " <<
- class_name() << " constants at: k put: v value].!" << endl;
+ f_ << prefix(class_name()) << " constants keysAndValuesDo: [:k :v | " <<
+ prefix(class_name()) << " constants at: k put: v value].!" << endl;
}
void t_st_generator::generate_typedef(t_typedef* ttypedef) {}
void t_st_generator::st_class_def(std::ofstream &out, string name) {
- out << "Object subclass: #" << capitalize(name) << endl;
+ out << "Object subclass: #" << prefix(name) << endl;
indent_up();
out << indent() << "instanceVariableNames: ''" << endl <<
indent() << "classVariableNames: ''" << endl <<
tinfo = localtime(&rawtime);
strftime(timestr, 50, "%m/%d/%Y %H:%M", tinfo);
- out << "!" << capitalize(cls) <<
+ out << "!" << prefix(cls) <<
" methodsFor: '"+category+"' stamp: 'thrift " << timestr << "'!\n" <<
name << endl;
}
void t_st_generator::generate_class_side_definition() {
- f_ << class_name() << " class" << endl <<
+ f_ << prefix(class_name()) << " class" << endl <<
"\tinstanceVariableNames: 'constants enums'!" << endl << endl;
st_accessors(f_, class_name() + " class", "enums");
st_accessors(f_, class_name() + " class", "constants");
- f_ << class_name() << " enums: Dictionary new!" << endl;
- f_ << class_name() << " constants: Dictionary new!" << endl;
+ f_ << prefix(class_name()) << " enums: Dictionary new!" << endl;
+ f_ << prefix(class_name()) << " constants: Dictionary new!" << endl;
f_ << endl;
}
void t_st_generator::generate_enum(t_enum* tenum) {
string cls_name = program_name_ + capitalize(tenum->get_name());
- f_ << class_name() << " enums at: '" << tenum->get_name() << "' put: [" <<
+ f_ << prefix(class_name()) << " enums at: '" << tenum->get_name() << "' put: [" <<
"(Dictionary new " << endl;
vector<t_enum_value*> constants = tenum->get_constants();
string name = tconst->get_name();
t_const_value* value = tconst->get_value();
- f_ << class_name() << " constants at: '" << name << "' put: [" <<
+ f_ << prefix(class_name()) << " constants at: '" << name << "' put: [" <<
render_const_value(type, value) << "]!" << endl << endl;
}
else
out << "Object";
- out << " subclass: #" << capitalize(type_name(tstruct)) << endl <<
+ out << " subclass: #" << prefix(type_name(tstruct)) << endl <<
"\tinstanceVariableNames: '";
if (members.size() > 0) {
out << "[|" << desc << " " << val << "|" << endl;
indent_up();
- out << indent() << val << " := " <<
- capitalize(clsName) << " new." << endl;
-
+ //This is nasty, but without it we'll break things by prefixing TResult.
+ string name = ((capitalize(clsName) == "TResult") ? capitalize(clsName) : prefix(clsName));
+ out << indent() << val << " := " << name << " new." << endl;
+
out << indent() << "iprot readStructBegin." << endl <<
indent() << "[" << desc << " := iprot readFieldBegin." << endl <<
indent() << desc << " type = TType stop] whileFalse: [|" << found << "|" << endl;
extends_client = extends + "Client";
}
- f_ << extends_client << " subclass: #" << client_class_name() << endl <<
+ f_ << extends_client << " subclass: #" << prefix(client_class_name()) << endl <<
"\tinstanceVariableNames: ''\n" <<
"\tclassVariableNames: ''\n" <<
"\tpoolDictionaries: ''\n" <<
std::string class_name();
std::string client_class_name();
+ std::string prefix(std::string name);
std::string declare_field(t_field* tfield);
- std::string sanitize(std::string s);
+ std::string sanitize(std::string s);
std::string type_name(t_type* ttype);
- std::string function_signature(t_function* tfunction);
+ std::string function_signature(t_function* tfunction);
std::string argument_list(t_struct* tstruct);
- std::string function_types_comment(t_function* fn);
+ std::string function_types_comment(t_function* fn);
std::string type_to_enum(t_type* ttype);
- std::string a_type(t_type* type);
+ std::string a_type(t_type* type);
bool is_vowel(char c);
std::string temp_name();
std::string generated_category();