bool run_intercept_handler_for_invokefunc(TypedValue* retval, const Func* f, CArrRef params, ObjectData* this_, StringData* invName, Variant* ihandler) { using namespace HPHP::VM::Transl; ASSERT(ihandler); ASSERT(retval); Variant doneFlag = true; Array args = params; if (invName) { // This is a magic call, so we need to shuffle the args HphpArray* magicArgs = NEW(HphpArray)(2); magicArgs->append(invName, false); magicArgs->append(params, false); args = magicArgs; } Array intArgs = CREATE_VECTOR5(f->fullNameRef(), (this_ ? Variant(Object(this_)) : null), args, ihandler->asCArrRef()[1], ref(doneFlag)); call_intercept_handler<false>(retval, intArgs, NULL, ihandler); // $done is true, meaning don't enter the intercepted function. return !doneFlag.toBoolean(); }
// Returned array has refcount one! Caller must not incref. HphpArray* pack_args_into_array(ActRec* ar, int nargs) { HphpArray* argArray = HphpArray::MakeReserve(nargs); for (int i = 0; i < nargs; ++i) { TypedValue* tv = (TypedValue*)(ar) - (i+1); argArray->HphpArray::appendWithRef(tvAsCVarRef(tv), false); } if (!ar->hasInvName()) { // If this is not a magic call, we're done return argArray; } // This is a magic call, so we need to shuffle the args HphpArray* magicArgs = HphpArray::MakeReserve(2); magicArgs->append(ar->getInvName(), false); magicArgs->append(argArray, false); return magicArgs; }