Make globals.h a generated header

* configure: Rebuild.
	* configure.in (NS_OBJC_OBJ): New subst.
lib-src
	* make-docfile.c: Unconditionally include stdlib.h.
	(generate_globals): New global.
	(xrealloc): New function.
	(main): Handle '-g'.  Call start_globals, write_globals.
	(scan_file): Conditionally call put_filename.
	(start_globals): New function.
	(struct global): New.
	(num_globals, globals): New globals.
	(add_global, compare_globals, write_globals): New functions.
	(scan_c_file): Update for "-g".
	(scan_lisp_file): Fail if "-g".
	(enum global_type): New.
src
	* Makefile.in (NS_OBJC_OBJ): New variable.
	(base_obj): Rename from 'obj'.
	(obj): New variable.
	(globals.h, gl-stamp, $(obj)): New targets.
	(GLOBAL_SOURCES): New variable.
	* globals.h: Remove.
	* nsselect.m (Vselection_alist): Define.  Reverts part of
	2011-01-19T22:11:33Z!jan.h.d@swipnet.se.
	* buffer.c: Don't use "no_cell" for name of kill-buffer-hook's
	variable.
	* xselect.c (Vselection_alist): Define.  Reverts part of 2011-01-19T23:32:42Z!eggert@cs.ucla.edu.
This commit is contained in:
Tom Tromey 2011-02-08 14:42:56 -07:00
parent 6ca94a0b49
commit 00b3c7ac85
11 changed files with 257 additions and 2909 deletions

View file

@ -1,3 +1,8 @@
2011-02-08 Tom Tromey <tromey@redhat.com>
* configure: Rebuild.
* configure.in (NS_OBJC_OBJ): New subst.
2011-02-06 Paul Eggert <eggert@cs.ucla.edu>
gnulib: allow multiple gnulib generated replacements to coexist

9
configure vendored
View file

@ -864,6 +864,7 @@ GMALLOC_OBJ
HAVE_XSERVER
LIB_STANDARD
NS_SUPPORT
NS_OBJC_OBJ
NS_OBJ
TEMACS_LDFLAGS2
LD_SWITCH_X_SITE_AUX_RPATH
@ -1042,9 +1043,6 @@ LDFLAGS
LIBS
CPPFLAGS
CPP
CPPFLAGS
CPP
CPPFLAGS
XMKMF'
@ -8791,6 +8789,7 @@ fi
ns_frag=/dev/null
NS_OBJ=
NS_OBJC_OBJ=
NS_SUPPORT=
if test "${HAVE_NS}" = yes; then
window_system=nextstep
@ -8802,7 +8801,8 @@ if test "${HAVE_NS}" = yes; then
prefix=${ns_appresdir}
fi
ns_frag=$srcdir/src/ns.mk
NS_OBJ="nsterm.o nsfns.o nsmenu.o nsselect.o nsimage.o nsfont.o fontset.o fringe.o image.o"
NS_OBJ="fontset.o fringe.o image.o"
NS_OBJC_OBJ="nsterm.o nsfns.o nsmenu.o nsselect.o nsimage.o nsfont.o"
NS_SUPPORT="\${lispsource}/emacs-lisp/easymenu.elc \${lispsource}/term/ns-win.elc"
fi
CFLAGS="$tmp_CFLAGS"
@ -8812,6 +8812,7 @@ CPPFLAGS="$tmp_CPPFLAGS"
case "${window_system}" in
x11 )
HAVE_X_WINDOWS=yes

View file

@ -1519,6 +1519,7 @@ AC_SUBST(TEMACS_LDFLAGS2)
ns_frag=/dev/null
NS_OBJ=
NS_OBJC_OBJ=
NS_SUPPORT=
if test "${HAVE_NS}" = yes; then
window_system=nextstep
@ -1530,12 +1531,14 @@ if test "${HAVE_NS}" = yes; then
prefix=${ns_appresdir}
fi
ns_frag=$srcdir/src/ns.mk
NS_OBJ="nsterm.o nsfns.o nsmenu.o nsselect.o nsimage.o nsfont.o fontset.o fringe.o image.o"
NS_OBJ="fontset.o fringe.o image.o"
NS_OBJC_OBJ="nsterm.o nsfns.o nsmenu.o nsselect.o nsimage.o nsfont.o"
NS_SUPPORT="\${lispsource}/emacs-lisp/easymenu.elc \${lispsource}/term/ns-win.elc"
fi
CFLAGS="$tmp_CFLAGS"
CPPFLAGS="$tmp_CPPFLAGS"
AC_SUBST(NS_OBJ)
AC_SUBST(NS_OBJC_OBJ)
AC_SUBST(NS_SUPPORT)
AC_SUBST(LIB_STANDARD)
AC_SUBST_FILE(ns_frag)

View file

@ -1,3 +1,17 @@
2011-02-08 Tom Tromey <tromey@redhat.com>
* make-docfile.c: Unconditionally include stdlib.h.
(generate_globals): New global.
(xrealloc): New function.
(main): Handle '-g'. Call start_globals, write_globals.
(scan_file): Conditionally call put_filename.
(start_globals): New function.
(struct global): New.
(num_globals, globals): New globals.
(add_global, compare_globals, write_globals): New functions.
(scan_c_file): Update for "-g".
(scan_lisp_file): Fail if "-g".
2011-02-05 Paul Eggert <eggert@cs.ucla.edu>
* emacsclient.c: conform to C89 pointer rules

View file

@ -41,11 +41,11 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#undef chdir
#include <stdio.h>
#include <stdlib.h>
#ifdef MSDOS
#include <fcntl.h>
#endif /* MSDOS */
#ifdef WINDOWSNT
#include <stdlib.h>
#include <fcntl.h>
#include <direct.h>
#endif /* WINDOWSNT */
@ -70,6 +70,8 @@ int scan_file (char *filename);
int scan_lisp_file (const char *filename, const char *mode);
int scan_c_file (char *filename, const char *mode);
void fatal (const char *s1, const char *s2) NO_RETURN;
void start_globals (void);
void write_globals (void);
#ifdef MSDOS
/* s/msdos.h defines this as sys_chdir, but we're not linking with the
@ -85,6 +87,9 @@ FILE *outfile;
/* Name this program was invoked with. */
char *progname;
/* Nonzero if this invocation is generating globals.h. */
int generate_globals;
/* Print error message. `s1' is printf control string, `s2' is arg for it. */
/* VARARGS1 */
@ -116,6 +121,18 @@ xmalloc (unsigned int size)
fatal ("virtual memory exhausted", 0);
return result;
}
/* Like realloc but get fatal error if memory is exhausted. */
void *
xrealloc (void *arg, unsigned int size)
{
void *result = (void *) realloc (arg, size);
if (result == NULL)
fatal ("virtual memory exhausted", 0);
return result;
}
int
main (int argc, char **argv)
@ -164,10 +181,18 @@ main (int argc, char **argv)
}
i += 2;
}
if (argc > i && !strcmp (argv[i], "-g"))
{
generate_globals = 1;
++i;
}
if (outfile == 0)
fatal ("No output file specified", "");
if (generate_globals)
start_globals ();
first_infile = i;
for (; i < argc; i++)
{
@ -179,6 +204,10 @@ main (int argc, char **argv)
if (j == i)
err_count += scan_file (argv[i]);
}
if (err_count == 0 && generate_globals)
write_globals ();
return (err_count > 0 ? EXIT_FAILURE : EXIT_SUCCESS);
}
@ -208,7 +237,8 @@ scan_file (char *filename)
size_t len = strlen (filename);
put_filename (filename);
if (!generate_globals)
put_filename (filename);
if (len > 4 && !strcmp (filename + len - 4, ".elc"))
return scan_lisp_file (filename, READ_BINARY);
else if (len > 3 && !strcmp (filename + len - 3, ".el"))
@ -216,6 +246,14 @@ scan_file (char *filename)
else
return scan_c_file (filename, READ_TEXT);
}
void
start_globals (void)
{
fprintf (outfile, "/* This file was auto-generated by make-docfile. */\n");
fprintf (outfile, "/* DO NOT EDIT. */\n");
fprintf (outfile, "struct emacs_globals {\n");
}
char buf[128];
@ -516,6 +554,98 @@ write_c_args (FILE *out, char *func, char *buf, int minargs, int maxargs)
putc (')', out);
}
/* The types of globals. */
enum global_type
{
EMACS_INT,
BOOLEAN,
LISP_OBJECT,
INVALID
};
/* A single global. */
struct global
{
enum global_type type;
char *name;
};
/* All the variable names we saw while scanning C sources in `-g'
mode. */
int num_globals;
int num_globals_allocated;
struct global *globals;
static void
add_global (enum global_type type, char *name)
{
/* Ignore the one non-symbol that can occur. */
if (strcmp (name, "..."))
{
++num_globals;
if (num_globals_allocated == 0)
{
num_globals_allocated = 100;
globals = xmalloc (num_globals_allocated * sizeof (struct global));
}
else if (num_globals == num_globals_allocated)
{
num_globals_allocated *= 2;
globals = xrealloc (globals,
num_globals_allocated * sizeof (struct global));
}
globals[num_globals - 1].type = type;
globals[num_globals - 1].name = name;
}
}
static int
compare_globals (const void *a, const void *b)
{
const struct global *ga = a;
const struct global *gb = b;
return strcmp (ga->name, gb->name);
}
void
write_globals (void)
{
int i;
qsort (globals, num_globals, sizeof (struct global), compare_globals);
for (i = 0; i < num_globals; ++i)
{
char *type;
switch (globals[i].type)
{
case EMACS_INT:
type = "EMACS_INT";
break;
case BOOLEAN:
type = "int";
break;
case LISP_OBJECT:
type = "Lisp_Object";
break;
default:
fatal ("not a recognized DEFVAR_", 0);
}
fprintf (outfile, " %s f_%s;\n", type, globals[i].name);
fprintf (outfile, "#define %s globals.f_%s\n",
globals[i].name, globals[i].name);
while (i + 1 < num_globals
&& !strcmp (globals[i].name, globals[i + 1].name))
++i;
}
fprintf (outfile, "};\n");
fprintf (outfile, "extern struct emacs_globals globals;\n");
}
/* Read through a c file. If a .o file is named,
the corresponding .c or .m file is read instead.
@ -533,6 +663,7 @@ scan_c_file (char *filename, const char *mode)
register int defvarflag;
int minargs, maxargs;
int extension = filename[strlen (filename) - 1];
enum global_type type;
if (extension == 'o')
filename[strlen (filename) - 1] = 'c';
@ -599,8 +730,23 @@ scan_c_file (char *filename, const char *mode)
c = getc (infile);
defvarperbufferflag = (c == 'P');
if (generate_globals)
{
if (c == 'I')
type = EMACS_INT;
else if (c == 'L')
type = LISP_OBJECT;
else if (c == 'B')
type = BOOLEAN;
else
type = INVALID;
}
c = getc (infile);
/* We need to distinguish between DEFVAR_BOOL and
DEFVAR_BUFFER_DEFAULTS. */
if (generate_globals && type == BOOLEAN && c != 'O')
type = INVALID;
}
else if (c == 'D')
{
@ -617,6 +763,10 @@ scan_c_file (char *filename, const char *mode)
}
else continue;
if (generate_globals && (!defvarflag || defvarperbufferflag
|| type == INVALID))
continue;
while (c != '(')
{
if (c < 0)
@ -630,6 +780,34 @@ scan_c_file (char *filename, const char *mode)
continue;
c = read_c_string_or_comment (infile, -1, 0, 0);
if (generate_globals)
{
int i = 0;
char *name;
/* Skip "," and whitespace. */
do
{
c = getc (infile);
}
while (c == ',' || c == ' ' || c == '\t' || c == '\n' || c == '\r');
/* Read in the identifier. */
do
{
buf[i++] = c;
c = getc (infile);
}
while (! (c == ',' || c == ' ' || c == '\t' ||
c == '\n' || c == '\r'));
buf[i] = '\0';
name = xmalloc (i + 1);
memcpy (name, buf, i + 1);
add_global (type, name);
continue;
}
/* DEFVAR_LISP ("name", addr, "doc")
DEFVAR_LISP ("name", addr /\* doc *\/)
DEFVAR_LISP ("name", addr, doc: /\* doc *\/) */
@ -845,6 +1023,9 @@ scan_lisp_file (const char *filename, const char *mode)
register int c;
char *saved_string = 0;
if (generate_globals)
fatal ("scanning lisp file when -g specified", 0);
infile = fopen (filename, mode);
if (infile == NULL)
{

View file

@ -1,3 +1,17 @@
2011-02-08 Tom Tromey <tromey@redhat.com>
* Makefile.in (NS_OBJC_OBJ): New variable.
(base_obj): Rename from 'obj'.
(obj): New variable.
(globals.h, gl-stamp, $(obj)): New targets.
(GLOBAL_SOURCES): New variable.
* globals.h: Remove.
* nsselect.m (Vselection_alist): Define. Reverts part of
2011-01-19T22:11:33Z!jan.h.d@swipnet.se.
* buffer.c: Don't use "no_cell" for name of kill-buffer-hook's
variable.
* xselect.c (Vselection_alist): Define. Reverts part of 2011-01-19T23:32:42Z!eggert@cs.ucla.edu.
2011-02-08 Kenichi Handa <handa@m17n.org>
* font.c (Ffont_get): Do not cache :otf value.

View file

@ -247,6 +247,7 @@ ns_appdir=@ns_appdir@
ns_appbindir=@ns_appbindir@
ns_appsrc=@ns_appsrc@
NS_OBJ=@NS_OBJ@
NS_OBJC_OBJ=@NS_OBJC_OBJ@
NS_SUPPORT=@NS_SUPPORT@
## Only set if NS_IMPL_GNUSTEP.
GNU_OBJC_CFLAGS=@GNU_OBJC_CFLAGS@
@ -341,7 +342,7 @@ ALL_OBJC_CFLAGS=$(ALL_CFLAGS) $(GNU_OBJC_CFLAGS)
## lastfile must follow all files whose initialized data areas should
## be dumped as pure by dump-emacs.
obj= dispnew.o frame.o scroll.o xdisp.o menu.o $(XMENU_OBJ) window.o \
base_obj = dispnew.o frame.o scroll.o xdisp.o menu.o $(XMENU_OBJ) window.o \
charset.o coding.o category.o ccl.o character.o chartab.o bidi.o \
cm.o term.o terminal.o xfaces.o $(XOBJ) $(GTK_OBJ) $(DBUS_OBJ) \
emacs.o keyboard.o macros.o keymap.o sysdep.o \
@ -355,6 +356,7 @@ obj= dispnew.o frame.o scroll.o xdisp.o menu.o $(XMENU_OBJ) window.o \
region-cache.o sound.o atimer.o \
doprnt.o intervals.o textprop.o composite.o md5.o xml.o \
$(MSDOS_OBJ) $(MSDOS_X_OBJ) $(NS_OBJ) $(CYGWIN_OBJ) $(FONT_OBJ)
obj = $(base_obj) $(NS_OBJC_OBJ)
## Object files used on some machine or other.
## These go in the DOC file on all machines in case they are needed.
@ -645,6 +647,18 @@ $(libsrc)/make-docfile$(EXEEXT):
buildobj.h: Makefile
echo "#define BUILDOBJ \"$(obj) $(otherobj) " "\"" > buildobj.h
globals.h: gl-stamp
cp gl-stamp globals.h
GLOBAL_SOURCES = $(base_obj:.o=.c) $(NS_OBJC_OBJ:.o=.m)
gl-stamp: $(libsrc)/make-docfile$(EXEEXT) $(GLOBAL_SOURCES)
@rm -f gl-tmp
$(libsrc)/make-docfile -d $(srcdir) -g $(SOME_MACHINE_OBJECTS) $(obj) > gl-tmp
$(srcdir)/../move-if-change gl-tmp gl-stamp
$(obj): globals.h
$(lib)/libgnu.a: $(config_h)
cd $(lib) && $(MAKE) libgnu.a

View file

@ -1320,7 +1320,7 @@ No argument or nil as argument means do this for the current buffer. */)
}
/*
DEFVAR_LISP ("kill-buffer-hook", no_cell, "\
DEFVAR_LISP ("kill-buffer-hook", ..., "\
Hook to be run (by `run-hooks', which see) when a buffer is killed.\n\
The buffer being killed will be current while the hook is running.\n\
See `kill-buffer'."

File diff suppressed because it is too large Load diff

View file

@ -39,6 +39,8 @@ Updated by Christian Limpach (chris@nice.ch)
Lisp_Object QCLIPBOARD, QSECONDARY, QTEXT, QFILE_NAME;
static Lisp_Object Vselection_alist;
static Lisp_Object Qforeign_selection;
/* NSGeneralPboard is pretty much analogous to X11 CLIPBOARD */

View file

@ -126,6 +126,20 @@ static Lisp_Object Qforeign_selection;
/* Defined in keyboard.c. */
extern unsigned long last_event_timestamp;
/* This is an association list whose elements are of the form
( SELECTION-NAME SELECTION-VALUE SELECTION-TIMESTAMP FRAME)
SELECTION-NAME is a lisp symbol, whose name is the name of an X Atom.
SELECTION-VALUE is the value that emacs owns for that selection.
It may be any kind of Lisp object.
SELECTION-TIMESTAMP is the time at which emacs began owning this selection,
as a cons of two 16-bit numbers (making a 32 bit time.)
FRAME is the frame for which we made the selection.
If there is an entry in this alist, then it can be assumed that Emacs owns
that selection.
The only (eq) parts of this list that are visible from Lisp are the
selection-values. */
static Lisp_Object Vselection_alist;
/* Define a queue to save up SELECTION_REQUEST_EVENT events for later