From 53d889ee38a097d7f86e1fe6d905172741db96ce Mon Sep 17 00:00:00 2001 From: Brad Nelson Date: Sat, 6 Feb 2021 19:50:36 -0800 Subject: [PATCH] Hide more. --- ueforth/Makefile | 5 ++-- ueforth/arduino/arduino_server.fs | 15 +++++++++--- ueforth/arduino/hide_io.fs | 30 ++++++++++++++++------- ueforth/common/boot.fs | 2 +- ueforth/common/hide_calls.fs | 6 ++--- ueforth/common/vocabulary.fs | 40 +++++++++++++++++-------------- ueforth/site/index.html | 1 + 7 files changed, 64 insertions(+), 35 deletions(-) diff --git a/ueforth/Makefile b/ueforth/Makefile index 45f3156..5bb750e 100644 --- a/ueforth/Makefile +++ b/ueforth/Makefile @@ -128,8 +128,9 @@ WINDOWS_BOOT = common/boot.fs common/vocabulary.fs common/hide_calls.fs common/a $(GEN)/windows_boot.h: common/source_to_string.js $(WINDOWS_BOOT) | $(GEN) echo "ok" | cat $(WINDOWS_BOOT) - | $< boot >$@ -ARDUINO_BOOT = common/boot.fs common/vocabulary.fs arduino/arduino.fs arduino/hide_io.fs \ - arduino/arduino_highlevel.fs common/highlevel.fs common/filetools.fs \ +ARDUINO_BOOT = common/boot.fs common/vocabulary.fs arduino/hide_io.fs \ + arduino/arduino.fs arduino/arduino_highlevel.fs \ + common/highlevel.fs common/filetools.fs \ common/tasks.fs common/streams.fs arduino/arduino_server.fs \ arduino/esp_camera.fs common/blocks.fs common/utils.fs \ arduino/autoboot.fs diff --git a/ueforth/arduino/arduino_server.fs b/ueforth/arduino/arduino_server.fs index 1eb42c6..5882772 100644 --- a/ueforth/arduino/arduino_server.fs +++ b/ueforth/arduino/arduino_server.fs @@ -98,16 +98,25 @@ window.onload = function() { | s>z constant index-html -variable webserver -20000 constant out-size - streams : >stream >stream ; : stream> stream> ; : stream>ch stream>ch ; : stream stream ; +WebServer +: WebServer.setContentLength WebServer.setContentLength ; +: WebServer.arg WebServer.arg ; +: WebServer.hasArg WebServer.hasArg ; +: WebServer.send WebServer.send ; +: WebServer.on WebServer.on ; +: WebServer.new WebServer.new ; +: WebServer.begin WebServer.begin ; +: WebServer.handleClient WebServer.handleClient ; web-interface +variable webserver +20000 constant out-size + 200 stream input-stream out-size dup stream output-stream diff --git a/ueforth/arduino/hide_io.fs b/ueforth/arduino/hide_io.fs index bb59583..93b0159 100644 --- a/ueforth/arduino/hide_io.fs +++ b/ueforth/arduino/hide_io.fs @@ -1,11 +1,25 @@ ( Migrate various words to separate vocabularies ) vocabulary Wire Wire definitions -transfer Wire.begin transfer Wire.setClock transfer Wire.getClock -transfer Wire.setTimeout transfer Wire.getTimeout -transfer Wire.lastError transfer Wire.getErrorText -transfer Wire.beginTransmission transfer Wire.endTransmission -transfer Wire.requestFrom transfer Wire.writeTransmission -transfer Wire.readTransmission transfer Wire.write -transfer Wire.available transfer Wire.read -transfer Wire.peek transfer Wire.busy transfer Wire.flush +transfer{ + Wire.begin Wire.setClock Wire.getClock + Wire.setTimeout Wire.getTimeout + Wire.lastError Wire.getErrorText + Wire.beginTransmission Wire.endTransmission + Wire.requestFrom Wire.writeTransmission + Wire.readTransmission Wire.write + Wire.available Wire.read + Wire.peek Wire.busy Wire.flush +}transfer +forth definitions + +vocabulary WebServer WebServer definitions +transfer{ + WebServer.arg WebServer.argi WebServer.argName + WebServer.new WebServer.delete + WebServer.begin WebServer.stop + WebServer.on WebServer.hasArg + WebServer.sendHeader WebServer.send WebServer.sendContent + WebServer.method WebServer.handleClient + WebServer.args WebServer.setContentLength +}transfer forth definitions diff --git a/ueforth/common/boot.fs b/ueforth/common/boot.fs index 5ef88cb..edf512e 100644 --- a/ueforth/common/boot.fs +++ b/ueforth/common/boot.fs @@ -195,7 +195,7 @@ variable hld 75 value line-width : onlines ( n xt -- n xt ) swap dup line-width > if drop 0 cr then over >name nip + 1+ swap ; -: words 0 context @ @ begin onlines dup see. >link dup 0= until 2drop cr ; +: words 0 context @ @ begin dup while onlines dup see. >link repeat 2drop cr ; ( Examine Memory ) : dump ( a n -- ) diff --git a/ueforth/common/hide_calls.fs b/ueforth/common/hide_calls.fs index 37b34c4..1fcdbf8 100644 --- a/ueforth/common/hide_calls.fs +++ b/ueforth/common/hide_calls.fs @@ -1,5 +1,5 @@ internals definitions -transfer call0 transfer call1 transfer call2 transfer call3 transfer call4 -transfer call5 transfer call6 transfer call7 transfer call8 transfer call9 -transfer call10 +transfer{ + call0 call1 call2 call3 call4 call5 call6 call7 call8 call9 call10 +}transfer forth definitions diff --git a/ueforth/common/vocabulary.fs b/ueforth/common/vocabulary.fs index e7e9708..5dddf05 100644 --- a/ueforth/common/vocabulary.fs +++ b/ueforth/common/vocabulary.fs @@ -4,25 +4,29 @@ : definitions context @ current ! ; : >name-length ( xt -- n ) dup 0= if exit then >name nip ; : vlist 0 context @ @ begin dup >name-length while onlines dup see. >link repeat 2drop cr ; -: transfer ( "name" ) ' context @ begin 2dup @ <> while @ >link& repeat nip - dup @ swap dup @ >link swap ! current @ @ over >link& ! - current @ ! ; + +( Make it easy to transfer words between vocabularies ) +: transfer-xt ( xt -- ) context @ begin 2dup @ <> while @ >link& repeat nip + dup @ swap dup @ >link swap ! current @ @ over >link& ! current @ ! ; +: transfer ( "name" ) ' transfer-xt ; +: }transfer ; +: transfer{ begin ' dup ['] }transfer = if drop exit then transfer-xt again ; ( Hide some words in an internals vocabulary ) vocabulary internals internals definitions -transfer branch transfer 0branch transfer donext transfer dolit -transfer 'notfound transfer notfound -transfer immediate? -transfer input-buffer transfer ?echo transfer ?echo-prompt -transfer evaluate1 transfer evaluate-buffer -transfer 'sys transfer 'heap -transfer aliteral -transfer leaving( transfer )leaving transfer leaving transfer leaving, -transfer (do) transfer (?do) transfer (+loop) -transfer parse-quote -transfer digit -transfer $@ -transfer see. transfer see-loop transfer >name-length transfer exit= -transfer see-one -transfer tib-setup transfer input-limit +transfer{ + transfer-xt + branch 0branch donext dolit + 'notfound notfound + immediate? input-buffer ?echo ?echo-prompt + evaluate1 evaluate-buffer + 'sys 'heap aliteral + leaving( )leaving leaving leaving, + (do) (?do) (+loop) + parse-quote digit $@ + see. see-loop >name-length exit= + see-one + tib-setup input-limit +}transfer forth definitions + diff --git a/ueforth/site/index.html b/ueforth/site/index.html index 1159954..d3f1b99 100644 --- a/ueforth/site/index.html +++ b/ueforth/site/index.html @@ -270,6 +270,7 @@ SPIFFS.usedBytes ( -- n )
WebServer
+These words are inside the WebServer vocabulary.
 WebServer.new ( port -- ws )   Allocate new webserver object
 WebServer.delete ( ws -- )   Delete webserver object