static int syck_dump(lua_State *L) { SyckEmitter *emitter; struct emitter_xtra *bonus; emitter = syck_new_emitter(); emitter->bonus = S_ALLOC_N(struct emitter_xtra, 1); bonus = (struct emitter_xtra *)emitter->bonus; bonus->L = lua_newthread(L); luaL_buffinit(L, &bonus->output); syck_emitter_handler(emitter, lua_syck_emitter_handler); syck_output_handler(emitter, lua_syck_output_handler); lua_pushvalue(L, -2); lua_xmove(L, bonus->L, 1); bonus->id = 1; lua_syck_mark_emitter(emitter, bonus->id); bonus->id = 1; syck_emit(emitter, (st_data_t)((long)bonus->id)); syck_emitter_flush(emitter, 0); luaL_pushresult(&bonus->output); syck_free_emitter(emitter); return 1; }
static JSBool syck_dump(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) { SyckEmitter *emitter = syck_new_emitter(); struct emitter_xtra * bonus = xcalloc(1, sizeof(*bonus)); JSBool ok = JS_FALSE; if (_debug) fprintf(stderr, "==> %s(%p,%p,%p[%u],%p)\n", __FUNCTION__, cx, obj, argv, (unsigned)argc, rval); #ifdef NOTYET ok = JS_ConvertArguments(cx, argc, argv, "", &version, &syck_ns_str, &data); #endif if (!ok) goto exit; bonus->iob = rpmiobNew(0); #ifdef NOTYET bonus->L = lua_newthread(L); luaL_buffinit(L, &bonus->output); #endif emitter->bonus = bonus; syck_emitter_handler(emitter, js_syck_emitter_handler); syck_output_handler(emitter, js_syck_output_handler); #ifdef NOTYET lua_pushvalue(L, -2); lua_xmove(L, bonus->L, 1); #endif bonus->id = 1; js_syck_mark_emitter(emitter, bonus->id); bonus->id = 1; syck_emit(emitter, (st_data_t)((long)bonus->id)); syck_emitter_flush(emitter, 0); #ifdef NOTYET luaL_pushresult(&bonus->output); #endif ok = JS_TRUE; exit: bonus->iob = rpmiobFree(bonus->iob); syck_free_emitter(emitter); return ok; }
int main(int argc, char *argv[]) { SyckEmitter *e; int k; e = syck_new_emitter(); syck_emitter_handler(e, emitter_handler); syck_output_handler(e, output_handler); for (k = 1; k < LENGTH; k++) { syck_emitter_mark_node(e, k); } syck_emit(e, 1); syck_emitter_flush(e, 0); syck_free_emitter(e); }