| Новости | FAQ | Авторы | Документация | В действии | Библиотека |
| Инструменты | Полезные ссылки | Хостинги | Скачать | Примеры | Форум |
G_Z 29.09.2016 22:30
@is[object;type;context]
# $object string
# $type string
# [$context] junction
#
# $result bool
# Проверяет имеет ли указанный по имени объект заданный тип.
^if($context is void){
$context[$caller.self]
}
$result(false)
$methods[^reflection:methods[$context.CLASS_NAME]]
^try{
$result(
(
^methods.contains[$object]
&& ^reflection:method[$context;$object] is $type
)
|| (
^reflection:is[$object;$type;$context]
&& $context.$object is $type
)
)
}{
$exception.handled(
$exception.type eq 'parser.runtime'
&& (
# ошибка при проверке string
^exception.comment.pos[element can not be fetched from string] > -1
|| ^exception.comment.pos[it has no elements] > -1
# ошибка при проверке таблицы
|| ^exception.comment.pos[column not found] > -1
# ошибка при проверке regex и console
|| ^exception.comment.pos[reading of invalid field] > -1
)
)
}Работает, конечно.