tree-sitter-sql 0.3.11__tar.gz → 0.3.12__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (26) hide show
  1. {tree_sitter_sql-0.3.11 → tree_sitter_sql-0.3.12}/PKG-INFO +2 -2
  2. tree_sitter_sql-0.3.12/bindings/python/tree_sitter_sql/__init__.pyi +17 -0
  3. {tree_sitter_sql-0.3.11 → tree_sitter_sql-0.3.12}/bindings/python/tree_sitter_sql.egg-info/PKG-INFO +2 -2
  4. {tree_sitter_sql-0.3.11 → tree_sitter_sql-0.3.12}/bindings/python/tree_sitter_sql.egg-info/SOURCES.txt +1 -2
  5. tree_sitter_sql-0.3.12/bindings/python/tree_sitter_sql.egg-info/requires.txt +3 -0
  6. {tree_sitter_sql-0.3.11 → tree_sitter_sql-0.3.12}/pyproject.toml +2 -2
  7. {tree_sitter_sql-0.3.11 → tree_sitter_sql-0.3.12}/queries/highlights.scm +28 -2
  8. {tree_sitter_sql-0.3.11 → tree_sitter_sql-0.3.12}/setup.py +24 -24
  9. tree_sitter_sql-0.3.12/src/parser.c +4 -0
  10. {tree_sitter_sql-0.3.11 → tree_sitter_sql-0.3.12}/src/tree_sitter/array.h +118 -73
  11. tree_sitter_sql-0.3.11/bindings/python/tree_sitter_sql/__init__.pyi +0 -10
  12. tree_sitter_sql-0.3.11/bindings/python/tree_sitter_sql.egg-info/requires.txt +0 -3
  13. tree_sitter_sql-0.3.11/src/parser.c +0 -674655
  14. tree_sitter_sql-0.3.11/src/scanner.c +0 -188
  15. {tree_sitter_sql-0.3.11 → tree_sitter_sql-0.3.12}/LICENSE +0 -0
  16. {tree_sitter_sql-0.3.11 → tree_sitter_sql-0.3.12}/README.md +0 -0
  17. {tree_sitter_sql-0.3.11 → tree_sitter_sql-0.3.12}/bindings/python/tree_sitter_sql/__init__.py +0 -0
  18. {tree_sitter_sql-0.3.11 → tree_sitter_sql-0.3.12}/bindings/python/tree_sitter_sql/binding.c +0 -0
  19. {tree_sitter_sql-0.3.11 → tree_sitter_sql-0.3.12}/bindings/python/tree_sitter_sql/py.typed +0 -0
  20. {tree_sitter_sql-0.3.11 → tree_sitter_sql-0.3.12}/bindings/python/tree_sitter_sql.egg-info/dependency_links.txt +0 -0
  21. {tree_sitter_sql-0.3.11 → tree_sitter_sql-0.3.12}/bindings/python/tree_sitter_sql.egg-info/not-zip-safe +0 -0
  22. {tree_sitter_sql-0.3.11 → tree_sitter_sql-0.3.12}/bindings/python/tree_sitter_sql.egg-info/top_level.txt +0 -0
  23. {tree_sitter_sql-0.3.11 → tree_sitter_sql-0.3.12}/queries/indents.scm +0 -0
  24. {tree_sitter_sql-0.3.11 → tree_sitter_sql-0.3.12}/setup.cfg +0 -0
  25. {tree_sitter_sql-0.3.11 → tree_sitter_sql-0.3.12}/src/tree_sitter/alloc.h +0 -0
  26. {tree_sitter_sql-0.3.11 → tree_sitter_sql-0.3.12}/src/tree_sitter/parser.h +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: tree-sitter-sql
3
- Version: 0.3.11
3
+ Version: 0.3.12
4
4
  Summary: Tree-sitter Grammar for SQL
5
5
  Author: derek stride
6
6
  License: MIT
@@ -15,7 +15,7 @@ Requires-Python: >=3.10
15
15
  Description-Content-Type: text/markdown
16
16
  License-File: LICENSE
17
17
  Provides-Extra: core
18
- Requires-Dist: tree-sitter~=0.24; extra == "core"
18
+ Requires-Dist: tree-sitter~=0.25; extra == "core"
19
19
  Dynamic: license-file
20
20
 
21
21
  # tree-sitter-sql
@@ -0,0 +1,17 @@
1
+ from typing import Final
2
+ from typing_extensions import CapsuleType
3
+
4
+ HIGHLIGHTS_QUERY: Final[str] | None
5
+ """The syntax highlighting query for this grammar."""
6
+
7
+ INJECTIONS_QUERY: Final[str] | None
8
+ """The language injection query for this grammar."""
9
+
10
+ LOCALS_QUERY: Final[str] | None
11
+ """The local variable query for this grammar."""
12
+
13
+ TAGS_QUERY: Final[str] | None
14
+ """The symbol tagging query for this grammar."""
15
+
16
+ def language() -> CapsuleType:
17
+ """The tree-sitter language function for this grammar."""
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: tree-sitter-sql
3
- Version: 0.3.11
3
+ Version: 0.3.12
4
4
  Summary: Tree-sitter Grammar for SQL
5
5
  Author: derek stride
6
6
  License: MIT
@@ -15,7 +15,7 @@ Requires-Python: >=3.10
15
15
  Description-Content-Type: text/markdown
16
16
  License-File: LICENSE
17
17
  Provides-Extra: core
18
- Requires-Dist: tree-sitter~=0.24; extra == "core"
18
+ Requires-Dist: tree-sitter~=0.25; extra == "core"
19
19
  Dynamic: license-file
20
20
 
21
21
  # tree-sitter-sql
@@ -12,5 +12,4 @@ bindings/python/tree_sitter_sql.egg-info/dependency_links.txt
12
12
  bindings/python/tree_sitter_sql.egg-info/not-zip-safe
13
13
  bindings/python/tree_sitter_sql.egg-info/requires.txt
14
14
  bindings/python/tree_sitter_sql.egg-info/top_level.txt
15
- src/parser.c
16
- src/scanner.c
15
+ src/parser.c
@@ -0,0 +1,3 @@
1
+
2
+ [core]
3
+ tree-sitter~=0.25
@@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"
5
5
  [project]
6
6
  name = "tree-sitter-sql"
7
7
  description = "Tree-sitter Grammar for SQL"
8
- version = "0.3.11"
8
+ version = "0.3.12"
9
9
  keywords = ["incremental", "parsing", "tree-sitter", "sql"]
10
10
  classifiers = [
11
11
  "Intended Audience :: Developers",
@@ -23,7 +23,7 @@ readme = "README.md"
23
23
  Homepage = "https://github.com/derekstride/tree-sitter-sql.git"
24
24
 
25
25
  [project.optional-dependencies]
26
- core = ["tree-sitter~=0.24"]
26
+ core = ["tree-sitter~=0.25"]
27
27
 
28
28
  [tool.cibuildwheel]
29
29
  build = "cp310-*"
@@ -35,10 +35,10 @@
35
35
  (marginalia) @comment
36
36
 
37
37
  ((literal) @number
38
- (#match? @number "^[-+]?%d+$"))
38
+ (#match? @number "^[-+]?[0-9]+$"))
39
39
 
40
40
  ((literal) @float
41
- (#match? @float "^[-+]?%d*\.%d*$"))
41
+ (#match? @float "^[-+]?[0-9]*\\.[0-9]*$"))
42
42
 
43
43
  (parameter) @parameter
44
44
 
@@ -104,6 +104,11 @@
104
104
 
105
105
  [
106
106
  (keyword_select)
107
+ (keyword_grant)
108
+ (keyword_revoke)
109
+ (keyword_privileges)
110
+ (keyword_granted)
111
+ (keyword_maintain)
107
112
  (keyword_from)
108
113
  (keyword_where)
109
114
  (keyword_index)
@@ -135,8 +140,10 @@
135
140
  (keyword_group)
136
141
  (keyword_with)
137
142
  (keyword_without)
143
+ (keyword_within)
138
144
  (keyword_as)
139
145
  (keyword_having)
146
+ (keyword_qualify)
140
147
  (keyword_limit)
141
148
  (keyword_offset)
142
149
  (keyword_table)
@@ -147,6 +154,7 @@
147
154
  (keyword_constraint)
148
155
  (keyword_force)
149
156
  (keyword_use)
157
+ (keyword_include)
150
158
  (keyword_for)
151
159
  (keyword_if)
152
160
  (keyword_exists)
@@ -168,6 +176,7 @@
168
176
  (keyword_data)
169
177
  (keyword_type)
170
178
  (keyword_rename)
179
+ (keyword_refresh)
171
180
  (keyword_to)
172
181
  (keyword_schema)
173
182
  (keyword_owner)
@@ -182,6 +191,7 @@
182
191
  (keyword_transaction)
183
192
  (keyword_only)
184
193
  (keyword_like)
194
+ (keyword_rlike)
185
195
  (keyword_similar)
186
196
  (keyword_over)
187
197
  (keyword_change)
@@ -197,6 +207,7 @@
197
207
  (keyword_others)
198
208
  (keyword_zerofill)
199
209
  (keyword_format)
210
+ (keyword_serde)
200
211
  (keyword_fields)
201
212
  (keyword_row)
202
213
  (keyword_sort)
@@ -207,6 +218,8 @@
207
218
  (keyword_uncached)
208
219
  (keyword_lines)
209
220
  (keyword_stored)
221
+ (keyword_inputformat)
222
+ (keyword_outputformat)
210
223
  (keyword_virtual)
211
224
  (keyword_partitioned)
212
225
  (keyword_analyze)
@@ -254,17 +267,28 @@
254
267
  (keyword_password)
255
268
  (keyword_reset)
256
269
  (keyword_role)
270
+ (keyword_current_role)
257
271
  (keyword_sequence)
258
272
  (keyword_start)
259
273
  (keyword_restart)
260
274
  (keyword_tablespace)
275
+ (keyword_split)
276
+ (keyword_tablets)
261
277
  (keyword_until)
262
278
  (keyword_user)
279
+ (keyword_current_user)
280
+ (keyword_session_user)
263
281
  (keyword_valid)
264
282
  (keyword_action)
265
283
  (keyword_definer)
266
284
  (keyword_invoker)
285
+ (keyword_enable)
286
+ (keyword_disable)
267
287
  (keyword_security)
288
+ (keyword_policy)
289
+ (keyword_permissive)
290
+ (keyword_restrictive)
291
+ (keyword_public)
268
292
  (keyword_extension)
269
293
  (keyword_version)
270
294
  (keyword_out)
@@ -320,6 +344,7 @@
320
344
  (keyword_storage)
321
345
  (keyword_compression)
322
346
  (keyword_duplicate)
347
+ (keyword_while)
323
348
  ] @keyword
324
349
 
325
350
  [
@@ -331,6 +356,7 @@
331
356
  (keyword_high_priority)
332
357
  (keyword_low_priority)
333
358
  (keyword_ignore)
359
+ (keyword_respect)
334
360
  (keyword_nothing)
335
361
  (keyword_check)
336
362
  (keyword_option)
@@ -1,31 +1,12 @@
1
1
  from os import path
2
- from platform import system
3
2
  from sysconfig import get_config_var
4
3
 
5
4
  from setuptools import Extension, find_packages, setup
6
5
  from setuptools.command.build import build
6
+ from setuptools.command.build_ext import build_ext
7
7
  from setuptools.command.egg_info import egg_info
8
8
  from wheel.bdist_wheel import bdist_wheel
9
9
 
10
- sources = [
11
- "bindings/python/tree_sitter_sql/binding.c",
12
- "src/parser.c",
13
- ]
14
- if path.exists("src/scanner.c"):
15
- sources.append("src/scanner.c")
16
-
17
- macros: list[tuple[str, str | None]] = [
18
- ("PY_SSIZE_T_CLEAN", None),
19
- ("TREE_SITTER_HIDE_SYMBOLS", None),
20
- ]
21
- if limited_api := not get_config_var("Py_GIL_DISABLED"):
22
- macros.append(("Py_LIMITED_API", "0x030A0000"))
23
-
24
- if system() != "Windows":
25
- cflags = ["-std=c11", "-fvisibility=hidden"]
26
- else:
27
- cflags = ["/std:c11", "/utf-8"]
28
-
29
10
 
30
11
  class Build(build):
31
12
  def run(self):
@@ -35,6 +16,19 @@ class Build(build):
35
16
  super().run()
36
17
 
37
18
 
19
+ class BuildExt(build_ext):
20
+ def build_extension(self, ext: Extension):
21
+ if self.compiler.compiler_type != "msvc":
22
+ ext.extra_compile_args = ["-std=c11", "-fvisibility=hidden"]
23
+ else:
24
+ ext.extra_compile_args = ["/std:c11", "/utf-8"]
25
+ if path.exists("src/scanner.c"):
26
+ ext.sources.append("src/scanner.c")
27
+ if ext.py_limited_api:
28
+ ext.define_macros.append(("Py_LIMITED_API", "0x030A0000"))
29
+ super().build_extension(ext)
30
+
31
+
38
32
  class BdistWheel(bdist_wheel):
39
33
  def get_tag(self):
40
34
  python, abi, platform = super().get_tag()
@@ -61,15 +55,21 @@ setup(
61
55
  ext_modules=[
62
56
  Extension(
63
57
  name="_binding",
64
- sources=sources,
65
- extra_compile_args=cflags,
66
- define_macros=macros,
58
+ sources=[
59
+ "bindings/python/tree_sitter_sql/binding.c",
60
+ "src/parser.c",
61
+ ],
62
+ define_macros=[
63
+ ("PY_SSIZE_T_CLEAN", None),
64
+ ("TREE_SITTER_HIDE_SYMBOLS", None),
65
+ ],
67
66
  include_dirs=["src"],
68
- py_limited_api=limited_api,
67
+ py_limited_api=not get_config_var("Py_GIL_DISABLED"),
69
68
  )
70
69
  ],
71
70
  cmdclass={
72
71
  "build": Build,
72
+ "build_ext": BuildExt,
73
73
  "bdist_wheel": BdistWheel,
74
74
  "egg_info": EggInfo,
75
75
  },
@@ -0,0 +1,4 @@
1
+ [diffend] Oversized file quarantined before diffing.
2
+ name: tree_sitter_sql-0.3.12/src/parser.c
3
+ size: 44670374 bytes
4
+ sha256: aa3da00a1eaf8badf826eabc85e3fe727021636def5579c027f6be1a68de542c
@@ -50,69 +50,104 @@ extern "C" {
50
50
  /// memory allocated for the array's contents.
51
51
  #define array_clear(self) ((self)->size = 0)
52
52
 
53
+ #ifdef __cplusplus
54
+ #define _array__cast(self, expr) (decltype((self)->contents))(expr)
55
+ #else
56
+ #define _array__cast(self, expr) (expr)
57
+ #endif
58
+
53
59
  /// Reserve `new_capacity` elements of space in the array. If `new_capacity` is
54
60
  /// less than the array's current capacity, this function has no effect.
55
- #define array_reserve(self, new_capacity) \
56
- _array__reserve((Array *)(self), array_elem_size(self), new_capacity)
61
+ #define array_reserve(self, new_capacity) \
62
+ ((self)->contents = _array__cast(self, _array__reserve( \
63
+ (void *)(self)->contents, &(self)->capacity, \
64
+ array_elem_size(self), new_capacity)) \
65
+ )
57
66
 
58
67
  /// Free any memory allocated for this array. Note that this does not free any
59
68
  /// memory allocated for the array's contents.
60
- #define array_delete(self) _array__delete((Array *)(self))
69
+ #define array_delete(self) \
70
+ do { \
71
+ if ((self)->contents) ts_free((self)->contents); \
72
+ (self)->contents = NULL; \
73
+ (self)->size = 0; \
74
+ (self)->capacity = 0; \
75
+ } while (0)
61
76
 
62
77
  /// Push a new `element` onto the end of the array.
63
- #define array_push(self, element) \
64
- (_array__grow((Array *)(self), 1, array_elem_size(self)), \
65
- (self)->contents[(self)->size++] = (element))
78
+ #define array_push(self, element) \
79
+ do { \
80
+ (self)->contents = _array__cast(self, _array__grow( \
81
+ (void *)(self)->contents, (self)->size, &(self)->capacity, \
82
+ 1, array_elem_size(self) \
83
+ )); \
84
+ (self)->contents[(self)->size++] = (element); \
85
+ } while(0)
66
86
 
67
87
  /// Increase the array's size by `count` elements.
68
88
  /// New elements are zero-initialized.
69
- #define array_grow_by(self, count) \
70
- do { \
71
- if ((count) == 0) break; \
72
- _array__grow((Array *)(self), count, array_elem_size(self)); \
89
+ #define array_grow_by(self, count) \
90
+ do { \
91
+ if ((count) == 0) break; \
92
+ (self)->contents = _array__cast(self, _array__grow( \
93
+ (self)->contents, (self)->size, &(self)->capacity, \
94
+ count, array_elem_size(self) \
95
+ )); \
73
96
  memset((self)->contents + (self)->size, 0, (count) * array_elem_size(self)); \
74
- (self)->size += (count); \
97
+ (self)->size += (count); \
75
98
  } while (0)
76
99
 
77
100
  /// Append all elements from one array to the end of another.
78
- #define array_push_all(self, other) \
101
+ #define array_push_all(self, other) \
79
102
  array_extend((self), (other)->size, (other)->contents)
80
103
 
81
104
  /// Append `count` elements to the end of the array, reading their values from the
82
105
  /// `contents` pointer.
83
- #define array_extend(self, count, contents) \
84
- _array__splice( \
85
- (Array *)(self), array_elem_size(self), (self)->size, \
86
- 0, count, contents \
87
- )
106
+ #define array_extend(self, count, other_contents) \
107
+ ((self)->contents = _array__cast(self, _array__splice( \
108
+ (void*)(self)->contents, &(self)->size, &(self)->capacity, \
109
+ array_elem_size(self), (self)->size, 0, count, other_contents \
110
+ )))
88
111
 
89
112
  /// Remove `old_count` elements from the array starting at the given `index`. At
90
113
  /// the same index, insert `new_count` new elements, reading their values from the
91
114
  /// `new_contents` pointer.
92
- #define array_splice(self, _index, old_count, new_count, new_contents) \
93
- _array__splice( \
94
- (Array *)(self), array_elem_size(self), _index, \
95
- old_count, new_count, new_contents \
96
- )
115
+ #define array_splice(self, _index, old_count, new_count, new_contents) \
116
+ ((self)->contents = _array__cast(self, _array__splice( \
117
+ (void *)(self)->contents, &(self)->size, &(self)->capacity, \
118
+ array_elem_size(self), _index, old_count, new_count, new_contents \
119
+ )))
97
120
 
98
121
  /// Insert one `element` into the array at the given `index`.
99
- #define array_insert(self, _index, element) \
100
- _array__splice((Array *)(self), array_elem_size(self), _index, 0, 1, &(element))
122
+ #define array_insert(self, _index, element) \
123
+ ((self)->contents = _array__cast(self, _array__splice( \
124
+ (void *)(self)->contents, &(self)->size, &(self)->capacity, \
125
+ array_elem_size(self), _index, 0, 1, &(element) \
126
+ )))
101
127
 
102
128
  /// Remove one element from the array at the given `index`.
103
129
  #define array_erase(self, _index) \
104
- _array__erase((Array *)(self), array_elem_size(self), _index)
130
+ _array__erase((void *)(self)->contents, &(self)->size, array_elem_size(self), _index)
105
131
 
106
132
  /// Pop the last element off the array, returning the element by value.
107
133
  #define array_pop(self) ((self)->contents[--(self)->size])
108
134
 
109
135
  /// Assign the contents of one array to another, reallocating if necessary.
110
- #define array_assign(self, other) \
111
- _array__assign((Array *)(self), (const Array *)(other), array_elem_size(self))
136
+ #define array_assign(self, other) \
137
+ ((self)->contents = _array__cast(self, _array__assign( \
138
+ (void *)(self)->contents, &(self)->size, &(self)->capacity, \
139
+ (const void *)(other)->contents, (other)->size, array_elem_size(self) \
140
+ )))
112
141
 
113
142
  /// Swap one array with another
114
- #define array_swap(self, other) \
115
- _array__swap((Array *)(self), (Array *)(other))
143
+ #define array_swap(self, other) \
144
+ do { \
145
+ void *_array_swap_tmp = (void *)(self)->contents; \
146
+ (self)->contents = (other)->contents; \
147
+ (other)->contents = _array__cast(other, _array_swap_tmp); \
148
+ _array__swap(&(self)->size, &(self)->capacity, \
149
+ &(other)->size, &(other)->capacity); \
150
+ } while (0)
116
151
 
117
152
  /// Get the size of the array contents
118
153
  #define array_elem_size(self) (sizeof *(self)->contents)
@@ -157,82 +192,90 @@ extern "C" {
157
192
 
158
193
  // Private
159
194
 
160
- typedef Array(void) Array;
161
-
162
- /// This is not what you're looking for, see `array_delete`.
163
- static inline void _array__delete(Array *self) {
164
- if (self->contents) {
165
- ts_free(self->contents);
166
- self->contents = NULL;
167
- self->size = 0;
168
- self->capacity = 0;
169
- }
170
- }
195
+ // Pointers to individual `Array` fields (rather than the entire `Array` itself)
196
+ // are passed to the various `_array__*` functions below to address strict aliasing
197
+ // violations that arises when the _entire_ `Array` struct is passed as `Array(void)*`.
198
+ //
199
+ // The `Array` type itself was not altered as a solution in order to avoid breakage
200
+ // with existing consumers (in particular, parsers with external scanners).
171
201
 
172
202
  /// This is not what you're looking for, see `array_erase`.
173
- static inline void _array__erase(Array *self, size_t element_size,
174
- uint32_t index) {
175
- assert(index < self->size);
176
- char *contents = (char *)self->contents;
203
+ static inline void _array__erase(void* self_contents, uint32_t *size,
204
+ size_t element_size, uint32_t index) {
205
+ assert(index < *size);
206
+ char *contents = (char *)self_contents;
177
207
  memmove(contents + index * element_size, contents + (index + 1) * element_size,
178
- (self->size - index - 1) * element_size);
179
- self->size--;
208
+ (*size - index - 1) * element_size);
209
+ (*size)--;
180
210
  }
181
211
 
182
212
  /// This is not what you're looking for, see `array_reserve`.
183
- static inline void _array__reserve(Array *self, size_t element_size, uint32_t new_capacity) {
184
- if (new_capacity > self->capacity) {
185
- if (self->contents) {
186
- self->contents = ts_realloc(self->contents, new_capacity * element_size);
213
+ static inline void *_array__reserve(void *contents, uint32_t *capacity,
214
+ size_t element_size, uint32_t new_capacity) {
215
+ void *new_contents = contents;
216
+ if (new_capacity > *capacity) {
217
+ if (contents) {
218
+ new_contents = ts_realloc(contents, new_capacity * element_size);
187
219
  } else {
188
- self->contents = ts_malloc(new_capacity * element_size);
220
+ new_contents = ts_malloc(new_capacity * element_size);
189
221
  }
190
- self->capacity = new_capacity;
222
+ *capacity = new_capacity;
191
223
  }
224
+ return new_contents;
192
225
  }
193
226
 
194
227
  /// This is not what you're looking for, see `array_assign`.
195
- static inline void _array__assign(Array *self, const Array *other, size_t element_size) {
196
- _array__reserve(self, element_size, other->size);
197
- self->size = other->size;
198
- memcpy(self->contents, other->contents, self->size * element_size);
228
+ static inline void *_array__assign(void* self_contents, uint32_t *self_size, uint32_t *self_capacity,
229
+ const void *other_contents, uint32_t other_size, size_t element_size) {
230
+ void *new_contents = _array__reserve(self_contents, self_capacity, element_size, other_size);
231
+ *self_size = other_size;
232
+ memcpy(new_contents, other_contents, *self_size * element_size);
233
+ return new_contents;
199
234
  }
200
235
 
201
236
  /// This is not what you're looking for, see `array_swap`.
202
- static inline void _array__swap(Array *self, Array *other) {
203
- Array swap = *other;
204
- *other = *self;
205
- *self = swap;
237
+ static inline void _array__swap(uint32_t *self_size, uint32_t *self_capacity,
238
+ uint32_t *other_size, uint32_t *other_capacity) {
239
+ uint32_t tmp_size = *self_size;
240
+ uint32_t tmp_capacity = *self_capacity;
241
+ *self_size = *other_size;
242
+ *self_capacity = *other_capacity;
243
+ *other_size = tmp_size;
244
+ *other_capacity = tmp_capacity;
206
245
  }
207
246
 
208
247
  /// This is not what you're looking for, see `array_push` or `array_grow_by`.
209
- static inline void _array__grow(Array *self, uint32_t count, size_t element_size) {
210
- uint32_t new_size = self->size + count;
211
- if (new_size > self->capacity) {
212
- uint32_t new_capacity = self->capacity * 2;
248
+ static inline void *_array__grow(void *contents, uint32_t size, uint32_t *capacity,
249
+ uint32_t count, size_t element_size) {
250
+ void *new_contents = contents;
251
+ uint32_t new_size = size + count;
252
+ if (new_size > *capacity) {
253
+ uint32_t new_capacity = *capacity * 2;
213
254
  if (new_capacity < 8) new_capacity = 8;
214
255
  if (new_capacity < new_size) new_capacity = new_size;
215
- _array__reserve(self, element_size, new_capacity);
256
+ new_contents = _array__reserve(contents, capacity, element_size, new_capacity);
216
257
  }
258
+ return new_contents;
217
259
  }
218
260
 
219
261
  /// This is not what you're looking for, see `array_splice`.
220
- static inline void _array__splice(Array *self, size_t element_size,
262
+ static inline void *_array__splice(void *self_contents, uint32_t *size, uint32_t *capacity,
263
+ size_t element_size,
221
264
  uint32_t index, uint32_t old_count,
222
265
  uint32_t new_count, const void *elements) {
223
- uint32_t new_size = self->size + new_count - old_count;
266
+ uint32_t new_size = *size + new_count - old_count;
224
267
  uint32_t old_end = index + old_count;
225
268
  uint32_t new_end = index + new_count;
226
- assert(old_end <= self->size);
269
+ assert(old_end <= *size);
227
270
 
228
- _array__reserve(self, element_size, new_size);
271
+ void *new_contents = _array__reserve(self_contents, capacity, element_size, new_size);
229
272
 
230
- char *contents = (char *)self->contents;
231
- if (self->size > old_end) {
273
+ char *contents = (char *)new_contents;
274
+ if (*size > old_end) {
232
275
  memmove(
233
276
  contents + new_end * element_size,
234
277
  contents + old_end * element_size,
235
- (self->size - old_end) * element_size
278
+ (*size - old_end) * element_size
236
279
  );
237
280
  }
238
281
  if (new_count > 0) {
@@ -250,7 +293,9 @@ static inline void _array__splice(Array *self, size_t element_size,
250
293
  );
251
294
  }
252
295
  }
253
- self->size += new_count - old_count;
296
+ *size += new_count - old_count;
297
+
298
+ return new_contents;
254
299
  }
255
300
 
256
301
  /// A binary search routine, based on Rust's `std::slice::binary_search_by`.
@@ -1,10 +0,0 @@
1
- from typing import Final
2
-
3
- # NOTE: uncomment these to include any queries that this grammar contains:
4
-
5
- HIGHLIGHTS_QUERY: Final[str]
6
- # INJECTIONS_QUERY: Final[str]
7
- # LOCALS_QUERY: Final[str]
8
- # TAGS_QUERY: Final[str]
9
-
10
- def language() -> object: ...
@@ -1,3 +0,0 @@
1
-
2
- [core]
3
- tree-sitter~=0.24