[gjs] system: Add wrapper for JS_ClearDateCaches
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs] system: Add wrapper for JS_ClearDateCaches
- Date: Mon, 24 Nov 2014 08:19:07 +0000 (UTC)
commit 3b3534fe7a26535d19eb2ed9fcd750577dc6c43d
Author: Martin Andersson <g02maran gmail com>
Date: Sun May 4 19:01:39 2014 +0300
system: Add wrapper for JS_ClearDateCaches
https://bugzilla.gnome.org/show_bug.cgi?id=739790
modules/system.cpp | 20 ++++++++++++++++++++
1 files changed, 20 insertions(+), 0 deletions(-)
---
diff --git a/modules/system.cpp b/modules/system.cpp
index 51f14ef..92c5640 100644
--- a/modules/system.cpp
+++ b/modules/system.cpp
@@ -26,6 +26,7 @@
#include <sys/types.h>
#include <unistd.h>
+#include <time.h>
#include <gjs/gjs-module.h>
#include <gi/object.h>
@@ -121,12 +122,31 @@ gjs_exit(JSContext *context,
return JS_TRUE;
}
+static JSBool
+gjs_clear_date_caches(JSContext *context,
+ unsigned argc,
+ jsval *vp)
+{
+ JS_BeginRequest(context);
+
+ // Workaround for a bug in SpiderMonkey where tzset is not called before
+ // localtime_r, see https://bugzilla.mozilla.org/show_bug.cgi?id=1004706
+ tzset();
+
+ JS_ClearDateCaches(context);
+ JS_EndRequest(context);
+
+ JS_SET_RVAL(context, vp, JSVAL_VOID);
+ return JS_TRUE;
+}
+
static JSFunctionSpec module_funcs[] = {
{ "addressOf", JSOP_WRAPPER (gjs_address_of), 1, GJS_MODULE_PROP_FLAGS },
{ "refcount", JSOP_WRAPPER (gjs_refcount), 1, GJS_MODULE_PROP_FLAGS },
{ "breakpoint", JSOP_WRAPPER (gjs_breakpoint), 0, GJS_MODULE_PROP_FLAGS },
{ "gc", JSOP_WRAPPER (gjs_gc), 0, GJS_MODULE_PROP_FLAGS },
{ "exit", JSOP_WRAPPER (gjs_exit), 0, GJS_MODULE_PROP_FLAGS },
+ { "clearDateCaches", JSOP_WRAPPER (gjs_clear_date_caches), 0, GJS_MODULE_PROP_FLAGS },
{ NULL },
};
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]