当前位置: 首页>>代码示例>>C++>>正文


C++ StaticString类代码示例

本文整理汇总了C++中StaticString的典型用法代码示例。如果您正苦于以下问题:C++ StaticString类的具体用法?C++ StaticString怎么用?C++ StaticString使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了StaticString类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: HHVM_FALIAS

void StandardExtension::initMisc() {
    HHVM_FALIAS(HH\\server_warmup_status, server_warmup_status);
    HHVM_FE(connection_aborted);
    HHVM_FE(connection_status);
    HHVM_FE(connection_timeout);
    HHVM_FE(constant);
    HHVM_FE(define);
    HHVM_FE(defined);
    HHVM_FE(ignore_user_abort);
    HHVM_FE(pack);
    HHVM_FE(sleep);
    HHVM_FE(usleep);
    HHVM_FE(time_nanosleep);
    HHVM_FE(time_sleep_until);
    HHVM_FE(uniqid);
    HHVM_FE(unpack);
    HHVM_FE(sys_getloadavg);
    HHVM_FE(token_get_all);
    HHVM_FE(token_name);
    HHVM_FE(hphp_to_string);
    HHVM_FALIAS(__SystemLib\\max2, SystemLib_max2);
    HHVM_FALIAS(__SystemLib\\min2, SystemLib_min2);
    Native::registerConstant<KindOfDouble>(makeStaticString("INF"), k_INF);
    Native::registerConstant<KindOfDouble>(makeStaticString("NAN"), k_NAN);
    Native::registerConstant<KindOfInt64>(
        makeStaticString("PHP_MAXPATHLEN"), MAXPATHLEN);
    Native::registerConstant<KindOfBoolean>(makeStaticString("PHP_DEBUG"),
      #if DEBUG
        true
      #else
        false
      #endif
     );
    bindTokenConstants();
    Native::registerConstant<KindOfInt64>(s_T_PAAMAYIM_NEKUDOTAYIM.get(),
                                          get_user_token_id(T_DOUBLE_COLON));

    HHVM_RC_STR(PHP_BINARY, current_executable_path());
    HHVM_RC_STR(PHP_BINDIR, current_executable_directory());
    HHVM_RC_STR(PHP_OS, HHVM_FN(php_uname)("s").toString().toCppString());
    HHVM_RC_STR(PHP_SAPI, RuntimeOption::ExecutionMode);

    HHVM_RC_INT(PHP_INT_SIZE, sizeof(int64_t));
    HHVM_RC_INT(PHP_INT_MIN, k_PHP_INT_MIN);
    HHVM_RC_INT(PHP_INT_MAX, k_PHP_INT_MAX);

    HHVM_RC_INT_SAME(PHP_MAJOR_VERSION);
    HHVM_RC_INT_SAME(PHP_MINOR_VERSION);
    HHVM_RC_INT_SAME(PHP_RELEASE_VERSION);
    HHVM_RC_STR_SAME(PHP_EXTRA_VERSION);
    HHVM_RC_STR_SAME(PHP_VERSION);
    HHVM_RC_INT_SAME(PHP_VERSION_ID);

    // FIXME: These values are hardcoded from their previous IDL values
    // Grab their correct values from the system as appropriate
    HHVM_RC_STR(PHP_EOL, "\n");
    HHVM_RC_STR(PHP_CONFIG_FILE_PATH, "");
    HHVM_RC_STR(PHP_CONFIG_FILE_SCAN_DIR, "");
    HHVM_RC_STR(PHP_DATADIR, "");
    HHVM_RC_STR(PHP_EXTENSION_DIR, "");
    HHVM_RC_STR(PHP_LIBDIR, "");
    HHVM_RC_STR(PHP_LOCALSTATEDIR, "");
    HHVM_RC_STR(PHP_PREFIX, "");
    HHVM_RC_STR(PHP_SHLIB_SUFFIX, "so");
    HHVM_RC_STR(PHP_SYSCONFDIR, "");
    HHVM_RC_STR(PEAR_EXTENSION_DIR, "");
    HHVM_RC_STR(PEAR_INSTALL_DIR, "");

    loadSystemlib("std_misc");
  }
开发者ID:khanhnguyenneka,项目名称:hhvm,代码行数:70,代码来源:ext_std_misc.cpp

示例2: s_reified_generics_var

namespace HPHP { namespace HHBBC {

//////////////////////////////////////////////////////////////////////

const StaticString s_reified_generics_var("0ReifiedGenerics");

//////////////////////////////////////////////////////////////////////

uint32_t closure_num_use_vars(const php::Func* f) {
  // Properties on the closure object are use vars.
  return f->cls->properties.size();
}

bool is_pseudomain(const php::Func* f) {
  return f->unit->pseudomain.get() == f;
}

bool is_methcaller(const StringData* name) {
  return Func::isMethCallerName(name);
}

bool is_volatile_local(const php::Func* func, LocalId lid) {
  auto const& l = func->locals[lid];
  if (!l.name) return false;

  // Named pseudomain locals are bound to $GLOBALS.
  if (is_pseudomain(func)) return true;

  return (RuntimeOption::EnableArgsInBacktraces &&
          l.name->same(s_reified_generics_var.get())) ||
         l.name->same(s_86metadata.get());
}

SString memoize_impl_name(const php::Func* func) {
  always_assert(func->isMemoizeWrapper);
  return Func::genMemoizeImplName(func->name);
}

bool check_nargs_in_range(const php::Func* func, uint32_t nArgs) {
  while (nArgs < func->dvEntries.size()) {
    if (func->dvEntries[nArgs++] == NoBlockId) return false;
  }
  return true;
}

//////////////////////////////////////////////////////////////////////

namespace {

using ExnNode = php::ExnNode;

void copy_into(php::FuncBase* dst, const php::FuncBase& other) {
  hphp_fast_map<ExnNode*, ExnNode*> processed;

  BlockId delta = dst->blocks.size();
  always_assert(!dst->exnNodes.size() || !other.exnNodes.size());
  dst->exnNodes.reserve(dst->exnNodes.size() + other.exnNodes.size());
  for (auto en : other.exnNodes) {
    en.region.catchEntry += delta;
    dst->exnNodes.push_back(std::move(en));
  }
  for (auto theirs : other.blocks) {
    if (delta) {
      auto const ours = theirs.mutate();
      if (ours->fallthrough != NoBlockId) ours->fallthrough += delta;
      if (ours->throwExit != NoBlockId) ours->throwExit += delta;
      for (auto& bc : ours->hhbcs) {
        // When merging functions (used for 86xints) we have to drop
        // the src info, because it might reference a different unit
        // (and as a generated function, the src info isn't very
        // meaningful anyway).
        bc.srcLoc = -1;
        bc.forEachTarget([&] (BlockId& b) { b += delta; });
      }
    }
    dst->blocks.push_back(std::move(theirs));
  }
}

//////////////////////////////////////////////////////////////////////

}

//////////////////////////////////////////////////////////////////////

bool append_func(php::Func* dst, const php::Func& src) {
  if (src.numIters || src.locals.size()) return false;
  if (src.exnNodes.size() && dst->exnNodes.size()) return false;

  bool ok = false;
  for (auto& b : dst->blocks) {
    if (b->hhbcs.back().op != Op::RetC) continue;
    auto const blk = b.mutate();
    blk->hhbcs.back() = bc::PopC {};
    blk->fallthrough = dst->blocks.size();
    ok = true;
  }
  if (!ok) return false;
  copy_into(dst, src);
  return true;
//.........这里部分代码省略.........
开发者ID:facebook,项目名称:hhvm,代码行数:101,代码来源:func-util.cpp

示例3: toHex

string
toHex(const StaticString &data) {
	string result(data.size() * 2, '\0');
	toHex(data, (char *) result.data());
	return result;
}
开发者ID:4moms,项目名称:passenger,代码行数:6,代码来源:StrIntUtils.cpp

示例4: s_Vector

namespace HPHP { namespace HHBBC {

//////////////////////////////////////////////////////////////////////

const StaticString s_Vector("HH\\Vector");
const StaticString s_Map("HH\\Map");
const StaticString s_Set("HH\\Set");

const StaticString s_add("add");
const StaticString s_addall("addall");
const StaticString s_append("append");
const StaticString s_clear("clear");
const StaticString s_remove("remove");
const StaticString s_removeall("removeall");
const StaticString s_removekey("removekey");
const StaticString s_set("set");
const StaticString s_setall("setall");

//////////////////////////////////////////////////////////////////////

bool is_collection_method_returning_this(const php::Class* cls,
                                         const php::Func* func) {
  if (!cls) return false;

  if (cls->name->isame(s_Vector.get())) {
    return
      func->name->isame(s_add.get()) ||
      func->name->isame(s_addall.get()) ||
      func->name->isame(s_append.get()) ||
      func->name->isame(s_clear.get()) ||
      func->name->isame(s_removekey.get()) ||
      func->name->isame(s_set.get()) ||
      func->name->isame(s_setall.get());
  }

  if (cls->name->isame(s_Map.get())) {
    return
      func->name->isame(s_add.get()) ||
      func->name->isame(s_addall.get()) ||
      func->name->isame(s_clear.get()) ||
      func->name->isame(s_remove.get()) ||
      func->name->isame(s_set.get()) ||
      func->name->isame(s_setall.get());
  }

  if (cls->name->isame(s_Set.get())) {
    return
      func->name->isame(s_add.get()) ||
      func->name->isame(s_addall.get()) ||
      func->name->isame(s_clear.get()) ||
      func->name->isame(s_remove.get()) ||
      func->name->isame(s_removeall.get());
  }

  return false;
}

Type native_function_return_type(const php::Func* f,
                                 bool include_coercion_failures) {
  assert(f->nativeInfo);

  // If the function returns by ref, we can't say much about it. It can be a ref
  // or null.
  if (f->attrs & AttrReference) {
    return union_of(TRef, TInitNull);
  }

  // Infer the type from the HNI declaration
  auto t = [&]{
    auto const hni = f->nativeInfo->returnType;
    return hni ? from_DataType(*hni) : TInitCell;
  }();
  if (t.subtypeOf(BArr)) {
    if (f->retTypeConstraint.isVArray()) {
      assertx(!RuntimeOption::EvalHackArrDVArrs);
      t = TVArr;
    } else if (f->retTypeConstraint.isDArray()) {
      assertx(!RuntimeOption::EvalHackArrDVArrs);
      t = TDArr;
    } else if (f->retTypeConstraint.isArray()) {
      t = TPArr;
    }
  }

  // Non-simple types (ones that are represented by pointers) can always
  // possibly be null.
  if (t.subtypeOfAny(TStr, TArr, TVec, TDict,
                     TKeyset, TObj, TRes)) {
    t |= TInitNull;
  } else {
    // Otherwise it should be a simple type or possibly everything.
    assert(t == TInitCell || t.subtypeOfAny(TBool, TInt, TDbl, TNull));
  }

  if (include_coercion_failures) {
    // If parameter coercion fails, we can also get null or false depending on
    // the function.
    if (f->attrs & AttrParamCoerceModeNull) {
      t |= TInitNull;
    }
//.........这里部分代码省略.........
开发者ID:swtaarrs,项目名称:hhvm,代码行数:101,代码来源:type-builtins.cpp

示例5: s_unknown_type

namespace HPHP {
///////////////////////////////////////////////////////////////////////////////

const StaticString
  s_unknown_type("unknown type"),
  s_boolean("boolean"),
  s_bool("bool"),
  s_integer("integer"),
  s_int("int"),
  s_float("float"),
  s_double("double"),
  s_string("string"),
  s_object("object"),
  s_array("array"),
  s_dict("dict"),
  s_vec("vec"),
  s_keyset("keyset"),
  s_NULL("NULL"),
  s_null("null");

String HHVM_FUNCTION(gettype, const Variant& v) {
  if (v.getType() == KindOfResource && v.toCResRef().isInvalid()) {
    return s_unknown_type;
  }
  /* Although getDataTypeString also handles the null type, it returns "null"
   * (lower case). Unfortunately, PHP returns "NULL" (upper case) for
   * gettype(). So we make an exception here. */
  if (v.isNull()) {
    return s_NULL;
  }
  if (v.isArray()) {
    if (v.toArray()->isDict()) return s_dict;
    if (v.toArray()->isVecArray()) return s_vec;
    if (v.toArray()->isKeyset()) return s_keyset;
  }
  return getDataTypeString(v.getType());
}

String HHVM_FUNCTION(get_resource_type, const Resource& handle) {
  return handle->o_getResourceName();
}

bool HHVM_FUNCTION(boolval, const Variant& v) {
  return v.toBoolean();
}

int64_t HHVM_FUNCTION(intval, const Variant& v, int64_t base /* = 10 */) {
  return v.toInt64(base);
}

double HHVM_FUNCTION(floatval, const Variant& v) {
  return v.toDouble();
}

String HHVM_FUNCTION(strval, const Variant& v) {
  return v.toString();
}

bool HHVM_FUNCTION(settype, VRefParam var, const String& type) {
  Variant val;
  if      (type == s_boolean) val = var.toBoolean();
  else if (type == s_bool   ) val = var.toBoolean();
  else if (type == s_integer) val = var.toInt64();
  else if (type == s_int    ) val = var.toInt64();
  else if (type == s_float  ) val = var.toDouble();
  else if (type == s_double ) val = var.toDouble();
  else if (type == s_string ) val = var.toString();
  else if (type == s_array  ) val = var.toArray();
  else if (type == s_object ) val = var.toObject();
  else if (type == s_null   ) val = uninit_null();
  else return false;
  var.assignIfRef(val);
  return true;
}

bool HHVM_FUNCTION(is_null, const Variant& v) {
  return is_null(v);
}

bool HHVM_FUNCTION(is_bool, const Variant& v) {
  return is_bool(v);
}

bool HHVM_FUNCTION(is_int, const Variant& v) {
  return is_int(v);
}

bool HHVM_FUNCTION(is_float, const Variant& v) {
  return is_double(v);
}

bool HHVM_FUNCTION(is_numeric, const Variant& v) {
  return v.isNumeric(true);
}

bool HHVM_FUNCTION(is_string, const Variant& v) {
  return is_string(v);
}

bool HHVM_FUNCTION(is_scalar, const Variant& v) {
//.........这里部分代码省略.........
开发者ID:Thomascarette,项目名称:hhvm,代码行数:101,代码来源:ext_std_variable.cpp

示例6: HHVM_FUNCTION


//.........这里部分代码省略.........
  if (json.size() > 1 && ch0 == '"' && json.charAt(json.size() - 1) == '"') {
    json_set_last_error_code(json_error_codes::JSON_ERROR_NONE);

    // Wrap the string in an array to allow the JSON_parser to handle
    // things like unicode escape sequences, then unwrap to get result
    String wrapped("[");
    wrapped += json + "]";
    // Stick to a normal hhvm array for the wrapper
    const int64_t mask = ~(k_JSON_FB_COLLECTIONS | k_JSON_FB_STABLE_MAPS);
    if (JSON_parser(z, wrapped.data(), wrapped.size(), false, depth,
                    parser_options & mask) && z.isArray()) {
      Array arr = z.toArray();
      if ((arr.size() == 1) && arr.exists(0)) {
        return arr[0];
      }
      // The input string could be something like: "foo","bar"
      // Which will parse inside the [] wrapper, but be invalid
      json_set_last_error_code(json_error_codes::JSON_ERROR_SYNTAX);
    }
  }

  if ((options & k_JSON_FB_LOOSE) && json.size() > 1 &&
      ch0 == '\'' && json.charAt(json.size() - 1) == '\'') {
    json_set_last_error_code(json_error_codes::JSON_ERROR_NONE);
    return json.substr(1, json.size() - 2);
  }

  assert(json_get_last_error_code() != json_error_codes::JSON_ERROR_NONE);
  return init_null();
}

///////////////////////////////////////////////////////////////////////////////

const StaticString
  s_JSON_HEX_TAG("JSON_HEX_TAG"),
  s_JSON_HEX_AMP("JSON_HEX_AMP"),
  s_JSON_HEX_APOS("JSON_HEX_APOS"),
  s_JSON_HEX_QUOT("JSON_HEX_QUOT"),
  s_JSON_FORCE_OBJECT("JSON_FORCE_OBJECT"),
  s_JSON_NUMERIC_CHECK("JSON_NUMERIC_CHECK"),
  s_JSON_UNESCAPED_SLASHES("JSON_UNESCAPED_SLASHES"),
  s_JSON_PRETTY_PRINT("JSON_PRETTY_PRINT"),
  s_JSON_UNESCAPED_UNICODE("JSON_UNESCAPED_UNICODE"),
  s_JSON_PARTIAL_OUTPUT_ON_ERROR("JSON_PARTIAL_OUTPUT_ON_ERROR"),
  s_JSON_BIGINT_AS_STRING("JSON_BIGINT_AS_STRING"),
  s_JSON_FB_LOOSE("JSON_FB_LOOSE"),
  s_JSON_FB_UNLIMITED("JSON_FB_UNLIMITED"),
  s_JSON_FB_EXTRA_ESCAPES("JSON_FB_EXTRA_ESCAPES"),
  s_JSON_FB_COLLECTIONS("JSON_FB_COLLECTIONS"),
  s_JSON_FB_STABLE_MAPS("JSON_FB_STABLE_MAPS"),
  s_JSON_ERROR_NONE("JSON_ERROR_NONE"),
  s_JSON_ERROR_DEPTH("JSON_ERROR_DEPTH"),
  s_JSON_ERROR_STATE_MISMATCH("JSON_ERROR_STATE_MISMATCH"),
  s_JSON_ERROR_CTRL_CHAR("JSON_ERROR_CTRL_CHAR"),
  s_JSON_ERROR_SYNTAX("JSON_ERROR_SYNTAX"),
  s_JSON_ERROR_UTF8("JSON_ERROR_UTF8"),
  s_JSON_ERROR_RECURSION("JSON_ERROR_RECURSION"),
  s_JSON_ERROR_INF_OR_NAN("JSON_ERROR_INF_OR_NAN"),
  s_JSON_ERROR_UNSUPPORTED_TYPE("JSON_ERROR_UNSUPPORTED_TYPE");

class JsonExtension : public Extension {
 public:
  JsonExtension() : Extension("json", "1.2.1") {}
  virtual void moduleInit() {
    Native::registerConstant<KindOfInt64>(
      s_JSON_HEX_TAG.get(), k_JSON_HEX_TAG
开发者ID:DieterLutz,项目名称:hhvm,代码行数:67,代码来源:ext_json.cpp

示例7: s_call

namespace HPHP {

StaticString s_call("__call");

UserFSNode::UserFSNode(Class* cls, const Variant& context /*= null */) {
  JIT::VMRegAnchor _;
  const Func* ctor;
  m_cls = cls;
  if (LookupResult::MethodFoundWithThis !=
      g_context->lookupCtorMethod(ctor, m_cls)) {
    throw InvalidArgumentException(0, "Unable to call %s's constructor",
                                   m_cls->name()->data());
  }

  m_obj = ObjectData::newInstance(m_cls);
  m_obj.o_set("context", context);
  Variant ret;
  g_context->invokeFuncFew(ret.asTypedValue(), ctor, m_obj.get());

  m_Call = lookupMethod(s_call.get());
}

Variant UserFSNode::invoke(const Func* func, const String& name,
                           const Array& args, bool& invoked) {
  JIT::VMRegAnchor _;

  // Assume failure
  invoked = false;

  // Public method, no private ancestor, no need for further checks (common)
  if (func &&
      !(func->attrs() & (AttrPrivate|AttrProtected|AttrAbstract)) &&
      !func->hasPrivateAncestor()) {
    Variant ret;
    g_context->invokeFunc(ret.asTypedValue(), func, args, m_obj.get());
    invoked = true;
    return ret;
  }

  // No explicitly defined function, no __call() magic method
  // Give up.
  if (!func && !m_Call) {
    return uninit_null();
  }

  HPHP::JIT::CallerFrame cf;
  Class* ctx = arGetContextClass(cf());
  switch(g_context->lookupObjMethod(func, m_cls, name.get(), ctx)) {
    case LookupResult::MethodFoundWithThis:
    {
      Variant ret;
      g_context->invokeFunc(ret.asTypedValue(), func, args, m_obj.get());
      invoked = true;
      return ret;
    }

    case LookupResult::MagicCallFound:
    {
      Variant ret;
      g_context->invokeFunc(ret.asTypedValue(), func,
                              make_packed_array(name, args), m_obj.get());
      invoked = true;
      return ret;
    }

    case LookupResult::MethodNotFound:
      // There's a method somewhere in the hierarchy, but none
      // which are accessible.
      /* fallthrough */
    case LookupResult::MagicCallStaticFound:
      // We're not calling statically, so this result is unhelpful
      // Also, it's never produced by lookupObjMethod, so it'll
      // never happen, but we must handle all enums
      return uninit_null();

    case LookupResult::MethodFoundNoThis:
      // Should never happen (Attr::Static check in ctor)
      assert(false);
      raise_error("%s::%s() must not be declared static",
                  m_cls->name()->data(), name.data());
      return uninit_null();
  }

  NOT_REACHED();
  return uninit_null();
}

const Func* UserFSNode::lookupMethod(const StringData* name) {
  const Func* f = m_cls->lookupMethod(name);
  if (!f) return nullptr;

  if (f->attrs() & AttrStatic) {
    throw InvalidArgumentException(0, "%s::%s() must not be declared static",
                                   m_cls->name()->data(), name->data());
  }
  return f;
}

}
开发者ID:2bj,项目名称:hhvm,代码行数:99,代码来源:user-fs-node.cpp

示例8: assert

void
DeviceListWidget::OnPaintItem(Canvas &canvas, const PixelRect rc, unsigned idx)
{
  assert(idx < NUMDEV);

  const DeviceConfig &config =
    CommonInterface::SetSystemSettings().devices[idx];
  const Flags flags(*items[idx]);

  const UPixelScalar margin = Layout::GetTextPadding();

  TCHAR port_name_buffer[128];
  const TCHAR *port_name =
    config.GetPortName(port_name_buffer, ARRAY_SIZE(port_name_buffer));

  StaticString<256> text(_T("A: "));
  text[0u] += idx;

  if (config.UsesDriver()) {
    const TCHAR *driver_name = FindDriverDisplayName(config.driver_name);

    text.AppendFormat(_("%s on %s"), driver_name, port_name);
  } else {
    text.append(port_name);
  }

  canvas.Select(*look.list.font);
  canvas.DrawText(rc.left + margin, rc.top + margin, text);

  /* show a list of features that are available in the second row */

  StaticString<256> buffer;
  const TCHAR *status;
  if (flags.alive) {
    if (flags.location) {
      buffer = _("GPS fix");
    } else if (flags.gps) {
      /* device sends GPGGA, but no valid location */
      buffer = _("Bad GPS");
    } else {
      buffer = _("Connected");
    }

    if (flags.baro) {
      buffer.append(_T("; "));
      buffer.append(_("Baro"));
    }

    if (flags.airspeed) {
      buffer.append(_T("; "));
      buffer.append(_("Airspeed"));
    }

    if (flags.vario) {
      buffer.append(_T("; "));
      buffer.append(_("Vario"));
    }

    if (flags.traffic)
      buffer.append(_T("; FLARM"));

    status = buffer;
  } else if (config.IsDisabled()) {
    status = _("Disabled");
  } else if (is_simulator() || !config.IsAvailable()) {
    status = _("N/A");
  } else if (flags.open) {
    status = _("No data");
#ifdef ANDROID
  } else if ((config.port_type == DeviceConfig::PortType::RFCOMM ||
              config.port_type == DeviceConfig::PortType::RFCOMM_SERVER) &&
             !BluetoothHelper::isEnabled(Java::GetEnv())) {
    status = _("Bluetooth is disabled");
#endif
  } else if (flags.error) {
    status = _("Error");
  } else {
    status = _("Not connected");
  }

  canvas.Select(*look.small_font);
  canvas.DrawText(rc.left + margin, rc.top + 2 * margin + font_height,
                  status);
}
开发者ID:rjsikarwar,项目名称:XCSoar,代码行数:84,代码来源:DeviceListDialog.cpp

示例9: IMPLEMENT_THREAD_LOCAL

namespace HPHP {

IMPLEMENT_THREAD_LOCAL(std::string, s_misc_highlight_default_string);
IMPLEMENT_THREAD_LOCAL(std::string, s_misc_highlight_default_comment);
IMPLEMENT_THREAD_LOCAL(std::string, s_misc_highlight_default_keyword);
IMPLEMENT_THREAD_LOCAL(std::string, s_misc_highlight_default_default);
IMPLEMENT_THREAD_LOCAL(std::string, s_misc_highlight_default_html);
IMPLEMENT_THREAD_LOCAL(std::string, s_misc_display_errors);

const std::string s_1("1"), s_2("2"), s_stdout("stdout"), s_stderr("stderr");
const double k_INF = std::numeric_limits<double>::infinity();
const double k_NAN = std::numeric_limits<double>::quiet_NaN();

static String HHVM_FUNCTION(server_warmup_status) {
  // Fail if we jitted more than 25kb of code.
  size_t begin, end;
  jit::mcg->codeEmittedThisRequest(begin, end);
  auto const diff = end - begin;
  auto constexpr kMaxTCBytes = 25 << 10;
  if (diff > kMaxTCBytes) {
    return folly::format("Translation cache grew by {} bytes to {} bytes.",
                         diff, begin).str();
  }

  // Fail if we spent more than 0.5ms in the JIT.
  auto const jittime = jit::Timer::CounterValue(jit::Timer::translate);
  auto constexpr kMaxJitTimeNS = 500000;
  if (jittime.total > kMaxJitTimeNS) {
    return folly::format("Spent {}us in the JIT.", jittime.total / 1000).str();
  }

  if (!isStandardRequest()) {
    return "Warmup is still in progress.";
  }

  if (requestCount() <= RuntimeOption::EvalJitProfileRequests) {
    return "PGO profiling translations are still enabled.";
  }

  auto tpc_diff = jit::s_perfCounters[jit::tpc_interp_bb] -
    jit::s_perfCounters[jit::tpc_interp_bb_force];
  if (tpc_diff) {
    return folly::sformat("Interpreted {} non-forced basic blocks.", tpc_diff);
  }

  return empty_string();
}


void StandardExtension::threadInitMisc() {
    IniSetting::Bind(
      this, IniSetting::PHP_INI_ALL,
      "highlight.string", "#DD0000",
      s_misc_highlight_default_string.get()
    );
    IniSetting::Bind(
      this, IniSetting::PHP_INI_ALL,
      "highlight.comment", "#FF8000",
      s_misc_highlight_default_comment.get()
    );
    IniSetting::Bind(
      this, IniSetting::PHP_INI_ALL,
      "highlight.keyword", "#007700",
      s_misc_highlight_default_keyword.get()
    );
    IniSetting::Bind(
      this, IniSetting::PHP_INI_ALL,
      "highlight.default", "#0000BB",
      s_misc_highlight_default_default.get()
    );
    IniSetting::Bind(
      this, IniSetting::PHP_INI_ALL,
      "highlight.html", "#000000",
      s_misc_highlight_default_html.get()
    );
    IniSetting::Bind(
      this, IniSetting::PHP_INI_ALL,
      "display_errors", RuntimeOption::EnableHipHopSyntax ? "stderr" : "1",
      IniSetting::SetAndGet<std::string>(
        [](const std::string& value) {
          if (value == s_1 || value == s_stdout) {
            Logger::SetStandardOut(stdout);
            return true;
          }
          if (value == s_2 || value == s_stderr) {
            Logger::SetStandardOut(stderr);
            return true;
          }
          return false;
        },
        nullptr
      ),
      s_misc_display_errors.get()
    );
  }

static void bindTokenConstants();
static int get_user_token_id(int internal_id);
const StaticString s_T_PAAMAYIM_NEKUDOTAYIM("T_PAAMAYIM_NEKUDOTAYIM");

//.........这里部分代码省略.........
开发者ID:khanhnguyenneka,项目名称:hhvm,代码行数:101,代码来源:ext_std_misc.cpp

示例10: AddBoolean

void
TrackingConfigPanel::Prepare(ContainerWindow &parent, const PixelRect &rc)
{
  const TrackingSettings &settings =
    CommonInterface::GetComputerSettings().tracking;

  RowFormWidget::Prepare(parent, rc);

#ifdef HAVE_SKYLINES_TRACKING
  AddBoolean(_T("SkyLines"), nullptr, settings.skylines.enabled, this);
#ifdef HAVE_NET_STATE_ROAMING
  AddBoolean(_T("Roaming"), nullptr, settings.skylines.roaming, this);
#endif
  AddEnum(_("Tracking Interval"), nullptr, tracking_intervals,
          settings.skylines.interval);

  AddBoolean(_("Track friends"),
             _("Download the position of your friends live from the SkyLines server."),
             settings.skylines.traffic_enabled, this);

  AddBoolean(_("Show nearby traffic"),
             _("Download the position of your nearby traffic live from the SkyLines server."),
             settings.skylines.near_traffic_enabled, this);

  StaticString<64> buffer;
  if (settings.skylines.key != 0)
    buffer.UnsafeFormat(_T("%llX"), (unsigned long long)settings.skylines.key);
  else
    buffer.clear();
  AddText(_T("Key"), nullptr, buffer);
#endif

#if defined(HAVE_SKYLINES_TRACKING) && defined(HAVE_LIVETRACK24)
  AddSpacer();
#endif

#ifdef HAVE_LIVETRACK24
  AddBoolean(_T("LiveTrack24"),  _T(""), settings.livetrack24.enabled, this);

  AddTime(_("Tracking Interval"), _T(""), 5, 3600, 5, settings.interval);

  AddEnum(_("Vehicle Type"), _("Type of vehicle used."), vehicle_type_list,
          (unsigned) settings.vehicleType);
  AddText(_("Vehicle Name"), _T("Name of vehicle used."),
          settings.vehicle_name);

  WndProperty *edit = AddEnum(_("Server"), _T(""), server_list, 0);
  ((DataFieldEnum *)edit->GetDataField())->Set(settings.livetrack24.server);
  edit->RefreshDisplay();

  AddText(_("Username"), _T(""), settings.livetrack24.username);
  AddPassword(_("Password"), _T(""), settings.livetrack24.password);
#endif

#ifdef HAVE_SKYLINES_TRACKING
  SetSkyLinesEnabled(settings.skylines.enabled);
#endif

#ifdef HAVE_LIVETRACK24
  SetEnabled(settings.livetrack24.enabled);
#endif
}
开发者ID:Advi42,项目名称:XCSoar,代码行数:62,代码来源:TrackingConfigPanel.cpp

示例11: writeExact

void
writeExact(int fd, const StaticString &data, unsigned long long *timeout) {
	const char * restrict data_ptr = data.data();
	writeExact(fd, data_ptr, data.size(), timeout);
}
开发者ID:godentarek,项目名称:passenger,代码行数:5,代码来源:IOUtils.cpp

示例12: ULOC_CHECK

namespace HPHP {
//////////////////////////////////////////////////////////////////////////////
// class Locale

#define ULOC_CHECK(err, ret) \
  if (U_FAILURE(err)) { \
    s_intl_error->set(err, "%s", u_errorName(err)); \
    return ret; \
  }

#define ULOC_DEFAULT(loc) (loc.empty() ? Intl::GetDefaultLocale() : loc)

#define MAX_LOCALE_LEN 80

/*returns TRUE if a is an ID separator FALSE otherwise*/
#define isIDSeparator(a) (a == '_' || a == '-')
#define isKeywordSeparator(a) (a == '@' )
#define isEndOfTag(a) (a == '\0' )

#define isPrefixLetter(a) ((a=='x')||(a=='X')||(a=='i')||(a=='I'))

/*returns TRUE if one of the special prefixes is here (s=string)
 *   'x-' or 'i-' */
#define isIDPrefix(s) (isPrefixLetter(s[0])&&isIDSeparator(s[1]))
#define isKeywordPrefix(s) ( isKeywordSeparator(s[0]) )

/* Dot terminates it because of POSIX form  where dot precedes the codepage
 *  * except for variant */
#define isTerminator(a)  ((a==0)||(a=='.')||(a=='@'))

static std::vector<std::string> g_grandfathered = {
  "art-lojban", "i-klingon", "i-lux", "i-navajo", "no-bok", "no-nyn",
  "cel-gaulish", "en-GB-oed", "i-ami", "i-bnn", "i-default", "i-enochian",
  "i-mingo", "i-pwn", "i-tao", "i-tay", "i-tsu", "sgn-BE-fr", "sgn-BE-nl",
  "sgn-CH-de", "zh-cmn", "zh-cmn-Hans", "zh-cmn-Hant", "zh-gan", "zh-guoyu",
  "zh-hakka", "zh-min", "zh-min-nan", "zh-wuu", "zh-xiang", "zh-yue"
};

/* Preferred locale codes for the first N entries of g_grandfathered
 * Must be kept in sync with above.
 */
static std::vector<std::string> g_grandfathered_preferred = {
  "jbo", "tlh", "lb", "nv", "nb", "nn"
};

static int getGrandfatheredOffset(const String& locale) {
  auto it = std::find(g_grandfathered.begin(),
                      g_grandfathered.end(), locale.data());
  if (it == g_grandfathered.end()) return -1;
  return (it - g_grandfathered.begin());
}

static String getGrandfatheredPreferred(int ofs) {
  if ((ofs < 0) || (ofs >= g_grandfathered.size())) {
    return null_string;
  }
  if (ofs < g_grandfathered_preferred.size()) {
    return g_grandfathered_preferred[ofs];
  }
  return g_grandfathered[ofs];
}

enum LocaleTag {
  LOC_SCRIPT,
  LOC_LANG,
  LOC_REGION,
  LOC_VARIANT,
  LOC_CANONICALIZE,
  LOC_PRIVATE,
  LOC_DISPLAY,
  LOC_EXTLANG,
};

const StaticString
  s_DEFAULT_LOCALE("DEFAULT_LOCALE"),
  s_LANG_TAG("LANG_TAG"),
  s_EXTLANG_TAG("EXTLANG_TAG"),
  s_SCRIPT_TAG("SCRIPT_TAG"),
  s_REGION_TAG("REGION_TAG"),
  s_VARIANT_TAG("VARIANT_TAG"),
  s_GRANDFATHERED_LANG_TAG("GRANDFATHERED_LANG_TAG"),
  s_PRIVATE_TAG("PRIVATE_TAG"),
  s_LOC_SCRIPT("script"),
  s_LOC_LANG("language"),
  s_LOC_REGION("region"),
  s_LOC_VARIANT("variant"),
  s_LOC_CANONICALIZE("canonicalize"),
  s_LOC_PRIVATE("private"),
  s_LOC_DISPLAY("display"),
  s_LOC_EXTLANG("extlang"),
  s_GRANDFATHERED("grandfathered"),
  s_SEPARATOR("_"),
  s_SEPARATOR_x("_x");

static const StaticString LocaleName(LocaleTag tag) {
  switch (tag) {
    case LOC_SCRIPT:       return s_LOC_SCRIPT;
    case LOC_LANG:         return s_LOC_LANG;
    case LOC_REGION:       return s_LOC_REGION;
    case LOC_VARIANT:      return s_LOC_VARIANT;
//.........这里部分代码省略.........
开发者ID:Alienfeel,项目名称:hhvm,代码行数:101,代码来源:ext_icu_locale.cpp

示例13: m_index

namespace HPHP {

Class* Generator::s_class = nullptr;
const StaticString Generator::s_className("Generator");

Generator::Generator()
  : m_index(-1LL)
  , m_key(make_tv<KindOfInt64>(-1LL))
  , m_value(make_tv<KindOfNull>())
  , m_delegate(make_tv<KindOfNull>())
{
}

Generator::~Generator() {
  if (LIKELY(getState() == State::Done)) {
    return;
  }

  assert(getState() != State::Running);
  tvRefcountedDecRef(m_key);
  tvRefcountedDecRef(m_value);
  tvRefcountedDecRef(m_delegate);

  // Free locals, but don't trigger the EventHook for FunctionReturn since
  // the generator has already been exited. We don't want redundant calls.
  ActRec* ar = actRec();
  frame_free_locals_inl_no_hook<false>(ar, ar->func()->numLocals());
}

Generator& Generator::operator=(const Generator& other) {
  auto const fp = other.actRec();
  const size_t numSlots = fp->func()->numSlotsInFrame();
  const size_t frameSz = Resumable::getFrameSize(numSlots);
  const size_t genSz = genSize(sizeof(Generator), frameSz);
  resumable()->initialize<true>(fp,
                                other.resumable()->resumeAddr(),
                                other.resumable()->resumeOffset(),
                                frameSz,
                                genSz);
  copyVars(fp);
  setState(other.getState());
  m_index = other.m_index;
  cellSet(other.m_key, m_key);
  cellSet(other.m_value, m_value);
  cellSet(other.m_delegate, m_delegate);
  return *this;
}

void Generator::copyVars(const ActRec* srcFp) {
  const auto dstFp = actRec();
  const auto func = dstFp->func();
  assert(srcFp->func() == dstFp->func());

  for (Id i = 0; i < func->numLocals(); ++i) {
    tvDupFlattenVars(frame_local(srcFp, i), frame_local(dstFp, i));
  }

  if (dstFp->hasThis()) {
    dstFp->getThis()->incRefCount();
  }

  if (LIKELY(!(srcFp->func()->attrs() & AttrMayUseVV))) return;
  if (LIKELY(srcFp->m_varEnv == nullptr)) return;

  if (srcFp->hasExtraArgs()) {
    dstFp->setExtraArgs(srcFp->getExtraArgs()->clone(dstFp));
  } else {
    assert(srcFp->hasVarEnv());
    dstFp->setVarEnv(srcFp->getVarEnv()->clone(dstFp));
  }
}

void Generator::yield(Offset resumeOffset,
                      const Cell* key, const Cell value) {
  assert(isRunning());
  resumable()->setResumeAddr(nullptr, resumeOffset);

  if (key) {
    cellSet(*key, m_key);
    tvRefcountedDecRefNZ(*key);
    if (m_key.m_type == KindOfInt64) {
      int64_t new_index = m_key.m_data.num;
      m_index = new_index > m_index ? new_index : m_index;
    }
  } else {
    cellSet(make_tv<KindOfInt64>(++m_index), m_key);
  }
  cellSet(value, m_value);
  tvRefcountedDecRefNZ(value);

  setState(State::Started);
}

void Generator::done(TypedValue tv) {
  assert(isRunning());
  cellSetNull(m_key);
  cellSet(*tvToCell(&tv), m_value);
  setState(State::Done);
}

//.........这里部分代码省略.........
开发者ID:anthonyattard,项目名称:hhvm,代码行数:101,代码来源:ext_generator.cpp

示例14: moduleInit

  void moduleInit() override {
    SOCK_CONST(AF_UNIX);
    SOCK_CONST(AF_INET);
    SOCK_CONST(AF_INET6);
    SOCK_CONST(SOCK_STREAM);
    SOCK_CONST(SOCK_DGRAM);
    SOCK_CONST(SOCK_RAW);
    SOCK_CONST(SOCK_SEQPACKET);
    SOCK_CONST(SOCK_RDM);

    SOCK_CONST(MSG_OOB);
    SOCK_CONST(MSG_WAITALL);
    SOCK_CONST(MSG_CTRUNC);
    SOCK_CONST(MSG_TRUNC);
    SOCK_CONST(MSG_PEEK);
    SOCK_CONST(MSG_DONTROUTE);
#ifdef MSG_EOR
    SOCK_CONST(MSG_EOR);
#endif
#ifdef MSG_EOF
    SOCK_CONST(MSG_EOF);
#endif
#ifdef MSG_CONFIRM
    SOCK_CONST(MSG_CONFIRM);
#endif
#ifdef MSG_ERRQUEUE
    SOCK_CONST(MSG_ERRQUEUE);
#endif
#ifdef MSG_NOSIGNAL
    SOCK_CONST(MSG_NOSIGNAL);
#endif
#ifdef MSG_DONTWAIT
    SOCK_CONST(MSG_DONTWAIT);
#endif
#ifdef MSG_MORE
    SOCK_CONST(MSG_MORE);
#endif
#ifdef MSG_WAITFORONE
    SOCK_CONST(MSG_WAITFORONE);
#endif
#ifdef MSG_CMSG_CLOEXEC
    SOCK_CONST(MSG_CMSG_CLOEXEC);
#endif

    SOCK_CONST(SO_DEBUG);
    SOCK_CONST(SO_REUSEADDR);
#ifdef SO_REUSEPORT
    SOCK_CONST(SO_REUSEPORT);
#endif
    SOCK_CONST(SO_KEEPALIVE);
    SOCK_CONST(SO_DONTROUTE);
    SOCK_CONST(SO_LINGER);
    SOCK_CONST(SO_BROADCAST);
    SOCK_CONST(SO_OOBINLINE);
    SOCK_CONST(SO_SNDBUF);
    SOCK_CONST(SO_RCVBUF);
    SOCK_CONST(SO_SNDLOWAT);
    SOCK_CONST(SO_RCVLOWAT);
    SOCK_CONST(SO_SNDTIMEO);
    SOCK_CONST(SO_RCVTIMEO);
    SOCK_CONST(SO_TYPE);
#ifdef SO_FAMILY
    SOCK_CONST(SO_FAMILY);
#endif
    SOCK_CONST(SO_ERROR);
#ifdef SO_BINDTODEVICE
    SOCK_CONST(SO_BINDTODEVICE);
#endif
    SOCK_CONST(SOL_SOCKET);
    SOCK_CONST(SOMAXCONN);
#ifdef TCP_NODELAY
    SOCK_CONST(TCP_NODELAY);
#endif
    SOCK_CONST(PHP_NORMAL_READ);
    SOCK_CONST(PHP_BINARY_READ);

    /* TODO: MCAST_* constants and logic to handle them */

    SOCK_CONST(IP_MULTICAST_IF);
    SOCK_CONST(IP_MULTICAST_TTL);
    SOCK_CONST(IP_MULTICAST_LOOP);
    SOCK_CONST(IPV6_MULTICAST_IF);
    SOCK_CONST(IPV6_MULTICAST_HOPS);
    SOCK_CONST(IPV6_MULTICAST_LOOP);
    SOCK_CONST(IPPROTO_IP);
    SOCK_CONST(IPPROTO_IPV6);

    Native::registerConstant<KindOfInt64>(s_SOL_TCP.get(), IPPROTO_TCP);
    Native::registerConstant<KindOfInt64>(s_SOL_UDP.get(), IPPROTO_UDP);

    SOCK_CONST(IPV6_UNICAST_HOPS);

    HHVM_FE(socket_create);
    HHVM_FE(socket_create_listen);
    HHVM_FE(socket_create_pair);
    HHVM_FE(socket_get_option);
    HHVM_FE(socket_getpeername);
    HHVM_FE(socket_getsockname);
    HHVM_FE(socket_set_block);
    HHVM_FE(socket_set_nonblock);
//.........这里部分代码省略.........
开发者ID:RyanCccc,项目名称:hhvm,代码行数:101,代码来源:ext_sockets.cpp

示例15: call_next

void c_Continuation::call_next() {
  const HPHP::Func* func = m_cls->lookupMethod(s_next.get());
  g_vmContext->invokeContFunc(func, this);
}
开发者ID:MarkTseng,项目名称:hiphop-php,代码行数:4,代码来源:ext_continuation.cpp


注:本文中的StaticString类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。