27
27
#include "jerryscript-ext/print.h"
28
28
29
29
jerry_value_t
30
- jerryx_source_parse_script (const char * path_p )
30
+ jerryx_source_parse_script (const jerry_string_t * path_p )
31
31
{
32
32
jerry_size_t source_size ;
33
- jerry_char_t * source_p = jerry_port_source_read (path_p , & source_size );
33
+ jerry_char_t * source_p = jerry_port_source_read (( const char * ) path_p -> ptr , & source_size );
34
34
35
35
if (source_p == NULL )
36
36
{
37
- jerry_log (JERRY_LOG_LEVEL_ERROR , "Failed to open file: %s\n" , path_p );
37
+ jerry_log (JERRY_LOG_LEVEL_ERROR , "Failed to open file: %.* s\n" , path_p -> size , path_p -> ptr );
38
38
return jerry_throw_sz (JERRY_ERROR_SYNTAX , "Source file not found" );
39
39
}
40
40
@@ -46,8 +46,7 @@ jerryx_source_parse_script (const char *path_p)
46
46
47
47
jerry_parse_options_t parse_options ;
48
48
parse_options .options = JERRY_PARSE_HAS_SOURCE_NAME ;
49
- parse_options .source_name =
50
- jerry_string ((const jerry_char_t * ) path_p , (jerry_size_t ) strlen (path_p ), JERRY_ENCODING_UTF8 );
49
+ parse_options .source_name = jerry_string (path_p -> ptr , path_p -> size , JERRY_ENCODING_UTF8 );
51
50
52
51
jerry_value_t result = jerry_parse (source_p , source_size , & parse_options );
53
52
@@ -58,7 +57,7 @@ jerryx_source_parse_script (const char *path_p)
58
57
} /* jerryx_source_parse_script */
59
58
60
59
jerry_value_t
61
- jerryx_source_exec_script (const char * path_p )
60
+ jerryx_source_exec_script (const jerry_string_t * path_p )
62
61
{
63
62
jerry_value_t result = jerryx_source_parse_script (path_p );
64
63
@@ -73,10 +72,9 @@ jerryx_source_exec_script (const char *path_p)
73
72
} /* jerryx_source_exec_script */
74
73
75
74
jerry_value_t
76
- jerryx_source_exec_module (const char * path_p )
75
+ jerryx_source_exec_module (const jerry_string_t * path_p )
77
76
{
78
- jerry_value_t specifier =
79
- jerry_string ((const jerry_char_t * ) path_p , (jerry_size_t ) strlen (path_p ), JERRY_ENCODING_UTF8 );
77
+ jerry_value_t specifier = jerry_string (path_p -> ptr , path_p -> size , JERRY_ENCODING_UTF8 );
80
78
jerry_value_t referrer = jerry_undefined ();
81
79
82
80
jerry_value_t module = jerry_module_resolve (specifier , referrer , NULL );
@@ -110,14 +108,14 @@ jerryx_source_exec_module (const char *path_p)
110
108
} /* jerryx_source_exec_module */
111
109
112
110
jerry_value_t
113
- jerryx_source_exec_snapshot (const char * path_p , size_t function_index )
111
+ jerryx_source_exec_snapshot (const jerry_string_t * path_p , size_t function_index )
114
112
{
115
113
jerry_size_t source_size ;
116
- jerry_char_t * source_p = jerry_port_source_read (path_p , & source_size );
114
+ jerry_char_t * source_p = jerry_port_source_read (( const char * ) path_p -> ptr , & source_size );
117
115
118
116
if (source_p == NULL )
119
117
{
120
- jerry_log (JERRY_LOG_LEVEL_ERROR , "Failed to open file: %s\n" , path_p );
118
+ jerry_log (JERRY_LOG_LEVEL_ERROR , "Failed to open file: %.* s\n" , path_p -> size , path_p -> ptr );
121
119
return jerry_throw_sz (JERRY_ERROR_SYNTAX , "Snapshot file not found" );
122
120
}
123
121
0 commit comments