gen_eval 0.3.2 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,13 +5,52 @@
5
5
 
6
6
  #include <ruby.h>
7
7
 
8
+ /* test for 1.9 */
9
+ #if !defined(RUBY_19) && defined(ROBJECT_EMBED_LEN_MAX)
10
+ # define RUBY_19
11
+ #endif
12
+
8
13
  /* macros for backwards compatibility with 1.8 */
9
14
  #ifndef RUBY_19
10
15
  # define RCLASS_M_TBL(c) (RCLASS(c)->m_tbl)
11
16
  # define RCLASS_SUPER(c) (RCLASS(c)->super)
12
17
  # define RCLASS_IV_TBL(c) (RCLASS(c)->iv_tbl)
18
+ # define OBJ_UNTRUSTED OBJ_TAINTED
19
+ # include "st.h"
20
+ #endif
21
+
22
+ #ifdef RUBY_19
23
+ inline static VALUE
24
+ class_alloc(VALUE flags, VALUE klass)
25
+ {
26
+ rb_classext_t *ext = ALLOC(rb_classext_t);
27
+ NEWOBJ(obj, struct RClass);
28
+ OBJSETUP(obj, klass, flags);
29
+ obj->ptr = ext;
30
+ RCLASS_IV_TBL(obj) = 0;
31
+ RCLASS_M_TBL(obj) = 0;
32
+ RCLASS_SUPER(obj) = 0;
33
+ RCLASS_IV_INDEX_TBL(obj) = 0;
34
+ return (VALUE)obj;
35
+ }
13
36
  #endif
14
37
 
38
+ inline static VALUE
39
+ create_class(VALUE flags, VALUE klass)
40
+ {
41
+ #ifdef RUBY_19
42
+ VALUE new_klass = class_alloc(flags, klass);
43
+ #else
44
+ NEWOBJ(new_klass, struct RClass);
45
+ OBJSETUP(new_klass, klass, flags);
46
+ #endif
47
+
48
+ return (VALUE)new_klass;
49
+ }
50
+
51
+ # define FALSE 0
52
+ # define TRUE 1
53
+
15
54
  /* a useful macro. cannot use ordinary CLASS_OF as it does not return an lvalue */
16
55
  #define KLASS_OF(c) (RBASIC(c)->klass)
17
56
 
@@ -1,8 +1,5 @@
1
1
  require 'mkmf'
2
2
 
3
- # 1.9 compatibility
4
- $CFLAGS += " -DRUBY_19" if RUBY_VERSION =~ /1.9/
5
-
6
3
  # let's use c99
7
4
  $CFLAGS += " -std=c99"
8
5
 
@@ -114,13 +114,14 @@ rb_mirror_object(VALUE context)
114
114
  VALUE duped_context;
115
115
 
116
116
  #ifdef RUBY_19
117
- if(TYPE(context) == T_OBJECT)
117
+ if(TYPE(context) == T_OBJECT) {
118
118
  duped_context = rb_funcall(rb_cObject, rb_intern("new"), 0);
119
- else
120
- duped_context = rb_funcall(rb_cClass, rb_intern("new"), 0);
121
-
119
+ }
120
+ else {
121
+ duped_context = create_class(T_ICLASS, rb_cClass);
122
+ }
122
123
  #else
123
- duped_context = rb_funcall(rb_cClass, rb_intern("new"), 0);
124
+ duped_context = create_class(T_ICLASS, rb_cClass);
124
125
  #endif
125
126
 
126
127
  /* the duped_context shares the context's iv_tbl.
@@ -145,8 +146,6 @@ rb_mirror_object(VALUE context)
145
146
  RCLASS_M_TBL(duped_context) = (struct st_table *) RCLASS_M_TBL(context);
146
147
  RCLASS_IV_TBL(duped_context) = (struct st_table *) RCLASS_IV_TBL(context);
147
148
  #endif
148
-
149
-
150
149
  }
151
150
 
152
151
  /* ensure singleton exists */
@@ -1,3 +1,3 @@
1
1
  module GenEval
2
- VERSION = "0.3.2"
2
+ VERSION = "0.4.0"
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gen_eval
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 15
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 3
9
- - 2
10
- version: 0.3.2
8
+ - 4
9
+ - 0
10
+ version: 0.4.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - John Mair (banisterfiend)
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-10-09 00:00:00 +13:00
18
+ date: 2010-11-02 00:00:00 +13:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency