small refactor to GenSetter method

This commit is contained in:
Maor Itzkovitch 2015-08-01 19:28:22 +03:00
parent f706a42951
commit 6be146d67f
1 changed files with 10 additions and 9 deletions

View File

@ -428,18 +428,19 @@ static std::string GenGetter(const LanguageParameters &lang,
}
}
// Direct mutation is only allowed for scalar fields.
// Hence a setter method will only be generated for such fields.
static std::string GenSetter(const LanguageParameters &lang,
const Type &type) {
switch (type.base_type) {
case BASE_TYPE_STRUCT: return "";
default: {
if (IsScalar(type.base_type)) {
std::string setter = "bb." + FunctionStart(lang, 'P') + "ut";
if (GenTypeBasic(lang, type) != "byte" &&
type.base_type != BASE_TYPE_BOOL) {
setter += MakeCamel(GenTypeGet(lang, type));
}
return setter;
}
} else {
return "";
}
}