Selaa lähdekoodia

ncd: modules: use the new static strings

ambrop7 13 vuotta sitten
vanhempi
sitoutus
b003fa6755

+ 3 - 10
ncd/modules/call2.c

@@ -139,12 +139,6 @@ static int caller_obj_func_getobj_with_caller_target (const NCDObject *obj, NCD_
 static void func_new_templ (void *vo, NCDModuleInst *i, NCDValRef template_name, NCDValRef args, int embed);
 static void instance_free (struct instance *o);
 
-enum {STRING_CALLER};
-
-static struct NCD_string_request strings[] = {
-    {"_caller"}, {NULL}
-};
-
 static void process_handler_event (NCDModuleProcess *process, int event)
 {
     struct instance *o = UPPER_OBJECT(process, struct instance, process);
@@ -193,7 +187,7 @@ static int process_func_getspecialobj_noembed (NCDModuleProcess *process, NCD_st
 {
     struct instance *o = UPPER_OBJECT(process, struct instance, process);
     
-    if (name == strings[STRING_CALLER].id) {
+    if (name == NCD_STRING_CALLER) {
         *out_object = NCDObject_Build(-1, o, NCDObject_no_getvar, caller_obj_func_getobj);
         return 1;
     }
@@ -205,7 +199,7 @@ static int process_func_getspecialobj_with_caller_target (NCDModuleProcess *proc
 {
     struct instance *o = UPPER_OBJECT(process, struct instance, process);
     
-    if (name == strings[STRING_CALLER].id) {
+    if (name == NCD_STRING_CALLER) {
         *out_object = NCDObject_Build(-1, o, NCDObject_no_getvar, caller_obj_func_getobj_with_caller_target);
         return 1;
     }
@@ -492,6 +486,5 @@ static struct NCDModule modules[] = {
 };
 
 const struct NCDModuleGroup ncdmodule_call2 = {
-    .modules = modules,
-    .strings = strings
+    .modules = modules
 };

+ 4 - 11
ncd/modules/file.c

@@ -106,12 +106,6 @@ struct stat_instance {
     struct stat result;
 };
 
-enum {STRING_SUCCEEDED, STRING_TYPE, STRING_SIZE};
-
-static struct NCD_string_request strings[] = {
-    {"succeeded"}, {"type"}, {"size"}, {NULL}
-};
-
 static void read_func_new (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
     struct read_instance *o = vo;
@@ -274,12 +268,12 @@ static int stat_func_getvar2 (void *vo, NCD_string_id_t name, NCDValMem *mem, NC
 {
     struct stat_instance *o = vo;
     
-    if (name == strings[STRING_SUCCEEDED].id) {
+    if (name == NCD_STRING_SUCCEEDED) {
         *out = ncd_make_boolean(mem, o->succeeded, o->i->params->iparams->string_index);
         return 1;
     }
     
-    if (name == strings[STRING_TYPE].id) {
+    if (name == NCD_STRING_TYPE) {
         const char *str;
         
         if (!o->succeeded) {
@@ -306,7 +300,7 @@ static int stat_func_getvar2 (void *vo, NCD_string_id_t name, NCDValMem *mem, NC
         return 1;
     }
     
-    if (name == strings[STRING_SIZE].id) {
+    if (name == NCD_STRING_SIZE) {
         char str[50];
         if (!o->succeeded) {
             strcpy(str, "failed");
@@ -347,6 +341,5 @@ static struct NCDModule modules[] = {
 };
 
 const struct NCDModuleGroup ncdmodule_file = {
-    .modules = modules,
-    .strings = strings
+    .modules = modules
 };

+ 3 - 10
ncd/modules/file_open.c

@@ -129,12 +129,6 @@ struct read_instance {
     size_t length;
 };
 
-enum {STRING_IS_ERROR, STRING_NOT_EOF};
-
-static struct NCD_string_request strings[] = {
-    {"is_error"}, {"not_eof"}, {NULL}
-};
-
 static int parse_mode (const char *data, size_t mode_len, char *out)
 {
     if (mode_len == 0) {
@@ -291,7 +285,7 @@ static int open_func_getvar (void *vo, NCD_string_id_t name, NCDValMem *mem, NCD
 {
     struct open_instance *o = vo;
     
-    if (name == strings[STRING_IS_ERROR].id) {
+    if (name == NCD_STRING_IS_ERROR) {
         *out = ncd_make_boolean(mem, !o->fh, o->i->params->iparams->string_index);
         return 1;
     }
@@ -378,7 +372,7 @@ static int read_func_getvar (void *vo, NCD_string_id_t name, NCDValMem *mem, NCD
         return 1;
     }
     
-    if (name == strings[STRING_NOT_EOF].id) {
+    if (name == NCD_STRING_NOT_EOF) {
         *out = ncd_make_boolean(mem, (o->length != 0), o->i->params->iparams->string_index);
         return 1;
     }
@@ -579,6 +573,5 @@ static struct NCDModule modules[] = {
 };
 
 const struct NCDModuleGroup ncdmodule_file_open = {
-    .modules = modules,
-    .strings = strings
+    .modules = modules
 };

+ 3 - 3
ncd/modules/foreach.c

@@ -138,10 +138,10 @@ static int element_map_key_object_func_getvar (const NCDObject *obj, NCD_string_
 static int element_map_val_object_func_getvar (const NCDObject *obj, NCD_string_id_t name, NCDValMem *mem, NCDValRef *out);
 static void instance_free (struct instance *o);
 
-enum {STRING_CALLER, STRING_INDEX, STRING_ELEM, STRING_KEY, STRING_VAL};
+enum {STRING_INDEX, STRING_ELEM, STRING_KEY, STRING_VAL};
 
 static struct NCD_string_request strings[] = {
-    {"_caller"}, {"_index"}, {"_elem"}, {"_key"}, {"_val"}, {NULL}
+    {"_index"}, {"_elem"}, {"_key"}, {"_val"}, {NULL}
 };
 
 static void assert_state (struct instance *o)
@@ -399,7 +399,7 @@ static int element_process_func_getspecialobj (NCDModuleProcess *process, NCD_st
         return NCDModuleInst_Backend_GetObj(o->i, name, out_object);
     }
     
-    if (name == strings[STRING_CALLER].id) {
+    if (name == NCD_STRING_CALLER) {
         *out_object = NCDObject_Build(-1, e, NCDObject_no_getvar, element_caller_object_func_getobj);
         return 1;
     }

+ 3 - 9
ncd/modules/imperative.c

@@ -55,6 +55,7 @@
 #include <misc/string_begins_with.h>
 #include <misc/offset.h>
 #include <ncd/NCDModule.h>
+#include <ncd/static_strings.h>
 #include <ncd/extra/value_utils.h>
 
 #include <generated/blog_channel_ncd_imperative.h>
@@ -86,12 +87,6 @@ static int process_caller_object_func_getobj (const NCDObject *obj, NCD_string_i
 static void deinit_timer_handler (struct instance *o);
 static void instance_free (struct instance *o);
 
-enum {STRING_CALLER};
-
-static struct NCD_string_request strings[] = {
-    {"_caller"}, {NULL}
-};
-
 static int start_process (struct instance *o, NCDValRef template_name, NCDValRef args, NCDModuleProcess_handler_event handler)
 {
     ASSERT(NCDVal_IsString(template_name))
@@ -208,7 +203,7 @@ static int process_func_getspecialobj (NCDModuleProcess *process, NCD_string_id_
     struct instance *o = UPPER_OBJECT(process, struct instance, process);
     ASSERT(o->state != STATE_UP)
     
-    if (name == strings[STRING_CALLER].id) {
+    if (name == NCD_STRING_CALLER) {
         *out_object = NCDObject_Build(-1, o, NCDObject_no_getvar, process_caller_object_func_getobj);
         return 1;
     }
@@ -325,6 +320,5 @@ static struct NCDModule modules[] = {
 };
 
 const struct NCDModuleGroup ncdmodule_imperative = {
-    .modules = modules,
-    .strings = strings
+    .modules = modules
 };

+ 5 - 5
ncd/modules/parse.c

@@ -84,10 +84,10 @@ struct ipv6_cidr_instance {
     struct ipv6_ifaddr ifaddr;
 };
 
-enum {STRING_SUCCEEDED, STRING_ADDR, STRING_PREFIX};
+enum {STRING_ADDR, STRING_PREFIX};
 
 static struct NCD_string_request strings[] = {
-    {"succeeded"}, {"addr"}, {"prefix"}, {NULL}
+    {"addr"}, {"prefix"}, {NULL}
 };
 
 typedef int (*parse_func) (NCDModuleInst *i, const char *str, size_t str_len, NCDValMem *mem, NCDValRef *out);
@@ -200,7 +200,7 @@ static int func_getvar2 (void *vo, NCD_string_id_t name, NCDValMem *mem, NCDValR
 {
     struct instance *o = vo;
     
-    if (name == strings[STRING_SUCCEEDED].id) {
+    if (name == NCD_STRING_SUCCEEDED) {
         *out = ncd_make_boolean(mem, o->succeeded, o->i->params->iparams->string_index);
         return 1;
     }
@@ -261,7 +261,7 @@ static int ipv4_cidr_addr_func_getvar2 (void *vo, NCD_string_id_t name, NCDValMe
 {
     struct ipv4_cidr_instance *o = vo;
     
-    if (name == strings[STRING_SUCCEEDED].id) {
+    if (name == NCD_STRING_SUCCEEDED) {
         *out = ncd_make_boolean(mem, o->succeeded, o->i->params->iparams->string_index);
         return 1;
     }
@@ -317,7 +317,7 @@ static int ipv6_cidr_addr_func_getvar2 (void *vo, NCD_string_id_t name, NCDValMe
 {
     struct ipv6_cidr_instance *o = vo;
     
-    if (name == strings[STRING_SUCCEEDED].id) {
+    if (name == NCD_STRING_SUCCEEDED) {
         *out = ncd_make_boolean(mem, o->succeeded, o->i->params->iparams->string_index);
         return 1;
     }

+ 3 - 9
ncd/modules/process_manager.c

@@ -77,6 +77,7 @@
 #include <misc/balloc.h>
 #include <structure/LinkedList1.h>
 #include <ncd/NCDModule.h>
+#include <ncd/static_strings.h>
 #include <ncd/extra/value_utils.h>
 
 #include <generated/blog_channel_ncd_process_manager.h>
@@ -123,12 +124,6 @@ static void process_stop (struct process *p);
 static int process_restart (struct process *p, NCDValMem *mem, NCDValSafeRef name, NCDValSafeRef template_name, NCDValSafeRef args);
 static void instance_free (struct instance *o);
 
-enum {STRING_CALLER};
-
-static struct NCD_string_request strings[] = {
-    {"_caller"}, {NULL}
-};
-
 static struct process * find_process (struct instance *o, NCDValRef name)
 {
     ASSERT(!NCDVal_IsInvalid(name))
@@ -311,7 +306,7 @@ static int process_module_process_func_getspecialobj (NCDModuleProcess *module_p
     struct process *p = UPPER_OBJECT(module_process, struct process, module_process);
     ASSERT(p->state != PROCESS_STATE_RETRYING)
     
-    if (name == strings[STRING_CALLER].id) {
+    if (name == NCD_STRING_CALLER) {
         *out_object = NCDObject_Build(-1, p, NCDObject_no_getvar, process_module_process_caller_obj_func_getobj);
         return 1;
     }
@@ -546,6 +541,5 @@ static struct NCDModule modules[] = {
 };
 
 const struct NCDModuleGroup ncdmodule_process_manager = {
-    .modules = modules,
-    .strings = strings
+    .modules = modules
 };

+ 6 - 5
ncd/modules/socket.c

@@ -143,6 +143,7 @@
 #include <system/BConnection.h>
 #include <system/BConnectionGeneric.h>
 #include <ncd/NCDModule.h>
+#include <ncd/static_strings.h>
 #include <ncd/extra/value_utils.h>
 #include <ncd/extra/address_utils.h>
 #include <ncd/extra/NCDBuf.h>
@@ -210,10 +211,10 @@ struct listen_instance {
     LinkedList0 clients_list;
 };
 
-enum {STRING_IS_ERROR, STRING_NOT_EOF, STRING_SOCKET, STRING_SYS_SOCKET, STRING_CLIENT_ADDR};
+enum {STRING_SOCKET, STRING_SYS_SOCKET, STRING_CLIENT_ADDR};
 
 static struct NCD_string_request strings[] = {
-    {"is_error"}, {"not_eof"}, {"_socket"}, {"sys.socket"}, {"client_addr"}, {NULL}
+    {"_socket"}, {"sys.socket"}, {"client_addr"}, {NULL}
 };
 
 static int parse_options (NCDModuleInst *i, NCDValRef options, size_t *out_read_size);
@@ -697,7 +698,7 @@ static int connect_func_getvar (void *vo, NCD_string_id_t name, NCDValMem *mem,
     ASSERT(o->type == CONNECTION_TYPE_CONNECT)
     ASSERT(o->state != CONNECTION_STATE_CONNECTING)
     
-    if (name == strings[STRING_IS_ERROR].id) {
+    if (name == NCD_STRING_IS_ERROR) {
         int is_error = (o->state == CONNECTION_STATE_ERROR);
         *out = ncd_make_boolean(mem, is_error, o->connect.i->params->iparams->string_index);
         return 1;
@@ -790,7 +791,7 @@ static int read_func_getvar (void *vo, NCD_string_id_t name, NCDValMem *mem, NCD
         return 1;
     }
     
-    if (name == strings[STRING_NOT_EOF].id) {
+    if (name == NCD_STRING_NOT_EOF) {
         *out = ncd_make_boolean(mem, (o->read_size != 0), o->i->params->iparams->string_index);
         return 1;
     }
@@ -997,7 +998,7 @@ static int listen_func_getvar (void *vo, NCD_string_id_t name, NCDValMem *mem, N
 {
     struct listen_instance *o = vo;
     
-    if (name == strings[STRING_IS_ERROR].id) {
+    if (name == NCD_STRING_IS_ERROR) {
         *out = ncd_make_boolean(mem, o->have_error, o->i->params->iparams->string_index);
         return 1;
     }

+ 3 - 9
ncd/modules/spawn.c

@@ -58,6 +58,7 @@
 #include <misc/debug.h>
 #include <structure/LinkedList0.h>
 #include <ncd/NCDModule.h>
+#include <ncd/static_strings.h>
 
 #include <generated/blog_channel_ncd_spawn.h>
 
@@ -93,12 +94,6 @@ static void continue_working (struct instance *o);
 static void continue_terminating (struct instance *o);
 static void instance_free (struct instance *o);
 
-enum {STRING_CALLER};
-
-static struct NCD_string_request strings[] = {
-    {"_caller"}, {NULL}
-};
-
 static void assert_dirty_state (struct instance *o)
 {
     ASSERT(!LinkedList0_IsEmpty(&o->dirty_list) == (o->state == STATE_WAITING || o->state == STATE_WAITING_TERMINATING))
@@ -160,7 +155,7 @@ static int process_func_getspecialobj (NCDModuleProcess *process, NCD_string_id_
 {
     struct instance *o = UPPER_OBJECT(process, struct instance, process);
     
-    if (name == strings[STRING_CALLER].id) {
+    if (name == NCD_STRING_CALLER) {
         *out_object = NCDObject_Build(-1, o, NCDObject_no_getvar, caller_obj_func_getobj);
         return 1;
     }
@@ -411,6 +406,5 @@ static struct NCDModule modules[] = {
 };
 
 const struct NCDModuleGroup ncdmodule_spawn = {
-    .modules = modules,
-    .strings = strings
+    .modules = modules
 };

+ 5 - 5
ncd/modules/sys_evdev.c

@@ -58,9 +58,9 @@
 
 #include <misc/nonblocking.h>
 #include <misc/debug.h>
-#include <ncd/extra/value_utils.h>
-
 #include <ncd/NCDModule.h>
+#include <ncd/static_strings.h>
+#include <ncd/extra/value_utils.h>
 
 #include <generated/blog_channel_ncd_sys_evdev.h>
 
@@ -78,10 +78,10 @@ struct instance {
 
 static void instance_free (struct instance *o, int is_error);
 
-enum {STRING_TYPE, STRING_VALUE, STRING_CODE_NUMERIC, STRING_CODE};
+enum {STRING_VALUE, STRING_CODE_NUMERIC, STRING_CODE};
 
 static struct NCD_string_request strings[] = {
-    {"type"}, {"value"}, {"code_numeric"}, {"code"}, {NULL}
+    {"value"}, {"code_numeric"}, {"code"}, {NULL}
 };
 
 #define MAKE_LOOKUP_FUNC(_name_) \
@@ -234,7 +234,7 @@ static int func_getvar2 (void *vo, NCD_string_id_t name, NCDValMem *mem, NCDValR
     struct instance *o = vo;
     ASSERT(o->processing)
     
-    if (name == strings[STRING_TYPE].id) {
+    if (name == NCD_STRING_TYPE) {
         *out = NCDVal_NewString(mem, evdev_type_to_str(o->event.type));
         return 1;
     }

+ 4 - 3
ncd/modules/sys_request_client.c

@@ -88,6 +88,7 @@
 #include <structure/LinkedList0.h>
 #include <structure/LinkedList1.h>
 #include <ncd/NCDModule.h>
+#include <ncd/static_strings.h>
 #include <ncd/extra/NCDRequestClient.h>
 #include <ncd/extra/value_utils.h>
 #include <ncd/extra/address_utils.h>
@@ -161,10 +162,10 @@ static int request_init_finished_process (struct request_instance *o);
 static void instance_free (struct instance *o, int with_error);
 static void request_instance_free (struct request_instance *o, int with_error);
 
-enum {STRING_CALLER, STRING_REPLY, STRING_DATA};
+enum {STRING_REPLY, STRING_DATA};
 
 static struct NCD_string_request strings[] = {
-    {"_caller"}, {"_reply"}, {"data"}, {NULL}
+    {"_reply"}, {"data"}, {NULL}
 };
 
 static void client_handler_error (struct instance *o)
@@ -322,7 +323,7 @@ static int request_process_func_getspecialobj (NCDModuleProcess *process, NCD_st
     struct request_instance *o = UPPER_OBJECT(process, struct request_instance, process);
     ASSERT(o->pstate != RPSTATE_NONE)
     
-    if (name == strings[STRING_CALLER].id) {
+    if (name == NCD_STRING_CALLER) {
         *out_object = NCDObject_Build(-1, o, NCDObject_no_getvar, request_process_caller_obj_func_getobj);
         return 1;
     }

+ 7 - 13
ncd/modules/sys_start_process.c

@@ -128,6 +128,7 @@
 #include <system/BProcess.h>
 #include <system/BConnection.h>
 #include <ncd/NCDModule.h>
+#include <ncd/static_strings.h>
 #include <ncd/extra/NCDBuf.h>
 #include <ncd/extra/value_utils.h>
 #include <ncd/extra/build_cmdline.h>
@@ -201,12 +202,6 @@ struct write_instance {
     size_t length;
 };
 
-enum {STRING_IS_ERROR, STRING_EXIT_STATUS, STRING_NOT_EOF};
-
-static struct NCD_string_request strings[] = {
-    {"is_error"}, {"exit_status"}, {"not_eof"}, {NULL}
-};
-
 static int parse_mode (NCDModuleInst *i, NCDValRef mode_arg, int *out_read, int *out_write)
 {
     if (!NCDVal_IsString(mode_arg)) {
@@ -439,7 +434,7 @@ static int process_func_getvar (void *vo, NCD_string_id_t name, NCDValMem *mem,
 {
     struct process_instance *o = vo;
     
-    if (name == strings[STRING_IS_ERROR].id) {
+    if (name == NCD_STRING_IS_ERROR) {
         int is_error = (o->state == PROCESS_STATE_ERROR);
         *out = ncd_make_boolean(mem, is_error, o->i->params->iparams->string_index);
         return 1;
@@ -505,7 +500,7 @@ static int wait_func_getvar (void *vo, NCD_string_id_t name, NCDValMem *mem, NCD
     struct wait_instance *o = vo;
     ASSERT(!o->pinst)
     
-    if (name == strings[STRING_EXIT_STATUS].id) {
+    if (name == NCD_STRING_EXIT_STATUS) {
         if (o->exit_status == -1) {
             *out = NCDVal_NewString(mem, "-1");
         } else {
@@ -708,7 +703,7 @@ static int read_pipe_func_getvar (void *vo, NCD_string_id_t name, NCDValMem *mem
 {
     struct read_pipe_instance *o = vo;
     
-    if (name == strings[STRING_IS_ERROR].id) {
+    if (name == NCD_STRING_IS_ERROR) {
         int is_error = (o->state == READER_STATE_ERROR);
         *out = ncd_make_boolean(mem, is_error, o->i->params->iparams->string_index);
         return 1;
@@ -816,7 +811,7 @@ static int read_func_getvar (void *vo, NCD_string_id_t name, NCDValMem *mem, NCD
         return 1;
     }
     
-    if (name == strings[STRING_NOT_EOF].id) {
+    if (name == NCD_STRING_NOT_EOF) {
         int not_eof = (o->read_size > 0);
         *out = ncd_make_boolean(mem, not_eof, o->i->params->iparams->string_index);
         return 1;
@@ -972,7 +967,7 @@ static int write_pipe_func_getvar (void *vo, NCD_string_id_t name, NCDValMem *me
 {
     struct write_pipe_instance *o = vo;
     
-    if (name == strings[STRING_IS_ERROR].id) {
+    if (name == NCD_STRING_IS_ERROR) {
         int is_error = (o->state == WRITER_STATE_ERROR);
         *out = ncd_make_boolean(mem, is_error, o->i->params->iparams->string_index);
         return 1;
@@ -1153,6 +1148,5 @@ static struct NCDModule modules[] = {
 };
 
 const struct NCDModuleGroup ncdmodule_sys_start_process = {
-    .modules = modules,
-    .strings = strings
+    .modules = modules
 };

+ 5 - 4
ncd/modules/try.c

@@ -61,6 +61,7 @@
 
 #include <misc/offset.h>
 #include <ncd/NCDModule.h>
+#include <ncd/static_strings.h>
 #include <ncd/extra/value_utils.h>
 
 #include <generated/blog_channel_ncd_try.h>
@@ -85,10 +86,10 @@ static int process_caller_object_func_getobj (const NCDObject *obj, NCD_string_i
 static void start_terminating (struct instance *o);
 static void instance_free (struct instance *o);
 
-enum {STRING_CALLER, STRING_TRY, STRING_TRY_TRY, STRING_SUCCEEDED};
+enum {STRING_TRY, STRING_TRY_TRY};
 
 static struct NCD_string_request strings[] = {
-    {"_caller"}, {"_try"}, {"try.try"}, {"succeeded"}, {NULL}
+    {"_try"}, {"try.try"}, {NULL}
 };
 
 static void process_handler_event (NCDModuleProcess *process, int event)
@@ -136,7 +137,7 @@ static int process_func_getspecialobj (NCDModuleProcess *process, NCD_string_id_
     struct instance *o = UPPER_OBJECT(process, struct instance, process);
     ASSERT(o->state == STATE_INIT || o->state == STATE_DEINIT)
     
-    if (name == strings[STRING_CALLER].id) {
+    if (name == NCD_STRING_CALLER) {
         *out_object = NCDObject_Build(-1, o, NCDObject_no_getvar, process_caller_object_func_getobj);
         return 1;
     }
@@ -235,7 +236,7 @@ static int func_getvar2 (void *vo, NCD_string_id_t name, NCDValMem *mem, NCDValR
     ASSERT(o->state == STATE_FINISHED)
     ASSERT(!o->dying)
     
-    if (name == strings[STRING_SUCCEEDED].id) {
+    if (name == NCD_STRING_SUCCEEDED) {
         *out = ncd_make_boolean(mem, o->succeeded, o->i->params->iparams->string_index);
         return 1;
     }

+ 5 - 5
ncd/modules/value.c

@@ -254,10 +254,10 @@ static void valref_free (struct valref *r);
 static struct value * valref_val (struct valref *r);
 static void valref_break (struct valref *r);
 
-enum {STRING_EXISTS, STRING_TYPE, STRING_LENGTH, STRING_KEYS};
+enum {STRING_EXISTS, STRING_KEYS};
 
 static struct NCD_string_request strings[] = {
-    {"exists"}, {"type"}, {"length"}, {"keys"}, {NULL}
+    {"exists"}, {"keys"}, {NULL}
 };
 
 #include "value_maptree.h"
@@ -1110,7 +1110,7 @@ static int func_getvar2 (void *vo, NCD_string_id_t name, NCDValMem *mem, NCDValR
         return 1;
     }
     
-    if (name != strings[STRING_TYPE].id && name != strings[STRING_LENGTH].id &&
+    if (name != NCD_STRING_TYPE && name != NCD_STRING_LENGTH &&
         name != strings[STRING_KEYS].id && name != NCD_STRING_EMPTY) {
         return 0;
     }
@@ -1120,10 +1120,10 @@ static int func_getvar2 (void *vo, NCD_string_id_t name, NCDValMem *mem, NCDValR
         return 0;
     }
     
-    if (name == strings[STRING_TYPE].id) {
+    if (name == NCD_STRING_TYPE) {
         *out = NCDVal_NewString(mem, get_type_str(v->type));
     }
-    else if (name == strings[STRING_LENGTH].id) {
+    else if (name == NCD_STRING_LENGTH) {
         size_t len = 0; // to remove warning
         switch (v->type) {
             case NCDVAL_LIST: