blob: a38ead0dd9f34bb3083e52642789ace003819dd9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
#!/bin/sh
#
# mkfunc libname file.o ...
#
# looks at the corresponding C files and generates an Icon procedure
# corresponding to each C function header that matches the pattern below.
#
# If a function name begins with "icon_", those characters are removed
# to form the procedure name. Otherwise, the name is copied verbatim.
LIB=${1?"usage: $0 libname obj..."}
shift
cat <<ENDHDR
############################################################################
#
# File: cfunc.icn
#
# Subject: Procedures implemented in C
#
# Author: Gregg M. Townsend
#
# Date: June 8, 2001
#
############################################################################
#
# These Icon procedures transparently load and execute functions
# implemented in C. Each procedure is a simple stub. The first call
# to a stub causes it to replace itself with the corresponding
# dynamically loaded C function, after which the C function processes
# the arguments and returns a result (or fails). Subsequent calls
# go straight to the C function without involving the Icon stub.
#
# C functions are loaded from a file "$LIB" that is found by
# searching \$FPATH. The default \$FPATH is set by iconx to include
# this library.
#
############################################################################
#
# Requires: Dynamic loading
#
############################################################################
# DO NOT EDIT THIS FILE DIRECTLY.
# It was created mechanically by the shell file "$0".
# Edit that instead.
link io
\$define LIB "$LIB"
ENDHDR
LC_ALL=POSIX
export LC_ALL
for i
do
FNAME=`basename $i .o`
echo ""
echo "# $FNAME.c:"
sed '
s/ / /g
s/^int *//
/^[a-z][a-z0-9_]* *(.*argc.*argv.*).*\/\*:.*\*\//!d
s/\([a-z0-9_]*\).*)\(.*\)$/\1(a[])\2@ return(\1:=pathload(LIB,"\1"))!a;end/
s/^[a-z]/procedure &/
s/\([^"]\)icon_/\1/g
s/)[ ]*\/\*\(.*\)\*\/.*@/) #\1@/
' $FNAME.c | tr '@' '\012'
done
echo ""
echo "#---"
|