Skip to content

Commit a8bcddc

Browse files
committed
FLTK: port to fltk 1.x
1 parent b6a0cf4 commit a8bcddc

Some content is hidden

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

54 files changed

+11517
-103
lines changed

Makefile.am

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ fuzz-test:
2020
(cd src/platform/console && make fuzz-test)
2121

2222
cppcheck:
23-
(cppcheck --quiet --enable=all src/common src/ui src/platform/android/jni src/platform/sdl)
23+
(cppcheck --quiet --enable=all src/common src/ui src/platform/android/jni src/platform/sdl src/platform/fltk)
2424

2525
covcheck:
2626
(make clean -s && \

configure.ac

Lines changed: 66 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
dnl
22
dnl Configure script for SmallBASIC
33
dnl
4-
dnl Copyright(C) 2001-2018 Chris Warren-Smith.
4+
dnl Copyright(C) 2001-2019 Chris Warren-Smith.
55
dnl
66
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
@@ -39,6 +39,11 @@ AC_ARG_ENABLE(web,
3939
[ac_build_web="yes"],
4040
[ac_build_web="no"])
4141

42+
AC_ARG_ENABLE(fltk,
43+
AS_HELP_STRING([--enable-fltk],[build fltk version(default=no)]),
44+
[ac_build_fltk="yes"],
45+
[ac_build_fltk="no"])
46+
4247
AC_ARG_ENABLE(dist,
4348
AS_HELP_STRING([--enable-dist],[prepare to run make dist(default=no)]),
4449
[ac_build_dist="yes"],
@@ -211,15 +216,13 @@ function buildSDL() {
211216
dnl preconfigured values for SDL build
212217
AC_DEFINE(_SDL, 1, [Defined when building SDL version])
213218
AC_DEFINE(_UnixOS, 1, [Building under Unix like systems.])
214-
AC_DEFINE(IMPL_DEV_DELAY, 1, [Driver implements dev_delay()])
215-
AC_DEFINE(IMPL_LOG_WRITE, 1, [Driver implements lwrite()])
216219
AC_DEFINE(IMPL_DEV_READ, 1, [Implement dev_read()])
220+
AC_DEFINE(IMPL_DEV_DELAY, 1, [Driver implements dev_delay()])
217221
AC_DEFINE(IMPL_LOG_WRITE, 1, [Driver implements lwrite()])
218222

219223
BUILD_SUBDIRS="src/common src/platform/sdl"
220224
AC_SUBST(BUILD_SUBDIRS)
221225
(cd src/platform/android/app/src/main/assets && xxd -i main.bas > ../../../../../../../src/platform/sdl/main_bas.h)
222-
(cd documentation && g++ -o build_kwp build_kwp.cpp && ./build_kwp > ../src/ui/kwp.h)
223226
}
224227

225228
function buildAndroid() {
@@ -238,8 +241,6 @@ function buildAndroid() {
238241

239242
TEST_DIR="src/platform/android"
240243
AC_SUBST(TEST_DIR)
241-
242-
(cd documentation && g++ -o build_kwp build_kwp.cpp && ./build_kwp > ../src/ui/kwp.h)
243244
}
244245

245246
function buildConsole() {
@@ -299,8 +300,6 @@ function buildConsole() {
299300
fi
300301

301302
AC_SUBST(BUILD_SUBDIRS)
302-
303-
(cd documentation && g++ -o build_kwp build_kwp.cpp && ./build_kwp > ../src/ui/kwp.h)
304303
}
305304

306305
function buildWeb() {
@@ -326,16 +325,74 @@ function buildWeb() {
326325
AC_SUBST(BUILD_SUBDIRS)
327326
}
328327

328+
function buildFLTK() {
329+
TARGET="Building FLTK version."
330+
331+
dnl Checks for FLTK 1.x
332+
AC_CHECK_PROG(have_fltk, fltk-config, [yes], [no])
333+
334+
AC_CHECK_PROG(have_xxd, xxd, [yes], [no])
335+
if test "${have_xxd}" = "no" ; then
336+
AC_MSG_ERROR([xxd command not installed: configure failed.])
337+
fi
338+
339+
dnl avoid using MSCRT versions of printf for long double
340+
case "${host_os}" in
341+
*mingw* | cygwin*)
342+
PACKAGE_CFLAGS="${PACKAGE_CFLAGS} -D__USE_MINGW_ANSI_STDIO"
343+
esac
344+
345+
FLTK_CXXFLAGS="${PACKAGE_CFLAGS} `fltk-config --cxxflags`"
346+
FLTK_CXXFLAGS="${FLTK_CXXFLAGS} -fno-exceptions -fno-rtti -std=c++11 -Wno-unknown-pragmas"
347+
PACKAGE_LIBS="${PACKAGE_LIBS} `fltk-config --ldstaticflags --use-images`"
348+
349+
dnl do not depend on cygwin.dll under cygwin build
350+
case "${host_os}" in
351+
*mingw* | cygwin*)
352+
FLTK_CXXFLAGS="${FLTK_CXXFLAGS} -mms-bitfields"
353+
PACKAGE_LIBS="-Wl,-Bstatic ${PACKAGE_LIBS} -lwsock32 -lws2_32 -static-libgcc -static-libstdc++"
354+
AC_DEFINE(_Win32, 1, [Windows build])
355+
;;
356+
357+
*)
358+
(cd images && xxd -i sb-desktop-128x128.png > ../src/platform/fltk/icon.h)
359+
xxd
360+
esac
361+
362+
defaultConditionals
363+
364+
dnl preconfigured values for FLTK build
365+
AC_DEFINE(_UnixOS, 1, [Building under Unix like systems.])
366+
AC_DEFINE(_FLTK, 1, [Defined for FLTK build.])
367+
AC_DEFINE(IMPL_DEV_READ, 1, [Implement dev_read()])
368+
AC_DEFINE(IMPL_DEV_DELAY, 1, [Driver implements dev_delay()])
369+
AC_DEFINE(IMPL_LOG_WRITE, 1, [Driver implements lwrite()])
370+
371+
BUILD_SUBDIRS="src/common src/platform/fltk"
372+
AC_SUBST(BUILD_SUBDIRS)
373+
AC_SUBST(FLTK_CXXFLAGS)
374+
375+
desktopentrydir='$(datarootdir)'/applications
376+
AC_SUBST(desktopentrydir)
377+
378+
dnl generate kwp.h
379+
(cd src/platform/fltk && g++ -o build_kwp build_kwp.cxx && ./build_kwp)
380+
}
381+
329382
if test x$ac_build_sdl = xyes; then
330383
buildSDL
331384
elif test x$ac_build_android = xyes; then
332385
buildAndroid
333386
elif test x$ac_build_web = xyes; then
334387
buildWeb
388+
elif test x$ac_build_fltk = xyes; then
389+
buildFLTK
335390
else
336391
buildConsole
337392
fi
338393

394+
(cd documentation && g++ -o build_kwp build_kwp.cpp && ./build_kwp > ../src/ui/kwp.h)
395+
339396
checkPCRE
340397
checkTermios
341398
checkDebugMode
@@ -368,6 +425,7 @@ src/platform/android/Makefile
368425
src/platform/console/Makefile
369426
src/platform/sdl/Makefile
370427
src/platform/web/Makefile
428+
src/platform/fltk/Makefile
371429
])
372430
AC_OUTPUT
373431

debian/changelog

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ smallbasic (0.12.15) unstable; urgency=low
66
smallbasic (0.12.14) unstable; urgency=low
77
* Various see web site
88

9-
-- Chris Warren-Smith <cwarrensmith@gmail.com> Sat, 15 Sept 2018 09:45:25 +1000
9+
-- Chris Warren-Smith <cwarrensmith@gmail.com> Sat, 15 Sep 2018 09:45:25 +1000
1010

1111
smallbasic (0.12.13) unstable; urgency=low
1212
* Various see web site

src/common/hashmap.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// This program is distributed under the terms of the GPL v2.0 or later
66
// Download the GNU Public License (GPL) from www.gnu.org
77
//
8-
// Copyright(C) 2007-2016 Chris Warren-Smith.
8+
// Copyright(C) 2007-2019 Chris Warren-Smith.
99

1010
#ifndef _HASHMAP_H_
1111
#define _HASHMAP_H_
@@ -16,12 +16,12 @@
1616
* Callback structure for hashmap_foreach
1717
*/
1818
typedef struct hashmap_cb {
19+
var_p_t var;
20+
var_p_t parent;
21+
char *buffer;
1922
int count;
2023
int index;
2124
int start;
22-
char *buffer;
23-
var_p_t var;
24-
var_p_t parent;
2525
} hashmap_cb;
2626

2727
typedef int (*hashmap_foreach_func)(hashmap_cb *cb, var_p_t k, var_p_t v);

src/common/sberr.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ void sc_raise(const char *format, ...) {
9494
* run-time error
9595
*/
9696
void rt_raise(const char *format, ...) {
97-
if (!gsb_last_error && !prog_error && prog_source) {
97+
if (!gsb_last_error && ctask && !prog_error && prog_source) {
9898
prog_error = errRuntime;
9999

100100
va_list args;

src/common/scan.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
#include "common/sys.h"
1818

19+
#define KEYWORD_PADDING 4
20+
1921
#if defined(__cplusplus)
2022
extern "C" {
2123
#endif
@@ -83,7 +85,7 @@ struct proc_keyword_s {
8385
* External procedure (Modules)
8486
*/
8587
typedef struct {
86-
char name[SB_KEYWORD_SIZE + 1]; /**< keyword name */
88+
char name[SB_KEYWORD_SIZE + KEYWORD_PADDING]; /**< keyword name */
8789
int lib_id; /**< library id */
8890
bid_t pcode; /**< keyword code */
8991
int symbol_index; /**< symbol index on symbol-table */
@@ -96,7 +98,7 @@ typedef struct {
9698
* External functions (Modules)
9799
*/
98100
typedef struct {
99-
char name[SB_KEYWORD_SIZE + 1]; /**< keyword name */
101+
char name[SB_KEYWORD_SIZE + KEYWORD_PADDING]; /**< keyword name */
100102
int lib_id; /**< library id */
101103
bid_t fcode; /**< keyword code */
102104
int symbol_index; /**< symbol index on symbol-table */
@@ -126,7 +128,7 @@ typedef struct comp_var_s comp_var_t;
126128
* compiler's label node
127129
*/
128130
struct comp_label_s {
129-
char name[SB_KEYWORD_SIZE + 1]; /**< label name @ingroup scan */
131+
char name[SB_KEYWORD_SIZE + KEYWORD_PADDING]; /**< label name @ingroup scan */
130132
bcip_t ip; /**< address in BC @ingroup scan */
131133
bid_t block_id; /**< block_id (FOR-NEXT,IF-FI,etc) used for GOTOs @ingroup scan */
132134
bcip_t dp; /**< data pointer @ingroup scan */
@@ -165,7 +167,7 @@ typedef struct comp_proc_s comp_udp_t;
165167
* compiler's pass-2 stack node
166168
*/
167169
struct comp_pass_node_s {
168-
char sec[SB_KEYWORD_SIZE + 1]; /**< section-name (PalmOS) @ingroup scan */
170+
char sec[SB_KEYWORD_SIZE + KEYWORD_PADDING]; /**< section-name (PalmOS) @ingroup scan */
169171
bcip_t pos; /**< address in BC @ingroup scan */
170172
int line; /**< source code line number @ingroup scan */
171173
bid_t block_id; /**< block ID @ingroup scan */

src/common/sys.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ extern "C" {
6969
#define SB_STR_VER VERSION " SDL " SB_VERSYS SB_BIT_SZ BUILD_DATE
7070
#elif defined (_ANDROID)
7171
#define SB_STR_VER VERSION " Android " BUILD_DATE
72+
#elif defined (_FLTK)
73+
#define SB_STR_VER VERSION " FLTK " BUILD_DATE
7274
#else
7375
#define SB_STR_VER VERSION " Console " SB_VERSYS SB_BIT_SZ BUILD_DATE
7476
#endif

src/common/var.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -790,3 +790,8 @@ void v_input2var(const char *str, var_t *var) {
790790
}
791791
}
792792

793+
void v_create_func(var_p_t map, const char *name, method cb) {
794+
var_p_t v_func = map_add_var(map, name, 0);
795+
v_func->type = V_FUNC;
796+
v_func->v.fn.cb = cb;
797+
}

src/include/var.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,13 @@ int v_strlen(const var_t *v);
467467
*/
468468
#define v_is_type(v, t) (v != NULL && v->type == t)
469469

470+
/**
471+
* @ingroup var
472+
*
473+
* setup a method on the map using the given name
474+
*/
475+
void v_create_func(var_p_t map, const char *name, method cb);
476+
470477
#if defined(__cplusplus)
471478
}
472479
#endif

src/platform/console/image.cpp

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,6 @@ ImageBuffer::~ImageBuffer() {
7070
_image = NULL;
7171
}
7272

73-
void create_function(var_p_t map, const char *name, method cb) {
74-
var_p_t v_func = map_add_var(map, name, 0);
75-
v_func->type = V_FUNC;
76-
v_func->v.fn.cb = cb;
77-
}
78-
7973
dev_file_t *get_file() {
8074
dev_file_t *result = NULL;
8175
code_skipnext();
@@ -434,10 +428,10 @@ void create_image(var_p_t var, ImageBuffer *image) {
434428
var_p_t value = map_add_var(var, IMG_NAME, 0);
435429
v_setstr(value, image->_filename);
436430
}
437-
create_function(var, "clip", cmd_image_clip);
438-
create_function(var, "filter", cmd_image_filter);
439-
create_function(var, "paste", cmd_image_paste);
440-
create_function(var, "save", cmd_image_save);
431+
v_create_func(var, "clip", cmd_image_clip);
432+
v_create_func(var, "filter", cmd_image_filter);
433+
v_create_func(var, "paste", cmd_image_paste);
434+
v_create_func(var, "save", cmd_image_save);
441435
}
442436

443437
//

0 commit comments

Comments
 (0)