Compare commits

...

4 Commits

Author SHA1 Message Date
Ernesto Castellotti 8d68279ae0 Update JSON scheme to TDLIB 8ab43e5 2022-10-09 16:54:32 +02:00
Ernesto Castellotti 2be9a475e9 Update JSON scheme to TDLIB 99163ff 2020-10-02 22:28:00 +02:00
Ernesto Castellotti 7499a41441
Base class name moved to a configurable constant 2019-06-03 23:16:23 +02:00
Ernesto Castellotti 192f909ae6 Added dscheme interface for use scheme on Dlang projects 2019-05-11 00:15:06 +02:00
4 changed files with 15539 additions and 3063 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,12 +1,12 @@
{
"name": "tlscheme2json",
"description": "A TLScheme generator for Json",
"dependencies": {
"asdf": "~>0.4.6"
},
"authors": [
"Ernesto Castellotti"
],
"copyright": "Copyright 2019 Ernesto Castellotti <erny.castell@gmail.com>",
"dependencies": {
"asdf": "~>0.4.6"
},
"description": "A TLScheme generator for Json",
"license": "MPL-2.0 with extra appendix",
"name": "tlscheme2json"
}
"license": "MPL-2.0 with extra appendix"
}

View File

@ -11,7 +11,7 @@
*/
void main(string[] args) {
import tlscheme2json;
import tlscheme2json : TLScheme2Json;
import std.getopt : getopt;
import std.getopt : config;
import std.array : empty;

View File

@ -13,19 +13,20 @@
module tlscheme2json;
enum DEFAULT_TL_URL = "https://raw.githubusercontent.com/tdlib/td/master/td/generate/scheme/td_api.tl";
enum BASECLASS_NAME = "TLBaseClass";
class TLMethod {
string name;
string type;
string description;
string name = "";
string type = "";
string description = "";
}
class TLClass {
string name;
string name = "";
TLMethod[] methods;
string description;
string inheritance;
string return_type;
string description = "";
string inheritance = "";
string return_type = "";
bool isFunction;
bool isSynchronous;
}
@ -96,12 +97,12 @@ class TLScheme2Json {
return this.classList.serializeToJsonPretty();
}
void parseType(ref string* lineptr, bool isFunction) {
private void parseType(ref string* lineptr, bool isFunction) {
auto tlClass = implParse(lineptr, isFunction);
this.classList ~= tlClass;
}
void parseClass(string line, bool isFunction) {
private void parseClass(string line, bool isFunction) {
import std.array : split;
import std.array : replace;
import std.string : strip;
@ -110,12 +111,12 @@ class TLScheme2Json {
auto tlClass = new TLClass();
tlClass.name = lineSplit[1].replace("class", "").strip();
tlClass.description = lineSplit[2].replace("description", "").strip();
tlClass.inheritance = "TLBaseClass";
tlClass.inheritance = BASECLASS_NAME;
tlClass.isFunction = isFunction;
this.classList ~= tlClass;
}
TLClass implParse(ref string* lineptr, bool isFunction) {
private TLClass implParse(ref string* lineptr, bool isFunction) {
import std.array : empty;
import std.array : split;
import std.array : join;
@ -127,10 +128,10 @@ class TLScheme2Json {
import std.uni : toLower;
import std.stdio : writeln;
string name;
string description;
string inheritance;
string return_type;
string name = "";
string description = "";
string inheritance = "";
string return_type = "";
bool isSynchronous = false;
TLMethod[] methods;
@ -159,6 +160,7 @@ class TLScheme2Json {
methods[i] = new TLMethod();
methods[i].name = methodProperties[0];
methods[i].type = methodProperties[1];
methods[i].description = "";
}
auto rawreturn = fields[fields.length -1].stripRight(";");
@ -176,7 +178,7 @@ class TLScheme2Json {
}
if(inheritance == null) {
inheritance = "BaseTLClass";
inheritance = BASECLASS_NAME;
}
if(isFunction && return_type.empty) {
@ -215,4 +217,20 @@ class TLScheme2Json {
tlClass.isSynchronous = isSynchronous;
return tlClass;
}
}
TLClass[] getTLClasses() {
return this.classList;
}
static TLClass[] get() {
auto tlScheme2Json = new TLScheme2Json();
tlScheme2Json.parse();
return tlScheme2Json.getTLClasses();
}
static TLClass[] get(string scheme) {
auto tlScheme2Json = new TLScheme2Json(scheme);
tlScheme2Json.parse();
return tlScheme2Json.getTLClasses();
}
}