summaryrefslogtreecommitdiff
path: root/src/idl_gen_java.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/idl_gen_java.cpp')
-rw-r--r--src/idl_gen_java.cpp51
1 files changed, 22 insertions, 29 deletions
diff --git a/src/idl_gen_java.cpp b/src/idl_gen_java.cpp
index b7c9d564..4eb8274f 100644
--- a/src/idl_gen_java.cpp
+++ b/src/idl_gen_java.cpp
@@ -69,9 +69,10 @@ static std::set<std::string> JavaKeywords() {
};
}
-static const TypedFloatConstantGenerator JavaFloatGen("Double.", "Float.", "NaN",
- "POSITIVE_INFINITY",
- "NEGATIVE_INFINITY");
+static const TypedFloatConstantGenerator JavaFloatGen("Double.", "Float.",
+ "NaN",
+ "POSITIVE_INFINITY",
+ "NEGATIVE_INFINITY");
static const CommentConfig comment_config = {
"/**",
@@ -79,7 +80,7 @@ static const CommentConfig comment_config = {
" */",
};
-} // namespace
+} // namespace
class JavaGenerator : public BaseGenerator {
struct FieldArrayLength {
@@ -89,16 +90,15 @@ class JavaGenerator : public BaseGenerator {
public:
JavaGenerator(const Parser &parser, const std::string &path,
- const std::string &file_name,
- const std::string &package_prefix)
+ const std::string &file_name, const std::string &package_prefix)
: BaseGenerator(parser, path, file_name, "", ".", "java"),
- cur_name_space_(nullptr),
+ cur_name_space_(nullptr),
namer_(WithFlagOptions(JavaDefaultConfig(), parser.opts, path),
JavaKeywords()) {
if (!package_prefix.empty()) {
std::istringstream iss(package_prefix);
std::string component;
- while(std::getline(iss, component, '.')) {
+ while (std::getline(iss, component, '.')) {
package_prefix_ns_.components.push_back(component);
}
package_prefix_ = package_prefix_ns_.GetFullyQualifiedName("") + ".";
@@ -184,10 +184,8 @@ class JavaGenerator : public BaseGenerator {
code = "// " + std::string(FlatBuffersGeneratedWarning()) + "\n\n";
Namespace combined_ns = package_prefix_ns_;
- std::copy(
- ns.components.begin(),
- ns.components.end(),
- std::back_inserter(combined_ns.components));
+ std::copy(ns.components.begin(), ns.components.end(),
+ std::back_inserter(combined_ns.components));
const std::string namespace_name = FullNamespace(".", combined_ns);
if (!namespace_name.empty()) {
@@ -368,9 +366,9 @@ class JavaGenerator : public BaseGenerator {
FLATBUFFERS_ASSERT(value.type.enum_def);
auto &enum_def = *value.type.enum_def;
auto enum_val = enum_def.FindByValue(value.constant);
- return
- enum_val ? Prefixed(namer_.NamespacedEnumVariant(enum_def, *enum_val))
- : value.constant;
+ return enum_val
+ ? Prefixed(namer_.NamespacedEnumVariant(enum_def, *enum_val))
+ : value.constant;
}
std::string GenDefaultValue(const FieldDef &field) const {
@@ -1653,9 +1651,9 @@ class JavaGenerator : public BaseGenerator {
break;
case BASE_TYPE_UNION:
array_type = "int";
- element_type =
- Prefixed(namer_.NamespacedType(*field.value.type.enum_def))
- + "Union";
+ element_type = Prefixed(namer_.NamespacedType(
+ *field.value.type.enum_def)) +
+ "Union";
to_array = element_type + ".pack(builder, _o." +
namer_.Method("get", property_name) + "()[_j])";
break;
@@ -2007,8 +2005,7 @@ class JavaGenerator : public BaseGenerator {
case BASE_TYPE_UNION: {
if (wrap_in_namespace) {
- type_name =
- Prefixed(namer_.NamespacedType(*type.enum_def)) + "Union";
+ type_name = Prefixed(namer_.NamespacedType(*type.enum_def)) + "Union";
} else {
type_name = namer_.Type(*type.enum_def) + "Union";
}
@@ -2042,15 +2039,13 @@ class JavaGenerator : public BaseGenerator {
type_name.replace(type_name.length() - type_name_length,
type_name_length, new_type_name);
} else if (type.element == BASE_TYPE_UNION) {
- type_name =
- Prefixed(namer_.NamespacedType(*type.enum_def)) + "Union";
+ type_name = Prefixed(namer_.NamespacedType(*type.enum_def)) + "Union";
}
break;
}
case BASE_TYPE_UNION: {
- type_name =
- Prefixed(namer_.NamespacedType(*type.enum_def)) + "Union";
+ type_name = Prefixed(namer_.NamespacedType(*type.enum_def)) + "Union";
break;
}
default: break;
@@ -2192,12 +2187,11 @@ class JavaGenerator : public BaseGenerator {
std::string package_prefix_;
Namespace package_prefix_ns_;
-
};
} // namespace java
static bool GenerateJava(const Parser &parser, const std::string &path,
- const std::string &file_name) {
+ const std::string &file_name) {
java::JavaGenerator generator(parser, path, file_name,
parser.opts.java_package_prefix);
return generator.generate();
@@ -2213,9 +2207,8 @@ class JavaCodeGenerator : public CodeGenerator {
return Status::OK;
}
- Status GenerateCode(const uint8_t *buffer, int64_t length) override {
- (void)buffer;
- (void)length;
+ Status GenerateCode(const uint8_t *, int64_t,
+ const CodeGenOptions &) override {
return Status::NOT_IMPLEMENTED;
}