Ruby: include/ruby/internal/core/rdata.h File Reference

Ruby 3.0.5p211 (2022-11-24 revision ba5cf0f7c52d4d35cc6a173c89eda98ceffa2dcf)

Data Structures | Macros | Typedefs | Functions | Variables
rdata.h File Reference

Defines struct RData. More...

`#include "ruby/internal/config.h"`
`#include "ruby/internal/attr/deprecated.h"`
`#include "ruby/internal/attr/warning.h"`
`#include "ruby/internal/cast.h"`
`#include "ruby/internal/core/rbasic.h"`
`#include "ruby/internal/dllexport.h"`
`#include "ruby/internal/fl_type.h"`
`#include "ruby/internal/token_paste.h"`
`#include "ruby/internal/value.h"`
`#include "ruby/internal/value_type.h"`
`#include "ruby/defines.h"`

Go to the source code of this file.

## Data Structures
struct | RData

## Macros
#define | RUBY_UNTYPED_DATA_WARNING 0
#define | RDATA(obj) RBIMPL_CAST((struct RData *)(obj))
#define | DATA_PTR(obj) RDATA(obj)->data
#define | RUBY_MACRO_SELECT RBIMPL_TOKEN_PASTE
#define | RUBY_DEFAULT_FREE RBIMPL_DATA_FUNC(-1)
#define | RUBY_NEVER_FREE RBIMPL_DATA_FUNC(0)
#define | RUBY_UNTYPED_DATA_FUNC(f) f RBIMPL_ATTRSET_UNTYPED_DATA_FUNC()
#define | Data_Wrap_Struct(klass, mark, free, sval)
#define | Data_Make_Struct0(result, klass, type, size, mark, free, sval)
#define | Data_Make_Struct(klass, type, mark, free, sval)
#define | Data_Get_Struct(obj, type, sval) ((sval) = RBIMPL_CAST((type*)rb_data_object_get(obj)))
#define | rb_cData rb_cData()
#define | rb_data_object_wrap_0 rb_data_object_wrap
#define | rb_data_object_wrap_1 rb_data_object_wrap_warning
#define | rb_data_object_wrap RUBY_MACRO_SELECT(rb_data_object_wrap_, RUBY_UNTYPED_DATA_WARNING)
#define | rb_data_object_get_0 rb_data_object_get
#define | rb_data_object_get_1 rb_data_object_get_warning
#define | rb_data_object_get RUBY_MACRO_SELECT(rb_data_object_get_, RUBY_UNTYPED_DATA_WARNING)
#define | rb_data_object_make_0 rb_data_object_make
#define | rb_data_object_make_1 rb_data_object_make_warning
#define | rb_data_object_make RUBY_MACRO_SELECT(rb_data_object_make_, RUBY_UNTYPED_DATA_WARNING)

## Typedefs
typedef void(* | RUBY_DATA_FUNC) (void *)

## Functions
VALUE | rb_data_object_wrap (VALUE klass, void *datap, RUBY_DATA_FUNC dmark, RUBY_DATA_FUNC dfree)
VALUE | rb_data_object_zalloc (VALUE klass, size_t size, RUBY_DATA_FUNC dmark, RUBY_DATA_FUNC dfree)

## Variables
VALUE | rb_cObject
| Object class. More...

## Detailed Description

Defines struct RData.

Author
  Ruby developers ruby-.nosp@m.core.nosp@m.@ruby.nosp@m.-lan.nosp@m.g.org

Copyright
  This file is a part of the programming language Ruby. Permission is hereby granted, to either redistribute and/or modify this file, provided that the conditions mentioned in the file COPYING are met. Consult the file for details.

Warning
  Symbols prefixed with either `RBIMPL` or `rbimpl` are implementation details. Don't take them as canon. They could rapidly appear then vanish. The name (path) of this header file is also an implementation detail. Do not expect it to persist at the place it is now. Developers are free to move it anywhere anytime at will.

Note
  To ruby-core: remember that this header can be possibly recursively included from extension libraries written in C++. Do not expect for instance `__VA_ARGS__` is always available. We assume C99 for ruby itself but we don't assume languages of extension libraries. They could be written in C++98.

Definition in file rdata.h.

## Macro Definition Documentation

## ◆ Data_Get_Struct

#define Data_Get_Struct | ( |  | obj,
|  |  | type,
|  |  | sval
| ) |  | ((sval) = RBIMPL_CAST((type*)rb_data_object_get(obj)))

Definition at line 119 of file rdata.h.

## ◆ Data_Make_Struct

#define Data_Make_Struct | ( |  | klass,
|  |  | type,
|  |  | mark,
|  |  | free,
|  |  | sval
| ) |  |

Value:
rb_data_object_make( \
(klass), \
RBIMPL_DATA_FUNC(mark), \
RBIMPL_DATA_FUNC(free), \
RBIMPL_CAST((void **)&(sval)), \
sizeof(type))
free
#define free(x)
Definition: dln.c:52
rb_data_object_make
#define rb_data_object_make
Definition: rdata.h:183

Definition at line 110 of file rdata.h.

## ◆ Data_Make_Struct0

#define Data_Make_Struct0 | ( |  | result,
|  |  | klass,
|  |  | type,
|  |  | size,
|  |  | mark,
|  |  | free,
|  |  | sval
| ) |  |

Value:
VALUE result = rb_data_object_zalloc( \
(klass), \
(size), \
RBIMPL_DATA_FUNC(mark), \
RBIMPL_DATA_FUNC(free)); \
(sval) = RBIMPL_CAST((type *)DATA_PTR(result)); \
RBIMPL_CAST(/*suppress unused variable warnings*/(void)(sval))
size
voidpf void uLong size
Definition: ioapi.h:138
DATA_PTR
#define DATA_PTR(obj)
Definition: rdata.h:56
rb_data_object_zalloc
VALUE rb_data_object_zalloc(VALUE klass, size_t size, RUBY_DATA_FUNC dmark, RUBY_DATA_FUNC dfree)
Definition: gc.c:2497
VALUE
unsigned long VALUE
Definition: value.h:38

Definition at line 87 of file rdata.h.

## ◆ DATA_PTR

#define DATA_PTR | ( |  | obj | ) | RDATA(obj)->data

Definition at line 56 of file rdata.h.

## ◆ Data_Wrap_Struct

#define Data_Wrap_Struct | ( |  | klass,
|  |  | mark,
|  |  | free,
|  |  | sval
| ) |  |

Value:
rb_data_object_wrap( \
(klass), \
(sval), \
RBIMPL_DATA_FUNC(mark), \
RBIMPL_DATA_FUNC(free))
rb_data_object_wrap
#define rb_data_object_wrap
Definition: rdata.h:177

Definition at line 80 of file rdata.h.

## ◆ rb_cData

static VALUE rb_cData | ( |  | void | ) | rb_cData()
| inline

Definition at line 173 of file rdata.h.

## ◆ rb_data_object_get

#define rb_data_object_get RUBY_MACRO_SELECT(rb_data_object_get_, RUBY_UNTYPED_DATA_WARNING)

Definition at line 180 of file rdata.h.

## ◆ rb_data_object_get_0

#define rb_data_object_get_0 rb_data_object_get

Definition at line 178 of file rdata.h.

## ◆ rb_data_object_get_1

#define rb_data_object_get_1 rb_data_object_get_warning

Definition at line 179 of file rdata.h.

## ◆ rb_data_object_make

#define rb_data_object_make RUBY_MACRO_SELECT(rb_data_object_make_, RUBY_UNTYPED_DATA_WARNING)

Definition at line 183 of file rdata.h.

## ◆ rb_data_object_make_0

#define rb_data_object_make_0 rb_data_object_make

Definition at line 181 of file rdata.h.

## ◆ rb_data_object_make_1

#define rb_data_object_make_1 rb_data_object_make_warning

Definition at line 182 of file rdata.h.

## ◆ rb_data_object_wrap

#define rb_data_object_wrap RUBY_MACRO_SELECT(rb_data_object_wrap_, RUBY_UNTYPED_DATA_WARNING)

Definition at line 177 of file rdata.h.

## ◆ rb_data_object_wrap_0

#define rb_data_object_wrap_0 rb_data_object_wrap

Definition at line 175 of file rdata.h.

## ◆ rb_data_object_wrap_1

#define rb_data_object_wrap_1 rb_data_object_wrap_warning

Definition at line 176 of file rdata.h.

## ◆ RDATA

#define RDATA | ( |  | obj | ) | RBIMPL_CAST((struct RData *)(obj))

Definition at line 55 of file rdata.h.

## ◆ RUBY_DEFAULT_FREE

#define RUBY_DEFAULT_FREE RBIMPL_DATA_FUNC(-1)

Definition at line 58 of file rdata.h.

## ◆ RUBY_MACRO_SELECT

#define RUBY_MACRO_SELECT RBIMPL_TOKEN_PASTE

Definition at line 57 of file rdata.h.

## ◆ RUBY_NEVER_FREE

#define RUBY_NEVER_FREE RBIMPL_DATA_FUNC(0)

Definition at line 59 of file rdata.h.

## ◆ RUBY_UNTYPED_DATA_FUNC

#define RUBY_UNTYPED_DATA_FUNC | ( |  | f | ) | f RBIMPL_ATTRSET_UNTYPED_DATA_FUNC()

Definition at line 60 of file rdata.h.

## ◆ RUBY_UNTYPED_DATA_WARNING

#define RUBY_UNTYPED_DATA_WARNING 0

Definition at line 45 of file rdata.h.

## Typedef Documentation

## ◆ RUBY_DATA_FUNC

typedef void(* RUBY_DATA_FUNC) (void *)

Definition at line 65 of file rdata.h.

## Function Documentation

## ◆ rb_data_object_wrap()

VALUE rb_data_object_wrap | ( | VALUE | klass,
|  | void * | datap,
|  | RUBY_DATA_FUNC | dmark,
|  | RUBY_DATA_FUNC | dfree
| ) |  |

Definition at line 2489 of file gc.c.

References FALSE, RUBY_ASSERT_ALWAYS, T_CLASS, and T_DATA.

## ◆ rb_data_object_zalloc()

VALUE rb_data_object_zalloc | ( | VALUE | klass,
|  | size_t | size,
|  | RUBY_DATA_FUNC | dmark,
|  | RUBY_DATA_FUNC | dfree
| ) |  |

Definition at line 2497 of file gc.c.

References DATA_PTR, rb_data_object_wrap, and xcalloc.