1.1 --- a/templates/ops.c Fri Oct 28 22:58:50 2016 +0200
1.2 +++ b/templates/ops.c Sat Oct 29 00:47:12 2016 +0200
1.3 @@ -62,14 +62,24 @@
1.4
1.5 /* Attribute testing operations. */
1.6
1.7 -int __test_specific_instance(__ref obj, __ref type)
1.8 +__ref __test_specific_instance(__ref obj, __ref type)
1.9 {
1.10 - return __get_class(obj) == type;
1.11 + return __get_class(obj) == type ? obj : 0;
1.12 }
1.13
1.14 -int __test_common_instance(__ref obj, int pos, int code)
1.15 +__ref __test_common_instance(__ref obj, int pos, int code)
1.16 +{
1.17 + return __HASATTR(__get_class(obj), pos, code) ? obj : 0;
1.18 +}
1.19 +
1.20 +__ref __test_common_object(__ref obj, int pos, int code)
1.21 {
1.22 - return __HASATTR(__get_class(obj), pos, code);
1.23 + return __test_common_type(obj, pos, code) || __test_common_instance(obj, pos, code) ? obj : 0;
1.24 +}
1.25 +
1.26 +__ref __test_common_type(__ref obj, int pos, int code)
1.27 +{
1.28 + return __HASATTR(obj, pos, code) ? obj : 0;
1.29 }
1.30
1.31 /* Attribute testing and retrieval operations. */
1.32 @@ -186,7 +196,7 @@
1.33
1.34 /* Type testing. */
1.35
1.36 -int __ISFUNC(__ref obj)
1.37 +__ref __ISFUNC(__ref obj)
1.38 {
1.39 return __test_specific_instance(obj, &__FUNCTION_TYPE);
1.40 }