Skip to content

Commit

Permalink
update idl reader
Browse files Browse the repository at this point in the history
  • Loading branch information
xpenatan committed Jul 3, 2023
1 parent 6a93d1b commit a55a376
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.github.xpenatan.gdx.html5.box2d;

import com.github.xpenatan.jparser.idl.IDLFile;
import com.github.xpenatan.jparser.idl.IDLReader;
import com.github.xpenatan.jparser.teavm.TeaVMCodeParser;

public class Box2dParser extends TeaVMCodeParser {
public Box2dParser(IDLFile idlFile) {
super("Box2D", idlFile);
public Box2dParser(IDLReader idlReader) {
super("Box2D", idlReader);
}
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
package com.github.xpenatan.gdx.html5.box2d;

import com.github.xpenatan.jparser.core.JParser;
import com.github.xpenatan.jparser.idl.IDLFile;
import com.github.xpenatan.jparser.idl.IDLReader;
import java.io.File;

public class Main {
public static void main(String[] args) throws Exception {
String path = "..\\..\\gdx-box2d\\gdx-box2d-build\\jni\\box2D.idl";
IDLFile idlFile = IDLReader.parseFile(path);
IDLReader idlReader = IDLReader.readIDL(path);

String basePath = new File(".").getAbsolutePath();
JParser.generate(new Box2dParser(idlFile), basePath + "./gdx-box2d-base/src", "../gdx-box2d-teavm/src", null);
JParser.generate(new Box2dParser(idlReader), basePath + "./gdx-box2d-base/src", "../gdx-box2d-teavm/src", null);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
import com.github.javaparser.ast.type.Type;
import com.github.xpenatan.jparser.core.JParserHelper;
import com.github.xpenatan.jparser.idl.IDLClass;
import com.github.xpenatan.jparser.idl.IDLFile;
import com.github.xpenatan.jparser.idl.IDLMethod;
import com.github.xpenatan.jparser.idl.IDLReader;
import com.github.xpenatan.jparser.teavm.TeaVMCodeParser;

/**
Expand All @@ -29,8 +29,8 @@
*/
public class BulletCodeParser extends TeaVMCodeParser {

public BulletCodeParser(IDLFile idlFile) {
super("Bullet", idlFile);
public BulletCodeParser(IDLReader idlReader) {
super("Bullet", idlReader);
enableAttributeParsing = false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
import com.github.javaparser.ast.stmt.Statement;
import com.github.javaparser.ast.type.Type;
import com.github.xpenatan.jparser.core.JParserHelper;
import com.github.xpenatan.jparser.idl.IDLFile;
import com.github.xpenatan.jparser.cpp.CppCodeParser;
import com.github.xpenatan.jparser.idl.IDLReader;

public class BulletCppParser extends CppCodeParser {

Expand All @@ -34,8 +34,8 @@ public BulletCppParser(String classpath, String jniDir) {
this(null, classpath, jniDir);
}

public BulletCppParser(IDLFile idlFile, String classpath, String jniDir) {
super(idlFile, classpath, jniDir);
public BulletCppParser(IDLReader idlReader, String classpath, String jniDir) {
super(idlReader, classpath, jniDir);
}

protected void generateGdxMethod(CompilationUnit unit, ClassOrInterfaceDeclaration classDeclaration, MethodDeclaration idlMethodDeclaration, MethodDeclaration nativeMethod, MethodCallExpr caller) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@
public class Main {
public static void main(String[] args) throws Exception {
String path = "..\\..\\gdx-bullet\\gdx-bullet-build\\jni\\bullet.idl";
IDLFile idlFile = IDLReader.parseFile(path);
IDLReader idlReader = IDLReader.readIDL(path);

String basePath = new File(".").getAbsolutePath();
JParser.generate(new BulletCodeParser(idlFile), basePath + "./gdx-bullet-base/src", "../gdx-bullet-teavm/src", null);
JParser.generate(new BulletCodeParser(idlReader), basePath + "./gdx-bullet-base/src", "../gdx-bullet-teavm/src", null);

buildBulletCPP(idlFile);
buildBulletCPP(idlReader);
}

private static void buildBulletCPP(IDLFile idlFile) throws Exception {
private static void buildBulletCPP(IDLReader idlReader) throws Exception {
String libName = "gdx-bullet";
String bulletPath = new File("../gdx-bullet/").getCanonicalPath();
String genDir = bulletPath + "/src/main/java";
Expand All @@ -29,7 +29,7 @@ private static void buildBulletCPP(IDLFile idlFile) throws Exception {

String sourceDir = "../gdx-bullet-base/src/main/java/";
String classPath = CppCodeParser.getClassPath("bullet-base", "gdx-1", "gdx-jnigen-loader", "jParser-loader");
BulletCppParser cppParser = new BulletCppParser(idlFile, classPath, buildPath);
BulletCppParser cppParser = new BulletCppParser(idlReader, classPath, buildPath);
JParser.generate(cppParser, sourceDir, genDir);

String [] flags = new String[1];
Expand Down

0 comments on commit a55a376

Please sign in to comment.