• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ NEWOBJ函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: raise_warning

File *PhpStreamWrapper::openFD(const char *sFD) {
  if (!RuntimeOption::ClientExecutionMode()) {
    raise_warning("Direct access to file descriptors "
                  "is only available from command-line");
    return nullptr;
  }

  char *end = nullptr;
  long nFD = strtol(sFD, &end, 10);
  if ((sFD == end) || (*end != '\0')) {
    raise_warning("php://fd/ stream must be specified in the form "
                  "php://fd/<orig fd>");
    return nullptr;
  }
  long dtablesize = getdtablesize();
  if ((nFD < 0) || (nFD >= dtablesize)) {
    raise_warning("The file descriptors must be non-negative numbers "
                  "smaller than %ld", dtablesize);
    return nullptr;
  }

  return NEWOBJ(PlainFile)(dup(nFD), true);
}
开发者ID:Barbayar,项目名称:hiphop-php,代码行数:23,代码来源:php-stream-wrapper.cpp


示例2: HHVM_FUNCTION

static Variant HHVM_FUNCTION(gmp_fact,
                             const Variant& data) {
  mpz_t gmpReturn;

  if (data.isResource()) {
    mpz_t gmpData;
    if (!variantToGMPData(cs_GMP_FUNC_NAME_GMP_FACT, gmpData, data, 0, true)) {
      return false;
    }

    if (mpz_sgn(gmpData) < 0) {
      mpz_clear(gmpData);

      raise_warning(cs_GMP_INVALID_VALUE_MUST_BE_POSITIVE,
                    cs_GMP_FUNC_NAME_GMP_FACT);
      return false;
    }

    mpz_init(gmpReturn);
    mpz_fac_ui(gmpReturn, mpz_get_ui(gmpData));
    mpz_clear(gmpData);
  } else {
    if (data.toInt64() < 0) {
      raise_warning(cs_GMP_INVALID_VALUE_MUST_BE_POSITIVE,
                    cs_GMP_FUNC_NAME_GMP_FACT);
      return false;
    }

    mpz_init(gmpReturn);
    mpz_fac_ui(gmpReturn, data.toInt64());
  }
  Variant ret = NEWOBJ(GMPResource)(gmpReturn);

  mpz_clear(gmpReturn);

  return ret;
}
开发者ID:SanjeebJena,项目名称:hhvm,代码行数:37,代码来源:ext_gmp.cpp


示例3: checker

bool TestExtIcu_uspoof::test_SpoofChecker_areconfusable() {
  p_SpoofChecker checker(NEWOBJ(c_SpoofChecker)());
  VS(checker->t_areconfusable("hello, world", "goodbye, world"), false);
  VS(checker->t_areconfusable("hello, world", "hello, world"), true);
  VS(checker->t_areconfusable("hello, world", "he11o, wor1d"), true);
  VS(checker->t_areconfusable("hell\u00f8", "hello\u0337"), true);

  VS(checker->t_areconfusable("facebook", "f\u0430\u0441\u0435b\u043e\u043ek"),
     true);

  // TODO: ICU bug 8341: \u017f should be treated as a spoof of "f".  Once
  // that bug is fixed, enable this test.
  //
  //VS(checker->t_areconfusable("facebook", "\u017facebook"), true);

  VS(checker->t_areconfusable("paypal", "payp\u0430l"), true);
  VS(checker->t_areconfusable(
       "NAPKIN PEZ",
       "\u039d\u0391\u03a1\u039a\u0399\u039d \u03a1\u0395\u0396"),
     true);

  VS(checker->t_areconfusable(
       "facebook",
       "ufiek-a\u048ba\u049d \u049da\u048b\u00f0a\u048b\u01e5a\u048b-\u049dota-"
       "\u00f0o\u00f0ol"),
     false);

  try {
    checker->t_areconfusable(
      "this is not UTF-8: \x87\xFB\xCA\x94\xDB",
      "so there.");
  } catch (Exception& e) {
    return Count(true);
  }

  return Count(false);
}
开发者ID:cdnewbee,项目名称:hiphop-php,代码行数:37,代码来源:test_ext_icu_uspoof.cpp


示例4: open

  virtual File* open(const String& filename, const String& mode,
                     int options, const Variant& context) {
    std::string url(filename.c_str());
    auto pound = url.find('#');
    if (pound == std::string::npos) {
      return nullptr;
    }

    // 6 is the position after zip://
    auto path = url.substr(6, pound - 6);
    auto file = url.substr(pound + 1);

    if (path.empty() || file.empty()) {
      return nullptr;
    }

    int err;
    auto z = zip_open(path.c_str(), 0, &err);
    if (z == nullptr) {
      return nullptr;
    }

    return NEWOBJ(ZipStream)(z, file);
  }
开发者ID:isgiker,项目名称:hhvm,代码行数:24,代码来源:ext_zip.cpp


示例5: checker

bool TestExtIcu_uspoof::test_SpoofChecker_areconfusable() {
    p_SpoofChecker checker(NEWOBJ(c_SpoofChecker)());
    VS(checker->t_areconfusable("hello, world", "goodbye, world"), false);
    VS(checker->t_areconfusable("hello, world", "hello, world"), true);
    VS(checker->t_areconfusable("hello, world", "he11o, wor1d"), true);
    VS(checker->t_areconfusable("hell\u00f8", "hello\u0337"), true);

    VS(checker->t_areconfusable("facebook", "f\u0430\u0441\u0435b\u043e\u043ek"),
       true);

    VS(checker->t_areconfusable("facebook", "\U0001d41faceboo\u1d0b"), true);

    VS(checker->t_areconfusable("facebook", "\u017facebook"), true);

    VS(checker->t_areconfusable("paypal", "payp\u0430l"), true);
    VS(checker->t_areconfusable(
           "NAPKIN PEZ",
           "\u039d\u0391\u03a1\u039a\u0399\u039d \u03a1\u0395\u0396"),
       true);

    VS(checker->t_areconfusable(
           "facebook",
           "ufiek-a\u048ba\u049d \u049da\u048b\u00f0a\u048b\u01e5a\u048b-\u049dota-"
           "\u00f0o\u00f0ol"),
       false);

    try {
        checker->t_areconfusable(
            "this is not UTF-8: \x87\xFB\xCA\x94\xDB",
            "so there.");
    } catch (Exception& e) {
        return Count(true);
    }

    return Count(false);
}
开发者ID:BauerBox,项目名称:hiphop-php,代码行数:36,代码来源:test_ext_icu_uspoof.cpp


示例6: sizeof

File* PhpStreamWrapper::open(const String& filename, const String& mode,
                             int options, CVarRef context) {
  if (strncasecmp(filename.c_str(), "php://", 6)) {
    return nullptr;
  }

  const char *req = filename.c_str() + sizeof("php://") - 1;

  if (!strcasecmp(req, "stdin")) {
    return NEWOBJ(PlainFile)(dup(STDIN_FILENO), true);
  }
  if (!strcasecmp(req, "stdout")) {
    return NEWOBJ(PlainFile)(dup(STDOUT_FILENO), true);
  }
  if (!strcasecmp(req, "stderr")) {
    return NEWOBJ(PlainFile)(dup(STDERR_FILENO), true);
  }
  if (!strncasecmp(req, "fd/", sizeof("fd/") - 1)) {
    return openFD(req + sizeof("fd/") - 1);
  }

  if (!strncasecmp(req, "temp", sizeof("temp") - 1) ||
      !strcasecmp(req, "memory")) {
    std::unique_ptr<TempFile> file(NEWOBJ(TempFile)());
    if (!file->valid()) {
      raise_warning("Unable to create temporary file");
      return nullptr;
    }
    return file.release();
  }

  if (!strcasecmp(req, "input")) {
    auto raw_post = g_context->getRawPostData();
    return NEWOBJ(MemFile)(raw_post.c_str(), raw_post.size());
  }

  if (!strcasecmp(req, "output")) {
    return NEWOBJ(OutputFile)(filename);
  }

  return nullptr;
}
开发者ID:Bluarggag,项目名称:hhvm,代码行数:42,代码来源:php-stream-wrapper.cpp


示例7: m_gzFile

ZipFile::ZipFile() : m_gzFile(nullptr) {
  m_innerFile = NEWOBJ(PlainFile)();
  m_innerFile->unregister(); // so Sweepable won't touch my child
  m_isLocal = true;
}
开发者ID:Halfnhav,项目名称:hiphop-php,代码行数:5,代码来源:zip-file.cpp


示例8: m_gzFile

ZipFile::ZipFile() : m_gzFile(nullptr) {
  m_innerFile = NEWOBJ(PlainFile)();
  m_isLocal = true;
}
开发者ID:Bharat1992,项目名称:hiphop-php,代码行数:4,代码来源:zip-file.cpp


示例9: NEWOBJ

SmartResource<TimeZone> TimeZone::Current() {
  return NEWOBJ(TimeZone)(CurrentName());
}
开发者ID:1mr3yn,项目名称:hhvm,代码行数:3,代码来源:timezone.cpp


示例10: NEWOBJ

ObjectData *coo_Directory() {
  return NEWOBJ(c_Directory)();
}
开发者ID:canerdogan,项目名称:hiphop-php,代码行数:3,代码来源:directory.cpp


示例11: di

Object c_DateInterval::ti_createfromdatestring(const String& time) {
  SmartResource<DateInterval> di(NEWOBJ(DateInterval)(time, true));
  return c_DateInterval::wrap(di);
}
开发者ID:Yermo,项目名称:hhvm,代码行数:4,代码来源:ext_datetime.cpp


示例12: STATIC_METHOD_INJECTION_BUILTIN

Variant c_Collator::ti_create(const char* cls, CStrRef locale) {
  STATIC_METHOD_INJECTION_BUILTIN(Collator, Collator::create);
  return (NEWOBJ(c_Collator)())->create(locale);
}
开发者ID:cdnewbee,项目名称:hiphop-php,代码行数:4,代码来源:ext_intl.cpp


示例13: NEWOBJ

ObjectData *coo_RuntimeException() {
  return NEWOBJ(c_RuntimeException)();
}
开发者ID:KWMalik,项目名称:hiphop-php,代码行数:3,代码来源:exception.cpp


示例14: NEWOBJ

SmartObject<DateInterval> DateInterval::cloneDateInterval() const {
  if (!m_di) return NEWOBJ(DateInterval)();
  return NEWOBJ(DateInterval)(timelib_rel_time_clone(m_di.get()));
}
开发者ID:Bathrisyah,项目名称:hiphop-php,代码行数:4,代码来源:dateinterval.cpp


示例15: NEWOBJ

SmartObject<TimeZone> TimeZone::Current() {
  return NEWOBJ(TimeZone)(CurrentName());
}
开发者ID:Bathrisyah,项目名称:hiphop-php,代码行数:3,代码来源:timezone.cpp


示例16: f_collator_create

Variant f_collator_create(CStrRef locale) {
  return (NEWOBJ(c_Collator)())->create(locale);
}
开发者ID:cdnewbee,项目名称:hiphop-php,代码行数:3,代码来源:ext_intl.cpp


示例17: f_timezone_open

Object f_timezone_open(const String& timezone) {
  c_DateTimeZone *ctz = NEWOBJ(c_DateTimeZone)();
  Object ret(ctz);
  ctz->t___construct(timezone);
  return ret;
}
开发者ID:Yermo,项目名称:hhvm,代码行数:6,代码来源:ext_datetime.cpp


示例18: HHVM_METHOD

static void HHVM_METHOD(IntlDateFormatter, __clone) {
  auto data = NEWOBJ(IntlDateFormatter)(IntlDateFormatter::Get(this_));
  this_->o_set(s_resdata, Resource(data), s_IntlDateFormatter.get());
}
开发者ID:BiggDaddy,项目名称:hhvm,代码行数:4,代码来源:ext_icu_date_fmt.cpp


示例19: db

bool TestExtSqlite3::test_sqlite3() {
  p_SQLite3 db(NEWOBJ(c_SQLite3)());
  db->t_open(":memory:test");
  db->t_exec("DROP TABLE foo");
  db->t_exec("CREATE TABLE foo (bar STRING)");

  db->t_exec("INSERT INTO foo VALUES ('ABC')");
  db->t_exec("INSERT INTO foo VALUES ('DEF')");
  VS(db->t_lastinsertrowid(), 2);
  VS(db->t_changes(), 1);
  VS(db->t_lasterrorcode(), 0);
  VS(db->t_lasterrormsg(), "not an error");

  VS(db->t_escapestring("'\""), "''\"");
  VS(db->t_querysingle("SELECT * FROM foo"), "ABC");
  VS(db->t_querysingle("SELECT * FROM foo", true), CREATE_MAP1("bar", "ABC"));

  // testing query() and SQLite3Result
  {
    Object objResult = db->t_query("SELECT * FROM foo").toObject();
    c_SQLite3Result *res = objResult.getTyped<c_SQLite3Result>();

    VS(res->t_fetcharray(), CREATE_MAP2(0, "ABC", "bar", "ABC"));
    VS(res->t_numcolumns(), 1);
    VS(res->t_columnname(0), "bar");
    VS(res->t_columntype(0), k_SQLITE3_TEXT);

    VS(res->t_fetcharray(k_SQLITE3_NUM), CREATE_VECTOR1("DEF"));
  }

  // testing prepare() and sqlite3stmt
  {
    Object objStmt = db->t_prepare("SELECT * FROM foo WHERE bar = :id");
    c_SQLite3Stmt *stmt = objStmt.getTyped<c_SQLite3Stmt>();
    VS(stmt->t_paramcount(), 1);

    Variant id = "DEF";
    VERIFY(stmt->t_bindvalue(":id", id, SQLITE3_TEXT));
    id = "ABC";
    {
      Object objResult = stmt->t_execute();
      c_SQLite3Result *res = objResult.getTyped<c_SQLite3Result>();
      VS(res->t_fetcharray(k_SQLITE3_NUM), CREATE_VECTOR1("DEF"));
    }

    VERIFY(stmt->t_clear());
    VERIFY(stmt->t_reset());
    id = "DEF";
    VERIFY(stmt->t_bindparam(":id", ref(id), SQLITE3_TEXT));
    id = "ABC";
    {
      Object objResult = stmt->t_execute();
      c_SQLite3Result *res = objResult.getTyped<c_SQLite3Result>();
      VS(res->t_fetcharray(k_SQLITE3_NUM), CREATE_VECTOR1("ABC"));
    }
  }

  // testing UDF
  {
    VERIFY(db->t_createfunction("tolower", "lower", 1));
    Object objResult = db->t_query("SELECT tolower(bar) FROM foo").toObject();
    c_SQLite3Result *res = objResult.getTyped<c_SQLite3Result>();
    VS(res->t_fetcharray(k_SQLITE3_NUM), CREATE_VECTOR1("abc"));
  }
  {
    VERIFY(db->t_createaggregate("sumlen", "sumlen_step", "sumlen_fini", 1));
    Object objResult = db->t_query("SELECT sumlen(bar) FROM foo").toObject();
    c_SQLite3Result *res = objResult.getTyped<c_SQLite3Result>();
    VS(res->t_fetcharray(k_SQLITE3_NUM), CREATE_VECTOR1(6));
  }

  db->t_close();

  VS(db->t_version(),
     CREATE_MAP2("versionString", "3.6.23.1", "versionNumber", 3006023));
  f_unlink(":memory:test");
  return Count(true);
}
开发者ID:HyeongKyu,项目名称:hiphop-php,代码行数:78,代码来源:test_ext_sqlite3.cpp


示例20: setNull


//.........这里部分代码省略.........
        StringData *sd;
      } u;
      uns->read(u.buf, 8);
      operator=(u.sd);
    } else {
      throw Exception("Unknown type '%c'", type);
    }
    break;
  case 'a':
    {
      Array v = Array::Create();
      v.unserialize(uns);
      operator=(v);
      return; // array has '}' terminating
    }
    break;
  case 'L':
    {
      int64_t id = uns->readInt();
      sep = uns->readChar();
      if (sep != ':') {
        throw Exception("Expected ':' but got '%c'", sep);
      }
      String rsrcName;
      rsrcName.unserialize(uns);
      sep = uns->readChar();
      if (sep != '{') {
        throw Exception("Expected '{' but got '%c'", sep);
      }
      sep = uns->readChar();
      if (sep != '}') {
        throw Exception("Expected '}' but got '%c'", sep);
      }
      DummyResource* rsrc = NEWOBJ(DummyResource);
      rsrc->o_setResourceId(id);
      rsrc->m_class_name = rsrcName;
      operator=(rsrc);
      return; // resource has '}' terminating
    }
    break;
  case 'O':
  case 'V':
  case 'K':
    {
      String clsName;
      clsName.unserialize(uns);

      sep = uns->readChar();
      if (sep != ':') {
        throw Exception("Expected ':' but got '%c'", sep);
      }
      int64_t size = uns->readInt();
      char sep = uns->readChar();
      if (sep != ':') {
        throw Exception("Expected ':' but got '%c'", sep);
      }
      sep = uns->readChar();
      if (sep != '{') {
        throw Exception("Expected '{' but got '%c'", sep);
      }

      const bool allowObjectFormatForCollections = true;

      Class* cls;
      // If we are potentially dealing with a collection, we need to try to
      // load the collection class under an alternate name so that we can
开发者ID:aripringle,项目名称:hhvm,代码行数:67,代码来源:type-variant.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ NEW_CHARACTER函数代码示例发布时间:2022-05-30
下一篇:
C++ NEWERROR函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap