mirror of
https://github.com/love2d/love.git
synced 2026-08-18 19:54:22 +02:00
Added many comments, and changed function names for wrapper functions.
This commit is contained in:
@@ -55,7 +55,7 @@ namespace sound
|
||||
/**
|
||||
* 16 bit audio is the default.
|
||||
**/
|
||||
static const int DEFAULT_BITS = 16;
|
||||
static const int DEFAULT_T = 16;
|
||||
|
||||
/**
|
||||
* Creates a deep of itself. The sound stream can (and should) be
|
||||
|
||||
@@ -26,41 +26,40 @@ namespace sound
|
||||
{
|
||||
Decoder * luax_checkdecoder(lua_State * L, int idx)
|
||||
{
|
||||
return luax_checktype<Decoder>(L, idx, "Decoder", LOVE_SOUND_DECODER_BITS);
|
||||
return luax_checktype<Decoder>(L, idx, "Decoder", SOUND_DECODER_T);
|
||||
}
|
||||
|
||||
int _wrap_Decoder_getChannels(lua_State * L)
|
||||
int w_Decoder_getChannels(lua_State * L)
|
||||
{
|
||||
Decoder * t = luax_checkdecoder(L, 1);
|
||||
lua_pushinteger(L, t->getChannels());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int _wrap_Decoder_getBits(lua_State * L)
|
||||
int w_Decoder_getBits(lua_State * L)
|
||||
{
|
||||
Decoder * t = luax_checkdecoder(L, 1);
|
||||
lua_pushinteger(L, t->getBits());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int _wrap_Decoder_getSampleRate(lua_State * L)
|
||||
int w_Decoder_getSampleRate(lua_State * L)
|
||||
{
|
||||
Decoder * t = luax_checkdecoder(L, 1);
|
||||
lua_pushinteger(L, t->getSampleRate());
|
||||
return 1;
|
||||
}
|
||||
|
||||
static const luaL_Reg wrap_Decoder_functions[] = {
|
||||
{ "getChannels", _wrap_Decoder_getChannels },
|
||||
{ "getBits", _wrap_Decoder_getBits },
|
||||
{ "getSampleRate", _wrap_Decoder_getSampleRate },
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
int wrap_Decoder_open(lua_State * L)
|
||||
int luaopen_decoder(lua_State * L)
|
||||
{
|
||||
luax_register_type(L, "Decoder", wrap_Decoder_functions);
|
||||
return 0;
|
||||
static const luaL_Reg functions[] = {
|
||||
{ "getChannels", w_Decoder_getChannels },
|
||||
{ "getBits", w_Decoder_getBits },
|
||||
{ "getSampleRate", w_Decoder_getSampleRate },
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
return luax_register_type(L, "Decoder", functions);
|
||||
}
|
||||
|
||||
} // sound
|
||||
|
||||
@@ -30,10 +30,10 @@ namespace love
|
||||
namespace sound
|
||||
{
|
||||
Decoder * luax_checkdecoder(lua_State * L, int idx);
|
||||
int _wrap_Decoder_getChannels(lua_State * L);
|
||||
int _wrap_Decoder_getBits(lua_State * L);
|
||||
int _wrap_Decoder_getSampleRate(lua_State * L);
|
||||
int wrap_Decoder_open(lua_State * L);
|
||||
int w_Decoder_getChannels(lua_State * L);
|
||||
int w_Decoder_getBits(lua_State * L);
|
||||
int w_Decoder_getSampleRate(lua_State * L);
|
||||
int luaopen_decoder(lua_State * L);
|
||||
|
||||
} // sound
|
||||
} // love
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace sound
|
||||
{
|
||||
static Sound * instance = 0;
|
||||
|
||||
int _wrap_newSoundData(lua_State * L)
|
||||
int w_newSoundData(lua_State * L)
|
||||
{
|
||||
SoundData * t = 0;
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace sound
|
||||
{
|
||||
int samples = luaL_checkint(L, 1);
|
||||
int sampleRate = luaL_optint(L, 2, Decoder::DEFAULT_SAMPLE_RATE);
|
||||
int bits = luaL_optint(L, 3, Decoder::DEFAULT_BITS);
|
||||
int bits = luaL_optint(L, 3, Decoder::DEFAULT_T);
|
||||
int channels = luaL_optint(L, 4, Decoder::DEFAULT_CHANNELS);
|
||||
|
||||
try
|
||||
@@ -55,9 +55,9 @@ namespace sound
|
||||
{
|
||||
|
||||
// Convert to Decoder, if necessary.
|
||||
if(!luax_istype(L, 1, LOVE_SOUND_DECODER_BITS))
|
||||
if(!luax_istype(L, 1, SOUND_DECODER_T))
|
||||
{
|
||||
_wrap_newDecoder(L);
|
||||
w_newDecoder(L);
|
||||
lua_replace(L, 1);
|
||||
}
|
||||
|
||||
@@ -71,18 +71,18 @@ namespace sound
|
||||
}
|
||||
}
|
||||
|
||||
luax_newtype(L, "SoundData", LOVE_SOUND_SOUND_DATA_BITS, (void*)t);
|
||||
luax_newtype(L, "SoundData", SOUND_SOUND_DATA_T, (void*)t);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int _wrap_newDecoder(lua_State * L)
|
||||
int w_newDecoder(lua_State * L)
|
||||
{
|
||||
// Convert to File, if necessary.
|
||||
if(lua_isstring(L, 1))
|
||||
luax_strtofile(L, 1);
|
||||
luax_convobj(L, 1, "filesystem", "newFile");
|
||||
|
||||
love::filesystem::File * file = luax_checktype<love::filesystem::File>(L, 1, "File", LOVE_FILESYSTEM_FILE_BITS);
|
||||
love::filesystem::File * file = luax_checktype<love::filesystem::File>(L, 1, "File", FILESYSTEM_FILE_T);
|
||||
int bufferSize = luaL_optint(L, 2, Decoder::DEFAULT_BUFFER_SIZE);
|
||||
int sampleRate = luaL_optint(L, 3, Decoder::DEFAULT_SAMPLE_RATE);
|
||||
|
||||
@@ -91,7 +91,7 @@ namespace sound
|
||||
Decoder * t = instance->newDecoder(file, bufferSize, sampleRate);
|
||||
if(t == 0)
|
||||
return luaL_error(L, "Extension \"%s\" not supported.", file->getExtension().c_str());
|
||||
luax_newtype(L, "Decoder", LOVE_SOUND_DECODER_BITS, (void*)t);
|
||||
luax_newtype(L, "Decoder", SOUND_DECODER_T, (void*)t);
|
||||
}
|
||||
catch(love::Exception & e)
|
||||
{
|
||||
@@ -101,21 +101,22 @@ namespace sound
|
||||
return 1;
|
||||
}
|
||||
|
||||
// List of functions to wrap.
|
||||
static const luaL_Reg wrap_Sound_functions[] = {
|
||||
{ "newSoundData", _wrap_newSoundData },
|
||||
{ "newDecoder", _wrap_newDecoder },
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
static const lua_CFunction wrap_Sound_types[] = {
|
||||
wrap_SoundData_open,
|
||||
wrap_Decoder_open,
|
||||
0
|
||||
};
|
||||
|
||||
int wrap_Sound_open(lua_State * L)
|
||||
int luaopen_love_sound(lua_State * L)
|
||||
{
|
||||
// List of functions to wrap.
|
||||
static const luaL_Reg functions[] = {
|
||||
{ "newSoundData", w_newSoundData },
|
||||
{ "newDecoder", w_newDecoder },
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
static const lua_CFunction types[] = {
|
||||
luaopen_sounddata,
|
||||
luaopen_decoder,
|
||||
0
|
||||
};
|
||||
|
||||
|
||||
if(instance == 0)
|
||||
{
|
||||
try
|
||||
@@ -128,15 +129,10 @@ namespace sound
|
||||
}
|
||||
}
|
||||
|
||||
luax_register_gc(L, "love.sound", instance);
|
||||
luax_register_gc(L, instance);
|
||||
|
||||
return luax_register_module(L, wrap_Sound_functions, wrap_Sound_types, 0, "sound");
|
||||
return luax_register_module(L, functions, types, 0, "sound");
|
||||
}
|
||||
|
||||
} // sound
|
||||
} // love
|
||||
|
||||
int luaopen_love_sound(lua_State * L)
|
||||
{
|
||||
return love::sound::wrap_Sound_open(L);
|
||||
}
|
||||
@@ -31,13 +31,11 @@ namespace love
|
||||
{
|
||||
namespace sound
|
||||
{
|
||||
int _wrap_newSoundData(lua_State * L);
|
||||
int _wrap_newDecoder(lua_State * L);
|
||||
int wrap_Sound_open(lua_State * L);
|
||||
int w_newSoundData(lua_State * L);
|
||||
int w_newDecoder(lua_State * L);
|
||||
extern "C" LOVE_EXPORT int luaopen_love_sound(lua_State * L);
|
||||
|
||||
} // sound
|
||||
} // love
|
||||
|
||||
#endif // LOVE_SOUND_WRAP_SOUND_H
|
||||
|
||||
extern "C" LOVE_EXPORT int luaopen_love_sound(lua_State * L);
|
||||
|
||||
@@ -28,31 +28,31 @@ namespace sound
|
||||
{
|
||||
SoundData * luax_checksounddata(lua_State * L, int idx)
|
||||
{
|
||||
return luax_checktype<SoundData>(L, idx, "SoundData", LOVE_SOUND_SOUND_DATA_BITS);
|
||||
return luax_checktype<SoundData>(L, idx, "SoundData", SOUND_SOUND_DATA_T);
|
||||
}
|
||||
|
||||
int _wrap_SoundData_getChannels(lua_State * L)
|
||||
int w_SoundData_getChannels(lua_State * L)
|
||||
{
|
||||
SoundData * t = luax_checksounddata(L, 1);
|
||||
lua_pushinteger(L, t->getChannels());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int _wrap_SoundData_getBits(lua_State * L)
|
||||
int w_SoundData_getBits(lua_State * L)
|
||||
{
|
||||
SoundData * t = luax_checksounddata(L, 1);
|
||||
lua_pushinteger(L, t->getBits());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int _wrap_SoundData_getSampleRate(lua_State * L)
|
||||
int w_SoundData_getSampleRate(lua_State * L)
|
||||
{
|
||||
SoundData * t = luax_checksounddata(L, 1);
|
||||
lua_pushinteger(L, t->getSampleRate());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int _wrap_SoundData_setSample(lua_State * L)
|
||||
int w_SoundData_setSample(lua_State * L)
|
||||
{
|
||||
SoundData * sd = luax_checksounddata(L, 1);
|
||||
int i = (int)lua_tointeger(L, 2);
|
||||
@@ -61,7 +61,7 @@ namespace sound
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _wrap_SoundData_getSample(lua_State * L)
|
||||
int w_SoundData_getSample(lua_State * L)
|
||||
{
|
||||
SoundData * sd = luax_checksounddata(L, 1);
|
||||
int i = (int)lua_tointeger(L, 2);
|
||||
@@ -69,24 +69,25 @@ namespace sound
|
||||
return 1;
|
||||
}
|
||||
|
||||
static const luaL_Reg wrap_SoundData_functions[] = {
|
||||
|
||||
// Data
|
||||
{ "getPointer", _wrap_Data_getPointer },
|
||||
{ "getSize", _wrap_Data_getSize },
|
||||
|
||||
{ "getChannels", _wrap_SoundData_getChannels },
|
||||
{ "getBits", _wrap_SoundData_getBits },
|
||||
{ "getSampleRate", _wrap_SoundData_getSampleRate },
|
||||
{ "setSample", _wrap_SoundData_setSample },
|
||||
{ "getSample", _wrap_SoundData_getSample },
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
int wrap_SoundData_open(lua_State * L)
|
||||
int luaopen_sounddata(lua_State * L)
|
||||
{
|
||||
luax_register_type(L, "SoundData", wrap_SoundData_functions);
|
||||
return 0;
|
||||
static const luaL_Reg functions[] = {
|
||||
|
||||
// Data
|
||||
{ "getPointer", w_Data_getPointer },
|
||||
{ "getSize", w_Data_getSize },
|
||||
|
||||
{ "getChannels", w_SoundData_getChannels },
|
||||
{ "getBits", w_SoundData_getBits },
|
||||
{ "getSampleRate", w_SoundData_getSampleRate },
|
||||
{ "setSample", w_SoundData_setSample },
|
||||
{ "getSample", w_SoundData_getSample },
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
return luax_register_type(L, "SoundData", functions);
|
||||
}
|
||||
|
||||
} // sound
|
||||
|
||||
@@ -30,14 +30,14 @@ namespace love
|
||||
namespace sound
|
||||
{
|
||||
SoundData * luax_checksounddata(lua_State * L, int idx);
|
||||
int _wrap_getPointer(lua_State * L);
|
||||
int _wrap_getSize(lua_State * L);
|
||||
int _wrap_getChannels(lua_State * L);
|
||||
int _wrap_getBits(lua_State * L);
|
||||
int _wrap_getSampleRate(lua_State * L);
|
||||
int _wrap_setSample(lua_State * L);
|
||||
int _wrap_getSample(lua_State * L);
|
||||
int wrap_SoundData_open(lua_State * L);
|
||||
int w_getPointer(lua_State * L);
|
||||
int w_getSize(lua_State * L);
|
||||
int w_getChannels(lua_State * L);
|
||||
int w_getBits(lua_State * L);
|
||||
int w_getSampleRate(lua_State * L);
|
||||
int w_setSample(lua_State * L);
|
||||
int w_getSample(lua_State * L);
|
||||
int luaopen_sounddata(lua_State * L);
|
||||
|
||||
} // sound
|
||||
} // love
|
||||
|
||||
Reference in New Issue
Block a user