Ruby 3.1.3p185 (2022-11-24 revision 1a6b16756e0ba6b95ab71a441357ed5484e33498)
|
This is the struct that holds necessary info for a struct. More...
#include <rtypeddata.h>
Data Fields | |
const char * | wrap_struct_name |
Name of structs of this kind. More... | |
struct { | |
RUBY_DATA_FUNC dmark | |
RUBY_DATA_FUNC dfree | |
size_t(* dsize )(const void *) | |
RUBY_DATA_FUNC dcompact | |
void * reserved [1] | |
} | function |
const rb_data_type_t * | parent |
Parent of this class. More... | |
void * | data |
Type-specific static data. More... | |
VALUE | flags |
Type-specific behavioural characteristics. More... | |
struct { | |
RUBY_DATA_FUNC dmark | |
This function is called when the object is experiencing GC marks. More... | |
RUBY_DATA_FUNC dfree | |
This function is called when the object is no longer used. More... | |
size_t(* dsize )(const void *) | |
This function is to query the size of the underlying memory regions. More... | |
RUBY_DATA_FUNC dcompact | |
This function is called when the object is relocated. More... | |
void * reserved [1] | |
This field is reserved for future extension. More... | |
} | function |
Function pointers. More... | |
This is the struct that holds necessary info for a struct.
It roughly resembles a Ruby level class; multiple objects can share a rb_data_type_t instance.
Definition at line 3814 of file rb_mjit_min_header-3.1.3.h.
void * rb_data_type_struct::data |
Type-specific static data.
This area can be used for any purpose by a programmer who define the type. Ruby does not manage this at all.
Definition at line 3824 of file rb_mjit_min_header-3.1.3.h.
RUBY_DATA_FUNC rb_data_type_struct::dcompact |
This function is called when the object is relocated.
Like rb_data_type_struct::dmark, you need to update references to Ruby objects inside of your structs.
Definition at line 3820 of file rb_mjit_min_header-3.1.3.h.
RUBY_DATA_FUNC rb_data_type_struct::dfree |
This function is called when the object is no longer used.
You need to do whatever necessary to avoid memory leaks.
Definition at line 3818 of file rb_mjit_min_header-3.1.3.h.
RUBY_DATA_FUNC rb_data_type_struct::dmark |
This function is called when the object is experiencing GC marks.
If it contains references to other Ruby objects, you need to mark them also. Otherwise GC will smash your data.
Definition at line 3817 of file rb_mjit_min_header-3.1.3.h.
size_t(* rb_data_type_struct::dsize) (const void *) |
This function is to query the size of the underlying memory regions.
Definition at line 3819 of file rb_mjit_min_header-3.1.3.h.
VALUE rb_data_type_struct::flags |
Type-specific behavioural characteristics.
This is a bitfield. It is an EXTREMELY WISE IDEA to leave this field blank. It is designed so that setting zero is the safest thing to do. If you risk to set any bits on, you have to know exactly what you are doing.
Definition at line 3825 of file rb_mjit_min_header-3.1.3.h.
struct { ... } rb_data_type_struct::function |
Function pointers.
Resembles C++ vtbl
.
const rb_data_type_t * rb_data_type_struct::parent |
Parent of this class.
Sometimes C structs have inheritance-like relationships. An example is struct sockaddr
and its family. If you design such things, make rb_data_type_t for each of them and connect using this field. Ruby can then transparently cast your data back and forth when you call TypedData_Get_Struct().
Definition at line 3823 of file rb_mjit_min_header-3.1.3.h.
Referenced by rb_typeddata_inherited_p().
void* rb_data_type_struct::reserved[1] |
This field is reserved for future extension.
For now, it must be filled with zeros.
Definition at line 3821 of file rb_mjit_min_header-3.1.3.h.
const char * rb_data_type_struct::wrap_struct_name |
Name of structs of this kind.
This is used for diagnostic purposes. This has to be unique in the process, but doesn't has to be a valid C/Ruby identifier.
Definition at line 3815 of file rb_mjit_min_header-3.1.3.h.