real_include 0.2.1-i386-mingw32 → 0.2.2-i386-mingw32
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.
- data/CHANGELOG +5 -1
- data/ext/real_include/compat.h +34 -0
- data/ext/real_include/extconf.rb +0 -3
- data/ext/real_include/patched_include.c +1 -22
- data/ext/real_include/real_include_one.c +1 -23
- data/lib/1.8/real_include.so +0 -0
- data/lib/1.9/real_include.so +0 -0
- data/lib/real_include.rb +0 -1
- data/lib/real_include/version.rb +1 -1
- data/test/test.rb +28 -0
- metadata +3 -3
data/CHANGELOG
CHANGED
@@ -1,5 +1,9 @@
|
|
1
|
-
|
1
|
+
22/10/2010 version 0.2.2
|
2
|
+
* refactored compat.h, incorporated test for 1.9
|
3
|
+
* created inline static function create_class() in compat.h
|
4
|
+
20/10/2010 version 0.2.1
|
2
5
|
* constant lookup should now work
|
6
|
+
* added real_extend and tests
|
3
7
|
15/10/2010 version 0.1.7
|
4
8
|
* should be properly working with normal Module#include now
|
5
9
|
* no more segfaults?
|
data/ext/real_include/compat.h
CHANGED
@@ -5,6 +5,11 @@
|
|
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)
|
@@ -14,6 +19,35 @@
|
|
14
19
|
# include "st.h"
|
15
20
|
#endif
|
16
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
|
+
}
|
36
|
+
#endif
|
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
|
+
|
17
51
|
# define FALSE 0
|
18
52
|
# define TRUE 1
|
19
53
|
|
data/ext/real_include/extconf.rb
CHANGED
@@ -4,32 +4,11 @@
|
|
4
4
|
#include <ruby.h>
|
5
5
|
#include "compat.h"
|
6
6
|
|
7
|
-
#ifdef RUBY_19
|
8
|
-
static VALUE
|
9
|
-
class_alloc(VALUE flags, VALUE klass)
|
10
|
-
{
|
11
|
-
rb_classext_t *ext = ALLOC(rb_classext_t);
|
12
|
-
NEWOBJ(obj, struct RClass);
|
13
|
-
OBJSETUP(obj, klass, flags);
|
14
|
-
obj->ptr = ext;
|
15
|
-
RCLASS_IV_TBL(obj) = 0;
|
16
|
-
RCLASS_M_TBL(obj) = 0;
|
17
|
-
RCLASS_SUPER(obj) = 0;
|
18
|
-
RCLASS_IV_INDEX_TBL(obj) = 0;
|
19
|
-
return (VALUE)obj;
|
20
|
-
}
|
21
|
-
#endif
|
22
|
-
|
23
7
|
/* patched to work well with real_include */
|
24
8
|
static VALUE
|
25
9
|
include_class_new(VALUE module, VALUE super)
|
26
10
|
{
|
27
|
-
|
28
|
-
VALUE klass = class_alloc(T_ICLASS, rb_cClass);
|
29
|
-
#else
|
30
|
-
NEWOBJ(klass, struct RClass);
|
31
|
-
OBJSETUP(klass, rb_singleton_class(rb_cModule), T_ICLASS);
|
32
|
-
#endif
|
11
|
+
VALUE klass = create_class(T_ICLASS, rb_cClass);
|
33
12
|
|
34
13
|
if (BUILTIN_TYPE(module) == T_ICLASS) {
|
35
14
|
|
@@ -6,23 +6,6 @@
|
|
6
6
|
#include <ruby.h>
|
7
7
|
#include "compat.h"
|
8
8
|
|
9
|
-
#ifdef RUBY_19
|
10
|
-
static VALUE
|
11
|
-
class_alloc(VALUE flags, VALUE klass)
|
12
|
-
{
|
13
|
-
rb_classext_t *ext = ALLOC(rb_classext_t);
|
14
|
-
NEWOBJ(obj, struct RClass);
|
15
|
-
OBJSETUP(obj, klass, flags);
|
16
|
-
obj->ptr = ext;
|
17
|
-
RCLASS_IV_TBL(obj) = 0;
|
18
|
-
RCLASS_M_TBL(obj) = 0;
|
19
|
-
RCLASS_SUPER(obj) = 0;
|
20
|
-
RCLASS_IV_INDEX_TBL(obj) = 0;
|
21
|
-
return (VALUE)obj;
|
22
|
-
}
|
23
|
-
#endif
|
24
|
-
|
25
|
-
|
26
9
|
static VALUE
|
27
10
|
class_to_s(VALUE self)
|
28
11
|
{
|
@@ -54,12 +37,7 @@ include_class_new(VALUE module, VALUE super)
|
|
54
37
|
}
|
55
38
|
|
56
39
|
/* allocate iclass */
|
57
|
-
|
58
|
-
VALUE klass = class_alloc(T_ICLASS, rb_singleton_class(rb_cModule));
|
59
|
-
#else
|
60
|
-
NEWOBJ(klass, struct RClass);
|
61
|
-
OBJSETUP(klass, rb_singleton_class(rb_cModule), T_ICLASS);
|
62
|
-
#endif
|
40
|
+
VALUE klass = create_class(T_ICLASS, rb_singleton_class(rb_cModule));
|
63
41
|
|
64
42
|
/* if the module hasn't yet got an ivtbl, create it */
|
65
43
|
if (!RCLASS_IV_TBL(module))
|
data/lib/1.8/real_include.so
CHANGED
Binary file
|
data/lib/1.9/real_include.so
CHANGED
Binary file
|
data/lib/real_include.rb
CHANGED
data/lib/real_include/version.rb
CHANGED
data/test/test.rb
CHANGED
@@ -35,6 +35,34 @@ describe 'Including a module into a class using real_include' do
|
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
|
+
describe 'Extending a module into a class using real_extend' do
|
39
|
+
before do
|
40
|
+
@m = Module.new {
|
41
|
+
def self.class_method
|
42
|
+
:class_method
|
43
|
+
end
|
44
|
+
|
45
|
+
def instance_method
|
46
|
+
:instance_method
|
47
|
+
end
|
48
|
+
}
|
49
|
+
|
50
|
+
@m::CONST = :const
|
51
|
+
|
52
|
+
@c = Class.new
|
53
|
+
|
54
|
+
@c.send(:real_extend, @m)
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'should make instance methods from the module available as class methods on the class' do
|
58
|
+
@c.instance_method.should.equal :instance_method
|
59
|
+
end
|
60
|
+
|
61
|
+
it 'should make class methods from the module available as class methods on the singleton class' do
|
62
|
+
class << @c; self; end.class_method.should.equal :class_method
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
38
66
|
|
39
67
|
describe 'Including a module into a module and then into a class using real_include' do
|
40
68
|
before do
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 2
|
8
|
-
-
|
9
|
-
version: 0.2.
|
8
|
+
- 2
|
9
|
+
version: 0.2.2
|
10
10
|
platform: i386-mingw32
|
11
11
|
authors:
|
12
12
|
- John Mair (banisterfiend)
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-10-
|
17
|
+
date: 2010-10-22 00:00:00 +13:00
|
18
18
|
default_executable:
|
19
19
|
dependencies: []
|
20
20
|
|