VR-Forces 5.0.2 Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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  DT_DLL_vrfLua int DtLuaAppendPath( lua_State* L, const std::vector<std::string>& paths );
59 
61  DT_DLL_vrfLua void DtLuaGetPath(lua_State* L, std::vector<std::string>& paths);
62 }
T * luaTypeCast(luabind::object const &luaObject)
separator for &quot;objects&quot; which are comprised of entries
Definition: luaUtils.h:22
DT_DLL_vrfLua int DtLuaErrorHandler(lua_State *L)
Lua Debugging functions.
DT_DLL_vrfLua bool DtLuaFunctionExists(lua_State *luaState, const char *functionName)
Determine whether or not a function exists.
DT_DLL_vrfLua void DtLuaGetPath(lua_State *L, std::vector< std::string > &paths)
Get the path from the Lua state.
static const char * entrySeparator
Definition: luaUtils.h:18
#define DT_DLL_vrfLua
This file is used to determine how to build.
Definition: vrfLuaDefines.h:25
DT_DLL_vrfLua int DtLuaAppendPath(lua_State *L, const char *path)
Add a path into Lua for include files.
static const char * objectSeparator
separator for entries in an &quot;object&quot;
Definition: luaUtils.h:19
T * luaTypeCastNoThrow(luabind::object const &luaObject)
Definition: luaUtils.h:36
DT_DLL_vrfLua int DtLuaErrorHandlerToString(lua_State *L)

Document ID: Generated on Sun Dec 4 20:22:03 EST 2022 from SVN revision 249613
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)