Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -208,16 +208,17 @@ private void addNonArcInitialization(EnumDeclaration node) {
} else {
baseTypeCount++;
}

initStatements.add(new ExpressionStatement(
new CommaExpression(
new CastExpression(voidType, new ParenthesizedExpression(
new Assignment(new SimpleName(varElement),
new Assignment(new SimpleName(localEnum),
Expression initExpr = new CastExpression(voidType, new ParenthesizedExpression(
new Assignment(new SimpleName(varElement),
new Assignment(new SimpleName(localEnum),
new NativeExpression(
UnicodeUtils.format("objc_constructInstance(%s, (void *)ptr)", classExpr),
type.asType()))))),
new NativeExpression("ptr += " + sizeName, voidType))));
type.asType())))));
if (i < node.getEnumConstants().size() - 1) {
initExpr = new CommaExpression(initExpr,
new NativeExpression("ptr += " + sizeName, voidType));
}
initStatements.add(new ExpressionStatement(initExpr));
String initName = nameTable.getFullFunctionName(methodElement);
FunctionElement initElement = new FunctionElement(initName, voidType, valueType)
.addParameters(valueType.asType())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ public void testGenericEnumConstructor() throws IOException {
"void Test_initWithId_withNSString_withInt_("
+ "Test *self, id t, NSString *__name, int32_t __ordinal) {");
assertTranslatedLines(translation,
"((void) (JreEnum(Test, A) = e = "
+ "objc_constructInstance(self, (void *)ptr)), ptr += objSize);",
"(void) (JreEnum(Test, A) = e = "
+ "objc_constructInstance(self, (void *)ptr));",
"Test_initWithId_withNSString_withInt_(e, @\"foo\", @\"A\", 0);");
}

Expand Down Expand Up @@ -160,8 +160,8 @@ public void testEnumAllocationCode() throws Exception {
"((void) (JreEnum(Test, B) = e = objc_constructInstance([Test_1 class],"
+ " (void *)ptr)), ptr += objSize_B);",
"Test_1_initWithNSString_withInt_(e, @\"B\", 1);",
"((void) (JreEnum(Test, C) = e = "
+ "objc_constructInstance(self, (void *)ptr)), ptr += objSize);",
"(void) (JreEnum(Test, C) = e = "
+ "objc_constructInstance(self, (void *)ptr));",
"Test_initWithNSString_withInt_(e, @\"C\", 2);");
}

Expand Down