summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard W.M. Jones <rjones@redhat.com>2011-12-05 10:36:13 +0000
committerRichard W.M. Jones <rjones@redhat.com>2011-12-05 10:36:13 +0000
commit2972987d0257d9c3d26b53f961e802d121b436cd (patch)
tree033c0227c34fa7d3a2344ffe3df9e79468c3d06c
parent6c5f7c954cfdce16d4883b7244b5bc324c417ddf (diff)
downloadlibguestfs-2972987d0257d9c3d26b53f961e802d121b436cd.tar.gz
libguestfs-2972987d0257d9c3d26b53f961e802d121b436cd.tar.xz
libguestfs-2972987d0257d9c3d26b53f961e802d121b436cd.zip
ruby: Use RSTRING_PTR, RSTRING_LEN for compat with Ruby 1.9 (RHBZ#760000).
-rw-r--r--generator/generator_ruby.ml13
1 files changed, 11 insertions, 2 deletions
diff --git a/generator/generator_ruby.ml b/generator/generator_ruby.ml
index a43b21fa..82d0018b 100644
--- a/generator/generator_ruby.ml
+++ b/generator/generator_ruby.ml
@@ -50,6 +50,15 @@ let rec generate_ruby_c () =
#define RARRAY_LEN(r) (RARRAY((r))->len)
#endif
+/* For Ruby < 1.8 */
+#ifndef RSTRING_LEN
+#define RSTRING_LEN(r) (RSTRING((r))->len)
+#endif
+
+#ifndef RSTRING_PTR
+#define RSTRING_PTR(r) (RSTRING((r))->ptr)
+#endif
+
static VALUE m_guestfs; /* guestfs module */
static VALUE c_guestfs; /* guestfs_h handle */
static VALUE e_Error; /* used for all errors */
@@ -417,11 +426,11 @@ ruby_user_cancel (VALUE gv)
pr " const char *%s = StringValueCStr (%sv);\n" n n;
| BufferIn n ->
pr " Check_Type (%sv, T_STRING);\n" n;
- pr " const char *%s = RSTRING (%sv)->ptr;\n" n n;
+ pr " const char *%s = RSTRING_PTR (%sv);\n" n n;
pr " if (!%s)\n" n;
pr " rb_raise (rb_eTypeError, \"expected string for parameter %%s of %%s\",\n";
pr " \"%s\", \"%s\");\n" n name;
- pr " size_t %s_size = RSTRING (%sv)->len;\n" n n
+ pr " size_t %s_size = RSTRING_LEN (%sv);\n" n n
| OptString n ->
pr " const char *%s = !NIL_P (%sv) ? StringValueCStr (%sv) : NULL;\n" n n n
| StringList n | DeviceList n ->