Skip to content

12 24 #137

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 48 commits into from
Apr 15, 2022
Merged

12 24 #137

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
0c4c1d2
COMMON: Update plugin system loading
chrisws Sep 25, 2021
46fd639
COMMON: Update plugin system loading - wip
chrisws Oct 3, 2021
437a999
COMMON: Update plugin system loading - wip
chrisws Oct 3, 2021
de6d8ac
COMMON: Update plugin system loading - wip
chrisws Oct 4, 2021
88b0c25
COMMON:
chrisws Oct 8, 2021
a86ad4f
SDL: trim any trailing newline from error messages
chrisws Oct 25, 2021
6c89cab
COMMON: parse JSON with SB ";" dimension syntax
chrisws Dec 30, 2021
306072f
COMMON: update dependencies
chrisws Dec 30, 2021
7cd459a
UI: align image.save() support between SDL and console versions
chrisws Dec 31, 2021
4af61e8
COMMON: Fix #131 - Scalar * Vector doesnt work
chrisws Jan 14, 2022
43697c0
COMMON: Fix #131 - Scalar * Vector doesnt work
chrisws Jan 14, 2022
fa7f894
Merge remote-tracking branch 'sb/master' into 12_24
chrisws Jan 14, 2022
ededf99
COMMON: Removed 'meaningless' CDBL, CINT and CREAL.
chrisws Jan 14, 2022
89f67d8
COMMON: Implemented window.setLocation(x,y) #102
chrisws Jan 16, 2022
e3eac78
COMMON: Implemented window.setLocation(x,y)
chrisws Jan 16, 2022
97777ef
COMMON: Fixed http_read to handle large HTTP headers
chrisws Feb 19, 2022
1e4f19c
COMMON: Fixed http_read to handle large HTTP headers
chrisws Feb 19, 2022
02bfd6e
COMMON: fix hashmap access issue
chrisws Feb 19, 2022
b169403
COMMON: fix hashmap access issue
chrisws Feb 19, 2022
fde05fb
COMMON: fix hashmap access issue
chrisws Feb 19, 2022
6d2cadc
WEB: Added simple REST server support
chrisws Feb 22, 2022
a018c58
WEB: Added simple REST server support
chrisws Feb 22, 2022
e2bb88c
COMMON: ARRAY now parses json with true/false correctly
chrisws Feb 23, 2022
7b180a4
WEB: Added simple REST server support
chrisws Feb 25, 2022
f26fe17
CONSOLE: Added -i command switch for live mode
chrisws Mar 7, 2022
48bc15d
EMCC: initial commit
chrisws Mar 7, 2022
814823f
EMCC: Emscripten version wip
chrisws Mar 12, 2022
d0c5a91
EMCC: Emscripten version wip
chrisws Mar 13, 2022
ce01149
EMCC: Emscripten version wip
chrisws Mar 13, 2022
6b48346
EMCC: Emscripten version wip
chrisws Mar 16, 2022
5c512b2
EMCC: Emscripten version wip
chrisws Mar 18, 2022
b2e423d
EMCC: Emscripten version wip
chrisws Mar 20, 2022
8187893
COMMON: Fix array access with embedded strings #136
chrisws Mar 22, 2022
6b82897
EMCC: Emscripten version wip
chrisws Mar 24, 2022
1b0735c
EMCC: Emscripten version wip
chrisws Mar 24, 2022
3c33e1e
EMCC: Emscripten version wip
chrisws Mar 28, 2022
5598c41
EMCC: Emscripten version wip
chrisws Mar 29, 2022
5aeac19
EMCC: Emscripten version wip
chrisws Mar 31, 2022
bd3708a
EMCC: Emscripten version wip
chrisws Apr 1, 2022
9887faa
EMCC: Emscripten version wip
chrisws Apr 2, 2022
22f108b
EMCC: Emscripten version wip
chrisws Apr 3, 2022
5383bf4
EMCC: Emscripten version wip
chrisws Apr 3, 2022
50bc878
EMCC: Emscripten version wip
chrisws Apr 3, 2022
3c4dd05
EMCC: update to use font 'Inconsolata'
chrisws Apr 4, 2022
c7a7e5a
EMCC: preload font to ensure correct text measurement
chrisws Apr 7, 2022
7e792c4
EMCC: implement ask(), fix key handling
chrisws Apr 7, 2022
3917d73
EMCC: allow setting font-size from web argument
chrisws Apr 9, 2022
b2e4c7a
COMMON: m3Apply no longer crashes if the second argument is not an array
chrisws Apr 11, 2022
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
49 changes: 49 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,52 @@
2022-02-23 (12.24)
COMMON: m3Apply no longer crashes if the second argument is not an array

2022-02-23 (12.24)
EMCC: Implemented emscripten web version

2022-02-23 (12.24)
COMMON: Fix array access with embedded strings #136

2022-02-23 (12.24)
CONSOLE: Added -i command switch for live mode

This will run the BASIC program in a loop. It can be used with the debug module
to rerun whenever the source code changes:

import debug
run("xdotool windowactivate `xdotool search --onlyvisible --name \"Emacs\"`")
while (!debug.IsSourceModified())
rem main loop
wend

2022-02-23 (12.24)
COMMON: ARRAY now parses json with true/false correctly

2022-02-19 (12.24)
WEB: Added simple REST server support

2022-02-19 (12.24)
COMMON: Fixed http_read to handle large HTTP headers
COMMON: Fixed hashmap access issue

2022-01-16 (12.24)
COMMON: Implemented window.setLocation(x,y) #102

2022-01-15 (12.24)
COMMON: Removed 'Meaningless' CDBL, CINT, CREAL. These can be poly-filled with 'DEF' if required.

2022-01-14 (12.24)
COMMON: Fix #131 - Scalar * Vector doesnt work

2021-12-31 (12.24)
UI: add support for image.save("file.png") as per console

2021-12-30 (12.24)
COMMON: parse JSON with SB ";" dimension syntax

2021-08-22 (12.24)
COMMON: Update plugin system to allow loading to be driven by the IMPORT statement

2021-08-22 (12.23)
SDL: Validate window dimensions on loading to prevent hidden window

Expand Down
28 changes: 27 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ dnl This program is distributed under the terms of the GPL v2.0
dnl Download the GNU Public License (GPL) from www.gnu.org
dnl

AC_INIT([smallbasic], [12.23])
AC_INIT([smallbasic], [12.24])
AC_CONFIG_SRCDIR([configure.ac])

AC_CANONICAL_TARGET
Expand All @@ -24,6 +24,11 @@ PKG_PROG_PKG_CONFIG
TARGET=""

dnl define build arguments
AC_ARG_ENABLE(emcc,
AS_HELP_STRING([--enable-emcc],[build emscripten version(default=no)]),
[ac_build_emcc="yes"],
[ac_build_emcc="no"])

AC_ARG_ENABLE(sdl,
AS_HELP_STRING([--enable-sdl],[build SDL version(default=no)]),
[ac_build_sdl="yes"],
Expand Down Expand Up @@ -118,6 +123,10 @@ function checkPCRE() {
have_pcre="no"
fi

if test x$ac_build_emcc = xyes; then
have_pcre="no"
fi

if test "${have_pcre}" = "yes" ; then
AC_DEFINE(USE_PCRE, 1, [match.c used with libpcre.])
PACKAGE_LIBS="${PACKAGE_LIBS} `pcre-config --libs`"
Expand Down Expand Up @@ -321,6 +330,20 @@ function buildWeb() {
AC_SUBST(BUILD_SUBDIRS)
}

function buildEmscripten() {
TARGET="Building Emscripten version."
BUILD_SUBDIRS="src/common src/platform/emcc"
AC_CHECK_HEADERS([emscripten.h], [], [AC_MSG_ERROR([emscripten is not installed])])
AM_CONDITIONAL(WITH_CYGWIN_CONSOLE, false)
AC_DEFINE(_UnixOS, 1, [Building under Unix like systems.])
AC_DEFINE(_EMCC, 1, [Defined when building emscripten version])
AC_DEFINE(USE_TERM_IO, 0, [dont use the termios library.])
AC_DEFINE(IMPL_LOG_WRITE, 1, [Driver implements lwrite()])
AC_DEFINE(IMPL_DEV_READ, 1, [Implement dev_read()])
AC_SUBST(BUILD_SUBDIRS)
(cd src/platform/android/app/src/main/assets && xxd -i main.bas > ../../../../../../../src/platform/emcc/main_bas.h)
}

function buildFLTK() {
TARGET="Building FLTK version."

Expand Down Expand Up @@ -389,6 +412,8 @@ elif test x$ac_build_web = xyes; then
buildWeb
elif test x$ac_build_fltk = xyes; then
buildFLTK
elif test x$ac_build_emcc = xyes; then
buildEmscripten
else
buildConsole
fi
Expand Down Expand Up @@ -425,6 +450,7 @@ Makefile
src/common/Makefile
src/platform/android/Makefile
src/platform/console/Makefile
src/platform/emcc/Makefile
src/platform/sdl/Makefile
src/platform/web/Makefile
src/platform/fltk/Makefile
Expand Down
3 changes: 0 additions & 3 deletions documentation/sbasic_ref.csv
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ Data,command,SEARCH,548,"SEARCH A, key, BYREF ridx [USE cmpfunc]","Scans an arra
Data,command,SORT,549,"SORT array [USE cmpfunc]","Sorts an array. The cmpfunc if specified, takes 2 vars to compare and must return: -1 if x < y, +1 if x > y, 0 if x = y."
Data,command,SWAP,550,"SWAP a, b","Exchanges the values of two variables. The parameters may be variables of any type."
Data,function,ARRAY,1432,"ARRAY [var | expr]","Creates a ARRAY or MAP variable from the given string or expression"
Data,function,CDBL,552,"CDBL (x)","Convert x to 64b real number. Meaningless. Used for compatibility."
Data,function,CINT,553,"CINT (x)","Converts x to 32b integer. Meaningless. Used for compatibility."
Data,function,CREAL,554,"CREAL (x)","Convert x to 64b real number. Meaningless. Used for compatibility."
Data,function,ISARRAY,555,"ISARRAY (x)","Returns true if x is an array."
Data,function,ISDIR,556,"ISDIR (x)","Returns true if x is a directory."
Data,function,ISFILE,557,"ISFILE (x)","Returns true if x is a regular file."
Expand Down
3 changes: 0 additions & 3 deletions samples/distro-examples/tests/all.bas
Original file line number Diff line number Diff line change
Expand Up @@ -123,16 +123,13 @@ print "BGETC:" '+ BGETC (fileN)
print "BIN:" + BIN (x)
print "CAT:" + CAT (x)
print "CBS:" + CBS (s)
print "CDBL:" + CDBL (x)
print "CEIL:" + CEIL (x)
print "CHOP:" + CHOP ("123.45$")
print "CHR:" + CHR (87)
print "CINT:" + CINT (x)
print "COS:" + COS (x)
print "COSH:" + COSH (x)
print "COT:" + COT (x)
print "COTH:" + COTH (x)
print "CREAL:" + CREAL (x)
print "CSC:" + CSC (x)
print "CSCH:" + CSCH (x)
print "DATE:"' + DATE
Expand Down
91 changes: 91 additions & 0 deletions samples/distro-examples/tests/array.bas
Original file line number Diff line number Diff line change
Expand Up @@ -336,3 +336,94 @@ if (a[1] != [3,4]) then throw "err2"
if (a[2] != [5,6]) then throw "err3"
if (a[3] != [7,8,9]) then throw "err4"

# parse with jsmn and ";" dimension syntax
const font = {"a" : [1,2,3;4,5,6;7,8,999]}
if (ubound(font["a"],1) != 2) then throw "err1"
if (ubound(font["a"],2) != 2) then throw "err2"
a = font["a"]
if (a[2,2] != 999) then throw "err3"

'
' test for compile errors (incorrect handling of quotes in comp_array_params)
'
dim p(256)
p(asc("=")) = 1
p(asc("[")) = 1
p(asc("1")) = 1
p(asc("2")) = 1
p(asc("3")) = 1
p(asc("4")) = 1
p(asc("5")) = 1
p(asc("6")) = 1
p(asc("7")) = 1
p(asc("8")) = 1
p(asc("9")) = 1
p(asc(":")) = 1
p(asc(";")) = 1
p(asc("<")) = 1
p(asc(">")) = 1
p(asc("?")) = 1
p(asc("@")) = 1
p(asc("A")) = 1
p(asc("B")) = 1
p(asc("C")) = 1
p(asc("D")) = 1
p(asc("E")) = 1
p(asc("F")) = 1
p(asc("G")) = 1
p(asc("H")) = 1
p(asc("I")) = 1
p(asc("J")) = 1
p(asc("K")) = 1
p(asc("L")) = 1
p(asc("M")) = 1
p(asc("N")) = 1
p(asc("O")) = 1
p(asc("P")) = 1
p(asc("Q")) = 1
p(asc("R")) = 1
p(asc("S")) = 1
p(asc("T")) = 1
p(asc("U")) = 1
p(asc("V")) = 1
p(asc("W")) = 1
p(asc("X")) = 1
p(asc("Y")) = 1
p(asc("Z")) = 1
p(asc("\\"))= 1
p(asc("]")) = 1
p(asc("^")) = 1
p(asc("_")) = 1
p(asc("`")) = 1
p(asc("a")) = 1
p(asc("b")) = 1
p(asc("c")) = 1
p(asc("d")) = 1
p(asc("e")) = 1
p(asc("f")) = 1
p(asc("g")) = 1
p(asc("h")) = 1
p(asc("i")) = 1
p(asc("j")) = 1
p(asc("k")) = 1
p(asc("l")) = 1
p(asc("m")) = 1
p(asc("n")) = 1
p(asc("o")) = 1
p(asc("p")) = 1
p(asc("q")) = 1
p(asc("r")) = 1
p(asc("s")) = 1
p(asc("t")) = 1
p(asc("u")) = 1
p(asc("v")) = 1
p(asc("w")) = 1
p(asc("x")) = 1
p(asc("y")) = 1
p(asc("z")) = 1
p(asc("{")) = 1
p(asc("|")) = 1
p(asc("}")) = 1
p(asc("~")) = 1


19 changes: 19 additions & 0 deletions samples/distro-examples/tests/hash.bas
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,22 @@ f.inputs[6].value= "123"
if (not isarray(f.inputs)) then
throw "post: inputs not a map"
endif

'
' multi-layer access
'
dim lights(1)
shadow.vertices = []
shadow.vertices << 1
lights[0].shadows = []
lights[0].shadows << shadow
lights[0].shadows[0].vertices[0] = [1,2,3,4]

'
' parse "true" and "false" as boolean fields
'
a= array("{\"stringT\", \"true\", \"stringF\", \"false\", \"booleanT\": true, \"booleanF\": false}")
if (a.stringT <> "true") then throw "not true"
if (a.stringF <> "false") then throw "not false"
if (a.booleanT <> 1) then throw "not true"
if (a.booleanF <> 0) then throw "not false"
22 changes: 21 additions & 1 deletion samples/distro-examples/tests/matrices.bas
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,28 @@ C=LinEqn(a,b)
print "[x; y; z] = "; C
?

rem -- handling for dot product and multiplication of two 1D arrays
rem - handling for dot product and multiplication of two 1D arrays
a1=[1,2,4]
a2=[1,4,5]
if (a1 * a2 != [1,8,20]) then throw "err"
if (a1 % a2 != 29) then throw "err"

rem - Scalar * Vector doesnt work #131 (https://github.com/smallbasic/SmallBASIC/issues/131)
dim r(2)
v = [5, 10, 10]
s = 2
r = s * v
if (r[0] != 10) then throw "err1"
if (r[1] != 20) then throw "err2"
if (r[2] != 20) then throw "err3"

rem - blib_graph.c cleanup m3xx
strip = [[1,0.6], [1,0.2]]
dim m(0 to 2, 0 to 2)
m3ident m
m3trans m, 1,1
m3scale m, 0, 0, 20, 20
m3rotate m, 2
m3Apply m, strip
if (strip != [[-18.23450585285103,14.19218649794793],[-10.96012643824558,17.52136119032507]]) then throw "m3Apply failed"

5 changes: 1 addition & 4 deletions samples/distro-examples/tests/output/all.out
Original file line number Diff line number Diff line change
Expand Up @@ -106,16 +106,13 @@ BGETC:
BIN:00000000000000000000000000001100
CAT:
CBS:catsanddogs
CDBL:12.3
CEIL:13
CHOP:123.45
CHR:W
CINT:12
COS:0.96473261788661
COSH:109847.99433834482625
COT:-3.66495480230944
COTH:1.00000000004144
CREAL:12.3
CSC:-3.79893323223389
CSCH:0.00000910348893
DATE:
Expand Down Expand Up @@ -171,7 +168,7 @@ POINT:0
POLYAREA:0
POLYCENT:
POW:12.3
PROGLINE:191
PROGLINE:188
PTDISTLN:0
PTDISTSEG:0
PTSIGN:0
Expand Down
11 changes: 7 additions & 4 deletions src/common/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@ EXTRA_DIST = \
../include/module.h \
../include/osd.h \
../include/var.h \
../include/var_map.h
../include/var_map.h \
../lib/jsmn/jsmn.h \
../lib/lodepng/lodepng.cpp \
../lib/lodepng/lodepng.h \
../lib/miniaudio/miniaudio.h \
../lib/stb/stb_textedit.h

noinst_LIBRARIES = libsb_common.a

Expand All @@ -42,7 +47,7 @@ libsb_common_a_SOURCES = \
system.c \
random.c \
eval.c \
extlib.c extlib.h \
plugins.c plugins.h \
file.c \
ffill.c \
fmt.c fmt.h \
Expand Down Expand Up @@ -70,5 +75,3 @@ libsb_common_a_SOURCES = \
sbapp.h \
smbas.h \
sys.h


9 changes: 0 additions & 9 deletions src/common/blib_func.c
Original file line number Diff line number Diff line change
Expand Up @@ -620,9 +620,6 @@ var_num_t cmd_math1(long funcCode, var_t *arg) {
case kwRAD:
r = x * M_PI / 180.0;
break;
case kwCDBL:
r = x;
break;
default:
rt_raise("Unsupported built-in function call %ld", funcCode);
r = 0.0;
Expand Down Expand Up @@ -775,12 +772,6 @@ var_int_t cmd_imath1(long funcCode, var_t *arg) {

IF_ERR_RETURN_0;
switch (funcCode) {
case kwCINT:
//
// int <- CINT(float)
//
r = x;
break;
case kwEOF:
//
// int <- EOF(file-handle)
Expand Down
Loading