@@ -35,6 +35,7 @@ VALUE rb_cRuggedOdbObject;
3535static ID id_call ;
3636
3737extern const rb_data_type_t rugged_object_type ;
38+ static const rb_data_type_t rugged_odb_object_type ;
3839
3940/*
4041 * call-seq:
@@ -48,7 +49,7 @@ extern const rb_data_type_t rugged_object_type;
4849static VALUE rb_git_odbobj_oid (VALUE self )
4950{
5051 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 );
5253 return rugged_create_oid (git_odb_object_id (obj ));
5354}
5455
@@ -66,7 +67,7 @@ static VALUE rb_git_odbobj_oid(VALUE self)
6667static VALUE rb_git_odbobj_data (VALUE self )
6768{
6869 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 );
7071 return rb_str_new (git_odb_object_data (obj ), git_odb_object_size (obj ));
7172}
7273
@@ -82,7 +83,7 @@ static VALUE rb_git_odbobj_data(VALUE self)
8283static VALUE rb_git_odbobj_size (VALUE self )
8384{
8485 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 );
8687 return INT2FIX (git_odb_object_size (obj ));
8788}
8889
@@ -98,7 +99,7 @@ static VALUE rb_git_odbobj_size(VALUE self)
9899static VALUE rb_git_odbobj_type (VALUE self )
99100{
100101 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 );
102103 return rugged_otype_new (git_odb_object_type (obj ));
103104}
104105
@@ -107,6 +108,24 @@ void rb_git__odbobj_free(void *obj)
107108 git_odb_object_free ((git_odb_object * )obj );
108109}
109110
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+
110129VALUE rugged_raw_read (git_repository * repo , const git_oid * oid )
111130{
112131 git_odb * odb ;
@@ -121,7 +140,7 @@ VALUE rugged_raw_read(git_repository *repo, const git_oid *oid)
121140 git_odb_free (odb );
122141 rugged_exception_check (error );
123142
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 );
125144}
126145
127146void rb_git_repo__free (git_repository * repo )
@@ -2816,7 +2835,7 @@ void Init_rugged_repo(void)
28162835 rb_define_method (rb_cRuggedRepo , "cherrypick_commit" , rb_git_repo_cherrypick_commit , -1 );
28172836 rb_define_method (rb_cRuggedRepo , "fetch_attributes" , rb_git_repo_attributes , -1 );
28182837
2819- rb_cRuggedOdbObject = rb_define_class_under (rb_mRugged , "OdbObject" , rb_cObject );
2838+ rb_cRuggedOdbObject = rb_define_class_under (rb_mRugged , "OdbObject" , rb_cData );
28202839 rb_define_method (rb_cRuggedOdbObject , "data" , rb_git_odbobj_data , 0 );
28212840 rb_define_method (rb_cRuggedOdbObject , "len" , rb_git_odbobj_size , 0 );
28222841 rb_define_method (rb_cRuggedOdbObject , "type" , rb_git_odbobj_type , 0 );
0 commit comments