From cdfb7428c8ab20ad355f6903186d99dbbea1f512 Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Thu, 10 Oct 2019 01:07:00 +0300 Subject: [PATCH] array/map: use get() instead of _get() etc --- compiler/cheaders.v | 6 +++--- compiler/gen_c.v | 10 +++++----- compiler/jsgen.v | 2 +- compiler/query.v | 4 ++-- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/compiler/cheaders.v b/compiler/cheaders.v index d4d7b723f4..b8c8747052 100644 --- a/compiler/cheaders.v +++ b/compiler/cheaders.v @@ -131,10 +131,10 @@ typedef map map_string; #endif //============================== HELPER C MACROS =============================*/ -#define _PUSH(arr, val, tmp, tmp_typ) {tmp_typ tmp = (val); array__push(arr, &tmp);} -#define _PUSH_MANY(arr, val, tmp, tmp_typ) {tmp_typ tmp = (val); array__push_many(arr, tmp.data, tmp.len);} +#define _PUSH(arr, val, tmp, tmp_typ) {tmp_typ tmp = (val); array_push(arr, &tmp);} +#define _PUSH_MANY(arr, val, tmp, tmp_typ) {tmp_typ tmp = (val); array_push_many(arr, tmp.data, tmp.len);} #define _IN(typ, val, arr) array_##typ##_contains(arr, val) -#define _IN_MAP(val, m) map__exists(m, val) +#define _IN_MAP(val, m) map_exists(m, val) #define DEFAULT_EQUAL(a, b) (a == b) #define DEFAULT_NOT_EQUAL(a, b) (a != b) #define DEFAULT_LT(a, b) (a < b) diff --git a/compiler/gen_c.v b/compiler/gen_c.v index 8c77f0980f..6bbf42ae67 100644 --- a/compiler/gen_c.v +++ b/compiler/gen_c.v @@ -180,9 +180,9 @@ fn (p mut Parser) index_get(typ string, fn_ph int, cfg IndexCfg) { } else { if cfg.is_ptr { - p.gen('( *($typ*) array__get(* $index_expr) )') + p.gen('( *($typ*) array_get(* $index_expr) )') } else { - p.gen('( *($typ*) array__get($index_expr) )') + p.gen('( *($typ*) array_get($index_expr) )') } } } @@ -358,7 +358,7 @@ fn (p mut Parser) gen_array_set(typ string, is_ptr, is_map bool,fn_ph, assign_po mut cao_tmp := p.cgen.cur_line mut func := '' if is_map { - func = 'map__set(&' + func = 'map_set(&' // CAO on map is a bit more complicated as it loads // the value inside a pointer instead of returning it. } @@ -366,13 +366,13 @@ fn (p mut Parser) gen_array_set(typ string, is_ptr, is_map bool,fn_ph, assign_po if is_ptr { func = 'array_set(' if is_cao { - cao_tmp = '*($p.expected_type *) array__get(*$cao_tmp)' + cao_tmp = '*($p.expected_type *) array_get(*$cao_tmp)' } } else { func = 'array_set(&/*q*/' if is_cao { - cao_tmp = '*($p.expected_type *) array__get($cao_tmp)' + cao_tmp = '*($p.expected_type *) array_get($cao_tmp)' } } } diff --git a/compiler/jsgen.v b/compiler/jsgen.v index c20a4e2725..e3676ecb6b 100644 --- a/compiler/jsgen.v +++ b/compiler/jsgen.v @@ -147,7 +147,7 @@ const cJSON *jsval = NULL; cJSON_ArrayForEach(jsval, root) { $s - array__push(res, &val); + array_push(res, &val); } ' } diff --git a/compiler/query.v b/compiler/query.v index 3272342030..d42ac88fbd 100644 --- a/compiler/query.v +++ b/compiler/query.v @@ -126,7 +126,7 @@ fn (p mut Parser) select_query(fn_ph int) string { if field.typ == 'int' { cast = 'v_string_int' } - obj_gen.writeln('${qprefix}$tmp . $field.name = $cast( *(string*)array__get(${qprefix}row.vals, $i) );') + obj_gen.writeln('${qprefix}$tmp . $field.name = $cast( *(string*)array_get(${qprefix}row.vals, $i) );') } // One object if query_one { @@ -165,7 +165,7 @@ array_pg__Row ${qprefix}rows = pg__res_to_rows(${qprefix}res); // TODO preallocate array ${qprefix}arr_$tmp = new_array(0, 0, sizeof($table_name)); for (int i = 0; i < ${qprefix}rows.len; i++) { - pg__Row ${qprefix}row = *(pg__Row*)array__get(${qprefix}rows, i); + pg__Row ${qprefix}row = *(pg__Row*)array_get(${qprefix}rows, i); $table_name ${qprefix}$tmp; ${obj_gen.str()} _PUSH(&${qprefix}arr_$tmp, ${qprefix}$tmp, ${tmp}2, $table_name);