void tex::make_accent () { fnt f; qcell i; ptr p, q, r; scal a, h, w, x; float s, t; scal delta; scan_char_num(); f = cur_font; p = new_character(f, cur_val); if (p != null) { x = x_height(f); s = (float) slant(f) / 65536.0; a = char_width(f, char_info(f, character(p))); do_assignments(); q = null; f = cur_font; if (cur_cmd == LETTER || cur_cmd == OTHER_CHAR || cur_cmd == CHAR_GIVEN) { q = new_character(f, cur_chr); } else if (cur_cmd == CHAR_NUM) { scan_char_num(); q = new_character(f, cur_val); } else { back_input(); } if (q != null) { t = (float) slant(f) / 65536.0; i = char_info(f, character(q)); w = char_width(f, i); h = char_height(f, height_depth(i)); if (h != x) { p = hpack(p, 0, ADDITIONAL); shift_amount(p) = x - h; } delta = round((float) (w - a) / 2.0 + h * t - x * s); r = new_kern(delta); subtype(r) = ACC_KERN; link(tail) = r; link(r) = p; tail = new_kern(-a - delta); subtype(tail) = ACC_KERN; link(p) = tail; p = q; } tail_append(p); space_factor = 1000; } }
tex::box_t::box_t() { type(this) = HLIST_NODE; subtype(this) = MIN_QUARTERWORD; box_width(this) = 0; box_depth(this) = 0; box_height(this) = 0; shift_amount(this) = 0; list_ptr(this) = 0; glue_sign(this) = NORMAL; glue_order(this) = NORMAL; glue_set(this) = 0.0; }
void allowCommand(const tf::TransformListener& listener){ float dt = simTime_/(float)numSteps_; // Offset current pose to the front left corner of the vehicle outline geometry_msgs::PoseStamped currentPose; currentPose.header.frame_id = "/base_link"; currentPose.pose.position.x = -length_/2.0 - originOffsetX_; currentPose.pose.position.y = -width_/2.0 - originOffsetY_; currentPose.pose.position.z = originOffsetZ_; currentPose.pose.orientation = tf::createQuaternionMsgFromYaw(0.0); // Transform this into the map frame? //tf_listener_.transformPose("/odom", ros::Time(0), currentPose, "/base_link", currentPose); for(int i = 1; i <= numSteps_; i++){ // Assume command is safe unless proven otherwise allowRecentCommand = true; // Propigate curvature addition through time float th = tf::getYaw(currentPose.pose.orientation); float v = cmd_.linear.x; float w = cmd_.angular.z; float dx; float dy; float dTh = w*i*dt; float thNew = th + dTh; if(fabs(w) < 0.001){ // Straight line dx = v*i*dt*cos(th); dy = v*i*dt*sin(th); } else { float r = v/w; dx = -r*sin(th)+r*sin(thNew); dy = r*cos(th)-r*cos(thNew); } // Check this position for collisions geometry_msgs::PoseStamped origin; tf::Stamped<tf::Pose > tf_origin; tf::poseStampedMsgToTF(currentPose, tf_origin); tf::Pose shift_amount(tf::createQuaternionFromYaw(dTh), tf::Vector3(dx, dy, 0.0)); tf_origin.setData(tf_origin * shift_amount); tf::poseStampedTFToMsg(tf_origin, origin); try{ bool collision_detected = costmap_->checkRectangularPrismBase(origin, width_, height_, length_, resolution_, checkFullVolume_); if(collision_detected){ allowRecentCommand = false; ROS_DEBUG("Collision detected, do not execute command!"); } } catch (tf::TransformException ex) { ROS_ERROR("%s", ex.what()); } ros::Duration(visPause_).sleep(); } }
void tex::show_box1(ptr p) { if (tex::type(p) == HLIST_NODE) print_esc("h"); else if (tex::type(p) == VLIST_NODE) print_esc("v"); else print_esc("unset"); print("box("); print_scaled(box_height(p)); print("+") ; print_scaled(box_depth(p)); print(")x") ; print_scaled(box_width(p)); if (tex::type(p) == UNSET_NODE) { if (unset_span_count(p) != MIN_QUARTERWORD) { print(" ("); print_int(unset_span_count(p)+1); print(" columns)"); } if (unset_stretch(p) != 0) { print(", stretch "); print_glue(unset_stretch(p), glue_order(p), null_str); } if (unset_shrink(p) != 0) { print(", shrink "); print_glue(unset_shrink(p), glue_sign(p), null_str); } } else { show_glue_set(p); if (shift_amount(p) != 0) { print(", shifted "); print_scaled(shift_amount(p)); } } node_list_display(list_ptr(p)); }
static wxString get_history_string(json::Object &obj) { wxString filename = to_wx(obj["filename"]); if (filename.empty()) filename = _("unsaved"); wxString shift_amount(to_wx(obj["amount"])); if (!obj["is by time"]) shift_amount = wxString::Format(_("%s frames"), shift_amount); wxString shift_direction = obj["is backward"] ? _("backward") : _("forward"); int64_t time_field = obj["fields"]; wxString fields = time_field == 0 ? _("s+e") : time_field == 1 ? _("s") : _("e") ; json::Array const& sel = obj["selection"]; wxString lines; int64_t sel_mode = obj["mode"]; if (sel_mode == 0) lines = _("all"); else if (sel_mode == 2) lines = wxString::Format(_("from %d onward"), (int)(int64_t)sel.front()["start"]); else { lines += _("sel "); for (auto it = sel.begin(); it != sel.end(); ++it) { int beg = (int64_t)(*it)["start"]; int end = (int64_t)(*it)["end"]; if (beg == end) lines += std::to_wstring(beg); else lines += wxString::Format("%d-%d", beg, end); if (it + 1 != sel.end()) lines += ";"; } } return wxString::Format("%s, %s %s, %s, %s", filename, shift_amount, shift_direction, fields, lines); }
void pdf_vlist_out (void) { scaled left_edge; scaled top_edge; scaled save_h, save_v; pointer this_box; // glue_ord g_order; int g_order; // char g_sign; int g_sign; pointer p; integer save_loc; pointer leader_box; scaled leader_ht; scaled lx; boolean outer_doing_leaders; scaled edge; real glue_temp; real cur_glue; scaled cur_g; cur_g = 0; cur_glue = 0.0; this_box = temp_ptr; g_order = glue_order(this_box); g_sign = glue_sign(this_box); p = list_ptr(this_box); incr(cur_s); if (cur_s > max_push) max_push = cur_s; save_loc = dvi_offset + dvi_ptr; left_edge = cur_h; cur_v = cur_v - height(this_box); top_edge = cur_v; while (p != 0) { if (is_char_node(p)) { confusion("vlistout"); return; } else { switch (type(p)) { case hlist_node: case vlist_node: if (list_ptr(p) == 0) cur_v = cur_v + height(p) + depth(p); else { cur_v = cur_v + height(p); pdf_synch_v(); save_h = dvi_h; save_v = dvi_v; cur_h = left_edge + shift_amount(p); temp_ptr = p; if (type(p) == vlist_node) pdf_vlist_out(); else pdf_hlist_out(); dvi_h = save_h; dvi_v = save_v; cur_v = save_v + depth(p); cur_h = left_edge; } break; case rule_node: { rule_ht = height(p); rule_dp = depth(p); rule_wd = width(p); goto fin_rule; } break; case whatsit_node: out_what(p); break; case glue_node: { g = glue_ptr(p); rule_ht = width(g) - cur_g; if (g_sign != normal) { if (g_sign == stretching) { if (stretch_order(g) == g_order) { cur_glue = cur_glue + stretch(g); vet_glue(glue_set(this_box) * cur_glue); cur_g = round(glue_temp); } } else if (shrink_order(g) == g_order) /* BUG FIX !!! */ { cur_glue = cur_glue - shrink(g); vet_glue(glue_set(this_box) * cur_glue); cur_g = round(glue_temp); } } rule_ht = rule_ht + cur_g; if (subtype(p) >= a_leaders) { leader_box = leader_ptr(p); if (type(leader_box) == rule_node) { rule_wd = width(leader_box); rule_dp = 0; goto fin_rule; } leader_ht = height(leader_box) + depth(leader_box); if ((leader_ht > 0) && (rule_ht > 0)) { rule_ht = rule_ht + 10; edge = cur_v + rule_ht; lx = 0; if (subtype(p) == a_leaders) { save_v = cur_v; cur_v = top_edge + leader_ht * ((cur_v - top_edge) / leader_ht); if (cur_v < save_v) cur_v = cur_v + leader_ht; } else { lq = rule_ht / leader_ht; lr = rule_ht % leader_ht; if (subtype(p) == c_leaders) cur_v = cur_v + (lr / 2); else { lx = (2 * lr + lq + 1) / (2 * lq + 2); cur_v = cur_v + ((lr - (lq - 1) * lx) / 2); } } while (cur_v + leader_ht <= edge) { cur_h = left_edge + shift_amount(leader_box); pdf_synch_h(); save_h = dvi_h; cur_v = cur_v + height(leader_box); pdf_synch_v(); save_v = dvi_v; temp_ptr = leader_box; outer_doing_leaders = doing_leaders; doing_leaders = true; if (type(leader_box) == vlist_node) pdf_vlist_out(); else pdf_hlist_out(); doing_leaders = outer_doing_leaders; dvi_v = save_v; dvi_h = save_h; cur_h = left_edge; cur_v = save_v - height(leader_box) + leader_ht + lx; } cur_v = edge - 10; goto next_p; } } goto move_past; } break; case kern_node: cur_v = cur_v + width(p); break; default: break; } goto next_p; fin_rule: if (is_running(rule_wd)) rule_wd = width(this_box); rule_ht = rule_ht + rule_dp; cur_v = cur_v + rule_ht; if ((rule_ht > 0) && (rule_wd > 0)) { pdf_synch_h(); pdf_synch_v(); pdf_dev_set_rule(dvi_h, -dvi_v, rule_wd, rule_ht); } goto next_p; move_past: cur_v = cur_v + rule_ht; } next_p: p = link(p); } prune_movements(save_loc); decr(cur_s); }
void pdf_hlist_out (void) { scaled base_line; scaled left_edge; scaled save_h, save_v; pointer this_box; // glue_ord g_order; int g_order; // char g_sign; int g_sign; pointer p; integer save_loc; pointer leader_box; scaled leader_wd; scaled lx; boolean outer_doing_leaders; scaled edge; real glue_temp; real cur_glue; scaled cur_g; cur_g = 0; cur_glue = 0.0; this_box = temp_ptr; g_order = glue_order(this_box); g_sign = glue_sign(this_box); p = list_ptr(this_box); incr(cur_s); if (cur_s > max_push) max_push = cur_s; save_loc = dvi_offset + dvi_ptr; base_line = cur_v; left_edge = cur_h; while (p != 0) reswitch: if (is_char_node(p)) { pdf_synch_h(); pdf_synch_v(); do { f = font(p); c = character(p); if (f != dvi_f) { if (!font_used[f]) { font_used[f] = true; font_id[f] = pdf_get_font_id(f); } dvi_f = f; } pdf_out_char(dvi_f, c); cur_h = cur_h + char_width(f, char_info(f, c)); p = link(p); } while (!(!is_char_node(p))); dvi_h = cur_h; } else { switch (type(p)) { case hlist_node: case vlist_node: if (list_ptr(p) == 0) cur_h = cur_h + width(p); else { save_h = dvi_h; save_v = dvi_v; cur_v = base_line + shift_amount(p); temp_ptr = p; edge = cur_h; if (type(p) == vlist_node) pdf_vlist_out(); else pdf_hlist_out(); dvi_h = save_h; dvi_v = save_v; cur_h = edge + width(p); cur_v = base_line; } break; case rule_node: { rule_ht = height(p); rule_dp = depth(p); rule_wd = width(p); goto fin_rule; } break; case whatsit_node: out_what(p); break; case glue_node: { g = glue_ptr(p); rule_wd = width(g) - cur_g; if (g_sign != normal) { if (g_sign == stretching) { if (stretch_order(g) == g_order) { cur_glue = cur_glue + stretch(g); vet_glue(glue_set(this_box) * cur_glue); cur_g = round(glue_temp); } } else if (shrink_order(g) == g_order) { cur_glue = cur_glue - shrink(g); vet_glue(glue_set(this_box) * cur_glue); cur_g = round(glue_temp); } } rule_wd = rule_wd + cur_g; if (subtype(p) >= a_leaders) { leader_box = leader_ptr(p); if (type(leader_box) == rule_node) { rule_ht = height(leader_box); rule_dp = depth(leader_box); goto fin_rule; } leader_wd = width(leader_box); if ((leader_wd > 0) && (rule_wd > 0)) { rule_wd = rule_wd + 10; edge = cur_h + rule_wd; lx = 0; if (subtype(p) == a_leaders) { save_h = cur_h; cur_h = left_edge + leader_wd * ((cur_h - left_edge) / leader_wd); if (cur_h < save_h) cur_h = cur_h + leader_wd; } else { lq = rule_wd / leader_wd; lr = rule_wd % leader_wd; if (subtype(p) == c_leaders) cur_h = cur_h + (lr / 2); else { lx = (2 * lr + lq + 1) / (2 * lq + 2); cur_h = cur_h + ((lr - (lq - 1)* lx) / 2); } } while (cur_h + leader_wd <= edge) { cur_v = base_line + shift_amount(leader_box); pdf_synch_v(); save_v = dvi_v; pdf_synch_h(); save_h = dvi_h; temp_ptr = leader_box; outer_doing_leaders = doing_leaders; doing_leaders = true; if (type(leader_box) == vlist_node) pdf_vlist_out(); else pdf_hlist_out(); doing_leaders = outer_doing_leaders; dvi_v = save_v; dvi_h = save_h; cur_v = base_line; cur_h = save_h + leader_wd + lx; } cur_h = edge - 10; goto next_p; } } goto move_past; } break; case kern_node: case math_node: cur_h = cur_h + width(p); break; case ligature_node: { mem[lig_trick] = mem[lig_char(p)]; link(lig_trick) = link(p); p = lig_trick; goto reswitch; } break; default: break; } goto next_p; fin_rule: if (is_running(rule_ht)) rule_ht = height(this_box); if (is_running(rule_dp)) rule_dp = depth(this_box); rule_ht = rule_ht + rule_dp; if ((rule_ht > 0) && (rule_wd > 0)) { pdf_synch_h(); cur_v = base_line + rule_dp; pdf_synch_v(); pdf_dev_set_rule(dvi_h, -dvi_v, rule_wd, rule_ht); cur_v = base_line; dvi_h = dvi_h + rule_wd; } move_past: cur_h = cur_h + rule_wd; next_p: p = link(p); } prune_movements(save_loc); decr(cur_s); }
static MonoMethod* create_allocator (int atype, int offset) { int index_var, bytes_var, my_fl_var, my_entry_var; guint32 no_freelist_branch, not_small_enough_branch = 0; guint32 size_overflow_branch = 0; MonoMethodBuilder *mb; MonoMethod *res; MonoMethodSignature *csig; AllocatorWrapperInfo *info; if (atype == ATYPE_STRING) { csig = mono_metadata_signature_alloc (mono_defaults.corlib, 2); csig->ret = &mono_defaults.string_class->byval_arg; csig->params [0] = &mono_defaults.int_class->byval_arg; csig->params [1] = &mono_defaults.int32_class->byval_arg; } else { csig = mono_metadata_signature_alloc (mono_defaults.corlib, 1); csig->ret = &mono_defaults.object_class->byval_arg; csig->params [0] = &mono_defaults.int_class->byval_arg; } mb = mono_mb_new (mono_defaults.object_class, "Alloc", MONO_WRAPPER_ALLOC); bytes_var = mono_mb_add_local (mb, &mono_defaults.int32_class->byval_arg); if (atype == ATYPE_STRING) { /* a string alloator method takes the args: (vtable, len) */ /* bytes = (sizeof (MonoString) + ((len + 1) * 2)); */ mono_mb_emit_ldarg (mb, 1); mono_mb_emit_icon (mb, 1); mono_mb_emit_byte (mb, MONO_CEE_ADD); mono_mb_emit_icon (mb, 1); mono_mb_emit_byte (mb, MONO_CEE_SHL); // sizeof (MonoString) might include padding mono_mb_emit_icon (mb, G_STRUCT_OFFSET (MonoString, chars)); mono_mb_emit_byte (mb, MONO_CEE_ADD); mono_mb_emit_stloc (mb, bytes_var); } else { /* bytes = vtable->klass->instance_size */ mono_mb_emit_ldarg (mb, 0); mono_mb_emit_icon (mb, G_STRUCT_OFFSET (MonoVTable, klass)); mono_mb_emit_byte (mb, MONO_CEE_ADD); mono_mb_emit_byte (mb, MONO_CEE_LDIND_I); mono_mb_emit_icon (mb, G_STRUCT_OFFSET (MonoClass, instance_size)); mono_mb_emit_byte (mb, MONO_CEE_ADD); /* FIXME: assert instance_size stays a 4 byte integer */ mono_mb_emit_byte (mb, MONO_CEE_LDIND_U4); mono_mb_emit_stloc (mb, bytes_var); } /* this is needed for strings/arrays only as the other big types are never allocated with this method */ if (atype == ATYPE_STRING) { /* check for size */ /* if (!SMALL_ENOUGH (bytes)) jump slow_path;*/ mono_mb_emit_ldloc (mb, bytes_var); mono_mb_emit_icon (mb, (NFREELISTS-1) * GRANULARITY); not_small_enough_branch = mono_mb_emit_short_branch (mb, MONO_CEE_BGT_UN_S); /* check for overflow */ mono_mb_emit_ldloc (mb, bytes_var); mono_mb_emit_icon (mb, sizeof (MonoString)); size_overflow_branch = mono_mb_emit_short_branch (mb, MONO_CEE_BLE_UN_S); } /* int index = INDEX_FROM_BYTES(bytes); */ index_var = mono_mb_add_local (mb, &mono_defaults.int32_class->byval_arg); mono_mb_emit_ldloc (mb, bytes_var); mono_mb_emit_icon (mb, GRANULARITY - 1); mono_mb_emit_byte (mb, MONO_CEE_ADD); mono_mb_emit_icon (mb, shift_amount (GRANULARITY)); mono_mb_emit_byte (mb, MONO_CEE_SHR_UN); mono_mb_emit_icon (mb, shift_amount (sizeof (gpointer))); mono_mb_emit_byte (mb, MONO_CEE_SHL); /* index var is already adjusted into bytes */ mono_mb_emit_stloc (mb, index_var); my_fl_var = mono_mb_add_local (mb, &mono_defaults.int_class->byval_arg); my_entry_var = mono_mb_add_local (mb, &mono_defaults.int_class->byval_arg); /* my_fl = ((GC_thread)tsd) -> ptrfree_freelists + index; */ mono_mb_emit_byte (mb, MONO_CUSTOM_PREFIX); mono_mb_emit_byte (mb, 0x0D); /* CEE_MONO_TLS */ mono_mb_emit_i4 (mb, offset); if (atype == ATYPE_FREEPTR || atype == ATYPE_FREEPTR_FOR_BOX || atype == ATYPE_STRING) mono_mb_emit_icon (mb, G_STRUCT_OFFSET (struct GC_Thread_Rep, ptrfree_freelists)); else if (atype == ATYPE_NORMAL) mono_mb_emit_icon (mb, G_STRUCT_OFFSET (struct GC_Thread_Rep, normal_freelists)); else if (atype == ATYPE_GCJ) mono_mb_emit_icon (mb, G_STRUCT_OFFSET (struct GC_Thread_Rep, gcj_freelists)); else g_assert_not_reached (); mono_mb_emit_byte (mb, MONO_CEE_ADD); mono_mb_emit_ldloc (mb, index_var); mono_mb_emit_byte (mb, MONO_CEE_ADD); mono_mb_emit_stloc (mb, my_fl_var); /* my_entry = *my_fl; */ mono_mb_emit_ldloc (mb, my_fl_var); mono_mb_emit_byte (mb, MONO_CEE_LDIND_I); mono_mb_emit_stloc (mb, my_entry_var); /* if (EXPECT((word)my_entry >= HBLKSIZE, 1)) { */ mono_mb_emit_ldloc (mb, my_entry_var); mono_mb_emit_icon (mb, HBLKSIZE); no_freelist_branch = mono_mb_emit_short_branch (mb, MONO_CEE_BLT_UN_S); /* ptr_t next = obj_link(my_entry); *my_fl = next; */ mono_mb_emit_ldloc (mb, my_fl_var); mono_mb_emit_ldloc (mb, my_entry_var); mono_mb_emit_byte (mb, MONO_CEE_LDIND_I); mono_mb_emit_byte (mb, MONO_CEE_STIND_I); /* set the vtable and clear the words in the object */ mono_mb_emit_ldloc (mb, my_entry_var); mono_mb_emit_ldarg (mb, 0); mono_mb_emit_byte (mb, MONO_CEE_STIND_I); if (atype == ATYPE_FREEPTR) { int start_var, end_var, start_loop; /* end = my_entry + bytes; start = my_entry + sizeof (gpointer); */ start_var = mono_mb_add_local (mb, &mono_defaults.int_class->byval_arg); end_var = mono_mb_add_local (mb, &mono_defaults.int_class->byval_arg); mono_mb_emit_ldloc (mb, my_entry_var); mono_mb_emit_ldloc (mb, bytes_var); mono_mb_emit_byte (mb, MONO_CEE_ADD); mono_mb_emit_stloc (mb, end_var); mono_mb_emit_ldloc (mb, my_entry_var); mono_mb_emit_icon (mb, G_STRUCT_OFFSET (MonoObject, synchronisation)); mono_mb_emit_byte (mb, MONO_CEE_ADD); mono_mb_emit_stloc (mb, start_var); /* * do { * *start++ = NULL; * } while (start < end); */ start_loop = mono_mb_get_label (mb); mono_mb_emit_ldloc (mb, start_var); mono_mb_emit_icon (mb, 0); mono_mb_emit_byte (mb, MONO_CEE_STIND_I); mono_mb_emit_ldloc (mb, start_var); mono_mb_emit_icon (mb, sizeof (gpointer)); mono_mb_emit_byte (mb, MONO_CEE_ADD); mono_mb_emit_stloc (mb, start_var); mono_mb_emit_ldloc (mb, start_var); mono_mb_emit_ldloc (mb, end_var); mono_mb_emit_byte (mb, MONO_CEE_BLT_UN_S); mono_mb_emit_byte (mb, start_loop - (mono_mb_get_label (mb) + 1)); } else if (atype == ATYPE_FREEPTR_FOR_BOX || atype == ATYPE_STRING) { /* need to clear just the sync pointer */ mono_mb_emit_ldloc (mb, my_entry_var); mono_mb_emit_icon (mb, G_STRUCT_OFFSET (MonoObject, synchronisation)); mono_mb_emit_byte (mb, MONO_CEE_ADD); mono_mb_emit_icon (mb, 0); mono_mb_emit_byte (mb, MONO_CEE_STIND_I); } if (atype == ATYPE_STRING) { /* need to set length and clear the last char */ /* s->length = len; */ mono_mb_emit_ldloc (mb, my_entry_var); mono_mb_emit_icon (mb, G_STRUCT_OFFSET (MonoString, length)); mono_mb_emit_byte (mb, MONO_CEE_ADD); mono_mb_emit_ldarg (mb, 1); mono_mb_emit_byte (mb, MONO_CEE_STIND_I4); /* s->chars [len] = 0; */ mono_mb_emit_ldloc (mb, my_entry_var); mono_mb_emit_ldloc (mb, bytes_var); mono_mb_emit_icon (mb, 2); mono_mb_emit_byte (mb, MONO_CEE_SUB); mono_mb_emit_byte (mb, MONO_CEE_ADD); mono_mb_emit_icon (mb, 0); mono_mb_emit_byte (mb, MONO_CEE_STIND_I2); } /* return my_entry; */ mono_mb_emit_ldloc (mb, my_entry_var); mono_mb_emit_byte (mb, MONO_CEE_RET); mono_mb_patch_short_branch (mb, no_freelist_branch); if (not_small_enough_branch > 0) mono_mb_patch_short_branch (mb, not_small_enough_branch); if (size_overflow_branch > 0) mono_mb_patch_short_branch (mb, size_overflow_branch); /* the slow path: we just call back into the runtime */ if (atype == ATYPE_STRING) { mono_mb_emit_ldarg (mb, 1); mono_mb_emit_icall (mb, mono_string_alloc); } else { mono_mb_emit_ldarg (mb, 0); mono_mb_emit_icall (mb, mono_object_new_specific); } mono_mb_emit_byte (mb, MONO_CEE_RET); res = mono_mb_create_method (mb, csig, 8); mono_mb_free (mb); mono_method_get_header (res)->init_locals = FALSE; info = mono_image_alloc0 (mono_defaults.corlib, sizeof (AllocatorWrapperInfo)); info->gc_name = "boehm"; info->alloc_type = atype; mono_marshal_set_wrapper_info (res, info); return res; }
void tex::box_end(int box_context) { ptr p; #define LEADERS "Leaders not followed by proper glue" if (box_context < BOX_FLAG) { if (cur_box != null) { shift_amount(cur_box) = box_context; if (abs(mode) == VMODE) { append_to_vlist(cur_box); if (tex::adjust_tail != null) { if (tex::adjust_head != tex::adjust_tail) { link(tail) = link(tex::adjust_head); tail = tex::adjust_tail; } tex::adjust_tail = null; } if (mode > 0) build_page(); } else { if (abs(mode) == HMODE) { space_factor = 1000; } else { p = new_noad(); math_type(nucleus(p)) = SUB_BOX; info(nucleus(p)) = cur_box; cur_box = p; } tail_append(cur_box); } } } else if (box_context < SHIP_OUT_FLAG) { if (box_context < BOX_FLAG + 256) { reg_define(box_reg[box_context - BOX_FLAG], BOX_REG, cur_box); } else { reg_gdefine(box_reg[box_context - BOX_FLAG - 256], BOX_REG, cur_box); } } else if (cur_box != null) { if (box_context > SHIP_OUT_FLAG) { get_nbrx_token(); if (cur_cmd == HSKIP && abs(mode) != VMODE || cur_cmd == VSKIP && abs(mode) == VMODE || cur_cmd == MSKIP && abs(mode) == MMODE) { append_glue(); leader_ptr(tail) = cur_box; subtype(tail) = box_context - (LEADER_FLAG - A_LEADERS); } else { print_err(LEADERS); help_leaders(); back_error(); flush_node_list(cur_box); } } else { ship_out(cur_box); } } }
void tex::begin_box(int box_context) { int k, m, n; ptr p=0, q; switch (cur_chr) { case BOX_CODE: scan_eight_bit_int(); cur_box = box(cur_val); box(cur_val) = null; break; case COPY_CODE: scan_eight_bit_int(); cur_box = copy_node_list(box(cur_val)); break; case LAST_BOX_CODE: cur_box = null; if (abs(mode) == MMODE) { you_cant(); help_lastbox_m(); error(); } else if (mode == VMODE && head == tail) { you_cant(); help_lastbox_v(); error(); } else if (type(tail) == HLIST_NODE || type(tail) == VLIST_NODE) { for (q = head; q != tail; q = link(p)) { p = q; if (type(q) == DISC_NODE) { m = 1; while (m <= replace_count(q)) { p = link(p); incr(m); } if (p == tail) { break; } } } cur_box = tail; shift_amount(cur_box) = 0; tail = p; link(p) = null; } break; case VSPLIT_CODE: scan_eight_bit_int(); n = cur_val; if (!scan_keyword("to")) { print_err("Missing `to' inserted"); help_vsplit(); error(); } scan_normal_dimen(); cur_box = vsplit(n, cur_val); break; default: k = cur_chr - VTOP_CODE; saved(0) = box_context; if (k == HMODE) { if (box_context < BOX_FLAG && abs(mode) == VMODE) { scan_spec(ADJUSTED_HBOX_GROUP, TRUE); } else { scan_spec(HBOX_GROUP, TRUE); } } else { if (k == VMODE) { scan_spec(VBOX_GROUP, TRUE); } else { scan_spec(VTOP_GROUP, TRUE); k = VMODE; } normal_paragraph(); } push_nest(); mode = -k; if (k == VMODE) { prev_depth = IGNORE_DEPTH; if (every_vbox != null) begin_token_list(every_vbox, EVERY_VBOX_TEXT); } else { space_factor = 1000; if (every_hbox != null) begin_token_list(every_hbox, EVERY_HBOX_TEXT); } return; } box_end(box_context); }
void tex::after_math () { ptr a; ptr b; scal d; scal e; bool l; int m; ptr p; scal q; ptr r; scal s; scal t; scal w; scal z; int g1; int g2; bool danger; danger = check_font_params(); m = mode; l = FALSE; p = fin_mlist(null); if (mode == -m) { check_dollar(); a = hpack(mlist_to_hlist(p, TEXT_STYLE, FALSE), 0, ADDITIONAL); unsave(); decr(save_ptr); if (saved(0) == 1) l = TRUE; danger = check_font_params(); m = mode; p = fin_mlist(null); } else { a = null; } if (m < 0) { tail_append(new_math(math_surround, BEFORE)); link(tail) = mlist_to_hlist(p, TEXT_STYLE, mode > 0); while (link(tail) != null) tail = link(tail); tail_append(new_math(math_surround, AFTER)); space_factor = 1000; unsave(); } else { if (a == null) check_dollar(); p = mlist_to_hlist(p, DISPLAY_STYLE, FALSE); tex::adjust_tail = tex::adjust_head; b = hpack(p, 0, ADDITIONAL); p = list_ptr(b); t = tex::adjust_tail; tex::adjust_tail = null; w = box_width(b); z = display_width; s = display_indent; if (a == null || danger) { e = q = 0; } else { e = box_width(a); q = e + math_quad(TEXT_SIZE); } if (w + q > z) { if (e != 0 && (w - tex::total_shrink[NORMAL] + q <= z || tex::total_shrink[FIL] != 0 || tex::total_shrink[FILL] != 0 || tex::total_shrink[FILLL] != 0)) { free_node(b, BOX_NODE_SIZE); b = hpack(p, z - q, EXACTLY); } else { e = 0; if (w > z) { free_node(b, BOX_NODE_SIZE); b = hpack(p, z, EXACTLY); } } w = box_width(b); } d = half(z - w); if (e > 0 && d < 2 * e) { d = half(z - w - e); if (p != null && type(p) == GLUE_NODE) { d = 0; } } tail_append(new_penalty(pre_display_penalty)); if (d + s <= pre_display_size || l) { g1 = ABOVE_DISPLAY_SKIP_CODE; g2 = BELOW_DISPLAY_SKIP_CODE; } else { g1 = ABOVE_DISPLAY_SHORT_SKIP_CODE; g2 = BELOW_DISPLAY_SHORT_SKIP_CODE; } if (l && e == 0) { shift_amount(a) = s; append_to_vlist(a); tail_append(new_penalty(INF_PENALTY)); } else { tail_append(new_param_glue(g1)); } if (e != 0) { r = new_kern(z - w - e - d); if (l) { link(a) = r; link(r) = b; b = a; d = 0; } else { link(b) = r; link(r) = a; } b = hpack(b, 0, ADDITIONAL); } shift_amount(b) = s + d; append_to_vlist(b); if (a != null && e == 0 && !l) { tail_append(new_penalty(INF_PENALTY)); shift_amount(a) = s + z - box_width(a); append_to_vlist(a); g2 = 0; } if (t != tex::adjust_head) { link(tail) = link(tex::adjust_head); tail = t; } tail_append(new_penalty(post_display_penalty)); if (g2 > 0) { tail_append(new_param_glue(g2)); } resume_after_display(); } }
void tex::init_math () { fnt f; int m, n; ptr p, q; scal d, l, s, v, w; get_token(); if (cur_cmd == MATH_SHIFT && mode > 0) { if (head == tail) { pop_nest(); w = -MAX_DIMEN; } else { line_break(display_widow_penalty); v = shift_amount(just_box) + 2 * quad(cur_font); w = -MAX_DIMEN; p = list_ptr(just_box); while (p != null) { reswitch: if (is_char_node(p)) { f = font(p); d = char_width(f, char_info(f, character(p))); goto found; } switch (type(p)) { case HLIST_NODE: case VLIST_NODE: case RULE_NODE: d = box_width(p); goto found; case LIGATURE_NODE: p = make_char_from_lig(p); goto reswitch; case KERN_NODE: d = kern_width(p); break; case MATH_NODE: d = box_width(p); break; case GLUE_NODE: q = glue_ptr(p); d = box_width(q); if (glue_sign(just_box) == STRETCHING) { if (glue_order(just_box) == stretch_order(q) && stretch(q) != 0) v = MAX_DIMEN; } else if (glue_sign(just_box) == SHRINKING) { if (glue_order(just_box) == shrink_order(q) && shrink(q) != 0) v = MAX_DIMEN; } if (subtype(p) >= A_LEADERS) goto found; break; case WHATSIT_NODE: d = 0; break; default: d = 0; break; } if (v < MAX_DIMEN) v += d; goto not_found; found: if (v < MAX_DIMEN) { v += d; w = v; } else { w = MAX_DIMEN; break; } not_found: p = link(p); } } if (par_shape_ptr == null) { if (hang_indent != 0 && (hang_after >= 0 && prev_graf + 2 > hang_after || prev_graf + 1 < -hang_after)) { l = hsize - abs(hang_indent); s = (hang_indent > 0) ? hang_indent : 0; } else { l = hsize; s = 0; } } else { n = info(par_shape_ptr); if (prev_graf + 2 >= n) m = n; else m = prev_graf + 2; l = par_shape_width(m); s = par_shape_indent(m); } push_math(MATH_SHIFT_GROUP); mode = MMODE; reg_define(int_reg[CUR_FAM_CODE], INT_REG, -1); reg_define(dimen_reg[PRE_DISPLAY_SIZE_CODE], DIMEN_REG, w); reg_define(dimen_reg[DISPLAY_WIDTH_CODE], DIMEN_REG, l); reg_define(dimen_reg[DISPLAY_INDENT_CODE], DIMEN_REG, s); if (every_display != null) begin_token_list(every_display, EVERY_DISPLAY_TEXT); if (nest_ptr == nest + 1) build_page(); } else { back_input(); push_math(MATH_SHIFT_GROUP); reg_define(int_reg[CUR_FAM_CODE], INT_REG, -1); if (every_math != null) begin_token_list(every_math, EVERY_MATH_TEXT); } }