--- gforth/libcc.fs 2009/10/03 21:33:48 1.59 +++ gforth/libcc.fs 2009/10/18 17:52:50 1.61 @@ -251,13 +251,21 @@ variable c-prefix-lines-end c-prefix-lin : print-c-prefix-lines ( -- ) c-prefix-lines @ ['] print-c-prefix-line list-map ; -: save-c-prefix-line ( c-addr u -- ) - c-source-file-id @ ?dup-if - >r 2dup r> write-line throw - then +: write-c-prefix-line ( c-addr u -- ) + c-source-file-id @ dup if + write-line throw + else + drop 2drop + then ; + +: save-c-prefix-line1 ( c-addr u -- ) + 2dup write-c-prefix-line align here 0 , c-prefix-lines-end list-append ( c-addr u ) longstring, ; +defer save-c-prefix-line ( c-addr u -- ) +' save-c-prefix-line1 is save-c-prefix-line + : \c ( "rest-of-line" -- ) \ gforth backslash-c \G One line of C declarations for the C interface -1 parse save-c-prefix-line ; @@ -486,12 +494,12 @@ create gen-wrapped-types assert( c-source-file-id @ 0= ) { d: filename } here 0 , lib-handle-addr ! filename lib-filename 2! - filename basename lib-modulename 2! ; + filename basename lib-modulename 2! + ['] write-c-prefix-line is save-c-prefix-line ; : c-library-name-create ( -- ) lib-filename 2@ s" .c" s+ 2dup w/o create-file throw - dup c-source-file-id ! - ['] print-c-prefix-lines swap outfile-execute + c-source-file-id ! drop free throw ; : c-named-library-name ( c-addr u -- ) @@ -503,13 +511,16 @@ create gen-wrapped-types else libcc-named-dir $1ff mkdir-parents drop drop c-library-name-create + c-prefix-lines @ ['] print-c-prefix-line \ first line only + c-source-file-id @ outfile-execute endif ; : c-tmp-library-name ( c-addr u -- ) \ set up filenames for a new library; c-addr u is the basename of \ the library libcc-tmp-dir 2dup $1ff mkdir-parents drop - prepend-dirname c-library-name-setup c-library-name-create ; + prepend-dirname c-library-name-setup c-library-name-create + ['] print-c-prefix-lines c-source-file-id @ outfile-execute ; : lib-handle ( -- addr ) lib-handle-addr @ @ ; @@ -635,6 +646,7 @@ clear-libs : end-c-library ( -- ) \ gforth \G Finish and (if necessary) build the latest C library interface. + ['] save-c-prefix-line1 is save-c-prefix-line ['] compile-wrapper-function1 is compile-wrapper-function compile-wrapper-function1 ;