* Registers an object's method as a Lua function (global or table field)
* The method may have any signature
*/
publicLuaFunctionRegisterFunction(stringpath,objecttarget,MethodBasefunction/*MethodInfo function*/)//CP: Fix for struct constructor by Alexander Kappner (link: http://luaforge.net/forum/forum.php?thread_id = 2859&forum_id = 145)
* Registers an object's method as a Lua function (global or table field)
* The method may have any signature
*/
publicLuaFunctionRegisterFunction(stringpath,objecttarget,MethodBasefunction/*MethodInfo function*/)//CP: Fix for struct constructor by Alexander Kappner (link: http://luaforge.net/forum/forum.php?thread_id = 2859&forum_id = 145)
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
usingSystem;
usingSystem.Text;
usingSystem.Collections.Generic;
namespaceLuaInterface
{
/// <summary>
/// Base class to provide consistent disposal flow across lua objects. Uses code provided by Yves Duhoux and suggestions by Hans Schmeidenbacher and Qingrui Li
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
usingSystem;
usingSystem.Text;
usingSystem.Collections.Generic;
namespaceLuaInterface
{
/// <summary>
/// Base class to provide consistent disposal flow across lua objects. Uses code provided by Yves Duhoux and suggestions by Hans Schmeidenbacher and Qingrui Li
lua.RegisterFunction(method.Name,null,method);// CLR name
else
lua.RegisterFunction(attribute.Name,null,method);// Custom name
}
}
}
#endregion
#regionEnumeration
/// <summary>
/// Registers an enumeration's values for usage as a Lua variable table
/// </summary>
/// <typeparam name="T">The enum type to register</typeparam>
/// <param name="lua">The Lua VM to add the enum to</param>
[SuppressMessage("Microsoft.Design","CA1004:GenericMethodsShouldProvideTypeParameter",Justification="The type parameter is used to select an enum type")]
publicstaticvoidEnumeration<T>(Lualua)
{
#regionSanitychecks
if(lua.IsNull())
thrownewArgumentNullException("lua");
#endregion
vartype=typeof(T);
if(!type.IsEnum)
thrownewArgumentException("The type must be an enumeration!");
string[]names=Enum.GetNames(type);
varvalues=(T[])Enum.GetValues(type);
lua.NewTable(type.Name);
for(inti=0;i<names.Length;i++)
{
stringpath=type.Name+"."+names[i];
lua[path]=values[i];
}
}
#endregion
}
/*
* This file is part of LuaInterface.
*
* Copyright (C) 2003-2005 Fabio Mascarenhas de Queiroz.
lua.RegisterFunction(method.Name,null,method);// CLR name
else
lua.RegisterFunction(attribute.Name,null,method);// Custom name
}
}
}
#endregion
#regionEnumeration
/// <summary>
/// Registers an enumeration's values for usage as a Lua variable table
/// </summary>
/// <typeparam name="T">The enum type to register</typeparam>
/// <param name="lua">The Lua VM to add the enum to</param>
[SuppressMessage("Microsoft.Design","CA1004:GenericMethodsShouldProvideTypeParameter",Justification="The type parameter is used to select an enum type")]
publicstaticvoidEnumeration<T>(Lualua)
{
#regionSanitychecks
if(lua.IsNull())
thrownewArgumentNullException("lua");
#endregion
vartype=typeof(T);
if(!type.IsEnum)
thrownewArgumentException("The type must be an enumeration!");
Debug.WriteLine(string.Format("An error occurred during an attempt to retrieve an extractor ({0}) while checking for params array status.",paramElementType.FullName));
}
if(!extractValue.IsNull())
{
returntrue;
}
}
}
Debug.WriteLine("Type wasn't Params object.");
returnfalse;
}
}
/*
* This file is part of LuaInterface.
*
* Copyright (C) 2003-2005 Fabio Mascarenhas de Queiroz.
Debug.WriteLine(string.Format("An error occurred during an attempt to retrieve an extractor ({0}) while checking for params array status.",paramElementType.FullName));