void listbox::place(const point& origin, const point& size) { boost::optional<unsigned> vertical_scrollbar_position, horizontal_scrollbar_position; // Check if this is the first time placing the list box if(get_origin() != point {-1, -1}) { vertical_scrollbar_position = get_vertical_scrollbar_item_position(); horizontal_scrollbar_position = get_horizontal_scrollbar_item_position(); } // Inherited. scrollbar_container::place(origin, size); const int selected_item = generator_->get_selected_item(); if(vertical_scrollbar_position && horizontal_scrollbar_position) { LOG_GUI_L << LOG_HEADER << " restoring scroll position" << std::endl; set_vertical_scrollbar_item_position(*vertical_scrollbar_position); set_horizontal_scrollbar_item_position(*horizontal_scrollbar_position); } else if(selected_item != -1) { LOG_GUI_L << LOG_HEADER << " making the initially selected item visible" << std::endl; const SDL_Rect& visible = content_visible_area(); SDL_Rect rect = generator_->item(selected_item).get_rectangle(); rect.x = visible.x; rect.w = visible.w; show_content_rect(rect); } }
void SingleStar::write_to_file(int i1, int i2, const char* idname) { char* fname; Real omega = State::get_omega(); FILE* fp; _3Vec O = get_origin(); // asprintf(&fname, "mv -f checkpoint.hello.%i.bin checkpoint.goodbye.%i.bin 2> /dev/null\n", MPI_rank(), MPI_rank()); // system(fname); // free(fname); asprintf(&fname, "checkpoint.%s.%i.bin", idname, MPI_rank()); fp = fopen(fname, "wb"); free(fname); // fwrite(&refine_floor, sizeof(Real), 1, fp); fwrite(&State::ei_floor, sizeof(Real), 1, fp); fwrite(&State::rho_floor, sizeof(Real), 1, fp); // fwrite(&com_vel_correction, sizeof(_3Vec), 1, fp); fwrite(&O, sizeof(_3Vec), 1, fp); fwrite(&omega, sizeof(Real), 1, fp); fwrite(&last_dt, sizeof(Real), 1, fp); fwrite(&i1, sizeof(int), 1, fp); fwrite(&i2, sizeof(int), 1, fp); get_root()->write_checkpoint(fp); fclose(fp); }
void UnitSymbol::draw(Canvas& canvas, PixelScalar x, PixelScalar y) const { const RasterPoint BmpPos = get_origin(UnitSymbol::NORMAL); const PixelSize size = get_size(); canvas.scale_copy(x, y, bitmap, BmpPos.x, BmpPos.y, size.cx, size.cy); }
/** * \brief Draws the sprite on a surface, with its current animation, * direction and frame. * \param dst_surface The destination surface. * \param dst_position Coordinates on the destination surface * (the origin will be placed at this position). */ void Sprite::raw_draw( Surface& dst_surface, const Rectangle& dst_position) { if (!is_animation_finished() && (blink_delay == 0 || blink_is_sprite_visible)) { if (intermediate_surface == NULL) { current_animation->draw(dst_surface, dst_position, current_direction, current_frame); } else { intermediate_surface->fill_with_color(Color::get_black()); current_animation->draw(*intermediate_surface, get_origin(), current_direction, current_frame); Rectangle dst_position2(dst_position); dst_position2.add_xy(-get_origin().get_x(), -get_origin().get_y()); intermediate_surface->draw_region(get_size(), dst_surface, dst_position2); } } }
void grid::request_placement(dispatcher&, const event::ui_event, bool& handled, bool&) { if (get_window()->invalidate_layout_blocked()) { handled = true; return; } point size = get_size(); point best_size = calculate_best_size(); if(size.x >= best_size.x && size.y >= best_size.y) { place(get_origin(), size); handled = true; return; } recalculate_best_size(); if(size.y >= best_size.y) { // We have enough space in the Y direction, but not in the X direction. // Try wrapping the content. request_reduce_width(size.x); best_size = get_best_size(); if(size.x >= best_size.x && size.y >= best_size.y) { // Wrapping succeeded, we still fit vertically. place(get_origin(), size); handled = true; return; } else { // Wrapping failed, we no longer fit. // Reset the sizes of child widgets. layout_initialize(true); } } /* Not enough space. Let the event flow higher up. This is a pre-event handler, so the event flows upwards. */ }
// write a relative ground position to home in meters, Down // will use the barometer if the EKF isn't available void AP_AHRS_NavEKF::get_relative_position_D_home(float &posD) const { Location originLLH; float originD; if (!get_relative_position_D_origin(originD) || !get_origin(originLLH)) { posD = -AP::baro().get_altitude(); return; } posD = originD - ((originLLH.alt - _home.alt) * 0.01f); return; }
void ttree_view::layout_children(const bool force) { assert(root_node_ && content_grid()); if(need_layout_ || force) { root_node_->place(indention_step_size_ , get_origin() , content_grid()->get_size().x); root_node_->set_visible_area(content_visible_area_); need_layout_ = false; } }
void scroll_label::set_label(const t_string& lbl) { // Inherit. styled_widget::set_label(lbl); if(label* widget = get_internal_label()) { widget->set_label(lbl); bool resize_needed = !content_resize_request(); if(resize_needed && get_size() != point()) { place(get_origin(), get_size()); } } }
// return a relative ground position to the home in meters // North/East order. bool AP_AHRS_NavEKF::get_relative_position_NE_home(Vector2f &posNE) const { Location originLLH; Vector2f originNE; if (!get_relative_position_NE_origin(originNE) || !get_origin(originLLH)) { return false; } const Vector2f offset = location_diff(originLLH, _home); posNE.x = originNE.x - offset.x; posNE.y = originNE.y - offset.y; return true; }
void tdrop_button::create_drop_listbox( bool& handled, bool& halt) { handled = halt = true; CVideo& video = get_window()->video(); tdrop_listbox dlg(get_origin(), vals_, linked_groups_, list_builder_, transform_, selected_); dlg.show(video); int ret = dlg.get_retval(); if (ret >= 0) { set_selected(ret); if (callback_selection_changed_) { callback_selection_changed_(this, ret); } } }
/** * \brief Draws a subrectangle of the current frame of this sprite. * \param region The subrectangle to draw, relative to the origin point. * It may be bigger than the frame: in this case it will be clipped. * \param dst_surface The destination surface. * \param dst_position Coordinates on the destination surface. * The origin point of the sprite will appear at these coordinates. */ void Sprite::raw_draw_region( const Rectangle& region, Surface& dst_surface, const Rectangle& dst_position) { if (!is_animation_finished() && (blink_delay == 0 || blink_is_sprite_visible)) { get_intermediate_surface().fill_with_color(Color::get_black()); const Rectangle& origin = get_origin(); current_animation->draw( get_intermediate_surface(), origin, current_direction, current_frame); // If the region is bigger than the current frame, clip it. // Otherwise, more than the current frame could be visible. Rectangle src_position(region); src_position.add_xy(origin.get_x(), origin.get_y()); const Rectangle& frame_size = get_size(); if (src_position.get_x() < 0) { src_position.set_width(src_position.get_width() + src_position.get_x()); src_position.set_x(0); } if (src_position.get_x() + src_position.get_width() > frame_size.get_width()) { src_position.set_width(frame_size.get_width() - src_position.get_x()); } if (src_position.get_y() < 0) { src_position.set_height(src_position.get_height() + src_position.get_y()); src_position.set_y(0); } if (src_position.get_y() + src_position.get_height() > frame_size.get_height()) { src_position.set_height(frame_size.get_height() - src_position.get_y()); } if (src_position.get_width() <= 0 || src_position.get_height() <= 0) { // Nothing remains visible. return; } // Calculate the destination coordinates. Rectangle dst_position2(dst_position); dst_position2.add_xy(src_position.get_x(), src_position.get_y()); // Let a space for the part outside the region. dst_position2.add_xy(-origin.get_x(), -origin.get_y()); // Input coordinates were relative to the origin. get_intermediate_surface().draw_region(src_position, dst_surface, dst_position2); } }
// return a relative ground position to the home in meters // North/East/Down order. bool AP_AHRS_NavEKF::get_relative_position_NED_home(Vector3f &vec) const { Location originLLH; Vector3f originNED; if (!get_relative_position_NED_origin(originNED) || !get_origin(originLLH)) { return false; } const Vector3f offset = location_3d_diff_NED(originLLH, _home); vec.x = originNED.x - offset.x; vec.y = originNED.y - offset.y; vec.z = originNED.z - offset.z; return true; }
// log ahrs home and EKF origin to dataflash void AP_AHRS::Log_Write_Home_And_Origin() { AP_Logger *df = AP_Logger::get_singleton(); if (df == nullptr) { return; } #if AP_AHRS_NAVEKF_AVAILABLE // log ekf origin if set Location ekf_orig; if (get_origin(ekf_orig)) { df->Write_Origin(LogOriginType::ekf_origin, ekf_orig); } #endif // log ahrs home if set if (home_is_set()) { df->Write_Origin(LogOriginType::ahrs_home, _home); } }
bool ControlServer::on_validate(websocketpp::connection_hdl hdl) { log_->trace() << log_tag() << BOOST_CURRENT_FUNCTION; auto connection_ptr = ws_server_.get_con_from_hdl(hdl); auto subprotocols = connection_ptr->get_requested_subprotocols(); auto origin = connection_ptr->get_origin(); log_->debug() << log_tag() << "Incoming connection from " << connection_ptr->get_remote_endpoint() << " Origin: " << origin; // Restrict access by "Origin" header if(!origin.empty()) { // TODO: Add a way to relax this restriction url origin_url(origin); if(origin_url.host != "127.0.0.1" && origin_url.host != "::1" && origin_url.host != "localhost") return false; } // Detect loopback if(std::find(subprotocols.begin(), subprotocols.end(), "librevaultctl1.0") != subprotocols.end()) connection_ptr->select_subprotocol("librevaultctl1.0"); return true; }
/* * We have an origin -- find the path that corresponds to it in its * parent and return an origin structure to represent it. */ static struct blame_origin *find_rename(struct commit *parent, struct blame_origin *origin) { struct blame_origin *porigin = NULL; struct diff_options diff_opts; int i; diff_setup(&diff_opts); DIFF_OPT_SET(&diff_opts, RECURSIVE); diff_opts.detect_rename = DIFF_DETECT_RENAME; diff_opts.output_format = DIFF_FORMAT_NO_OUTPUT; diff_opts.single_follow = origin->path; diff_setup_done(&diff_opts); if (is_null_oid(&origin->commit->object.oid)) do_diff_cache(&parent->tree->object.oid, &diff_opts); else diff_tree_oid(&parent->tree->object.oid, &origin->commit->tree->object.oid, "", &diff_opts); diffcore_std(&diff_opts); for (i = 0; i < diff_queued_diff.nr; i++) { struct diff_filepair *p = diff_queued_diff.queue[i]; if ((p->status == 'R' || p->status == 'C') && !strcmp(p->two->path, origin->path)) { porigin = get_origin(parent, p->one->path); oidcpy(&porigin->blob_oid, &p->one->oid); porigin->mode = p->one->mode; break; } } diff_flush(&diff_opts); clear_pathspec(&diff_opts.pathspec); return porigin; }
/*======================================================================================== * Turns the passed value into a Y/M/D date */ int utCalendar2_cal( double val, ut_unit *dataunits, int *year, int *month, int *day, int *hour, int *minute, double *second, const char *calendar_name ) { int jdnew, ndinc, ierr, iorig, iround; double fdays, extra_seconds, tot_extra_seconds; int ndays; calcalcs_cal *cal2use; /* Following vars are saved between invocations and reused if the * passed units are the same as last time. */ static ut_unit *prev_units=NULL; static cv_converter *conv_user_units_to_days=NULL; static int y0, mon0, d0, h0, min0, jday0; static double s0, extra_seconds0; static char *prev_calendar=NULL; if( dataunits == NULL ) { fprintf( stderr, "Error, utCalendar2 passed a NULL units\n" ); return( UT_ENOINIT ); } if( have_initted == 0 ) initialize( ut_get_system(dataunits) ); /* Get the calendar we will be using, based on the passed name */ cal2use = getcal( calendar_name ); if( cal2use == NULL ) { unknown_cal_emit_warning( calendar_name ); cal2use = getcal( "Standard" ); } /* See if we are being passed the same units and calendar as last time. If so, * we can optimize by not recomputing all this junk */ if( (prev_units != NULL) && (prev_calendar != NULL) && (strcmp(prev_calendar,cal2use->name)==0) && (ut_compare( prev_units, dataunits ) == 0)) { /* Units and calendar are same as used last call */ } else { /* Units/calendar combo are different from previously saved units, must redo calcs */ if( prev_units != NULL ) ut_free( prev_units ); if( prev_calendar != NULL ) free( prev_calendar ); /* Get origin day of the data units */ get_origin( dataunits, &y0, &mon0, &d0, &h0, &min0, &s0 ); /* Note: static vars */ /* Number of seconds into the specified origin day */ extra_seconds0 = h0*3600.0 + min0*60.0 + s0; /* Note: static vars */ /* Convert the origin day to Julian Day number in the specified calendar */ if( (ierr = ccs_date2jday( cal2use, y0, mon0, d0, &jday0 )) != 0 ) { fprintf( stderr, "Error in utCalendar2: %s\n", ccs_err_str(ierr) ); return( UT_EINVALID ); } /* Get converter from user-specified units to "days" */ if( conv_user_units_to_days != NULL ) cv_free( conv_user_units_to_days ); conv_user_units_to_days = get_user_to_day_converter( dataunits, y0, mon0, d0, h0, min0, s0 ); /* Save these units so we can reuse our time-consuming * calculations next time if they are the same units */ prev_units = ut_clone( dataunits ); if( ut_compare( prev_units, dataunits ) != 0 ) { fprintf( stderr, "error, internal error in udunits2 library found in routine utCalendar2: a clone of the user's units does not equal the original units!\n" ); exit(-1); } prev_calendar = (char *)malloc( sizeof(char) * (strlen(cal2use->name)+1 )); strcpy( prev_calendar, cal2use->name ); } /* Convert user value of offset to floating point days */ fdays = cv_convert_double( conv_user_units_to_days, val ); /* Get integer number of days and seconds past that */ ndays = fdays; extra_seconds = (fdays - ndays)*86400.0; /* Get new Julian day */ jdnew = jday0 + ndays; /* Handle the sub-day part */ tot_extra_seconds = extra_seconds0 + extra_seconds; ndinc = tot_extra_seconds / 86400.0; jdnew += ndinc; tot_extra_seconds -= ndinc*86400.0; if( tot_extra_seconds < 0.0 ) { tot_extra_seconds += 86400.0; jdnew--; } /* Convert to a date */ if( (ierr = ccs_jday2date( cal2use, jdnew, year, month, day )) != 0 ) { fprintf( stderr, "Error in utCalendar2: %s\n", ccs_err_str(ierr) ); return( UT_EINVALID ); } *hour = tot_extra_seconds / 3600.0; tot_extra_seconds -= *hour * 3600.0; *minute = tot_extra_seconds / 60.0; tot_extra_seconds -= *minute * 60.0; *second = tot_extra_seconds; /* Handle the rouding issues */ iorig = *second; /* Integer conversion */ iround = *second + sec_rounding_value; if( iround > iorig ) { /* printf( "rounding alg invoked, orig date: %04d-%02d-%02d %02d:%02d:%.20lf\n", *year, *month, *day, *hour, *minute, *second ); */ *second = (double)iround; if( *second >= 60.0 ) { *second -= 60.0; *minute += 1.0; if( *minute >= 60.0 ) { *minute -= 60.0; *hour += 1.0; if( *hour >= 24.0 ) { *hour -= 24.0; if( (ierr = ccs_jday2date( cal2use, jdnew+1, year, month, day )) != 0 ) { fprintf( stderr, "Error in utCalendar2: %s\n", ccs_err_str(ierr) ); return( UT_EINVALID ); } } } } /* printf( "after rounding alg here is new date: %04d-%02d-%02d %02d:%02d:%02.20lf\n", *year, *month, *day, *hour, *minute, *second ); */ } return(0); }
/*======================================================================================== * Turn the passed Y/M/D date into a value in the user's units */ int utInvCalendar2_cal( int year, int month, int day, int hour, int minute, double second, ut_unit *user_unit, double *value, const char *calendar_name ) { int jday, ierr, diff_in_days; double fdiff_in_days, val_days, val_partdays, fdiff_in_partdays, fpartday; calcalcs_cal *cal2use; /* Following vars are static and retained between invocations for efficiency */ static ut_unit *prev_units=NULL; static int y0, mon0, d0, h0, min0, jday0; static double s0, fpartday0; static cv_converter *conv_days_to_user_units=NULL; static char *prev_calendar=NULL; if( have_initted == 0 ) initialize( ut_get_system(user_unit) ); /* Get the calendar we will be using, based on the passed name */ cal2use = getcal( calendar_name ); if( cal2use == NULL ) { unknown_cal_emit_warning( calendar_name ); cal2use = getcal( "Standard" ); } if( (prev_units != NULL) && (prev_calendar != NULL) && (strcmp(prev_calendar,cal2use->name)==0) && (ut_compare( prev_units, user_unit ) == 0)) { /* Units are same as used last call */ } else { if( prev_units != NULL ) ut_free( prev_units ); if( prev_calendar != NULL ) free( prev_calendar ); if( conv_days_to_user_units != NULL ) cv_free( conv_days_to_user_units ); /* Get origin day of the data units */ get_origin( user_unit, &y0, &mon0, &d0, &h0, &min0, &s0 ); /* Note: static vars */ /* Convert the origin day to Julian Day number in the specified calendar */ if( (ierr = ccs_date2jday( cal2use, y0, mon0, d0, &jday0 )) != 0 ) { fprintf( stderr, "Error in utCalendar2: %s\n", ccs_err_str(ierr) ); return( UT_EINVALID ); } /* Get the origin's HMS in fractional (floating point) part of a Julian day */ fpartday0 = (double)h0/24.0 + (double)min0/1440.0 + s0/86400.0; /* Get converter for turning days into user's units */ conv_days_to_user_units = get_day_to_user_converter( user_unit, y0, mon0, d0, h0, min0, s0 ); /* Save these units so we can reuse our time-consuming * calculations next time if they are the same units */ prev_units = ut_clone( user_unit ); if( ut_compare( prev_units, user_unit ) != 0 ) { fprintf( stderr, "error, internal error in udunits2 library found in routine utInvCalendar2: a clone of the user's units does not equal the original units!\n" ); exit(-1); } prev_calendar = (char *)malloc( sizeof(char) * (strlen(cal2use->name)+1 )); strcpy( prev_calendar, cal2use->name ); } /* Turn passed date into a Julian day */ if( (ierr = ccs_date2jday( cal2use, year, month, day, &jday )) != 0 ) { fprintf( stderr, "Error in utInvCalendar2: %s\n", ccs_err_str(ierr) ); return( UT_EINVALID ); } /* jday and jday0 can be very large and nearly equal, so we difference * them first to keep the precision high */ diff_in_days = jday - jday0; fdiff_in_days = (double)diff_in_days; /* Get the fractional (floating point) part of a Julian day difference */ fpartday = (double)hour/24.0 + (double)minute/1440.0 + second/86400.0; fdiff_in_partdays = fpartday - fpartday0; /* Convert days and partial days to user's units */ val_days = cv_convert_double( conv_days_to_user_units, fdiff_in_days ); val_partdays = cv_convert_double( conv_days_to_user_units, fdiff_in_partdays ); /* Hopefully this will minimize the roundoff errors */ *value = val_days + val_partdays; return(0); }
bool tscrollbar_container::content_resize_request(const bool force_sizing) { /** * @todo Try to handle auto_visible_first_run here as well. * * Handling it here makes the code a bit more complex but allows to not * reserve space for scrollbars, which will look nicer in the MP lobby. * But the extra complexity is no 1.8 material. */ assert(content_ && content_grid_); tpoint best_size = content_grid_->recalculate_best_size(); tpoint size = content_->get_size(); DBG_GUI_L << LOG_HEADER << " wanted size " << best_size << " available size " << size << ".\n"; if(size == tpoint(0, 0)) { DBG_GUI_L << LOG_HEADER << " initial setup not done, bailing out.\n"; return false; } if(best_size.x <= size.x && best_size.y <= size.y) { const tpoint content_size = content_grid_->get_size(); if(content_size.x > size.x || content_size.y > size.y) { DBG_GUI_L << LOG_HEADER << " will fit, only needs a resize.\n"; goto resize; } if(force_sizing) { DBG_GUI_L << LOG_HEADER << " fits, but resize forced.\n"; goto resize; } DBG_GUI_L << LOG_HEADER << " fits, nothing to do.\n"; return true; } if(best_size.x > size.x) { DBG_GUI_L << LOG_HEADER << " content too wide.\n"; if(horizontal_scrollbar_mode_ == always_invisible || (horizontal_scrollbar_mode_ == auto_visible_first_run && horizontal_scrollbar_grid_->get_visible() == twidget::tvisible::invisible)) { DBG_GUI_L << LOG_HEADER << " can't use horizontal scrollbar, ask window.\n"; twindow* window = get_window(); assert(window); window->invalidate_layout(); return false; } } if(best_size.y > size.y) { DBG_GUI_L << LOG_HEADER << " content too high.\n"; if(vertical_scrollbar_mode_ == always_invisible || (vertical_scrollbar_mode_ == auto_visible_first_run && vertical_scrollbar_grid_->get_visible() == twidget::tvisible::invisible)) { DBG_GUI_L << LOG_HEADER << " can't use vertical scrollbar, ask window.\n"; twindow* window = get_window(); assert(window); window->invalidate_layout(); return false; } } resize: DBG_GUI_L << LOG_HEADER << " handle resizing.\n"; place(get_origin(), get_size()); return true; }
/** Gets the sizes in one rect structure. */ SDL_Rect get_rect() const { return create_rect(get_origin(), get_size()); }
/* Reads one entry from file. Returns entry or NULL on error. */ struct entry* read_entry(FILE* in, const char* name, int *lineno, uint32_t* default_ttl, ldns_rdf** origin, ldns_rdf** prev_rr) { struct entry* current = NULL; char line[MAX_LINE]; char* parse; ldns_pkt_section add_section = LDNS_SECTION_QUESTION; struct reply_packet *cur_reply = NULL; bool reading_hex = false; ldns_buffer* hex_data_buffer = NULL; while(fgets(line, (int)sizeof(line), in) != NULL) { line[MAX_LINE-1] = 0; parse = line; (*lineno) ++; while(isspace((int)*parse)) parse++; /* test for keywords */ if(isendline(*parse)) continue; /* skip comment and empty lines */ if(str_keyword(&parse, "ENTRY_BEGIN")) { if(current) { error("%s line %d: previous entry does not ENTRY_END", name, *lineno); } current = new_entry(); current->lineno = *lineno; cur_reply = entry_add_reply(current); continue; } else if(str_keyword(&parse, "$ORIGIN")) { get_origin(name, *lineno, origin, parse); continue; } else if(str_keyword(&parse, "$TTL")) { *default_ttl = (uint32_t)atoi(parse); continue; } /* working inside an entry */ if(!current) { error("%s line %d: expected ENTRY_BEGIN but got %s", name, *lineno, line); } if(str_keyword(&parse, "MATCH")) { matchline(parse, current); } else if(str_keyword(&parse, "REPLY")) { replyline(parse, cur_reply->reply); } else if(str_keyword(&parse, "ADJUST")) { adjustline(parse, current, cur_reply); } else if(str_keyword(&parse, "EXTRA_PACKET")) { cur_reply = entry_add_reply(current); } else if(str_keyword(&parse, "SECTION")) { if(str_keyword(&parse, "QUESTION")) add_section = LDNS_SECTION_QUESTION; else if(str_keyword(&parse, "ANSWER")) add_section = LDNS_SECTION_ANSWER; else if(str_keyword(&parse, "AUTHORITY")) add_section = LDNS_SECTION_AUTHORITY; else if(str_keyword(&parse, "ADDITIONAL")) add_section = LDNS_SECTION_ADDITIONAL; else error("%s line %d: bad section %s", name, *lineno, parse); } else if(str_keyword(&parse, "HEX_ANSWER_BEGIN")) { hex_data_buffer = ldns_buffer_new(LDNS_MAX_PACKETLEN); reading_hex = true; } else if(str_keyword(&parse, "HEX_ANSWER_END")) { if (!reading_hex) { error("%s line %d: HEX_ANSWER_END read but no HEX_ANSWER_BEGIN keyword seen", name, *lineno); } reading_hex = false; cur_reply->reply_from_hex = data_buffer2wire(hex_data_buffer); ldns_buffer_free(hex_data_buffer); } else if(str_keyword(&parse, "ENTRY_END")) { return current; } else if(reading_hex) { ldns_buffer_printf(hex_data_buffer, line); } else { /* it must be a RR, parse and add to packet. */ ldns_rr* n = NULL; ldns_status status; if(add_section == LDNS_SECTION_QUESTION) status = ldns_rr_new_question_frm_str( &n, parse, *origin, prev_rr); else status = ldns_rr_new_frm_str(&n, parse, *default_ttl, *origin, prev_rr); if(status != LDNS_STATUS_OK) error("%s line %d:\n\t%s: %s", name, *lineno, ldns_get_errorstr_by_id(status), parse); ldns_pkt_push_rr(cur_reply->reply, add_section, n); } } if (reading_hex) { error("%s: End of file reached while still reading hex, " "missing HEX_ANSWER_END\n", name); } if(current) { error("%s: End of file reached while reading entry. " "missing ENTRY_END\n", name); } return 0; }
std::pair<float,float> Text::get_origin_ratio() { return window->get_ratio_from_pixels(get_origin()); }
bool Flag::is_default() { return (get_origin() == DEFAULT); }
SDL_Rect widget::get_rectangle() const { return create_rect(get_origin(), get_size()); }
/* * We have an origin -- check if the same path exists in the * parent and return an origin structure to represent it. */ static struct blame_origin *find_origin(struct commit *parent, struct blame_origin *origin) { struct blame_origin *porigin; struct diff_options diff_opts; const char *paths[2]; /* First check any existing origins */ for (porigin = parent->util; porigin; porigin = porigin->next) if (!strcmp(porigin->path, origin->path)) { /* * The same path between origin and its parent * without renaming -- the most common case. */ return blame_origin_incref (porigin); } /* See if the origin->path is different between parent * and origin first. Most of the time they are the * same and diff-tree is fairly efficient about this. */ diff_setup(&diff_opts); DIFF_OPT_SET(&diff_opts, RECURSIVE); diff_opts.detect_rename = 0; diff_opts.output_format = DIFF_FORMAT_NO_OUTPUT; paths[0] = origin->path; paths[1] = NULL; parse_pathspec(&diff_opts.pathspec, PATHSPEC_ALL_MAGIC & ~PATHSPEC_LITERAL, PATHSPEC_LITERAL_PATH, "", paths); diff_setup_done(&diff_opts); if (is_null_oid(&origin->commit->object.oid)) do_diff_cache(&parent->tree->object.oid, &diff_opts); else diff_tree_oid(&parent->tree->object.oid, &origin->commit->tree->object.oid, "", &diff_opts); diffcore_std(&diff_opts); if (!diff_queued_diff.nr) { /* The path is the same as parent */ porigin = get_origin(parent, origin->path); oidcpy(&porigin->blob_oid, &origin->blob_oid); porigin->mode = origin->mode; } else { /* * Since origin->path is a pathspec, if the parent * commit had it as a directory, we will see a whole * bunch of deletion of files in the directory that we * do not care about. */ int i; struct diff_filepair *p = NULL; for (i = 0; i < diff_queued_diff.nr; i++) { const char *name; p = diff_queued_diff.queue[i]; name = p->one->path ? p->one->path : p->two->path; if (!strcmp(name, origin->path)) break; } if (!p) die("internal error in blame::find_origin"); switch (p->status) { default: die("internal error in blame::find_origin (%c)", p->status); case 'M': porigin = get_origin(parent, origin->path); oidcpy(&porigin->blob_oid, &p->one->oid); porigin->mode = p->one->mode; break; case 'A': case 'T': /* Did not exist in parent, or type changed */ break; } } diff_flush(&diff_opts); clear_pathspec(&diff_opts.pathspec); return porigin; }
void Simple_manifold_2:: determine_incident_halfedges() { COM_assertion_msg( _is_str || int(_pane->size_of_real_nodes())==_maxsize_real_nodes && int(_pane->size_of_real_elements())==_maxsize_real_elmts, "Support for maxsize not yet fully implemented"); int nnodes, nelems; if ( _is_str) { // For structured meshes, real and ghost are stored together nnodes = _pane->size_of_nodes(); nelems = _pane->size_of_elements(); } else { nnodes = _pane->size_of_real_nodes(); nelems = _pane->size_of_real_elements(); } _ieIDs_real_or_str.clear(); _ieIDs_real_or_str.resize( nnodes, Edge_ID()); Element_node_enumerator ene( _pane, 1); for ( int j=0; j<nelems; ++j, ene.next()) { int ne=ene.size_of_edges(); for ( int i=0; i<ne; ++i) { int vID=ene[i]; // If the incident elements has not been assigned, or the // incident edge is a border edge, then assign the incident elements. Edge_ID prev( ene.id(),i?i-1:ne-1); Edge_ID eoppID = is_real_element( ene.id()) ? get_opposite_real_edge_interior( prev) : get_opposite_ghost_edge_interior( prev); Edge_ID &iid = _ieIDs_real_or_str[ vID-1]; if ( eoppID.is_border() && !is_border_edge( iid)) { iid = eoppID; COM_assertion( get_origin( iid) == vID); } else if ( iid==Edge_ID()) { iid = Edge_ID( ene.id(), i); COM_assertion( get_origin( iid, &ene) == vID); } } // Special treatment for edge centers of quadratic elements int ne2 = std::min(ne+ne,ene.size_of_nodes()); for ( int i=ne, ni=ne2; i<ni; ++i) { int vID=ene[i]; // Make sure every edge centers points to one of its halfedge, and // always points to the border halfedge if on the boundary. Edge_ID eID( ene.id(), i-ne); Edge_ID eoppID = is_real_element( ene.id()) ? get_opposite_real_edge_interior( eID) : get_opposite_ghost_edge_interior( eID); Edge_ID &iid = _ieIDs_real_or_str[ vID-1]; if ( eoppID.is_border() && !is_border_edge( iid)) iid =eoppID; else if ( iid==Edge_ID()) iid = eID; } // Finally, handle face center. if ( ne2<ene.size_of_nodes()) _ieIDs_real_or_str[ene[ne2]-1] = Edge_ID(ene.id(),0); } if (!_is_str) { // Identify isolated nodes that are not incident on any element // and create a numbering for the isolated nodes. _isovIDs.clear(); // Loop through all the nodes for ( int i=1; i<=nnodes; ++i) { Edge_ID &iid = _ieIDs_real_or_str[ i-1]; if ( iid == Edge_ID()) { _isovIDs.push_back( i); iid = Edge_ID( _beIDs.size()+_isovIDs.size(), -1); } } } // We are done for structured mesh and unstructured without ghost nnodes = _with_ghost ? _pane->size_of_ghost_nodes() : 0; _ieIDs_ghost.clear(); _ieIDs_ghost.resize( nnodes, Edge_ID()); if ( _is_str || nnodes==0) return; // Handle ghost nodes and elements nelems = _pane->size_of_ghost_elements(); if ( nelems>0) ene = Element_node_enumerator( _pane, _maxsize_real_elmts+1); for ( int j=0; j<nelems; ++j, ene.next()) { int ne=ene.size_of_edges(); for ( int i=0; i<ne; ++i) { int vID=ene[i]; if ( is_real_node( vID)) continue; // skip real nodes. // If the incident elements has not been assigned, or the // incident edge is a border edge, then assign the incident elements. Edge_ID prev( ene.id(),i?i-1:ne-1); Edge_ID eoppID = get_opposite_ghost_edge_interior( prev); Edge_ID &iid = _ieIDs_ghost[ vID-_maxsize_real_nodes-1]; if ( eoppID.is_border() && !is_border_edge( iid)) { iid = eoppID; COM_assertion( get_origin( iid) == vID); } else if ( iid==Edge_ID()) { iid = Edge_ID( ene.id(), i); COM_assertion( get_origin( iid, &ene) == vID); } } // Special treatment for edge centers of quadratic elements int ne2 = std::min(ne+ne,ene.size_of_nodes()); for ( int i=ne, ni=ne2; i<ni; ++i) { int vID=ene[i]; if ( is_real_node( vID)) continue; // skip real nodes. // Make sure every edge centers points to one of its halfedge, and // always points to the border halfedge if on the boundary. Edge_ID eID( ene.id(), i-ne); Edge_ID eoppID = get_opposite_ghost_edge_interior(eID); Edge_ID &iid = _ieIDs_ghost[ vID-_maxsize_real_nodes-1]; if ( eoppID.is_border() && !is_border_edge( iid)) { iid =eoppID; COM_assertion( get_origin( iid) == vID); } else if ( iid==Edge_ID()) { iid = eID; COM_assertion( get_origin( iid, &ene) == vID); } } // Finally, handle face center. if ( ne2<ene.size_of_nodes()) _ieIDs_ghost[ene[ne2]-_maxsize_real_nodes-1] = Edge_ID(ene.id(),0); } }
bool Flag::is_ergonomic() { return (get_origin() == ERGONOMIC); }
bool Flag::is_command_line() { return (get_origin() == COMMAND_LINE); }
/* * For lines target is suspected for, see if we can find code movement * across file boundary from the parent commit. porigin is the path * in the parent we already tried. */ static void find_copy_in_parent(struct blame_scoreboard *sb, struct blame_entry ***blamed, struct blame_entry **toosmall, struct blame_origin *target, struct commit *parent, struct blame_origin *porigin, int opt) { struct diff_options diff_opts; int i, j; struct blame_list *blame_list; int num_ents; struct blame_entry *unblamed = target->suspects; struct blame_entry *leftover = NULL; if (!unblamed) return; /* nothing remains for this target */ diff_setup(&diff_opts); diff_opts.flags.recursive = 1; diff_opts.output_format = DIFF_FORMAT_NO_OUTPUT; diff_setup_done(&diff_opts); /* Try "find copies harder" on new path if requested; * we do not want to use diffcore_rename() actually to * match things up; find_copies_harder is set only to * force diff_tree_oid() to feed all filepairs to diff_queue, * and this code needs to be after diff_setup_done(), which * usually makes find-copies-harder imply copy detection. */ if ((opt & PICKAXE_BLAME_COPY_HARDEST) || ((opt & PICKAXE_BLAME_COPY_HARDER) && (!porigin || strcmp(target->path, porigin->path)))) diff_opts.flags.find_copies_harder = 1; if (is_null_oid(&target->commit->object.oid)) do_diff_cache(get_commit_tree_oid(parent), &diff_opts); else diff_tree_oid(get_commit_tree_oid(parent), get_commit_tree_oid(target->commit), "", &diff_opts); if (!diff_opts.flags.find_copies_harder) diffcore_std(&diff_opts); do { struct blame_entry **unblamedtail = &unblamed; blame_list = setup_blame_list(unblamed, &num_ents); for (i = 0; i < diff_queued_diff.nr; i++) { struct diff_filepair *p = diff_queued_diff.queue[i]; struct blame_origin *norigin; mmfile_t file_p; struct blame_entry potential[3]; if (!DIFF_FILE_VALID(p->one)) continue; /* does not exist in parent */ if (S_ISGITLINK(p->one->mode)) continue; /* ignore git links */ if (porigin && !strcmp(p->one->path, porigin->path)) /* find_move already dealt with this path */ continue; norigin = get_origin(parent, p->one->path); oidcpy(&norigin->blob_oid, &p->one->oid); norigin->mode = p->one->mode; fill_origin_blob(&sb->revs->diffopt, norigin, &file_p, &sb->num_read_blob); if (!file_p.ptr) continue; for (j = 0; j < num_ents; j++) { find_copy_in_blob(sb, blame_list[j].ent, norigin, potential, &file_p); copy_split_if_better(sb, blame_list[j].split, potential); decref_split(potential); } blame_origin_decref(norigin); } for (j = 0; j < num_ents; j++) { struct blame_entry *split = blame_list[j].split; if (split[1].suspect && sb->copy_score < blame_entry_score(sb, &split[1])) { split_blame(blamed, &unblamedtail, split, blame_list[j].ent); } else { blame_list[j].ent->next = leftover; leftover = blame_list[j].ent; } decref_split(split); } free(blame_list); *unblamedtail = NULL; toosmall = filter_small(sb, toosmall, &unblamed, sb->copy_score); } while (unblamed); target->suspects = reverse_blame(leftover, NULL); diff_flush(&diff_opts); clear_pathspec(&diff_opts.pathspec); }