Browse Source

Added dscheme interface for use scheme on Dlang projects

scheme-update v1.0.3
Ernesto Castellotti 3 years ago
parent
commit
192f909ae6
  1. 1508
      TLScheme.json
  2. 14
      dub.json
  3. 2
      source/app.d
  4. 47
      source/tlscheme2json.d

1508
TLScheme.json

File diff suppressed because it is too large

14
dub.json

@ -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 <[email protected]>",
"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"
}

2
source/app.d

@ -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;

47
source/TLScheme2Json.d → source/tlscheme2json.d

@ -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();
}
}
Loading…
Cancel
Save