]> Dogcows Code - chaz/yoink/blob - src/moof/sound_bindings.cc
mesh and other random adjustments
[chaz/yoink] / src / moof / sound_bindings.cc
1
2 /*] Copyright (c) 2009-2010, Charles McGarvey [**************************
3 **] All rights reserved.
4 *
5 * vi:ts=4 sw=4 tw=75
6 *
7 * Distributable under the terms and conditions of the 2-clause BSD license;
8 * see the file COPYING for a complete text of the license.
9 *
10 **************************************************************************/
11
12 #include "script.hh"
13 #include "sound.hh"
14
15
16 namespace moof {
17
18
19 static int sound_new(script& script)
20 {
21 script::slot name = script[2].require_string("sound name");
22
23 std::string str;
24 name.get(str);
25
26 script.push(sound(str));
27 return 1;
28 }
29
30 static int sound_enqueue(script& script)
31 {
32 sound* sound;
33 script[1].require_object<moof::sound>("sound").get(sound);
34
35 std::string name;
36 script[2].require_string("sound name").get(name);
37
38 sound->enqueue(name);
39 return 0;
40 }
41
42 static int sound_play(script& script)
43 {
44 sound* sound;
45 script[1].require_object<moof::sound>("sound").get(sound);
46 sound->play();
47 return 0;
48 }
49
50 static int sound_stop(script& script)
51 {
52 sound* sound;
53 script[1].require_object<moof::sound>("sound").get(sound);
54 sound->stop();
55 return 0;
56 }
57
58 static int sound_pause(script& script)
59 {
60 sound* sound;
61 script[1].require_object<moof::sound>("sound").get(sound);
62 sound->pause();
63 return 0;
64 }
65
66 static int sound_rewind(script& script)
67 {
68 sound* sound;
69 script[1].require_object<moof::sound>("sound").get(sound);
70 sound->rewind();
71 return 0;
72 }
73
74 static int sound_toggle(script& script)
75 {
76 sound* sound;
77 script[1].require_object<moof::sound>("sound").get(sound);
78 sound->toggle();
79 return 0;
80 }
81
82 static int sound_is_playing(script& script)
83 {
84 sound* sound;
85 script[1].require_object<moof::sound>("sound").get(sound);
86 script.push(sound->is_playing());
87 return 1;
88 }
89
90
91 void sound::import(script& script, const std::string& nspace)
92 {
93 script.check_stack(4);
94
95 script::slot parent = script.push_table(nspace);
96 script::slot meta = script.push_class<sound>(sound_new);
97
98 meta.set_field("enqueue", sound_enqueue);
99 meta.set_field("play", sound_play);
100 meta.set_field("stop", sound_stop);
101 meta.set_field("pause", sound_pause);
102 meta.set_field("rewind", sound_rewind);
103 meta.set_field("toggle", sound_toggle);
104 meta.set_field("is_playing", sound_is_playing);
105
106 parent.set_field("sound");
107 parent.pop();
108 }
109
110
111 } // namespace moof
112
This page took 0.036292 seconds and 4 git commands to generate.