parent
ccf2da2865
commit
48a93aadb9
@ -164,7 +164,7 @@ EOT
|
|||||||
return "\r\n$shift/// <para>Returns <see cref=\"".substr($return_type, 0, -1).'"/>.</para>';
|
return "\r\n$shift/// <para>Returns <see cref=\"".substr($return_type, 0, -1).'"/>.</para>';
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function addClassDocumentation($class_name, $base_class_name, $description)
|
protected function addClassDocumentation($class_name, $base_class_name, $return_type, $description)
|
||||||
{
|
{
|
||||||
$this->addDocumentation("public ref class $class_name sealed : $base_class_name {", <<<EOT
|
$this->addDocumentation("public ref class $class_name sealed : $base_class_name {", <<<EOT
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -389,7 +389,7 @@ EOT
|
|||||||
return PHP_EOL.$shift.'*'.PHP_EOL.$shift."* Returns $return_type.";
|
return PHP_EOL.$shift.'*'.PHP_EOL.$shift."* Returns $return_type.";
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function addClassDocumentation($class_name, $base_class_name, $description)
|
protected function addClassDocumentation($class_name, $base_class_name, $return_type, $description)
|
||||||
{
|
{
|
||||||
$this->addDocumentation("class $class_name final : public $base_class_name {", <<<EOT
|
$this->addDocumentation("class $class_name final : public $base_class_name {", <<<EOT
|
||||||
/**
|
/**
|
||||||
|
@ -104,7 +104,7 @@ class JavadocTlDocumentationGenerator extends TlDocumentationGenerator
|
|||||||
protected function extractClassName($line)
|
protected function extractClassName($line)
|
||||||
{
|
{
|
||||||
if (strpos($line, 'public static class ') > 0) {
|
if (strpos($line, 'public static class ') > 0) {
|
||||||
return explode(' ', trim($line))[3];
|
return preg_split('/( |<|>)/', trim($line))[3];
|
||||||
}
|
}
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
@ -157,7 +157,7 @@ EOT
|
|||||||
EOT
|
EOT
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->addDocumentation(' public abstract static class Function extends Object {', <<<EOT
|
$this->addDocumentation(' public abstract static class Function<R extends Object> extends Object {', <<<EOT
|
||||||
/**
|
/**
|
||||||
* This class is a base class for all TDLib interface function-classes.
|
* This class is a base class for all TDLib interface function-classes.
|
||||||
*/
|
*/
|
||||||
@ -196,9 +196,9 @@ EOT
|
|||||||
return PHP_EOL.$shift.'*'.PHP_EOL.$shift."* <p> Returns {@link $return_type $return_type} </p>";
|
return PHP_EOL.$shift.'*'.PHP_EOL.$shift."* <p> Returns {@link $return_type $return_type} </p>";
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function addClassDocumentation($class_name, $base_class_name, $description)
|
protected function addClassDocumentation($class_name, $base_class_name, $return_type, $description)
|
||||||
{
|
{
|
||||||
$this->addDocumentation(" public static class $class_name extends $base_class_name {", <<<EOT
|
$this->addDocumentation(" public static class $class_name extends ".$base_class_name.(empty($return_type) ? "" : "<".$return_type.">")." {", <<<EOT
|
||||||
/**
|
/**
|
||||||
* $description
|
* $description
|
||||||
*/
|
*/
|
||||||
|
@ -89,7 +89,7 @@ abstract class TlDocumentationGenerator
|
|||||||
|
|
||||||
abstract protected function getFunctionReturnTypeDescription($return_type, $for_constructor);
|
abstract protected function getFunctionReturnTypeDescription($return_type, $for_constructor);
|
||||||
|
|
||||||
abstract protected function addClassDocumentation($class_name, $base_class_name, $description);
|
abstract protected function addClassDocumentation($class_name, $base_class_name, $return_type, $description);
|
||||||
|
|
||||||
abstract protected function addFieldDocumentation($class_name, $field_name, $type_name, $field_info, $may_be_null);
|
abstract protected function addFieldDocumentation($class_name, $field_name, $type_name, $field_info, $may_be_null);
|
||||||
|
|
||||||
@ -244,10 +244,12 @@ abstract class TlDocumentationGenerator
|
|||||||
|
|
||||||
$base_class_name = $current_class ?: $this->getBaseClassName($is_function);
|
$base_class_name = $current_class ?: $this->getBaseClassName($is_function);
|
||||||
$class_description = $description;
|
$class_description = $description;
|
||||||
|
$return_type = "";
|
||||||
if ($is_function) {
|
if ($is_function) {
|
||||||
$class_description .= $this->getFunctionReturnTypeDescription($this->getTypeName($type), false);
|
$return_type = $this->getTypeName($type);
|
||||||
|
$class_description .= $this->getFunctionReturnTypeDescription($return_type, false);
|
||||||
}
|
}
|
||||||
$this->addClassDocumentation($class_name, $base_class_name, $class_description);
|
$this->addClassDocumentation($class_name, $base_class_name, $return_type, $class_description);
|
||||||
|
|
||||||
foreach ($known_fields as $name => $field_type) {
|
foreach ($known_fields as $name => $field_type) {
|
||||||
$may_be_null = stripos($info[$name], 'may be null') !== false;
|
$may_be_null = stripos($info[$name], 'may be null') !== false;
|
||||||
|
@ -303,7 +303,7 @@ class TlWriterCCommon final : public tl::TL_writer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string gen_class_begin(const std::string &class_name, const std::string &base_class_name,
|
std::string gen_class_begin(const std::string &class_name, const std::string &base_class_name,
|
||||||
bool is_proxy) const final {
|
bool is_proxy, const tl::tl_tree *result) const final {
|
||||||
if (is_header_ != 1 || class_name == "") {
|
if (is_header_ != 1 || class_name == "") {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
@ -493,7 +493,7 @@ std::string TD_TL_writer_cpp::gen_forward_class_declaration(const std::string &c
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string TD_TL_writer_cpp::gen_class_begin(const std::string &class_name, const std::string &base_class_name,
|
std::string TD_TL_writer_cpp::gen_class_begin(const std::string &class_name, const std::string &base_class_name,
|
||||||
bool is_proxy) const {
|
bool is_proxy, const tl::tl_tree *result) const {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ class TD_TL_writer_cpp : public TD_TL_writer {
|
|||||||
std::string gen_forward_class_declaration(const std::string &class_name, bool is_proxy) const override;
|
std::string gen_forward_class_declaration(const std::string &class_name, bool is_proxy) const override;
|
||||||
|
|
||||||
std::string gen_class_begin(const std::string &class_name, const std::string &base_class_name,
|
std::string gen_class_begin(const std::string &class_name, const std::string &base_class_name,
|
||||||
bool is_proxy) const override;
|
bool is_proxy, const tl::tl_tree *result) const override;
|
||||||
std::string gen_class_end() const override;
|
std::string gen_class_end() const override;
|
||||||
|
|
||||||
std::string gen_class_alias(const std::string &class_name, const std::string &alias_name) const override;
|
std::string gen_class_alias(const std::string &class_name, const std::string &alias_name) const override;
|
||||||
|
@ -201,7 +201,7 @@ class TlWriterDotNet final : public TL_writer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string gen_class_begin(const std::string &class_name, const std::string &base_class_name,
|
std::string gen_class_begin(const std::string &class_name, const std::string &base_class_name,
|
||||||
bool is_proxy) const final {
|
bool is_proxy, const tl::tl_tree *result) const final {
|
||||||
if (!is_header_) {
|
if (!is_header_) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
@ -255,7 +255,7 @@ std::string TD_TL_writer_h::gen_forward_class_declaration(const std::string &cla
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string TD_TL_writer_h::gen_class_begin(const std::string &class_name, const std::string &base_class_name,
|
std::string TD_TL_writer_h::gen_class_begin(const std::string &class_name, const std::string &base_class_name,
|
||||||
bool is_proxy) const {
|
bool is_proxy, const tl::tl_tree *result) const {
|
||||||
return "class " + class_name + (!is_proxy ? " final " : "") + ": public " + base_class_name +
|
return "class " + class_name + (!is_proxy ? " final " : "") + ": public " + base_class_name +
|
||||||
" {\n"
|
" {\n"
|
||||||
" public:\n";
|
" public:\n";
|
||||||
|
@ -34,7 +34,7 @@ class TD_TL_writer_h : public TD_TL_writer {
|
|||||||
std::string gen_forward_class_declaration(const std::string &class_name, bool is_proxy) const override;
|
std::string gen_forward_class_declaration(const std::string &class_name, bool is_proxy) const override;
|
||||||
|
|
||||||
std::string gen_class_begin(const std::string &class_name, const std::string &base_class_name,
|
std::string gen_class_begin(const std::string &class_name, const std::string &base_class_name,
|
||||||
bool is_proxy) const override;
|
bool is_proxy, const tl::tl_tree *result) const override;
|
||||||
std::string gen_class_end() const override;
|
std::string gen_class_end() const override;
|
||||||
|
|
||||||
std::string gen_class_alias(const std::string &class_name, const std::string &alias_name) const override;
|
std::string gen_class_alias(const std::string &class_name, const std::string &alias_name) const override;
|
||||||
|
@ -117,7 +117,7 @@ std::string TD_TL_writer_hpp::gen_forward_class_declaration(const std::string &c
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string TD_TL_writer_hpp::gen_class_begin(const std::string &class_name, const std::string &base_class_name,
|
std::string TD_TL_writer_hpp::gen_class_begin(const std::string &class_name, const std::string &base_class_name,
|
||||||
bool is_proxy) const {
|
bool is_proxy, const tl::tl_tree *result) const {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ class TD_TL_writer_hpp final : public TD_TL_writer {
|
|||||||
std::string gen_forward_class_declaration(const std::string &class_name, bool is_proxy) const final;
|
std::string gen_forward_class_declaration(const std::string &class_name, bool is_proxy) const final;
|
||||||
|
|
||||||
std::string gen_class_begin(const std::string &class_name, const std::string &base_class_name,
|
std::string gen_class_begin(const std::string &class_name, const std::string &base_class_name,
|
||||||
bool is_proxy) const final;
|
bool is_proxy, const tl::tl_tree *result) const final;
|
||||||
std::string gen_class_end() const final;
|
std::string gen_class_end() const final;
|
||||||
|
|
||||||
std::string gen_class_alias(const std::string &class_name, const std::string &alias_name) const final;
|
std::string gen_class_alias(const std::string &class_name, const std::string &alias_name) const final;
|
||||||
|
@ -206,11 +206,25 @@ std::string TD_TL_writer_java::gen_forward_class_declaration(const std::string &
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string TD_TL_writer_java::gen_class_begin(const std::string &class_name, const std::string &base_class_name,
|
std::string TD_TL_writer_java::gen_class_begin(const std::string &class_name, const std::string &base_class_name,
|
||||||
bool is_proxy) const {
|
bool is_proxy, const tl::tl_tree *result_tl) const {
|
||||||
std::string full_class_name = "static class " + class_name;
|
std::string full_class_name = "static class " + class_name;
|
||||||
|
if (class_name == "Function") {
|
||||||
|
full_class_name += "<R extends " + gen_base_tl_class_name() + ">";
|
||||||
|
}
|
||||||
if (class_name != gen_base_tl_class_name()) {
|
if (class_name != gen_base_tl_class_name()) {
|
||||||
full_class_name += " extends " + base_class_name;
|
full_class_name += " extends " + base_class_name;
|
||||||
}
|
}
|
||||||
|
if (result_tl != nullptr && base_class_name == "Function") {
|
||||||
|
assert(result_tl->get_type() == tl::NODE_TYPE_TYPE);
|
||||||
|
const tl::tl_tree_type *result_type = static_cast<const tl::tl_tree_type *>(result_tl);
|
||||||
|
std::string fetched_type = gen_type_name(result_type);
|
||||||
|
|
||||||
|
if (!fetched_type.empty() && fetched_type[fetched_type.size() - 1] == ' ') {
|
||||||
|
fetched_type.pop_back();
|
||||||
|
}
|
||||||
|
|
||||||
|
full_class_name += "<" + fetched_type + ">";
|
||||||
|
}
|
||||||
std::string result = " public " + std::string(is_proxy ? "abstract " : "") + full_class_name + " {\n";
|
std::string result = " public " + std::string(is_proxy ? "abstract " : "") + full_class_name + " {\n";
|
||||||
if (class_name == gen_base_tl_class_name() || class_name == gen_base_function_class_name()) {
|
if (class_name == gen_base_tl_class_name() || class_name == gen_base_function_class_name()) {
|
||||||
result += " public native String toString();\n";
|
result += " public native String toString();\n";
|
||||||
|
@ -59,7 +59,7 @@ class TD_TL_writer_java final : public tl::TL_writer {
|
|||||||
std::string gen_forward_class_declaration(const std::string &class_name, bool is_proxy) const final;
|
std::string gen_forward_class_declaration(const std::string &class_name, bool is_proxy) const final;
|
||||||
|
|
||||||
std::string gen_class_begin(const std::string &class_name, const std::string &base_class_name,
|
std::string gen_class_begin(const std::string &class_name, const std::string &base_class_name,
|
||||||
bool is_proxy) const final;
|
bool is_proxy, const tl::tl_tree *result) const final;
|
||||||
std::string gen_class_end() const final;
|
std::string gen_class_end() const final;
|
||||||
|
|
||||||
std::string gen_class_alias(const std::string &class_name, const std::string &alias_name) const final;
|
std::string gen_class_alias(const std::string &class_name, const std::string &alias_name) const final;
|
||||||
|
@ -57,7 +57,7 @@ std::string TD_TL_writer_jni_cpp::gen_base_tl_class_name() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string TD_TL_writer_jni_cpp::gen_class_begin(const std::string &class_name, const std::string &base_class_name,
|
std::string TD_TL_writer_jni_cpp::gen_class_begin(const std::string &class_name, const std::string &base_class_name,
|
||||||
bool is_proxy) const {
|
bool is_proxy, const tl::tl_tree *result) const {
|
||||||
return "\n"
|
return "\n"
|
||||||
"jclass " +
|
"jclass " +
|
||||||
class_name + "::Class;\n";
|
class_name + "::Class;\n";
|
||||||
|
@ -55,7 +55,7 @@ class TD_TL_writer_jni_cpp final : public TD_TL_writer_cpp {
|
|||||||
std::string gen_base_tl_class_name() const final;
|
std::string gen_base_tl_class_name() const final;
|
||||||
|
|
||||||
std::string gen_class_begin(const std::string &class_name, const std::string &base_class_name,
|
std::string gen_class_begin(const std::string &class_name, const std::string &base_class_name,
|
||||||
bool is_proxy) const final;
|
bool is_proxy, const tl::tl_tree *result) const final;
|
||||||
|
|
||||||
std::string gen_field_definition(const std::string &class_name, const std::string &type_name,
|
std::string gen_field_definition(const std::string &class_name, const std::string &type_name,
|
||||||
const std::string &field_name) const final;
|
const std::string &field_name) const final;
|
||||||
|
@ -126,7 +126,7 @@ std::string TD_TL_writer_jni_h::gen_output_begin() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string TD_TL_writer_jni_h::gen_class_begin(const std::string &class_name, const std::string &base_class_name,
|
std::string TD_TL_writer_jni_h::gen_class_begin(const std::string &class_name, const std::string &base_class_name,
|
||||||
bool is_proxy) const {
|
bool is_proxy, const tl::tl_tree *result) const {
|
||||||
if (class_name == gen_base_tl_class_name()) {
|
if (class_name == gen_base_tl_class_name()) {
|
||||||
return "class " + class_name +
|
return "class " + class_name +
|
||||||
" {\n"
|
" {\n"
|
||||||
|
@ -35,7 +35,7 @@ class TD_TL_writer_jni_h final : public TD_TL_writer_h {
|
|||||||
std::string gen_output_begin() const final;
|
std::string gen_output_begin() const final;
|
||||||
|
|
||||||
std::string gen_class_begin(const std::string &class_name, const std::string &base_class_name,
|
std::string gen_class_begin(const std::string &class_name, const std::string &base_class_name,
|
||||||
bool is_proxy) const final;
|
bool is_proxy, const tl::tl_tree *result) const final;
|
||||||
|
|
||||||
std::string gen_field_definition(const std::string &class_name, const std::string &type_name,
|
std::string gen_field_definition(const std::string &class_name, const std::string &type_name,
|
||||||
const std::string &field_name) const final;
|
const std::string &field_name) const final;
|
||||||
|
@ -245,7 +245,7 @@ static void write_function(tl_outputer &out, const tl_combinator *t, const std::
|
|||||||
|
|
||||||
std::string class_name = w.gen_class_name(t->name);
|
std::string class_name = w.gen_class_name(t->name);
|
||||||
|
|
||||||
out.append(w.gen_class_begin(class_name, w.gen_base_function_class_name(), false));
|
out.append(w.gen_class_begin(class_name, w.gen_base_function_class_name(), false, t->result));
|
||||||
|
|
||||||
int required_args = gen_field_definitions(out, t, class_name, w);
|
int required_args = gen_field_definitions(out, t, class_name, w);
|
||||||
out.append(w.gen_flags_definitions(t, true));
|
out.append(w.gen_flags_definitions(t, true));
|
||||||
@ -302,7 +302,7 @@ static void write_constructor(tl_outputer &out, const tl_combinator *t, const st
|
|||||||
|
|
||||||
std::string class_name = w.gen_class_name(t->name);
|
std::string class_name = w.gen_class_name(t->name);
|
||||||
|
|
||||||
out.append(w.gen_class_begin(class_name, base_class, is_proxy));
|
out.append(w.gen_class_begin(class_name, base_class, is_proxy, t->result));
|
||||||
int required_args = gen_field_definitions(out, t, class_name, w);
|
int required_args = gen_field_definitions(out, t, class_name, w);
|
||||||
|
|
||||||
bool can_be_parsed = false;
|
bool can_be_parsed = false;
|
||||||
@ -386,7 +386,7 @@ void write_class(tl_outputer &out, const tl_type *t, const std::set<std::string>
|
|||||||
std::vector<var_description> empty_vars;
|
std::vector<var_description> empty_vars;
|
||||||
bool optimize_one_constructor = (t->simple_constructors == 1);
|
bool optimize_one_constructor = (t->simple_constructors == 1);
|
||||||
if (!optimize_one_constructor) {
|
if (!optimize_one_constructor) {
|
||||||
out.append(w.gen_class_begin(class_name, base_class, true));
|
out.append(w.gen_class_begin(class_name, base_class, true, nullptr));
|
||||||
|
|
||||||
out.append(w.gen_get_id(class_name, 0, true));
|
out.append(w.gen_get_id(class_name, 0, true));
|
||||||
|
|
||||||
@ -648,7 +648,7 @@ void write_tl(const tl_config &config, tl_outputer &out, const TL_writer &w) {
|
|||||||
// write base classes
|
// write base classes
|
||||||
std::vector<var_description> empty_vars;
|
std::vector<var_description> empty_vars;
|
||||||
for (int i = 0; i <= w.get_max_arity(); i++) {
|
for (int i = 0; i <= w.get_max_arity(); i++) {
|
||||||
out.append(w.gen_class_begin(w.gen_base_type_class_name(i), w.gen_base_tl_class_name(), true));
|
out.append(w.gen_class_begin(w.gen_base_type_class_name(i), w.gen_base_tl_class_name(), true, nullptr));
|
||||||
|
|
||||||
out.append(w.gen_get_id(w.gen_base_type_class_name(i), 0, true));
|
out.append(w.gen_get_id(w.gen_base_type_class_name(i), 0, true));
|
||||||
|
|
||||||
@ -742,7 +742,7 @@ void write_tl(const tl_config &config, tl_outputer &out, const TL_writer &w) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
out.append(w.gen_class_begin(w.gen_base_function_class_name(), w.gen_base_tl_class_name(), true));
|
out.append(w.gen_class_begin(w.gen_base_function_class_name(), w.gen_base_tl_class_name(), true, nullptr));
|
||||||
|
|
||||||
out.append(w.gen_get_id(w.gen_base_function_class_name(), 0, true));
|
out.append(w.gen_get_id(w.gen_base_function_class_name(), 0, true));
|
||||||
|
|
||||||
|
@ -89,7 +89,7 @@ class TL_writer {
|
|||||||
virtual std::string gen_forward_class_declaration(const std::string &class_name, bool is_proxy) const = 0;
|
virtual std::string gen_forward_class_declaration(const std::string &class_name, bool is_proxy) const = 0;
|
||||||
|
|
||||||
virtual std::string gen_class_begin(const std::string &class_name, const std::string &base_class_name,
|
virtual std::string gen_class_begin(const std::string &class_name, const std::string &base_class_name,
|
||||||
bool is_proxy) const = 0;
|
bool is_proxy, const tl_tree *result) const = 0;
|
||||||
virtual std::string gen_class_end() const = 0;
|
virtual std::string gen_class_end() const = 0;
|
||||||
|
|
||||||
virtual std::string gen_class_alias(const std::string &class_name, const std::string &alias_name) const = 0;
|
virtual std::string gen_class_alias(const std::string &class_name, const std::string &alias_name) const = 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user