diff options
| -rw-r--r-- | src/date.h | 4 | ||||
| -rw-r--r-- | src/main.c | 4 | ||||
| -rw-r--r-- | src/polyfill.h | 6 | ||||
| -rw-r--r-- | src/time.c | 15 | ||||
| -rw-r--r-- | src/tm.c | 21 |
5 files changed, 25 insertions, 25 deletions
@@ -13,7 +13,7 @@ JanetBuffer *strftime_buffer(const char *format, const struct tm *tm, JanetBuffer *buffer); // time.c -extern const JanetRegExt jd_time_cfuns[]; +void jd_time_register(JanetTable*, const char*); time_t *jd_gettime(Janet *argv, int32_t n); time_t *jd_maketime(void); JANET_CFUN(jd_gmtime); @@ -21,7 +21,7 @@ JANET_CFUN(jd_localtime); JANET_CFUN(jd_time); // tm.c -extern const JanetRegExt jd_tm_cfuns[]; +void jd_tm_register(JanetTable*, const char*); struct tm *jd_gettm(Janet *argv, int32_t n); struct tm *jd_opttm(Janet *argv, int32_t argc, int32_t n); struct tm *jd_maketm(void); @@ -1,6 +1,6 @@ #include "date.h" JANET_MODULE_ENTRY(JanetTable *env) { - janet_cfuns_ext(env, "date/native", jd_time_cfuns); - janet_cfuns_ext(env, "date/native", jd_tm_cfuns); + jd_time_register(env, "date/native"); + jd_tm_register(env, "date/native"); } diff --git a/src/polyfill.h b/src/polyfill.h index e595ce0..70ea4f5 100644 --- a/src/polyfill.h +++ b/src/polyfill.h @@ -21,12 +21,6 @@ const char *janet_optcbytes(const Janet *argv, int32_t argc, int32_t n, const ch #endif // !defined(JANET_NO_SOURCEMAPS) #endif // JANET_VERSION_MAJOR < 2 && JANET_VERSION_MINOR < 28 -// JANET_REG is broken on windows, so make it JANET_REG_ (no S no D) -#ifdef _MSC_VER -#undef JANET_REG -#define JANET_REG JANET_REG_ -#endif - // timegm #ifdef _MSC_VER #define timegm _mkgmtime @@ -82,9 +82,12 @@ JANET_FN(jd_time, return janet_wrap_abstract(out); } -const JanetRegExt jd_time_cfuns[] = { - JANET_REG("gmtime", jd_gmtime), - JANET_REG("localtime", jd_localtime), - JANET_REG("time", jd_time), - JANET_REG_END -}; +void jd_time_register(JanetTable *env, const char *regprefix) { + const JanetRegExt cfuns[] = { + JANET_REG("gmtime", jd_gmtime), + JANET_REG("localtime", jd_localtime), + JANET_REG("time", jd_time), + JANET_REG_END + }; + janet_cfuns_ext(env, regprefix, cfuns); +} @@ -340,12 +340,15 @@ JANET_FN(jd_strftime, return janet_wrap_buffer(strftime_buffer(format, tm, NULL)); } -const JanetRegExt jd_tm_cfuns[] = { - JANET_REG("tm", jd_tm), - JANET_REG("mktime", jd_mktime), - JANET_REG("mktime!", jd_mktime_inplace), - JANET_REG("timegm", jd_timegm), - JANET_REG("timegm!", jd_timegm_inplace), - JANET_REG("strftime", jd_strftime), - JANET_REG_END -}; +void jd_tm_register(JanetTable *env, const char *regprefix) { + const JanetRegExt cfuns[] = { + JANET_REG("tm", jd_tm), + JANET_REG("mktime", jd_mktime), + JANET_REG("mktime!", jd_mktime_inplace), + JANET_REG("timegm", jd_timegm), + JANET_REG("timegm!", jd_timegm_inplace), + JANET_REG("strftime", jd_strftime), + JANET_REG_END + }; + janet_cfuns_ext(env, regprefix, cfuns); +} |
