Rizin
unix-like reverse engineering framework and cli tools
length.h
Go to the documentation of this file.
1 #ifndef TREE_SITTER_LENGTH_H_
2 #define TREE_SITTER_LENGTH_H_
3 
4 #include <stdlib.h>
5 #include <stdbool.h>
6 #include "./point.h"
7 #include "tree_sitter/api.h"
8 
9 typedef struct {
12 } Length;
13 
14 static const Length LENGTH_UNDEFINED = {0, {0, 1}};
16 
17 static inline bool length_is_undefined(Length length) {
18  return length.bytes == 0 && length.extent.column != 0;
19 }
20 
21 static inline Length length_min(Length len1, Length len2) {
22  return (len1.bytes < len2.bytes) ? len1 : len2;
23 }
24 
25 static inline Length length_add(Length len1, Length len2) {
26  Length result;
27  result.bytes = len1.bytes + len2.bytes;
28  result.extent = point_add(len1.extent, len2.extent);
29  return result;
30 }
31 
32 static inline Length length_sub(Length len1, Length len2) {
33  Length result;
34  result.bytes = len1.bytes - len2.bytes;
35  result.extent = point_sub(len1.extent, len2.extent);
36  return result;
37 }
38 
39 static inline Length length_zero(void) {
40  Length result = {0, {0, 0}};
41  return result;
42 }
43 
44 #endif
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags static arg static fd static protocol static who struct sockaddr static addrlen static backlog struct timeval struct timezone static tz const struct iovec static count static mode const void const struct sockaddr static tolen const char static pathname void static offset struct stat static buf void long static basep static whence static length const void static len static semflg const void static shmflg const struct timespec struct timespec static rem const char static group const void length
Definition: sflib.h:133
static const Length LENGTH_UNDEFINED
Definition: length.h:14
static Length length_zero(void)
Definition: length.h:39
static Length length_add(Length len1, Length len2)
Definition: length.h:25
static bool length_is_undefined(Length length)
Definition: length.h:17
static Length length_min(Length len1, Length len2)
Definition: length.h:21
static Length length_sub(Length len1, Length len2)
Definition: length.h:32
static const Length LENGTH_MAX
Definition: length.h:15
static TSPoint point_sub(TSPoint a, TSPoint b)
Definition: point.h:21
static TSPoint point_add(TSPoint a, TSPoint b)
Definition: point.h:14
unsigned int uint32_t
Definition: sftypes.h:29
#define UINT32_MAX
Definition: length.h:9
uint32_t bytes
Definition: length.h:10
TSPoint extent
Definition: length.h:11
Definition: api.h:55