summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-05-16 12:17:14 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-05-16 12:17:14 +0000
commitecbad6dfa87b78832294e3eff7a64f5d94215f87 (patch)
treecce6b7837cd6b726be4cdf7a27487cfc5134d460
parent4eb4f1fd7e267eee38ed4d402c2cdd7f85532d6b (diff)
gc.c: rename alloc as wrap
* gc.c (rb_data_object_wrap, rb_data_typed_object_wrap): rename alloc as wrap. these functions do not allocate data pointers but just wrap the given pointers. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50506 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog6
-rw-r--r--ext/objspace/objspace.c2
-rw-r--r--gc.c10
-rw-r--r--include/ruby/ruby.h40
4 files changed, 32 insertions, 26 deletions
diff --git a/ChangeLog b/ChangeLog
index b590bdeebb..c16099c4c5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Sat May 16 21:17:11 2015 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * gc.c (rb_data_object_wrap, rb_data_typed_object_wrap): rename
+ alloc as wrap. these functions do not allocate data pointers
+ but just wrap the given pointers.
+
Sat May 16 19:59:24 2015 NAKAMURA Usaku <usa@ruby-lang.org>
* win32/win32.c (rb_w32_accept): simplified.
diff --git a/ext/objspace/objspace.c b/ext/objspace/objspace.c
index bf0d31a8e2..844beef381 100644
--- a/ext/objspace/objspace.c
+++ b/ext/objspace/objspace.c
@@ -600,7 +600,7 @@ static VALUE rb_mInternalObjectWrapper;
static VALUE
iow_newobj(VALUE obj)
{
- return rb_data_typed_object_alloc(rb_mInternalObjectWrapper, (void *)obj, &iow_data_type);
+ return TypedData_Wrap_Struct(rb_mInternalObjectWrapper, &iow_data_type, (void *)obj);
}
/* Returns the type of the internal object. */
diff --git a/gc.c b/gc.c
index 53c0ec5dd4..7f1d77c4df 100644
--- a/gc.c
+++ b/gc.c
@@ -30,7 +30,7 @@
#include <sys/types.h>
#include <assert.h>
-#undef rb_data_object_alloc
+#undef rb_data_object_wrap
#ifndef __has_feature
# define __has_feature(x) 0
@@ -1806,7 +1806,7 @@ rb_imemo_new_debug(enum imemo_type type, VALUE v1, VALUE v2, VALUE v3, VALUE v0,
#endif
VALUE
-rb_data_object_alloc(VALUE klass, void *datap, RUBY_DATA_FUNC dmark, RUBY_DATA_FUNC dfree)
+rb_data_object_wrap(VALUE klass, void *datap, RUBY_DATA_FUNC dmark, RUBY_DATA_FUNC dfree)
{
if (klass) Check_Type(klass, T_CLASS);
return newobj_of(klass, T_DATA, (VALUE)dmark, (VALUE)dfree, (VALUE)datap);
@@ -1815,13 +1815,13 @@ rb_data_object_alloc(VALUE klass, void *datap, RUBY_DATA_FUNC dmark, RUBY_DATA_F
VALUE
rb_data_object_zalloc(VALUE klass, size_t size, RUBY_DATA_FUNC dmark, RUBY_DATA_FUNC dfree)
{
- VALUE obj = rb_data_object_alloc(klass, 0, dmark, dfree);
+ VALUE obj = rb_data_object_wrap(klass, 0, dmark, dfree);
DATA_PTR(obj) = xcalloc(1, size);
return obj;
}
VALUE
-rb_data_typed_object_alloc(VALUE klass, void *datap, const rb_data_type_t *type)
+rb_data_typed_object_wrap(VALUE klass, void *datap, const rb_data_type_t *type)
{
if (klass) Check_Type(klass, T_CLASS);
return newobj_of(klass, T_DATA | (type->flags & ~T_MASK), (VALUE)type, (VALUE)1, (VALUE)datap);
@@ -1830,7 +1830,7 @@ rb_data_typed_object_alloc(VALUE klass, void *datap, const rb_data_type_t *type)
VALUE
rb_data_typed_object_zalloc(VALUE klass, size_t size, const rb_data_type_t *type)
{
- VALUE obj = rb_data_typed_object_alloc(klass, 0, type);
+ VALUE obj = rb_data_typed_object_wrap(klass, 0, type);
DATA_PTR(obj) = xcalloc(1, size);
return obj;
}
diff --git a/include/ruby/ruby.h b/include/ruby/ruby.h
index 43554df06a..99dcd6acb3 100644
--- a/include/ruby/ruby.h
+++ b/include/ruby/ruby.h
@@ -1010,9 +1010,9 @@ typedef void (*RUBY_DATA_FUNC)(void*);
# define RUBY_UNTYPED_DATA_WARNING 0
# endif
#endif
-VALUE rb_data_object_alloc(VALUE,void*,RUBY_DATA_FUNC,RUBY_DATA_FUNC);
+VALUE rb_data_object_wrap(VALUE,void*,RUBY_DATA_FUNC,RUBY_DATA_FUNC);
VALUE rb_data_object_zalloc(VALUE,size_t,RUBY_DATA_FUNC,RUBY_DATA_FUNC);
-VALUE rb_data_typed_object_alloc(VALUE klass, void *datap, const rb_data_type_t *);
+VALUE rb_data_typed_object_wrap(VALUE klass, void *datap, const rb_data_type_t *);
VALUE rb_data_typed_object_zalloc(VALUE klass, size_t size, const rb_data_type_t *type);
int rb_typeddata_inherited_p(const rb_data_type_t *child, const rb_data_type_t *parent);
int rb_typeddata_is_kind_of(VALUE, const rb_data_type_t *);
@@ -1029,7 +1029,7 @@ void *rb_check_typeddata(VALUE, const rb_data_type_t *);
#define RUBY_TYPED_PROMOTED1 FL_PROMOTED1 /* THIS FLAG DEPENDS ON Ruby version */
#define Data_Wrap_Struct(klass,mark,free,sval)\
- rb_data_object_alloc((klass),(sval),(RUBY_DATA_FUNC)(mark),(RUBY_DATA_FUNC)(free))
+ rb_data_object_wrap((klass),(sval),(RUBY_DATA_FUNC)(mark),(RUBY_DATA_FUNC)(free))
#define Data_Make_Struct0(result, klass, size, mark, free, sval) \
VALUE result = rb_data_object_zalloc(klass, size, mark, free); \
@@ -1042,12 +1042,12 @@ void *rb_check_typeddata(VALUE, const rb_data_type_t *);
})
#else
#define Data_Make_Struct(klass,type,mark,free,sval) (\
- rb_data_struct_make((klass),(RUBY_DATA_FUNC)(mark),(RUBY_DATA_FUNC)(free),(void **)&(sval),sizeof(type)) \
+ rb_data_object_make((klass),(RUBY_DATA_FUNC)(mark),(RUBY_DATA_FUNC)(free),(void **)&(sval),sizeof(type)) \
)
#endif
#define TypedData_Wrap_Struct(klass,data_type,sval)\
- rb_data_typed_object_alloc((klass),(sval),(data_type))
+ rb_data_typed_object_wrap((klass),(sval),(data_type))
#define TypedData_Make_Struct0(result, klass, size, data_type, sval) \
VALUE result = rb_data_typed_object_zalloc(klass, size, data_type); \
@@ -1060,7 +1060,7 @@ void *rb_check_typeddata(VALUE, const rb_data_type_t *);
})
#else
#define TypedData_Make_Struct(klass, type, data_type, sval) (\
- rb_data_typed_struct_make((klass),(data_type),(void **)&(sval),sizeof(type)) \
+ rb_data_typed_object_make((klass),(data_type),(void **)&(sval),sizeof(type)) \
)
#endif
@@ -1192,23 +1192,23 @@ rb_obj_freeze_inline(VALUE x)
#endif
#if defined(HAVE_BUILTIN___BUILTIN_CHOOSE_EXPR_CONSTANT_P)
-RUBY_UNTYPED_DATA_FUNC(static inline VALUE rb_data_object_alloc_warning(VALUE,void*,RUBY_DATA_FUNC,RUBY_DATA_FUNC));
+RUBY_UNTYPED_DATA_FUNC(static inline VALUE rb_data_object_wrap_warning(VALUE,void*,RUBY_DATA_FUNC,RUBY_DATA_FUNC));
#endif
RUBY_UNTYPED_DATA_FUNC(static inline void *rb_data_object_get_warning(VALUE));
static inline VALUE
-rb_data_object_alloc_warning(VALUE klass, void *ptr, RUBY_DATA_FUNC mark, RUBY_DATA_FUNC free)
+rb_data_object_wrap_warning(VALUE klass, void *ptr, RUBY_DATA_FUNC mark, RUBY_DATA_FUNC free)
{
- return rb_data_object_alloc(klass, ptr, mark, free);
+ return rb_data_object_wrap(klass, ptr, mark, free);
}
#if defined(HAVE_BUILTIN___BUILTIN_CHOOSE_EXPR_CONSTANT_P)
-#define rb_data_object_alloc_warning(klass, ptr, mark, free) \
+#define rb_data_object_wrap_warning(klass, ptr, mark, free) \
__extension__( \
__builtin_choose_expr( \
__builtin_constant_p(klass) && !(klass), \
- rb_data_object_alloc(klass, ptr, mark, free), \
- rb_data_object_alloc_warning(klass, ptr, mark, free)))
+ rb_data_object_wrap(klass, ptr, mark, free), \
+ rb_data_object_wrap_warning(klass, ptr, mark, free)))
#endif
static inline void *
@@ -1225,28 +1225,28 @@ rb_data_object_get_warning(VALUE obj)
}
static inline VALUE
-rb_data_struct_make(VALUE klass, RUBY_DATA_FUNC mark_func, RUBY_DATA_FUNC free_func, void **datap, size_t size)
+rb_data_object_make(VALUE klass, RUBY_DATA_FUNC mark_func, RUBY_DATA_FUNC free_func, void **datap, size_t size)
{
Data_Make_Struct0(result, klass, size, mark_func, free_func, *datap);
return result;
}
static inline VALUE
-rb_data_typed_struct_make(VALUE klass, const rb_data_type_t *type, void **datap, size_t size)
+rb_data_typed_object_make(VALUE klass, const rb_data_type_t *type, void **datap, size_t size)
{
TypedData_Make_Struct0(result, klass, size, type, *datap);
return result;
}
-#define rb_data_object_alloc_0 rb_data_object_alloc
-#define rb_data_object_alloc_1 rb_data_object_alloc_warning
-#define rb_data_object_alloc RUBY_MACRO_SELECT(rb_data_object_alloc_, RUBY_UNTYPED_DATA_WARNING)
+#define rb_data_object_wrap_0 rb_data_object_wrap
+#define rb_data_object_wrap_1 rb_data_object_wrap_warning
+#define rb_data_object_wrap RUBY_MACRO_SELECT(rb_data_object_wrap_, RUBY_UNTYPED_DATA_WARNING)
#define rb_data_object_get_0 rb_data_object_get
#define rb_data_object_get_1 rb_data_object_get_warning
#define rb_data_object_get RUBY_MACRO_SELECT(rb_data_object_get_, RUBY_UNTYPED_DATA_WARNING)
-#define rb_data_struct_make_0 rb_data_struct_make
-#define rb_data_struct_make_1 rb_data_struct_make_warning
-#define rb_data_struct_make RUBY_MACRO_SELECT(rb_data_struct_make_, RUBY_UNTYPED_DATA_WARNING)
+#define rb_data_object_make_0 rb_data_object_make
+#define rb_data_object_make_1 rb_data_object_make_warning
+#define rb_data_object_make RUBY_MACRO_SELECT(rb_data_object_make_, RUBY_UNTYPED_DATA_WARNING)
#if USE_RGENGC
#define OBJ_PROMOTED_RAW(x) ((RBASIC(x)->flags & (FL_PROMOTED0|FL_PROMOTED1)) == (FL_PROMOTED0|FL_PROMOTED1))