-
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.
#993. Tests for not external members of Struct subtype added
- Loading branch information
sgrekhov
committed
Mar 12, 2021
1 parent
bdd4c79
commit 53e0635
Showing
3 changed files
with
98 additions
and
0 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,33 @@ | ||
/* | ||
* 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 All field declarations in a Struct subclass declaration must be | ||
* marked external. You cannot create instances of the class, only have it point | ||
* to existing native memory, so there is no memory in which to store non-native | ||
* fields. External fields also cannot be initialized by constructors since no | ||
* Dart object is being created. | ||
* | ||
* @description Checks that all field declarations in a Struct subclass | ||
* declaration must be marked external | ||
* @author sgrekhov@unipro.ru | ||
* @issue 45293 | ||
*/ | ||
import "dart:ffi"; | ||
import "package:ffi/ffi.dart"; | ||
|
||
class S1 extends Struct { | ||
@Int16() | ||
int? i; | ||
//^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} | ||
|
||
void main() { | ||
Pointer<S1> p = calloc<S1>(); | ||
S1 s1 = p.ref; | ||
print(s1.i); | ||
} |
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,33 @@ | ||
/* | ||
* 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 All field declarations in a Struct subclass declaration must be | ||
* marked external. You cannot create instances of the class, only have it point | ||
* to existing native memory, so there is no memory in which to store non-native | ||
* fields. External fields also cannot be initialized by constructors since no | ||
* Dart object is being created. | ||
* | ||
* @description Checks that all field declarations in a Struct subclass | ||
* declaration must be marked external | ||
* @author sgrekhov@unipro.ru | ||
* @issue 45293 | ||
*/ | ||
import "dart:ffi"; | ||
import "package:ffi/ffi.dart"; | ||
|
||
class S1 extends Struct { | ||
@Double() | ||
double? d; | ||
//^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} | ||
|
||
void main() { | ||
Pointer<S1> p = calloc<S1>(); | ||
S1 s1 = p.ref; | ||
print(s1.d); | ||
} |
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,32 @@ | ||
/* | ||
* 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 All field declarations in a Struct subclass declaration must be | ||
* marked external. You cannot create instances of the class, only have it point | ||
* to existing native memory, so there is no memory in which to store non-native | ||
* fields. External fields also cannot be initialized by constructors since no | ||
* Dart object is being created. | ||
* | ||
* @description Checks that all field declarations in a Struct subclass | ||
* declaration must be marked external | ||
* @author sgrekhov@unipro.ru | ||
* @issue 45293 | ||
*/ | ||
import "dart:ffi"; | ||
import "package:ffi/ffi.dart"; | ||
|
||
class S1 extends Struct { | ||
Pointer<S1>? next; | ||
//^^^^^^^^^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} | ||
|
||
void main() { | ||
Pointer<S1> p = calloc<S1>(); | ||
S1 s1 = p.ref; | ||
print(s1.next); | ||
} |