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_
#define TREE_SITTER_LENGTH_H_
#include "../src/point.h"
#include "parser/point.h"
#include "parser/api.h"
#include <stdbool.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 */