From 0999273d3204d30d93ca88885cb6398ac1820e48 Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Sat, 30 Nov 2019 15:40:08 +0300 Subject: [PATCH] CReserved => c_reserved; charptr --- vlib/compiler/cheaders.v | 1 + vlib/compiler/gen_c.v | 2 +- vlib/compiler/table.v | 5 +++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/vlib/compiler/cheaders.v b/vlib/compiler/cheaders.v index a19b06feaa..cf5f360c96 100644 --- a/vlib/compiler/cheaders.v +++ b/vlib/compiler/cheaders.v @@ -187,6 +187,7 @@ typedef double f64; typedef unsigned char* byteptr; typedef int* intptr; typedef void* voidptr; +typedef char* charptr; typedef struct array array; typedef struct map map; typedef array array_string; diff --git a/vlib/compiler/gen_c.v b/vlib/compiler/gen_c.v index 327b46c5b7..6a145d7fac 100644 --- a/vlib/compiler/gen_c.v +++ b/vlib/compiler/gen_c.v @@ -271,7 +271,7 @@ fn (table mut Table) fn_gen_name(f &Fn) string { // Avoid name conflicts (with things like abs(), print() etc). // Generate v_abs(), v_print() // TODO duplicate functionality - if f.mod == 'builtin' && f.name in CReserved { + if f.mod == 'builtin' && f.name in c_reserved { return 'v_$name' } // Obfuscate but skip certain names diff --git a/vlib/compiler/table.v b/vlib/compiler/table.v index 30ec9b7f0a..865d4d1c1f 100644 --- a/vlib/compiler/table.v +++ b/vlib/compiler/table.v @@ -144,7 +144,7 @@ fn (t Type) str() string { */ const ( - CReserved = [ + c_reserved = [ 'delete', 'exit', 'unix', @@ -245,6 +245,7 @@ fn new_table(obfuscate bool) &Table { t.register_builtin('bool') t.register_builtin('void') t.register_builtin('voidptr') + t.register_builtin('charptr') t.register_builtin('va_list') for c in reserved_type_param_names { t.register_builtin(c) @@ -260,7 +261,7 @@ fn new_table(obfuscate bool) &Table { // If `name` is a reserved C keyword, returns `v_name` instead. fn (t &Table) var_cgen_name(name string) string { - if name in CReserved { + if name in c_reserved { return 'v_$name' } else {