コード例 #1
0
ファイル: fixedarray.cpp プロジェクト: sdsgwangpeng/kbengine
//-------------------------------------------------------------------------------------
FixedArray::FixedArray(DataType* dataType, PyObject* pyInitData):
    Sequence(getScriptType(), false)
{
    _dataType = static_cast<FixedArrayType*>(dataType);
    _dataType->incRef();
    initialize(pyInitData);
}
コード例 #2
0
ファイル: client_entity.cpp プロジェクト: MapleEve/kbengine
//-------------------------------------------------------------------------------------
ClientEntity::ClientEntity(ENTITY_ID srcEntityID,
		ENTITY_ID clientEntityID):
ScriptObject(getScriptType(), false),
srcEntityID_(srcEntityID),
clientEntityID_(clientEntityID)
{
}
コード例 #3
0
ファイル: fixedarray.cpp プロジェクト: sdsgwangpeng/kbengine
//-------------------------------------------------------------------------------------
FixedArray::FixedArray(DataType* dataType):
    Sequence(getScriptType(), false)
{
    _dataType = static_cast<FixedArrayType*>(dataType);
    _dataType->incRef();
    initialize("");
}
コード例 #4
0
ファイル: fixedarray.cpp プロジェクト: sdsgwangpeng/kbengine
//-------------------------------------------------------------------------------------
FixedArray::FixedArray(DataType* dataType, std::string& strInitData):
    Sequence(getScriptType(), false)
{
    _dataType = static_cast<FixedArrayType*>(dataType);
    _dataType->incRef();
    initialize(strInitData);
}
コード例 #5
0
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;
    }
}
コード例 #6
0
//-------------------------------------------------------------------------------------
ClientEntityMethod::ClientEntityMethod(MethodDescription* methodDescription, 
		ENTITY_ID srcEntityID, ENTITY_ID clientEntityID):
script::ScriptObject(getScriptType(), false),
methodDescription_(methodDescription),
srcEntityID_(srcEntityID),
clientEntityID_(clientEntityID)
{
}
コード例 #7
0
//-------------------------------------------------------------------------------------
RemoteEntityMethod::RemoteEntityMethod(MethodDescription* methodDescription, 
	EntityMailboxAbstract* mailbox, PyTypeObject* pyType):
script::ScriptObject((pyType == NULL ? getScriptType() : pyType), false),
methodDescription_(methodDescription),
pMailbox_(mailbox)
{
	Py_INCREF(pMailbox_);
}
コード例 #8
0
//-------------------------------------------------------------------------------------
AllClients::AllClients(const ScriptDefModule* scriptModule, 
						ENTITY_ID eid, 
						bool otherClients):
ScriptObject(getScriptType(), false),
scriptModule_(scriptModule),
id_(eid),
otherClients_(otherClients)
{
}
コード例 #9
0
ファイル: entity.cpp プロジェクト: guozanhua/kbengine
//-------------------------------------------------------------------------------------
Entity::Entity(ENTITY_ID id, const ScriptDefModule* scriptModule):
ScriptObject(getScriptType(), true),
ENTITY_CONSTRUCTION(Entity),
cellMailbox_(NULL),
baseMailbox_(NULL),
pChannel_(NULL)
{
	ENTITY_INIT_PROPERTYS(Entity);
}
コード例 #10
0
//-------------------------------------------------------------------------------------
ClientsRemoteEntityMethod::ClientsRemoteEntityMethod(MethodDescription* methodDescription,
													 bool otherClients,
													 ENTITY_ID id):
script::ScriptObject(getScriptType(), false),
methodDescription_(methodDescription),
otherClients_(otherClients),
id_(id)
{
}
コード例 #11
0
//-------------------------------------------------------------------------------------
RealEntityMethod::RealEntityMethod(MethodDescription* methodDescription, 
		Entity* ghostEntity):
script::ScriptObject(getScriptType(), false),
methodDescription_(methodDescription),
ghostEntityID_(ghostEntity->getID()),
realCell_(ghostEntity->realCell()),
scriptName_(ghostEntity->getScriptName())
{
}
コード例 #12
0
//-------------------------------------------------------------------------------------
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));
}
コード例 #13
0
ファイル: clientobject.cpp プロジェクト: acrossteams/kbengine
//-------------------------------------------------------------------------------------
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";
}
コード例 #14
0
ファイル: clientobject.cpp プロジェクト: yinjun322/kbengine
//-------------------------------------------------------------------------------------
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";
}
コード例 #15
0
ファイル: clientobject.cpp プロジェクト: mengdizhang/kbengine
//-------------------------------------------------------------------------------------
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;
}
コード例 #16
0
//-------------------------------------------------------------------------------------
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);
}
コード例 #17
0
ファイル: entity.cpp プロジェクト: fengqk/kbengine
//-------------------------------------------------------------------------------------
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);
}
コード例 #18
0
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
}
コード例 #19
0
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
}
コード例 #20
0
//-------------------------------------------------------------------------------------
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++;
}
コード例 #21
0
ファイル: clientobjectbase.cpp プロジェクト: Sumxx/kbengine
//-------------------------------------------------------------------------------------
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);
}
コード例 #22
0
ファイル: blob.cpp プロジェクト: AddictXQ/kbengine
//-------------------------------------------------------------------------------------
Blob::Blob(MemoryStream* streamInitData, bool readonly):
PyMemoryStream(getScriptType(), false, readonly)
{
	initialize(streamInitData);
	script::PyGC::incTracing("Blob");
}
コード例 #23
0
ファイル: base_remotemethod.cpp プロジェクト: Anehta/kbengine
//-------------------------------------------------------------------------------------
BaseRemoteMethod::BaseRemoteMethod(MethodDescription* methodDescription, 
						EntityMailboxAbstract* mailbox):
RemoteEntityMethod(methodDescription, mailbox, getScriptType())
{
}
コード例 #24
0
ファイル: proxy.cpp プロジェクト: sdsgwangpeng/kbengine
//-------------------------------------------------------------------------------------
Proxy::Proxy(ENTITY_ID id, const ScriptDefModule* scriptModule):
Base(id, scriptModule, getScriptType(), true),
rndUUID_(KBEngine::genUUID64()),
addr_(Mercury::Address::NONE)
{
}
コード例 #25
0
ファイル: blob.cpp プロジェクト: AddictXQ/kbengine
//-------------------------------------------------------------------------------------
Blob::Blob(PyObject* pyDictInitData, bool readonly):
PyMemoryStream(getScriptType(), false, readonly)
{
	initialize(pyDictInitData);
	script::PyGC::incTracing("Blob");
}
コード例 #26
0
ファイル: globaldata_client.cpp プロジェクト: Weooh/kbengine
//-------------------------------------------------------------------------------------
GlobalDataClient::GlobalDataClient(COMPONENT_TYPE componentType, GlobalDataServer::DATA_TYPE dataType):
script::Map(getScriptType(), false),
serverComponentType_(componentType),
dataType_(dataType)
{
}
コード例 #27
0
ファイル: blob.cpp プロジェクト: AddictXQ/kbengine
//-------------------------------------------------------------------------------------
Blob::Blob(bool readonly):
PyMemoryStream(getScriptType(), false, readonly)
{
	initialize("");
	script::PyGC::incTracing("Blob");
}
コード例 #28
0
ファイル: CCNode.cpp プロジェクト: 2youyou2/cocos2d-x-lite
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;
}