Changed (u)int\d+_t to their stdme types

This commit is contained in:
Maix0 2024-07-03 19:03:19 +02:00
parent a7bfe526b0
commit 38bdd66f78
22 changed files with 1034 additions and 981 deletions

View file

@ -1,8 +1,9 @@
#ifndef TREE_SITTER_SUBTREE_H_
#define TREE_SITTER_SUBTREE_H_
#include "me/types.h"
#include "./array.h"
#include "./error_costs.h"
#include "./length.h"
#include "./parser.h"
#include "api.h"
@ -31,7 +32,7 @@ typedef struct ExternalScannerState
char *long_data;
char short_data[24];
};
uint32_t length;
t_u32 length;
} ExternalScannerState;
// A compact representation of a subtree.
@ -56,19 +57,19 @@ typedef struct SubtreeInlineData SubtreeInlineData;
bool is_keyword : 1;
#define SUBTREE_SIZE \
uint8_t padding_columns; \
uint8_t padding_rows : 4; \
uint8_t lookahead_bytes : 4; \
uint8_t padding_bytes; \
uint8_t size_bytes;
t_u8 padding_columns; \
t_u8 padding_rows : 4; \
t_u8 lookahead_bytes : 4; \
t_u8 padding_bytes; \
t_u8 size_bytes;
#if TS_BIG_ENDIAN
# if TS_PTR_SIZE == 32
struct SubtreeInlineData
{
uint16_t parse_state;
uint8_t symbol;
t_u16 parse_state;
t_u8 symbol;
SUBTREE_BITS
bool unused : 1;
bool is_inline : 1;
@ -80,8 +81,8 @@ struct SubtreeInlineData
struct SubtreeInlineData
{
SUBTREE_SIZE
uint16_t parse_state;
uint8_t symbol;
t_u16 parse_state;
t_u8 symbol;
SUBTREE_BITS
bool unused : 1;
bool is_inline : 1;
@ -94,8 +95,8 @@ struct SubtreeInlineData
{
bool is_inline : 1;
SUBTREE_BITS
uint8_t symbol;
uint16_t parse_state;
t_u8 symbol;
t_u16 parse_state;
SUBTREE_SIZE
};
@ -111,12 +112,12 @@ struct SubtreeInlineData
// the inline representation.
typedef struct SubtreeHeapData
{
volatile uint32_t ref_count;
volatile t_u32 ref_count;
Length padding;
Length size;
uint32_t lookahead_bytes;
uint32_t error_cost;
uint32_t child_count;
t_u32 lookahead_bytes;
t_u32 error_cost;
t_u32 child_count;
TSSymbol symbol;
TSStateId parse_state;
@ -136,12 +137,12 @@ typedef struct SubtreeHeapData
// Non-terminal subtrees (`child_count > 0`)
struct
{
uint32_t visible_child_count;
uint32_t named_child_count;
uint32_t visible_descendant_count;
int32_t dynamic_precedence;
uint16_t repeat_depth;
uint16_t production_id;
t_u32 visible_child_count;
t_u32 named_child_count;
t_u32 visible_descendant_count;
t_i32 dynamic_precedence;
t_u16 repeat_depth;
t_u16 production_id;
struct
{
TSSymbol symbol;
@ -153,7 +154,7 @@ typedef struct SubtreeHeapData
ExternalScannerState external_scanner_state;
// Error terminal subtrees (`child_count == 0 && symbol == ts_builtin_sym_error`)
int32_t lookahead_char;
t_i32 lookahead_char;
};
} SubtreeHeapData;
@ -189,20 +190,20 @@ void ts_subtree_array_delete(SubtreePool *, SubtreeArray *);
void ts_subtree_array_remove_trailing_extras(SubtreeArray *, SubtreeArray *);
void ts_subtree_array_reverse(SubtreeArray *);
SubtreePool ts_subtree_pool_new(uint32_t capacity);
SubtreePool ts_subtree_pool_new(t_u32 capacity);
void ts_subtree_pool_delete(SubtreePool *);
Subtree ts_subtree_new_leaf(SubtreePool *, TSSymbol, Length, Length, uint32_t, TSStateId, bool, bool, bool, const TSLanguage *);
Subtree ts_subtree_new_error(SubtreePool *, int32_t, Length, Length, uint32_t, TSStateId, const TSLanguage *);
Subtree ts_subtree_new_leaf(SubtreePool *, TSSymbol, Length, Length, t_u32, TSStateId, bool, bool, bool, const TSLanguage *);
Subtree ts_subtree_new_error(SubtreePool *, t_i32, Length, Length, t_u32, TSStateId, const TSLanguage *);
MutableSubtree ts_subtree_new_node(TSSymbol, SubtreeArray *, unsigned, const TSLanguage *);
Subtree ts_subtree_new_error_node(SubtreeArray *, bool, const TSLanguage *);
Subtree ts_subtree_new_missing_leaf(SubtreePool *, TSSymbol, Length, uint32_t, const TSLanguage *);
Subtree ts_subtree_new_missing_leaf(SubtreePool *, TSSymbol, Length, t_u32, const TSLanguage *);
MutableSubtree ts_subtree_make_mut(SubtreePool *, Subtree);
void ts_subtree_retain(Subtree);
void ts_subtree_release(SubtreePool *, Subtree);
int ts_subtree_compare(Subtree, Subtree, SubtreePool *);
void ts_subtree_set_symbol(MutableSubtree *, TSSymbol, const TSLanguage *);
void ts_subtree_summarize(MutableSubtree, const Subtree *, uint32_t, const TSLanguage *);
void ts_subtree_summarize(MutableSubtree, const Subtree *, t_u32, const TSLanguage *);
void ts_subtree_summarize_children(MutableSubtree, const TSLanguage *);
void ts_subtree_balance(Subtree, SubtreePool *, const TSLanguage *);
Subtree ts_subtree_edit(Subtree, const TSInputEdit *edit, SubtreePool *);
@ -246,7 +247,7 @@ static inline TSStateId ts_subtree_parse_state(Subtree self)
{
return SUBTREE_GET(self, parse_state);
}
static inline uint32_t ts_subtree_lookahead_bytes(Subtree self)
static inline t_u32 ts_subtree_lookahead_bytes(Subtree self)
{
return SUBTREE_GET(self, lookahead_bytes);
}
@ -255,7 +256,7 @@ static inline uint32_t ts_subtree_lookahead_bytes(Subtree self)
// Get the size needed to store a heap-allocated subtree with the given
// number of children.
static inline size_t ts_subtree_alloc_size(uint32_t child_count)
static inline size_t ts_subtree_alloc_size(t_u32 child_count)
{
return child_count * sizeof(Subtree) + sizeof(SubtreeHeapData);
}
@ -325,32 +326,32 @@ static inline Length ts_subtree_total_size(Subtree self)
return length_add(ts_subtree_padding(self), ts_subtree_size(self));
}
static inline uint32_t ts_subtree_total_bytes(Subtree self)
static inline t_u32 ts_subtree_total_bytes(Subtree self)
{
return ts_subtree_total_size(self).bytes;
}
static inline uint32_t ts_subtree_child_count(Subtree self)
static inline t_u32 ts_subtree_child_count(Subtree self)
{
return self.data.is_inline ? 0 : self.ptr->child_count;
}
static inline uint32_t ts_subtree_repeat_depth(Subtree self)
static inline t_u32 ts_subtree_repeat_depth(Subtree self)
{
return self.data.is_inline ? 0 : self.ptr->repeat_depth;
}
static inline uint32_t ts_subtree_is_repetition(Subtree self)
static inline t_u32 ts_subtree_is_repetition(Subtree self)
{
return self.data.is_inline ? 0 : !self.ptr->named && !self.ptr->visible && self.ptr->child_count != 0;
}
static inline uint32_t ts_subtree_visible_descendant_count(Subtree self)
static inline t_u32 ts_subtree_visible_descendant_count(Subtree self)
{
return (self.data.is_inline || self.ptr->child_count == 0) ? 0 : self.ptr->visible_descendant_count;
}
static inline uint32_t ts_subtree_visible_child_count(Subtree self)
static inline t_u32 ts_subtree_visible_child_count(Subtree self)
{
if (ts_subtree_child_count(self) > 0)
{
@ -362,7 +363,7 @@ static inline uint32_t ts_subtree_visible_child_count(Subtree self)
}
}
static inline uint32_t ts_subtree_error_cost(Subtree self)
static inline t_u32 ts_subtree_error_cost(Subtree self)
{
if (ts_subtree_missing(self))
{
@ -374,12 +375,12 @@ static inline uint32_t ts_subtree_error_cost(Subtree self)
}
}
static inline int32_t ts_subtree_dynamic_precedence(Subtree self)
static inline t_i32 ts_subtree_dynamic_precedence(Subtree self)
{
return (self.data.is_inline || self.ptr->child_count == 0) ? 0 : self.ptr->dynamic_precedence;
}
static inline uint16_t ts_subtree_production_id(Subtree self)
static inline t_u16 ts_subtree_production_id(Subtree self)
{
if (ts_subtree_child_count(self) > 0)
{