rua 0.4.7-mswin32 → 0.4.8-mswin32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/README.txt +2 -0
  2. data/ext/rua.c +39 -6
  3. data/lib/i386-mswin32/rua.so +0 -0
  4. metadata +3 -3
data/README.txt CHANGED
@@ -23,6 +23,7 @@ http://rubyforge.org/frs/?group_id=4845
23
23
  require 'rua'
24
24
 
25
25
  class MyClass
26
+ CONST_FOO = 100
26
27
  def val=(v); @val = v; end
27
28
  def val; @val; end
28
29
  def [](k); "#{k}->#{@val}"; end
@@ -68,6 +69,7 @@ http://rubyforge.org/frs/?group_id=4845
68
69
  print(my_obj['foo'])
69
70
  my_obj['bar'] = 'zoo'
70
71
  print(my_obj.val())
72
+ print(MyClass.CONST_FOO)
71
73
 
72
74
  f = function()
73
75
  print('f() called.')
data/ext/rua.c CHANGED
@@ -17,7 +17,13 @@ __declspec(dllexport) void Init_rua(void);
17
17
  #include "iconv.h"
18
18
 
19
19
  #include "ruby.h"
20
+
21
+ #ifndef RUBY_VM
20
22
  #include "rubysig.h"
23
+ #else
24
+ #define TRAP_BEG
25
+ #define TRAP_END
26
+ #endif
21
27
 
22
28
  #include "rua.h"
23
29
 
@@ -37,7 +43,11 @@ __declspec(dllexport) void Init_rua(void);
37
43
  #define RARRAY_LEN(s) (RARRAY(s)->len)
38
44
  #endif
39
45
 
40
- #define VERSION "0.4.7"
46
+ #ifndef RUBY_VM
47
+ #define rb_errinfo() ruby_errinfo
48
+ #endif
49
+
50
+ #define VERSION "0.4.8"
41
51
  #define REF_RBOBJ "self"
42
52
 
43
53
  #define ICONV_JIS "ISO-2022-JP"
@@ -104,6 +114,7 @@ static const int insecure_method_num = sizeof(insecure_methods) / sizeof(char*);
104
114
  static VALUE Rua, RuaFunc, RuaThread, RuaError, RuaDebug;
105
115
  static VALUE s_all, s_base, s_package, s_string, s_table, s_math, s_io, s_debug;
106
116
  static VALUE m_method_unbound, m_methods_unbound;
117
+ static VALUE m_constants_unbound, m_const_get_unbound;
107
118
 
108
119
  void Init_rua() {
109
120
  Rua = rb_define_class("Rua", rb_cObject);
@@ -142,6 +153,11 @@ void Init_rua() {
142
153
  rb_define_class_variable(Rua, "@@m_method_unbound", m_method_unbound);
143
154
  rb_define_class_variable(Rua, "@@m_methods_unbound", m_methods_unbound);
144
155
 
156
+ m_constants_unbound = rb_funcall(rb_cModule, rb_intern("instance_method"), 1, ID2SYM(rb_intern("constants")));
157
+ m_const_get_unbound = rb_funcall(rb_cModule, rb_intern("instance_method"), 1, ID2SYM(rb_intern("const_get")));
158
+ rb_define_class_variable(Rua, "@@m_constants_unbound", m_constants_unbound);
159
+ rb_define_class_variable(Rua, "@@m_const_get_unbound", m_const_get_unbound);
160
+
145
161
  rb_define_alloc_func(RuaFunc, rua_ref_alloc);
146
162
  rb_define_private_method(RuaFunc, "initialize", rua_func_initialize, 0);
147
163
  rb_define_method(RuaFunc, "call", rua_func_call, -1);
@@ -1157,7 +1173,7 @@ static void rua_newtable_from_obj(lua_State *L, VALUE obj, struct rua_state *R)
1157
1173
  method = rb_funcall(m_method_bound, rb_intern("call"), 1, name);
1158
1174
  rb_hash_aset(R->refs, method, Qtrue);
1159
1175
 
1160
- if (R->secure && rua_name_is_insecure_method(RSTRING_PTR(name))) {
1176
+ if (R->secure && rua_name_is_insecure_method(StringValuePtr(name))) {
1161
1177
  continue;
1162
1178
  }
1163
1179
 
@@ -1166,6 +1182,23 @@ static void rua_newtable_from_obj(lua_State *L, VALUE obj, struct rua_state *R)
1166
1182
  lua_rawset(L, tblidx);
1167
1183
  }
1168
1184
 
1185
+ if (rb_obj_is_kind_of(obj, rb_cModule)) {
1186
+ VALUE cnsts, cname, cnst;
1187
+ VALUE m_const_get_bound, m_constants_bound;
1188
+ m_const_get_bound = rb_funcall(m_const_get_unbound, rb_intern("bind"), 1, obj);
1189
+ m_constants_bound = rb_funcall(m_constants_unbound, rb_intern("bind"), 1, obj);
1190
+ cnsts = rb_check_convert_type(m_constants_bound, T_ARRAY, "Array", "call");
1191
+
1192
+ for (i = 0; i < RARRAY_LEN(cnsts); i++) {
1193
+ cname = rb_ary_entry(cnsts, i);
1194
+ cnst = rb_funcall(m_const_get_bound, rb_intern("call"), 1, cname);
1195
+ rb_hash_aset(R->refs, cnst, Qtrue);
1196
+ rua_pushrbval(L, cname, R);
1197
+ rua_pushrbval(L, cnst, R);
1198
+ lua_rawset(L, tblidx);
1199
+ }
1200
+ }
1201
+
1169
1202
  lua_pushvalue(L, -1);
1170
1203
  rua_setmeta(L, prxidx, "__index", rua_getobject_event, 1);
1171
1204
  rua_setmeta(L, prxidx, "__newindex", rua_setobject_event, 1);
@@ -1261,12 +1294,12 @@ static int rua_proc_call(lua_State *L) {
1261
1294
  if (status != 0) {
1262
1295
  if (R->wrap_error) {
1263
1296
  if (lua_getstack(L, 1, &ar) && lua_getinfo(L, "nSlu", &ar)) {
1264
- error = rua_toruaerror(ruby_errinfo, rua_toruadebug(&ar));
1297
+ error = rua_toruaerror(rb_errinfo(), rua_toruadebug(&ar));
1265
1298
  } else {
1266
- error = rua_toruaerror(ruby_errinfo, Qnil);
1299
+ error = rua_toruaerror(rb_errinfo(), Qnil);
1267
1300
  }
1268
1301
  } else {
1269
- error = ruby_errinfo;
1302
+ error = rb_errinfo();
1270
1303
  }
1271
1304
 
1272
1305
  if (rua_obj_is_executable(R->error_handler)) {
@@ -1276,7 +1309,7 @@ static int rua_proc_call(lua_State *L) {
1276
1309
  retval = rb_protect(_rua_proc_call, errargs, &status);
1277
1310
 
1278
1311
  if (status != 0) {
1279
- rb_warn("%s\n", rua_to_sptr(ruby_errinfo));
1312
+ rb_warn("%s\n", rua_to_sptr(rb_errinfo()));
1280
1313
  }
1281
1314
  } else {
1282
1315
  retval = Qnil;
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rua
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.7
4
+ version: 0.4.8
5
5
  platform: mswin32
6
6
  authors:
7
7
  - winebarrel
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-09-30 00:00:00 +09:00
12
+ date: 2009-06-26 00:00:00 +09:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -49,7 +49,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
49
49
  requirements: []
50
50
 
51
51
  rubyforge_project: rua
52
- rubygems_version: 1.2.0
52
+ rubygems_version: 1.3.1
53
53
  signing_key:
54
54
  specification_version: 2
55
55
  summary: Rua is a library for using Lua under Ruby.