static function asSurpriseTypedError($err, $msg = null, $p = null)
 {
     if ($msg === null) {
         $msg = "Failure: " . Std::string($err);
     }
     return tink_core__Future_Future_Impl_::sync(tink_core_Outcome::Failure(ufront_web_HttpError::wrap($err, $msg, $p)));
 }
 public function getTemplateString($viewRelativePath)
 {
     $fullPath = _hx_string_or_null($this->get_viewDirectory()) . _hx_string_or_null($viewRelativePath);
     try {
         if (file_exists($fullPath)) {
             return tink_core__Future_Future_Impl_::sync(tink_core_Outcome::Success(haxe_ds_Option::Some(sys_io_File::getContent($fullPath))));
         } else {
             return tink_core__Future_Future_Impl_::sync(tink_core_Outcome::Success(haxe_ds_Option::$None));
         }
     } catch (Exception $__hx__e) {
         $_ex_ = $__hx__e instanceof HException ? $__hx__e->e : $__hx__e;
         $e = $_ex_;
         return $e->asSurpriseError("Failed to load template " . _hx_string_or_null($viewRelativePath));
     }
 }
 public function executeResult($context)
 {
     try {
         return $context->actionContext->actionResult->executeResult($context->actionContext);
     } catch (Exception $__hx__e) {
         $_ex_ = $__hx__e instanceof HException ? $__hx__e->e : $__hx__e;
         $e = $_ex_;
         $p_methodName = "executeResult";
         $p_lineNumber = -1;
         $p_fileName = "";
         $p_customParams = new _hx_array(array("actionContext"));
         $p_className = Type::getClassName(Type::getClass($context->actionContext));
         return tink_core__Future_Future_Impl_::sync(tink_core_Outcome::Failure(ufront_web_HttpError::wrap($e, null, _hx_anonymous(array("fileName" => "MVCHandler.hx", "lineNumber" => 70, "className" => "ufront.web.MVCHandler", "methodName" => "executeResult")))));
     }
 }
 static function ofMany($futures, $gather = null)
 {
     if ($gather === null) {
         $gather = true;
     }
     $ret = tink_core__Future_Future_Impl_::sync(new _hx_array(array()));
     $_g = 0;
     while ($_g < $futures->length) {
         $f = $futures[$_g];
         ++$_g;
         $ret = tink_core__Future_Future_Impl_::flatMap($ret, array(new _hx_lambda(array(&$_g, &$f, &$futures, &$gather, &$ret), "tink_core__Future_Future_Impl__5"), 'execute'), false);
         unset($f);
     }
     if ($gather) {
         return tink_core__Future_Future_Impl_::gather($ret);
     } else {
         return $ret;
     }
 }
 public function process($onData, $partSize = null)
 {
     try {
         if ($partSize === null) {
             $partSize = 8192;
         }
         $doneTrigger = new tink_core_FutureTrigger();
         $fh = sys_io_File::read($this->tmpFileName, null);
         $pos = 0;
         $readNext = null;
         $readNext1 = null;
         $readNext1 = array(new _hx_lambda(array(&$doneTrigger, &$fh, &$onData, &$partSize, &$pos, &$readNext, &$readNext1), "ufront_web_upload_TmpFileUpload_0"), 'execute');
         $readNext = $readNext1;
         call_user_func($readNext);
         return $doneTrigger->future;
     } catch (Exception $__hx__e) {
         $_ex_ = $__hx__e instanceof HException ? $__hx__e->e : $__hx__e;
         $e1 = $_ex_;
         $data = tink_core_Outcome::Failure(tink_core_TypedError::withData(null, "Error during TmpFileUpload.process()", $e1, _hx_anonymous(array("fileName" => "TmpFileUpload.hx", "lineNumber" => 148, "className" => "ufront.web.upload.TmpFileUpload", "methodName" => "process"))));
         return tink_core__Future_Future_Impl_::sync($data);
     }
 }
 public function executeApiCall($path, $args, $remotingContext, $actionContext)
 {
     if ($remotingContext->objects->exists($path[0]) === false) {
         throw new HException("Invalid path " . _hx_string_or_null($path->join(".")));
     }
     $actionContext->handler = $this;
     $actionContext->action = $path[$path->length - 1];
     $actionContext->controller = $remotingContext->objects->get($path[0])->obj;
     $actionContext->args = $args;
     $returnType = null;
     try {
         $fieldsMeta = haxe_rtti_Meta::getFields(Type::getClass($actionContext->controller));
         $actionMeta = Reflect::field($fieldsMeta, $actionContext->action);
         $returnType = $actionMeta->returnType[0];
     } catch (Exception $__hx__e) {
         $_ex_ = $__hx__e instanceof HException ? $__hx__e->e : $__hx__e;
         $e = $_ex_;
         $returnType = 0;
     }
     $flags = $returnType;
     $result = $remotingContext->call($path, $args);
     if (($flags & 1 << ufront_api_ApiReturnType::$ARTFuture->index) !== 0) {
         return $result;
     } else {
         if (($flags & 1 << ufront_api_ApiReturnType::$ARTVoid->index) !== 0) {
             return tink_core__Future_Future_Impl_::sync(null);
         } else {
             return tink_core__Future_Future_Impl_::sync($result);
         }
     }
 }
 public function parseMultipart($onPart = null, $onData = null, $onEndPart = null)
 {
     $_g = $this;
     if (!$this->isMultipart()) {
         return ufront_core_SurpriseTools::success();
     }
     if ($this->_parsed) {
         throw new HException(ufront_web_HttpError::internalServerError("parseMultipart() has been called more than once.", null, _hx_anonymous(array("fileName" => "HttpRequest.hx", "lineNumber" => 93, "className" => "sys.ufront.web.context.HttpRequest", "methodName" => "parseMultipart"))));
     }
     $this->_parsed = true;
     if ($onPart === null) {
         $onPart = array(new _hx_lambda(array(&$_g, &$onData, &$onEndPart, &$onPart), "sys_ufront_web_context_HttpRequest_0"), 'execute');
     }
     if ($onData === null) {
         $onData = array(new _hx_lambda(array(&$_g, &$onData, &$onEndPart, &$onPart), "sys_ufront_web_context_HttpRequest_1"), 'execute');
     }
     if ($onEndPart === null) {
         $onEndPart = array(new _hx_lambda(array(&$_g, &$onData, &$onEndPart, &$onPart), "sys_ufront_web_context_HttpRequest_2"), 'execute');
     }
     $this->post = new haxe_ds_StringMap();
     $noParts = true;
     $isFile = false;
     $partName = null;
     $fileName = null;
     $currentContent = null;
     $callbackFutures = new _hx_array(array());
     $errors = new _hx_array(array());
     $processCallbackResult = array(new _hx_lambda(array(&$_g, &$callbackFutures, &$currentContent, &$errors, &$fileName, &$isFile, &$noParts, &$onData, &$onEndPart, &$onPart, &$partName), "sys_ufront_web_context_HttpRequest_3"), 'execute');
     $doEndOfPart = array(new _hx_lambda(array(&$_g, &$callbackFutures, &$currentContent, &$errors, &$fileName, &$isFile, &$noParts, &$onData, &$onEndPart, &$onPart, &$partName, &$processCallbackResult), "sys_ufront_web_context_HttpRequest_4"), 'execute');
     $doPart = array(new _hx_lambda(array(&$_g, &$callbackFutures, &$currentContent, &$doEndOfPart, &$errors, &$fileName, &$isFile, &$noParts, &$onData, &$onEndPart, &$onPart, &$partName, &$processCallbackResult), "sys_ufront_web_context_HttpRequest_5"), 'execute');
     $doData = array(new _hx_lambda(array(&$_g, &$callbackFutures, &$currentContent, &$doEndOfPart, &$doPart, &$errors, &$fileName, &$isFile, &$noParts, &$onData, &$onEndPart, &$onPart, &$partName, &$processCallbackResult), "sys_ufront_web_context_HttpRequest_6"), 'execute');
     try {
         sys_ufront_web_context__HttpRequest_WebOverride::parseMultipart($doPart, $doData);
     } catch (Exception $__hx__e) {
         $_ex_ = $__hx__e instanceof HException ? $__hx__e->e : $__hx__e;
         $e = $_ex_;
         $stack = haxe_CallStack::toString(haxe_CallStack::exceptionStack());
         $err1 = "Failed to parse multipart data: " . Std::string($e) . "\n" . _hx_string_or_null($stack);
         $errors->push($err1);
     }
     if ($noParts === false) {
         call_user_func($doEndOfPart);
     }
     if ($callbackFutures->length > 0) {
         return tink_core__Future_Future_Impl_::flatMap(tink_core__Future_Future_Impl_::ofMany($callbackFutures, null), array(new _hx_lambda(array(&$_g, &$callbackFutures, &$currentContent, &$doData, &$doEndOfPart, &$doPart, &$e, &$errors, &$fileName, &$isFile, &$noParts, &$onData, &$onEndPart, &$onPart, &$partName, &$processCallbackResult), "sys_ufront_web_context_HttpRequest_7"), 'execute'), null);
     } else {
         $data5 = tink_core_Outcome::Success(tink_core_Noise::$Noise);
         return tink_core__Future_Future_Impl_::sync($data5);
     }
 }
 public function wrapInFuture($result)
 {
     return tink_core__Future_Future_Impl_::sync($result);
 }
function ufront_app_HttpApplication_9(&$_g, &$ctx, &$done, &$flag, &$modules, &$runNext, &$runNext1)
{
    $m = $modules->shift();
    if ($flag !== null && ($ctx->completion & 1 << $flag->index) !== 0) {
        $result = tink_core_Outcome::Success(tink_core_Noise::$Noise);
        if ($done->{"list"} === null) {
            false;
        } else {
            $list = $done->{"list"};
            $done->{"list"} = null;
            $done->result = $result;
            tink_core__Callback_CallbackList_Impl_::invoke($list, $result);
            tink_core__Callback_CallbackList_Impl_::clear($list);
            true;
        }
    } else {
        if ($m === null) {
            if ($flag !== null) {
                $ctx->completion |= 1 << $flag->index;
            }
            $result1 = tink_core_Outcome::Success(tink_core_Noise::$Noise);
            if ($done->{"list"} === null) {
                false;
            } else {
                $list1 = $done->{"list"};
                $done->{"list"} = null;
                $done->result = $result1;
                tink_core__Callback_CallbackList_Impl_::invoke($list1, $result1);
                tink_core__Callback_CallbackList_Impl_::clear($list1);
                true;
            }
        } else {
            $moduleCb = isset($m->a) ? $m->a : array($m, "a");
            $_g->currentModule = $m->b;
            $moduleResult = null;
            try {
                $moduleResult = call_user_func_array($moduleCb, array($ctx));
            } catch (Exception $__hx__e) {
                $_ex_ = $__hx__e instanceof HException ? $__hx__e->e : $__hx__e;
                $e = $_ex_;
                $ctx->messages->push(_hx_anonymous(array("msg" => "Caught error " . Std::string($e) . " while executing module " . _hx_string_or_null($_g->currentModule->className) . "." . _hx_string_or_null($_g->currentModule->methodName) . " in HttpApplication.executeModules()", "pos" => _hx_anonymous(array("fileName" => "HttpApplication.hx", "lineNumber" => 405, "className" => "ufront.app.HttpApplication", "methodName" => "executeModules")), "type" => ufront_log_MessageType::$MLog)));
                $moduleResult = tink_core__Future_Future_Impl_::sync(tink_core_Outcome::Failure(ufront_web_HttpError::wrap($e, null, $_g->currentModule)));
            }
            $moduleResult(array(new _hx_lambda(array(&$_g, &$ctx, &$done, &$e, &$flag, &$m, &$moduleCb, &$moduleResult, &$modules, &$runNext, &$runNext1), "ufront_app_HttpApplication_22"), 'execute'));
        }
    }
}
 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 asFuture($data)
 {
     return tink_core__Future_Future_Impl_::sync($data);
 }
 public function commit()
 {
     return tink_core__Future_Future_Impl_::sync(tink_core_Outcome::Success(tink_core_Noise::$Noise));
 }
 public function commitSession()
 {
     if ($this->session !== null) {
         return $this->session->commit();
     } else {
         return tink_core__Future_Future_Impl_::sync(tink_core_Outcome::Success(tink_core_Noise::$Noise));
     }
 }
 public function getTemplateString($path)
 {
     return tink_core__Future_Future_Impl_::sync(tink_core_Outcome::Failure(new tink_core_TypedError(null, "Attempting to fetch template " . _hx_string_or_null($path) . " with UFViewEngine.  This is an abstract class, you must use one of the ViewEngine implementations.", _hx_anonymous(array("fileName" => "UFViewEngine.hx", "lineNumber" => 208, "className" => "ufront.view.UFViewEngine", "methodName" => "getTemplateString")))));
 }