add pic_intern_cstr
This commit is contained in:
parent
0fad63f22a
commit
0c382c2bdb
|
@ -13,8 +13,10 @@ void pic_free(pic_state *, void *);
|
||||||
pic_state *pic_open();
|
pic_state *pic_open();
|
||||||
void pic_close(pic_state *);
|
void pic_close(pic_state *);
|
||||||
|
|
||||||
pic_value pic_cons(pic_state *pic, pic_value, pic_value);
|
pic_value pic_cons(pic_state *, pic_value, pic_value);
|
||||||
pic_value pic_car(pic_state *pic, pic_value);
|
pic_value pic_car(pic_state *, pic_value);
|
||||||
pic_value pic_cdr(pic_state *pic, pic_value);
|
pic_value pic_cdr(pic_state *, pic_value);
|
||||||
|
|
||||||
|
pic_value pic_intern_cstr(pic_state *, const char *);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "picrin.h"
|
||||||
|
|
||||||
|
pic_value
|
||||||
|
pic_intern_cstr(pic_state *pic, char *name)
|
||||||
|
{
|
||||||
|
struct pic_symbol *sym;
|
||||||
|
size_t len;
|
||||||
|
|
||||||
|
sym = (struct pic_symbol*)pic_gc_alloc(pic, sizeof(struct pic_symbol), PIC_TT_SYMBOL);
|
||||||
|
|
||||||
|
/* clone name string */
|
||||||
|
len = strlen(name);
|
||||||
|
sym->name = (char *)pic_alloc(pic, len + 1);
|
||||||
|
strncpy(sym->name, name, len + 1);
|
||||||
|
|
||||||
|
return pic_obj_value(sym);
|
||||||
|
}
|
Loading…
Reference in New Issue