fix(generate): extern allocator functions for the template don't need to be "exported"

This commit is contained in:
Amaan Qureshi 2024-03-04 22:28:02 -05:00
parent 54a31069af
commit 92675117a6
3 changed files with 5 additions and 18 deletions

View file

@ -1341,10 +1341,6 @@ impl Generator {
add_line!(self, "");
}
add_line!(self, "#ifdef TS_PUBLIC");
add_line!(self, "#undef TS_PUBLIC");
add_line!(self, "#endif");
add_line!(self, "");
add_line!(self, "#ifdef _WIN32");
add_line!(self, "#define TS_PUBLIC __declspec(dllexport)");
add_line!(self, "#else");

View file

@ -9,20 +9,14 @@ extern "C" {
#include <stdio.h>
#include <stdlib.h>
#ifdef _WIN32
#define TS_PUBLIC
#else
#define TS_PUBLIC __attribute__((visibility("default")))
#endif
TS_PUBLIC extern void *(*ts_current_malloc)(size_t);
TS_PUBLIC extern void *(*ts_current_calloc)(size_t, size_t);
TS_PUBLIC extern void *(*ts_current_realloc)(void *, size_t);
TS_PUBLIC extern void (*ts_current_free)(void *);
// Allow clients to override allocation functions
#ifdef TREE_SITTER_REUSE_ALLOCATOR
extern void *(*ts_current_malloc)(size_t);
extern void *(*ts_current_calloc)(size_t, size_t);
extern void *(*ts_current_realloc)(void *, size_t);
extern void (*ts_current_free)(void *);
#ifndef ts_malloc
#define ts_malloc ts_current_malloc
#endif

View file

@ -97,9 +97,6 @@ fn tree_sitter_dir(package_json: &str, name: &str) -> tempfile::TempDir {
format!(
r##"
#include "tree_sitter/parser.h"
#ifdef TS_PUBLIC
#undef TS_PUBLIC
#endif
#ifdef _WIN32
#define TS_PUBLIC __declspec(dllexport)
#else