1
0
mirror of https://github.com/janet-lang/janet synced 2024-11-17 14:14:49 +00:00

Merge pull request #56 from jfcap/register-corefile

Register core/file abstract type
This commit is contained in:
Calvin Rose 2019-03-02 11:40:05 -05:00 committed by GitHub
commit efbb704247
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 0 deletions

View File

@ -400,6 +400,14 @@ static const JanetReg io_cfuns[] = {
{NULL, NULL, NULL} {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 */ /* Module entry point */
void janet_lib_io(JanetTable *env) { void janet_lib_io(JanetTable *env) {
janet_core_cfuns(env, NULL, io_cfuns); janet_core_cfuns(env, NULL, io_cfuns);
@ -416,4 +424,5 @@ void janet_lib_io(JanetTable *env) {
janet_core_def(env, "stdin", janet_core_def(env, "stdin",
makef(stdin, IO_READ | IO_NOT_CLOSEABLE | IO_SERIALIZABLE), makef(stdin, IO_READ | IO_NOT_CLOSEABLE | IO_SERIALIZABLE),
JDOC("The standard input file.")); JDOC("The standard input file."));
} }

View File

@ -1254,6 +1254,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_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 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 */ /* Marshal API */
JANET_API void janet_marshal_int(JanetMarshalContext *ctx, int32_t value); JANET_API void janet_marshal_int(JanetMarshalContext *ctx, int32_t value);