summaryrefslogtreecommitdiff
path: root/src/image.c
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2015-01-05 09:07:45 -0800
committerPaul Eggert <eggert@cs.ucla.edu>2015-01-05 10:14:58 -0800
commit58f2d6ef32b28a787fcc4e0d98b3f331ceb2a68c (patch)
treed6d79ad7b7cceafc78c5a9c54f5be1ac441a8ed7 /src/image.c
parentd2cf05d1bac19d8564d0806f515b9f40fe57f4df (diff)
downloademacs-58f2d6ef32b28a787fcc4e0d98b3f331ceb2a68c.tar.gz
emacs-58f2d6ef32b28a787fcc4e0d98b3f331ceb2a68c.tar.bz2
emacs-58f2d6ef32b28a787fcc4e0d98b3f331ceb2a68c.zip
Compute C decls for DEFSYMs automatically
Fixes Bug#15880. This patch also makes Q constants (e.g., Qnil) constant addresses from the C point of view. * make-docfile.c: Revamp to generate table of symbols, too. Include <stdbool.h>. (xstrdup): New function. (main): Don't process the same file twice. (SYMBOL): New constant in enum global_type. (struct symbol): Turn 'value' member into a union, either v.value for int or v.svalue for string. All uses changed. (add_global): New arg svalue, which overrides value, so that globals can have a string value. (close_emacs_global): New arg num_symbols; all uses changed. Output lispsym decl. (write_globals): Output symbol globals too. Output more ATTRIBUTE_CONST, now that Qnil etc. are C constants. Output defsym_name table. (scan_c_file): Move most of guts into ... (scan_c_stream): ... new function. Scan for DEFSYMs and record symbols found. Don't read past EOF if file doesn't end in newline. * alloc.c, bidi.c, buffer.c, bytecode.c, callint.c, casefiddle: * casetab.c, category.c, ccl.c, charset.c, chartab.c, cmds.c, coding.c: * composite.c, data.c, dbusbind.c, decompress.c, dired.c, dispnew.c: * doc.c, editfns.c, emacs.c, eval.c, fileio.c, fns.c, font.c, fontset.c: * frame.c, fringe.c, ftfont.c, ftxfont.c, gfilenotify.c, gnutls.c: * image.c, inotify.c, insdel.c, keyboard.c, keymap.c, lread.c: * macfont.m, macros.c, minibuf.c, nsfns.m, nsfont.m, nsimage.m: * nsmenu.m, nsselect.m, nsterm.m, print.c, process.c, profiler.c: * search.c, sound.c, syntax.c, term.c, terminal.c, textprop.c, undo.c: * window.c, xdisp.c, xfaces.c, xfns.c, xftfont.c, xmenu.c, xml.c: * xselect.c, xsettings.c, xterm.c: Remove Q vars that represent symbols (e.g., Qnil, Qt, Qemacs). These names are now defined automatically by make-docfile. * alloc.c (init_symbol): New function. (Fmake_symbol): Use it. (c_symbol_p): New function. (valid_lisp_object_p, purecopy): Use it. * alloc.c (marked_pinned_symbols): Use make_lisp_symbol instead of make_lisp_ptr. (garbage_collect_1): Mark lispsym symbols. (CHECK_ALLOCATED_AND_LIVE_SYMBOL): New macro. (mark_object): Use it. (sweep_symbols): Sweep lispsym symbols. (symbol_uses_obj): New function. (which_symbols): Use it. Work for lispsym symbols, too. (init_alloc_once): Initialize Vpurify_flag here; no need to wait, since Qt's address is already known now. (syms_of_alloc): Add lispsym count to symbols_consed. * buffer.c (init_buffer_once): Compare to Qnil, not to make_number (0), when testing whether storage is all bits zero. * dispextern (struct image_type): * font.c (font_property_table): * frame.c (struct frame_parm_table, frame_parms): * keyboard.c (scroll_bar_parts, struct event_head): * xdisp.c (struct props): Use XSYMBOL_INIT (Qfoo) and struct Lisp_Symbol * rather than &Qfoo and Lisp_Object *, since Qfoo is no longer an object whose address can be taken. All uses changed. * eval.c (run_hook): New function. Most uses of Frun_hooks changed to use it, so that they no longer need to take the address of a Lisp sym. (syms_of_eval): Don't use DEFSYM on Vrun_hooks, as it's a variable. * frame.c (syms_of_frame): Add defsyms for the frame_parms table. * keyboard.c (syms_of_keyboard): Don't DEFSYM Qmenu_bar here. DEFSYM Qdeactivate_mark before the corresponding var. * keymap.c (syms_of_keymap): Use DEFSYM for Qmenu_bar and Qmode_line instead of interning their symbols; this avoids duplicates. (LISP_INITIALLY, TAG_PTR) (DEFINE_LISP_SYMBOL_BEGIN, DEFINE_LISP_SYMBOL_END, XSYMBOL_INIT): New macros. (LISP_INITIALLY_ZERO): Use it. (enum symbol_interned, enum symbol_redirect, struct Lisp_Symbol) (EXFUN, DEFUN_ARGS_MANY, DEFUN_ARGS_UNEVALLED, DEFUN_ARGS_*): Move decls up, to avoid forward uses. Include globals.h earlier, too. (make_lisp_symbol): New function. (XSETSYMBOL): Use it. (DEFSYM): Now just a placeholder for make-docfile. * lread.c (DEFINE_SYMBOLS): Define, for globals.h. (intern_sym): New function, with body taken from old intern_driver. (intern_driver): Use it. Last arg is now Lisp integer, not ptrdiff_t. All uses changed. (define_symbol): New function. (init_obarray): Define the C symbols taken from lispsym. Use plain DEFSYM for Qt and Qnil. * syntax.c (init_syntax_once): No need to worry about Qchar_table_extra_slots.
Diffstat (limited to 'src/image.c')
-rw-r--r--src/image.c104
1 files changed, 23 insertions, 81 deletions
diff --git a/src/image.c b/src/image.c
index 6240c64b201..addb932f834 100644
--- a/src/image.c
+++ b/src/image.c
@@ -86,12 +86,6 @@ typedef struct w32_bitmap_record Bitmap_Record;
#define x_defined_color w32_defined_color
#define DefaultDepthOfScreen(screen) (one_w32_display_info.n_cbits)
-/* Versions of libpng, libgif, and libjpeg that we were compiled with,
- or -1 if no PNG/GIF support was compiled in. This is tested by
- w32-win.el to correctly set up the alist used to search for the
- respective image libraries. */
-Lisp_Object Qlibpng_version, Qlibgif_version, Qlibjpeg_version;
-
#endif /* HAVE_NTGUI */
#ifdef HAVE_NS
@@ -110,11 +104,6 @@ typedef struct ns_bitmap_record Bitmap_Record;
#define DefaultDepthOfScreen(screen) x_display_list->n_planes
#endif /* HAVE_NS */
-
-/* The symbol `postscript' identifying images of this type. */
-
-static Lisp_Object Qpostscript;
-
static void x_disable_image (struct frame *, struct image *);
static void x_edge_detection (struct frame *, struct image *, Lisp_Object,
Lisp_Object);
@@ -126,8 +115,6 @@ static void free_color_table (void);
static unsigned long *colors_in_color_table (int *n);
#endif
-static Lisp_Object QCmax_width, QCmax_height;
-
/* Code to deal with bitmaps. Bitmaps are referenced by their bitmap
id, which is just an int that this section returns. Bitmaps are
reference counted so they can be shared among frames.
@@ -537,24 +524,6 @@ x_create_bitmap_mask (struct frame *f, ptrdiff_t id)
static struct image_type *image_types;
-/* The symbol `xbm' which is used as the type symbol for XBM images. */
-
-static Lisp_Object Qxbm;
-
-/* Keywords. */
-
-Lisp_Object QCascent, QCmargin, QCrelief;
-Lisp_Object QCconversion;
-static Lisp_Object QCheuristic_mask;
-static Lisp_Object QCcolor_symbols;
-static Lisp_Object QCindex, QCmatrix, QCcolor_adjustment, QCmask, QCgeometry;
-static Lisp_Object QCcrop, QCrotation;
-
-/* Other symbols. */
-
-static Lisp_Object Qcount, Qextension_data, Qdelay;
-static Lisp_Object Qlaplace, Qemboss, Qedge_detection, Qheuristic;
-
/* Forward function prototypes. */
static struct image_type *lookup_image_type (Lisp_Object);
@@ -579,27 +548,28 @@ static struct image_type *
define_image_type (struct image_type *type)
{
struct image_type *p = NULL;
- Lisp_Object target_type = *type->type;
+ struct Lisp_Symbol *new_type = type->type;
bool type_valid = 1;
block_input ();
for (p = image_types; p; p = p->next)
- if (EQ (*p->type, target_type))
+ if (p->type == new_type)
goto done;
if (type->init)
{
#if defined HAVE_NTGUI && defined WINDOWSNT
/* If we failed to load the library before, don't try again. */
- Lisp_Object tested = Fassq (target_type, Vlibrary_cache);
+ Lisp_Object tested = Fassq (make_lisp_symbol (new_type), Vlibrary_cache);
if (CONSP (tested) && NILP (XCDR (tested)))
type_valid = 0;
else
#endif
{
type_valid = type->init ();
- CACHE_IMAGE_TYPE (target_type, type_valid ? Qt : Qnil);
+ CACHE_IMAGE_TYPE (make_lisp_symbol (new_type),
+ type_valid ? Qt : Qnil);
}
}
@@ -1777,7 +1747,7 @@ lookup_image (struct frame *f, Lisp_Object spec)
/* Do image transformations and compute masks, unless we
don't have the image yet. */
- if (!EQ (*img->type->type, Qpostscript))
+ if (!EQ (make_lisp_symbol (img->type->type), Qpostscript))
postprocess_image (f, img);
}
@@ -2362,7 +2332,7 @@ static const struct image_keyword xbm_format[XBM_LAST] =
static struct image_type xbm_type =
{
- &Qxbm,
+ XSYMBOL_INIT (Qxbm),
xbm_image_p,
xbm_load,
x_clear_image,
@@ -3121,9 +3091,6 @@ static bool xpm_load (struct frame *f, struct image *img);
#endif /* HAVE_XPM */
#if defined (HAVE_XPM) || defined (HAVE_NS)
-/* The symbol `xpm' identifying XPM-format images. */
-
-static Lisp_Object Qxpm;
/* Indices of image specification fields in xpm_format, below. */
@@ -3171,7 +3138,7 @@ static bool init_xpm_functions (void);
static struct image_type xpm_type =
{
- &Qxpm,
+ XSYMBOL_INIT (Qxpm),
xpm_image_p,
xpm_load,
x_clear_image,
@@ -5059,10 +5026,6 @@ x_build_heuristic_mask (struct frame *f, struct image *img, Lisp_Object how)
static bool pbm_image_p (Lisp_Object object);
static bool pbm_load (struct frame *f, struct image *img);
-/* The symbol `pbm' identifying images of this type. */
-
-static Lisp_Object Qpbm;
-
/* Indices of image specification fields in gs_format, below. */
enum pbm_keyword_index
@@ -5103,7 +5066,7 @@ static const struct image_keyword pbm_format[PBM_LAST] =
static struct image_type pbm_type =
{
- &Qpbm,
+ XSYMBOL_INIT (Qpbm),
pbm_image_p,
pbm_load,
x_clear_image,
@@ -5446,10 +5409,6 @@ pbm_load (struct frame *f, struct image *img)
static bool png_image_p (Lisp_Object object);
static bool png_load (struct frame *f, struct image *img);
-/* The symbol `png' identifying images of this type. */
-
-static Lisp_Object Qpng;
-
/* Indices of image specification fields in png_format, below. */
enum png_keyword_index
@@ -5494,7 +5453,7 @@ static bool init_png_functions (void);
static struct image_type png_type =
{
- &Qpng,
+ XSYMBOL_INIT (Qpng),
png_image_p,
png_load,
x_clear_image,
@@ -6102,10 +6061,6 @@ png_load (struct frame *f, struct image *img)
static bool jpeg_image_p (Lisp_Object object);
static bool jpeg_load (struct frame *f, struct image *img);
-/* The symbol `jpeg' identifying images of this type. */
-
-static Lisp_Object Qjpeg;
-
/* Indices of image specification fields in gs_format, below. */
enum jpeg_keyword_index
@@ -6150,7 +6105,7 @@ static bool init_jpeg_functions (void);
static struct image_type jpeg_type =
{
- &Qjpeg,
+ XSYMBOL_INIT (Qjpeg),
jpeg_image_p,
jpeg_load,
x_clear_image,
@@ -6704,10 +6659,6 @@ jpeg_load (struct frame *f, struct image *img)
static bool tiff_image_p (Lisp_Object object);
static bool tiff_load (struct frame *f, struct image *img);
-/* The symbol `tiff' identifying images of this type. */
-
-static Lisp_Object Qtiff;
-
/* Indices of image specification fields in tiff_format, below. */
enum tiff_keyword_index
@@ -6754,7 +6705,7 @@ static bool init_tiff_functions (void);
static struct image_type tiff_type =
{
- &Qtiff,
+ XSYMBOL_INIT (Qtiff),
tiff_image_p,
tiff_load,
x_clear_image,
@@ -7167,10 +7118,6 @@ static bool gif_image_p (Lisp_Object object);
static bool gif_load (struct frame *f, struct image *img);
static void gif_clear_image (struct frame *f, struct image *img);
-/* The symbol `gif' identifying images of this type. */
-
-static Lisp_Object Qgif;
-
/* Indices of image specification fields in gif_format, below. */
enum gif_keyword_index
@@ -7217,7 +7164,7 @@ static bool init_gif_functions (void);
static struct image_type gif_type =
{
- &Qgif,
+ XSYMBOL_INIT (Qgif),
gif_image_p,
gif_load,
gif_clear_image,
@@ -7841,8 +7788,6 @@ compute_image_size (size_t width, size_t height,
*d_height = desired_height;
}
-static Lisp_Object Qimagemagick;
-
static bool imagemagick_image_p (Lisp_Object);
static bool imagemagick_load (struct frame *, struct image *);
static void imagemagick_clear_image (struct frame *, struct image *);
@@ -7906,7 +7851,7 @@ static bool init_imagemagick_functions (void);
static struct image_type imagemagick_type =
{
- &Qimagemagick,
+ XSYMBOL_INIT (Qimagemagick),
imagemagick_image_p,
imagemagick_load,
imagemagick_clear_image,
@@ -8632,10 +8577,6 @@ static bool svg_load (struct frame *f, struct image *img);
static bool svg_load_image (struct frame *, struct image *,
unsigned char *, ptrdiff_t, char *);
-/* The symbol `svg' identifying images of this type. */
-
-static Lisp_Object Qsvg;
-
/* Indices of image specification fields in svg_format, below. */
enum svg_keyword_index
@@ -8682,7 +8623,7 @@ static bool init_svg_functions (void);
static struct image_type svg_type =
{
- &Qsvg,
+ XSYMBOL_INIT (Qsvg),
svg_image_p,
svg_load,
x_clear_image,
@@ -8737,8 +8678,6 @@ DEF_DLL_FN (void, g_type_init, (void));
DEF_DLL_FN (void, g_object_unref, (gpointer));
DEF_DLL_FN (void, g_error_free, (GError *));
-Lisp_Object Qgdk_pixbuf, Qglib, Qgobject;
-
static bool
init_svg_functions (void)
{
@@ -9056,10 +8995,6 @@ static bool gs_image_p (Lisp_Object object);
static bool gs_load (struct frame *f, struct image *img);
static void gs_clear_image (struct frame *f, struct image *img);
-/* Keyword symbols. */
-
-static Lisp_Object QCloader, QCbounding_box, QCpt_width, QCpt_height;
-
/* Indices of image specification fields in gs_format, below. */
enum gs_keyword_index
@@ -9104,7 +9039,7 @@ static const struct image_keyword gs_format[GS_LAST] =
static struct image_type gs_type =
{
- &Qpostscript,
+ XSYMBOL_INIT (Qpostscript),
gs_image_p,
gs_load,
gs_clear_image,
@@ -9479,10 +9414,12 @@ as a ratio to the frame height and width. If the value is
non-numeric, there is no explicit limit on the size of images. */);
Vmax_image_size = make_float (MAX_IMAGE_SIZE);
+ /* Other symbols. */
DEFSYM (Qcount, "count");
DEFSYM (Qextension_data, "extension-data");
DEFSYM (Qdelay, "delay");
+ /* Keywords. */
DEFSYM (QCascent, ":ascent");
DEFSYM (QCmargin, ":margin");
DEFSYM (QCrelief, ":relief");
@@ -9497,6 +9434,7 @@ non-numeric, there is no explicit limit on the size of images. */);
DEFSYM (QCcolor_adjustment, ":color-adjustment");
DEFSYM (QCmask, ":mask");
+ /* Other symbols. */
DEFSYM (Qlaplace, "laplace");
DEFSYM (Qemboss, "emboss");
DEFSYM (Qedge_detection, "edge-detection");
@@ -9514,6 +9452,10 @@ non-numeric, there is no explicit limit on the size of images. */);
#endif /* HAVE_GHOSTSCRIPT */
#ifdef HAVE_NTGUI
+ /* Versions of libpng, libgif, and libjpeg that we were compiled with,
+ or -1 if no PNG/GIF support was compiled in. This is tested by
+ w32-win.el to correctly set up the alist used to search for the
+ respective image libraries. */
DEFSYM (Qlibpng_version, "libpng-version");
Fset (Qlibpng_version,
#if HAVE_PNG