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

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

Data Structures | Macros | Typedefs | Enumerations | Functions
rtypeddata.h File Reference

Defines struct RTypedData. More...

`#include "ruby/internal/config.h"`
`#include "ruby/internal/assume.h"`
`#include "ruby/internal/attr/artificial.h"`
`#include "ruby/internal/attr/pure.h"`
`#include "ruby/internal/cast.h"`
`#include "ruby/internal/core/rbasic.h"`
`#include "ruby/internal/core/rdata.h"`
`#include "ruby/internal/dllexport.h"`
`#include "ruby/internal/error.h"`
`#include "ruby/internal/fl_type.h"`
`#include "ruby/internal/stdbool.h"`
`#include "ruby/internal/value_type.h"`

Go to the source code of this file.

## Data Structures
struct | rb_data_type_struct
struct | RTypedData

## Macros
#define | HAVE_TYPE_RB_DATA_TYPE_T 1
#define | HAVE_RB_DATA_TYPE_T_FUNCTION 1
#define | HAVE_RB_DATA_TYPE_T_PARENT 1
#define | RUBY_TYPED_DEFAULT_FREE RUBY_DEFAULT_FREE
#define | RUBY_TYPED_NEVER_FREE RUBY_NEVER_FREE
#define | RTYPEDDATA(obj) RBIMPL_CAST((struct RTypedData *)(obj))
#define | RTYPEDDATA_DATA(v) (RTYPEDDATA(v)->data)
#define | Check_TypedStruct(v, t) rb_check_typeddata(RBIMPL_CAST((VALUE)(v)), (t))
#define | TypedData_Wrap_Struct(klass, data_type, sval) rb_data_typed_object_wrap((klass),(sval),(data_type))
#define | TypedData_Make_Struct0(result, klass, type, size, data_type, sval)
#define | TypedData_Make_Struct(klass, type, data_type, sval)
#define | TypedData_Get_Struct(obj, type, data_type, sval) ((sval) = RBIMPL_CAST((type *)rb_check_typeddata((obj), (data_type))))

## Typedefs
typedef struct rb_data_type_struct | rb_data_type_t

## Enumerations
enum | rbimpl_typeddata_flags { RUBY_TYPED_FREE_IMMEDIATELY = 1 , RUBY_TYPED_FROZEN_SHAREABLE = RUBY_FL_SHAREABLE , RUBY_TYPED_WB_PROTECTED = RUBY_FL_WB_PROTECTED , RUBY_TYPED_PROMOTED1 = RUBY_FL_PROMOTED1 }

## Functions
VALUE | rb_data_typed_object_wrap (VALUE klass, void *datap, const rb_data_type_t *)
VALUE | rb_data_typed_object_zalloc (VALUE klass, size_t size, const rb_data_type_t *type)
int | rb_typeddata_inherited_p (const rb_data_type_t *child, const rb_data_type_t *parent)
int | rb_typeddata_is_kind_of (VALUE obj, const rb_data_type_t *data_type)
void * | rb_check_typeddata (VALUE obj, const rb_data_type_t *data_type)

## Detailed Description

Defines struct RTypedData.

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 rtypeddata.h.

## Macro Definition Documentation

## ◆ Check_TypedStruct

#define Check_TypedStruct | ( |  | v,
|  |  | t
| ) |  | rb_check_typeddata(RBIMPL_CAST((VALUE)(v)), (t))

Definition at line 48 of file rtypeddata.h.

## ◆ HAVE_RB_DATA_TYPE_T_FUNCTION

#define HAVE_RB_DATA_TYPE_T_FUNCTION 1

Definition at line 42 of file rtypeddata.h.

## ◆ HAVE_RB_DATA_TYPE_T_PARENT

#define HAVE_RB_DATA_TYPE_T_PARENT 1

Definition at line 43 of file rtypeddata.h.

## ◆ HAVE_TYPE_RB_DATA_TYPE_T

#define HAVE_TYPE_RB_DATA_TYPE_T 1

Definition at line 41 of file rtypeddata.h.

## ◆ RTYPEDDATA

#define RTYPEDDATA | ( |  | obj | ) | RBIMPL_CAST((struct RTypedData *)(obj))

Definition at line 46 of file rtypeddata.h.

## ◆ RTYPEDDATA_DATA

#define RTYPEDDATA_DATA | ( |  | v | ) | (RTYPEDDATA(v)->data)

Definition at line 47 of file rtypeddata.h.

## ◆ RUBY_TYPED_DEFAULT_FREE

#define RUBY_TYPED_DEFAULT_FREE RUBY_DEFAULT_FREE

Definition at line 44 of file rtypeddata.h.

## ◆ RUBY_TYPED_NEVER_FREE

#define RUBY_TYPED_NEVER_FREE RUBY_NEVER_FREE

Definition at line 45 of file rtypeddata.h.

## ◆ TypedData_Get_Struct

#define TypedData_Get_Struct | ( |  | obj,
|  |  | type,
|  |  | data_type,
|  |  | sval
| ) |  | ((sval) = RBIMPL_CAST((type *)rb_check_typeddata((obj), (data_type))))

Definition at line 130 of file rtypeddata.h.

## ◆ TypedData_Make_Struct

#define TypedData_Make_Struct | ( |  | klass,
|  |  | type,
|  |  | data_type,
|  |  | sval
| ) |  |

Value:
rb_data_typed_object_make( \
(klass), \
(data_type), \
RBIMPL_CAST((void **)&(sval)), \
sizeof(type))

Definition at line 122 of file rtypeddata.h.

## ◆ TypedData_Make_Struct0

#define TypedData_Make_Struct0 | ( |  | result,
|  |  | klass,
|  |  | type,
|  |  | size,
|  |  | data_type,
|  |  | sval
| ) |  |

Value:
VALUE result = rb_data_typed_object_zalloc(klass, size, data_type); \
(sval) = RBIMPL_CAST((type *)RTYPEDDATA_DATA(result)); \
RBIMPL_CAST(/*suppress unused variable warnings*/(void)(sval))
size
voidpf void uLong size
Definition: ioapi.h:138
RTYPEDDATA_DATA
#define RTYPEDDATA_DATA(v)
Definition: rtypeddata.h:47
rb_data_typed_object_zalloc
VALUE rb_data_typed_object_zalloc(VALUE klass, size_t size, const rb_data_type_t *type)
Definition: gc.c:2513
VALUE
unsigned long VALUE
Definition: value.h:38

Definition at line 104 of file rtypeddata.h.

## ◆ TypedData_Wrap_Struct

#define TypedData_Wrap_Struct | ( |  | klass,
|  |  | data_type,
|  |  | sval
| ) |  | rb_data_typed_object_wrap((klass),(sval),(data_type))

Definition at line 101 of file rtypeddata.h.

## Typedef Documentation

## ◆ rb_data_type_t

typedef struct rb_data_type_struct rb_data_type_t

Definition at line 68 of file rtypeddata.h.

## Enumeration Type Documentation

## ◆ rbimpl_typeddata_flags

enum rbimpl_typeddata_flags

Enumerator
RUBY_TYPED_FREE_IMMEDIATELY |
RUBY_TYPED_FROZEN_SHAREABLE |
RUBY_TYPED_WB_PROTECTED |
RUBY_TYPED_PROMOTED1 |

Definition at line 61 of file rtypeddata.h.

## Function Documentation

## ◆ rb_data_typed_object_wrap()

VALUE rb_data_typed_object_wrap | ( | VALUE | klass,
|  | void * | datap,
|  | const rb_data_type_t * | type
| ) |  |

Definition at line 2505 of file gc.c.

References RUBY_ASSERT_ALWAYS, RUBY_FL_WB_PROTECTED, T_CLASS, and T_DATA.

Referenced by rb_data_typed_object_zalloc().

## ◆ rb_data_typed_object_zalloc()

VALUE rb_data_typed_object_zalloc | ( | VALUE | klass,
|  | size_t | size,
|  | const rb_data_type_t * | type
| ) |  |

Definition at line 2513 of file gc.c.

References DATA_PTR, rb_data_typed_object_wrap(), and xcalloc.