本文整理汇总了C++中ASObject::toString方法的典型用法代码示例。如果您正苦于以下问题:C++ ASObject::toString方法的具体用法?C++ ASObject::toString怎么用?C++ ASObject::toString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ASObject
的用法示例。
在下文中一共展示了ASObject::toString方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
ASFUNCTIONBODY(JSON,_stringify)
{
_NR<ASObject> value;
ARG_UNPACK(value);
std::vector<ASObject *> path;
tiny_string filter;
IFunction* replacer = NULL;
if (argslen > 1 && !args[1]->is<Null>() && !args[1]->is<Undefined>())
{
if (args[1]->is<IFunction>())
{
replacer = args[1]->as<IFunction>();
}
else if (args[1]->is<Array>())
{
filter = " ";
Array* ar = args[1]->as<Array>();
for (uint64_t i = 0; i < ar->size(); i++)
{
filter += ar->at(i)->toString();
filter += " ";
}
}
else
throwError<TypeError>(kJSONInvalidReplacer);
}
tiny_string spaces = "";
if (argslen > 2)
{
ASObject* space = args[2];
spaces = " ";
if (space->is<Number>() || space->is<Integer>() || space->is<UInteger>())
{
int32_t v = space->toInt();
if (v < 0) v = 0;
if (v > 10) v = 10;
spaces = spaces.substr_bytes(0,v);
}
else if (space->is<Boolean>() || space->is<Null>())
{
spaces = "";
}
else
{
if(space->has_toString())
{
_R<ASObject> ret = space->call_toString();
spaces = ret->toString();
}
else
spaces = space->toString();
if (spaces.numBytes() > 10)
spaces = spaces.substr_bytes(0,10);
}
}
tiny_string res = value->toJSON(path,replacer,spaces,filter);
return Class<ASString>::getInstanceS(res);
}
示例2: abstract_b
ASFUNCTIONBODY(Vector, every)
{
Vector* th=static_cast<Vector*>(obj);
if (argslen < 1)
throwError<ArgumentError>(kWrongArgumentCountError, "Vector.some", "1", Integer::toString(argslen));
if (!args[0]->is<IFunction>())
throwError<TypeError>(kCheckTypeFailedError, args[0]->getClassName(), "Function");
IFunction* f = static_cast<IFunction*>(args[0]);
ASObject* params[3];
ASObject *funcRet;
for(unsigned int i=0; i < th->size(); i++)
{
if (th->vec[i])
{
params[0] = th->vec[i];
th->vec[i]->incRef();
}
else
params[0] = obj->getSystemState()->getNullRef();
params[1] = abstract_i(obj->getSystemState(),i);
params[2] = th;
th->incRef();
if(argslen==1)
{
funcRet=f->call(obj->getSystemState()->getNullRef(), params, 3);
}
else
{
args[1]->incRef();
funcRet=f->call(args[1], params, 3);
}
if(funcRet)
{
if (funcRet->is<Undefined>() || funcRet->is<Null>())
throwError<TypeError>(kCallOfNonFunctionError, funcRet->toString());
if(!Boolean_concrete(funcRet))
{
return funcRet;
}
funcRet->decRef();
}
}
return abstract_b(obj->getSystemState(),true);
}