Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FEAT: switch pair! from integer! to float32! #4049

Open
wants to merge 21 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
FEAT: preliminary use float32! in pair!
  • Loading branch information
qtxie committed Sep 21, 2019
commit 2dda6e35cda1ce81df94f288c353650e2a486e36
2 changes: 1 addition & 1 deletion compiler.r
Original file line number Diff line number Diff line change
Expand Up @@ -1760,7 1760,7 @@ red: context [
]
]
pair? :value [
emit 'pair/push
emit 'pair/push-int
emit reduce [value/1 value/2]
insert-lf -3
]
Expand Down
21 changes: 13 additions & 8 deletions environment/console/CLI/win32.reds
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 208,6 @@ fd-read: func [
key [key-event!]
n [integer!]
keycode [integer!]
size [red-pair!]
][
n: 0
forever [
Expand Down Expand Up @@ -258,22 257,28 @@ get-window-size: func [
info [screenbuf-info!]
x-y [integer!]
size [red-pair!]
x [integer!]
y [integer!]
][
info: declare screenbuf-info!
size: as red-pair! #get system/console/size
size/x: 80 ;-- set defaults when working with stdout
size/y: 50 ; as many output funcs rely on it
columns: size/x
rows: size/y
x: 80 ;-- set defaults when working with stdout
y: 50
columns: x
rows: y
size/x: as-float32 x
size/y: as-float32 y
if zero? GetConsoleScreenBufferInfo stdout as-integer info [return -1]
x-y: info/Size
columns: FIRST_WORD(x-y)
rows: SECOND_WORD(x-y)
size/x: SECOND_WORD(info/top-right) - SECOND_WORD(info/attr-left) 1
size/y: FIRST_WORD(info/bottom-maxWidth) - FIRST_WORD(info/top-right) 1
if columns <= 0 [size/x: 80 columns: 80 return -1]
x: SECOND_WORD(info/top-right) - SECOND_WORD(info/attr-left) 1
y: FIRST_WORD(info/bottom-maxWidth) - FIRST_WORD(info/top-right) 1
if columns <= 0 [x: 80 columns: 80 return -1]
x-y: info/Position
base-y: SECOND_WORD(x-y)
size/x: as-float32 x
size/y: as-float32 y
0
]

Expand Down
10 changes: 5 additions & 5 deletions runtime/datatypes/image.reds
Original file line number Diff line number Diff line change
Expand Up @@ -344,8 344,8 @@ image: context [
idx: index/value
][ ;-- pair!
pair: as red-pair! index
x: pair/x
y: pair/y
x: as-integer pair/x
y: as-integer pair/y
if out-range <> null [
either base = 1 [
if any [x > w x <= 0 y > h y <= 0][out-range/value: 1]
Expand Down Expand Up @@ -432,9 432,9 @@ image: context [
default [return to proto spec type]
]

x: pair/x
x: as-integer pair/x
if negative? x [x: 0]
y: pair/y
y: as-integer pair/y
if negative? y [y: 0]
img/size: y << 16 or x
img/node: OS-image/make-image x y rgb alpha color
Expand Down Expand Up @@ -702,7 702,7 @@ image: context [
case [
sym = words/size [
if set? [fire [TO_ERROR(script invalid-path) path element]]
pair/push IMAGE_WIDTH(parent/size) IMAGE_HEIGHT(parent/size)
pair/push-int IMAGE_WIDTH(parent/size) IMAGE_HEIGHT(parent/size)
]
sym = words/argb [
either set? [
Expand Down
Loading