Added janet_getfile C API function and revert core/file AT registering

This commit is contained in:
J.-F. Cap 2019-03-02 15:36:34 +01:00
parent d70049dbb1
commit 1753f8bc18
2 changed files with 10 additions and 2 deletions

View File

@ -400,6 +400,14 @@ static const JanetReg io_cfuns[] = {
{NULL, NULL, NULL}
};
/* C API */
FILE *janet_getfile(const Janet *argv, int32_t n, int *flags) {
IOFile *iof = janet_getabstract(argv, n, &cfun_io_filetype);
*flags = iof->flags;
return iof->file;
}
/* Module entry point */
void janet_lib_io(JanetTable *env) {
janet_core_cfuns(env, NULL, io_cfuns);
@ -417,6 +425,4 @@ void janet_lib_io(JanetTable *env) {
makef(stdin, IO_READ | IO_NOT_CLOSEABLE | IO_SERIALIZABLE),
JDOC("The standard input file."));
janet_register_abstract_type(&cfun_io_filetype);
}

View File

@ -1250,6 +1250,8 @@ JANET_API JanetRange janet_getslice(int32_t argc, const Janet *argv);
JANET_API int32_t janet_gethalfrange(const Janet *argv, int32_t n, int32_t length, const char *which);
JANET_API int32_t janet_getargindex(const Janet *argv, int32_t n, int32_t length, const char *which);
JANET_API FILE *janet_getfile(const Janet *argv, int32_t n, int *flags);
/* Marshal API */
JANET_API void janet_marshal_int(JanetMarshalContext *ctx, int32_t value);