1#ifndef RBIMPL_RSTRING_H
2#define RBIMPL_RSTRING_H
23#include "ruby/internal/config.h"
27#include "ruby/internal/cast.h"
41#define RSTRING(obj) RBIMPL_CAST((struct RString *)(obj))
44#define RSTRING_NOEMBED RSTRING_NOEMBED
45#define RSTRING_FSTR RSTRING_FSTR
46#define RSTRING_LEN RSTRING_LEN
47#define RSTRING_LENINT RSTRING_LENINT
48#define RSTRING_PTR RSTRING_PTR
49#define RSTRING_END RSTRING_END
66#define StringValue(v) rb_string_value(&(v))
76#define StringValuePtr(v) rb_string_value_ptr(&(v))
89#define StringValueCStr(v) rb_string_value_cstr(&(v))
98#define SafeStringValue(v) StringValue(v)
117#define ExportStringValue(v) do { \
119 (v) = rb_str_export(v); \
137enum ruby_rstring_flags {
327RBIMPL_ATTR_ERROR((
"rb_check_safe_str() and Check_SafeStr() are obsolete; use StringValue() instead"))
335void rb_check_safe_str(
VALUE);
344#define Check_SafeStr(v) rb_check_safe_str(RBIMPL_CAST((VALUE)(v)))
354void rb_debug_rstring_null_ptr(
const char *func);
383 char *
ptr = RB_FL_TEST_RAW(str, RSTRING_NOEMBED) ?
394 rb_debug_rstring_null_ptr(
"RSTRING_PTR");
411 char *
ptr = RB_FL_TEST_RAW(str, RSTRING_NOEMBED) ?
414 long len = RSTRING_LEN(str);
418 rb_debug_rstring_null_ptr(
"RSTRING_END");
450# define RSTRING_GETMEM(str, ptrvar, lenvar) \
451 ((ptrvar) = RSTRING_PTR(str), \
452 (lenvar) = RSTRING_LEN(str))
Defines RBIMPL_ATTR_ARTIFICIAL.
#define RBIMPL_ATTR_ARTIFICIAL()
Wraps (or simulates) __attribute__((artificial)).
#define RUBY_DEBUG
Define this macro when you want assertions.
Tweaking visibility of C variables/functions.
#define RBIMPL_SYMBOL_EXPORT_END()
Counterpart of RBIMPL_SYMBOL_EXPORT_BEGIN.
#define RBIMPL_SYMBOL_EXPORT_BEGIN()
Shortcut macro equivalent to RUBY_SYMBOL_EXPORT_BEGIN extern "C" {.
Defines enum ruby_fl_type.
@ RUBY_FL_USER17
User-defined flag.
@ RUBY_FL_USER1
User-defined flag.
#define RBIMPL_ATTR_ERROR(msg)
Wraps (or simulates) __attribute__((error)).
char * ptr
Pointer to the underlying memory region, of at least capa bytes.
int len
Length of the buffer.
Arithmetic conversion between C's long and Ruby's.
#define rb_long2int
Just another name of rb_long2int_inline.
#define inline
Old Visual Studio versions do not support the inline keyword, so we need to define it to be __inline.
Defines RBIMPL_ATTR_PURE.
#define RBIMPL_ATTR_PURE_UNLESS_DEBUG()
Enables RBIMPL_ATTR_PURE if and only if.
VALUE rb_str_export_locale(VALUE obj)
Identical to rb_str_export(), except it converts into the locale encoding instead.
char * rb_string_value_cstr(volatile VALUE *ptr)
Identical to rb_string_value_ptr(), except it additionally checks for the contents for viability as a...
static int RSTRING_LENINT(VALUE str)
Identical to RSTRING_LEN(), except it differs for the return type.
static char * RSTRING_END(VALUE str)
Queries the end of the contents pointer of the string.
VALUE rb_string_value(volatile VALUE *ptr)
Identical to rb_str_to_str(), except it fills the passed pointer with the converted object.
#define RSTRING(obj)
Convenient casting macro.
VALUE rb_str_export(VALUE obj)
Identical to rb_str_to_str(), except it additionally converts the string into default external encodi...
char * rb_string_value_ptr(volatile VALUE *ptr)
Identical to rb_str_to_str(), except it returns the converted string's backend memory region.
VALUE rb_str_to_str(VALUE obj)
Identical to rb_check_string_type(), except it raises exceptions in case of conversion failures.
Ruby object's base components.
char * ptr
Pointer to the contents of the string.
struct RBasic basic
Basic part, including flags and class.
long len
Length of the string, not including terminating NUL character.
long capa
Capacity of *ptr.
VALUE shared
Parent of the string.
uintptr_t VALUE
Type that represents a Ruby object.
Defines enum ruby_value_type.
Defines RBIMPL_WARNING_PUSH.