• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

dart-lang / ffigen / 6470767942

10 Oct 2023 02:29PM UTC coverage: 91.966% (-0.6%) from 92.593%
6470767942

push

github

web-flow
Refactor `sameFfiDartAndCType` to not require a `Writer` (#629)

40 of 40 new or added lines in 12 files covered. (100.0%)

3709 of 4033 relevant lines covered (91.97%)

28.07 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

91.89
/lib/src/code_generator/pointer.dart
1
// Copyright (c) 2022, the Dart project authors. Please see the AUTHORS file
2
// for details. All rights reserved. Use of this source code is governed by a
3
// BSD-style license that can be found in the LICENSE file.
4

5
import 'package:ffigen/src/code_generator.dart';
6

7
import 'writer.dart';
8

9
/// Represents a pointer.
10
class PointerType extends Type {
11
  final Type child;
12

13
  PointerType._(this.child);
26✔
14

15
  factory PointerType(Type child) {
25✔
16
    if (child == objCObjectType) {
50✔
17
      return ObjCObjectPointer();
2✔
18
    }
19
    return PointerType._(child);
25✔
20
  }
21

22
  @override
25✔
23
  void addDependencies(Set<Binding> dependencies) {
24
    child.addDependencies(dependencies);
50✔
25
  }
26

27
  @override
24✔
28
  Type get baseType => child.baseType;
48✔
29

30
  @override
25✔
31
  String getCType(Writer w) =>
32
      '${w.ffiLibraryPrefix}.Pointer<${child.getCType(w)}>';
100✔
33

34
  // Both the C type and the FFI Dart type are 'Pointer<$cType>'.
35
  @override
13✔
36
  bool get sameFfiDartAndCType => true;
37

38
  @override
2✔
39
  String toString() => '$child*';
4✔
40

41
  @override
2✔
42
  String cacheKey() => '${child.cacheKey()}*';
6✔
43
}
44

45
/// Represents a constant array, which has a fixed size.
46
class ConstantArray extends PointerType {
47
  final int length;
48
  ConstantArray(this.length, Type child) : super._(child);
20✔
49

50
  @override
9✔
51
  Type get baseArrayType => child.baseArrayType;
18✔
52

53
  @override
9✔
54
  bool get isIncompleteCompound => baseArrayType.isIncompleteCompound;
18✔
55

56
  @override
2✔
57
  String toString() => '$child[$length]';
6✔
58

59
  @override
2✔
60
  String cacheKey() => '${child.cacheKey()}[$length]';
8✔
61
}
62

63
/// Represents an incomplete array, which has an unknown size.
64
class IncompleteArray extends PointerType {
65
  IncompleteArray(Type child) : super._(child);
10✔
66

67
  @override
×
68
  Type get baseArrayType => child.baseArrayType;
×
69

70
  @override
2✔
71
  String toString() => '$child[]';
4✔
72

73
  @override
2✔
74
  String cacheKey() => '${child.cacheKey()}[]';
6✔
75
}
76

77
/// A pointer to an NSObject.
78
class ObjCObjectPointer extends PointerType {
79
  factory ObjCObjectPointer() => _inst;
4✔
80

81
  static final _inst = ObjCObjectPointer._();
6✔
82
  ObjCObjectPointer._() : super._(objCObjectType);
6✔
83

84
  @override
2✔
85
  String getDartType(Writer w) => 'NSObject';
86

87
  @override
×
88
  bool get sameDartAndCType => false;
89
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc