-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
138 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,31 @@ | ||
#include "ParentClass.h" | ||
#include "ParamClass.h" | ||
#include "ReturnClass.h" | ||
|
||
#ifndef NORMALCLASS_H | ||
#define NORMALCLASS_H | ||
|
||
class NormalClass : public ParentClass | ||
{ | ||
int hiddenInt = 1; | ||
|
||
ReturnClass valueReturnClass; | ||
ReturnClass * pointerReturnClass; | ||
ReturnClass * nullPointerReturnClass; | ||
|
||
public: | ||
NormalClass(); | ||
NormalClass(int c, ParamClass & refParamClass); | ||
NormalClass(ParamClass * pointerParamClass, ParamClass & refParamClass, ParamClass valueParamClass); | ||
|
||
int addIntValue(int a, int b); | ||
ReturnClass getReturnValueClass(); | ||
ReturnClass & getReturnRefClass(); | ||
ReturnClass * getReturnPointerClass(); | ||
ReturnClass * getReturnNullPointerClass(); | ||
void refParam(ParamClass & refParamClass); | ||
void pointerParam(ParamClass * pointerParamClass); | ||
void valueParam(ParamClass valueParamClass); | ||
}; | ||
|
||
#endif //NORMALCLASS_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
#include "ParamClass.h" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#ifndef PARAMCLASS_H | ||
#define PARAMCLASS_H | ||
|
||
class ParamClass | ||
{ | ||
}; | ||
|
||
#endif //PARAMCLASS_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
#include "ReturnClass.h" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#ifndef RETURNCLASS_H | ||
#define RETURNCLASS_H | ||
|
||
class ReturnClass | ||
{ | ||
}; | ||
|
||
#endif //RETURNCLASS_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 25 additions & 1 deletion
26
...e/src/main/java/com/github/xpenatan/jparser/core/codeparser/idl/IDLConstructorParser.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,39 @@ | ||
package com.github.xpenatan.jparser.core.codeparser.idl; | ||
|
||
import com.github.javaparser.ast.CompilationUnit; | ||
import com.github.javaparser.ast.Modifier; | ||
import com.github.javaparser.ast.body.ClassOrInterfaceDeclaration; | ||
import com.github.javaparser.ast.body.ConstructorDeclaration; | ||
import com.github.xpenatan.jparser.core.JParser; | ||
import com.github.xpenatan.jparser.idl.IDLClass; | ||
import com.github.xpenatan.jparser.idl.IDLConstructor; | ||
import com.github.xpenatan.jparser.idl.IDLParameter; | ||
import java.util.ArrayList; | ||
import java.util.Optional; | ||
|
||
public class IDLConstructorParser { | ||
|
||
public static void generateConstructor(IDLDefaultCodeParser idlParser, JParser jParser, CompilationUnit unit, ClassOrInterfaceDeclaration classOrInterfaceDeclaration, IDLClass idlClass, IDLConstructor idlConstructor) { | ||
// TODO | ||
ConstructorDeclaration constructorDeclaration = containsConstructor(classOrInterfaceDeclaration, idlConstructor); | ||
if(constructorDeclaration == null) { | ||
constructorDeclaration = classOrInterfaceDeclaration.addConstructor(Modifier.Keyword.PUBLIC); | ||
ArrayList<IDLParameter> parameters = idlConstructor.parameters; | ||
for(int i = 0; i < parameters.size(); i++) { | ||
IDLParameter parameter = parameters.get(i); | ||
constructorDeclaration.addAndGetParameter(parameter.type, parameter.name); | ||
} | ||
} | ||
} | ||
|
||
private static ConstructorDeclaration containsConstructor(ClassOrInterfaceDeclaration classOrInterfaceDeclaration, IDLConstructor idlConstructor) { | ||
ArrayList<IDLParameter> parameters = idlConstructor.parameters; | ||
String[] paramTypes = new String[parameters.size()]; | ||
for(int i = 0; i < parameters.size(); i++) { | ||
IDLParameter parameter = parameters.get(i); | ||
String paramType = parameter.type; | ||
paramTypes[i] = paramType; | ||
} | ||
Optional<ConstructorDeclaration> constructorDeclarationOptional = classOrInterfaceDeclaration.getConstructorByParameterTypes(paramTypes); | ||
return constructorDeclarationOptional.orElse(null); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters