utilrb 1.6.6 → 2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. data/Manifest.txt +10 -9
  2. data/README.rd +23 -0
  3. data/Rakefile +40 -37
  4. data/ext/utilrb/extconf.rb +36 -0
  5. data/ext/{proc.cc → utilrb/proc.c} +7 -6
  6. data/ext/utilrb/ruby_allocator.hh +76 -0
  7. data/ext/{ruby_internals-1.8.h → utilrb/ruby_internals-1.8.h} +0 -0
  8. data/ext/{ruby_internals-1.9.h → utilrb/ruby_internals-1.9.h} +0 -0
  9. data/ext/{swap.cc → utilrb/swap.cc} +0 -0
  10. data/ext/utilrb/utilrb.cc +79 -0
  11. data/ext/{value_set.cc → utilrb/value_set.cc} +5 -5
  12. data/ext/{weakref.cc → utilrb/weakref.cc} +0 -0
  13. data/lib/utilrb/common.rb +7 -2
  14. data/lib/utilrb/doc/rake.rb +46 -15
  15. data/lib/utilrb/kernel/load_dsl_file.rb +2 -2
  16. data/lib/utilrb/kernel/options.rb +6 -0
  17. data/lib/utilrb/logger/forward.rb +7 -0
  18. data/lib/utilrb/logger/hierarchy.rb +100 -42
  19. data/lib/utilrb/logger/indent.rb +38 -3
  20. data/lib/utilrb/logger/log_pp.rb +1 -1
  21. data/lib/utilrb/logger/root.rb +27 -12
  22. data/lib/utilrb/module/inherited_enumerable.rb +2 -196
  23. data/lib/utilrb/objectstats.rb +4 -1
  24. data/lib/utilrb/pkgconfig.rb +42 -6
  25. data/lib/utilrb/rake_common.rb +12 -0
  26. data/lib/utilrb/ruby_object_graph.rb +195 -46
  27. data/lib/utilrb/yard.rb +89 -89
  28. data/test/test_array.rb +1 -1
  29. data/test/test_dir.rb +1 -1
  30. data/test/test_enumerable.rb +7 -1
  31. data/test/test_event_loop.rb +407 -0
  32. data/test/test_exception.rb +1 -1
  33. data/test/test_gc.rb +1 -1
  34. data/test/test_hash.rb +57 -1
  35. data/test/test_kernel.rb +52 -21
  36. data/test/test_logger.rb +150 -1
  37. data/test/test_misc.rb +1 -1
  38. data/test/test_models.rb +212 -0
  39. data/test/test_module.rb +41 -71
  40. data/test/test_object.rb +1 -1
  41. data/test/test_objectstats.rb +1 -1
  42. data/test/test_pkgconfig.rb +7 -5
  43. data/test/test_proc.rb +1 -1
  44. data/test/test_set.rb +1 -1
  45. data/test/test_thread_pool.rb +409 -0
  46. data/test/test_time.rb +6 -6
  47. data/test/test_unbound_method.rb +1 -1
  48. metadata +157 -131
  49. data/README.txt +0 -45
  50. data/ext/extconf.rb +0 -29
  51. data/ext/utilrb_ext.cc +0 -144
data/ext/utilrb_ext.cc DELETED
@@ -1,144 +0,0 @@
1
- #include <ruby.h>
2
- #include <set>
3
-
4
- #ifndef RUBINIUS
5
- #ifdef RUBY_IS_19
6
- #include "ruby_internals-1.9.h"
7
- #else
8
- #include "ruby_internals-1.8.h"
9
- #endif
10
- #endif
11
-
12
- static VALUE mUtilrb;
13
-
14
- using namespace std;
15
-
16
- #ifndef RUBINIUS
17
- static VALUE enumerable_each_uniq_i(VALUE i, VALUE* memo)
18
- {
19
- set<VALUE>& seen = *reinterpret_cast< set<VALUE>* >(memo);
20
- if (seen.find(i) == seen.end())
21
- {
22
- seen.insert(i);
23
- return rb_yield(i);
24
- }
25
- else
26
- return Qnil;
27
-
28
- }
29
-
30
- /* :nodoc: */
31
- static VALUE enumerable_each_uniq(VALUE self)
32
- {
33
- set<VALUE> seen;
34
- rb_iterate(rb_each, self,
35
- RUBY_METHOD_FUNC(enumerable_each_uniq_i), (VALUE)&seen);
36
- return self;
37
- }
38
-
39
- /* call-seq:
40
- * Kernel.is_singleton?(object)
41
- *
42
- * Returns true if +self+ is a singleton class
43
- */
44
- static VALUE kernel_is_singleton_p(VALUE self)
45
- {
46
- if (BUILTIN_TYPE(self) == T_CLASS && FL_TEST(self, FL_SINGLETON))
47
- return Qtrue;
48
- else
49
- return Qfalse;
50
- }
51
-
52
- #ifndef RUBY_IS_19
53
-
54
- /* call-seq:
55
- * proc.same_body?(other) => true or false
56
- *
57
- * Returns true if +self+ and +other+ have the same body
58
- */
59
- static VALUE proc_same_body_p(VALUE self, VALUE other)
60
- {
61
- if (self == other) return Qtrue;
62
- if (TYPE(other) != T_DATA) return Qfalse;
63
- if (RDATA(other)->dmark != RDATA(self)->dmark) return Qfalse;
64
- if (CLASS_OF(self) != CLASS_OF(other)) return Qfalse;
65
-
66
- struct BLOCK* data, *data2;
67
- Data_Get_Struct(self, struct BLOCK, data);
68
- Data_Get_Struct(other, struct BLOCK, data2);
69
- return (data->body == data2->body) ? Qtrue : Qfalse;
70
- }
71
-
72
- /* call-seq:
73
- * proc.file
74
- *
75
- * Returns the file in which the proc body is defined, or nil
76
- */
77
- static VALUE proc_file(VALUE self)
78
- {
79
- struct BLOCK *data;
80
- NODE *node;
81
-
82
- Data_Get_Struct(self, struct BLOCK, data);
83
- if ((node = data->frame.node) || (node = data->body))
84
- return rb_str_new2(node->nd_file);
85
- else
86
- return Qnil;
87
- }
88
-
89
- /* call-seq:
90
- * proc.line
91
- *
92
- * Returns the line at which the proc body is defined, or nil
93
- */
94
- static VALUE proc_line(VALUE self)
95
- {
96
- struct BLOCK *data;
97
- NODE *node;
98
-
99
- Data_Get_Struct(self, struct BLOCK, data);
100
- if ((node = data->frame.node) || (node = data->body))
101
- return INT2FIX(nd_line(node));
102
- else
103
- return Qnil;
104
- }
105
-
106
- #endif
107
-
108
- static VALUE kernel_is_immediate(VALUE klass, VALUE object)
109
- { return IMMEDIATE_P(object) ? Qtrue : Qfalse; }
110
- #endif
111
-
112
- static VALUE kernel_crash(VALUE klass)
113
- { *((int*)0) = 10; }
114
-
115
- extern "C" void Init_value_set();
116
- extern "C" void Init_swap();
117
- extern "C" void Init_weakref(VALUE mUtilrb);
118
- extern "C" void Init_proc();
119
-
120
- extern "C" void Init_utilrb_ext()
121
- {
122
- mUtilrb = rb_define_module("Utilrb");
123
-
124
- #ifndef RUBINIUS
125
- rb_define_method(rb_mEnumerable, "each_uniq", RUBY_METHOD_FUNC(enumerable_each_uniq), 0);
126
- rb_define_method(rb_mKernel, "is_singleton?", RUBY_METHOD_FUNC(kernel_is_singleton_p), 0);
127
- #ifndef RUBY_IS_19
128
- rb_define_method(rb_cProc, "same_body?", RUBY_METHOD_FUNC(proc_same_body_p), 1);
129
- rb_define_method(rb_cProc, "file", RUBY_METHOD_FUNC(proc_file), 0);
130
- rb_define_method(rb_cProc, "line", RUBY_METHOD_FUNC(proc_line), 0);
131
- #endif
132
-
133
- rb_define_singleton_method(rb_mKernel, "crash!", RUBY_METHOD_FUNC(kernel_crash), 0);
134
- rb_define_singleton_method(rb_mKernel, "immediate?", RUBY_METHOD_FUNC(kernel_is_immediate), 1);
135
-
136
- Init_swap();
137
- Init_weakref(mUtilrb);
138
- #endif
139
-
140
- Init_proc();
141
-
142
- Init_value_set();
143
- }
144
-