rucy 0.1.3 → 0.1.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 (50) hide show
  1. data/.doc/ext/rucy/class.cpp +244 -0
  2. data/.doc/ext/rucy/exception.cpp +99 -0
  3. data/.doc/ext/rucy/function.cpp +63 -0
  4. data/.doc/ext/rucy/struct.cpp +80 -0
  5. data/.doc/ext/rucy/tester.cpp +41 -184
  6. data/.doc/ext/rucy/value.cpp +42 -0
  7. data/.gitignore +22 -0
  8. data/Rakefile +4 -29
  9. data/VERSION +1 -1
  10. data/ext/rucy/class.cpp +262 -0
  11. data/ext/rucy/class.h +96 -0
  12. data/ext/rucy/exception.cpp +107 -0
  13. data/ext/rucy/extconf.rb +9 -8
  14. data/ext/rucy/function.cpp +68 -0
  15. data/ext/rucy/struct.cpp +83 -0
  16. data/ext/rucy/tester.cpp +41 -197
  17. data/ext/rucy/tester.h +10 -0
  18. data/ext/rucy/value.cpp +46 -0
  19. data/include/rucy/defs.h.erb +17 -0
  20. data/include/rucy/exception.h +2 -0
  21. data/include/rucy/extension.h +206 -0
  22. data/include/rucy/rucy.h +25 -2
  23. data/include/rucy/symbol.h +11 -0
  24. data/include/rucy/value.h.erb +66 -14
  25. data/include/rucy.h +1 -1
  26. data/lib/rucy/module.rb +9 -2
  27. data/rucy.gemspec +16 -40
  28. data/src/exception.cpp +17 -25
  29. data/src/rucy.cpp +2 -2
  30. data/src/symbol.cpp +24 -0
  31. data/src/value.cpp.erb +161 -25
  32. data/task/doc.rake +50 -0
  33. data/test/helpers.rb +7 -0
  34. data/test/test_class.rb +161 -0
  35. data/test/test_exception.rb +39 -0
  36. data/test/test_function.rb +31 -0
  37. data/test/test_struct.rb +30 -0
  38. data/test/test_value.rb +18 -0
  39. metadata +123 -74
  40. data/include/rucy/defs.h +0 -101
  41. data/include/rucy/function.h +0 -245
  42. data/include/rucy/gc.h +0 -59
  43. data/include/rucy/module.h +0 -98
  44. data/include/rucy/value.h +0 -291
  45. data/src/function.cpp +0 -158
  46. data/src/gc.cpp +0 -63
  47. data/src/module.cpp +0 -325
  48. data/src/value.cpp +0 -511
  49. data/task/ext.rake +0 -96
  50. data/test/test_rucy.rb +0 -73
@@ -0,0 +1,46 @@
1
+ #include <rucy.h>
2
+
3
+
4
+ using namespace Rucy;
5
+
6
+
7
+ static
8
+ RUBY_DEFN(true_to_value)
9
+ {
10
+ return value(true);
11
+ }
12
+ RUBY_END
13
+
14
+ static
15
+ RUBY_DEFN(false_to_value)
16
+ {
17
+ return value(false);
18
+ }
19
+ RUBY_END
20
+
21
+ static
22
+ RUBY_DEFN(NULL_to_value)
23
+ {
24
+ return nil();
25
+ }
26
+ RUBY_END
27
+
28
+ static
29
+ RUBY_DEFN(nil_value)
30
+ {
31
+ return nil();
32
+ }
33
+ RUBY_END
34
+
35
+
36
+ void
37
+ Init_value ()
38
+ {
39
+ Module mRucy = define_module("Rucy");
40
+ Module mTester = mRucy.define_module("Tester");
41
+
42
+ mTester.define_method("true_to_value", true_to_value);
43
+ mTester.define_method("false_to_value", false_to_value);
44
+ mTester.define_method("null_to_value", NULL_to_value);
45
+ mTester.define_method("nil_value", nil_value);
46
+ }
@@ -56,4 +56,21 @@ namespace Rucy
56
56
  #endif
57
57
 
58
58
 
59
+ #define RUCY_CHECK_OBJ(obj, type, klass) \
60
+ do \
61
+ { \
62
+ type* p = Rucy::get_type_ptr<type>(obj, klass); \
63
+ if (!p) Rucy::invalid_object_error(); \
64
+ } \
65
+ while(0)
66
+
67
+ #define RUCY_CHECK_OBJECT(obj, type, klass) \
68
+ do \
69
+ { \
70
+ type* p = Rucy::get_type_ptr<type>(obj, klass); \
71
+ if (!p || !*p) Rucy::invalid_object_error(); \
72
+ } \
73
+ while(0)
74
+
75
+
59
76
  #endif//EOH
@@ -61,6 +61,8 @@ namespace Rucy
61
61
  int n1 = -1, int n2 = -1, int n3 = -1, int n4 = -1, int n5 = -1,
62
62
  int n6 = -1, int n7 = -1, int n8 = -1, int n9 = -1, int n10 = -1);
63
63
 
64
+ void index_error (const char* format = NULL, ...);
65
+
64
66
  void not_implemented_error (const char* format = NULL, ...);
65
67
 
66
68
 
@@ -0,0 +1,206 @@
1
+ // -*- c++ -*-
2
+ #pragma once
3
+ #ifndef __RUCY_EXTENSION_H__
4
+ #define __RUCY_EXTENSION_H__
5
+
6
+
7
+ #include <boost/dynamic_bitset.hpp>
8
+ #include <xot/ref.h>
9
+ #include <rucy/module.h>
10
+
11
+
12
+ namespace Rucy
13
+ {
14
+
15
+
16
+ template <typename T>
17
+ class ClassWrapper : public T
18
+ {
19
+
20
+ typedef ClassWrapper This;
21
+
22
+ public:
23
+
24
+ typedef T Super;
25
+
26
+ GlobalValue value;
27
+
28
+ ClassWrapper ()
29
+ : value(Qnil, true)
30
+ {
31
+ }
32
+
33
+ virtual void retain ()
34
+ {
35
+ value.gc(false);
36
+ Super::retain();
37
+ }
38
+
39
+ virtual void release ()
40
+ {
41
+ Super::release();
42
+ value.gc(true);
43
+ }
44
+
45
+ virtual void clear_override_flags ()
46
+ {
47
+ override_flags.reset();
48
+ }
49
+
50
+ virtual bool is_overridden (const Value& klass, const Symbol& name, uint id) const
51
+ {
52
+ if (id <= OVERRIDE_ID_UNKNOWN)
53
+ return false;
54
+
55
+ bool checked = false, overridden = false;
56
+ get_override_flag(&checked, &overridden, id);
57
+ if (checked) return overridden;
58
+
59
+ overridden = check_overridden(klass, name);
60
+ if (!const_cast<This*>(this)->set_override_flag(id, true, overridden))
61
+ return false;
62
+
63
+ return overridden;
64
+ }
65
+
66
+ protected:
67
+
68
+ enum
69
+ {
70
+
71
+ OVERRIDE_ID_UNKNOWN = 0,
72
+
73
+ OVERRIDE_ID_LAST,
74
+
75
+ OVERRIDE_ID_MAX = 256
76
+
77
+ };
78
+
79
+ private:
80
+
81
+ boost::dynamic_bitset<> override_flags;
82
+
83
+ bool check_overridden (const Value& klass, const Symbol& name) const
84
+ {
85
+ SYM(method);
86
+ SYM(owner);
87
+ return this->value.call(method, name.value()).call(owner) != klass;
88
+ }
89
+
90
+ void get_override_flag (bool* checked, bool* overridden, uint id) const
91
+ {
92
+ assert(checked || overridden);
93
+
94
+ int checked_pos = id2index(id);
95
+ int overridden_pos = checked_pos + 1;
96
+ bool valid = 0 <= checked_pos && overridden_pos < (int) override_flags.size();
97
+ if (checked) *checked = valid ? override_flags[checked_pos] : false;
98
+ if (overridden) *overridden = valid ? override_flags[overridden_pos] : false;
99
+ }
100
+
101
+ bool set_override_flag (uint id, bool checked, bool overridden)
102
+ {
103
+ assert(id < OVERRIDE_ID_MAX);
104
+
105
+ int checked_pos = id2index(id);
106
+ if (checked_pos < 0) return true;
107
+
108
+ int overridden_pos = checked_pos + 1;
109
+ if (overridden_pos >= (int) override_flags.size())
110
+ override_flags.resize(overridden_pos + 1);
111
+
112
+ override_flags[checked_pos] = checked;
113
+ override_flags[overridden_pos] = overridden;
114
+ return true;
115
+ }
116
+
117
+ int id2index (uint id) const
118
+ {
119
+ return (id - 1) * 2;
120
+ }
121
+
122
+ };// ClassWrapper
123
+
124
+
125
+ template <typename T> inline void release_wrapper (void* p)
126
+ {
127
+ if (p) ((T*) p)->Xot::template RefCountable<>::release();
128
+ }
129
+
130
+ template <typename T> inline Value new_wrapper (
131
+ Value klass, T* ptr,
132
+ RUBY_DATA_FUNC mark = NULL,
133
+ RUBY_DATA_FUNC free = release_wrapper<T>)
134
+ {
135
+ if (ptr) ptr->Xot::template RefCountable<>::retain();
136
+ return new_type(klass, ptr, mark, free);
137
+ }
138
+
139
+ template <typename T> inline Value new_wrapper (
140
+ Value klass,
141
+ RUBY_DATA_FUNC mark = NULL,
142
+ RUBY_DATA_FUNC free = release_wrapper<T>)
143
+ {
144
+ return new_wrapper(klass, new T, mark, free);
145
+ }
146
+
147
+
148
+ }// Rucy
149
+
150
+
151
+ #define RUCY_WRAPPER_VALUE_FROM(wrapped_class, ruby_class) \
152
+ namespace Rucy \
153
+ { \
154
+ inline Value \
155
+ value (wrapped_class* obj, Value klass = ruby_class) \
156
+ { \
157
+ if (!obj) return Qnil; \
158
+ ClassWrapper<wrapped_class>* p = dynamic_cast<ClassWrapper<wrapped_class>*>(obj); \
159
+ if (!p) return new_ref(klass, obj); \
160
+ if (p->value.is_nil()) p->value = new_wrapper(klass, obj); \
161
+ return p->value; \
162
+ } \
163
+ }
164
+
165
+ #define RUCY_WRAPPER_VALUE_TO(wrapped_class, ruby_class) \
166
+ namespace Rucy \
167
+ { \
168
+ template <> inline wrapped_class* \
169
+ value_to<wrapped_class*> (Value value, bool convert) \
170
+ { \
171
+ return get_type_ptr<wrapped_class>(value, ruby_class); \
172
+ } \
173
+ }
174
+
175
+ #define RUCY_WRAPPER_VALUE_FROM_TO(wrapped_class, ruby_class) \
176
+ RUCY_WRAPPER_VALUE_FROM(wrapped_class, ruby_class) \
177
+ RUCY_WRAPPER_VALUE_TO(wrapped_class, ruby_class)
178
+
179
+
180
+ #define RUCY_WRAPPER_CALL(wrapper_class, obj, fun) \
181
+ (dynamic_cast<wrapper_class*>(obj) \
182
+ ? reinterpret_cast<wrapper_class*>(obj)->Super::fun \
183
+ : (obj)->fun)
184
+
185
+
186
+ #define RUCY_OVERRIDE_ID_START(name) enum { OID_##name = Super::OVERRIDE_ID_LAST,
187
+ #define RUCY_OVERRIDE_ID(name) OID_##name,
188
+ #define RUCY_OVERRIDE_ID_LAST OVERRIDE_ID_LAST };
189
+
190
+
191
+ #define RUCY_IS_OVERRIDDEN(name, ruby_class) \
192
+ this->is_overridden(ruby_class, name, OID_##name)
193
+
194
+ #define RUCY_OVERRIDABLE_METHOD(name, ruby_class, suffix) \
195
+ SYM(name); \
196
+ return this->value.call(name) suffix ;
197
+
198
+ #define RUCY_OVERRIDABLE_METHOD_FAST(name, ruby_class, suffix) \
199
+ SYM(name); \
200
+ if (RUCY_IS_OVERRIDDEN(name, ruby_class)) \
201
+ return this->value.call(name) suffix ; \
202
+ else \
203
+ return this->Super::name();
204
+
205
+
206
+ #endif//EOH
data/include/rucy/rucy.h CHANGED
@@ -33,7 +33,7 @@ namespace Rucy
33
33
 
34
34
  template <typename T> inline void mark_type (void* p)
35
35
  {
36
- ((T*) p)->mark();
36
+ if (p) ((T*) p)->mark();
37
37
  }
38
38
 
39
39
  template <typename T> inline void delete_type (void* p)
@@ -41,11 +41,17 @@ namespace Rucy
41
41
  delete (T*) p;
42
42
  }
43
43
 
44
+ template <typename T> inline void release_type (void* p)
45
+ {
46
+ if (p) ((T*) p)->release();
47
+ }
48
+
44
49
  template <typename T> inline Value new_type (
45
50
  Value klass, T* ptr,
46
51
  RUBY_DATA_FUNC mark = NULL,
47
52
  RUBY_DATA_FUNC free = delete_type<T>)
48
53
  {
54
+ if (!ptr) return Qnil;
49
55
  return Data_Wrap_Struct(klass, mark, free, ptr);
50
56
  }
51
57
 
@@ -57,7 +63,24 @@ namespace Rucy
57
63
  return new_type(klass, new T, mark, free);
58
64
  }
59
65
 
60
- template <typename T> inline T* get_type (Value obj, Value klass = Qnil)
66
+ template <typename T> inline Value new_ref (
67
+ Value klass, T* ptr,
68
+ RUBY_DATA_FUNC mark = NULL,
69
+ RUBY_DATA_FUNC free = release_type<T>)
70
+ {
71
+ if (ptr) ptr->retain();
72
+ return new_type(klass, ptr, mark, free);
73
+ }
74
+
75
+ template <typename T> inline Value new_ref (
76
+ Value klass,
77
+ RUBY_DATA_FUNC mark = NULL,
78
+ RUBY_DATA_FUNC free = release_type<T>)
79
+ {
80
+ return new_ref(klass, new T, mark, free);
81
+ }
82
+
83
+ template <typename T> inline T* get_type_ptr (Value obj, Value klass = Qnil)
61
84
  {
62
85
  if (klass && !check_class(obj, klass)) return NULL;
63
86
  T* p = NULL;
@@ -18,6 +18,9 @@ namespace Rucy
18
18
  {
19
19
 
20
20
 
21
+ class Value;
22
+
23
+
21
24
  class Symbol
22
25
  {
23
26
 
@@ -27,16 +30,24 @@ namespace Rucy
27
30
 
28
31
  Symbol (ID id);
29
32
 
33
+ Symbol (const Value& value);
34
+
30
35
  Symbol (const char* str);
31
36
 
32
37
  ID id () const;
33
38
 
39
+ VALUE value () const;
40
+
34
41
  const char* c_str () const;
35
42
 
36
43
  operator bool () const;
37
44
 
38
45
  bool operator ! () const;
39
46
 
47
+ friend bool operator == (const Symbol& lhs, const Symbol& rhs);
48
+
49
+ friend bool operator != (const Symbol& lhs, const Symbol& rhs);
50
+
40
51
  private:
41
52
 
42
53
  ID id_;
@@ -35,16 +35,16 @@ namespace Rucy
35
35
 
36
36
  Value (VALUE v);
37
37
 
38
- VALUE value () const;
39
-
40
38
  void mark () const;
41
39
 
40
+ bool is_kind_of (Value klass) const;
41
+
42
+ VALUE value () const;
43
+
42
44
  int type () const;
43
45
 
44
46
  Value klass () const;
45
47
 
46
- bool is_kind_of (Value klass) const;
47
-
48
48
  int size () const;
49
49
 
50
50
  int length () const;
@@ -57,6 +57,14 @@ namespace Rucy
57
57
 
58
58
  Value to_sym () const;
59
59
 
60
+ int as_i (bool convert = false) const;
61
+
62
+ double as_f (bool convert = false) const;
63
+
64
+ const char* as_s (bool convert = false) const;
65
+
66
+ Symbol as_sym (bool convert = false) const;
67
+
60
68
  bool is_i () const;
61
69
 
62
70
  bool is_f () const;
@@ -67,13 +75,7 @@ namespace Rucy
67
75
 
68
76
  bool is_a () const;
69
77
 
70
- int as_i (bool convert = false) const;
71
-
72
- double as_f (bool convert = false) const;
73
-
74
- const char* as_s (bool convert = false) const;
75
-
76
- Symbol as_sym (bool convert = false) const;
78
+ bool is_nil () const;
77
79
 
78
80
  % ["call", "operator ()"].each do |op|
79
81
  Value <%= op %> (Symbol name, int argc, const Value* argv) const;
@@ -110,15 +112,61 @@ namespace Rucy
110
112
 
111
113
  Value unshift (Value obj);
112
114
 
113
- private:
115
+ protected:
114
116
 
115
117
  VALUE v;
116
118
 
117
- friend class GCGuard;
118
-
119
119
  };// Value
120
120
 
121
121
 
122
+ class GlobalValue : public Value
123
+ {
124
+
125
+ typedef Value Super;
126
+
127
+ public:
128
+
129
+ GlobalValue ();// gc = false
130
+
131
+ GlobalValue (bool b, bool gc = false);
132
+
133
+ GlobalValue (int i, bool gc = false);
134
+
135
+ GlobalValue (float f, bool gc = false);
136
+
137
+ GlobalValue (double d, bool gc = false);
138
+
139
+ GlobalValue (const char* s, bool tainted = false, bool gc = false);
140
+
141
+ GlobalValue (const char* s, size_t len, bool tainted = false, bool gc = false);
142
+
143
+ GlobalValue (size_t size, const Value* values, bool gc = false);
144
+
145
+ GlobalValue (VALUE v, bool gc = false);
146
+
147
+ GlobalValue (const Value& obj, bool gc = false);
148
+
149
+ GlobalValue (const GlobalValue& obj, bool gc = false);
150
+
151
+ GlobalValue& operator = (const Value& v);
152
+
153
+ ~GlobalValue ();
154
+
155
+ void gc (bool enable = true);
156
+
157
+ private:
158
+
159
+ short gc_disable_count;
160
+
161
+ bool gc_guarded;
162
+
163
+ void init (bool gc);
164
+
165
+ void update_guard ();
166
+
167
+ };// GlobalValue
168
+
169
+
122
170
  Value value (bool b);
123
171
 
124
172
  Value value (char c);
@@ -153,6 +201,10 @@ namespace Rucy
153
201
 
154
202
  Value value (Symbol sym);
155
203
 
204
+ Value value (void* ptr);
205
+
206
+ Value nil ();
207
+
156
208
 
157
209
  template <typename T> T value_to (Value obj, bool convert = true);
158
210
 
data/include/rucy.h CHANGED
@@ -7,4 +7,4 @@
7
7
  #include <rucy/module.h>
8
8
  #include <rucy/class.h>
9
9
  #include <rucy/symbol.h>
10
- #include <rucy/gc.h>
10
+ #include <rucy/extension.h>
data/lib/rucy/module.rb CHANGED
@@ -22,8 +22,15 @@ module Rucy
22
22
  File.join root_dir, 'task'
23
23
  end
24
24
 
25
- def load_tasks ()
26
- Dir["#{task_dir}/**/*.rake"].each {|path| load path}
25
+ def load_tasks (*names)
26
+ if names.empty?
27
+ Dir["#{task_dir}/**/*.rake"].each {|path| load path}
28
+ else
29
+ names.each do |name|
30
+ path = "#{task_dir}/#{name}.rake"
31
+ load path if File.exist? path
32
+ end
33
+ end
27
34
  end
28
35
 
29
36
  def version ()
data/rucy.gemspec CHANGED
@@ -1,66 +1,42 @@
1
1
  # -*- mode: ruby; coding: utf-8 -*-
2
2
 
3
3
 
4
- $: << File.join(File.dirname(__FILE__), 'lib')
4
+ $: << File.expand_path('../lib', __FILE__)
5
5
 
6
- require 'rake'
7
6
  require 'rucy/module'
8
7
 
9
8
 
10
- MODULE = Rucy
11
- NAME = MODULE.name.downcase
12
-
13
-
14
- FILES = FileList[*%W[
15
- README
16
- ChangeLog
17
- Rakefile
18
- #{NAME}.gemspec
19
- VERSION
20
- task/**/*.rake
21
- ext/**/*.rb
22
- ext/**/*.h
23
- ext/**/*.cpp
24
- include/**/*.erb
25
- include/**/*.h
26
- lib/**/*.rb
27
- src/**/*.erb
28
- src/**/*.h
29
- src/**/*.cpp
30
- test/**/*.rb
31
- ]]
32
-
33
- RDOCS = FileList[*%W[
34
- README
35
- .doc/ext/**/*.cpp
36
- ]]
9
+ Gem::Specification.new do |s|
10
+ def glob (*patterns)
11
+ patterns.map {|pat| Dir.glob(pat).to_a}.flatten
12
+ end
37
13
 
14
+ mod = Rucy
15
+ name = mod.name.downcase
16
+ rdocs = glob *%w[README .doc/ext/**/*.cpp]
38
17
 
39
- Gem::Specification.new do |s|
40
- s.name = NAME
18
+ s.name = name
41
19
  s.summary = 'A Ruby C++ Extension Helper Library.'
42
20
  s.description = 'This library helps you to develop Ruby Extension by C++.'
43
- s.version = MODULE.version
21
+ s.version = mod.version
44
22
 
45
23
  s.authors = %w[snori]
46
24
  s.email = 'snori@xord.org'
47
- s.homepage = "http://github.com/xord/#{NAME}"
25
+ s.homepage = "http://github.com/xord/#{name}"
48
26
 
49
27
  s.platform = Gem::Platform::RUBY
50
28
  s.required_ruby_version = '>=1.9.0'
51
- s.require_paths << 'ext'
52
29
 
30
+ s.add_runtime_dependency 'bundler'
53
31
  s.add_runtime_dependency 'xot'
54
32
  s.add_development_dependency 'rake'
55
33
  s.add_development_dependency 'gemcutter'
56
34
 
57
- s.files = FILES.to_a
58
- s.test_files = FileList['test/**/test_*.rb'].to_a
59
-
35
+ s.files = `git ls-files`.split $/
36
+ s.executables = s.files.grep(%r{^bin/}) {|f| File.basename f}
37
+ s.test_files = s.files.grep %r{^(test|spec|features)/}
38
+ s.extra_rdoc_files = rdocs.to_a
60
39
  s.has_rdoc = true
61
- s.extra_rdoc_files = RDOCS.to_a
62
-
63
- s.executables << 'rucy2rdoc'
64
40
 
65
41
  s.extensions << 'Rakefile'
66
42
  end
data/src/exception.cpp CHANGED
@@ -10,21 +10,6 @@
10
10
  #endif
11
11
 
12
12
 
13
- #define VA_STRING(format, result) \
14
- String result; \
15
- do \
16
- { \
17
- if (format) \
18
- { \
19
- va_list args; \
20
- va_start(args, format); \
21
- result = Xot::stringf(format, args); \
22
- va_end(args); \
23
- } \
24
- } \
25
- while (false)
26
-
27
-
28
13
  namespace Rucy
29
14
  {
30
15
 
@@ -37,7 +22,7 @@ namespace Rucy
37
22
  RubyException::RubyException (Value type, const char* format, ...)
38
23
  : Super(""), val(Qnil)
39
24
  {
40
- VA_STRING(format, s);
25
+ XOT_STRINGF(format, s);
41
26
  val = rb_exc_new2(type, s.c_str());
42
27
  }
43
28
 
@@ -66,29 +51,29 @@ namespace Rucy
66
51
  {
67
52
  if (!format) throw;
68
53
 
69
- VA_STRING(format, message);
54
+ XOT_STRINGF(format, message);
70
55
  throw message;
71
56
  }
72
57
 
73
58
  void
74
- raise (Value type, const char* format, ...)
59
+ raise (VALUE exception, const char* format, ...)
75
60
  {
76
- VA_STRING(format, message);
77
- throw RubyException(type, message.c_str());
61
+ XOT_STRINGF(format, message);
62
+ throw RubyException(exception, message.c_str());
78
63
  }
79
64
 
80
65
 
81
66
  void
82
67
  type_error (const char* format, ...)
83
68
  {
84
- VA_STRING(format, message);
69
+ XOT_STRINGF(format, message);
85
70
  raise(rb_eTypeError, message.c_str());
86
71
  }
87
72
 
88
73
  void
89
74
  argument_error (const char* format, ...)
90
75
  {
91
- VA_STRING(format, message);
76
+ XOT_STRINGF(format, message);
92
77
  raise(rb_eArgError, message.c_str());
93
78
  }
94
79
 
@@ -110,10 +95,17 @@ namespace Rucy
110
95
  argument_error(message.c_str());
111
96
  }
112
97
 
98
+ void
99
+ index_error (const char* format, ...)
100
+ {
101
+ XOT_STRINGF(format, message);
102
+ raise(rb_eIndexError, message.c_str());
103
+ }
104
+
113
105
  void
114
106
  not_implemented_error (const char* format, ...)
115
107
  {
116
- VA_STRING(format, message);
108
+ XOT_STRINGF(format, message);
117
109
  raise(rb_eNotImpError, message.c_str());
118
110
  }
119
111
 
@@ -121,7 +113,7 @@ namespace Rucy
121
113
  void
122
114
  system_error (const char* format, ...)
123
115
  {
124
- VA_STRING(format, message);
116
+ XOT_STRINGF(format, message);
125
117
 
126
118
  #ifdef WIN32
127
119
  DWORD lasterror = GetLastError();
@@ -149,7 +141,7 @@ namespace Rucy
149
141
  void
150
142
  invalid_object_error (const char* format, ...)
151
143
  {
152
- VA_STRING(format, message);
144
+ XOT_STRINGF(format, message);
153
145
  raise(invalid_object_error_class(), message.c_str());
154
146
  }
155
147