idk what was going on here, it's been months

This commit is contained in:
Vivian Lim 2023-10-11 15:36:29 -07:00
parent 10669bf9d4
commit 81b6b1eefe
3 changed files with 881 additions and 0 deletions

View File

@ -10,6 +10,7 @@ namespace TreeSitterLib
unsafe
{
var parser = TreeSitterNative.ts_parser_new();
TreeSitterNative.ts_parser_set_language(parser);
}
}

View File

@ -0,0 +1,868 @@
// <auto-generated>
// This code is generated by csbindgen.
// DON'T CHANGE THIS DIRECTLY.
// </auto-generated>
#pragma warning disable CS8500
#pragma warning disable CS8981
using System;
using System.Runtime.InteropServices;
namespace CsBindgen
{
internal static unsafe partial class NativeMethods
{
const string __DllName = "tree-sitter-csbindings";
[DllImport(__DllName, EntryPoint = "csbindgen_calloc", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern void* calloc(ulong _Count, ulong _Size);
[DllImport(__DllName, EntryPoint = "csbindgen_free", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern void free(void* _Block);
[DllImport(__DllName, EntryPoint = "csbindgen_malloc", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern void* malloc(ulong _Size);
[DllImport(__DllName, EntryPoint = "csbindgen_realloc", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern void* realloc(void* _Block, ulong _Size);
[DllImport(__DllName, EntryPoint = "csbindgen_bsearch_s", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern void* bsearch_s(void* _Key, void* _Base, nuint _NumOfElements, nuint _SizeOfElements, delegate* unmanaged[Cdecl]<void*, void*, void*, int> _CompareFunction, void* _Context);
[DllImport(__DllName, EntryPoint = "csbindgen_qsort_s", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern void qsort_s(void* _Base, nuint _NumOfElements, nuint _SizeOfElements, delegate* unmanaged[Cdecl]<void*, void*, void*, int> _CompareFunction, void* _Context);
[DllImport(__DllName, EntryPoint = "csbindgen_bsearch", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern void* bsearch(void* _Key, void* _Base, nuint _NumOfElements, nuint _SizeOfElements, delegate* unmanaged[Cdecl]<void*, void*, int> _CompareFunction);
[DllImport(__DllName, EntryPoint = "csbindgen_qsort", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern void qsort(void* _Base, nuint _NumOfElements, nuint _SizeOfElements, delegate* unmanaged[Cdecl]<void*, void*, int> _CompareFunction);
[DllImport(__DllName, EntryPoint = "csbindgen_lfind", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern void* lfind(void* _Key, void* _Base, uint* _NumOfElements, uint _SizeOfElements, delegate* unmanaged[Cdecl]<void*, void*, int> _CompareFunction);
[DllImport(__DllName, EntryPoint = "csbindgen_lsearch", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern void* lsearch(void* _Key, void* _Base, uint* _NumOfElements, uint _SizeOfElements, delegate* unmanaged[Cdecl]<void*, void*, int> _CompareFunction);
[DllImport(__DllName, EntryPoint = "csbindgen_wcstod", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern double wcstod(ushort* _String, ushort** _EndPtr);
[DllImport(__DllName, EntryPoint = "csbindgen_wcstol", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern CLong wcstol(ushort* _String, ushort** _EndPtr, int _Radix);
[DllImport(__DllName, EntryPoint = "csbindgen_wcstoll", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern long wcstoll(ushort* _String, ushort** _EndPtr, int _Radix);
[DllImport(__DllName, EntryPoint = "csbindgen_wcstoul", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern CULong wcstoul(ushort* _String, ushort** _EndPtr, int _Radix);
[DllImport(__DllName, EntryPoint = "csbindgen_wcstoull", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern ulong wcstoull(ushort* _String, ushort** _EndPtr, int _Radix);
[DllImport(__DllName, EntryPoint = "csbindgen_wcstold", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern double wcstold(ushort* _String, ushort** _EndPtr);
[DllImport(__DllName, EntryPoint = "csbindgen_wcstof", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern float wcstof(ushort* _String, ushort** _EndPtr);
[DllImport(__DllName, EntryPoint = "csbindgen_atexit", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern int atexit(delegate* unmanaged[Cdecl]<void> arg1);
[DllImport(__DllName, EntryPoint = "csbindgen_at_quick_exit", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern int at_quick_exit(delegate* unmanaged[Cdecl]<void> arg1);
[DllImport(__DllName, EntryPoint = "csbindgen_perror", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern void perror(byte* _ErrMsg);
[DllImport(__DllName, EntryPoint = "csbindgen_abs", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern int abs(int _Number);
[DllImport(__DllName, EntryPoint = "csbindgen_labs", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern CLong labs(CLong _Number);
[DllImport(__DllName, EntryPoint = "csbindgen_llabs", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern long llabs(long _Number);
[DllImport(__DllName, EntryPoint = "csbindgen_div", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern _div_t div(int _Numerator, int _Denominator);
[DllImport(__DllName, EntryPoint = "csbindgen_ldiv", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern _ldiv_t ldiv(CLong _Numerator, CLong _Denominator);
[DllImport(__DllName, EntryPoint = "csbindgen_lldiv", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern _lldiv_t lldiv(long _Numerator, long _Denominator);
[DllImport(__DllName, EntryPoint = "csbindgen_srand", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern void srand(uint _Seed);
[DllImport(__DllName, EntryPoint = "csbindgen_rand", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern int rand();
[DllImport(__DllName, EntryPoint = "csbindgen_atof", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern double atof(byte* _String);
[DllImport(__DllName, EntryPoint = "csbindgen_atoi", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern int atoi(byte* _String);
[DllImport(__DllName, EntryPoint = "csbindgen_atol", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern CLong atol(byte* _String);
[DllImport(__DllName, EntryPoint = "csbindgen_atoll", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern long atoll(byte* _String);
[DllImport(__DllName, EntryPoint = "csbindgen_strtof", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern float strtof(byte* _String, byte** _EndPtr);
[DllImport(__DllName, EntryPoint = "csbindgen_strtod", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern double strtod(byte* _String, byte** _EndPtr);
[DllImport(__DllName, EntryPoint = "csbindgen_strtold", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern double strtold(byte* _String, byte** _EndPtr);
[DllImport(__DllName, EntryPoint = "csbindgen_strtol", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern CLong strtol(byte* _String, byte** _EndPtr, int _Radix);
[DllImport(__DllName, EntryPoint = "csbindgen_strtoll", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern long strtoll(byte* _String, byte** _EndPtr, int _Radix);
[DllImport(__DllName, EntryPoint = "csbindgen_strtoul", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern CULong strtoul(byte* _String, byte** _EndPtr, int _Radix);
[DllImport(__DllName, EntryPoint = "csbindgen_strtoull", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern ulong strtoull(byte* _String, byte** _EndPtr, int _Radix);
[DllImport(__DllName, EntryPoint = "csbindgen_mblen", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern int mblen(byte* _Ch, nuint _MaxCount);
[DllImport(__DllName, EntryPoint = "csbindgen_mbtowc", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern int mbtowc(ushort* _DstCh, byte* _SrcCh, nuint _SrcSizeInBytes);
[DllImport(__DllName, EntryPoint = "csbindgen_mbstowcs_s", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern int mbstowcs_s(nuint* _PtNumOfCharConverted, ushort* _DstBuf, nuint _SizeInWords, byte* _SrcBuf, nuint _MaxCount);
[DllImport(__DllName, EntryPoint = "csbindgen_mbstowcs", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern nuint mbstowcs(ushort* _Dest, byte* _Source, nuint _MaxCount);
[DllImport(__DllName, EntryPoint = "csbindgen_wctomb", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern int wctomb(byte* _MbCh, ushort _WCh);
[DllImport(__DllName, EntryPoint = "csbindgen_wctomb_s", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern int wctomb_s(int* _SizeConverted, byte* _MbCh, nuint _SizeInBytes, ushort _WCh);
[DllImport(__DllName, EntryPoint = "csbindgen_wcstombs_s", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern int wcstombs_s(nuint* _PtNumOfCharConverted, byte* _Dst, nuint _DstSizeInBytes, ushort* _Src, nuint _MaxCountInBytes);
[DllImport(__DllName, EntryPoint = "csbindgen_wcstombs", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern nuint wcstombs(byte* _Dest, ushort* _Source, nuint _MaxCount);
[DllImport(__DllName, EntryPoint = "csbindgen_getenv_s", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern int getenv_s(nuint* _RequiredCount, byte* _Buffer, nuint _BufferCount, byte* _VarName);
[DllImport(__DllName, EntryPoint = "csbindgen_getenv", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern byte* getenv(byte* _VarName);
[DllImport(__DllName, EntryPoint = "csbindgen_system", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern int system(byte* _Command);
[DllImport(__DllName, EntryPoint = "csbindgen_ecvt", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern byte* ecvt(double _Value, int _DigitCount, int* _PtDec, int* _PtSign);
[DllImport(__DllName, EntryPoint = "csbindgen_fcvt", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern byte* fcvt(double _Value, int _FractionalDigitCount, int* _PtDec, int* _PtSign);
[DllImport(__DllName, EntryPoint = "csbindgen_gcvt", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern byte* gcvt(double _Value, int _DigitCount, byte* _DstBuf);
[DllImport(__DllName, EntryPoint = "csbindgen_itoa", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern byte* itoa(int _Value, byte* _Buffer, int _Radix);
[DllImport(__DllName, EntryPoint = "csbindgen_ltoa", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern byte* ltoa(CLong _Value, byte* _Buffer, int _Radix);
[DllImport(__DllName, EntryPoint = "csbindgen_swab", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern void swab(byte* _Buf1, byte* _Buf2, int _SizeInBytes);
[DllImport(__DllName, EntryPoint = "csbindgen_ultoa", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern byte* ultoa(CULong _Value, byte* _Buffer, int _Radix);
[DllImport(__DllName, EntryPoint = "csbindgen_putenv", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern int putenv(byte* _EnvString);
[DllImport(__DllName, EntryPoint = "csbindgen_onexit", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern delegate* unmanaged[Cdecl]<int> onexit(delegate* unmanaged[Cdecl]<int> _Func);
/// <summary>Create a new parser.</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_ts_parser_new", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern TSParser* ts_parser_new();
/// <summary>Delete the parser, freeing all of the memory that it used.</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_ts_parser_delete", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern void ts_parser_delete(TSParser* self_);
/// <summary>Get the parser's current language.</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_ts_parser_language", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern TSLanguage* ts_parser_language(TSParser* self_);
/// <summary>Set the language that the parser should use for parsing. Returns a boolean indicating whether or not the language was successfully assigned. True means assignment succeeded. False means there was a version mismatch: the language was generated with an incompatible version of the Tree-sitter CLI. Check the language's version using [`ts_language_version`] and compare it to this library's [`TREE_SITTER_LANGUAGE_VERSION`] and [`TREE_SITTER_MIN_COMPATIBLE_LANGUAGE_VERSION`] constants.</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_ts_parser_set_language", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[return: MarshalAs(UnmanagedType.U1)]
public static extern bool ts_parser_set_language(TSParser* self_, TSLanguage* language);
/// <summary>Set the ranges of text that the parser should include when parsing. By default, the parser will always include entire documents. This function allows you to parse only a *portion* of a document but still return a syntax tree whose ranges match up with the document as a whole. You can also pass multiple disjoint ranges. The second and third parameters specify the location and length of an array of ranges. The parser does *not* take ownership of these ranges; it copies the data, so it doesn't matter how these ranges are allocated. If `count` is zero, then the entire document will be parsed. Otherwise, the given ranges must be ordered from earliest to latest in the document, and they must not overlap. That is, the following must hold for all: `i &lt; count - 1`: `ranges[i].end_byte &lt;= ranges[i + 1].start_byte` If this requirement is not satisfied, the operation will fail, the ranges will not be assigned, and this function will return `false`. On success, this function returns `true`</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_ts_parser_set_included_ranges", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[return: MarshalAs(UnmanagedType.U1)]
public static extern bool ts_parser_set_included_ranges(TSParser* self_, TSRange* ranges, uint count);
/// <summary>Get the ranges of text that the parser will include when parsing. The returned pointer is owned by the parser. The caller should not free it or write to it. The length of the array will be written to the given `count` pointer.</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_ts_parser_included_ranges", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern TSRange* ts_parser_included_ranges(TSParser* self_, uint* count);
/// <summary>Use the parser to parse some source code and create a syntax tree. If you are parsing this document for the first time, pass `NULL` for the `old_tree` parameter. Otherwise, if you have already parsed an earlier version of this document and the document has since been edited, pass the previous syntax tree so that the unchanged parts of it can be reused. This will save time and memory. For this to work correctly, you must have already edited the old syntax tree using the [`ts_tree_edit`] function in a way that exactly matches the source code changes. The [`TSInput`] parameter lets you specify how to read the text. It has the following three fields: 1. [`read`]: A function to retrieve a chunk of text at a given byte offset and (row, column) position. The function should return a pointer to the text and write its length to the [`bytes_read`] pointer. The parser does not take ownership of this buffer; it just borrows it until it has finished reading it. The function should write a zero value to the [`bytes_read`] pointer to indicate the end of the document. 2. [`payload`]: An arbitrary pointer that will be passed to each invocation of the [`read`] function. 3. [`encoding`]: An indication of how the text is encoded. Either `TSInputEncodingUTF8` or `TSInputEncodingUTF16`. This function returns a syntax tree on success, and `NULL` on failure. There are three possible reasons for failure: 1. The parser does not have a language assigned. Check for this using the[`ts_parser_language`] function. 2. Parsing was cancelled due to a timeout that was set by an earlier call to the [`ts_parser_set_timeout_micros`] function. You can resume parsing from where the parser left out by calling [`ts_parser_parse`] again with the same arguments. Or you can start parsing from scratch by first calling [`ts_parser_reset`]. 3. Parsing was cancelled using a cancellation flag that was set by an earlier call to [`ts_parser_set_cancellation_flag`]. You can resume parsing from where the parser left out by calling [`ts_parser_parse`] again with the same arguments. [`read`]: TSInput::read [`payload`]: TSInput::payload [`encoding`]: TSInput::encoding [`bytes_read`]: TSInput::read</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_ts_parser_parse", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern TSTree* ts_parser_parse(TSParser* self_, TSTree* old_tree, TSInput input);
/// <summary>Use the parser to parse some source code stored in one contiguous buffer. The first two parameters are the same as in the [`ts_parser_parse`] function above. The second two parameters indicate the location of the buffer and its length in bytes.</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_ts_parser_parse_string", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern TSTree* ts_parser_parse_string(TSParser* self_, TSTree* old_tree, byte* @string, uint length);
/// <summary>Use the parser to parse some source code stored in one contiguous buffer with a given encoding. The first four parameters work the same as in the [`ts_parser_parse_string`] method above. The final parameter indicates whether the text is encoded as UTF8 or UTF16.</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_ts_parser_parse_string_encoding", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern TSTree* ts_parser_parse_string_encoding(TSParser* self_, TSTree* old_tree, byte* @string, uint length, int encoding);
/// <summary>Instruct the parser to start the next parse from the beginning. If the parser previously failed because of a timeout or a cancellation, then by default, it will resume where it left off on the next call to [`ts_parser_parse`] or other parsing functions. If you don't want to resume, and instead intend to use this parser to parse some other document, you must call [`ts_parser_reset`] first.</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_ts_parser_reset", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern void ts_parser_reset(TSParser* self_);
/// <summary>Set the maximum duration in microseconds that parsing should be allowed to take before halting. If parsing takes longer than this, it will halt early, returning NULL. See [`ts_parser_parse`] for more information.</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_ts_parser_set_timeout_micros", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern void ts_parser_set_timeout_micros(TSParser* self_, ulong timeout_micros);
/// <summary>Get the duration in microseconds that parsing is allowed to take.</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_ts_parser_timeout_micros", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern ulong ts_parser_timeout_micros(TSParser* self_);
/// <summary>Set the parser's current cancellation flag pointer. If a non-null pointer is assigned, then the parser will periodically read from this pointer during parsing. If it reads a non-zero value, it will halt early, returning NULL. See [`ts_parser_parse`] for more information.</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_ts_parser_set_cancellation_flag", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern void ts_parser_set_cancellation_flag(TSParser* self_, nuint* flag);
/// <summary>Get the parser's current cancellation flag pointer.</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_ts_parser_cancellation_flag", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern nuint* ts_parser_cancellation_flag(TSParser* self_);
/// <summary>Set the logger that a parser should use during parsing. The parser does not take ownership over the logger payload. If a logger was previously assigned, the caller is responsible for releasing any memory owned by the previous logger.</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_ts_parser_set_logger", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern void ts_parser_set_logger(TSParser* self_, TSLogger logger);
/// <summary>Get the parser's current logger.</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_ts_parser_logger", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern TSLogger ts_parser_logger(TSParser* self_);
/// <summary>Set the file descriptor to which the parser should write debugging graphs during parsing. The graphs are formatted in the DOT language. You may want to pipe these graphs directly to a `dot(1)` process in order to generate SVG output. You can turn off this logging by passing a negative number.</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_ts_parser_print_dot_graphs", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern void ts_parser_print_dot_graphs(TSParser* self_, int fd);
/// <summary>Create a shallow copy of the syntax tree. This is very fast. You need to copy a syntax tree in order to use it on more than one thread at a time, as syntax trees are not thread safe.</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_ts_tree_copy", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern TSTree* ts_tree_copy(TSTree* self_);
/// <summary>Delete the syntax tree, freeing all of the memory that it used.</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_ts_tree_delete", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern void ts_tree_delete(TSTree* self_);
/// <summary>Get the root node of the syntax tree.</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_ts_tree_root_node", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern TSNode ts_tree_root_node(TSTree* self_);
/// <summary>Get the root node of the syntax tree, but with its position shifted forward by the given offset.</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_ts_tree_root_node_with_offset", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern TSNode ts_tree_root_node_with_offset(TSTree* self_, uint offset_bytes, TSPoint offset_extent);
/// <summary>Get the language that was used to parse the syntax tree.</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_ts_tree_language", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern TSLanguage* ts_tree_language(TSTree* self_);
/// <summary>Get the array of included ranges that was used to parse the syntax tree. The returned pointer must be freed by the caller.</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_ts_tree_included_ranges", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern TSRange* ts_tree_included_ranges(TSTree* self_, uint* length);
/// <summary>Edit the syntax tree to keep it in sync with source code that has been edited. You must describe the edit both in terms of byte offsets and in terms of (row, column) coordinates.</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_ts_tree_edit", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern void ts_tree_edit(TSTree* self_, TSInputEdit* edit);
/// <summary>Compare an old edited syntax tree to a new syntax tree representing the same document, returning an array of ranges whose syntactic structure has changed. For this to work correctly, the old syntax tree must have been edited such that its ranges match up to the new tree. Generally, you'll want to call this function right after calling one of the [`ts_parser_parse`] functions. You need to pass the old tree that was passed to parse, as well as the new tree that was returned from that function. The returned array is allocated using `malloc` and the caller is responsible for freeing it using `free`. The length of the array will be written to the given `length` pointer.</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_ts_tree_get_changed_ranges", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern TSRange* ts_tree_get_changed_ranges(TSTree* old_tree, TSTree* new_tree, uint* length);
/// <summary>Write a DOT graph describing the syntax tree to the given file.</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_ts_tree_print_dot_graph", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern void ts_tree_print_dot_graph(TSTree* self_, int file_descriptor);
/// <summary>Get the node's type as a null-terminated string.</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_ts_node_type", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern byte* ts_node_type(TSNode self_);
/// <summary>Get the node's type as a numerical id.</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_ts_node_symbol", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern ushort ts_node_symbol(TSNode self_);
/// <summary>Get the node's language.</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_ts_node_language", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern TSLanguage* ts_node_language(TSNode self_);
/// <summary>Get the node's type as it appears in the grammar ignoring aliases as a null-terminated string.</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_ts_node_grammar_type", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern byte* ts_node_grammar_type(TSNode self_);
/// <summary>Get the node's type as a numerical id as it appears in the grammar ignoring aliases. This should be used in [`ts_language_next_state`] instead of [`ts_node_symbol`].</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_ts_node_grammar_symbol", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern ushort ts_node_grammar_symbol(TSNode self_);
/// <summary>Get the node's start byte.</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_ts_node_start_byte", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern uint ts_node_start_byte(TSNode self_);
/// <summary>Get the node's start position in terms of rows and columns.</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_ts_node_start_point", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern TSPoint ts_node_start_point(TSNode self_);
/// <summary>Get the node's end byte.</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_ts_node_end_byte", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern uint ts_node_end_byte(TSNode self_);
/// <summary>Get the node's end position in terms of rows and columns.</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_ts_node_end_point", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern TSPoint ts_node_end_point(TSNode self_);
/// <summary>Get an S-expression representing the node as a string. This string is allocated with `malloc` and the caller is responsible for freeing it using `free`.</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_ts_node_string", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern byte* ts_node_string(TSNode self_);
/// <summary>Check if the node is null. Functions like [`ts_node_child`] and [`ts_node_next_sibling`] will return a null node to indicate that no such node was found.</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_ts_node_is_null", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[return: MarshalAs(UnmanagedType.U1)]
public static extern bool ts_node_is_null(TSNode self_);
/// <summary>Check if the node is *named*. Named nodes correspond to named rules in the grammar, whereas *anonymous* nodes correspond to string literals in the grammar.</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_ts_node_is_named", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[return: MarshalAs(UnmanagedType.U1)]
public static extern bool ts_node_is_named(TSNode self_);
/// <summary>Check if the node is *missing*. Missing nodes are inserted by the parser in order to recover from certain kinds of syntax errors.</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_ts_node_is_missing", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[return: MarshalAs(UnmanagedType.U1)]
public static extern bool ts_node_is_missing(TSNode self_);
/// <summary>Check if the node is *extra*. Extra nodes represent things like comments, which are not required the grammar, but can appear anywhere.</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_ts_node_is_extra", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[return: MarshalAs(UnmanagedType.U1)]
public static extern bool ts_node_is_extra(TSNode self_);
/// <summary>Check if a syntax node has been edited.</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_ts_node_has_changes", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[return: MarshalAs(UnmanagedType.U1)]
public static extern bool ts_node_has_changes(TSNode self_);
/// <summary>Check if the node is a syntax error or contains any syntax errors.</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_ts_node_has_error", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[return: MarshalAs(UnmanagedType.U1)]
public static extern bool ts_node_has_error(TSNode self_);
/// <summary>Check if the node is a syntax error.</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_ts_node_is_error", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[return: MarshalAs(UnmanagedType.U1)]
public static extern bool ts_node_is_error(TSNode self_);
/// <summary>Get this node's parse state.</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_ts_node_parse_state", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern ushort ts_node_parse_state(TSNode self_);
/// <summary>Get the parse state after this node.</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_ts_node_next_parse_state", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern ushort ts_node_next_parse_state(TSNode self_);
/// <summary>Get the node's immediate parent.</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_ts_node_parent", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern TSNode ts_node_parent(TSNode self_);
/// <summary>Get the node's child at the given index, where zero represents the first child.</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_ts_node_child", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern TSNode ts_node_child(TSNode self_, uint child_index);
/// <summary>Get the field name for node's child at the given index, where zero represents the first child. Returns NULL, if no field is found.</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_ts_node_field_name_for_child", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern byte* ts_node_field_name_for_child(TSNode self_, uint child_index);
/// <summary>Get the node's number of children.</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_ts_node_child_count", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern uint ts_node_child_count(TSNode self_);
/// <summary>Get the node's *named* child at the given index. See also [`ts_node_is_named`].</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_ts_node_named_child", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern TSNode ts_node_named_child(TSNode self_, uint child_index);
/// <summary>Get the node's number of *named* children. See also [`ts_node_is_named`].</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_ts_node_named_child_count", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern uint ts_node_named_child_count(TSNode self_);
/// <summary>Get the node's child with the given field name.</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_ts_node_child_by_field_name", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern TSNode ts_node_child_by_field_name(TSNode self_, byte* name, uint name_length);
/// <summary>Get the node's child with the given numerical field id. You can convert a field name to an id using the [`ts_language_field_id_for_name`] function.</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_ts_node_child_by_field_id", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern TSNode ts_node_child_by_field_id(TSNode self_, ushort field_id);
/// <summary>Get the node's next / previous sibling.</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_ts_node_next_sibling", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern TSNode ts_node_next_sibling(TSNode self_);
[DllImport(__DllName, EntryPoint = "csbindgen_ts_node_prev_sibling", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern TSNode ts_node_prev_sibling(TSNode self_);
/// <summary>Get the node's next / previous *named* sibling.</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_ts_node_next_named_sibling", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern TSNode ts_node_next_named_sibling(TSNode self_);
[DllImport(__DllName, EntryPoint = "csbindgen_ts_node_prev_named_sibling", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern TSNode ts_node_prev_named_sibling(TSNode self_);
/// <summary>Get the node's first child that extends beyond the given byte offset.</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_ts_node_first_child_for_byte", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern TSNode ts_node_first_child_for_byte(TSNode self_, uint @byte);
/// <summary>Get the node's first named child that extends beyond the given byte offset.</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_ts_node_first_named_child_for_byte", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern TSNode ts_node_first_named_child_for_byte(TSNode self_, uint @byte);
/// <summary>Get the node's number of descendants, including one for the node itself.</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_ts_node_descendant_count", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern uint ts_node_descendant_count(TSNode self_);
/// <summary>Get the smallest node within this node that spans the given range of bytes or (row, column) positions.</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_ts_node_descendant_for_byte_range", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern TSNode ts_node_descendant_for_byte_range(TSNode self_, uint start, uint end);
[DllImport(__DllName, EntryPoint = "csbindgen_ts_node_descendant_for_point_range", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern TSNode ts_node_descendant_for_point_range(TSNode self_, TSPoint start, TSPoint end);
/// <summary>Get the smallest named node within this node that spans the given range of bytes or (row, column) positions.</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_ts_node_named_descendant_for_byte_range", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern TSNode ts_node_named_descendant_for_byte_range(TSNode self_, uint start, uint end);
[DllImport(__DllName, EntryPoint = "csbindgen_ts_node_named_descendant_for_point_range", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern TSNode ts_node_named_descendant_for_point_range(TSNode self_, TSPoint start, TSPoint end);
/// <summary>Edit the node to keep it in-sync with source code that has been edited. This function is only rarely needed. When you edit a syntax tree with the [`ts_tree_edit`] function, all of the nodes that you retrieve from the tree afterward will already reflect the edit. You only need to use [`ts_node_edit`] when you have a [`TSNode`] instance that you want to keep and continue to use after an edit.</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_ts_node_edit", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern void ts_node_edit(TSNode* self_, TSInputEdit* edit);
/// <summary>Check if two nodes are identical.</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_ts_node_eq", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[return: MarshalAs(UnmanagedType.U1)]
public static extern bool ts_node_eq(TSNode self_, TSNode other);
/// <summary>Create a new tree cursor starting from the given node. A tree cursor allows you to walk a syntax tree more efficiently than is possible using the [`TSNode`] functions. It is a mutable object that is always on a certain syntax node, and can be moved imperatively to different nodes.</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_ts_tree_cursor_new", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern TSTreeCursor ts_tree_cursor_new(TSNode node);
/// <summary>Delete a tree cursor, freeing all of the memory that it used.</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_ts_tree_cursor_delete", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern void ts_tree_cursor_delete(TSTreeCursor* self_);
/// <summary>Re-initialize a tree cursor to start at a different node.</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_ts_tree_cursor_reset", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern void ts_tree_cursor_reset(TSTreeCursor* self_, TSNode node);
/// <summary>Re-initialize a tree cursor to the same position as another cursor. Unlike [`ts_tree_cursor_reset`], this will not lose parent information and allows reusing already created cursors.</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_ts_tree_cursor_reset_to", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern void ts_tree_cursor_reset_to(TSTreeCursor* dst, TSTreeCursor* src);
/// <summary>Get the tree cursor's current node.</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_ts_tree_cursor_current_node", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern TSNode ts_tree_cursor_current_node(TSTreeCursor* self_);
/// <summary>Get the field name of the tree cursor's current node. This returns `NULL` if the current node doesn't have a field. See also [`ts_node_child_by_field_name`].</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_ts_tree_cursor_current_field_name", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern byte* ts_tree_cursor_current_field_name(TSTreeCursor* self_);
/// <summary>Get the field id of the tree cursor's current node. This returns zero if the current node doesn't have a field. See also [`ts_node_child_by_field_id`], [`ts_language_field_id_for_name`].</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_ts_tree_cursor_current_field_id", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern ushort ts_tree_cursor_current_field_id(TSTreeCursor* self_);
/// <summary>Move the cursor to the parent of its current node. This returns `true` if the cursor successfully moved, and returns `false` if there was no parent node (the cursor was already on the root node).</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_ts_tree_cursor_goto_parent", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[return: MarshalAs(UnmanagedType.U1)]
public static extern bool ts_tree_cursor_goto_parent(TSTreeCursor* self_);
/// <summary>Move the cursor to the next sibling of its current node. This returns `true` if the cursor successfully moved, and returns `false` if there was no next sibling node.</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_ts_tree_cursor_goto_next_sibling", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[return: MarshalAs(UnmanagedType.U1)]
public static extern bool ts_tree_cursor_goto_next_sibling(TSTreeCursor* self_);
/// <summary>Move the cursor to the previous sibling of its current node. This returns `true` if the cursor successfully moved, and returns `false` if there was no previous sibling node. Note, that this function may be slower than [`ts_tree_cursor_goto_next_sibling`] due to how node positions are stored. In the worst case, this will need to iterate through all the children upto the previous sibling node to recalculate its position.</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_ts_tree_cursor_goto_previous_sibling", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[return: MarshalAs(UnmanagedType.U1)]
public static extern bool ts_tree_cursor_goto_previous_sibling(TSTreeCursor* self_);
/// <summary>Move the cursor to the first child of its current node. This returns `true` if the cursor successfully moved, and returns `false` if there were no children.</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_ts_tree_cursor_goto_first_child", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[return: MarshalAs(UnmanagedType.U1)]
public static extern bool ts_tree_cursor_goto_first_child(TSTreeCursor* self_);
/// <summary>Move the cursor to the last child of its current node. This returns `true` if the cursor successfully moved, and returns `false` if there were no children. Note that this function may be slower than [`ts_tree_cursor_goto_first_child`] because it needs to iterate through all the children to compute the child's position.</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_ts_tree_cursor_goto_last_child", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[return: MarshalAs(UnmanagedType.U1)]
public static extern bool ts_tree_cursor_goto_last_child(TSTreeCursor* self_);
/// <summary>Move the cursor to the node that is the nth descendant of the original node that the cursor was constructed with, where zero represents the original node itself.</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_ts_tree_cursor_goto_descendant", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern void ts_tree_cursor_goto_descendant(TSTreeCursor* self_, uint goal_descendant_index);
/// <summary>Get the index of the cursor's current node out of all of the descendants of the original node that the cursor was constructed with.</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_ts_tree_cursor_current_descendant_index", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern uint ts_tree_cursor_current_descendant_index(TSTreeCursor* self_);
/// <summary>Get the depth of the cursor's current node relative to the original node that the cursor was constructed with.</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_ts_tree_cursor_current_depth", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern uint ts_tree_cursor_current_depth(TSTreeCursor* self_);
/// <summary>Move the cursor to the first child of its current node that extends beyond the given byte offset or point. This returns the index of the child node if one was found, and returns -1 if no such child was found.</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_ts_tree_cursor_goto_first_child_for_byte", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern long ts_tree_cursor_goto_first_child_for_byte(TSTreeCursor* self_, uint goal_byte);
[DllImport(__DllName, EntryPoint = "csbindgen_ts_tree_cursor_goto_first_child_for_point", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern long ts_tree_cursor_goto_first_child_for_point(TSTreeCursor* self_, TSPoint goal_point);
[DllImport(__DllName, EntryPoint = "csbindgen_ts_tree_cursor_copy", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern TSTreeCursor ts_tree_cursor_copy(TSTreeCursor* cursor);
/// <summary>Create a new query from a string containing one or more S-expression patterns. The query is associated with a particular language, and can only be run on syntax nodes parsed with that language. If all of the given patterns are valid, this returns a [`TSQuery`]. If a pattern is invalid, this returns `NULL`, and provides two pieces of information about the problem: 1. The byte offset of the error is written to the `error_offset` parameter. 2. The type of error is written to the `error_type` parameter.</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_ts_query_new", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern TSQuery* ts_query_new(TSLanguage* language, byte* source, uint source_len, uint* error_offset, int* error_type);
/// <summary>Delete a query, freeing all of the memory that it used.</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_ts_query_delete", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern void ts_query_delete(TSQuery* self_);
/// <summary>Get the number of patterns, captures, or string literals in the query.</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_ts_query_pattern_count", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern uint ts_query_pattern_count(TSQuery* self_);
[DllImport(__DllName, EntryPoint = "csbindgen_ts_query_capture_count", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern uint ts_query_capture_count(TSQuery* self_);
[DllImport(__DllName, EntryPoint = "csbindgen_ts_query_string_count", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern uint ts_query_string_count(TSQuery* self_);
/// <summary>Get the byte offset where the given pattern starts in the query's source. This can be useful when combining queries by concatenating their source code strings.</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_ts_query_start_byte_for_pattern", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern uint ts_query_start_byte_for_pattern(TSQuery* self_, uint pattern_index);
/// <summary>Get all of the predicates for the given pattern in the query. The predicates are represented as a single array of steps. There are three types of steps in this array, which correspond to the three legal values for the `type` field: - `TSQueryPredicateStepTypeCapture` - Steps with this type represent names of captures. Their `value_id` can be used with the [`ts_query_capture_name_for_id`] function to obtain the name of the capture. - `TSQueryPredicateStepTypeString` - Steps with this type represent literal strings. Their `value_id` can be used with the [`ts_query_string_value_for_id`] function to obtain their string value. - `TSQueryPredicateStepTypeDone` - Steps with this type are *sentinels* that represent the end of an individual predicate. If a pattern has two predicates, then there will be two steps with this `type` in the array.</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_ts_query_predicates_for_pattern", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern TSQueryPredicateStep* ts_query_predicates_for_pattern(TSQuery* self_, uint pattern_index, uint* step_count);
[DllImport(__DllName, EntryPoint = "csbindgen_ts_query_is_pattern_rooted", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[return: MarshalAs(UnmanagedType.U1)]
public static extern bool ts_query_is_pattern_rooted(TSQuery* self_, uint pattern_index);
[DllImport(__DllName, EntryPoint = "csbindgen_ts_query_is_pattern_non_local", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[return: MarshalAs(UnmanagedType.U1)]
public static extern bool ts_query_is_pattern_non_local(TSQuery* self_, uint pattern_index);
[DllImport(__DllName, EntryPoint = "csbindgen_ts_query_is_pattern_guaranteed_at_step", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[return: MarshalAs(UnmanagedType.U1)]
public static extern bool ts_query_is_pattern_guaranteed_at_step(TSQuery* self_, uint byte_offset);
/// <summary>Get the name and length of one of the query's captures, or one of the query's string literals. Each capture and string is associated with a numeric id based on the order that it appeared in the query's source.</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_ts_query_capture_name_for_id", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern byte* ts_query_capture_name_for_id(TSQuery* self_, uint index, uint* length);
/// <summary>Get the quantifier of the query's captures. Each capture is * associated with a numeric id based on the order that it appeared in the query's source.</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_ts_query_capture_quantifier_for_id", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern int ts_query_capture_quantifier_for_id(TSQuery* self_, uint pattern_index, uint capture_index);
[DllImport(__DllName, EntryPoint = "csbindgen_ts_query_string_value_for_id", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern byte* ts_query_string_value_for_id(TSQuery* self_, uint index, uint* length);
/// <summary>Disable a certain capture within a query. This prevents the capture from being returned in matches, and also avoids any resource usage associated with recording the capture. Currently, there is no way to undo this.</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_ts_query_disable_capture", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern void ts_query_disable_capture(TSQuery* self_, byte* name, uint length);
/// <summary>Disable a certain pattern within a query. This prevents the pattern from matching and removes most of the overhead associated with the pattern. Currently, there is no way to undo this.</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_ts_query_disable_pattern", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern void ts_query_disable_pattern(TSQuery* self_, uint pattern_index);
/// <summary>Create a new cursor for executing a given query. The cursor stores the state that is needed to iteratively search for matches. To use the query cursor, first call [`ts_query_cursor_exec`] to start running a given query on a given syntax node. Then, there are two options for consuming the results of the query: 1. Repeatedly call [`ts_query_cursor_next_match`] to iterate over all of the *matches* in the order that they were found. Each match contains the index of the pattern that matched, and an array of captures. Because multiple patterns can match the same set of nodes, one match may contain captures that appear *before* some of the captures from a previous match. 2. Repeatedly call [`ts_query_cursor_next_capture`] to iterate over all of the individual *captures* in the order that they appear. This is useful if don't care about which pattern matched, and just want a single ordered sequence of captures. If you don't care about consuming all of the results, you can stop calling [`ts_query_cursor_next_match`] or [`ts_query_cursor_next_capture`] at any point. You can then start executing another query on another node by calling [`ts_query_cursor_exec`] again.</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_ts_query_cursor_new", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern TSQueryCursor* ts_query_cursor_new();
/// <summary>Delete a query cursor, freeing all of the memory that it used.</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_ts_query_cursor_delete", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern void ts_query_cursor_delete(TSQueryCursor* self_);
/// <summary>Start running a given query on a given node.</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_ts_query_cursor_exec", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern void ts_query_cursor_exec(TSQueryCursor* self_, TSQuery* query, TSNode node);
/// <summary>Manage the maximum number of in-progress matches allowed by this query cursor. Query cursors have an optional maximum capacity for storing lists of in-progress captures. If this capacity is exceeded, then the earliest-starting match will silently be dropped to make room for further matches. This maximum capacity is optional — by default, query cursors allow any number of pending matches, dynamically allocating new space for them as needed as the query is executed.</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_ts_query_cursor_did_exceed_match_limit", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[return: MarshalAs(UnmanagedType.U1)]
public static extern bool ts_query_cursor_did_exceed_match_limit(TSQueryCursor* self_);
[DllImport(__DllName, EntryPoint = "csbindgen_ts_query_cursor_match_limit", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern uint ts_query_cursor_match_limit(TSQueryCursor* self_);
[DllImport(__DllName, EntryPoint = "csbindgen_ts_query_cursor_set_match_limit", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern void ts_query_cursor_set_match_limit(TSQueryCursor* self_, uint limit);
/// <summary>Set the range of bytes or (row, column) positions in which the query will be executed.</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_ts_query_cursor_set_byte_range", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern void ts_query_cursor_set_byte_range(TSQueryCursor* self_, uint start_byte, uint end_byte);
[DllImport(__DllName, EntryPoint = "csbindgen_ts_query_cursor_set_point_range", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern void ts_query_cursor_set_point_range(TSQueryCursor* self_, TSPoint start_point, TSPoint end_point);
/// <summary>Advance to the next match of the currently running query. If there is a match, write it to `*match` and return `true`. Otherwise, return `false`.</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_ts_query_cursor_next_match", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[return: MarshalAs(UnmanagedType.U1)]
public static extern bool ts_query_cursor_next_match(TSQueryCursor* self_, TSQueryMatch* match_);
[DllImport(__DllName, EntryPoint = "csbindgen_ts_query_cursor_remove_match", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern void ts_query_cursor_remove_match(TSQueryCursor* self_, uint match_id);
/// <summary>Advance to the next capture of the currently running query. If there is a capture, write its match to `*match` and its index within the matche's capture list to `*capture_index`. Otherwise, return `false`.</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_ts_query_cursor_next_capture", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[return: MarshalAs(UnmanagedType.U1)]
public static extern bool ts_query_cursor_next_capture(TSQueryCursor* self_, TSQueryMatch* match_, uint* capture_index);
/// <summary>Set the maximum start depth for a query cursor. This prevents cursors from exploring children nodes at a certain depth. Note if a pattern includes many children, then they will still be checked. The zero max start depth value can be used as a special behavior and it helps to destructure a subtree by staying on a node and using captures for interested parts. Note that the zero max start depth only limit a search depth for a pattern's root node but other nodes that are parts of the pattern may be searched at any depth what defined by the pattern structure. Set to `UINT32_MAX` to remove the maximum start depth.</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_ts_query_cursor_set_max_start_depth", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern void ts_query_cursor_set_max_start_depth(TSQueryCursor* self_, uint max_start_depth);
/// <summary>Get the number of distinct node types in the language.</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_ts_language_symbol_count", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern uint ts_language_symbol_count(TSLanguage* self_);
/// <summary>Get the number of valid states in this language.</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_ts_language_state_count", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern uint ts_language_state_count(TSLanguage* self_);
/// <summary>Get a node type string for the given numerical id.</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_ts_language_symbol_name", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern byte* ts_language_symbol_name(TSLanguage* self_, ushort symbol);
/// <summary>Get the numerical id for the given node type string.</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_ts_language_symbol_for_name", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern ushort ts_language_symbol_for_name(TSLanguage* self_, byte* @string, uint length, [MarshalAs(UnmanagedType.U1)] bool is_named);
/// <summary>Get the number of distinct field names in the language.</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_ts_language_field_count", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern uint ts_language_field_count(TSLanguage* self_);
/// <summary>Get the field name string for the given numerical id.</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_ts_language_field_name_for_id", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern byte* ts_language_field_name_for_id(TSLanguage* self_, ushort id);
/// <summary>Get the numerical id for the given field name string.</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_ts_language_field_id_for_name", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern ushort ts_language_field_id_for_name(TSLanguage* self_, byte* name, uint name_length);
/// <summary>Check whether the given node type id belongs to named nodes, anonymous nodes, or a hidden nodes. See also [`ts_node_is_named`]. Hidden nodes are never returned from the API.</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_ts_language_symbol_type", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern int ts_language_symbol_type(TSLanguage* self_, ushort symbol);
/// <summary>Get the ABI version number for this language. This version number is used to ensure that languages were generated by a compatible version of Tree-sitter. See also [`ts_parser_set_language`].</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_ts_language_version", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern uint ts_language_version(TSLanguage* self_);
/// <summary>Get the next parse state. Combine this with lookahead iterators to generate completion suggestions or valid symbols in error nodes. Use [`ts_node_grammar_symbol`] for valid symbols.</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_ts_language_next_state", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern ushort ts_language_next_state(TSLanguage* self_, ushort state, ushort symbol);
/// <summary>Create a new lookahead iterator for the given language and parse state. This returns `NULL` if state is invalid for the language. Repeatedly using [`ts_lookahead_iterator_next`] and [`ts_lookahead_iterator_current_symbol`] will generate valid symbols in the given parse state. Newly created lookahead iterators will contain the `ERROR` symbol. Lookahead iterators can be useful to generate suggestions and improve syntax error diagnostics. To get symbols valid in an ERROR node, use the lookahead iterator on its first leaf node state. For `MISSING` nodes, a lookahead iterator created on the previous non-extra leaf node may be appropriate.</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_ts_lookahead_iterator_new", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern TSLookaheadIterator* ts_lookahead_iterator_new(TSLanguage* self_, ushort state);
/// <summary>Delete a lookahead iterator freeing all the memory used.</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_ts_lookahead_iterator_delete", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern void ts_lookahead_iterator_delete(TSLookaheadIterator* self_);
/// <summary>Reset the lookahead iterator to another state. This returns `true` if the iterator was reset to the given state and `false` otherwise.</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_ts_lookahead_iterator_reset_state", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[return: MarshalAs(UnmanagedType.U1)]
public static extern bool ts_lookahead_iterator_reset_state(TSLookaheadIterator* self_, ushort state);
/// <summary>Reset the lookahead iterator. This returns `true` if the language was set successfully and `false` otherwise.</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_ts_lookahead_iterator_reset", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[return: MarshalAs(UnmanagedType.U1)]
public static extern bool ts_lookahead_iterator_reset(TSLookaheadIterator* self_, TSLanguage* language, ushort state);
/// <summary>Get the current language of the lookahead iterator.</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_ts_lookahead_iterator_language", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern TSLanguage* ts_lookahead_iterator_language(TSLookaheadIterator* self_);
/// <summary>Advance the lookahead iterator to the next symbol. This returns `true` if there is a new symbol and `false` otherwise.</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_ts_lookahead_iterator_next", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[return: MarshalAs(UnmanagedType.U1)]
public static extern bool ts_lookahead_iterator_next(TSLookaheadIterator* self_);
/// <summary>Get the current symbol of the lookahead iterator;</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_ts_lookahead_iterator_current_symbol", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern ushort ts_lookahead_iterator_current_symbol(TSLookaheadIterator* self_);
/// <summary>Get the current symbol type of the lookahead iterator as a null terminated string.</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_ts_lookahead_iterator_current_symbol_name", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern byte* ts_lookahead_iterator_current_symbol_name(TSLookaheadIterator* self_);
/// <summary>Set the allocation functions used by the library. By default, Tree-sitter uses the standard libc allocation functions, but aborts the process when an allocation fails. This function lets you supply alternative allocation functions at runtime. If you pass `NULL` for any parameter, Tree-sitter will switch back to its default implementation of that function. If you call this function after the library has already been used, then you must ensure that either: 1. All the existing objects have been freed. 2. The new allocator shares its state with the old one, so it is capable of freeing memory that was allocated by the old allocator.</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_ts_set_allocator", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern void ts_set_allocator(delegate* unmanaged[Cdecl]<nuint, void*> new_malloc, delegate* unmanaged[Cdecl]<nuint, nuint, void*> new_calloc, delegate* unmanaged[Cdecl]<void*, nuint, void*> new_realloc, delegate* unmanaged[Cdecl]<void*, void> new_free);
}
[StructLayout(LayoutKind.Sequential)]
internal unsafe partial struct _div_t
{
public int quot;
public int rem;
}
[StructLayout(LayoutKind.Sequential)]
internal unsafe partial struct _ldiv_t
{
public CLong quot;
public CLong rem;
}
[StructLayout(LayoutKind.Sequential)]
internal unsafe partial struct _lldiv_t
{
public long quot;
public long rem;
}
[StructLayout(LayoutKind.Sequential)]
internal unsafe partial struct TSLanguage
{
public fixed byte _unused[1];
}
[StructLayout(LayoutKind.Sequential)]
internal unsafe partial struct TSParser
{
public fixed byte _unused[1];
}
[StructLayout(LayoutKind.Sequential)]
internal unsafe partial struct TSTree
{
public fixed byte _unused[1];
}
[StructLayout(LayoutKind.Sequential)]
internal unsafe partial struct TSQuery
{
public fixed byte _unused[1];
}
[StructLayout(LayoutKind.Sequential)]
internal unsafe partial struct TSQueryCursor
{
public fixed byte _unused[1];
}
[StructLayout(LayoutKind.Sequential)]
internal unsafe partial struct TSLookaheadIterator
{
public fixed byte _unused[1];
}
[StructLayout(LayoutKind.Sequential)]
internal unsafe partial struct TSPoint
{
public uint row;
public uint column;
}
[StructLayout(LayoutKind.Sequential)]
internal unsafe partial struct TSRange
{
public TSPoint start_point;
public TSPoint end_point;
public uint start_byte;
public uint end_byte;
}
[StructLayout(LayoutKind.Sequential)]
internal unsafe partial struct TSInput
{
public void* payload;
public delegate* unmanaged[Cdecl]<void*, uint, TSPoint, uint*, byte*> read;
public int encoding;
}
[StructLayout(LayoutKind.Sequential)]
internal unsafe partial struct TSLogger
{
public void* payload;
public delegate* unmanaged[Cdecl]<void*, int, byte*, void> log;
}
[StructLayout(LayoutKind.Sequential)]
internal unsafe partial struct TSInputEdit
{
public uint start_byte;
public uint old_end_byte;
public uint new_end_byte;
public TSPoint start_point;
public TSPoint old_end_point;
public TSPoint new_end_point;
}
[StructLayout(LayoutKind.Sequential)]
internal unsafe partial struct TSNode
{
public fixed uint context[4];
public void* id;
public TSTree* tree;
}
[StructLayout(LayoutKind.Sequential)]
internal unsafe partial struct TSTreeCursor
{
public void* tree;
public void* id;
public fixed uint context[2];
}
[StructLayout(LayoutKind.Sequential)]
internal unsafe partial struct TSQueryCapture
{
public TSNode node;
public uint index;
}
[StructLayout(LayoutKind.Sequential)]
internal unsafe partial struct TSQueryMatch
{
public uint id;
public ushort pattern_index;
public ushort capture_count;
public TSQueryCapture* captures;
}
[StructLayout(LayoutKind.Sequential)]
internal unsafe partial struct TSQueryPredicateStep
{
public int type_;
public uint value_id;
}
}

View File

@ -1,2 +1,14 @@
pub mod ffi;
pub mod tree_sitter_api;
pub mod languages {
use tree_sitter::Parser;
use crate::tree_sitter_api::TSParser;
#[no_mangle]
pub unsafe extern "C" fn set_lang_rust(self_: *mut TSParser) -> *const TSLanguage {
let p: tree_sitter::ffi::TSParser =
tree_sitter_rust::language().0
}
}