* Registers an object's method as a Lua function (global or table field)
* Registers an object's method as a Lua function (global or table field)
* The method may have any signature
* 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)
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
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* furnished to do so, subject to the following conditions:
*
*
* The above copyright notice and this permission notice shall be included in
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
* all copies or substantial portions of the Software.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* 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
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
* THE SOFTWARE.
*/
*/
usingSystem;
usingSystem;
usingSystem.Text;
usingSystem.Text;
usingSystem.Collections.Generic;
usingSystem.Collections.Generic;
namespaceLuaInterface
namespaceLuaInterface
{
{
/// <summary>
/// <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
/// 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
lua.RegisterFunction(method.Name,null,method);// CLR name
else
else
lua.RegisterFunction(attribute.Name,null,method);// Custom name
lua.RegisterFunction(attribute.Name,null,method);// Custom name
}
}
}
}
}
}
#endregion
#endregion
#regionEnumeration
#regionEnumeration
/// <summary>
/// <summary>
/// Registers an enumeration's values for usage as a Lua variable table
/// Registers an enumeration's values for usage as a Lua variable table
/// </summary>
/// </summary>
/// <typeparam name="T">The enum type to register</typeparam>
/// <typeparam name="T">The enum type to register</typeparam>
/// <param name="lua">The Lua VM to add the enum to</param>
/// <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")]
[SuppressMessage("Microsoft.Design","CA1004:GenericMethodsShouldProvideTypeParameter",Justification="The type parameter is used to select an enum type")]
publicstaticvoidEnumeration<T>(Lualua)
publicstaticvoidEnumeration<T>(Lualua)
{
{
#regionSanitychecks
#regionSanitychecks
if(lua.IsNull())
if(lua.IsNull())
thrownewArgumentNullException("lua");
thrownewArgumentNullException("lua");
#endregion
#endregion
vartype=typeof(T);
vartype=typeof(T);
if(!type.IsEnum)
if(!type.IsEnum)
thrownewArgumentException("The type must be an enumeration!");
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));
Debug.WriteLine(string.Format("An error occurred during an attempt to retrieve an extractor ({0}) while checking for params array status.",paramElementType.FullName));