summaryrefslogtreecommitdiffstats
path: root/player/javascript.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2020-02-01 18:09:40 +0100
committerwm4 <wm4@nowhere>2020-02-01 18:09:40 +0100
commitda38caff9c0bec4745cef16b7904e26e51a4539b (patch)
tree39ea39729f109713d1871f0aed053a156f86c768 /player/javascript.c
parent66a979bd757f27739158023f44a943a406a59159 (diff)
downloadmpv-da38caff9c0bec4745cef16b7904e26e51a4539b.tar.bz2
mpv-da38caff9c0bec4745cef16b7904e26e51a4539b.tar.xz
scripting: load scripts from directories
The intention is to provide a slightly nicer way to distribute scripts. For example, you could put multiple source files into the directory, and then import them from the actual script file (this is still unimplemented). At first I wanted to require a config file (because you need to know at least which scripting backend it should use). This wouldn't have been too hard (could have reused/abused the mpv config file parsing mechanism, and I already had working code that was just 2 function calls). But probably better to do this without new config files, because it might become a pain in the distant future. So this just probes for "main.lua", "main.js", etc., until an existing file is found. Another important change is that this skips all directory entries whose name starts with ".". This automatically excludes the "." and ".." special directories, and is probably useful to exclude random crap that might be lying around in the directory (such as editor temporary files, or OSX, in its usual hrmful, annoying, and idiotic modus operandi, sharting all over any directories opened by "Finder"). Although the changelog mentions the docs, they're added only in a later commit.
Diffstat (limited to 'player/javascript.c')
-rw-r--r--player/javascript.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/player/javascript.c b/player/javascript.c
index 8d0e7715f1..6047add255 100644
--- a/player/javascript.c
+++ b/player/javascript.c
@@ -468,15 +468,15 @@ static int s_init_js(js_State *J, struct script_ctx *ctx)
//
// Note: init functions don't need autofree. They can use ctx as a talloc
// context and free normally. If they throw - ctx is freed right afterwards.
-static int s_load_javascript(struct mpv_handle *client, const char *fname)
+static int s_load_javascript(struct mp_script_args *args)
{
struct script_ctx *ctx = talloc_ptrtype(NULL, ctx);
*ctx = (struct script_ctx) {
- .client = client,
- .mpctx = mp_client_get_core(client),
- .log = mp_client_get_log(client),
+ .client = args->client,
+ .mpctx = args->mpctx,
+ .log = args->log,
.last_error_str = talloc_strdup(ctx, "Cannot initialize JavaScript"),
- .filename = fname,
+ .filename = args->filename,
};
int r = -1;