Added dscheme interface for use scheme on Dlang projects
Signed-off-by: Ernesto Castellotti <erny.castell@gmail.com>
This commit is contained in:
parent
9b6fadaf9e
commit
ec1e334f4c
1508
TLScheme.json
1508
TLScheme.json
File diff suppressed because it is too large
Load Diff
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
18
dub.json
18
dub.json
|
@ -1,12 +1,20 @@
|
||||||
{
|
{
|
||||||
|
"name": "tlscheme2json",
|
||||||
|
"description": "A TLScheme generator for Json",
|
||||||
|
"dependencies": {
|
||||||
|
"asdf": "~>0.4.6"
|
||||||
|
},
|
||||||
"authors": [
|
"authors": [
|
||||||
"Ernesto Castellotti"
|
"Ernesto Castellotti"
|
||||||
],
|
],
|
||||||
"copyright": "Copyright 2019 Ernesto Castellotti <erny.castell@gmail.com>",
|
"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",
|
"license": "MPL-2.0 with extra appendix",
|
||||||
"name": "tlscheme2json"
|
"subPackages": [
|
||||||
|
{
|
||||||
|
"name" : "dscheme",
|
||||||
|
"targetType": "library",
|
||||||
|
"sourcePaths": ["dscheme"],
|
||||||
|
"importPaths": ["dscheme"]
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
|
@ -15,17 +15,17 @@ module tlscheme2json;
|
||||||
enum DEFAULT_TL_URL = "https://raw.githubusercontent.com/tdlib/td/master/td/generate/scheme/td_api.tl";
|
enum DEFAULT_TL_URL = "https://raw.githubusercontent.com/tdlib/td/master/td/generate/scheme/td_api.tl";
|
||||||
|
|
||||||
class TLMethod {
|
class TLMethod {
|
||||||
string name;
|
string name = "";
|
||||||
string type;
|
string type = "";
|
||||||
string description;
|
string description = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
class TLClass {
|
class TLClass {
|
||||||
string name;
|
string name = "";
|
||||||
TLMethod[] methods;
|
TLMethod[] methods;
|
||||||
string description;
|
string description = "";
|
||||||
string inheritance;
|
string inheritance = "";
|
||||||
string return_type;
|
string return_type = "";
|
||||||
bool isFunction;
|
bool isFunction;
|
||||||
bool isSynchronous;
|
bool isSynchronous;
|
||||||
}
|
}
|
||||||
|
@ -133,10 +133,10 @@ class TLScheme2Json {
|
||||||
import std.uni : toLower;
|
import std.uni : toLower;
|
||||||
import std.stdio : writeln;
|
import std.stdio : writeln;
|
||||||
|
|
||||||
string name;
|
string name = "";
|
||||||
string description;
|
string description = "";
|
||||||
string inheritance;
|
string inheritance = "";
|
||||||
string return_type;
|
string return_type = "";
|
||||||
bool isSynchronous = false;
|
bool isSynchronous = false;
|
||||||
TLMethod[] methods;
|
TLMethod[] methods;
|
||||||
|
|
||||||
|
@ -165,6 +165,7 @@ class TLScheme2Json {
|
||||||
methods[i] = new TLMethod();
|
methods[i] = new TLMethod();
|
||||||
methods[i].name = methodProperties[0];
|
methods[i].name = methodProperties[0];
|
||||||
methods[i].type = methodProperties[1];
|
methods[i].type = methodProperties[1];
|
||||||
|
methods[i].description = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
auto rawreturn = fields[fields.length -1].stripRight(";");
|
auto rawreturn = fields[fields.length -1].stripRight(";");
|
||||||
|
|
Loading…
Reference in New Issue