inline unsigned int check_ub32(Value value) { #ifdef __x86_64__ if (fixnump(value)) { long n = xlong(value); if (n >= 0 && n < 4294967296) return (unsigned int) n; } #else // 32-bit Lisp if (fixnump(value)) { long n = xlong(value); if (n >= 0) return (unsigned int) n; } else if (bignump(value)) { Bignum * b = the_bignum(value); if (mpz_sgn(b->_z) >= 0 && mpz_fits_ulong_p(b->_z)) return mpz_get_ui(b->_z); } #endif signal_type_error(value, UB32_TYPE); // not reached return 0; }
Value SimpleArray_UB16_1::aset(INDEX i, Value new_value) { if (i >= _capacity) return bad_index(i); if (fixnump(new_value)) { long n = xlong(new_value); if (n >= 0 && n < 65536) { _data[i] = (unsigned short) n; return new_value; } } return signal_type_error(new_value, UB16_TYPE); }
// ### fasl-sharp-r stream sub-char numarg => value Value SYS_fasl_sharp_r(Value streamarg, Value subchar, Value numarg) { if (ansi_stream_p(streamarg)) { AnsiStream * stream = check_ansi_stream(streamarg); Thread * thread = current_thread(); if (fixnump(numarg)) { long radix = xlong(numarg); if (radix >= 2 && radix <= 36) return stream_read_radix(streamarg, radix, thread, FASL_READTABLE); } // illegal radix while (true) { int n = stream->read_char(); if (n < 0) break; BASE_CHAR c = (BASE_CHAR) n; unsigned int syntax = FASL_READTABLE->syntax(c); if (syntax == SYNTAX_TYPE_WHITESPACE || syntax == SYNTAX_TYPE_TERMINATING_MACRO) { stream->unread_char(c); break; } } if (thread->symbol_value(S_read_suppress) != NIL) return NIL; String * string = new String("Illegal radix for #R: "); string->append(::prin1_to_string(numarg)); return signal_lisp_error(new ReaderError(stream, string)); } else { // fundamental-stream return signal_lisp_error("FaslReadtable::SYS_fasl_sharp_r needs code!"); } }
// ### digit-char weight &optional radix => char Value CL_digit_char(unsigned int numargs, Value args[]) { if (numargs < 1 || numargs > 2) return wrong_number_of_arguments(S_digit_char_p, numargs, 1, 2); if (indexp(args[0])) { unsigned long weight = xlong(args[0]); unsigned long radix; if (numargs == 2) radix = check_index(args[1], 2, 36); else radix = 10; if (weight >= radix) return NIL; else if (weight < 10) return make_character('0' + weight); else return make_character('A' + weight - 10); } if (bignump(args[0]) && !the_bignum(args[0])->minusp()) return NIL; return signal_type_error(args[0], S_unsigned_byte); }
Value RandomState::random(Value arg) { if (fixnump(arg)) { long n = xlong(arg); if (n > 0) { mpz_t limit; mpz_init_set_si(limit, n); mpz_t result; mpz_init(result); mpz_urandomm(result, _state, limit); return normalize(result); } } else if (bignump(arg)) { Bignum * b = the_bignum(arg); if (b->plusp()) { mpz_t result; mpz_init(result); mpz_urandomm(result, _state, b->_z); return normalize(result); } } else if (single_float_p(arg)) { float f = the_single_float(arg)->_f; if (f > 0) { mpz_t fixnum_limit; mpz_init_set_si(fixnum_limit, MOST_POSITIVE_FIXNUM); mpz_t fixnum_result; mpz_init(fixnum_result); mpz_urandomm(fixnum_result, _state, fixnum_limit); double double_result = mpz_get_si(fixnum_result); double_result /= MOST_POSITIVE_FIXNUM; return make_value(new SingleFloat(double_result * f)); } } else if (double_float_p(arg)) { double d = the_double_float(arg)->_d; if (d > 0) { mpz_t fixnum_limit; mpz_init_set_si(fixnum_limit, MOST_POSITIVE_FIXNUM); mpz_t fixnum_result; mpz_init(fixnum_result); mpz_urandomm(fixnum_result, _state, fixnum_limit); double double_result = mpz_get_si(fixnum_result); double_result /= MOST_POSITIVE_FIXNUM; return make_value(new DoubleFloat(double_result * d)); } } return signal_type_error(arg, list3(S_or, list2(S_integer, list1(FIXNUM_ZERO)), list2(S_float, list1(FIXNUM_ZERO)))); }
void ScreenCamView::OnSize( wxSizeEvent &event ) { // This is called early, so if pDocView is null do nothing if( NULL == pDocView ) return; SetCurrentStates(); Document* pCurDoc = Document::GetCurrent(); DocView* pCurView = DocView::GetCurrent(); // these lines are here to stop very strange things happening on exit under Win32s // when this fn gets called when it really shouldn't. I would like to really know // just what on earth os going on under Win32s but it iss something strange in message // handling as far as I can tell. wxSize size( event.GetSize() ); // Check for irrelevant or potty messages. if (size.x <= 0 || size.y <= 0) { // TRACEUSER( "JustinF", _T("Strange size msg in ScreenView::OnSize(0x%X, %d, %d)\n"), // nType, cx, cy); return; } // Handle OLE 2.0 in-place activation stuff. #if (_OLE_VER >= 0x200) if(GetDocument()) { COleClientItem* pActiveItem = GetDocument()->GetInPlaceActiveItem(this); if (pActiveItem) pActiveItem->SetItemRects(); } #endif if (Status->ScrollersVisible) { PORTNOTETRACE( "other", "ScreenCamView::OnSize - Removed scroller usage" ); #if !defined(EXCLUDE_FROM_XARALX) // Resize and reposition the proportional scrollers. wxRect hrect, vrect; HScrollBar->CalcPosFromParentClient(&hrect); UINT32 RulerWidth = OILRuler::GetWidth(); //if rulers are switched on the scroll bars are made // smaller to accomodate them if (Status->RulersVisible) hrect.left += RulerWidth; if (RULER_BORDERS) hrect.left-=2; HScrollBar->MoveWindow(&hrect, TRUE); VScrollBar->CalcPosFromParentClient(&vrect); if (Status->RulersVisible) vrect.top += RulerWidth; if (RULER_BORDERS) vrect.top-=2; VScrollBar->MoveWindow(&vrect, TRUE); // Reposition the corner window at the bottom-right. Corner->MoveWindow(vrect.left, hrect.top, vrect.Width(), hrect.Height()); // Resize/reposition the rendering window. CurrentSize.left = CurrentSize.top = 0; CurrentSize.right = cx - vrect.Width() + 1; CurrentSize.bottom = cy - hrect.Height() + 1; #endif } else { CurrentSize.x = CurrentSize.y = 0; CurrentSize.width = size.x; CurrentSize.height = size.y; } if (Status->RulersVisible) { PORTNOTETRACE( "other", "ScreenCamView::OnSize - Removed scroller / ruler usage" ); #if !defined(EXCLUDE_FROM_XARALX) wxRect hRect, vRect, oRect; HRuler->CalcPosFromParentClient(&hRect); HRuler->MoveWindow(&hRect, TRUE); HRuler->PositionLegend(); CurrentSize.top = 0 + hRect.Height() ; VRuler->CalcPosFromParentClient(&vRect); VRuler->MoveWindow(&vRect, TRUE); CurrentSize.left = 0 + vRect.Width(); OGadget->CalcPosFromParentClient(&oRect); OGadget->MoveWindow(&oRect, TRUE); if (RULER_BORDERS) { CurrentSize.top --; CurrentSize.left--; } #endif } PORTNOTE( "other", "ScreenCamView::OnSize - Removed RenderWindow usage -not sure if needed" ) #ifndef EXCLUDE_FROM_XARALX RenderWindow->MoveWindow(&CurrentSize, TRUE); #endif // Update the rest of the window placement information. UpdateViewPosition(); // Calculate the work area, page & line sizes etc etc. FIXED16 PixelWidth, PixelHeight; pDocView->GetPixelSize(&PixelWidth, &PixelHeight); PORTNOTE( "other", "ScreenCamView::OnSize - Removed scroller usage" ) #if !defined(EXCLUDE_FROM_XARALX) XLONG x1 = CurrentSize.GetWidth() * PixelWidth; XLONG x2 = CurrentSize.GetHeight() * PixelHeight; HScrollBar->SetPageSize(x1); VScrollBar->SetPageSize(x2); HScrollBar->SetLineSize(x1 / xlong(10) + xlong(1)); VScrollBar->SetLineSize(x2 / xlong(10) + xlong(1)); #endif SetWorkAreaExtent(Status->WorkAreaExtent, FALSE); // Make sure the scroll offsets are valid - if we resize the bottom of the window // when at the extreme bottom of the view, then the scroll offsets should be // changed - we use the scrollers' own integrity checks to do this automatically. // Don't do this until the setup flag is TRUE, so we don't overwrite scroll offsets // that have been reloaded. if (fSetupDone) { WorkCoord CurrScrollPos; GetScrollOffset(&CurrScrollPos); SetScrollOffset(CurrScrollPos, TRUE); } // Inform the associated DocView object that something has happened. pDocView->ViewStateChanged(); pCurDoc->SetCurrent(); pCurView->SetCurrent(); }
// ### %set-sbit1 simple-bit-vector index new-value => new-value Value SYS_xset_sbit1(Value arg1, Value arg2, Value arg3) { return the_simple_bit_vector(arg1)->inline_aset(xlong(arg2), arg3); }
// ### %sbit1 simple-bit-vector index => bit Value SYS_xsbit1(Value arg1, Value arg2) { return make_fixnum(the_simple_bit_vector(arg1)->inline_getbit(xlong(arg2))); }