mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-17 01:26:45 +00:00
Apply Namer to Java. (#7194)
* Started applying Namer to Java. - Java didn't previously have keyword escaping - Added prefixes and suffixes to the Namer methods - TODO: migrate previous namer applications to using pre/suffixes - Java methods / functions are interesting, it's mostly camel case except when it involves a struct/enum name. That section is Keep case - I changed the casing for some internal arguments/variables. This violates the "don't change genfiles" rule that I've been using but it shouldn't break user code. - LegacyJavaMethod2 is interesting. Basically, Java has a "mixed" case convention where it's camel case, except for the type/variant name itself, which is keep case. So a type foo_bar would become getfoo_bar instead of getFooBar. * small fix * Namer for Namespaces * removed unused parameter, add const everywhere * Remove unused argument * More unused args * Use mutable reference out parameters * Made more strings const and inlined const empty strings * remove do not submit Co-authored-by: Casper Neo <cneo@google.com>
This commit is contained in:
17
src/namer.h
17
src/namer.h
@@ -112,6 +112,11 @@ class Namer {
|
||||
return Method(s.name);
|
||||
}
|
||||
|
||||
virtual std::string Method(const std::string &pre,
|
||||
const std::string &suf) const {
|
||||
return Format(pre + "_" + suf, config_.methods);
|
||||
}
|
||||
|
||||
virtual std::string Method(const std::string &s) const {
|
||||
return Format(s, config_.methods);
|
||||
}
|
||||
@@ -128,6 +133,15 @@ class Namer {
|
||||
return Format(s, config_.variables);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
std::string Variable(const std::string &p, const T &s) const {
|
||||
return Format(p + "_" + s.name, config_.variables);
|
||||
}
|
||||
virtual std::string Variable(const std::string &p,
|
||||
const std::string &s) const {
|
||||
return Format(p + "_" + s, config_.variables);
|
||||
}
|
||||
|
||||
virtual std::string Namespace(const std::string &s) const {
|
||||
return Format(s, config_.namespaces);
|
||||
}
|
||||
@@ -191,6 +205,9 @@ class Namer {
|
||||
virtual std::string Type(const std::string &s) const {
|
||||
return Format(s, config_.types);
|
||||
}
|
||||
virtual std::string Type(const std::string &t, const std::string &s) const {
|
||||
return Format(t + "_" + s, config_.types);
|
||||
}
|
||||
|
||||
virtual std::string ObjectType(const std::string &s) const {
|
||||
return config_.object_prefix + Type(s) + config_.object_suffix;
|
||||
|
||||
Reference in New Issue
Block a user