Commit 8a76b646 authored by Megax's avatar Megax
Browse files

* LuaInterface szerkezeti felepitese lasacskan at lesz formalva. Amikor lesz...

* LuaInterface szerkezeti felepitese lasacskan at lesz formalva. Amikor lesz idom es kedvem folytatom az atalakitast.
parent 02869e90
LuaInterface License
--------------------
LuaInterface is licensed under the terms of the MIT license reproduced below.
This mean that LuaInterface is free software and can be used for both academic and
commercial purposes at absolutely no cost.
===============================================================================
Copyright (C) 2003-2005 Fabio Mascarenhas de Queiroz.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
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.
===============================================================================
(end of COPYRIGHT)
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Resources;
// Управление общими сведениями о сборке осуществляется с помощью следующего
// набора атрибутов. Измените значения этих атрибутов для изменения
// сведений о сборке.
[assembly: AssemblyTitle("KopiLua_wp7")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("MICROSOFT")]
[assembly: AssemblyProduct("KopiLua_wp7")]
[assembly: AssemblyCopyright("Copyright © 2012 Gerasimov Sergey")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Если для ComVisible установить значение false, типы в этой сборке не будут поддерживаться
// COM-компонентами. При необходимости доступа к какому-либо типу в этой сборке
// из модели COM задайте для атрибута ComVisible этого типа значение true.
[assembly: ComVisible(false)]
// Следующий GUID служит для идентификации библиотеки типов, если данный проект видим для COM
[assembly: Guid("63906a16-e4d0-4ad7-ba8f-cb4d6c29d2d5")]
// Сведения о версии сборки состоят из следующих четырех значений:
//
// Основной номер версии
// Дополнительный номер версии
// Номер построения
// Редакция
//
// Можно указать все значения или задать для номеров редакции и построения значения по умолчанию
// с помощью символа '*', как показано ниже:
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: NeutralResourcesLanguageAttribute("ru-RU")]
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Lua")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Lua")]
[assembly: AssemblyCopyright("Copyright © Mark Feldman 2009")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("42f29687-47be-4860-a332-c7c4c75b7119")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Luac")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Luac")]
[assembly: AssemblyCopyright("Copyright © Mark Feldman 2009")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("403d5192-280f-4171-98e6-c818dd6b9981")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.50727</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{56CCEE95-B8C5-42B3-B008-F7CD58268683}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>AT.MIN.Tools.Tests</RootNamespace>
<AssemblyName>AT.MIN.Tools.Tests</AssemblyName>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="nunit.framework, Version=2.4.1.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL" />
<Reference Include="System" />
</ItemGroup>
<ItemGroup>
<Compile Include="Tools.Tests.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\AT.MIN.Tools\AT.MIN.Tools.csproj">
<Project>{7D53822B-6176-4856-AED0-E53F34739C70}</Project>
<Name>AT.MIN.Tools</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
\ No newline at end of file
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle( "printf.tests" )]
[assembly: AssemblyDescription( "" )]
[assembly: AssemblyConfiguration( "" )]
[assembly: AssemblyCompany( "www.MIN.at" )]
[assembly: AssemblyProduct( "printf.tests" )]
[assembly: AssemblyCopyright( "Copyright © MIN.at 2007" )]
[assembly: AssemblyTrademark( "" )]
[assembly: AssemblyCulture( "" )]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible( false )]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid( "cc02f410-6de5-4ecd-aea2-383cdf3bb0d7" )]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion( "1.5.0.0" )]
[assembly: AssemblyFileVersion( "1.5.0.0" )]
#region Usinges
using System;
using NUnit.Framework;
#endregion
namespace AT.MIN
{
[TestFixture]
public class ToolTests
{
private string sepDecimal = System.Globalization.CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator;
private string sep1000 = System.Globalization.CultureInfo.CurrentCulture.NumberFormat.NumberGroupSeparator;
#region Setup Tests
[TestFixtureSetUp]
public void SetUp()
{
}
#endregion
#region Tests
#region Special Formats
[Category( "Special" )]
[Test( Description = "Special formats %% / %n" )]
public void SpecialFormats()
{
Console.WriteLine( "Test special formats %% / %n" );
Console.WriteLine( "--------------------------------------------------------------------------------" );
Assert.IsTrue( RunTest( "[%%]", "[%]" ) );
Assert.IsTrue( RunTest( "[%n]", "[1]" ) );
Assert.IsTrue( RunTest( "[%%n shows the number of processed chars so far (%010n)]",
"[%n shows the number of processed chars so far (0000000048)]" ) );
Console.WriteLine( "\n\n" );
}
#endregion
#region PositiveInteger
[Category( "Integer" )]
[Test( Description = "Test positive signed integer format %d / %i" )]
public void PositiveInteger()
{
Console.WriteLine( "Test positive signed integer format %d / %i" );
Console.WriteLine( "--------------------------------------------------------------------------------" );
Assert.IsTrue( RunTest( "[%d]", "[42]", 42 ) );
Assert.IsTrue( RunTest( "[%10d]", "[ 42]", 42 ) );
Assert.IsTrue( RunTest( "[%-10d]", "[42 ]", 42 ) );
Assert.IsTrue( RunTest( "[%010d]", "[0000000042]", 42 ) );
Assert.IsTrue( RunTest( "[%-010d]", "[42 ]", 42 ) );
Assert.IsTrue( RunTest( "[%+d]", "[+42]", 42 ) );
Assert.IsTrue( RunTest( "[%+10d]", "[ +42]", 42 ) );
Assert.IsTrue( RunTest( "[%-+10d]", "[+42 ]", 42 ) );
Assert.IsTrue( RunTest( "[%+010d]", "[+000000042]", 42 ) );
Assert.IsTrue( RunTest( "[%-+010d]", "[+42 ]", 42 ) );
Assert.IsTrue( RunTest( "[%d]", "[65537]", 65537 ) );
Assert.IsTrue( RunTest( "[%'d]", String.Format( "[65{0}537]", sep1000 ), 65537 ) );
Assert.IsTrue( RunTest( "[%'d]", String.Format( "[10{0}065{0}537]", sep1000 ), 10065537 ) );
Console.WriteLine( "\n\n" );
}
#endregion
#region NegativeInteger
[Category( "Integer" )]
[Test( Description = "Test negative signed integer format %d / %i" )]
public void NegativeInteger()
{
Console.WriteLine( "Test negative signed integer format %d / %i" );
Console.WriteLine( "--------------------------------------------------------------------------------" );
Assert.IsTrue( RunTest( "[%d]", "[-42]", -42 ) );
Assert.IsTrue( RunTest( "[%10d]", "[ -42]", -42 ) );
Assert.IsTrue( RunTest( "[%-10d]", "[-42 ]", -42 ) );
Assert.IsTrue( RunTest( "[%010d]", "[-000000042]", -42 ) );
Assert.IsTrue( RunTest( "[%-010d]", "[-42 ]", -42 ) );
Assert.IsTrue( RunTest( "[%+d]", "[-42]", -42 ) );
Assert.IsTrue( RunTest( "[%+10d]", "[ -42]", -42 ) );
Assert.IsTrue( RunTest( "[%-+10d]", "[-42 ]", -42 ) );
Assert.IsTrue( RunTest( "[%+010d]", "[-000000042]", -42 ) );
Assert.IsTrue( RunTest( "[%-+010d]", "[-42 ]", -42 ) );
Assert.IsTrue( RunTest( "[%d]", "[-65537]", -65537 ) );
Assert.IsTrue( RunTest( "[%'d]", String.Format( "[-65{0}537]", sep1000 ), -65537 ) );
Assert.IsTrue( RunTest( "[%'d]", String.Format( "[-10{0}065{0}537]", sep1000 ), -10065537 ) );
Console.WriteLine( "\n\n" );
}
#endregion
#region UnsignedInteger
[Category( "Integer" )]
[Test( Description = "Test unsigned integer format %u" )]
public void UnsignedInteger()
{
Console.WriteLine( "Test unsigned integer format %u" );
Console.WriteLine( "--------------------------------------------------------------------------------" );
Assert.IsTrue( RunTest( "[%u]", "[42]", 42 ) );
Assert.IsTrue( RunTest( "[%10u]", "[ 42]", 42 ) );
Assert.IsTrue( RunTest( "[%-10u]", "[42 ]", 42 ) );
Assert.IsTrue( RunTest( "[%010u]", "[0000000042]", 42 ) );
Assert.IsTrue( RunTest( "[%-010u]", "[42 ]", 42 ) );
Assert.IsTrue( RunTest( "[%u]", "[4294967254]", -42 ) );
Assert.IsTrue( RunTest( "[%20u]", "[ 4294967254]", -42 ) );
Assert.IsTrue( RunTest( "[%-20u]", "[4294967254 ]", -42 ) );
Assert.IsTrue( RunTest( "[%020u]", "[00000000004294967254]", -42 ) );
Assert.IsTrue( RunTest( "[%-020u]", "[4294967254 ]", -42 ) );
Assert.IsTrue( RunTest( "[%u]", "[65537]", 65537 ) );
Assert.IsTrue( RunTest( "[%'u]", String.Format( "[65{0}537]", sep1000 ), 65537 ) );
Assert.IsTrue( RunTest( "[%'u]", String.Format( "[10{0}065{0}537]", sep1000 ), 10065537 ) );
Console.WriteLine( "\n\n" );
}
#endregion
#region Float
[Category( "Float" )]
[Test( Description = "Test float format %f" )]
public void Floats()
{
Console.WriteLine( "Test float format %f" );
Console.WriteLine( "--------------------------------------------------------------------------------" );
Assert.IsTrue( RunTest( "[%f]", String.Format( "[42{0}000000]", sepDecimal ), 42 ) );
Assert.IsTrue( RunTest( "[%f]", String.Format("[42{0}500000]", sepDecimal ), 42.5 ) );
Assert.IsTrue( RunTest( "[%10f]", String.Format("[ 42{0}000000]", sepDecimal ), 42 ) );
Assert.IsTrue( RunTest( "[%10f]", String.Format("[ 42{0}500000]", sepDecimal ), 42.5 ) );
Assert.IsTrue( RunTest( "[%-10f]", String.Format("[42{0}000000 ]", sepDecimal ), 42 ) );
Assert.IsTrue( RunTest( "[%-10f]", String.Format("[42{0}500000 ]", sepDecimal ), 42.5 ) );
Assert.IsTrue( RunTest( "[%010f]", String.Format("[042{0}000000]", sepDecimal ), 42 ) );
Assert.IsTrue( RunTest( "[%010f]", String.Format("[042{0}500000]", sepDecimal ), 42.5 ) );
Assert.IsTrue( RunTest( "[%-010f]", String.Format("[42{0}000000 ]", sepDecimal ), 42 ) );
Assert.IsTrue( RunTest( "[%-010f]", String.Format("[42{0}500000 ]", sepDecimal ), 42.5 ) );
Assert.IsTrue( RunTest( "[%+f]", String.Format("[+42{0}000000]", sepDecimal ), 42 ) );
Assert.IsTrue( RunTest( "[%+f]", String.Format("[+42{0}500000]", sepDecimal ), 42.5 ) );
Assert.IsTrue( RunTest( "[%+10f]", String.Format("[+42{0}000000]", sepDecimal ), 42 ) );
Assert.IsTrue( RunTest( "[%+10f]", String.Format("[+42{0}500000]", sepDecimal ), 42.5 ) );
Assert.IsTrue( RunTest( "[%+-10f]", String.Format("[+42{0}000000]", sepDecimal ), 42 ) );
Assert.IsTrue( RunTest( "[%+-10f]", String.Format("[+42{0}500000]", sepDecimal ), 42.5 ) );
Assert.IsTrue( RunTest( "[%+010f]", String.Format("[+42{0}000000]", sepDecimal ), 42 ) );
Assert.IsTrue( RunTest( "[%+010f]", String.Format("[+42{0}500000]", sepDecimal ), 42.5 ) );
Assert.IsTrue( RunTest( "[%+-010f]", String.Format("[+42{0}000000]", sepDecimal ), 42 ) );
Assert.IsTrue( RunTest( "[%+-010f]", String.Format("[+42{0}500000]", sepDecimal ), 42.5 ) );
Assert.IsTrue( RunTest( "[%f]", String.Format("[-42{0}000000]", sepDecimal ), -42 ) );
Assert.IsTrue( RunTest( "[%f]", String.Format("[-42{0}500000]", sepDecimal ), -42.5 ) );
Assert.IsTrue( RunTest( "[%10f]", String.Format("[-42{0}000000]", sepDecimal ), -42 ) );
Assert.IsTrue( RunTest( "[%10f]", String.Format("[-42{0}500000]", sepDecimal ), -42.5 ) );
Assert.IsTrue( RunTest( "[%-10f]", String.Format("[-42{0}000000]", sepDecimal ), -42 ) );
Assert.IsTrue( RunTest( "[%-10f]", String.Format("[-42{0}500000]", sepDecimal ), -42.5 ) );
Assert.IsTrue( RunTest( "[%010f]", String.Format("[-42{0}000000]", sepDecimal ), -42 ) );
Assert.IsTrue( RunTest( "[%010f]", String.Format("[-42{0}500000]", sepDecimal ), -42.5 ) );
Assert.IsTrue( RunTest( "[%-010f]", String.Format("[-42{0}000000]", sepDecimal ), -42 ) );
Assert.IsTrue( RunTest( "[%-010f]", String.Format("[-42{0}500000]", sepDecimal ), -42.5 ) );
Assert.IsTrue( RunTest( "[%+f]", String.Format("[-42{0}000000]", sepDecimal ), -42 ) );
Assert.IsTrue( RunTest( "[%+f]", String.Format("[-42{0}500000]", sepDecimal ), -42.5 ) );
Assert.IsTrue( RunTest( "[%+10f]", String.Format("[-42{0}000000]", sepDecimal ), -42 ) );
Assert.IsTrue( RunTest( "[%+10f]", String.Format("[-42{0}500000]", sepDecimal ), -42.5 ) );
Assert.IsTrue( RunTest( "[%+-10f]", String.Format("[-42{0}000000]", sepDecimal ), -42 ) );
Assert.IsTrue( RunTest( "[%+-10f]", String.Format("[-42{0}500000]", sepDecimal ), -42.5 ) );
Assert.IsTrue( RunTest( "[%+010f]", String.Format("[-42{0}000000]", sepDecimal ), -42 ) );
Assert.IsTrue( RunTest( "[%+010f]", String.Format("[-42{0}500000]", sepDecimal ), -42.5 ) );
Assert.IsTrue( RunTest( "[%+-010f]", String.Format("[-42{0}000000]", sepDecimal ), -42 ) );
Assert.IsTrue( RunTest( "[%+-010f]", String.Format("[-42{0}500000]", sepDecimal ), -42.5 ) );
// -----
Assert.IsTrue( RunTest( "[%.2f]", String.Format("[42{0}00]", sepDecimal ), 42 ) );
Assert.IsTrue( RunTest( "[%.2f]", String.Format("[42{0}50]", sepDecimal ), 42.5 ) );
Assert.IsTrue( RunTest( "[%10.2f]", String.Format("[ 42{0}00]", sepDecimal ), 42 ) );
Assert.IsTrue( RunTest( "[%10.2f]", String.Format("[ 42{0}50]", sepDecimal ), 42.5 ) );
Assert.IsTrue( RunTest( "[%-10.2f]", String.Format("[42{0}00 ]", sepDecimal ), 42 ) );
Assert.IsTrue( RunTest( "[%-10.2f]", String.Format("[42{0}50 ]", sepDecimal ), 42.5 ) );
Assert.IsTrue( RunTest( "[%010.2f]", String.Format("[0000042{0}00]", sepDecimal ), 42 ) );
Assert.IsTrue( RunTest( "[%010.2f]", String.Format("[0000042{0}50]", sepDecimal ), 42.5 ) );
Assert.IsTrue( RunTest( "[%-010.2f]", String.Format("[42{0}00 ]", sepDecimal ), 42 ) );
Assert.IsTrue( RunTest( "[%-010.2f]", String.Format("[42{0}50 ]", sepDecimal ), 42.5 ) );
Assert.IsTrue( RunTest( "[%+.2f]", String.Format("[+42{0}00]", sepDecimal ), 42 ) );
Assert.IsTrue( RunTest( "[%+.2f]", String.Format("[+42{0}50]", sepDecimal ), 42.5 ) );
Assert.IsTrue( RunTest( "[%+10.2f]", String.Format("[ +42{0}00]", sepDecimal ), 42 ) );
Assert.IsTrue( RunTest( "[%+10.2f]", String.Format("[ +42{0}50]", sepDecimal ), 42.5 ) );
Assert.IsTrue( RunTest( "[%+-10.2f]", String.Format("[+42{0}00 ]", sepDecimal ), 42 ) );
Assert.IsTrue( RunTest( "[%+-10.2f]", String.Format("[+42{0}50 ]", sepDecimal ), 42.5 ) );
Assert.IsTrue( RunTest( "[%+010.2f]", String.Format("[+000042{0}00]", sepDecimal ), 42 ) );
Assert.IsTrue( RunTest( "[%+010.2f]", String.Format("[+000042{0}50]", sepDecimal ), 42.5 ) );
Assert.IsTrue( RunTest( "[%+-010.2f]", String.Format("[+42{0}00 ]", sepDecimal ), 42 ) );
Assert.IsTrue( RunTest( "[%+-010.2f]", String.Format("[+42{0}50 ]", sepDecimal ), 42.5 ) );
Assert.IsTrue( RunTest( "[%.2f]", String.Format("[-42{0}00]", sepDecimal ), -42 ) );
Assert.IsTrue( RunTest( "[%.2f]", String.Format("[-42{0}50]", sepDecimal ), -42.5 ) );
Assert.IsTrue( RunTest( "[%10.2f]", String.Format("[ -42{0}00]", sepDecimal ), -42 ) );
Assert.IsTrue( RunTest( "[%10.2f]", String.Format("[ -42{0}50]", sepDecimal ), -42.5 ) );
Assert.IsTrue( RunTest( "[%-10.2f]", String.Format("[-42{0}00 ]", sepDecimal ), -42 ) );
Assert.IsTrue( RunTest( "[%-10.2f]", String.Format("[-42{0}50 ]", sepDecimal ), -42.5 ) );
Assert.IsTrue( RunTest( "[%010.2f]", String.Format("[-000042{0}00]", sepDecimal ), -42 ) );
Assert.IsTrue( RunTest( "[%010.2f]", String.Format("[-000042{0}50]", sepDecimal ), -42.5 ) );
Assert.IsTrue( RunTest( "[%-010.2f]", String.Format("[-42{0}00 ]", sepDecimal ), -42 ) );
Assert.IsTrue( RunTest( "[%-010.2f]", String.Format("[-42{0}50 ]", sepDecimal ), -42.5 ) );
Assert.IsTrue( RunTest( "[%+.2f]", String.Format("[-42{0}00]", sepDecimal ), -42 ) );
Assert.IsTrue( RunTest( "[%+.2f]", String.Format("[-42{0}50]", sepDecimal ), -42.5 ) );
Assert.IsTrue( RunTest( "[%+10.2f]", String.Format("[ -42{0}00]", sepDecimal ), -42 ) );
Assert.IsTrue( RunTest( "[%+10.2f]", String.Format("[ -42{0}50]", sepDecimal ), -42.5 ) );
Assert.IsTrue( RunTest( "[%+-10.2f]", String.Format("[-42{0}00 ]", sepDecimal ), -42 ) );
Assert.IsTrue( RunTest( "[%+-10.2f]", String.Format("[-42{0}50 ]", sepDecimal ), -42.5 ) );
Assert.IsTrue( RunTest( "[%+010.2f]", String.Format("[-000042{0}00]", sepDecimal ), -42 ) );
Assert.IsTrue( RunTest( "[%+010.2f]", String.Format("[-000042{0}50]", sepDecimal ), -42.5 ) );
Assert.IsTrue( RunTest( "[%+-010.2f]", String.Format("[-42{0}00 ]", sepDecimal ), -42 ) );
Assert.IsTrue( RunTest( "[%+-010.2f]", String.Format( "[-42{0}50 ]", sepDecimal ), -42.5 ) );
Console.WriteLine( "\n\n" );
}
#endregion
#region Exponent
[Category( "Exponent" )]
[Test( Description = "Test exponent format %f" )]
public void Exponents()
{
Console.WriteLine( "Test exponent format %f" );
Console.WriteLine( "--------------------------------------------------------------------------------" );
Assert.IsTrue( RunTest( "[%e]", String.Format( "[4{0}200000e+001]", sepDecimal ), 42 ) );
Assert.IsTrue( RunTest( "[%e]", String.Format("[4{0}250000e+001]", sepDecimal ), 42.5 ) );
Assert.IsTrue( RunTest( "[%20e]", String.Format("[ 4{0}200000e+001]", sepDecimal ), 42 ) );
Assert.IsTrue( RunTest( "[%20e]", String.Format("[ 4{0}250000e+001]", sepDecimal ), 42.5 ) );
Assert.IsTrue( RunTest( "[%-20e]", String.Format("[4{0}200000e+001 ]", sepDecimal ), 42 ) );
Assert.IsTrue( RunTest( "[%-20e]", String.Format("[4{0}250000e+001 ]", sepDecimal ), 42.5 ) );
Assert.IsTrue( RunTest( "[%020e]", String.Format("[00000004{0}200000e+001]", sepDecimal ), 42 ) );
Assert.IsTrue( RunTest( "[%020e]", String.Format("[00000004{0}250000e+001]", sepDecimal ), 42.5 ) );
Assert.IsTrue( RunTest( "[%-020e]", String.Format("[4{0}200000e+001 ]", sepDecimal ), 42 ) );
Assert.IsTrue( RunTest( "[%-020e]", String.Format("[4{0}250000e+001 ]", sepDecimal ), 42.5 ) );
Assert.IsTrue( RunTest( "[%+E]", String.Format("[+4{0}200000E+001]", sepDecimal ), 42 ) );
Assert.IsTrue( RunTest( "[%+E]", String.Format("[+4{0}250000E+001]", sepDecimal ), 42.5 ) );
Assert.IsTrue( RunTest( "[%+20E]", String.Format("[ +4{0}200000E+001]", sepDecimal ), 42 ) );
Assert.IsTrue( RunTest( "[%+20E]", String.Format("[ +4{0}250000E+001]", sepDecimal ), 42.5 ) );
Assert.IsTrue( RunTest( "[%+-20E]", String.Format("[+4{0}200000E+001 ]", sepDecimal ), 42 ) );
Assert.IsTrue( RunTest( "[%+-20E]", String.Format("[+4{0}250000E+001 ]", sepDecimal ), 42.5 ) );
Assert.IsTrue( RunTest( "[%+020E]", String.Format("[+0000004{0}200000E+001]", sepDecimal ), 42 ) );
Assert.IsTrue( RunTest( "[%+020E]", String.Format("[+0000004{0}250000E+001]", sepDecimal ), 42.5 ) );
Assert.IsTrue( RunTest( "[%+-020E]", String.Format("[+4{0}200000E+001 ]", sepDecimal ), 42 ) );
Assert.IsTrue( RunTest( "[%+-020E]", String.Format("[+4{0}250000E+001 ]", sepDecimal ), 42.5 ) );
Assert.IsTrue( RunTest( "[%e]", String.Format("[-4{0}200000e+001]", sepDecimal ), -42 ) );
Assert.IsTrue( RunTest( "[%e]", String.Format("[-4{0}250000e+001]", sepDecimal ), -42.5 ) );
Assert.IsTrue( RunTest( "[%20e]", String.Format("[ -4{0}200000e+001]", sepDecimal ), -42 ) );
Assert.IsTrue( RunTest( "[%20e]", String.Format("[ -4{0}250000e+001]", sepDecimal ), -42.5 ) );
Assert.IsTrue( RunTest( "[%-20e]", String.Format("[-4{0}200000e+001 ]", sepDecimal ), -42 ) );
Assert.IsTrue( RunTest( "[%-20e]", String.Format("[-4{0}250000e+001 ]", sepDecimal ), -42.5 ) );
Assert.IsTrue( RunTest( "[%020e]", String.Format("[-0000004{0}200000e+001]", sepDecimal ), -42 ) );
Assert.IsTrue( RunTest( "[%020e]", String.Format("[-0000004{0}250000e+001]", sepDecimal ), -42.5 ) );
Assert.IsTrue( RunTest( "[%-020e]", String.Format("[-4{0}200000e+001 ]", sepDecimal ), -42 ) );
Assert.IsTrue( RunTest( "[%-020e]", String.Format("[-4{0}250000e+001 ]", sepDecimal ), -42.5 ) );
Assert.IsTrue( RunTest( "[%+e]", String.Format("[-4{0}200000e+001]", sepDecimal ), -42 ) );
Assert.IsTrue( RunTest( "[%+e]", String.Format("[-4{0}250000e+001]", sepDecimal ), -42.5 ) );
Assert.IsTrue( RunTest( "[%+20e]", String.Format("[ -4{0}200000e+001]", sepDecimal ), -42 ) );
Assert.IsTrue( RunTest( "[%+20e]", String.Format("[ -4{0}250000e+001]", sepDecimal ), -42.5 ) );
Assert.IsTrue( RunTest( "[%+-20e]", String.Format("[-4{0}200000e+001 ]", sepDecimal ), -42 ) );
Assert.IsTrue( RunTest( "[%+-20e]", String.Format("[-4{0}250000e+001 ]", sepDecimal ), -42.5 ) );
Assert.IsTrue( RunTest( "[%+020e]", String.Format("[-0000004{0}200000e+001]", sepDecimal ), -42 ) );
Assert.IsTrue( RunTest( "[%+020e]", String.Format("[-0000004{0}250000e+001]", sepDecimal ), -42.5 ) );
Assert.IsTrue( RunTest( "[%+-020e]", String.Format("[-4{0}200000e+001 ]", sepDecimal ), -42 ) );
Assert.IsTrue( RunTest( "[%+-020e]", String.Format("[-4{0}250000e+001 ]", sepDecimal ), -42.5 ) );
// -----
Assert.IsTrue( RunTest( "[%.2e]", String.Format("[4{0}20e+001]", sepDecimal ), 42 ) );
Assert.IsTrue( RunTest( "[%.2e]", String.Format("[4{0}25e+001]", sepDecimal ), 42.5 ) );
Assert.IsTrue( RunTest( "[%20.2e]", String.Format("[ 4{0}20e+001]", sepDecimal ), 42 ) );
Assert.IsTrue( RunTest( "[%20.2e]", String.Format("[ 4{0}25e+001]", sepDecimal ), 42.5 ) );
Assert.IsTrue( RunTest( "[%-20.2e]", String.Format("[4{0}20e+001 ]", sepDecimal ), 42 ) );
Assert.IsTrue( RunTest( "[%-20.2e]", String.Format("[4{0}25e+001 ]", sepDecimal ), 42.5 ) );
Assert.IsTrue( RunTest( "[%020.2e]", String.Format("[000000000004{0}20e+001]", sepDecimal ), 42 ) );
Assert.IsTrue( RunTest( "[%020.2e]", String.Format("[000000000004{0}25e+001]", sepDecimal ), 42.5 ) );
Assert.IsTrue( RunTest( "[%-020.2e]", String.Format("[4{0}20e+001 ]", sepDecimal ), 42 ) );
Assert.IsTrue( RunTest( "[%-020.2e]", String.Format("[4{0}25e+001 ]", sepDecimal ), 42.5 ) );
Assert.IsTrue( RunTest( "[%+.2E]", String.Format("[+4{0}20E+001]", sepDecimal ), 42 ) );
Assert.IsTrue( RunTest( "[%+.2E]", String.Format("[+4{0}25E+001]", sepDecimal ), 42.5 ) );
Assert.IsTrue( RunTest( "[%+20.2E]", String.Format("[ +4{0}20E+001]", sepDecimal ), 42 ) );
Assert.IsTrue( RunTest( "[%+20.2E]", String.Format("[ +4{0}25E+001]", sepDecimal ), 42.5 ) );
Assert.IsTrue( RunTest( "[%+-20.2E]", String.Format("[+4{0}20E+001 ]", sepDecimal ), 42 ) );
Assert.IsTrue( RunTest( "[%+-20.2E]", String.Format("[+4{0}25E+001 ]", sepDecimal ), 42.5 ) );
Assert.IsTrue( RunTest( "[%+020.2E]", String.Format("[+00000000004{0}20E+001]", sepDecimal ), 42 ) );
Assert.IsTrue( RunTest( "[%+020.2E]", String.Format("[+00000000004{0}25E+001]", sepDecimal ), 42.5 ) );
Assert.IsTrue( RunTest( "[%+-020.2E]", String.Format("[+4{0}20E+001 ]", sepDecimal ), 42 ) );
Assert.IsTrue( RunTest( "[%+-020.2E]", String.Format("[+4{0}25E+001 ]", sepDecimal ), 42.5 ) );
Assert.IsTrue( RunTest( "[%.2e]", String.Format("[-4{0}20e+001]", sepDecimal ), -42 ) );
Assert.IsTrue( RunTest( "[%.2e]", String.Format("[-4{0}25e+001]", sepDecimal ), -42.5 ) );
Assert.IsTrue( RunTest( "[%20.2e]", String.Format("[ -4{0}20e+001]", sepDecimal ), -42 ) );
Assert.IsTrue( RunTest( "[%20.2e]", String.Format("[ -4{0}25e+001]", sepDecimal ), -42.5 ) );
Assert.IsTrue( RunTest( "[%-20.2e]", String.Format("[-4{0}20e+001 ]", sepDecimal ), -42 ) );
Assert.IsTrue( RunTest( "[%-20.2e]", String.Format("[-4{0}25e+001 ]", sepDecimal ), -42.5 ) );
Assert.IsTrue( RunTest( "[%020.2e]", String.Format("[-00000000004{0}20e+001]", sepDecimal ), -42 ) );
Assert.IsTrue( RunTest( "[%020.2e]", String.Format("[-00000000004{0}25e+001]", sepDecimal ), -42.5 ) );
Assert.IsTrue( RunTest( "[%-020.2e]", String.Format("[-4{0}20e+001 ]", sepDecimal ), -42 ) );
Assert.IsTrue( RunTest( "[%-020.2e]", String.Format("[-4{0}25e+001 ]", sepDecimal ), -42.5 ) );
Assert.IsTrue( RunTest( "[%+.2e]", String.Format("[-4{0}20e+001]", sepDecimal ), -42 ) );
Assert.IsTrue( RunTest( "[%+.2e]", String.Format("[-4{0}25e+001]", sepDecimal ), -42.5 ) );
Assert.IsTrue( RunTest( "[%+20.2e]", String.Format("[ -4{0}20e+001]", sepDecimal ), -42 ) );
Assert.IsTrue( RunTest( "[%+20.2e]", String.Format("[ -4{0}25e+001]", sepDecimal ), -42.5 ) );
Assert.IsTrue( RunTest( "[%+-20.2e]", String.Format("[-4{0}20e+001 ]", sepDecimal ), -42 ) );
Assert.IsTrue( RunTest( "[%+-20.2e]", String.Format("[-4{0}25e+001 ]", sepDecimal ), -42.5 ) );
Assert.IsTrue( RunTest( "[%+020.2e]", String.Format("[-00000000004{0}20e+001]", sepDecimal ), -42 ) );
Assert.IsTrue( RunTest( "[%+020.2e]", String.Format("[-00000000004{0}25e+001]", sepDecimal ), -42.545 ) );
Assert.IsTrue( RunTest( "[%+-020.2e]", String.Format("[-4{0}20e+001 ]", sepDecimal ), -42 ) );
Assert.IsTrue( RunTest( "[%+-020.2e]", String.Format( "[-4{0}26e+001 ]", sepDecimal ), -42.555 ) );
Console.WriteLine( "\n\n" );
}
#endregion
#region Character
[Category( "Character" )]
[Test( Description = "Character format %c" )]
public void CharacterFormat()
{
Console.WriteLine( "Test character formats %c" );
Console.WriteLine( "--------------------------------------------------------------------------------" );
Assert.IsTrue( RunTest( "[%c]", "[]", null ) );
Assert.IsTrue( RunTest( "[%c]", "[A]", 'A' ) );
Assert.IsTrue( RunTest( "[%c]", "[A]", "A Test" ) );
Assert.IsTrue( RunTest( "[%c]", "[A]", 65 ) );
Console.WriteLine( "\n\n" );
}
#endregion
#region Strings
[Category( "String" )]
[Test( Description = "Test string format %s" )]
public void Strings()
{
Console.WriteLine( "Test string format %s" );
Console.WriteLine( "--------------------------------------------------------------------------------" );
Assert.IsTrue( RunTest( "[%s]", "[This is a test]", "This is a test" ) );
Assert.IsTrue( RunTest( "[%s]", "[A test with %]", "A test with %" ) );
Assert.IsTrue( RunTest( "[%s]", "[A test with %s inside]", "A test with %s inside" ) );
Assert.IsTrue( RunTest( "[%% %s %%]", "[% % Another test % %]", "% Another test %" ) );
Assert.IsTrue( RunTest( "[%20s]", "[ a long string]", "a long string" ) );
Assert.IsTrue( RunTest( "[%-20s]", "[a long string ]", "a long string" ) );
Assert.IsTrue( RunTest( "[%020s]", "[0000000a long string]", "a long string" ) );
Assert.IsTrue( RunTest( "[%-020s]", "[a long string ]", "a long string" ) );
Assert.IsTrue( RunTest( "[%.10s]", "[This is a ]", "This is a shortened string" ) );
Assert.IsTrue( RunTest( "[%20.10s]", "[ This is a ]", "This is a shortened string" ) );
Assert.IsTrue( RunTest( "[%-20.10s]", "[This is a ]", "This is a shortened string" ) );
Assert.IsTrue( RunTest( "[%020.10s]", "[0000000000This is a ]", "This is a shortened string" ) );
Assert.IsTrue( RunTest( "[%-020.10s]", "[This is a ]", "This is a shortened string" ) );
Tools.printf( "Account balance: %'+20.2f\n", 12345678 );
Console.WriteLine( "\n\n" );
}
#endregion
#region Hex
[Category( "HEX" )]
[Test( Description = "Test hex format %x / %X" )]
public void Hex()
{
Console.WriteLine( "Test hex format %x / %X" );
Console.WriteLine( "--------------------------------------------------------------------------------" );
Assert.IsTrue( RunTest( "[%x]", "[2a]", 42 ) );
Assert.IsTrue( RunTest( "[%X]", "[2A]", 42 ) );
Assert.IsTrue( RunTest( "[%5x]", "[ 2a]", 42 ) );
Assert.IsTrue( RunTest( "[%5X]", "[ 2A]", 42 ) );
Assert.IsTrue( RunTest( "[%05x]", "[0002a]", 42 ) );
Assert.IsTrue( RunTest( "[%05X]", "[0002A]", 42 ) );
Assert.IsTrue( RunTest( "[%-05x]", "[2a ]", 42 ) );
Assert.IsTrue( RunTest( "[%-05X]", "[2A ]", 42 ) );
Assert.IsTrue( RunTest( "[%#x]", "[0x2a]", 42 ) );
Assert.IsTrue( RunTest( "[%#X]", "[0X2A]", 42 ) );
Assert.IsTrue( RunTest( "[%#5x]", "[ 0x2a]", 42 ) );
Assert.IsTrue( RunTest( "[%#5X]", "[ 0X2A]", 42 ) );
Assert.IsTrue( RunTest( "[%#05x]", "[0x02a]", 42 ) );
Assert.IsTrue( RunTest( "[%#05X]", "[0X02A]", 42 ) );
Assert.IsTrue( RunTest( "[%#-05x]", "[0x2a ]", 42 ) );
Assert.IsTrue( RunTest( "[%#-05X]", "[0X2A ]", 42 ) );
Assert.IsTrue( RunTest( "[%.2x]", "[05]", 5 ) );
Console.WriteLine( "\n\n" );
}
#endregion
#region Octal
[Category( "Octal" )]
[Test( Description = "Test octal format %o" )]
public void Octal()
{
Console.WriteLine( "Test octal format %o" );
Console.WriteLine( "--------------------------------------------------------------------------------" );
Assert.IsTrue( RunTest( "[%o]", "[52]", 42 ) );
Assert.IsTrue( RunTest( "[%o]", "[52]", 42 ) );
Assert.IsTrue( RunTest( "[%5o]", "[ 52]", 42 ) );
Assert.IsTrue( RunTest( "[%5o]", "[ 52]", 42 ) );
Assert.IsTrue( RunTest( "[%05o]", "[00052]", 42 ) );
Assert.IsTrue( RunTest( "[%05o]", "[00052]", 42 ) );
Assert.IsTrue( RunTest( "[%-05o]", "[52 ]", 42 ) );
Assert.IsTrue( RunTest( "[%-05o]", "[52 ]", 42 ) );
Assert.IsTrue( RunTest( "[%#o]", "[052]", 42 ) );
Assert.IsTrue( RunTest( "[%#o]", "[052]", 42 ) );
Assert.IsTrue( RunTest( "[%#5o]", "[ 052]", 42 ) );
Assert.IsTrue( RunTest( "[%#5o]", "[ 052]", 42 ) );
Assert.IsTrue( RunTest( "[%#05o]", "[00052]", 42 ) );
Assert.IsTrue( RunTest( "[%#05o]", "[00052]", 42 ) );
Assert.IsTrue( RunTest( "[%#-05o]", "[052 ]", 42 ) );
Assert.IsTrue( RunTest( "[%#-05o]", "[052 ]", 42 ) );
Console.WriteLine( "\n\n" );
}
#endregion
#region PositionIndex
[Category( "PositionIndex" )]
[Test( Description = "Test position index (n$)" )]
public void PositionIndex()
{
Console.WriteLine( "Test position index (n$)" );
Console.WriteLine( "--------------------------------------------------------------------------------" );
Assert.IsTrue( RunTest( "[%2$d %1$#x %1$d]", "[17 0x10 16]", 16, 17 ) );
Console.WriteLine( "\n\n" );
}
#endregion
#endregion
#region Destroy Tests
[TestFixtureTearDown]
public void TearDown()
{
}
#endregion
#region Private Methods
#region RunTest
[Ignore( "" )]
private bool RunTest( string Format, string Wanted, params object[] Parameters )
{
string result = Tools.sprintf( Format, Parameters );
Console.WriteLine( "Format:\t{0,-30}Parameters: {1}\nWanted:\t{2}\nResult:\t{3}",
Format, ShowParameters( Parameters ), Wanted, result );
if ( Wanted == null || Wanted == result )
{
Console.WriteLine();
return true;
}
else
{
Console.WriteLine( "*** ERROR ***\n" );
return false;
}
}
#endregion
#region ShowParameters
private string ShowParameters( params object[] Parameters )
{
string w = String.Empty;
if ( Parameters == null )
return "(null)";
foreach ( object o in Parameters )
w += ( w.Length > 0 ? ", " : "" ) + ( o == null ? "(null)" : o.ToString() );
return w;
}
#endregion
#endregion
}
}
[ViewState]
Mode=
Vid=
FolderType=Documents

Microsoft Visual Studio Solution File, Format Version 9.00
# Visual Studio 2005
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AT.MIN.Tools", "AT.MIN.Tools\AT.MIN.Tools.csproj", "{7D53822B-6176-4856-AED0-E53F34739C70}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AT.MIN.Tools.Tests", "AT.MIN.Tools.Tests\AT.MIN.Tools.Tests.csproj", "{56CCEE95-B8C5-42B3-B008-F7CD58268683}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Build", "Build", "{50E69E84-2107-4EA9-B7D1-31C0E07B54CE}"
ProjectSection(SolutionItems) = preProject
AT.MIN.Tools.sln.config = AT.MIN.Tools.sln.config
AT.MIN.Tools.sln.nunit = AT.MIN.Tools.sln.nunit
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{7D53822B-6176-4856-AED0-E53F34739C70}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7D53822B-6176-4856-AED0-E53F34739C70}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7D53822B-6176-4856-AED0-E53F34739C70}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7D53822B-6176-4856-AED0-E53F34739C70}.Release|Any CPU.Build.0 = Release|Any CPU
{56CCEE95-B8C5-42B3-B008-F7CD58268683}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{56CCEE95-B8C5-42B3-B008-F7CD58268683}.Debug|Any CPU.Build.0 = Debug|Any CPU
{56CCEE95-B8C5-42B3-B008-F7CD58268683}.Release|Any CPU.ActiveCfg = Release|Any CPU
{56CCEE95-B8C5-42B3-B008-F7CD58268683}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<add key="Dummy" value="1000"/>
</appSettings>
</configuration>
\ No newline at end of file
<NUnitProject>
<Settings activeconfig="Debug" />
<Config name="Debug" configfile="AT.MIN.Tools.sln.config" binpathtype="Auto">
<assembly path="AT.MIN.Tools.Tests\bin\Debug\AT.MIN.Tools.Tests.dll" />
</Config>
<Config name="Release" configfile="AT.MIN.Tools.sln.config" binpathtype="Auto">
<assembly path="AT.MIN.Tools.Tests\bin\Release\AT.MIN.Tools.Tests.dll" />
</Config>
</NUnitProject>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.50727</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{7D53822B-6176-4856-AED0-E53F34739C70}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>AT.MIN.Tools</RootNamespace>
<AssemblyName>AT.MIN.Tools</AssemblyName>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Tools.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
\ No newline at end of file
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle( "printf" )]
[assembly: AssemblyDescription( "" )]
[assembly: AssemblyConfiguration( "" )]
[assembly: AssemblyCompany( "www.MIN.at" )]
[assembly: AssemblyProduct( "printf" )]
[assembly: AssemblyCopyright( "Copyright © MIN.at 2007" )]
[assembly: AssemblyTrademark( "" )]
[assembly: AssemblyCulture( "" )]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible( false )]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid( "143c09a9-4b91-44ed-aed7-f32e62368a2e" )]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion( "1.5.0.0" )]
[assembly: AssemblyFileVersion( "1.5.0.0" )]
/*
* This file is part of LuaInterface.
*
* Copyright (C) 2003-2005 Fabio Mascarenhas de Queiroz.
* Copyright (C) 2012 Megax <http://megax.yeahunter.hu/>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* 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.
*/
using System;
using System.Collections.Generic;
using System.Reflection;
using LuaWrap;
using System.Collections.Generic;
using LuaInterface.Extensions;
namespace LuaInterface
{
......@@ -13,15 +38,13 @@ namespace LuaInterface
*/
class CheckType
{
private Dictionary<long, ExtractValue> extractValues = new Dictionary<long, ExtractValue>();
private ExtractValue extractNetObject;
private ObjectTranslator translator;
ExtractValue extractNetObject;
Dictionary<long, ExtractValue> extractValues = new Dictionary<long, ExtractValue>();
public CheckType(ObjectTranslator translator)
{
this.translator = translator;
extractValues.Add(typeof(object).TypeHandle.Value.ToInt64(), new ExtractValue(getAsObject));
extractValues.Add(typeof(sbyte).TypeHandle.Value.ToInt64(), new ExtractValue(getAsSbyte));
extractValues.Add(typeof(byte).TypeHandle.Value.ToInt64(), new ExtractValue(getAsByte));
......@@ -40,7 +63,6 @@ namespace LuaInterface
extractValues.Add(typeof(LuaFunction).TypeHandle.Value.ToInt64(), new ExtractValue(getAsFunction));
extractValues.Add(typeof(LuaTable).TypeHandle.Value.ToInt64(), new ExtractValue(getAsTable));
extractValues.Add(typeof(LuaUserData).TypeHandle.Value.ToInt64(), new ExtractValue(getAsUserdata));
extractNetObject = new ExtractValue(getAsNetObject);
}
......@@ -52,104 +74,98 @@ namespace LuaInterface
{
return getExtractor(paramType.UnderlyingSystemType);
}
internal ExtractValue getExtractor(Type paramType)
{
if(paramType.IsByRef) paramType=paramType.GetElementType();
if(paramType.IsByRef)
paramType = paramType.GetElementType();
long runtimeHandleValue = paramType.TypeHandle.Value.ToInt64();
if(extractValues.ContainsKey(runtimeHandleValue))
return extractValues[runtimeHandleValue];
else
return extractNetObject;
return extractValues.ContainsKey(runtimeHandleValue) ? extractValues[runtimeHandleValue] : extractNetObject;
}
internal ExtractValue checkType(KopiLua.Lua.lua_State luaState,int stackPos,Type paramType)
internal ExtractValue checkType(KopiLua.Lua.lua_State luaState, int stackPos, Type paramType)
{
LuaTypes luatype = KopiLua.Lua.lua_type(luaState, stackPos).ToLuaTypes();
var luatype = KopiLua.Lua.lua_type(luaState, stackPos).ToLuaTypes();
if(paramType.IsByRef) paramType=paramType.GetElementType();
if(paramType.IsByRef)
paramType = paramType.GetElementType();
Type underlyingType = Nullable.GetUnderlyingType(paramType);
if (underlyingType != null)
{
var underlyingType = Nullable.GetUnderlyingType(paramType);
if(!underlyingType.IsNull())
paramType = underlyingType; // Silently convert nullable types to their non null requics
}
long runtimeHandleValue = paramType.TypeHandle.Value.ToInt64();
if (paramType.Equals(typeof(object)))
if(paramType.Equals(typeof(object)))
return extractValues[runtimeHandleValue];
//CP: Added support for generic parameters
if (paramType.IsGenericParameter)
if(paramType.IsGenericParameter)
{
if (luatype == LuaTypes.Boolean)
if(luatype == LuaTypes.Boolean)
return extractValues[typeof(bool).TypeHandle.Value.ToInt64()];
else if (luatype == LuaTypes.String)
else if(luatype == LuaTypes.String)
return extractValues[typeof(string).TypeHandle.Value.ToInt64()];
else if (luatype == LuaTypes.Table)
else if(luatype == LuaTypes.Table)
return extractValues[typeof(LuaTable).TypeHandle.Value.ToInt64()];
else if (luatype == LuaTypes.UserData)
else if(luatype == LuaTypes.UserData)
return extractValues[typeof(object).TypeHandle.Value.ToInt64()];
else if (luatype == LuaTypes.Function)
else if(luatype == LuaTypes.Function)
return extractValues[typeof(LuaFunction).TypeHandle.Value.ToInt64()];
else if (luatype == LuaTypes.Number)
else if(luatype == LuaTypes.Number)
return extractValues[typeof(double).TypeHandle.Value.ToInt64()];
else
;//an unsupported type was encountered
//else
//;//an unsupported type was encountered
}
if (KopiLua.Lua.lua_isnumber(luaState, stackPos).ToBoolean())
if(KopiLua.Lua.lua_isnumber(luaState, stackPos).ToBoolean())
return extractValues[runtimeHandleValue];
if (paramType == typeof(bool))
if(paramType == typeof(bool))
{
if (KopiLua.Lua.lua_isboolean(luaState, stackPos))
if(KopiLua.Lua.lua_isboolean(luaState, stackPos))
return extractValues[runtimeHandleValue];
}
else if (paramType == typeof(string))
else if(paramType == typeof(string))
{
if (KopiLua.Lua.lua_isstring(luaState, stackPos).ToBoolean())
if(KopiLua.Lua.lua_isstring(luaState, stackPos).ToBoolean())
return extractValues[runtimeHandleValue];
else if (luatype == LuaTypes.Nil)
else if(luatype == LuaTypes.Nil)
return extractNetObject; // kevinh - silently convert nil to a null string pointer
}
else if (paramType == typeof(LuaTable))
else if(paramType == typeof(LuaTable))
{
if (luatype == LuaTypes.Table)
if(luatype == LuaTypes.Table)
return extractValues[runtimeHandleValue];
}
else if (paramType == typeof(LuaUserData))
else if(paramType == typeof(LuaUserData))
{
if (luatype == LuaTypes.UserData)
if(luatype == LuaTypes.UserData)
return extractValues[runtimeHandleValue];
}
else if (paramType == typeof(LuaFunction))
else if(paramType == typeof(LuaFunction))
{
if (luatype == LuaTypes.Function)
if(luatype == LuaTypes.Function)
return extractValues[runtimeHandleValue];
}
else if (typeof(Delegate).IsAssignableFrom(paramType) && luatype == LuaTypes.Function)
{
else if(typeof(Delegate).IsAssignableFrom(paramType) && luatype == LuaTypes.Function)
return new ExtractValue(new DelegateGenerator(translator, paramType).extractGenerated);
}
else if (paramType.IsInterface && luatype == LuaTypes.Table)
{
else if(paramType.IsInterface && luatype == LuaTypes.Table)
return new ExtractValue(new ClassGenerator(translator, paramType).extractGenerated);
}
else if ((paramType.IsInterface || paramType.IsClass) && luatype == LuaTypes.Nil)
else if((paramType.IsInterface || paramType.IsClass) && luatype == LuaTypes.Nil)
{
// kevinh - allow nil to be silently converted to null - extractNetObject will return null when the item ain't found
return extractNetObject;
}
else if (KopiLua.Lua.lua_type(luaState, stackPos).ToLuaTypes() == LuaTypes.Table)
else if(KopiLua.Lua.lua_type(luaState, stackPos).ToLuaTypes() == LuaTypes.Table)
{
if (KopiLua.Lua.luaL_getmetafield(luaState, stackPos, "__index").ToBoolean())
if(KopiLua.Lua.luaL_getmetafield(luaState, stackPos, "__index").ToBoolean())
{
object obj = translator.getNetObject(luaState, -1);
KopiLua.Lua.lua_settop(luaState, -2);
if (obj != null && paramType.IsAssignableFrom(obj.GetType()))
if(!obj.IsNull() && paramType.IsAssignableFrom(obj.GetType()))
return extractNetObject;
}
else
......@@ -158,7 +174,7 @@ namespace LuaInterface
else
{
object obj = translator.getNetObject(luaState, stackPos);
if (obj != null && paramType.IsAssignableFrom(obj.GetType()))
if(!obj.IsNull() && paramType.IsAssignableFrom(obj.GetType()))
return extractNetObject;
}
......@@ -170,145 +186,182 @@ namespace LuaInterface
* index stackPos as the desired type if it can, or null
* otherwise.
*/
private object getAsSbyte(KopiLua.Lua.lua_State luaState,int stackPos)
private object getAsSbyte(KopiLua.Lua.lua_State luaState, int stackPos)
{
sbyte retVal=(sbyte)KopiLua.Lua.lua_tonumber(luaState,stackPos);
if(retVal==0 && !KopiLua.Lua.lua_isnumber(luaState,stackPos).ToBoolean())
sbyte retVal = (sbyte)KopiLua.Lua.lua_tonumber(luaState, stackPos);
if(retVal == 0 && !KopiLua.Lua.lua_isnumber(luaState, stackPos).ToBoolean())
return null;
return retVal;
}
private object getAsByte(KopiLua.Lua.lua_State luaState,int stackPos)
private object getAsByte(KopiLua.Lua.lua_State luaState, int stackPos)
{
byte retVal=(byte)KopiLua.Lua.lua_tonumber(luaState,stackPos);
if(retVal==0 && !KopiLua.Lua.lua_isnumber(luaState,stackPos).ToBoolean())
byte retVal = (byte)KopiLua.Lua.lua_tonumber(luaState, stackPos);
if(retVal == 0 && !KopiLua.Lua.lua_isnumber(luaState, stackPos).ToBoolean())
return null;
return retVal;
}
private object getAsShort(KopiLua.Lua.lua_State luaState,int stackPos)
private object getAsShort(KopiLua.Lua.lua_State luaState, int stackPos)
{
short retVal=(short)KopiLua.Lua.lua_tonumber(luaState,stackPos);
if(retVal==0 && !KopiLua.Lua.lua_isnumber(luaState,stackPos).ToBoolean())
short retVal = (short)KopiLua.Lua.lua_tonumber(luaState, stackPos);
if(retVal == 0 && !KopiLua.Lua.lua_isnumber(luaState, stackPos).ToBoolean())
return null;
return retVal;
}
private object getAsUshort(KopiLua.Lua.lua_State luaState,int stackPos)
private object getAsUshort(KopiLua.Lua.lua_State luaState, int stackPos)
{
ushort retVal=(ushort)KopiLua.Lua.lua_tonumber(luaState,stackPos);
if(retVal==0 && !KopiLua.Lua.lua_isnumber(luaState,stackPos).ToBoolean()) return null;
ushort retVal = (ushort)KopiLua.Lua.lua_tonumber(luaState, stackPos);
if(retVal == 0 && !KopiLua.Lua.lua_isnumber(luaState, stackPos).ToBoolean())
return null;
return retVal;
}
private object getAsInt(KopiLua.Lua.lua_State luaState,int stackPos)
private object getAsInt(KopiLua.Lua.lua_State luaState, int stackPos)
{
int retVal=(int)KopiLua.Lua.lua_tonumber(luaState,stackPos);
if(retVal==0 && !KopiLua.Lua.lua_isnumber(luaState,stackPos).ToBoolean()) return null;
int retVal = (int)KopiLua.Lua.lua_tonumber(luaState, stackPos);
if(retVal == 0 && !KopiLua.Lua.lua_isnumber(luaState, stackPos).ToBoolean())
return null;
return retVal;
}
private object getAsUint(KopiLua.Lua.lua_State luaState,int stackPos)
private object getAsUint(KopiLua.Lua.lua_State luaState, int stackPos)
{
uint retVal=(uint)KopiLua.Lua.lua_tonumber(luaState,stackPos);
if(retVal==0 && !KopiLua.Lua.lua_isnumber(luaState,stackPos).ToBoolean()) return null;
uint retVal = (uint)KopiLua.Lua.lua_tonumber(luaState, stackPos);
if(retVal == 0 && !KopiLua.Lua.lua_isnumber(luaState, stackPos).ToBoolean())
return null;
return retVal;
}
private object getAsLong(KopiLua.Lua.lua_State luaState,int stackPos)
private object getAsLong(KopiLua.Lua.lua_State luaState, int stackPos)
{
long retVal=(long)KopiLua.Lua.lua_tonumber(luaState,stackPos);
if(retVal==0 && !KopiLua.Lua.lua_isnumber(luaState,stackPos).ToBoolean()) return null;
long retVal = (long)KopiLua.Lua.lua_tonumber(luaState, stackPos);
if(retVal == 0 && !KopiLua.Lua.lua_isnumber(luaState, stackPos).ToBoolean())
return null;
return retVal;
}
private object getAsUlong(KopiLua.Lua.lua_State luaState,int stackPos)
private object getAsUlong(KopiLua.Lua.lua_State luaState, int stackPos)
{
ulong retVal=(ulong)KopiLua.Lua.lua_tonumber(luaState,stackPos);
if(retVal==0 && !KopiLua.Lua.lua_isnumber(luaState,stackPos).ToBoolean()) return null;
ulong retVal = (ulong)KopiLua.Lua.lua_tonumber(luaState, stackPos);
if(retVal == 0 && !KopiLua.Lua.lua_isnumber(luaState, stackPos).ToBoolean())
return null;
return retVal;
}
private object getAsDouble(KopiLua.Lua.lua_State luaState,int stackPos)
private object getAsDouble(KopiLua.Lua.lua_State luaState, int stackPos)
{
double retVal=KopiLua.Lua.lua_tonumber(luaState,stackPos);
if(retVal==0 && !KopiLua.Lua.lua_isnumber(luaState,stackPos).ToBoolean()) return null;
double retVal = KopiLua.Lua.lua_tonumber(luaState, stackPos);
if(retVal == 0 && !KopiLua.Lua.lua_isnumber(luaState, stackPos).ToBoolean())
return null;
return retVal;
}
private object getAsChar(KopiLua.Lua.lua_State luaState,int stackPos)
private object getAsChar(KopiLua.Lua.lua_State luaState, int stackPos)
{
char retVal=(char)KopiLua.Lua.lua_tonumber(luaState,stackPos);
if(retVal==0 && !KopiLua.Lua.lua_isnumber(luaState,stackPos).ToBoolean()) return null;
char retVal = (char)KopiLua.Lua.lua_tonumber(luaState, stackPos);
if(retVal == 0 && !KopiLua.Lua.lua_isnumber(luaState, stackPos).ToBoolean())
return null;
return retVal;
}
private object getAsFloat(KopiLua.Lua.lua_State luaState,int stackPos)
private object getAsFloat(KopiLua.Lua.lua_State luaState, int stackPos)
{
float retVal=(float)KopiLua.Lua.lua_tonumber(luaState,stackPos);
if(retVal==0 && !KopiLua.Lua.lua_isnumber(luaState,stackPos).ToBoolean()) return null;
float retVal = (float)KopiLua.Lua.lua_tonumber(luaState, stackPos);
if(retVal == 0 && !KopiLua.Lua.lua_isnumber(luaState, stackPos).ToBoolean())
return null;
return retVal;
}
private object getAsDecimal(KopiLua.Lua.lua_State luaState,int stackPos)
private object getAsDecimal(KopiLua.Lua.lua_State luaState, int stackPos)
{
decimal retVal=(decimal)KopiLua.Lua.lua_tonumber(luaState,stackPos);
if(retVal==0 && !KopiLua.Lua.lua_isnumber(luaState,stackPos).ToBoolean()) return null;
decimal retVal = (decimal)KopiLua.Lua.lua_tonumber(luaState, stackPos);
if(retVal == 0 && !KopiLua.Lua.lua_isnumber(luaState, stackPos).ToBoolean())
return null;
return retVal;
}
private object getAsBoolean(KopiLua.Lua.lua_State luaState,int stackPos)
private object getAsBoolean(KopiLua.Lua.lua_State luaState, int stackPos)
{
return KopiLua.Lua.lua_toboolean(luaState,stackPos);
return KopiLua.Lua.lua_toboolean(luaState, stackPos);
}
private object getAsString(KopiLua.Lua.lua_State luaState,int stackPos)
private object getAsString(KopiLua.Lua.lua_State luaState, int stackPos)
{
string retVal=KopiLua.Lua.lua_tostring(luaState,stackPos).ToString();
if(retVal=="" && !KopiLua.Lua.lua_isstring(luaState,stackPos).ToBoolean()) return null;
string retVal = KopiLua.Lua.lua_tostring(luaState, stackPos).ToString();
if(retVal == string.Empty && !KopiLua.Lua.lua_isstring(luaState, stackPos).ToBoolean())
return null;
return retVal;
}
private object getAsTable(KopiLua.Lua.lua_State luaState,int stackPos)
private object getAsTable(KopiLua.Lua.lua_State luaState, int stackPos)
{
return translator.getTable(luaState,stackPos);
return translator.getTable(luaState, stackPos);
}
private object getAsFunction(KopiLua.Lua.lua_State luaState,int stackPos)
private object getAsFunction(KopiLua.Lua.lua_State luaState, int stackPos)
{
return translator.getFunction(luaState,stackPos);
return translator.getFunction(luaState, stackPos);
}
private object getAsUserdata(KopiLua.Lua.lua_State luaState,int stackPos)
private object getAsUserdata(KopiLua.Lua.lua_State luaState, int stackPos)
{
return translator.getUserData(luaState,stackPos);
return translator.getUserData(luaState, stackPos);
}
public object getAsObject(KopiLua.Lua.lua_State luaState,int stackPos)
public object getAsObject(KopiLua.Lua.lua_State luaState, int stackPos)
{
if(KopiLua.Lua.lua_type(luaState,stackPos).ToLuaTypes()==LuaTypes.Table)
if(KopiLua.Lua.lua_type(luaState, stackPos).ToLuaTypes() == LuaTypes.Table)
{
if(KopiLua.Lua.luaL_getmetafield(luaState,stackPos,"__index").ToBoolean())
if(KopiLua.Lua.luaL_getmetafield(luaState, stackPos, "__index").ToBoolean())
{
if(LuaLib.luaL_checkmetatable(luaState,-1))
if(LuaLib.luaL_checkmetatable(luaState, -1))
{
KopiLua.Lua.lua_insert(luaState,stackPos);
KopiLua.Lua.lua_remove(luaState,stackPos+1);
KopiLua.Lua.lua_insert(luaState, stackPos);
KopiLua.Lua.lua_remove(luaState, stackPos+1);
}
else
{
KopiLua.Lua.lua_settop(luaState,-2);
}
KopiLua.Lua.lua_settop(luaState, -2);
}
}
object obj=translator.getObject(luaState,stackPos);
object obj = translator.getObject(luaState, stackPos);
return obj;
}
public object getAsNetObject(KopiLua.Lua.lua_State luaState,int stackPos)
public object getAsNetObject(KopiLua.Lua.lua_State luaState, int stackPos)
{
object obj=translator.getNetObject(luaState,stackPos);
if(obj==null && KopiLua.Lua.lua_type(luaState,stackPos).ToLuaTypes()==LuaTypes.Table)
object obj = translator.getNetObject(luaState, stackPos);
if(obj.IsNull() && KopiLua.Lua.lua_type(luaState, stackPos).ToLuaTypes() == LuaTypes.Table)
{
if(KopiLua.Lua.luaL_getmetafield(luaState,stackPos,"__index").ToBoolean())
if(KopiLua.Lua.luaL_getmetafield(luaState, stackPos, "__index").ToBoolean())
{
if(LuaLib.luaL_checkmetatable(luaState,-1))
if(LuaLib.luaL_checkmetatable(luaState, -1))
{
KopiLua.Lua.lua_insert(luaState,stackPos);
KopiLua.Lua.lua_remove(luaState,stackPos+1);
obj=translator.getNetObject(luaState,stackPos);
KopiLua.Lua.lua_insert(luaState, stackPos);
KopiLua.Lua.lua_remove(luaState, stackPos+1);
obj = translator.getNetObject(luaState, stackPos);
}
else
{
KopiLua.Lua.lua_settop(luaState,-2);
}
KopiLua.Lua.lua_settop(luaState, -2);
}
}
return obj;
}
}
......
/*
* This file is part of LuaInterface.
*
* Copyright (C) 2003-2005 Fabio Mascarenhas de Queiroz.
* Copyright (C) 2012 Megax <http://megax.yeahunter.hu/>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* 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.
*/
using System;
namespace LuaInterface.Event
{
/// <summary>
/// Event args for hook callback event
/// </summary>
/// <author>Reinhard Ostermeier</author>
public class DebugHookEventArgs : EventArgs
{
private readonly LuaDebug luaDebug;
public DebugHookEventArgs(LuaDebug luaDebug)
{
this.luaDebug = luaDebug;
}
public LuaDebug LuaDebug
{
get { return luaDebug; }
}
}
}
\ No newline at end of file
/*
* This file is part of LuaInterface.
*
* Copyright (C) 2003-2005 Fabio Mascarenhas de Queiroz.
* Copyright (C) 2012 Megax <http://megax.yeahunter.hu/>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* 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.
*/
using System;
namespace LuaInterface.Event
{
/// <summary>
/// Event codes for lua hook function
/// </summary>
/// <remarks>
/// Do not change any of the values because they must match the lua values
/// </remarks>
/// <author>Reinhard Ostermeier</author>
public enum EventCodes
{
LUA_HOOKCALL = 0,
LUA_HOOKRET = 1,
LUA_HOOKLINE = 2,
LUA_HOOKCOUNT = 3,
LUA_HOOKTAILRET = 4,
}
}
\ No newline at end of file
/*
* This file is part of LuaInterface.
*
* Copyright (C) 2003-2005 Fabio Mascarenhas de Queiroz.
* Copyright (C) 2012 Megax <http://megax.yeahunter.hu/>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* 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.
*/
using System;
namespace LuaInterface.Event
{
/// <summary>
/// Event masks for lua hook callback
/// </summary>
/// <remarks>
/// Do not change any of the values because they must match the lua values
/// </remarks>
/// <author>Reinhard Ostermeier</author>
[Flags]
public enum EventMasks
{
LUA_MASKCALL = (1 << EventCodes.LUA_HOOKCALL),
LUA_MASKRET = (1 << EventCodes.LUA_HOOKRET),
LUA_MASKLINE = (1 << EventCodes.LUA_HOOKLINE),
LUA_MASKCOUNT = (1 << EventCodes.LUA_HOOKCOUNT),
LUA_MASKALL = Int32.MaxValue,
}
}
\ No newline at end of file
/*
* This file is part of LuaInterface.
*
* Copyright (C) 2003-2005 Fabio Mascarenhas de Queiroz.
* Copyright (C) 2012 Megax <http://megax.yeahunter.hu/>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* 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.
*/
using System;
namespace LuaInterface.Event
{
public class HookExceptionEventArgs : EventArgs
{
private readonly Exception m_Exception;
public Exception Exception
{
get { return m_Exception; }
}
public HookExceptionEventArgs(Exception ex)
{
m_Exception = ex;
}
}
}
\ No newline at end of file
/*
* This file is part of LuaInterface.
*
* Copyright (C) 2003-2005 Fabio Mascarenhas de Queiroz.
* Copyright (C) 2012 Megax <http://megax.yeahunter.hu/>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* 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.
*/
using System;
namespace LuaInterface.Event
{
/// <summary>
/// Structure for lua debug information
/// </summary>
/// <remarks>
/// Do not change this struct because it must match the lua structure lua_debug
/// </remarks>
/// <author>Reinhard Ostermeier</author>
[System.Runtime.InteropServices.StructLayout(System.Runtime.InteropServices.LayoutKind.Sequential)]
public struct LuaDebug
{
public EventCodes eventCode;
[System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.LPStr)]
public String name;
[System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.LPStr)]
public String namewhat;
[System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.LPStr)]
public String what;
[System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.LPStr)]
public String source;
public int currentline;
public int nups;
public int linedefined;
public int lastlinedefined;
[System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValTStr, SizeConst = 60/*LUA_IDSIZE*/)]
public String shortsrc;
public int i_ci;
}
}
\ No newline at end of file
/*
* This file is part of LuaInterface.
*
* Copyright (C) 2012 Megax <http://megax.yeahunter.hu/>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* 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.
*/
using System;
namespace LuaInterface.Extensions
{
/// <summary>
/// Some random extension stuff.
/// </summary>
static class GeneralExtensions
{
/// <summary>
/// Determines whether the specified obj is null.
/// </summary>
/// <param name="obj">The obj.</param>
/// <returns>
/// <c>true</c> if the specified obj is null; otherwise, <c>false</c>.
/// </returns>
public static bool IsNull(this object obj)
{
return (obj == null);
}
}
}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment