Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,187 changes: 651 additions & 536 deletions SQLite.Net.sln

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion nuget/SQLite.Net.Platform.XamarinIOS.nuspec
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata>
<id>SQLite.Net.Platform.XamarinIOS</id>
Expand All @@ -21,5 +21,6 @@ Many changes, please see commit log.</releaseNotes>
</metadata>
<files>
<file src="SQLite.Net.Platform.XamarinIOS\SQLite.Net.Platform.XamarinIOS.dll" target="lib\monotouch\SQLite.Net.Platform.XamarinIOS.dll" />
<file src="SQLite.Net.Platform.XamarinIOS.Unified\SQLite.Net.Platform.XamarinIOS.Unified.dll" target="lib\Xamarin.iOS10\SQLite.Net.Platform.XamarinIOS.Unified.dll" />
</files>
</package>
3 changes: 3 additions & 0 deletions nuget/prepare.bat
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,6 @@ copy ..\src\SQLite.Net.Platform.XamarinAndroid\bin\Release\SQLite.Net.Platform.X

mkdir SQLite.Net.Platform.XamarinIOS
copy ..\src\SQLite.Net.Platform.XamarinIOS\bin\iPhone\Release\SQLite.Net.Platform.XamarinIOS.dll SQLite.Net.Platform.XamarinIOS

mkdir SQLite.Net.Platform.XamarinIOS.Unified
copy ..\src\SQLite.Net.Platform.XamarinIOS.Unified\bin\iPhone\Release\SQLite.Net.Platform.XamarinIOS.Unified.dll SQLite.Net.Platform.XamarinIOS.Unified
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// Information about this assembly is defined by the following attributes.
// Change them to the values specific to your project.

[assembly: AssemblyTitle ("SQLite.Net.Platform.XamarinIOS.Unified")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Leon Lucardie")]
[assembly: AssemblyProduct("SQLite.Net.Platform.XamarinIOS.Unified")]
[assembly: AssemblyCopyright("Copyright ©Øystein Krog 2013-2015")]
[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 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("")]

31 changes: 31 additions & 0 deletions src/SQLite.Net.Platform.XamarinIOS.Unified/ReflectionServiceIOS.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Reflection;
using SQLite.Net.Interop;

namespace SQLite.Net.Platform.XamarinIOS
{
public class ReflectionServiceIOS : IReflectionService
{
public IEnumerable<PropertyInfo> GetPublicInstanceProperties(Type mappedType)
{
return mappedType.GetProperties(BindingFlags.Public | BindingFlags.Instance | BindingFlags.SetProperty);
}

public object GetMemberValue(object obj, Expression expr, MemberInfo member)
{
if (member.MemberType == MemberTypes.Property)
{
var m = (PropertyInfo) member;
return m.GetValue(obj, null);
}
if (member.MemberType == MemberTypes.Field)
{
var m = (FieldInfo) member;
return m.GetValue(obj);
}
throw new NotSupportedException("MemberExpr: " + member.MemberType);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectTypeGuids>{FEACFBD2-3405-455C-9665-78FE426C6842};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<ProjectGuid>{3173703F-8B1F-4772-9AE3-44913F413FB1}</ProjectGuid>
<OutputType>Library</OutputType>
<RootNamespace>SQLite.Net.Platform.XamarinIOS.Unified</RootNamespace>
<IPhoneResourcePrefix>Resources</IPhoneResourcePrefix>
<AssemblyName>SQLite.Net.Platform.XamarinIOS.Unified</AssemblyName>
</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>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>full</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Xml" />
<Reference Include="System.Core" />
<Reference Include="Xamarin.iOS" />
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="..\GlobalAssemblyInfo.cs">
<Link>Properties\GlobalAssemblyInfo.cs</Link>
</Compile>
<Compile Include="ReflectionServiceIOS.cs" />
<Compile Include="SQLiteApiIOS.cs" />
<Compile Include="SQLiteApiIOSInternal.cs" />
<Compile Include="SQLitePlatformIOS.cs" />
<Compile Include="StopwatchFactoryIOS.cs" />
<Compile Include="VolatileServiceIOS.cs" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.CSharp.targets" />
<ItemGroup>
<ProjectReference Include="..\SQLite.Net\SQLite.Net.csproj">
<Project>{4971D437-0694-4297-A8CC-146CE08C3BD9}</Project>
<Name>SQLite.Net</Name>
</ProjectReference>
</ItemGroup>
</Project>
242 changes: 242 additions & 0 deletions src/SQLite.Net.Platform.XamarinIOS.Unified/SQLiteApiIOS.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,242 @@
using System;
using System.Runtime.InteropServices;
using SQLite.Net.Interop;

namespace SQLite.Net.Platform.XamarinIOS
{
public class SQLiteApiIOS : ISQLiteApi
{
public Result Open(byte[] filename, out IDbHandle db, int flags, IntPtr zvfs)
{
IntPtr dbPtr;
Result r = SQLiteApiIOSInternal.sqlite3_open_v2(filename, out dbPtr, flags, zvfs);
db = new DbHandle(dbPtr);
return r;
}

public ExtendedResult ExtendedErrCode(IDbHandle db)
{
var internalDbHandle = (DbHandle) db;
return SQLiteApiIOSInternal.sqlite3_extended_errcode(internalDbHandle.DbPtr);
}

public int LibVersionNumber()
{
return SQLiteApiIOSInternal.sqlite3_libversion_number();
}

public Result EnableLoadExtension(IDbHandle db, int onoff)
{
var internalDbHandle = (DbHandle) db;
return SQLiteApiIOSInternal.sqlite3_enable_load_extension(internalDbHandle.DbPtr, onoff);
}

public Result Close(IDbHandle db)
{
var internalDbHandle = (DbHandle) db;
return SQLiteApiIOSInternal.sqlite3_close(internalDbHandle.DbPtr);
}

public Result Initialize()
{
return SQLiteApiIOSInternal.sqlite3_initialize();
}
public Result Shutdown()
{
return SQLiteApiIOSInternal.sqlite3_shutdown();
}

public Result Config(ConfigOption option)
{
return SQLiteApiIOSInternal.sqlite3_config(option);
}

public Result BusyTimeout(IDbHandle db, int milliseconds)
{
var internalDbHandle = (DbHandle) db;
return SQLiteApiIOSInternal.sqlite3_busy_timeout(internalDbHandle.DbPtr, milliseconds);
}

public int Changes(IDbHandle db)
{
var internalDbHandle = (DbHandle) db;
return SQLiteApiIOSInternal.sqlite3_changes(internalDbHandle.DbPtr);
}

public IDbStatement Prepare2(IDbHandle db, string query)
{
var internalDbHandle = (DbHandle) db;
IntPtr stmt;
Result r = SQLiteApiIOSInternal.sqlite3_prepare_v2(internalDbHandle.DbPtr, query, query.Length, out stmt, IntPtr.Zero);
if (r != Result.OK)
{
throw SQLiteException.New(r, Errmsg16(internalDbHandle));
}
return new DbStatement(stmt);
}

public Result Step(IDbStatement stmt)
{
var internalStmt = (DbStatement) stmt;
return SQLiteApiIOSInternal.sqlite3_step(internalStmt.StmtPtr);
}

public Result Reset(IDbStatement stmt)
{
var internalStmt = (DbStatement) stmt;
return SQLiteApiIOSInternal.sqlite3_reset(internalStmt.StmtPtr);
}

public Result Finalize(IDbStatement stmt)
{
var internalStmt = (DbStatement) stmt;
return SQLiteApiIOSInternal.sqlite3_finalize(internalStmt.StmtPtr);
}

public long LastInsertRowid(IDbHandle db)
{
var internalDbHandle = (DbHandle) db;
return SQLiteApiIOSInternal.sqlite3_last_insert_rowid(internalDbHandle.DbPtr);
}

public string Errmsg16(IDbHandle db)
{
var internalDbHandle = (DbHandle) db;
return Marshal.PtrToStringUni(SQLiteApiIOSInternal.sqlite3_errmsg16(internalDbHandle.DbPtr));
}

public int BindParameterIndex(IDbStatement stmt, string name)
{
var internalStmt = (DbStatement) stmt;
return SQLiteApiIOSInternal.sqlite3_bind_parameter_index(internalStmt.StmtPtr, name);
}

public int BindNull(IDbStatement stmt, int index)
{
var internalStmt = (DbStatement) stmt;
return SQLiteApiIOSInternal.sqlite3_bind_null(internalStmt.StmtPtr, index);
}

public int BindInt(IDbStatement stmt, int index, int val)
{
var internalStmt = (DbStatement) stmt;
return SQLiteApiIOSInternal.sqlite3_bind_int(internalStmt.StmtPtr, index, val);
}

public int BindInt64(IDbStatement stmt, int index, long val)
{
var internalStmt = (DbStatement) stmt;
return SQLiteApiIOSInternal.sqlite3_bind_int64(internalStmt.StmtPtr, index, val);
}

public int BindDouble(IDbStatement stmt, int index, double val)
{
var internalStmt = (DbStatement) stmt;
return SQLiteApiIOSInternal.sqlite3_bind_double(internalStmt.StmtPtr, index, val);
}

public int BindText16(IDbStatement stmt, int index, string val, int n, IntPtr free)
{
var internalStmt = (DbStatement) stmt;
return SQLiteApiIOSInternal.sqlite3_bind_text16(internalStmt.StmtPtr, index, val, n, free);
}

public int BindBlob(IDbStatement stmt, int index, byte[] val, int n, IntPtr free)
{
var internalStmt = (DbStatement) stmt;
return SQLiteApiIOSInternal.sqlite3_bind_blob(internalStmt.StmtPtr, index, val, n, free);
}

public int ColumnCount(IDbStatement stmt)
{
var internalStmt = (DbStatement) stmt;
return SQLiteApiIOSInternal.sqlite3_column_count(internalStmt.StmtPtr);
}

public string ColumnName16(IDbStatement stmt, int index)
{
var internalStmt = (DbStatement) stmt;
return SQLiteApiIOSInternal.ColumnName16(internalStmt.StmtPtr, index);
}

public ColType ColumnType(IDbStatement stmt, int index)
{
var internalStmt = (DbStatement) stmt;
return SQLiteApiIOSInternal.sqlite3_column_type(internalStmt.StmtPtr, index);
}

public int ColumnInt(IDbStatement stmt, int index)
{
var internalStmt = (DbStatement) stmt;
return SQLiteApiIOSInternal.sqlite3_column_int(internalStmt.StmtPtr, index);
}

public long ColumnInt64(IDbStatement stmt, int index)
{
var internalStmt = (DbStatement) stmt;
return SQLiteApiIOSInternal.sqlite3_column_int64(internalStmt.StmtPtr, index);
}

public double ColumnDouble(IDbStatement stmt, int index)
{
var internalStmt = (DbStatement) stmt;
return SQLiteApiIOSInternal.sqlite3_column_double(internalStmt.StmtPtr, index);
}

public string ColumnText16(IDbStatement stmt, int index)
{
var internalStmt = (DbStatement) stmt;
return Marshal.PtrToStringUni(SQLiteApiIOSInternal.sqlite3_column_text16(internalStmt.StmtPtr, index));
}

public byte[] ColumnBlob(IDbStatement stmt, int index)
{
var internalStmt = (DbStatement) stmt;
return SQLiteApiIOSInternal.ColumnBlob(internalStmt.StmtPtr, index);
}

public int ColumnBytes(IDbStatement stmt, int index)
{
var internalStmt = (DbStatement) stmt;
return SQLiteApiIOSInternal.sqlite3_column_bytes(internalStmt.StmtPtr, index);
}

public byte[] ColumnByteArray(IDbStatement stmt, int index)
{
var internalStmt = (DbStatement) stmt;
return SQLiteApiIOSInternal.ColumnByteArray(internalStmt.StmtPtr, index);
}

private struct DbHandle : IDbHandle
{
public DbHandle(IntPtr dbPtr)
: this()
{
DbPtr = dbPtr;
}

internal IntPtr DbPtr { get; set; }

public bool Equals(IDbHandle other)
{
return other is DbHandle && DbPtr == ((DbHandle) other).DbPtr;
}
}

private struct DbStatement : IDbStatement
{
public DbStatement(IntPtr stmtPtr)
: this()
{
StmtPtr = stmtPtr;
}

internal IntPtr StmtPtr { get; set; }

public bool Equals(IDbStatement other)
{
return other is DbStatement && StmtPtr == ((DbStatement) other).StmtPtr;
}
}
}
}
Loading