Generate code to the lib module
This commit is contained in:
parent
9c0402e909
commit
957e29b4db
|
@ -1,5 +1,6 @@
|
|||
plugins {
|
||||
id 'java'
|
||||
id 'application'
|
||||
}
|
||||
|
||||
version '0.1'
|
||||
|
@ -9,3 +10,14 @@ sourceCompatibility = 1.8
|
|||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
task('gen_tl', dependsOn: jar, type: JavaExec) {
|
||||
main = "io.github.lonamiwebs.overgram.Overgram"
|
||||
classpath = sourceSets.main.runtimeClasspath
|
||||
// TODO Learn gradle and do this properly
|
||||
setArgs([
|
||||
'../lib/src/main/java/io/github/lonamiwebs/overgram/tl/',
|
||||
'src/main/resources/mtproto_api.tl',
|
||||
'src/main/resources/telegram_api.tl'
|
||||
])
|
||||
}
|
||||
|
|
|
@ -6,21 +6,24 @@ import io.github.lonamiwebs.overgram.parser.TLReader;
|
|||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class Overgram {
|
||||
public static void main(final String... args) {
|
||||
final Map<String, List<TLObject>> objects = TLReader.readTlObjects(new File("telegram_api.tl"));
|
||||
try {
|
||||
Generator.generateJava(
|
||||
objects.get("types"),
|
||||
objects.get("functions"),
|
||||
new File("Abstract.java"),
|
||||
new File("Types.java"),
|
||||
new File("Functions.java")
|
||||
);
|
||||
} catch (IOException ignored) {
|
||||
public static void main(final String... args) throws IOException {
|
||||
final Map<String, List<TLObject>> objects = new HashMap<>();
|
||||
for (int i = 1; i < args.length; ++i) {
|
||||
TLReader.readTlObjects(objects, new File(args[i]));
|
||||
}
|
||||
|
||||
final File parent = new File(args[0]);
|
||||
Generator.generateJava(
|
||||
objects.get("types"),
|
||||
objects.get("functions"),
|
||||
new File(parent, "Abstract.java"),
|
||||
new File(parent, "Types.java"),
|
||||
new File(parent, "Functions.java")
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,8 +12,7 @@ import java.util.Map;
|
|||
|
||||
public class TLReader {
|
||||
|
||||
public static final Map<String, List<TLObject>> readTlObjects(final File file) {
|
||||
final Map<String, List<TLObject>> result = new HashMap<>();
|
||||
public static void readTlObjects(final Map<String, List<TLObject>> result, final File file) {
|
||||
for (final Map.Entry<String, List<String>> entry : readTl(file).entrySet()) {
|
||||
final List<TLObject> objects = new ArrayList<>();
|
||||
for (final String string : entry.getValue()) {
|
||||
|
@ -21,7 +20,6 @@ public class TLReader {
|
|||
}
|
||||
result.put(entry.getKey(), objects);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private static Map<String, List<String>> readTl(final File file) {
|
||||
|
|
Loading…
Reference in New Issue