Add core unicode functionality.

Add utf-8 processing routines.
Change ecma_char_t from char/uint16_t to uint16_t.
Apply all utf-8 processing routines.
Change char to jerry_api_char in API functions' declarations.

JerryScript-DCO-1.0-Signed-off-by: Andrey Shitov a.shitov@samsung.com
This commit is contained in:
Andrey Shitov
2015-06-29 19:17:17 +03:00
parent c4b0cd2196
commit fd9ff8e3bd
56 changed files with 2468 additions and 1480 deletions
@@ -21,6 +21,7 @@
#include "ecma-lex-env.h"
#include "ecma-try-catch-macro.h"
#include "serializer.h"
#include "lit-magic-strings.h"
#include "parser.h"
#define ECMA_BUILTINS_INTERNAL
@@ -73,22 +74,22 @@ ecma_builtin_function_dispatch_construct (const ecma_value_t *arguments_list_p,
/* Last string, if any, is the function's body, and the rest, if any - are the function's parameter names */
MEM_DEFINE_LOCAL_ARRAY (string_params_p,
arguments_list_len == 0 ? 1 : arguments_list_len,
ecma_string_t*);
ecma_string_t *);
uint32_t params_count;
size_t zt_strings_buffer_size;
size_t strings_buffer_size;
if (arguments_list_len == 0)
{
/* 3. */
string_params_p[0] = ecma_new_ecma_string_from_magic_string_id (LIT_MAGIC_STRING__EMPTY);
zt_strings_buffer_size = sizeof (ecma_char_t);
strings_buffer_size = lit_get_magic_string_size (LIT_MAGIC_STRING__EMPTY);
params_count = 1;
}
else
{
/* 4., 5., 6. */
zt_strings_buffer_size = 0;
strings_buffer_size = 0;
params_count = 0;
while (params_count < arguments_list_len
@@ -99,8 +100,7 @@ ecma_builtin_function_dispatch_construct (const ecma_value_t *arguments_list_p,
ret_value);
string_params_p[params_count] = ecma_copy_or_ref_ecma_string (ecma_get_string_from_value (str_arg_value));
zt_strings_buffer_size += ((size_t) ecma_string_get_length (string_params_p[params_count]) +
sizeof (ecma_char_t));
strings_buffer_size += ecma_string_get_size (string_params_p[params_count]);
params_count++;
ECMA_FINALIZE (str_arg_value);
@@ -111,30 +111,35 @@ ecma_builtin_function_dispatch_construct (const ecma_value_t *arguments_list_p,
{
JERRY_ASSERT (params_count >= 1);
MEM_DEFINE_LOCAL_ARRAY (zt_string_params_p,
MEM_DEFINE_LOCAL_ARRAY (utf8_string_params_p,
params_count,
ecma_char_t*);
MEM_DEFINE_LOCAL_ARRAY (zt_string_buffer_p,
zt_strings_buffer_size,
ecma_char_t);
lit_utf8_byte_t *);
MEM_DEFINE_LOCAL_ARRAY (utf8_string_params_size,
params_count,
size_t);
MEM_DEFINE_LOCAL_ARRAY (utf8_string_buffer_p,
strings_buffer_size,
lit_utf8_byte_t);
ssize_t zt_string_buffer_pos = 0;
ssize_t utf8_string_buffer_pos = 0;
for (uint32_t i = 0; i < params_count; i++)
{
ssize_t sz = ecma_string_to_zt_string (string_params_p[i],
&zt_string_buffer_p[zt_string_buffer_pos],
(ssize_t) zt_strings_buffer_size - zt_string_buffer_pos);
JERRY_ASSERT (sz > 0);
ssize_t sz = ecma_string_to_utf8_string (string_params_p[i],
&utf8_string_buffer_p[utf8_string_buffer_pos],
(ssize_t) strings_buffer_size - utf8_string_buffer_pos);
JERRY_ASSERT (sz >= 0);
zt_string_params_p[i] = zt_string_buffer_p + zt_string_buffer_pos;
utf8_string_params_p[i] = utf8_string_buffer_p + utf8_string_buffer_pos;
utf8_string_params_size[i] = (size_t) sz;
zt_string_buffer_pos += sz;
utf8_string_buffer_pos += sz;
}
const opcode_t* opcodes_p;
bool is_syntax_correct;
is_syntax_correct = parser_parse_new_function ((const char **) zt_string_params_p,
is_syntax_correct = parser_parse_new_function ((const jerry_api_char_t **) utf8_string_params_p,
utf8_string_params_size,
params_count,
&opcodes_p);
@@ -180,8 +185,9 @@ ecma_builtin_function_dispatch_construct (const ecma_value_t *arguments_list_p,
ret_value = ecma_make_normal_completion_value (ecma_make_object_value (func_obj_p));
}
MEM_FINALIZE_LOCAL_ARRAY (zt_string_buffer_p);
MEM_FINALIZE_LOCAL_ARRAY (zt_string_params_p);
MEM_FINALIZE_LOCAL_ARRAY (utf8_string_buffer_p);
MEM_FINALIZE_LOCAL_ARRAY (utf8_string_params_size);
MEM_FINALIZE_LOCAL_ARRAY (utf8_string_params_p);
}
for (uint32_t i = 0; i < params_count; i++)