rua 0.3.5-mswin32 → 0.3.7-mswin32
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.
- data/README.txt +6 -1
- data/ext/rua.c +79 -12
- data/lib/i386-mswin32/rua.so +0 -0
- metadata +41 -34
data/README.txt
CHANGED
@@ -24,7 +24,10 @@ http://storehouse.sakura.ne.jp/rua/
|
|
24
24
|
|
25
25
|
require 'rua'
|
26
26
|
|
27
|
-
class MyClass
|
27
|
+
class MyClass
|
28
|
+
def val=(v); @val = v; end
|
29
|
+
def val; @val; end
|
30
|
+
end
|
28
31
|
|
29
32
|
rua = Rua.new(:all)
|
30
33
|
#rua.external_charset = Rua::SJIS
|
@@ -60,6 +63,8 @@ http://storehouse.sakura.ne.jp/rua/
|
|
60
63
|
err()
|
61
64
|
print(Time.new().to_s())
|
62
65
|
my_obj = MyClass.new()
|
66
|
+
my_obj.val = 'my_obj.val'
|
67
|
+
print(my_obj.val())
|
63
68
|
|
64
69
|
f = function()
|
65
70
|
print('f() called.')
|
data/ext/rua.c
CHANGED
@@ -9,6 +9,7 @@ __declspec(dllexport) void Init_rua(void);
|
|
9
9
|
#include <string.h>
|
10
10
|
#include <malloc.h>
|
11
11
|
#include <errno.h>
|
12
|
+
#include <stdarg.h>
|
12
13
|
|
13
14
|
#include "ruby.h"
|
14
15
|
|
@@ -20,7 +21,7 @@ __declspec(dllexport) void Init_rua(void);
|
|
20
21
|
|
21
22
|
#include "rua.h"
|
22
23
|
|
23
|
-
#define VERSION "0.3.
|
24
|
+
#define VERSION "0.3.7"
|
24
25
|
#define REF_RBOBJ "self"
|
25
26
|
|
26
27
|
#define ICONV_JIS "ISO-2022-JP"
|
@@ -978,7 +979,7 @@ static void rua_pushrbval(lua_State *L, VALUE rbval, struct rua_state *R) {
|
|
978
979
|
lua_pushlightuserdata(L, (void *) rbval);
|
979
980
|
lua_pushlightuserdata(L, R);
|
980
981
|
lua_pushcclosure(L, rua_proc_call, 2);
|
981
|
-
|
982
|
+
rua_setmeta2(L, -1, "__gc", rua_finalize_rbobj, 2, rbval, R);
|
982
983
|
} else {
|
983
984
|
rua_newtable_from_obj(L, rbval, R);
|
984
985
|
}
|
@@ -1021,15 +1022,17 @@ static void rua_newtable_from_hash(lua_State *L, VALUE hash, struct rua_state *R
|
|
1021
1022
|
|
1022
1023
|
static void rua_newtable_from_obj(lua_State *L, VALUE obj, struct rua_state *R) {
|
1023
1024
|
VALUE methods, name, method;
|
1024
|
-
int i, tblidx;
|
1025
|
+
int i, tblidx, prxidx;
|
1025
1026
|
|
1027
|
+
lua_newtable(L);
|
1028
|
+
prxidx = lua_gettop(L);
|
1026
1029
|
lua_newtable(L);
|
1027
1030
|
tblidx = lua_gettop(L);
|
1028
1031
|
methods = rb_check_convert_type(obj, T_ARRAY, "Array", "methods");
|
1029
1032
|
|
1030
1033
|
lua_pushstring(L, REF_RBOBJ);
|
1031
1034
|
lua_pushlightuserdata(L, (void *) obj);
|
1032
|
-
|
1035
|
+
rua_setmeta2(L, -1, "__gc", rua_finalize_rbobj, 2, obj, R);
|
1033
1036
|
lua_rawset(L, tblidx);
|
1034
1037
|
rb_hash_aset(R->refs, obj, Qtrue);
|
1035
1038
|
|
@@ -1046,6 +1049,47 @@ static void rua_newtable_from_obj(lua_State *L, VALUE obj, struct rua_state *R)
|
|
1046
1049
|
rua_pushrbval(L, method, R);
|
1047
1050
|
lua_rawset(L, tblidx);
|
1048
1051
|
}
|
1052
|
+
|
1053
|
+
lua_pushvalue(L, -1);
|
1054
|
+
rua_setmeta(L, prxidx, "__index", rua_getobject_event, 1);
|
1055
|
+
rua_setmeta(L, prxidx, "__newindex", rua_setobject_event, 1);
|
1056
|
+
}
|
1057
|
+
|
1058
|
+
static int rua_getobject_event(lua_State *L) {
|
1059
|
+
int tblidx;
|
1060
|
+
|
1061
|
+
tblidx = lua_upvalueindex(1);
|
1062
|
+
lua_rawget(L, tblidx);
|
1063
|
+
return 1;
|
1064
|
+
}
|
1065
|
+
|
1066
|
+
static int rua_setobject_event(lua_State *L) {
|
1067
|
+
const char *key;
|
1068
|
+
size_t keylen;
|
1069
|
+
char *setter;
|
1070
|
+
int tblidx;
|
1071
|
+
|
1072
|
+
tblidx = lua_upvalueindex(1);
|
1073
|
+
|
1074
|
+
key = lua_tostring(L, -2);
|
1075
|
+
keylen = strlen(key);
|
1076
|
+
setter = alloca(keylen + 2);
|
1077
|
+
memcpy(setter, key, keylen);
|
1078
|
+
setter[keylen] = '=';
|
1079
|
+
setter[keylen + 1] = '\0';
|
1080
|
+
|
1081
|
+
lua_pushstring(L, setter);
|
1082
|
+
lua_rawget(L, tblidx);
|
1083
|
+
|
1084
|
+
if (lua_isfunction(L, -1)) {
|
1085
|
+
lua_pushvalue(L, -2);
|
1086
|
+
lua_call(L, 1, 0);
|
1087
|
+
} else {
|
1088
|
+
lua_pop(L, 1);
|
1089
|
+
lua_rawset(L, tblidx);
|
1090
|
+
}
|
1091
|
+
|
1092
|
+
return 0;
|
1049
1093
|
}
|
1050
1094
|
|
1051
1095
|
static int rua_proc_call(lua_State *L) {
|
@@ -1213,10 +1257,10 @@ static const char *rua_classname_ptr(VALUE v) {
|
|
1213
1257
|
return StringValuePtr(klassname);
|
1214
1258
|
}
|
1215
1259
|
|
1216
|
-
static void
|
1217
|
-
int
|
1260
|
+
static void rua_setmeta(lua_State *L, int idx, const char *key, lua_CFunction f, int n) {
|
1261
|
+
int basetop, objidx, tblidx, i;
|
1218
1262
|
|
1219
|
-
|
1263
|
+
basetop = lua_gettop(L) - n;
|
1220
1264
|
lua_pushvalue(L, idx);
|
1221
1265
|
objidx = lua_gettop(L);
|
1222
1266
|
|
@@ -1227,14 +1271,37 @@ static void rua_set_finalizer(lua_State *L, int idx, VALUE rbobj, struct rua_sta
|
|
1227
1271
|
}
|
1228
1272
|
|
1229
1273
|
tblidx = lua_gettop(L);
|
1230
|
-
lua_pushstring(L,
|
1274
|
+
lua_pushstring(L, key);
|
1231
1275
|
|
1232
|
-
|
1233
|
-
|
1234
|
-
|
1276
|
+
for (i = 1; i <= n; i++) {
|
1277
|
+
lua_pushvalue(L, basetop + i);
|
1278
|
+
}
|
1279
|
+
|
1280
|
+
if (n > 0) {
|
1281
|
+
lua_pushcclosure(L, f, n);
|
1282
|
+
} else {
|
1283
|
+
lua_pushcfunction(L, f);
|
1284
|
+
}
|
1235
1285
|
|
1236
1286
|
lua_rawset(L, tblidx);
|
1237
|
-
lua_pop(L, lua_gettop(L) -
|
1287
|
+
lua_pop(L, lua_gettop(L) - basetop);
|
1288
|
+
}
|
1289
|
+
|
1290
|
+
static void rua_setmeta2(lua_State *L, int idx, const char *key, lua_CFunction f, int n, ...) {
|
1291
|
+
va_list argp;
|
1292
|
+
int i;
|
1293
|
+
|
1294
|
+
va_start(argp, n);
|
1295
|
+
|
1296
|
+
for (i = 0; i < n; i++) {
|
1297
|
+
lua_pushlightuserdata(L, va_arg(argp, void*));
|
1298
|
+
}
|
1299
|
+
|
1300
|
+
if (idx < 0) {
|
1301
|
+
idx -= n;
|
1302
|
+
}
|
1303
|
+
|
1304
|
+
rua_setmeta(L, idx, key, f, n);
|
1238
1305
|
}
|
1239
1306
|
|
1240
1307
|
static int rua_finalize_rbobj(lua_State *L) {
|
data/lib/i386-mswin32/rua.so
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,50 +1,57 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.9.2
|
3
|
-
specification_version: 1
|
4
2
|
name: rua
|
5
3
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.3.
|
7
|
-
date: 2007-12-10 00:00:00 +09:00
|
8
|
-
summary: Rua is a library for using Lua under Ruby.
|
9
|
-
require_paths:
|
10
|
-
- lib/i386-mswin32
|
11
|
-
email: sgwr_dts@yahoo.co.jp
|
12
|
-
homepage: http://rua.rubyforge.org
|
13
|
-
rubyforge_project:
|
14
|
-
description:
|
15
|
-
autorequire:
|
16
|
-
default_executable:
|
17
|
-
bindir: bin
|
18
|
-
has_rdoc: true
|
19
|
-
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
20
|
-
requirements:
|
21
|
-
- - ">"
|
22
|
-
- !ruby/object:Gem::Version
|
23
|
-
version: 0.0.0
|
24
|
-
version:
|
4
|
+
version: 0.3.7
|
25
5
|
platform: mswin32
|
26
|
-
signing_key:
|
27
|
-
cert_chain:
|
28
|
-
post_install_message:
|
29
6
|
authors:
|
30
7
|
- winebarrel
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2007-12-26 00:00:00 +09:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description:
|
17
|
+
email: sgwr_dts@yahoo.co.jp
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files:
|
23
|
+
- README.txt
|
24
|
+
- ext/rua.c
|
31
25
|
files:
|
32
26
|
- README.txt
|
33
27
|
- lib/i386-mswin32/rua.so
|
34
28
|
- ext/rua.c
|
35
|
-
|
36
|
-
|
29
|
+
has_rdoc: true
|
30
|
+
homepage: http://rua.rubyforge.org
|
31
|
+
post_install_message:
|
37
32
|
rdoc_options:
|
38
33
|
- --title
|
39
34
|
- Rua - library for using Lua under Ruby.
|
40
|
-
|
41
|
-
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
35
|
+
require_paths:
|
36
|
+
- lib/i386-mswin32
|
37
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: "0"
|
42
|
+
version:
|
43
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: "0"
|
48
|
+
version:
|
47
49
|
requirements: []
|
48
50
|
|
49
|
-
|
51
|
+
rubyforge_project:
|
52
|
+
rubygems_version: 0.9.5
|
53
|
+
signing_key:
|
54
|
+
specification_version: 2
|
55
|
+
summary: Rua is a library for using Lua under Ruby.
|
56
|
+
test_files: []
|
50
57
|
|