Skip to content

Commit

Permalink
KopiLuaInterface working - VS and Unity
Browse files Browse the repository at this point in the history
  • Loading branch information
gfoot committed Feb 22, 2012
0 parents commit d1608a2
Show file tree
Hide file tree
Showing 89 changed files with 27,241 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
*/bin
*/obj
*.suo
*/*.csproj.user

42 changes: 42 additions & 0 deletions DummyLuaInterface/DummyLua.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using System;
using System.Collections.Generic;
using System.Text;
using Lua511;

namespace DummyLuaInterface
{
public class Lua
{
KopiLua.Lua.lua_State luaState;

static string luaIndexFunction = "local function index(obj,name)\n" +
" local meta=getmetatable(obj)\n" +
" local cached=meta.cache[name]\n" +
" if cached~=nil then\n" +
" return cached\n" +
" else\n" +
" local value,isFunc=get_object_member(obj,name)\n" +
" if isFunc then\n" +
" meta.cache[name]=value\n" +
" end\n" +
" return value\n" +
" end\n" +
"end\n" +
"return index";

public Lua()
{
luaState = LuaDLL.luaL_newstate(); // steffenj: Lua 5.1.1 API change (lua_open is gone)
//LuaDLL.luaopen_base(luaState); // steffenj: luaopen_* no longer used
LuaDLL.luaL_openlibs(luaState); // steffenj: Lua 5.1.1 API change (luaopen_base is gone, just open all libs right here)

LuaDLL.lua_pushstring(luaState, "luaNet_indexfunction");
LuaDLL.luaL_dostring(luaState, luaIndexFunction); // steffenj: lua_dostring renamed to luaL_dostring
//LuaDLL.lua_pushstdcallcfunction(luaState,indexFunction);
KopiLua.Lua.WriteLine("type: {0}", LuaDLL.lua_type(luaState, -1));
KopiLua.Lua.Assert(LuaDLL.lua_type(luaState, -1) == LuaTypes.LUA_TFUNCTION, "luaNet_indexfunction ought to have been a function");

KopiLua.Lua.Assert(false);
}
}
}
65 changes: 65 additions & 0 deletions DummyLuaInterface/DummyLuaInterface.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?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>{F6583945-D4B9-4C11-93E1-2BDF84030A7E}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>DummyLuaInterface</RootNamespace>
<AssemblyName>DummyLuaInterface</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<FileUpgradeFlags>
</FileUpgradeFlags>
<UpgradeBackupLocation>
</UpgradeBackupLocation>
<OldToolsVersion>3.5</OldToolsVersion>
</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" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="DummyLua.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\KopiLuaDll\KopiLuaDll.csproj">
<Project>{A9659B55-727E-454F-B32D-E6C337031939}</Project>
<Name>KopiLuaDll</Name>
</ProjectReference>
<ProjectReference Include="..\KopiLua\KopiLua.csproj">
<Project>{B754A868-A0FB-4270-B60D-E9CFF28ED540}</Project>
<Name>KopiLua</Name>
</ProjectReference>
</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>
36 changes: 36 additions & 0 deletions DummyLuaInterface/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
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("DummyLuaInterface")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Microsoft")]
[assembly: AssemblyProduct("DummyLuaInterface")]
[assembly: AssemblyCopyright("Copyright © Microsoft 2011")]
[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("61160204-b293-4b92-b63b-f866cccd00d2")]

// 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")]
56 changes: 56 additions & 0 deletions KLI.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual C# Express 2010
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KopiLua", "KopiLua\KopiLua.csproj", "{B754A868-A0FB-4270-B60D-E9CFF28ED540}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KopiLuaDll", "KopiLuaDll\KopiLuaDll.csproj", "{A9659B55-727E-454F-B32D-E6C337031939}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KopiLuaInterface", "KopiLuaInterface\KopiLuaInterface.csproj", "{976CA064-F07C-44C4-AC50-CF834EAD0BCA}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LuaRunner", "LuaRunner\LuaRunner.csproj", "{3CE4CCB6-3465-43E3-B5ED-5FB9B70D20E5}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SimpleTest", "SimpleTest\SimpleTest.csproj", "{62A2C241-3C98-491A-B0F5-DBE40B336FDB}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestLuaInterface", "TestLuaInterface\TestLuaInterface.csproj", "{AEAB974E-4F69-4840-A2C4-7BC55F7C7C3E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DummyLuaInterface", "DummyLuaInterface\DummyLuaInterface.csproj", "{F6583945-D4B9-4C11-93E1-2BDF84030A7E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{B754A868-A0FB-4270-B60D-E9CFF28ED540}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B754A868-A0FB-4270-B60D-E9CFF28ED540}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B754A868-A0FB-4270-B60D-E9CFF28ED540}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B754A868-A0FB-4270-B60D-E9CFF28ED540}.Release|Any CPU.Build.0 = Release|Any CPU
{A9659B55-727E-454F-B32D-E6C337031939}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A9659B55-727E-454F-B32D-E6C337031939}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A9659B55-727E-454F-B32D-E6C337031939}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A9659B55-727E-454F-B32D-E6C337031939}.Release|Any CPU.Build.0 = Release|Any CPU
{976CA064-F07C-44C4-AC50-CF834EAD0BCA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{976CA064-F07C-44C4-AC50-CF834EAD0BCA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{976CA064-F07C-44C4-AC50-CF834EAD0BCA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{976CA064-F07C-44C4-AC50-CF834EAD0BCA}.Release|Any CPU.Build.0 = Release|Any CPU
{3CE4CCB6-3465-43E3-B5ED-5FB9B70D20E5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3CE4CCB6-3465-43E3-B5ED-5FB9B70D20E5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3CE4CCB6-3465-43E3-B5ED-5FB9B70D20E5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3CE4CCB6-3465-43E3-B5ED-5FB9B70D20E5}.Release|Any CPU.Build.0 = Release|Any CPU
{62A2C241-3C98-491A-B0F5-DBE40B336FDB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{62A2C241-3C98-491A-B0F5-DBE40B336FDB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{62A2C241-3C98-491A-B0F5-DBE40B336FDB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{62A2C241-3C98-491A-B0F5-DBE40B336FDB}.Release|Any CPU.Build.0 = Release|Any CPU
{AEAB974E-4F69-4840-A2C4-7BC55F7C7C3E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AEAB974E-4F69-4840-A2C4-7BC55F7C7C3E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AEAB974E-4F69-4840-A2C4-7BC55F7C7C3E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AEAB974E-4F69-4840-A2C4-7BC55F7C7C3E}.Release|Any CPU.Build.0 = Release|Any CPU
{F6583945-D4B9-4C11-93E1-2BDF84030A7E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F6583945-D4B9-4C11-93E1-2BDF84030A7E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F6583945-D4B9-4C11-93E1-2BDF84030A7E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F6583945-D4B9-4C11-93E1-2BDF84030A7E}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
86 changes: 86 additions & 0 deletions KopiLua/KopiLua.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
<?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>{B754A868-A0FB-4270-B60D-E9CFF28ED540}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>KopiLua</RootNamespace>
<AssemblyName>KopiLua</AssemblyName>
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</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;xCATCH_EXCEPTIONS;DISABLE_STDIO</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;LUA_CORE;_WIN32;LUA_COMPAT_VARARG;LUA_COMPAT_MOD;LUA_COMPAT_GFIND;xCATCH_EXCEPTIONS;DISABLE_STDIO</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="src\Debug.cs" />
<Compile Include="src\lapi.cs" />
<Compile Include="src\lauxlib.cs" />
<Compile Include="src\lbaselib.cs" />
<Compile Include="src\lcode.cs" />
<Compile Include="src\ldblib.cs" />
<Compile Include="src\ldebug.cs" />
<Compile Include="src\ldo.cs" />
<Compile Include="src\ldump.cs" />
<Compile Include="src\lfunc.cs" />
<Compile Include="src\lgc.cs" />
<Compile Include="src\linit.cs" />
<Compile Include="src\liolib.cs" />
<Compile Include="src\llex.cs" />
<Compile Include="src\llimits.cs" />
<Compile Include="src\lmathlib.cs" />
<Compile Include="src\lmem.cs" />
<Compile Include="src\loadlib.cs" />
<Compile Include="src\lobject.cs" />
<Compile Include="src\lopcodes.cs" />
<Compile Include="src\loslib.cs" />
<Compile Include="src\lparser.cs" />
<Compile Include="src\lstate.cs" />
<Compile Include="src\lstring.cs" />
<Compile Include="src\lstrlib.cs" />
<Compile Include="src\ltable.cs" />
<Compile Include="src\ltablib.cs" />
<Compile Include="src\ltm.cs" />
<Compile Include="src\lua.cs" />
<Compile Include="src\luaconf.cs" />
<Compile Include="src\lualib.cs" />
<Compile Include="src\lundump.cs" />
<Compile Include="src\lvm.cs" />
<Compile Include="src\lzio.cs" />
<Compile Include="src\print.cs" />
<Compile Include="src\printf\Tools.cs" />
</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>
36 changes: 36 additions & 0 deletions KopiLua/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
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 © 2011")]
[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("9ae9fa51-0b50-4e1e-bc3d-3f350a3c10d1")]

// 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")]
48 changes: 48 additions & 0 deletions KopiLua/src/Debug.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
namespace KopiLua
{
public partial class Lua
{

static private void DefaultWriteLine(string format, params object[] arg)
{
System.Console.WriteLine(format, arg);
}

public delegate void WriteLineFunc(string format, params object[] arg);
static public WriteLineFunc WriteLine = DefaultWriteLine;

//[System.Diagnostics.ConditionalAttribute("DEBUG")]
static public void Assert(bool condition)
{
if (condition) return;
WriteLine("Assert fail");
throw new System.Exception();
}

//[System.Diagnostics.ConditionalAttribute("DEBUG")]
static public void Assert(bool condition, string message)
{
if (condition) return;
WriteLine("Assert fail - {0}", message);
throw new System.Exception();
}

//[System.Diagnostics.ConditionalAttribute("DEBUG")]
static public void Assert(bool condition, string message, string detail)
{
if (condition) return;
WriteLine("Assert fail - {0}", message);
WriteLine(" detail: {0}", detail);
throw new System.Exception();
}

//[System.Diagnostics.ConditionalAttribute("DEBUG")]
static public void Assert(bool condition, string message, string detail, params object[] arg)
{
if (condition) return;
WriteLine("Assert fail - {0}", message);
WriteLine(" detail: " + detail, arg);
throw new System.Exception();
}
}
}
Loading

0 comments on commit d1608a2

Please sign in to comment.