add pic_dict_new
This commit is contained in:
parent
03bffef748
commit
82de3cfe2f
|
@ -17,6 +17,8 @@ struct pic_dict {
|
||||||
#define pic_dict_p(v) (pic_type(v) == PIC_TT_DICT)
|
#define pic_dict_p(v) (pic_type(v) == PIC_TT_DICT)
|
||||||
#define pic_dict_ptr(v) ((struct pic_dict *)pic_ptr(v))
|
#define pic_dict_ptr(v) ((struct pic_dict *)pic_ptr(v))
|
||||||
|
|
||||||
|
struct pic_dict *pic_dict_new(pic_state *);
|
||||||
|
|
||||||
#if defined(__cplusplus)
|
#if defined(__cplusplus)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
15
src/dict.c
15
src/dict.c
|
@ -5,6 +5,17 @@
|
||||||
#include "picrin.h"
|
#include "picrin.h"
|
||||||
#include "picrin/dict.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
|
static pic_value
|
||||||
pic_dict_dict(pic_state *pic)
|
pic_dict_dict(pic_state *pic)
|
||||||
{
|
{
|
||||||
|
@ -12,9 +23,7 @@ pic_dict_dict(pic_state *pic)
|
||||||
|
|
||||||
pic_get_args(pic, "");
|
pic_get_args(pic, "");
|
||||||
|
|
||||||
dict = (struct pic_dict *)pic_obj_alloc(pic, sizeof(struct pic_dict), PIC_TT_DICT);
|
dict = pic_dict_new(pic);
|
||||||
|
|
||||||
xh_init_int(&dict->hash, sizeof(pic_value));
|
|
||||||
|
|
||||||
return pic_obj_value(dict);
|
return pic_obj_value(dict);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue