00001
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 #ifndef __STUB_PROBE
00036 #pragma once
00037 #ifndef SEXP_MANIP_H
00038 #define SEXP_MANIP_H
00039
00040 #include <stdarg.h>
00041 #include <stddef.h>
00042 #include <stdint.h>
00043 #include <stdbool.h>
00044 #include <sexp-types.h>
00045
00046
00047
00048
00049
00055 SEXP_t *SEXP_number_new (SEXP_numtype_t t, const void *n) __attribute__ ((nonnull (2)));
00056
00061 SEXP_t *SEXP_number_newb (bool n);
00062
00067 SEXP_t *SEXP_number_newi_8 (int8_t n);
00068
00073 SEXP_t *SEXP_number_newu_8 (uint8_t n);
00074
00079 uint8_t SEXP_number_getu_8 (const SEXP_t *s_exp);
00080
00085 SEXP_t *SEXP_number_newi_16 (int16_t n);
00086
00091 SEXP_t *SEXP_number_newu_16 (uint16_t n);
00092
00097 #define SEXP_number_newi SEXP_number_newi_32
00098
00103 SEXP_t *SEXP_number_newi_32 (int32_t n);
00104
00109 #define SEXP_number_geti SEXP_number_geti_32
00110
00115 int32_t SEXP_number_geti_32 (const SEXP_t *s_exp);
00116
00121 #define SEXP_number_newu SEXP_number_newu_32
00122
00127 SEXP_t *SEXP_number_newu_32 (uint32_t n);
00128
00133 #define SEXP_number_getu SEXP_number_getu_32
00134
00139 uint32_t SEXP_number_getu_32 (const SEXP_t *s_exp);
00140
00145 SEXP_t *SEXP_number_newi_64 (int64_t n);
00146
00151 int64_t SEXP_number_geti_64 (const SEXP_t *s_exp);
00152
00157 SEXP_t *SEXP_number_newu_64 (uint64_t n);
00158
00163 uint64_t SEXP_number_getu_64 (const SEXP_t *s_exp);
00164
00169 SEXP_t *SEXP_number_newf (double n);
00170
00175 double SEXP_number_getf (const SEXP_t *s_exp);
00176
00183 int SEXP_number_get (const SEXP_t *s_exp, void *dst, SEXP_numtype_t type);
00184
00189 uint16_t SEXP_number_getu_16 (const SEXP_t *s_exp);
00190
00195 void SEXP_number_free (SEXP_t *s_exp);
00196
00201 bool SEXP_numberp (const SEXP_t *s_exp);
00202
00207 SEXP_numtype_t SEXP_number_type (const SEXP_t *sexp);
00208
00209
00210
00211
00212
00218 SEXP_t *SEXP_string_new (const void *string, size_t strlen) __attribute__ ((nonnull (1)));
00219
00225 SEXP_t *SEXP_string_newf (const char *format, ...) __attribute__ ((format (printf, 1, 2), nonnull (1)));
00226
00231 void SEXP_string_free (SEXP_t *s_exp);
00232
00237 bool SEXP_stringp (const SEXP_t *s_exp);
00238
00243 size_t SEXP_string_length (const SEXP_t *s_exp);
00244
00250 int SEXP_strcmp (const SEXP_t *s_exp, const char *str) __attribute__ ((nonnull (2)));
00251
00258 int SEXP_strncmp (const SEXP_t *s_exp, const char *str, size_t n) __attribute__ ((nonnull (2)));
00259
00265 int SEXP_string_nth (const SEXP_t *s_exp, size_t n);
00266
00270 char *SEXP_string_cstr (const SEXP_t *s_exp);
00271
00279 size_t SEXP_string_cstr_r (const SEXP_t *s_exp, char *buf, size_t len) __attribute__ ((nonnull (2)));
00280
00284 char *SEXP_string_cstrp (const SEXP_t *s_exp);
00285
00292 char *SEXP_string_subcstr (const SEXP_t *s_exp, size_t beg, size_t len);
00293
00299 int SEXP_string_cmp (const SEXP_t *str_a, const SEXP_t *str_b);
00300
00301
00302
00303
00304
00311 SEXP_t *SEXP_list_new (SEXP_t *memb, ...);
00312
00317 void SEXP_list_free (SEXP_t *s_exp);
00318
00323 bool SEXP_listp (const SEXP_t *s_exp);
00324
00329 size_t SEXP_list_length (const SEXP_t *s_exp);
00330
00336 SEXP_t *SEXP_list_first (const SEXP_t *list);
00337
00343 SEXP_t *SEXP_list_rest (const SEXP_t *list);
00344
00350 SEXP_t *SEXP_list_last (const SEXP_t *list);
00351
00358 SEXP_t *SEXP_list_nth (const SEXP_t *list, uint32_t n);
00359
00366 SEXP_t *SEXP_list_add (SEXP_t *list, const SEXP_t *s_exp);
00367
00374 SEXP_t *SEXP_list_join (const SEXP_t *list_a, const SEXP_t *list_b);
00375
00382 SEXP_t *SEXP_list_push (SEXP_t *list, const SEXP_t *s_exp);
00383
00389 SEXP_t *SEXP_list_pop (SEXP_t *list);
00390
00399 SEXP_t *SEXP_list_replace (SEXP_t *list, uint32_t n, const SEXP_t *s_exp);
00400
00406 SEXP_t *SEXP_listref_first (SEXP_t *list);
00407
00413 SEXP_t *SEXP_listref_rest (SEXP_t *list);
00414
00420 SEXP_t *SEXP_listref_last (SEXP_t *list);
00421
00428 SEXP_t *SEXP_listref_nth (SEXP_t *list, uint32_t n);
00429
00430 typedef struct SEXP_it SEXP_it_t;
00431
00432 #define SEXP_IT_RECURSIVE 0x01
00433 #define SEXP_IT_HARDREF 0x02
00434
00435 SEXP_it_t *SEXP_listit_new (const SEXP_t *list, int flags);
00436 SEXP_t *SEXP_listit_next(SEXP_it_t *it);
00437 SEXP_t *SEXP_listit_prev (SEXP_it_t *it);
00438 SEXP_t *SEXP_listit_length (SEXP_it_t *it);
00439 SEXP_t *SEXP_listit_seek (SEXP_it_t *it, uint32_t n);
00440 void SEXP_listit_free (SEXP_it_t *it);
00441
00442 #if __STDC_VERSION__ >= 199901L
00443 # include <sys/cdefs.h>
00444 # define __XC(a,b) __CONCAT(a,b)
00445
00446
00452 #define SEXP_list_foreach(var, list) \
00453 for (uint32_t __XC(i,__LINE__) = 1; ((var) = SEXP_list_nth (list, __XC(i,__LINE__))) != NULL; ++__XC(i,__LINE__), SEXP_free (var))
00454
00462 #define SEXP_sublist_foreach(var, list, beg, end) \
00463 for (uint32_t __XC(i,__LINE__) = (beg); __XC(i,__LINE__) <= ((size_t)(end)) && ((var) = SEXP_list_nth (list, __XC(i,__LINE__))) != NULL; ++__XC(i,__LINE__), SEXP_free (var))
00464
00465 #endif
00466
00467
00468
00469
00470
00471 SEXP_t *SEXP_new (void);
00472
00477 SEXP_t *SEXP_ref (const SEXP_t *s_exp);
00478
00483 SEXP_t *SEXP_softref (SEXP_t *s_exp);
00484 #if defined(NDEBUG)
00485
00490 void SEXP_free (SEXP_t *s_exp);
00491
00498 void SEXP_vfree (SEXP_t *s_exp, ...);
00499 #else
00500 # define SEXP_free(ptr) __SEXP_free (ptr, __FILE__, __LINE__, __PRETTY_FUNCTION__)
00501 void __SEXP_free (SEXP_t *s_exp, const char *file, uint32_t line, const char *func);
00502 # define SEXP_vfree(...) __SEXP_vfree (__FILE__, __LINE__, __PRETTY_FUNCTION__, __VA_ARGS__)
00503 void __SEXP_vfree (const char *file, uint32_t line, const char *func, SEXP_t *s_exp, ...);
00504 #endif
00505
00510 const char *SEXP_datatype (const SEXP_t *s_exp);
00511
00516 int SEXP_datatype_set (SEXP_t *s_exp, const char *name) __attribute__ ((nonnull (2)));
00517
00524 int SEXP_datatype_set_nth (SEXP_t *list, int n, const char *name) __attribute__ ((nonnull (3)));
00525
00530 SEXP_type_t SEXP_typeof (const SEXP_t *s_exp);
00531
00536 const char *SEXP_strtype (const SEXP_t *s_exp);
00537
00538 SEXP_t *SEXP_build (const char *s_str, ...);
00539
00540 size_t SEXP_sizeof (const SEXP_t *s_exp);
00541
00542 #if !defined(NDEBUG)
00543 # define SEXP_VALIDATE(s) __SEXP_VALIDATE(s, __FILE__, __LINE__, __PRETTY_FUNCTION__)
00544 # include <stdlib.h>
00545
00546 void __SEXP_VALIDATE(const SEXP_t *s_exp, const char *file, uint32_t line, const char *func);
00547
00548 #else
00549 # define SEXP_VALIDATE(s)
00550 #endif
00551
00552 #endif
00553 #endif