1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-15 10:30:25 -08:00

Auto-generate EXFUN using make-docfile

src
	* window.c (Fset_window_margins, Fset_window_fringes)
	(Fset_window_scroll_bars, Fset_window_vscroll): No longer static.
	* textprop.c (Fprevious_property_change): No longer static.
	* syntax.c (Fsyntax_table_p): No longer static.
	* process.c (Fget_process, Fprocess_datagram_address): No longer
	static.
	* keymap.c (Flookup_key, Fcopy_keymap): No longer static.
	* keyboard.c (Fcommand_execute): No longer static.
	Remove EXFUN.
	* insdel.c (Fcombine_after_change_execute): No longer static.
	* image.c (Finit_image_library): No longer static.
	* fileio.c (Fmake_symbolic_link): No longer static.
	* eval.c (Ffetch_bytecode): No longer static.
	* editfns.c (Fuser_full_name): No longer static.
	* doc.c: (Fdocumentation_property, Fsnarf_documentation): No
	longer static.
	* buffer.c (Fset_buffer_major_mode, Fdelete_overlay): No longer
	static.
	* dired.c (Ffile_attributes): No longer static.
	* composite.c (Fcomposition_get_gstring): No longer static.
	* callproc.c (Fgetenv_internal): No longer static.

	* ccl.h: Remove EXFUNs.
	* buffer.h: Remove EXFUNs.
	* dispextern.h: Remove EXFUNs.
	* intervals.h: Remove EXFUNs.
	* fontset.h: Remove EXFUN.
	* font.h: Remove EXFUNs.
	* dosfns.c (system_process_attributes): Remove EXFUN.
	* keymap.h: Remove EXFUNs.
	* lisp.h: Remove EXFUNs.
	* w32term.h: Remove EXFUNs.
	* window.h: Remove EXFUNs.
	* xsettings.h: Remove EXFUN.
	* xterm.h: Remove EXFUN.

lib-src
	* make-docfile.c (enum global_type) <FUNCTION>: New constant.
	(struct global) <value>: New field.
	(add_global): Add 'value' argument.
	(compare_globals): Sort functions at the end.
	(close_emacs_globals): New function.
	(write_globals): Handle functions.
	(scan_c_file): Call add_global for DEFUN.
This commit is contained in:
Tom Tromey 2012-07-03 12:24:42 -06:00
parent 8e4fd1e172
commit 404dbd373a
33 changed files with 127 additions and 411 deletions

View file

@ -564,6 +564,7 @@ write_c_args (FILE *out, char *func, char *buf, int minargs, int maxargs)
/* The types of globals. */
enum global_type
{
FUNCTION,
EMACS_INTEGER,
BOOLEAN,
LISP_OBJECT,
@ -575,6 +576,7 @@ struct global
{
enum global_type type;
char *name;
int value;
};
/* All the variable names we saw while scanning C sources in `-g'
@ -584,7 +586,7 @@ int num_globals_allocated;
struct global *globals;
static void
add_global (enum global_type type, char *name)
add_global (enum global_type type, char *name, int value)
{
/* Ignore the one non-symbol that can occur. */
if (strcmp (name, "..."))
@ -605,6 +607,7 @@ add_global (enum global_type type, char *name)
globals[num_globals - 1].type = type;
globals[num_globals - 1].name = name;
globals[num_globals - 1].value = value;
}
}
@ -613,13 +616,29 @@ compare_globals (const void *a, const void *b)
{
const struct global *ga = a;
const struct global *gb = b;
if (ga->type == FUNCTION)
{
if (gb->type != FUNCTION)
return 1;
}
else if (gb->type == FUNCTION)
return -1;
return strcmp (ga->name, gb->name);
}
static void
close_emacs_globals (void)
{
fprintf (outfile, "};\n");
fprintf (outfile, "extern struct emacs_globals globals;\n");
}
static void
write_globals (void)
{
int i;
int i, seen_defun = 0;
qsort (globals, num_globals, sizeof (struct global), compare_globals);
for (i = 0; i < num_globals; ++i)
{
@ -636,20 +655,49 @@ write_globals (void)
case LISP_OBJECT:
type = "Lisp_Object";
break;
case FUNCTION:
if (!seen_defun)
{
close_emacs_globals ();
fprintf (outfile, "\n");
seen_defun = 1;
}
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);
if (globals[i].type != FUNCTION)
{
fprintf (outfile, " %s f_%s;\n", type, globals[i].name);
fprintf (outfile, "#define %s globals.f_%s\n",
globals[i].name, globals[i].name);
}
else
{
/* It would be nice to have a cleaner way to deal with these
special hacks. */
if (strcmp (globals[i].name, "Fthrow") == 0
|| strcmp (globals[i].name, "Ftop_level") == 0
|| strcmp (globals[i].name, "Fkill_emacs") == 0)
fprintf (outfile, "_Noreturn ");
fprintf (outfile, "EXFUN (%s, ", globals[i].name);
if (globals[i].value == -1)
fprintf (outfile, "MANY");
else if (globals[i].value == -2)
fprintf (outfile, "UNEVALLED");
else
fprintf (outfile, "%d", globals[i].value);
fprintf (outfile, ");\n");
}
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");
if (!seen_defun)
close_emacs_globals ();
}
@ -699,6 +747,7 @@ scan_c_file (char *filename, const char *mode)
int defvarperbufferflag = 0;
int defvarflag = 0;
enum global_type type = INVALID;
char *name;
if (c != '\n' && c != '\r')
{
@ -764,8 +813,9 @@ scan_c_file (char *filename, const char *mode)
}
else continue;
if (generate_globals && (!defvarflag || defvarperbufferflag
|| type == INVALID))
if (generate_globals
&& (!defvarflag || defvarperbufferflag || type == INVALID)
&& !defunflag)
continue;
while (c != '(')
@ -784,7 +834,6 @@ scan_c_file (char *filename, const char *mode)
if (generate_globals)
{
int i = 0;
char *name;
/* Skip "," and whitespace. */
do
@ -805,8 +854,12 @@ scan_c_file (char *filename, const char *mode)
name = xmalloc (i + 1);
memcpy (name, input_buffer, i + 1);
add_global (type, name);
continue;
if (!defunflag)
{
add_global (type, name, 0);
continue;
}
}
/* DEFVAR_LISP ("name", addr, "doc")
@ -814,7 +867,7 @@ scan_c_file (char *filename, const char *mode)
DEFVAR_LISP ("name", addr, doc: /\* doc *\/) */
if (defunflag)
commas = 5;
commas = generate_globals ? 4 : 5;
else if (defvarperbufferflag)
commas = 3;
else if (defvarflag)
@ -841,7 +894,12 @@ scan_c_file (char *filename, const char *mode)
scanned = fscanf (infile, "%d", &minargs);
else /* Pick up maxargs. */
if (c == 'M' || c == 'U') /* MANY || UNEVALLED */
maxargs = -1;
{
if (generate_globals)
maxargs = (c == 'M') ? -1 : -2;
else
maxargs = -1;
}
else
scanned = fscanf (infile, "%d", &maxargs);
if (scanned < 0)
@ -854,6 +912,12 @@ scan_c_file (char *filename, const char *mode)
c = getc (infile);
}
if (generate_globals)
{
add_global (FUNCTION, name, maxargs);
continue;
}
while (c == ' ' || c == '\n' || c == '\r' || c == '\t')
c = getc (infile);