Skip to content

Commit

Permalink
use the php/ocaml version of alloc.h
Browse files Browse the repository at this point in the history
  • Loading branch information
yangchi committed Sep 9, 2024
1 parent 3edd529 commit 088363a
Show file tree
Hide file tree
Showing 9 changed files with 186 additions and 88 deletions.
37 changes: 25 additions & 12 deletions cpp/alloc.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@


////////////////////////////////////////////////////////////////////////////////
// Poolside modification in the fork, generated at 2024-09-06 11:07:56.198057 //
// Poolside modification in the fork, generated at 2024-09-06 11:07:56.547306 //
////////////////////////////////////////////////////////////////////////////////


Expand All @@ -16,18 +16,14 @@ extern "C" {
#include <stdio.h>
#include <stdlib.h>

#if defined(TREE_SITTER_HIDDEN_SYMBOLS) || defined(_WIN32)
#define TS_PUBLIC
#else
#define TS_PUBLIC __attribute__((visibility("default")))
#endif
// Allow clients to override allocation functions
#ifdef TREE_SITTER_REUSE_ALLOCATOR

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 *);
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 *);

// Allow clients to override allocation functions
#ifndef ts_malloc
#define ts_malloc ts_current_malloc
#endif
Expand All @@ -41,6 +37,23 @@ TS_PUBLIC extern void (*ts_current_free)(void *);
#define ts_free ts_current_free
#endif

#else

#ifndef ts_malloc
#define ts_malloc malloc
#endif
#ifndef ts_calloc
#define ts_calloc calloc
#endif
#ifndef ts_realloc
#define ts_realloc realloc
#endif
#ifndef ts_free
#define ts_free free
#endif

#endif

#ifdef __cplusplus
}
#endif
Expand All @@ -49,7 +62,7 @@ TS_PUBLIC extern void (*ts_current_free)(void *);


////////////////////////////////////////////////////////////////////////////////
// Poolside modification in the fork, generated at 2024-09-06 11:07:56.198057 //
// Poolside modification in the fork, generated at 2024-09-06 11:07:56.547306 //
////////////////////////////////////////////////////////////////////////////////


37 changes: 25 additions & 12 deletions csharp/alloc.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@


////////////////////////////////////////////////////////////////////////////////
// Poolside modification in the fork, generated at 2024-09-06 11:07:56.082258 //
// Poolside modification in the fork, generated at 2024-09-06 11:07:56.547306 //
////////////////////////////////////////////////////////////////////////////////


Expand All @@ -16,18 +16,14 @@ extern "C" {
#include <stdio.h>
#include <stdlib.h>

#if defined(TREE_SITTER_HIDDEN_SYMBOLS) || defined(_WIN32)
#define TS_PUBLIC
#else
#define TS_PUBLIC __attribute__((visibility("default")))
#endif
// Allow clients to override allocation functions
#ifdef TREE_SITTER_REUSE_ALLOCATOR

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 *);
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 *);

// Allow clients to override allocation functions
#ifndef ts_malloc
#define ts_malloc ts_current_malloc
#endif
Expand All @@ -41,6 +37,23 @@ TS_PUBLIC extern void (*ts_current_free)(void *);
#define ts_free ts_current_free
#endif

#else

#ifndef ts_malloc
#define ts_malloc malloc
#endif
#ifndef ts_calloc
#define ts_calloc calloc
#endif
#ifndef ts_realloc
#define ts_realloc realloc
#endif
#ifndef ts_free
#define ts_free free
#endif

#endif

#ifdef __cplusplus
}
#endif
Expand All @@ -49,7 +62,7 @@ TS_PUBLIC extern void (*ts_current_free)(void *);


////////////////////////////////////////////////////////////////////////////////
// Poolside modification in the fork, generated at 2024-09-06 11:07:56.082258 //
// Poolside modification in the fork, generated at 2024-09-06 11:07:56.547306 //
////////////////////////////////////////////////////////////////////////////////


11 changes: 9 additions & 2 deletions header_fix.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@
'zig'
]


file_map = {
'alloc.h': 'ocaml/alloc.h'
}

# flatten a directory
def flatten_dir(root):
print(f'Flattening {root}')
Expand Down Expand Up @@ -126,8 +131,10 @@ def op_recur(src, dst_dir, operation):


def copy_with_extra_commends(src, dst):
if os.path.basename(src) in file_map.keys():
src = file_map[os.path.basename(src)]
shutil.copy2(src, dst)
add_extra_line(dst, make_comments())
add_extra_line(os.path.join(dst, os.path.basename(src)), make_comments())

def copy_recur(src, dst_dir):
op_recur(src, dst_dir, copy_with_extra_commends)
Expand All @@ -144,4 +151,4 @@ def copy_recur(src, dst_dir):
for dir in lang_dirs:
flatten_dir(dir)
for f in ls_exts(dir, ['.h', '.c']):
fix_headers(f)
fix_headers(f)
37 changes: 25 additions & 12 deletions kotlin/alloc.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@


////////////////////////////////////////////////////////////////////////////////
// Poolside modification in the fork, generated at 2024-09-06 11:07:56.663188 //
// Poolside modification in the fork, generated at 2024-09-06 11:07:56.547306 //
////////////////////////////////////////////////////////////////////////////////


Expand All @@ -16,18 +16,14 @@ extern "C" {
#include <stdio.h>
#include <stdlib.h>

#if defined(TREE_SITTER_HIDDEN_SYMBOLS) || defined(_WIN32)
#define TS_PUBLIC
#else
#define TS_PUBLIC __attribute__((visibility("default")))
#endif
// Allow clients to override allocation functions
#ifdef TREE_SITTER_REUSE_ALLOCATOR

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 *);
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 *);

// Allow clients to override allocation functions
#ifndef ts_malloc
#define ts_malloc ts_current_malloc
#endif
Expand All @@ -41,6 +37,23 @@ TS_PUBLIC extern void (*ts_current_free)(void *);
#define ts_free ts_current_free
#endif

#else

#ifndef ts_malloc
#define ts_malloc malloc
#endif
#ifndef ts_calloc
#define ts_calloc calloc
#endif
#ifndef ts_realloc
#define ts_realloc realloc
#endif
#ifndef ts_free
#define ts_free free
#endif

#endif

#ifdef __cplusplus
}
#endif
Expand All @@ -49,7 +62,7 @@ TS_PUBLIC extern void (*ts_current_free)(void *);


////////////////////////////////////////////////////////////////////////////////
// Poolside modification in the fork, generated at 2024-09-06 11:07:56.663188 //
// Poolside modification in the fork, generated at 2024-09-06 11:07:56.547306 //
////////////////////////////////////////////////////////////////////////////////


37 changes: 25 additions & 12 deletions python/alloc.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@


////////////////////////////////////////////////////////////////////////////////
// Poolside modification in the fork, generated at 2024-09-06 11:07:56.569321 //
// Poolside modification in the fork, generated at 2024-09-06 11:07:56.547306 //
////////////////////////////////////////////////////////////////////////////////


Expand All @@ -16,18 +16,14 @@ extern "C" {
#include <stdio.h>
#include <stdlib.h>

#if defined(TREE_SITTER_HIDDEN_SYMBOLS) || defined(_WIN32)
#define TS_PUBLIC
#else
#define TS_PUBLIC __attribute__((visibility("default")))
#endif
// Allow clients to override allocation functions
#ifdef TREE_SITTER_REUSE_ALLOCATOR

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 *);
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 *);

// Allow clients to override allocation functions
#ifndef ts_malloc
#define ts_malloc ts_current_malloc
#endif
Expand All @@ -41,6 +37,23 @@ TS_PUBLIC extern void (*ts_current_free)(void *);
#define ts_free ts_current_free
#endif

#else

#ifndef ts_malloc
#define ts_malloc malloc
#endif
#ifndef ts_calloc
#define ts_calloc calloc
#endif
#ifndef ts_realloc
#define ts_realloc realloc
#endif
#ifndef ts_free
#define ts_free free
#endif

#endif

#ifdef __cplusplus
}
#endif
Expand All @@ -49,7 +62,7 @@ TS_PUBLIC extern void (*ts_current_free)(void *);


////////////////////////////////////////////////////////////////////////////////
// Poolside modification in the fork, generated at 2024-09-06 11:07:56.569321 //
// Poolside modification in the fork, generated at 2024-09-06 11:07:56.547306 //
////////////////////////////////////////////////////////////////////////////////


37 changes: 25 additions & 12 deletions ruby/alloc.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@


////////////////////////////////////////////////////////////////////////////////
// Poolside modification in the fork, generated at 2024-09-06 11:07:56.588302 //
// Poolside modification in the fork, generated at 2024-09-09 17:42:48.693736 //
////////////////////////////////////////////////////////////////////////////////


Expand All @@ -16,18 +16,14 @@ extern "C" {
#include <stdio.h>
#include <stdlib.h>

#if defined(TREE_SITTER_HIDDEN_SYMBOLS) || defined(_WIN32)
#define TS_PUBLIC
#else
#define TS_PUBLIC __attribute__((visibility("default")))
#endif
// Allow clients to override allocation functions
#ifdef TREE_SITTER_REUSE_ALLOCATOR

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 *);
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 *);

// Allow clients to override allocation functions
#ifndef ts_malloc
#define ts_malloc ts_current_malloc
#endif
Expand All @@ -41,6 +37,23 @@ TS_PUBLIC extern void (*ts_current_free)(void *);
#define ts_free ts_current_free
#endif

#else

#ifndef ts_malloc
#define ts_malloc malloc
#endif
#ifndef ts_calloc
#define ts_calloc calloc
#endif
#ifndef ts_realloc
#define ts_realloc realloc
#endif
#ifndef ts_free
#define ts_free free
#endif

#endif

#ifdef __cplusplus
}
#endif
Expand All @@ -49,7 +62,7 @@ TS_PUBLIC extern void (*ts_current_free)(void *);


////////////////////////////////////////////////////////////////////////////////
// Poolside modification in the fork, generated at 2024-09-06 11:07:56.588302 //
// Poolside modification in the fork, generated at 2024-09-09 17:42:48.693736 //
////////////////////////////////////////////////////////////////////////////////


4 changes: 2 additions & 2 deletions ruby/array.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@


////////////////////////////////////////////////////////////////////////////////
// Poolside modification in the fork, generated at 2024-09-06 11:07:56.588479 //
// Poolside modification in the fork, generated at 2024-09-09 17:42:48.694339 //
////////////////////////////////////////////////////////////////////////////////


Expand Down Expand Up @@ -298,7 +298,7 @@ static inline void _array__splice(Array *self, size_t element_size,


////////////////////////////////////////////////////////////////////////////////
// Poolside modification in the fork, generated at 2024-09-06 11:07:56.588479 //
// Poolside modification in the fork, generated at 2024-09-09 17:42:48.694339 //
////////////////////////////////////////////////////////////////////////////////


Loading

0 comments on commit 088363a

Please sign in to comment.