mult 0.2.0-i386-mswin32 → 0.2.2-i386-mswin32
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 +23 -3
- data/ext/mult/extconf.rb +6 -0
- data/ext/mult/mult.c +59 -21
- data/lib/1.8/mult.so +0 -0
- data/lib/1.9/mult.so +0 -0
- data/lib/mult/version.rb +1 -1
- metadata +3 -3
data/README.rdoc
CHANGED
@@ -1,6 +1,9 @@
|
|
1
|
-
|
1
|
+
Mult: utility functions for playing with Ruby Objects
|
2
|
+
======================================================
|
3
|
+
|
4
|
+
Methods:
|
5
|
+
---------
|
2
6
|
|
3
|
-
Includes:
|
4
7
|
* actual_class
|
5
8
|
* actual_class=
|
6
9
|
* actual_super
|
@@ -12,7 +15,24 @@ Includes:
|
|
12
15
|
* ivar_get
|
13
16
|
* m_tbl
|
14
17
|
* m_tbl=
|
18
|
+
* iv_tbl
|
19
|
+
* iv_tbl=
|
20
|
+
* has_flag?
|
21
|
+
* flags
|
22
|
+
* flags=
|
23
|
+
|
24
|
+
Constants:
|
25
|
+
----------
|
26
|
+
|
27
|
+
* T_CLASS
|
28
|
+
* T_MODULE
|
29
|
+
* T_OBJECT
|
30
|
+
* T_ICLASS
|
31
|
+
* T_DATA
|
32
|
+
* FL_SINGLETON
|
33
|
+
* FL_FREEZE
|
15
34
|
|
16
35
|
TO USE:
|
36
|
+
--------
|
17
37
|
|
18
|
-
gem install mult
|
38
|
+
`gem install mult`
|
data/ext/mult/extconf.rb
CHANGED
data/ext/mult/mult.c
CHANGED
@@ -20,7 +20,6 @@ set_class(VALUE self, VALUE klass) {
|
|
20
20
|
return klass;
|
21
21
|
}
|
22
22
|
|
23
|
-
|
24
23
|
/* get the actual super class of an object */
|
25
24
|
static VALUE
|
26
25
|
get_super(VALUE self)
|
@@ -76,33 +75,57 @@ set_attached(VALUE self, VALUE klass) {
|
|
76
75
|
return Qnil;
|
77
76
|
}
|
78
77
|
|
78
|
+
/* generate table get methods */
|
79
|
+
#define CREATE_GET_TBL_FUNC(func_name, table_type) \
|
80
|
+
static VALUE func_name(VALUE self) { \
|
81
|
+
RubyTable * tbl_struct = ALLOC(RubyTable); \
|
82
|
+
if (!table_type(self)) \
|
83
|
+
table_type(self) = st_init_numtable(); \
|
84
|
+
tbl_struct->table = table_type(self); \
|
85
|
+
return Data_Wrap_Struct(cRubyTable, 0, free, tbl_struct); \
|
86
|
+
}
|
87
|
+
|
88
|
+
/* generate table set methods */
|
89
|
+
#define CREATE_SET_TBL_FUNC(func_name, table_type) \
|
90
|
+
static VALUE \
|
91
|
+
func_name(VALUE self, VALUE rb_tbl) { \
|
92
|
+
Check_Type(rb_tbl, T_DATA); \
|
93
|
+
RubyTable * tbl_struct; \
|
94
|
+
Data_Get_Struct(rb_tbl, RubyTable, tbl_struct); \
|
95
|
+
table_type(self) = tbl_struct->table; \
|
96
|
+
rb_clear_cache(); \
|
97
|
+
return self; \
|
98
|
+
}
|
99
|
+
|
79
100
|
/* get the method table */
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
if (!RCLASS_M_TBL(self))
|
85
|
-
RCLASS_M_TBL(self) = st_init_numtable();
|
101
|
+
CREATE_GET_TBL_FUNC(get_m_tbl, RCLASS_M_TBL)
|
102
|
+
/* set the method table */
|
103
|
+
CREATE_SET_TBL_FUNC(set_m_tbl, RCLASS_M_TBL)
|
86
104
|
|
87
|
-
|
88
|
-
|
105
|
+
/* get the iv table */
|
106
|
+
CREATE_GET_TBL_FUNC(get_iv_tbl, RCLASS_IV_TBL)
|
107
|
+
/* set the iv table */
|
108
|
+
CREATE_SET_TBL_FUNC(set_iv_tbl, RCLASS_IV_TBL)
|
89
109
|
|
90
|
-
|
110
|
+
static VALUE
|
111
|
+
set_flags(VALUE self, VALUE flag)
|
112
|
+
{
|
113
|
+
Check_Type(flag, T_FIXNUM);
|
114
|
+
FL_SET(self, FIX2INT(flag));
|
115
|
+
return self;
|
91
116
|
}
|
92
117
|
|
93
|
-
/* set the method table */
|
94
118
|
static VALUE
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
Data_Get_Struct(rb_m, RubyTable, m_tbl_struct);
|
100
|
-
|
101
|
-
RCLASS_M_TBL(self) = m_tbl_struct->table;
|
119
|
+
get_flags(VALUE self)
|
120
|
+
{
|
121
|
+
return INT2FIX(RBASIC(self)->flags);
|
122
|
+
}
|
102
123
|
|
103
|
-
|
104
|
-
|
105
|
-
|
124
|
+
static VALUE
|
125
|
+
has_flag_p(VALUE self, VALUE flag)
|
126
|
+
{
|
127
|
+
Check_Type(flag, T_FIXNUM);
|
128
|
+
return FL_TEST(self, FIX2INT(flag)) ? Qtrue : Qfalse;
|
106
129
|
}
|
107
130
|
|
108
131
|
void
|
@@ -118,6 +141,8 @@ Init_mult() {
|
|
118
141
|
|
119
142
|
rb_define_method(rb_cModule, "m_tbl", get_m_tbl, 0);
|
120
143
|
rb_define_method(rb_cModule, "m_tbl=", set_m_tbl, 1);
|
144
|
+
rb_define_method(rb_cModule, "iv_tbl", get_iv_tbl, 0);
|
145
|
+
rb_define_method(rb_cModule, "iv_tbl=", set_iv_tbl, 1);
|
121
146
|
|
122
147
|
rb_define_method(rb_cModule, "actual_super", get_super, 0);
|
123
148
|
rb_define_method(rb_cModule, "actual_super=", set_super, 1);
|
@@ -126,4 +151,17 @@ Init_mult() {
|
|
126
151
|
|
127
152
|
rb_define_method(rb_cClass, "attached", get_attached, 0);
|
128
153
|
rb_define_method(rb_cClass, "attached=", set_attached, 1);
|
154
|
+
|
155
|
+
rb_define_method(rb_cObject, "has_flag?", has_flag_p, 1);
|
156
|
+
rb_define_method(rb_cObject, "flags=", set_flags, 1);
|
157
|
+
rb_define_method(rb_cObject, "flags", get_flags, 0);
|
158
|
+
|
159
|
+
// constants
|
160
|
+
rb_define_const(rb_cObject, "T_CLASS", INT2FIX(T_CLASS));
|
161
|
+
rb_define_const(rb_cObject, "T_MODULE", INT2FIX(T_MODULE));
|
162
|
+
rb_define_const(rb_cObject, "T_OBJECT", INT2FIX(T_OBJECT));
|
163
|
+
rb_define_const(rb_cObject, "T_DATA", INT2FIX(T_DATA));
|
164
|
+
rb_define_const(rb_cObject, "T_ICLASS", INT2FIX(T_ICLASS));
|
165
|
+
rb_define_const(rb_cObject, "FL_FREEZE", INT2FIX(FL_FREEZE));
|
166
|
+
rb_define_const(rb_cObject, "FL_SINGLETON", INT2FIX(FL_SINGLETON));
|
129
167
|
}
|
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: 19
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 2
|
10
|
+
version: 0.2.2
|
11
11
|
platform: i386-mswin32
|
12
12
|
authors:
|
13
13
|
- John Mair (banisterfiend)
|