Skip to content

Commit 9423c21

Browse files
committed
Swift: Add simple model for pointer types.
1 parent 9f86bcb commit 9423c21

File tree

1 file changed

+71
-0
lines changed

1 file changed

+71
-0
lines changed
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
/**
2+
* Provides models for Swift pointer types including `UnsafePointer`,
3+
* `UnsafeBufferPointer` and similar types.
4+
*/
5+
6+
import swift
7+
8+
/**
9+
* A Swift unsafe typed pointer type such as `UnsafePointer`,
10+
* `UnsafeMutablePointer` or `UnsafeBufferPointer`.
11+
*/
12+
class UnsafeTypedPointerType extends BoundGenericType {
13+
UnsafeTypedPointerType() {
14+
this.getName().regexpMatch("Unsafe(Mutable|)(Buffer|)Pointer<.*")
15+
}
16+
}
17+
18+
/**
19+
* A Swift unsafe raw pointer type such as `UnsafeRawPointer`,
20+
* `UnsafeMutableRawPointer` or `UnsafeRawBufferPointer`.
21+
*/
22+
class UnsafeRawPointerType extends NominalType {
23+
UnsafeRawPointerType() {
24+
this.getName().regexpMatch("Unsafe(Mutable|)Raw(Buffer|)Pointer")
25+
}
26+
}
27+
28+
/**
29+
* A Swift `OpaquePointer`.
30+
*/
31+
class OpaquePointerType extends NominalType {
32+
OpaquePointerType() {
33+
this.getName() = "OpaquePointer"
34+
}
35+
}
36+
37+
/**
38+
* A Swift `AutoreleasingUnsafeMutablePointer`.
39+
*/
40+
class AutoreleasingUnsafeMutablePointerType extends BoundGenericType {
41+
AutoreleasingUnsafeMutablePointerType() {
42+
this.getName().matches("AutoreleasingUnsafeMutablePointer<%")
43+
}
44+
}
45+
46+
/**
47+
* A Swift `Unmanaged` object reference.
48+
*/
49+
class UnmanagedType extends BoundGenericType {
50+
UnmanagedType() {
51+
this.getName().matches("Unmanaged<%")
52+
}
53+
}
54+
55+
/**
56+
* A Swift `CVaListPointer`.
57+
*/
58+
class CVaListPointerType extends NominalType {
59+
CVaListPointerType() {
60+
this.getName() = "CVaListPointer"
61+
}
62+
}
63+
64+
/**
65+
* A Swift `ManagedBufferPointer`.
66+
*/
67+
class ManagedBufferPointerType extends BoundGenericType {
68+
ManagedBufferPointerType() {
69+
this.getName().matches("ManagedBufferPointer<%")
70+
}
71+
}

0 commit comments

Comments
 (0)