1
0
mirror of https://github.com/ErnyTech/TLScheme2Json synced 2024-12-28 04:15:52 +01:00

Added dscheme interface for use scheme on Dlang projects

This commit is contained in:
Ernesto Castellotti 2019-05-11 00:15:06 +02:00
parent 30eff2526d
commit 192f909ae6
4 changed files with 794 additions and 777 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

@ -15,17 +15,17 @@ module tlscheme2json;
enum DEFAULT_TL_URL = "https://raw.githubusercontent.com/tdlib/td/master/td/generate/scheme/td_api.tl";
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 +96,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;
@ -115,7 +115,7 @@ class TLScheme2Json {
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 +127,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 +159,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(";");
@ -215,4 +216,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();
}
}