summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog7
-rw-r--r--include/ruby/ruby.h7
-rw-r--r--object.c9
3 files changed, 18 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index a84743e..f462c77 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Mon May 13 15:31:10 2013 Koichi Sasada <ko1@atdot.net>
+
+ * object.c (rb_obj_setup): added.
+
+ * include/ruby/ruby.h (OBJSETUP): ues rb_obj_setup() instead of
+ a macro.
+
Mon May 13 15:24:16 2013 Koichi Sasada <ko1@atdot.net>
* gc.c (rb_data_object_alloc): check klass only if klass is not 0.
diff --git a/include/ruby/ruby.h b/include/ruby/ruby.h
index 062e3db..1838a39 100644
--- a/include/ruby/ruby.h
+++ b/include/ruby/ruby.h
@@ -667,13 +667,10 @@ VALUE rb_int2big(SIGNED_VALUE);
VALUE rb_newobj(void);
VALUE rb_newobj_of(VALUE, VALUE);
+VALUE rb_obj_setup(VALUE obj, VALUE klass, VALUE type);
#define NEWOBJ(obj,type) type *(obj) = (type*)rb_newobj()
#define NEWOBJ_OF(obj,type,klass,flags) type *(obj) = (type*)rb_newobj_of(klass, flags)
-#define OBJSETUP(obj,c,t) do {\
- RBASIC(obj)->flags = (t);\
- RBASIC(obj)->klass = (c);\
- if (rb_safe_level() >= 3) FL_SET((obj), FL_TAINT | FL_UNTRUSTED);\
-} while (0)
+#define OBJSETUP(obj,c,t) rb_obj_setup(obj, c, t) /* use NEWOBJ_OF instead of NEWOBJ()+OBJSTUP() */
#define CLONESETUP(clone,obj) do {\
OBJSETUP((clone),rb_singleton_class_clone((VALUE)(obj)),RBASIC(obj)->flags);\
rb_singleton_class_attached(RBASIC(clone)->klass, (VALUE)(clone));\
diff --git a/object.c b/object.c
index f1ab33c..d999c8c 100644
--- a/object.c
+++ b/object.c
@@ -58,6 +58,15 @@ rb_obj_hide(VALUE obj)
return obj;
}
+VALUE
+rb_obj_setup(VALUE obj, VALUE klass, VALUE type)
+{
+ RBASIC(obj)->flags = type;
+ RBASIC(obj)->klass = klass;
+ if (rb_safe_level() >= 3) FL_SET((obj), FL_TAINT | FL_UNTRUSTED);
+ return obj;
+}
+
/*
* call-seq:
* obj === other -> true or false