void get_print_string(oop_t x, char* s, int size) { // toto unimplemented incomplete -- dmu 1/06 switch (tag(x)) { default: fatal("???"); case float_tag: sprintf(s, "a float 0x%x", x); return; case smi_tag: sprintf(s, "a smi %d", value_of_smiOop(x)); return; case mark_tag: sprintf(s, "a markOop 0x%x", x); return; case mem_tag: break; } if (size < length_of_C_string(s)) fatal("string overflow"); size -= length_of_C_string(s); if (is_byteVector(x)) { ByteVectorObj::from(x)->copy_to_C_string(s, size); } else if (is_method(x)) { printf_and_flush("object vector printing not implemented\n"); // }else if (is_blockMethod(x)) { // printf_and_flush("block method printing not implemented\n"); } else if (is_block(x)) { printf_and_flush("block printing not implemented\n"); } else if (is_objVector(x)) { smi id = Object_Table::index_for_oop(x); ObjVectorObj* x_ov = ObjVectorObj::from(x); printf_and_flush("object vector [ID: %d, size: %d], contents:\n", id , x_ov->indexableSize()); //x_ov->print(); printf_and_flush("done contents [ID: %d].\n", id); } else { printf_and_flush("printing not implemented for ??? object type\n"); } if (size < length_of_C_string(s)) fatal("string overflow"); }
void migrate_value(Value* value, Migration* migration) { if (is_ref(value)) { set_term_ref(value, migrate_term_pointer(as_term_ref(value), migration)); } else if (is_block(value)) { set_block(value, migrate_block_pointer(as_block(value), migration)); } else if (is_list_based(value)) { migrate_list_value(value, migration); } else if (is_hashtable(value)) { Value oldHashtable; move(value, &oldHashtable); set_hashtable(value); Value* hashtable = value; for (int i=0; i < hashtable_slot_count(&oldHashtable); i++) { Value* oldKey = hashtable_key_by_index(&oldHashtable, i); if (oldKey == NULL || is_null(oldKey)) continue; Value* oldValue = hashtable_value_by_index(&oldHashtable, i); Value key; copy(oldKey, &key); migrate_value(&key, migration); Value* newValue = hashtable_insert(hashtable, &key); copy(oldValue, newValue); migrate_value(newValue, migration); } } }
int ldiskfs_prepare_lustre(struct mkfs_opts *mop, char *wanted_mountopts, size_t len) { struct lustre_disk_data *ldd = &mop->mo_ldd; int ret; /* Set MO_IS_LOOP to indicate a loopback device is needed */ ret = is_block(mop->mo_device); if (ret < 0) { return errno; } else if (ret == 0) { mop->mo_flags |= MO_IS_LOOP; } if (IS_MDT(ldd) || IS_MGS(ldd)) strscat(wanted_mountopts, ",user_xattr", len); return 0; }
Term* find_name_at(Value* location, Value* name, Symbol lookupType) { NameSearch nameSearch; copy(name, &nameSearch.name); if (is_block(location)) { Block* block = as_block(location); nameSearch.block = block; set_symbol(&nameSearch.position, s_last); } else if (is_term_ref(location)) { Term* term = as_term_ref(location); nameSearch.block = term->owningBlock; set_int(&nameSearch.position, term->index); } else { internal_error("find_name_at"); } nameSearch.ordinal = -1; nameSearch.lookupType = lookupType; nameSearch.searchParent = true; return run_name_search(&nameSearch); }
int add_to_list(t_list **list, int i, int j, char **tab) { t_list *elem; int nbr; int pos; if ((elem = malloc(sizeof(t_list))) == NULL) return (-1); elem->i = i; elem->j = j; nbr = 0; pos = 0; while (++nbr < 10) if (is_line(tab, i, (nbr + '0')) == 0 && is_column(tab, j, (nbr + '0')) == 0 && is_block(tab, i, j, (nbr + '0')) == 0) ++pos; elem->possibilities = pos; elem->next = *list; *list = elem; return (0); }
void CL_CSSUsedValues::set_width(const CL_CSSBoxProperties &properties) { margin.left = get_margin_width(properties.margin_width_left); margin.right = get_margin_width(properties.margin_width_right); border.left = properties.border_width_left.length.value; border.right = properties.border_width_right.length.value; padding.left = get_padding_width(properties.padding_width_left); padding.right = get_padding_width(properties.padding_width_right); width = 0; undetermined_width = false; if (replaced) { if (properties.width.type == CL_CSSBoxWidth::type_auto && properties.height.type == CL_CSSBoxHeight::type_auto && intrinsic.has_width) { width = intrinsic.width; } else if (properties.width.type == CL_CSSBoxWidth::type_auto && properties.height.type == CL_CSSBoxHeight::type_auto && intrinsic.has_height && intrinsic.has_ratio) { width = intrinsic.height / intrinsic.ratio; } else if (properties.width.type == CL_CSSBoxWidth::type_auto && properties.height.type == CL_CSSBoxHeight::type_auto && intrinsic.has_ratio) { if (containing.undetermined_width) { width = 0; undetermined_width = true; } else { width = containing.width - margin.left - margin.right - border.left - border.right - padding.left - padding.right; } } else if (properties.width.type == CL_CSSBoxWidth::type_auto && intrinsic.has_width) { width = intrinsic.width; } else if (properties.width.type == CL_CSSBoxWidth::type_auto) { width = 300; // bug: Should be 300px (css physical length) /*if (width > device.width) { width = largest_2_1_ratio_rect(); }*/ } } else if (is_inline(properties)) { // width property does not apply. width = 0; undetermined_width = true; } else if (is_absolute(properties)) { if (properties.width.type == CL_CSSBoxWidth::type_length) { width = properties.width.length.value; } else if (properties.width.type == CL_CSSBoxWidth::type_percentage) { if (containing.undetermined_width) { width = 0; undetermined_width = true; } else { width = properties.width.percentage * containing.width / 100.0f; } } else if (properties.width.type == CL_CSSBoxWidth::type_auto && properties.left.type != CL_CSSBoxLeft::type_auto && properties.right.type != CL_CSSBoxRight::type_auto) { if (containing.undetermined_width) { width = 0; undetermined_width = true; } else { // To do: Handle the cases where the length property is a percentage. Also determine what the containing box is (the viewport/page-area?) width = containing.width - properties.left.length.value - properties.right.length.value - margin.left - margin.right - border.left - border.right - padding.left - padding.right; } } else if (properties.width.type == CL_CSSBoxWidth::type_auto) { width = 0.0f; undetermined_width = true; // shrink-to-fit } } else if (is_floating(properties) || is_inline_block(properties)) { if (properties.width.type == CL_CSSBoxWidth::type_length) { width = properties.width.length.value; } else if (properties.width.type == CL_CSSBoxWidth::type_percentage) { if (containing.undetermined_width) { width = 0; undetermined_width = true; } else { width = properties.width.percentage * containing.width / 100.0f; } } else if (properties.width.type == CL_CSSBoxWidth::type_auto) { width = 0.0f; undetermined_width = true; // shrink-to-fit } } else if (is_block(properties)) { if (properties.width.type == CL_CSSBoxWidth::type_length) { width = properties.width.length.value; } else if (properties.width.type == CL_CSSBoxWidth::type_percentage) { if (containing.undetermined_width) { width = 0; undetermined_width = true; } else { width = properties.width.percentage * containing.width / 100.0f; } } else if (properties.width.type == CL_CSSBoxWidth::type_auto) { if (containing.undetermined_width) { width = 0; undetermined_width = true; } else { width = cl_max(0.0f, containing.width - margin.left - margin.right - border.left - border.right - padding.left - padding.right); } } } if (!undetermined_width) { if (properties.max_width.type == CL_CSSBoxMaxWidth::type_length) { width = cl_min(width, properties.max_width.length.value); } else if (properties.max_width.type == CL_CSSBoxMaxWidth::type_percentage && !containing.undetermined_width) { width = cl_min(width, properties.max_width.percentage * containing.width / 100.0f); } if (properties.min_width.type == CL_CSSBoxMinWidth::type_length) { width = cl_max(width, properties.min_width.length.value); } else if (properties.min_width.type == CL_CSSBoxMinWidth::type_percentage && !containing.undetermined_width) { width = cl_max(width, properties.min_width.percentage * containing.width / 100.0f); } } calc_noncontent_width(properties); }
void CL_CSSUsedValues::set_height(const CL_CSSBoxProperties &properties) { height = 0; undetermined_height = false; if (replaced) { if (!is_absolute(properties)) { if (properties.height.type == CL_CSSBoxHeight::type_length) { height = properties.height.length.value; } else if (properties.height.type == CL_CSSBoxHeight::type_percentage) { if (containing.undetermined_height) { height = 0; undetermined_height = true; } else { height = containing.height * properties.height.percentage / 100.0f; } } else if (properties.height.type == CL_CSSBoxHeight::type_auto) { height = 0; undetermined_height = true; } } else { height = 0; undetermined_height = true; // 'top' + 'margin-top' + 'border-top-width' + 'padding-top' + 'height' + 'padding-bottom' + 'border-bottom-width' + 'margin-bottom' + 'bottom' = height of containing block } } else if (is_inline(properties)) { // Height does not apply. height = 0; undetermined_height = true; } else if (is_block(properties)) { if (properties.height.type == CL_CSSBoxHeight::type_length) { height = properties.height.length.value; } else if (properties.height.type == CL_CSSBoxHeight::type_percentage) { if (containing.undetermined_height) { height = 0; undetermined_height = true; } else { height = containing.height * properties.height.percentage / 100.0f; } } else if (properties.height.type == CL_CSSBoxHeight::type_auto) { height = 0; undetermined_height = true; } } else if (is_absolute(properties)) { height = 0; undetermined_height = true; // 'top' + 'margin-top' + 'border-top-width' + 'padding-top' + 'height' + 'padding-bottom' + 'border-bottom-width' + 'margin-bottom' + 'bottom' = height of containing block } if (!undetermined_height) { if (properties.max_height.type == CL_CSSBoxMaxHeight::type_length) { height = cl_min(height, properties.max_height.length.value); } else if (properties.max_height.type == CL_CSSBoxMaxHeight::type_percentage && !containing.undetermined_height) { height = cl_min(height, properties.max_height.percentage * containing.height / 100.0f); } if (properties.min_height.type == CL_CSSBoxMinHeight::type_length) { height = cl_max(height, properties.min_height.length.value); } else if (properties.min_height.type == CL_CSSBoxMinHeight::type_percentage && !containing.undetermined_height) { height = cl_max(height, properties.min_height.percentage * containing.height / 100.0f); } } calc_noncontent_height(properties); }
void CL_CSSUsedValues::calc_noncontent_width(const CL_CSSBoxProperties &properties) { margin.left = get_margin_width(properties.margin_width_left); margin.right = get_margin_width(properties.margin_width_right); border.left = properties.border_width_left.length.value; border.right = properties.border_width_right.length.value; padding.left = get_padding_width(properties.padding_width_left); padding.right = get_padding_width(properties.padding_width_right); if (is_inline(properties) || is_inline_block(properties) || is_floating(properties)) { // Do nothing. Correct values already set by get_margin_width. } else if (is_block(properties)) { if (properties.margin_width_left.type == CL_CSSBoxMarginWidth::type_auto && properties.margin_width_right.type == CL_CSSBoxMarginWidth::type_auto) { margin.left = cl_max(0.0f, (containing.width-border.left-border.right-padding.left-padding.right-width)/2.0f); margin.right = cl_max(0.0f, containing.width-border.left-border.right-padding.left-padding.right-width-margin.left); } else if (properties.margin_width_left.type == CL_CSSBoxMarginWidth::type_auto) { margin.left = cl_max(0.0f, containing.width-margin.right-border.left-border.right-padding.left-padding.right-width); } else if (properties.margin_width_right.type == CL_CSSBoxMarginWidth::type_auto) { margin.right = cl_max(0.0f, containing.width-margin.left-border.left-border.right-padding.left-padding.right-width); } if (margin.left + border.left + width + border.right + padding.right + margin.right > containing.width) { if (properties.direction.type == CL_CSSBoxDirection::type_ltr) margin.right = cl_max(0.0f, containing.width-margin.left-border.left-border.right-padding.left-padding.right-width); else margin.left = cl_max(0.0f, containing.width-margin.right-border.left-border.right-padding.left-padding.right-width); } } else if (is_absolute(properties) && !replaced) { // Lots of annoying calculations here using 'left', 'right', 'width', 'direction' and the margin+border+padding+width=containing.width constraint } else if (is_absolute(properties) && replaced) { if (properties.margin_width_left.type == CL_CSSBoxMarginWidth::type_auto) { if (properties.left.type == CL_CSSBoxLeft::type_auto || properties.right.type == CL_CSSBoxRight::type_auto) { margin.left = 0; } else { // solve using margin+border+padding+width=containing.width constraint } } if (properties.margin_width_right.type == CL_CSSBoxMarginWidth::type_auto) { if (properties.left.type == CL_CSSBoxLeft::type_auto || properties.right.type == CL_CSSBoxRight::type_auto) { margin.right = 0; } else { // solve using margin+border+padding+width=containing.width constraint } } } }
inline static oop_t assert_block(oop_t rcvr) { assert(is_block(rcvr)); return rcvr; }
Block* as_block(caValue* value) { ca_assert(is_block(value)); return (Block*) value->value_data.ptr; }