rua 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.txt +12 -4
- data/ext/rua.c +30 -5
- metadata +1 -1
data/README.txt
CHANGED
@@ -10,7 +10,11 @@ Rua is a library for using Lua under Ruby.
|
|
10
10
|
|
11
11
|
require 'rua'
|
12
12
|
|
13
|
-
|
13
|
+
error_handler = lambda do |e|
|
14
|
+
p e
|
15
|
+
end
|
16
|
+
|
17
|
+
rua = Rua.new(error_handler)
|
14
18
|
rua.openlibs(:all)
|
15
19
|
#rua.openlibs(:base, :package, :string)
|
16
20
|
#rua.secure = false
|
@@ -18,15 +22,19 @@ Rua is a library for using Lua under Ruby.
|
|
18
22
|
rua[:str] = 'xxx'
|
19
23
|
rua[:num] = 100
|
20
24
|
rua[:proc] = lambda do
|
21
|
-
puts '
|
25
|
+
puts 'proc called.'
|
26
|
+
end
|
27
|
+
rua[:err] = lambda do
|
28
|
+
raise 'err called.'
|
22
29
|
end
|
23
30
|
|
24
|
-
puts rua.eval(
|
31
|
+
puts rua.eval(<<-EOS)
|
25
32
|
print('hello Rua!')
|
26
33
|
print(str)
|
27
34
|
print(num)
|
28
35
|
proc()
|
29
|
-
|
36
|
+
err()
|
37
|
+
|
30
38
|
f = function()
|
31
39
|
print('f() called.')
|
32
40
|
end
|
data/ext/rua.c
CHANGED
@@ -16,33 +16,58 @@ __declspec(dllexport) void Init_rua(void);
|
|
16
16
|
#include "rua.h"
|
17
17
|
|
18
18
|
static const char *insecure_methods[] = {
|
19
|
-
"
|
19
|
+
"__id__",
|
20
20
|
"__send__",
|
21
|
+
"ancestors",
|
22
|
+
"autoload",
|
23
|
+
"autoload?",
|
21
24
|
"class",
|
25
|
+
"class_eval",
|
26
|
+
"class_variable_defined?",
|
27
|
+
"class_variables",
|
28
|
+
"const_defined?",
|
29
|
+
"const_get",
|
30
|
+
"const_missing",
|
31
|
+
"const_set",
|
32
|
+
"constants",
|
22
33
|
"extend",
|
23
34
|
"freeze",
|
24
35
|
"id",
|
36
|
+
"include?",
|
37
|
+
"included_modules",
|
25
38
|
"instance_eval",
|
39
|
+
"instance_method",
|
40
|
+
"instance_methods",
|
26
41
|
"instance_variable_defined?",
|
27
42
|
"instance_variable_get",
|
28
43
|
"instance_variable_set",
|
29
44
|
"instance_variables",
|
30
45
|
"method",
|
46
|
+
"method_defined?",
|
31
47
|
"method_missing",
|
32
48
|
"methods",
|
49
|
+
"module_eval",
|
50
|
+
"private_class_method",
|
51
|
+
"private_instance_methods",
|
52
|
+
"private_method_defined?",
|
33
53
|
"private_methods",
|
54
|
+
"protected_instance_methods",
|
55
|
+
"protected_method_defined?",
|
34
56
|
"protected_methods",
|
57
|
+
"public_class_method",
|
58
|
+
"public_instance_methods",
|
59
|
+
"public_method_defined?",
|
35
60
|
"public_methods",
|
36
61
|
"respond_to?",
|
37
62
|
"send",
|
38
63
|
"singleton_methods",
|
39
64
|
"taint",
|
40
|
-
"type",
|
41
|
-
"untaint",
|
42
65
|
"to_ary",
|
43
66
|
"to_hash",
|
44
67
|
"to_int",
|
45
|
-
"to_str"
|
68
|
+
"to_str",
|
69
|
+
"type",
|
70
|
+
"untaint"
|
46
71
|
};
|
47
72
|
|
48
73
|
static const int insecure_method_num = sizeof(insecure_methods) / sizeof(char*);
|
@@ -55,7 +80,7 @@ void Init_rua() {
|
|
55
80
|
RuaError = rb_define_class("RuaError", rb_eStandardError);
|
56
81
|
|
57
82
|
rb_define_alloc_func(Rua, rua_alloc);
|
58
|
-
rb_define_const(Rua, "VERSION", rb_str_new2("0.1.
|
83
|
+
rb_define_const(Rua, "VERSION", rb_str_new2("0.1.2"));
|
59
84
|
rb_define_private_method(Rua, "initialize", rua_initialize, -1);
|
60
85
|
rb_define_method(Rua, "openlibs", rua_openlibs, -1);
|
61
86
|
rb_define_method(Rua, "eval", rua_eval, 1);
|