VR-Forces 4.1 Class Documentation
luaUtils.h
Go to the documentation of this file.
1 /*******************************************************************************
2 ** Copyright (c) 2012 MAK Technologies, Inc.
3 ** All rights reserved.
4 *******************************************************************************/
5 #pragma once
6 
7 #include <vrfLua/vrfLuaDefines.h>
8 #include "vlutil/vlString.h"
9 
10 #include <lua.hpp>
11 #include <lauxlib.h>
12 #include <lualib.h>
13 
14 #include <luabind/luabind.hpp>
15 
16 namespace vrfLua
17 {
18  static const char* entrySeparator = ":";
19  static const char* objectSeparator = "|";
20 
21  template<class T>
22  T* luaTypeCast(luabind::object const& luaObject)
23  {
24  try
25  {
26  T* value = luabind::object_cast<T*>(luaObject);
27  return value;
28  }
29  catch (luabind::cast_failed*)
30  {
31  return 0;
32  }
33  }
34 
35  template<class T>
36  T* luaTypeCastNoThrow(luabind::object const& luaObject)
37  {
38  boost::optional<T*> val;
39  val = luabind::object_cast_nothrow<T*>(luaObject);
40  if (val)
41  {
42  return val.get();
43  //T* obj = new T(val.get());
44  //return obj;
45  }
46  return 0;
47  }
48 
50  DT_DLL_vrfLua bool DtLuaFunctionExists(lua_State* luaState, const char* functionName);
51 
53  DT_DLL_vrfLua int DtLuaErrorHandler(lua_State *L) ;
54  DT_DLL_vrfLua int DtLuaErrorHandlerToString(lua_State *L);
55 
57  DT_DLL_vrfLua int DtLuaAppendPath( lua_State* L, const char* path );
58 }

Document ID: Generated on Tue Jan 29 18:21:16 EST 2013 from SVN revision 123193
Copyright © 2005-2013 VT MÄK Inc. All Rights Reserved (www.mak.com)