git.annexia.org
/
libguestfs.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
6c5f7c9
)
ruby: Use RSTRING_PTR, RSTRING_LEN for compat with Ruby 1.9 (RHBZ#760000).
author
Richard W.M. Jones
<rjones@redhat.com>
Mon, 5 Dec 2011 10:36:13 +0000
(10:36 +0000)
committer
Richard W.M. Jones
<rjones@redhat.com>
Mon, 5 Dec 2011 10:36:13 +0000
(10:36 +0000)
generator/generator_ruby.ml
patch
|
blob
|
history
diff --git
a/generator/generator_ruby.ml
b/generator/generator_ruby.ml
index
a43b21f
..
82d0018
100644
(file)
--- 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
#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 */
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 = 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 " 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 ->
| OptString n ->
pr " const char *%s = !NIL_P (%sv) ? StringValueCStr (%sv) : NULL;\n" n n n
| StringList n | DeviceList n ->