Alex Szpakowski avatar Alex Szpakowski committed aee4f2c

Added Source:getType

Comments (0)

Files changed (4)

src/modules/audio/Source.cpp

 {
 }
 
+Source::Type Source::getType() const
+{
+	return type;
+}
+
 bool Source::getConstant(const char *in, Type &out)
 {
 	return types.find(in, out);

src/modules/audio/Source.h

 	virtual void setMaxDistance(float distance) = 0;
 	virtual float getMaxDistance() const = 0;
 
+	virtual Type getType() const;
+
 	static bool getConstant(const char *in, Type &out);
 	static bool getConstant(Type in, const char  *&out);
 	static bool getConstant(const char *in, Unit &out);

src/modules/audio/wrap_Source.cpp

 	return 1;
 }
 
+int w_Source_getType(lua_State *L)
+{
+	Source *t = luax_checksource(L, 1);
+	Source::Type stype = t->getType();
+	const char *typestr;
+
+	if (!Source::getConstant(stype, typestr))
+		return luaL_error(L, "Unknown Source type.");
+
+	lua_pushstring(L, typestr);
+	return 1;
+}
+
 static const luaL_Reg functions[] =
 {
 	{ "play", w_Source_play },
 	{ "setRolloff", w_Source_setRolloff},
 	{ "getRolloff", w_Source_getRolloff},
 
+	{ "getType", w_Source_getType },
+
 	{ 0, 0 }
 };
 

src/modules/audio/wrap_Source.h

 int w_Source_getDistance(lua_State *L);
 int w_Source_setRolloff(lua_State *L);
 int w_Source_getRolloff(lua_State *L);
+int w_Source_getType(lua_State *L);
 extern "C" int luaopen_source(lua_State *L);
 
 } // audio
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.