Exemplo n.º 1
0
void FakeAudio::_js_register(JSContext* cx, JSObject* global)
{
	// create the class
	FakeAudio::js_class = {
		"FakeAudio", JSCLASS_HAS_PRIVATE,
		JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_StrictPropertyStub,
		JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, basic_object_finalize,
		JSCLASS_NO_OPTIONAL_MEMBERS
	};
	static JSPropertySpec props[] = {
		JS_BINDED_PROP_DEF_ACCESSOR(FakeAudio, autoplay),
		JS_BINDED_PROP_DEF_ACCESSOR(FakeAudio, loop),
		JS_BINDED_PROP_DEF_ACCESSOR(FakeAudio, preload),
		JS_BINDED_PROP_DEF_ACCESSOR(FakeAudio, muted),
		JS_BINDED_PROP_DEF_ACCESSOR(FakeAudio, src),
		JS_BINDED_PROP_DEF_ACCESSOR(FakeAudio, currentTime),
		JS_BINDED_PROP_DEF_ACCESSOR(FakeAudio, volume),
		JS_BINDED_PROP_DEF_GETTER(FakeAudio, played),
		JS_BINDED_PROP_DEF_GETTER(FakeAudio, ended),
		JS_BINDED_PROP_DEF_GETTER(FakeAudio, duration),
		JS_BINDED_PROP_DEF_GETTER(FakeAudio, currentSrc),
		JS_BINDED_PROP_DEF_GETTER(FakeAudio, readyState),
		{0, 0, 0, 0, 0}
	};
	static JSFunctionSpec funcs[] = {
		JS_BINDED_FUNC_FOR_DEF(FakeAudio, canPlayType),
		JS_BINDED_FUNC_FOR_DEF(FakeAudio, load),
		JS_BINDED_FUNC_FOR_DEF(FakeAudio, play),
		JS_BINDED_FUNC_FOR_DEF(FakeAudio, pause),
		JS_BINDED_FUNC_FOR_DEF(FakeAudio, addEventListener),
		JS_FS_END
	};
	FakeAudio::js_parent = NULL;
	FakeAudio::js_proto = JS_InitClass(cx, global, NULL, &FakeAudio::js_class, FakeAudio::_js_constructor, 1, props, funcs, NULL, NULL);
}
Exemplo n.º 2
0
void FakeCanvas::_js_register(JSContext* cx, JSObject* global)
{
	// create the class
	FakeCanvas::js_class = {
		"FakeCanvas", JSCLASS_HAS_PRIVATE,
		JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_StrictPropertyStub,
		JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, basic_object_finalize,
		JSCLASS_NO_OPTIONAL_MEMBERS
	};
	static JSPropertySpec props[] = {
		JS_BINDED_PROP_DEF_GETTER(FakeCanvas, clientWidth),
		JS_BINDED_PROP_DEF_GETTER(FakeCanvas, clientHeight),
		JS_BINDED_PROP_DEF_ACCESSOR(FakeCanvas, width),
		JS_BINDED_PROP_DEF_ACCESSOR(FakeCanvas, height),
		{0, 0, 0, 0, 0}
	};
	static JSFunctionSpec funcs[] = {
		JS_BINDED_FUNC_FOR_DEF(FakeCanvas, getContext),
		JS_BINDED_FUNC_FOR_DEF(FakeCanvas, getBoundingClientRect),
		JS_BINDED_FUNC_FOR_DEF(FakeCanvas, addEventListener),
		JS_FS_END
	};
	FakeCanvas::js_parent = NULL;
	FakeCanvas::js_proto = JS_InitClass(cx, global, NULL, &FakeCanvas::js_class, FakeCanvas::_js_constructor, 1, props, funcs, NULL, NULL);
}