64-bits compatibility

This commit is contained in:
Mark van Renswoude 2016-02-07 18:06:05 +01:00
parent 10d9e020f6
commit b250054d26
7 changed files with 57 additions and 13 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/__history/

View File

@ -69,7 +69,7 @@ const
type
size_t = Cardinal;
size_t = NativeUint;
psize_t = ^size_t;
lua_State = type Pointer;

22
Lua.pas
View File

@ -282,7 +282,7 @@ type
constructor Create(const AStream: TStream; AOwnership: TStreamOwnership = soReference); overload;
destructor Destroy; override;
function GetNextChunk(out ASize: Cardinal): PAnsiChar; virtual;
function GetNextChunk(out ASize: NativeUint): PAnsiChar; virtual;
end;
@ -300,7 +300,7 @@ type
function GetHasState: Boolean; virtual;
function GetState: lua_State; virtual;
function DoAlloc(APointer: Pointer; AOldSize, ANewSize: Cardinal): Pointer; virtual;
function DoAlloc(APointer: Pointer; AOldSize, ANewSize: NativeUint): Pointer; virtual;
procedure DoNewState; virtual;
procedure DoClose; virtual;
@ -826,7 +826,7 @@ end;
class function TLuaHelpers.LuaToString(AState: lua_State; AIndex: Integer): string;
var
len: Cardinal;
len: NativeUint;
value: PAnsiChar;
stringValue: RawByteString;
@ -1050,7 +1050,10 @@ begin
Result := BobJenkinsHash(s[1], Length(s) * SizeOf(s[1]), 0);
end;
VariableTable:
Result := Integer(Value.AsTable);
begin
p := Pointer(Value.AsTable);
Result := BobJenkinsHash(p, SizeOf(p), 0);
end;
end;
end;
@ -1203,7 +1206,7 @@ begin
end;
function TLuaScript.GetNextChunk(out ASize: Cardinal): PAnsiChar;
function TLuaScript.GetNextChunk(out ASize: NativeUint): PAnsiChar;
const
BufferSize = 4096;
@ -1594,7 +1597,7 @@ begin
end;
function TLua.DoAlloc(APointer: Pointer; AOldSize, ANewSize: Cardinal): Pointer;
function TLua.DoAlloc(APointer: Pointer; AOldSize, ANewSize: NativeUint): Pointer;
begin
Result := DefaultLuaAlloc(nil, APointer, AOldSize, ANewSize);
end;
@ -1618,7 +1621,12 @@ end;
procedure TLua.DoRegistration(ARegistration: TCustomLuaRegistration);
var
this: TLua;
begin
this := Self;
ARegistration.Apply(State,
procedure(AFunction: TLuaCFunction)
var
@ -1628,7 +1636,7 @@ begin
cookie := GetRegisteredFunctionCookie;
RegisteredFunctions.Add(cookie, AFunction);
lua_pushlightuserdata(State, Self);
lua_pushlightuserdata(State, this);
lua_pushinteger(State, Cookie);
lua_pushcclosure(State, @LuaWrapperFunction, 2);
end);

View File

@ -4,11 +4,11 @@
This project consists of two parts: a straight-up conversion of the [LuaBinaries](http://luabinaries.sourceforge.net/) 5.2 C headers to Delphi, and the TLua class to make integrating Lua with Delphi projects easier.
##### A note on compatibility
It's been tested and developed on Delphi XE2 32-bits. Minimum version for the wrapper is probably 2010, due to anonymous functions and TRttiContext being used. I also know for sure that the code isn't 64-bits compatible yet.
It's been tested and developed on Delphi XE2 32-bits and 64-bits. Minimum version for the wrapper is probably 2010, due to anonymous functions and TRttiContext being used.
### Getting started
Download lua-5.2.4_Win32_bin.zip from [LuaBinaries](http://luabinaries.sourceforge.net/) and extract lua52.dll.
Download lua-5.2.4_Win32_bin.zip or lua-5.2.4_Win64_bin.zip from [LuaBinaries](http://luabinaries.sourceforge.net/) and extract lua52.dll.
If you're just interested in the API, the [Lua manual](http://www.lua.org/manual/5.2/manual.html#4) is the best place to start.

2
UnitTests/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
*.local
*.identcache

View File

@ -6,7 +6,7 @@
<Base>True</Base>
<Config Condition="'$(Config)'==''">Debug</Config>
<Platform Condition="'$(Platform)'==''">Win32</Platform>
<TargetedPlatforms>1</TargetedPlatforms>
<TargetedPlatforms>3</TargetedPlatforms>
<AppType>Console</AppType>
<MainSource>DelphiLuaUnitTests.dpr</MainSource>
</PropertyGroup>
@ -28,6 +28,12 @@
<CfgParent>Base</CfgParent>
<Base>true</Base>
</PropertyGroup>
<PropertyGroup Condition="('$(Platform)'=='Win64' and '$(Cfg_1)'=='true') or '$(Cfg_1_Win64)'!=''">
<Cfg_1_Win64>true</Cfg_1_Win64>
<CfgParent>Cfg_1</CfgParent>
<Cfg_1>true</Cfg_1>
<Base>true</Base>
</PropertyGroup>
<PropertyGroup Condition="('$(Platform)'=='Win32' and '$(Cfg_1)'=='true') or '$(Cfg_1_Win32)'!=''">
<Cfg_1_Win32>true</Cfg_1_Win32>
<CfgParent>Cfg_1</CfgParent>
@ -39,6 +45,12 @@
<CfgParent>Base</CfgParent>
<Base>true</Base>
</PropertyGroup>
<PropertyGroup Condition="('$(Platform)'=='Win64' and '$(Cfg_2)'=='true') or '$(Cfg_2_Win64)'!=''">
<Cfg_2_Win64>true</Cfg_2_Win64>
<CfgParent>Cfg_2</CfgParent>
<Cfg_2>true</Cfg_2>
<Base>true</Base>
</PropertyGroup>
<PropertyGroup Condition="('$(Platform)'=='Win32' and '$(Cfg_2)'=='true') or '$(Cfg_2_Win32)'!=''">
<Cfg_2_Win32>true</Cfg_2_Win32>
<CfgParent>Cfg_2</CfgParent>
@ -55,9 +67,17 @@
<DCC_ExeOutput>.\bin</DCC_ExeOutput>
</PropertyGroup>
<PropertyGroup Condition="'$(Base_Win64)'!=''">
<DCC_Namespace>Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;$(DCC_Namespace)</DCC_Namespace>
<DCC_ExeOutput>.\bin\win64</DCC_ExeOutput>
<VerInfo_IncludeVerInfo>true</VerInfo_IncludeVerInfo>
<DCC_DcuOutput>.\lib\win64</DCC_DcuOutput>
<VerInfo_Locale>1033</VerInfo_Locale>
<Manifest_File>$(BDS)\bin\default_app.manifest</Manifest_File>
<DCC_UsePackage>dxdborRS16;cxLibraryRS16;dxLayoutControlRS16;dxPScxPivotGridLnkRS16;dxCoreRS16;cxExportRS16;dxBarRS16;cxSpreadSheetRS16;cxTreeListdxBarPopupMenuRS16;TeeDB;dxDBXServerModeRS16;dxPsPrVwAdvRS16;dxPSCoreRS16;dxPScxTLLnkRS16;dxPScxGridLnkRS16;cxPageControlRS16;dxRibbonRS16;DBXSybaseASEDriver;vclimg;cxTreeListRS16;dxComnRS16;vcldb;vcldsnap;dxBarExtDBItemsRS16;DBXDb2Driver;vcl;DBXMSSQLDriver;cxDataRS16;cxBarEditItemRS16;dxDockingRS16;cxPageControldxBarPopupMenuRS16;cxSchedulerGridRS16;dxPSLnksRS16;dxBarExtItemsRS16;dxtrmdRS16;webdsnap;dxPSdxLCLnkRS16;dxorgcRS16;dxWizardControlRS16;dxPScxExtCommonRS16;dxNavBarRS16;dxPSdxDBOCLnkRS16;cxSchedulerTreeBrowserRS16;Tee;DBXOdbcDriver;dxdbtrRS16;dxPScxSSLnkRS16;cxPivotGridChartRS16;dxPScxCommonRS16;dxmdsRS16;dxPSPrVwRibbonRS16;cxGridRS16;cxEditorsRS16;cxPivotGridRS16;dxPSdxDBTVLnkRS16;dxPScxSchedulerLnkRS16;TeeUI;dxServerModeRS16;bindcompvcl;vclactnband;vclie;cxSchedulerRS16;vcltouch;websnap;VclSmp;dxTabbedMDIRS16;dxPSdxOCLnkRS16;dsnapcon;dxPSdxFCLnkRS16;dxThemeRS16;dxPScxPCProdRS16;vclx;dxFlowChartRS16;dxGDIPlusRS16;dxBarDBNavRS16;$(DCC_UsePackage)</DCC_UsePackage>
</PropertyGroup>
<PropertyGroup Condition="'$(Base_Win32)'!=''">
<DCC_ExeOutput>.\bin\win32</DCC_ExeOutput>
<DCC_DcuOutput>.\lib\win32</DCC_DcuOutput>
<DCC_UsePackage>dxdborRS16;cxLibraryRS16;dxLayoutControlRS16;dxPScxPivotGridLnkRS16;dxCoreRS16;cxExportRS16;dxBarRS16;cxSpreadSheetRS16;cxTreeListdxBarPopupMenuRS16;TeeDB;dxDBXServerModeRS16;dxPsPrVwAdvRS16;vclib;dxPSCoreRS16;dxPScxTLLnkRS16;dxPScxGridLnkRS16;inetdbbde;cxPageControlRS16;dxRibbonRS16;DBXSybaseASEDriver;vclimg;cxTreeListRS16;fmi;dxComnRS16;vcldb;vcldsnap;dxBarExtDBItemsRS16;X2CLGL;DBXDb2Driver;vcl;CloudService;DBXMSSQLDriver;CodeSiteExpressPkg;FmxTeeUI;cxDataRS16;cxBarEditItemRS16;dxDockingRS16;cxPageControldxBarPopupMenuRS16;cxSchedulerGridRS16;dxPSLnksRS16;dxBarExtItemsRS16;dxtrmdRS16;webdsnap;X2CLMB;OmniThreadLibraryRuntimeXE2;adortl;dxPSdxLCLnkRS16;dxorgcRS16;dxWizardControlRS16;dxPScxExtCommonRS16;vcldbx;dxNavBarRS16;dxPSdxDBOCLnkRS16;cxSchedulerTreeBrowserRS16;Tee;DBXOdbcDriver;dxdbtrRS16;svnui;dxPScxSSLnkRS16;cxPivotGridChartRS16;dxPScxCommonRS16;dxmdsRS16;dxPSPrVwRibbonRS16;ibxpress;cxGridRS16;cxEditorsRS16;cxPivotGridRS16;dxPSdxDBTVLnkRS16;FMXTee;dxPScxSchedulerLnkRS16;TeeUI;dxServerModeRS16;bindcompvcl;vclactnband;vclie;cxSchedulerRS16;vcltouch;websnap;VclSmp;dxTabbedMDIRS16;DataSnapConnectors;dxPSdxOCLnkRS16;dsnapcon;dxPSdxFCLnkRS16;dxThemeRS16;dxPScxPCProdRS16;vclx;svn;dxFlowChartRS16;bdertl;VirtualTreesR;dxGDIPlusRS16;dxBarDBNavRS16;$(DCC_UsePackage)</DCC_UsePackage>
<DCC_Namespace>Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace)</DCC_Namespace>
<VerInfo_Locale>1033</VerInfo_Locale>
@ -69,6 +89,13 @@
<DCC_DebugInfoInExe>true</DCC_DebugInfoInExe>
<DCC_RemoteDebug>true</DCC_RemoteDebug>
</PropertyGroup>
<PropertyGroup Condition="'$(Cfg_1_Win64)'!=''">
<DCC_ExeOutput>.\bin\win64</DCC_ExeOutput>
<VerInfo_IncludeVerInfo>true</VerInfo_IncludeVerInfo>
<Manifest_File>$(BDS)\bin\default_app.manifest</Manifest_File>
<VerInfo_Locale>1033</VerInfo_Locale>
<DCC_DcuOutput>.\lib\win64</DCC_DcuOutput>
</PropertyGroup>
<PropertyGroup Condition="'$(Cfg_1_Win32)'!=''">
<VerInfo_Locale>1033</VerInfo_Locale>
<DCC_RemoteDebug>false</DCC_RemoteDebug>
@ -79,6 +106,11 @@
<DCC_SymbolReferenceInfo>0</DCC_SymbolReferenceInfo>
<DCC_DebugInformation>false</DCC_DebugInformation>
</PropertyGroup>
<PropertyGroup Condition="'$(Cfg_2_Win64)'!=''">
<VerInfo_IncludeVerInfo>true</VerInfo_IncludeVerInfo>
<Manifest_File>$(BDS)\bin\default_app.manifest</Manifest_File>
<VerInfo_Locale>1033</VerInfo_Locale>
</PropertyGroup>
<PropertyGroup Condition="'$(Cfg_2_Win32)'!=''">
<VerInfo_Locale>1033</VerInfo_Locale>
</PropertyGroup>
@ -138,12 +170,13 @@
<Source Name="MainSource">DelphiLuaUnitTests.dpr</Source>
</Source>
<Excluded_Packages>
<Excluded_Packages Name="F:\Components\bin\DXE2\win32\JvBDEDesign160.bpl">JVCL BDE Components</Excluded_Packages>
<Excluded_Packages Name="$(BDSBIN)\dcloffice2k160.bpl">Microsoft Office 2000 Sample Automation Server Wrapper Components</Excluded_Packages>
<Excluded_Packages Name="$(BDSBIN)\dclofficexp160.bpl">Microsoft Office XP Sample Automation Server Wrapper Components</Excluded_Packages>
</Excluded_Packages>
</Delphi.Personality>
<Deployment/>
<Platforms>
<Platform value="Win64">False</Platform>
<Platform value="Win64">True</Platform>
<Platform value="OSX32">False</Platform>
<Platform value="Win32">True</Platform>
</Platforms>

Binary file not shown.