本文整理汇总了C++中cns函数的典型用法代码示例。如果您正苦于以下问题:C++ cns函数的具体用法?C++ cns怎么用?C++ cns使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cns函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: QVBoxLayout
void LoadEmojiUI::init()
{
mValue = 0;
QVBoxLayout *v = new QVBoxLayout();
QHBoxLayout *h = new QHBoxLayout();
QLabel *label = new QLabel(cns("请选择过滤文件的大小"), this);
mSlider = new QSlider(Qt::Horizontal, this);
mSlider->setMaximum(100);
mSlider->setMinimum(0);
mSlider->setValue(0);
connect(mSlider, SIGNAL(valueChanged(int)), this, SLOT(valueChanged(int)));
mLabel = new QLabel(cns("当前:0.0Kb"), this);
h->addWidget(label);
h->addSpacing(2);
h->addWidget(mLabel);
v->addLayout(h);
v->addWidget(mSlider);
mBar = new QProgressBar(this);
mBar->setMaximum(100);
mBar->setMinimum(0);
MoveEmojiCustom *movee = MoveEmojiCustom::GetInstance();
connect(movee, SIGNAL(signalProgress(int)), this, SLOT(progressValue(int)));
QPushButton *load = new QPushButton(cns("选择目录"), this);
connect(load, SIGNAL(clicked()), this, SLOT(clickLoad()));
v->addWidget(mBar);
v->addWidget(load, 0, Qt::AlignCenter);
setLayout(v);
this->setStyle(QStyleFactory::create(QStyleFactory::keys().last()));
}
开发者ID:AlanHJ,项目名称:TogetherHappy,代码行数:33,代码来源:loademojiui.cpp
示例2: emitCreateCl
/*
* The CreateCl opcode is specified as not being allowed before the
* class it creates exists, and closure classes are always unique.
*
* This means even if we're not in RepoAuthoritative mode, as long as
* this code is reachable it will always use the same closure Class*,
* so we can just burn it into the TC without using RDS.
*/
void emitCreateCl(HTS& env, int32_t numParams, const StringData* clsName) {
auto const cls = Unit::lookupClassOrUniqueClass(clsName);
auto const invokeFunc = cls->lookupMethod(s_uuinvoke.get());
auto const clonedFunc = invokeFunc->cloneAndSetClass(
const_cast<Class*>(curClass(env))
);
assert(cls && (cls->attrs() & AttrUnique));
auto const closure = allocObjFast(env, cls);
gen(env, IncRef, closure);
auto const ctx = [&]{
if (!curClass(env)) return cns(env, nullptr);
auto const ldctx = gen(env, LdCtx, fp(env));
if (invokeFunc->attrs() & AttrStatic) {
return gen(env, ConvClsToCctx, gen(env, LdClsCtx, ldctx));
}
gen(env, IncRefCtx, ldctx);
return ldctx;
}();
gen(env, StClosureCtx, closure, ctx);
gen(env, StClosureFunc, FuncData(clonedFunc), closure);
SSATmp* args[numParams];
for (int32_t i = 0; i < numParams; ++i) {
args[numParams - i - 1] = popF(env);
}
int32_t propId = 0;
for (; propId < numParams; ++propId) {
gen(
env,
StClosureArg,
PropByteOffset(cls->declPropOffset(propId)),
closure,
args[propId]
);
}
// Closure static variables are per instance, and need to start
// uninitialized. After numParams use vars, the remaining instance
// properties hold any static locals.
assert(cls->numDeclProperties() ==
clonedFunc->numStaticLocals() + numParams);
for (int32_t numDeclProperties = cls->numDeclProperties();
propId < numDeclProperties;
++propId) {
gen(
env,
StClosureArg,
PropByteOffset(cls->declPropOffset(propId)),
closure,
cns(env, Type::Uninit)
);
}
push(env, closure);
}
开发者ID:bsmr-misc-forks,项目名称:hhvm,代码行数:66,代码来源:irgen-create.cpp
示例3: emitNewArray
void emitNewArray(HTS& env, int32_t capacity) {
if (capacity == 0) {
push(env, cns(env, staticEmptyArray()));
} else {
if (auto newCap = PackedArray::getMaxCapInPlaceFast(capacity)) {
assert(newCap > static_cast<uint32_t>(capacity));
capacity = newCap;
}
push(env, gen(env, NewArray, cns(env, capacity)));
}
}
开发者ID:bsmr-misc-forks,项目名称:hhvm,代码行数:11,代码来源:irgen-create.cpp
示例4: emitNewLikeArrayL
void emitNewLikeArrayL(HTS& env, int32_t id, int32_t capacity) {
auto const ldrefExit = makeExit(env);
auto const ldPMExit = makeExit(env);
auto const ld = ldLocInner(env, id, ldrefExit, ldPMExit, DataTypeSpecific);
SSATmp* arr;
if (ld->isA(Type::Arr)) {
arr = gen(env, NewLikeArray, ld, cns(env, capacity));
} else {
capacity = (capacity ? capacity : MixedArray::SmallSize);
arr = gen(env, NewArray, cns(env, capacity));
}
push(env, arr);
}
开发者ID:bsmr-misc-forks,项目名称:hhvm,代码行数:14,代码来源:irgen-create.cpp
示例5: makeExitTrace
Trace* TraceBuilder::genExitTrace(uint32_t bcOff,
int32_t stackDeficit,
uint32_t numOpnds,
SSATmp* const* opnds,
TraceExitType::ExitType exitType,
uint32_t notTakenBcOff,
std::function<void(IRFactory*, Trace*)>
beforeExit) {
Trace* exitTrace = makeExitTrace(bcOff);
MarkerData marker;
marker.bcOff = bcOff;
marker.stackOff = m_spOffset + numOpnds - stackDeficit;
marker.func = m_curFunc->getValFunc();
exitTrace->back()->push_back(m_irFactory.gen(Marker, marker));
if (beforeExit) {
beforeExit(&m_irFactory, exitTrace);
}
SSATmp* sp = m_spValue;
if (numOpnds != 0 || stackDeficit != 0) {
SSATmp* srcs[numOpnds + 2];
srcs[0] = m_spValue;
srcs[1] = cns(stackDeficit);
std::copy(opnds, opnds + numOpnds, srcs + 2);
SSATmp** decayedPtr = srcs;
auto* spillInst = m_irFactory.gen(
SpillStack,
std::make_pair(numOpnds + 2, decayedPtr)
);
sp = spillInst->getDst();
exitTrace->back()->push_back(spillInst);
}
SSATmp* pc = cns(int64_t(bcOff));
if (exitType == TraceExitType::NormalCc) {
assert(notTakenBcOff != 0);
SSATmp* notTakenPC = cns(notTakenBcOff);
genFor(exitTrace, getExitOpcode(exitType),
m_curFunc,
pc, sp, m_fpValue,
notTakenPC);
} else {
assert(notTakenBcOff == 0);
genFor(exitTrace, getExitOpcode(exitType),
m_curFunc,
pc, sp, m_fpValue);
}
return exitTrace;
}
开发者ID:CyaLiven,项目名称:hiphop-php,代码行数:50,代码来源:tracebuilder.cpp
示例6: emitIssetS
void emitIssetS(HTS& env) {
auto const ssaPropName = topC(env, BCSPOffset{1});
if (!ssaPropName->isA(Type::Str)) {
PUNT(IssetS-PropNameNotString);
}
auto const ssaCls = popA(env);
auto const ret = cond(
env,
0,
[&] (Block* taken) {
auto propAddr = ldClsPropAddr(env, ssaCls, ssaPropName, false);
return gen(env, CheckNonNull, taken, propAddr);
},
[&] (SSATmp* ptr) { // Next: property or global exists
return gen(env, IsNTypeMem, Type::Null, gen(env, UnboxPtr, ptr));
},
[&] { // Taken: LdClsPropAddr* returned Nullptr because it isn't defined
return cns(env, false);
}
);
destroyName(env, ssaPropName);
push(env, ret);
}
开发者ID:bjori,项目名称:hhvm,代码行数:25,代码来源:irgen-sprop-global.cpp
示例7: parseIDL
void parseIDL(const char* idlFilePath,
fbvector<PhpFunc>& funcVec,
fbvector<PhpClass>& classVec,
fbvector<PhpConst>& constVec,
fbvector<PhpExtension>& extVec) {
std::ostringstream jsonString;
std::ifstream infile(idlFilePath);
infile >> jsonString.rdbuf();
auto parsed = folly::parseJson(jsonString.str());
for (auto const& f : parsed["funcs"]) {
PhpFunc func(f, "");
funcVec.push_back(func);
}
for (auto const& c : parsed["classes"]) {
PhpClass klass(c);
classVec.push_back(klass);
}
for (auto const& c : parsed["consts"]) {
PhpConst cns(c);
constVec.push_back(cns);
}
auto it = parsed.find("extension");
if (it != parsed.items().end()) {
PhpExtension ext(it->second);
extVec.push_back(ext);
}
}
开发者ID:abacaxinho,项目名称:hhvm,代码行数:29,代码来源:idl.cpp
示例8: emitInitProp
void emitInitProp(IRGS& env, const StringData* propName, InitPropOp op) {
auto const val = popC(env);
auto const ctx = curClass(env);
SSATmp* base;
Slot idx = 0;
switch (op) {
case InitPropOp::Static:
{
// For sinit, the context class is always the same as the late-bound
// class, so we can just use curClass().
auto const handle = ctx->sPropHandle(ctx->lookupSProp(propName));
base = gen(
env,
LdRDSAddr,
RDSHandleData { handle },
TPtrToSPropCell
);
}
break;
case InitPropOp::NonStatic:
{
// The above is not the case for pinit, so we need to load.
auto const cctx = gen(env, LdCctx, fp(env));
auto const cls = gen(env, LdClsCtx, cctx);
base = gen(env, LdClsInitData, cls);
idx = ctx->lookupDeclProp(propName);
}
break;
}
gen(env, StElem, base, cns(env, idx * sizeof(TypedValue)), val);
}
开发者ID:191919,项目名称:hhvm,代码行数:35,代码来源:irgen-sprop-global.cpp
示例9: localType
SSATmp* TraceBuilder::preOptimizeAssertLoc(IRInstruction* inst) {
auto const locId = inst->extra<AssertLoc>()->locId;
auto const prevType = localType(locId, DataTypeGeneric);
auto const typeParam = inst->typeParam();
if (!prevType.equals(Type::None) && !typeParam.strictSubtypeOf(prevType)) {
if (!prevType.subtypeOf(typeParam)) {
/* Task #2553746
* This is triggering for a case where the tracked state says the local is
* InitNull but the AssertLoc says it's Str. */
static auto const error =
StringData::GetStaticString("Internal error: static analysis was "
"wrong about a local variable's type.");
auto* errorInst = m_irFactory.gen(RaiseError, inst->marker(), cns(error));
inst->become(&m_irFactory, errorInst);
// It's not a disaster to generate this in unreachable code for
// now. t2590033.
if (false) {
assert_log(false, [&]{
IRTrace& mainTrace = trace()->isMain() ? *trace()
: *(trace()->main());
return folly::format("\npreOptimizeAssertLoc: prevType: {} "
"typeParam: {}\nin instr: {}\nin trace: {}\n",
prevType.toString(), typeParam.toString(),
inst->toString(), mainTrace.toString()).str();
});
}
} else {
inst->convertToNop();
}
}
return nullptr;
}
开发者ID:bnovoa,项目名称:hiphop-php,代码行数:34,代码来源:trace-builder.cpp
示例10: implInstanceOfD
SSATmp* implInstanceOfD(IRGS& env, SSATmp* src, const StringData* className) {
/*
* InstanceOfD is always false if it's not an object.
*
* We're prepared to generate translations for known non-object types, but if
* it's Gen/Cell we're going to PUNT because it's natural to translate that
* case with control flow TODO(#2020251)
*/
if (TObj < src->type()) {
PUNT(InstanceOfD_MaybeObj);
}
if (!src->isA(TObj)) {
bool res = ((src->isA(TArr) && interface_supports_array(className))) ||
(src->isA(TStr) && interface_supports_string(className)) ||
(src->isA(TInt) && interface_supports_int(className)) ||
(src->isA(TDbl) && interface_supports_double(className));
return cns(env, res);
}
auto const checkCls = ldClassSafe(env, className);
if (auto isInstance = implInstanceCheck(env, src, className, checkCls)) {
return isInstance;
}
return gen(env, InstanceOf, gen(env, LdObjClass, src), checkCls);
}
开发者ID:Apfelfrisch,项目名称:hhvm,代码行数:26,代码来源:irgen-types.cpp
示例11: emitPrint
void emitPrint(HTS& env) {
auto const type = topC(env)->type();
if (!type.subtypeOfAny(Type::Int, Type::Bool, Type::Null, Type::Str)) {
interpOne(env, Type::Int, 1);
return;
}
auto const cell = popC(env);
Opcode op;
if (type <= Type::Str) {
op = PrintStr;
} else if (type <= Type::Int) {
op = PrintInt;
} else if (type <= Type::Bool) {
op = PrintBool;
} else {
assert(type <= Type::Null);
op = Nop;
}
// the print helpers decref their arg, so don't decref pop'ed value
if (op != Nop) {
gen(env, op, cell);
}
push(env, cns(env, 1));
}
开发者ID:bsmr-misc-forks,项目名称:hhvm,代码行数:26,代码来源:irgen-basic.cpp
示例12: cns
void LoadEmojiUI::clickLoad()
{
// QString dirctory =
// QFileDialog::getExistingDirectory(this, cns("选择表情包路径"));
// QStringList filters;
// filters << "*.jpg" << "*.gif" << "*.bmp"
// << "*.jpeg" << "*.png" << "*.pbm"
// << "*.pgm" << "*.ppm" << "*.xbm" << "*.xpm";
// QDir dirs(dirctory);
// QFileInfoList infolst = dirs.entryInfoList(filters, QDir::Files);
QString filter = "(*.jpg);;(*.png);;(*.gif);;(*.bmp);;(*)";
QStringList infolst = QFileDialog::getOpenFileNames(this, cns("选择表情包"), ".", filter);
QStringList imagelist;
auto it = infolst.begin();
while (it != infolst.end())
{
QFileInfo info = *it;
if (info.exists())
{
qint64 size = info.size();
if (size > mValue)
{
imagelist << info.filePath();
}
// qDebug() << info.filePath() + " size:" + QString::number(size);
}
++it;
}
QString path = "D:/Program Files/happy";
QDir dir(".");
QFileInfo info(path);
if (!info.exists())
{
dir.mkpath(info.absoluteFilePath());
}
if (imagelist.isEmpty())
{
// mBar->setValue(100);
}
QFile file(path + "/emoji.data");
if (file.open(QIODevice::WriteOnly | QIODevice::Append))
{
for (int i = 0; i < imagelist.size(); i++)
{
QString image = imagelist.at(i) + ";";
file.seek(file.size());
file.write(image.toLocal8Bit());
// float num = i;
// float counts = imagelist.size();
// mBar->setValue(num / (counts - 1) * 100);
}
}
file.close();
emit MoveEmojiCustom::GetInstance()->signalStartMoves(imagelist);
}
开发者ID:AlanHJ,项目名称:TogetherHappy,代码行数:60,代码来源:loademojiui.cpp
示例13: ldClsPropAddr
SSATmp* ldClsPropAddr(IRGS& env, SSATmp* ssaCls, SSATmp* ssaName, bool raise) {
/*
* We can use ldClsPropAddrKnown if either we know which property it is and
* that it is visible && accessible, or we know it is a property on this
* class itself.
*/
bool const sPropKnown = [&] {
if (!ssaName->hasConstVal()) return false;
auto const propName = ssaName->strVal();
if (!ssaCls->hasConstVal()) return false;
auto const cls = ssaCls->clsVal();
if (!classIsPersistentOrCtxParent(env, cls)) return false;
auto const lookup = cls->findSProp(curClass(env), propName);
return lookup.prop != kInvalidSlot && lookup.accessible;
}();
if (sPropKnown) {
return ldClsPropAddrKnown(env, ssaCls->clsVal(), ssaName->strVal());
}
return gen(
env,
raise ? LdClsPropAddrOrRaise : LdClsPropAddrOrNull,
ssaCls,
ssaName,
cns(env, curClass(env))
);
}
开发者ID:191919,项目名称:hhvm,代码行数:30,代码来源:irgen-sprop-global.cpp
示例14: emitStaticLocInit
void emitStaticLocInit(HTS& env, int32_t locId, const StringData* name) {
if (curFunc(env)->isPseudoMain()) PUNT(StaticLocInit);
auto const ldPMExit = makePseudoMainExit(env);
auto const value = popC(env);
// Closures and generators from closures don't satisfy the "one static per
// source location" rule that the inline fastpath requires
auto const box = [&]{
if (curFunc(env)->isClosureBody()) {
return gen(env, ClosureStaticLocInit, cns(env, name), fp(env), value);
}
auto const cachedBox =
gen(env, LdStaticLocCached, StaticLocName { curFunc(env), name });
ifThen(
env,
[&] (Block* taken) {
gen(env, CheckStaticLocInit, taken, cachedBox);
},
[&] {
hint(env, Block::Hint::Unlikely);
gen(env, StaticLocInitCached, cachedBox, value);
}
);
return cachedBox;
}();
gen(env, IncRef, box);
auto const oldValue = ldLoc(env, locId, ldPMExit, DataTypeSpecific);
stLocRaw(env, locId, fp(env), box);
gen(env, DecRef, oldValue);
// We don't need to decref value---it's a bytecode invariant that
// our Cell was not ref-counted.
}
开发者ID:bsmr-misc-forks,项目名称:hhvm,代码行数:34,代码来源:irgen-create.cpp
示例15: localType
SSATmp* TraceBuilder::preOptimizeAssertLoc(IRInstruction* inst) {
auto const locId = inst->extra<AssertLoc>()->locId;
auto const prevType = localType(locId, DataTypeGeneric);
auto const typeParam = inst->typeParam();
if (prevType.not(typeParam)) {
/* Task #2553746
* This is triggering for a case where the tracked state says the local is
* InitNull but the AssertLoc says it's Str. */
static auto const error =
makeStaticString("Internal error: static analysis was "
"wrong about a local variable's type.");
auto* errorInst = m_unit.gen(RaiseError, inst->marker(), cns(error));
inst->become(m_unit, errorInst);
// It's not a disaster to generate this in unreachable code for
// now. t2590033.
if (false) {
assert_log(false, [&]{
return folly::format("\npreOptimizeAssertLoc: prevType: {} "
"typeParam: {}\nin instr: {}\nin trace: {}\n",
prevType.toString(),
typeParam.toString(),
inst->toString(),
m_unit.main()->toString()).str();
});
}
} else if (shouldElideAssertType(prevType, typeParam, nullptr)) {
// The type we're asserting is worse than the last known type.
return inst->src(0);
}
return nullptr;
}
开发者ID:davedevelopment,项目名称:hhvm,代码行数:34,代码来源:trace-builder.cpp
示例16: QWidget
LoadEmojiUI::LoadEmojiUI(QWidget *parent) : QWidget(parent)
{
init();
setWindowFlags(Qt::Tool);
setAttribute(Qt::WA_DeleteOnClose);
setWindowModality(Qt::ApplicationModal);
setWindowTitle(cns("哈啤表情导入"));
}
开发者ID:AlanHJ,项目名称:TogetherHappy,代码行数:8,代码来源:loademojiui.cpp
示例17: gen
void TraceBuilder::genTraceEnd(uint32_t nextPc,
TraceExitType::ExitType exitType /* = Normal */) {
gen(getExitOpcode(TraceExitType::Normal),
m_curFunc,
cns(nextPc),
m_spValue,
m_fpValue);
}
开发者ID:CyaLiven,项目名称:hiphop-php,代码行数:8,代码来源:tracebuilder.cpp
示例18: cns
vespalib::HealthProducer::Health
StateReporter::getHealth() const
{
lib::NodeState cns(*_component.getStateUpdater().getCurrentNodeState());
bool up = cns.getState().oneOf("u");
std::string message = up ? "" : "Node state: " + cns.toString(true);
return vespalib::HealthProducer::Health(up, message);
}
开发者ID:songhtdo,项目名称:vespa,代码行数:8,代码来源:statereporter.cpp
示例19: switch
void ClientOpt::recvMessageData(MessageData data)
{
mData->type = data.datatype();
switch (mData->type) {
case Ping:
{
qDebug() << cns("recv ping");
MessageData msg;
MessagePong *pong = new MessagePong();
msg.setDatatype(pong->datatype());
msg.setContent(pong);
NetworkData data;
msg.toStream(data);
emit sendMessage(data);
qDebug() << cns("send pong");
}
break;
case Pong:
qDebug() << cns("recv pong");
break;
case Greeting:
{
mData->state = ReadyForUse;
MessageGreeting *greeting = dynamic_cast<MessageGreeting *>(data.content());
if (nullptr != greeting)
{
mData->clientKey = greeting->greetingKey();
emit readyForUse(mData->clientKey);
}
}
break;
case RichText:
emit sendUIMessage(data);
break;
case FileSendType:
emit sendFileMessage(data);
break;
case FileHead:
emit sendFileMessage(data);
break;
case undefine:
break;
default:
break;
}
}
开发者ID:AlanHJ,项目名称:TogetherHappy,代码行数:46,代码来源:clientopt.cpp
示例20: QWidget
BuildGroupUI::BuildGroupUI(QWidget *parent) : QWidget(parent)
{
init();
setWindowTitle(cns("新建群"));
setAttribute(Qt::WA_DeleteOnClose);
setWindowFlags(Qt::Tool);
setWindowModality(Qt::ApplicationModal);
}
开发者ID:AlanHJ,项目名称:TogetherHappy,代码行数:8,代码来源:buildgroupui.cpp
注:本文中的cns函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论