Last idl_gen_general.cpp update

This commit is contained in:
TGIshib 2016-08-27 00:04:25 +03:00
parent ea9ee4c99e
commit 1a18122e3f
1 changed files with 6 additions and 3 deletions

View File

@ -1215,7 +1215,8 @@ void GenStruct(StructDef &struct_def, std::string *code_ptr) {
code += "); }\n"; code += "); }\n";
} }
} }
if (struct_def.has_key) { if (struct_def.has_key && (lang_.language == IDLOptions::kJava ||
lang_.language == IDLOptions::kCSharp)) {
if (lang_.language == IDLOptions::kJava) { if (lang_.language == IDLOptions::kJava) {
code += "\n @Override\n protected int keysCompare("; code += "\n @Override\n protected int keysCompare(";
code += "Integer o1, Integer o2, ByteBuffer _bb) {"; code += "Integer o1, Integer o2, ByteBuffer _bb) {";
@ -1240,12 +1241,14 @@ void GenStruct(StructDef &struct_def, std::string *code_ptr) {
if (key_field->value.type.base_type == BASE_TYPE_STRING) { if (key_field->value.type.base_type == BASE_TYPE_STRING) {
code += " byte[] byteKey = "; code += " byte[] byteKey = ";
if (lang_.language == IDLOptions::kJava) if (lang_.language == IDLOptions::kJava)
code += "key.getBytes(StandardCharsets.UTF_8);\n"; code += "key.getBytes(java.nio.charset.StandardCharsets.UTF_8);\n";
else else
code += "System.Text.Encoding.UTF8.GetBytes(key);\n"; code += "System.Text.Encoding.UTF8.GetBytes(key);\n";
} }
code += " int vectorLocation = " + GenByteBufferLength("bb"); code += " int vectorLocation = " + GenByteBufferLength("bb");
code += " - vectorOffset.Value;\n int span = "; code += " - vectorOffset";
if (lang_.language == IDLOptions::kCSharp) code += ".Value";
code += ";\n int span = ";
code += "bb." + FunctionStart('G') + "etInt(vectorLocation), "; code += "bb." + FunctionStart('G') + "etInt(vectorLocation), ";
code += "middle, start = 0, comp, tableOffset; \n"; code += "middle, start = 0, comp, tableOffset; \n";
code += " vectorLocation += 4;\n"; code += " vectorLocation += 4;\n";