| // Copyright (c) 2020, 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. | |
| import '../config_provider/public_ast.dart' as public_ast; | |
| import '../visitor/ast.dart'; | |
| import 'compound.dart'; | |
| /// A binding for C Struct. | |
| /// | |
| /// For a C structure - | |
| /// ```c | |
| /// struct C { | |
| /// int a; | |
| /// double b; | |
| /// int c; | |
| /// }; | |
| /// ``` | |
| /// The generated dart code is - | |
| /// <!-- no-source-file --> | |
| /// ```dart | |
| /// final class Struct extends ffi.Struct { | |
| /// @ffi.Int32() | |
| /// int a; | |
| /// | |
| /// @ffi.Double() | |
| /// double b; | |
| /// | |
| /// @ffi.Uint8() | |
| /// int c; | |
| /// | |
| /// } | |
| /// ``` | |
| class Struct extends Compound { | |
| Struct({ | |
| super.usr, | |
| super.originalName, | |
| required super.name, | |
| super.isIncomplete, | |
| this.pack, | |
| super.dartDoc, | |
| super.members, | |
| required super.context, | |
| super.nativeType, | |
| super.apiAvailability, | |
| super.sizeInBytes, | |
| super.dependencies, | |
| }); | |
| @override | |
| int? pack; | |
| @override | |
| public_ast.AstNode? toPublicAstNode() => public_ast.Struct(this); | |
| @override | |
| void visit(Visitation visitation) => visitation.visitStruct(this); | |
| } |