//------------------------------------------------------------------------------------- FixedArray::FixedArray(DataType* dataType, PyObject* pyInitData): Sequence(getScriptType(), false) { _dataType = static_cast<FixedArrayType*>(dataType); _dataType->incRef(); initialize(pyInitData); }
//------------------------------------------------------------------------------------- ClientEntity::ClientEntity(ENTITY_ID srcEntityID, ENTITY_ID clientEntityID): ScriptObject(getScriptType(), false), srcEntityID_(srcEntityID), clientEntityID_(clientEntityID) { }
//------------------------------------------------------------------------------------- FixedArray::FixedArray(DataType* dataType): Sequence(getScriptType(), false) { _dataType = static_cast<FixedArrayType*>(dataType); _dataType->incRef(); initialize(""); }
//------------------------------------------------------------------------------------- FixedArray::FixedArray(DataType* dataType, std::string& strInitData): Sequence(getScriptType(), false) { _dataType = static_cast<FixedArrayType*>(dataType); _dataType->incRef(); initialize(strInitData); }
void Ref::release() { CCASSERT(_referenceCount > 0, "reference count should be greater than 0"); --_referenceCount; #if CC_ENABLE_SCRIPT_BINDING && CC_ENABLE_GC_FOR_NATIVE_OBJECTS if (_scriptOwned && _rooted && _referenceCount==/*_referenceCountAtRootTime*/ 1) { auto scriptMgr = ScriptEngineManager::getInstance()->getScriptEngine(); if (scriptMgr && scriptMgr->getScriptType() == kScriptTypeJavascript) { scriptMgr->unrootObject(this); } } #endif // CC_ENABLE_SCRIPT_BINDING if (_referenceCount == 0) { #if defined(COCOS2D_DEBUG) && (COCOS2D_DEBUG > 0) auto poolManager = PoolManager::getInstance(); if (!poolManager->getCurrentPool()->isClearing() && poolManager->isObjectInPools(this)) { // Trigger an assert if the reference count is 0 but the Ref is still in autorelease pool. // This happens when 'autorelease/release' were not used in pairs with 'new/retain'. // // Wrong usage (1): // // auto obj = Node::create(); // Ref = 1, but it's an autorelease Ref which means it was in the autorelease pool. // obj->autorelease(); // Wrong: If you wish to invoke autorelease several times, you should retain `obj` first. // // Wrong usage (2): // // auto obj = Node::create(); // obj->release(); // Wrong: obj is an autorelease Ref, it will be released when clearing current pool. // // Correct usage (1): // // auto obj = Node::create(); // |- new Node(); // `new` is the pair of the `autorelease` of next line // |- autorelease(); // The pair of `new Node`. // // obj->retain(); // obj->autorelease(); // This `autorelease` is the pair of `retain` of previous line. // // Correct usage (2): // // auto obj = Node::create(); // obj->retain(); // obj->release(); // This `release` is the pair of `retain` of previous line. CCASSERT(false, "The reference shouldn't be 0 because it is still in autorelease pool."); } #endif #if CC_REF_LEAK_DETECTION untrackRef(this); #endif delete this; } }
//------------------------------------------------------------------------------------- ClientEntityMethod::ClientEntityMethod(MethodDescription* methodDescription, ENTITY_ID srcEntityID, ENTITY_ID clientEntityID): script::ScriptObject(getScriptType(), false), methodDescription_(methodDescription), srcEntityID_(srcEntityID), clientEntityID_(clientEntityID) { }
//------------------------------------------------------------------------------------- RemoteEntityMethod::RemoteEntityMethod(MethodDescription* methodDescription, EntityMailboxAbstract* mailbox, PyTypeObject* pyType): script::ScriptObject((pyType == NULL ? getScriptType() : pyType), false), methodDescription_(methodDescription), pMailbox_(mailbox) { Py_INCREF(pMailbox_); }
//------------------------------------------------------------------------------------- AllClients::AllClients(const ScriptDefModule* scriptModule, ENTITY_ID eid, bool otherClients): ScriptObject(getScriptType(), false), scriptModule_(scriptModule), id_(eid), otherClients_(otherClients) { }
//------------------------------------------------------------------------------------- Entity::Entity(ENTITY_ID id, const ScriptDefModule* scriptModule): ScriptObject(getScriptType(), true), ENTITY_CONSTRUCTION(Entity), cellMailbox_(NULL), baseMailbox_(NULL), pChannel_(NULL) { ENTITY_INIT_PROPERTYS(Entity); }
//------------------------------------------------------------------------------------- ClientsRemoteEntityMethod::ClientsRemoteEntityMethod(MethodDescription* methodDescription, bool otherClients, ENTITY_ID id): script::ScriptObject(getScriptType(), false), methodDescription_(methodDescription), otherClients_(otherClients), id_(id) { }
//------------------------------------------------------------------------------------- RealEntityMethod::RealEntityMethod(MethodDescription* methodDescription, Entity* ghostEntity): script::ScriptObject(getScriptType(), false), methodDescription_(methodDescription), ghostEntityID_(ghostEntity->getID()), realCell_(ghostEntity->realCell()), scriptName_(ghostEntity->getScriptName()) { }
//------------------------------------------------------------------------------------- FixedArray::FixedArray(DataType* dataType): Sequence(getScriptType(), false) { _dataType = static_cast<FixedArrayType*>(dataType); _dataType->incRef(); script::PyGC::incTracing("FixedArray"); // DEBUG_MSG(fmt::format("FixedArray::FixedArray(): {:p}\n", this)); }
//------------------------------------------------------------------------------------- ClientObject::ClientObject(std::string name, Mercury::NetworkInterface& ninterface): ClientObjectBase(ninterface, getScriptType()), error_(C_ERROR_NONE), state_(C_STATE_INIT), pBlowfishFilter_(0) { name_ = name; typeClient_ = CLIENT_TYPE_BOTS; extradatas_ = "bots"; }
//------------------------------------------------------------------------------------- ClientObject::ClientObject(std::string name, Network::NetworkInterface& ninterface): ClientObjectBase(ninterface, getScriptType()), error_(C_ERROR_NONE), state_(C_STATE_INIT), pBlowfishFilter_(0), pTCPPacketSenderEx_(NULL), pTCPPacketReceiverEx_(NULL) { name_ = name; typeClient_ = CLIENT_TYPE_BOTS; clientDatas_ = "bots"; }
//------------------------------------------------------------------------------------- ClientObject::ClientObject(std::string name, Network::NetworkInterface& ninterface): ClientObjectBase(ninterface, getScriptType()), Network::TCPPacketReceiver(), error_(C_ERROR_NONE), state_(C_STATE_INIT), pBlowfishFilter_(0) { name_ = name; typeClient_ = CLIENT_TYPE_BOTS; extradatas_ = "bots"; this->pNetworkInterface_ = &ninterface; }
//------------------------------------------------------------------------------------- Proxy::Proxy(ENTITY_ID id, const ScriptDefModule* scriptModule): Base(id, scriptModule, getScriptType(), true), rndUUID_(KBEngine::genUUID64()), addr_(Mercury::Address::NONE), dataDownloads_(), entitiesEnabled_(false), bandwidthPerSecond_(0), encryptionKey(), pProxyForwarder_(NULL), clientComponentType_(UNKNOWN_CLIENT_COMPONENT_TYPE) { Baseapp::getSingleton().incProxicesCount(); pProxyForwarder_ = new ProxyForwarder(this); }
//------------------------------------------------------------------------------------- Entity::Entity(ENTITY_ID id, const ScriptDefModule* scriptModule): ScriptObject(getScriptType(), true), ENTITY_CONSTRUCTION(Entity), clientMailbox_(NULL), baseMailbox_(NULL), isReal_(true), topSpeed_(-0.1f), topSpeedY_(-0.1f), isWitnessed_(false), pWitness_(NULL), allClients_(new AllClients(scriptModule, id, true)), otherClients_(new AllClients(scriptModule, id, false)) { ENTITY_INIT_PROPERTYS(Entity); }
void Ref::retain() { CCASSERT(_referenceCount > 0, "reference count should be greater than 0"); ++_referenceCount; #if CC_ENABLE_SCRIPT_BINDING && CC_ENABLE_GC_FOR_NATIVE_OBJECTS if (_scriptOwned && !_rooted) { auto scriptMgr = ScriptEngineManager::getInstance()->getScriptEngine(); if (scriptMgr && scriptMgr->getScriptType() == kScriptTypeJavascript) { _referenceCountAtRootTime = _referenceCount-1; scriptMgr->rootObject(this); } } #endif // CC_ENABLE_SCRIPT_BINDING }
void Ref::retain() { CCASSERT(_referenceCount > 0, "reference count should be greater than 0"); #if CC_ENABLE_SCRIPT_BINDING auto engine = ScriptEngineManager::getInstance()->getScriptEngine(); if (!engine || engine->getScriptType() != kScriptTypeRuby) { ++_referenceCount; } else { if (!engine->retainScriptObjectByObject(this)) { ++_referenceCount; } } #else ++_referenceCount; #endif }
//------------------------------------------------------------------------------------- ClientObject::ClientObject(std::string name): ScriptObject(getScriptType(), false), appID_(0), pChannel_(new Mercury::Channel()), name_(name), password_(), error_(C_ERROR_NONE), state_(C_STATE_INIT), entityID_(0), dbid_(0), ip_(), port_(), lastSentActiveTickTime_(timestamp()), connectedGateway_(false), pEntities_(new Entities<Entity>()), pyCallbackMgr_() { pChannel_->incRef(); appID_ = g_appID++; }
//------------------------------------------------------------------------------------- ClientObjectBase::ClientObjectBase(Mercury::NetworkInterface& ninterface, PyTypeObject* pyType): ScriptObject(pyType != NULL ? pyType : getScriptType(), false), appID_(0), pServerChannel_(new Mercury::Channel()), pEntities_(new Entities<client::Entity>()), pyCallbackMgr_(), entityID_(0), dbid_(0), ip_(), port_(), lastSentActiveTickTime_(timestamp()), connectedGateway_(false), name_(), password_(), extradatas_("unknown"), typeClient_(CLIENT_TYPE_PC), bufferedCreateEntityMessage_(), eventHandler_() { pServerChannel_->incRef(); appID_ = g_appID++; pServerChannel_->pNetworkInterface(&ninterface); }
//------------------------------------------------------------------------------------- Blob::Blob(MemoryStream* streamInitData, bool readonly): PyMemoryStream(getScriptType(), false, readonly) { initialize(streamInitData); script::PyGC::incTracing("Blob"); }
//------------------------------------------------------------------------------------- BaseRemoteMethod::BaseRemoteMethod(MethodDescription* methodDescription, EntityMailboxAbstract* mailbox): RemoteEntityMethod(methodDescription, mailbox, getScriptType()) { }
//------------------------------------------------------------------------------------- Proxy::Proxy(ENTITY_ID id, const ScriptDefModule* scriptModule): Base(id, scriptModule, getScriptType(), true), rndUUID_(KBEngine::genUUID64()), addr_(Mercury::Address::NONE) { }
//------------------------------------------------------------------------------------- Blob::Blob(PyObject* pyDictInitData, bool readonly): PyMemoryStream(getScriptType(), false, readonly) { initialize(pyDictInitData); script::PyGC::incTracing("Blob"); }
//------------------------------------------------------------------------------------- GlobalDataClient::GlobalDataClient(COMPONENT_TYPE componentType, GlobalDataServer::DATA_TYPE dataType): script::Map(getScriptType(), false), serverComponentType_(componentType), dataType_(dataType) { }
//------------------------------------------------------------------------------------- Blob::Blob(bool readonly): PyMemoryStream(getScriptType(), false, readonly) { initialize(""); script::PyGC::incTracing("Blob"); }
Node::Node() : _rotationX(0.0f) , _rotationY(0.0f) , _rotationZ_X(0.0f) , _rotationZ_Y(0.0f) , _scaleX(1.0f) , _scaleY(1.0f) , _scaleZ(1.0f) , _positionZ(0.0f) , _usingNormalizedPosition(false) , _normalizedPositionDirty(false) , _skewX(0.0f) , _skewY(0.0f) , _contentSize(Size::ZERO) , _contentSizeDirty(true) , _transformDirty(true) , _inverseDirty(true) , _useAdditionalTransform(false) , _transformUpdated(true) // children (lazy allocs) // lazy alloc , _localZOrder(0) , _globalZOrder(0) , _parent(nullptr) // "whole screen" objects. like Scenes and Layers, should set _ignoreAnchorPointForPosition to true , _tag(Node::INVALID_TAG) , _name("") , _hashOfName(0) // userData is always inited as nil , _userData(nullptr) , _userObject(nullptr) , _glProgramState(nullptr) , _orderOfArrival(0) , _running(false) , _visible(true) , _ignoreAnchorPointForPosition(false) , _reorderChildDirty(false) , _isTransitionFinished(false) #if CC_ENABLE_SCRIPT_BINDING , _updateScriptHandler(0) #endif , _componentContainer(nullptr) , _displayedOpacity(255) , _realOpacity(255) , _displayedColor(Color3B::WHITE) , _realColor(Color3B::WHITE) , _cascadeColorEnabled(false) , _cascadeOpacityEnabled(false) , _cameraMask(1) { // set default scheduler and actionManager _director = Director::getInstance(); _actionManager = _director->getActionManager(); _actionManager->retain(); _scheduler = _director->getScheduler(); _scheduler->retain(); _eventDispatcher = _director->getEventDispatcher(); _eventDispatcher->retain(); #if CC_ENABLE_SCRIPT_BINDING if (ScriptEngineManager::ShareInstance) { auto engine = ScriptEngineManager::ShareInstance->getScriptEngine(); _scriptType = engine != nullptr ? engine->getScriptType() : kScriptTypeNone; } else _scriptType = kScriptTypeNone; #endif _transform = _inverse = _additionalTransform = Mat4::IDENTITY; }