Added dscheme interface for use scheme on Dlang projects

Signed-off-by: Ernesto Castellotti <erny.castell@gmail.com>
This commit is contained in:
Ernesto Castellotti 2019-05-04 22:06:12 +02:00
parent 9b6fadaf9e
commit ec1e334f4c
4 changed files with 802 additions and 770 deletions

File diff suppressed because it is too large Load Diff

23
dscheme/dscheme.d Normal file
View File

@ -0,0 +1,23 @@
module dscheme;
import tlscheme2json;
enum DEFAULT_SCHEME_URL = "https://raw.githubusercontent.com/ErnyTech/TLScheme2Json/master/TLScheme.json";
class DScheme {
private static TLClass[] tlClasses;
static this() {
import std.stdio : writeln;
import std.net.curl : get;
import asdf : deserialize;
writeln("Obtaining TLScheme Json from " , DEFAULT_SCHEME_URL);
auto jsonScheme = get(DEFAULT_SCHEME_URL).dup;
auto tljson = deserialize!TLJson(jsonScheme);
this.tlClasses = tljson.tl_classes;
}
static TLClass get() {
return this.tlClasses;
}
}

View File

@ -1,12 +1,20 @@
{
"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"
"subPackages": [
{
"name" : "dscheme",
"targetType": "library",
"sourcePaths": ["dscheme"],
"importPaths": ["dscheme"]
}
]
}

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;
}
@ -133,10 +133,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;
@ -165,6 +165,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(";");