1 #ifndef VCTRS_TYPE_DATA_FRAME_H
2 #define VCTRS_TYPE_DATA_FRAME_H
3 
4 #include "arg.h"
5 #include "names.h"
6 #include "ptype2.h"
7 
8 
9 SEXP new_data_frame(SEXP x, R_len_t n);
10 void init_data_frame(SEXP x, R_len_t n);
11 void init_tibble(SEXP x, R_len_t n);
12 void init_compact_rownames(SEXP x, R_len_t n);
13 
14 static inline
df_rownames(SEXP x)15 SEXP df_rownames(SEXP x) {
16   return r_attrib_get(x, R_RowNamesSymbol);
17 }
18 
19 bool is_native_df(SEXP x);
20 SEXP df_poke(SEXP x, R_len_t i, SEXP value);
21 SEXP df_poke_at(SEXP x, SEXP name, SEXP value);
22 SEXP df_flatten(SEXP x);
23 SEXP df_repair_names(SEXP x, struct name_repair_opts* name_repair);
24 
25 static inline
26 SEXP df_cast(SEXP x, SEXP to, struct vctrs_arg* x_arg, struct vctrs_arg* to_arg);
27 
28 enum rownames_type {
29   ROWNAMES_AUTOMATIC,
30   ROWNAMES_AUTOMATIC_COMPACT,
31   ROWNAMES_IDENTIFIERS
32 };
33 enum rownames_type rownames_type(SEXP rn);
34 R_len_t rownames_size(SEXP rn);
35 
36 
37 SEXP df_ptype2(const struct ptype2_opts* opts);
38 
39 static inline
df_ptype2_params(SEXP x,SEXP y,struct vctrs_arg * x_arg,struct vctrs_arg * y_arg,enum df_fallback df_fallback)40 SEXP df_ptype2_params(SEXP x,
41                       SEXP y,
42                       struct vctrs_arg* x_arg,
43                       struct vctrs_arg* y_arg,
44                       enum df_fallback df_fallback) {
45   const struct ptype2_opts opts = {
46     .x = x,
47     .y = y,
48     .x_arg = x_arg,
49     .y_arg = y_arg,
50     .fallback = {
51       .df = df_fallback
52     }
53   };
54   return df_ptype2(&opts);
55 }
56 
57 
58 #endif
59