public function _makeApiCall($method, $args, $flags, $pos = null) { if (!php_Boot::$skip_constructor) { $_g = $this; $remotingCallString = "" . _hx_string_or_null($this->className) . "." . _hx_string_or_null($method) . "(" . _hx_string_or_null($args->join(",")) . ")"; $callApi = array(new _hx_lambda(array(&$_g, &$args, &$flags, &$method, &$pos, &$remotingCallString), "ufront_api_UFAsyncApi_0"), 'execute'); $returnError = array(new _hx_lambda(array(&$_g, &$args, &$callApi, &$flags, &$method, &$pos, &$remotingCallString), "ufront_api_UFAsyncApi_1"), 'execute'); if (($flags & 1 << ufront_api_ApiReturnType::$ARTVoid->index) !== 0) { try { call_user_func($callApi); return tink_core__Future_Future_Impl_::sync(tink_core_Outcome::Success(null)); } catch (Exception $__hx__e) { $_ex_ = $__hx__e instanceof HException ? $__hx__e->e : $__hx__e; $e1 = $_ex_; return call_user_func_array($returnError, array($e1)); } } else { if (($flags & 1 << ufront_api_ApiReturnType::$ARTFuture->index) !== 0 && ($flags & 1 << ufront_api_ApiReturnType::$ARTOutcome->index) !== 0) { try { $surprise = call_user_func($callApi); return tink_core__Future_Future_Impl_::map($surprise, array(new _hx_lambda(array(&$_g, &$args, &$callApi, &$flags, &$method, &$pos, &$remotingCallString, &$returnError, &$surprise), "ufront_api_UFAsyncApi_2"), 'execute'), null); } catch (Exception $__hx__e) { $_ex_ = $__hx__e instanceof HException ? $__hx__e->e : $__hx__e; $e2 = $_ex_; return call_user_func_array($returnError, array($e2)); } } else { if (($flags & 1 << ufront_api_ApiReturnType::$ARTFuture->index) !== 0) { try { $future = call_user_func($callApi); return tink_core__Future_Future_Impl_::map($future, array(new _hx_lambda(array(&$_g, &$args, &$callApi, &$flags, &$future, &$method, &$pos, &$remotingCallString, &$returnError), "ufront_api_UFAsyncApi_3"), 'execute'), null); } catch (Exception $__hx__e) { $_ex_ = $__hx__e instanceof HException ? $__hx__e->e : $__hx__e; $e3 = $_ex_; return call_user_func_array($returnError, array($e3)); } } else { if (($flags & 1 << ufront_api_ApiReturnType::$ARTOutcome->index) !== 0) { try { $outcome = call_user_func($callApi); switch ($outcome->index) { case 0: $data2 = _hx_deref($outcome)->params[0]; return tink_core__Future_Future_Impl_::sync(tink_core_Outcome::Success($data2)); break; case 1: $err1 = _hx_deref($outcome)->params[0]; return tink_core__Future_Future_Impl_::sync(tink_core_Outcome::Failure(ufront_web_HttpError::remotingError(ufront_remoting_RemotingError::RApiFailure($remotingCallString, $err1), $pos))); break; } } catch (Exception $__hx__e) { $_ex_ = $__hx__e instanceof HException ? $__hx__e->e : $__hx__e; $e4 = $_ex_; return call_user_func_array($returnError, array($e4)); } } else { try { $result1 = call_user_func($callApi); return tink_core__Future_Future_Impl_::sync(tink_core_Outcome::Success($result1)); } catch (Exception $__hx__e) { $_ex_ = $__hx__e instanceof HException ? $__hx__e->e : $__hx__e; $e5 = $_ex_; return call_user_func_array($returnError, array($e5)); } } } } } } }
static function processResponse($response, $onResult, $errorHandler, $remotingCallString) { $ret = null; $stack = null; $hxrFound = false; $errors = new _hx_array(array()); $onError = ufront_remoting_RemotingUtil::wrapErrorHandler($errorHandler); if (_hx_substr($response, 0, 2) !== "hx") { call_user_func_array($onError, array(ufront_remoting_RemotingError::RNoRemotingResult($remotingCallString, $response))); } else { $_g = 0; $_g1 = _hx_explode("\n", $response); while ($_g < $_g1->length) { $line = $_g1[$_g]; ++$_g; if ($line === "") { continue; } $_g2 = _hx_substr($line, 0, 3); switch ($_g2) { case "hxr": $s = new haxe_Unserializer(_hx_substr($line, 3, null)); try { $ret = $s->unserialize(); } catch (Exception $__hx__e) { $_ex_ = $__hx__e instanceof HException ? $__hx__e->e : $__hx__e; $e = $_ex_; $ret = $errors->push(ufront_remoting_RemotingError::RUnserializeFailed($remotingCallString, _hx_substr($line, 3, null), "" . Std::string($e))); } $hxrFound = true; break; case "hxt": $s1 = new haxe_Unserializer(_hx_substr($line, 3, null)); $m = null; try { $m = $s1->unserialize(); } catch (Exception $__hx__e) { $_ex_ = $__hx__e instanceof HException ? $__hx__e->e : $__hx__e; $e1 = $_ex_; $m = $errors->push(ufront_remoting_RemotingError::RUnserializeFailed($remotingCallString, _hx_substr($line, 3, null), "" . Std::string($e1))); } $m->pos->fileName = "[R]" . _hx_string_or_null($m->pos->fileName); haxe_Log::trace("[" . Std::string($m->type) . "]" . Std::string($m->msg), $m->pos); break; case "hxs": $s2 = new haxe_Unserializer(_hx_substr($line, 3, null)); try { $stack = $s2->unserialize(); } catch (Exception $__hx__e) { $_ex_ = $__hx__e instanceof HException ? $__hx__e->e : $__hx__e; $e2 = $_ex_; $stack = $errors->push(ufront_remoting_RemotingError::RUnserializeFailed($remotingCallString, _hx_substr($line, 3, null), "" . Std::string($e2))); } break; case "hxe": $s3 = new haxe_Unserializer(_hx_substr($line, 3, null)); try { $ret = $s3->unserialize(); } catch (Exception $__hx__e) { $_ex_ = $__hx__e instanceof HException ? $__hx__e->e : $__hx__e; $e3 = $_ex_; $ret = $errors->push(ufront_remoting_RemotingError::RServerSideException($remotingCallString, $e3, $stack)); } break; default: $errors->push(ufront_remoting_RemotingError::RUnserializeFailed($remotingCallString, $line, "Invalid line in response")); break; } unset($_g2); unset($line); } } if ($errors->length === 0) { if ($hxrFound) { try { call_user_func_array($onResult, array($ret)); } catch (Exception $__hx__e) { $_ex_ = $__hx__e instanceof HException ? $__hx__e->e : $__hx__e; $e4 = $_ex_; call_user_func_array($onError, array(ufront_remoting_RemotingError::RClientCallbackException($remotingCallString, $e4))); } } else { call_user_func_array($onError, array(ufront_remoting_RemotingError::RNoRemotingResult($remotingCallString, $response))); } } else { $_g3 = 0; while ($_g3 < $errors->length) { $err = $errors[$_g3]; ++$_g3; call_user_func_array($onError, array($err)); unset($err); } } }