public function remove_trailing_slash($s) { if (_hx_char_at($s, strlen($s) - 1) === "/") { $s = _hx_substr($s, 0, strlen($s) - 1); } return $s; }
public function getCell($x, $y) { if ($x === 0) { $v = $this->getCellView(); $txt = $v->toString($this->all->getCell($x, $y)); if (_hx_char_at($txt, 0) === "@") { return _hx_substr($txt, 1, strlen($txt)); } } return $this->all->getCell($x, $y); }
public function base26($num) { $alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; if ($num < 0) { return "-"; } $out = ""; do { $out = _hx_string_or_null($out) . _hx_string_or_null(_hx_char_at($alpha, _hx_mod($num, 26))); $num = Math::floor($num / 26) - 1; } while ($num >= 0); return $out; }
public function renderCell($v, $d) { if ($d === null) { return "NULL"; } $str = $v->toString($d); $need_quote = false; $_g1 = 0; $_g = strlen($str); while ($_g1 < $_g) { $i = $_g1++; $ch = _hx_char_at($str, $i); if ($ch === "\"" || $ch === "'" || $ch === $this->delim || $ch === "\r" || $ch === "\n" || $ch === "\t" || $ch === " ") { $need_quote = true; break; } unset($i, $ch); } $result = ""; if ($need_quote) { $result .= "\""; } $line_buf = ""; $_g11 = 0; $_g2 = strlen($str); while ($_g11 < $_g2) { $i1 = $_g11++; $ch1 = _hx_char_at($str, $i1); if ($ch1 === "\"") { $result .= "\""; } if ($ch1 !== "\r" && $ch1 !== "\n") { if (strlen($line_buf) > 0) { $result .= _hx_string_or_null($line_buf); $line_buf = ""; } $result .= _hx_string_or_null($ch1); } else { $line_buf .= _hx_string_or_null($ch1); } unset($i1, $ch1); } if ($need_quote) { $result .= "\""; } return $result; }
static function create() { $s = new _hx_array(array()); $_g = 0; while ($_g < 8) { $i = $_g++; $s[$i] = _hx_char_at("0123456789ABCDEF", Math::floor(Math::random() * 16)); unset($i); } $s[8] = "-"; $_g1 = 9; while ($_g1 < 13) { $i1 = $_g1++; $s[$i1] = _hx_char_at("0123456789ABCDEF", Math::floor(Math::random() * 16)); unset($i1); } $s[13] = "-"; $s[14] = "4"; $_g2 = 15; while ($_g2 < 18) { $i2 = $_g2++; $s[$i2] = _hx_char_at("0123456789ABCDEF", Math::floor(Math::random() * 16)); unset($i2); } $s[18] = "-"; $s[19] = "" . _hx_string_or_null(_hx_char_at("89AB", Math::floor(Math::random() * 4))); $_g3 = 20; while ($_g3 < 23) { $i3 = $_g3++; $s[$i3] = _hx_char_at("0123456789ABCDEF", Math::floor(Math::random() * 16)); unset($i3); } $s[23] = "-"; $_g4 = 24; while ($_g4 < 36) { $i4 = $_g4++; $s[$i4] = _hx_char_at("0123456789ABCDEF", Math::floor(Math::random() * 16)); unset($i4); } return $s->join(""); }
static function htmlUnescape($input) { $output = ""; $start = 0; $position = _hx_index_of($input, "&", $start); while ($position !== -1) { $output .= _hx_substr($input, $start, $position - $start); if (_hx_char_at($input, $position + 1) === "#") { $startPosition = $position + 2; $endPosition = _hx_index_of($input, ";", $startPosition); if ($endPosition !== -1) { $number = _hx_substr($input, $startPosition, $endPosition - $startPosition); if (StringTools::startsWith($number, "x")) { $number = "0" . $number; } $charCode = Std::parseInt($number); $output .= com_wiris_util_xml_WXmlUtils_0($charCode, $endPosition, $input, $number, $output, $position, $start, $startPosition); $start = $endPosition + 1; unset($number, $charCode); } else { $output .= "&"; $start = $position + 1; } unset($startPosition, $endPosition); } else { $output .= "&"; $start = $position + 1; } $position = _hx_index_of($input, "&", $start); } $output .= _hx_substr($input, $start, strlen($input) - $start); $output = str_replace("<", "<", $output); $output = str_replace(">", ">", $output); $output = str_replace(""", "\"", $output); $output = str_replace("'", "'", $output); $output = str_replace("&", "&", $output); return $output; }
public function splitSchema($db, $name, $sql) { $preamble = ""; $parts = new _hx_array(array()); $double_quote = false; $single_quote = false; $token = ""; $nesting = 0; $_g1 = 0; $_g = strlen($sql); while ($_g1 < $_g) { $i = $_g1++; $ch = _hx_char_at($sql, $i); if ($double_quote || $single_quote) { if ($double_quote) { if ($ch === "\"") { $double_quote = false; } } if ($single_quote) { if ($ch === "'") { $single_quote = false; } } $token .= _hx_string_or_null($ch); continue; } $brk = false; if ($ch === "(") { $nesting++; if ($nesting === 1) { $brk = true; } } else { if ($ch === ")") { $nesting--; if ($nesting === 0) { $brk = true; } } } if ($ch === ",") { $brk = true; if ($nesting === 1) { } } if ($brk) { if (_hx_char_at($token, 0) === " ") { $token = _hx_substr($token, 1, strlen($token)); } if ($preamble === "") { $preamble = $token; } else { $parts->push($token); } $token = ""; } else { $token .= _hx_string_or_null($ch); } unset($i, $ch, $brk); } $cols = $db->getColumns($name); $name2part = new haxe_ds_StringMap(); $name2col = new haxe_ds_StringMap(); $_g11 = 0; $_g2 = $cols->length; while ($_g11 < $_g2) { $i1 = $_g11++; $col = $cols[$i1]; $name2part->set($col->name, $parts[$i1]); $name2col->set($col->name, $cols[$i1]); unset($i1, $col); } return _hx_anonymous(array("preamble" => $preamble, "parts" => $parts, "name2part" => $name2part, "columns" => $cols, "name2column" => $name2col)); }
public function encodeString($sb, $s) { $sb->add("\""); $i = null; $_g1 = 0; $_g = strlen($s); while ($_g1 < $_g) { $i1 = $_g1++; $c = _hx_char_code_at($s, $i1); if ($c === 34) { $sb->add("\\\""); } else { if ($c === 13) { $sb->add("\\r"); } else { if ($c === 10) { $sb->add("\\n"); } else { if ($c === 9) { $sb->add("\\t"); } else { if ($c === 92) { $sb->add("\\\\"); } else { $sb->add(_hx_char_at($s, $i1)); } } } } } unset($i1, $c); } $sb->add("\""); }
public function serialize($v) { $_g = Type::typeof($v); switch ($_g->index) { case 0: $this->buf->add("n"); break; case 1: $v1 = $v; if ($v1 === 0) { $this->buf->add("z"); return; } $this->buf->add("i"); $this->buf->add($v1); break; case 2: $v2 = $v; if (Math::isNaN($v2)) { $this->buf->add("k"); } else { if (!Math::isFinite($v2)) { $this->buf->add($v2 < 0 ? "m" : "p"); } else { $this->buf->add("d"); $this->buf->add($v2); } } break; case 3: $this->buf->add($v ? "t" : "f"); break; case 6: $c = _hx_deref($_g)->params[0]; if (is_object($_t = $c) && !$_t instanceof Enum ? $_t === _hx_qtype("String") : $_t == _hx_qtype("String")) { $this->serializeString($v); return; } if ($this->useCache && $this->serializeRef($v)) { return; } switch ($c) { case _hx_qtype("Array"): $ucount = 0; $this->buf->add("a"); $l = _hx_len($v); $_g1 = 0; while ($_g1 < $l) { $i = $_g1++; if ($v[$i] === null) { $ucount++; } else { if ($ucount > 0) { if ($ucount === 1) { $this->buf->add("n"); } else { $this->buf->add("u"); $this->buf->add($ucount); } $ucount = 0; } $this->serialize($v[$i]); } unset($i); } if ($ucount > 0) { if ($ucount === 1) { $this->buf->add("n"); } else { $this->buf->add("u"); $this->buf->add($ucount); } } $this->buf->add("h"); break; case _hx_qtype("List"): $this->buf->add("l"); $v3 = $v; if (null == $v3) { throw new HException('null iterable'); } $__hx__it = $v3->iterator(); while ($__hx__it->hasNext()) { unset($i1); $i1 = $__hx__it->next(); $this->serialize($i1); } $this->buf->add("h"); break; case _hx_qtype("Date"): $d = $v; $this->buf->add("v"); $this->buf->add($d->getTime()); break; case _hx_qtype("haxe.ds.StringMap"): $this->buf->add("b"); $v4 = $v; if (null == $v4) { throw new HException('null iterable'); } $__hx__it = $v4->keys(); while ($__hx__it->hasNext()) { unset($k); $k = $__hx__it->next(); $this->serializeString($k); $this->serialize($v4->get($k)); } $this->buf->add("h"); break; case _hx_qtype("haxe.ds.IntMap"): $this->buf->add("q"); $v5 = $v; if (null == $v5) { throw new HException('null iterable'); } $__hx__it = $v5->keys(); while ($__hx__it->hasNext()) { unset($k1); $k1 = $__hx__it->next(); $this->buf->add(":"); $this->buf->add($k1); $this->serialize($v5->get($k1)); } $this->buf->add("h"); break; case _hx_qtype("haxe.ds.ObjectMap"): $this->buf->add("M"); $v6 = $v; $__hx__it = new _hx_array_iterator(array_values($v6->hk)); while ($__hx__it->hasNext()) { unset($k2); $k2 = $__hx__it->next(); $this->serialize($k2); $this->serialize($v6->get($k2)); } $this->buf->add("h"); break; case _hx_qtype("haxe.io.Bytes"): $v7 = $v; $i2 = 0; $max = $v7->length - 2; $charsBuf = new StringBuf(); $b64 = haxe_Serializer::$BASE64; while ($i2 < $max) { $b1 = null; $pos = $i2++; $b1 = ord($v7->b[$pos]); unset($pos); $b2 = null; $pos1 = $i2++; $b2 = ord($v7->b[$pos1]); unset($pos1); $b3 = null; $pos2 = $i2++; $b3 = ord($v7->b[$pos2]); unset($pos2); $charsBuf->add(_hx_char_at($b64, $b1 >> 2)); $charsBuf->add(_hx_char_at($b64, ($b1 << 4 | $b2 >> 4) & 63)); $charsBuf->add(_hx_char_at($b64, ($b2 << 2 | $b3 >> 6) & 63)); $charsBuf->add(_hx_char_at($b64, $b3 & 63)); unset($b3, $b2, $b1); } if ($i2 === $max) { $b11 = null; $pos3 = $i2++; $b11 = ord($v7->b[$pos3]); $b21 = null; $pos4 = $i2++; $b21 = ord($v7->b[$pos4]); $charsBuf->add(_hx_char_at($b64, $b11 >> 2)); $charsBuf->add(_hx_char_at($b64, ($b11 << 4 | $b21 >> 4) & 63)); $charsBuf->add(_hx_char_at($b64, $b21 << 2 & 63)); } else { if ($i2 === $max + 1) { $b12 = null; $pos5 = $i2++; $b12 = ord($v7->b[$pos5]); $charsBuf->add(_hx_char_at($b64, $b12 >> 2)); $charsBuf->add(_hx_char_at($b64, $b12 << 4 & 63)); } } $chars = $charsBuf->b; $this->buf->add("s"); $this->buf->add(strlen($chars)); $this->buf->add(":"); $this->buf->add($chars); break; default: if ($this->useCache) { $this->cache->pop(); } if (_hx_field($v, "hxSerialize") !== null) { $this->buf->add("C"); $this->serializeString(Type::getClassName($c)); if ($this->useCache) { $this->cache->push($v); } $v->hxSerialize($this); $this->buf->add("g"); } else { $this->buf->add("c"); $this->serializeString(Type::getClassName($c)); if ($this->useCache) { $this->cache->push($v); } $this->serializeFields($v); } break; } break; case 4: if (Std::is($v, _hx_qtype("Class"))) { $className = Type::getClassName($v); $this->buf->add("A"); $this->serializeString($className); } else { if (Std::is($v, _hx_qtype("Enum"))) { $this->buf->add("B"); $this->serializeString(Type::getEnumName($v)); } else { if ($this->useCache && $this->serializeRef($v)) { return; } $this->buf->add("o"); $this->serializeFields($v); } } break; case 7: $e = _hx_deref($_g)->params[0]; if ($this->useCache) { if ($this->serializeRef($v)) { return; } $this->cache->pop(); } $this->buf->add($this->useEnumIndex ? "j" : "w"); $this->serializeString(Type::getEnumName($e)); if ($this->useEnumIndex) { $this->buf->add(":"); $this->buf->add($v->index); } else { $this->serializeString($v->tag); } $this->buf->add(":"); $l1 = count($v->params); if ($l1 === 0 || _hx_field($v, "params") === null) { $this->buf->add(0); } else { $this->buf->add($l1); $_g11 = 0; while ($_g11 < $l1) { $i3 = $_g11++; $this->serialize($v->params[$i3]); unset($i3); } } if ($this->useCache) { $this->cache->push($v); } break; case 5: throw new HException("Cannot serialize function"); break; default: throw new HException("Cannot serialize " . Std::string($v)); break; } }
public function unserialize() { $_g = null; $p = $this->pos++; $_g = ord(substr($this->buf, $p, 1)); switch ($_g) { case 110: return null; break; case 116: return true; break; case 102: return false; break; case 122: return 0; break; case 105: return $this->readDigits(); break; case 100: $p1 = $this->pos; while (true) { $c = ord(substr($this->buf, $this->pos, 1)); if ($c >= 43 && $c < 58 || $c === 101 || $c === 69) { $this->pos++; } else { break; } unset($c); } return Std::parseFloat(_hx_substr($this->buf, $p1, $this->pos - $p1)); break; case 121: $len = $this->readDigits(); if (haxe_Unserializer_3($this, $_g, $len) !== 58 || $this->length - $this->pos < $len) { throw new HException("Invalid string length"); } $s = _hx_substr($this->buf, $this->pos, $len); $this->pos += $len; $s = urldecode($s); $this->scache->push($s); return $s; break; case 107: return Math::$NaN; break; case 109: return Math::$NEGATIVE_INFINITY; break; case 112: return Math::$POSITIVE_INFINITY; break; case 97: $buf = $this->buf; $a = new _hx_array(array()); $this->cache->push($a); while (true) { $c1 = ord(substr($this->buf, $this->pos, 1)); if ($c1 === 104) { $this->pos++; break; } if ($c1 === 117) { $this->pos++; $n = $this->readDigits(); $a[$a->length + $n - 1] = null; unset($n); } else { $a->push($this->unserialize()); } unset($c1); } return $a; break; case 111: $o = _hx_anonymous(array()); $this->cache->push($o); $this->unserializeObject($o); return $o; break; case 114: $n1 = $this->readDigits(); if ($n1 < 0 || $n1 >= $this->cache->length) { throw new HException("Invalid reference"); } return $this->cache[$n1]; break; case 82: $n2 = $this->readDigits(); if ($n2 < 0 || $n2 >= $this->scache->length) { throw new HException("Invalid string reference"); } return $this->scache[$n2]; break; case 120: throw new HException($this->unserialize()); break; case 99: $name = $this->unserialize(); $cl = $this->resolver->resolveClass($name); if ($cl === null) { throw new HException("Class not found " . _hx_string_or_null($name)); } $o1 = Type::createEmptyInstance($cl); $this->cache->push($o1); $this->unserializeObject($o1); return $o1; break; case 119: $name1 = $this->unserialize(); $edecl = $this->resolver->resolveEnum($name1); if ($edecl === null) { throw new HException("Enum not found " . _hx_string_or_null($name1)); } $e = $this->unserializeEnum($edecl, $this->unserialize()); $this->cache->push($e); return $e; break; case 106: $name2 = $this->unserialize(); $edecl1 = $this->resolver->resolveEnum($name2); if ($edecl1 === null) { throw new HException("Enum not found " . _hx_string_or_null($name2)); } $this->pos++; $index = $this->readDigits(); $tag = _hx_array_get(Type::getEnumConstructs($edecl1), $index); if ($tag === null) { throw new HException("Unknown enum index " . _hx_string_or_null($name2) . "@" . _hx_string_rec($index, "")); } $e1 = $this->unserializeEnum($edecl1, $tag); $this->cache->push($e1); return $e1; break; case 108: $l = new HList(); $this->cache->push($l); $buf1 = $this->buf; while (ord(substr($this->buf, $this->pos, 1)) !== 104) { $l->add($this->unserialize()); } $this->pos++; return $l; break; case 98: $h = new haxe_ds_StringMap(); $this->cache->push($h); $buf2 = $this->buf; while (ord(substr($this->buf, $this->pos, 1)) !== 104) { $s1 = $this->unserialize(); $h->set($s1, $this->unserialize()); unset($s1); } $this->pos++; return $h; break; case 113: $h1 = new haxe_ds_IntMap(); $this->cache->push($h1); $buf3 = $this->buf; $c2 = null; $p3 = $this->pos++; $c2 = ord(substr($this->buf, $p3, 1)); while ($c2 === 58) { $i = $this->readDigits(); $h1->set($i, $this->unserialize()); $p4 = $this->pos++; $c2 = ord(substr($this->buf, $p4, 1)); unset($p4); unset($i); } if ($c2 !== 104) { throw new HException("Invalid IntMap format"); } return $h1; break; case 77: $h2 = new haxe_ds_ObjectMap(); $this->cache->push($h2); $buf4 = $this->buf; while (ord(substr($this->buf, $this->pos, 1)) !== 104) { $s2 = $this->unserialize(); $h2->set($s2, $this->unserialize()); unset($s2); } $this->pos++; return $h2; break; case 118: $d = Date::fromString(_hx_substr($this->buf, $this->pos, 19)); $this->cache->push($d); $this->pos += 19; return $d; break; case 115: $len1 = $this->readDigits(); $buf5 = $this->buf; if (haxe_Unserializer_4($this, $_g, $buf5, $len1) !== 58 || $this->length - $this->pos < $len1) { throw new HException("Invalid bytes length"); } $codes = haxe_Unserializer::$CODES; if ($codes === null) { $codes = haxe_Unserializer::initCodes(); haxe_Unserializer::$CODES = $codes; } $i1 = $this->pos; $rest = $len1 & 3; $size = null; $size = ($len1 >> 2) * 3 + haxe_Unserializer_5($this, $_g, $buf5, $codes, $i1, $len1, $rest, $size); $max = $i1 + ($len1 - $rest); $bytes = haxe_io_Bytes::alloc($size); $bpos = 0; while ($i1 < $max) { $c11 = $codes[haxe_Unserializer_6($this, $_g, $bpos, $buf5, $bytes, $codes, $i1, $len1, $max, $rest, $size)]; $c21 = $codes[haxe_Unserializer_7($this, $_g, $bpos, $buf5, $bytes, $c11, $codes, $i1, $len1, $max, $rest, $size)]; $pos = $bpos++; $bytes->b[$pos] = chr($c11 << 2 | $c21 >> 4); unset($pos); $c3 = $codes[haxe_Unserializer_8($this, $_g, $bpos, $buf5, $bytes, $c11, $c21, $codes, $i1, $len1, $max, $rest, $size)]; $pos1 = $bpos++; $bytes->b[$pos1] = chr($c21 << 4 | $c3 >> 2); unset($pos1); $c4 = $codes[haxe_Unserializer_9($this, $_g, $bpos, $buf5, $bytes, $c11, $c21, $c3, $codes, $i1, $len1, $max, $rest, $size)]; $pos2 = $bpos++; $bytes->b[$pos2] = chr($c3 << 6 | $c4); unset($pos2); unset($c4, $c3, $c21, $c11); } if ($rest >= 2) { $c12 = $codes[haxe_Unserializer_10($this, $_g, $bpos, $buf5, $bytes, $codes, $i1, $len1, $max, $rest, $size)]; $c22 = $codes[haxe_Unserializer_11($this, $_g, $bpos, $buf5, $bytes, $c12, $codes, $i1, $len1, $max, $rest, $size)]; $pos3 = $bpos++; $bytes->b[$pos3] = chr($c12 << 2 | $c22 >> 4); if ($rest === 3) { $c31 = $codes[haxe_Unserializer_12($this, $_g, $bpos, $buf5, $bytes, $c12, $c22, $codes, $i1, $len1, $max, $rest, $size)]; $pos4 = $bpos++; $bytes->b[$pos4] = chr($c22 << 4 | $c31 >> 2); } } $this->pos += $len1; $this->cache->push($bytes); return $bytes; break; case 67: $name3 = $this->unserialize(); $cl1 = $this->resolver->resolveClass($name3); if ($cl1 === null) { throw new HException("Class not found " . _hx_string_or_null($name3)); } $o2 = Type::createEmptyInstance($cl1); $this->cache->push($o2); $o2->hxUnserialize($this); if (haxe_Unserializer_13($this, $_g, $cl1, $name3, $o2) !== 103) { throw new HException("Invalid custom data"); } return $o2; break; default: break; } $this->pos--; throw new HException("Invalid char " . _hx_string_or_null(_hx_char_at($this->buf, $this->pos)) . " at position " . _hx_string_rec($this->pos, "")); }
static function markSpaces($sl, $sr) { if ($sl === $sr) { return $sl; } if ($sl === null || $sr === null) { return $sl; } $slc = str_replace(" ", "", $sl); $src = str_replace(" ", "", $sr); if ($slc !== $src) { return $sl; } $slo = ""; $il = 0; $ir = 0; while ($il < strlen($sl)) { $cl = _hx_char_at($sl, $il); $cr = ""; if ($ir < strlen($sr)) { $cr = _hx_char_at($sr, $ir); } if ($cl === $cr) { $slo .= _hx_string_or_null($cl); $il++; $ir++; } else { if ($cr === " ") { $ir++; } else { $slo .= _hx_string_or_null(chr(9251)); $il++; } } unset($cr, $cl); } return $slo; }
static function skippy($needle, $sql, $position) { $c = null; $string = new StringBuf(); $string->add($needle); do { $c = _hx_char_at($sql, $position++); if ($c === system_base_Sql_colour::$REV_SOLDIUS) { $position += 1; $c = _hx_char_at($sql, $position); } $string->add($c); } while ($c !== $needle && $position <= strlen($sql)); return _hx_anonymous(array("position" => $position, "string" => $string->b)); }