change return type of pic_str_new to struct pic_string *
This commit is contained in:
parent
ca66291d93
commit
6ac3055816
|
@ -102,8 +102,8 @@ void pic_defun(pic_state *, const char *, pic_func_t);
|
|||
pic_sym pic_intern_cstr(pic_state *, const char *);
|
||||
const char *pic_symbol_name(pic_state *, pic_sym);
|
||||
|
||||
pic_value pic_str_new(pic_state *, const char *, size_t);
|
||||
pic_value pic_str_new_cstr(pic_state *, const char *);
|
||||
struct pic_string *pic_str_new(pic_state *, const char *, size_t);
|
||||
struct pic_string *pic_str_new_cstr(pic_state *, const char *);
|
||||
|
||||
struct pic_vector *pic_vec_new(pic_state *, size_t);
|
||||
struct pic_vector *pic_vec_new_from_list(pic_state *, pic_value);
|
||||
|
|
|
@ -154,7 +154,7 @@ pic_error_error_object_message(pic_state *pic)
|
|||
|
||||
pic_get_args(pic, "e", &e);
|
||||
|
||||
return pic_str_new_cstr(pic, e->msg);
|
||||
return pic_obj_value(pic_str_new_cstr(pic, e->msg));
|
||||
}
|
||||
|
||||
static pic_value
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
#include "picrin.h"
|
||||
|
||||
pic_value
|
||||
struct pic_string *
|
||||
pic_str_new(pic_state *pic, const char *cstr, size_t len)
|
||||
{
|
||||
struct pic_string *str;
|
||||
|
@ -10,11 +10,10 @@ pic_str_new(pic_state *pic, const char *cstr, size_t len)
|
|||
str = (struct pic_string *)pic_obj_alloc(pic, sizeof(struct pic_string), PIC_TT_STRING);
|
||||
str->len = len;
|
||||
str->str = strdup(cstr);
|
||||
|
||||
return pic_obj_value(str);
|
||||
return str;
|
||||
}
|
||||
|
||||
pic_value
|
||||
struct pic_string *
|
||||
pic_str_new_cstr(pic_state *pic, const char *cstr)
|
||||
{
|
||||
size_t len;
|
||||
|
|
|
@ -52,7 +52,7 @@ pic_symbol_symbol_to_string(pic_state *pic)
|
|||
pic_error(pic, "symbol->string: expected symbol");
|
||||
}
|
||||
|
||||
return pic_str_new_cstr(pic, pic_symbol_name(pic, pic_sym(v)));
|
||||
return pic_obj_value(pic_str_new_cstr(pic, pic_symbol_name(pic, pic_sym(v))));
|
||||
}
|
||||
|
||||
static pic_value
|
||||
|
|
|
@ -14,7 +14,7 @@ pic_system_cmdline(pic_state *pic)
|
|||
for (i = 0; i < pic->argc; ++i) {
|
||||
int ai = pic_gc_arena_preserve(pic);
|
||||
|
||||
v = pic_cons(pic, pic_str_new_cstr(pic, pic->argv[i]), v);
|
||||
v = pic_cons(pic, pic_obj_value(pic_str_new_cstr(pic, pic->argv[i])), v);
|
||||
pic_gc_arena_restore(pic, ai);
|
||||
}
|
||||
|
||||
|
@ -80,7 +80,7 @@ pic_system_getenv(pic_state *pic)
|
|||
if (val == NULL)
|
||||
return pic_nil_value();
|
||||
else
|
||||
return pic_str_new_cstr(pic, val);
|
||||
return pic_obj_value(pic_str_new_cstr(pic, val));
|
||||
}
|
||||
|
||||
static pic_value
|
||||
|
@ -99,8 +99,8 @@ pic_system_getenvs(pic_state *pic)
|
|||
for (i = 0; (*envp)[i] != '='; ++i)
|
||||
;
|
||||
|
||||
key = pic_str_new(pic, *envp, i);
|
||||
val = pic_str_new_cstr(pic, getenv(*envp));
|
||||
key = pic_obj_value(pic_str_new(pic, *envp, i));
|
||||
val = pic_obj_value(pic_str_new_cstr(pic, getenv(*envp)));
|
||||
|
||||
/* push */
|
||||
data = pic_acons(pic, key, val, data);
|
||||
|
|
Loading…
Reference in New Issue