Exemple #1
0
void loom_asset_initialize(const char *rootUri)
{
    // Set up the lock for the mutex.
    lmAssert(gAssetLock == NULL, "Double initialization!");
    gAssetLock = loom_mutex_create();

    // Note the CWD.
    char tmpBuff[1024];
    platform_getCurrentWorkingDir(tmpBuff, 1024);
    lmLog(gAssetLogGroup, "Current working directory ='%s'", tmpBuff);

    // And the allocator.
    //gAssetAllocator = loom_allocator_initializeTrackerProxyAllocator(loom_allocator_getGlobalHeap());
    gAssetAllocator = (loom_allocator_getGlobalHeap());

    // Clear, it might have been filled up before (for unit tests)
    gAssetLoadQueue.clear();
    gAssetHash.clear();

    // Asset server connection state.
    gAssetServerSocketLock = loom_mutex_create();

    // And set up some default asset types.
    loom_asset_registerType(LATText, loom_asset_textDeserializer, loom_asset_textRecognizer);
    loom_asset_registerType(LATBinary, loom_asset_binaryDeserializer, loom_asset_binaryRecognizer);

    loom_asset_registerImageAsset();
    loom_asset_registerSoundAsset();
    loom_asset_registerScriptAsset();

    // Listen to log and send it if we have a connection.
    loom_log_addListener(loom_asset_logListener, NULL);
}
Exemple #2
0
void Type::findMembers(const MemberTypes& memberTypes,
                       utArray<MemberInfo *>& membersOut, bool includeBases, bool includePropertyGetterSetters)
{
    if (!includeBases)
    {
        membersOut.clear();
    }

    for (size_t i = 0; i < members.size(); i++)
    {
        MemberInfo *m = members.at((int)i);

        if (m->isConstructor() && memberTypes.constructor)
        {
            membersOut.push_back(m);
        }

        if (m->isMethod() && memberTypes.method)
        {
            membersOut.push_back(m);
        }

        if (m->isField() && memberTypes.field)
        {
            membersOut.push_back(m);
        }

        if (m->isProperty() && memberTypes.property)
        {
            membersOut.push_back(m);

            if (includePropertyGetterSetters)
            {
                PropertyInfo *p = (PropertyInfo *)m;

                if (p->getter && (p->getter->getDeclaringType() == p->getDeclaringType()))
                {
                    membersOut.push_back(p->getter);
                }

                if (p->setter && (p->setter->getDeclaringType() == p->getDeclaringType()))
                {
                    membersOut.push_back(p->setter);
                }
            }
        }
    }

    if (baseType && includeBases)
    {
        baseType->findMembers(memberTypes, membersOut, true, includePropertyGetterSetters);
    }
}
Exemple #3
0
void loom_asset_shutdown()
{
    loom_asset_flushAll();

    // Clear out our queues and maps.
    gAssetDeserializerMap.clear();
    gRecognizerList.clear();

    lmAssert(gAssetLock != NULL, "Shutdown without being initialized!");
    loom_mutex_destroy(gAssetLock);
    gAssetLock = NULL;
}
void NativeDelegate::executeDeferredCalls(lua_State *L)
{
    ensureQueueInit();
    loom_mutex_lock(gCallNoteMutex);

    // Try to resolve the delegate pointer.
    utArray<NativeDelegate *> *delegates = NULL;
    if (sActiveNativeDelegates.find(L) != UT_NPOS)
    {
        delegates = *(sActiveNativeDelegates.get(L));
    }
    else
    {
        // No delegate list, can't do it.
        loom_mutex_unlock(gCallNoteMutex);
        return;
    }

    for(unsigned int i=0; i<gNDCallNoteQueue.size(); i++)
    {
        NativeDelegateCallNote *ndcn = gNDCallNoteQueue[i];

        bool found = false;
        for(unsigned int i=0; i<delegates->size(); i++)
        {
            // Look for our delegate.
            if((*delegates)[i] != ndcn->delegate)
                continue;

            // If key mismatches, warn and bail.
            if((*delegates)[i]->_key != ndcn->delegateKey)
            {
                lmLogError(gNativeDelegateGroup, "Found delegate call note with key mismatch (delegate=%x actualKey=%x expectedKey=%x), ignoring...", (*delegates)[i], (*delegates)[i]->_key, ndcn->delegateKey);
                break;
            }

            // Match!
            found = true;
            break;
        }

        // Bail if no match.
        if(!found)
            continue;

        // Otherwise, let's call it.
        const NativeDelegate *theDelegate = ndcn->delegate;
        for(;;)
        {
            unsigned char actionType = ndcn->readByte();
            bool done = false;
            char *str = NULL;
            utByteArray *bytes;
            switch(actionType)
            {
                case MSG_Nop:
                    lmLogError(gNativeDelegateGroup, "Got a nop in delegate data stream.");
                break;

                case MSG_PushString:
                    str = ndcn->readString();
                    theDelegate->pushArgument(str);
                    free(str);
                    break;

                case MSG_PushByteArray:
                    bytes = ndcn->readByteArray();
                    theDelegate->pushArgument(bytes);
                    free(bytes);
                    break;

                case MSG_PushDouble:
                    theDelegate->pushArgument(ndcn->readDouble());
                    break;

                case MSG_PushFloat:
                    theDelegate->pushArgument(ndcn->readFloat());
                    break;
                
                case MSG_PushInt:
                    theDelegate->pushArgument((int)ndcn->readInt());
                    break;
                
                case MSG_PushBool:
                    theDelegate->pushArgument(ndcn->readBool());
                    break;

                case MSG_Invoke:
                    theDelegate->invoke();
                    done = true;
                    break;
            }

            if(done)
                break;
        }

    }

    // Purge queue.
    gNDCallNoteQueue.clear();

    loom_mutex_unlock(gCallNoteMutex);
}
 ~akSubMeshPair()
 {
     idxmap.clear();
 }