Commit 27d57562 authored by John P. Willis's avatar John P. Willis
Browse files

Make MWAPI compilation conditional

parent ecdb23f0
Pipeline #676 failed with stage
in 10 seconds
......@@ -44,11 +44,17 @@ AC_CONFIG_MACRO_DIRS([m4])
PKG_PROG_PKG_CONFIG
PKG_CHECK_MODULES([FREEM], [
glib-2.0
gtk+-3.0
x11
])
AC_ARG_ENABLE([mwapigtk],
AS_HELP_STRING([--enable-mwapigtk], [Enable MWAPI (GTK) support]))
AS_IF([test "x$enable_mwapigtk" = "xyes"], [
PKG_CHECK_MODULES([FREEM], [
glib-2.0
gtk+-3.0
x11
])
AC_DEFINE([MWAPI_GTK], [1], [Define if --enable-mwapigtk is set])
])
AX_LIB_READLINE
......
......@@ -272,7 +272,7 @@ $ chmod +x @emph{myscript.m}
@cindex modes, programmer
The FreeM direct-mode environment is the mode entered when FreeM is loaded without the use of @option{-r @emph{<entryref>}} or @option{--routine=@emph{<entryref>}}:
The FreeM direct-mode environment is the mode entered when FreeM is invoked without the use of @option{-r @emph{<entryref>}} or @option{--routine=@emph{<entryref>}}:
@example
Coherent Logic Development FreeM version 0.44.0 (x86_64-pc-linux-gnu)
......@@ -315,8 +315,18 @@ POWER Disabled 0
TIMER Disabled 0
USER Disabled 0
WAPI Disabled 0
TRIGGER Disabled 0
@end example
@item @command{tdump}
Displays information about any uncommitted transactions currently in-flight for this process.
@item @command{shmstat}
Displays the configuration of FreeM shared memory. Intended only for advanced debugging of the FreeM environment.
@item @command{shmpages}
Lists the status of each FreeM shared memory page. Intended only for advanced debugging of the FreeM environment.
@item @command{history}
Prints a list of all the direct-mode commands you have entered across all sessions.
......@@ -346,9 +356,6 @@ If the @command{>} character is supplied immediately preceding @emph{<external-c
@code{%} contains the number of lines in the input or output. @code{%(1)..%(@emph{n})} contains the data for lines 1-@emph{n}.
@item @command{tdump}
Writes detailed information about the status of any pending transactions to @code{$PRINCIPAL}.
@end table
@cindex HALT, in direct-mode
......@@ -392,7 +399,7 @@ USER> 100/DENOM
USER>
@end example
Such expressions will be immediately evaluated, and the result printed on @code{$PRINCIPAL}.
Such expressions will be immediately evaluated, and the result printed on @code{$IO}.
@node Intrinsic Special Variables
@chapter Intrinsic Special Variables
......@@ -432,6 +439,14 @@ Sets or retrieves the M code that is run when an error is encountered or @code{$
Returns a string containing the current date and time as @code{<days>,<seconds>}, where @code{<days>} represents the number of days since the M epoch (midnight on 31 December 1840),
and @code{<seconds>} represents the number of seconds since the most recent midnight.
@cartouche
@quotation
@emph{FreeM Extension}
In FreeM, @code{$HOROLOG} is @code{SET}table. Setting @code{$HOROLOG} will set the system clock if your user account has the appropriate permissions. If your user account does not have permissions to modify the system clock, FreeM will raise a @code{ZPROTECT} error.
@end quotation
@end cartouche
@section $IO
@cindex $IO
@cindex intrinsic special variables, $IO
......@@ -503,6 +518,8 @@ Returns the MDC system ID of FreeM.
@code{$TEST} is implicitly @code{NEW}ed when entering a new stack frame for extrinsic functions and argumentless @code{DO}. @code{$TEST}
is @emph{not} implicitly @code{NEW}ed when a new stack frame is entered with an argumented @code{DO}.
For single-line @code{IF} or @code{ELSE} expressions, you may use @code{THEN} to stack @code{$TEST} until the end of the line. All new code should employ @code{THEN} in this manner, as stacking @code{$TEST} prevents a wide range of coding errors that can be very challenging to detect and eliminate.
@section $TLEVEL
@cindex $TLEVEL
@cindex intrinsic special variables, $TLEVEL
......@@ -622,13 +639,15 @@ Gets or sets the number of digits of numeric precision used for fixed-point deci
@cindex intrinsic special variables, $ZREFERENCE
@cindex intrinsic special variables, implementation-specific
Returns the last @emph{glvn} referenced.
Returns the last @emph{gvn} referenced.
@section $ZSYSTEM
@cindex $ZSYSTEM
@cindex intrinsic special variables, $ZSYSTEM
@cindex intrinsic special variables, implementation-specific
Represents the return value of the last external command run with @code{!}.
@section $ZTIME
@cindex $ZTIME
@cindex intrinsic special variables, $ZTIME
......@@ -815,32 +834,119 @@ The optional third argument is the first @code{d}-delimited piece to access, and
The optional fourth argument is the final @code{d}-delimited piece to access, and defaults to the value of the third argument (@code{n}).
Can be used on the right-hand side of an expression in order to @code{SET} a value into a @code{d}-delimited piece of @code{s}.
Can be used on the left-hand side of an expression in order to @code{SET} a value into a @code{d}-delimited piece of @code{s}, as in:
@example
; ^jpw="this^is^a^piece"
SET $PIECE(^jpw,"^",2)="isn't" ; => "this^isn't^a^piece"
@end example
@section $QLENGTH
@cindex $QLENGTH
@cindex intrinsic functions, $QLENGTH
@emph{Syntax}
@example
@code{$QLENGTH(@emph{expr V glvn})}
@end example
Returns the number of subscripts in @emph{glvn}.
@emph{Example}
@example
@code{SET SUBCT=$QLENGTH("^GBL(1,2,3)") ; => 3}
@end example
@section $QSUBSCRIPT
@cindex $QSUBSCRIPT
@cindex intrinsic functions, $QSUBSCRIPT
@emph{Syntax}
@example
@code{$QSUBSCRIPT(@emph{expr V glvn},@emph{expr V n})}
@end example
Returns the @emph{n}th subscript of @emph{glvn}.
@emph{Example}
@example
@code{SET SUB=$QSUBSCRIPT("^GBL(1,2,3)",2) ; => 2}
@end example
@section $QUERY
@cindex $QUERY
@cindex intrinsic functions, $QUERY
Returns the next subscripted reference in a global.
@emph{Syntax}
@example
@code{$QUERY(@emph{glvn})}
@end example
@emph{Example}
We will assume the following data structure exists:
@example
^jpw(1)=1
^jpw(1,2)="foo"
^jpw(2)=3
^jpw(3)=""
@end example
The following code will retrieve the next subscripted name after @code{^jpw(1)}:
@example
@code{SET NEXTNAM=$QUERY(^jpw(1)) ; => ^jpw(1,2)}
@end example
@section $RANDOM
@cindex $RANDOM
@cindex intrinsic functions, $RANDOM
@emph{Syntax}
@example
$RANDOM(@emph{max})
@end example
Returns a pseudo-random integer in the range of @code{0..@emph{max} - 1}
@section $REVERSE
@cindex $REVERSE
@cindex intrinsic functions, $REVERSE
@emph{Syntax}
@example
$REVERSE(@emph{s})
@end example
Returns the reverse of string @emph{s}.
@emph{Example}
@example
SET FOO=$REVERSE("ABC") ; => CBA
@end example
@section $SELECT
@cindex $SELECT
@cindex intrinsic functions, $SELECT
Returns a value corresponding to the first true condition in a list of conditional expressions. Each argument is an expression, followed by a colon, followed by an expression whose value will be returned if the first expression is true. If no expressions are true, error condition @code{M4} is raised.
@emph{Example}
@example
SET FOO=$SELECT(1=2:"math is broken",1=1:"the world makes sense") ; => "the world makes sense"
@end example
@section $STACK
@cindex $STACK
@cindex intrinsic functions, $STACK
......@@ -881,6 +987,8 @@ Returns the error codes, M program code, or entryref applicable to the action th
@cindex $TEXT
@cindex intrinsic functions, $TEXT
Returns a line of code from a routine.
@section $TRANSLATE
@cindex $TRANSLATE
@cindex intrinsic functions, $TRANSLATE
......@@ -945,11 +1053,6 @@ Always @emph{true}
@cindex intrinsic functions, $ZCALL
@cindex intrinsic functions, implementation-specific
@section $ZCR
@cindex $ZCR
@cindex intrinsic functions, $ZCR
@cindex intrinsic functions, implementation-specific
@section $ZCRC
@cindex $ZCRC
@cindex intrinsic functions, $ZCRC
......
......@@ -46,7 +46,12 @@
#include <sys/stat.h>
#include <pwd.h>
#include <time.h>
#include <gtk/gtk.h>
#include "config.h"
#if defined(MWAPI_GTK)
# include <gtk/gtk.h>
#endif
#include "mpsdef.h"
#include "transact.h"
......@@ -457,12 +462,19 @@ void init_estack (void)
stcpy (merr_stack[0].PLACE, "xecline()\201");
}
#if defined(MWAPI_GTK)
void init_mwapi (void)
{
if (getenv("DISPLAY") != NULL) {
gtk_init (0, NULL);
}
}
}
#else
void init_mwapi (void)
{
return;
}
#endif
void init_io (void)
{
......
......@@ -36,6 +36,9 @@
* along with FreeM. If not, see <https://www.gnu.org/licenses/>.
*
**/
#include "config.h"
#if defined(MWAPI_GTK)
#include <gtk/gtk.h>
#include "mpsdef0.h"
......@@ -133,3 +136,5 @@ void mwapi_on_merge_complete(char *window_name)
}
}
#endif
......@@ -37,7 +37,9 @@
*
**/
#if !defined(__MWAPI_EVENT_H)
#include "config.h"
#if !defined(__MWAPI_EVENT_H) && defined(MWAPI_GTK)
# define __MWAPI_EVENT_H
#include <gtk/gtk.h>
......
......@@ -37,6 +37,10 @@
*
**/
#include "config.h"
#if defined(MWAPI_GTK)
#include "mpsdef0.h"
#include "mwapi_window.h"
#include "mwapi_event.h"
......@@ -113,3 +117,4 @@ mwapi_window *mwapi_win_get(char *window_name)
return t;
}
#endif
......@@ -37,7 +37,9 @@
*
**/
#if !defined(__MWAPI_WINDOW_H)
#include "config.h"
#if !defined(__MWAPI_WINDOW_H) && defined(MWAPI_GTK)
# define __MWAPI_WINDOW_H
#include <gtk/gtk.h>
......
......@@ -41,6 +41,7 @@
#include <stdio.h>
#include "shmmgr.h"
#include "mpsdef.h"
#include <assert.h>
shm_config_t *shm_config;
......@@ -120,6 +121,8 @@ short shm_init(const size_t seg_size)
}
}
assert(shm_address_to_page_num(shm_page_num_to_address(20)) == 20);
}
......@@ -137,20 +140,10 @@ void *shm_page_num_to_address(const int page_num)
int shm_address_to_page_num(const void *address)
{
void *btm_a = shm_page_num_to_address (0);
void *top_a = shm_page_num_to_address (shm_config->pgct - 1);
unsigned long old_min = (unsigned long) btm_a;
unsigned long old_max = (unsigned long) top_a;
int new_min = 0;
int new_max = shm_config->pgct - 1;
unsigned long val = (unsigned long) address - (unsigned long) shm_config->buf;
unsigned long new_val = val / shm_config->pgsiz;
unsigned long val = (unsigned long) address;
//(max'-min')/(max-min)*(value-max)+max'
return (int) (new_max - new_min) / (old_max - old_min) * (val - old_max) + new_max;
return (int) new_val;
}
void *shm_alloc_pages(const int page_count)
......@@ -264,7 +257,7 @@ void shm_free_page(const int page_number)
void shm_free(const void *addr)
{
shm_free_page (shm_address_to_page_num (addr));
}
void *shmd_find(const short shmd_key)
......
......@@ -43,13 +43,17 @@
#include <errno.h>
#include <ctype.h>
#include <unistd.h>
#include "mpsdef.h"
#if defined(MWAPI_GTK)
#include <gtk/gtk.h>
#include <X11/Xlib.h>
#include <glib.h>
#include <pango/pangocairo.h>
#include "mref.h"
#include "mpsdef.h"
int ssvn_display_initialized = 0;
char clipboard_buffer[256];
......@@ -251,3 +255,16 @@ done:
return;
}
#else
void ssvn_display_update(void)
{
return;
}
void ssvn_display(short action, char *key, char *data)
{
ierr = M38;
*data = EOL;
return;
}
#endif
#ifndef FREEM_VERSION_H
#define FREEM_VERSION_H
#define FREEM_VERSION_ID PACKAGE_VERSION"\201"
#define FREEM_VERSION_STR PACKAGE_VERSION" ("HOST")\201"
#define FREEM_VERSION_CSTR PACKAGE_VERSION" ("HOST")"
#if !defined(MWAPI_GTK)
# define FREEM_VERSION_STR PACKAGE_VERSION" ("HOST")\201"
# define FREEM_VERSION_CSTR PACKAGE_VERSION" ("HOST")"
#else
# define FREEM_VERSION_STR PACKAGE_VERSION" ("HOST" [MWAPI/GTK])\201"
# define FREEM_VERSION_CSTR PACKAGE_VERSION" ("HOST" [MWAPI/GTK])"
#endif
#endif
......@@ -91,10 +91,12 @@
#endif /* LINUX_GLIBC */
#if defined(MWAPI_GTK)
void destroy(GtkWidget* widget, gpointer data)
{
gtk_main_quit();
}
#endif
void view_com ()
......@@ -601,9 +603,11 @@ void view_com ()
break;
case 103: /* MERGE to ^$WINDOW complete. Parameter is empty (for all windows) or string for window name in subscript 1 */
#if defined(MWAPI_GTK)
mwapi_on_merge_complete (argptr);
#endif
break;
case 110: /* VIEW 110: local $o/$q data value */
......
......@@ -216,8 +216,11 @@ int xecline(int typ)
register int ch;
int then_ctr = 0;
#if defined(MWAPI_GTK)
int syn_event_entry_nstx = 0;
int in_syn_event_loop = FALSE;
#endif
# ifdef DEBUG_NEWSTACK
int loop;
......@@ -2958,8 +2961,9 @@ quit0:
ierr = deferred_ierr;
}
#if defined(MWAPI_GTK)
if ((in_syn_event_loop == TRUE) && (nstx == syn_event_entry_nstx)) goto syn_evt_loop_bottom;
#endif
break;
......@@ -6766,7 +6770,8 @@ evthandler: /* for event handlers */
ierr = CMMND;
break;
#if defined(MWAPI_GTK)
case ESTART:
{
if (in_syn_event_loop == TRUE) break;
......@@ -6818,6 +6823,7 @@ syn_evt_loop_bottom:
case ESTOP:
evt_sync_enabled = FALSE;
break;
#endif
default:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment