本文整理汇总了C++中NEWOBJ函数的典型用法代码示例。如果您正苦于以下问题:C++ NEWOBJ函数的具体用法?C++ NEWOBJ怎么用?C++ NEWOBJ使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NEWOBJ函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}
示例8: m_gzFile
ZipFile::ZipFile() : m_gzFile(nullptr) {
m_innerFile = NEWOBJ(PlainFile)();
m_isLocal = true;
}
示例9: NEWOBJ
SmartResource<TimeZone> TimeZone::Current() {
return NEWOBJ(TimeZone)(CurrentName());
}
示例10: NEWOBJ
ObjectData *coo_Directory() {
return NEWOBJ(c_Directory)();
}
示例11: di
Object c_DateInterval::ti_createfromdatestring(const String& time) {
SmartResource<DateInterval> di(NEWOBJ(DateInterval)(time, true));
return c_DateInterval::wrap(di);
}
示例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);
}
示例13: NEWOBJ
ObjectData *coo_RuntimeException() {
return NEWOBJ(c_RuntimeException)();
}
示例14: NEWOBJ
SmartObject<DateInterval> DateInterval::cloneDateInterval() const {
if (!m_di) return NEWOBJ(DateInterval)();
return NEWOBJ(DateInterval)(timelib_rel_time_clone(m_di.get()));
}
示例15: NEWOBJ
SmartObject<TimeZone> TimeZone::Current() {
return NEWOBJ(TimeZone)(CurrentName());
}