rustr/
rtype.rs

1//! C Macro constant for R
2//!
3//!
4//!
5
6use rdll::{TYPEOF, SEXP, SET_TYPEOF};
7
8pub type Rtype = ::std::os::raw::c_uint;
9
10#[allow(unused_doc_comments)]
11#[derive(Copy, PartialEq, Eq, Clone, Debug)]
12pub enum RTypeEnum {
13    NIL,
14    SYM,
15    LIST,
16    CLO,
17    ENV,
18    PROM,
19    LANG,
20    SPECIAL,
21    BUILTIN,
22    /// ////////////VECTOR BEGIN
23    CHAR,
24    LGL,
25    INT,
26    REAL,
27    CPLX,
28    STR,
29    VEC,
30    S4,
31    RAW,
32    EXPR,
33    /// ///////////VECTOR END
34    DOT,
35    ANY,
36    BCODE,
37    EXTPTR,
38    WEAKREF,
39    NEW,
40    FREE,
41    FUN,
42}
43
44#[allow(unused_doc_comments)]
45#[inline]
46pub fn match_rtype(x: Rtype) -> RTypeEnum {
47    match x {
48        NILSXP => RTypeEnum::NIL,
49        SYMSXP => RTypeEnum::SYM,
50        LISTSXP => RTypeEnum::LIST,
51        CLOSXP => RTypeEnum::CLO,
52        ENVSXP => RTypeEnum::ENV,
53        PROMSXP => RTypeEnum::PROM,
54        LANGSXP => RTypeEnum::LANG,
55        SPECIALSXP => RTypeEnum::SPECIAL,
56        BUILTINSXP => RTypeEnum::BUILTIN,
57        /// ////////////VECTOR BEGIN
58        CHARSXP => RTypeEnum::CHAR,
59        LGLSXP => RTypeEnum::LGL,
60        INTSXP => RTypeEnum::INT,
61        REALSXP => RTypeEnum::REAL,
62        CPLXSXP => RTypeEnum::CPLX,
63        STRSXP => RTypeEnum::STR,
64        VECSXP => RTypeEnum::VEC,
65        S4SXP => RTypeEnum::S4,
66        RAWSXP => RTypeEnum::RAW,
67        EXPRSXP => RTypeEnum::EXPR,
68        /// ///////////VECTOR END
69        DOTSXP => RTypeEnum::DOT,
70        ANYSXP => RTypeEnum::ANY,
71        BCODESXP => RTypeEnum::BCODE,
72        EXTPTRSXP => RTypeEnum::EXTPTR,
73        WEAKREFSXP => RTypeEnum::WEAKREF,
74        NEWSXP => RTypeEnum::NEW,
75        FREESXP => RTypeEnum::FREE,
76        FUNSXP => RTypeEnum::FUN,
77        _ => RTypeEnum::NIL, // unreachable but to keep safe
78    }
79}
80
81#[allow(non_snake_case)]
82#[inline]
83pub fn RTYPEOF(x: SEXP) -> ::std::os::raw::c_uint {
84    unsafe { TYPEOF(x) as ::std::os::raw::c_uint }
85}
86
87#[allow(non_snake_case)]
88#[inline]
89pub unsafe fn SET_RTYPEOF(x: SEXP, v: ::std::os::raw::c_uint) {
90    SET_TYPEOF(x, v as ::std::os::raw::c_int);
91}
92
93
94
95pub const NILSXP: ::std::os::raw::c_uint = 0;	  /* nil = NULL */
96pub struct RNIL;
97
98pub const SYMSXP: ::std::os::raw::c_uint = 1;	  /* symbols */
99pub struct RSYM;
100
101pub const LISTSXP: ::std::os::raw::c_uint = 2;	  /* lists of dotted pairs */
102pub struct RLIST;
103pub const CLOSXP: ::std::os::raw::c_uint = 3;	  /* closures */
104pub struct RCLOS;
105pub const ENVSXP: ::std::os::raw::c_uint = 4;  /* environments */
106pub struct RENV;
107pub const PROMSXP: ::std::os::raw::c_uint = 5;  /* promises: [un]evaluated closure arguments */
108pub struct RPROM;
109pub const LANGSXP: ::std::os::raw::c_uint = 6;	  /* language constructs (special lists) */
110pub struct RLANG;
111pub const SPECIALSXP: ::std::os::raw::c_uint = 7;  /* special forms */
112pub struct RSPECIAL;
113pub const BUILTINSXP: ::std::os::raw::c_uint = 8;  /* builtin non-special forms */
114// pub struct
115pub const CHARSXP: ::std::os::raw::c_uint = 9;  /* "scalar" string type (internal only)*/
116pub struct RCHAR;
117pub const LGLSXP: ::std::os::raw::c_uint = 10;  /* logical vectors */
118// 11 and 12 were factors and ordered factors in the 1990s
119pub struct RLGL;
120pub const INTSXP: ::std::os::raw::c_uint = 13;  /* integer vectors */
121pub struct RINT;
122pub const REALSXP: ::std::os::raw::c_uint = 14;  /* real variables */
123pub struct RREAL;
124pub const CPLXSXP: ::std::os::raw::c_uint = 15;  /* complex variables */
125pub struct RCPLX;
126pub const STRSXP: ::std::os::raw::c_uint = 16;  /* string vectors */
127pub struct RSTR;
128pub const DOTSXP: ::std::os::raw::c_uint = 17;  /* dot-dot-dot object */
129pub struct RDOT;
130pub const ANYSXP: ::std::os::raw::c_uint = 18;
131pub struct RANY;
132// make "any" args work.
133// Used in specifying types for symbol
134// registration to mean anything is okay
135
136pub const VECSXP: ::std::os::raw::c_uint = 19;  /* generic vectors */
137pub struct RVEC;
138pub const EXPRSXP: ::std::os::raw::c_uint = 20;  /* expressions vectors */
139pub struct REXPR;
140pub const BCODESXP: ::std::os::raw::c_uint = 21; /* byte code */
141pub struct RBCODESXP;
142pub const EXTPTRSXP: ::std::os::raw::c_uint = 22;  /* external pointer */
143pub struct REXTPTR;
144pub const WEAKREFSXP: ::std::os::raw::c_uint = 23;  /* weak reference */
145pub struct RWEAKREF;
146pub const RAWSXP: ::std::os::raw::c_uint = 24; /* raw bytes */
147pub struct RRAW;
148pub const S4SXP: ::std::os::raw::c_uint = 25;  /* S4, non-vector */
149pub struct RS4;
150
151// used for detecting PROTECT issues in memory.c
152pub const NEWSXP: ::std::os::raw::c_uint = 30;  /* fresh node created in new page */
153pub struct RNEW;
154pub const FREESXP: ::std::os::raw::c_uint = 31;  /* node released by GC */
155pub struct RFREE;
156pub const FUNSXP: ::std::os::raw::c_uint = 99;  /* Closure or Builtin or Special */
157pub struct RFUN;