Skip to content

Commit

Permalink
Ruby 1.9.3 Support
Browse files Browse the repository at this point in the history
Reference: banister#26

Ruby 1.9.3 does not support `rb_obj_reveal` so ifdef conditionals were added to allow the gem to be compiled.
  • Loading branch information
Franklin Webber committed Aug 28, 2014
1 parent 22ff506 commit 31bbe18
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
11 changes: 9 additions & 2 deletions ext/texplay/bindings.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <ruby.h>
#include <ruby/version.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
Expand Down Expand Up @@ -307,8 +308,14 @@ m_clone_image(VALUE self)

cloned_image = m_dup_image(self);

/* the main diff b/w clone and dup is that clone also dups the singleton */
rb_obj_reveal(cloned_image, rb_singleton_class_clone(self));
#if RUBY_API_VERSION_MAJOR >=2 && RUBY_API_VERSION_MINOR >= 1
/* the main diff b/w clone and dup is that clone also dups the singleton */
rb_obj_reveal(cloned_image, rb_singleton_class_clone(self));
#else
KLASS_OF(cloned_image) = rb_singleton_class_clone(self);
#endif



return cloned_image;
}
Expand Down
5 changes: 5 additions & 0 deletions ext/texplay/compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#define GUARD_COMPAT_H

#include <ruby.h>
#include <ruby/version.h>

/* macros for backwards compatibility with 1.8 */
#ifndef RCLASS_M_TBL
Expand All @@ -18,4 +19,8 @@
# define RCLASS_IV_TBL(c) (RCLASS(c)->iv_tbl)
#endif

#if RUBY_API_VERSION_MAJOR <= 2 && RUBY_API_VERSION_MINOR < 1
#define KLASS_OF(c) (RBASIC(c)->klass)
#endif

#endif

0 comments on commit 31bbe18

Please sign in to comment.