mirror of
https://github.com/love2d/love.git
synced 2026-08-16 08:11:02 +02:00
Build type information on first use (load-time), instead of using a hardcoded list
--HG-- branch : dynamiccore2
This commit is contained in:
@@ -27,6 +27,8 @@ namespace love
|
||||
namespace video
|
||||
{
|
||||
|
||||
love::Type VideoStream::type(&Stream::type);
|
||||
|
||||
void VideoStream::setSync(VideoStream::FrameSync *frameSync)
|
||||
{
|
||||
this->frameSync = frameSync;
|
||||
|
||||
@@ -34,6 +34,9 @@ namespace video
|
||||
class VideoStream : public Stream
|
||||
{
|
||||
public:
|
||||
|
||||
static love::Type type;
|
||||
|
||||
virtual ~VideoStream() {}
|
||||
|
||||
virtual int getWidth() const = 0;
|
||||
|
||||
@@ -45,7 +45,7 @@ int w_newVideoStream(lua_State *L)
|
||||
stream = instance()->newVideoStream(file);
|
||||
});
|
||||
|
||||
luax_pushtype(L, VIDEO_VIDEO_STREAM_ID, stream);
|
||||
luax_pushtype(L, VideoStream::type, stream);
|
||||
stream->release();
|
||||
return 1;
|
||||
}
|
||||
@@ -75,7 +75,7 @@ extern "C" int luaopen_love_video(lua_State *L)
|
||||
WrappedModule w;
|
||||
w.module = instance;
|
||||
w.name = "video";
|
||||
w.type = MODULE_ID;
|
||||
w.type = &Module::type;
|
||||
w.functions = functions;
|
||||
w.types = types;
|
||||
|
||||
|
||||
@@ -27,23 +27,23 @@ namespace video
|
||||
|
||||
VideoStream *luax_checkvideostream(lua_State *L, int idx)
|
||||
{
|
||||
return luax_checktype<VideoStream>(L, idx, VIDEO_VIDEO_STREAM_ID);
|
||||
return luax_checktype<VideoStream>(L, idx, VideoStream::type);
|
||||
}
|
||||
|
||||
int w_VideoStream_setSync(lua_State *L)
|
||||
{
|
||||
auto stream = luax_checkvideostream(L, 1);
|
||||
|
||||
if (luax_istype(L, 2, AUDIO_SOURCE_ID))
|
||||
if (luax_istype(L, 2, love::audio::Source::type))
|
||||
{
|
||||
auto src = luax_totype<love::audio::Source>(L, 2, AUDIO_SOURCE_ID);
|
||||
auto src = luax_totype<love::audio::Source>(L, 2, love::audio::Source::type);
|
||||
auto sync = new VideoStream::SourceSync(src);
|
||||
stream->setSync(sync);
|
||||
sync->release();
|
||||
}
|
||||
else if (luax_istype(L, 2, VIDEO_VIDEO_STREAM_ID))
|
||||
else if (luax_istype(L, 2, VideoStream::type))
|
||||
{
|
||||
auto other = luax_totype<VideoStream>(L, 2, VIDEO_VIDEO_STREAM_ID);
|
||||
auto other = luax_totype<VideoStream>(L, 2, VideoStream::type);
|
||||
stream->setSync(other->getSync());
|
||||
}
|
||||
else if (lua_isnoneornil(L, 2))
|
||||
@@ -124,7 +124,7 @@ static const luaL_Reg videostream_functions[] =
|
||||
|
||||
int luaopen_videostream(lua_State *L)
|
||||
{
|
||||
return luax_register_type(L, VIDEO_VIDEO_STREAM_ID, "VideoStream", videostream_functions, nullptr);
|
||||
return luax_register_type(L, VideoStream::type, "VideoStream", videostream_functions, nullptr);
|
||||
}
|
||||
|
||||
} // video
|
||||
|
||||
Reference in New Issue
Block a user