本文整理汇总了C++中VRefParam::isReferenced方法的典型用法代码示例。如果您正苦于以下问题:C++ VRefParam::isReferenced方法的具体用法?C++ VRefParam::isReferenced怎么用?C++ VRefParam::isReferenced使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VRefParam
的用法示例。
在下文中一共展示了VRefParam::isReferenced方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: t_getmultibykey
Variant c_Memcached::t_getmultibykey(CStrRef server_key, CArrRef keys,
VRefParam cas_tokens /*= null_variant*/,
int flags /*= 0*/) {
INSTANCE_METHOD_INJECTION_BUILTIN(Memcached, Memcached::getmultibykey);
m_impl->rescode = q_Memcached_RES_SUCCESS;
bool preserveOrder = flags & q_Memcached_GET_PRESERVE_ORDER;
Array returnValue;
if (!getMultiImpl(server_key, keys, cas_tokens.isReferenced(),
preserveOrder ? &returnValue : NULL)) {
return false;
}
if (cas_tokens.isReferenced()) cas_tokens = Array();
MemcachedResultWrapper result(&m_impl->memcached);
memcached_return status;
while (memcached_fetch_result(&m_impl->memcached, &result.value, &status)) {
Variant value;
if (!toObject(value, result.value)) {
m_impl->rescode = q_Memcached_RES_PAYLOAD_FAILURE;
return false;
}
const char *key = memcached_result_key_value(&result.value);
size_t keyLength = memcached_result_key_length(&result.value);
String sKey(key, keyLength, CopyString);
returnValue.set(sKey, value, true);
if (cas_tokens.isReferenced()) {
double cas = (double) memcached_result_cas(&result.value);
cas_tokens->set(sKey, cas, true);
}
}
if (status != MEMCACHED_END && !handleError(status)) return false;
return returnValue;
}
示例2: f_preg_match_all
Variant f_preg_match_all(CStrRef pattern, CStrRef subject, VRefParam matches,
int flags /* = 0 */, int offset /* = 0 */) {
if (matches.isReferenced()) {
return preg_match_all(pattern, subject, matches, flags, offset);
} else {
return preg_match_all(pattern, subject, flags, offset);
}
}
示例3: HHVM_FUNCTION
Variant HHVM_FUNCTION(preg_match, const String& pattern, const String& subject,
VRefParam matches /* = null */,
int flags /* = 0 */, int offset /* = 0 */) {
if (matches.isReferenced()) {
return preg_match(pattern, subject, matches, flags, offset);
} else {
return preg_match(pattern, subject, flags, offset);
}
}
示例4: parse_str_impl
static void parse_str_impl(const String& str, VRefParam arr) {
Array result = Array::Create();
HttpProtocol::DecodeParameters(result, str.data(), str.size());
if (!arr.isReferenced()) {
HHVM_FN(SystemLib_extract)(result);
return;
}
arr.assignIfRef(result);
}
示例5: t_getbykey
Variant c_Memcached::t_getbykey(CStrRef server_key, CStrRef key,
CVarRef cache_cb /*= null_variant*/,
VRefParam cas_token /*= null_variant*/) {
INSTANCE_METHOD_INJECTION_BUILTIN(Memcached, Memcached::getbykey);
m_impl->rescode = q_Memcached_RES_SUCCESS;
if (key.empty()) {
m_impl->rescode = q_Memcached_RES_BAD_KEY_PROVIDED;
return false;
}
memcached_behavior_set(&m_impl->memcached, MEMCACHED_BEHAVIOR_SUPPORT_CAS,
cas_token.isReferenced() ? 1 : 0);
const char *myServerKey = server_key.empty() ? NULL : server_key.c_str();
size_t myServerKeyLen = server_key.length();
const char *myKey = key.c_str();
size_t myKeyLen = key.length();
memcached_return status = memcached_mget_by_key(&m_impl->memcached,
myServerKey, myServerKeyLen, &myKey, &myKeyLen, 1);
if (!handleError(status)) return false;
Variant returnValue;
MemcachedResultWrapper result(&m_impl->memcached);
if (!memcached_fetch_result(&m_impl->memcached, &result.value, &status)) {
if (status == MEMCACHED_END) status = MEMCACHED_NOTFOUND;
if (status == MEMCACHED_NOTFOUND && !cache_cb.isNull()) {
status = doCacheCallback(cache_cb, key, returnValue);
if (!handleError(status)) return false;
if (cas_token.isReferenced()) cas_token = 0.0;
return returnValue;
}
handleError(status);
return false;
}
if (!toObject(returnValue, result.value)) {
m_impl->rescode = q_Memcached_RES_PAYLOAD_FAILURE;
return false;
}
if (cas_token.isReferenced()) {
cas_token = (double) memcached_result_cas(&result.value);
}
return returnValue;
}
示例6: HHVM_STATIC_METHOD
static bool HHVM_STATIC_METHOD(EventUtil, getSocketName, const Resource &socket, VRefParam address, VRefParam port){
evutil_socket_t fd = resource_to_fd(socket);
struct sockaddr sa;
socklen_t sa_len = sizeof(struct sockaddr);
long l_port = 0;
if (getsockname(fd, &sa, &sa_len)) {
raise_warning("Unable to retreive socket name.");
return false;
}
switch (sa.sa_family) {
case AF_INET:
{
struct sockaddr_in *sa_in = (struct sockaddr_in *) &sa;
char c_addr[INET_ADDRSTRLEN + 1];
if (evutil_inet_ntop(sa.sa_family, &sa_in->sin_addr, c_addr, sizeof(c_addr))) {
address = StringData::Make(c_addr, CopyString);
l_port = ntohs(sa_in->sin_port);
}
}
break;
#ifdef AF_INET6
case AF_INET6: {
struct sockaddr_in6 *sa_in6 = (struct sockaddr_in6 *) &sa;
char c_addr6[INET6_ADDRSTRLEN + 1];
if (evutil_inet_ntop(sa.sa_family, &sa_in6->sin6_addr, c_addr6, sizeof(c_addr6))) {
address = StringData::Make(c_addr6, CopyString);
l_port = ntohs(sa_in6->sin6_port);
}
break;
}
#endif
#ifdef HAVE_SYS_UN_H
case AF_UNIX: {
struct sockaddr_un *ua = (struct sockaddr_un *) &sa;
address = StringData::Make(ua->sun_path, CopyString);
break;
}
#endif
default:
raise_warning("Unsupported address family.");
return false;
}
if(port.isReferenced()){
port = l_port;
}
return true;
}
示例7: preg_replace_callback_array_impl
static Variant preg_replace_callback_array_impl(
const Variant& patterns_and_callbacks,
const Array& subjects,
int limit,
VRefParam count) {
Array ret = Array::Create();
auto key = 0;
auto total_replacement_count = 0;
for (ArrayIter s_iter(subjects); s_iter; ++s_iter) {
assert(s_iter.second().isString());
auto subj = s_iter.second();
for (ArrayIter pc_iter(patterns_and_callbacks.toArray());
pc_iter; ++pc_iter) {
Variant pattern(pc_iter.first());
assert(pattern.isString());
Variant callback(pc_iter.second());
subj = HHVM_FN(preg_replace_callback)(pattern, callback, subj, limit,
count);
// If we got an error on the replacement, the subject will be null,
// and then we will return null.
if (subj.isNull()) {
return init_null();
}
if (count.isReferenced()) {
total_replacement_count += count.toInt64();
}
}
ret.add(key++, subj);
}
// If count was passed in as an explicit reference, we will assign it to our
// total replacement count; otherwise, count will just remained unassigned
count.assignIfRef(total_replacement_count);
// If there were no replacements (i.e., matches) return original subject(s)
if (ret.empty()) {
return subjects;
}
return ret;
}
示例8: f_is_callable
bool f_is_callable(CVarRef v, bool syntax /* = false */,
VRefParam name /* = null */) {
bool ret = true;
if (LIKELY(!syntax)) {
CallerFrame cf;
ObjectData* obj = NULL;
HPHP::Class* cls = NULL;
StringData* invName = NULL;
const HPHP::Func* f = vm_decode_function(v, cf(), false, obj, cls,
invName, false);
if (f == NULL) {
ret = false;
}
if (invName != NULL) {
decRefStr(invName);
}
if (!name.isReferenced()) return ret;
}
auto const tv_func = v.asCell();
if (IS_STRING_TYPE(tv_func->m_type)) {
if (name.isReferenced()) name = tv_func->m_data.pstr;
return ret;
}
if (tv_func->m_type == KindOfArray) {
CArrRef arr = tv_func->m_data.parr;
CVarRef clsname = arr.rvalAtRef(int64_t(0));
CVarRef mthname = arr.rvalAtRef(int64_t(1));
if (arr.size() != 2 ||
&clsname == &null_variant ||
&mthname == &null_variant) {
name = v.toString();
return false;
}
auto const tv_meth = mthname.asCell();
if (!IS_STRING_TYPE(tv_meth->m_type)) {
if (name.isReferenced()) name = v.toString();
return false;
}
auto const tv_cls = clsname.asCell();
if (tv_cls->m_type == KindOfObject) {
name = tv_cls->m_data.pobj->o_getClassName();
} else if (IS_STRING_TYPE(tv_cls->m_type)) {
name = tv_cls->m_data.pstr;
} else {
name = v.toString();
return false;
}
name = concat3(name, s_colon2, tv_meth->m_data.pstr);
return ret;
}
if (tv_func->m_type == KindOfObject) {
ObjectData *d = tv_func->m_data.pobj;
const Func* invoke = d->getVMClass()->lookupMethod(s__invoke.get());
if (name.isReferenced()) {
if (d->instanceof(c_Closure::classof())) {
// Hack to stop the mangled name from showing up
name = s_Closure__invoke;
} else {
name = d->o_getClassName() + "::__invoke";
}
}
return invoke != NULL;
}
return false;
}
示例9: HHVM_FUNCTION
bool HHVM_FUNCTION(is_callable, const Variant& v, bool syntax /* = false */,
VRefParam name /* = null */) {
return is_callable(v, syntax, name.isReferenced() ?
name.wrapped().asTypedValue()->m_data.pref : nullptr);
}
示例10: f_is_callable
bool f_is_callable(CVarRef v, bool syntax /* = false */,
VRefParam name /* = null */) {
bool ret = true;
if (LIKELY(!syntax)) {
if (hhvm) {
CallerFrame cf;
ObjectData* obj = NULL;
HPHP::VM::Class* cls = NULL;
StringData* invName = NULL;
const HPHP::VM::Func* f = vm_decode_function(v, cf(), false, obj, cls,
invName, false);
if (f == NULL) {
ret = false;
}
if (invName != NULL) {
LITSTR_DECREF(invName);
}
} else {
MethodCallPackage mcp;
String classname, methodname;
bool doBind;
ret = get_user_func_handler(v, true, mcp,
classname, methodname, doBind, false);
if (ret && mcp.ci->m_flags & (CallInfo::Protected|CallInfo::Private)) {
classname = mcp.getClassName();
if (!ClassInfo::HasAccess(classname, *mcp.name,
mcp.ci->m_flags & CallInfo::StaticMethod ||
!mcp.obj,
mcp.obj)) {
ret = false;
}
}
}
if (!name.isReferenced()) return ret;
}
Variant::TypedValueAccessor tv_func = v.getTypedAccessor();
if (Variant::IsString(tv_func)) {
if (name.isReferenced()) name = Variant::GetStringData(tv_func);
return ret;
}
if (Variant::GetAccessorType(tv_func) == KindOfArray) {
CArrRef arr = Variant::GetAsArray(tv_func);
CVarRef clsname = arr.rvalAtRef(0LL);
CVarRef mthname = arr.rvalAtRef(1LL);
if (arr.size() != 2 ||
&clsname == &null_variant ||
&mthname == &null_variant) {
name = v.toString();
return false;
}
Variant::TypedValueAccessor tv_meth = mthname.getTypedAccessor();
if (!Variant::IsString(tv_meth)) {
if (name.isReferenced()) name = v.toString();
return false;
}
Variant::TypedValueAccessor tv_cls = clsname.getTypedAccessor();
if (Variant::GetAccessorType(tv_cls) == KindOfObject) {
name = Variant::GetObjectData(tv_cls)->o_getClassName();
} else if (Variant::IsString(tv_cls)) {
name = Variant::GetStringData(tv_cls);
} else {
name = v.toString();
return false;
}
name = concat3(name, "::", Variant::GetAsString(tv_meth));
return ret;
}
if (Variant::GetAccessorType(tv_func) == KindOfObject) {
ObjectData *d = Variant::GetObjectData(tv_func);
if (hhvm) {
static const StringData* sd__invoke
= StringData::GetStaticString("__invoke");
const VM::Func* invoke = d->getVMClass()->lookupMethod(sd__invoke);
if (name.isReferenced()) {
if (d->o_instanceof("closure")) {
// Hack to stop the mangled name from showing up
name = "Closure::__invoke";
} else {
name = d->o_getClassName() + "::__invoke";
}
}
return invoke != NULL;
} else {
void *extra;
if (d->t___invokeCallInfoHelper(extra)) {
name = d->o_getClassName() + "::__invoke";
return ret;
}
if (name.isReferenced()) {
name = v.toString();
}
}
}
//.........这里部分代码省略.........
示例11: f_icu_match
Variant f_icu_match(CStrRef pattern, CStrRef subject,
VRefParam matches /* = null */, int64_t flags /* = 0 */) {
UErrorCode status = U_ZERO_ERROR;
if (matches.isReferenced()) {
matches = Array();
}
// Create hash map key by concatenating pattern and flags.
StringBuffer bpattern;
bpattern.append(pattern);
bpattern.append(':');
bpattern.append(flags);
String spattern = bpattern.detach();
// Find compiled pattern matcher in hash map or add it.
PatternStringMap::accessor accessor;
const RegexPattern* rpattern;
if (s_patternCacheMap.find(accessor, spattern.get())) {
rpattern = accessor->second;
} else {
// First 32 bits are reserved for ICU-specific flags.
rpattern = RegexPattern::compile(
UnicodeString::fromUTF8(pattern.data()), (flags & 0xFFFFFFFF), status);
if (U_FAILURE(status)) {
return false;
}
if (s_patternCacheMap.insert(
accessor, StringData::GetStaticString(spattern.get()))) {
accessor->second = rpattern;
} else {
delete rpattern;
rpattern = accessor->second;
}
}
// Build regex matcher from compiled pattern and passed-in subject.
UnicodeString usubject = UnicodeString::fromUTF8(subject.data());
boost::scoped_ptr<RegexMatcher> matcher(rpattern->matcher(usubject, status));
if (U_FAILURE(status)) {
return false;
}
// Return 0 or 1 depending on whether or not a match was found and
// (optionally), set matched (sub-)patterns for passed-in reference.
int matched = 0;
if (matcher->find()) {
matched = 1;
if (matches.isReferenced()) {
int32_t count = matcher->groupCount();
for (int32_t i = 0; i <= count; i++) {
UnicodeString ustring = matcher->group(i, status);
if (U_FAILURE(status)) {
return false;
}
// Convert UnicodeString back to UTF-8.
std::string string;
ustring.toUTF8String(string);
String match = String(string);
if (flags & k_UREGEX_OFFSET_CAPTURE) {
// start() returns the index in UnicodeString, which
// normally means the index into an array of 16-bit
// code "units" (not "points").
int32_t start = matcher->start(i, status);
if (U_FAILURE(status)) {
return false;
}
start = usubject.countChar32(0, start);
matches->append(CREATE_VECTOR2(match, start));
} else {
matches->append(match);
}
}
}
}
return matched;
}
示例12: f_is_callable
bool f_is_callable(CVarRef v, bool syntax /* = false */,
VRefParam name /* = null */) {
if (v.isString()) {
if (name.isReferenced()) name = v;
if (syntax) return true;
String str = v.toString();
int c = str.find("::");
if (c != 0 && c != String::npos && c + 2 < str.size()) {
String classname = str.substr(0, c);
String methodname = str.substr(c + 2);
return f_class_exists(classname) &&
ClassInfo::HasAccess(classname, methodname, true, false);
}
return f_function_exists(str);
}
if (v.is(KindOfArray)) {
Array arr = v.toArray();
if (arr.size() == 2 && arr.exists(0LL) && arr.exists(1LL)) {
Variant v0 = arr.rvalAt(0LL);
Variant v1 = arr.rvalAt(1LL);
Object obj;
bool staticCall = false;
if (v0.is(KindOfObject)) {
obj = v0.toObject();
v0 = obj->o_getClassName();
} else if (v0.isString()) {
if (!f_class_exists(v0.toString())) {
return false;
}
staticCall = true;
}
if (v1.isString()) {
String str = v1.toString();
int c = str.find("::");
if (c != 0 && c != String::npos && c + 2 < str.size()) {
String name1 = v0.toString();
String name2 = str.substr(0, c);
ASSERT(name1.get() && name2.get());
if (name1->isame(name2.get()) ||
ClassInfo::IsSubClass(name1, name2, false)) {
staticCall = true;
v0 = name2;
v1 = str.substr(c + 2);
}
}
}
if (v0.isString() && v1.isString()) {
if (name.isReferenced()) {
name = v0.toString() + "::" + v1.toString();
}
if (same(v0, s_self) || same(v0, s_parent)) {
throw NotImplementedException("augmenting class scope info");
}
return ClassInfo::HasAccess(v0, v1, staticCall, !obj.isNull());
}
}
}
if (v.isObject()) {
ObjectData *d = v.objectForCall();
if (name.isReferenced()) {
name = d->o_getClassName() + "::__invoke";
}
void *extra;
const CallInfo *cit = d->t___invokeCallInfoHelper(extra);
return cit != NULL;
}
if (name.isReferenced()) {
name = v.toString();
}
return false;
}
示例13: f_is_callable
bool f_is_callable(CVarRef v, bool syntax /* = false */,
VRefParam name /* = null */) {
bool ret = true;
if (LIKELY(!syntax)) {
CallerFrame cf;
ObjectData* obj = NULL;
HPHP::VM::Class* cls = NULL;
StringData* invName = NULL;
const HPHP::VM::Func* f = vm_decode_function(v, cf(), false, obj, cls,
invName, false);
if (f == NULL) {
ret = false;
}
if (invName != NULL) {
decRefStr(invName);
}
if (!name.isReferenced()) return ret;
}
Variant::TypedValueAccessor tv_func = v.getTypedAccessor();
if (Variant::IsString(tv_func)) {
if (name.isReferenced()) name = Variant::GetStringData(tv_func);
return ret;
}
if (Variant::GetAccessorType(tv_func) == KindOfArray) {
CArrRef arr = Variant::GetAsArray(tv_func);
CVarRef clsname = arr.rvalAtRef(int64_t(0));
CVarRef mthname = arr.rvalAtRef(int64_t(1));
if (arr.size() != 2 ||
&clsname == &null_variant ||
&mthname == &null_variant) {
name = v.toString();
return false;
}
Variant::TypedValueAccessor tv_meth = mthname.getTypedAccessor();
if (!Variant::IsString(tv_meth)) {
if (name.isReferenced()) name = v.toString();
return false;
}
Variant::TypedValueAccessor tv_cls = clsname.getTypedAccessor();
if (Variant::GetAccessorType(tv_cls) == KindOfObject) {
name = Variant::GetObjectData(tv_cls)->o_getClassName();
} else if (Variant::IsString(tv_cls)) {
name = Variant::GetStringData(tv_cls);
} else {
name = v.toString();
return false;
}
name = concat3(name, "::", Variant::GetAsString(tv_meth));
return ret;
}
if (Variant::GetAccessorType(tv_func) == KindOfObject) {
ObjectData *d = Variant::GetObjectData(tv_func);
static const StringData* sd__invoke
= StringData::GetStaticString("__invoke");
const VM::Func* invoke = d->getVMClass()->lookupMethod(sd__invoke);
if (name.isReferenced()) {
if (d->instanceof(c_Closure::s_cls)) {
// Hack to stop the mangled name from showing up
name = "Closure::__invoke";
} else {
name = d->o_getClassName() + "::__invoke";
}
}
return invoke != NULL;
}
return false;
}