-
Notifications
You must be signed in to change notification settings - Fork 28
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
sgrekhov
committed
Mar 31, 2021
1 parent
e5b0950
commit 1f471ad
Showing
9 changed files
with
440 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
/* | ||
* Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file | ||
* for details. All rights reserved. Use of this source code is governed by a | ||
* BSD-style license that can be found in the LICENSE file. | ||
*/ | ||
/** | ||
* @assertion | ||
* const Array<T extends NativeType>.multi(List<int> dimensions) | ||
* Const constructor to specify Array dimensions in Structs. | ||
* | ||
* class MyStruct extends Struct { | ||
* @Array.multi([2, 2, 2]) | ||
* external Array<Array<Array<Uint8>>> threeDimensionalInlineArray; | ||
* | ||
* @Array.multi([2, 2, 2, 2, 2, 2, 2, 2]) | ||
* external Array<Array<Array<Array<Array<Array<Array<Array<Uint8>>>>>>>> eightDimensionalInlineArray; | ||
* } | ||
* Do not invoke in normal code. | ||
* | ||
* @description Checks multidimentional array created by Array.multi() | ||
* @author sgrekhov@unipro.ru | ||
*/ | ||
import "dart:ffi"; | ||
import "package:ffi/ffi.dart"; | ||
import "../../../Utils/expect.dart"; | ||
|
||
class MyStruct extends Struct { | ||
@Array.multi([1, 2, 3, 4, 5, 6]) | ||
external Array<Array<Array<Array<Array<Array<Uint8>>>>>> a0; | ||
} | ||
|
||
void main() { | ||
final pointer = calloc<MyStruct>(); | ||
try { | ||
final array = pointer.ref.a0; | ||
|
||
for (int i1 = 0; i1 < 1; i1++) { | ||
for (int i2 = 0; i2 < 2; i2++) { | ||
for (int i3 = 0; i3 < 3; i3++) { | ||
for (int i4 = 0; i4 < 4; i4++) { | ||
for (int i5 = 0; i5 < 5; i5++) { | ||
for (int i6 = 0; i6 < 5; i6++) { | ||
Expect.equals(0, array[i1][i2][i3][i4][i5][i6]); | ||
array[i1][i2][i3][i4][i5][i6] = i1 + i2 + i3 + i4 + i5 + i6; | ||
Expect.equals( | ||
i1 + i2 + i3 + i4 + i5 + i6, array[i1][i2][i3][i4][i5][i6]); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
Expect.throws(() { | ||
array[-1]; | ||
}); | ||
Expect.throws(() { | ||
array[1]; | ||
}); | ||
Expect.throws(() { | ||
array[0][-1]; | ||
}); | ||
Expect.throws(() { | ||
array[0][2]; | ||
}); | ||
Expect.throws(() { | ||
array[0][1][-1]; | ||
}); | ||
Expect.throws(() { | ||
array[0][1][3]; | ||
}); | ||
Expect.throws(() { | ||
array[0][0][0][-1]; | ||
}); | ||
Expect.throws(() { | ||
array[0][1][2][4]; | ||
}); | ||
Expect.throws(() { | ||
array[0][0][0][0][-1]; | ||
}); | ||
Expect.throws(() { | ||
array[0][1][2][3][5]; | ||
}); | ||
Expect.throws(() { | ||
array[0][0][0][0][0][-1]; | ||
}); | ||
Expect.throws(() { | ||
array[0][1][2][3][4][6]; | ||
}); | ||
} finally { | ||
calloc.free(pointer); | ||
} | ||
} |
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,42 @@ | ||
/* | ||
* Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file | ||
* for details. All rights reserved. Use of this source code is governed by a | ||
* BSD-style license that can be found in the LICENSE file. | ||
*/ | ||
/** | ||
* @assertion | ||
* const Array<T extends NativeType>.multi(List<int> dimensions) | ||
* Const constructor to specify Array dimensions in Structs. | ||
* | ||
* class MyStruct extends Struct { | ||
* @Array.multi([2, 2, 2]) | ||
* external Array<Array<Array<Uint8>>> threeDimensionalInlineArray; | ||
* | ||
* @Array.multi([2, 2, 2, 2, 2, 2, 2, 2]) | ||
* external Array<Array<Array<Array<Array<Array<Array<Array<Uint8>>>>>>>> eightDimensionalInlineArray; | ||
* } | ||
* Do not invoke in normal code. | ||
* | ||
* @description Checks multidimentional array created by Array.multi(). Check | ||
* wrong array size | ||
* @author sgrekhov@unipro.ru | ||
*/ | ||
import "dart:ffi"; | ||
|
||
class MyStruct extends Struct { | ||
@Array.multi([]) | ||
//^^^^^^^^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] | ||
external Array<Int16> a0; | ||
|
||
@Array.multi([1]) | ||
//^^^^^^^^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] | ||
external Array<Array<Int16>> a1; | ||
} | ||
|
||
void main() { | ||
MyStruct? ms = 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file | ||
* for details. All rights reserved. Use of this source code is governed by a | ||
* BSD-style license that can be found in the LICENSE file. | ||
*/ | ||
/** | ||
* @assertion | ||
* const Array<T extends NativeType>.multi(List<int> dimensions) | ||
* Const constructor to specify Array dimensions in Structs. | ||
* | ||
* class MyStruct extends Struct { | ||
* @Array.multi([2, 2, 2]) | ||
* external Array<Array<Array<Uint8>>> threeDimensionalInlineArray; | ||
* | ||
* @Array.multi([2, 2, 2, 2, 2, 2, 2, 2]) | ||
* external Array<Array<Array<Array<Array<Array<Array<Array<Uint8>>>>>>>> eightDimensionalInlineArray; | ||
* } | ||
* Do not invoke in normal code. | ||
* | ||
* @description Checks multidimentional array created by Array.multi(). Check | ||
* not literal argument | ||
* @author sgrekhov@unipro.ru | ||
* @issue 45537 | ||
*/ | ||
import "dart:ffi"; | ||
import "package:ffi/ffi.dart"; | ||
import "../../../Utils/expect.dart"; | ||
|
||
const arr = [3, 1]; | ||
|
||
class MyStruct extends Struct { | ||
@Array.multi(arr) | ||
external Array<Array<Int8>> a0; | ||
} | ||
|
||
void main() { | ||
final pointer = calloc<MyStruct>(); | ||
try { | ||
final array = pointer.ref.a0; | ||
|
||
for (int i1 = 0; i1 < 3; i1++) { | ||
for (int i2 = 0; i2 < 1; i2++) { | ||
Expect.equals(0, array[i1][i2]); | ||
array[i1][i2] = i1 + i2; | ||
Expect.equals(i1 + i2, array[i1][i2]); | ||
} | ||
} | ||
} finally { | ||
calloc.free(pointer); | ||
} | ||
} |
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,37 @@ | ||
/* | ||
* Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file | ||
* for details. All rights reserved. Use of this source code is governed by a | ||
* BSD-style license that can be found in the LICENSE file. | ||
*/ | ||
/** | ||
* @assertion | ||
* const Array<T extends NativeType>.multi(List<int> dimensions) | ||
* Const constructor to specify Array dimensions in Structs. | ||
* | ||
* class MyStruct extends Struct { | ||
* @Array.multi([2, 2, 2]) | ||
* external Array<Array<Array<Uint8>>> threeDimensionalInlineArray; | ||
* | ||
* @Array.multi([2, 2, 2, 2, 2, 2, 2, 2]) | ||
* external Array<Array<Array<Array<Array<Array<Array<Array<Uint8>>>>>>>> eightDimensionalInlineArray; | ||
* } | ||
* Do not invoke in normal code. | ||
* | ||
* @description Checks multidimentional array created by Array.multi(). Check | ||
* negative array size | ||
* @author sgrekhov@unipro.ru | ||
* @issue 45538 | ||
*/ | ||
import "dart:ffi"; | ||
|
||
class MyStruct extends Struct { | ||
@Array.multi([-1]) | ||
//^^^^^^^^^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
external Array<Uint8> a0; | ||
} | ||
|
||
void main() { | ||
MyStruct? ms = 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
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,89 @@ | ||
/* | ||
* Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file | ||
* for details. All rights reserved. Use of this source code is governed by a | ||
* BSD-style license that can be found in the LICENSE file. | ||
*/ | ||
/** | ||
* @assertion | ||
* const Array<T extends NativeType>( | ||
* int dimension1, | ||
* [int dimension2, | ||
* int dimension3, | ||
* int dimension4, | ||
* int dimension5] | ||
* ) | ||
* Const constructor to specify Array dimensions in Structs. | ||
* | ||
* class MyStruct extends Struct { | ||
* @Array(8) | ||
* external Array<Uint8> inlineArray; | ||
* | ||
* @Array(2, 2, 2) | ||
* external Array<Array<Array<Uint8>>> threeDimensionalInlineArray; | ||
* } | ||
* Do not invoke in normal code. | ||
* | ||
* @description Checks multidimentional array | ||
* @author sgrekhov@unipro.ru | ||
*/ | ||
import "dart:ffi"; | ||
import "package:ffi/ffi.dart"; | ||
import "../../../Utils/expect.dart"; | ||
|
||
class MyStruct extends Struct { | ||
@Array(1, 2, 3, 4, 5) | ||
external Array<Array<Array<Array<Array<Uint8>>>>> a0; | ||
} | ||
|
||
void main() { | ||
final pointer = calloc<MyStruct>(); | ||
try { | ||
final array = pointer.ref.a0; | ||
|
||
for (int i1 = 0; i1 < 1; i1++) { | ||
for (int i2 = 0; i2 < 2; i2++) { | ||
for (int i3 = 0; i3 < 3; i3++) { | ||
for (int i4 = 0; i4 < 4; i4++) { | ||
for (int i5 = 0; i5 < 5; i5++) { | ||
Expect.equals(0, array[i1][i2][i3][i4][i5]); | ||
array[i1][i2][i3][i4][i5] = i1 + i2 + i3 + i4 + i5; | ||
Expect.equals(i1 + i2 + i3 + i4 + i5, array[i1][i2][i3][i4][i5]); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
Expect.throws(() { | ||
array[-1]; | ||
}); | ||
Expect.throws(() { | ||
array[1]; | ||
}); | ||
Expect.throws(() { | ||
array[0][-1]; | ||
}); | ||
Expect.throws(() { | ||
array[0][2]; | ||
}); | ||
Expect.throws(() { | ||
array[0][1][-1]; | ||
}); | ||
Expect.throws(() { | ||
array[0][1][3]; | ||
}); | ||
Expect.throws(() { | ||
array[0][0][0][-1]; | ||
}); | ||
Expect.throws(() { | ||
array[0][1][2][4]; | ||
}); | ||
Expect.throws(() { | ||
array[0][0][0][0][-1]; | ||
}); | ||
Expect.throws(() { | ||
array[0][1][2][3][5]; | ||
}); | ||
} finally { | ||
calloc.free(pointer); | ||
} | ||
} |
Oops, something went wrong.