texplay 0.3.5 → 0.4

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.
Files changed (73) hide show
  1. data/CHANGELOG +222 -222
  2. data/README.markdown +43 -43
  3. data/Rakefile +3 -99
  4. data/examples/common.rb +18 -18
  5. data/examples/example_alpha_blend.rb +29 -29
  6. data/examples/example_bezier.rb +41 -41
  7. data/examples/example_blank.rb +37 -37
  8. data/examples/example_cache.rb +21 -21
  9. data/examples/example_color_control.rb +69 -69
  10. data/examples/example_color_transform.rb +62 -62
  11. data/examples/example_color_transform_circle.rb +34 -34
  12. data/examples/example_darken.rb +24 -24
  13. data/examples/example_dup.rb +73 -73
  14. data/examples/example_each.rb +39 -39
  15. data/examples/example_effect.rb +34 -34
  16. data/examples/example_fill.rb +43 -43
  17. data/examples/example_fill_old.rb +48 -48
  18. data/examples/example_fluent.rb +29 -29
  19. data/examples/example_font.rb +31 -31
  20. data/examples/example_hash_arguments.rb +46 -46
  21. data/examples/example_ippa.rb +23 -23
  22. data/examples/example_light.rb +75 -75
  23. data/examples/example_light_multiply.rb +18 -18
  24. data/examples/example_lsystem.rb +61 -61
  25. data/examples/example_melt.rb +25 -25
  26. data/examples/example_meyet.rb +62 -62
  27. data/examples/example_polyline.rb +42 -42
  28. data/examples/example_scale.rb +27 -27
  29. data/examples/example_select.rb +36 -36
  30. data/examples/example_select2.rb +25 -25
  31. data/examples/example_simple.rb +46 -46
  32. data/examples/example_splice.rb +26 -26
  33. data/examples/example_sync.rb +59 -59
  34. data/examples/example_tiles.rb +41 -41
  35. data/examples/example_trace.rb +22 -22
  36. data/examples/example_transparent.rb +28 -28
  37. data/examples/example_transparent2.rb +24 -24
  38. data/examples/example_transparent3.rb +20 -20
  39. data/examples/example_turtle.rb +39 -39
  40. data/examples/example_weird.rb +22 -22
  41. data/examples/example_window_render_to_image.rb +41 -41
  42. data/examples/example_window_to_blob.rb +35 -35
  43. data/examples/media/maria.png +0 -0
  44. data/examples/media/rose.bmp +0 -0
  45. data/ext/texplay/actions.c +1006 -1006
  46. data/ext/texplay/actions.h +60 -60
  47. data/ext/texplay/bindings.c +1125 -1186
  48. data/ext/texplay/bindings.h +46 -46
  49. data/ext/texplay/cache.c +118 -118
  50. data/ext/texplay/cache.h +24 -24
  51. data/ext/texplay/compat.h +27 -27
  52. data/ext/texplay/extconf.rb +28 -28
  53. data/ext/texplay/graphics_utils.c +1313 -1313
  54. data/ext/texplay/graphics_utils.h +22 -22
  55. data/ext/texplay/texplay.c +201 -216
  56. data/ext/texplay/texplay.h +153 -153
  57. data/ext/texplay/utils.c +891 -891
  58. data/ext/texplay/utils.h +153 -153
  59. data/lib/texplay-contrib.rb +147 -164
  60. data/lib/texplay.rb +341 -356
  61. data/lib/texplay/alone.rb +20 -20
  62. data/lib/texplay/c_function_docs.rb +178 -190
  63. data/lib/texplay/live.rb +84 -84
  64. data/lib/texplay/version.rb +3 -3
  65. data/live/live.rb +85 -85
  66. data/test/image_spec.rb +45 -45
  67. data/test/texplay_spec.rb +144 -141
  68. metadata +54 -42
  69. data/examples/example_gen_eval.rb +0 -32
  70. data/ext/texplay/gen_eval.c +0 -211
  71. data/ext/texplay/gen_eval.h +0 -20
  72. data/ext/texplay/object2module.c +0 -171
  73. data/ext/texplay/object2module.h +0 -11
metadata CHANGED
@@ -1,46 +1,60 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: texplay
3
- version: !ruby/object:Gem::Version
4
- version: 0.3.5
3
+ version: !ruby/object:Gem::Version
5
4
  prerelease:
5
+ version: "0.4"
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - John Mair (banisterfiend)
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-02-22 00:00:00.000000000 +13:00
13
- default_executable:
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
12
+
13
+ date: 2011-11-08 00:00:00 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
16
  name: gosu
17
- requirement: &16942704 !ruby/object:Gem::Requirement
17
+ prerelease: false
18
+ requirement: &id001 !ruby/object:Gem::Requirement
18
19
  none: false
19
- requirements:
20
- - - ! '>='
21
- - !ruby/object:Gem::Version
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
22
23
  version: 0.7.25
23
24
  type: :runtime
25
+ version_requirements: *id001
26
+ - !ruby/object:Gem::Dependency
27
+ name: rspec
24
28
  prerelease: false
25
- version_requirements: *16942704
26
- - !ruby/object:Gem::Dependency
27
- name: bacon
28
- requirement: &16942356 !ruby/object:Gem::Requirement
29
+ requirement: &id002 !ruby/object:Gem::Requirement
29
30
  none: false
30
- requirements:
31
- - - ! '>='
32
- - !ruby/object:Gem::Version
33
- version: 1.1.0
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: 2.0.0
34
35
  type: :development
36
+ version_requirements: *id002
37
+ - !ruby/object:Gem::Dependency
38
+ name: rake-compiler
35
39
  prerelease: false
36
- version_requirements: *16942356
40
+ requirement: &id003 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ version: 0.7.9
46
+ type: :development
47
+ version_requirements: *id003
37
48
  description: TexPlay is a light-weight image manipulation framework for Ruby and Gosu
38
- email: jrmair@gmail.com
49
+ email:
50
+ - jrmair@gmail.com
39
51
  executables: []
40
- extensions:
52
+
53
+ extensions:
41
54
  - ext/texplay/extconf.rb
42
55
  extra_rdoc_files: []
43
- files:
56
+
57
+ files:
44
58
  - Rakefile
45
59
  - README.markdown
46
60
  - CHANGELOG
@@ -55,17 +69,13 @@ files:
55
69
  - ext/texplay/bindings.h
56
70
  - ext/texplay/cache.h
57
71
  - ext/texplay/compat.h
58
- - ext/texplay/gen_eval.h
59
72
  - ext/texplay/graphics_utils.h
60
- - ext/texplay/object2module.h
61
73
  - ext/texplay/texplay.h
62
74
  - ext/texplay/utils.h
63
75
  - ext/texplay/actions.c
64
76
  - ext/texplay/bindings.c
65
77
  - ext/texplay/cache.c
66
- - ext/texplay/gen_eval.c
67
78
  - ext/texplay/graphics_utils.c
68
- - ext/texplay/object2module.c
69
79
  - ext/texplay/texplay.c
70
80
  - ext/texplay/utils.c
71
81
  - examples/common.rb
@@ -84,7 +94,6 @@ files:
84
94
  - examples/example_fill_old.rb
85
95
  - examples/example_fluent.rb
86
96
  - examples/example_font.rb
87
- - examples/example_gen_eval.rb
88
97
  - examples/example_hash_arguments.rb
89
98
  - examples/example_ippa.rb
90
99
  - examples/example_light.rb
@@ -126,29 +135,32 @@ files:
126
135
  - test/texplay_spec.rb
127
136
  - live/live.rb
128
137
  - .gemtest
129
- has_rdoc: true
130
138
  homepage: http://banisterfiend.wordpress.com/2008/08/23/texplay-an-image-manipulation-tool-for-ruby-and-gosu/
131
139
  licenses: []
140
+
132
141
  post_install_message:
133
142
  rdoc_options: []
134
- require_paths:
143
+
144
+ require_paths:
135
145
  - lib
136
- required_ruby_version: !ruby/object:Gem::Requirement
146
+ required_ruby_version: !ruby/object:Gem::Requirement
137
147
  none: false
138
- requirements:
139
- - - ! '>='
140
- - !ruby/object:Gem::Version
141
- version: '0'
142
- required_rubygems_version: !ruby/object:Gem::Requirement
148
+ requirements:
149
+ - - ">="
150
+ - !ruby/object:Gem::Version
151
+ version: "0"
152
+ required_rubygems_version: !ruby/object:Gem::Requirement
143
153
  none: false
144
- requirements:
145
- - - ! '>='
146
- - !ruby/object:Gem::Version
147
- version: '0'
154
+ requirements:
155
+ - - ">="
156
+ - !ruby/object:Gem::Version
157
+ version: "0"
148
158
  requirements: []
159
+
149
160
  rubyforge_project:
150
- rubygems_version: 1.5.2
161
+ rubygems_version: 1.8.11
151
162
  signing_key:
152
163
  specification_version: 3
153
164
  summary: TexPlay is a light-weight image manipulation framework for Ruby and Gosu
154
165
  test_files: []
166
+
@@ -1,32 +0,0 @@
1
- $LOAD_PATH.unshift File.dirname(File.expand_path(__FILE__))
2
- require 'common'
3
-
4
-
5
- class W < Gosu::Window
6
- def initialize
7
- super(500, 500, false, 20)
8
- @img = Gosu::Image.new(self, "#{Common::MEDIA}/empty2.png")
9
-
10
- @width = @img.width
11
- @height = @img.height
12
-
13
- # turn alpha blending and filling on
14
- @img.set_options :alpha_blend => true, :fill => true
15
- end
16
- def draw
17
-
18
- # Gen_eval lets us use local instance vars within the block
19
- # even though the block appears to be getting instance_eval'd
20
- # for more information see gen_eval.c and object2module.c
21
- @img.paint {
22
- rect @width * rand, @height * rand, @width * rand, @height * rand,
23
- :color => [rand, rand ,rand, rand]
24
- }
25
-
26
- @img.draw 0, 0,1
27
- end
28
- end
29
-
30
- w = W.new
31
- w.show
32
-
@@ -1,211 +0,0 @@
1
- /* gen_eval.c */
2
- /* (C) John Mair 2009
3
- * This program is distributed under the terms of the MIT License
4
- * */
5
-
6
- #include <ruby.h>
7
- #include "object2module.h"
8
- #include "compat.h"
9
-
10
- VALUE
11
- retrieve_hidden_self(VALUE duped_context)
12
- {
13
- VALUE thread_id, unique_name, hidden_self;
14
-
15
- /* retrieve hidden self (if it exists) */
16
- thread_id = rb_funcall(rb_obj_id(rb_thread_current()), rb_intern("to_s"), 0);
17
- unique_name = rb_str_plus(rb_str_new2("__hidden_self__"), thread_id);
18
-
19
- hidden_self = rb_ivar_get(duped_context, rb_to_id(unique_name));
20
-
21
- return hidden_self;
22
- }
23
-
24
- void
25
- set_hidden_self(VALUE duped_context, VALUE hidden_self)
26
- {
27
- VALUE thread_id, unique_name;
28
-
29
- /* generate a unique (thread safe) name for the hidden self */
30
- thread_id = rb_funcall(rb_obj_id(rb_thread_current()), rb_intern("to_s"), 0);
31
- unique_name = rb_str_plus(rb_str_new2("__hidden_self__"), thread_id);
32
-
33
- /* store self in hidden var in duped context */
34
- rb_ivar_set(duped_context, rb_to_id(unique_name), hidden_self);
35
- }
36
-
37
- VALUE
38
- rb_capture(VALUE self) {
39
- VALUE hidden_self;
40
- VALUE result;
41
-
42
- rb_need_block();
43
-
44
- hidden_self = retrieve_hidden_self(self);
45
-
46
- /* 2 cases: (1) if rb_gen_eval is active then instance_eval wrt hidden_self
47
- (2) otherwise simply yield to the block
48
- */
49
- if(!NIL_P(hidden_self))
50
- result = rb_obj_instance_eval(0, 0, hidden_self);
51
- else
52
- result = rb_yield(Qnil);
53
-
54
- /* we want the return value of capture to be the return value of the block */
55
- return result;
56
- }
57
-
58
- /** ruby 1.9 funcs **/
59
- #ifdef RUBY_19
60
- void
61
- redirect_iv_for_object(VALUE obj, VALUE dest)
62
- {
63
- if(TYPE(obj) != T_OBJECT)
64
- rb_raise(rb_eArgError, "must provide a T_OBJECT");
65
-
66
- if (!(RBASIC(dest)->flags & ROBJECT_EMBED) && ROBJECT_IVPTR(dest)) {
67
- rb_raise(rb_eArgError, "im sorry gen_eval does not yet work with this type of ROBJECT");
68
- }
69
- if (RBASIC(obj)->flags & ROBJECT_EMBED) {
70
- rb_raise(rb_eArgError, "im sorry gen_eval does not yet work with ROBJECT_EMBED types");
71
- }
72
- else {
73
- ROBJECT(dest)->as.heap.ivptr = ROBJECT(obj)->as.heap.ivptr;
74
- ROBJECT(dest)->as.heap.numiv = ROBJECT(obj)->as.heap.numiv;
75
- ROBJECT(dest)->as.heap.iv_index_tbl = ROBJECT(obj)->as.heap.iv_index_tbl;
76
- RBASIC(dest)->flags &= ~ROBJECT_EMBED;
77
- }
78
- }
79
-
80
- void
81
- release_iv_for_object(VALUE obj)
82
- {
83
- if(TYPE(obj) != T_OBJECT)
84
- rb_raise(rb_eArgError, "must provide a T_OBJECT");
85
-
86
- ROBJECT(obj)->as.heap.ivptr = (void *) 0;
87
- ROBJECT(obj)->as.heap.numiv = 0;
88
- ROBJECT(obj)->as.heap.iv_index_tbl = (void *) 0;
89
- RBASIC(obj)->flags &= ~ROBJECT_EMBED;
90
- }
91
- #endif
92
- /** end of ruby 1.9 funcs **/
93
-
94
- VALUE
95
- rb_gen_eval(int argc, VALUE * argv, VALUE self) {
96
- VALUE duped_context;
97
- VALUE is_a_module;
98
- VALUE context;
99
- VALUE result;
100
-
101
- rb_need_block();
102
-
103
- context = rb_funcall(rb_block_proc(), rb_intern("__context__"), 0);
104
-
105
- /* using Class instead of Object (where possible) because Object's iv_tbl setup in 1.9 is weird */
106
- #ifdef RUBY_19
107
- if(TYPE(context) == T_OBJECT)
108
- duped_context = rb_funcall(rb_cObject, rb_intern("new"), 0);
109
- else
110
- duped_context = rb_funcall(rb_cClass, rb_intern("new"), 0);
111
-
112
- #else
113
-
114
- duped_context = rb_funcall(rb_cClass, rb_intern("new"), 0);
115
-
116
- #endif
117
-
118
-
119
- /* the duped_context shares the context's iv_tbl.
120
- 2 cases: (1) external iv_tbl, (2) local iv_tbl
121
-
122
- NOTE: we do not need to save original iv_tbl before replacing it, a brand new Class
123
- instance does not yet have an iv_tbl (the pointer is set to 0)
124
- */
125
- if(FL_TEST(context, FL_EXIVAR))
126
- RCLASS_IV_TBL(duped_context) = (struct st_table *) rb_generic_ivar_table(context);
127
- else {
128
- #ifdef RUBY_19
129
- if(TYPE(context) == T_OBJECT)
130
- redirect_iv_for_object(context, duped_context);
131
- else {
132
- RCLASS_IV_TBL(duped_context) = (struct st_table *) RCLASS_IV_TBL(context);
133
- }
134
- #else
135
- RCLASS_IV_TBL(duped_context) = (struct st_table *) RCLASS_IV_TBL(context);
136
- #endif
137
-
138
-
139
- }
140
-
141
- /* ensure singleton exists */
142
- rb_singleton_class(context);
143
-
144
- /* set up the class hierarchy for our dup_context */
145
- KLASS_OF(duped_context) = rb_singleton_class_clone(context);
146
-
147
- /* if no args then default to mixing in 'self' */
148
- if(argc == 0) {
149
- argc = 1;
150
- argv = &self;
151
- }
152
-
153
- /* mix the objects (or self) into the duped context */
154
- rb_gen_extend(argc, argv, duped_context);
155
-
156
- /* store self in hidden var in duped context */
157
- set_hidden_self(duped_context, self);
158
-
159
- is_a_module = rb_funcall(duped_context, rb_intern("is_a?"), 1, rb_cModule);
160
-
161
- /* eval block wrt duped_context */
162
- if(is_a_module == Qtrue)
163
- result = rb_mod_module_eval(0, 0, duped_context);
164
- else
165
- result = rb_obj_instance_eval(0, 0, duped_context);
166
-
167
- /* clean up goes below */
168
-
169
- /* release context's iv_tbl from duped_context. */
170
- #ifdef RUBY_19
171
- if(TYPE(duped_context) == T_OBJECT)
172
- release_iv_for_object(duped_context);
173
- else {
174
- RCLASS_IV_TBL(duped_context) = (struct st_table *) 0;
175
- }
176
- #else
177
- RCLASS_IV_TBL(duped_context) = (struct st_table *) 0;
178
- #endif
179
-
180
- /* delete hidden self */
181
- set_hidden_self(duped_context, Qnil);
182
-
183
- return result;
184
- }
185
-
186
- void
187
- Init_gen_eval() {
188
-
189
- rb_define_method(rb_cObject, "gen_eval", rb_gen_eval, -1);
190
- rb_define_method(rb_cObject, "capture", rb_capture, 0);
191
-
192
- rb_define_method(rb_cObject, "to_module", rb_to_module , 0);
193
- rb_define_method(rb_cObject, "reset_tbls", rb_reset_tbls , 0);
194
- rb_define_method(rb_cObject, "gen_extend", rb_gen_extend, -1);
195
- rb_define_method(rb_cModule, "gen_include", rb_gen_include, -1);
196
-
197
- /* below is much too hard to achieve in pure C */
198
- rb_eval_string("class Proc;"
199
- " def __context__;"
200
- " eval('self', self.binding);"
201
- " end;"
202
- "end;"
203
- );
204
-
205
- rb_define_alias(rb_cObject, "gen_eval_with", "gen_eval");
206
- }
207
-
208
-
209
-
210
-
211
-
@@ -1,20 +0,0 @@
1
- /* gen_eval.h */
2
-
3
- #ifndef GUARD_GEN_EVAL_H
4
- #define GUARD_GEN_EVAL_H
5
-
6
- #include <ruby.h>
7
-
8
- VALUE rb_gen_eval(int argc, VALUE * argv, VALUE self);
9
- VALUE rb_capture(VALUE self);
10
- VALUE retrieve_hidden_self(VALUE duped_context);
11
- void set_hidden_self(VALUE duped_context, VALUE hidden_self);
12
-
13
- /* change self to hidden self if __hidden_self__ defined */
14
- #define ADJUST_SELF(X) \
15
- do { \
16
- if(!NIL_P(retrieve_hidden_self((X)))) \
17
- (X) = retrieve_hidden_self((X)); \
18
- } while(0)
19
-
20
- #endif
@@ -1,171 +0,0 @@
1
- /* object2module.c */
2
- /* (C) John Mair 2009
3
- * This program is distributed under the terms of the MIT License
4
- * */
5
-
6
- #include <ruby.h>
7
- #include "compat.h"
8
-
9
- #ifdef RUBY_19
10
- # include <ruby/st.h>
11
- #else
12
- # include <st.h>
13
- #endif
14
-
15
- /* class creation. from class.c in 1.9.1 */
16
- #ifdef RUBY_19
17
- static VALUE
18
- class_alloc(VALUE flags, VALUE klass)
19
- {
20
- rb_classext_t *ext = ALLOC(rb_classext_t);
21
- NEWOBJ(obj, struct RClass);
22
- OBJSETUP(obj, klass, flags);
23
- obj->ptr = ext;
24
- RCLASS_IV_TBL(obj) = 0;
25
- RCLASS_M_TBL(obj) = 0;
26
- RCLASS_SUPER(obj) = 0;
27
- RCLASS_IV_INDEX_TBL(obj) = 0;
28
- return (VALUE)obj;
29
- }
30
- #endif
31
-
32
- /* a modified version of include_class_new from class.c */
33
- static VALUE
34
- j_class_new(VALUE module, VALUE sup)
35
- {
36
-
37
- #ifdef RUBY_19
38
- VALUE klass = class_alloc(T_ICLASS, rb_cClass);
39
- #else
40
- NEWOBJ(klass, struct RClass);
41
- OBJSETUP(klass, rb_cClass, T_ICLASS);
42
- #endif
43
-
44
- if (BUILTIN_TYPE(module) == T_ICLASS) {
45
- module = KLASS_OF(module);
46
- }
47
-
48
- if (!RCLASS_IV_TBL(module)) {
49
-
50
- RCLASS_IV_TBL(module) = (struct st_table *)st_init_numtable();
51
- }
52
-
53
- /* assign iv_tbl, m_tbl and super */
54
- RCLASS_IV_TBL(klass) = RCLASS_IV_TBL(module);
55
- RCLASS_SUPER(klass) = sup;
56
- if(TYPE(module) != T_OBJECT) {
57
-
58
- RCLASS_M_TBL(klass) = RCLASS_M_TBL(module);
59
- }
60
- else {
61
- RCLASS_M_TBL(klass) = RCLASS_M_TBL(CLASS_OF(module));
62
- }
63
-
64
- /* */
65
-
66
- if (TYPE(module) == T_ICLASS) {
67
- KLASS_OF(klass) = KLASS_OF(module);
68
- }
69
- else {
70
- KLASS_OF(klass) = module;
71
- }
72
-
73
- if(TYPE(module) != T_OBJECT) {
74
- OBJ_INFECT(klass, module);
75
- OBJ_INFECT(klass, sup);
76
- }
77
- return (VALUE)klass;
78
- }
79
-
80
- VALUE
81
- rb_to_module(VALUE self)
82
- {
83
- VALUE rclass, chain_start, jcur, klass;
84
-
85
- switch(BUILTIN_TYPE(self)) {
86
- case T_MODULE:
87
- return self;
88
- case T_CLASS:
89
- klass = self;
90
- break;
91
- case T_OBJECT:
92
- default:
93
- klass = rb_singleton_class(self);
94
- }
95
-
96
- chain_start = j_class_new(klass, rb_cObject);
97
-
98
- KLASS_OF(chain_start) = rb_cModule;
99
- RBASIC(chain_start)->flags = T_MODULE;
100
-
101
- jcur = chain_start;
102
- for(rclass = RCLASS_SUPER(klass); rclass != rb_cObject;
103
- rclass = RCLASS_SUPER(rclass)) {
104
-
105
- RCLASS_SUPER(jcur) = j_class_new(rclass, rb_cObject);
106
- jcur = RCLASS_SUPER(jcur);
107
- }
108
-
109
- RCLASS_SUPER(jcur) = (VALUE)NULL;
110
-
111
- return chain_start;
112
- }
113
-
114
- VALUE
115
- rb_reset_tbls(VALUE self)
116
- {
117
- RCLASS_IV_TBL(self) = (struct st_table *) 0;
118
- RCLASS_M_TBL(self) = (struct st_table *) st_init_numtable();
119
- return Qnil;
120
- }
121
-
122
- /* cannot simply forward to gen_include as need to invoke 'extended' hook */
123
- VALUE
124
- rb_gen_extend(int argc, VALUE * argv, VALUE self)
125
- {
126
- int i;
127
-
128
- if (argc == 0) rb_raise(rb_eArgError, "wrong number of arguments (0 for 1)");
129
-
130
- rb_singleton_class(self);
131
-
132
- for(i = 0; i < argc; i++) {
133
- VALUE mod = rb_to_module(argv[i]);
134
- rb_funcall(mod, rb_intern("extend_object"), 1, self);
135
- rb_funcall(mod, rb_intern("extended"), 1, self);
136
-
137
- /* only redirect if argv[i] is not a module */
138
- if(argv[i] != mod) rb_reset_tbls(mod);
139
- }
140
-
141
- return self;
142
- }
143
-
144
- VALUE
145
- rb_gen_include(int argc, VALUE * argv, VALUE self)
146
- {
147
- int i;
148
-
149
- if (argc == 0) rb_raise(rb_eArgError, "wrong number of arguments (0 for 1)");
150
-
151
- for(i = 0; i < argc; i++) {
152
- VALUE mod = rb_to_module(argv[i]);
153
- rb_funcall(mod, rb_intern("append_features"), 1, self);
154
- rb_funcall(mod, rb_intern("included"), 1, self);
155
-
156
- if(argv[i] != mod) rb_reset_tbls(mod);
157
- }
158
-
159
- return self;
160
- }
161
-
162
-
163
- void Init_object2module()
164
- {
165
-
166
- rb_define_method(rb_cObject, "to_module", rb_to_module , 0);
167
- rb_define_method(rb_cObject, "gen_extend", rb_gen_extend, -1);
168
- rb_define_method(rb_cModule, "gen_include", rb_gen_include, -1);
169
- rb_define_method(rb_cModule, "reset_tbls", rb_reset_tbls, 0);
170
- }
171
-