LevelObjPtr EditorLevel::object_at(int x, int y) { // we travel reversly through the object list, so that we get the // top-most object for (auto i = (*get_objects()).rbegin (); i != (*get_objects()).rend (); ++i) { if ((*i)->is_at(x, y)) return *i; } return LevelObjPtr(); }
// NB arrays or mappings containing arrays, mappings or // functions are liable to confuse this function. // This could be made a simul_efun some time. // Fixed to handle the case ([]) and ({}) 93-02-05 Pallando mixed resolv_str( string a ) { mapping v_m; mixed v_o; //object or array of objects mixed *v_a; string v_s, sa, sb; int v_i, ia, ib; if( !a ) return a; if( a == "" || a == " " || a == " " ) return a; if( sscanf( a, " %s", sa ) ) a = sa; ib = strlen( a ) - 1; if( a[ib..ib] == " " ) a = a[0..(ib-1)]; if( sscanf( a, "\"%s\"", v_s ) ) return v_s; // If you want to make resolv_str() a simul_efun, change the next line to // tmp1 = REFS_D->resolv_ref( a ); tmp1 = resolv_ref( a ); if( tmp1 != a ) return tmp1; if( sscanf( a, "%d", v_i ) ) return v_i; if( v_o = get_objects( a ) ) return v_o; if( sscanf( a, "(:%s,%s:)", sa, sb ) == 2 ) { tmp1 = resolv_str( sa ); tmp2 = resolv_str( sb ); if( objectp( tmp1 ) && stringp( tmp2 ) ) return (: tmp1, tmp2 :); }
mixed ref_ob( mixed a ) { mixed tmp; a = resolv_ref( a ); if( stringp( a ) && ( tmp = get_objects( a, 0, 1 ) ) ) a = tmp; return a; }
void invariant_propagationt::add_objects( const goto_functionst &goto_functions) { // get the globals object_listt globals; get_globals(globals); for(goto_functionst::function_mapt::const_iterator f_it=goto_functions.function_map.begin(); f_it!=goto_functions.function_map.end(); f_it++) { // get the locals std::set<irep_idt> locals; get_local_identifiers(f_it->second, locals); const goto_programt &goto_program=f_it->second.body; // cache the list for the locals to speed things up typedef hash_map_cont<irep_idt, object_listt, irep_id_hash> object_cachet; object_cachet object_cache; for(goto_programt::instructionst::const_iterator i_it=goto_program.instructions.begin(); i_it!=goto_program.instructions.end(); i_it++) { #if 0 invariant_sett &is=(*this)[i_it].invariant_set; is.add_objects(globals); #endif for(std::set<irep_idt>::const_iterator l_it=locals.begin(); l_it!=locals.end(); l_it++) { // cache hit? object_cachet::const_iterator e_it=object_cache.find(*l_it); if(e_it==object_cache.end()) { const symbolt &symbol=ns.lookup(*l_it); object_listt &objects=object_cache[*l_it]; get_objects(symbol, objects); #if 0 is.add_objects(objects); #endif } #if 0 else is.add_objects(e_it->second); #endif } } } }
void KeepAlive::process(int timeout) { // Get the objects to wait for std::vector<KeepAliveObject *> objects = get_objects(); std::vector<Event> events; for (auto & object : objects) { events.push_back(object->impl->wakeup_event); } ubyte64 time_start = System::get_time(); while (true) { int time_elapsed = System::get_time() - time_start; int time_to_wait = timeout - time_elapsed; if (time_to_wait < 0) time_to_wait = 0; if (timeout < 0) // Wait forever option { time_to_wait = -1; } // Wait for the events int wakeup_reason; if (cl_keepalive_func_event_wait) { wakeup_reason = cl_keepalive_func_event_wait(events, time_to_wait); } else { wakeup_reason = Event::wait(events, time_to_wait); } // Check for Timeout if (wakeup_reason < 0) { break; } timeout = 0; // Event found, reset the timeout // Process the event if ( ((unsigned int) wakeup_reason) < events.size()) // (Note, wakeup_reason is >=0) { objects[wakeup_reason]->impl->wakeup_event.reset(); objects[wakeup_reason]->process(); } } }
AddonManager::AddonList AddonManager::parse_addon_infos(const std::string& filename) const { AddonList m_addons; try { register_translation_directory(filename); auto doc = ReaderDocument::parse(filename); auto root = doc.get_root(); if(root.get_name() != "supertux-addons") { throw std::runtime_error("Downloaded file is not an Add-on list"); } else { auto addon_collection = root.get_collection(); for(auto const& addon_node : addon_collection.get_objects()) { if(addon_node.get_name() != "supertux-addoninfo") { log_warning << "Unknown token '" << addon_node.get_name() << "' in Add-on list" << std::endl; } else { try { std::unique_ptr<Addon> addon = Addon::parse(addon_node.get_mapping()); m_addons.push_back(std::move(addon)); } catch(const std::exception& e) { log_warning << "Problem when reading Add-on entry: " << e.what() << std::endl; } } } return m_addons; } } catch(const std::exception& e) { std::stringstream msg; msg << "Problem when reading Add-on list: " << e.what(); throw std::runtime_error(msg.str()); } return m_addons; }
PathObjectList get_objects(const hdf5::node::Group &base,const Path &path) { PathObjectList list; if(path.has_attribute()) { //if we are looking for attributes we first have to identify the parent //objects. NodeList parent_list; if(path.size()==0) { parent_list.push_back(base); } else { Path parent_path(path); parent_path.attribute(std::string()); parent_list = get_objects(base,parent_path); } //once we have identified the parents we can select those who have //an attribute of appropriate name for(auto node: parent_list) { if(node.attributes.exists(path.attribute())) list.push_back(node.attributes[path.attribute()]); } } else { auto iter_begin = hdf5::node::RecursiveLinkIterator::begin(base); auto iter_end = hdf5::node::RecursiveLinkIterator::end(base); if(is_absolute(path)) std::copy_if(iter_begin,iter_end,std::back_inserter(list),AbsolutePathMatcher(path)); else { std::copy_if(iter_begin,iter_end,std::back_inserter(list),RelativePathMatcher(path,get_path(base))); } } return list; }
clan::Vec2i GridComponent::snap(GridObject *object, const std::vector<SnapLine> &source_snaplines, const clan::Rect &source_rect) { std::vector<SnapLine::SnapLineTarget> targets; // Add all other components std::vector<GridObject*> objects = get_objects(); for (size_t object_index = 0; object_index < objects.size(); object_index++) { GridObject *target_object = objects[object_index]; if(target_object != object) targets.push_back(SnapLine::SnapLineTarget(target_object->get_geometry(), target_object->get_snaplines())); } // Add GridComponent itself targets.push_back(SnapLine::SnapLineTarget(get_dialog_size(), get_snaplines())); return SnapLine::snap(source_rect, source_snaplines, targets); }
bool cps_db::get_objects(cps_db::connection &conn, cps_api_object_t obj,cps_api_object_list_t obj_list) { std::vector<char> k; if (!cps_db::dbkey_from_instance_key(k,obj)) return false; return get_objects(conn,k,obj_list); }