зеркало из https://github.com/github/ruby.git
* error.c (rb_typed_struct_is_kind_of): new function to see if the
given typed struct. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23983 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
74a6cc877c
Коммит
ac3c2866c7
|
@ -1,3 +1,8 @@
|
|||
Tue Jul 7 16:54:24 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* error.c (rb_typed_struct_is_kind_of): new function to see if the
|
||||
given typed struct.
|
||||
|
||||
Tue Jul 7 13:44:49 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* error.c (rb_check_typed_struct): new function to check typed
|
||||
|
|
10
error.c
10
error.c
|
@ -316,6 +316,16 @@ rb_check_type(VALUE x, int t)
|
|||
}
|
||||
}
|
||||
|
||||
int
|
||||
rb_typed_struct_is_kind_of(VALUE obj, const rb_data_type_t *data_type)
|
||||
{
|
||||
if (SPECIAL_CONST_P(obj) || BUILTIN_TYPE(obj) != T_DATA ||
|
||||
!RTYPEDDATA_P(obj) || RTYPEDDATA_TYPE(obj) != data_type) {
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
void *
|
||||
rb_check_typed_struct(VALUE obj, const rb_data_type_t *data_type)
|
||||
{
|
||||
|
|
|
@ -764,8 +764,10 @@ typedef void (*RUBY_DATA_FUNC)(void*);
|
|||
|
||||
VALUE rb_data_object_alloc(VALUE,void*,RUBY_DATA_FUNC,RUBY_DATA_FUNC);
|
||||
VALUE rb_data_typed_object_alloc(VALUE klass, void *datap, const rb_data_type_t *);
|
||||
int rb_typed_struct_is_kind_of(VALUE, const rb_data_type_t *);
|
||||
void *rb_check_typed_struct(VALUE, const rb_data_type_t *);
|
||||
#define Check_TypedStruct(v,t) rb_check_typed_struct((VALUE)(v),t)
|
||||
#define RUBY_TYPED_DEFAULT_FREE ((void (*)(void *))-1)
|
||||
|
||||
#define Data_Wrap_Struct(klass,mark,free,sval)\
|
||||
rb_data_object_alloc(klass,sval,(RUBY_DATA_FUNC)mark,(RUBY_DATA_FUNC)free)
|
||||
|
|
Загрузка…
Ссылка в новой задаче