Generate Docygen-comments for td_api when JNI is enabled.

GitOrigin-RevId: dae3cea234beba9aee8283c24f28266620de82f2
This commit is contained in:
levlam 2018-01-21 15:24:00 +03:00
parent d8f13abb2c
commit 20cd6c7aca
3 changed files with 28 additions and 12 deletions

View File

@ -79,7 +79,7 @@ set(TL_GENERATE_JSON_SOURCE
if (NOT CMAKE_CROSSCOMPILING) if (NOT CMAKE_CROSSCOMPILING)
find_program(PHP_EXECUTABLE php) find_program(PHP_EXECUTABLE php)
if (PHP_EXECUTABLE AND NOT TD_ENABLE_JNI) if (PHP_EXECUTABLE)
set(GENERATE_COMMON_CMD generate_common && ${PHP_EXECUTABLE} DoxygenTlDocumentationGenerator.php scheme/td_api.tl auto/td/telegram/td_api.h) set(GENERATE_COMMON_CMD generate_common && ${PHP_EXECUTABLE} DoxygenTlDocumentationGenerator.php scheme/td_api.tl auto/td/telegram/td_api.h)
else() else()
set(GENERATE_COMMON_CMD generate_common) set(GENERATE_COMMON_CMD generate_common)

View File

@ -117,7 +117,9 @@ class DoxygenTlDocumentationGenerator extends TlDocumentationGenerator
$tline = trim($line); $tline = trim($line);
return empty($tline) || $tline[0] == '}' || $tline == 'public:' || strpos($line, '#pragma ') === 0 || return empty($tline) || $tline[0] == '}' || $tline == 'public:' || strpos($line, '#pragma ') === 0 ||
strpos($line, '#include <') === 0 || strpos($tline, 'return ') === 0 || strpos($tline, 'namespace') === 0 || strpos($line, '#include <') === 0 || strpos($tline, 'return ') === 0 || strpos($tline, 'namespace') === 0 ||
preg_match('/class [A-Za-z0-9_]*;/', $line) || $tline === 'if (value == nullptr) {'; preg_match('/class [A-Za-z0-9_]*;/', $line) || $tline === 'if (value == nullptr) {' ||
strpos($line, 'JNIEnv') || strpos($line, 'jfieldID') || $tline === 'virtual ~Object() {' ||
$tline == 'virtual void store(TlStorerToString &s, const char *field_name) const = 0;';
} }
protected function isHeaderLine($line) protected function isHeaderLine($line)
@ -135,9 +137,15 @@ class DoxygenTlDocumentationGenerator extends TlDocumentationGenerator
protected function fixLine($line) protected function fixLine($line)
{ {
if (strpos($line, 'ID = ') > 0 || strpos($line, 'ReturnType = ') > 0) { if (strpos($line, 'ID = ') > 0 || strpos($line, 'ReturnType = ') > 0 || strpos($line, 'using BaseObject = ') === 0) {
return substr($line, 0, strpos($line, '=')); return substr($line, 0, strpos($line, '='));
} }
if (strpos($line, 'class Function: ') === 0) {
return 'class Function';
}
if (strpos($line, 'class Object {') === 0 || strpos($line, 'class Object: public TlObject {') === 0) {
return 'class Object';
}
return $line; return $line;
} }
@ -152,7 +160,7 @@ class DoxygenTlDocumentationGenerator extends TlDocumentationGenerator
EOT EOT
); );
$this->addDocumentation('using BaseObject = ::td::TlObject;', <<<EOT $this->addDocumentation('using BaseObject', <<<EOT
/** /**
* This class is a base class for all TDLib API classes and functions. * This class is a base class for all TDLib API classes and functions.
*/ */
@ -189,10 +197,10 @@ EOT
* Casting an object to an incorrect type will lead to undefined bejaviour. * Casting an object to an incorrect type will lead to undefined bejaviour.
* Usage example: * Usage example:
* \\code * \\code
* td::tl_object_ptr<td::td_api::callState> call_state = ...; * td::td_api::object_ptr<td::td_api::callState> call_state = ...;
* switch (call_state->get_id()) { * switch (call_state->get_id()) {
* case td::td_api::callStatePending::ID: { * case td::td_api::callStatePending::ID: {
* auto state = td::move_tl_object_as<td::td_api::callStatePending>(call_state); * auto state = td::td_api::move_object_as<td::td_api::callStatePending>(call_state);
* // use state * // use state
* break; * break;
* } * }
@ -201,7 +209,7 @@ EOT
* break; * break;
* } * }
* case td::td_api::callStateReady::ID: { * case td::td_api::callStateReady::ID: {
* auto state = td::move_tl_object_as<td::td_api::callStateReady>(call_state); * auto state = td::td_api::move_object_as<td::td_api::callStateReady>(call_state);
* // use state * // use state
* break; * break;
* } * }
@ -210,12 +218,12 @@ EOT
* break; * break;
* } * }
* case td::td_api::callStateDiscarded::ID: { * case td::td_api::callStateDiscarded::ID: {
* auto state = td::move_tl_object_as<td::td_api::callStateDiscarded>(call_state); * auto state = td::td_api::move_object_as<td::td_api::callStateDiscarded>(call_state);
* // use state * // use state
* break; * break;
* } * }
* case td::td_api::callStateError::ID: { * case td::td_api::callStateError::ID: {
* auto state = td::move_tl_object_as<td::td_api::callStateError>(call_state); * auto state = td::td_api::move_object_as<td::td_api::callStateError>(call_state);
* // use state * // use state
* break; * break;
* } * }
@ -259,14 +267,14 @@ EOT
EOT EOT
); );
$this->addDocumentation('class Object: public TlObject {', <<<EOT $this->addDocumentation('class Object', <<<EOT
/** /**
* This class is a base class for all TDLib API classes. * This class is a base class for all TDLib API classes.
*/ */
EOT EOT
); );
$this->addDocumentation('class Function: public TlObject {', <<<EOT $this->addDocumentation('class Function', <<<EOT
/** /**
* This class is a base class for all TDLib API functions. * This class is a base class for all TDLib API functions.
*/ */
@ -276,6 +284,13 @@ EOT
$this->addDocumentation(' static const std::int32_t ID', <<<EOT $this->addDocumentation(' static const std::int32_t ID', <<<EOT
/// Identifier uniquely determining a type of the object. /// Identifier uniquely determining a type of the object.
EOT EOT
);
$this->addDocumentation(' virtual std::int32_t get_id() const = 0;', <<<EOT
/**
* Returns identifier uniquely determining a type of the object.
*/
EOT
); );
$this->addDocumentation(' std::int32_t get_id() const final {', <<<EOT $this->addDocumentation(' std::int32_t get_id() const final {', <<<EOT

View File

@ -118,7 +118,8 @@ std::string TD_TL_writer_jni_h::gen_class_begin(const std::string &class_name, c
" {\n" " {\n"
" public:\n" " public:\n"
" virtual ~" + " virtual ~" +
class_name + "() {}\n\n" + class_name + "() {\n"
" }\n\n" +
" virtual void store(JNIEnv *env, jobject &s) const {\n" " virtual void store(JNIEnv *env, jobject &s) const {\n"
" }\n\n" " }\n\n"
" virtual void store(TlStorerToString &s, const char *field_name) const = 0;\n\n" " virtual void store(TlStorerToString &s, const char *field_name) const = 0;\n\n"