Merge pull request #2515 from ahlinc/clib-fix-vis2
fix(lib): expose only symbols defined in `api.h`
This commit is contained in:
commit
5fbb2775aa
4 changed files with 17 additions and 8 deletions
7
Makefile
7
Makefile
|
|
@ -18,8 +18,8 @@ endif
|
|||
OBJ := $(SRC:.c=.o)
|
||||
|
||||
# define default flags, and override to append mandatory flags
|
||||
CFLAGS ?= -O3 -Wall -Wextra -Werror -Wshadow
|
||||
override CFLAGS += -std=gnu99 -fPIC -Ilib/src -Ilib/include
|
||||
override CFLAGS := -O3 -std=gnu99 -fPIC -fvisibility=hidden -Wall -Wextra -Werror -Wshadow $(CFLAGS)
|
||||
override CFLAGS += -Ilib/src -Ilib/include
|
||||
|
||||
# ABI versioning
|
||||
SONAME_MAJOR := 0
|
||||
|
|
@ -50,6 +50,9 @@ libtree-sitter.$(SOEXTVER): $(OBJ)
|
|||
$(CC) $(LDFLAGS) $(LINKSHARED) $^ $(LDLIBS) -o $@
|
||||
ln -sf $@ libtree-sitter.$(SOEXT)
|
||||
ln -sf $@ libtree-sitter.$(SOEXTVER_MAJOR)
|
||||
ifneq ($(STRIP),)
|
||||
$(STRIP) $@
|
||||
endif
|
||||
|
||||
install: all
|
||||
install -d '$(DESTDIR)$(LIBDIR)'
|
||||
|
|
|
|||
|
|
@ -26,7 +26,9 @@ fn main() {
|
|||
|
||||
cc::Build::new()
|
||||
.flag_if_supported("-std=c99")
|
||||
.flag_if_supported("-Wno-unused-parameter")
|
||||
.flag_if_supported("-fvisibility=hidden")
|
||||
.flag_if_supported("-Wshadow")
|
||||
.flag_if_supported("-Werror")
|
||||
.include(src_path)
|
||||
.include("include")
|
||||
.file(src_path.join("lib.c"))
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
#ifndef TREE_SITTER_API_H_
|
||||
#define TREE_SITTER_API_H_
|
||||
|
||||
#pragma GCC visibility push(default)
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
|
@ -1163,4 +1165,6 @@ void ts_set_allocator(
|
|||
}
|
||||
#endif
|
||||
|
||||
#pragma GCC visibility pop
|
||||
|
||||
#endif // TREE_SITTER_API_H_
|
||||
|
|
|
|||
|
|
@ -647,10 +647,10 @@ Subtree ts_subtree_edit(Subtree self, const TSInputEdit *input_edit, SubtreePool
|
|||
typedef struct {
|
||||
Subtree *tree;
|
||||
Edit edit;
|
||||
} StackEntry;
|
||||
} EditEntry;
|
||||
|
||||
Array(StackEntry) stack = array_new();
|
||||
array_push(&stack, ((StackEntry) {
|
||||
Array(EditEntry) stack = array_new();
|
||||
array_push(&stack, ((EditEntry) {
|
||||
.tree = &self,
|
||||
.edit = (Edit) {
|
||||
.start = {input_edit->start_byte, input_edit->start_point},
|
||||
|
|
@ -660,7 +660,7 @@ Subtree ts_subtree_edit(Subtree self, const TSInputEdit *input_edit, SubtreePool
|
|||
}));
|
||||
|
||||
while (stack.size) {
|
||||
StackEntry entry = array_pop(&stack);
|
||||
EditEntry entry = array_pop(&stack);
|
||||
Edit edit = entry.edit;
|
||||
bool is_noop = edit.old_end.bytes == edit.start.bytes && edit.new_end.bytes == edit.start.bytes;
|
||||
bool is_pure_insertion = edit.old_end.bytes == edit.start.bytes;
|
||||
|
|
@ -788,7 +788,7 @@ Subtree ts_subtree_edit(Subtree self, const TSInputEdit *input_edit, SubtreePool
|
|||
}
|
||||
|
||||
// Queue processing of this child's subtree.
|
||||
array_push(&stack, ((StackEntry) {
|
||||
array_push(&stack, ((EditEntry) {
|
||||
.tree = child,
|
||||
.edit = child_edit,
|
||||
}));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue