summaryrefslogtreecommitdiff
path: root/doc/extension.rdoc
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2021-08-21 16:42:50 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2021-08-21 16:48:13 +0900
commit8f755ad6c88f5a2318c0f810f872b9e54daa517c (patch)
tree527c997a93d3d75443ebc8ea9c62d31456b1fc4c /doc/extension.rdoc
parente2b2b577b664a39011ea9137d643b2eac7785c7d (diff)
downloadruby-8f755ad6c88f5a2318c0f810f872b9e54daa517c.tar.gz
[DOC] mention rb_define_alloc_func [ci skip]
Diffstat (limited to 'doc/extension.rdoc')
-rw-r--r--doc/extension.rdoc28
1 files changed, 15 insertions, 13 deletions
diff --git a/doc/extension.rdoc b/doc/extension.rdoc
index f8e0a1ec3d..fc83801b3d 100644
--- a/doc/extension.rdoc
+++ b/doc/extension.rdoc
@@ -657,8 +657,10 @@ with the next macro.
TypedData_Wrap_Struct() returns a created Ruby object as a VALUE.
-The klass argument is the class for the object. It is recommended
-that klass derives from rb_cObject.
+The klass argument is the class for the object. The klass should
+derive from rb_cObject, and the allocator must be set by calling
+rb_define_alloc_func or rb_undef_alloc_func.
+
data_type is a pointer to a const rb_data_type_t which describes
how Ruby should manage the struct.
@@ -668,17 +670,17 @@ member of the struct.
typedef struct rb_data_type_struct rb_data_type_t;
struct rb_data_type_struct {
- const char *wrap_struct_name;
- struct {
- void (*dmark)(void*);
- void (*dfree)(void*);
- size_t (*dsize)(const void *);
- void (*dcompact)(void*);
- void *reserved[1];
- } function;
- const rb_data_type_t *parent;
- void *data;
- VALUE flags;
+ const char *wrap_struct_name;
+ struct {
+ void (*dmark)(void*);
+ void (*dfree)(void*);
+ size_t (*dsize)(const void *);
+ void (*dcompact)(void*);
+ void *reserved[1];
+ } function;
+ const rb_data_type_t *parent;
+ void *data;
+ VALUE flags;
};
wrap_struct_name is an identifier of this instance of the struct.