rua 0.3.8 → 0.3.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/ext/rua.c +13 -3
  2. metadata +1 -1
data/ext/rua.c CHANGED
@@ -21,7 +21,7 @@ __declspec(dllexport) void Init_rua(void);
21
21
 
22
22
  #include "rua.h"
23
23
 
24
- #define VERSION "0.3.8"
24
+ #define VERSION "0.3.9"
25
25
  #define REF_RBOBJ "self"
26
26
 
27
27
  #define ICONV_JIS "ISO-2022-JP"
@@ -87,6 +87,7 @@ static const char *insecure_methods[] = {
87
87
  static const int insecure_method_num = sizeof(insecure_methods) / sizeof(char*);
88
88
  static VALUE Rua, RuaFunc, RuaThread, RuaError, RuaDebug;
89
89
  static VALUE s_all, s_base, s_package, s_string, s_table, s_math, s_io, s_debug;
90
+ static VALUE m_method_unbound, m_methods_unbound;
90
91
 
91
92
  void Init_rua() {
92
93
  Rua = rb_define_class("Rua", rb_cObject);
@@ -118,6 +119,11 @@ void Init_rua() {
118
119
  rb_define_method(Rua, "error_handler=", rua_set_error_handler, 1);
119
120
  rb_define_method(Rua, "method_missing", rua_method_missing, -1);
120
121
 
122
+ m_method_unbound = rb_funcall(rb_cObject, rb_intern("instance_method"), 1, ID2SYM(rb_intern("method")));
123
+ m_methods_unbound = rb_funcall(rb_cObject, rb_intern("instance_method"), 1, ID2SYM(rb_intern("methods")));
124
+ rb_define_class_variable(Rua, "@@m_method_unbound", m_method_unbound);
125
+ rb_define_class_variable(Rua, "@@m_methods_unbound", m_methods_unbound);
126
+
121
127
  rb_define_alloc_func(RuaFunc, rua_ref_alloc);
122
128
  rb_define_private_method(RuaFunc, "initialize", rua_func_initialize, 0);
123
129
  rb_define_method(RuaFunc, "call", rua_func_call, -1);
@@ -1022,13 +1028,17 @@ static void rua_newtable_from_hash(lua_State *L, VALUE hash, struct rua_state *R
1022
1028
 
1023
1029
  static void rua_newtable_from_obj(lua_State *L, VALUE obj, struct rua_state *R) {
1024
1030
  VALUE methods, name, method;
1031
+ VALUE m_method_bound, m_methods_bound;
1025
1032
  int i, tblidx, prxidx;
1026
1033
 
1027
1034
  lua_newtable(L);
1028
1035
  prxidx = lua_gettop(L);
1029
1036
  lua_newtable(L);
1030
1037
  tblidx = lua_gettop(L);
1031
- methods = rb_check_convert_type(obj, T_ARRAY, "Array", "methods");
1038
+
1039
+ m_method_bound = rb_funcall(m_method_unbound, rb_intern("bind"), 1, obj);
1040
+ m_methods_bound = rb_funcall(m_methods_unbound, rb_intern("bind"), 1, obj);
1041
+ methods = rb_check_convert_type(m_methods_bound, T_ARRAY, "Array", "call");
1032
1042
 
1033
1043
  lua_pushstring(L, REF_RBOBJ);
1034
1044
  lua_pushlightuserdata(L, (void *) obj);
@@ -1038,7 +1048,7 @@ static void rua_newtable_from_obj(lua_State *L, VALUE obj, struct rua_state *R)
1038
1048
 
1039
1049
  for (i = 0; i < RARRAY(methods)->len; i++) {
1040
1050
  name = rb_ary_entry(methods, i);
1041
- method = rb_funcall(obj, rb_intern("method"), 1, name);
1051
+ method = rb_funcall(m_method_bound, rb_intern("call"), 1, name);
1042
1052
  rb_hash_aset(R->refs, method, Qtrue);
1043
1053
 
1044
1054
  if (R->secure && rua_name_is_insecure_method(StringValuePtr(name))) {
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.3.8
4
+ version: 0.3.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - winebarrel