add pic_dict_new

This commit is contained in:
Yuichi Nishiwaki 2014-07-13 10:58:13 +09:00
parent 03bffef748
commit 82de3cfe2f
2 changed files with 14 additions and 3 deletions

View File

@ -17,6 +17,8 @@ struct pic_dict {
#define pic_dict_p(v) (pic_type(v) == PIC_TT_DICT)
#define pic_dict_ptr(v) ((struct pic_dict *)pic_ptr(v))
struct pic_dict *pic_dict_new(pic_state *);
#if defined(__cplusplus)
}
#endif

View File

@ -5,6 +5,17 @@
#include "picrin.h"
#include "picrin/dict.h"
struct pic_dict *
pic_dict_new(pic_state *pic)
{
struct pic_dict *dict;
dict = (struct pic_dict *)pic_obj_alloc(pic, sizeof(struct pic_dict), PIC_TT_DICT);
xh_init_int(&dict->hash, sizeof(pic_value));
return dict;
}
static pic_value
pic_dict_dict(pic_state *pic)
{
@ -12,9 +23,7 @@ pic_dict_dict(pic_state *pic)
pic_get_args(pic, "");
dict = (struct pic_dict *)pic_obj_alloc(pic, sizeof(struct pic_dict), PIC_TT_DICT);
xh_init_int(&dict->hash, sizeof(pic_value));
dict = pic_dict_new(pic);
return pic_obj_value(dict);
}