本文整理汇总了C++中ASObject::incRef方法的典型用法代码示例。如果您正苦于以下问题:C++ ASObject::incRef方法的具体用法?C++ ASObject::incRef怎么用?C++ ASObject::incRef使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ASObject
的用法示例。
在下文中一共展示了ASObject::incRef方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
ASFUNCTIONBODY(Vector,_map)
{
Vector* th=static_cast<Vector*>(obj);
_NR<IFunction> func;
_NR<ASObject> thisObject;
if (argslen >= 1 && !args[0]->is<IFunction>())
throwError<TypeError>(kCheckTypeFailedError, args[0]->getClassName(), "Function");
ARG_UNPACK(func)(thisObject,NullRef);
Vector* ret= (Vector*)obj->getClass()->getInstance(true,NULL,0);
ASObject* thisObj;
for(uint32_t i=0;i<th->size();i++)
{
ASObject* funcArgs[3];
if (!th->vec[i])
funcArgs[0]=obj->getSystemState()->getNullRef();
else
{
if(th->vec[i])
{
funcArgs[0]=th->vec[i];
funcArgs[0]->incRef();
}
else
funcArgs[0]=obj->getSystemState()->getUndefinedRef();
}
funcArgs[1]=abstract_i(obj->getSystemState(),i);
funcArgs[2]=th;
funcArgs[2]->incRef();
if (thisObject.isNull())
thisObj = obj->getSystemState()->getNullRef();
else
{
thisObj = thisObject.getPtr();
thisObj->incRef();
}
ASObject* funcRet=func->call(thisObj, funcArgs, 3);
assert_and_throw(funcRet);
ret->vec.push_back(funcRet);
}
return ret;
}
示例2: generator
ASObject* Vector::generator(TemplatedClass<Vector>* o_class, ASObject* const* args, const unsigned int argslen)
{
assert_and_throw(argslen == 1);
assert_and_throw(args[0]->getClass());
assert_and_throw(o_class->getTypes().size() == 1);
Type* type = o_class->getTypes()[0];
if(args[0]->getClass() == Class<Array>::getClass())
{
//create object without calling _constructor
Vector* ret = o_class->getInstance(false,NULL,0);
Array* a = static_cast<Array*>(args[0]);
for(unsigned int i=0;i<a->size();++i)
{
ASObject* obj = a->at(i).getPtr();
obj->incRef();
//Convert the elements of the array to the type of this vector
ret->vec.push_back( type->coerce(obj) );
}
return ret;
}
else if(args[0]->getClass()->getTemplate() == Template<Vector>::getTemplate())
{
Vector* arg = static_cast<Vector*>(args[0]);
//create object without calling _constructor
Vector* ret = o_class->getInstance(false,NULL,0);
for(auto i = arg->vec.begin(); i != arg->vec.end(); ++i)
{
(*i)->incRef();
ret->vec.push_back( type->coerce(*i) );
}
return ret;
}
else
{
throw Class<ArgumentError>::getInstanceS("global Vector() function takes Array or Vector");
}
}
示例3: setprop_prototype
/*
* (creates and) sets the property 'prototype' to o
* 'prototype' is usually DYNAMIC_TRAIT, but on Class_base
* it is a DECLARED_TRAIT, which is gettable only
*/
void ASObject::setprop_prototype(_NR<ASObject>& o)
{
ASObject* obj = o.getPtr();
obj->incRef();
multiname prototypeName;
prototypeName.name_type=multiname::NAME_STRING;
prototypeName.name_s="prototype";
prototypeName.ns.push_back(nsNameAndKind("",NAMESPACE));
bool has_getter = false;
variable* ret=findSettable(prototypeName,false, &has_getter);
if(!ret && has_getter)
throw Class<ReferenceError>::getInstanceS("Error #1074: Illegal write to read-only property prototype");
if(!ret)
ret = Variables.findObjVar(prototypeName,DYNAMIC_TRAIT,DECLARED_TRAIT|DYNAMIC_TRAIT);
if(ret->setter)
{
this->incRef();
_MR( ret->setter->call(this,&obj,1) );
}
else
ret->setVar(obj);
}
示例4: execute
//.........这里部分代码省略.........
getVm()->addEvent(this, status);
status->decRef();
}
else
{
videoDecoder->decodeData(tag.packetData,tag.packetLen, frameTime);
decodedVideoFrames++;
}
break;
}
case 18:
{
tag = ScriptDataTag(s);
prevSize=tag.getTotalLen();
//The frameRate of the container overrides the stream
if(tag.metadataDouble.find("framerate") != tag.metadataDouble.end())
frameRate=tag.metadataDouble["framerate"];
break;
}
default:
LOG(LOG_ERROR,_("Unexpected tag type ") << (int)TagType << _(" in FLV"));
threadAbort();
}
if(!tickStarted && isReady())
{
{
multiname onMetaDataName;
onMetaDataName.name_type=multiname::NAME_STRING;
onMetaDataName.name_s="onMetaData";
onMetaDataName.ns.push_back(nsNameAndKind("",NAMESPACE));
ASObject* callback = client->getVariableByMultiname(onMetaDataName);
if(callback && callback->getObjectType() == T_FUNCTION)
{
ASObject* callbackArgs[1];
ASObject* metadata = Class<ASObject>::getInstanceS();
if(tag.metadataDouble.find("width") != tag.metadataDouble.end())
metadata->setVariableByQName("width", "",
abstract_d(tag.metadataDouble["width"]));
else
metadata->setVariableByQName("width", "", abstract_d(getVideoWidth()));
if(tag.metadataDouble.find("height") != tag.metadataDouble.end())
metadata->setVariableByQName("height", "",
abstract_d(tag.metadataDouble["height"]));
else
metadata->setVariableByQName("height", "", abstract_d(getVideoHeight()));
if(tag.metadataDouble.find("framerate") != tag.metadataDouble.end())
metadata->setVariableByQName("framerate", "",
abstract_d(tag.metadataDouble["framerate"]));
if(tag.metadataDouble.find("duration") != tag.metadataDouble.end())
metadata->setVariableByQName("duration", "",
abstract_d(tag.metadataDouble["duration"]));
if(tag.metadataInteger.find("canseekontime") != tag.metadataInteger.end())
metadata->setVariableByQName("canSeekToEnd", "",
abstract_b(tag.metadataInteger["canseekontime"] == 1));
if(tag.metadataDouble.find("audiodatarate") != tag.metadataDouble.end())
metadata->setVariableByQName("audiodatarate", "",
abstract_d(tag.metadataDouble["audiodatarate"]));
if(tag.metadataDouble.find("videodatarate") != tag.metadataDouble.end())
metadata->setVariableByQName("videodatarate", "",
abstract_d(tag.metadataDouble["videodatarate"]));
//TODO: missing: audiocodecid (Number), cuePoints (Object[]),
//videocodecid (Number), custommetadata's
callbackArgs[0] = metadata;
client->incRef();
metadata->incRef();
FunctionEvent* event =
new FunctionEvent(static_cast<IFunction*>(callback), client, callbackArgs, 1);
getVm()->addEvent(NULL,event);
event->decRef();
}
}
tickStarted=true;
if(frameRate==0)
{
assert(videoDecoder->frameRate);
frameRate=videoDecoder->frameRate;
}
sys->addTick(1000/frameRate,this);
//Also ask for a render rate equal to the video one (capped at 24)
float localRenderRate=dmin(frameRate,24);
sys->setRenderRate(localRenderRate);
}
profile->accountTime(chronometer.checkpoint());
if(aborting)
{
throw JobTerminationException();
}
}
while(!done);
}
else
threadAbort();
}
示例5: execute
void NetStream::execute()
{
//checkPolicyFile only applies to per-pixel access, loading and playing is always allowed.
//So there is no need to disallow playing if policy files disallow it.
//We do need to check if per-pixel access is allowed.
SecurityManager::EVALUATIONRESULT evaluationResult = sys->securityManager->evaluatePoliciesURL(url, true);
if(evaluationResult == SecurityManager::NA_CROSSDOMAIN_POLICY)
rawAccessAllowed = true;
if(downloader->hasFailed())
{
this->incRef();
sys->currentVm->addEvent(_MR(this),_MR(Class<Event>::getInstanceS("ioError")));
sys->downloadManager->destroy(downloader);
return;
}
//The downloader hasn't failed yet at this point
istream s(downloader);
s.exceptions ( istream::eofbit | istream::failbit | istream::badbit );
ThreadProfile* profile=sys->allocateProfiler(RGB(0,0,200));
profile->setTag("NetStream");
bool waitForFlush=true;
StreamDecoder* streamDecoder=NULL;
//We need to catch possible EOF and other error condition in the non reliable stream
try
{
Chronometer chronometer;
streamDecoder=new FFMpegStreamDecoder(s);
if(!streamDecoder->isValid())
threadAbort();
bool done=false;
while(!done)
{
//Check if threadAbort has been called, if so, stop this loop
if(closed)
done = true;
bool decodingSuccess=streamDecoder->decodeNextFrame();
if(decodingSuccess==false)
done = true;
if(videoDecoder==NULL && streamDecoder->videoDecoder)
{
videoDecoder=streamDecoder->videoDecoder;
this->incRef();
getVm()->addEvent(_MR(this),
_MR(Class<NetStatusEvent>::getInstanceS("status", "NetStream.Play.Start")));
this->incRef();
getVm()->addEvent(_MR(this),
_MR(Class<NetStatusEvent>::getInstanceS("status", "NetStream.Buffer.Full")));
}
if(audioDecoder==NULL && streamDecoder->audioDecoder)
audioDecoder=streamDecoder->audioDecoder;
if(audioStream==NULL && audioDecoder && audioDecoder->isValid() && sys->audioManager->pluginLoaded())
audioStream=sys->audioManager->createStreamPlugin(audioDecoder);
if(audioStream && audioStream->paused() && !paused)
{
//The audio stream is paused but should not!
//As we have new data fill the stream
audioStream->fill();
}
if(!tickStarted && isReady())
{
multiname onMetaDataName;
onMetaDataName.name_type=multiname::NAME_STRING;
onMetaDataName.name_s="onMetaData";
onMetaDataName.ns.push_back(nsNameAndKind("",NAMESPACE));
ASObject* callback = client->getVariableByMultiname(onMetaDataName);
if(callback && callback->getObjectType() == T_FUNCTION)
{
ASObject* callbackArgs[1];
ASObject* metadata = Class<ASObject>::getInstanceS();
double d;
uint32_t i;
if(streamDecoder->getMetadataDouble("width",d))
metadata->setVariableByQName("width", "",abstract_d(d),DYNAMIC_TRAIT);
else
metadata->setVariableByQName("width", "", abstract_d(getVideoWidth()),DYNAMIC_TRAIT);
if(streamDecoder->getMetadataDouble("height",d))
metadata->setVariableByQName("height", "",abstract_d(d),DYNAMIC_TRAIT);
else
metadata->setVariableByQName("height", "", abstract_d(getVideoHeight()),DYNAMIC_TRAIT);
if(streamDecoder->getMetadataDouble("framerate",d))
metadata->setVariableByQName("framerate", "",abstract_d(d),DYNAMIC_TRAIT);
if(streamDecoder->getMetadataDouble("duration",d))
metadata->setVariableByQName("duration", "",abstract_d(d),DYNAMIC_TRAIT);
if(streamDecoder->getMetadataInteger("canseekontime",i))
metadata->setVariableByQName("canSeekToEnd", "",abstract_b(i == 1),DYNAMIC_TRAIT);
if(streamDecoder->getMetadataDouble("audiodatarate",d))
metadata->setVariableByQName("audiodatarate", "",abstract_d(d),DYNAMIC_TRAIT);
if(streamDecoder->getMetadataDouble("videodatarate",d))
metadata->setVariableByQName("videodatarate", "",abstract_d(d),DYNAMIC_TRAIT);
//.........这里部分代码省略.........