From e76ba67cbf6f9c77581f26da1632fe26ad6ccee9 Mon Sep 17 00:00:00 2001 From: slava Date: Fri, 19 May 2006 19:53:30 +0000 Subject: [PATCH] Minor alien fixes --- TODO.FACTOR.txt | 25 ++++++++++--------- library/compiler/alien/c-types.factor | 5 +--- library/compiler/alien/primitive-types.factor | 5 ---- library/compiler/alien/structs.factor | 14 +++++++++-- 4 files changed, 26 insertions(+), 23 deletions(-) diff --git a/TODO.FACTOR.txt b/TODO.FACTOR.txt index 684c4d6eaf..f2303bb497 100644 --- a/TODO.FACTOR.txt +++ b/TODO.FACTOR.txt @@ -1,12 +1,8 @@ - remove F_USERENV rel -- method ordering and interpreter algorithm sections need updates - update walker for new interpreter - quotations should store their originating word - core foundation should use unicode strings - alien>utf16-string, utf16-string>alien words -- can only be called with an alien? -- remove , , set-char*-nth, set-ushort*-nth since they - have incorrect semantics - fix compiled gc check - 3 >n fep - code walker & exceptions @@ -22,6 +18,19 @@ - yield in a loop starves i/o - "localhost" 50 won't fail ++ help: + +- method ordering and interpreter algorithm sections need updates +- document that can only be called with an alien +- help search +- fix remaining HTML stream issues +- automatically update help graph when adding/removing articles/words +- document conventions +- new turtle graphics tutorial +- better line spacing in ui and html +- tabular formatting - for inspector, changes and $values in help +- grid layout + + ui/help: - implement handlers for open, quit events, and whatever else @@ -33,7 +42,6 @@ - speed up ideas: - only do clipping for certain gadgets - use glRect -- help search - reimplement tab completion - x11 input methods - x11 title bars are funny @@ -45,14 +53,7 @@ - saving the image should save window configuration - make the UI look better, something like this: http://twb.ath.cx/~twb/darcs/OBSOLETE/factor/final.html -- fix remaining HTML stream issues - fix up the min thumb size hack -- automatically update help graph when adding/removing articles/words -- document conventions -- new turtle graphics tutorial -- better line spacing in ui and html -- tabular formatting - for inspector, changes and $values in help -- grid layout - variable width word wrap + compiler/ffi: diff --git a/library/compiler/alien/c-types.factor b/library/compiler/alien/c-types.factor index a162521da2..b9afbe4c0e 100644 --- a/library/compiler/alien/c-types.factor +++ b/library/compiler/alien/c-types.factor @@ -7,8 +7,6 @@ parser sequences strings words ; : ( -- type ) H{ - { "setter" [ "Cannot read struct fields with type" throw ] } - { "getter" [ "Cannot write struct fields with type" throw ] } { "boxer" [ "boxer-function" get %box ] } { "unboxer" [ "unboxer-function" get %unbox ] } { "reg-class" T{ int-regs f } } @@ -77,8 +75,7 @@ SYMBOL: c-types [ define-c-type ] keep "alien" 2dup init-c-type 2dup define-deref - 2dup define-set-nth - define-out ; + over c-setter [ 2dup define-set-nth define-out ] when ; : typedef ( old new -- ) over "*" append over "*" append (typedef) (typedef) ; diff --git a/library/compiler/alien/primitive-types.factor b/library/compiler/alien/primitive-types.factor index f2415f36d7..f33ac24acc 100644 --- a/library/compiler/alien/primitive-types.factor +++ b/library/compiler/alien/primitive-types.factor @@ -103,10 +103,6 @@ USING: alien compiler kernel kernel-internals math namespaces ; [ [ alien-unsigned-cell alien>string ] "getter" set - [ - >r >r string>alien alien-address r> r> - set-alien-unsigned-cell - ] "setter" set bootstrap-cell "width" set bootstrap-cell "align" set "box_c_string" "boxer-function" set @@ -115,7 +111,6 @@ USING: alien compiler kernel kernel-internals math namespaces ; [ [ alien-unsigned-4 ] "getter" set - [ set-alien-unsigned-4 ] "setter" set bootstrap-cell "width" set bootstrap-cell "align" set "box_utf16_string" "boxer-function" set diff --git a/library/compiler/alien/structs.factor b/library/compiler/alien/structs.factor index bc80992512..5c302db4a0 100644 --- a/library/compiler/alien/structs.factor +++ b/library/compiler/alien/structs.factor @@ -7,15 +7,25 @@ sequences strings words ; ! Some code for interfacing with C structures. +: c-getter* ( name -- quot ) + c-getter [ + [ "Cannot read struct fields with type" throw ] + ] unless* ; + : define-getter ( offset type name -- ) #! Define a word with stack effect ( alien -- obj ) in the #! current 'in' vocabulary. - create-in >r c-getter swap add* r> swap define-compound ; + create-in >r c-getter* swap add* r> swap define-compound ; + +: c-setter* ( name -- quot ) + c-setter [ + [ "Cannot write struct fields with type" throw ] + ] unless* ; : define-setter ( offset type name -- ) #! Define a word with stack effect ( obj alien -- ) in the #! current 'in' vocabulary. - "set-" swap append create-in >r c-setter swap add* r> + "set-" swap append create-in >r c-setter* swap add* r> swap define-compound ; : define-field ( offset type name -- offset )