summaryrefslogtreecommitdiff
path: root/ext/fiddle
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-01-15 08:16:44 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-01-15 08:16:44 +0000
commita1a237fb36d4b78548d2aa94f03a6c460e50b4a7 (patch)
tree28e8856e45f2cb15563b8182e4fe3f89237563e6 /ext/fiddle
parenteb6575e137c750f7bdc5ff64ffbe0a5f12f56e7f (diff)
ext/fiddle: backward compatibilities
* ext/fiddle/function.c, ext/fiddle/pointer.c: add macros for backward compatibilities. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44614 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/fiddle')
-rw-r--r--ext/fiddle/function.c12
-rw-r--r--ext/fiddle/pointer.c11
2 files changed, 21 insertions, 2 deletions
diff --git a/ext/fiddle/function.c b/ext/fiddle/function.c
index 066602e..56f949e 100644
--- a/ext/fiddle/function.c
+++ b/ext/fiddle/function.c
@@ -1,5 +1,14 @@
#include <fiddle.h>
+#ifdef PRIsVALUE
+# define RB_OBJ_CLASSNAME(obj) rb_obj_class(obj)
+# define RB_OBJ_STRING(obj) (obj)
+#else
+# define PRIsVALUE "s"
+# define RB_OBJ_CLASSNAME(obj) rb_obj_classname(obj)
+# define RB_OBJ_STRING(obj) StringValueCStr(obj)
+#endif
+
VALUE cFiddleFunction;
static void
@@ -56,7 +65,8 @@ parse_keyword_arg_i(VALUE key, VALUE value, VALUE self)
if (key == ID2SYM(rb_intern("name"))) {
rb_iv_set(self, "@name", value);
} else {
- rb_raise(rb_eArgError, "unknown keyword: %"PRIsVALUE, key);
+ rb_raise(rb_eArgError, "unknown keyword: %"PRIsVALUE,
+ RB_OBJ_STRING(key));
}
return ST_CONTINUE;
}
diff --git a/ext/fiddle/pointer.c b/ext/fiddle/pointer.c
index 0129363..0a914dd 100644
--- a/ext/fiddle/pointer.c
+++ b/ext/fiddle/pointer.c
@@ -7,6 +7,15 @@
#include <ctype.h>
#include <fiddle.h>
+#ifdef PRIsVALUE
+# define RB_OBJ_CLASSNAME(obj) rb_obj_class(obj)
+# define RB_OBJ_STRING(obj) (obj)
+#else
+# define PRIsVALUE "s"
+# define RB_OBJ_CLASSNAME(obj) rb_obj_classname(obj)
+# define RB_OBJ_STRING(obj) StringValueCStr(obj)
+#endif
+
VALUE rb_cPointer;
typedef void (*freefunc_t)(void*);
@@ -430,7 +439,7 @@ rb_fiddle_ptr_inspect(VALUE self)
TypedData_Get_Struct(self, struct ptr_data, &fiddle_ptr_data_type, data);
return rb_sprintf("#<%"PRIsVALUE":%p ptr=%p size=%ld free=%p>",
- rb_obj_class(self), data, data->ptr, data->size, data->free);
+ RB_OBJ_CLASSNAME(self), data, data->ptr, data->size, data->free);
}
/*