rua 0.1.5 → 0.2.0
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/ext/rua.c +84 -128
- data/ext/rua.h +13 -17
- metadata +2 -2
data/ext/rua.c
CHANGED
@@ -15,8 +15,8 @@ __declspec(dllexport) void Init_rua(void);
|
|
15
15
|
|
16
16
|
#include "rua.h"
|
17
17
|
|
18
|
-
#define
|
19
|
-
#define
|
18
|
+
#define VERSION "0.2.0"
|
19
|
+
#define REF_RBOBJ "self"
|
20
20
|
|
21
21
|
static const char *insecure_methods[] = {
|
22
22
|
"__id__",
|
@@ -142,8 +142,8 @@ static VALUE rua_initialize(int argc, VALUE *argv, VALUE self) {
|
|
142
142
|
}
|
143
143
|
|
144
144
|
p->L = lua_open();
|
145
|
-
p->secure = 1;
|
146
|
-
p->error_handler = error_handler;
|
145
|
+
p->R.secure = 1;
|
146
|
+
p->R.error_handler = error_handler;
|
147
147
|
return Qnil;
|
148
148
|
}
|
149
149
|
|
@@ -198,9 +198,8 @@ static VALUE rua_openlibs(int argc, VALUE *argv, VALUE self) {
|
|
198
198
|
|
199
199
|
static VALUE rua_eval(VALUE self, VALUE str) {
|
200
200
|
struct rua *p;
|
201
|
-
VALUE retval;
|
202
201
|
const char *errmsg;
|
203
|
-
int pretop
|
202
|
+
int pretop;
|
204
203
|
|
205
204
|
Check_Type(str, T_STRING);
|
206
205
|
Data_Get_Struct(self, struct rua, p);
|
@@ -208,30 +207,12 @@ static VALUE rua_eval(VALUE self, VALUE str) {
|
|
208
207
|
luaL_loadstring(p->L, StringValuePtr(str));
|
209
208
|
|
210
209
|
if (lua_pcall(p->L, 0, LUA_MULTRET, 0) != 0) {
|
211
|
-
RuaError = rb_const_get(rb_cObject, rb_intern("RuaError"));
|
212
210
|
errmsg = lua_tostring(p->L, -1);
|
213
211
|
lua_pop(p->L, 1);
|
214
212
|
rb_raise(RuaError, "%s", errmsg);
|
215
213
|
}
|
216
214
|
|
217
|
-
|
218
|
-
|
219
|
-
if (nresults == 0) {
|
220
|
-
return Qnil;
|
221
|
-
} else if (nresults == 1) {
|
222
|
-
retval = rua_torbval(p->L, -1, p->error_handler, p->secure);
|
223
|
-
lua_pop(p->L, 1);
|
224
|
-
return retval;
|
225
|
-
} else {
|
226
|
-
retval = rb_ary_new();
|
227
|
-
|
228
|
-
for (i = nresults; i > 0; i--) {
|
229
|
-
rb_ary_push(retval, rua_torbval(p->L, -i, p->error_handler, p->secure));
|
230
|
-
}
|
231
|
-
|
232
|
-
lua_pop(p->L, nresults);
|
233
|
-
return retval;
|
234
|
-
}
|
215
|
+
return rua_tomultiretval(p->L, pretop, p->R);
|
235
216
|
}
|
236
217
|
|
237
218
|
static VALUE rua_get(VALUE self, VALUE key) {
|
@@ -240,7 +221,7 @@ static VALUE rua_get(VALUE self, VALUE key) {
|
|
240
221
|
|
241
222
|
Data_Get_Struct(self, struct rua, p);
|
242
223
|
lua_getglobal(p->L, rua_to_sptr(key));
|
243
|
-
retval = rua_torbval(p->L, -1, p->
|
224
|
+
retval = rua_torbval(p->L, -1, p->R);
|
244
225
|
lua_pop(p->L, 1);
|
245
226
|
return retval;
|
246
227
|
}
|
@@ -250,11 +231,11 @@ static VALUE rua_set(VALUE self, VALUE key, VALUE val) {
|
|
250
231
|
|
251
232
|
Data_Get_Struct(self, struct rua, p);
|
252
233
|
|
253
|
-
if (p->secure && (rb_equal(rb_cModule, val) || rb_equal(rb_cClass, val))) {
|
234
|
+
if (p->R.secure && (rb_equal(rb_cModule, val) || rb_equal(rb_cClass, val))) {
|
254
235
|
rb_raise(RuaError, "set insecure value %s", rua_to_sptr(val));
|
255
236
|
}
|
256
237
|
|
257
|
-
rua_pushrbval(p->L, val, p->
|
238
|
+
rua_pushrbval(p->L, val, p->R);
|
258
239
|
lua_setglobal(p->L, rua_to_sptr(key));
|
259
240
|
return Qnil;
|
260
241
|
}
|
@@ -263,7 +244,7 @@ static VALUE rua_get_secure(VALUE self) {
|
|
263
244
|
struct rua *p;
|
264
245
|
|
265
246
|
Data_Get_Struct(self, struct rua, p);
|
266
|
-
return p->secure ? Qtrue : Qfalse;
|
247
|
+
return p->R.secure ? Qtrue : Qfalse;
|
267
248
|
}
|
268
249
|
|
269
250
|
static VALUE rua_set_secure(VALUE self, VALUE secure) {
|
@@ -272,8 +253,8 @@ static VALUE rua_set_secure(VALUE self, VALUE secure) {
|
|
272
253
|
Data_Get_Struct(self, struct rua, p);
|
273
254
|
|
274
255
|
switch (TYPE(secure)) {
|
275
|
-
case T_TRUE: p->secure = 1; break;
|
276
|
-
case T_FALSE: p->secure = 0; break;
|
256
|
+
case T_TRUE: p->R.secure = 1; break;
|
257
|
+
case T_FALSE: p->R.secure = 0; break;
|
277
258
|
default:
|
278
259
|
rb_raise(rb_eTypeError, "wrong argument type %s (expected TrueClass or FalseClass)", rua_classname_ptr(secure));
|
279
260
|
break;
|
@@ -307,7 +288,7 @@ static VALUE rua_method_missing(int argc, VALUE *argv, VALUE self) {
|
|
307
288
|
// ------------------------------------------------------------------
|
308
289
|
|
309
290
|
static VALUE rua_func_alloc(VALUE klass) {
|
310
|
-
struct
|
291
|
+
struct rua_ref *p = ALLOC(struct rua_ref);
|
311
292
|
|
312
293
|
return Data_Wrap_Struct(klass, 0, -1, p);
|
313
294
|
}
|
@@ -317,17 +298,16 @@ static VALUE rua_func_initialize(VALUE self) {
|
|
317
298
|
}
|
318
299
|
|
319
300
|
static VALUE rua_func_call(int argc, VALUE *argv, VALUE self) {
|
320
|
-
struct
|
321
|
-
|
322
|
-
int pretop, nresults, i;
|
301
|
+
struct rua_ref *p;
|
302
|
+
int pretop, i;
|
323
303
|
const char *errmsg;
|
324
304
|
|
325
|
-
Data_Get_Struct(self, struct
|
305
|
+
Data_Get_Struct(self, struct rua_ref, p);
|
326
306
|
pretop = lua_gettop(p->L);
|
327
307
|
lua_rawgeti(p->L, LUA_REGISTRYINDEX, p->ref);
|
328
308
|
|
329
309
|
for (i = 0; i < argc; i ++) {
|
330
|
-
rua_pushrbval(p->L, argv[i], p->
|
310
|
+
rua_pushrbval(p->L, argv[i], p->R);
|
331
311
|
}
|
332
312
|
|
333
313
|
if (lua_pcall(p->L, argc, LUA_MULTRET, 0) != 0) {
|
@@ -336,30 +316,13 @@ static VALUE rua_func_call(int argc, VALUE *argv, VALUE self) {
|
|
336
316
|
rb_raise(RuaError, "%s", errmsg);
|
337
317
|
}
|
338
318
|
|
339
|
-
|
340
|
-
|
341
|
-
if (nresults == 0) {
|
342
|
-
return Qnil;
|
343
|
-
} else if (nresults == 1) {
|
344
|
-
retval = rua_torbval(p->L, -1, p->error_handler, p->secure);
|
345
|
-
lua_pop(p->L, 1);
|
346
|
-
return retval;
|
347
|
-
} else {
|
348
|
-
retval = rb_ary_new();
|
349
|
-
|
350
|
-
for (i = nresults; i > 0; i--) {
|
351
|
-
rb_ary_push(retval, rua_torbval(p->L, -i, p->error_handler, p->secure));
|
352
|
-
}
|
353
|
-
|
354
|
-
lua_pop(p->L, nresults);
|
355
|
-
return retval;
|
356
|
-
}
|
319
|
+
return rua_tomultiretval(p->L, pretop, p->R);
|
357
320
|
}
|
358
321
|
|
359
322
|
// ------------------------------------------------------------------
|
360
323
|
|
361
324
|
static VALUE rua_thread_alloc(VALUE klass) {
|
362
|
-
struct
|
325
|
+
struct rua_ref *p = ALLOC(struct rua_ref);
|
363
326
|
|
364
327
|
return Data_Wrap_Struct(klass, 0, -1, p);
|
365
328
|
}
|
@@ -369,12 +332,12 @@ static VALUE rua_thread_initialize(VALUE self) {
|
|
369
332
|
}
|
370
333
|
|
371
334
|
static VALUE rua_thread_resume(int argc, VALUE *argv, VALUE self) {
|
372
|
-
struct
|
335
|
+
struct rua_ref *p;
|
373
336
|
VALUE retval;
|
374
|
-
int pretop,
|
337
|
+
int pretop, i;
|
375
338
|
const char *errmsg;
|
376
339
|
|
377
|
-
Data_Get_Struct(self, struct
|
340
|
+
Data_Get_Struct(self, struct rua_ref, p);
|
378
341
|
lua_getglobal(p->L, "coroutine");
|
379
342
|
pretop = lua_gettop(p->L);
|
380
343
|
lua_pushstring(p->L, "resume");
|
@@ -382,7 +345,7 @@ static VALUE rua_thread_resume(int argc, VALUE *argv, VALUE self) {
|
|
382
345
|
lua_rawgeti(p->L, LUA_REGISTRYINDEX, p->ref);
|
383
346
|
|
384
347
|
for (i = 0; i < argc; i ++) {
|
385
|
-
rua_pushrbval(p->L, argv[i], p->
|
348
|
+
rua_pushrbval(p->L, argv[i], p->R);
|
386
349
|
}
|
387
350
|
|
388
351
|
if (lua_pcall(p->L, argc + 1, LUA_MULTRET, 0) != 0) {
|
@@ -391,30 +354,38 @@ static VALUE rua_thread_resume(int argc, VALUE *argv, VALUE self) {
|
|
391
354
|
rb_raise(RuaError, "%s", errmsg);
|
392
355
|
}
|
393
356
|
|
394
|
-
|
357
|
+
retval = rua_tomultiretval(p->L, pretop, p->R);
|
358
|
+
lua_pop(p->L, 1);
|
359
|
+
return retval;
|
360
|
+
}
|
361
|
+
|
362
|
+
// ------------------------------------------------------------------
|
363
|
+
|
364
|
+
static VALUE rua_tomultiretval(lua_State *L, int pretop, struct rua_state R) {
|
365
|
+
VALUE retval;
|
366
|
+
int nresults, i;
|
367
|
+
|
368
|
+
nresults = lua_gettop(L) - pretop;
|
395
369
|
|
396
370
|
if (nresults == 0) {
|
397
|
-
lua_pop(p->L, 1);
|
398
371
|
return Qnil;
|
399
372
|
} else if (nresults == 1) {
|
400
|
-
retval = rua_torbval(
|
401
|
-
lua_pop(
|
373
|
+
retval = rua_torbval(L, -1, R);
|
374
|
+
lua_pop(L, 1);
|
402
375
|
return retval;
|
403
376
|
} else {
|
404
377
|
retval = rb_ary_new();
|
405
378
|
|
406
379
|
for (i = nresults; i > 0; i--) {
|
407
|
-
rb_ary_push(retval, rua_torbval(
|
380
|
+
rb_ary_push(retval, rua_torbval(L, -i, R));
|
408
381
|
}
|
409
382
|
|
410
|
-
lua_pop(
|
383
|
+
lua_pop(L, nresults);
|
411
384
|
return retval;
|
412
385
|
}
|
413
386
|
}
|
414
387
|
|
415
|
-
|
416
|
-
|
417
|
-
static VALUE rua_torbval(lua_State *L, int idx, VALUE error_handler, int secure) {
|
388
|
+
static VALUE rua_torbval(lua_State *L, int idx, struct rua_state R) {
|
418
389
|
VALUE rbval = Qnil;
|
419
390
|
|
420
391
|
switch (lua_type(L, idx)) {
|
@@ -434,17 +405,17 @@ static VALUE rua_torbval(lua_State *L, int idx, VALUE error_handler, int secure)
|
|
434
405
|
if (rua_is_rbobj(L, idx)) {
|
435
406
|
rbval = rua_torbobj(L, idx);
|
436
407
|
} else {
|
437
|
-
rbval = rua_tohash(L, idx,
|
408
|
+
rbval = rua_tohash(L, idx, R);
|
438
409
|
}
|
439
410
|
|
440
411
|
break;
|
441
412
|
|
442
413
|
case LUA_TFUNCTION:
|
443
|
-
rbval =
|
414
|
+
rbval = rua_toruaobj(RuaFunc, L, idx, R);
|
444
415
|
break;
|
445
416
|
|
446
417
|
case LUA_TTHREAD:
|
447
|
-
rbval =
|
418
|
+
rbval = rua_toruaobj(RuaThread, L, idx, R);
|
448
419
|
break;
|
449
420
|
|
450
421
|
case LUA_TLIGHTUSERDATA:
|
@@ -475,12 +446,12 @@ static VALUE rua_torbobj(lua_State *L, int idx) {
|
|
475
446
|
tblidx = lua_gettop(L);
|
476
447
|
lua_pushstring(L, REF_RBOBJ);
|
477
448
|
lua_rawget(L, tblidx);
|
478
|
-
rbobj = (VALUE)
|
449
|
+
rbobj = (VALUE) lua_touserdata(L, -1);
|
479
450
|
lua_pop(L, 2);
|
480
451
|
return rbobj;
|
481
452
|
}
|
482
453
|
|
483
|
-
static VALUE rua_tohash(lua_State *L, int idx,
|
454
|
+
static VALUE rua_tohash(lua_State *L, int idx, struct rua_state R) {
|
484
455
|
VALUE hash, key, val;
|
485
456
|
int tblidx;
|
486
457
|
|
@@ -490,8 +461,8 @@ static VALUE rua_tohash(lua_State *L, int idx, VALUE error_handler, int secure)
|
|
490
461
|
lua_pushnil(L);
|
491
462
|
|
492
463
|
while (lua_next(L, tblidx) != 0) {
|
493
|
-
key = rua_torbval(L, -2,
|
494
|
-
val = rua_torbval(L, -1,
|
464
|
+
key = rua_torbval(L, -2, R);
|
465
|
+
val = rua_torbval(L, -1, R);
|
495
466
|
rb_hash_aset(hash, key, val);
|
496
467
|
lua_pop(L, 1);
|
497
468
|
}
|
@@ -500,9 +471,8 @@ static VALUE rua_tohash(lua_State *L, int idx, VALUE error_handler, int secure)
|
|
500
471
|
return hash;
|
501
472
|
}
|
502
473
|
|
503
|
-
static void rua_pushrbval(lua_State *L, VALUE rbval,
|
504
|
-
struct
|
505
|
-
struct rua_thread *pt;
|
474
|
+
static void rua_pushrbval(lua_State *L, VALUE rbval, struct rua_state R) {
|
475
|
+
struct rua_ref *p;
|
506
476
|
|
507
477
|
switch (TYPE(rbval)) {
|
508
478
|
case T_NIL:
|
@@ -528,37 +498,37 @@ static void rua_pushrbval(lua_State *L, VALUE rbval, VALUE error_handler, int se
|
|
528
498
|
break;
|
529
499
|
|
530
500
|
case T_ARRAY:
|
531
|
-
rua_newtable_from_ary(L, rbval,
|
501
|
+
rua_newtable_from_ary(L, rbval, R);
|
532
502
|
break;
|
533
503
|
|
534
504
|
case T_HASH:
|
535
|
-
rua_newtable_from_hash(L, rbval,
|
505
|
+
rua_newtable_from_hash(L, rbval, R);
|
536
506
|
break;
|
537
507
|
|
538
508
|
default:
|
539
|
-
if (secure && (rb_equal(rb_cModule, rbval) || rb_equal(rb_cClass, rbval))) {
|
509
|
+
if (R.secure && (rb_equal(rb_cModule, rbval) || rb_equal(rb_cClass, rbval))) {
|
540
510
|
fprintf(stderr, "warning: convert insecure value %s", rua_to_sptr(rbval));
|
541
511
|
lua_pushnil(L);
|
542
512
|
} else if (rb_obj_is_kind_of(rbval, RuaFunc)) {
|
543
|
-
Data_Get_Struct(rbval, struct
|
544
|
-
lua_rawgeti(L, LUA_REGISTRYINDEX,
|
513
|
+
Data_Get_Struct(rbval, struct rua_ref, p);
|
514
|
+
lua_rawgeti(L, LUA_REGISTRYINDEX, p->ref);
|
545
515
|
} else if (rb_obj_is_kind_of(rbval, RuaThread)) {
|
546
|
-
Data_Get_Struct(rbval, struct
|
547
|
-
lua_rawgeti(L, LUA_REGISTRYINDEX,
|
516
|
+
Data_Get_Struct(rbval, struct rua_ref, p);
|
517
|
+
lua_rawgeti(L, LUA_REGISTRYINDEX, p->ref);
|
548
518
|
} else if (rua_obj_is_executable(rbval)) {
|
549
519
|
lua_pushlightuserdata(L, (void *) rbval);
|
550
|
-
lua_pushlightuserdata(L, (void *) error_handler);
|
551
|
-
lua_pushlightuserdata(L, (void *) secure);
|
520
|
+
lua_pushlightuserdata(L, (void *) R.error_handler);
|
521
|
+
lua_pushlightuserdata(L, (void *) R.secure);
|
552
522
|
lua_pushcclosure(L, rua_proc_call, 3);
|
553
523
|
} else {
|
554
|
-
rua_newtable_from_obj(L, rbval,
|
524
|
+
rua_newtable_from_obj(L, rbval, R);
|
555
525
|
}
|
556
526
|
|
557
527
|
break;
|
558
528
|
}
|
559
529
|
}
|
560
530
|
|
561
|
-
static void rua_newtable_from_ary(lua_State *L, VALUE ary,
|
531
|
+
static void rua_newtable_from_ary(lua_State *L, VALUE ary, struct rua_state R) {
|
562
532
|
VALUE entry;
|
563
533
|
int i, tblidx;
|
564
534
|
|
@@ -568,12 +538,12 @@ static void rua_newtable_from_ary(lua_State *L, VALUE ary, VALUE error_handler,
|
|
568
538
|
for (i = 0; i < RARRAY(ary)->len; i++) {
|
569
539
|
entry = rb_ary_entry(ary, i);
|
570
540
|
lua_pushnumber(L, i + 1);
|
571
|
-
rua_pushrbval(L, entry,
|
541
|
+
rua_pushrbval(L, entry, R);
|
572
542
|
lua_settable(L, tblidx);
|
573
543
|
}
|
574
544
|
}
|
575
545
|
|
576
|
-
static void rua_newtable_from_hash(lua_State *L, VALUE hash,
|
546
|
+
static void rua_newtable_from_hash(lua_State *L, VALUE hash, struct rua_state R) {
|
577
547
|
VALUE keys, key, val;
|
578
548
|
int i, tblidx;
|
579
549
|
|
@@ -584,13 +554,13 @@ static void rua_newtable_from_hash(lua_State *L, VALUE hash, VALUE error_handler
|
|
584
554
|
for (i = 0; i < RARRAY(keys)->len; i++) {
|
585
555
|
key = rb_ary_entry(keys, i);
|
586
556
|
val = rb_hash_aref(hash, key);
|
587
|
-
rua_pushrbval(L, key,
|
588
|
-
rua_pushrbval(L, val,
|
557
|
+
rua_pushrbval(L, key, R);
|
558
|
+
rua_pushrbval(L, val, R);
|
589
559
|
lua_settable(L, tblidx);
|
590
560
|
}
|
591
561
|
}
|
592
562
|
|
593
|
-
static void rua_newtable_from_obj(lua_State *L, VALUE obj,
|
563
|
+
static void rua_newtable_from_obj(lua_State *L, VALUE obj, struct rua_state R) {
|
594
564
|
VALUE methods, name, method;
|
595
565
|
int i, tblidx;
|
596
566
|
|
@@ -606,38 +576,39 @@ static void rua_newtable_from_obj(lua_State *L, VALUE obj, VALUE error_handler,
|
|
606
576
|
name = rb_ary_entry(methods, i);
|
607
577
|
method = rb_funcall(obj, rb_intern("method"), 1, name);
|
608
578
|
|
609
|
-
if (secure && rua_name_is_insecure_method(StringValuePtr(name))) {
|
579
|
+
if (R.secure && rua_name_is_insecure_method(StringValuePtr(name))) {
|
610
580
|
continue;
|
611
581
|
}
|
612
582
|
|
613
|
-
rua_pushrbval(L, name,
|
614
|
-
rua_pushrbval(L, method,
|
583
|
+
rua_pushrbval(L, name, R);
|
584
|
+
rua_pushrbval(L, method, R);
|
615
585
|
lua_settable(L, tblidx);
|
616
586
|
}
|
617
587
|
}
|
618
588
|
|
619
589
|
static int rua_proc_call(lua_State *L) {
|
620
|
-
|
621
|
-
|
590
|
+
struct rua_state R;
|
591
|
+
VALUE proc, args, retval, errargs;
|
592
|
+
int i, n, status;
|
622
593
|
|
623
594
|
proc = (VALUE) lua_touserdata(L, lua_upvalueindex(1));
|
624
|
-
error_handler = (VALUE) lua_touserdata(L, lua_upvalueindex(2));
|
625
|
-
secure = (int) lua_touserdata(L, lua_upvalueindex(3));
|
595
|
+
R.error_handler = (VALUE) lua_touserdata(L, lua_upvalueindex(2));
|
596
|
+
R.secure = (int) lua_touserdata(L, lua_upvalueindex(3));
|
626
597
|
args = rb_ary_new();
|
627
598
|
n = lua_gettop(L);
|
628
599
|
|
629
600
|
for (i = 0; i < n; i++) {
|
630
|
-
rb_ary_push(args, rua_torbval(L, i + 1,
|
601
|
+
rb_ary_push(args, rua_torbval(L, i + 1, R));
|
631
602
|
}
|
632
603
|
|
633
604
|
rb_ary_push(args, proc);
|
634
605
|
retval = rb_protect(_rua_proc_call, args, &status);
|
635
606
|
|
636
607
|
if (status != 0) {
|
637
|
-
if (rua_obj_is_executable(error_handler)) {
|
608
|
+
if (rua_obj_is_executable(R.error_handler)) {
|
638
609
|
errargs = rb_ary_new();
|
639
610
|
rb_ary_push(errargs, ruby_errinfo);
|
640
|
-
rb_ary_push(errargs, error_handler);
|
611
|
+
rb_ary_push(errargs, R.error_handler);
|
641
612
|
retval = rb_protect(_rua_proc_call, errargs, &status);
|
642
613
|
|
643
614
|
if (status != 0) {
|
@@ -648,7 +619,7 @@ static int rua_proc_call(lua_State *L) {
|
|
648
619
|
}
|
649
620
|
}
|
650
621
|
|
651
|
-
rua_pushrbval(L, retval,
|
622
|
+
rua_pushrbval(L, retval, R);
|
652
623
|
return 1;
|
653
624
|
}
|
654
625
|
|
@@ -658,32 +629,17 @@ static VALUE _rua_proc_call(VALUE args) {
|
|
658
629
|
return rb_apply(proc, rb_intern("call"), args);
|
659
630
|
}
|
660
631
|
|
661
|
-
static VALUE
|
662
|
-
struct
|
663
|
-
VALUE
|
664
|
-
|
665
|
-
f = rb_funcall(RuaFunc, rb_intern("new"), 0);
|
666
|
-
Data_Get_Struct(f, struct rua_func, p);
|
667
|
-
p->L = L;
|
668
|
-
p->error_handler = error_handler;
|
669
|
-
p->secure = secure;
|
670
|
-
lua_pushvalue(L, idx);
|
671
|
-
p->ref = luaL_ref(L, LUA_REGISTRYINDEX);
|
672
|
-
return f;
|
673
|
-
}
|
674
|
-
|
675
|
-
static VALUE rua_toruathread(lua_State *L, int idx, VALUE error_handler, int secure) {
|
676
|
-
struct rua_thread *p;
|
677
|
-
VALUE t;
|
632
|
+
static VALUE rua_toruaobj(VALUE klass, lua_State *L, int idx, struct rua_state R) {
|
633
|
+
struct rua_ref *p;
|
634
|
+
VALUE ruaobj;
|
678
635
|
|
679
|
-
|
680
|
-
Data_Get_Struct(
|
636
|
+
ruaobj = rb_funcall(klass, rb_intern("new"), 0);
|
637
|
+
Data_Get_Struct(ruaobj, struct rua_ref , p);
|
681
638
|
p->L = L;
|
682
|
-
p->
|
683
|
-
p->secure = secure;
|
639
|
+
p->R = R;
|
684
640
|
lua_pushvalue(L, idx);
|
685
641
|
p->ref = luaL_ref(L, LUA_REGISTRYINDEX);
|
686
|
-
return
|
642
|
+
return ruaobj;
|
687
643
|
}
|
688
644
|
|
689
645
|
static VALUE rua_obj_is_executable(VALUE obj) {
|
data/ext/rua.h
CHANGED
@@ -1,24 +1,20 @@
|
|
1
1
|
#ifndef __RUA_H__
|
2
2
|
#define __RUA_H__
|
3
3
|
|
4
|
-
struct
|
5
|
-
lua_State *L;
|
4
|
+
struct rua_state {
|
6
5
|
VALUE error_handler;
|
7
6
|
int secure;
|
8
7
|
};
|
9
8
|
|
10
|
-
struct
|
9
|
+
struct rua {
|
11
10
|
lua_State *L;
|
12
|
-
|
13
|
-
VALUE error_handler;
|
14
|
-
int secure;
|
11
|
+
struct rua_state R;
|
15
12
|
};
|
16
13
|
|
17
|
-
struct
|
14
|
+
struct rua_ref {
|
18
15
|
lua_State *L;
|
16
|
+
struct rua_state R;
|
19
17
|
int ref;
|
20
|
-
VALUE error_handler;
|
21
|
-
int secure;
|
22
18
|
};
|
23
19
|
|
24
20
|
void Init_rua();
|
@@ -41,18 +37,18 @@ static VALUE rua_thread_alloc(VALUE klass);
|
|
41
37
|
static VALUE rua_thread_initialize(VALUE self);
|
42
38
|
static VALUE rua_thread_resume(int argc, VALUE *argv, VALUE self);
|
43
39
|
|
44
|
-
static VALUE
|
40
|
+
static VALUE rua_tomultiretval(lua_State *L, int pretop, struct rua_state R);
|
41
|
+
static VALUE rua_torbval(lua_State *L, int idx, struct rua_state R);
|
45
42
|
static int rua_is_rbobj(lua_State *L, int idx);
|
46
43
|
static VALUE rua_torbobj(lua_State *L, int idx);
|
47
|
-
static VALUE rua_tohash(lua_State *L, int idx,
|
48
|
-
static void rua_pushrbval(lua_State *L, VALUE rbval,
|
49
|
-
static void rua_newtable_from_ary(lua_State *L, VALUE ary,
|
50
|
-
static void rua_newtable_from_hash(lua_State *L, VALUE hash,
|
51
|
-
static void rua_newtable_from_obj(lua_State *L, VALUE obj,
|
44
|
+
static VALUE rua_tohash(lua_State *L, int idx, struct rua_state R);
|
45
|
+
static void rua_pushrbval(lua_State *L, VALUE rbval, struct rua_state R);
|
46
|
+
static void rua_newtable_from_ary(lua_State *L, VALUE ary, struct rua_state R);
|
47
|
+
static void rua_newtable_from_hash(lua_State *L, VALUE hash, struct rua_state R);
|
48
|
+
static void rua_newtable_from_obj(lua_State *L, VALUE obj, struct rua_state R);
|
52
49
|
static int rua_proc_call(lua_State *L);
|
53
50
|
static VALUE _rua_proc_call(VALUE args);
|
54
|
-
static VALUE
|
55
|
-
static VALUE rua_toruathread(lua_State *L, int idx, VALUE error_handler, int secure);
|
51
|
+
static VALUE rua_toruaobj(VALUE klass, lua_State *L, int idx, struct rua_state R);
|
56
52
|
static VALUE rua_obj_is_executable(VALUE obj);
|
57
53
|
static int rua_name_is_insecure_method(const char *name);
|
58
54
|
static VALUE rua_to_s(VALUE v);
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.2
|
|
3
3
|
specification_version: 1
|
4
4
|
name: rua
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.
|
7
|
-
date: 2007-11-
|
6
|
+
version: 0.2.0
|
7
|
+
date: 2007-11-18 00:00:00 +09:00
|
8
8
|
summary: rua is a library for using Lua under Ruby.
|
9
9
|
require_paths:
|
10
10
|
- lib
|