@@ -35,6 +35,7 @@ VALUE rb_cRuggedOdbObject;
35
35
static ID id_call ;
36
36
37
37
extern const rb_data_type_t rugged_object_type ;
38
+ static const rb_data_type_t rugged_odb_object_type ;
38
39
39
40
/*
40
41
* call-seq:
@@ -48,7 +49,7 @@ extern const rb_data_type_t rugged_object_type;
48
49
static VALUE rb_git_odbobj_oid (VALUE self )
49
50
{
50
51
git_odb_object * obj ;
51
- Data_Get_Struct (self , git_odb_object , obj );
52
+ TypedData_Get_Struct (self , git_odb_object , & rugged_odb_object_type , obj );
52
53
return rugged_create_oid (git_odb_object_id (obj ));
53
54
}
54
55
@@ -66,7 +67,7 @@ static VALUE rb_git_odbobj_oid(VALUE self)
66
67
static VALUE rb_git_odbobj_data (VALUE self )
67
68
{
68
69
git_odb_object * obj ;
69
- Data_Get_Struct (self , git_odb_object , obj );
70
+ TypedData_Get_Struct (self , git_odb_object , & rugged_odb_object_type , obj );
70
71
return rb_str_new (git_odb_object_data (obj ), git_odb_object_size (obj ));
71
72
}
72
73
@@ -82,7 +83,7 @@ static VALUE rb_git_odbobj_data(VALUE self)
82
83
static VALUE rb_git_odbobj_size (VALUE self )
83
84
{
84
85
git_odb_object * obj ;
85
- Data_Get_Struct (self , git_odb_object , obj );
86
+ TypedData_Get_Struct (self , git_odb_object , & rugged_odb_object_type , obj );
86
87
return INT2FIX (git_odb_object_size (obj ));
87
88
}
88
89
@@ -98,7 +99,7 @@ static VALUE rb_git_odbobj_size(VALUE self)
98
99
static VALUE rb_git_odbobj_type (VALUE self )
99
100
{
100
101
git_odb_object * obj ;
101
- Data_Get_Struct (self , git_odb_object , obj );
102
+ TypedData_Get_Struct (self , git_odb_object , & rugged_odb_object_type , obj );
102
103
return rugged_otype_new (git_odb_object_type (obj ));
103
104
}
104
105
@@ -107,6 +108,24 @@ void rb_git__odbobj_free(void *obj)
107
108
git_odb_object_free ((git_odb_object * )obj );
108
109
}
109
110
111
+ static size_t rb_git__odbobj_size (const void * obj )
112
+ {
113
+ return git_odb_object_size ((git_odb_object * )obj );
114
+ }
115
+
116
+ static const rb_data_type_t rugged_odb_object_type = {
117
+ .wrap_struct_name = "Rugged::OdbObject" ,
118
+ .function = {
119
+ .dmark = NULL ,
120
+ .dfree = rb_git__odbobj_free ,
121
+ .dsize = rb_git__odbobj_size ,
122
+ },
123
+ .data = NULL ,
124
+ .flags = RUBY_TYPED_FREE_IMMEDIATELY ,
125
+ };
126
+
127
+
128
+
110
129
VALUE rugged_raw_read (git_repository * repo , const git_oid * oid )
111
130
{
112
131
git_odb * odb ;
@@ -121,7 +140,7 @@ VALUE rugged_raw_read(git_repository *repo, const git_oid *oid)
121
140
git_odb_free (odb );
122
141
rugged_exception_check (error );
123
142
124
- return Data_Wrap_Struct (rb_cRuggedOdbObject , NULL , rb_git__odbobj_free , obj );
143
+ return TypedData_Wrap_Struct (rb_cRuggedOdbObject , & rugged_odb_object_type , obj );
125
144
}
126
145
127
146
void rb_git_repo__free (git_repository * repo )
@@ -2816,7 +2835,7 @@ void Init_rugged_repo(void)
2816
2835
rb_define_method (rb_cRuggedRepo , "cherrypick_commit" , rb_git_repo_cherrypick_commit , -1 );
2817
2836
rb_define_method (rb_cRuggedRepo , "fetch_attributes" , rb_git_repo_attributes , -1 );
2818
2837
2819
- rb_cRuggedOdbObject = rb_define_class_under (rb_mRugged , "OdbObject" , rb_cObject );
2838
+ rb_cRuggedOdbObject = rb_define_class_under (rb_mRugged , "OdbObject" , rb_cData );
2820
2839
rb_define_method (rb_cRuggedOdbObject , "data" , rb_git_odbobj_data , 0 );
2821
2840
rb_define_method (rb_cRuggedOdbObject , "len" , rb_git_odbobj_size , 0 );
2822
2841
rb_define_method (rb_cRuggedOdbObject , "type" , rb_git_odbobj_type , 0 );
0 commit comments