Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/makefile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
run: sudo apt install libsqlite3-dev libhiredis-dev

- name: configure
run: ./configure --maintainer --full --allextmod --disable-docs
run: ./configure --maintainer --allextmod --disable-docs

- name: Build
run: make
Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ addons:
- libsqlite3-dev
- libhiredis-dev
before_script:
- ./configure --maintainer --full --allextmod --disable-docs
- ./configure --maintainer --allextmod --disable-docs
script:
- make all test
- ./test-bootstrap-jim
50 changes: 50 additions & 0 deletions README.ensemble
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
An ensemble is a single command that can dispatch subcommands
to other commands.

For example [string] is a built-in ensemble.

The ensemble command allows an ensemble command to be created
that redirects to other commands.

Create an ensemble by having multiple commands that all share
the same prefix. For example:

proc {test open} {name} { ... }
proc {test close} {handle} { ... }
proc {test show} {handle} { ... }

Then simply:

ensemble test

Now a new command, test, is created that will invoke the other commands
based on the first argument. For example:

set h [test open file.txt]
test show $h
test close $h

By default ensemble expects the commands to be named "<name> ". If another
prefix is used, this can be specified with the -automap option. e.g.

ensemble test -automap test.

This could be used if the commands were named test.open, test.close, test.show

Note that ensembles are dynamic, not fixed at the point of creation.
This means, for example, that we can can create a new commands, "test reverse"
after the ensemble has been created and it can still be invoked as test reverse ...

It is easy to create an ensemble for commands in a namespace by simply using
-automap <ns>:: however for compatibility with Tcl, 'namespace ensemble create' is provided
that does with when invoked within a namespace. e.g.

namespace eval test {
namespace ensemble create

proc open {name} { ... }
proc close {handle} { ... }
proc show {handle} { ... }
}

test open file.txt
30 changes: 30 additions & 0 deletions README.redis
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ If no message is received, the read command will wait forever.

The message is returned as: message <channel> <text>

The 'read' subcommand is also used in non-blocking mode. See the section below for more details.

The readable subcommand
~~~~~~~~~~~~~~~~~~~~~~~

Expand All @@ -133,3 +135,31 @@ The 'close' command is supported to close the connection.
This command is equivalent to deleting the command with:

rename $r ""

Async/Non-blocking support
~~~~~~~~~~~~~~~~~~~~~~~~~~

It is possible to connect to redis in non-blocking mode by using the '-async' flag. e.g.

set r [redis -async [socket stream localhost:6379]]

Now commands will return immediately with an empty result and 'read' in a 'readable' should
be used to retrieve the result. As a simple example:

$r readable {
set result [$r read]
if {$result ne ""} {
puts $result
incr next
}
}
$r SET x 5
vwait next
$r INCR x
vwait next

Note that if a large result is returned, 'read' may return an empty string, in
which case further calls to 'readable' are required to return the result.

In general the underlying socket should be put into non-blocking mode ($sock ndelay 1)
and a while loop should be used to read reponses until and empty result is returned.
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ install:
- cmd: C:\msys64\usr\bin\bash -lc "pacman --sync --noconfirm make mingw-w64-i686-gcc mingw-w64-i686-sqlite3"
- cmd: cd C:\projects & mklink /D %APPVEYOR_PROJECT_NAME% %APPVEYOR_PROJECT_SLUG% & exit 0
build_script:
- cmd: C:\msys64\usr\bin\bash -lc "cd /c/projects/jimtcl; ./configure --full --ssl --with-ext='sqlite3 win32 zlib' --disable-docs CFLAGS=-D__MINGW_USE_VC2005_COMPAT"
- cmd: C:\msys64\usr\bin\bash -lc "cd /c/projects/jimtcl; ./configure --ssl --with-ext='sqlite3 win32 zlib' --disable-docs CFLAGS=-D__MINGW_USE_VC2005_COMPAT"
- cmd: C:\msys64\usr\bin\bash -lc "cd /c/projects/jimtcl; make"
test_script:
- cmd: C:\msys64\usr\bin\bash -lc "cd /c/projects/jimtcl; make test"
Expand Down
75 changes: 47 additions & 28 deletions auto.def
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,16 @@ define CFLAGS [get-env CFLAGS ""]
define CXXFLAGS [get-env CFLAGS ""]

options {
utf8 => "Include support for utf8-encoded strings"
utf8=1 => "Disable support for utf8-encoded strings"
lineedit=1 => "Disable line editing"
references=1 => "Disable support for references"
math => "Include support for math functions"
ssl => "Include ssl/tls support in the aio extension"
ipv6 => "Include ipv6 support in the aio extension"
math=1 => "Disable math functions"
ssl=1 => "Disable ssl/tls support in the aio extension"
ipv6=1 => "Disable ipv6 support in the aio extension"
maintainer => {Enable the [debug] command and JimPanic}
full => "Enable some optional features: ipv6, ssl, math, utf8, and some extensions (see --extinfo)"
minimal => "Disable some optional features: ipv6, ssl, math, utf8 and some extensions. Also see --without-ext=default"
# Note that full is now the default
full
allextmod => "Enable all non-default extensions as modules if prerequisites are found"
compat => "Enable some backward compatibility behaviour"
extinfo => "Show information about available extensions"
Expand Down Expand Up @@ -55,13 +57,15 @@ options {
# off=Off unless explicitly enabled or required by an enabled extension
# optional=Off by default, but selected by --full
# cpp=Is a C++ extension
# always=Always include, even if minimal
global extdb

foreach {mod attrs help} {
aio { static } {File and socket (networking) I/O}
array {} {Tcl-compatible array command}
binary { tcl optional } {Tcl-compatible binary command}
clock {} {Tcl-compatible clock command}
ensemble { optional tcl } {Ensemble command}
eventloop { static } {after, vwait, update}
exec { static } {Tcl-compatible exec command}
file {} {Tcl-compatible file command}
Expand All @@ -76,7 +80,7 @@ foreach {mod attrs help} {
nshelper { tcl off } {}
oo { tcl } {Object Oriented class support}
pack {} {Low level binary pack and unpack}
package { static } {Package management with the package command}
package { static always } {Package management with the package command}
posix {} {Posix APIs including os.fork, os.uptime}
readdir {} {Read the contents of a directory (used by glob)}
readline { off } {Interface to libreadline}
Expand All @@ -86,7 +90,7 @@ foreach {mod attrs help} {
sdl { off } {SDL graphics interface}
signal { static } {Signal handling}
sqlite3 { off } {Interface to sqlite3 database}
stdlib { tcl static } {Built-in commands including lambda, stacktrace and some dict subcommands}
stdlib { tcl static always } {Built-in commands including lambda, stacktrace and some dict subcommands}
syslog {} {System logging with syslog}
tclcompat { tcl static } {Tcl compatible read, gets, puts, parray, case, ...}
tclprefix { optional } {Support for the tcl::prefix command}
Expand All @@ -98,6 +102,10 @@ foreach {mod attrs help} {
dict set extdb help $mod $help
}

if {[opt-bool full]} {
user-notice "Note that --full is now the default, and need not be specified (see --minimal)"
}

if {[opt-bool extinfo]} {
use text-formatting
use help
Expand Down Expand Up @@ -138,7 +146,7 @@ if {[opt-bool extinfo]} {
}
showmods "These extensions are enabled by default:" $info default
nl
showmods "These are disabled by default, but enabled by --full:" $info optional
showmods "These are enabled by default, but disabled by --minimal:" $info optional
nl
showmods {
These are disabled unless explicitly enabled or --allextmod is selected and
Expand Down Expand Up @@ -247,11 +255,14 @@ if {[cc-check-function-in-lib socket socket]} {
}

cc-check-functions ualarm lstat fork system select execvpe
cc-check-functions geteuid mkstemp realpath isatty
cc-check-functions geteuid mkstemp isatty
cc-check-functions regcomp waitpid sigaction sys_signame sys_siglist isascii
cc-check-functions syslog opendir readlink sleep usleep pipe getaddrinfo utimes
cc-check-functions shutdown socketpair link symlink fsync dup umask
cc-check-functions localtime gmtime strptime clock_gettime
cc-check-functions localtime gmtime strptime
if {![cc-check-functions realpath]} {
cc-check-functions _fullpath
}

cc-with {-includes math.h} {
cc-check-decls isinf isnan
Expand Down Expand Up @@ -372,20 +383,23 @@ cc-with {-includes sys/stat.h} {
set extra_objs {}
set jimregexp 0

# Returns 1 if either the given option is enabled, or
# --full is enabled and the option isn't explicitly disabled
#
proc opt-bool-or-full {opt} {
if {[opt-bool $opt]} {
return 1
}
if {[opt-bool full] && [opt-bool -nodefault $opt] != 0} {
return 1
}
return 0
# Like opt-bool except defaults to on normally and off if --minimal
# In either case if explicitly enable or disabled, that takes precedence
proc opt-bool-unless-minimal {opt} {
if {[opt-bool minimal]} {
set default 0
} else {
set default 1
}
# If not explicitly enabled/disabled, use the default based on --minimal
set val [opt-bool -nodefault $opt]
if {$val < 0} {
set val $default
}
return $val
}

if {[opt-bool-or-full utf8]} {
if {[opt-bool-unless-minimal utf8]} {
msg-result "Enabling UTF-8"
define JIM_UTF8
define-append AS_CFLAGS -DUSE_UTF8
Expand All @@ -398,19 +412,18 @@ if {[opt-bool maintainer]} {
msg-result "Enabling maintainer settings"
define JIM_MAINTAINER
}
# If --math or --full and not --disable-math
if {[opt-bool-or-full math]} {
if {[opt-bool-unless-minimal math]} {
msg-result "Enabling math functions"
define JIM_MATH_FUNCTIONS
cc-check-function-in-lib sin m
define-append LDLIBS [get-define lib_sin]
}
if {[opt-bool-or-full ipv6]} {
if {[opt-bool-unless-minimal ipv6]} {
msg-result "Enabling IPv6"
define JIM_IPV6
}
define-append PKG_CONFIG_REQUIRES ""
if {[opt-bool-or-full ssl]} {
if {[opt-bool-unless-minimal ssl]} {
if {[pkg-config-init 0]} {
foreach pkg {openssl libssl} {
if {[pkg-config $pkg]} {
Expand Down Expand Up @@ -438,7 +451,7 @@ if {[opt-bool-or-full ssl]} {
define-append AS_CFLAGS -DUSE_TLSv1_2_method
}
}
if {[opt-bool-or-full lineedit]} {
if {[opt-bool-unless-minimal lineedit]} {
if {([cc-check-includes termios.h] && [have-feature isatty]) || [have-feature winconsole]} {
msg-result "Enabling line editing"
define USE_LINENOISE
Expand Down Expand Up @@ -508,7 +521,10 @@ set withinfo(without) [join-ext-names [opt-val {without-ext with-out-jim-ext}]]
set withinfo(ext) [join-ext-names [opt-val {with-ext with-jim-ext}]]
set withinfo(mod) [join-ext-names [opt-val {with-mod with-jim-extmod}]]
set withinfo(nodefault) 0
set withinfo(optional) [opt-bool full]
set withinfo(optional) 1
if {[opt-bool minimal]} {
set withinfo(optional) 0
}
if {$withinfo(without) eq "default"} {
set withinfo(without) {}
set withinfo(nodefault) 1
Expand All @@ -531,6 +547,9 @@ if {[have-feature windows]} {
set buildjimext 0
}
}
} else {
# We don't trust any version of clock_gettime on windows
cc-check-functions clock_gettime
}
if {[have-feature termios.h]} {
lappend extra_objs jim-tty.o
Expand Down
43 changes: 22 additions & 21 deletions autosetup/local.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -219,27 +219,28 @@ proc check-extensions {allextmod} {
set withinfo(maybemod) {}

# Now work out the default status. We have.
# normal case, include !off, !optional if possible
# --full, include !off if possible
# --without=default, don't include optional or off
if {$withinfo(nodefault)} {
lappend withinfo(maybe) stdlib
} else {
foreach i $extlist {
if {[ext-has $i off]} {
if {$allextmod} {
lappend withinfo(maybemod) $i
}
continue
}
if {[ext-has $i optional] && !$withinfo(optional)} {
if {$allextmod} {
lappend withinfo(maybemod) $i
}
continue
}
lappend withinfo(maybe) $i
}
# normal case: include !off, !optional if possible
# --without=default: only include always
foreach i $extlist {
if {$withinfo(nodefault)} {
if {[ext-has $i always]} {
lappend withinfo(maybe) $i
}
continue
}
if {[ext-has $i off]} {
if {$allextmod} {
lappend withinfo(maybemod) $i
}
continue
}
if {[ext-has $i optional] && !$withinfo(optional)} {
if {$allextmod} {
lappend withinfo(maybemod) $i
}
continue
}
lappend withinfo(maybe) $i
}

foreach i $extlist {
Expand Down
Loading