From fb30318185fb11c98832d58ab9e197a7ade9ae05 Mon Sep 17 00:00:00 2001 From: Natan Date: Mon, 2 Sep 2024 12:46:49 -0300 Subject: [PATCH] Fix comparing method --- .../com/github/xpenatan/jparser/cpp/CppCodeParser.java | 10 ++++------ .../com/github/xpenatan/jparser/idl/IDLMethod.java | 6 +++++- .../com/github/xpenatan/jparser/idl/IDLParameter.java | 6 +++++- .../jparser/idl/parser/IDLConstructorParser.java | 4 ++-- .../xpenatan/jparser/idl/parser/IDLMethodParser.java | 6 +++--- .../github/xpenatan/jparser/teavm/TeaVMCodeParser.java | 2 +- 6 files changed, 20 insertions(+), 14 deletions(-) diff --git a/jParser/cpp/src/main/java/com/github/xpenatan/jparser/cpp/CppCodeParser.java b/jParser/cpp/src/main/java/com/github/xpenatan/jparser/cpp/CppCodeParser.java index 6fce04a..9c39dd8 100644 --- a/jParser/cpp/src/main/java/com/github/xpenatan/jparser/cpp/CppCodeParser.java +++ b/jParser/cpp/src/main/java/com/github/xpenatan/jparser/cpp/CppCodeParser.java @@ -9,10 +9,8 @@ import com.github.javaparser.ast.body.FieldDeclaration; import com.github.javaparser.ast.body.MethodDeclaration; import com.github.javaparser.ast.body.Parameter; -import com.github.javaparser.ast.comments.BlockComment; import com.github.javaparser.ast.expr.MethodCallExpr; import com.github.javaparser.ast.stmt.BlockStmt; -import com.github.javaparser.ast.type.PrimitiveType; import com.github.javaparser.ast.type.Type; import com.github.javaparser.utils.Pair; import com.github.xpenatan.jparser.core.JParser; @@ -557,7 +555,7 @@ private String generateMethodCallers(IDLClass idlClass, ArrayList parameters, ArrayList 0) { param += ", "; } diff --git a/jParser/idl/src/main/java/com/github/xpenatan/jparser/idl/IDLMethod.java b/jParser/idl/src/main/java/com/github/xpenatan/jparser/idl/IDLMethod.java index 7a43945..7749491 100644 --- a/jParser/idl/src/main/java/com/github/xpenatan/jparser/idl/IDLMethod.java +++ b/jParser/idl/src/main/java/com/github/xpenatan/jparser/idl/IDLMethod.java @@ -91,7 +91,11 @@ else if(returnType.contains("long")) { } } - public String getReturnType() { + public String getCPPReturnType() { + return returnType; + } + + public String getJavaReturnType() { return returnType.replace("unsigned", "").trim(); } diff --git a/jParser/idl/src/main/java/com/github/xpenatan/jparser/idl/IDLParameter.java b/jParser/idl/src/main/java/com/github/xpenatan/jparser/idl/IDLParameter.java index 36734a2..f371261 100644 --- a/jParser/idl/src/main/java/com/github/xpenatan/jparser/idl/IDLParameter.java +++ b/jParser/idl/src/main/java/com/github/xpenatan/jparser/idl/IDLParameter.java @@ -108,7 +108,11 @@ else if(type.equals("double[]")) { } } - public String getType() { + public String getCPPReturnType() { + return type; + } + + public String getJavaType() { if(isAny) { return "long"; } diff --git a/jParser/idl/src/main/java/com/github/xpenatan/jparser/idl/parser/IDLConstructorParser.java b/jParser/idl/src/main/java/com/github/xpenatan/jparser/idl/parser/IDLConstructorParser.java index 6253f12..73fd597 100644 --- a/jParser/idl/src/main/java/com/github/xpenatan/jparser/idl/parser/IDLConstructorParser.java +++ b/jParser/idl/src/main/java/com/github/xpenatan/jparser/idl/parser/IDLConstructorParser.java @@ -85,7 +85,7 @@ public static ConstructorDeclaration getOrCreateConstructorDeclaration(IDLDefaul ArrayList parameters = idlConstructor.parameters; for(int i = 0; i < parameters.size(); i++) { IDLParameter parameter = parameters.get(i); - String paramType = parameter.getType(); + String paramType = parameter.getJavaType(); paramType = IDLHelper.convertEnumToInt(idlParser.idlReader, paramType); JParserHelper.addMissingImportType(jParser, unit, paramType); constructorDeclaration.addAndGetParameter(paramType, parameter.name); @@ -126,7 +126,7 @@ public static ConstructorDeclaration containsConstructor(ClassOrInterfaceDeclara String[] paramTypes = new String[parameters.size()]; for(int i = 0; i < parameters.size(); i++) { IDLParameter parameter = parameters.get(i); - String paramType = parameter.type; + String paramType = parameter.getJavaType(); paramTypes[i] = paramType; } Optional constructorDeclarationOptional = classOrInterfaceDeclaration.getConstructorByParameterTypes(paramTypes); diff --git a/jParser/idl/src/main/java/com/github/xpenatan/jparser/idl/parser/IDLMethodParser.java b/jParser/idl/src/main/java/com/github/xpenatan/jparser/idl/parser/IDLMethodParser.java index 838afe7..5938852 100644 --- a/jParser/idl/src/main/java/com/github/xpenatan/jparser/idl/parser/IDLMethodParser.java +++ b/jParser/idl/src/main/java/com/github/xpenatan/jparser/idl/parser/IDLMethodParser.java @@ -108,7 +108,7 @@ public static MethodDeclaration generateAndAddMethodOnly(IDLDefaultCodeParser id methodDeclaration.setStatic(idlMethod.isStaticMethod); for(int i = 0; i < parameters.size(); i++) { IDLParameter idlParameter = parameters.get(i); - String paramType = idlParameter.getType(); + String paramType = idlParameter.getJavaType(); String paramName = idlParameter.name; paramType = IDLHelper.convertEnumToInt(idlParser.idlReader, paramType); Parameter parameter = methodDeclaration.addAndGetParameter(paramType, paramName); @@ -117,7 +117,7 @@ public static MethodDeclaration generateAndAddMethodOnly(IDLDefaultCodeParser id } if(returnType == null) { - String returnTypeStr = IDLHelper.convertEnumToInt(idlParser.idlReader, idlMethod.getReturnType()); + String returnTypeStr = IDLHelper.convertEnumToInt(idlParser.idlReader, idlMethod.getJavaReturnType()); returnType = StaticJavaParser.parseType(returnTypeStr); } methodDeclaration.setType(returnType); @@ -403,7 +403,7 @@ private static MethodDeclaration containsMethod(IDLDefaultCodeParser idlParser, for(int i = 0; i < parameters.size(); i++) { IDLParameter parameter = parameters.get(i); - String paramType = parameter.type; + String paramType = parameter.getJavaType(); paramType = IDLHelper.convertEnumToInt(idlParser.idlReader, paramType); paramTypes[i] = paramType; } diff --git a/jParser/teavm/src/main/java/com/github/xpenatan/jparser/teavm/TeaVMCodeParser.java b/jParser/teavm/src/main/java/com/github/xpenatan/jparser/teavm/TeaVMCodeParser.java index 1594873..754bc34 100644 --- a/jParser/teavm/src/main/java/com/github/xpenatan/jparser/teavm/TeaVMCodeParser.java +++ b/jParser/teavm/src/main/java/com/github/xpenatan/jparser/teavm/TeaVMCodeParser.java @@ -409,7 +409,7 @@ private static String getParams(NodeList parameters, ArrayList 0) { param += ", "; }