start async
This commit is contained in:
@@ -70,7 +70,44 @@ jerry_value_t moduleRequireAsyncFunc(
|
|||||||
const jerry_value_t args[],
|
const jerry_value_t args[],
|
||||||
const jerry_length_t argc
|
const jerry_length_t argc
|
||||||
) {
|
) {
|
||||||
return jerry_undefined();
|
assertNotNull(callInfo, "callInfo must not be null.");
|
||||||
|
assertNotNull(args, "args must not be null.");
|
||||||
|
|
||||||
|
// Filename, required
|
||||||
|
if(argc < 1 || !jerry_value_is_string(args[0])) {
|
||||||
|
return moduleBaseThrow(
|
||||||
|
"requireAsync expects filename."
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Callback, optional.
|
||||||
|
if(argc >= 2 && !jerry_value_is_function(args[1])) {
|
||||||
|
return moduleBaseThrow(
|
||||||
|
"requireAsync callback must be a function."
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Is filename too long?
|
||||||
|
if(
|
||||||
|
jerry_string_size(args[0], JERRY_ENCODING_UTF8) >= ASSET_FILE_NAME_MAX
|
||||||
|
) {
|
||||||
|
return moduleBaseThrow("Module name too long.");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get C string
|
||||||
|
char_t moduleName[ASSET_FILE_NAME_MAX];
|
||||||
|
moduleBaseToString(args[0], moduleName, sizeof(moduleName));
|
||||||
|
|
||||||
|
// Lock asset
|
||||||
|
assetloaderinput_t input;
|
||||||
|
input.script.nothing = NULL;
|
||||||
|
|
||||||
|
assetentry_t *entry = assetLock(
|
||||||
|
moduleName,
|
||||||
|
ASSET_LOADER_TYPE_SCRIPT,
|
||||||
|
&input
|
||||||
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void moduleRequireInit(void) {
|
void moduleRequireInit(void) {
|
||||||
|
|||||||
Reference in New Issue
Block a user