diff options
author | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2018-06-11 05:10:19 +0600 |
---|---|---|
committer | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2018-06-11 05:10:19 +0600 |
commit | 524bc3960e6a6e5645ce904e20f72479e24e0a23 (patch) | |
tree | 4147b687b1de89d41a2bd2a5fd02620a64e75a77 | |
parent | df6c898e8e56886488951bc51967089003768b12 (diff) | |
download | sciteco-524bc3960e6a6e5645ce904e20f72479e24e0a23.tar.gz |
improved Emscripten support: fixed configure-checks, generate *.js and detect EMCurses
* Emscripten can be used (theoretically) to build a host-only platform-independant version
of SciTECO (running under node.js instead of the browser).
* I ported netbsd-curses with Emscripten for that purpose. Therefore, adaptions for running
in the browser are restricted to EMcurses now.
-rw-r--r-- | configure.ac | 20 | ||||
-rw-r--r-- | src/cmdline.cpp | 6 | ||||
-rw-r--r-- | src/interface-curses/interface-curses.cpp | 13 | ||||
-rw-r--r-- | src/parser.h | 8 |
4 files changed, 33 insertions, 14 deletions
diff --git a/configure.ac b/configure.ac index 032ab10..dd4854d 100644 --- a/configure.ac +++ b/configure.ac @@ -57,7 +57,6 @@ AX_CXX_COMPILE_STDCXX(11, noext, mandatory) AC_PROG_CC AC_PROG_CC_C99 AC_PROG_SED -AC_PROG_GREP AC_PROG_INSTALL # Mainly because of Scintilla, which depends on @@ -88,10 +87,18 @@ case $host in ;; esac -# Detect Clang. Emscripten is based on Clang as well. -if $CXX --version | $GREP -E "clang|Emscripten" >/dev/null; then +# Detect Clang (including Emscripten). +# A particular warning does not cooperate well with our use +# of the BSD data structures. +AC_CHECK_DECL(__clang__, [ CXXFLAGS="$CXXFLAGS -Wno-mismatched-tags" -fi +]) + +# Changing the EXEEXT on emscripten ensures that we don't +# need a special Makefile rule to generate Javascript files. +AC_CHECK_DECL(EMSCRIPTEN, [ + EXEEXT=.js +]) AC_CHECK_PROG(DATE, date, date) if [[ x$DATE = x ]]; then @@ -179,7 +186,10 @@ esac # Some of this will only be found on glibc, # others on FreeBSD/jemalloc. AC_CHECK_HEADERS([malloc.h malloc_np.h]) -AC_CHECK_FUNCS([malloc_trim malloc_usable_size]) +AC_CHECK_FUNCS([malloc_trim malloc_usable_size], [ + # Sometimes the declaration is missing. + AC_CHECK_DECLS([malloc_trim]) +]) # # Config options diff --git a/src/cmdline.cpp b/src/cmdline.cpp index daf1a9b..9262e27 100644 --- a/src/cmdline.cpp +++ b/src/cmdline.cpp @@ -47,6 +47,12 @@ #include "error.h" #include "cmdline.h" +extern "C" { +#if defined(HAVE_MALLOC_TRIM) && !HAVE_DECL_MALLOC_TRIM +int malloc_trim(size_t pad); +#endif +} + namespace SciTECO { static gchar *filename_complete(const gchar *filename, gchar completed = ' ', diff --git a/src/interface-curses/interface-curses.cpp b/src/interface-curses/interface-curses.cpp index 96ce0d4..a06fe30 100644 --- a/src/interface-curses/interface-curses.cpp +++ b/src/interface-curses/interface-curses.cpp @@ -89,6 +89,15 @@ #define A_UNDERLINE 0 #endif +/** + * Whether we're on EMCurses. + * Could be replaced with a configure-time check for + * PDC_emscripten_set_handler(). + */ +#if defined(__PDCURSES__) && defined(EMSCRIPTEN) +#define EMCURSES +#endif + #ifdef NCURSES_VERSION #if defined(G_OS_UNIX) || defined(G_OS_HAIKU) /** @@ -630,7 +639,7 @@ InterfaceCurses::init_interactive(void) cmdline_window = newwin(0, 0, LINES - 1, 0); keypad(cmdline_window, TRUE); -#ifdef EMSCRIPTEN +#ifdef EMCURSES nodelay(cmdline_window, TRUE); #endif @@ -1533,7 +1542,7 @@ InterfaceCurses::event_loop_impl(void) wnoutrefresh(cmdline_window); doupdate(); -#ifdef EMSCRIPTEN +#ifdef EMCURSES PDC_emscripten_set_handler(event_loop_iter, TRUE); /* * We must not block emscripten's main loop, diff --git a/src/parser.h b/src/parser.h index f61d335..9255268 100644 --- a/src/parser.h +++ b/src/parser.h @@ -149,13 +149,7 @@ protected: MicroState state; -#ifdef EMSCRIPTEN - /* FIXME: Shouldn't be required! */ - __attribute__((noinline)) -#else - inline -#endif - void + inline void set(MicroState next) { if (next != state) |