diff options
| author | Tom Tromey | 2012-07-03 12:24:42 -0600 |
|---|---|---|
| committer | Tom Tromey | 2012-07-03 12:24:42 -0600 |
| commit | 404dbd373a91c0b994005e88fe703d9144873b27 (patch) | |
| tree | 758143095cab84ccd7962166584b94787df03267 /lib-src/make-docfile.c | |
| parent | 8e4fd1e172f5fc3daf8219965a588bf0125ba311 (diff) | |
| download | emacs-404dbd373a91c0b994005e88fe703d9144873b27.tar.gz emacs-404dbd373a91c0b994005e88fe703d9144873b27.zip | |
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.
Diffstat (limited to 'lib-src/make-docfile.c')
| -rw-r--r-- | lib-src/make-docfile.c | 92 |
1 files changed, 78 insertions, 14 deletions
diff --git a/lib-src/make-docfile.c b/lib-src/make-docfile.c index 8156db9b73a..2a5f028976a 100644 --- a/lib-src/make-docfile.c +++ b/lib-src/make-docfile.c | |||
| @@ -564,6 +564,7 @@ write_c_args (FILE *out, char *func, char *buf, int minargs, int maxargs) | |||
| 564 | /* The types of globals. */ | 564 | /* The types of globals. */ |
| 565 | enum global_type | 565 | enum global_type |
| 566 | { | 566 | { |
| 567 | FUNCTION, | ||
| 567 | EMACS_INTEGER, | 568 | EMACS_INTEGER, |
| 568 | BOOLEAN, | 569 | BOOLEAN, |
| 569 | LISP_OBJECT, | 570 | LISP_OBJECT, |
| @@ -575,6 +576,7 @@ struct global | |||
| 575 | { | 576 | { |
| 576 | enum global_type type; | 577 | enum global_type type; |
| 577 | char *name; | 578 | char *name; |
| 579 | int value; | ||
| 578 | }; | 580 | }; |
| 579 | 581 | ||
| 580 | /* All the variable names we saw while scanning C sources in `-g' | 582 | /* All the variable names we saw while scanning C sources in `-g' |
| @@ -584,7 +586,7 @@ int num_globals_allocated; | |||
| 584 | struct global *globals; | 586 | struct global *globals; |
| 585 | 587 | ||
| 586 | static void | 588 | static void |
| 587 | add_global (enum global_type type, char *name) | 589 | add_global (enum global_type type, char *name, int value) |
| 588 | { | 590 | { |
| 589 | /* Ignore the one non-symbol that can occur. */ | 591 | /* Ignore the one non-symbol that can occur. */ |
| 590 | if (strcmp (name, "...")) | 592 | if (strcmp (name, "...")) |
| @@ -605,6 +607,7 @@ add_global (enum global_type type, char *name) | |||
| 605 | 607 | ||
| 606 | globals[num_globals - 1].type = type; | 608 | globals[num_globals - 1].type = type; |
| 607 | globals[num_globals - 1].name = name; | 609 | globals[num_globals - 1].name = name; |
| 610 | globals[num_globals - 1].value = value; | ||
| 608 | } | 611 | } |
| 609 | } | 612 | } |
| 610 | 613 | ||
| @@ -613,13 +616,29 @@ compare_globals (const void *a, const void *b) | |||
| 613 | { | 616 | { |
| 614 | const struct global *ga = a; | 617 | const struct global *ga = a; |
| 615 | const struct global *gb = b; | 618 | const struct global *gb = b; |
| 619 | |||
| 620 | if (ga->type == FUNCTION) | ||
| 621 | { | ||
| 622 | if (gb->type != FUNCTION) | ||
| 623 | return 1; | ||
| 624 | } | ||
| 625 | else if (gb->type == FUNCTION) | ||
| 626 | return -1; | ||
| 627 | |||
| 616 | return strcmp (ga->name, gb->name); | 628 | return strcmp (ga->name, gb->name); |
| 617 | } | 629 | } |
| 618 | 630 | ||
| 619 | static void | 631 | static void |
| 632 | close_emacs_globals (void) | ||
| 633 | { | ||
| 634 | fprintf (outfile, "};\n"); | ||
| 635 | fprintf (outfile, "extern struct emacs_globals globals;\n"); | ||
| 636 | } | ||
| 637 | |||
| 638 | static void | ||
| 620 | write_globals (void) | 639 | write_globals (void) |
| 621 | { | 640 | { |
| 622 | int i; | 641 | int i, seen_defun = 0; |
| 623 | qsort (globals, num_globals, sizeof (struct global), compare_globals); | 642 | qsort (globals, num_globals, sizeof (struct global), compare_globals); |
| 624 | for (i = 0; i < num_globals; ++i) | 643 | for (i = 0; i < num_globals; ++i) |
| 625 | { | 644 | { |
| @@ -636,20 +655,49 @@ write_globals (void) | |||
| 636 | case LISP_OBJECT: | 655 | case LISP_OBJECT: |
| 637 | type = "Lisp_Object"; | 656 | type = "Lisp_Object"; |
| 638 | break; | 657 | break; |
| 658 | case FUNCTION: | ||
| 659 | if (!seen_defun) | ||
| 660 | { | ||
| 661 | close_emacs_globals (); | ||
| 662 | fprintf (outfile, "\n"); | ||
| 663 | seen_defun = 1; | ||
| 664 | } | ||
| 665 | break; | ||
| 639 | default: | 666 | default: |
| 640 | fatal ("not a recognized DEFVAR_", 0); | 667 | fatal ("not a recognized DEFVAR_", 0); |
| 641 | } | 668 | } |
| 642 | 669 | ||
| 643 | fprintf (outfile, " %s f_%s;\n", type, globals[i].name); | 670 | if (globals[i].type != FUNCTION) |
| 644 | fprintf (outfile, "#define %s globals.f_%s\n", | 671 | { |
| 645 | globals[i].name, globals[i].name); | 672 | fprintf (outfile, " %s f_%s;\n", type, globals[i].name); |
| 673 | fprintf (outfile, "#define %s globals.f_%s\n", | ||
| 674 | globals[i].name, globals[i].name); | ||
| 675 | } | ||
| 676 | else | ||
| 677 | { | ||
| 678 | /* It would be nice to have a cleaner way to deal with these | ||
| 679 | special hacks. */ | ||
| 680 | if (strcmp (globals[i].name, "Fthrow") == 0 | ||
| 681 | || strcmp (globals[i].name, "Ftop_level") == 0 | ||
| 682 | || strcmp (globals[i].name, "Fkill_emacs") == 0) | ||
| 683 | fprintf (outfile, "_Noreturn "); | ||
| 684 | fprintf (outfile, "EXFUN (%s, ", globals[i].name); | ||
| 685 | if (globals[i].value == -1) | ||
| 686 | fprintf (outfile, "MANY"); | ||
| 687 | else if (globals[i].value == -2) | ||
| 688 | fprintf (outfile, "UNEVALLED"); | ||
| 689 | else | ||
| 690 | fprintf (outfile, "%d", globals[i].value); | ||
| 691 | fprintf (outfile, ");\n"); | ||
| 692 | } | ||
| 693 | |||
| 646 | while (i + 1 < num_globals | 694 | while (i + 1 < num_globals |
| 647 | && !strcmp (globals[i].name, globals[i + 1].name)) | 695 | && !strcmp (globals[i].name, globals[i + 1].name)) |
| 648 | ++i; | 696 | ++i; |
| 649 | } | 697 | } |
| 650 | 698 | ||
| 651 | fprintf (outfile, "};\n"); | 699 | if (!seen_defun) |
| 652 | fprintf (outfile, "extern struct emacs_globals globals;\n"); | 700 | close_emacs_globals (); |
| 653 | } | 701 | } |
| 654 | 702 | ||
| 655 | 703 | ||
| @@ -699,6 +747,7 @@ scan_c_file (char *filename, const char *mode) | |||
| 699 | int defvarperbufferflag = 0; | 747 | int defvarperbufferflag = 0; |
| 700 | int defvarflag = 0; | 748 | int defvarflag = 0; |
| 701 | enum global_type type = INVALID; | 749 | enum global_type type = INVALID; |
| 750 | char *name; | ||
| 702 | 751 | ||
| 703 | if (c != '\n' && c != '\r') | 752 | if (c != '\n' && c != '\r') |
| 704 | { | 753 | { |
| @@ -764,8 +813,9 @@ scan_c_file (char *filename, const char *mode) | |||
| 764 | } | 813 | } |
| 765 | else continue; | 814 | else continue; |
| 766 | 815 | ||
| 767 | if (generate_globals && (!defvarflag || defvarperbufferflag | 816 | if (generate_globals |
| 768 | || type == INVALID)) | 817 | && (!defvarflag || defvarperbufferflag || type == INVALID) |
| 818 | && !defunflag) | ||
| 769 | continue; | 819 | continue; |
| 770 | 820 | ||
| 771 | while (c != '(') | 821 | while (c != '(') |
| @@ -784,7 +834,6 @@ scan_c_file (char *filename, const char *mode) | |||
| 784 | if (generate_globals) | 834 | if (generate_globals) |
| 785 | { | 835 | { |
| 786 | int i = 0; | 836 | int i = 0; |
| 787 | char *name; | ||
| 788 | 837 | ||
| 789 | /* Skip "," and whitespace. */ | 838 | /* Skip "," and whitespace. */ |
| 790 | do | 839 | do |
| @@ -805,8 +854,12 @@ scan_c_file (char *filename, const char *mode) | |||
| 805 | 854 | ||
| 806 | name = xmalloc (i + 1); | 855 | name = xmalloc (i + 1); |
| 807 | memcpy (name, input_buffer, i + 1); | 856 | memcpy (name, input_buffer, i + 1); |
| 808 | add_global (type, name); | 857 | |
| 809 | continue; | 858 | if (!defunflag) |
| 859 | { | ||
| 860 | add_global (type, name, 0); | ||
| 861 | continue; | ||
| 862 | } | ||
| 810 | } | 863 | } |
| 811 | 864 | ||
| 812 | /* DEFVAR_LISP ("name", addr, "doc") | 865 | /* DEFVAR_LISP ("name", addr, "doc") |
| @@ -814,7 +867,7 @@ scan_c_file (char *filename, const char *mode) | |||
| 814 | DEFVAR_LISP ("name", addr, doc: /\* doc *\/) */ | 867 | DEFVAR_LISP ("name", addr, doc: /\* doc *\/) */ |
| 815 | 868 | ||
| 816 | if (defunflag) | 869 | if (defunflag) |
| 817 | commas = 5; | 870 | commas = generate_globals ? 4 : 5; |
| 818 | else if (defvarperbufferflag) | 871 | else if (defvarperbufferflag) |
| 819 | commas = 3; | 872 | commas = 3; |
| 820 | else if (defvarflag) | 873 | else if (defvarflag) |
| @@ -841,7 +894,12 @@ scan_c_file (char *filename, const char *mode) | |||
| 841 | scanned = fscanf (infile, "%d", &minargs); | 894 | scanned = fscanf (infile, "%d", &minargs); |
| 842 | else /* Pick up maxargs. */ | 895 | else /* Pick up maxargs. */ |
| 843 | if (c == 'M' || c == 'U') /* MANY || UNEVALLED */ | 896 | if (c == 'M' || c == 'U') /* MANY || UNEVALLED */ |
| 844 | maxargs = -1; | 897 | { |
| 898 | if (generate_globals) | ||
| 899 | maxargs = (c == 'M') ? -1 : -2; | ||
| 900 | else | ||
| 901 | maxargs = -1; | ||
| 902 | } | ||
| 845 | else | 903 | else |
| 846 | scanned = fscanf (infile, "%d", &maxargs); | 904 | scanned = fscanf (infile, "%d", &maxargs); |
| 847 | if (scanned < 0) | 905 | if (scanned < 0) |
| @@ -854,6 +912,12 @@ scan_c_file (char *filename, const char *mode) | |||
| 854 | c = getc (infile); | 912 | c = getc (infile); |
| 855 | } | 913 | } |
| 856 | 914 | ||
| 915 | if (generate_globals) | ||
| 916 | { | ||
| 917 | add_global (FUNCTION, name, maxargs); | ||
| 918 | continue; | ||
| 919 | } | ||
| 920 | |||
| 857 | while (c == ' ' || c == '\n' || c == '\r' || c == '\t') | 921 | while (c == ' ' || c == '\n' || c == '\r' || c == '\t') |
| 858 | c = getc (infile); | 922 | c = getc (infile); |
| 859 | 923 | ||