From 66a5374e724612cd16f270f43102a6ed347208d7 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sat, 25 Dec 2010 00:58:03 -0800 Subject: add support for Rubinius RSTRUCT_PTR access is unlikely to ever happen for Rubinius, so we'll just make a method dispatch and leave the faster code for Ruby 1.8 and 1.9. --- ext/clogger_ext/clogger.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'ext/clogger_ext/clogger.c') diff --git a/ext/clogger_ext/clogger.c b/ext/clogger_ext/clogger.c index bc61f2a..4c3d93a 100644 --- a/ext/clogger_ext/clogger.c +++ b/ext/clogger_ext/clogger.c @@ -818,9 +818,17 @@ static VALUE clogger_init_copy(VALUE clone, VALUE orig) #define CONST_GLOBAL_STR(val) CONST_GLOBAL_STR2(val, #val) +#ifdef RSTRUCT_PTR +# define ToPath_clogger(tp) RSTRUCT_PTR(tp)[0] +#else +static ID clogger_id; +# define ToPath_clogger(tp) rb_funcall(tp,clogger_id,0) +#endif + static VALUE to_path(VALUE self) { - struct clogger *c = clogger_get(RSTRUCT_PTR(self)[0]); + VALUE my_clogger = ToPath_clogger(self); + struct clogger *c = clogger_get(my_clogger); VALUE path = rb_funcall(c->body, to_path_id, 0); struct stat sb; int rv; @@ -897,4 +905,7 @@ void Init_clogger_ext(void) cHeaderHash = rb_const_get(tmp, rb_intern("HeaderHash")); cToPath = rb_const_get(cClogger, rb_intern("ToPath")); rb_define_method(cToPath, "to_path", to_path, 0); +#ifndef RSTRUCT_PTR + clogger_id = rb_intern("clogger"); +#endif } -- cgit v1.2.3-24-ge0c7