changelog shortlog graph tags branches changeset files revisions annotate raw help

Mercurial > core / lisp/ffi/tree-sitter/alien.c

changeset 698: 96958d3eb5b0
parent: 08621be7e780
author: Richard Westhaver <ellis@rwest.io>
date: Fri, 04 Oct 2024 22:04:59 -0400
permissions: -rw-r--r--
description: fixes
1 //! tree-sitter/alien.c --- Tree-sitter C wrapper
2 
3 // based on https://github.com/death/cl-tree-sitter
4 
5 // it's annoying that we need this, I thought we could get away
6 // without it. Alas, SB-ALIEN is also unable to fully interoperate
7 // with the types defined in api.h, so we need to manually create
8 // pointer type definitions for them.
9 
10 // build with:
11 /*
12  cc -g -O2 -Wall -Wno-unused-value -ltree-sitter -shared lisp/ffi/tree-sitter/alien.c \
13  -o .stash/libtree-sitter-alien.so
14 */
15 
16 /// Code:
17 #include <tree_sitter/api.h>
18 TSNode *ts_tree_root_node_pointer(const TSTree *self) {
19  TSNode *node = malloc(sizeof(TSNode));
20 
21  if (node) {
22  *node = ts_tree_root_node(self);
23  }
24 
25  return node;
26 }
27 
28 TSTreeCursor *ts_tree_cursor_new_pointer(TSNode *node) {
29  TSTreeCursor *cursor = malloc(sizeof(TSTreeCursor));
30 
31  if (cursor) {
32  *cursor = ts_tree_cursor_new(*node);
33  }
34 
35  return cursor;
36 }
37 
38 TSNode *ts_tree_cursor_current_node_pointer(const TSTreeCursor *cursor) {
39  TSNode *return_node = malloc(sizeof(TSNode));
40 
41  if (return_node) {
42  *return_node = ts_tree_cursor_current_node(cursor);
43  }
44 
45  return return_node;
46 }
47 
48 int ts_node_is_named_pointer(TSNode *node) {
49  return ts_node_is_named(*node);
50 }
51 
52 TSPoint ts_node_start_point_pointer(TSNode *node) {
53  return ts_node_start_point(*node);
54 }
55 
56 
57 TSPoint ts_node_end_point_pointer(TSNode *node) {
58  return ts_node_end_point(*node);
59 }
60 
61 const char *ts_node_type_pointer(TSNode *node) {
62  return ts_node_type(*node);
63 }