FFI:\r
- is signed -vs- unsigned pointers an issue?\r
- bitfields in C structs\r
-- unsigned types\r
- SDL_Rect** type\r
- struct membres that are not *\r
- float types\r
+- SDL_MapRGB broken\r
\r
- command line parsing cleanup\r
- > 1 ( ) inside word def\r
+- parsing-word test fails\r
\r
- when* compilation in jvm\r
- compile word twice; no more 'cannot compile' error!\r
: END-UNION ( max -- )
dup define-constructor define-struct-type ; parsing
+: NULL ( -- null )
+ #! C null value.
+ 0 <alien> ;
+
global [ <namespace> "c-types" set ] bind
[
[ alien-4 ] "getter" set
[ set-alien-4 ] "setter" set
4 "width" set
- "box_integer" "boxer" set
- "unbox_integer" "unboxer" set
+ "box_cell" "boxer" set
+ "unbox_cell" "unboxer" set
] "uint" define-c-type
[
[ alien-2 ] "getter" set
[ set-alien-2 ] "setter" set
2 "width" set
- "box_integer" "boxer" set
- "unbox_integer" "unboxer" set
+ "box_signed_2" "boxer" set
+ "unbox_signed_2" "unboxer" set
] "short" define-c-type
[
[ alien-2 ] "getter" set
[ set-alien-2 ] "setter" set
2 "width" set
- "box_integer" "boxer" set
- "unbox_integer" "unboxer" set
+ "box_cell" "boxer" set
+ "unbox_cell" "unboxer" set
] "ushort" define-c-type
[
[ alien-1 ] "getter" set
[ set-alien-1 ] "setter" set
1 "width" set
- "box_integer" "boxer" set
- "unbox_integer" "unboxer" set
+ "box_signed_1" "boxer" set
+ "unbox_signed_1" "unboxer" set
] "char" define-c-type
[
[ alien-1 ] "getter" set
[ set-alien-1 ] "setter" set
1 "width" set
- "box_integer" "boxer" set
- "unbox_integer" "unboxer" set
+ "box_cell" "boxer" set
+ "unbox_cell" "unboxer" set
] "uchar" define-c-type
[
2dup < [ drop ] [ nip ] ifte ;
: between? ( x min max -- ? )
- #! Push if min <= x <= max.
- >r dupd max r> min = ;
+ #! Push if min <= x <= max. Handles case where min > max
+ #! by swapping them.
+ 2dup > [ swap ] when >r dupd max r> min = ;
: sq dup * ; inline
: f f parsed ; parsing
! Lists
-: [ [ ] ; parsing
+: [ f ; parsing
: ] reverse parsed ; parsing
: | ( syntax: | cdr ] )
: define-compound ( word def -- )
over set-word-parameter
+ ( dup f "parsing" set-word-property )
1 swap set-word-primitive ;
: define-symbol ( word -- )
! SDL_HAT_LEFT SDL_HAT_CENTERED SDL_HAT_RIGHT
! SDL_HAT_LEFTDOWN SDL_HAT_DOWN SDL_HAT_RIGHTDOWN
! Note that zero means the POV is centered.
-END-STRUCT
+END-STRUCT
BEGIN-STRUCT: joy-button-event
FIELD: uchar type ! SDL_JOYBUTTONDOWN or SDL_JOYBUTTONUP
! SDL_SetGamma: float types
: SDL_FillRect ( surface rect color -- n )
+ #! If rect is null, fills entire surface.
"int" "sdl" "SDL_FillRect"
- [ "surface*" "rect*" "unint" ] alien-call ;
+ [ "surface*" "rect*" "uint" ] alien-call ;
: SDL_LockSurface ( surface -- )
"int" "sdl" "SDL_LockSurface" [ "surface*" ] alien-call ;
"void" "sdl" "SDL_UnlockSurface" [ "surface*" ] alien-call ;
: SDL_MapRGB ( surface r g b -- )
- "int" "sdl" "SDL_MapRGB"
- [ "surface*" "char" "char" "char" ] alien-call ;
+ "uint" "sdl" "SDL_MapRGB"
+ [ "surface*" "uchar" "uchar" "uchar" ] alien-call ;
USE: stack
USE: test
+[ slip ] unit-test-fails
+[ 1 slip ] unit-test-fails
+[ 1 2 slip ] unit-test-fails
+[ 1 2 3 slip ] unit-test-fails
+
[ 5 ] [ [ 2 2 + ] 1 slip + ] unit-test
[ 6 ] [ [ 2 2 + ] 1 1 2slip + + ] unit-test
[ 6 ] [ [ 2 1 + ] 1 1 1 3slip + + + ] unit-test
+[ [ ] keep ] unit-test-fails
+
[ 6 ] [ 2 [ sq ] keep + ] unit-test
+[ cond ] unit-test-fails
+[ [ [ 1 = ] [ ] ] cond ] unit-test-fails
+
[ ] [ 3 [ ] cond ] unit-test
[ t ] [ 4 [ [ 1 = ] [ ] [ 4 = ] [ drop t ] [ 2 = ] [ ] ] cond ] unit-test
--- /dev/null
+IN: scratchpad
+
+USE: parser
+USE: test
+
+DEFER: foo
+
+": foo 2 2 + . ; parsing" eval
+
+[ [ ] ] [ "foo" parse ] unit-test
+
+": foo 2 2 + . ;" eval
+
+[ [ foo ] ] [ "foo" parse ] unit-test
"crashes" test
"sbuf" test
"threads" test
+ "parsing-word" test
cpu "x86" = [
[
dpush(tag_integer(integer));
}
+/* FFI calls this */
+void box_cell(CELL cell)
+{
+ dpush(tag_cell(cell));
+}
+
/* FFI calls this */
FIXNUM unbox_integer(void)
{
return to_integer(dpop());
}
+/* FFI calls this */
+CELL unbox_cell(void)
+{
+ return to_integer(dpop());
+}
+
ARRAY* to_bignum(CELL tagged)
{
RATIO* r;
FIXNUM to_integer(CELL x);
void box_integer(FIXNUM integer);
+void box_cell(CELL cell);
FIXNUM unbox_integer(void);
+CELL unbox_cell(void);
ARRAY* to_bignum(CELL tagged);
void primitive_to_bignum(void);
void primitive_bignum_eq(void);
{
#ifdef FFI
CELL ptr = alien_pointer();
- box_integer(*(CHAR*)ptr);
+ box_signed_2(*(CHAR*)ptr);
#else
general_error(ERROR_FFI_DISABLED,F);
#endif
{
#ifdef FFI
CELL ptr = alien_pointer();
- CELL value = unbox_integer();
+ CELL value = unbox_signed_2();
*(CHAR*)ptr = value;
#else
general_error(ERROR_FFI_DISABLED,F);
void primitive_alien_1(void)
{
#ifdef FFI
- box_integer(bget(alien_pointer()));
+ box_signed_1(bget(alien_pointer()));
#else
general_error(ERROR_FFI_DISABLED,F);
#endif
{
#ifdef FFI
CELL ptr = alien_pointer();
- BYTE value = value = unbox_integer();
+ BYTE value = value = unbox_signed_1();
bput(ptr,value);
#else
general_error(ERROR_FFI_DISABLED,F);
{
drepl(tag_fixnum(~to_fixnum(dpeek())));
}
+
+/* FFI calls this */
+void box_signed_1(signed char integer)
+{
+ dpush(tag_integer(integer));
+}
+
+/* FFI calls this */
+void box_signed_2(signed short integer)
+{
+ dpush(tag_integer(integer));
+}
+
+/* FFI calls this */
+signed char unbox_signed_1(void)
+{
+ return to_integer(dpop());
+}
+
+/* FFI calls this */
+signed short unbox_signed_2(void)
+{
+ return to_integer(dpop());
+}
void primitive_fixnum_greater(void);
void primitive_fixnum_greatereq(void);
void primitive_fixnum_not(void);
+void box_signed_1(signed char integer);
+void box_signed_2(signed short integer);
+signed char unbox_signed_1(void);
+signed short unbox_signed_2(void);