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
# Visual Studio 2010
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LuaInterface", "LuaInterface\LuaInterface.csproj", "{F55CABBB-4108-4A39-94E1-581FD46DC021}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LuaWrap", "LuaWrap\LuaWrap.csproj", "{76D7F266-456D-4A7C-916E-E35D057E5F98}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
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.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.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(MonoDevelopProperties) = preSolution
StartupItem = LuaInterface.csproj
StartupItem = LuaInterface\LuaInterface.csproj
EndGlobalSection
EndGlobal
......@@ -3,7 +3,7 @@ using System.Collections.Generic;
using System.Reflection;
using LuaWrap;
namespace LuaInterface
namespace Mono.LuaInterface
{
/*
* Type checking and conversion functions.
......
......@@ -5,7 +5,7 @@ using System.Reflection;
using System.Reflection.Emit;
using System.Threading;
namespace LuaInterface
namespace Mono.LuaInterface
{
/*
* Structure to store a type and the return types of
......
namespace LuaInterface
namespace Mono.LuaInterface
{
using System;
......@@ -273,12 +273,14 @@ namespace LuaInterface
returnValue=getObject(remainingPath);
}
LuaLib.lua_settop(luaState,oldTop);
//Console.WriteLine("get: {0}", returnValue);
return returnValue;
}
set
{
int oldTop=LuaLib.lua_gettop(luaState);
string[] path=fullPath.Split(new char[] { '.' });
//Console.WriteLine("set: {0}", path.Length);
if(path.Length==1)
{
translator.push(luaState,value);
......
......@@ -2,7 +2,7 @@ using System;
using System.Collections.Generic;
using System.Text;
namespace LuaInterface
namespace Mono.LuaInterface
{
/// <summary>
/// Add a specific type for Lua exceptions (kevinh)
......
......@@ -36,7 +36,6 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="AssemblyInfo.cs" />
<Compile Include="CheckType.cs" />
<Compile Include="GenerateEventAssembly.cs" />
<Compile Include="Lua.cs" />
......@@ -45,9 +44,8 @@
<Compile Include="MethodWrapper.cs" />
<Compile Include="ObjectTranslator.cs" />
<Compile Include="ProxyType.cs" />
</ItemGroup>
<ItemGroup>
<Folder Include="Properties\" />
<Compile Include="LuaLib\LuaLib.cs" />
<Compile Include="Properties\AssemblyInfo.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.
......@@ -58,9 +56,10 @@
</Target>
-->
<ItemGroup>
<ProjectReference Include="..\LuaWrap\LuaWrap.csproj">
<Project>{76D7F266-456D-4A7C-916E-E35D057E5F98}</Project>
<Name>LuaWrap</Name>
</ProjectReference>
<None Include="..\Dependencies\liblua5.1.so">
<Link>liblua5.1.so</Link>
<Gettext-ScanForTranslations>false</Gettext-ScanForTranslations>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>
......@@ -152,7 +152,7 @@ namespace LuaWrap
public static class LuaLib
{
private const string Lib = "lua51.dll";
private const string Lib = "liblua5.1.so";
private static int tag = 0;
#region Core Library
......@@ -1126,7 +1126,7 @@ namespace LuaWrap
/// </returns>
public static extern bool luaL_getmetafield( IntPtr state, int index, string key );
[DllImport( Lib, CallingConvention = CallingConvention.Cdecl )]
//[DllImport( Lib, CallingConvention = CallingConvention.Cdecl )]
/// <summary>
/// Pushes onto the stack the metatable associated with name tname in the registry (see luaL_newmetatable).
/// </summary>
......@@ -1136,7 +1136,11 @@ namespace LuaWrap
/// <param name="key">
/// A <see cref="System.String"/>
/// </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 )]
/// <summary>
......@@ -1345,7 +1349,7 @@ namespace LuaWrap
public static bool luaL_checkmetatable(IntPtr luaState,int index)
{
bool retVal=false;
bool retVal = false;
if(lua_getmetatable(luaState,index)!=0)
{
......@@ -1424,9 +1428,8 @@ namespace LuaWrap
public static void luanet_newudata(IntPtr luaState,int val)
{
/*IntPtr pointer= *///lua_newuserdata(luaState, sizeof(int));
lua_newuserdata(luaState, val);
//pointer=(IntPtr)val;
IntPtr pointer = lua_newuserdata(luaState, sizeof(int));
pointer = (IntPtr)val;
}
public static int luanet_tonetobject(IntPtr luaState,int index)
......@@ -1437,9 +1440,9 @@ namespace LuaWrap
{
if(luaL_checkmetatable(luaState, index))
{
udata=(IntPtr) lua_touserdata(luaState,index);
if(udata!=(IntPtr)0)
return udata.ToInt32();
udata=(IntPtr) lua_touserdata(luaState,index);
if(udata!=(IntPtr)0)
return udata.ToInt32();
}
udata=(IntPtr)checkudata_raw(luaState,index, "luaNet_class");
......
namespace LuaInterface
namespace Mono.LuaInterface
{
using System;
using System.IO;
......
namespace LuaInterface
namespace Mono.LuaInterface
{
using System;
using System.IO;
......
namespace LuaInterface
namespace Mono.LuaInterface
{
using System;
using System.IO;
......@@ -269,8 +269,9 @@ namespace LuaInterface
// Pushes the object again, this time as the base field
// of the table and with the luaNet_searchbase metatable
LuaLib.lua_pushstring(luaState, "base");
int index = addObject(obj);
pushNewObject(luaState, obj, index, "luaNet_searchbase");
//int index = addObject(obj);
//pushNewObject(luaState, obj, index, "luaNet_searchbase");
pushNewObject(luaState, obj, 0, "luaNet_searchbase");
LuaLib.lua_rawset(luaState, 1);
}
else
......@@ -439,9 +440,10 @@ namespace LuaInterface
collectObject(o, index); // Remove from both our tables and fall out to get a new ID
}
index = addObject(o);
pushNewObject(luaState,o,index,metatable);
//index = addObject(o);
//Console.WriteLine("pushObject: {0}", index);
pushNewObject(luaState,o,0,metatable);
//pushNewObject(luaState,o,index,metatable);
}
......@@ -489,7 +491,12 @@ namespace LuaInterface
// Stores the object index in the Lua list and pushes the
// index into the Lua stack
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_remove(luaState,-4);
LuaLib.lua_setmetatable(luaState,-2);
......@@ -552,7 +559,7 @@ namespace LuaInterface
// New object: inserts it in the list
int index = nextObj++;
// Debug.WriteLine("Adding " + obj.ToString() + " @ " + index);
//Console.WriteLine("Adding " + obj.ToString() + " @ " + index);
objects[index] = obj;
objectsBackMap[obj] = index;
......@@ -560,7 +567,18 @@ namespace LuaInterface
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.
......@@ -568,6 +586,7 @@ namespace LuaInterface
internal object getObject(IntPtr luaState,int index)
{
LuaType type=LuaLib.lua_type(luaState,index);
switch(type)
{
case LuaType.Number:
......@@ -593,6 +612,7 @@ namespace LuaInterface
case LuaType.UserData:
{
int udata=LuaLib.luanet_tonetobject(luaState,index);
if(udata!=-1)
return objects[udata];
else
......@@ -739,6 +759,7 @@ namespace LuaInterface
*/
internal void push(IntPtr luaState, object o)
{
Console.WriteLine("push: {0}, {1}", o, luaState);
if(o==null)
{
LuaLib.lua_pushnil(luaState);
......
......@@ -22,7 +22,7 @@ using System.Security.Permissions;
// You can specify all the values or you can default the Revision and Build Numbers
// 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
......
......@@ -2,7 +2,7 @@ using System;
using System.Globalization;
using System.Reflection;
namespace LuaInterface
namespace Mono.LuaInterface
{
/// <summary>
/// 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