Expand description
Implementation of Ruby macros.
Since macros are rely on the C preprocessor, or defined as inline C
functions, they are not available when linking libruby. In order to use the
libruby macros from Rust, rb-sys implements them using the following
strategies:
- For stable versions of Ruby, the macros are implemented as Rust functions
- For ruby-head, the macros are implemented as C functions that are linked into the crate.
Functions§
- DATA_
PTR ⚠ - Get data pointer from RData/TypedData object (akin to
DATA_PTR). - DBL2NUM
- Convert C double to Ruby Float VALUE (akin to
DBL2NUM). - ENCODING_
GET ⚠ - Get encoding index from object (akin to
ENCODING_GET). - FIX2LONG⚠
- Convert Fixnum to long (akin to
FIX2LONG). - FIX2ULONG⚠
- Convert Fixnum to unsigned long (akin to
FIX2ULONG). - FIXABLE
- Check if long value can be represented as Fixnum (akin to
FIXABLE). - FIXNUM_
P - Checks if the given object is a so-called Fixnum.
- FLONUM_
P - Checks if the given object is a so-called Flonum.
- FL_ABLE
- Check if an object can have flags (akin to
RB_FL_ABLE). - ID2SYM
- Convert ID to Symbol (akin to
ID2SYMorRB_ID2SYM). - IMMEDIATE_
P - Checks if the given object is an immediate i.e. an object which has no corresponding storage inside of the object space.
- LONG2FIX⚠
- Convert long to Fixnum (akin to
LONG2FIX). - LONG2NUM
- Convert long to Ruby Integer (akin to
LONG2NUM). - NIL_P
- Checks if the given object is nil.
- NUM2DBL⚠
- Convert Ruby numeric to C double (akin to
NUM2DBL). - NUM2LONG⚠
- Convert Ruby Integer to long (akin to
NUM2LONG). - NUM2ULONG⚠
- Convert Ruby Integer to unsigned long (akin to
NUM2ULONG). - POSFIXABLE
- Check if unsigned long value can be represented as positive Fixnum (akin to
POSFIXABLE). - RARRAY_
AREF ⚠ - Read array element at index (akin to
RARRAY_AREF). - RARRAY_
ASET ⚠ - Write array element at index (akin to
RARRAY_ASET). - RARRAY_
CONST_ ⚠PTR - Get the backend storage of a Ruby array.
- RARRAY_
LEN ⚠ - Get the length of a Ruby array.
- RBIGNUM_
NEGATIVE_ ⚠P - Checks if the bignum is negative.
- RBIGNUM_
POSITIVE_ ⚠P - Checks if the bignum is positive.
- RB_
BUILTIN_ ⚠TYPE - Queries the type of the object.
- RB_
DYNAMIC_ ⚠SYM_ P - Queries if the object is a dynamic symbol.
- RB_
FLOAT_ ⚠TYPE_ P - Queries if the object is an instance of ::rb_cFloat.
- RB_
ID2SYM - Alias for ID2SYM for compatibility with Ruby naming conventions.
- RB_
INTEGER_ ⚠TYPE_ P - Queries if the object is an instance of ::rb_cInteger.
- RB_
OBJ_ ⚠FREEZE - Freeze an object (akin to
RB_OBJ_FREEZE). - RB_
OBJ_ ⚠PROMOTED - Check if object is promoted to old GC generation (akin to
RB_OBJ_PROMOTED). - RB_
OBJ_ ⚠PROMOTED_ RAW - Raw version assuming FL_ABLE (akin to
RB_OBJ_PROMOTED_RAW). - RB_
OBJ_ ⚠WRITE - Execute GC write barrier when storing a reference (akin to
RB_OBJ_WRITE). - RB_
OBJ_ ⚠WRITTEN - Declare a write barrier without actually writing (akin to
RB_OBJ_WRITTEN). - RB_
SYM2ID ⚠ - Alias for SYM2ID for compatibility with Ruby naming conventions.
- RB_
SYMBOL_ ⚠P - Queries if the object is an instance of ::rb_cSymbol.
- RB_TYPE⚠
- Identical to RB_BUILTIN_TYPE(), except it can also accept special constants.
- RB_
TYPE_ ⚠P - Queries if the given object is of given type.
- RHASH_
EMPTY_ ⚠P - Check if hash is empty (akin to
RHASH_EMPTY_P). - RHASH_
SIZE ⚠ - Get hash size (akin to
RHASH_SIZE). - RSTRING_
END ⚠ - Get pointer to end of string contents (akin to
RSTRING_END). - RSTRING_
LEN ⚠ - Get the length of a Ruby string.
- RSTRING_
PTR ⚠ - Get the backend storage of a Ruby string.
- RTYPEDDATA_
GET_ ⚠DATA - Gets the data pointer from an RTypedData object.
- RTYPEDDATA_
P ⚠ - Checks if the given object is an RTypedData.
- RTYPEDDATA_
TYPE ⚠ - Gets the data type information from an RTypedData object.
- SPECIAL_
CONST_ P - Checks if the given object is of enum ::ruby_special_consts.
- STATIC_
SYM_ P - Checks if the given object is a static symbol.
- SYM2ID⚠
- Convert Symbol to ID (akin to
SYM2IDorRB_SYM2ID). - TEST
- Emulates Ruby’s “if” statement.
- ULON
G2NUM - Convert unsigned long to Ruby Integer (akin to
ULONG2NUM).