56 lines
1.2 KiB
C
56 lines
1.2 KiB
C
/**
|
|
* Copyright (c) 2026 Dominic Masters
|
|
*
|
|
* This software is released under the MIT License.
|
|
* https://opensource.org/licenses/MIT
|
|
*/
|
|
|
|
#pragma once
|
|
#include "error/error.h"
|
|
|
|
typedef struct {
|
|
bool_t initialized;
|
|
} script_t;
|
|
|
|
extern script_t SCRIPT;
|
|
|
|
/**
|
|
* Initializes the script system, starting up JerryScript and registering all
|
|
* built-in modules.
|
|
*
|
|
* @return Any error that occurred.
|
|
*/
|
|
errorret_t scriptInit(void);
|
|
|
|
/**
|
|
* Updates the script system, running any pending jobs. This should be called
|
|
* once per frame.
|
|
*
|
|
* @return Any error that occurred.
|
|
*/
|
|
errorret_t scriptUpdate(void);
|
|
|
|
/**
|
|
* Evaluates a JS source string in the global scope.
|
|
*
|
|
* @param source Null-terminated JS source to evaluate.
|
|
* @return Any error that occurred.
|
|
*/
|
|
errorret_t scriptExecString(const char_t *source);
|
|
|
|
/**
|
|
* Loads and evaluates a script asset from the archive. The result is cached
|
|
* by the asset system; repeated calls with the same path do not re-execute.
|
|
*
|
|
* @param path Path of the script inside the asset archive.
|
|
* @return Any error that occurred.
|
|
*/
|
|
errorret_t scriptExecFile(const char_t *path);
|
|
|
|
/**
|
|
* Disposes of the script system and shuts down JerryScript.
|
|
*
|
|
* @return Any error that occurred.
|
|
*/
|
|
errorret_t scriptDispose(void);
|