Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
Summpot committed Oct 29, 2023
1 parent 9432d31 commit c099437
Show file tree
Hide file tree
Showing 13 changed files with 220 additions and 227 deletions.
132 changes: 0 additions & 132 deletions api.md

This file was deleted.

4 changes: 3 additions & 1 deletion publish.ps1
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
Param(
[switch]$Push
)
$tag = git describe --tags --abbrev=0
$tag = git tag | Select-Object -Last 1
Write-Host "Tag: $tag"
$major, $minor, $patch = $tag -split '\.'
$patch = [int]$patch + 1
$newTag = "$major.$minor.$patch"
Write-Host "New tag: $newTag"
git tag $newTag
if ($Push) {
git push --tags
Expand Down
4 changes: 2 additions & 2 deletions src/TreeSitterSharp.C/CLanguageProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
using TreeSitterSharp.Native;

namespace TreeSitterSharp.C;
public class CLanguageProvider : ILanguageProvider
internal class CLanguageProvider : ILanguageProvider
{
[DllImport("libtree-sitter-c", EntryPoint = "tree_sitter_c", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
private static extern unsafe TsLanguage* tree_sitter_c();

public static unsafe Language GetLanguage()
{
return Language.FromUnmanaged(tree_sitter_c());
return new Language(tree_sitter_c());
}

}
13 changes: 13 additions & 0 deletions src/TreeSitterSharp.C/CParser.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TreeSitterSharp.C;
public class CParser : Parser
{
public CParser() : base(CLanguageProvider.GetLanguage())
{
}
}
4 changes: 2 additions & 2 deletions src/TreeSitterSharp.Json/JsonLanguageProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@

namespace TreeSitterSharp.Json
{
public unsafe class JsonLanguageProvider : ILanguageProvider
internal unsafe class JsonLanguageProvider : ILanguageProvider
{
[DllImport("libtree-sitter-json", EntryPoint = "tree_sitter_json", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
private static extern unsafe TsLanguage* tree_sitter_json();

public static Language GetLanguage() => Language.FromUnmanaged(tree_sitter_json());
public static Language GetLanguage() => new(tree_sitter_json());
}
}
14 changes: 14 additions & 0 deletions src/TreeSitterSharp.Json/JsonParser.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TreeSitterSharp.Json;
public class JsonParser : Parser
{
public JsonParser() : base(JsonLanguageProvider.GetLanguage())
{
}
}
8 changes: 4 additions & 4 deletions src/TreeSitterSharp/Language.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
namespace TreeSitterSharp;
public unsafe class Language
{
private TsLanguage* _internalLanguage;
private TsLanguage* _language;

public static Language FromUnmanaged(TsLanguage* language)
public Language(TsLanguage* language)
{
return new Language() { _internalLanguage = language };
_language = language;
}

public TsLanguage* ToUnmanaged()
{
return _internalLanguage;
return _language;
}
}
43 changes: 20 additions & 23 deletions src/TreeSitterSharp/Native/Ts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public static extern byte parser_set_included_ranges(TsParser* self,

[DllImport("libtree-sitter", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "ts_parser_set_timeout_micros", ExactSpelling = true)]
public static extern void parser_set_timeout_micros(TsParser* self,
public static extern void parser_set_timeout_micros(TsParser* self,
[NativeTypeName("uint64_t")] ulong timeout_micros);

[DllImport("libtree-sitter", CallingConvention = CallingConvention.Cdecl, EntryPoint = "ts_parser_timeout_micros",
Expand Down Expand Up @@ -300,96 +300,93 @@ public static extern TsNode node_named_descendant_for_byte_range(TsNode self,
[DllImport("libtree-sitter", CallingConvention = CallingConvention.Cdecl, EntryPoint = "ts_node_eq",
ExactSpelling = true)]
[return: NativeTypeName("bool")]
public static extern byte node_eq(TsNode self, TsNode other);
public static extern bool node_eq(TsNode self, TsNode other);

[DllImport("libtree-sitter", CallingConvention = CallingConvention.Cdecl, EntryPoint = "ts_tree_cursor_new",
ExactSpelling = true)]
public static extern TsTreeCursor tree_cursor_new(TsNode node);

[DllImport("libtree-sitter", CallingConvention = CallingConvention.Cdecl, EntryPoint = "ts_tree_cursor_delete",
ExactSpelling = true)]
public static extern void tree_cursor_delete(TsTreeCursor* self);
public static extern void tree_cursor_delete(in TsTreeCursor self);

[DllImport("libtree-sitter", CallingConvention = CallingConvention.Cdecl, EntryPoint = "ts_tree_cursor_reset",
ExactSpelling = true)]
public static extern void tree_cursor_reset(TsTreeCursor* self, TsNode node);
public static extern void tree_cursor_reset(in TsTreeCursor self, TsNode node);

[DllImport("libtree-sitter", CallingConvention = CallingConvention.Cdecl, EntryPoint = "ts_tree_cursor_reset_to",
ExactSpelling = true)]
public static extern void tree_cursor_reset_to(TsTreeCursor* dst,
[NativeTypeName("const TsTreeCursor *")] TsTreeCursor* src);
public static extern void tree_cursor_reset_to(in TsTreeCursor dst,
in TsTreeCursor src);

[DllImport("libtree-sitter", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "ts_tree_cursor_current_node", ExactSpelling = true)]
public static extern TsNode tree_cursor_current_node([NativeTypeName("const TsTreeCursor *")] TsTreeCursor* self);
public static extern TsNode tree_cursor_current_node(in TsTreeCursor self);

[DllImport("libtree-sitter", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "ts_tree_cursor_current_field_name", ExactSpelling = true)]
[return: NativeTypeName("const char *")]
public static extern string tree_cursor_current_field_name(
[NativeTypeName("const TsTreeCursor *")] TsTreeCursor* self);
in TsTreeCursor self);

[DllImport("libtree-sitter", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "ts_tree_cursor_current_field_id", ExactSpelling = true)]
[return: NativeTypeName("TSFieldId")]
public static extern ushort tree_cursor_current_field_id(
[NativeTypeName("const TsTreeCursor *")] TsTreeCursor* self);
public static extern ushort tree_cursor_current_field_id(in TsTreeCursor self);

[DllImport("libtree-sitter", CallingConvention = CallingConvention.Cdecl, EntryPoint = "ts_tree_cursor_goto_parent",
ExactSpelling = true)]
[return: NativeTypeName("bool")]
public static extern byte tree_cursor_goto_parent(TsTreeCursor* self);
public static extern bool tree_cursor_goto_parent(in TsTreeCursor self);

[DllImport("libtree-sitter", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "ts_tree_cursor_goto_next_sibling", ExactSpelling = true)]
[return: NativeTypeName("bool")]
public static extern byte tree_cursor_goto_next_sibling(TsTreeCursor* self);
public static extern bool tree_cursor_goto_next_sibling(in TsTreeCursor self);

[DllImport("libtree-sitter", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "ts_tree_cursor_goto_previous_sibling", ExactSpelling = true)]
[return: NativeTypeName("bool")]
public static extern byte tree_cursor_goto_previous_sibling(TsTreeCursor* self);
public static extern bool tree_cursor_goto_previous_sibling(in TsTreeCursor self);

[DllImport("libtree-sitter", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "ts_tree_cursor_goto_first_child", ExactSpelling = true)]
[return: NativeTypeName("bool")]
public static extern byte tree_cursor_goto_first_child(TsTreeCursor* self);
public static extern bool tree_cursor_goto_first_child(in TsTreeCursor self);

[DllImport("libtree-sitter", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "ts_tree_cursor_goto_last_child", ExactSpelling = true)]
[return: NativeTypeName("bool")]
public static extern byte tree_cursor_goto_last_child(TsTreeCursor* self);
public static extern bool tree_cursor_goto_last_child(in TsTreeCursor self);

[DllImport("libtree-sitter", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "ts_tree_cursor_goto_descendant", ExactSpelling = true)]
public static extern void tree_cursor_goto_descendant(TsTreeCursor* self,
[NativeTypeName("uint32_t")] uint goal_descendant_index);
public static extern void tree_cursor_goto_descendant(in TsTreeCursor self, uint goal_descendant_index);

[DllImport("libtree-sitter", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "ts_tree_cursor_current_descendant_index", ExactSpelling = true)]
[return: NativeTypeName("uint32_t")]
public static extern uint tree_cursor_current_descendant_index(
[NativeTypeName("const TsTreeCursor *")] TsTreeCursor* self);
in TsTreeCursor self);

[DllImport("libtree-sitter", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "ts_tree_cursor_current_depth", ExactSpelling = true)]
[return: NativeTypeName("uint32_t")]
public static extern uint tree_cursor_current_depth([NativeTypeName("const TsTreeCursor *")] TsTreeCursor* self);
public static extern uint tree_cursor_current_depth(in TsTreeCursor self);

[DllImport("libtree-sitter", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "ts_tree_cursor_goto_first_child_for_byte", ExactSpelling = true)]
[return: NativeTypeName("int64_t")]
public static extern long tree_cursor_goto_first_child_for_byte(TsTreeCursor* self,
[NativeTypeName("uint32_t")] uint goal_byte);
public static extern long tree_cursor_goto_first_child_for_byte(in TsTreeCursor self, uint goal_byte);

[DllImport("libtree-sitter", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "ts_tree_cursor_goto_first_child_for_point", ExactSpelling = true)]
[return: NativeTypeName("int64_t")]
public static extern long tree_cursor_goto_first_child_for_point(TsTreeCursor* self, TsPoint goal_point);
public static extern long tree_cursor_goto_first_child_for_point(in TsTreeCursor self, TsPoint goal_point);

[DllImport("libtree-sitter", CallingConvention = CallingConvention.Cdecl, EntryPoint = "ts_tree_cursor_copy",
ExactSpelling = true)]
public static extern TsTreeCursor tree_cursor_copy([NativeTypeName("const TsTreeCursor *")] TsTreeCursor* cursor);
public static extern TsTreeCursor tree_cursor_copy(in TsTreeCursor cursor);

[DllImport("libtree-sitter", CallingConvention = CallingConvention.Cdecl, EntryPoint = "ts_query_new",
ExactSpelling = true)]
Expand Down
Loading

0 comments on commit c099437

Please sign in to comment.