public function call($path, $params) { if ($path->length < 2) { throw new HException("Invalid path '" . _hx_string_or_null($path->join(".")) . "'"); } $inf = $this->objects->get($path[0]); if ($inf === null) { throw new HException("No such object " . _hx_string_or_null($path[0])); } $o = $inf->obj; $m = Reflect::field($o, $path[1]); if ($path->length > 2) { if (!$inf->rec) { throw new HException("Can't access " . _hx_string_or_null($path->join("."))); } $_g1 = 2; $_g = $path->length; while ($_g1 < $_g) { $i = $_g1++; $o = $m; $m = Reflect::field($o, $path[$i]); unset($i); } } if (!Reflect::isFunction($m)) { throw new HException("No such method " . _hx_string_or_null($path->join("."))); } return Reflect::callMethod($o, $m, $params); }
public function call() { $obj = Type::createEmptyInstance($this->scope); $method = Reflect::field($obj, $this->func); if ($method === null) { throw new HException($obj . " does not contain " . $this->func); } if (!Reflect::isFunction($method)) { throw new HException($this->func . " is not a method of " . $obj); } $ret = Reflect::callMethod($obj, $method, new _hx_array(array())); haxe_Log::trace("Returned: " . $ret, _hx_anonymous(array("fileName" => "Route.hx", "lineNumber" => 28, "className" => "sinatra.Route", "methodName" => "call"))); return Std::is($ret, _hx_qtype("String")) ? new sinatra_View($ret, null) : eval("if(isset(\$this)) \$»this =& \$this;\$tmp = \$ret;\n\t\t\t\$»r = (Std::is(\$tmp, _hx_qtype(\"sinatra.View\")) ? \$tmp : eval(\"if(isset(\\\$this)) \\\$»this =& \\\$this;throw new HException(\\\"Class cast error\\\");\n\t\t\t\treturn \\\$»r2;\n\t\t\t\"));\n\t\t\treturn \$»r;\n\t\t"); }
static function compareMethods($f1, $f2) { if (_hx_equal($f1, $f2)) { return true; } if (!Reflect::isFunction($f1) || !Reflect::isFunction($f2)) { return false; } if (is_array($f1) && is_array($f1)) { return $f1[0] === $f2[0] && $f1[1] == $f2[1]; } if (is_string($f1) && is_string($f2)) { return _hx_equal($f1, $f2); } return false; }
static function createEnum($e, $constr, $params = null) { $f = Reflect::field($e, $constr); if ($f === null) { throw new HException("No such constructor " . _hx_string_or_null($constr)); } if (Reflect::isFunction($f)) { if ($params === null) { throw new HException("Constructor " . _hx_string_or_null($constr) . " need parameters"); } return Reflect::callMethod($e, $f, $params); } if ($params !== null && $params->length !== 0) { throw new HException("Constructor " . _hx_string_or_null($constr) . " does not need parameters"); } return $f; }
public function fieldsString($v, $fields) { $this->buf->b .= "{"; $len = $fields->length; $last = $len - 1; $first = true; $_g = 0; while ($_g < $len) { $i = $_g++; $f = $fields[$i]; $value = Reflect::field($v, $f); if (Reflect::isFunction($value)) { continue; } if ($first) { $this->nind++; $first = false; } else { $this->buf->b .= ","; } if ($this->pretty) { $this->buf->b .= "\n"; } if ($this->pretty) { $v1 = null; $c = $this->indent; $l = $this->nind * strlen($this->indent); if (strlen($c) === 0 || strlen("") >= $l) { $v1 = ""; } else { $v1 = str_pad("", Math::ceil(($l - strlen("")) / strlen($c)) * strlen($c) + strlen(""), $c, STR_PAD_LEFT); } unset($l, $c); $this->buf->add($v1); unset($v1); } $this->quote($f); $this->buf->b .= ":"; if ($this->pretty) { $this->buf->b .= " "; } $this->write($f, $value); if ($i === $last) { $this->nind--; if ($this->pretty) { $this->buf->b .= "\n"; } if ($this->pretty) { $v2 = null; $c1 = $this->indent; $l1 = $this->nind * strlen($this->indent); if (strlen($c1) === 0 || strlen("") >= $l1) { $v2 = ""; } else { $v2 = str_pad("", Math::ceil(($l1 - strlen("")) / strlen($c1)) * strlen($c1) + strlen(""), $c1, STR_PAD_LEFT); } unset($l1, $c1); $this->buf->add($v2); unset($v2); } } unset($value, $i, $f); } $this->buf->b .= "}"; }
static function allEnums($e) { $all = new _hx_array(array()); $_g = 0; $_g1 = Type::getEnumConstructs($e); while ($_g < $_g1->length) { $c = $_g1[$_g]; ++$_g; $v = Reflect::field($e, $c); if (!Reflect::isFunction($v)) { $all->push($v); } unset($v, $c); } return $all; }