Commit 0032a2c3 authored by Megax's avatar Megax
Browse files

* Kód tökéletesitve.

parent e6f33788
...@@ -3,24 +3,18 @@ Microsoft Visual Studio Solution File, Format Version 11.00 ...@@ -3,24 +3,18 @@ Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010 # Visual Studio 2010
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LuaInterface", "LuaInterface\LuaInterface.csproj", "{F55CABBB-4108-4A39-94E1-581FD46DC021}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LuaInterface", "LuaInterface\LuaInterface.csproj", "{F55CABBB-4108-4A39-94E1-581FD46DC021}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LuaWrap", "LuaWrap\LuaWrap.csproj", "{76D7F266-456D-4A7C-916E-E35D057E5F98}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU Release|Any CPU = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution GlobalSection(ProjectConfigurationPlatforms) = postSolution
{76D7F266-456D-4A7C-916E-E35D057E5F98}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{76D7F266-456D-4A7C-916E-E35D057E5F98}.Debug|Any CPU.Build.0 = Debug|Any CPU
{76D7F266-456D-4A7C-916E-E35D057E5F98}.Release|Any CPU.ActiveCfg = Release|Any CPU
{76D7F266-456D-4A7C-916E-E35D057E5F98}.Release|Any CPU.Build.0 = Release|Any CPU
{F55CABBB-4108-4A39-94E1-581FD46DC021}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {F55CABBB-4108-4A39-94E1-581FD46DC021}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F55CABBB-4108-4A39-94E1-581FD46DC021}.Debug|Any CPU.Build.0 = Debug|Any CPU {F55CABBB-4108-4A39-94E1-581FD46DC021}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F55CABBB-4108-4A39-94E1-581FD46DC021}.Release|Any CPU.ActiveCfg = Release|Any CPU {F55CABBB-4108-4A39-94E1-581FD46DC021}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F55CABBB-4108-4A39-94E1-581FD46DC021}.Release|Any CPU.Build.0 = Release|Any CPU {F55CABBB-4108-4A39-94E1-581FD46DC021}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(MonoDevelopProperties) = preSolution GlobalSection(MonoDevelopProperties) = preSolution
StartupItem = LuaInterface.csproj StartupItem = LuaInterface\LuaInterface.csproj
EndGlobalSection EndGlobalSection
EndGlobal EndGlobal
...@@ -3,7 +3,7 @@ using System.Collections.Generic; ...@@ -3,7 +3,7 @@ using System.Collections.Generic;
using System.Reflection; using System.Reflection;
using LuaWrap; using LuaWrap;
namespace LuaInterface namespace Mono.LuaInterface
{ {
/* /*
* Type checking and conversion functions. * Type checking and conversion functions.
......
...@@ -5,7 +5,7 @@ using System.Reflection; ...@@ -5,7 +5,7 @@ using System.Reflection;
using System.Reflection.Emit; using System.Reflection.Emit;
using System.Threading; using System.Threading;
namespace LuaInterface namespace Mono.LuaInterface
{ {
/* /*
* Structure to store a type and the return types of * Structure to store a type and the return types of
......
namespace LuaInterface namespace Mono.LuaInterface
{ {
using System; using System;
...@@ -273,12 +273,14 @@ namespace LuaInterface ...@@ -273,12 +273,14 @@ namespace LuaInterface
returnValue=getObject(remainingPath); returnValue=getObject(remainingPath);
} }
LuaLib.lua_settop(luaState,oldTop); LuaLib.lua_settop(luaState,oldTop);
//Console.WriteLine("get: {0}", returnValue);
return returnValue; return returnValue;
} }
set set
{ {
int oldTop=LuaLib.lua_gettop(luaState); int oldTop=LuaLib.lua_gettop(luaState);
string[] path=fullPath.Split(new char[] { '.' }); string[] path=fullPath.Split(new char[] { '.' });
//Console.WriteLine("set: {0}", path.Length);
if(path.Length==1) if(path.Length==1)
{ {
translator.push(luaState,value); translator.push(luaState,value);
......
...@@ -2,7 +2,7 @@ using System; ...@@ -2,7 +2,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
namespace LuaInterface namespace Mono.LuaInterface
{ {
/// <summary> /// <summary>
/// Add a specific type for Lua exceptions (kevinh) /// Add a specific type for Lua exceptions (kevinh)
......
...@@ -36,7 +36,6 @@ ...@@ -36,7 +36,6 @@
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="AssemblyInfo.cs" />
<Compile Include="CheckType.cs" /> <Compile Include="CheckType.cs" />
<Compile Include="GenerateEventAssembly.cs" /> <Compile Include="GenerateEventAssembly.cs" />
<Compile Include="Lua.cs" /> <Compile Include="Lua.cs" />
...@@ -45,9 +44,8 @@ ...@@ -45,9 +44,8 @@
<Compile Include="MethodWrapper.cs" /> <Compile Include="MethodWrapper.cs" />
<Compile Include="ObjectTranslator.cs" /> <Compile Include="ObjectTranslator.cs" />
<Compile Include="ProxyType.cs" /> <Compile Include="ProxyType.cs" />
</ItemGroup> <Compile Include="LuaLib\LuaLib.cs" />
<ItemGroup> <Compile Include="Properties\AssemblyInfo.cs" />
<Folder Include="Properties\" />
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
...@@ -58,9 +56,10 @@ ...@@ -58,9 +56,10 @@
</Target> </Target>
--> -->
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\LuaWrap\LuaWrap.csproj"> <None Include="..\Dependencies\liblua5.1.so">
<Project>{76D7F266-456D-4A7C-916E-E35D057E5F98}</Project> <Link>liblua5.1.so</Link>
<Name>LuaWrap</Name> <Gettext-ScanForTranslations>false</Gettext-ScanForTranslations>
</ProjectReference> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup> </ItemGroup>
</Project> </Project>
...@@ -152,7 +152,7 @@ namespace LuaWrap ...@@ -152,7 +152,7 @@ namespace LuaWrap
public static class LuaLib public static class LuaLib
{ {
private const string Lib = "lua51.dll"; private const string Lib = "liblua5.1.so";
private static int tag = 0; private static int tag = 0;
#region Core Library #region Core Library
...@@ -1126,7 +1126,7 @@ namespace LuaWrap ...@@ -1126,7 +1126,7 @@ namespace LuaWrap
/// </returns> /// </returns>
public static extern bool luaL_getmetafield( IntPtr state, int index, string key ); public static extern bool luaL_getmetafield( IntPtr state, int index, string key );
[DllImport( Lib, CallingConvention = CallingConvention.Cdecl )] //[DllImport( Lib, CallingConvention = CallingConvention.Cdecl )]
/// <summary> /// <summary>
/// Pushes onto the stack the metatable associated with name tname in the registry (see luaL_newmetatable). /// Pushes onto the stack the metatable associated with name tname in the registry (see luaL_newmetatable).
/// </summary> /// </summary>
...@@ -1136,7 +1136,11 @@ namespace LuaWrap ...@@ -1136,7 +1136,11 @@ namespace LuaWrap
/// <param name="key"> /// <param name="key">
/// A <see cref="System.String"/> /// A <see cref="System.String"/>
/// </param> /// </param>
public static extern void luaL_getmetatable( IntPtr state, string key ); //public static extern void luaL_getmetatable( IntPtr state, string key );
public static void luaL_getmetatable( IntPtr luaState, string key )
{
lua_getfield(luaState, (int) PseudoIndex.Registry, key);
}
[DllImport( Lib, CallingConvention = CallingConvention.Cdecl )] [DllImport( Lib, CallingConvention = CallingConvention.Cdecl )]
/// <summary> /// <summary>
...@@ -1345,7 +1349,7 @@ namespace LuaWrap ...@@ -1345,7 +1349,7 @@ namespace LuaWrap
public static bool luaL_checkmetatable(IntPtr luaState,int index) public static bool luaL_checkmetatable(IntPtr luaState,int index)
{ {
bool retVal=false; bool retVal = false;
if(lua_getmetatable(luaState,index)!=0) if(lua_getmetatable(luaState,index)!=0)
{ {
...@@ -1424,9 +1428,8 @@ namespace LuaWrap ...@@ -1424,9 +1428,8 @@ namespace LuaWrap
public static void luanet_newudata(IntPtr luaState,int val) public static void luanet_newudata(IntPtr luaState,int val)
{ {
/*IntPtr pointer= *///lua_newuserdata(luaState, sizeof(int)); IntPtr pointer = lua_newuserdata(luaState, sizeof(int));
lua_newuserdata(luaState, val); pointer = (IntPtr)val;
//pointer=(IntPtr)val;
} }
public static int luanet_tonetobject(IntPtr luaState,int index) public static int luanet_tonetobject(IntPtr luaState,int index)
...@@ -1437,9 +1440,9 @@ namespace LuaWrap ...@@ -1437,9 +1440,9 @@ namespace LuaWrap
{ {
if(luaL_checkmetatable(luaState, index)) if(luaL_checkmetatable(luaState, index))
{ {
udata=(IntPtr) lua_touserdata(luaState,index); udata=(IntPtr) lua_touserdata(luaState,index);
if(udata!=(IntPtr)0) if(udata!=(IntPtr)0)
return udata.ToInt32(); return udata.ToInt32();
} }
udata=(IntPtr)checkudata_raw(luaState,index, "luaNet_class"); udata=(IntPtr)checkudata_raw(luaState,index, "luaNet_class");
......
namespace LuaInterface namespace Mono.LuaInterface
{ {
using System; using System;
using System.IO; using System.IO;
......
namespace LuaInterface namespace Mono.LuaInterface
{ {
using System; using System;
using System.IO; using System.IO;
......
namespace LuaInterface namespace Mono.LuaInterface
{ {
using System; using System;
using System.IO; using System.IO;
...@@ -269,8 +269,9 @@ namespace LuaInterface ...@@ -269,8 +269,9 @@ namespace LuaInterface
// Pushes the object again, this time as the base field // Pushes the object again, this time as the base field
// of the table and with the luaNet_searchbase metatable // of the table and with the luaNet_searchbase metatable
LuaLib.lua_pushstring(luaState, "base"); LuaLib.lua_pushstring(luaState, "base");
int index = addObject(obj); //int index = addObject(obj);
pushNewObject(luaState, obj, index, "luaNet_searchbase"); //pushNewObject(luaState, obj, index, "luaNet_searchbase");
pushNewObject(luaState, obj, 0, "luaNet_searchbase");
LuaLib.lua_rawset(luaState, 1); LuaLib.lua_rawset(luaState, 1);
} }
else else
...@@ -439,9 +440,10 @@ namespace LuaInterface ...@@ -439,9 +440,10 @@ namespace LuaInterface
collectObject(o, index); // Remove from both our tables and fall out to get a new ID collectObject(o, index); // Remove from both our tables and fall out to get a new ID
} }
index = addObject(o); //index = addObject(o);
//Console.WriteLine("pushObject: {0}", index);
pushNewObject(luaState,o,index,metatable); pushNewObject(luaState,o,0,metatable);
//pushNewObject(luaState,o,index,metatable);
} }
...@@ -489,7 +491,12 @@ namespace LuaInterface ...@@ -489,7 +491,12 @@ namespace LuaInterface
// Stores the object index in the Lua list and pushes the // Stores the object index in the Lua list and pushes the
// index into the Lua stack // index into the Lua stack
LuaLib.luaL_getmetatable(luaState,"luaNet_objects"); LuaLib.luaL_getmetatable(luaState,"luaNet_objects");
LuaLib.luanet_newudata(luaState,index); //Console.WriteLine("luaState2:" + luaState);
nextObj++;
index = LuaLib.lua_newuserdata(luaState, nextObj).ToInt32();
addObject(o, index);
//LuaLib.luanet_newudata(luaState,index);
//Console.WriteLine("index:"+index);
LuaLib.lua_pushvalue(luaState,-3); LuaLib.lua_pushvalue(luaState,-3);
LuaLib.lua_remove(luaState,-4); LuaLib.lua_remove(luaState,-4);
LuaLib.lua_setmetatable(luaState,-2); LuaLib.lua_setmetatable(luaState,-2);
...@@ -552,7 +559,7 @@ namespace LuaInterface ...@@ -552,7 +559,7 @@ namespace LuaInterface
// New object: inserts it in the list // New object: inserts it in the list
int index = nextObj++; int index = nextObj++;
// Debug.WriteLine("Adding " + obj.ToString() + " @ " + index); //Console.WriteLine("Adding " + obj.ToString() + " @ " + index);
objects[index] = obj; objects[index] = obj;
objectsBackMap[obj] = index; objectsBackMap[obj] = index;
...@@ -560,7 +567,18 @@ namespace LuaInterface ...@@ -560,7 +567,18 @@ namespace LuaInterface
return index; return index;
} }
int addObject(object obj, int index)
{
// New object: inserts it in the list
//int index = nextObj++;
//Console.WriteLine("Adding " + obj.ToString() + " @ " + index);
objects[index] = obj;
objectsBackMap[obj] = index;
return index;
}
/* /*
* Gets an object from the Lua stack according to its Lua type. * Gets an object from the Lua stack according to its Lua type.
...@@ -568,6 +586,7 @@ namespace LuaInterface ...@@ -568,6 +586,7 @@ namespace LuaInterface
internal object getObject(IntPtr luaState,int index) internal object getObject(IntPtr luaState,int index)
{ {
LuaType type=LuaLib.lua_type(luaState,index); LuaType type=LuaLib.lua_type(luaState,index);
switch(type) switch(type)
{ {
case LuaType.Number: case LuaType.Number:
...@@ -593,6 +612,7 @@ namespace LuaInterface ...@@ -593,6 +612,7 @@ namespace LuaInterface
case LuaType.UserData: case LuaType.UserData:
{ {
int udata=LuaLib.luanet_tonetobject(luaState,index); int udata=LuaLib.luanet_tonetobject(luaState,index);
if(udata!=-1) if(udata!=-1)
return objects[udata]; return objects[udata];
else else
...@@ -739,6 +759,7 @@ namespace LuaInterface ...@@ -739,6 +759,7 @@ namespace LuaInterface
*/ */
internal void push(IntPtr luaState, object o) internal void push(IntPtr luaState, object o)
{ {
Console.WriteLine("push: {0}, {1}", o, luaState);
if(o==null) if(o==null)
{ {
LuaLib.lua_pushnil(luaState); LuaLib.lua_pushnil(luaState);
......
...@@ -22,7 +22,7 @@ using System.Security.Permissions; ...@@ -22,7 +22,7 @@ using System.Security.Permissions;
// You can specify all the values or you can default the Revision and Build Numbers // You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
[assembly: AssemblyVersion("2.0.0.*")] [assembly: AssemblyVersion("2.0.1.*")]
// //
// In order to sign your assembly you must specify a key to use. Refer to the // In order to sign your assembly you must specify a key to use. Refer to the
......
...@@ -2,7 +2,7 @@ using System; ...@@ -2,7 +2,7 @@ using System;
using System.Globalization; using System.Globalization;
using System.Reflection; using System.Reflection;
namespace LuaInterface namespace Mono.LuaInterface
{ {
/// <summary> /// <summary>
/// Summary description for ProxyType. /// Summary description for ProxyType.
......
//
// AssemblyInfo.cs
//
// Author:
// Joshua Simmons <simmons.44@gmail.com>
//
// Copyright (c) 2009 Joshua Simmons
//
// 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.Reflection;
using System.Runtime.CompilerServices;
// Information about this assembly is defined by the following attributes.
// Change them to the values specific to your project.
[assembly: AssemblyTitle("LuaWrap")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("")]
[assembly: AssemblyCopyright("")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
// The form "{Major}.{Minor}.*" will automatically update the build and revision,
// and "{Major}.{Minor}.{Build}.*" will update just the revision.
[assembly: AssemblyVersion("1.0.*")]
// The following attributes are used to specify the signing key for the assembly,
// if desired. See the Mono documentation for more information about signing.
//[assembly: AssemblyDelaySign(false)]
[assembly: AssemblyKeyFile("")]
<?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)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.50727</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{76D7F266-456D-4A7C-916E-E35D057E5F98}</ProjectGuid>
<OutputType>Library</OutputType>
<RootNamespace>LuaWrap</RootNamespace>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug</OutputPath>
<DefineConstants>DEBUG</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
<AssemblyName>LuaWrap</AssemblyName>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>none</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Release</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
<AssemblyName>Lua</AssemblyName>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core">
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="LuaLib.cs" />
<Compile Include="AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>
<Resource Include="LuaWrap.dll.config">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Resource>
</ItemGroup>
</Project>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<dllmap os="!windows" dll="lua5.1.dll" target="lua5.1" ></dllmap>
</configuration>
\ 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