rewrote stix_bitandints(), stix_bitorints(), stix_bitxorints() to handle negative numbers in the 2's complement form

This commit is contained in:
hyunghwan.chung 2015-12-17 16:11:10 +00:00
parent bf412e0c07
commit 08cfa55acc
17 changed files with 866 additions and 556 deletions

View File

@ -294,13 +294,13 @@ PROCESS TESTING
##(0 \\ -50000000000000000000000000000000000000000000000000000000000000000000) dump. ##(0 \\ -50000000000000000000000000000000000000000000000000000000000000000000) dump.
##(0 // -50000000000000000000000000000000000000000000000000000000000000000000) dump. ##(0 // -50000000000000000000000000000000000000000000000000000000000000000000) dump.
(-270000000000000000000000000000000000000000000000000000000000000000000 rem: -1) dump. ##(-270000000000000000000000000000000000000000000000000000000000000000000 rem: -1) dump.
(-270000000000000000000000000000000000000000000000000000000000000000000 quo: -1) dump. ##(-270000000000000000000000000000000000000000000000000000000000000000000 quo: -1) dump.
(-270000000000000000000000000000000000000000000000000000000000000000000 \\ -1) dump. ##(-270000000000000000000000000000000000000000000000000000000000000000000 \\ -1) dump.
(-270000000000000000000000000000000000000000000000000000000000000000000 // -1) dump. ##(-270000000000000000000000000000000000000000000000000000000000000000000 // -1) dump.
## (-27029038 // 2) asString dump. ## (-27029038 // 2) asString dump.
(-270290380000000000000000000000000000000000000000000000000000000000000000000000000000000000000 // 2) asString dump. ## (-270290380000000000000000000000000000000000000000000000000000000000000000000000000000000000000 // 2) asString dump.
##(-16rAAAAAAAABBBBBBBBCCCCCCCCDDDDDDDDEEEEEEEEFFFFFFFF) asString dump. ##(-16rAAAAAAAABBBBBBBBCCCCCCCCDDDDDDDDEEEEEEEEFFFFFFFF) asString dump.
## (16r2dd01fc06c265c8163ac729b49d890939826ce3dd quo: 16r3b9aca00) dump. ## (16r2dd01fc06c265c8163ac729b49d890939826ce3dd quo: 16r3b9aca00) dump.
@ -321,7 +321,10 @@ PROCESS TESTING
##(-270 // 5) dump. ##(-270 // 5) dump.
##(16rFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF bitAnd: 16r1111111111111111111111111111111111111111) dump. ##(16rFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF bitAnd: 16r1111111111111111111111111111111111111111) dump.
(16rF0FFFF bitOr: 16r111111) dump.
(2r1111111111111111111111111111111111111111111111111111111111111111 printStringRadix:2) dump.
"(16rF0FFFF bitOr: 16r111111) dump.
(16r11 bitOr: 16r20000000000000000000000000000000FFFFFFFFFFFFFFFF11111100000000000000000001) dump. (16r11 bitOr: 16r20000000000000000000000000000000FFFFFFFFFFFFFFFF11111100000000000000000001) dump.
((16r11 bitOr: 16r20000000000000000000000000000000FFFFFFFFFFFFFFFF11111100000000000000000001) bitOr: 16r1100) dump. ((16r11 bitOr: 16r20000000000000000000000000000000FFFFFFFFFFFFFFFF11111100000000000000000001) bitOr: 16r1100) dump.
@ -332,6 +335,24 @@ PROCESS TESTING
((2r11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 bitXor: 2r11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111) printStringRadix: 2) dump. ((2r11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 bitXor: 2r11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111) printStringRadix: 2) dump.
((2r10101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101 bitAnd: 2r01010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010) printStringRadix: 2) dump. ((2r10101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101 bitAnd: 2r01010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010) printStringRadix: 2) dump.
"
(16rFFFFFFFFFFFFFFFF bitOr: 16rFFFFFFFFFFFFFFFFFFFFFFFF) dump.
(-16rFFFFFFFFFFFFFFFF bitOr: 16rFFFFFFFFFFFFFFFFFFFFFFFF) dump.
(16rFFFFFFFFFFFFFFFF bitOr: -16rFFFFFFFFFFFFFFFFFFFFFFFF) dump.
(-16rFFFFFFFFFFFFFFFF bitOr: -16rFFFFFFFFFFFFFFFFFFFFFFFF) dump.
((16rFFFFFFF bitXor: -16rFFFFFFF) printStringRadix: 16) dump.
((16r1234 bitXor: -16rFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF) printStringRadix: 16) dump.
((16r1234 bitXor: 2r1111111111111111111111111111111111111111111111111111111111111) printStringRadix: 16) dump.
((16r1234 bitXor: 2r100000000000000000000000000000000000000000000000000000000000000000000000000000) printStringRadix: 16) dump.
((-16r1234 bitXor: 2r100000000000000000000000000000000000000000000000000000000000000000000000000000) printStringRadix: 16) dump.
((16r1234 bitXor: -2r100000000000000000000000000000000000000000000000000000000000000000000000000000) printStringRadix: 16) dump.
((-16r1234 bitXor: -2r100000000000000000000000000000000000000000000000000000000000000000000000000000) printStringRadix: 16) dump.
" "
FFI isNil dump. FFI isNil dump.
FFI notNil dump. FFI notNil dump.

File diff suppressed because it is too large Load Diff

View File

@ -70,7 +70,7 @@ typedef enum var_type_t var_type_t;
struct var_info_t struct var_info_t
{ {
var_type_t type; var_type_t type;
stix_ssize_t pos; /* not used for VAR_GLOBAL */ stix_ooi_t pos; /* not used for VAR_GLOBAL */
stix_oop_class_t cls; /* useful if type is VAR_CLASS. note STIX_NULL indicates the self class. */ stix_oop_class_t cls; /* useful if type is VAR_CLASS. note STIX_NULL indicates the self class. */
stix_oop_association_t gbl; /* used for VAR_GLOBAL only */ stix_oop_association_t gbl; /* used for VAR_GLOBAL only */
}; };
@ -149,7 +149,7 @@ typedef enum voca_id_t voca_id_t;
static int compile_block_statement (stix_t* stix); static int compile_block_statement (stix_t* stix);
static int compile_method_statement (stix_t* stix); static int compile_method_statement (stix_t* stix);
static int compile_method_expression (stix_t* stix, int pop); static int compile_method_expression (stix_t* stix, int pop);
static int add_literal (stix_t* stix, stix_oop_t lit, stix_size_t* index); static int add_literal (stix_t* stix, stix_oop_t lit, stix_oow_t* index);
static STIX_INLINE int is_spacechar (stix_ooci_t c) static STIX_INLINE int is_spacechar (stix_ooci_t c)
{ {
@ -327,9 +327,9 @@ static void set_syntax_error (stix_t* stix, stix_synerrnum_t num, const stix_iol
} }
} }
static int copy_string_to (stix_t* stix, const stix_oocs_t* src, stix_oocs_t* dst, stix_size_t* dst_capa, int append, stix_ooch_t add_delim) static int copy_string_to (stix_t* stix, const stix_oocs_t* src, stix_oocs_t* dst, stix_oow_t* dst_capa, int append, stix_ooch_t add_delim)
{ {
stix_size_t len, pos; stix_oow_t len, pos;
if (append) if (append)
{ {
@ -346,7 +346,7 @@ static int copy_string_to (stix_t* stix, const stix_oocs_t* src, stix_oocs_t* ds
if (len > *dst_capa) if (len > *dst_capa)
{ {
stix_ooch_t* tmp; stix_ooch_t* tmp;
stix_size_t capa; stix_oow_t capa;
capa = STIX_ALIGN(len, CLASS_BUFFER_ALIGN); capa = STIX_ALIGN(len, CLASS_BUFFER_ALIGN);
@ -363,7 +363,7 @@ static int copy_string_to (stix_t* stix, const stix_oocs_t* src, stix_oocs_t* ds
return 0; return 0;
} }
static int find_word_in_string (const stix_oocs_t* haystack, const stix_oocs_t* name, stix_size_t* xindex) static int find_word_in_string (const stix_oocs_t* haystack, const stix_oocs_t* name, stix_oow_t* xindex)
{ {
/* this function is inefficient. but considering the typical number /* this function is inefficient. but considering the typical number
* of arguments and temporary variables, the inefficiency can be * of arguments and temporary variables, the inefficiency can be
@ -372,7 +372,7 @@ static int find_word_in_string (const stix_oocs_t* haystack, const stix_oocs_t*
* inefficient lookup */ * inefficient lookup */
stix_ooch_t* t, * e; stix_ooch_t* t, * e;
stix_size_t index, i; stix_oow_t index, i;
t = haystack->ptr; t = haystack->ptr;
e = t + haystack->len; e = t + haystack->len;
@ -554,7 +554,7 @@ static stix_oop_t string_to_num (stix_t* stix, stix_oocs_t* str, int radixed)
do { if (add_token_char(stix, c) <= -1) return -1; } while (0) do { if (add_token_char(stix, c) <= -1) return -1; } while (0)
static STIX_INLINE int add_token_str (stix_t* stix, const stix_ooch_t* ptr, stix_size_t len) static STIX_INLINE int add_token_str (stix_t* stix, const stix_ooch_t* ptr, stix_oow_t len)
{ {
stix_oocs_t tmp; stix_oocs_t tmp;
@ -581,7 +581,7 @@ static STIX_INLINE void unget_char (stix_t* stix, const stix_iolxc_t* c)
static int get_char (stix_t* stix) static int get_char (stix_t* stix)
{ {
stix_ssize_t n; stix_ooi_t n;
stix_ooci_t lc, ec; stix_ooci_t lc, ec;
if (stix->c->nungots > 0) if (stix->c->nungots > 0)
@ -993,11 +993,11 @@ static int get_strlit (stix_t* stix)
return 0; return 0;
} }
static int get_string (stix_t* stix, stix_ooch_t end_char, stix_ooch_t esc_char, int regex, stix_size_t preescaped) static int get_string (stix_t* stix, stix_ooch_t end_char, stix_ooch_t esc_char, int regex, stix_oow_t preescaped)
{ {
stix_ooci_t c; stix_ooci_t c;
stix_size_t escaped = preescaped; stix_oow_t escaped = preescaped;
stix_size_t digit_count = 0; stix_oow_t digit_count = 0;
stix_ooci_t c_acc = 0; stix_ooci_t c_acc = 0;
stix->c->tok.type = STIX_IOTOK_STRLIT; stix->c->tok.type = STIX_IOTOK_STRLIT;
@ -1624,7 +1624,7 @@ static int end_include (stix_t* stix)
static STIX_INLINE int emit_byte_instruction (stix_t* stix, stix_oob_t code) static STIX_INLINE int emit_byte_instruction (stix_t* stix, stix_oob_t code)
{ {
stix_size_t i; stix_oow_t i;
i = stix->c->mth.code.len + 1; i = stix->c->mth.code.len + 1;
if (i > stix->c->mth.code_capa) if (i > stix->c->mth.code_capa)
@ -1716,7 +1716,7 @@ write_long:
} }
static int emit_double_param_instruction (stix_t* stix, int cmd, stix_size_t param_1, stix_size_t param_2) static int emit_double_param_instruction (stix_t* stix, int cmd, stix_oow_t param_1, stix_oow_t param_2)
{ {
stix_oob_t bc; stix_oob_t bc;
@ -1773,7 +1773,7 @@ write_long:
static int emit_push_smint_literal (stix_t* stix, stix_ooi_t i) static int emit_push_smint_literal (stix_t* stix, stix_ooi_t i)
{ {
stix_size_t index; stix_oow_t index;
switch (i) switch (i)
{ {
@ -1818,9 +1818,9 @@ printf ("\tpush litral_0 %d\n", (int)index);
* --------------------------------------------------------------------- */ * --------------------------------------------------------------------- */
static int add_literal (stix_t* stix, stix_oop_t lit, stix_size_t* index) static int add_literal (stix_t* stix, stix_oop_t lit, stix_oow_t* index)
{ {
stix_size_t i; stix_oow_t i;
for (i = 0; i < stix->c->mth.literal_count; i++) for (i = 0; i < stix->c->mth.literal_count; i++)
{ {
@ -1839,7 +1839,7 @@ static int add_literal (stix_t* stix, stix_oop_t lit, stix_size_t* index)
if (stix->c->mth.literal_count >= stix->c->mth.literal_capa) if (stix->c->mth.literal_count >= stix->c->mth.literal_capa)
{ {
stix_oop_t* tmp; stix_oop_t* tmp;
stix_size_t new_capa; stix_oow_t new_capa;
new_capa = STIX_ALIGN (stix->c->mth.literal_count + 1, LITERAL_BUFFER_ALIGN); new_capa = STIX_ALIGN (stix->c->mth.literal_count + 1, LITERAL_BUFFER_ALIGN);
tmp = (stix_oop_t*)stix_reallocmem (stix, stix->c->mth.literals, new_capa * STIX_SIZEOF(*tmp)); tmp = (stix_oop_t*)stix_reallocmem (stix, stix->c->mth.literals, new_capa * STIX_SIZEOF(*tmp));
@ -1854,15 +1854,15 @@ static int add_literal (stix_t* stix, stix_oop_t lit, stix_size_t* index)
return 0; return 0;
} }
static STIX_INLINE int add_character_literal (stix_t* stix, stix_ooch_t ch, stix_size_t* index) static STIX_INLINE int add_character_literal (stix_t* stix, stix_ooch_t ch, stix_oow_t* index)
{ {
return add_literal (stix, STIX_CHAR_TO_OOP(ch), index); return add_literal (stix, STIX_CHAR_TO_OOP(ch), index);
} }
static int add_string_literal (stix_t* stix, const stix_oocs_t* str, stix_size_t* index) static int add_string_literal (stix_t* stix, const stix_oocs_t* str, stix_oow_t* index)
{ {
stix_oop_t lit; stix_oop_t lit;
stix_size_t i; stix_oow_t i;
for (i = 0; i < stix->c->mth.literal_count; i++) for (i = 0; i < stix->c->mth.literal_count; i++)
{ {
@ -1883,7 +1883,7 @@ static int add_string_literal (stix_t* stix, const stix_oocs_t* str, stix_size_t
return add_literal (stix, lit, index); return add_literal (stix, lit, index);
} }
static int add_symbol_literal (stix_t* stix, const stix_oocs_t* str, stix_size_t* index) static int add_symbol_literal (stix_t* stix, const stix_oocs_t* str, stix_oow_t* index)
{ {
stix_oop_t tmp; stix_oop_t tmp;
@ -1924,7 +1924,7 @@ static STIX_INLINE int add_class_level_variable (stix_t* stix, var_type_t index,
static STIX_INLINE int add_pool_dictionary (stix_t* stix, const stix_oocs_t* name, stix_oop_set_t pooldic_oop) static STIX_INLINE int add_pool_dictionary (stix_t* stix, const stix_oocs_t* name, stix_oop_set_t pooldic_oop)
{ {
int n; int n;
stix_size_t saved_len; stix_oow_t saved_len;
saved_len = stix->c->cls.pooldic.len; saved_len = stix->c->cls.pooldic.len;
@ -1933,7 +1933,7 @@ static STIX_INLINE int add_pool_dictionary (stix_t* stix, const stix_oocs_t* nam
{ {
if (stix->c->cls.pooldic_count >= stix->c->cls.pooldic_oop_capa) if (stix->c->cls.pooldic_count >= stix->c->cls.pooldic_oop_capa)
{ {
stix_size_t new_capa; stix_oow_t new_capa;
stix_oop_set_t* tmp; stix_oop_set_t* tmp;
new_capa = STIX_ALIGN(stix->c->cls.pooldic_oop_capa + 1, POOLDIC_OOP_BUFFER_ALIGN); new_capa = STIX_ALIGN(stix->c->cls.pooldic_oop_capa + 1, POOLDIC_OOP_BUFFER_ALIGN);
@ -1957,9 +1957,9 @@ static STIX_INLINE int add_pool_dictionary (stix_t* stix, const stix_oocs_t* nam
} }
static stix_ssize_t find_class_level_variable (stix_t* stix, stix_oop_class_t self, const stix_oocs_t* name, var_info_t* var) static stix_ooi_t find_class_level_variable (stix_t* stix, stix_oop_class_t self, const stix_oocs_t* name, var_info_t* var)
{ {
stix_size_t pos; stix_oow_t pos;
stix_oop_t super; stix_oop_t super;
stix_oop_char_t v; stix_oop_char_t v;
stix_oop_char_t* vv; stix_oop_char_t* vv;
@ -2093,10 +2093,10 @@ done:
return pos; return pos;
} }
static int clone_assignee (stix_t* stix, const stix_oocs_t* name, stix_size_t* offset) static int clone_assignee (stix_t* stix, const stix_oocs_t* name, stix_oow_t* offset)
{ {
int n; int n;
stix_size_t old_len; stix_oow_t old_len;
old_len = stix->c->mth.assignees.len; old_len = stix->c->mth.assignees.len;
n = copy_string_to (stix, name, &stix->c->mth.assignees, &stix->c->mth.assignees_capa, 1, '\0'); n = copy_string_to (stix, name, &stix->c->mth.assignees, &stix->c->mth.assignees_capa, 1, '\0');
@ -2108,10 +2108,10 @@ static int clone_assignee (stix_t* stix, const stix_oocs_t* name, stix_size_t* o
return 0; return 0;
} }
static int clone_binary_selector (stix_t* stix, const stix_oocs_t* name, stix_size_t* offset) static int clone_binary_selector (stix_t* stix, const stix_oocs_t* name, stix_oow_t* offset)
{ {
int n; int n;
stix_size_t old_len; stix_oow_t old_len;
old_len = stix->c->mth.binsels.len; old_len = stix->c->mth.binsels.len;
n = copy_string_to (stix, name, &stix->c->mth.binsels, &stix->c->mth.binsels_capa, 1, '\0'); n = copy_string_to (stix, name, &stix->c->mth.binsels, &stix->c->mth.binsels_capa, 1, '\0');
@ -2123,10 +2123,10 @@ static int clone_binary_selector (stix_t* stix, const stix_oocs_t* name, stix_si
return 0; return 0;
} }
static int clone_keyword (stix_t* stix, const stix_oocs_t* name, stix_size_t* offset) static int clone_keyword (stix_t* stix, const stix_oocs_t* name, stix_oow_t* offset)
{ {
int n; int n;
stix_size_t old_len; stix_oow_t old_len;
old_len = stix->c->mth.kwsels.len; old_len = stix->c->mth.kwsels.len;
n = copy_string_to (stix, name, &stix->c->mth.kwsels, &stix->c->mth.kwsels_capa, 1, '\0'); n = copy_string_to (stix, name, &stix->c->mth.kwsels, &stix->c->mth.kwsels_capa, 1, '\0');
@ -2157,14 +2157,14 @@ static int add_temporary_variable (stix_t* stix, const stix_oocs_t* name)
return copy_string_to (stix, name, &stix->c->mth.tmprs, &stix->c->mth.tmprs_capa, 1, ' '); return copy_string_to (stix, name, &stix->c->mth.tmprs, &stix->c->mth.tmprs_capa, 1, ' ');
} }
static STIX_INLINE int find_temporary_variable (stix_t* stix, const stix_oocs_t* name, stix_size_t* xindex) static STIX_INLINE int find_temporary_variable (stix_t* stix, const stix_oocs_t* name, stix_oow_t* xindex)
{ {
return find_word_in_string (&stix->c->mth.tmprs, name, xindex); return find_word_in_string (&stix->c->mth.tmprs, name, xindex);
} }
static stix_oop_set_t add_namespace (stix_t* stix, stix_oop_set_t dic, const stix_oocs_t* name) static stix_oop_set_t add_namespace (stix_t* stix, stix_oop_set_t dic, const stix_oocs_t* name)
{ {
stix_size_t tmp_count = 0; stix_oow_t tmp_count = 0;
stix_oop_t sym; stix_oop_t sym;
stix_oop_set_t ns; stix_oop_set_t ns;
stix_oop_association_t ass; stix_oop_association_t ass;
@ -2195,7 +2195,7 @@ oops:
static int preprocess_dotted_name (stix_t* stix, int dont_add_ns, int accept_pooldic_as_ns, const stix_oocs_t* fqn, const stix_ioloc_t* fqn_loc, stix_oocs_t* name, stix_oop_set_t* ns_oop) static int preprocess_dotted_name (stix_t* stix, int dont_add_ns, int accept_pooldic_as_ns, const stix_oocs_t* fqn, const stix_ioloc_t* fqn_loc, stix_oocs_t* name, stix_oop_set_t* ns_oop)
{ {
const stix_ooch_t* ptr, * dot; const stix_ooch_t* ptr, * dot;
stix_size_t len; stix_oow_t len;
stix_oocs_t seg; stix_oocs_t seg;
stix_oop_set_t dic; stix_oop_set_t dic;
stix_oop_association_t ass; stix_oop_association_t ass;
@ -2332,7 +2332,7 @@ static int compile_class_level_variables (stix_t* stix)
stix_oocs_t last; stix_oocs_t last;
stix_oop_set_t ns_oop; stix_oop_set_t ns_oop;
stix_oop_association_t ass; stix_oop_association_t ass;
stix_size_t i; stix_oow_t i;
do do
{ {
@ -2648,7 +2648,7 @@ static int compile_method_primitive (stix_t* stix)
us = stix_findoochar (stix->c->tok.name.ptr, stix->c->tok.name.len, '_'); us = stix_findoochar (stix->c->tok.name.ptr, stix->c->tok.name.len, '_');
if (us > stix->c->tok.name.ptr && us < stix->c->tok.name.ptr + stix->c->tok.name.len - 1) if (us > stix->c->tok.name.ptr && us < stix->c->tok.name.ptr + stix->c->tok.name.len - 1)
{ {
stix_size_t lit_idx; stix_oow_t lit_idx;
/* the symbol literal contains an underscore. /* the symbol literal contains an underscore.
* and it is none of the first of the last character */ * and it is none of the first of the last character */
if (add_symbol_literal(stix, &stix->c->tok.name, &lit_idx) >= 0 && if (add_symbol_literal(stix, &stix->c->tok.name, &lit_idx) >= 0 &&
@ -2692,7 +2692,7 @@ static int compile_method_primitive (stix_t* stix)
static int get_variable_info (stix_t* stix, const stix_oocs_t* name, const stix_ioloc_t* name_loc, int name_dotted, var_info_t* var) static int get_variable_info (stix_t* stix, const stix_oocs_t* name, const stix_ioloc_t* name_loc, int name_dotted, var_info_t* var)
{ {
stix_size_t index; stix_oow_t index;
STIX_MEMSET (var, 0, STIX_SIZEOF(*var)); STIX_MEMSET (var, 0, STIX_SIZEOF(*var));
@ -2826,7 +2826,7 @@ printf ("\n");
} }
else else
{ {
stix_size_t i; stix_oow_t i;
stix_oop_association_t ass2 = STIX_NULL; stix_oop_association_t ass2 = STIX_NULL;
/* attempt to find the variable in pool dictionaries */ /* attempt to find the variable in pool dictionaries */
@ -2915,15 +2915,15 @@ static int compile_block_temporaries (stix_t* stix)
return 0; return 0;
} }
static int store_tmpr_count_for_block (stix_t* stix, stix_size_t tmpr_count) static int store_tmpr_count_for_block (stix_t* stix, stix_oow_t tmpr_count)
{ {
if (stix->c->mth.blk_depth >= stix->c->mth.blk_tmprcnt_capa) if (stix->c->mth.blk_depth >= stix->c->mth.blk_tmprcnt_capa)
{ {
stix_size_t* tmp; stix_oow_t* tmp;
stix_size_t new_capa; stix_oow_t new_capa;
new_capa = STIX_ALIGN (stix->c->mth.blk_depth + 1, BLK_TMPRCNT_BUFFER_ALIGN); new_capa = STIX_ALIGN (stix->c->mth.blk_depth + 1, BLK_TMPRCNT_BUFFER_ALIGN);
tmp = (stix_size_t*)stix_reallocmem (stix, stix->c->mth.blk_tmprcnt, new_capa * STIX_SIZEOF(*tmp)); tmp = (stix_oow_t*)stix_reallocmem (stix, stix->c->mth.blk_tmprcnt, new_capa * STIX_SIZEOF(*tmp));
if (!tmp) return -1; if (!tmp) return -1;
stix->c->mth.blk_tmprcnt_capa = new_capa; stix->c->mth.blk_tmprcnt_capa = new_capa;
@ -2937,10 +2937,10 @@ static int store_tmpr_count_for_block (stix_t* stix, stix_size_t tmpr_count)
static int compile_block_expression (stix_t* stix) static int compile_block_expression (stix_t* stix)
{ {
stix_size_t jump_inst_pos; stix_oow_t jump_inst_pos;
stix_size_t saved_tmpr_count, saved_tmprs_len; stix_oow_t saved_tmpr_count, saved_tmprs_len;
stix_size_t block_arg_count, block_tmpr_count; stix_oow_t block_arg_count, block_tmpr_count;
stix_size_t block_code_size; stix_oow_t block_code_size;
stix_ioloc_t block_loc, colon_loc, tmpr_loc; stix_ioloc_t block_loc, colon_loc, tmpr_loc;
/* /*
@ -3088,7 +3088,7 @@ printf ("\treturn_from_block\n");
} }
else else
{ {
stix_size_t jump_offset; stix_oow_t jump_offset;
if (block_code_size > MAX_CODE_JUMP) if (block_code_size > MAX_CODE_JUMP)
{ {
@ -3126,7 +3126,7 @@ static int add_to_balit_buffer (stix_t* stix, stix_oob_t b)
if (stix->c->mth.balit_count >= stix->c->mth.balit_capa) if (stix->c->mth.balit_count >= stix->c->mth.balit_capa)
{ {
stix_oob_t* tmp; stix_oob_t* tmp;
stix_size_t new_capa; stix_oow_t new_capa;
new_capa = STIX_ALIGN (stix->c->mth.balit_count + 1, BALIT_BUFFER_ALIGN); new_capa = STIX_ALIGN (stix->c->mth.balit_count + 1, BALIT_BUFFER_ALIGN);
tmp = (stix_oob_t*)stix_reallocmem (stix, stix->c->mth.balit, new_capa * STIX_SIZEOF(*tmp)); tmp = (stix_oob_t*)stix_reallocmem (stix, stix->c->mth.balit, new_capa * STIX_SIZEOF(*tmp));
@ -3145,7 +3145,7 @@ static int add_to_arlit_buffer (stix_t* stix, stix_oop_t item)
if (stix->c->mth.arlit_count >= stix->c->mth.arlit_capa) if (stix->c->mth.arlit_count >= stix->c->mth.arlit_capa)
{ {
stix_oop_t* tmp; stix_oop_t* tmp;
stix_size_t new_capa; stix_oow_t new_capa;
new_capa = STIX_ALIGN (stix->c->mth.arlit_count + 1, ARLIT_BUFFER_ALIGN); new_capa = STIX_ALIGN (stix->c->mth.arlit_count + 1, ARLIT_BUFFER_ALIGN);
tmp = (stix_oop_t*)stix_reallocmem (stix, stix->c->mth.arlit, new_capa * STIX_SIZEOF(*tmp)); tmp = (stix_oop_t*)stix_reallocmem (stix, stix->c->mth.arlit, new_capa * STIX_SIZEOF(*tmp));
@ -3207,8 +3207,8 @@ static int __read_byte_array_literal (stix_t* stix, stix_oop_t* xlit)
struct arlit_info_t struct arlit_info_t
{ {
stix_size_t pos; stix_oow_t pos;
stix_size_t len; stix_oow_t len;
}; };
typedef struct arlit_info_t arlit_info_t; typedef struct arlit_info_t arlit_info_t;
@ -3216,7 +3216,7 @@ typedef struct arlit_info_t arlit_info_t;
static int __read_array_literal (stix_t* stix, stix_oop_t* xlit) static int __read_array_literal (stix_t* stix, stix_oop_t* xlit)
{ {
stix_oop_t lit, a; stix_oop_t lit, a;
stix_size_t i, saved_arlit_count; stix_oow_t i, saved_arlit_count;
arlit_info_t info; arlit_info_t info;
info.pos = stix->c->mth.arlit_count; info.pos = stix->c->mth.arlit_count;
@ -3320,7 +3320,7 @@ static STIX_INLINE int read_byte_array_literal (stix_t* stix, stix_oop_t* xlit)
static int compile_byte_array_literal (stix_t* stix) static int compile_byte_array_literal (stix_t* stix)
{ {
stix_oop_t lit; stix_oop_t lit;
stix_size_t index; stix_oow_t index;
if (read_byte_array_literal(stix, &lit) <= -1 || if (read_byte_array_literal(stix, &lit) <= -1 ||
add_literal(stix, lit, &index) <= -1 || add_literal(stix, lit, &index) <= -1 ||
@ -3334,7 +3334,7 @@ printf ("\tpush_literal byte_array\n");
static int read_array_literal (stix_t* stix, stix_oop_t* xlit) static int read_array_literal (stix_t* stix, stix_oop_t* xlit)
{ {
int x; int x;
stix_size_t saved_arlit_count; stix_oow_t saved_arlit_count;
stix->c->in_array = 1; stix->c->in_array = 1;
if (get_token(stix) <= -1) if (get_token(stix) <= -1)
@ -3354,7 +3354,7 @@ static int read_array_literal (stix_t* stix, stix_oop_t* xlit)
static int compile_array_literal (stix_t* stix) static int compile_array_literal (stix_t* stix)
{ {
stix_oop_t lit; stix_oop_t lit;
stix_size_t index; stix_oow_t index;
STIX_ASSERT (stix->c->mth.arlit_count == 0); STIX_ASSERT (stix->c->mth.arlit_count == 0);
@ -3375,7 +3375,7 @@ static int compile_expression_primary (stix_t* stix, const stix_oocs_t* ident, c
var_info_t var; var_info_t var;
int read_next_token = 0; int read_next_token = 0;
stix_size_t index; stix_oow_t index;
*to_super = 0; *to_super = 0;
@ -3393,7 +3393,7 @@ static int compile_expression_primary (stix_t* stix, const stix_oocs_t* ident, c
#if defined(STIX_USE_CTXTEMPVAR) #if defined(STIX_USE_CTXTEMPVAR)
if (stix->c->mth.blk_depth > 0) if (stix->c->mth.blk_depth > 0)
{ {
stix_size_t i; stix_oow_t i;
STIX_ASSERT (var.pos < stix->c->mth.blk_tmprcnt[stix->c->mth.blk_depth]); STIX_ASSERT (var.pos < stix->c->mth.blk_tmprcnt[stix->c->mth.blk_depth]);
for (i = stix->c->mth.blk_depth; i > 0; i--) for (i = stix->c->mth.blk_depth; i > 0; i--)
@ -3603,7 +3603,7 @@ static stix_oob_t send_message_cmd[] =
static int compile_unary_message (stix_t* stix, int to_super) static int compile_unary_message (stix_t* stix, int to_super)
{ {
stix_size_t index; stix_oow_t index;
STIX_ASSERT (stix->c->tok.type == STIX_IOTOK_IDENT); STIX_ASSERT (stix->c->tok.type == STIX_IOTOK_IDENT);
@ -3628,10 +3628,10 @@ static int compile_binary_message (stix_t* stix, int to_super)
* binary-message := binary-selector binary-argument * binary-message := binary-selector binary-argument
* binary-argument := expression-primary unary-message* * binary-argument := expression-primary unary-message*
*/ */
stix_size_t index; stix_oow_t index;
int to_super2; int to_super2;
stix_oocs_t binsel; stix_oocs_t binsel;
stix_size_t saved_binsels_len, binsel_offset; stix_oow_t saved_binsels_len, binsel_offset;
STIX_ASSERT (stix->c->tok.type == STIX_IOTOK_BINSEL); STIX_ASSERT (stix->c->tok.type == STIX_IOTOK_BINSEL);
@ -3676,13 +3676,13 @@ static int compile_keyword_message (stix_t* stix, int to_super)
* keyword-argument := expression-primary unary-message* binary-message* * keyword-argument := expression-primary unary-message* binary-message*
*/ */
stix_size_t index; stix_oow_t index;
int to_super2; int to_super2;
stix_oocs_t kw, kwsel; stix_oocs_t kw, kwsel;
stix_ioloc_t saved_kwsel_loc; stix_ioloc_t saved_kwsel_loc;
stix_size_t saved_kwsel_len; stix_oow_t saved_kwsel_len;
stix_size_t kw_offset; stix_oow_t kw_offset;
stix_size_t nargs = 0; stix_oow_t nargs = 0;
saved_kwsel_loc = stix->c->tok.loc; saved_kwsel_loc = stix->c->tok.loc;
saved_kwsel_len = stix->c->mth.kwsels.len; saved_kwsel_len = stix->c->mth.kwsels.len;
@ -3746,7 +3746,7 @@ static int compile_message_expression (stix_t* stix, int to_super)
* unary-message := unary-selector * unary-message := unary-selector
* cascaded-message := (";" single-message)* * cascaded-message := (";" single-message)*
*/ */
stix_size_t noop_pos; stix_oow_t noop_pos;
do do
{ {
@ -3873,7 +3873,7 @@ static int compile_method_expression (stix_t* stix, int pop)
*/ */
stix_oocs_t assignee; stix_oocs_t assignee;
stix_size_t index; stix_oow_t index;
int ret = 0; int ret = 0;
STIX_ASSERT (pop == 0 || pop == 1); STIX_ASSERT (pop == 0 || pop == 1);
@ -3883,7 +3883,7 @@ static int compile_method_expression (stix_t* stix, int pop)
stix->c->tok.type == STIX_IOTOK_IDENT_DOTTED) stix->c->tok.type == STIX_IOTOK_IDENT_DOTTED)
{ {
stix_ioloc_t assignee_loc; stix_ioloc_t assignee_loc;
stix_size_t assignee_offset; stix_oow_t assignee_offset;
int assignee_dotted; int assignee_dotted;
/* store the assignee name to the internal buffer /* store the assignee name to the internal buffer
@ -3931,7 +3931,7 @@ printf ("\n");
#if defined(STIX_USE_CTXTEMPVAR) #if defined(STIX_USE_CTXTEMPVAR)
if (stix->c->mth.blk_depth > 0) if (stix->c->mth.blk_depth > 0)
{ {
stix_size_t i; stix_oow_t i;
STIX_ASSERT (var.pos < stix->c->mth.blk_tmprcnt[stix->c->mth.blk_depth]); STIX_ASSERT (var.pos < stix->c->mth.blk_tmprcnt[stix->c->mth.blk_depth]);
for (i = stix->c->mth.blk_depth; i > 0; i--) for (i = stix->c->mth.blk_depth; i > 0; i--)
@ -4105,8 +4105,8 @@ static int add_compiled_method (stix_t* stix)
#else #else
stix_oop_byte_t code; stix_oop_byte_t code;
#endif #endif
stix_size_t tmp_count = 0; stix_oow_t tmp_count = 0;
stix_size_t i; stix_oow_t i;
stix_ooi_t preamble_code, preamble_index; stix_ooi_t preamble_code, preamble_index;
name = stix_makesymbol (stix, stix->c->mth.name.ptr, stix->c->mth.name.len); name = stix_makesymbol (stix, stix->c->mth.name.ptr, stix->c->mth.name.len);
@ -4780,7 +4780,7 @@ printf ("\n");
static int compile_class_definition (stix_t* stix, int extend) static int compile_class_definition (stix_t* stix, int extend)
{ {
int n; int n;
stix_size_t i; stix_oow_t i;
/* reset the structure to hold information about a class to be compiled */ /* reset the structure to hold information about a class to be compiled */
stix->c->cls.flags = 0; stix->c->cls.flags = 0;
@ -4834,7 +4834,7 @@ static int __compile_pooldic_definition (stix_t* stix)
{ {
stix_oop_t lit; stix_oop_t lit;
stix_ooi_t tally; stix_ooi_t tally;
stix_size_t i; stix_oow_t i;
if (stix->c->tok.type != STIX_IOTOK_IDENT && if (stix->c->tok.type != STIX_IOTOK_IDENT &&
stix->c->tok.type != STIX_IOTOK_IDENT_DOTTED) stix->c->tok.type != STIX_IOTOK_IDENT_DOTTED)
@ -5076,7 +5076,7 @@ static void gc_compiler (stix_t* stix)
/* called when garbage collection is performed */ /* called when garbage collection is performed */
if (stix->c) if (stix->c)
{ {
stix_size_t i; stix_oow_t i;
if (stix->c->cls.self_oop) if (stix->c->cls.self_oop)
stix->c->cls.self_oop = (stix_oop_class_t)stix_moveoop (stix, (stix_oop_t)stix->c->cls.self_oop); stix->c->cls.self_oop = (stix_oop_class_t)stix_moveoop (stix, (stix_oop_t)stix->c->cls.self_oop);
@ -5118,7 +5118,7 @@ static void fini_compiler (stix_t* stix)
/* called before the stix object is closed */ /* called before the stix object is closed */
if (stix->c) if (stix->c)
{ {
stix_size_t i; stix_oow_t i;
clear_io_names (stix); clear_io_names (stix);

View File

@ -78,7 +78,7 @@ void dump_dictionary (stix_t* stix, stix_oop_set_t dic, const char* title)
void print_oocs (const stix_oocs_t* name) void print_oocs (const stix_oocs_t* name)
{ {
stix_size_t i; stix_oow_t i;
for (i = 0; i < name->len; i++) printf ("%c", name->ptr[i]); for (i = 0; i < name->len; i++) printf ("%c", name->ptr[i]);
} }
@ -105,7 +105,7 @@ void print_object (stix_t* stix, stix_oop_t oop)
{ {
stix_bch_t bcs[32]; stix_bch_t bcs[32];
stix_uch_t uch; stix_uch_t uch;
stix_size_t ucslen, bcslen; stix_oow_t ucslen, bcslen;
uch = STIX_OOP_TO_CHAR(oop); uch = STIX_OOP_TO_CHAR(oop);
bcslen = STIX_COUNTOF(bcs); bcslen = STIX_COUNTOF(bcs);
@ -119,9 +119,9 @@ void print_object (stix_t* stix, stix_oop_t oop)
{ {
stix_oop_class_t c; stix_oop_class_t c;
stix_oocs_t s; stix_oocs_t s;
stix_size_t i; stix_oow_t i;
stix_bch_t bcs[32]; stix_bch_t bcs[32];
stix_size_t ucslen, bcslen; stix_oow_t ucslen, bcslen;
STIX_ASSERT (STIX_OOP_IS_POINTER(oop)); STIX_ASSERT (STIX_OOP_IS_POINTER(oop));
c = (stix_oop_class_t)STIX_OBJ_GET_CLASS(oop); /*STIX_CLASSOF(stix, oop);*/ c = (stix_oop_class_t)STIX_OBJ_GET_CLASS(oop); /*STIX_CLASSOF(stix, oop);*/
@ -256,7 +256,7 @@ static void __dump_object (stix_t* stix, stix_oop_t oop, int depth)
{ {
stix_bch_t bcs[32]; stix_bch_t bcs[32];
stix_uch_t uch; stix_uch_t uch;
stix_size_t ucslen, bcslen; stix_oow_t ucslen, bcslen;
uch = STIX_OOP_TO_CHAR(oop); uch = STIX_OOP_TO_CHAR(oop);
bcslen = STIX_COUNTOF(bcs); bcslen = STIX_COUNTOF(bcs);
@ -292,7 +292,7 @@ static void __dump_object (stix_t* stix, stix_oop_t oop, int depth)
{ {
stix_bch_t bcs[32]; stix_bch_t bcs[32];
stix_uch_t uch; stix_uch_t uch;
stix_size_t ucslen, bcslen; stix_oow_t ucslen, bcslen;
uch = ((stix_oop_char_t)oop)->slot[i]; uch = ((stix_oop_char_t)oop)->slot[i];
if (uch == '\'') printf ("''"); if (uch == '\'') printf ("''");
else else

View File

@ -1617,7 +1617,7 @@ printf ("CALL MODE 222 ERROR %d %d\n", dcGetError (dc), DC_ERROR_UNSUPPORTED_MOD
case 's': case 's':
{ {
stix_size_t bcslen, ucslen; stix_oow_t bcslen, ucslen;
stix_bch_t bcs[1024]; stix_bch_t bcs[1024];
ucslen = STIX_OBJ_GET_SIZE(arr->slot[i - 2]); ucslen = STIX_OBJ_GET_SIZE(arr->slot[i - 2]);
@ -1673,7 +1673,7 @@ printf ("CALL ERROR %d %d\n", dcGetError (dc), DC_ERROR_UNSUPPORTED_MODE);
case 's': case 's':
{ {
stix_size_t bcslen, ucslen; stix_oow_t bcslen, ucslen;
stix_ooch_t ucs[1024]; stix_ooch_t ucs[1024];
stix_oop_t s; stix_oop_t s;
char* r = dcCallPointer (dc, f); char* r = dcCallPointer (dc, f);
@ -1975,7 +1975,7 @@ int stix_execute (stix_t* stix)
stix_oop_t return_value; stix_oop_t return_value;
#if defined(STIX_PROFILE_EXEC) #if defined(STIX_PROFILE_EXEC)
stix_size_t inst_counter = 0; stix_oow_t inst_counter = 0;
#endif #endif
STIX_ASSERT (stix->active_context != STIX_NULL); STIX_ASSERT (stix->active_context != STIX_NULL);

View File

@ -26,7 +26,7 @@
#include "stix-prv.h" #include "stix-prv.h"
stix_heap_t* stix_makeheap (stix_t* stix, stix_size_t size) stix_heap_t* stix_makeheap (stix_t* stix, stix_oow_t size)
{ {
stix_heap_t* heap; stix_heap_t* heap;
@ -61,7 +61,7 @@ void stix_killheap (stix_t* stix, stix_heap_t* heap)
STIX_MMGR_FREE (stix->mmgr, heap); STIX_MMGR_FREE (stix->mmgr, heap);
} }
void* stix_allocheapmem (stix_t* stix, stix_heap_t* heap, stix_size_t size) void* stix_allocheapmem (stix_t* stix, stix_heap_t* heap, stix_oow_t size)
{ {
stix_uint8_t* ptr; stix_uint8_t* ptr;

View File

@ -84,16 +84,16 @@ struct xtn_t
const char* source_path; const char* source_path;
char bchar_buf[1024]; char bchar_buf[1024];
stix_size_t bchar_pos; stix_oow_t bchar_pos;
stix_size_t bchar_len; stix_oow_t bchar_len;
}; };
static void* sys_alloc (stix_mmgr_t* mmgr, stix_size_t size) static void* sys_alloc (stix_mmgr_t* mmgr, stix_oow_t size)
{ {
return malloc (size); return malloc (size);
} }
static void* sys_realloc (stix_mmgr_t* mmgr, void* ptr, stix_size_t size) static void* sys_realloc (stix_mmgr_t* mmgr, void* ptr, stix_oow_t size)
{ {
return realloc (ptr, size); return realloc (ptr, size);
} }
@ -112,14 +112,14 @@ static stix_mmgr_t sys_mmgr =
}; };
static STIX_INLINE stix_ssize_t open_input (stix_t* stix, stix_io_arg_t* arg) static STIX_INLINE stix_ooi_t open_input (stix_t* stix, stix_io_arg_t* arg)
{ {
if (arg->includer) if (arg->includer)
{ {
/* includee */ /* includee */
stix_bch_t bcs[1024]; /* TODO: right buffer size */ stix_bch_t bcs[1024]; /* TODO: right buffer size */
stix_size_t bcslen = STIX_COUNTOF(bcs); stix_oow_t bcslen = STIX_COUNTOF(bcs);
stix_size_t ucslen = ~(stix_size_t)0; stix_oow_t ucslen = ~(stix_oow_t)0;
if (stix_ucstoutf8 (arg->name, &ucslen, bcs, &bcslen) <= -1) if (stix_ucstoutf8 (arg->name, &ucslen, bcs, &bcslen) <= -1)
{ {
@ -155,10 +155,10 @@ static STIX_INLINE stix_ssize_t open_input (stix_t* stix, stix_io_arg_t* arg)
return 0; return 0;
} }
static STIX_INLINE stix_ssize_t read_input (stix_t* stix, stix_io_arg_t* arg) static STIX_INLINE stix_ooi_t read_input (stix_t* stix, stix_io_arg_t* arg)
{ {
xtn_t* xtn = stix_getxtn(stix); xtn_t* xtn = stix_getxtn(stix);
stix_size_t n, bcslen, ucslen, remlen; stix_oow_t n, bcslen, ucslen, remlen;
int x; int x;
STIX_ASSERT (arg->handle != STIX_NULL); STIX_ASSERT (arg->handle != STIX_NULL);
@ -188,14 +188,14 @@ static STIX_INLINE stix_ssize_t read_input (stix_t* stix, stix_io_arg_t* arg)
return ucslen; return ucslen;
} }
static STIX_INLINE stix_ssize_t close_input (stix_t* stix, stix_io_arg_t* arg) static STIX_INLINE stix_ooi_t close_input (stix_t* stix, stix_io_arg_t* arg)
{ {
STIX_ASSERT (arg->handle != STIX_NULL); STIX_ASSERT (arg->handle != STIX_NULL);
fclose ((FILE*)arg->handle); fclose ((FILE*)arg->handle);
return 0; return 0;
} }
static stix_ssize_t input_handler (stix_t* stix, stix_io_cmd_t cmd, stix_io_arg_t* arg) static stix_ooi_t input_handler (stix_t* stix, stix_io_cmd_t cmd, stix_io_arg_t* arg)
{ {
switch (cmd) switch (cmd)
{ {
@ -219,8 +219,8 @@ static void* mod_open (stix_t* stix, const stix_ooch_t* name)
#if defined(USE_LTDL) #if defined(USE_LTDL)
/* TODO: support various platforms */ /* TODO: support various platforms */
stix_bch_t buf[1024]; /* TODO: use a proper path buffer */ stix_bch_t buf[1024]; /* TODO: use a proper path buffer */
stix_size_t ucslen, bcslen; stix_oow_t ucslen, bcslen;
stix_size_t len; stix_oow_t len;
void* handle; void* handle;
/* TODO: using MODPREFIX isn't a good idean for all kind of modules. /* TODO: using MODPREFIX isn't a good idean for all kind of modules.
@ -236,7 +236,7 @@ static void* mod_open (stix_t* stix, const stix_ooch_t* name)
len = stix_copybcstr (buf, STIX_COUNTOF(buf), STIX_DEFAULT_MODPREFIX); len = stix_copybcstr (buf, STIX_COUNTOF(buf), STIX_DEFAULT_MODPREFIX);
/* TODO: proper error checking and overflow checking */ /* TODO: proper error checking and overflow checking */
ucslen = ~(stix_size_t)0; ucslen = ~(stix_oow_t)0;
bcslen = STIX_COUNTOF(buf) - len; bcslen = STIX_COUNTOF(buf) - len;
stix_ucstoutf8 (name, &ucslen, &buf[len], &bcslen); stix_ucstoutf8 (name, &ucslen, &buf[len], &bcslen);
@ -279,12 +279,12 @@ static void* mod_getsym (stix_t* stix, void* handle, const stix_ooch_t* name)
{ {
#if defined(USE_LTDL) #if defined(USE_LTDL)
stix_bch_t buf[1024]; /* TODO: use a proper buffer. dynamically allocated if conversion result in too a large value */ stix_bch_t buf[1024]; /* TODO: use a proper buffer. dynamically allocated if conversion result in too a large value */
stix_size_t ucslen, bcslen; stix_oow_t ucslen, bcslen;
void* sym; void* sym;
buf[0] = '_'; buf[0] = '_';
ucslen = ~(stix_size_t)0; ucslen = ~(stix_oow_t)0;
bcslen = STIX_COUNTOF(buf) - 2; bcslen = STIX_COUNTOF(buf) - 2;
stix_ucstoutf8 (name, &ucslen, &buf[1], &bcslen); stix_ucstoutf8 (name, &ucslen, &buf[1], &bcslen);
printf ("MOD_GETSYM [%s]\n", &buf[1]); printf ("MOD_GETSYM [%s]\n", &buf[1]);
@ -542,7 +542,7 @@ printf ("%p\n", a);
{ {
stix_synerr_t synerr; stix_synerr_t synerr;
stix_bch_t bcs[1024]; /* TODO: right buffer size */ stix_bch_t bcs[1024]; /* TODO: right buffer size */
stix_size_t bcslen, ucslen; stix_oow_t bcslen, ucslen;
stix_getsynerr (stix, &synerr); stix_getsynerr (stix, &synerr);
@ -550,7 +550,7 @@ printf ("%p\n", a);
if (synerr.loc.file) if (synerr.loc.file)
{ {
bcslen = STIX_COUNTOF(bcs); bcslen = STIX_COUNTOF(bcs);
ucslen = ~(stix_size_t)0; ucslen = ~(stix_oow_t)0;
if (stix_ucstoutf8 (synerr.loc.file, &ucslen, bcs, &bcslen) >= 0) if (stix_ucstoutf8 (synerr.loc.file, &ucslen, bcs, &bcslen) >= 0)
{ {
printf ("%.*s ", (int)bcslen, bcs); printf ("%.*s ", (int)bcslen, bcs);

View File

@ -26,7 +26,7 @@
#include "stix-prv.h" #include "stix-prv.h"
void* stix_allocbytes (stix_t* stix, stix_size_t size) void* stix_allocbytes (stix_t* stix, stix_oow_t size)
{ {
stix_uint8_t* ptr; stix_uint8_t* ptr;

View File

@ -272,21 +272,48 @@
# error UNKNOWN INTMAX SIZE # error UNKNOWN INTMAX SIZE
#endif #endif
/* =========================================================================
* BASIC STIX TYPES
* =========================================================================*/
typedef stix_uintptr_t stix_size_t; typedef char stix_bch_t;
typedef stix_intptr_t stix_ssize_t; typedef int stix_bci_t;
typedef char stix_bch_t; typedef stix_uint16_t stix_uch_t; /* TODO ... wchar_t??? */
typedef stix_uint16_t stix_uch_t; /* TODO ... wchar_t??? */ typedef stix_int32_t stix_uci_t;
typedef stix_int32_t stix_uci_t;
typedef stix_uint8_t stix_oob_t;
/* NOTE: sizeof(stix_oop_t) must be equal to sizeof(stix_oow_t) */
typedef stix_uintptr_t stix_oow_t;
typedef stix_intptr_t stix_ooi_t;
#define STIX_SIZEOF_OOW_T STIX_SIZEOF_UINTPTR_T
#define STIX_SIZEOF_OOI_T STIX_SIZEOF_INTPTR_T
typedef stix_ushortptr_t stix_oohw_t; /* half word - half word */
typedef stix_shortptr_t stix_oohi_t; /* signed half word */
#define STIX_SIZEOF_OOHW_T STIX_SIZEOF_USHORTPTR_T
#define STIX_SIZEOF_OOHI_T STIX_SIZEOF_SHORTPTR_T
struct stix_ucs_t struct stix_ucs_t
{ {
stix_uch_t* ptr; stix_uch_t* ptr;
stix_size_t len; stix_oow_t len;
}; };
typedef struct stix_ucs_t stix_ucs_t; typedef struct stix_ucs_t stix_ucs_t;
struct stix_bcs_t
{
stix_bch_t* ptr;
stix_oow_t len;
};
typedef struct stix_bcs_t stix_bcs_t;
typedef stix_uch_t stix_ooch_t;
typedef stix_uci_t stix_ooci_t;
typedef stix_ucs_t stix_oocs_t;
#define STIX_OOCH_IS_UCH
/* ========================================================================= /* =========================================================================
* PRIMITIVE MACROS * PRIMITIVE MACROS
@ -378,12 +405,12 @@ typedef struct stix_mmgr_t stix_mmgr_t;
* allocate a memory chunk of the size \a n. * allocate a memory chunk of the size \a n.
* \return pointer to a memory chunk on success, #STIX_NULL on failure. * \return pointer to a memory chunk on success, #STIX_NULL on failure.
*/ */
typedef void* (*stix_mmgr_alloc_t) (stix_mmgr_t* mmgr, stix_size_t n); typedef void* (*stix_mmgr_alloc_t) (stix_mmgr_t* mmgr, stix_oow_t n);
/** /**
* resize a memory chunk pointed to by \a ptr to the size \a n. * resize a memory chunk pointed to by \a ptr to the size \a n.
* \return pointer to a memory chunk on success, #STIX_NULL on failure. * \return pointer to a memory chunk on success, #STIX_NULL on failure.
*/ */
typedef void* (*stix_mmgr_realloc_t) (stix_mmgr_t* mmgr, void* ptr, stix_size_t n); typedef void* (*stix_mmgr_realloc_t) (stix_mmgr_t* mmgr, void* ptr, stix_oow_t n);
/** /**
* free a memory chunk pointed to by \a ptr. * free a memory chunk pointed to by \a ptr.
*/ */
@ -432,16 +459,16 @@ struct stix_mmgr_t
typedef struct stix_cmgr_t stix_cmgr_t; typedef struct stix_cmgr_t stix_cmgr_t;
typedef stix_size_t (*stix_cmgr_bctouc_t) ( typedef stix_oow_t (*stix_cmgr_bctouc_t) (
const stix_bch_t* mb, const stix_bch_t* mb,
stix_size_t size, stix_oow_t size,
stix_uch_t* wc stix_uch_t* wc
); );
typedef stix_size_t (*stix_cmgr_uctobc_t) ( typedef stix_oow_t (*stix_cmgr_uctobc_t) (
stix_uch_t wc, stix_uch_t wc,
stix_bch_t* mb, stix_bch_t* mb,
stix_size_t size stix_oow_t size
); );
/** /**
@ -524,29 +551,6 @@ struct stix_cmgr_t
((STIX_TYPE_IS_SIGNED(type)? STIX_TYPE_SIGNED_MIN(type): STIX_TYPE_UNSIGNED_MIN(type))) ((STIX_TYPE_IS_SIGNED(type)? STIX_TYPE_SIGNED_MIN(type): STIX_TYPE_UNSIGNED_MIN(type)))
/* =========================================================================
* BASIC STIX TYPES
* =========================================================================*/
typedef stix_uint8_t stix_oob_t;
/* NOTE: sizeof(stix_oop_t) must be equal to sizeof(stix_oow_t) */
typedef stix_uintptr_t stix_oow_t;
typedef stix_intptr_t stix_ooi_t;
#define STIX_SIZEOF_OOW_T STIX_SIZEOF_UINTPTR_T
#define STIX_SIZEOF_OOI_T STIX_SIZEOF_INTPTR_T
typedef stix_ushortptr_t stix_oohw_t; /* half word - half word */
typedef stix_shortptr_t stix_oohi_t; /* signed half word */
#define STIX_SIZEOF_OOHW_T STIX_SIZEOF_USHORTPTR_T
#define STIX_SIZEOF_OOHI_T STIX_SIZEOF_SHORTPTR_T
typedef stix_uch_t stix_ooch_t;
typedef stix_uci_t stix_ooci_t;
typedef stix_ucs_t stix_oocs_t;
#define STIX_OOCH_IS_UCH
/* ========================================================================= /* =========================================================================
* COMPILER FEATURE TEST MACROS * COMPILER FEATURE TEST MACROS
* =========================================================================*/ * =========================================================================*/

View File

@ -271,7 +271,7 @@ struct stix_io_arg_t
/*-----------------------------------------------------------------*/ /*-----------------------------------------------------------------*/
}; };
typedef stix_ssize_t (*stix_io_impl_t) ( typedef stix_ooi_t (*stix_io_impl_t) (
stix_t* stix, stix_t* stix,
stix_io_cmd_t cmd, stix_io_cmd_t cmd,
stix_io_arg_t* arg stix_io_arg_t* arg
@ -314,7 +314,7 @@ struct stix_iotok_t
} type; } type;
stix_oocs_t name; stix_oocs_t name;
stix_size_t name_capa; stix_oow_t name_capa;
stix_ioloc_t loc; stix_ioloc_t loc;
}; };
@ -395,7 +395,7 @@ typedef struct stix_synerr_t stix_synerr_t;
struct stix_code_t struct stix_code_t
{ {
stix_uint8_t* ptr; stix_uint8_t* ptr;
stix_size_t len; stix_oow_t len;
}; };
typedef struct stix_code_t stix_code_t; typedef struct stix_code_t stix_code_t;
@ -445,31 +445,31 @@ struct stix_compiler_t
stix_oop_set_t ns_oop; stix_oop_set_t ns_oop;
stix_oocs_t fqn; stix_oocs_t fqn;
stix_oocs_t name; stix_oocs_t name;
stix_size_t fqn_capa; stix_oow_t fqn_capa;
stix_ioloc_t fqn_loc; stix_ioloc_t fqn_loc;
stix_oop_set_t superns_oop; stix_oop_set_t superns_oop;
stix_oocs_t superfqn; stix_oocs_t superfqn;
stix_oocs_t supername; stix_oocs_t supername;
stix_size_t superfqn_capa; stix_oow_t superfqn_capa;
stix_ioloc_t superfqn_loc; stix_ioloc_t superfqn_loc;
/* instance variable, class variable, class instance variable */ /* instance variable, class variable, class instance variable */
stix_oocs_t vars[3]; stix_oocs_t vars[3];
stix_size_t vars_capa[3]; stix_oow_t vars_capa[3];
/* var_count, unlike vars above, includes superclass counts as well. /* var_count, unlike vars above, includes superclass counts as well.
* var_count[0] - number of named instance variables * var_count[0] - number of named instance variables
* var_count[1] - number of class variables * var_count[1] - number of class variables
* var_count[2] - number of class instance variables */ * var_count[2] - number of class instance variables */
stix_size_t var_count[3]; stix_oow_t var_count[3];
stix_oocs_t pooldic; stix_oocs_t pooldic;
stix_size_t pooldic_capa; stix_oow_t pooldic_capa;
stix_size_t pooldic_count; stix_oow_t pooldic_count;
stix_oop_set_t* pooldic_oops; stix_oop_set_t* pooldic_oops;
stix_size_t pooldic_oop_capa; stix_oow_t pooldic_oop_capa;
} cls; } cls;
/* information about a function being comipled */ /* information about a function being comipled */
@ -479,45 +479,45 @@ struct stix_compiler_t
/* method source text */ /* method source text */
stix_oocs_t text; stix_oocs_t text;
stix_size_t text_capa; stix_oow_t text_capa;
/* buffer to store identifier names to be assigned */ /* buffer to store identifier names to be assigned */
stix_oocs_t assignees; stix_oocs_t assignees;
stix_size_t assignees_capa; stix_oow_t assignees_capa;
/* buffer to store binary selectors being worked on */ /* buffer to store binary selectors being worked on */
stix_oocs_t binsels; stix_oocs_t binsels;
stix_size_t binsels_capa; stix_oow_t binsels_capa;
/* buffer to store keyword selectors being worked on */ /* buffer to store keyword selectors being worked on */
stix_oocs_t kwsels; stix_oocs_t kwsels;
stix_size_t kwsels_capa; stix_oow_t kwsels_capa;
/* method name */ /* method name */
stix_oocs_t name; stix_oocs_t name;
stix_size_t name_capa; stix_oow_t name_capa;
stix_ioloc_t name_loc; stix_ioloc_t name_loc;
/* single string containing a space separated list of temporaries */ /* single string containing a space separated list of temporaries */
stix_oocs_t tmprs; stix_oocs_t tmprs;
stix_size_t tmprs_capa; stix_oow_t tmprs_capa;
stix_size_t tmpr_count; /* total number of temporaries including arguments */ stix_oow_t tmpr_count; /* total number of temporaries including arguments */
stix_size_t tmpr_nargs; stix_oow_t tmpr_nargs;
/* literals */ /* literals */
stix_oop_t* literals; stix_oop_t* literals;
stix_size_t literal_count; stix_oow_t literal_count;
stix_size_t literal_capa; stix_oow_t literal_capa;
/* byte array elements */ /* byte array elements */
stix_oob_t* balit; stix_oob_t* balit;
stix_size_t balit_count; stix_oow_t balit_count;
stix_size_t balit_capa; stix_oow_t balit_capa;
/* array elements */ /* array elements */
stix_oop_t* arlit; stix_oop_t* arlit;
stix_size_t arlit_count; stix_oow_t arlit_count;
stix_size_t arlit_capa; stix_oow_t arlit_capa;
/* 0 for no primitive, 1 for a normal primitive, 2 for a named primitive */ /* 0 for no primitive, 1 for a normal primitive, 2 for a named primitive */
int prim_type; int prim_type;
@ -525,13 +525,13 @@ struct stix_compiler_t
stix_ooi_t prim_no; stix_ooi_t prim_no;
/* block depth */ /* block depth */
stix_size_t blk_depth; stix_oow_t blk_depth;
stix_size_t* blk_tmprcnt; stix_oow_t* blk_tmprcnt;
stix_size_t blk_tmprcnt_capa; stix_oow_t blk_tmprcnt_capa;
/* byte code */ /* byte code */
stix_code_t code; stix_code_t code;
stix_size_t code_capa; stix_oow_t code_capa;
} mth; } mth;
}; };
@ -855,7 +855,7 @@ extern "C" {
*/ */
stix_heap_t* stix_makeheap ( stix_heap_t* stix_makeheap (
stix_t* stix, stix_t* stix,
stix_size_t size stix_oow_t size
); );
/** /**
@ -875,7 +875,7 @@ void stix_killheap (
void* stix_allocheapmem ( void* stix_allocheapmem (
stix_t* stix, stix_t* stix,
stix_heap_t* heap, stix_heap_t* heap,
stix_size_t size stix_oow_t size
); );
@ -892,7 +892,7 @@ stix_oop_t stix_moveoop (
/* ========================================================================= */ /* ========================================================================= */
void* stix_allocbytes ( void* stix_allocbytes (
stix_t* stix, stix_t* stix,
stix_size_t size stix_oow_t size
); );
/** /**
@ -1023,23 +1023,23 @@ stix_oop_process_t stix_makeproc (
/* ========================================================================= */ /* ========================================================================= */
/* utf8.c */ /* utf8.c */
/* ========================================================================= */ /* ========================================================================= */
stix_size_t stix_uctoutf8 ( stix_oow_t stix_uctoutf8 (
stix_uch_t uc, stix_uch_t uc,
stix_bch_t* utf8, stix_bch_t* utf8,
stix_size_t size stix_oow_t size
); );
stix_size_t stix_utf8touc ( stix_oow_t stix_utf8touc (
const stix_bch_t* utf8, const stix_bch_t* utf8,
stix_size_t size, stix_oow_t size,
stix_uch_t* uc stix_uch_t* uc
); );
int stix_ucstoutf8 ( int stix_ucstoutf8 (
const stix_uch_t* ucs, const stix_uch_t* ucs,
stix_size_t* ucslen, stix_oow_t* ucslen,
stix_bch_t* bcs, stix_bch_t* bcs,
stix_size_t* bcslen stix_oow_t* bcslen
); );
/** /**
@ -1050,14 +1050,14 @@ int stix_ucstoutf8 (
* \code * \code
* const stix_bch_t* bcs = "test string"; * const stix_bch_t* bcs = "test string";
* stix_uch_t ucs[100]; * stix_uch_t ucs[100];
* stix_size_t ucslen = STIX_COUNTOF(buf), n; * stix_oow_t ucslen = STIX_COUNTOF(buf), n;
* stix_size_t bcslen = 11; * stix_oow_t bcslen = 11;
* int n; * int n;
* n = stix_utf8toucs (bcs, &bcslen, ucs, &ucslen); * n = stix_utf8toucs (bcs, &bcslen, ucs, &ucslen);
* if (n <= -1) { invalid/incomplenete sequence or buffer to small } * if (n <= -1) { invalid/incomplenete sequence or buffer to small }
* \endcode * \endcode
* *
* For a null-terminated string, you can specify ~(stix_size_t)0 in * For a null-terminated string, you can specify ~(stix_oow_t)0 in
* \a bcslen. The destination buffer \a ucs also must be large enough to * \a bcslen. The destination buffer \a ucs also must be large enough to
* store a terminating null. Otherwise, -2 is returned. * store a terminating null. Otherwise, -2 is returned.
* *
@ -1072,9 +1072,9 @@ int stix_ucstoutf8 (
*/ */
int stix_utf8toucs ( int stix_utf8toucs (
const stix_bch_t* bcs, const stix_bch_t* bcs,
stix_size_t* bcslen, stix_oow_t* bcslen,
stix_uch_t* ucs, stix_uch_t* ucs,
stix_size_t* ucslen stix_oow_t* ucslen
); );
/* ========================================================================= */ /* ========================================================================= */

View File

@ -56,14 +56,14 @@
#define rotate_right(rbt,pivot) rotate(rbt,pivot,0); #define rotate_right(rbt,pivot) rotate(rbt,pivot,0);
STIX_INLINE stix_rbt_pair_t* stix_rbt_allocpair ( STIX_INLINE stix_rbt_pair_t* stix_rbt_allocpair (
stix_rbt_t* rbt, void* kptr, stix_size_t klen, void* vptr, stix_size_t vlen) stix_rbt_t* rbt, void* kptr, stix_oow_t klen, void* vptr, stix_oow_t vlen)
{ {
stix_rbt_pair_t* n; stix_rbt_pair_t* n;
copier_t kcop = rbt->style->copier[STIX_RBT_KEY]; copier_t kcop = rbt->style->copier[STIX_RBT_KEY];
copier_t vcop = rbt->style->copier[STIX_RBT_VAL]; copier_t vcop = rbt->style->copier[STIX_RBT_VAL];
stix_size_t as = STIX_SIZEOF(stix_rbt_pair_t); stix_oow_t as = STIX_SIZEOF(stix_rbt_pair_t);
if (kcop == STIX_RBT_COPIER_INLINE) as += KTOB(rbt,klen); if (kcop == STIX_RBT_COPIER_INLINE) as += KTOB(rbt,klen);
if (vcop == STIX_RBT_COPIER_INLINE) as += VTOB(rbt,vlen); if (vcop == STIX_RBT_COPIER_INLINE) as += VTOB(rbt,vlen);
@ -191,7 +191,7 @@ const stix_rbt_style_t* stix_getrbtstyle (stix_rbt_style_kind_t kind)
return &style[kind]; return &style[kind];
} }
stix_rbt_t* stix_rbt_open (stix_mmgr_t* mmgr, stix_size_t xtnsize, int kscale, int vscale) stix_rbt_t* stix_rbt_open (stix_mmgr_t* mmgr, stix_oow_t xtnsize, int kscale, int vscale)
{ {
stix_rbt_t* rbt; stix_rbt_t* rbt;
@ -264,12 +264,12 @@ void stix_rbt_setstyle (stix_rbt_t* rbt, const stix_rbt_style_t* style)
rbt->style = style; rbt->style = style;
} }
stix_size_t stix_rbt_getsize (const stix_rbt_t* rbt) stix_oow_t stix_rbt_getsize (const stix_rbt_t* rbt)
{ {
return rbt->size; return rbt->size;
} }
stix_rbt_pair_t* stix_rbt_search (const stix_rbt_t* rbt, const void* kptr, stix_size_t klen) stix_rbt_pair_t* stix_rbt_search (const stix_rbt_t* rbt, const void* kptr, stix_oow_t klen)
{ {
stix_rbt_pair_t* pair = rbt->root; stix_rbt_pair_t* pair = rbt->root;
@ -418,7 +418,7 @@ static void adjust (stix_rbt_t* rbt, stix_rbt_pair_t* pair)
} }
static stix_rbt_pair_t* change_pair_val ( static stix_rbt_pair_t* change_pair_val (
stix_rbt_t* rbt, stix_rbt_pair_t* pair, void* vptr, stix_size_t vlen) stix_rbt_t* rbt, stix_rbt_pair_t* pair, void* vptr, stix_oow_t vlen)
{ {
if (VPTR(pair) == vptr && VLEN(pair) == vlen) if (VPTR(pair) == vptr && VLEN(pair) == vlen)
{ {
@ -434,7 +434,7 @@ static stix_rbt_pair_t* change_pair_val (
{ {
copier_t vcop = rbt->style->copier[STIX_RBT_VAL]; copier_t vcop = rbt->style->copier[STIX_RBT_VAL];
void* ovptr = VPTR(pair); void* ovptr = VPTR(pair);
stix_size_t ovlen = VLEN(pair); stix_oow_t ovlen = VLEN(pair);
/* place the new value according to the copier */ /* place the new value according to the copier */
if (vcop == STIX_RBT_COPIER_SIMPLE) if (vcop == STIX_RBT_COPIER_SIMPLE)
@ -501,7 +501,7 @@ static stix_rbt_pair_t* change_pair_val (
} }
static stix_rbt_pair_t* insert ( static stix_rbt_pair_t* insert (
stix_rbt_t* rbt, void* kptr, stix_size_t klen, void* vptr, stix_size_t vlen, int opt) stix_rbt_t* rbt, void* kptr, stix_oow_t klen, void* vptr, stix_oow_t vlen, int opt)
{ {
stix_rbt_pair_t* x_cur = rbt->root; stix_rbt_pair_t* x_cur = rbt->root;
stix_rbt_pair_t* x_par = STIX_NULL; stix_rbt_pair_t* x_par = STIX_NULL;
@ -570,32 +570,32 @@ static stix_rbt_pair_t* insert (
} }
stix_rbt_pair_t* stix_rbt_upsert ( stix_rbt_pair_t* stix_rbt_upsert (
stix_rbt_t* rbt, void* kptr, stix_size_t klen, void* vptr, stix_size_t vlen) stix_rbt_t* rbt, void* kptr, stix_oow_t klen, void* vptr, stix_oow_t vlen)
{ {
return insert (rbt, kptr, klen, vptr, vlen, UPSERT); return insert (rbt, kptr, klen, vptr, vlen, UPSERT);
} }
stix_rbt_pair_t* stix_rbt_ensert ( stix_rbt_pair_t* stix_rbt_ensert (
stix_rbt_t* rbt, void* kptr, stix_size_t klen, void* vptr, stix_size_t vlen) stix_rbt_t* rbt, void* kptr, stix_oow_t klen, void* vptr, stix_oow_t vlen)
{ {
return insert (rbt, kptr, klen, vptr, vlen, ENSERT); return insert (rbt, kptr, klen, vptr, vlen, ENSERT);
} }
stix_rbt_pair_t* stix_rbt_insert ( stix_rbt_pair_t* stix_rbt_insert (
stix_rbt_t* rbt, void* kptr, stix_size_t klen, void* vptr, stix_size_t vlen) stix_rbt_t* rbt, void* kptr, stix_oow_t klen, void* vptr, stix_oow_t vlen)
{ {
return insert (rbt, kptr, klen, vptr, vlen, INSERT); return insert (rbt, kptr, klen, vptr, vlen, INSERT);
} }
stix_rbt_pair_t* stix_rbt_update ( stix_rbt_pair_t* stix_rbt_update (
stix_rbt_t* rbt, void* kptr, stix_size_t klen, void* vptr, stix_size_t vlen) stix_rbt_t* rbt, void* kptr, stix_oow_t klen, void* vptr, stix_oow_t vlen)
{ {
return insert (rbt, kptr, klen, vptr, vlen, UPDATE); return insert (rbt, kptr, klen, vptr, vlen, UPDATE);
} }
stix_rbt_pair_t* stix_rbt_cbsert ( stix_rbt_pair_t* stix_rbt_cbsert (
stix_rbt_t* rbt, void* kptr, stix_size_t klen, cbserter_t cbserter, void* ctx) stix_rbt_t* rbt, void* kptr, stix_oow_t klen, cbserter_t cbserter, void* ctx)
{ {
stix_rbt_pair_t* x_cur = rbt->root; stix_rbt_pair_t* x_cur = rbt->root;
stix_rbt_pair_t* x_par = STIX_NULL; stix_rbt_pair_t* x_par = STIX_NULL;
@ -865,7 +865,7 @@ static void delete_pair (stix_rbt_t* rbt, stix_rbt_pair_t* pair)
rbt->size--; rbt->size--;
} }
int stix_rbt_delete (stix_rbt_t* rbt, const void* kptr, stix_size_t klen) int stix_rbt_delete (stix_rbt_t* rbt, const void* kptr, stix_oow_t klen)
{ {
stix_rbt_pair_t* pair; stix_rbt_pair_t* pair;
@ -979,9 +979,9 @@ void stix_rbt_rwalk (stix_rbt_t* rbt, walker_t walker, void* ctx)
walk (rbt, walker, ctx, RIGHT, LEFT); walk (rbt, walker, ctx, RIGHT, LEFT);
} }
int stix_rbt_dflcomp (const stix_rbt_t* rbt, const void* kptr1, stix_size_t klen1, const void* kptr2, stix_size_t klen2) int stix_rbt_dflcomp (const stix_rbt_t* rbt, const void* kptr1, stix_oow_t klen1, const void* kptr2, stix_oow_t klen2)
{ {
stix_size_t min; stix_oow_t min;
int n, nn; int n, nn;
if (klen1 < klen2) if (klen1 < klen2)

View File

@ -101,7 +101,7 @@ typedef enum stix_rbt_id_t stix_rbt_id_t;
typedef void* (*stix_rbt_copier_t) ( typedef void* (*stix_rbt_copier_t) (
stix_rbt_t* rbt /* red-black tree */, stix_rbt_t* rbt /* red-black tree */,
void* dptr /* pointer to a key or a value */, void* dptr /* pointer to a key or a value */,
stix_size_t dlen /* length of a key or a value */ stix_oow_t dlen /* length of a key or a value */
); );
/** /**
@ -110,7 +110,7 @@ typedef void* (*stix_rbt_copier_t) (
typedef void (*stix_rbt_freeer_t) ( typedef void (*stix_rbt_freeer_t) (
stix_rbt_t* rbt, /**< red-black tree */ stix_rbt_t* rbt, /**< red-black tree */
void* dptr, /**< pointer to a key or a value */ void* dptr, /**< pointer to a key or a value */
stix_size_t dlen /**< length of a key or a value */ stix_oow_t dlen /**< length of a key or a value */
); );
/** /**
@ -123,9 +123,9 @@ typedef void (*stix_rbt_freeer_t) (
typedef int (*stix_rbt_comper_t) ( typedef int (*stix_rbt_comper_t) (
const stix_rbt_t* rbt, /**< red-black tree */ const stix_rbt_t* rbt, /**< red-black tree */
const void* kptr1, /**< key pointer */ const void* kptr1, /**< key pointer */
stix_size_t klen1, /**< key length */ stix_oow_t klen1, /**< key length */
const void* kptr2, /**< key pointer */ const void* kptr2, /**< key pointer */
stix_size_t klen2 /**< key length */ stix_oow_t klen2 /**< key length */
); );
/** /**
@ -137,7 +137,7 @@ typedef int (*stix_rbt_comper_t) (
typedef void (*stix_rbt_keeper_t) ( typedef void (*stix_rbt_keeper_t) (
stix_rbt_t* rbt, /**< red-black tree */ stix_rbt_t* rbt, /**< red-black tree */
void* vptr, /**< value pointer */ void* vptr, /**< value pointer */
stix_size_t vlen /**< value length */ stix_oow_t vlen /**< value length */
); );
/** /**
@ -163,7 +163,7 @@ typedef stix_rbt_pair_t* (*stix_rbt_cbserter_t) (
stix_rbt_t* rbt, /**< red-black tree */ stix_rbt_t* rbt, /**< red-black tree */
stix_rbt_pair_t* pair, /**< pair pointer */ stix_rbt_pair_t* pair, /**< pair pointer */
void* kptr, /**< key pointer */ void* kptr, /**< key pointer */
stix_size_t klen, /**< key length */ stix_oow_t klen, /**< key length */
void* ctx /**< callback context */ void* ctx /**< callback context */
); );
@ -178,13 +178,13 @@ struct stix_rbt_pair_t
struct struct
{ {
void* ptr; void* ptr;
stix_size_t len; stix_oow_t len;
} key; } key;
struct struct
{ {
void* ptr; void* ptr;
stix_size_t len; stix_oow_t len;
} val; } val;
/* management information below */ /* management information below */
@ -238,7 +238,7 @@ struct stix_rbt_t
const stix_rbt_style_t* style; const stix_rbt_style_t* style;
stix_oob_t scale[2]; /**< length scale */ stix_oob_t scale[2]; /**< length scale */
stix_rbt_pair_t xnil; /**< internal nil node */ stix_rbt_pair_t xnil; /**< internal nil node */
stix_size_t size; /**< number of pairs */ stix_oow_t size; /**< number of pairs */
stix_rbt_pair_t* root; /**< root pair */ stix_rbt_pair_t* root; /**< root pair */
}; };
@ -262,7 +262,7 @@ struct stix_rbt_t
/** /**
* The STIX_RBT_SIZE() macro returns the number of pairs in red-black tree. * The STIX_RBT_SIZE() macro returns the number of pairs in red-black tree.
*/ */
#define STIX_RBT_SIZE(m) ((const stix_size_t)(m)->size) #define STIX_RBT_SIZE(m) ((const stix_oow_t)(m)->size)
#define STIX_RBT_KSCALE(m) ((const int)(m)->scale[STIX_RBT_KEY]) #define STIX_RBT_KSCALE(m) ((const int)(m)->scale[STIX_RBT_KEY])
#define STIX_RBT_VSCALE(m) ((const int)(m)->scale[STIX_RBT_VAL]) #define STIX_RBT_VSCALE(m) ((const int)(m)->scale[STIX_RBT_VAL])
@ -294,7 +294,7 @@ STIX_EXPORT const stix_rbt_style_t* stix_getrbtstyle (
*/ */
STIX_EXPORT stix_rbt_t* stix_rbt_open ( STIX_EXPORT stix_rbt_t* stix_rbt_open (
stix_mmgr_t* mmgr, /**< memory manager */ stix_mmgr_t* mmgr, /**< memory manager */
stix_size_t xtnsize, /**< extension size in bytes */ stix_oow_t xtnsize, /**< extension size in bytes */
int kscale, /**< key scale */ int kscale, /**< key scale */
int vscale /**< value scale */ int vscale /**< value scale */
); );
@ -353,7 +353,7 @@ STIX_EXPORT void stix_rbt_setstyle (
/** /**
* The stix_rbt_getsize() function gets the number of pairs in red-black tree. * The stix_rbt_getsize() function gets the number of pairs in red-black tree.
*/ */
STIX_EXPORT stix_size_t stix_rbt_getsize ( STIX_EXPORT stix_oow_t stix_rbt_getsize (
const stix_rbt_t* rbt /**< red-black tree */ const stix_rbt_t* rbt /**< red-black tree */
); );
@ -367,7 +367,7 @@ STIX_EXPORT stix_size_t stix_rbt_getsize (
STIX_EXPORT stix_rbt_pair_t* stix_rbt_search ( STIX_EXPORT stix_rbt_pair_t* stix_rbt_search (
const stix_rbt_t* rbt, /**< red-black tree */ const stix_rbt_t* rbt, /**< red-black tree */
const void* kptr, /**< key pointer */ const void* kptr, /**< key pointer */
stix_size_t klen /**< the size of the key */ stix_oow_t klen /**< the size of the key */
); );
/** /**
@ -381,9 +381,9 @@ STIX_EXPORT stix_rbt_pair_t* stix_rbt_search (
STIX_EXPORT stix_rbt_pair_t* stix_rbt_upsert ( STIX_EXPORT stix_rbt_pair_t* stix_rbt_upsert (
stix_rbt_t* rbt, /**< red-black tree */ stix_rbt_t* rbt, /**< red-black tree */
void* kptr, /**< key pointer */ void* kptr, /**< key pointer */
stix_size_t klen, /**< key length */ stix_oow_t klen, /**< key length */
void* vptr, /**< value pointer */ void* vptr, /**< value pointer */
stix_size_t vlen /**< value length */ stix_oow_t vlen /**< value length */
); );
/** /**
@ -395,9 +395,9 @@ STIX_EXPORT stix_rbt_pair_t* stix_rbt_upsert (
STIX_EXPORT stix_rbt_pair_t* stix_rbt_ensert ( STIX_EXPORT stix_rbt_pair_t* stix_rbt_ensert (
stix_rbt_t* rbt, /**< red-black tree */ stix_rbt_t* rbt, /**< red-black tree */
void* kptr, /**< key pointer */ void* kptr, /**< key pointer */
stix_size_t klen, /**< key length */ stix_oow_t klen, /**< key length */
void* vptr, /**< value pointer */ void* vptr, /**< value pointer */
stix_size_t vlen /**< value length */ stix_oow_t vlen /**< value length */
); );
/** /**
@ -409,9 +409,9 @@ STIX_EXPORT stix_rbt_pair_t* stix_rbt_ensert (
STIX_EXPORT stix_rbt_pair_t* stix_rbt_insert ( STIX_EXPORT stix_rbt_pair_t* stix_rbt_insert (
stix_rbt_t* rbt, /**< red-black tree */ stix_rbt_t* rbt, /**< red-black tree */
void* kptr, /**< key pointer */ void* kptr, /**< key pointer */
stix_size_t klen, /**< key length */ stix_oow_t klen, /**< key length */
void* vptr, /**< value pointer */ void* vptr, /**< value pointer */
stix_size_t vlen /**< value length */ stix_oow_t vlen /**< value length */
); );
/** /**
@ -422,9 +422,9 @@ STIX_EXPORT stix_rbt_pair_t* stix_rbt_insert (
STIX_EXPORT stix_rbt_pair_t* stix_rbt_update ( STIX_EXPORT stix_rbt_pair_t* stix_rbt_update (
stix_rbt_t* rbt, /**< red-black tree */ stix_rbt_t* rbt, /**< red-black tree */
void* kptr, /**< key pointer */ void* kptr, /**< key pointer */
stix_size_t klen, /**< key length */ stix_oow_t klen, /**< key length */
void* vptr, /**< value pointer */ void* vptr, /**< value pointer */
stix_size_t vlen /**< value length */ stix_oow_t vlen /**< value length */
); );
/** /**
@ -446,7 +446,7 @@ STIX_EXPORT stix_rbt_pair_t* stix_rbt_update (
* *
* stix_rbt_pair_t* cbserter ( * stix_rbt_pair_t* cbserter (
* stix_rbt_t* rbt, stix_rbt_pair_t* pair, * stix_rbt_t* rbt, stix_rbt_pair_t* pair,
* void* kptr, stix_size_t klen, void* ctx) * void* kptr, stix_oow_t klen, void* ctx)
* { * {
* stix_cstr_t* v = (stix_cstr_t*)ctx; * stix_cstr_t* v = (stix_cstr_t*)ctx;
* if (pair == STIX_NULL) * if (pair == STIX_NULL)
@ -517,7 +517,7 @@ STIX_EXPORT stix_rbt_pair_t* stix_rbt_update (
STIX_EXPORT stix_rbt_pair_t* stix_rbt_cbsert ( STIX_EXPORT stix_rbt_pair_t* stix_rbt_cbsert (
stix_rbt_t* rbt, /**< red-black tree */ stix_rbt_t* rbt, /**< red-black tree */
void* kptr, /**< key pointer */ void* kptr, /**< key pointer */
stix_size_t klen, /**< key length */ stix_oow_t klen, /**< key length */
stix_rbt_cbserter_t cbserter, /**< callback function */ stix_rbt_cbserter_t cbserter, /**< callback function */
void* ctx /**< callback context */ void* ctx /**< callback context */
); );
@ -529,7 +529,7 @@ STIX_EXPORT stix_rbt_pair_t* stix_rbt_cbsert (
STIX_EXPORT int stix_rbt_delete ( STIX_EXPORT int stix_rbt_delete (
stix_rbt_t* rbt, /**< red-black tree */ stix_rbt_t* rbt, /**< red-black tree */
const void* kptr, /**< key pointer */ const void* kptr, /**< key pointer */
stix_size_t klen /**< key size */ stix_oow_t klen /**< key size */
); );
/** /**
@ -574,9 +574,9 @@ STIX_EXPORT void stix_rbt_rwalk (
STIX_EXPORT stix_rbt_pair_t* stix_rbt_allocpair ( STIX_EXPORT stix_rbt_pair_t* stix_rbt_allocpair (
stix_rbt_t* rbt, stix_rbt_t* rbt,
void* kptr, void* kptr,
stix_size_t klen, stix_oow_t klen,
void* vptr, void* vptr,
stix_size_t vlen stix_oow_t vlen
); );
/** /**
@ -595,9 +595,9 @@ STIX_EXPORT void stix_rbt_freepair (
STIX_EXPORT int stix_rbt_dflcomp ( STIX_EXPORT int stix_rbt_dflcomp (
const stix_rbt_t* rbt, const stix_rbt_t* rbt,
const void* kptr1, const void* kptr1,
stix_size_t klen1, stix_oow_t klen1,
const void* kptr2, const void* kptr2,
stix_size_t klen2 stix_oow_t klen2
); );
#if defined(__cplusplus) #if defined(__cplusplus)

View File

@ -27,9 +27,9 @@
#include "stix-utl.h" #include "stix-utl.h"
stix_size_t stix_hashbytes (const stix_oob_t* ptr, stix_size_t len) stix_oow_t stix_hashbytes (const stix_oob_t* ptr, stix_oow_t len)
{ {
stix_size_t h = 0; stix_oow_t h = 0;
const stix_uint8_t* bp, * be; const stix_uint8_t* bp, * be;
bp = ptr; be = bp + len; bp = ptr; be = bp + len;
@ -38,14 +38,14 @@ stix_size_t stix_hashbytes (const stix_oob_t* ptr, stix_size_t len)
return h; return h;
} }
stix_size_t stix_hashuchars (const stix_uch_t* ptr, stix_size_t len) stix_oow_t stix_hashuchars (const stix_uch_t* ptr, stix_oow_t len)
{ {
return stix_hashbytes ((const stix_oob_t *)ptr, len * STIX_SIZEOF(*ptr)); return stix_hashbytes ((const stix_oob_t *)ptr, len * STIX_SIZEOF(*ptr));
} }
int stix_equalchars (const stix_uch_t* str1, const stix_uch_t* str2, stix_size_t len) int stix_equalchars (const stix_uch_t* str1, const stix_uch_t* str2, stix_oow_t len)
{ {
stix_size_t i; stix_oow_t i;
for (i = 0; i < len; i++) for (i = 0; i < len; i++)
{ {
@ -88,7 +88,7 @@ int stix_compucbcstr (const stix_uch_t* str1, const stix_bch_t* str2)
return (*str1 > *str2)? 1: -1; return (*str1 > *str2)? 1: -1;
} }
int stix_compucxbcstr (const stix_uch_t* str1, stix_size_t len, const stix_bch_t* str2) int stix_compucxbcstr (const stix_uch_t* str1, stix_oow_t len, const stix_bch_t* str2)
{ {
const stix_uch_t* end = str1 + len; const stix_uch_t* end = str1 + len;
while (str1 < end && *str2 != '\0' && *str1 == *str2) str1++, str2++; while (str1 < end && *str2 != '\0' && *str1 == *str2) str1++, str2++;
@ -97,25 +97,25 @@ int stix_compucxbcstr (const stix_uch_t* str1, stix_size_t len, const stix_bch_t
return (*str1 > *str2)? 1: -1; return (*str1 > *str2)? 1: -1;
} }
void stix_copyuchars (stix_uch_t* dst, const stix_uch_t* src, stix_size_t len) void stix_copyuchars (stix_uch_t* dst, const stix_uch_t* src, stix_oow_t len)
{ {
stix_size_t i; stix_oow_t i;
for (i = 0; i < len; i++) dst[i] = src[i]; for (i = 0; i < len; i++) dst[i] = src[i];
} }
void stix_copybchars (stix_bch_t* dst, const stix_bch_t* src, stix_size_t len) void stix_copybchars (stix_bch_t* dst, const stix_bch_t* src, stix_oow_t len)
{ {
stix_size_t i; stix_oow_t i;
for (i = 0; i < len; i++) dst[i] = src[i]; for (i = 0; i < len; i++) dst[i] = src[i];
} }
void stix_copybchtouchars (stix_uch_t* dst, const stix_bch_t* src, stix_size_t len) void stix_copybchtouchars (stix_uch_t* dst, const stix_bch_t* src, stix_oow_t len)
{ {
stix_size_t i; stix_oow_t i;
for (i = 0; i < len; i++) dst[i] = src[i]; for (i = 0; i < len; i++) dst[i] = src[i];
} }
stix_size_t stix_copyucstr (stix_uch_t* dst, stix_size_t len, const stix_uch_t* src) stix_oow_t stix_copyucstr (stix_uch_t* dst, stix_oow_t len, const stix_uch_t* src)
{ {
stix_uch_t* p, * p2; stix_uch_t* p, * p2;
@ -131,7 +131,7 @@ stix_size_t stix_copyucstr (stix_uch_t* dst, stix_size_t len, const stix_uch_t*
return p - dst; return p - dst;
} }
stix_size_t stix_copybcstr (stix_bch_t* dst, stix_size_t len, const stix_bch_t* src) stix_oow_t stix_copybcstr (stix_bch_t* dst, stix_oow_t len, const stix_bch_t* src)
{ {
stix_bch_t* p, * p2; stix_bch_t* p, * p2;
@ -147,21 +147,21 @@ stix_size_t stix_copybcstr (stix_bch_t* dst, stix_size_t len, const stix_bch_t*
return p - dst; return p - dst;
} }
stix_size_t stix_countucstr (const stix_uch_t* str) stix_oow_t stix_countucstr (const stix_uch_t* str)
{ {
const stix_uch_t* ptr = str; const stix_uch_t* ptr = str;
while (*ptr != '\0') ptr++; while (*ptr != '\0') ptr++;
return ptr - str; return ptr - str;
} }
stix_size_t stix_countbcstr (const stix_bch_t* str) stix_oow_t stix_countbcstr (const stix_bch_t* str)
{ {
const stix_bch_t* ptr = str; const stix_bch_t* ptr = str;
while (*ptr != '\0') ptr++; while (*ptr != '\0') ptr++;
return ptr - str; return ptr - str;
} }
stix_uch_t* stix_finduchar (const stix_uch_t* ptr, stix_size_t len, stix_uch_t c) stix_uch_t* stix_finduchar (const stix_uch_t* ptr, stix_oow_t len, stix_uch_t c)
{ {
const stix_uch_t* end; const stix_uch_t* end;
@ -175,7 +175,7 @@ stix_uch_t* stix_finduchar (const stix_uch_t* ptr, stix_size_t len, stix_uch_t c
return STIX_NULL; return STIX_NULL;
} }
stix_bch_t* stix_findbchar (const stix_bch_t* ptr, stix_size_t len, stix_bch_t c) stix_bch_t* stix_findbchar (const stix_bch_t* ptr, stix_oow_t len, stix_bch_t c)
{ {
const stix_bch_t* end; const stix_bch_t* end;

View File

@ -57,14 +57,14 @@ extern "C" {
/* ========================================================================= */ /* ========================================================================= */
/* stix-utl.c */ /* stix-utl.c */
/* ========================================================================= */ /* ========================================================================= */
stix_size_t stix_hashbytes ( stix_oow_t stix_hashbytes (
const stix_oob_t* ptr, const stix_oob_t* ptr,
stix_size_t len stix_oow_t len
); );
stix_size_t stix_hashuchars ( stix_oow_t stix_hashuchars (
const stix_uch_t* ptr, const stix_uch_t* ptr,
stix_size_t len stix_oow_t len
); );
#define stix_hashbchars(ptr,len) stix_hashbytes(ptr,len) #define stix_hashbchars(ptr,len) stix_hashbytes(ptr,len)
@ -73,7 +73,7 @@ stix_size_t stix_hashuchars (
int stix_equalchars ( int stix_equalchars (
const stix_uch_t* str1, const stix_uch_t* str1,
const stix_uch_t* str2, const stix_uch_t* str2,
stix_size_t len stix_oow_t len
); );
int stix_compucstr ( int stix_compucstr (
@ -93,57 +93,57 @@ int stix_compucbcstr (
int stix_compucxbcstr ( int stix_compucxbcstr (
const stix_uch_t* str1, const stix_uch_t* str1,
stix_size_t len, stix_oow_t len,
const stix_bch_t* str2 const stix_bch_t* str2
); );
void stix_copyuchars ( void stix_copyuchars (
stix_uch_t* dst, stix_uch_t* dst,
const stix_uch_t* src, const stix_uch_t* src,
stix_size_t len stix_oow_t len
); );
void stix_copybchars ( void stix_copybchars (
stix_bch_t* dst, stix_bch_t* dst,
const stix_bch_t* src, const stix_bch_t* src,
stix_size_t len stix_oow_t len
); );
void stix_copybchtouchars ( void stix_copybchtouchars (
stix_uch_t* dst, stix_uch_t* dst,
const stix_bch_t* src, const stix_bch_t* src,
stix_size_t len stix_oow_t len
); );
stix_size_t stix_copyucstr ( stix_oow_t stix_copyucstr (
stix_uch_t* dst, stix_uch_t* dst,
stix_size_t len, stix_oow_t len,
const stix_uch_t* src const stix_uch_t* src
); );
stix_size_t stix_copybcstr ( stix_oow_t stix_copybcstr (
stix_bch_t* dst, stix_bch_t* dst,
stix_size_t len, stix_oow_t len,
const stix_bch_t* src const stix_bch_t* src
); );
stix_uch_t* stix_finduchar ( stix_uch_t* stix_finduchar (
const stix_uch_t* ptr, const stix_uch_t* ptr,
stix_size_t len, stix_oow_t len,
stix_uch_t c stix_uch_t c
); );
stix_bch_t* stix_findbchar ( stix_bch_t* stix_findbchar (
const stix_bch_t* ptr, const stix_bch_t* ptr,
stix_size_t len, stix_oow_t len,
stix_bch_t c stix_bch_t c
); );
stix_size_t stix_countucstr ( stix_oow_t stix_countucstr (
const stix_uch_t* str const stix_uch_t* str
); );
stix_size_t stix_countbcstr ( stix_oow_t stix_countbcstr (
const stix_bch_t* str const stix_bch_t* str
); );

View File

@ -27,7 +27,7 @@
#include "stix-prv.h" #include "stix-prv.h"
stix_t* stix_open (stix_mmgr_t* mmgr, stix_size_t xtnsize, stix_size_t heapsize, const stix_vmprim_t* vmprim, stix_errnum_t* errnum) stix_t* stix_open (stix_mmgr_t* mmgr, stix_oow_t xtnsize, stix_oow_t heapsize, const stix_vmprim_t* vmprim, stix_errnum_t* errnum)
{ {
stix_t* stix; stix_t* stix;
@ -83,7 +83,7 @@ static void fill_bigint_tables (stix_t* stix)
} }
} }
int stix_init (stix_t* stix, stix_mmgr_t* mmgr, stix_size_t heapsz, const stix_vmprim_t* vmprim) int stix_init (stix_t* stix, stix_mmgr_t* mmgr, stix_oow_t heapsz, const stix_vmprim_t* vmprim)
{ {
STIX_MEMSET (stix, 0, STIX_SIZEOF(*stix)); STIX_MEMSET (stix, 0, STIX_SIZEOF(*stix));
stix->mmgr = mmgr; stix->mmgr = mmgr;
@ -244,7 +244,7 @@ void stix_deregcb (stix_t* stix, stix_cb_t* cb)
stix_freemem (stix, cb); stix_freemem (stix, cb);
} }
void* stix_allocmem (stix_t* stix, stix_size_t size) void* stix_allocmem (stix_t* stix, stix_oow_t size)
{ {
void* ptr; void* ptr;
@ -253,7 +253,7 @@ void* stix_allocmem (stix_t* stix, stix_size_t size)
return ptr; return ptr;
} }
void* stix_callocmem (stix_t* stix, stix_size_t size) void* stix_callocmem (stix_t* stix, stix_oow_t size)
{ {
void* ptr; void* ptr;
@ -263,7 +263,7 @@ void* stix_callocmem (stix_t* stix, stix_size_t size)
return ptr; return ptr;
} }
void* stix_reallocmem (stix_t* stix, void* ptr, stix_size_t size) void* stix_reallocmem (stix_t* stix, void* ptr, stix_oow_t size)
{ {
ptr = STIX_MMGR_REALLOC (stix->mmgr, ptr, size); ptr = STIX_MMGR_REALLOC (stix->mmgr, ptr, size);
if (!ptr) stix->errnum = STIX_ENOMEM; if (!ptr) stix->errnum = STIX_ENOMEM;

View File

@ -759,8 +759,8 @@ extern "C" {
STIX_EXPORT stix_t* stix_open ( STIX_EXPORT stix_t* stix_open (
stix_mmgr_t* mmgr, stix_mmgr_t* mmgr,
stix_size_t xtnsize, stix_oow_t xtnsize,
stix_size_t heapsize, stix_oow_t heapsize,
const stix_vmprim_t* vmprim, const stix_vmprim_t* vmprim,
stix_errnum_t* errnum stix_errnum_t* errnum
); );
@ -772,7 +772,7 @@ STIX_EXPORT void stix_close (
STIX_EXPORT int stix_init ( STIX_EXPORT int stix_init (
stix_t* vm, stix_t* vm,
stix_mmgr_t* mmgr, stix_mmgr_t* mmgr,
stix_size_t heapsize, stix_oow_t heapsize,
const stix_vmprim_t* vmprim const stix_vmprim_t* vmprim
); );
@ -912,18 +912,18 @@ STIX_EXPORT void stix_poptmps (
STIX_EXPORT void* stix_allocmem ( STIX_EXPORT void* stix_allocmem (
stix_t* stix, stix_t* stix,
stix_size_t size stix_oow_t size
); );
STIX_EXPORT void* stix_callocmem ( STIX_EXPORT void* stix_callocmem (
stix_t* stix, stix_t* stix,
stix_size_t size stix_oow_t size
); );
STIX_EXPORT void* stix_reallocmem ( STIX_EXPORT void* stix_reallocmem (
stix_t* stix, stix_t* stix,
void* ptr, void* ptr,
stix_size_t size stix_oow_t size
); );
STIX_EXPORT void stix_freemem ( STIX_EXPORT void stix_freemem (

View File

@ -81,7 +81,7 @@ static STIX_INLINE __utf8_t* get_utf8_slot (stix_uch_t uc)
return STIX_NULL; /* invalid character */ return STIX_NULL; /* invalid character */
} }
stix_size_t stix_uctoutf8 (stix_uch_t uc, stix_bch_t* utf8, stix_size_t size) stix_oow_t stix_uctoutf8 (stix_uch_t uc, stix_bch_t* utf8, stix_oow_t size)
{ {
__utf8_t* cur = get_utf8_slot (uc); __utf8_t* cur = get_utf8_slot (uc);
@ -105,10 +105,10 @@ stix_size_t stix_uctoutf8 (stix_uch_t uc, stix_bch_t* utf8, stix_size_t size)
/* small buffer is also indicated by this return value /* small buffer is also indicated by this return value
* greater than 'size'. */ * greater than 'size'. */
return (stix_size_t)cur->length; return (stix_oow_t)cur->length;
} }
stix_size_t stix_utf8touc (const stix_bch_t* utf8, stix_size_t size, stix_uch_t* uc) stix_oow_t stix_utf8touc (const stix_bch_t* utf8, stix_oow_t size, stix_uch_t* uc)
{ {
__utf8_t* cur, * end; __utf8_t* cur, * end;
@ -171,7 +171,7 @@ stix_size_t stix_utf8touc (const stix_bch_t* utf8, stix_size_t size, stix_uch_t*
* and * and
* the incomplete seqeunce error (size < cur->length). * the incomplete seqeunce error (size < cur->length).
*/ */
return (stix_size_t)cur->length; return (stix_oow_t)cur->length;
} }
cur++; cur++;
} }
@ -182,12 +182,12 @@ stix_size_t stix_utf8touc (const stix_bch_t* utf8, stix_size_t size, stix_uch_t*
/* ----------------------------------------------------------------------- */ /* ----------------------------------------------------------------------- */
static STIX_INLINE int bcsn_to_ucsn_with_cmgr ( static STIX_INLINE int bcsn_to_ucsn_with_cmgr (
const stix_bch_t* bcs, stix_size_t* bcslen, const stix_bch_t* bcs, stix_oow_t* bcslen,
stix_uch_t* ucs, stix_size_t* ucslen, stix_cmgr_t* cmgr, int all) stix_uch_t* ucs, stix_oow_t* ucslen, stix_cmgr_t* cmgr, int all)
{ {
const stix_bch_t* p; const stix_bch_t* p;
int ret = 0; int ret = 0;
stix_size_t mlen; stix_oow_t mlen;
if (ucs) if (ucs)
{ {
@ -203,7 +203,7 @@ static STIX_INLINE int bcsn_to_ucsn_with_cmgr (
while (mlen > 0) while (mlen > 0)
{ {
stix_size_t n; stix_oow_t n;
if (q >= qend) if (q >= qend)
{ {
@ -259,14 +259,14 @@ static STIX_INLINE int bcsn_to_ucsn_with_cmgr (
* the buffer. */ * the buffer. */
stix_uch_t w; stix_uch_t w;
stix_size_t wlen = 0; stix_oow_t wlen = 0;
p = bcs; p = bcs;
mlen = *bcslen; mlen = *bcslen;
while (mlen > 0) while (mlen > 0)
{ {
stix_size_t n; stix_oow_t n;
n = cmgr->bctouc (p, mlen, &w); n = cmgr->bctouc (p, mlen, &w);
if (n == 0) if (n == 0)
@ -303,11 +303,11 @@ static STIX_INLINE int bcsn_to_ucsn_with_cmgr (
} }
static STIX_INLINE int bcs_to_ucs_with_cmgr ( static STIX_INLINE int bcs_to_ucs_with_cmgr (
const stix_bch_t* bcs, stix_size_t* bcslen, const stix_bch_t* bcs, stix_oow_t* bcslen,
stix_uch_t* ucs, stix_size_t* ucslen, stix_cmgr_t* cmgr, int all) stix_uch_t* ucs, stix_oow_t* ucslen, stix_cmgr_t* cmgr, int all)
{ {
const stix_bch_t* bp; const stix_bch_t* bp;
stix_size_t mlen, wlen; stix_oow_t mlen, wlen;
int n; int n;
for (bp = bcs; *bp != '\0'; bp++) /* nothing */ ; for (bp = bcs; *bp != '\0'; bp++) /* nothing */ ;
@ -326,8 +326,8 @@ static STIX_INLINE int bcs_to_ucs_with_cmgr (
} }
static STIX_INLINE int ucsn_to_bcsn_with_cmgr ( static STIX_INLINE int ucsn_to_bcsn_with_cmgr (
const stix_uch_t* ucs, stix_size_t* ucslen, const stix_uch_t* ucs, stix_oow_t* ucslen,
stix_bch_t* bcs, stix_size_t* bcslen, stix_cmgr_t* cmgr) stix_bch_t* bcs, stix_oow_t* bcslen, stix_cmgr_t* cmgr)
{ {
const stix_uch_t* p = ucs; const stix_uch_t* p = ucs;
const stix_uch_t* end = ucs + *ucslen; const stix_uch_t* end = ucs + *ucslen;
@ -335,11 +335,11 @@ static STIX_INLINE int ucsn_to_bcsn_with_cmgr (
if (bcs) if (bcs)
{ {
stix_size_t rem = *bcslen; stix_oow_t rem = *bcslen;
while (p < end) while (p < end)
{ {
stix_size_t n; stix_oow_t n;
if (rem <= 0) if (rem <= 0)
{ {
@ -366,11 +366,11 @@ static STIX_INLINE int ucsn_to_bcsn_with_cmgr (
else else
{ {
stix_bch_t bcsbuf[STIX_BCLEN_MAX]; stix_bch_t bcsbuf[STIX_BCLEN_MAX];
stix_size_t mlen = 0; stix_oow_t mlen = 0;
while (p < end) while (p < end)
{ {
stix_size_t n; stix_oow_t n;
n = cmgr->uctobc (*p, bcsbuf, STIX_COUNTOF(bcsbuf)); n = cmgr->uctobc (*p, bcsbuf, STIX_COUNTOF(bcsbuf));
if (n == 0) if (n == 0)
@ -396,19 +396,19 @@ static STIX_INLINE int ucsn_to_bcsn_with_cmgr (
static int ucs_to_bcs_with_cmgr ( static int ucs_to_bcs_with_cmgr (
const stix_uch_t* ucs, stix_size_t* ucslen, const stix_uch_t* ucs, stix_oow_t* ucslen,
stix_bch_t* bcs, stix_size_t* bcslen, stix_cmgr_t* cmgr) stix_bch_t* bcs, stix_oow_t* bcslen, stix_cmgr_t* cmgr)
{ {
const stix_uch_t* p = ucs; const stix_uch_t* p = ucs;
int ret = 0; int ret = 0;
if (bcs) if (bcs)
{ {
stix_size_t rem = *bcslen; stix_oow_t rem = *bcslen;
while (*p != '\0') while (*p != '\0')
{ {
stix_size_t n; stix_oow_t n;
if (rem <= 0) if (rem <= 0)
{ {
@ -448,11 +448,11 @@ static int ucs_to_bcs_with_cmgr (
else else
{ {
stix_bch_t bcsbuf[STIX_BCLEN_MAX]; stix_bch_t bcsbuf[STIX_BCLEN_MAX];
stix_size_t mlen = 0; stix_oow_t mlen = 0;
while (*p != '\0') while (*p != '\0')
{ {
stix_size_t n; stix_oow_t n;
n = cmgr->uctobc (*p, bcsbuf, STIX_COUNTOF(bcsbuf)); n = cmgr->uctobc (*p, bcsbuf, STIX_COUNTOF(bcsbuf));
if (n == 0) if (n == 0)
@ -482,9 +482,9 @@ static stix_cmgr_t utf8_cmgr =
stix_uctoutf8 stix_uctoutf8
}; };
int stix_utf8toucs (const stix_bch_t* bcs, stix_size_t* bcslen, stix_uch_t* ucs, stix_size_t* ucslen) int stix_utf8toucs (const stix_bch_t* bcs, stix_oow_t* bcslen, stix_uch_t* ucs, stix_oow_t* ucslen)
{ {
if (*bcslen == ~(stix_size_t)0) if (*bcslen == ~(stix_oow_t)0)
{ {
/* the source is null-terminated. */ /* the source is null-terminated. */
return bcs_to_ucs_with_cmgr (bcs, bcslen, ucs, ucslen, &utf8_cmgr, 0); return bcs_to_ucs_with_cmgr (bcs, bcslen, ucs, ucslen, &utf8_cmgr, 0);
@ -496,9 +496,9 @@ int stix_utf8toucs (const stix_bch_t* bcs, stix_size_t* bcslen, stix_uch_t* ucs,
} }
} }
int stix_ucstoutf8 (const stix_uch_t* ucs, stix_size_t *ucslen, stix_bch_t* bcs, stix_size_t* bcslen) int stix_ucstoutf8 (const stix_uch_t* ucs, stix_oow_t *ucslen, stix_bch_t* bcs, stix_oow_t* bcslen)
{ {
if (*ucslen == ~(stix_size_t)0) if (*ucslen == ~(stix_oow_t)0)
{ {
/* null-terminated */ /* null-terminated */
return ucs_to_bcs_with_cmgr (ucs, ucslen, bcs, bcslen, &utf8_cmgr); return ucs_to_bcs_with_cmgr (ucs, ucslen, bcs, bcslen, &utf8_cmgr);
@ -511,7 +511,7 @@ int stix_ucstoutf8 (const stix_uch_t* ucs, stix_size_t *ucslen, stix_bch_t* bcs,
} }
/* /*
stix_size_t stix_ucslen (const stix_uch_t* ucs) stix_oow_t stix_ucslen (const stix_uch_t* ucs)
{ {
const stix_uch_t* ptr = ucs; const stix_uch_t* ptr = ucs;
while (*ptr) ptr = STIX_INCPTR(const stix_uch_t, ptr, 1); while (*ptr) ptr = STIX_INCPTR(const stix_uch_t, ptr, 1);