Skip to content

Commit 2757b10

Browse files
committed
split need.fs into provides.fs
1 parent ac05d3b commit 2757b10

File tree

5 files changed

+101
-50
lines changed

5 files changed

+101
-50
lines changed

minos2/bidi.fs

+3-1
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,10 @@
2020

2121
\ Description: https://unicode.org/reports/tr9/
2222

23+
require set-compsem.fs
24+
[IFDEF] <provides <provides [THEN]
2325
require unicode/bidi-db.fs
2426
require unicode/brackets.fs
25-
require set-compsem.fs
2627

2728
: (b') ( "name" -- n )
2829
parse-name [: ." .." type ;] $tmp
@@ -550,3 +551,4 @@ Defer skip-bidi? ' (skip-bidi?) is skip-bidi?
550551
x1-rest x1-start bidi-rest ;
551552

552553
previous
554+
[IFDEF] provides> provides> [THEN]

minos2/ftgl-helper.fs

+2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
require unix/freetype_gl.fs
2424
require unix/harfbuzz.fs
2525

26+
debug: time( \ +db time( \ )
27+
2628
also freetype-gl
2729
also opengl
2830

minos2/widgets.fs

+14-11
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,24 @@
2121
\ A MINOS2 widget is composed of drawable elements, boxes and actors.
2222
\ to make things easier, neither drawable elements nor boxes need an actor.
2323

24-
debug: time( \ +db time( \ )
25-
debug: gui( \ +db gui( \ )
26-
debug: click( \ +db click( \ )
27-
debug: click-o( \ +db click-o( \ )
28-
debug: resize( \ +db resize( \ )
29-
debug: dispose( \ +db dispose( \ )
24+
require ../i18n.fs \ localization
25+
require ../mini-oof2.fs
26+
require ../config.fs
27+
require gl-terminal.fs
28+
require ftgl-helper.fs
29+
30+
[IFDEF] <provides <provides [THEN]
3031

3132
[IFUNDEF] no-file#
3233
2 Constant ENOENT
3334
#-512 ENOENT - Constant no-file#
3435
[THEN]
3536

36-
require ../i18n.fs \ localization
37-
require gl-terminal.fs
38-
require ftgl-helper.fs
39-
require ../mini-oof2.fs
40-
require ../config.fs
37+
debug: gui( \ +db gui( \ )
38+
debug: click( \ +db click( \ )
39+
debug: click-o( \ +db click-o( \ )
40+
debug: resize( \ +db resize( \ )
41+
debug: dispose( \ +db dispose( \ )
4142

4243
Variable minos2-debug$
4344
${MINOS2_DEBUGS} minos2-debug$ $!
@@ -1917,3 +1918,5 @@ previous
19171918

19181919
previous previous previous
19191920
set-current
1921+
1922+
[IFDEF] provides> provides> [THEN]

need.fs

+14-38
Original file line numberDiff line numberDiff line change
@@ -18,42 +18,13 @@
1818
\ You should have received a copy of the GNU General Public License
1919
\ along with this program. If not, see http://www.gnu.org/licenses/.
2020

21-
\ create database for what sources provide
22-
23-
2variable last-loadfilename
24-
0 Value provides.fd
25-
26-
: provides-header ( -- )
27-
provides.fd 0= latest 0= or get-current >voc xt? 0= or ?EXIT
28-
[: sourcefilename last-loadfilename 2@ d<>
29-
IF
30-
sourcefilename last-loadfilename 2!
31-
cr sourcefilename type ':' emit
32-
THEN
33-
space
34-
get-current forth-wordlist <> IF
35-
get-current >voc name>string type ':' emit
36-
THEN
37-
latest name>string type
38-
;] provides.fd outfile-execute ;
39-
40-
: provides-file ( -- addr u )
41-
${XDG_DATA_HOME} dup 0= IF 2drop "~/.local/share" THEN
42-
[: type ." /gforth/provides" ;] $tmp ;
43-
44-
\ to generate the database, call
45-
\ gforth need.fs -e 'provides' <files>
46-
\ and to add more infos to the data base
47-
\ gforth need.fs -e 'provides+' <more-files>
48-
49-
: provides ( -- )
50-
provides-file w/o create-file throw to provides.fd
51-
['] provides-header IS header-extra ;
52-
: provides+ ( -- )
53-
provides-file w/o open-file throw to provides.fd
54-
['] provides-header IS header-extra ;
55-
56-
\ read said database matching need query
21+
\ read povides database matching need query
22+
23+
[IFUNDEF] provides-file
24+
: provides-file ( -- addr u )
25+
${XDG_DATA_HOME} dup 0= IF 2drop "~/.local/share" THEN
26+
[: type ." /gforth/provides" ;] $tmp ;
27+
[THEN]
5728

5829
$[]variable $need[]
5930
$[]variable $require[]
@@ -84,11 +55,16 @@ $Variable last-require
8455
: checkneeds ( addr u -- nt )
8556
rec-checkneeds dup IF drop THEN ;
8657

87-
: read-needs ( -- )
88-
provides-file r/o open-file throw
58+
: (read-needs) ( fd -- )
8959
[: ['] rec-needs ['] forth-recognize ['] read-loop wrap-xt ;]
9060
execute-parsing-file ;
9161

62+
: read-needs ( -- )
63+
"provides" [: ofile $@ r/o open-file
64+
IF drop ELSE (read-needs) THEN false ;]
65+
fpath execute-path-file
66+
provides-file r/o open-file throw (read-needs) ;
67+
9268
: parse-needs ( "need1" .. "needn" "close-paren" -- )
9369
BEGIN parse-name 2dup ")" str= 0= WHILE
9470
dup 0= IF

provides.fs

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
\ need database generator
2+
3+
\ Authors: Bernd Paysan
4+
\ Copyright (C) 2024 Free Software Foundation, Inc.
5+
6+
\ This file is part of Gforth.
7+
8+
\ Gforth is free software; you can redistribute it and/or
9+
\ modify it under the terms of the GNU General Public License
10+
\ as published by the Free Software Foundation, either version 3
11+
\ of the License, or (at your option) any later version.
12+
13+
\ This program is distributed in the hope that it will be useful,
14+
\ but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
\ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
\ GNU General Public License for more details.
17+
18+
\ You should have received a copy of the GNU General Public License
19+
\ along with this program. If not, see http://www.gnu.org/licenses/.
20+
21+
\ create database for what sources provide
22+
23+
2variable last-provider
24+
2variable provider-file
25+
0 Value provides.fd
26+
27+
: <provides ( -- ) ." <provides " sourcefilename type cr
28+
sourcefilename provider-file 2! ;
29+
: provides> ( -- ) ." provides>" cr #0. provider-file 2! ;
30+
: source-provider ( -- addr u )
31+
provider-file 2@ 2dup d0= IF 2drop sourcefilename THEN ;
32+
33+
[IFUNDEF] provides-file
34+
: provides-file ( -- addr u )
35+
${XDG_DATA_HOME} dup 0= IF 2drop "~/.local/share" THEN
36+
[: type ." /gforth/provides" ;] $tmp ;
37+
[THEN]
38+
39+
: provides-header ( -- )
40+
provides.fd 0= latest 0= or get-current >voc xt? 0= or ?EXIT
41+
[: source-provider last-provider 2@ d<>
42+
IF
43+
source-provider last-provider 2!
44+
cr source-provider type ':' emit
45+
THEN
46+
space
47+
get-current forth-wordlist <> IF
48+
get-current >voc name>string type ':' emit
49+
THEN
50+
latest name>string type
51+
;] provides.fd outfile-execute ;
52+
53+
: provides-file ( -- addr u )
54+
${GFORTH_PROVIDES} dup ?EXIT
55+
${XDG_DATA_HOME} dup 0= IF 2drop "~/.local/share" THEN
56+
[: type ." /gforth/provides" ;] $tmp ;
57+
58+
\ to generate the database, call
59+
\ gforth need.fs -e 'provides' <files>
60+
\ and to add more infos to the data base
61+
\ gforth need.fs -e 'provides+' <more-files>
62+
63+
: provides ( -- )
64+
provides-file w/o create-file throw to provides.fd
65+
['] provides-header IS header-extra ;
66+
: provides+ ( -- )
67+
provides-file w/o open-file throw to provides.fd
68+
['] provides-header IS header-extra ;

0 commit comments

Comments
 (0)