fx: handle nullptr arguments in all iterator functions
This commit is contained in:
+28
-6
@@ -25,6 +25,10 @@ static enum fx_status iterator_set_status(
|
|||||||
|
|
||||||
const fx_iterator *fx_iterator_begin(const fx_iterable *it)
|
const fx_iterator *fx_iterator_begin(const fx_iterable *it)
|
||||||
{
|
{
|
||||||
|
if (!it) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
FX_CLASS_DISPATCH_VIRTUAL_0(
|
FX_CLASS_DISPATCH_VIRTUAL_0(
|
||||||
fx_iterable,
|
fx_iterable,
|
||||||
FX_TYPE_ITERABLE,
|
FX_TYPE_ITERABLE,
|
||||||
@@ -35,11 +39,19 @@ const fx_iterator *fx_iterator_begin(const fx_iterable *it)
|
|||||||
|
|
||||||
enum fx_status fx_iterator_get_status(const fx_iterator *it)
|
enum fx_status fx_iterator_get_status(const fx_iterator *it)
|
||||||
{
|
{
|
||||||
|
if (!it) {
|
||||||
|
return FX_ERR_NO_DATA;
|
||||||
|
}
|
||||||
|
|
||||||
FX_CLASS_DISPATCH_STATIC_0(FX_TYPE_ITERATOR, iterator_get_status, it);
|
FX_CLASS_DISPATCH_STATIC_0(FX_TYPE_ITERATOR, iterator_get_status, it);
|
||||||
}
|
}
|
||||||
|
|
||||||
enum fx_status fx_iterator_set_status(const fx_iterator *it, fx_status status)
|
enum fx_status fx_iterator_set_status(const fx_iterator *it, fx_status status)
|
||||||
{
|
{
|
||||||
|
if (!it) {
|
||||||
|
return FX_ERR_NO_DATA;
|
||||||
|
}
|
||||||
|
|
||||||
FX_CLASS_DISPATCH_STATIC(
|
FX_CLASS_DISPATCH_STATIC(
|
||||||
FX_TYPE_ITERATOR,
|
FX_TYPE_ITERATOR,
|
||||||
iterator_set_status,
|
iterator_set_status,
|
||||||
@@ -49,11 +61,14 @@ enum fx_status fx_iterator_set_status(const fx_iterator *it, fx_status status)
|
|||||||
|
|
||||||
enum fx_status fx_iterator_move_next(const fx_iterator *it)
|
enum fx_status fx_iterator_move_next(const fx_iterator *it)
|
||||||
{
|
{
|
||||||
|
if (!it) {
|
||||||
|
return FX_ERR_NO_DATA;
|
||||||
|
}
|
||||||
|
|
||||||
enum fx_status status = FX_ERR_NOT_SUPPORTED;
|
enum fx_status status = FX_ERR_NOT_SUPPORTED;
|
||||||
|
|
||||||
fx_iterator_class *iface = fx_object_get_interface(
|
fx_iterator_class *iface
|
||||||
it,
|
= fx_object_get_interface(it, FX_TYPE_ITERATOR);
|
||||||
FX_TYPE_ITERATOR);
|
|
||||||
if (iface && iface->it_move_next) {
|
if (iface && iface->it_move_next) {
|
||||||
status = iface->it_move_next(it);
|
status = iface->it_move_next(it);
|
||||||
}
|
}
|
||||||
@@ -66,6 +81,10 @@ enum fx_status fx_iterator_move_next(const fx_iterator *it)
|
|||||||
|
|
||||||
const fx_value *fx_iterator_get_value(const fx_iterator *it)
|
const fx_value *fx_iterator_get_value(const fx_iterator *it)
|
||||||
{
|
{
|
||||||
|
if (!it) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
FX_CLASS_DISPATCH_VIRTUAL_0(
|
FX_CLASS_DISPATCH_VIRTUAL_0(
|
||||||
fx_iterator,
|
fx_iterator,
|
||||||
FX_TYPE_ITERATOR,
|
FX_TYPE_ITERATOR,
|
||||||
@@ -76,11 +95,14 @@ const fx_value *fx_iterator_get_value(const fx_iterator *it)
|
|||||||
|
|
||||||
fx_status fx_iterator_erase(fx_iterator *it)
|
fx_status fx_iterator_erase(fx_iterator *it)
|
||||||
{
|
{
|
||||||
|
if (!it) {
|
||||||
|
return FX_ERR_NO_DATA;
|
||||||
|
}
|
||||||
|
|
||||||
enum fx_status status = FX_ERR_NOT_SUPPORTED;
|
enum fx_status status = FX_ERR_NOT_SUPPORTED;
|
||||||
|
|
||||||
fx_iterator_class *iface = fx_object_get_interface(
|
fx_iterator_class *iface
|
||||||
it,
|
= fx_object_get_interface(it, FX_TYPE_ITERATOR);
|
||||||
FX_TYPE_ITERATOR);
|
|
||||||
if (iface && iface->it_erase) {
|
if (iface && iface->it_erase) {
|
||||||
status = iface->it_erase(it);
|
status = iface->it_erase(it);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user