Ref::~Ref() { #if CC_ENABLE_SCRIPT_BINDING // if the object is referenced by Lua engine, remove it if (_luaID) { ScriptEngineManager::getInstance()->getScriptEngine()->removeScriptObjectByObject(this); } else { ScriptEngineProtocol* pEngine = ScriptEngineManager::getInstance()->getScriptEngine(); if (pEngine != NULL && pEngine->getScriptType() == kScriptTypeJavascript) { pEngine->removeScriptObjectByObject(this); } } #endif #if CC_USE_MEM_LEAK_DETECTION if (_referenceCount != 0) // delete this object from list untrackRef(this); #endif }
Ref::~Ref() { #if CC_ENABLE_SCRIPT_BINDING // if the object is referenced by Lua engine, remove it if (_luaID) { ScriptEngineManager::getInstance()->getScriptEngine()->removeScriptObjectByObject(this); } #if !CC_ENABLE_GC_FOR_NATIVE_OBJECTS else { ScriptEngineProtocol* pEngine = ScriptEngineManager::getInstance()->getScriptEngine(); if (pEngine != nullptr && pEngine->getScriptType() == kScriptTypeJavascript) { pEngine->removeScriptObjectByObject(this); } } #endif // !CC_ENABLE_GC_FOR_NATIVE_OBJECTS #endif // CC_ENABLE_SCRIPT_BINDING #if CC_REF_LEAK_DETECTION if (_referenceCount != 0) untrackRef(this); #endif }
Node::Node(void) : _rotationX(0.0f) , _rotationY(0.0f) , _scaleX(1.0f) , _scaleY(1.0f) , _vertexZ(0.0f) , _position(Point::ZERO) , _skewX(0.0f) , _skewY(0.0f) , _anchorPointInPoints(Point::ZERO) , _anchorPoint(Point::ZERO) , _contentSize(Size::ZERO) , _additionalTransformDirty(false) , _transformDirty(true) , _inverseDirty(true) // children (lazy allocs) // lazy alloc , _ZOrder(0) , _parent(nullptr) // "whole screen" objects. like Scenes and Layers, should set _ignoreAnchorPointForPosition to true , _tag(Node::INVALID_TAG) // userData is always inited as nil , _userData(nullptr) , _userObject(nullptr) , _shaderProgram(nullptr) , _orderOfArrival(0) , _running(false) , _visible(true) , _ignoreAnchorPointForPosition(false) , _reorderChildDirty(false) , _isTransitionFinished(false) , _updateScriptHandler(0) , _componentContainer(nullptr) #if CC_USE_PHYSICS , _physicsBody(nullptr) #endif , _displayedOpacity(255) , _realOpacity(255) , _displayedColor(Color3B::WHITE) , _realColor(Color3B::WHITE) , _cascadeColorEnabled(false) , _cascadeOpacityEnabled(false) { // set default scheduler and actionManager Director *director = Director::getInstance(); _actionManager = director->getActionManager(); _actionManager->retain(); _scheduler = director->getScheduler(); _scheduler->retain(); _eventDispatcher = director->getEventDispatcher(); _eventDispatcher->retain(); ScriptEngineProtocol* engine = ScriptEngineManager::getInstance()->getScriptEngine(); _scriptType = engine != nullptr ? engine->getScriptType() : kScriptTypeNone; kmMat4Identity(&_transform); kmMat4Identity(&_inverse); kmMat4Identity(&_additionalTransform); }
NS_CC_BEGIN Component::Component(void) : _owner(nullptr) , _enabled(true) { #if CC_ENABLE_SCRIPT_BINDING ScriptEngineProtocol* engine = ScriptEngineManager::getInstance()->getScriptEngine(); _scriptType = engine != nullptr ? engine->getScriptType() : kScriptTypeNone; #endif }
Node::Node(void) : _rotationX(0.0f) , _rotationY(0.0f) , _scaleX(1.0f) , _scaleY(1.0f) , _vertexZ(0.0f) , _position(Point::ZERO) , _skewX(0.0f) , _skewY(0.0f) , _anchorPointInPoints(Point::ZERO) , _anchorPoint(Point::ZERO) , _contentSize(Size::ZERO) , _additionalTransform(AffineTransformMakeIdentity()) , _camera(NULL) // children (lazy allocs) // lazy alloc , _grid(NULL) , _ZOrder(0) , _children(NULL) , _parent(NULL) // "whole screen" objects. like Scenes and Layers, should set _ignoreAnchorPointForPosition to true , _tag(kNodeTagInvalid) // userData is always inited as nil , _userData(NULL) , _userObject(NULL) , _shaderProgram(NULL) , _GLServerState(ccGLServerState(0)) , _orderOfArrival(0) , _running(false) , _transformDirty(true) , _inverseDirty(true) , _additionalTransformDirty(false) , _visible(true) , _ignoreAnchorPointForPosition(false) , _reorderChildDirty(false) , _isTransitionFinished(false) , _updateScriptHandler(0) , _componentContainer(NULL) { // set default scheduler and actionManager Director *director = Director::getInstance(); _actionManager = director->getActionManager(); _actionManager->retain(); _scheduler = director->getScheduler(); _scheduler->retain(); ScriptEngineProtocol* pEngine = ScriptEngineManager::getInstance()->getScriptEngine(); _scriptType = pEngine != NULL ? pEngine->getScriptType() : kScriptTypeNone; _componentContainer = new ComponentContainer(this); }
NS_CC_BEGIN // // Action Base Class // Action::Action() :_originalTarget(nullptr) ,_target(nullptr) ,_tag(Action::INVALID_TAG) ,_flags(0) { #if CC_ENABLE_SCRIPT_BINDING ScriptEngineProtocol* engine = ScriptEngineManager::getInstance()->getScriptEngine(); _scriptType = engine != nullptr ? engine->getScriptType() : kScriptTypeNone; #endif }
Object::~Object() { // if the object is referenced by Lua engine, remove it if (_luaID) { ScriptEngineManager::getInstance()->getScriptEngine()->removeScriptObjectByObject(this); } else { ScriptEngineProtocol* pEngine = ScriptEngineManager::getInstance()->getScriptEngine(); if (pEngine != NULL && pEngine->getScriptType() == kScriptTypeJavascript) { pEngine->removeScriptObjectByObject(this); } } }
System::System(const std::string& type,const std::string& firstType,int priority) :_type(type) ,_firstType(firstType) ,_priority(priority) ,_isFree(true) ,_entityManager(nullptr) ,_ownEntity(nullptr) ,_isCustom(false) #if CC_ENABLE_SCRIPT_BINDING , _scriptHandler(0) #endif { #if CC_ENABLE_SCRIPT_BINDING ScriptEngineProtocol* engine = ScriptEngineManager::getInstance()->getScriptEngine(); _scriptType = engine != nullptr ? engine->getScriptType() : kScriptTypeNone; #endif }
Ref::~Ref() { #if CC_ENABLE_SCRIPT_BINDING // if the object is referenced by Lua engine, remove it if (_luaID) { ScriptEngineManager::getInstance()->getScriptEngine()->removeScriptObjectByObject(this); } else { ScriptEngineProtocol* pEngine = ScriptEngineManager::getInstance()->getScriptEngine(); if (pEngine != NULL && pEngine->getScriptType() == kScriptTypeJavascript) { pEngine->removeScriptObjectByObject(this); } } #endif }
Object::~Object() { // if the object is managed, we should remove it // from pool manager if (_autoReleaseCount > 0) { PoolManager::sharedPoolManager()->removeObject(this); } // if the object is referenced by Lua engine, remove it if (_luaID) { ScriptEngineManager::getInstance()->getScriptEngine()->removeScriptObjectByObject(this); } else { ScriptEngineProtocol* pEngine = ScriptEngineManager::getInstance()->getScriptEngine(); if (pEngine != NULL && pEngine->getScriptType() == kScriptTypeJavascript) { pEngine->removeScriptObjectByObject(this); } } }
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 , _displayedOpacity(255) , _realOpacity(255) , _displayedColor(Color3B::WHITE) , _realColor(Color3B::WHITE) , _cascadeColorEnabled(false) , _cascadeOpacityEnabled(false) , _cameraMask(1) #if CC_USE_PHYSICS , _physicsBody(nullptr) #endif { // 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 ScriptEngineProtocol* engine = ScriptEngineManager::getInstance()->getScriptEngine(); _scriptType = engine != nullptr ? engine->getScriptType() : kScriptTypeNone; #endif _transform = _inverse = _additionalTransform = Mat4::IDENTITY; }