}
}
+#ifdef WINDOWSNT
+static bool
+json_available_p (void)
+{
+ if (json_initialized)
+ return true;
+ json_initialized = init_json_functions ();
+ Lisp_Object status = json_initialized ? Qt : Qnil;
+ Vlibrary_cache = Fcons (Fcons (Qjson, status), Vlibrary_cache);
+ return json_initialized;
+}
+#endif
+
+static void
+ensure_json_available (void)
+{
+#ifdef WINDOWSNT
+ if (!json_available_p ())
+ Fsignal (Qjson_unavailable,
+ list1 (build_unibyte_string ("jansson library not found")));
+#endif
+}
+
+#ifdef WINDOWSNT
+DEFUN ("json--available-p", Fjson__available_p, Sjson__available_p, 0, 0, NULL,
+ doc: /* Whether libjansson is available (internal). */)
+ (void)
+{
+ return json_available_p () ? Qt : Qnil;
+}
+#endif
+
DEFUN ("json-serialize", Fjson_serialize, Sjson_serialize, 1, MANY,
NULL,
doc: /* Return the JSON representation of OBJECT as a string.
(ptrdiff_t nargs, Lisp_Object *args)
{
specpdl_ref count = SPECPDL_INDEX ();
-
-#ifdef WINDOWSNT
- if (!json_initialized)
- {
- Lisp_Object status;
- json_initialized = init_json_functions ();
- status = json_initialized ? Qt : Qnil;
- Vlibrary_cache = Fcons (Fcons (Qjson, status), Vlibrary_cache);
- }
- if (!json_initialized)
- Fsignal (Qjson_unavailable,
- list1 (build_unibyte_string ("jansson library not found")));
-#endif
+ ensure_json_available ();
struct json_configuration conf =
{json_object_hashtable, json_array_array, QCnull, QCfalse};
(ptrdiff_t nargs, Lisp_Object *args)
{
specpdl_ref count = SPECPDL_INDEX ();
-
-#ifdef WINDOWSNT
- if (!json_initialized)
- {
- Lisp_Object status;
- json_initialized = init_json_functions ();
- status = json_initialized ? Qt : Qnil;
- Vlibrary_cache = Fcons (Fcons (Qjson, status), Vlibrary_cache);
- }
- if (!json_initialized)
- Fsignal (Qjson_unavailable,
- list1 (build_unibyte_string ("jansson library not found")));
-#endif
+ ensure_json_available ();
struct json_configuration conf =
{json_object_hashtable, json_array_array, QCnull, QCfalse};
(ptrdiff_t nargs, Lisp_Object *args)
{
specpdl_ref count = SPECPDL_INDEX ();
-
-#ifdef WINDOWSNT
- if (!json_initialized)
- {
- Lisp_Object status;
- json_initialized = init_json_functions ();
- status = json_initialized ? Qt : Qnil;
- Vlibrary_cache = Fcons (Fcons (Qjson, status), Vlibrary_cache);
- }
- if (!json_initialized)
- Fsignal (Qjson_unavailable,
- list1 (build_unibyte_string ("jansson library not found")));
-#endif
+ ensure_json_available ();
Lisp_Object string = args[0];
CHECK_STRING (string);
(ptrdiff_t nargs, Lisp_Object *args)
{
specpdl_ref count = SPECPDL_INDEX ();
-
-#ifdef WINDOWSNT
- if (!json_initialized)
- {
- Lisp_Object status;
- json_initialized = init_json_functions ();
- status = json_initialized ? Qt : Qnil;
- Vlibrary_cache = Fcons (Fcons (Qjson, status), Vlibrary_cache);
- }
- if (!json_initialized)
- Fsignal (Qjson_unavailable,
- list1 (build_unibyte_string ("jansson library not found")));
-#endif
+ ensure_json_available ();
struct json_configuration conf =
{json_object_hashtable, json_array_array, QCnull, QCfalse};
DEFSYM (Qplist, "plist");
DEFSYM (Qarray, "array");
+#ifdef WINDOWSNT
+ defsubr (&Sjson__available_p);
+#endif
defsubr (&Sjson_serialize);
defsubr (&Sjson_insert);
defsubr (&Sjson_parse_string);