| 73472 |
luke |
1 |
/*
|
|
|
2 |
* R : A Computer Language for Statistical Data Analysis
|
| 87075 |
kalibera |
3 |
* Copyright (C) 2016-2024 The R Core Team.
|
| 73472 |
luke |
4 |
*
|
|
|
5 |
* This program is free software; you can redistribute it and/or modify
|
|
|
6 |
* it under the terms of the GNU Lesser General Public License as published by
|
|
|
7 |
* the Free Software Foundation; either version 2.1 of the License, or
|
|
|
8 |
* (at your option) any later version.
|
|
|
9 |
*
|
|
|
10 |
* This program is distributed in the hope that it will be useful,
|
|
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
13 |
* GNU Lesser General Public License for more details.
|
|
|
14 |
*
|
|
|
15 |
* You should have received a copy of the GNU Lesser General Public License
|
|
|
16 |
* along with this program; if not, a copy is available at
|
|
|
17 |
* https://www.R-project.org/Licenses/
|
|
|
18 |
*/
|
|
|
19 |
|
| 86459 |
ripley |
20 |
/*
|
| 86467 |
luke |
21 |
This API is experimental and may change on short notice.
|
|
|
22 |
Package authors using this API should be prepared to adapt to changes
|
|
|
23 |
when they occur.
|
| 86459 |
ripley |
24 |
*/
|
|
|
25 |
|
| 73472 |
luke |
26 |
#ifndef R_EXT_ALTREP_H_
|
|
|
27 |
#define R_EXT_ALTREP_H_
|
|
|
28 |
|
| 87075 |
kalibera |
29 |
#include <R_ext/Complex.h>
|
|
|
30 |
|
| 75414 |
luke |
31 |
#ifdef __cplusplus
|
|
|
32 |
extern "C" {
|
|
|
33 |
#endif
|
|
|
34 |
|
| 73472 |
luke |
35 |
#define STRUCT_SUBTYPES
|
|
|
36 |
#ifdef STRUCT_SUBTYPES
|
|
|
37 |
# define R_SEXP(x) (x).ptr
|
|
|
38 |
# define R_SUBTYPE_INIT(x) { x }
|
|
|
39 |
typedef struct { SEXP ptr; } R_altrep_class_t;
|
|
|
40 |
#else
|
|
|
41 |
# define R_SEXP(x) ((SEXP) (x))
|
|
|
42 |
# define R_SUBTYPE_INIT(x) (void *) (x)
|
|
|
43 |
typedef struct R_altcls *R_altrep_class_t;
|
|
|
44 |
#endif
|
|
|
45 |
|
|
|
46 |
SEXP
|
| 75414 |
luke |
47 |
R_new_altrep(R_altrep_class_t aclass, SEXP data1, SEXP data2);
|
| 73472 |
luke |
48 |
|
|
|
49 |
R_altrep_class_t
|
|
|
50 |
R_make_altstring_class(const char *cname, const char *pname, DllInfo *info);
|
|
|
51 |
R_altrep_class_t
|
|
|
52 |
R_make_altinteger_class(const char *cname, const char *pname, DllInfo *info);
|
|
|
53 |
R_altrep_class_t
|
|
|
54 |
R_make_altreal_class(const char *cname, const char *pname, DllInfo *info);
|
| 75481 |
luke |
55 |
R_altrep_class_t
|
|
|
56 |
R_make_altlogical_class(const char *cname, const char *pname, DllInfo *info);
|
|
|
57 |
R_altrep_class_t
|
|
|
58 |
R_make_altraw_class(const char *cname, const char *pname, DllInfo *info);
|
|
|
59 |
R_altrep_class_t
|
|
|
60 |
R_make_altcomplex_class(const char *cname, const char *pname, DllInfo *info);
|
| 83914 |
luke |
61 |
R_altrep_class_t
|
|
|
62 |
R_make_altlist_class(const char *cname, const char *pname, DllInfo *info);
|
| 75481 |
luke |
63 |
|
| 73472 |
luke |
64 |
Rboolean R_altrep_inherits(SEXP x, R_altrep_class_t);
|
|
|
65 |
|
|
|
66 |
typedef SEXP (*R_altrep_UnserializeEX_method_t)(SEXP, SEXP, SEXP, int, int);
|
|
|
67 |
typedef SEXP (*R_altrep_Unserialize_method_t)(SEXP, SEXP);
|
|
|
68 |
typedef SEXP (*R_altrep_Serialized_state_method_t)(SEXP);
|
|
|
69 |
typedef SEXP (*R_altrep_DuplicateEX_method_t)(SEXP, Rboolean);
|
|
|
70 |
typedef SEXP (*R_altrep_Duplicate_method_t)(SEXP, Rboolean);
|
|
|
71 |
typedef SEXP (*R_altrep_Coerce_method_t)(SEXP, int);
|
|
|
72 |
typedef Rboolean (*R_altrep_Inspect_method_t)(SEXP, int, int, int,
|
|
|
73 |
void (*)(SEXP, int, int, int));
|
|
|
74 |
typedef R_xlen_t (*R_altrep_Length_method_t)(SEXP);
|
|
|
75 |
|
|
|
76 |
typedef void *(*R_altvec_Dataptr_method_t)(SEXP, Rboolean);
|
| 73718 |
luke |
77 |
typedef const void *(*R_altvec_Dataptr_or_null_method_t)(SEXP);
|
| 73472 |
luke |
78 |
typedef SEXP (*R_altvec_Extract_subset_method_t)(SEXP, SEXP, SEXP);
|
|
|
79 |
|
|
|
80 |
typedef int (*R_altinteger_Elt_method_t)(SEXP, R_xlen_t);
|
|
|
81 |
typedef R_xlen_t
|
|
|
82 |
(*R_altinteger_Get_region_method_t)(SEXP, R_xlen_t, R_xlen_t, int *);
|
|
|
83 |
typedef int (*R_altinteger_Is_sorted_method_t)(SEXP);
|
|
|
84 |
typedef int (*R_altinteger_No_NA_method_t)(SEXP);
|
| 74224 |
luke |
85 |
typedef SEXP (*R_altinteger_Sum_method_t)(SEXP, Rboolean);
|
|
|
86 |
typedef SEXP (*R_altinteger_Min_method_t)(SEXP, Rboolean);
|
|
|
87 |
typedef SEXP (*R_altinteger_Max_method_t)(SEXP, Rboolean);
|
| 73472 |
luke |
88 |
|
|
|
89 |
typedef double (*R_altreal_Elt_method_t)(SEXP, R_xlen_t);
|
|
|
90 |
typedef R_xlen_t
|
|
|
91 |
(*R_altreal_Get_region_method_t)(SEXP, R_xlen_t, R_xlen_t, double *);
|
|
|
92 |
typedef int (*R_altreal_Is_sorted_method_t)(SEXP);
|
|
|
93 |
typedef int (*R_altreal_No_NA_method_t)(SEXP);
|
| 74224 |
luke |
94 |
typedef SEXP (*R_altreal_Sum_method_t)(SEXP, Rboolean);
|
|
|
95 |
typedef SEXP (*R_altreal_Min_method_t)(SEXP, Rboolean);
|
|
|
96 |
typedef SEXP (*R_altreal_Max_method_t)(SEXP, Rboolean);
|
| 73472 |
luke |
97 |
|
| 75481 |
luke |
98 |
typedef int (*R_altlogical_Elt_method_t)(SEXP, R_xlen_t);
|
|
|
99 |
typedef R_xlen_t
|
|
|
100 |
(*R_altlogical_Get_region_method_t)(SEXP, R_xlen_t, R_xlen_t, int *);
|
|
|
101 |
typedef int (*R_altlogical_Is_sorted_method_t)(SEXP);
|
|
|
102 |
typedef int (*R_altlogical_No_NA_method_t)(SEXP);
|
|
|
103 |
typedef SEXP (*R_altlogical_Sum_method_t)(SEXP, Rboolean);
|
|
|
104 |
|
|
|
105 |
typedef Rbyte (*R_altraw_Elt_method_t)(SEXP, R_xlen_t);
|
|
|
106 |
typedef R_xlen_t
|
|
|
107 |
(*R_altraw_Get_region_method_t)(SEXP, R_xlen_t, R_xlen_t, Rbyte *);
|
|
|
108 |
|
|
|
109 |
typedef Rcomplex (*R_altcomplex_Elt_method_t)(SEXP, R_xlen_t);
|
|
|
110 |
typedef R_xlen_t
|
|
|
111 |
(*R_altcomplex_Get_region_method_t)(SEXP, R_xlen_t, R_xlen_t, Rcomplex *);
|
|
|
112 |
|
| 73472 |
luke |
113 |
typedef SEXP (*R_altstring_Elt_method_t)(SEXP, R_xlen_t);
|
|
|
114 |
typedef void (*R_altstring_Set_elt_method_t)(SEXP, R_xlen_t, SEXP);
|
|
|
115 |
typedef int (*R_altstring_Is_sorted_method_t)(SEXP);
|
|
|
116 |
typedef int (*R_altstring_No_NA_method_t)(SEXP);
|
|
|
117 |
|
| 83914 |
luke |
118 |
typedef SEXP (*R_altlist_Elt_method_t)(SEXP, R_xlen_t);
|
|
|
119 |
typedef void (*R_altlist_Set_elt_method_t)(SEXP, R_xlen_t, SEXP);
|
|
|
120 |
|
| 73472 |
luke |
121 |
#define DECLARE_METHOD_SETTER(CNAME, MNAME) \
|
|
|
122 |
void \
|
|
|
123 |
R_set_##CNAME##_##MNAME##_method(R_altrep_class_t cls, \
|
|
|
124 |
R_##CNAME##_##MNAME##_method_t fun);
|
|
|
125 |
|
|
|
126 |
DECLARE_METHOD_SETTER(altrep, UnserializeEX)
|
|
|
127 |
DECLARE_METHOD_SETTER(altrep, Unserialize)
|
|
|
128 |
DECLARE_METHOD_SETTER(altrep, Serialized_state)
|
|
|
129 |
DECLARE_METHOD_SETTER(altrep, DuplicateEX)
|
|
|
130 |
DECLARE_METHOD_SETTER(altrep, Duplicate)
|
|
|
131 |
DECLARE_METHOD_SETTER(altrep, Coerce)
|
|
|
132 |
DECLARE_METHOD_SETTER(altrep, Inspect)
|
|
|
133 |
DECLARE_METHOD_SETTER(altrep, Length)
|
|
|
134 |
|
|
|
135 |
DECLARE_METHOD_SETTER(altvec, Dataptr)
|
|
|
136 |
DECLARE_METHOD_SETTER(altvec, Dataptr_or_null)
|
|
|
137 |
DECLARE_METHOD_SETTER(altvec, Extract_subset)
|
|
|
138 |
|
|
|
139 |
DECLARE_METHOD_SETTER(altinteger, Elt)
|
|
|
140 |
DECLARE_METHOD_SETTER(altinteger, Get_region)
|
|
|
141 |
DECLARE_METHOD_SETTER(altinteger, Is_sorted)
|
|
|
142 |
DECLARE_METHOD_SETTER(altinteger, No_NA)
|
| 74224 |
luke |
143 |
DECLARE_METHOD_SETTER(altinteger, Sum)
|
|
|
144 |
DECLARE_METHOD_SETTER(altinteger, Min)
|
|
|
145 |
DECLARE_METHOD_SETTER(altinteger, Max)
|
| 73472 |
luke |
146 |
|
|
|
147 |
DECLARE_METHOD_SETTER(altreal, Elt)
|
|
|
148 |
DECLARE_METHOD_SETTER(altreal, Get_region)
|
|
|
149 |
DECLARE_METHOD_SETTER(altreal, Is_sorted)
|
|
|
150 |
DECLARE_METHOD_SETTER(altreal, No_NA)
|
| 74224 |
luke |
151 |
DECLARE_METHOD_SETTER(altreal, Sum)
|
|
|
152 |
DECLARE_METHOD_SETTER(altreal, Min)
|
|
|
153 |
DECLARE_METHOD_SETTER(altreal, Max)
|
| 73472 |
luke |
154 |
|
| 75481 |
luke |
155 |
DECLARE_METHOD_SETTER(altlogical, Elt)
|
|
|
156 |
DECLARE_METHOD_SETTER(altlogical, Get_region)
|
|
|
157 |
DECLARE_METHOD_SETTER(altlogical, Is_sorted)
|
|
|
158 |
DECLARE_METHOD_SETTER(altlogical, No_NA)
|
|
|
159 |
DECLARE_METHOD_SETTER(altlogical, Sum)
|
|
|
160 |
|
|
|
161 |
DECLARE_METHOD_SETTER(altraw, Elt)
|
|
|
162 |
DECLARE_METHOD_SETTER(altraw, Get_region)
|
|
|
163 |
|
|
|
164 |
DECLARE_METHOD_SETTER(altcomplex, Elt)
|
|
|
165 |
DECLARE_METHOD_SETTER(altcomplex, Get_region)
|
|
|
166 |
|
| 73472 |
luke |
167 |
DECLARE_METHOD_SETTER(altstring, Elt)
|
|
|
168 |
DECLARE_METHOD_SETTER(altstring, Set_elt)
|
|
|
169 |
DECLARE_METHOD_SETTER(altstring, Is_sorted)
|
|
|
170 |
DECLARE_METHOD_SETTER(altstring, No_NA)
|
|
|
171 |
|
| 83914 |
luke |
172 |
DECLARE_METHOD_SETTER(altlist, Elt)
|
|
|
173 |
DECLARE_METHOD_SETTER(altlist, Set_elt)
|
|
|
174 |
|
| 89022 |
luke |
175 |
/* DATAPTR_RW is declared here since it should only be used to
|
|
|
176 |
implement Dataptr methods. */
|
|
|
177 |
void *DATAPTR_RW(SEXP);
|
|
|
178 |
|
| 75414 |
luke |
179 |
#ifdef __cplusplus
|
|
|
180 |
}
|
|
|
181 |
#endif
|
|
|
182 |
|
| 73472 |
luke |
183 |
#endif /* R_EXT_ALTREP_H_ */
|