Commit b969a882 authored by Megax's avatar Megax
Browse files

* Project fajlok at lettek alakitva. Igy most mindegyik normalisan hasznalhato...

* Project fajlok at lettek alakitva. Igy most mindegyik normalisan hasznalhato forditasnal. Nincsenek hibak. KopiLua-ba kerult egy fix. Nem ertem mitol jott elo az a hiba ami elojott de most van a kodban (vagy is volt mert fixaltam).
parent d7bb0c93
using System;
using LuaInterface;
using System.Threading;
/*
* Application to run Lua scripts that can use LuaInterface
* from the console
*
* Author: Fabio Mascarenhas
* Version: 1.0
*/
namespace LuaRunner
{
public class LuaNetRunner
{
/*
* Runs the Lua script passed as the first command-line argument.
* It passed all the command-line arguments to the script.
*/
[STAThread] // steffenj: testluaform.lua "Load" button complained with an exception that STAThread was missing
public static void Main(string[] args)
{
if(args.Length > 0)
{
// For attaching from the debugger
// Thread.Sleep(20000);
using (Lua lua = new Lua())
{
//lua.OpenLibs(); // steffenj: Lua 5.1.1 API change (all libs already opened in Lua constructor!)
lua.NewTable("arg");
LuaTable argc = (LuaTable)lua["arg"];
argc[-1] = "LuaRunner";
argc[0] = args[0];
for (int i = 1; i < args.Length; i++)
{
argc[i] = args[i];
}
argc["n"] = args.Length - 1;
try
{
//Console.WriteLine("DoFile(" + args[0] + ");");
lua.DoFile(args[0]);
}
catch (Exception e)
{
// steffenj: BEGIN error message improved, output is now in decending order of importance (message, where, stacktrace)
// limit size of strack traceback message to roughly 1 console screen height
string trace = e.StackTrace;
if (e.StackTrace.Length > 1300)
trace = e.StackTrace.Substring(0, 1300) + " [...] (traceback cut short)";
Console.WriteLine();
Console.WriteLine(e.Message);
Console.WriteLine(e.Source + " raised a " + e.GetType().ToString());
Console.WriteLine(trace);
// wait for keypress if there is an error
Console.ReadKey();
// steffenj: END error message improved
}
}
}
else
{
Console.WriteLine("LuaRunner -- runs Lua scripts with CLR access");
Console.WriteLine("Usage: luarunner <script.lua> [{<arg>}]");
}
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<ProductVersion>9.0.21022</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{3CE4CCB6-3465-43E3-B5ED-5FB9B70D20E5}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>LuaRunner</RootNamespace>
<AssemblyName>LuaRunner</AssemblyName>
<ReleaseVersion>2.x</ReleaseVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\..\Run\Debug</OutputPath>
<DefineConstants>DEBUG</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PlatformTarget>x86</PlatformTarget>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<DebugType>none</DebugType>
<Optimize>true</Optimize>
<OutputPath>..\..\Run\Release</OutputPath>
<DefineConstants>RELEASE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PlatformTarget>x86</PlatformTarget>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\..\Run\Debug_x64</OutputPath>
<DefineConstants>DEBUG</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PlatformTarget>x64</PlatformTarget>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' ">
<DebugType>none</DebugType>
<Optimize>true</Optimize>
<OutputPath>..\..\Run\Release_x64</OutputPath>
<DefineConstants>RELEASE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PlatformTarget>x64</PlatformTarget>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="LuaNetRunner.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Core\LuaInterface\LuaInterface.csproj">
<Project>{F55CABBB-4108-4A39-94E1-581FD46DC021}</Project>
<Name>LuaInterface</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
<Visible>False</Visible>
<ProductName>Windows Installer 3.1</ProductName>
<Install>true</Install>
</BootstrapperPackage>
</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("LuaRunner")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("LuaRunner")]
[assembly: AssemblyCopyright("Copyright © 2006")]
[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("0db73438-fb76-4991-b61d-3c072d340154")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
[assembly: AssemblyVersion("1.5.2")]
[assembly: AssemblyFileVersion("1.5.2")]
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.30729</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{E8DDBC21-EF74-4ABA-9C49-BFC702BE25D8}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Lua</RootNamespace>
<AssemblyName>KopiLua</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<FileUpgradeFlags>
</FileUpgradeFlags>
<OldToolsVersion>3.5</OldToolsVersion>
<UpgradeBackupLocation />
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>TRACE;DEBUG;LUA_CORE;_WIN32;LUA_COMPAT_VARARG;LUA_COMPAT_MOD;LUA_COMPAT_GFIND;CATCH_EXCEPTIONS</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE;LUA_CORE;_WIN32;LUA_COMPAT_VARARG;LUA_COMPAT_MOD;LUA_COMPAT_GFIND;CATCH_EXCEPTIONS</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data.DataSetExtensions">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data" />
</ItemGroup>
<ItemGroup>
<Compile Include="lapi.cs" />
<Compile Include="lauxlib.cs" />
<Compile Include="lbaselib.cs" />
<Compile Include="lcode.cs" />
<Compile Include="ldblib.cs" />
<Compile Include="ldebug.cs" />
<Compile Include="ldo.cs" />
<Compile Include="ldump.cs" />
<Compile Include="lfunc.cs" />
<Compile Include="lgc.cs" />
<Compile Include="linit.cs" />
<Compile Include="liolib.cs" />
<Compile Include="llex.cs" />
<Compile Include="llimits.cs" />
<Compile Include="lmathlib.cs" />
<Compile Include="lmem.cs" />
<Compile Include="loadlib.cs" />
<Compile Include="lobject.cs" />
<Compile Include="lopcodes.cs" />
<Compile Include="loslib.cs" />
<Compile Include="lparser.cs" />
<Compile Include="lstate.cs" />
<Compile Include="lstring.cs" />
<Compile Include="lstrlib.cs" />
<Compile Include="ltable.cs" />
<Compile Include="ltablib.cs" />
<Compile Include="ltm.cs" />
<Compile Include="lua.cs" />
<Compile Include="luaconf.cs" />
<Compile Include="lualib.cs" />
<Compile Include="lundump.cs" />
<Compile Include="lvm.cs" />
<Compile Include="lzio.cs" />
<Compile Include="print.cs" />
<Compile Include="printf\Tools.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
<Visible>False</Visible>
<ProductName>Клиентский профиль .NET Framework 3.5 SP1</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
<Visible>False</Visible>
<ProductName>Установщик Windows 3.1</ProductName>
<Install>true</Install>
</BootstrapperPackage>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\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>
-->
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<ProductVersion>9.0.30729</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{E8DDBC21-EF74-4ABA-9C49-BFC702BE25D8}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Lua</RootNamespace>
<AssemblyName>KopiLua</AssemblyName>
<ReleaseVersion>2.x</ReleaseVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\..\Run\Debug</OutputPath>
<DefineConstants>TRACE;DEBUG;LUA_CORE;_WIN32;LUA_COMPAT_VARARG;LUA_COMPAT_MOD;LUA_COMPAT_GFIND;CATCH_EXCEPTIONS</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PlatformTarget>x86</PlatformTarget>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<DebugType>none</DebugType>
<Optimize>true</Optimize>
<OutputPath>..\..\Run\Release</OutputPath>
<DefineConstants>TRACE;RELEASE;LUA_CORE;_WIN32;LUA_COMPAT_VARARG;LUA_COMPAT_MOD;LUA_COMPAT_GFIND;CATCH_EXCEPTIONS</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PlatformTarget>x86</PlatformTarget>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\..\Run\Debug_x64</OutputPath>
<DefineConstants>TRACE;DEBUG;LUA_CORE;_WIN32;LUA_COMPAT_VARARG;LUA_COMPAT_MOD;LUA_COMPAT_GFIND;CATCH_EXCEPTIONS</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PlatformTarget>x64</PlatformTarget>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' ">
<DebugType>none</DebugType>
<Optimize>true</Optimize>
<OutputPath>..\..\Run\Release_x64</OutputPath>
<DefineConstants>TRACE;RELEASE;LUA_CORE;_WIN32;LUA_COMPAT_VARARG;LUA_COMPAT_MOD;LUA_COMPAT_GFIND;CATCH_EXCEPTIONS</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PlatformTarget>x64</PlatformTarget>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Data" />
</ItemGroup>
<ItemGroup>
<Compile Include="lapi.cs" />
<Compile Include="lauxlib.cs" />
<Compile Include="lbaselib.cs" />
<Compile Include="lcode.cs" />
<Compile Include="ldblib.cs" />
<Compile Include="ldebug.cs" />
<Compile Include="ldo.cs" />
<Compile Include="ldump.cs" />
<Compile Include="lfunc.cs" />
<Compile Include="lgc.cs" />
<Compile Include="linit.cs" />
<Compile Include="liolib.cs" />
<Compile Include="llex.cs" />
<Compile Include="llimits.cs" />
<Compile Include="lmathlib.cs" />
<Compile Include="lmem.cs" />
<Compile Include="loadlib.cs" />
<Compile Include="lobject.cs" />
<Compile Include="lopcodes.cs" />
<Compile Include="loslib.cs" />
<Compile Include="lparser.cs" />
<Compile Include="lstate.cs" />
<Compile Include="lstring.cs" />
<Compile Include="lstrlib.cs" />
<Compile Include="ltable.cs" />
<Compile Include="ltablib.cs" />
<Compile Include="ltm.cs" />
<Compile Include="lua.cs" />
<Compile Include="luaconf.cs" />
<Compile Include="lualib.cs" />
<Compile Include="lundump.cs" />
<Compile Include="lvm.cs" />
<Compile Include="lzio.cs" />
<Compile Include="print.cs" />
<Compile Include="printf\Tools.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
<Visible>False</Visible>
<ProductName>Клиентский профиль .NET Framework 3.5 SP1</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
<Visible>False</Visible>
<ProductName>Установщик Windows 3.1</ProductName>
<Install>true</Install>
</BootstrapperPackage>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\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("KopiLua")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("KopiLua")]
[assembly: AssemblyCopyright("Copyright © 2009 Mark Feldman")]
[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("1a9cd761-692f-40db-8566-c0217e5d3e0a")]
// 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")]
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("KopiLua")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("KopiLua")]
[assembly: AssemblyCopyright("Copyright © 2009 Mark Feldman")]
[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("1a9cd761-692f-40db-8566-c0217e5d3e0a")]
// 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")]
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/*
** $Id: ldump.c,v 2.8.1.1 2007/12/27 13:02:25 roberto Exp $
** save precompiled Lua chunks
** See Copyright Notice in lua.h
*/
using System;
using System.IO;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
using System.Diagnostics;
using System.Runtime.Serialization;
namespace KopiLua
{
using lua_Number = System.Double;
using TValue = Lua.lua_TValue;
public partial class Lua
{
public class DumpState {
public lua_State L;
public lua_Writer writer;
public object data;
public int strip;
public int status;
};
public static void DumpMem(object b, DumpState D)
{
#if XBOX || SILVERLIGHT
// todo: implement this - mjf
Debug.Assert(false);
#else
int size = Marshal.SizeOf(b);
IntPtr ptr = Marshal.AllocHGlobal(size);
Marshal.StructureToPtr(b, ptr, false);
byte[] bytes = new byte[size];
Marshal.Copy(ptr, bytes, 0, size);
char[] ch = new char[bytes.Length];
for (int i = 0; i < bytes.Length; i++)
ch[i] = (char)bytes[i];
CharPtr str = ch;
DumpBlock(str, (uint)str.chars.Length, D);
Marshal.Release(ptr);
#endif
}
public static void DumpMem(object b, int n, DumpState D)
{
Array array = b as Array;
Debug.Assert(array.Length == n);
for (int i = 0; i < n; i++)
DumpMem(array.GetValue(i), D);
}
public static void DumpVar(object x, DumpState D)
{
DumpMem(x, D);
}
private static void DumpBlock(CharPtr b, uint size, DumpState D)
{
if (D.status==0)
{
lua_unlock(D.L);
D.status=D.writer(D.L,b,size,D.data);
lua_lock(D.L);
}
}
private static void DumpChar(int y, DumpState D)
{
char x=(char)y;
DumpVar(x,D);
}
private static void DumpInt(int x, DumpState D)
{
DumpVar(x,D);
}
private static void DumpNumber(lua_Number x, DumpState D)
{
DumpVar(x,D);
}
static void DumpVector(object b, int n, DumpState D)
{
DumpInt(n,D);
DumpMem(b, n, D);
}
private static void DumpString(TString s, DumpState D)
{
if (s==null || getstr(s)==null)
{
uint size=0;
DumpVar(size,D);
}
else
{
uint size=s.tsv.len+1; /* include trailing '\0' */
DumpVar(size,D);
DumpBlock(getstr(s),size,D);
}
}
private static void DumpCode(Proto f,DumpState D)
{
DumpVector(f.code, f.sizecode, D);
}
private static void DumpConstants(Proto f, DumpState D)
{
int i,n=f.sizek;
DumpInt(n,D);
for (i=0; i<n; i++)
{
/*const*/ TValue o=f.k[i];
DumpChar(ttype(o),D);
switch (ttype(o))
{
case LUA_TNIL:
break;
case LUA_TBOOLEAN:
DumpChar(bvalue(o),D);
break;
case LUA_TNUMBER:
DumpNumber(nvalue(o),D);
break;
case LUA_TSTRING:
DumpString(rawtsvalue(o),D);
break;
default:
lua_assert(0); /* cannot happen */
break;
}
}
n=f.sizep;
DumpInt(n,D);
for (i=0; i<n; i++) DumpFunction(f.p[i],f.source,D);
}
private static void DumpDebug(Proto f, DumpState D)
{
int i,n;
n= (D.strip != 0) ? 0 : f.sizelineinfo;
DumpVector(f.lineinfo, n, D);
n= (D.strip != 0) ? 0 : f.sizelocvars;
DumpInt(n,D);
for (i=0; i<n; i++)
{
DumpString(f.locvars[i].varname,D);
DumpInt(f.locvars[i].startpc,D);
DumpInt(f.locvars[i].endpc,D);
}
n= (D.strip != 0) ? 0 : f.sizeupvalues;
DumpInt(n,D);
for (i=0; i<n; i++) DumpString(f.upvalues[i],D);
}
private static void DumpFunction(Proto f, TString p, DumpState D)
{
DumpString( ((f.source==p) || (D.strip!=0)) ? null : f.source, D);
DumpInt(f.linedefined,D);
DumpInt(f.lastlinedefined,D);
DumpChar(f.nups,D);
DumpChar(f.numparams,D);
DumpChar(f.is_vararg,D);
DumpChar(f.maxstacksize,D);
DumpCode(f,D);
DumpConstants(f,D);
DumpDebug(f,D);
}
private static void DumpHeader(DumpState D)
{
CharPtr h = new char[LUAC_HEADERSIZE];
luaU_header(h);
DumpBlock(h,LUAC_HEADERSIZE,D);
}
/*
** dump Lua function as precompiled chunk
*/
public static int luaU_dump (lua_State L, Proto f, lua_Writer w, object data, int strip)
{
DumpState D = new DumpState();
D.L=L;
D.writer=w;
D.data=data;
D.strip=strip;
D.status=0;
DumpHeader(D);
DumpFunction(f,null,D);
return D.status;
}
}
}
/*
** $Id: ldump.c,v 2.8.1.1 2007/12/27 13:02:25 roberto Exp $
** save precompiled Lua chunks
** See Copyright Notice in lua.h
*/
using System;
using System.IO;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
using System.Diagnostics;
using System.Runtime.Serialization;
namespace KopiLua
{
using lua_Number = System.Double;
using TValue = Lua.lua_TValue;
public partial class Lua
{
public class DumpState {
public lua_State L;
public lua_Writer writer;
public object data;
public int strip;
public int status;
};
public static void DumpMem(object b, DumpState D)
{
#if XBOX || SILVERLIGHT
// todo: implement this - mjf
Debug.Assert(false);
#else
int size = Marshal.SizeOf(b);
IntPtr ptr = Marshal.AllocHGlobal(size);
Marshal.StructureToPtr(b, ptr, false);
byte[] bytes = new byte[size];
Marshal.Copy(ptr, bytes, 0, size);
char[] ch = new char[bytes.Length];
for (int i = 0; i < bytes.Length; i++)
ch[i] = (char)bytes[i];
CharPtr str = ch;
DumpBlock(str, (uint)str.chars.Length, D);
Marshal.Release(ptr);
#endif
}
public static void DumpMem(object b, int n, DumpState D)
{
Array array = b as Array;
Debug.Assert(array.Length == n);
for (int i = 0; i < n; i++)
DumpMem(array.GetValue(i), D);
}
public static void DumpVar(object x, DumpState D)
{
DumpMem(x, D);
}
private static void DumpBlock(CharPtr b, uint size, DumpState D)
{
if (D.status==0)
{
lua_unlock(D.L);
D.status=D.writer(D.L,b,size,D.data);
lua_lock(D.L);
}
}
private static void DumpChar(int y, DumpState D)
{
char x=(char)y;
DumpVar(x,D);
}
private static void DumpInt(int x, DumpState D)
{
DumpVar(x,D);
}
private static void DumpNumber(lua_Number x, DumpState D)
{
DumpVar(x,D);
}
static void DumpVector(object b, int n, DumpState D)
{
DumpInt(n,D);
DumpMem(b, n, D);
}
private static void DumpString(TString s, DumpState D)
{
if (s==null || getstr(s)==null)
{
uint size=0;
DumpVar(size,D);
}
else
{
uint size=s.tsv.len+1; /* include trailing '\0' */
DumpVar(size,D);
DumpBlock(getstr(s),size,D);
}
}
private static void DumpCode(Proto f,DumpState D)
{
DumpVector(f.code, f.sizecode, D);
}
private static void DumpConstants(Proto f, DumpState D)
{
int i,n=f.sizek;
DumpInt(n,D);
for (i=0; i<n; i++)
{
/*const*/ TValue o=f.k[i];
DumpChar(ttype(o),D);
switch (ttype(o))
{
case LUA_TNIL:
break;
case LUA_TBOOLEAN:
DumpChar(bvalue(o),D);
break;
case LUA_TNUMBER:
DumpNumber(nvalue(o),D);
break;
case LUA_TSTRING:
DumpString(rawtsvalue(o),D);
break;
default:
lua_assert(0); /* cannot happen */
break;
}
}
n=f.sizep;
DumpInt(n,D);
for (i=0; i<n; i++) DumpFunction(f.p[i],f.source,D);
}
private static void DumpDebug(Proto f, DumpState D)
{
int i,n;
n= (D.strip != 0) ? 0 : f.sizelineinfo;
DumpVector(f.lineinfo, n, D);
n= (D.strip != 0) ? 0 : f.sizelocvars;
DumpInt(n,D);
for (i=0; i<n; i++)
{
DumpString(f.locvars[i].varname,D);
DumpInt(f.locvars[i].startpc,D);
DumpInt(f.locvars[i].endpc,D);
}
n= (D.strip != 0) ? 0 : f.sizeupvalues;
DumpInt(n,D);
for (i=0; i<n; i++) DumpString(f.upvalues[i],D);
}
private static void DumpFunction(Proto f, TString p, DumpState D)
{
DumpString( ((f.source==p) || (D.strip!=0)) ? null : f.source, D);
DumpInt(f.linedefined,D);
DumpInt(f.lastlinedefined,D);
DumpChar(f.nups,D);
DumpChar(f.numparams,D);
DumpChar(f.is_vararg,D);
DumpChar(f.maxstacksize,D);
DumpCode(f,D);
DumpConstants(f,D);
DumpDebug(f,D);
}
private static void DumpHeader(DumpState D)
{
CharPtr h = new char[LUAC_HEADERSIZE];
luaU_header(h);
DumpBlock(h,LUAC_HEADERSIZE,D);
}
/*
** dump Lua function as precompiled chunk
*/
public static int luaU_dump (lua_State L, Proto f, lua_Writer w, object data, int strip)
{
DumpState D = new DumpState();
D.L=L;
D.writer=w;
D.data=data;
D.strip=strip;
D.status=0;
DumpHeader(D);
DumpFunction(f,null,D);
return D.status;
}
}
}
This diff is collapsed.
This diff is collapsed.
/*
** $Id: linit.c,v 1.14.1.1 2007/12/27 13:02:25 roberto Exp $
** Initialization of libraries for lua.c
** See Copyright Notice in lua.h
*/
using System;
using System.Collections.Generic;
using System.Text;
namespace KopiLua
{
public partial class Lua
{
private readonly static luaL_Reg[] lualibs = {
new luaL_Reg("", luaopen_base),
new luaL_Reg(LUA_LOADLIBNAME, luaopen_package),
new luaL_Reg(LUA_TABLIBNAME, luaopen_table),
new luaL_Reg(LUA_IOLIBNAME, luaopen_io),
new luaL_Reg(LUA_OSLIBNAME, luaopen_os),
new luaL_Reg(LUA_STRLIBNAME, luaopen_string),
new luaL_Reg(LUA_MATHLIBNAME, luaopen_math),
new luaL_Reg(LUA_DBLIBNAME, luaopen_debug),
new luaL_Reg(null, null)
};
public static void luaL_openlibs (lua_State L) {
for (int i=0; i<lualibs.Length-1; i++)
{
luaL_Reg lib = lualibs[i];
lua_pushcfunction(L, lib.func);
lua_pushstring(L, lib.name);
lua_call(L, 1, 0);
}
}
}
}
/*
** $Id: linit.c,v 1.14.1.1 2007/12/27 13:02:25 roberto Exp $
** Initialization of libraries for lua.c
** See Copyright Notice in lua.h
*/
using System;
using System.Collections.Generic;
using System.Text;
namespace KopiLua
{
public partial class Lua
{
private readonly static luaL_Reg[] lualibs = {
new luaL_Reg("", luaopen_base),
new luaL_Reg(LUA_LOADLIBNAME, luaopen_package),
new luaL_Reg(LUA_TABLIBNAME, luaopen_table),
new luaL_Reg(LUA_IOLIBNAME, luaopen_io),
new luaL_Reg(LUA_OSLIBNAME, luaopen_os),
new luaL_Reg(LUA_STRLIBNAME, luaopen_string),
new luaL_Reg(LUA_MATHLIBNAME, luaopen_math),
new luaL_Reg(LUA_DBLIBNAME, luaopen_debug),
new luaL_Reg(null, null)
};
public static void luaL_openlibs (lua_State L) {
for (int i=0; i<lualibs.Length-1; i++)
{
luaL_Reg lib = lualibs[i];
lua_pushcfunction(L, lib.func);
lua_pushstring(L, lib.name);
lua_call(L, 1, 0);
}
}
}
}
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