Fix Java interface with SplitSource.

This commit is contained in:
levlam 2023-08-07 01:47:43 +03:00
parent ac74ecaad5
commit a7f8ff6eef
4 changed files with 8 additions and 8 deletions

View File

@ -168,7 +168,7 @@ static jint register_native(JavaVM *vm) {
#undef TD_OBJECT
td::jni::init_vars(env, PACKAGE_NAME);
td::td_api::set_package_name(PACKAGE_NAME);
td::td_api::get_package_name_ref() = PACKAGE_NAME;
return JAVA_VERSION;
}

View File

@ -130,7 +130,7 @@ class DoxygenTlDocumentationGenerator extends TlDocumentationGenerator
strpos($tline, 'result += ') === 0 || strpos($tline, 'result = ') || strpos($tline, ' : values') ||
strpos($line, 'JNIEnv') || strpos($line, 'jfieldID') || $tline === 'virtual ~Object() {' ||
$tline === 'virtual void store(TlStorerToString &s, const char *field_name) const = 0;' ||
$tline === 'void set_package_name(const char *new_package_name);';
$tline === 'const char *&get_package_name_ref();';
}
protected function isHeaderLine($line)

View File

@ -13,9 +13,9 @@ namespace td {
std::string TD_TL_writer_jni_cpp::gen_output_begin_once() const {
return TD_TL_writer_cpp::gen_output_begin_once() +
"\nstatic const char *package_name = \"Call set_package_name\";\n\n"
"void set_package_name(const char *new_package_name) {\n"
" package_name = new_package_name;\n"
"\nconst char *&get_package_name_ref() {\n"
" static const char *package_name = \"Package name must be initialized first\";\n"
" return package_name;\n"
"}\n";
}
@ -538,7 +538,7 @@ std::string TD_TL_writer_jni_cpp::gen_basic_java_class_name(std::string name) co
}
std::string TD_TL_writer_jni_cpp::gen_java_class_name(std::string name) const {
return "(PSLICE() << package_name << \"/TdApi$" + gen_basic_java_class_name(name) + "\").c_str()";
return "(PSLICE() << get_package_name_ref() << \"/TdApi$" + gen_basic_java_class_name(name) + "\").c_str()";
}
std::string TD_TL_writer_jni_cpp::gen_type_signature(const tl::tl_tree_type *tree_type) const {
@ -600,7 +600,7 @@ std::string TD_TL_writer_jni_cpp::gen_additional_function(const std::string &fun
std::string new_type_signature = "(PSLICE()";
std::size_t pos = type_signature.find("%PACKAGE_NAME%");
while (pos != std::string::npos) {
new_type_signature += " << \"" + type_signature.substr(0, pos) + "\" << package_name";
new_type_signature += " << \"" + type_signature.substr(0, pos) + "\" << get_package_name_ref()";
type_signature = type_signature.substr(pos + 14);
pos = type_signature.find("%PACKAGE_NAME%");
}

View File

@ -87,7 +87,7 @@ std::string TD_TL_writer_jni_h::gen_output_begin_once() const {
";\n"
"using BaseObject = " +
gen_base_tl_class_name());
return result + "void set_package_name(const char *new_package_name);\n\n";
return result + "const char *&get_package_name_ref();\n\n";
}
std::string TD_TL_writer_jni_h::gen_class_begin(const std::string &class_name, const std::string &base_class_name,