コード例 #1
0
ファイル: LuaWorker.cpp プロジェクト: beltoforion/InstantLua
//-------------------------------------------------------------------------------------------------
LuaWorker::LuaWorker(IConsole *pConsole)
    :QObject(NULL)
    ,IScriptEngine()
    ,ISyncContext()
    ,m_pConsole(pConsole)
    ,m_mtxTasks()
    ,m_luaState(NULL)
    ,m_pSysVar(NULL)
    ,m_vLuaTables()
{
    ILuaTable::setSyncContext(this);

    // Hier keine dynamische allokation, da diese im Hauptthread geschehen würde!
    if (m_pConsole==NULL)
        throw InternalError(tr("Can't create Lua worker with null console pointer"));

    m_vLuaTables.push_back(new LuaTabWindow());
    m_vLuaTables.push_back(new LuaTabSys());
    m_vLuaTables.push_back(new LuaTabMessageBox());
    m_vLuaTables.push_back(new LuaTabCanvas());


    init();
    initTables();

    splashScreen();
}
コード例 #2
0
void QxtWebJsonRPCService::Private::handle(QxtWebRequestEvent *event, QVariant rid, QString action,  QVariant argsE)
{
    QVariantMap argsM;
    QVariantList args;

    if (argsE.type() == QVariant::Map) {
        argsM = argsE.toMap();
        args = argsM.values();
    } else {
        args = argsE.toList();
    }

    if (!invokable)
        initTables(p);


    if (!methods.contains(action.toUtf8() + QByteArray::number(args.count()))) {
        QVariantMap res;
        res.insert("result", QVariant());
        res.insert("error", "no such method or incorrect number of arguments");
        res.insert("id", rid);
        QxtWebPageEvent *err = new QxtWebPageEvent(event->sessionID, event->requestID,
                QxtJSON::stringify(res).toUtf8() + "\r\n");
        p->postEvent(err);
        return;
    }
    Method method = methods.value(action.toUtf8() + QByteArray::number(args.count()));
    if (argsE.type() == QVariant::Map) {
        args.clear();
        foreach (const QString &pname, method.meta.parameterNames ()) {
            args.append(argsM.value(pname));
        }
    }
コード例 #3
0
ファイル: shmcachemanager.cpp プロジェクト: 52M/openlitespeed
int ShmCacheManager::init(const char *pStoreDir)
{
    LsShm *pShm;
    LsShmPool *pPool;
    const char *pFileName = ".cacheman";
    int attempts;
    int ret = -1;
    for (attempts = 0; attempts < 3; ++attempts)
    {
        pShm = LsShm::open(pFileName, 40960, pStoreDir);

        if (!pShm)
        {
            pShm = LsShm::open(pFileName, 40960, pStoreDir);
            if (!pShm)
            {
                logShmError();
                return LS_FAIL;
            }
        }

        pPool = pShm->getGlobalPool();
        if (!pPool)
        {
            pShm->deleteFile();
            pShm->close();
            continue;
        }

        pPool->disableLock();
        pPool->lock();

        if ((initCacheInfo(pPool) == LS_FAIL)
            || (ret = initTables(pPool)) == LS_FAIL)
        {
            pPool->unlock();
            pPool->close();
            pShm->deleteFile();
            pShm->close();
        }
        else
            break;
    }

    pPool->unlock();
    pPool->enableLock();

    return ret;
}
コード例 #4
0
ファイル: storage.cpp プロジェクト: MarmopemarZcity/mZcv1
void Storage::createDatabaseConnection()
{
    db = QSqlDatabase::addDatabase("QSQLITE");
    db.setDatabaseName("marzcityclient");
    bool ok = db.open();
    if(!ok){
        qWarning("database not open");
    }

    QSettings settings("marZcity", "Marmope inc");
    if(!settings.value("Installed", "").toBool()){
        initTables();
    }

}
コード例 #5
0
ファイル: absint.c プロジェクト: jkeiren/muCRL
void initAbsInt(){
	ATbool ok;
	AFun memberTag;	

	initTables();	
	
	conflictingPars = ATmakeList0();

	ATprotect((ATerm *)&conflictingPars);
	
	memberTag = createNewFuncSym(memberSym, 
			ATmakeList2(MCRLterm_bool, liftSort(MCRLterm_bool)));
	
	MCRLputMap((ATerm)ATmakeAppl2(memberTag, 
				MCRLterm_bool, liftSort(MCRLterm_bool)), 
			MCRLterm_bool, &ok);	
}
コード例 #6
0
ファイル: script.cpp プロジェクト: jaeyeonkim/scummvm-kor
void ScScript::afterLoad() {
	if (_buffer == nullptr) {
		byte *buffer = _engine->getCompiledScript(_filename, &_bufferSize);
		if (!buffer) {
			_gameRef->LOG(0, "Error reinitializing script '%s' after load. Script will be terminated.", _filename);
			_state = SCRIPT_ERROR;
			return;
		}

		_buffer = new byte [_bufferSize];
		memcpy(_buffer, buffer, _bufferSize);

		delete _scriptStream;
		_scriptStream = new Common::MemoryReadStream(_buffer, _bufferSize);

		initTables();
	}
}
コード例 #7
0
// ***************************************************************************
// Initialize internal data structures.
// ***************************************************************************
void MVDetails::init(CollHeap* heap)
{
  // Init the superclass
  DescriptorDetails::init(heap);

  const NAPtrList<QRJBBPtr>& jbbs = descriptor_->getJbbList();
  assertLogAndThrow(CAT_MATCHTST_MVDETAILS, LL_MVQR_FAIL,
                    jbbs.entries() == 1, QRLogicException, 
		    "Support single JBB MVs only for now.");
  // Init the shortcut to the first (and only) JBB in MV descriptors.
  jbbDetails_ = jbbDetailsList_[0];
  // TBD - When we support multi-JBB MVs, we need to loop over the jbb list.
  const QRJBBPtr jbb = jbbs[0];

  // Initialize the several hash tables that map output list elements.
  initOutputs(jbb, heap);

  // Initialize the hash of tables in the descriptor.
  initTables(jbb, heap);
}
コード例 #8
0
ファイル: PhotonMap.cpp プロジェクト: varunk08/raytracing
PhotonMap *createPhotonMap(int max_photons)
{
	PhotonMap *map=(PhotonMap *)malloc(sizeof(PhotonMap));
    map->stored_photons = 0;
    map->prev_scale = 1;
    map->max_photons = max_photons;
    
    map->photons = (Photon*)malloc( sizeof( Photon ) * ( max_photons+1 ) );
    
    if (map->photons == NULL) {
        fprintf(stderr,"Out of memory initializing photon map\n");
        exit(-1);
    }
    
    map->bbox_min[0] = map->bbox_min[1] = map->bbox_min[2] = 1e8f;
    map->bbox_max[0] = map->bbox_max[1] = map->bbox_max[2] = -1e8f;
    
    initTables();
    return map;
}
コード例 #9
0
void StronglyConnectedComponentsVisitor::computeComponents(Graph & graph, bool color)
{
    // reset _SCC
    _SCC.clear();

    vector<Node*> nodes = graph.getNodes();
    int size = nodes.size();

    initTables(size);

    for ( int i = 0; i < size; ++i )
    {
        // if nodes[i] has no index
        if ( _indexTable[i] == -1 )
            strongconnect( &graph, nodes[i], i );
    }

    if ( color )
    // color the different strongly connected components to distinguish them
        colorComponents();
}
コード例 #10
0
ファイル: script.cpp プロジェクト: jaeyeonkim/scummvm-kor
bool ScScript::initScript() {
	if (!_scriptStream) {
		_scriptStream = new Common::MemoryReadStream(_buffer, _bufferSize);
	}
	readHeader();

	if (_header.magic != SCRIPT_MAGIC) {
		_gameRef->LOG(0, "File '%s' is not a valid compiled script", _filename);
		cleanup();
		return STATUS_FAILED;
	}

	if (_header.version > SCRIPT_VERSION) {
		_gameRef->LOG(0, "Script '%s' has a wrong version %d.%d (expected %d.%d)", _filename, _header.version / 256, _header.version % 256, SCRIPT_VERSION / 256, SCRIPT_VERSION % 256);
		cleanup();
		return STATUS_FAILED;
	}

	initTables();

	// init stacks
	_scopeStack = new ScStack(_gameRef);
	_callStack  = new ScStack(_gameRef);
	_thisStack  = new ScStack(_gameRef);
	_stack      = new ScStack(_gameRef);

	_operand    = new ScValue(_gameRef);
	_reg1       = new ScValue(_gameRef);


	// skip to the beginning
	_iP = _header.codeStart;
	_scriptStream->seek(_iP);
	_currentLine = 0;

	// ready to rumble...
	_state = SCRIPT_RUNNING;

	return STATUS_OK;
}
コード例 #11
0
void HistorySqlStorage::initDatabase()
{
	kdebugf();

	if (!QSqlDatabase::isDriverAvailable("QSQLITE"))
	{
		MessageDialog::show("dialog-warning", tr("Kadu"),
				tr("It seems your Qt library does not provide support for selected database.\n "
				   "Please select another driver in configuration window or install Qt with %1 plugin.").arg("QSQLITE"));
		History::instance()->unregisterStorage(this);
		return;
	}

	if (QSqlDatabase::contains("kadu-history"))
	{
		if (Database.isOpen())
			Database.close();
		QSqlDatabase::removeDatabase("kadu-history");
	}

	QDir historyDir(profilePath("history"));
	if (!historyDir.exists())
		historyDir.mkpath(profilePath("history"));

	Database = QSqlDatabase::addDatabase("QSQLITE", "kadu-history");
	Database.setDatabaseName(profilePath("history/history.db"));

	if (!Database.open())
	{
		MessageDialog::show("dialog-warning", tr("Kadu"), Database.lastError().text());
		return;
	}

	Database.transaction();

	initTables();
	initIndexes();
}
コード例 #12
0
/**
 * Init tables
 */
USBinfoTables::USBinfoTables() {
	vendorIDmap.clear();
	languageIDmap.clear();
	initTables();
}
コード例 #13
0
ファイル: wb_dbms.cpp プロジェクト: jordibrus/proview
wb_dbms::wb_dbms(pwr_tVid vid) :
    m_vid(0), m_cid(0), m_env(0), m_con(0), m_txn(0)
{
    initTables();
}
コード例 #14
0
ファイル: script.cpp プロジェクト: jaeyeonkim/scummvm-kor
bool ScScript::persist(BasePersistenceManager *persistMgr) {

	persistMgr->transferPtr(TMEMBER_PTR(_gameRef));

	// buffer
	if (persistMgr->getIsSaving()) {
		if (_state != SCRIPT_PERSISTENT && _state != SCRIPT_FINISHED && _state != SCRIPT_THREAD_FINISHED) {
			persistMgr->transfer(TMEMBER(_bufferSize));
			persistMgr->putBytes(_buffer, _bufferSize);
		} else {
			// don't save idle/finished scripts
			int32 bufferSize = 0;
			persistMgr->transfer(TMEMBER(bufferSize));
		}
	} else {
		persistMgr->transfer(TMEMBER(_bufferSize));
		if (_bufferSize > 0) {
			_buffer = new byte[_bufferSize];
			persistMgr->getBytes(_buffer, _bufferSize);
			_scriptStream = new Common::MemoryReadStream(_buffer, _bufferSize);
			initTables();
		} else {
			_buffer = nullptr;
			_scriptStream = nullptr;
		}
	}

	persistMgr->transferPtr(TMEMBER_PTR(_callStack));
	persistMgr->transfer(TMEMBER(_currentLine));
	persistMgr->transferPtr(TMEMBER_PTR(_engine));
	persistMgr->transfer(TMEMBER(_filename));
	persistMgr->transferBool(TMEMBER(_freezable));
	persistMgr->transferPtr(TMEMBER_PTR(_globals));
	persistMgr->transfer(TMEMBER(_iP));
	persistMgr->transferPtr(TMEMBER_PTR(_scopeStack));
	persistMgr->transferPtr(TMEMBER_PTR(_stack));
	persistMgr->transfer(TMEMBER_INT(_state));
	persistMgr->transferPtr(TMEMBER_PTR(_operand));
	persistMgr->transfer(TMEMBER_INT(_origState));
	persistMgr->transferPtr(TMEMBER_PTR(_owner));
	persistMgr->transferPtr(TMEMBER_PTR(_reg1));
	persistMgr->transferBool(TMEMBER(_thread));
	persistMgr->transfer(TMEMBER(_threadEvent));
	persistMgr->transferPtr(TMEMBER_PTR(_thisStack));
	persistMgr->transfer(TMEMBER(_timeSlice));
	persistMgr->transferPtr(TMEMBER_PTR(_waitObject));
	persistMgr->transferPtr(TMEMBER_PTR(_waitScript));
	persistMgr->transfer(TMEMBER(_waitTime));
	persistMgr->transferBool(TMEMBER(_waitFrozen));

	persistMgr->transferBool(TMEMBER(_methodThread));
	persistMgr->transferBool(TMEMBER(_methodThread)); // TODO-SAVE: Deduplicate.
	persistMgr->transferBool(TMEMBER(_unbreakable));
	persistMgr->transferPtr(TMEMBER_PTR(_parentScript));

	if (!persistMgr->getIsSaving()) {
		_tracingMode = false;
	}

	return STATUS_OK;
}
コード例 #15
0
ファイル: osm_storage_db.hpp プロジェクト: malasiot/maplite
 DBStorage(SQLite::Connection &db): db_(db) {
     initTables() ;
 }