]> gitweb.factorcode.org Git - factor.git/commitdiff
Merge branch 'master' into c-type-words
authorJoe Groff <arcata@gmail.com>
Wed, 16 Sep 2009 00:14:41 +0000 (19:14 -0500)
committerJoe Groff <arcata@gmail.com>
Wed, 16 Sep 2009 00:14:41 +0000 (19:14 -0500)
1  2 
basis/alien/arrays/arrays.factor
basis/alien/c-types/c-types.factor
basis/alien/structs/structs.factor
basis/cpu/x86/64/unix/unix.factor

index 86d6c2d49bb35b2ae17d048af0f00cfdc5390409,a69f7609b1847ad54f89ae83148d63ed7d11be7c..52c6afa4dfdd60ae1bf478f1e7b462b210373033
@@@ -40,17 -40,8 +40,8 @@@ M: array c-type-boxer-quo
  
  M: array c-type-unboxer-quot drop [ >c-ptr ] ;
  
- M: value-type c-type-rep drop int-rep ;
- M: value-type c-type-getter
-     drop [ swap <displaced-alien> ] ;
- M: value-type c-type-setter ( type -- quot )
-     [ c-type-getter ] [ c-type-unboxer-quot ] [ heap-size ] tri
-     '[ @ swap @ _ memcpy ] ;
  PREDICATE: string-type < pair
 -    first2 [ "char*" = ] [ word? ] bi* and ;
 +    first2 [ char* = ] [ word? ] bi* and ;
  
  M: string-type c-type ;
  
index 553ff264431bc30ed8a4a1df1cd8f6334c3fe085,35a9627d503b63c9474c6dbd7a12a86a2a20be50..71073ddc91386f1a95b69bd8610713da9e3119f8
@@@ -81,24 -58,26 +81,31 @@@ M: string resolve-pointer-typ
  
  : parse-array-type ( name -- array )
      "[" split unclip
 -    [ [ "]" ?tail drop string>number ] map ] dip prefix ;
 +    [ [ "]" ?tail drop string>number ] map ] dip
 +    parse-c-type-name prefix ;
 +
 +: parse-c-type ( string -- array )
 +    {
 +        { [ CHAR: ] over member?    ] [ parse-array-type ] }
 +        { [ dup search c-type-word? ] [ parse-c-type-name resolve-typedef ] }
 +        { [ dup c-types get at      ] [ c-types get at resolve-typedef ] }
 +        { [ "*" ?tail               ] [ parse-c-type-name resolve-pointer-type ] }
 +        [ no-c-type ]
 +    } cond ;
  
  M: string c-type ( name -- type )
 -    CHAR: ] over member? [
 -        parse-array-type
 -    ] [
 -        dup c-types get at [
 -            resolve-typedef
 -        ] [
 -            "*" ?tail [ resolve-pointer-type ] [ no-c-type ] if
 -        ] ?if
 -    ] if ;
 +    parse-c-type ;
 +
 +M: word c-type
 +    "c-type" word-prop resolve-typedef ;
  
+ GENERIC: c-struct? ( type -- ? )
+ M: object c-struct?
+     drop f ;
+ M: string c-struct?
+     dup "void" = [ drop f ] [ c-type c-struct? ] if ;
  ! These words being foldable means that words need to be
  ! recompiled if a C type is redefined. Even so, folding the
  ! size facilitates some optimizations.
Simple merge
index 1088f2017591bc749da829dbe8155e36373e6c89,17cc0e3f8042ff40274cad621b243f790585aa52..2f8a01f0fe76991f964031d4407b5aadb37fadbe
@@@ -37,9 -38,9 +39,9 @@@ stack-params \ (stack-value) c-type (>>
  
  : flatten-large-struct ( c-type -- seq )
      heap-size cell align
 -    cell /i "__stack_value" c-type <repetition> ;
 +    cell /i \ (stack-value) c-type <repetition> ;
  
M: struct-type flatten-value-type ( type -- seq )
: flatten-struct ( c-type -- seq )
      dup heap-size 16 > [
          flatten-large-struct
      ] [