Esempio n. 1
0
pdf_jsimp_type *pdf_jsimp_new_type(pdf_jsimp *imp, pdf_jsimp_dtr *dtr, char *name)
{
	js_State *J = imp->J;
	js_newobject(J);
	js_setregistry(J, name);
	return (pdf_jsimp_type*)name;
}
Esempio n. 2
0
pdf_jsimp *pdf_new_jsimp(fz_context *ctx, void *jsctx)
{
	js_State *J;
	pdf_jsimp *imp;

	J = js_newstate(alloc, ctx);

	js_pushnull(J); /* prototype for jsctx userdata object */
	js_newuserdata(J, "jsctx", jsctx); /* create jsctx userdata object */
	js_setregistry(J, "jsctx"); /* hide it in the registry */

	imp = fz_malloc_struct(ctx, pdf_jsimp);
	imp->ctx = ctx;
	imp->jsctx = jsctx;
	imp->J = J;
	return imp;
}
Esempio n. 3
0
const char *js_ref(js_State *J)
{
	js_Value *v = stackidx(J, -1);
	const char *s;
	char buf[32];
	switch (v->type) {
	case JS_TUNDEFINED: s = "_Undefined"; break;
	case JS_TNULL: s = "_Null"; break;
	case JS_TBOOLEAN:
		s = v->u.boolean ? "_True" : "_False";
		break;
	case JS_TOBJECT:
		sprintf(buf, "%p", (void*)v->u.object);
		s = js_intern(J, buf);
		break;
	default:
		sprintf(buf, "%d", J->nextref++);
		s = js_intern(J, buf);
		break;
	}
	js_setregistry(J, s);
	return s;
}