X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fyoink;a=blobdiff_plain;f=src%2Fmoof%2Fsound_bindings.cc;fp=src%2Fmoof%2Fsound_bindings.cc;h=9e81aa34a4aa1880f932bcbb373f5419493b8d05;hp=0000000000000000000000000000000000000000;hb=6f1b787a10d8ab1a3117a4b8c004dd2d90599608;hpb=c143f7e806766a73cd69dc6e084e977641019ce6 diff --git a/src/moof/sound_bindings.cc b/src/moof/sound_bindings.cc new file mode 100644 index 0000000..9e81aa3 --- /dev/null +++ b/src/moof/sound_bindings.cc @@ -0,0 +1,112 @@ + +/*] Copyright (c) 2009-2010, Charles McGarvey [************************** +**] All rights reserved. +* +* vi:ts=4 sw=4 tw=75 +* +* Distributable under the terms and conditions of the 2-clause BSD license; +* see the file COPYING for a complete text of the license. +* +**************************************************************************/ + +#include "script.hh" +#include "sound.hh" + + +namespace moof { + + +static int sound_new(script& script) +{ + script::slot name = script[2].require_string("sound name"); + + std::string str; + name.get(str); + + script.push(sound(str)); + return 1; +} + +static int sound_enqueue(script& script) +{ + sound* sound; + script[1].require_object("sound").get(sound); + + std::string name; + script[2].require_string("sound name").get(name); + + sound->enqueue(name); + return 0; +} + +static int sound_play(script& script) +{ + sound* sound; + script[1].require_object("sound").get(sound); + sound->play(); + return 0; +} + +static int sound_stop(script& script) +{ + sound* sound; + script[1].require_object("sound").get(sound); + sound->stop(); + return 0; +} + +static int sound_pause(script& script) +{ + sound* sound; + script[1].require_object("sound").get(sound); + sound->pause(); + return 0; +} + +static int sound_rewind(script& script) +{ + sound* sound; + script[1].require_object("sound").get(sound); + sound->rewind(); + return 0; +} + +static int sound_toggle(script& script) +{ + sound* sound; + script[1].require_object("sound").get(sound); + sound->toggle(); + return 0; +} + +static int sound_is_playing(script& script) +{ + sound* sound; + script[1].require_object("sound").get(sound); + script.push(sound->is_playing()); + return 1; +} + + +void sound::import(script& script, const std::string& nspace) +{ + script.check_stack(4); + + script::slot parent = script.push_table(nspace); + script::slot meta = script.push_class(sound_new); + + meta.set_field("enqueue", sound_enqueue); + meta.set_field("play", sound_play); + meta.set_field("stop", sound_stop); + meta.set_field("pause", sound_pause); + meta.set_field("rewind", sound_rewind); + meta.set_field("toggle", sound_toggle); + meta.set_field("is_playing", sound_is_playing); + + parent.set_field("sound"); + parent.pop(); +} + + +} // namespace moof +