MCPcopy Create free account
hub / github.com/Redot-Engine/redot-engine / find_custom

Method find_custom

core/variant/array.cpp:391–417  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

389}
390
391int Array::find_custom(const Callable &p_callable, int p_from) const {
392 int ret = -1;
393
394 if (p_from < 0 || size() == 0) {
395 return ret;
396 }
397
398 const Variant *argptrs[1];
399
400 for (int i = p_from; i < size(); i++) {
401 const Variant &val = _p->array[i];
402 argptrs[0] = &val;
403 Variant res;
404 Callable::CallError ce;
405 p_callable.callp(argptrs, 1, res, ce);
406 if (unlikely(ce.error != Callable::CallError::CALL_OK)) {
407 ERR_FAIL_V_MSG(ret, vformat("Error calling method from 'find_custom': %s.", Variant::get_callable_error_text(p_callable, argptrs, 1, ce)));
408 }
409
410 ERR_FAIL_COND_V_MSG(res.get_type() != Variant::Type::BOOL, ret, "Error on method from 'find_custom': Return type of callable must be boolean.");
411 if (res.operator bool()) {
412 return i;
413 }
414 }
415
416 return ret;
417}
418
419int Array::rfind(const Variant &p_value, int p_from) const {
420 if (_p->array.is_empty()) {

Callers 1

test_array.hFile · 0.80

Calls 3

vformatFunction · 0.85
callpMethod · 0.45
get_typeMethod · 0.45

Tested by

no test coverage detected