/** * 複製 */ int map_dup(Value *vret, Value *v, RefNode *node) { RefMap *src = Value_vp(*v); RefNode *type = FUNC_VP(node); int i; int max = src->entry_num; RefMap *dst = buf_new(type, sizeof(RefMap)); *vret = vp_Value(dst); dst->count = src->count; dst->entry_num = max; dst->entry = malloc(sizeof(HashValueEntry*) * max); for (i = 0; i < max; i++) { HashValueEntry *hsrc = src->entry[i]; HashValueEntry **hdst = &dst->entry[i]; for (; hsrc != NULL; hsrc = hsrc->next) { HashValueEntry *he = malloc(sizeof(HashValueEntry)); he->key = Value_cp(hsrc->key); he->val = Value_cp(hsrc->val); he->hash = hsrc->hash; *hdst = he; hdst = &he->next; } *hdst = NULL; } return TRUE; }
static int markdown_new(Value *vret, Value *v, RefNode *node) { RefNode *cls_markdown = FUNC_VP(node); Ref *ref; Markdown *md; RefNode *type = fs->Value_type(*v); // 継承可能なクラス if (type == fs->cls_fn) { ref = fs->ref_new(cls_markdown); *vret = vp_Value(ref); } else { ref = Value_vp(*v); *vret = fs->Value_cp(*v); } md = malloc(sizeof(Markdown)); memset(md, 0, sizeof(Markdown)); ref->v[INDEX_MARKDOWN_MD] = ptr_Value(md); fs->Mem_init(&md->mem, 1024); md->tabstop = 4; md->heading_level = 1; md->footnote_id = 1; md->heading_p = &md->heading; md->footnote_p = &md->footnote; fs->Hash_init(&md->hilight, &md->mem, 16); return TRUE; }
static int applescript_new(Value *vret, Value *v, RefNode *node) { RefNode *cls_as = FUNC_VP(node); RefAppleScript *r = fs->buf_new(cls_as, sizeof(RefAppleScript)); const char *src = Value_cstr(v[1]); *vret = vp_Value(r); if (!apple_script_new_sub(r, src)) { return FALSE; } return TRUE; }