Skip to content

Commit c410df4

Browse files
authored
Merge pull request #137 from chrisws/12_24
12 24
2 parents ddb0927 + b2e4c7a commit c410df4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+3154
-1392
lines changed

ChangeLog

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,52 @@
1+
2022-02-23 (12.24)
2+
COMMON: m3Apply no longer crashes if the second argument is not an array
3+
4+
2022-02-23 (12.24)
5+
EMCC: Implemented emscripten web version
6+
7+
2022-02-23 (12.24)
8+
COMMON: Fix array access with embedded strings #136
9+
10+
2022-02-23 (12.24)
11+
CONSOLE: Added -i command switch for live mode
12+
13+
This will run the BASIC program in a loop. It can be used with the debug module
14+
to rerun whenever the source code changes:
15+
16+
import debug
17+
run("xdotool windowactivate `xdotool search --onlyvisible --name \"Emacs\"`")
18+
while (!debug.IsSourceModified())
19+
rem main loop
20+
wend
21+
22+
2022-02-23 (12.24)
23+
COMMON: ARRAY now parses json with true/false correctly
24+
25+
2022-02-19 (12.24)
26+
WEB: Added simple REST server support
27+
28+
2022-02-19 (12.24)
29+
COMMON: Fixed http_read to handle large HTTP headers
30+
COMMON: Fixed hashmap access issue
31+
32+
2022-01-16 (12.24)
33+
COMMON: Implemented window.setLocation(x,y) #102
34+
35+
2022-01-15 (12.24)
36+
COMMON: Removed 'Meaningless' CDBL, CINT, CREAL. These can be poly-filled with 'DEF' if required.
37+
38+
2022-01-14 (12.24)
39+
COMMON: Fix #131 - Scalar * Vector doesnt work
40+
41+
2021-12-31 (12.24)
42+
UI: add support for image.save("file.png") as per console
43+
44+
2021-12-30 (12.24)
45+
COMMON: parse JSON with SB ";" dimension syntax
46+
47+
2021-08-22 (12.24)
48+
COMMON: Update plugin system to allow loading to be driven by the IMPORT statement
49+
150
2021-08-22 (12.23)
251
SDL: Validate window dimensions on loading to prevent hidden window
352

configure.ac

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ dnl This program is distributed under the terms of the GPL v2.0
77
dnl Download the GNU Public License (GPL) from www.gnu.org
88
dnl
99

10-
AC_INIT([smallbasic], [12.23])
10+
AC_INIT([smallbasic], [12.24])
1111
AC_CONFIG_SRCDIR([configure.ac])
1212

1313
AC_CANONICAL_TARGET
@@ -24,6 +24,11 @@ PKG_PROG_PKG_CONFIG
2424
TARGET=""
2525

2626
dnl define build arguments
27+
AC_ARG_ENABLE(emcc,
28+
AS_HELP_STRING([--enable-emcc],[build emscripten version(default=no)]),
29+
[ac_build_emcc="yes"],
30+
[ac_build_emcc="no"])
31+
2732
AC_ARG_ENABLE(sdl,
2833
AS_HELP_STRING([--enable-sdl],[build SDL version(default=no)]),
2934
[ac_build_sdl="yes"],
@@ -118,6 +123,10 @@ function checkPCRE() {
118123
have_pcre="no"
119124
fi
120125

126+
if test x$ac_build_emcc = xyes; then
127+
have_pcre="no"
128+
fi
129+
121130
if test "${have_pcre}" = "yes" ; then
122131
AC_DEFINE(USE_PCRE, 1, [match.c used with libpcre.])
123132
PACKAGE_LIBS="${PACKAGE_LIBS} `pcre-config --libs`"
@@ -321,6 +330,20 @@ function buildWeb() {
321330
AC_SUBST(BUILD_SUBDIRS)
322331
}
323332

333+
function buildEmscripten() {
334+
TARGET="Building Emscripten version."
335+
BUILD_SUBDIRS="src/common src/platform/emcc"
336+
AC_CHECK_HEADERS([emscripten.h], [], [AC_MSG_ERROR([emscripten is not installed])])
337+
AM_CONDITIONAL(WITH_CYGWIN_CONSOLE, false)
338+
AC_DEFINE(_UnixOS, 1, [Building under Unix like systems.])
339+
AC_DEFINE(_EMCC, 1, [Defined when building emscripten version])
340+
AC_DEFINE(USE_TERM_IO, 0, [dont use the termios library.])
341+
AC_DEFINE(IMPL_LOG_WRITE, 1, [Driver implements lwrite()])
342+
AC_DEFINE(IMPL_DEV_READ, 1, [Implement dev_read()])
343+
AC_SUBST(BUILD_SUBDIRS)
344+
(cd src/platform/android/app/src/main/assets && xxd -i main.bas > ../../../../../../../src/platform/emcc/main_bas.h)
345+
}
346+
324347
function buildFLTK() {
325348
TARGET="Building FLTK version."
326349

@@ -389,6 +412,8 @@ elif test x$ac_build_web = xyes; then
389412
buildWeb
390413
elif test x$ac_build_fltk = xyes; then
391414
buildFLTK
415+
elif test x$ac_build_emcc = xyes; then
416+
buildEmscripten
392417
else
393418
buildConsole
394419
fi
@@ -425,6 +450,7 @@ Makefile
425450
src/common/Makefile
426451
src/platform/android/Makefile
427452
src/platform/console/Makefile
453+
src/platform/emcc/Makefile
428454
src/platform/sdl/Makefile
429455
src/platform/web/Makefile
430456
src/platform/fltk/Makefile

documentation/sbasic_ref.csv

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@ Data,command,SEARCH,548,"SEARCH A, key, BYREF ridx [USE cmpfunc]","Scans an arra
2626
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."
2727
Data,command,SWAP,550,"SWAP a, b","Exchanges the values of two variables. The parameters may be variables of any type."
2828
Data,function,ARRAY,1432,"ARRAY [var | expr]","Creates a ARRAY or MAP variable from the given string or expression"
29-
Data,function,CDBL,552,"CDBL (x)","Convert x to 64b real number. Meaningless. Used for compatibility."
30-
Data,function,CINT,553,"CINT (x)","Converts x to 32b integer. Meaningless. Used for compatibility."
31-
Data,function,CREAL,554,"CREAL (x)","Convert x to 64b real number. Meaningless. Used for compatibility."
3229
Data,function,ISARRAY,555,"ISARRAY (x)","Returns true if x is an array."
3330
Data,function,ISDIR,556,"ISDIR (x)","Returns true if x is a directory."
3431
Data,function,ISFILE,557,"ISFILE (x)","Returns true if x is a regular file."

samples/distro-examples/tests/all.bas

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,16 +123,13 @@ print "BGETC:" '+ BGETC (fileN)
123123
print "BIN:" + BIN (x)
124124
print "CAT:" + CAT (x)
125125
print "CBS:" + CBS (s)
126-
print "CDBL:" + CDBL (x)
127126
print "CEIL:" + CEIL (x)
128127
print "CHOP:" + CHOP ("123.45$")
129128
print "CHR:" + CHR (87)
130-
print "CINT:" + CINT (x)
131129
print "COS:" + COS (x)
132130
print "COSH:" + COSH (x)
133131
print "COT:" + COT (x)
134132
print "COTH:" + COTH (x)
135-
print "CREAL:" + CREAL (x)
136133
print "CSC:" + CSC (x)
137134
print "CSCH:" + CSCH (x)
138135
print "DATE:"' + DATE

samples/distro-examples/tests/array.bas

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,3 +336,94 @@ if (a[1] != [3,4]) then throw "err2"
336336
if (a[2] != [5,6]) then throw "err3"
337337
if (a[3] != [7,8,9]) then throw "err4"
338338

339+
# parse with jsmn and ";" dimension syntax
340+
const font = {"a" : [1,2,3;4,5,6;7,8,999]}
341+
if (ubound(font["a"],1) != 2) then throw "err1"
342+
if (ubound(font["a"],2) != 2) then throw "err2"
343+
a = font["a"]
344+
if (a[2,2] != 999) then throw "err3"
345+
346+
'
347+
' test for compile errors (incorrect handling of quotes in comp_array_params)
348+
'
349+
dim p(256)
350+
p(asc("=")) = 1
351+
p(asc("[")) = 1
352+
p(asc("1")) = 1
353+
p(asc("2")) = 1
354+
p(asc("3")) = 1
355+
p(asc("4")) = 1
356+
p(asc("5")) = 1
357+
p(asc("6")) = 1
358+
p(asc("7")) = 1
359+
p(asc("8")) = 1
360+
p(asc("9")) = 1
361+
p(asc(":")) = 1
362+
p(asc(";")) = 1
363+
p(asc("<")) = 1
364+
p(asc(">")) = 1
365+
p(asc("?")) = 1
366+
p(asc("@")) = 1
367+
p(asc("A")) = 1
368+
p(asc("B")) = 1
369+
p(asc("C")) = 1
370+
p(asc("D")) = 1
371+
p(asc("E")) = 1
372+
p(asc("F")) = 1
373+
p(asc("G")) = 1
374+
p(asc("H")) = 1
375+
p(asc("I")) = 1
376+
p(asc("J")) = 1
377+
p(asc("K")) = 1
378+
p(asc("L")) = 1
379+
p(asc("M")) = 1
380+
p(asc("N")) = 1
381+
p(asc("O")) = 1
382+
p(asc("P")) = 1
383+
p(asc("Q")) = 1
384+
p(asc("R")) = 1
385+
p(asc("S")) = 1
386+
p(asc("T")) = 1
387+
p(asc("U")) = 1
388+
p(asc("V")) = 1
389+
p(asc("W")) = 1
390+
p(asc("X")) = 1
391+
p(asc("Y")) = 1
392+
p(asc("Z")) = 1
393+
p(asc("\\"))= 1
394+
p(asc("]")) = 1
395+
p(asc("^")) = 1
396+
p(asc("_")) = 1
397+
p(asc("`")) = 1
398+
p(asc("a")) = 1
399+
p(asc("b")) = 1
400+
p(asc("c")) = 1
401+
p(asc("d")) = 1
402+
p(asc("e")) = 1
403+
p(asc("f")) = 1
404+
p(asc("g")) = 1
405+
p(asc("h")) = 1
406+
p(asc("i")) = 1
407+
p(asc("j")) = 1
408+
p(asc("k")) = 1
409+
p(asc("l")) = 1
410+
p(asc("m")) = 1
411+
p(asc("n")) = 1
412+
p(asc("o")) = 1
413+
p(asc("p")) = 1
414+
p(asc("q")) = 1
415+
p(asc("r")) = 1
416+
p(asc("s")) = 1
417+
p(asc("t")) = 1
418+
p(asc("u")) = 1
419+
p(asc("v")) = 1
420+
p(asc("w")) = 1
421+
p(asc("x")) = 1
422+
p(asc("y")) = 1
423+
p(asc("z")) = 1
424+
p(asc("{")) = 1
425+
p(asc("|")) = 1
426+
p(asc("}")) = 1
427+
p(asc("~")) = 1
428+
429+

samples/distro-examples/tests/hash.bas

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,22 @@ f.inputs[6].value= "123"
6161
if (not isarray(f.inputs)) then
6262
throw "post: inputs not a map"
6363
endif
64+
65+
'
66+
' multi-layer access
67+
'
68+
dim lights(1)
69+
shadow.vertices = []
70+
shadow.vertices << 1
71+
lights[0].shadows = []
72+
lights[0].shadows << shadow
73+
lights[0].shadows[0].vertices[0] = [1,2,3,4]
74+
75+
'
76+
' parse "true" and "false" as boolean fields
77+
'
78+
a= array("{\"stringT\", \"true\", \"stringF\", \"false\", \"booleanT\": true, \"booleanF\": false}")
79+
if (a.stringT <> "true") then throw "not true"
80+
if (a.stringF <> "false") then throw "not false"
81+
if (a.booleanT <> 1) then throw "not true"
82+
if (a.booleanF <> 0) then throw "not false"

samples/distro-examples/tests/matrices.bas

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,28 @@ C=LinEqn(a,b)
3939
print "[x; y; z] = "; C
4040
?
4141

42-
rem -- handling for dot product and multiplication of two 1D arrays
42+
rem - handling for dot product and multiplication of two 1D arrays
4343
a1=[1,2,4]
4444
a2=[1,4,5]
4545
if (a1 * a2 != [1,8,20]) then throw "err"
4646
if (a1 % a2 != 29) then throw "err"
47+
48+
rem - Scalar * Vector doesnt work #131 (https://github.com/smallbasic/SmallBASIC/issues/131)
49+
dim r(2)
50+
v = [5, 10, 10]
51+
s = 2
52+
r = s * v
53+
if (r[0] != 10) then throw "err1"
54+
if (r[1] != 20) then throw "err2"
55+
if (r[2] != 20) then throw "err3"
56+
57+
rem - blib_graph.c cleanup m3xx
58+
strip = [[1,0.6], [1,0.2]]
59+
dim m(0 to 2, 0 to 2)
60+
m3ident m
61+
m3trans m, 1,1
62+
m3scale m, 0, 0, 20, 20
63+
m3rotate m, 2
64+
m3Apply m, strip
65+
if (strip != [[-18.23450585285103,14.19218649794793],[-10.96012643824558,17.52136119032507]]) then throw "m3Apply failed"
66+

samples/distro-examples/tests/output/all.out

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,16 +106,13 @@ BGETC:
106106
BIN:00000000000000000000000000001100
107107
CAT:
108108
CBS:catsanddogs
109-
CDBL:12.3
110109
CEIL:13
111110
CHOP:123.45
112111
CHR:W
113-
CINT:12
114112
COS:0.96473261788661
115113
COSH:109847.99433834482625
116114
COT:-3.66495480230944
117115
COTH:1.00000000004144
118-
CREAL:12.3
119116
CSC:-3.79893323223389
120117
CSCH:0.00000910348893
121118
DATE:
@@ -171,7 +168,7 @@ POINT:0
171168
POLYAREA:0
172169
POLYCENT:
173170
POW:12.3
174-
PROGLINE:191
171+
PROGLINE:188
175172
PTDISTLN:0
176173
PTDISTSEG:0
177174
PTSIGN:0

src/common/Makefile.am

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,12 @@ EXTRA_DIST = \
1919
../include/module.h \
2020
../include/osd.h \
2121
../include/var.h \
22-
../include/var_map.h
22+
../include/var_map.h \
23+
../lib/jsmn/jsmn.h \
24+
../lib/lodepng/lodepng.cpp \
25+
../lib/lodepng/lodepng.h \
26+
../lib/miniaudio/miniaudio.h \
27+
../lib/stb/stb_textedit.h
2328

2429
noinst_LIBRARIES = libsb_common.a
2530

@@ -42,7 +47,7 @@ libsb_common_a_SOURCES = \
4247
system.c \
4348
random.c \
4449
eval.c \
45-
extlib.c extlib.h \
50+
plugins.c plugins.h \
4651
file.c \
4752
ffill.c \
4853
fmt.c fmt.h \
@@ -70,5 +75,3 @@ libsb_common_a_SOURCES = \
7075
sbapp.h \
7176
smbas.h \
7277
sys.h
73-
74-

src/common/blib_func.c

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -620,9 +620,6 @@ var_num_t cmd_math1(long funcCode, var_t *arg) {
620620
case kwRAD:
621621
r = x * M_PI / 180.0;
622622
break;
623-
case kwCDBL:
624-
r = x;
625-
break;
626623
default:
627624
rt_raise("Unsupported built-in function call %ld", funcCode);
628625
r = 0.0;
@@ -775,12 +772,6 @@ var_int_t cmd_imath1(long funcCode, var_t *arg) {
775772

776773
IF_ERR_RETURN_0;
777774
switch (funcCode) {
778-
case kwCINT:
779-
//
780-
// int <- CINT(float)
781-
//
782-
r = x;
783-
break;
784775
case kwEOF:
785776
//
786777
// int <- EOF(file-handle)

0 commit comments

Comments
 (0)