version 1.10, 2007/04/09 10:26:35
|
version 1.11, 2007/04/25 17:59:36
|
Line 328 create gen-wrapped-types
|
Line 328 create gen-wrapped-types
|
\ addr points to the return type index of a c-function descriptor |
\ addr points to the return type index of a c-function descriptor |
dup { descriptor } |
dup { descriptor } |
c@+ { ret } count 2dup { d: pars } chars + count { d: c-name } |
c@+ { ret } count 2dup { d: pars } chars + count { d: c-name } |
print-c-prefix-lines |
|
." void " descriptor wrapper-function-name 2dup type drop free throw |
." void " descriptor wrapper-function-name 2dup type drop free throw |
.\" (void)\n" |
.\" (void)\n" |
.\" {\n Cell MAYBE_UNUSED *sp = gforth_SP;\n Float MAYBE_UNUSED *fp = gforth_FP;\n " |
.\" {\n Cell MAYBE_UNUSED *sp = gforth_SP;\n Float MAYBE_UNUSED *fp = gforth_FP;\n " |
Line 341 create gen-wrapped-types
|
Line 340 create gen-wrapped-types
|
endif |
endif |
.\" }\n" ; |
.\" }\n" ; |
|
|
|
variable c-source-file-id |
|
0 c-source-file-id ! |
|
|
|
: c-source-file ( -- file-id ) |
|
c-source-file-id @ ?dup-if |
|
exit |
|
endif |
|
s" xxx.c" w/o create-file throw dup c-source-file-id ! |
|
['] print-c-prefix-lines over outfile-execute ; |
|
|
: compile-wrapper-function ( -- ) |
: compile-wrapper-function ( -- ) |
|
c-source-file-id @ assert( dup ) |
|
close-file throw 0 c-source-file-id ! |
s" gcc -fPIC -shared -Wl,-soname,xxx.so.1 -Wl,-export_dynamic -o xxx.so.1 -O xxx.c" system |
s" gcc -fPIC -shared -Wl,-soname,xxx.so.1 -Wl,-export_dynamic -o xxx.so.1 -O xxx.c" system |
$? abort" compiler generated error" ; |
$? abort" compiler generated error" ; |
\ s" ar rcs xxx.a xxx.o" system |
\ s" ar rcs xxx.a xxx.o" system |
Line 358 create gen-wrapped-types
|
Line 369 create gen-wrapped-types
|
noname create 2, |
noname create 2, |
parse-name { d: c-name } |
parse-name { d: c-name } |
here parse-function-types c-name string, |
here parse-function-types c-name string, |
s" xxx.c" w/o create-file throw >r ( R:file-id ) |
['] gen-wrapper-function c-source-file outfile-execute |
['] gen-wrapper-function r@ outfile-execute |
|
r> close-file throw |
|
does> ( ... -- ... ) |
does> ( ... -- ... ) |
dup 2@ { xt-defer xt-cfr } |
dup 2@ { xt-defer xt-cfr } |
compile-wrapper-function |
compile-wrapper-function |
Line 413 s" Library not found" exception constant
|
Line 422 s" Library not found" exception constant
|
\ c-function void test6 -- void |
\ c-function void test6 -- void |
|
|
\c #include <string.h> |
\c #include <string.h> |
|
\c #include <stdlib.h> |
|
|
|
cr here hex. |
|
|
c-function strlen strlen a -- n |
c-function strlen strlen a -- n |
|
c-function labs labs n -- n |
|
|
cr s\" fooo\0" 2dup dump drop .s strlen cr .s cr |
cr s\" fooo\0" 2dup dump drop .s strlen cr .s drop cr |
|
\ -5 labs .s drop cr |