33 |
33 |
VALUE rb_cData;
|
34 |
34 |
|
35 |
35 |
VALUE rb_cNilClass;
|
|
36 |
VALUE rb_mBool;
|
36 |
37 |
VALUE rb_cTrueClass;
|
37 |
38 |
VALUE rb_cFalseClass;
|
|
39 |
VALUE rb_mTrue;
|
|
40 |
VALUE rb_mFalse;
|
38 |
41 |
|
39 |
42 |
#define id_eq idEq
|
40 |
43 |
#define id_eql idEqlP
|
... | ... | |
1386 |
1389 |
return Qfalse;
|
1387 |
1390 |
}
|
1388 |
1391 |
|
|
1392 |
static VALUE
|
|
1393 |
rb_bool_append_features(VALUE module, VALUE includeto)
|
|
1394 |
{
|
|
1395 |
if ((includeto != rb_cFalseClass) && (includeto != rb_cTrueClass)) {
|
|
1396 |
rb_raise(rb_eTypeError, "'%s' isn't FalseClass nor TrueClass",
|
|
1397 |
rb_class2name(includeto));
|
|
1398 |
}
|
|
1399 |
|
|
1400 |
return module;
|
|
1401 |
}
|
|
1402 |
|
|
1403 |
/*
|
|
1404 |
* call-seq:
|
|
1405 |
* False === nil -> true
|
|
1406 |
* False === false -> true
|
|
1407 |
* False === true -> false
|
|
1408 |
* False === <anything_else> -> false
|
|
1409 |
*
|
|
1410 |
* Only the objects <i>nil</i> and <i>false</i> respond <code>true</code>.
|
|
1411 |
* Others respond <code>false</code>.
|
|
1412 |
*/
|
|
1413 |
|
|
1414 |
static VALUE
|
|
1415 |
rb_false_rtest(VALUE obj1, VALUE obj2)
|
|
1416 |
{
|
|
1417 |
VALUE result;
|
|
1418 |
|
|
1419 |
result = rb_funcall(obj2, id_eq, 1, Qnil);
|
|
1420 |
if (RTEST(result)) return Qtrue;
|
|
1421 |
|
|
1422 |
result = rb_funcall(obj2, id_eq, 1, Qfalse);
|
|
1423 |
if (RTEST(result)) return Qtrue;
|
|
1424 |
|
|
1425 |
return Qfalse;
|
|
1426 |
}
|
|
1427 |
|
|
1428 |
/*
|
|
1429 |
* call-seq:
|
|
1430 |
* True === nil -> false
|
|
1431 |
* True === false -> false
|
|
1432 |
* True === true -> true
|
|
1433 |
* True === <anything_else> -> true
|
|
1434 |
*
|
|
1435 |
* Only the objects <i>nil</i> and <i>false</i> respond <code>false</code>.
|
|
1436 |
* Others respond <code>true</code>.
|
|
1437 |
*/
|
|
1438 |
|
|
1439 |
static VALUE
|
|
1440 |
rb_true_rtest(VALUE obj1, VALUE obj2)
|
|
1441 |
{
|
|
1442 |
VALUE result;
|
|
1443 |
|
|
1444 |
result = rb_funcall(obj2, id_eq, 1, Qnil);
|
|
1445 |
if (!RTEST(result)) {
|
|
1446 |
result = rb_funcall(obj2, id_eq, 1, Qfalse);
|
|
1447 |
if (!RTEST(result)) return Qtrue;
|
|
1448 |
}
|
|
1449 |
|
|
1450 |
return Qfalse;
|
|
1451 |
}
|
1389 |
1452 |
|
1390 |
1453 |
/*
|
1391 |
1454 |
* call-seq:
|
... | ... | |
3445 |
3508 |
rb_cData = rb_define_class("Data", rb_cObject);
|
3446 |
3509 |
rb_undef_alloc_func(rb_cData);
|
3447 |
3510 |
|
|
3511 |
rb_mBool = rb_define_module("Bool");
|
|
3512 |
rb_define_singleton_method(rb_mBool, "append_features", rb_bool_append_features, 1);
|
|
3513 |
|
3448 |
3514 |
rb_cTrueClass = rb_define_class("TrueClass", rb_cObject);
|
|
3515 |
rb_include_module(rb_cTrueClass, rb_mBool);
|
3449 |
3516 |
rb_define_method(rb_cTrueClass, "to_s", true_to_s, 0);
|
3450 |
3517 |
rb_define_alias(rb_cTrueClass, "inspect", "to_s");
|
3451 |
3518 |
rb_define_method(rb_cTrueClass, "&", true_and, 1);
|
... | ... | |
3459 |
3526 |
rb_define_global_const("TRUE", Qtrue);
|
3460 |
3527 |
|
3461 |
3528 |
rb_cFalseClass = rb_define_class("FalseClass", rb_cObject);
|
|
3529 |
rb_include_module(rb_cFalseClass, rb_mBool);
|
3462 |
3530 |
rb_define_method(rb_cFalseClass, "to_s", false_to_s, 0);
|
3463 |
3531 |
rb_define_alias(rb_cFalseClass, "inspect", "to_s");
|
3464 |
3532 |
rb_define_method(rb_cFalseClass, "&", false_and, 1);
|