removed src/point.h

This commit is contained in:
Maieul BOYER 2024-04-30 15:06:33 +02:00
parent dfdd8e4503
commit 5bec1546aa
No known key found for this signature in database
8 changed files with 153 additions and 66 deletions

View file

@ -1,7 +1,7 @@
#ifndef TREE_SITTER_LENGTH_H_ #ifndef TREE_SITTER_LENGTH_H_
#define TREE_SITTER_LENGTH_H_ #define TREE_SITTER_LENGTH_H_
#include "../src/point.h" #include "parser/point.h"
#include "parser/api.h" #include "parser/api.h"
#include <stdbool.h> #include <stdbool.h>
#include <stdlib.h> #include <stdlib.h>

21
parser/includes/point.h Normal file
View file

@ -0,0 +1,21 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* point.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/04/30 14:35:22 by maiboyer #+# #+# */
/* Updated: 2024/04/30 14:46:18 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef POINT_H
#define POINT_H
#include "parser/point/inline1.h"
#include "parser/point/inline2.h"
#include "parser/point/inline3.h"
#endif /* POINT_H */

View file

@ -0,0 +1,50 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* inline1.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/04/30 14:35:50 by maiboyer #+# #+# */
/* Updated: 2024/04/30 14:43:49 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef INLINE1_H
#define INLINE1_H
#include "parser/types/types_point.h"
static inline t_point point__new(unsigned row, unsigned column)
{
t_point result = {row, column};
return result;
}
static inline t_point point_add(t_point a, t_point b)
{
if (b.row > 0)
return point__new(a.row + b.row, b.column);
else
return point__new(a.row, a.column + b.column);
}
static inline t_point point_sub(t_point a, t_point b)
{
if (a.row > b.row)
return point__new(a.row - b.row, a.column);
else
return point__new(0, a.column - b.column);
}
static inline bool point_lte(t_point a, t_point b)
{
return (a.row < b.row) || (a.row == b.row && a.column <= b.column);
}
static inline bool point_lt(t_point a, t_point b)
{
return (a.row < b.row) || (a.row == b.row && a.column < b.column);
}
#endif /* INLINE1_H */

View file

@ -0,0 +1,49 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* inline2.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/04/30 14:43:58 by maiboyer #+# #+# */
/* Updated: 2024/04/30 14:44:12 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef INLINE2_H
#define INLINE2_H
#include "parser/types/types_point.h"
static inline bool point_gt(t_point a, t_point b)
{
return (a.row > b.row) || (a.row == b.row && a.column > b.column);
}
static inline bool point_gte(t_point a, t_point b)
{
return (a.row > b.row) || (a.row == b.row && a.column >= b.column);
}
static inline bool point_eq(t_point a, t_point b)
{
return a.row == b.row && a.column == b.column;
}
static inline t_point point_min(t_point a, t_point b)
{
if (a.row < b.row || (a.row == b.row && a.column < b.column))
return a;
else
return b;
}
static inline t_point point_max(t_point a, t_point b)
{
if (a.row > b.row || (a.row == b.row && a.column > b.column))
return a;
else
return b;
}
#endif /* INLINE2_H */

View file

@ -0,0 +1,29 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* inline3.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/04/30 14:44:49 by maiboyer #+# #+# */
/* Updated: 2024/04/30 15:04:39 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef INLINE3_H
#define INLINE3_H
#include "parser/types/types_point.h"
#include <stdint.h>
static inline t_point point_val_zero(void)
{
return ((t_point){0, 0});
}
static inline t_point point_val_max(void)
{
return ((t_point){UINT32_MAX, UINT32_MAX});
}
#endif /* INLINE3_H */

View file

@ -1,62 +0,0 @@
#ifndef TREE_SITTER_POINT_H_
#define TREE_SITTER_POINT_H_
#include "parser/api.h"
#define POINT_ZERO ((t_point) {0, 0})
#define POINT_MAX ((t_point) {UINT32_MAX, UINT32_MAX})
static inline t_point point__new(unsigned row, unsigned column) {
t_point result = {row, column};
return result;
}
static inline t_point point_add(t_point a, t_point b) {
if (b.row > 0)
return point__new(a.row + b.row, b.column);
else
return point__new(a.row, a.column + b.column);
}
static inline t_point point_sub(t_point a, t_point b) {
if (a.row > b.row)
return point__new(a.row - b.row, a.column);
else
return point__new(0, a.column - b.column);
}
static inline bool point_lte(t_point a, t_point b) {
return (a.row < b.row) || (a.row == b.row && a.column <= b.column);
}
static inline bool point_lt(t_point a, t_point b) {
return (a.row < b.row) || (a.row == b.row && a.column < b.column);
}
static inline bool point_gt(t_point a, t_point b) {
return (a.row > b.row) || (a.row == b.row && a.column > b.column);
}
static inline bool point_gte(t_point a, t_point b) {
return (a.row > b.row) || (a.row == b.row && a.column >= b.column);
}
static inline bool point_eq(t_point a, t_point b) {
return a.row == b.row && a.column == b.column;
}
static inline t_point point_min(t_point a, t_point b) {
if (a.row < b.row || (a.row == b.row && a.column < b.column))
return a;
else
return b;
}
static inline t_point point_max(t_point a, t_point b) {
if (a.row > b.row || (a.row == b.row && a.column > b.column))
return a;
else
return b;
}
#endif

View file

@ -66,7 +66,7 @@ void ts_tree_edit(t_parse_tree *self, const t_input_edit *edit) {
); );
if (range->end_byte < edit->new_end_byte) { if (range->end_byte < edit->new_end_byte) {
range->end_byte = UINT32_MAX; range->end_byte = UINT32_MAX;
range->end_point = POINT_MAX; range->end_point = point_val_max();
} }
} }
} else if (range->end_byte > edit->start_byte) { } else if (range->end_byte > edit->start_byte) {
@ -81,7 +81,7 @@ void ts_tree_edit(t_parse_tree *self, const t_input_edit *edit) {
); );
if (range->start_byte < edit->new_end_byte) { if (range->start_byte < edit->new_end_byte) {
range->start_byte = UINT32_MAX; range->start_byte = UINT32_MAX;
range->start_point = POINT_MAX; range->start_point = point_val_max();
} }
} else if (range->start_byte > edit->start_byte) { } else if (range->start_byte > edit->start_byte) {
range->start_byte = edit->start_byte; range->start_byte = edit->start_byte;

View file

@ -299,7 +299,7 @@ static inline t_i64 ts_tree_cursor_goto_first_child_for_byte_and_point(
} }
t_i64 ts_tree_cursor_goto_first_child_for_byte(t_parse_tree_cursor *self, t_u32 goal_byte) { t_i64 ts_tree_cursor_goto_first_child_for_byte(t_parse_tree_cursor *self, t_u32 goal_byte) {
return ts_tree_cursor_goto_first_child_for_byte_and_point(self, goal_byte, POINT_ZERO); return ts_tree_cursor_goto_first_child_for_byte_and_point(self, goal_byte, point_val_zero());
} }
t_i64 ts_tree_cursor_goto_first_child_for_point(t_parse_tree_cursor *self, t_point goal_point) { t_i64 ts_tree_cursor_goto_first_child_for_point(t_parse_tree_cursor *self, t_point goal_point) {