Coverage report: /home/ellis/comp/core/ffi/tree-sitter/ffi.lisp
Kind | Covered | All | % |
expression | 0 | 83 | 0.0 |
branch | 0 | 0 | nil |
Key
Not instrumented
Conditionalized out
Executed
Not executed
Both branches taken
One branch taken
Neither branch taken
1
;;; ffi/tree-sitter/ffi.lisp --- Low-level FFI bindings for Tree-sitter
5
;; see https://github.com/death/cl-tree-sitter for an alternative
6
;; implementation - has functions for working on pointers instead of
7
;; raw objects like below:
9
;;(defar ts-node-start-point-pointer ts-point (self (* ts-node)))
10
;;(defar ts-node-end-point-pointer ts-point (self (* ts-node)))
13
(in-package :tree-sitter)
16
(define-alien-type ts-state-id unsigned-int)
17
(define-alien-type ts-symbol unsigned-int)
18
(define-alien-type ts-field-id unsigned-int)
19
(define-alien-type ts-language (struct ts-language))
20
(define-alien-type ts-parser (struct ts-parser))
21
(define-alien-type ts-tree (struct ts-tree))
22
(define-alien-enum (ts-query-error unsigned-int)
29
(define-alien-type ts-query
33
(error-offset unsigned-int)
34
(error-type ts-query-error)))
36
(define-alien-type ts-query-cursor (struct ts-query-cursor))
37
(define-alien-type ts-query-cursor-state
38
(struct ts-query-cursor-state
40
(current-byte-offset unsigned-int)))
42
(define-alien-type ts-node
44
(context (array unsigned-int 4))
48
(define-alien-type ts-query-capture
49
(struct ts-query-capture
51
(index unsigned-int)))
53
(define-alien-type ts-query-match
54
(struct ts-query-match
56
(pattern-index unsigned-short)
57
(capture-count unsigned-short)
58
;; (* ts-query-capture)
61
(define-alien-type ts-query-cursor-options
62
(struct ts-query-cursor-options
64
(state (* ts-query-cursor-state))))
66
(define-alien-type ts-lookahead-iterator (struct ts-lookahead-iterator))
68
(define-alien-type ts-point
71
(column unsigned-int)))
73
(define-alien-type ts-range
75
(start-point ts-point)
77
(start-byte unsigned-int)
78
(end-byte unsigned-int)))
80
(define-alien-enum (ts-log-type int)
84
(define-alien-type ts-logger
87
(log (* (function void (* t) ts-log-type c-string)))))
89
(define-alien-type ts-input-edit
91
(start-byte unsigned-int)
92
(old-end-byte unsigned-int)
93
(new-end-byte unsigned-int)
94
(start-point ts-point)
95
(old-end-point ts-point)
96
(new-end-point ts-point)))
98
(define-alien-type ts-tree-cursor
102
(context (array unsigned-int 2))))
104
(define-alien-enum (ts-input-encoding int)
108
(define-alien-enum (ts-symbol-type int)
113
(define-alien-type ts-input (struct ts-input
115
(read (* (function c-string (* t)
119
(encoding ts-input-encoding)))
122
(defar ts-parser-new (* ts-parser))
123
(defar ts-parser-delete void (self (* ts-parser)))
124
(defar ts-parser-reset void (self (* ts-parser)))
125
(defar ts-parser-set-language boolean (self (* ts-parser)) (language (* ts-language)))
126
(defar ts-parser-language (* ts-language) (self (* ts-parser)))
127
;; (defar ts-parser-parse (* ts-tree) (self (* ts-parser)) (old-tree (* ts-tree)) (input ts-input))
128
(defar ts-parser-parse-string (* ts-tree) (self (* ts-parser)) (old-tree (* ts-tree)) (string c-string) (length unsigned-int))
129
;; Set the file descriptor to which the parser should write debugging graphs
130
;; during parsing. The graphs are formatted in the DOT language. You may want
131
;; to pipe these graphs directly to a `dot(1)` process in order to generate
132
;; SVG output. You can turn off this logging by passing a negative number.
133
(defar ts-parser-print-dot-graphs void (self (* ts-parser)) (fd int))
135
(defar ts-tree-copy (* ts-tree) (self (* ts-tree)))
136
(defar ts-tree-delete void (self (* ts-tree)))
137
(defar ts-tree-language (* ts-language) (self (* ts-tree)))
138
(defar ts-tree-edit void (self (* ts-tree)) (edit (* unsigned-int)))
139
(defar ts-tree-print-dot-graph void (self (* ts-tree)) (file-descriptor int))
142
(defar ts-tree-cursor-current-field-name c-string (cursor (* ts-tree-cursor)))
143
(defar ts-tree-cursor-current-field-id ts-field-id (cursor (* ts-tree-cursor)))
144
(defar ts-tree-cursor-current-descendant-index unsigned-int (cursor (* ts-tree-cursor)))
145
(defar ts-tree-cursor-current-depth unsigned-int (cursor (* ts-tree-cursor)))
146
(defar ts-tree-cursor-goto-next-sibling boolean (self (* ts-tree-cursor)))
147
(defar ts-tree-cursor-goto-first-child-for-byte long (self (* ts-tree-cursor)) (goal-byte unsigned-int))
148
(defar ts-tree-cursor-goto-first-child-for-point-pointer long (self (* ts-tree-cursor)) (goal-point (* ts-point)))
149
(defar ts-tree-cursor-goto-parent boolean (self (* ts-tree-cursor)))
150
(defar ts-tree-cursor-copy-pointer (* ts-tree-cursor) (cursor (* ts-tree-cursor)))
151
(defar ts-tree-cursor-goto-first-child boolean (self (* ts-tree-cursor)))
152
(defar ts-tree-cursor-goto-last-child boolean (self (* ts-tree-cursor)))
153
(defar ts-tree-cursor-goto-descendant void (self (* ts-tree-cursor)) (goal-descendant-index unsigned-int))
154
(defar ts-tree-cursor-delete void (cursor (* ts-tree-cursor)))
156
(defar ts-language-version unsigned-int (v (* ts-language)))
157
(defar ts-language-symbol-count unsigned-int (v (* ts-language)))
158
(defar ts-language-symbol-name c-string (v (* ts-language)) (s (* ts-symbol)))
159
(defar ts-language-symbol-type ts-symbol-type (v (* ts-language)) (s ts-symbol))
160
(defar ts-language-field-count unsigned-int (v (* ts-language)))
161
(defar ts-language-field-name-for-id c-string (v (* ts-language)) (id ts-field-id))
162
(defar ts-language-field-id-for-name ts-field-id (v (* ts-language)) (name c-string) (nlen (unsigned 32)))
164
(defar ts-language-next-state ts-state-id
165
(self (* ts-language))
170
(defar ts-query-new (* ts-query)
171
(lang (* ts-language))
173
(source-len unsigned-int)
174
(error-offset (* unsigned-int))
175
(error-type (* ts-query-error)))
177
(defar ts-query-delete void (query (* ts-query)))
179
(defar ts-query-cursor-new (* ts-query-cursor))
181
(defar ts-query-cursor-delete void
182
(cursor (* ts-query-cursor)))
184
(defar ts-query-pattern-count unsigned-int
186
(defar ts-query-capture-count unsigned-int
188
(defar ts-query-string-count unsigned-int
192
(defar ts-query-cursor-exec-pointer void
193
(cursor (* ts-query-cursor))
197
(defar ts-query-cursor-exec-with-options-pointer void
198
(cursor (* ts-query-cursor))
201
(options (* ts-query-cursor-options)))
203
(defar ts-query-cursor-next-match boolean
204
(cursor (* ts-query-cursor))
205
(match (* ts-query-match)))
207
(defar ts-query-cursor-remove-match void
208
(cursor (* ts-query-cursor))
209
(match-id unsigned-int))
211
(defar ts-query-cursor-next-capture boolean
212
(cursor (* ts-query-cursor))
213
(match (* ts-query-match))
214
(capture-index (* unsigned-int)))
216
(defar ts-query-cursor-set-max-start-depth void
217
(cursor (* ts-query-cursor))
218
(max-start-depth unsigned-int))
220
(defar ts-tree-root-node-pointer (* ts-node)
223
(defar ts-tree-cursor-new-pointer (* ts-tree-cursor)
226
(defar ts-node-is-named-pointer boolean
229
(defar ts-tree-cursor-current-node-pointer (* ts-node)
230
(cursor (* ts-tree-cursor)))
232
(defar ts-node-start-point-pointer (* ts-point)
235
(defar ts-node-end-point-pointer (* ts-point)
238
(defar ts-node-type-pointer c-string
241
(defar ts-node-string-pointer c-string
244
(defar ts-node-start-byte-pointer unsigned-int
247
(defar ts-node-end-byte-pointer unsigned-int
250
(defar ts-node-child-count-pointer unsigned-int
253
(defar ts-node-parent-pointer (* ts-node)