Skip to content

Commit f9071e5

Browse files
committed
<fix>(v2,v3): fix static struct static array bug.
1 parent a69ad7d commit f9071e5

File tree

6 files changed

+27
-2
lines changed

6 files changed

+27
-2
lines changed

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ ext {
3131
commonsLang3Version = '3.12.0'
3232

3333
javaSDKVersion3 = "3.6.0"
34-
javaSDKVersion2 = "2.9.1"
34+
javaSDKVersion2 = "2.10.0-SNAPSHOT"
3535
slf4jVersion = "1.7.32"
3636
}
3737

@@ -50,7 +50,7 @@ sourceSets {
5050
// integrationTest.mustRunAfter test
5151
allprojects {
5252
group = 'org.fisco-bcos.code-generator'
53-
version = '1.3.0'
53+
version = '1.4.0-SNAPSHOT'
5454
apply plugin: 'maven-publish'
5555
apply plugin: 'idea'
5656
apply plugin: 'eclipse'

src/main/java/org/fisco/bcos/codegen/v2/wrapper/SolidityContractWrapper.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1651,6 +1651,11 @@ private List<TypeSpec> buildStructTypes(List<ABIDefinition> functionDefinitions)
16511651
if (namedType.getType().equals("tuple[]") && internalType.endsWith("[]")) {
16521652
internalType = internalType.substring(0, internalType.lastIndexOf("["));
16531653
}
1654+
if (namedType.getType().matches("tuple\\[\\d+\\]")
1655+
&& internalType.endsWith("]")
1656+
&& internalType.matches(".*\\[\\d+\\]")) {
1657+
internalType = internalType.substring(0, internalType.lastIndexOf("["));
1658+
}
16541659
if (internalType.contains(".")) {
16551660
structName = internalType.substring(internalType.lastIndexOf(".") + 1);
16561661
} else {

src/main/java/org/fisco/bcos/codegen/v3/wrapper/ContractWrapper.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,11 @@ private List<TypeSpec> buildStructTypes(List<ABIDefinition> functionDefinitions)
416416
if (namedType.getType().equals("tuple[]") && internalType.endsWith("[]")) {
417417
internalType = internalType.substring(0, internalType.lastIndexOf("["));
418418
}
419+
if (namedType.getType().matches("tuple\\[\\d+\\]")
420+
&& internalType.endsWith("]")
421+
&& internalType.matches(".*\\[\\d+\\]")) {
422+
internalType = internalType.substring(0, internalType.lastIndexOf("["));
423+
}
419424
if (isWasm) {
420425
structName = internalType.substring(internalType.lastIndexOf(".") + 1);
421426
} else {

src/test/java/org/fisco/bcos/codegen/v2/test/CodeGenV2Test.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,13 @@ public void complexABICodeGen() throws IOException {
7272
codeGenTest(COMPLEX_ABI_FILE, COMPLEX_NAME);
7373
}
7474

75+
@Test
76+
public void complexABICodeGen2() throws IOException {
77+
final String COMPLEX_ABI_FILE = "ComplexCodecTest2.abi";
78+
final String COMPLEX_NAME = "ComplexCodecTest";
79+
codeGenTest(COMPLEX_ABI_FILE, COMPLEX_NAME);
80+
}
81+
7582
@Test
7683
public void tableABICodeGen() throws IOException {
7784
final String ABI_FILE = "Table.abi";

src/test/java/org/fisco/bcos/codegen/v3/test/CodeGenV3Test.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,13 @@ public void complexABICodeGen() throws IOException {
8888
codeGenTest(COMPLEX_ABI_FILE, COMPLEX_NAME);
8989
}
9090

91+
@Test
92+
public void complexABICodeGen2() throws IOException {
93+
final String COMPLEX_ABI_FILE = "ComplexCodecTest2.abi";
94+
final String COMPLEX_NAME = "ComplexCodecTest";
95+
codeGenTest(COMPLEX_ABI_FILE, COMPLEX_NAME);
96+
}
97+
9198
@Test
9299
public void tableABICodeGen() throws IOException {
93100
final String ABI_FILE = "Table.abi";

0 commit comments

Comments
 (0)