Skip to content

Commit

Permalink
Change conflicting methods/temp constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
xpenatan committed Jan 31, 2024
1 parent 7c5dee5 commit c76a9b2
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 11 deletions.
10 changes: 5 additions & 5 deletions jParser/base/src/main/java/idl/IDLBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,19 @@ public void setPointer(long cPtr) {
/**
* Obtains a reference to this object, call release to free the reference.
*/
public void obtain() {
public void idl_obtain() {
refCount++;
}

/**
* Release a previously obtained reference, causing the object to be disposed when this was the last reference.
*/
public void release() {
public void idl_release() {
if(--refCount <= 0 && USE_REF_COUNTING) dispose();
}

/**
* @return Whether this instance is obtained using the {@link #obtain()} method.
* @return Whether this instance is obtained using the {@link #idl_obtain()} method.
*/
public boolean isObtained() {
return refCount > 0;
Expand All @@ -57,7 +57,7 @@ protected void construct() {
}

protected void reset(long cPtr, boolean cMemoryOwn) {
if(!destroyed) destroy();
if(!destroyed) idl_destroy();
cMemOwn = cMemoryOwn;
cPointer = cPtr;
construct();
Expand Down Expand Up @@ -133,7 +133,7 @@ public String toString() {
return getClass().getSimpleName() + "(" + cPointer + "," + cMemOwn + ")";
}

protected void destroy() {
protected void idl_destroy() {
try {
if(destroyed && ENABLE_LOGGING) {
error("IDL", "Already destroyed " + toString());
Expand Down
4 changes: 2 additions & 2 deletions jParser/base/src/main/java/idl/helper/IDLString.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

public class IDLString extends IDLBase {

public static IDLString TMP_EMPTY_1 = new IDLString((byte)0);
public static IDLString TMP_EMPTY_1 = new IDLString((byte)0, '0');

public static IDLString TMP_1 = new IDLString();
public static IDLString TMP_2 = new IDLString();
Expand All @@ -17,7 +17,7 @@ public static void disposeTEMP() {
public IDLString() {
}

public IDLString(byte b) {}
public IDLString(byte b, char c) {}

public String c_str() {
String text = c_strNATIVE(getCPointer());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,12 @@ public static void generateConstructor(IDLDefaultCodeParser idlParser, JParser j
// All classes contain a temp constructor so temp objects can be reused
if(idlParser.baseClassUnit != unit) {
ClassOrInterfaceDeclaration classDeclaration = JParserHelper.getClassDeclaration(unit);
Optional<ConstructorDeclaration> constructorDeclarationOptional = classDeclaration.getConstructorByParameterTypes("byte");
Optional<ConstructorDeclaration> constructorDeclarationOptional = classDeclaration.getConstructorByParameterTypes("byte", "char");
if(constructorDeclarationOptional.isEmpty()) {
//Only add temp constructor if it does not exist
ConstructorDeclaration constructorDeclaration = classDeclaration.addConstructor(Modifier.Keyword.PUBLIC);
constructorDeclaration.addParameter("byte", "temp");
constructorDeclaration.addParameter("byte", "b");
constructorDeclaration.addParameter("char", "c");
}
}

Expand All @@ -63,7 +64,7 @@ private static void addSuperTempConstructor(ClassOrInterfaceDeclaration classDec
}
}
if(addSuperByte) {
Statement statement = StaticJavaParser.parseStatement("super((byte)1);");
Statement statement = StaticJavaParser.parseStatement("super((byte)1, (char)1);");
constructorDeclaration.getBody().addStatement(0, statement);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class IDLMethodParser {
"{\n" +
" long pointer = [METHOD];\n" +
" if(pointer == 0) return null;\n" +
" if([TYPE]_TEMP_GEN_[NUM] == null) [TYPE]_TEMP_GEN_[NUM] = new [TYPE]((byte)1);\n" +
" if([TYPE]_TEMP_GEN_[NUM] == null) [TYPE]_TEMP_GEN_[NUM] = new [TYPE]((byte)1, (char)1);\n" +
" [TYPE]_TEMP_GEN_[NUM].setPointer(pointer);\n" +
" return [TYPE]_TEMP_GEN_[NUM];\n" +
"}";
Expand Down Expand Up @@ -295,6 +295,7 @@ public static String generateFieldName(String fieldName, ClassOrInterfaceDeclara
ObjectCreationExpr expression = new ObjectCreationExpr();
expression.setType(fieldType);
expression.addArgument(StaticJavaParser.parseExpression("(byte)1"));
expression.addArgument(StaticJavaParser.parseExpression("(char)1"));
fieldDeclaration = classDeclaration.addFieldWithInitializer(fieldType, fieldName, expression, Modifier.Keyword.STATIC, keyword, Modifier.Keyword.FINAL);
}
else {
Expand Down

0 comments on commit c76a9b2

Please sign in to comment.