__host__ __device__ range<typename range_iterator<Range>::type> slice(Range &rng, Size first, Size last) { return make_range(begin(rng) + first, begin(rng) + last); }
auto operator|(Range&& range, skip s) { using skipper = SkipIterator<decltype(begin(range))>; return make_range(skipper(begin(range), s.n), end(range)); }
__host__ __device__ range<typename range_iterator<const Range>::type> slice(const Range &rng, Size first) { return make_range(begin(rng) + first, end(rng)); }
void first_finder( const char*& Search ) { make_range( Search, is_char_ptr(Search) ); }
iterator_range<const_iterator> find(osmium::object_id_type id) const { return make_range(std::equal_range(m_elements.cbegin(), m_elements.cend(), element{id}, compare_member_id{})); }
ts::Range<const ts::script::Member_function_definition*> ts::script_api::Delegate_traits<ts::resources::Car_model>::member_functions() { return make_range(std::begin(car_model::member_functions), std::end(car_model::member_functions)); }
// Parameters initialization GLCanvas::Params::Params() : m_zoom_range(get_conf<float>("zoom_pan", "zoom_range", make_range(0.0001f, 1000.0f))) {}
uint32_t Tracer::trace(const WorldRay* w_rays_begin, const WorldRay* w_rays_end, Intersection* intersections_begin, Intersection* intersections_end) { // Clear ID element_id.clear(); // Get rays w_rays = make_range(w_rays_begin, w_rays_end); Global::Stats::rays_shot += w_rays.size(); // Create initial rays rays.resize(w_rays.size()); for (size_t i = 0; i < rays.size(); ++i) { rays[i] = w_rays[i].to_ray(); rays[i].set_id(i); } // Get and initialize intersections intersections = make_range(intersections_begin, intersections_end); std::fill(intersections.begin(), intersections.end(), Intersection()); // Clear and initialize stacks surface_shader_stack.clear(); surface_shader_stack.emplace_back(nullptr); xform_stack.clear(); xform_stack.push_frame<Transform>(0); data_stack.clear(); // Start tracing! #if 1 // Split rays into groups based on direction signs before tracing auto xsplit_4 = std::partition(rays.begin(), rays.end(), [](Ray r) { return (r.d[0] > 0.0f); }); auto ysplit_2 = std::partition(rays.begin(), xsplit_4, [](Ray r) { return (r.d[1] > 0.0f); }); auto ysplit_6 = std::partition(xsplit_4, rays.end(), [](Ray r) { return (r.d[1] > 0.0f); }); auto zsplit_1 = std::partition(rays.begin(), ysplit_2, [](Ray r) { return (r.d[2] > 0.0f); }); auto zsplit_3 = std::partition(ysplit_2, xsplit_4, [](Ray r) { return (r.d[2] > 0.0f); }); auto zsplit_5 = std::partition(xsplit_4, ysplit_6, [](Ray r) { return (r.d[2] > 0.0f); }); auto zsplit_7 = std::partition(ysplit_6, rays.end(), [](Ray r) { return (r.d[2] > 0.0f); }); // +X +Y +Z trace_assembly(scene->root.get(), &(*rays.begin()), &(*zsplit_1)); // +X +Y -Z trace_assembly(scene->root.get(), &(*zsplit_1), &(*ysplit_2)); // +X -Y +Z trace_assembly(scene->root.get(), &(*ysplit_2), &(*zsplit_3)); // +X -Y -Z trace_assembly(scene->root.get(), &(*zsplit_3), &(*xsplit_4)); // -X +Y +Z trace_assembly(scene->root.get(), &(*xsplit_4), &(*zsplit_5)); // -X +Y -Z trace_assembly(scene->root.get(), &(*zsplit_5), &(*ysplit_6)); // -X -Y +Z trace_assembly(scene->root.get(), &(*ysplit_6), &(*zsplit_7)); // -X -Y -Z trace_assembly(scene->root.get(), &(*zsplit_7), &(*rays.end())); #else // Just trace all the rays together trace_assembly(scene->root.get(), &(*rays.begin()), &(*rays.end())); #endif return w_rays.size(); }
constexpr auto make_iterator_range(Container&& c){ return make_range( mitrax::make_move_iterator(mitrax::begin(c)), mitrax::make_move_iterator(mitrax::end(c))); }
int GetString( const wchar_t *Title, const wchar_t *Prompt, const wchar_t *HistoryName, const wchar_t *SrcText, string &strDestText, const wchar_t *HelpTopic, DWORD Flags, int *CheckBoxValue, const wchar_t *CheckBoxText, Plugin* PluginNumber, const GUID* Id ) { int Substract=5; // дополнительная величина :-) int ExitCode; bool addCheckBox=Flags&FIB_CHECKBOX && CheckBoxValue && CheckBoxText; int offset=addCheckBox?2:0; FarDialogItem StrDlgData[]= { {DI_DOUBLEBOX, 3, 1, 72, 4, 0, nullptr, nullptr, 0, L""}, {DI_TEXT, 5, 2, 0, 2, 0, nullptr, nullptr, DIF_SHOWAMPERSAND, L""}, {DI_EDIT, 5, 3, 70, 3, 0, nullptr, nullptr, DIF_FOCUS|DIF_DEFAULTBUTTON, L""}, {DI_TEXT, -1, 4, 0, 4, 0, nullptr, nullptr, DIF_SEPARATOR, L""}, {DI_CHECKBOX, 5, 5, 0, 5, 0, nullptr, nullptr, 0, L""}, {DI_TEXT, -1, 6, 0, 6, 0, nullptr, nullptr, DIF_SEPARATOR, L""}, {DI_BUTTON, 0, 7, 0, 7, 0, nullptr, nullptr, DIF_CENTERGROUP, L""}, {DI_BUTTON, 0, 7, 0, 7, 0, nullptr, nullptr, DIF_CENTERGROUP, L""}, }; auto StrDlg = MakeDialogItemsEx(StrDlgData); if (addCheckBox) { Substract-=2; StrDlg[0].Y2+=2; StrDlg[4].Selected = *CheckBoxValue != 0; StrDlg[4].strData = CheckBoxText; } if (Flags&FIB_BUTTONS) { Substract-=3; StrDlg[0].Y2+=2; StrDlg[2].Flags&=~DIF_DEFAULTBUTTON; StrDlg[5+offset].Y1=StrDlg[4+offset].Y1=5+offset; StrDlg[4+offset].Type=StrDlg[5+offset].Type=DI_BUTTON; StrDlg[4+offset].Flags=StrDlg[5+offset].Flags=DIF_CENTERGROUP; StrDlg[4+offset].Flags|=DIF_DEFAULTBUTTON; StrDlg[4+offset].strData = MSG(MOk); StrDlg[5+offset].strData = MSG(MCancel); } if (Flags&FIB_EXPANDENV) { StrDlg[2].Flags|=DIF_EDITEXPAND; } if (Flags&FIB_EDITPATH) { StrDlg[2].Flags|=DIF_EDITPATH; } if (Flags&FIB_EDITPATHEXEC) { StrDlg[2].Flags|=DIF_EDITPATHEXEC; } if (HistoryName) { StrDlg[2].strHistory=HistoryName; StrDlg[2].Flags|=DIF_HISTORY|(Flags&FIB_NOUSELASTHISTORY?0:DIF_USELASTHISTORY); } if (Flags&FIB_PASSWORD) StrDlg[2].Type=DI_PSWEDIT; if (Title) StrDlg[0].strData = Title; if (Prompt) { StrDlg[1].strData = Prompt; TruncStrFromEnd(StrDlg[1].strData, 66); if (Flags&FIB_NOAMPERSAND) StrDlg[1].Flags&=~DIF_SHOWAMPERSAND; } if (SrcText) StrDlg[2].strData = SrcText; { auto Dlg = Dialog::create(make_range(StrDlg.data(), StrDlg.data() + StrDlg.size() - Substract)); Dlg->SetPosition(-1,-1,76,offset+((Flags&FIB_BUTTONS)?8:6)); if(Id) Dlg->SetId(*Id); if (HelpTopic) Dlg->SetHelp(HelpTopic); Dlg->SetPluginOwner(PluginNumber); Dlg->Process(); ExitCode=Dlg->GetExitCode(); if (ExitCode == -2 && Global->CtrlObject->Macro.IsExecuting() != MACROSTATE_NOMACRO) Global->CtrlObject->Macro.SendDropProcess(); } if (ExitCode == 2 || ExitCode == 4 || (addCheckBox && ExitCode == 6)) { if (!(Flags&FIB_ENABLEEMPTY) && StrDlg[2].strData.empty()) return FALSE; strDestText = StrDlg[2].strData; if (addCheckBox) *CheckBoxValue=StrDlg[4].Selected; return TRUE; } return FALSE; }
auto make_range(Container&& container) { return make_range(container.begin(), container.end()); }
void reader_writer::sync(){ AIO_PRE_CONDITION(valid()); if (!m_imp->dirty) return; bool zip64_enabled = false; long_size_t cd_size = 0; for (auto & i : m_imp->items){ file_header& h = i; cd_size += K_fix_part_of_central_header + h.name.str().size() + h.comments.size(); auto need_zip64 = h.compressed_size >= uint32_t(-1) || h.uncompressed_size >= uint32_t(-1) || h.relative_offset_ >= uint32_t(-1); zip64_enabled = zip64_enabled || need_zip64; if (need_zip64) cd_size += h.extra.size(); } if (m_imp->items.size() >= uint16_t(-1) || cd_size >= uint32_t(-1) || m_imp->end_of_last >= uint32_t(-1)) zip64_enabled = true; uint16_t num_entries = m_imp->items.size() >= uint16_t(-1) ? uint16_t(-1) : uint16_t(m_imp->items.size()); auto cd_and_end_size = cd_size + K_sizeof_cd_end; if (zip64_enabled) cd_and_end_size += K_sizeof_zip64_end_cd + K_sizeof_zip64_locator; auto view = m_imp->archive.get<io::write_map>().view_wr(ext_heap::handle(m_imp->end_of_last, m_imp->end_of_last + cd_and_end_size)); auto address = view.get<io::write_view>().address(); io::fixed_buffer_io bout(address); auto saver = io::exchange::as_sink(bout); for (auto & i : m_imp->items){ file_header& h = i; auto need_zip64 = h.compressed_size >= uint32_t(-1) || h.uncompressed_size >= uint32_t(-1) || h.relative_offset_ >= uint32_t(-1); saver & K_sig_central_file_header & h.creator_version & h.reader_version & h.flags & h.method & h.modified_time & h.modified_date & h.crc32; if (need_zip64) saver & uint32_t(-1) & uint32_t(-1); else saver & uint32_t(h.compressed_size) & uint32_t(h.uncompressed_size); saver & uint16_t(h.name.str().size()) & uint16_t(need_zip64 ? h.extra.size() : 0) & uint16_t(h.comments.size()) & uint16_t(0) //disk number start & uint16_t(0) //internal file attributes & h.external_attrs; if (need_zip64) saver & uint32_t(-1); else saver & uint32_t(h.relative_offset_); bout.write(make_range(reinterpret_cast<const byte*>(h.name.str().begin()) , reinterpret_cast<const byte*>(h.name.str().end()))); if (need_zip64) bout.write(to_range(h.extra)); bout.write(make_range(reinterpret_cast<const byte*>(h.comments.begin()) , reinterpret_cast<const byte*>(h.comments.end()))); } if (zip64_enabled){ saver & K_sig_zip64_end_cd & uint64_t(cd_size) & uint16_t(20) //version made by & uint16_t(20) //version needed to extract & uint32_t(0) //number of this disk & uint32_t(0) //number of the disk with the start of the central directory & uint64_t(m_imp->items.size()) //total number of entries in the central directory on this disk & uint64_t(m_imp->items.size()) //total number of entries in the central directory & uint64_t(cd_size) //size of the central directory & uint64_t(m_imp->end_of_last); //offset of start of central directory with respect to the starting disk number saver & K_sig_zip64_end_of_cd_locator & uint32_t(0) //number of the disk with the start of the zip64 end of central directory & uint64_t(cd_size + m_imp->end_of_last) //relative offset of the zip64 end of central directory record & uint32_t(1); //total number of disks } saver & K_sig_end_central_dir_signature & uint16_t(0) //number of this disk & uint16_t(0) //number of the disk with the start of the central directory & num_entries //total number of entries in the central directory on this disk & num_entries //total number of entries in the central directory & (cd_size >= uint32_t(-1)? uint32_t(-1) : uint32_t(cd_size)) //size of the central directory & (m_imp->end_of_last >= uint32_t(-1)? uint32_t(-1) : uint32_t(m_imp->end_of_last)) //offset of start of central directory with respect to the starting disk number & uint16_t(0); //.ZIP file comment length m_imp->archive.get<io::write_map>().sync(); m_imp->dirty = false; }
const file_header* append_(IoType& ar, const file_header& h_, file_type type, zip_package_writer_imp * m_imp){ file_header h = h_; AIO_PRE_CONDITION(m_imp); AIO_PRE_CONDITION(h.method == cm_deflate || h.method == cm_store); AIO_PRE_CONDITION(h.name.str().size() < uint16_t(-1) ); AIO_PRE_CONDITION(h.comments.size() < uint16_t(-1) ); if (m_imp->exist_(h.name)) return 0; auto header_size = K_fix_part_of_local_header + h.name.str().size() + K_sizeof_zip64_extra_field; auto dest_map = io::decorate<io::tail_archive , io::tail_read_map_p , io::tail_write_map_p >(m_imp->archive, m_imp->end_of_last + header_size); m_imp->dirty = true; if (h.method == cm_deflate){ if (type == ft_raw){ deflate_writer d_writer(dest_map); iref<io::writer> dest(d_writer); io::copy_data(ar, dest.get<io::writer>()); d_writer.finish(); h.uncompressed_size = d_writer.uncompressed_size(); h.compressed_size = d_writer.size(); h.crc32 = d_writer.crc32(); } else {// type == ft_defalted io::copy_data(ar, dest_map); } } else { // == cm_store auto size = io::copy_data(ar, dest_map); h.uncompressed_size = size; h.compressed_size = size; h.crc32 = crc32(dest_map); } setDateTime(h); h.relative_offset_ = m_imp->end_of_last; bool zip64_enabled = (h.uncompressed_size >= uint32_t(-1) || h.compressed_size >= uint32_t(-1) || h.relative_offset_ >= uint32_t(-1) ); { // fill extra data for zip64 io::buffer_out bout(h.extra); auto saver = io::exchange::as_sink(bout); save(saver, uint16_t(K_z64_extra_id)); // save(saver, uint16_t(28)); //sizeof extra data save(saver, uint64_t(h.uncompressed_size)); save(saver, uint64_t(h.compressed_size)); save(saver, uint64_t(h.relative_offset_)); save(saver, uint32_t(0)); //Disk Start Number } auto hview = m_imp->archive.get<io::write_map>().view_wr(ext_heap::handle(m_imp->end_of_last , m_imp->end_of_last + header_size)); io::fixed_buffer_io bout(hview.get<io::write_view>().address()); auto saver = io::exchange::as_sink(bout); saver & K_sig_local_eader; saver & h.reader_version & h.flags & h.method & h.modified_time & h.modified_date & h.crc32; if (zip64_enabled) saver & uint32_t(-1) & uint32_t(-1); else saver & uint32_t(h.compressed_size) & uint32_t(h.uncompressed_size); saver & uint16_t(h.name.str().size()) & uint16_t(h.extra.size()); bout.write(make_range(reinterpret_cast<const byte*>(h.name.str().begin()) , reinterpret_cast<const byte*>(h.name.str().end()))); bout.write(to_range(h.extra)); h.local_header_size_ = header_size; m_imp->items.push_back(h); m_imp->end_of_last += header_size + h.compressed_size; return &m_imp->items.back(); }
iterator_range<CtorDtorIterator> getDestructors(const Module &M) { const GlobalVariable *DtorsList = M.getNamedGlobal("llvm.global_dtors"); return make_range(CtorDtorIterator(DtorsList, false), CtorDtorIterator(DtorsList, true)); }