Commit d07ff9db authored by Chong Yidong's avatar Chong Yidong

Remove LIBRARIES arg from w32_delayed_load and friends.

These always use Vdynamic_library_alist anyway.

* src/image.c (Finit_image_library, lookup_image_type)
(define_image_type): Remove now-unneeded second arg.
(init_xpm_functions, init_png_functions, init_jpeg_functions)
(init_tiff_functions, init_gif_functions, init_svg_functions):
Arglist and w32_delayed_load calling convention changed.
(gs_type): Remove init_gs_functions; there is no such function.

* src/gnutls.c (init_gnutls_functions): Caller changed; remove arg.
(Fgnutls_available_p): Caller changed.

* src/xml.c (init_libxml2_functions, Flibxml_parse_html_region)
(Flibxml_parse_xml_region): Likewise.

* src/dispextern.h (struct image_type): Remove arg from init function.

* src/w32.c (w32_delayed_load): Remove LIBRARIES argument; always use
Vdynamic_library_alist.

* lisp/image.el (image-type-available-p): Change caller to
init-image-library.
parent 4d7e6e51
2012-09-23 Chong Yidong <cyd@gnu.org>
* image.el (image-type-available-p): Adapt to init-image-library
argument changes.
2012-09-22 Juri Linkov <juri@jurta.org>
* dired.el (dired-mode-map): Add [remap read-only-mode] for
......
......@@ -346,7 +346,7 @@ Optional DATA-P non-nil means SOURCE is a string containing image data."
"Return non-nil if image type TYPE is available.
Image types are symbols like `xbm' or `jpeg'."
(and (fboundp 'init-image-library)
(init-image-library type dynamic-library-alist)))
(init-image-library type)))
;;;###autoload
......
2012-09-23 Chong Yidong <cyd@gnu.org>
* w32.c (w32_delayed_load): Remove LIBRARIES argument; always use
Vdynamic_library_alist.
* gnutls.c (init_gnutls_functions): Caller changed; remove arg.
(Fgnutls_available_p): Caller changed.
* xml.c (init_libxml2_functions, Flibxml_parse_html_region)
(Flibxml_parse_xml_region): Likewise.
* dispextern.h (struct image_type): Remove arg from init function.
* image.c (Finit_image_library, lookup_image_type)
(define_image_type): Remove now-unneeded second arg.
(init_xpm_functions, init_png_functions, init_jpeg_functions)
(init_tiff_functions, init_gif_functions, init_svg_functions):
Arglist and w32_delayed_load calling convention changed.
(gs_type): Remove init_gs_functions; there is no such function.
2012-09-23 Paul Eggert <eggert@cs.ucla.edu>
Simplify and avoid signal-handling races (Bug#12471).
......
......@@ -2769,7 +2769,7 @@ struct image_type
/* Initialization function (used for dynamic loading of image
libraries on Windows), or NULL if none. */
int (* init) (Lisp_Object);
int (* init) (void);
/* Next in list of all supported image types. */
struct image_type *next;
......
......@@ -142,12 +142,12 @@ DEF_GNUTLS_FN (int, gnutls_x509_crt_import,
DEF_GNUTLS_FN (int, gnutls_x509_crt_init, (gnutls_x509_crt_t *));
static int
init_gnutls_functions (Lisp_Object libraries)
init_gnutls_functions (void)
{
HMODULE library;
int max_log_level = 1;
if (!(library = w32_delayed_load (libraries, Qgnutls_dll)))
if (!(library = w32_delayed_load (Qgnutls_dll)))
{
GNUTLS_LOG (1, max_log_level, "GnuTLS library not found");
return 0;
......@@ -656,7 +656,7 @@ DEFUN ("gnutls-available-p", Fgnutls_available_p, Sgnutls_available_p, 0, 0, 0,
else
{
Lisp_Object status;
status = init_gnutls_functions (Vdynamic_library_alist) ? Qt : Qnil;
status = init_gnutls_functions () ? Qt : Qnil;
Vlibrary_cache = Fcons (Fcons (Qgnutls_dll, status), Vlibrary_cache);
return status;
}
......
......@@ -579,15 +579,10 @@ static int x_build_heuristic_mask (struct frame *, struct image *,
do { Vimage_types = Fcons (type, Vimage_types); } while (0)
/* Define a new image type from TYPE. This adds a copy of TYPE to
image_types and caches the loading status of TYPE.
LIBRARIES is an alist associating dynamic libraries to external
files implementing them, which is passed to the image library
initialization function if necessary. A nil value defaults to
Vdynamic_library_alist. */
image_types and caches the loading status of TYPE. */
static struct image_type *
define_image_type (struct image_type *type, Lisp_Object libraries)
define_image_type (struct image_type *type)
{
struct image_type *p = NULL;
Lisp_Object target_type = *type->type;
......@@ -609,7 +604,7 @@ define_image_type (struct image_type *type, Lisp_Object libraries)
else
#endif
{
type_valid = type->init (libraries);
type_valid = type->init ();
CACHE_IMAGE_TYPE (target_type, type_valid ? Qt : Qnil);
}
}
......@@ -3053,7 +3048,7 @@ static const struct image_keyword xpm_format[XPM_LAST] =
};
#ifdef HAVE_NTGUI
static int init_xpm_functions (Lisp_Object);
static int init_xpm_functions (void);
#else
#define init_xpm_functions NULL
#endif
......@@ -3267,11 +3262,11 @@ DEF_IMGLIB_FN (int, XpmReadFileToImage, (Display *, char *, xpm_XImage **,
DEF_IMGLIB_FN (void, XImageFree, (xpm_XImage *));
static int
init_xpm_functions (Lisp_Object libraries)
init_xpm_functions (void)
{
HMODULE library;
if (!(library = w32_delayed_load (libraries, Qxpm)))
if (!(library = w32_delayed_load (Qxpm)))
return 0;
LOAD_IMGLIB_FN (library, XpmFreeAttributes);
......@@ -5397,7 +5392,7 @@ static const struct image_keyword png_format[PNG_LAST] =
};
#ifdef HAVE_NTGUI
static int init_png_functions (Lisp_Object);
static int init_png_functions (void);
#else
#define init_png_functions NULL
#endif
......@@ -5469,11 +5464,11 @@ DEF_IMGLIB_FN (jmp_buf *, png_set_longjmp_fn, (png_structp, png_longjmp_ptr, siz
#endif /* libpng version >= 1.5 */
static int
init_png_functions (Lisp_Object libraries)
init_png_functions (void)
{
HMODULE library;
if (!(library = w32_delayed_load (libraries, Qpng)))
if (!(library = w32_delayed_load (Qpng)))
return 0;
LOAD_IMGLIB_FN (library, png_get_io_ptr);
......@@ -6056,7 +6051,7 @@ static const struct image_keyword jpeg_format[JPEG_LAST] =
};
#ifdef HAVE_NTGUI
static int init_jpeg_functions (Lisp_Object);
static int init_jpeg_functions (void);
#else
#define init_jpeg_functions NULL
#endif
......@@ -6125,11 +6120,11 @@ DEF_IMGLIB_FN (struct jpeg_error_mgr *, jpeg_std_error, (struct jpeg_error_mgr *
DEF_IMGLIB_FN (boolean, jpeg_resync_to_restart, (j_decompress_ptr, int));
static int
init_jpeg_functions (Lisp_Object libraries)
init_jpeg_functions (void)
{
HMODULE library;
if (!(library = w32_delayed_load (libraries, Qjpeg)))
if (!(library = w32_delayed_load (Qjpeg)))
return 0;
LOAD_IMGLIB_FN (library, jpeg_finish_decompress);
......@@ -6648,7 +6643,7 @@ static const struct image_keyword tiff_format[TIFF_LAST] =
};
#ifdef HAVE_NTGUI
static int init_tiff_functions (Lisp_Object);
static int init_tiff_functions (void);
#else
#define init_tiff_functions NULL
#endif
......@@ -6702,11 +6697,11 @@ DEF_IMGLIB_FN (void, TIFFClose, (TIFF *));
DEF_IMGLIB_FN (int, TIFFSetDirectory, (TIFF *, tdir_t));
static int
init_tiff_functions (Lisp_Object libraries)
init_tiff_functions (void)
{
HMODULE library;
if (!(library = w32_delayed_load (libraries, Qtiff)))
if (!(library = w32_delayed_load (Qtiff)))
return 0;
LOAD_IMGLIB_FN (library, TIFFSetErrorHandler);
......@@ -7103,7 +7098,7 @@ static const struct image_keyword gif_format[GIF_LAST] =
};
#ifdef HAVE_NTGUI
static int init_gif_functions (Lisp_Object);
static int init_gif_functions (void);
#else
#define init_gif_functions NULL
#endif
......@@ -7175,11 +7170,11 @@ DEF_IMGLIB_FN (GifFileType *, DGifOpen, (void *, InputFunc));
DEF_IMGLIB_FN (GifFileType *, DGifOpenFileName, (const char *));
static int
init_gif_functions (Lisp_Object libraries)
init_gif_functions (void)
{
HMODULE library;
if (!(library = w32_delayed_load (libraries, Qgif)))
if (!(library = w32_delayed_load (Qgif)))
return 0;
LOAD_IMGLIB_FN (library, DGifCloseFile);
......@@ -7600,7 +7595,7 @@ static struct image_keyword imagemagick_format[IMAGEMAGICK_LAST] =
};
#ifdef HAVE_NTGUI
static int init_imagemagick_functions (Lisp_Object);
static int init_imagemagick_functions (void);
#else
#define init_imagemagick_functions NULL
#endif
......@@ -8154,7 +8149,7 @@ static const struct image_keyword svg_format[SVG_LAST] =
};
#ifdef HAVE_NTGUI
static int init_svg_functions (Lisp_Object);
static int init_svg_functions (void);
#else
#define init_svg_functions NULL
#endif
......@@ -8218,14 +8213,14 @@ DEF_IMGLIB_FN (void, g_error_free);
Lisp_Object Qgdk_pixbuf, Qglib, Qgobject;
static int
init_svg_functions (Lisp_Object libraries)
init_svg_functions (void)
{
HMODULE library, gdklib, glib, gobject;
if (!(glib = w32_delayed_load (libraries, Qglib))
|| !(gobject = w32_delayed_load (libraries, Qgobject))
|| !(gdklib = w32_delayed_load (libraries, Qgdk_pixbuf))
|| !(library = w32_delayed_load (libraries, Qsvg)))
if (!(glib = w32_delayed_load (Qglib))
|| !(gobject = w32_delayed_load (Qgobject))
|| !(gdklib = w32_delayed_load (Qgdk_pixbuf))
|| !(library = w32_delayed_load (Qsvg)))
return 0;
LOAD_IMGLIB_FN (library, rsvg_handle_new);
......@@ -8549,12 +8544,6 @@ static const struct image_keyword gs_format[GS_LAST] =
{":background", IMAGE_STRING_OR_NIL_VALUE, 0}
};
#ifdef HAVE_NTGUI
static int init_gs_functions (Lisp_Object);
#else
#define init_gs_functions NULL
#endif
/* Structure describing the image type `ghostscript'. */
static struct image_type gs_type =
......@@ -8563,7 +8552,7 @@ static struct image_type gs_type =
gs_image_p,
gs_load,
gs_clear_image,
init_gs_functions,
NULL,
NULL
};
......@@ -8826,77 +8815,69 @@ DEFUN ("lookup-image", Flookup_image, Slookup_image, 1, 1, 0, "")
Initialization
***********************************************************************/
DEFUN ("init-image-library", Finit_image_library, Sinit_image_library, 2, 2, 0,
DEFUN ("init-image-library", Finit_image_library, Sinit_image_library, 1, 1, 0,
doc: /* Initialize image library implementing image type TYPE.
Return non-nil if TYPE is a supported image type.
Image types pbm and xbm are prebuilt; other types are loaded here.
Libraries to load are specified in alist LIBRARIES (usually, the value
of `dynamic-library-alist', which see). */)
(Lisp_Object type, Lisp_Object libraries)
If image libraries are loaded dynamically (currently only the case on
MS-Windows), load the library for TYPE if it is not yet loaded, using
the library file(s) specified by `dynamic-library-alist'. */)
(Lisp_Object type)
{
return lookup_image_type (type, libraries) ? Qt : Qnil;
return lookup_image_type (type) ? Qt : Qnil;
}
/* Look up image type TYPE, and return a pointer to its image_type
structure. Return 0 if TYPE is not a known image type.
LIBRARIES is an alist associating dynamic libraries to external
files implementing them, which is passed to the image library
initialization function if necessary. A nil value defaults to
Vdynamic_library_alist. */
structure. Return 0 if TYPE is not a known image type. */
static struct image_type *
lookup_image_type (Lisp_Object type, Lisp_Object libraries)
lookup_image_type (Lisp_Object type)
{
if (NILP (libraries))
libraries = Vdynamic_library_alist;
/* Types pbm and xbm are built-in and always available. */
if (EQ (type, Qpbm))
return define_image_type (&pbm_type, libraries);
return define_image_type (&pbm_type);
if (EQ (type, Qxbm))
return define_image_type (&xbm_type, libraries);
return define_image_type (&xbm_type);
#if defined (HAVE_XPM) || defined (HAVE_NS)
if (EQ (type, Qxpm))
return define_image_type (&xpm_type, libraries);
return define_image_type (&xpm_type);
#endif
#if defined (HAVE_JPEG) || defined (HAVE_NS)
if (EQ (type, Qjpeg))
return define_image_type (&jpeg_type, libraries);
return define_image_type (&jpeg_type);
#endif
#if defined (HAVE_TIFF) || defined (HAVE_NS)
if (EQ (type, Qtiff))
return define_image_type (&tiff_type, libraries);
return define_image_type (&tiff_type);
#endif
#if defined (HAVE_GIF) || defined (HAVE_NS)
if (EQ (type, Qgif))
return define_image_type (&gif_type, libraries);
return define_image_type (&gif_type);
#endif
#if defined (HAVE_PNG) || defined (HAVE_NS)
if (EQ (type, Qpng))
return define_image_type (&png_type, libraries);
return define_image_type (&png_type);
#endif
#if defined (HAVE_RSVG)
if (EQ (type, Qsvg))
return define_image_type (&svg_type, libraries);
return define_image_type (&svg_type);
#endif
#if defined (HAVE_IMAGEMAGICK)
if (EQ (type, Qimagemagick))
return define_image_type (&imagemagick_type, libraries);
return define_image_type (&imagemagick_type);
#endif
#ifdef HAVE_GHOSTSCRIPT
if (EQ (type, Qpostscript))
return define_image_type (&gs_type, libraries);
return define_image_type (&gs_type);
#endif
return NULL;
......
......@@ -6525,29 +6525,27 @@ sys_localtime (const time_t *t)
Lisp_Object Vlibrary_cache;
/* The argument LIBRARIES is an alist that associates a symbol
LIBRARY_ID, identifying an external DLL library known to Emacs, to
a list of filenames under which the library is usually found. In
most cases, the argument passed as LIBRARIES is the variable
`dynamic-library-alist', which is initialized to a list of common
library names. If the function loads the library successfully, it
returns the handle of the DLL, and records the filename in the
property :loaded-from of LIBRARY_ID; it returns NULL if the library
could not be found, or when it was already loaded (because the
handle is not recorded anywhere, and so is lost after use). It
would be trivial to save the handle too in :loaded-from, but
currently there's no use case for it. */
/* Try loading LIBRARY_ID from the file(s) specified in
Vdynamic_library_alist. If the library is loaded successfully,
return the handle of the DLL, and record the filename in the
property :loaded-from of LIBRARY_ID. If the library could not be
found, or when it was already loaded (because the handle is not
recorded anywhere, and so is lost after use), return NULL.
We could also save the handle in :loaded-from, but currently
there's no use case for it. */
HMODULE
w32_delayed_load (Lisp_Object libraries, Lisp_Object library_id)
w32_delayed_load (Lisp_Object library_id)
{
HMODULE library_dll = NULL;
CHECK_SYMBOL (library_id);
if (CONSP (libraries) && NILP (Fassq (library_id, Vlibrary_cache)))
if (CONSP (Vdynamic_library_alist)
&& NILP (Fassq (library_id, Vlibrary_cache)))
{
Lisp_Object found = Qnil;
Lisp_Object dlls = Fassq (library_id, libraries);
Lisp_Object dlls = Fassq (library_id, Vdynamic_library_alist);
if (CONSP (dlls))
for (dlls = XCDR (dlls); CONSP (dlls); dlls = XCDR (dlls))
......
......@@ -146,7 +146,7 @@ extern int _sys_read_ahead (int fd);
extern int _sys_wait_accept (int fd);
extern Lisp_Object Vlibrary_cache, QCloaded_from;
extern HMODULE w32_delayed_load (Lisp_Object, Lisp_Object);
extern HMODULE w32_delayed_load (Lisp_Object);
#ifdef HAVE_GNUTLS
#include <gnutls/gnutls.h>
......
......@@ -82,7 +82,7 @@ libxml2_loaded_p (void)
#endif /* !WINDOWSNT */
static int
init_libxml2_functions (Lisp_Object libraries)
init_libxml2_functions (void)
{
#ifdef WINDOWSNT
if (libxml2_loaded_p ())
......@@ -91,7 +91,7 @@ init_libxml2_functions (Lisp_Object libraries)
{
HMODULE library;
if (!(library = w32_delayed_load (libraries, Qlibxml2_dll)))
if (!(library = w32_delayed_load (Qlibxml2_dll)))
{
message ("%s", "libxml2 library not found");
return 0;
......@@ -257,7 +257,7 @@ DEFUN ("libxml-parse-html-region", Flibxml_parse_html_region,
If BASE-URL is non-nil, it is used to expand relative URLs. */)
(Lisp_Object start, Lisp_Object end, Lisp_Object base_url)
{
if (init_libxml2_functions (Vdynamic_library_alist))
if (init_libxml2_functions ())
return parse_region (start, end, base_url, 1);
return Qnil;
}
......@@ -269,7 +269,7 @@ DEFUN ("libxml-parse-xml-region", Flibxml_parse_xml_region,
If BASE-URL is non-nil, it is used to expand relative URLs. */)
(Lisp_Object start, Lisp_Object end, Lisp_Object base_url)
{
if (init_libxml2_functions (Vdynamic_library_alist))
if (init_libxml2_functions ())
return parse_region (start, end, base_url, 0);
return Qnil;
}
......
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