mult 0.1.4-i386-mingw32 → 0.2.0-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/README.rdoc +4 -1
- data/Rakefile +4 -4
- data/ext/mult/compat.h +6 -10
- data/ext/mult/mult.c +82 -25
- data/lib/1.8/mult.so +0 -0
- data/lib/1.9/mult.so +0 -0
- data/lib/mult/version.rb +1 -1
- metadata +6 -6
data/README.rdoc
CHANGED
data/Rakefile
CHANGED
@@ -21,11 +21,11 @@ spec = Gem::Specification.new do |s|
|
|
21
21
|
s.require_path = 'lib'
|
22
22
|
s.homepage = "http://banisterfiend.wordpress.com"
|
23
23
|
s.platform = 'i386-mingw32'
|
24
|
-
|
25
|
-
#
|
24
|
+
#s.platform = Gem::Platform::RUBY
|
25
|
+
#s.extensions = FileList["ext/**/extconf.rb"]
|
26
26
|
s.has_rdoc = 'yard'
|
27
|
-
s.files = ["Rakefile", "README.rdoc", "LICENSE", "lib/mult.rb", "lib/
|
28
|
-
|
27
|
+
s.files = ["Rakefile", "README.rdoc", "LICENSE", "lib/mult.rb", "lib/mult/version.rb"] +
|
28
|
+
["lib/1.8/mult.#{dlext}", "lib/1.9/mult.#{dlext}"] +
|
29
29
|
FileList["ext/**/extconf.rb", "ext/**/*.h", "ext/**/*.c"].to_a
|
30
30
|
end
|
31
31
|
|
data/ext/mult/compat.h
CHANGED
@@ -5,22 +5,18 @@
|
|
5
5
|
|
6
6
|
#include <ruby.h>
|
7
7
|
|
8
|
-
/* this is the test we use to identify ruby 1.9.1 */
|
9
|
-
|
10
|
-
/* commenting out this test because it doesn't seem to work in 1.8.7 */
|
11
|
-
/*
|
12
|
-
#ifdef RCLASS_M_TBL
|
13
|
-
# define RUBY_19
|
14
|
-
#endif
|
15
|
-
*/
|
16
|
-
|
17
8
|
/* macros for backwards compatibility with 1.8 */
|
18
|
-
#ifndef
|
9
|
+
#ifndef RUBY_19
|
19
10
|
# define RCLASS_M_TBL(c) (RCLASS(c)->m_tbl)
|
20
11
|
# define RCLASS_SUPER(c) (RCLASS(c)->super)
|
21
12
|
# define RCLASS_IV_TBL(c) (RCLASS(c)->iv_tbl)
|
13
|
+
# define OBJ_UNTRUSTED OBJ_TAINTED
|
14
|
+
# include "st.h"
|
22
15
|
#endif
|
23
16
|
|
17
|
+
# define FALSE 0
|
18
|
+
# define TRUE 1
|
19
|
+
|
24
20
|
/* a useful macro. cannot use ordinary CLASS_OF as it does not return an lvalue */
|
25
21
|
#define KLASS_OF(c) (RBASIC(c)->klass)
|
26
22
|
|
data/ext/mult/mult.c
CHANGED
@@ -1,17 +1,23 @@
|
|
1
1
|
#include <ruby.h>
|
2
2
|
#include "compat.h"
|
3
3
|
|
4
|
+
static VALUE cRubyTable;
|
5
|
+
|
6
|
+
typedef struct {
|
7
|
+
st_table* table;
|
8
|
+
} RubyTable;
|
9
|
+
|
4
10
|
/* return the actual class of an object */
|
5
11
|
static VALUE
|
6
12
|
get_class(VALUE self) {
|
7
|
-
|
13
|
+
return CLASS_OF(self);
|
8
14
|
}
|
9
15
|
|
10
16
|
/* set the class of an object */
|
11
17
|
static VALUE
|
12
18
|
set_class(VALUE self, VALUE klass) {
|
13
|
-
|
14
|
-
|
19
|
+
KLASS_OF(self) = klass;
|
20
|
+
return klass;
|
15
21
|
}
|
16
22
|
|
17
23
|
|
@@ -19,54 +25,105 @@ set_class(VALUE self, VALUE klass) {
|
|
19
25
|
static VALUE
|
20
26
|
get_super(VALUE self)
|
21
27
|
{
|
22
|
-
|
28
|
+
return RCLASS_SUPER(self);
|
23
29
|
}
|
24
30
|
|
25
31
|
/* set the super class of an object */
|
26
32
|
static VALUE
|
27
33
|
set_super(VALUE self, VALUE klass) {
|
28
|
-
|
29
|
-
|
34
|
+
RCLASS_SUPER(self) = klass;
|
35
|
+
return klass;
|
30
36
|
}
|
31
37
|
|
32
38
|
/* is the object a singleton class ? */
|
33
39
|
static VALUE
|
34
40
|
is_singleton(VALUE self, VALUE klass) {
|
35
|
-
|
41
|
+
return FL_TEST(self, FL_SINGLETON) ? Qtrue : Qfalse;
|
42
|
+
}
|
43
|
+
|
44
|
+
/* get a raw instance var */
|
45
|
+
static VALUE
|
46
|
+
get_ivar(VALUE self, VALUE sym)
|
47
|
+
{
|
48
|
+
return rb_ivar_get(self, rb_to_id(sym));
|
49
|
+
}
|
50
|
+
|
51
|
+
/* set a raw instance var */
|
52
|
+
static VALUE
|
53
|
+
set_ivar(VALUE self, VALUE sym, VALUE val)
|
54
|
+
{
|
55
|
+
return rb_ivar_set(self, rb_to_id(sym), val);
|
36
56
|
}
|
37
57
|
|
38
58
|
/* get the attached class if receiver is a singleton class */
|
39
59
|
static VALUE
|
40
60
|
get_attached(VALUE self)
|
41
61
|
{
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
62
|
+
if(FL_TEST(self, FL_SINGLETON))
|
63
|
+
return rb_iv_get(self, "__attached__");
|
64
|
+
else
|
65
|
+
return Qnil;
|
46
66
|
}
|
47
67
|
|
48
|
-
|
49
68
|
/* set the attached class if receiver is a singleton class */
|
50
69
|
static VALUE
|
51
70
|
set_attached(VALUE self, VALUE klass) {
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
71
|
+
if(FL_TEST(self, FL_SINGLETON)) {
|
72
|
+
rb_iv_set(self, "__attached__", klass);
|
73
|
+
return self;
|
74
|
+
}
|
75
|
+
else
|
76
|
+
return Qnil;
|
77
|
+
}
|
78
|
+
|
79
|
+
/* get the method table */
|
80
|
+
static VALUE
|
81
|
+
get_m_tbl(VALUE self) {
|
82
|
+
RubyTable * m_tbl_struct = ALLOC(RubyTable);
|
83
|
+
|
84
|
+
if (!RCLASS_M_TBL(self))
|
85
|
+
RCLASS_M_TBL(self) = st_init_numtable();
|
86
|
+
|
87
|
+
m_tbl_struct->table = RCLASS_M_TBL(self);
|
88
|
+
VALUE ret = Data_Wrap_Struct(cRubyTable, 0, free, m_tbl_struct);
|
89
|
+
|
90
|
+
return ret;
|
91
|
+
}
|
92
|
+
|
93
|
+
/* set the method table */
|
94
|
+
static VALUE
|
95
|
+
set_m_tbl(VALUE self, VALUE rb_m) {
|
96
|
+
Check_Type(rb_m, T_DATA);
|
97
|
+
|
98
|
+
RubyTable * m_tbl_struct;
|
99
|
+
Data_Get_Struct(rb_m, RubyTable, m_tbl_struct);
|
100
|
+
|
101
|
+
RCLASS_M_TBL(self) = m_tbl_struct->table;
|
102
|
+
|
103
|
+
rb_clear_cache();
|
104
|
+
|
105
|
+
return self;
|
58
106
|
}
|
59
107
|
|
60
108
|
void
|
61
109
|
Init_mult() {
|
62
|
-
rb_define_method(rb_cObject, "actual_class", get_class, 0);
|
63
|
-
rb_define_method(rb_cObject, "actual_class=", set_class, 1);
|
64
110
|
|
65
|
-
|
66
|
-
|
111
|
+
cRubyTable = rb_define_class("RubyTable", rb_cObject);
|
112
|
+
|
113
|
+
rb_define_method(rb_cObject, "actual_class", get_class, 0);
|
114
|
+
rb_define_method(rb_cObject, "actual_class=", set_class, 1);
|
115
|
+
|
116
|
+
rb_define_method(rb_cObject, "ivar_get", get_ivar, 1);
|
117
|
+
rb_define_method(rb_cObject, "ivar_set", set_ivar, 2);
|
118
|
+
|
119
|
+
rb_define_method(rb_cModule, "m_tbl", get_m_tbl, 0);
|
120
|
+
rb_define_method(rb_cModule, "m_tbl=", set_m_tbl, 1);
|
121
|
+
|
122
|
+
rb_define_method(rb_cModule, "actual_super", get_super, 0);
|
123
|
+
rb_define_method(rb_cModule, "actual_super=", set_super, 1);
|
67
124
|
|
68
|
-
|
125
|
+
rb_define_method(rb_cClass, "is_singleton?", is_singleton, 0);
|
69
126
|
|
70
|
-
|
71
|
-
|
127
|
+
rb_define_method(rb_cClass, "attached", get_attached, 0);
|
128
|
+
rb_define_method(rb_cClass, "attached=", set_attached, 1);
|
72
129
|
}
|
data/lib/1.8/mult.so
CHANGED
Binary file
|
data/lib/1.9/mult.so
CHANGED
Binary file
|
data/lib/mult/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mult
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 0.
|
8
|
+
- 2
|
9
|
+
- 0
|
10
|
+
version: 0.2.0
|
11
11
|
platform: i386-mingw32
|
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-
|
18
|
+
date: 2010-10-22 00:00:00 +13:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|
@@ -32,9 +32,9 @@ files:
|
|
32
32
|
- README.rdoc
|
33
33
|
- LICENSE
|
34
34
|
- lib/mult.rb
|
35
|
+
- lib/mult/version.rb
|
35
36
|
- lib/1.8/mult.so
|
36
37
|
- lib/1.9/mult.so
|
37
|
-
- lib/mult/version.rb
|
38
38
|
- ext/mult/extconf.rb
|
39
39
|
- ext/mult/compat.h
|
40
40
|
- ext/mult/mult.c
|