void lua::TableWrapper::removeReference() { utils::StackCleaner cleaner(m_L, 0); // push the table on the stack lua_rawgeti(m_L, LUA_REGISTRYINDEX, m_tableReference); auto tableIndex = lua_gettop(m_L); // get the ref count field lua_pushstring(m_L, refCountIndex()); lua_rawget(m_L, tableIndex); // extract the ref count value and decrement the value auto refCount = lua_tointeger(m_L, -1); --refCount; // remove the ref count from the stack lua_pop(m_L, 1); if (refCount == 0) { luaL_unref(m_L, LUA_REGISTRYINDEX, m_tableReference); m_tableReference = s_invalidReference; } else { lua_pushstring(m_L, refCountIndex()); lua_pushinteger(m_L, refCount); lua_rawset(m_L, tableIndex); } }
void TestDeleteOrderSimpleMesh() throw(Exception) { TrianglesMeshReader<1,3> mesh_reader("lung/test/airway_generation/data/test_major_airways_mesh"); MutableMesh<1,3> mesh; mesh.ConstructFromMeshReader(mesh_reader); //Assign valid radii for(unsigned node_index = 0; node_index < mesh.GetNumNodes(); ++node_index) { mesh.GetNode(node_index)->rGetNodeAttributes()[0] = 1.0; } TS_ASSERT_EQUALS(mesh.GetNumNodes(), 6u); TS_ASSERT_EQUALS(mesh.GetNumElements(), 5u); MajorAirwaysCentreLinesCleaner cleaner(mesh, 0u); cleaner.CleanUsingHorsfieldOrder(1u); NodeMap node_map(mesh.GetNumAllNodes()); mesh.ReIndex(node_map); TS_ASSERT_EQUALS(mesh.GetNumNodes(), 2u); TS_ASSERT_EQUALS(mesh.GetNumElements(), 1u); TS_ASSERT_DELTA(mesh.GetNode(0u)->rGetLocation()[0], 0.0, 1e-6); TS_ASSERT_DELTA(mesh.GetNode(0u)->rGetLocation()[1], 0.0, 1e-6); TS_ASSERT_DELTA(mesh.GetNode(0u)->rGetLocation()[2], -2.0, 1e-6); TS_ASSERT_DELTA(mesh.GetNode(1u)->rGetLocation()[0], 0.0, 1e-6); TS_ASSERT_DELTA(mesh.GetNode(1u)->rGetLocation()[1], 0.0, 1e-6); TS_ASSERT_DELTA(mesh.GetNode(1u)->rGetLocation()[2], 0.0, 1e-6); }
PROCESS_THREAD(knot_controller_process, ev, data) { static struct etimer clean; PROCESS_BEGIN(); SENSORS_ACTIVATE(button_sensor); etimer_set(&clean,TIMER_INTERVAL); while (1){ PROCESS_WAIT_EVENT(); if (ev == tcpip_event && uip_newdata()) { network_handler(ev, data); } else if ((ev == PROCESS_EVENT_TIMER)){ if (data == &clean) { cleaner(); etimer_set(&clean,TIMER_INTERVAL); } } else if (ev == KNOT_EVENT_CONNECT){ create_channel((ServiceRecord *)data); } else if(ev == KNOT_EVENT_COMMAND){ send_actuator_command(*((int *)data)); } } PROCESS_END(); }
void PolicyDatabase::purgeObjects(double priority) { SQLite::Statement cleaner(*this, "DELETE FROM object WHERE expires <= JULIANDAY('now') OR (SELECT priority FROM authority WHERE id = object.authority) <= :priority;"); cleaner.bind(":priority") = priority; cleaner.execute(); }
void TestDeleteFirstOrder() throw(Exception) { #ifdef CHASTE_VTK VtkMeshReader<1,3> mesh_reader("lung/test/data/TestSubject002MajorAirways.vtu"); MutableMesh<1,3> mesh; mesh.ConstructFromMeshReader(mesh_reader); //Assign valid radii for(unsigned node_index = 0; node_index < mesh.GetNumNodes(); ++node_index) { mesh.GetNode(node_index)->AddNodeAttribute(1.0); } TS_ASSERT_EQUALS(mesh.GetNumNodes(), 12065u); TS_ASSERT_EQUALS(mesh.GetNumElements(), 12064u); MajorAirwaysCentreLinesCleaner cleaner(mesh, 0u); cleaner.CleanUsingHorsfieldOrder(1u); NodeMap node_map(mesh.GetNumAllNodes()); mesh.ReIndex(node_map); //Confirmed visually to be correct TS_ASSERT_EQUALS(mesh.GetNumNodes(), 3683u); TS_ASSERT_EQUALS(mesh.GetNumElements(), 3682u); // Uncomment to visualise // VtkMeshWriter<1,3> mesh_writer("TestMajorAirwaysCentreLinesCleaner", "Novartis002Trimmed"); // mesh_writer.WriteFilesUsingMesh(mesh); #endif //CHASTE_VTK }
~CYPool() { for (Cleaner *cleaner(cleaner_); cleaner != NULL; ) { Cleaner *next(cleaner->next_); (*cleaner->code_)(cleaner->data_); cleaner = next; } }
// This should go into Qt 4.8 once we start using it for Qt Creator QMap<QString, QUrl> HelpManager::linksForKeyword(const QString &key) { QMap<QString, QUrl> links; if (d->m_needsSetup) return links; const QLatin1String sqlite("QSQLITE"); const QLatin1String name("HelpManager::linksForKeyword"); DbCleaner cleaner(name); QSqlDatabase db = QSqlDatabase::addDatabase(sqlite, name); if (db.driver() && db.driver()->lastError().type() == QSqlError::NoError) { const QStringList ®isteredDocs = d->m_helpEngine->registeredDocumentations(); foreach (const QString &nameSpace, registeredDocs) { db.setDatabaseName(d->m_helpEngine->documentationFileName(nameSpace)); if (db.open()) { QSqlQuery query = QSqlQuery(db); query.setForwardOnly(true); query.exec(QString::fromLatin1(linksForKeyQuery).arg(key)); while (query.next()) { QString title = query.value(0).toString(); if (title.isEmpty()) // generate a title + corresponding path title = key + QLatin1String(" : ") + query.value(3).toString(); links.insertMulti(title, buildQUrl(query.value(1).toString(), query.value(2).toString(), query.value(3).toString(), query.value(4).toString())); } } } }
TEST_F(MergeReceiveExecutorTest, singlePartitionBigOffsetTest) { std::vector<int> values; values.push_back(0); values.push_back(1); values.push_back(1); values.push_back(2); std::vector<TableTuple> tuples; std::vector<int64_t> partitionTupleCounts; boost::scoped_ptr<char> cleaner( addPartitionData(values, tuples, partitionTupleCounts)); std::vector<SortDirectionType> dirs(1, SORT_DIRECTION_TYPE_ASC); AbstractExecutor::TupleComparer comp(getSortKeys(), dirs); int limit = -1; int offset = 10; AggregateExecutorBase* agg_exec = NULL; ProgressMonitorProxy* pmp = NULL; MergeReceiveExecutor::merge_sort(tuples, partitionTupleCounts, comp, limit, offset, agg_exec, getDstTempTable(), pmp); ASSERT_EQ(0, getDstTempTable()->activeTupleCount()); }
BOOST_LOG_EXPORT void basic_event_log_backend< CharT >::consume(record_type const& record) { if (!m_pImpl->m_EventComposer.empty()) { log::aux::cleanup_guard< insertion_list > cleaner(m_pImpl->m_Insertions); // Get event ID and construct insertions DWORD id = m_pImpl->m_EventComposer(record, m_pImpl->m_Insertions); WORD string_count = static_cast< WORD >(m_pImpl->m_Insertions.size()); scoped_array< const char_type* > strings(new const char_type*[string_count]); for (WORD i = 0; i < string_count; ++i) strings[i] = m_pImpl->m_Insertions[i].c_str(); // Get event type WORD event_type = EVENTLOG_INFORMATION_TYPE; if (!m_pImpl->m_LevelMapper.empty()) event_type = static_cast< WORD >(m_pImpl->m_LevelMapper(record)); WORD event_category = 0; if (!m_pImpl->m_CategoryMapper.empty()) event_category = static_cast< WORD >(m_pImpl->m_CategoryMapper(record)); report_event( m_pImpl->m_SourceHandle, // Event log handle. event_type, // Event type. event_category, // Event category. id, // Event identifier. NULL, // No user security identifier. string_count, // Number of substitution strings. 0, // No data. strings.get(), // Pointer to strings. NULL); // No data. } }
//~~<<luaengine_init void LuaGameEngine::init() { StackCleaner cleaner(L); lua_getglobal(L, "init"); dieIfFail(lua_pcall(L, 0, 1, 0)); gameState_ = luaL_ref(L, LUA_REGISTRYINDEX); }
int main() { setlocale( LC_ALL,"Russian" ); //Русский язык для консоли Windows trasher(); cout << endl << endl << "Нажмите ENTER, чтобы очистить консоль" << endl; cleaner(); return 0; }
//~~<<luaengine_update void LuaGameEngine::update(double elapsed) { StackCleaner cleaner(L); lua_getglobal(L, "update"); lua_rawgeti(L, LUA_REGISTRYINDEX, gameState_); lua_pushnumber(L, elapsed); dieIfFail(lua_pcall(L, 2, 0, 0)); }
/// Constructs a new parser. /// /// \param [in,out] config_tree The configuration tree into which the values set /// in the configuration file will be stored. config::parser::parser(tree& config_tree) : _pimpl(new impl(this, config_tree)) { lutok::stack_cleaner cleaner(_pimpl->_state); _pimpl->_state.push_cxx_function(lua_syntax); _pimpl->_state.set_global("syntax"); *_pimpl->_state.new_userdata< config::parser::impl* >() = _pimpl.get(); _pimpl->_state.set_global("_config_parser"); }
int _tmain(int argc, _TCHAR* argv[]) { InputLineStream input; OutputLineStream output; DupCleaner cleaner(input, output); cleaner.process(); _getch(); return 0; }
bool DocCacheMemory::saveDoc(const TagKey *key, CacheContext *cache_ctx, const Tag &tag, const boost::shared_ptr<CacheData> &cache_data) { log()->debug("saving doc in memory cache"); DocPool *mpool = pool(key); assert(NULL != mpool); DocCleaner cleaner(cache_ctx->context()); return mpool->saveDoc(key->asString(), tag, cache_data, cleaner); }
void InternalCleanJob::start() { try { ArtifactCleaner cleaner(logger(), observer()); cleaner.cleanup(project(), products(), m_options); } catch (const ErrorInfo &error) { setError(error); } storeBuildGraph(); emit finished(this); }
GrouppingMpiAsync::~GrouppingMpiAsync() { if(groupsMap.size() > 0) { LOG(WARNING) << "Pending requests left in GrouppingMpiAsync, but destructor has been called. Canceling them"; for(auto& kv: groupsMap) { El& el = kv.second; MPI_Cancel(el.rq); cleaner(el.rq); } } }
//~~<<luaengine_running bool LuaGameEngine::running() const { StackCleaner cleaner(L); lua_getglobal(L, "running"); lua_rawgeti(L, LUA_REGISTRYINDEX, gameState_); dieIfFail(lua_pcall(L, 1, 1, 0)); int is_running = lua_toboolean(L, 1); return is_running == 1; }
void lua::TableWrapper::injectRefCountEntry(int tableIndex) { utils::StackCleaner cleaner(m_L, 0); // set the ref count within the table to 1 lua_pushstring(m_L, refCountIndex()); lua_pushinteger(m_L, 1); lua_rawset(m_L, tableIndex); // generate a unique reference to our helper table. Pops the ref'd table. m_tableReference = luaL_ref(m_L, LUA_REGISTRYINDEX); }
/** * Pointers 'list' and 'el' should already have been validated */ void __cjld_list_destroy_element(cjld_list *list, void *el, int id) { void (*cleaner)(void *el, int id); cleaner = list->cleaner; if (NULL==cleaner) { free(el); } *cleaner(el, id); }//
/// Creates a module: i.e. a table with a set of methods in it. /// /// \param s The Lua state. /// \param name The name of the module to create. /// \param members The list of member functions to add to the module. void lutok::create_module(state& s, const std::string& name, const std::map< std::string, cxx_function >& members) { stack_cleaner cleaner(s); s.new_table(); for (std::map< std::string, cxx_function >::const_iterator iter = members.begin(); iter != members.end(); iter++) { s.push_string((*iter).first); s.push_cxx_function((*iter).second); s.set_table(-3); } s.set_global(name); }
void lua::FunctionWrapper::push() { utils::StackCleaner cleaner(m_L, 1); // Push the table on the stack pushTable(); auto tableIndex = lua_gettop(m_L); lua_pushinteger(m_L, s_functionIndex); lua_rawget(m_L, tableIndex); // Swap the table with the function so that the table is at the top of the stack. lua_insert(m_L, -2); }
/* Install the cleanup dialog frame to know what should be cleaned */ void PCB_EDIT_FRAME::Clean_Pcb() { DIALOG_CLEANING_OPTIONS dlg( this ); if( dlg.ShowModal() != wxID_OK ) return; wxBusyCursor( dummy ); TRACKS_CLEANER cleaner( GetBoard() ); cleaner.CleanupBoard( this, dlg.m_cleanVias, dlg.m_mergeSegments, dlg.m_deleteUnconnectedSegm ); m_canvas->Refresh( true ); }
void CollectionListView::deleteCollection() { int collectionId = MetadataEngine::getInstance().getCurrentCollectionId(); if ((collectionId == 0) || SyncSession::IS_READ_ONLY) return; //0 stands for invalid //ask for confirmation QMessageBox box(QMessageBox::Question, tr("Delete Collection"), tr("Are you sure you want to delete the selected collection?" "<br><br><b>Warning:</b> This cannot be undone!"), QMessageBox::Yes | QMessageBox::No, this); box.setDefaultButton(QMessageBox::Yes); box.setWindowModality(Qt::WindowModal); int r = box.exec(); if (r == QMessageBox::No) return; //check all fields for delete triggers CollectionFieldCleaner cleaner(this); cleaner.cleanCollection(collectionId); //delete metadata and tables MetadataEngine::getInstance().deleteCollection(collectionId); //delete from model m_model->removeRow(currentIndex().row()); //delete settings about collection's column positions in TableView SettingsManager s; QString settingsKey = QString("collection_") + QString::number(collectionId); s.deleteObjectProperties(settingsKey); //reset cached id m_currentCollectionId = 0; //clear undo stack since this action is not undoable QUndoStack *stack = MainWindow::getUndoStack(); if (stack) stack->clear(); //set first collection as current one QModelIndex first = m_model->index(0, 1); if (first.isValid()) setCurrentIndex(first); else MetadataEngine::getInstance().setCurrentCollectionId(0); //set invalid //set local data changed SyncSession::LOCAL_DATA_CHANGED = true; }
int main(void) { Periphery(); //настройка периферии //главный цикл программы while(1) { button(); cycle(); drive(); cleaner(); bumper(); led(); } }
GEP_API std::string lua::utils::traceback(lua_State* L) { StackCleaner cleaner(L, 0); lua_getglobal(L, "debug"); // If global 'debug' is a table, everything is file if (lua_istable(L, -1)) { lua_getfield(L, -1, "traceback"); lua_pushnil(L); lua_pushinteger(L, 1); lua_call(L, 2, 1); return lua_tostring(L, -1); } return "<Global 'debug' is not a table!>"; }
void MainWindow::clearForm() { // Создаём окно, запрашивающее подтверждение действия QMessageBox messageBox(QMessageBox::Question, tr("Очистка формы"), tr("Вы действительно хотите очистить форму? <br /> Все данные будут потеряны!"), QMessageBox::Yes | QMessageBox::No, this); messageBox.setButtonText(QMessageBox::Yes, tr("Да")); messageBox.setButtonText(QMessageBox::No, tr("Нет")); // Если действие подтверждено if (messageBox.exec() == QMessageBox::Yes) { cleaner(); } }
TJObjectRef TJClassRef::field(const std::string& name, const std::string& objClassDescriptor, TJRefType refType) { JNIEnv* environment = TJGetEnvironment(); if (environment == nullptr) throw TJNIException(kThreadDetached, "Failed to get jnienv in TJClassRef::getObjectField"); jfieldID fieldDescriptor = environment->GetStaticFieldID(mHandle, name.c_str(), objClassDescriptor.c_str()); if (fieldDescriptor == nullptr) GenerateJavaException(environment, environment->ExceptionOccurred(), "GetStaticFieldID failed in TJClassRef::getObjectField"); jobject resObject = environment->GetStaticObjectField(mHandle, fieldDescriptor); if (refType == kLocalRef) return TJObjectRef(resObject, false, kLocalRef); else { ScopedLocalRef<jobject> cleaner(resObject); return TJObjectRef(resObject, true, refType); } };
bool DocCacheMemory::loadDoc(const TagKey *key, CacheContext *cache_ctx, Tag &tag, boost::shared_ptr<CacheData> &cache_data) { log()->debug("loading doc in memory cache"); DocPool *mpool = pool(key); assert(NULL != mpool); DocCleaner cleaner(cache_ctx->context()); if (!mpool->loadDoc(key->asString(), tag, cache_data, cleaner)) { return false; } if (!DocCacheBase::checkTag(NULL, NULL, tag, "loading doc from memory cache")) { return false; } return true; }
void lua::FunctionWrapper::addReference() { utils::StackCleaner cleaner(m_L, 0); // push the table on the stack pushTable(); auto tableIndex = lua_gettop(m_L); lua_pushinteger(m_L, s_refCountIndex); lua_rawget(m_L, tableIndex); auto refCount = lua_tointeger(m_L, -1); ++refCount; lua_pop(m_L, 1); lua_pushinteger(m_L, s_refCountIndex); lua_pushinteger(m_L, refCount); lua_rawset(m_L, tableIndex); }