changelog shortlog graph tags branches changeset files revisions annotate raw help

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

changeset 696: 38e9c3be2392
parent: dda17d7dba4f
child: 08621be7e780
author: Richard Westhaver <ellis@rwest.io>
date: Fri, 04 Oct 2024 21:11:52 -0400
permissions: -rw-r--r--
description: prep for adding zdict wrapper, change default control stack size of inferior-lisp to 8M
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 alien.c -o /usr/local/lib/libtree-sitter-alien.so
13 */
14 
15 /// Code:
16 #include <stdlib.h>
17 
18 #include "alien.h"
19 
20 TSNode *ts_tree_root_node_pointer(const TSTree *self) {
21  TSNode *node = malloc(sizeof(TSNode));
22 
23  if (node) {
24  *node = ts_tree_root_node(self);
25  }
26 
27  return node;
28 }
29 
30 TSTreeCursor *ts_tree_cursor_new_pointer(TSNode *node) {
31  TSTreeCursor *cursor = malloc(sizeof(TSTreeCursor));
32 
33  if (cursor) {
34  *cursor = ts_tree_cursor_new(*node);
35  }
36 
37  return cursor;
38 }
39 
40 TSNode *ts_tree_cursor_current_node_pointer(const TSTreeCursor *cursor) {
41  TSNode *return_node = malloc(sizeof(TSNode));
42 
43  if (return_node) {
44  *return_node = ts_tree_cursor_current_node(cursor);
45  }
46 
47  return return_node;
48 }
49 
50 int ts_node_is_named_pointer(TSNode *node) {
51  return ts_node_is_named(*node);
52 }
53 
54 TSPoint ts_node_start_point_pointer(TSNode *node) {
55  return ts_node_start_point(*node);
56 }
57 
58 
59 TSPoint ts_node_end_point_pointer(TSNode *node) {
60  return ts_node_end_point(*node);
61 }
62 
63 const char *ts_node_type_pointer(TSNode *node) {
64  return ts_node_type(*node);
65 }