Skip to content
This repository has been archived by the owner on Nov 14, 2018. It is now read-only.

Commit

Permalink
#92
Browse files Browse the repository at this point in the history
  • Loading branch information
adamansky committed Aug 15, 2013
1 parent e8195bd commit 4b9ec9f
Show file tree
Hide file tree
Showing 13 changed files with 141 additions and 47 deletions.
52 changes: 26 additions & 26 deletions Ejdb.DB/EJDB.cs
Expand Up @@ -153,13 +153,13 @@ public class EJDB : IDisposable {
// Native functions refs
//.//////////////////////////////////////////////////////////////////
#region NativeRefs
[DllImport(EJDB_LIB_NAME, EntryPoint="ejdbnew")]
[DllImport(EJDB_LIB_NAME, EntryPoint = "ejdbnew", CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr _ejdbnew();

[DllImport(EJDB_LIB_NAME, EntryPoint="ejdbdel")]
[DllImport(EJDB_LIB_NAME, EntryPoint = "ejdbdel", CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr _ejdbdel([In] IntPtr db);

[DllImport(EJDB_LIB_NAME, EntryPoint="ejdbopen")]
[DllImport(EJDB_LIB_NAME, EntryPoint = "ejdbopen", CallingConvention = CallingConvention.Cdecl)]
internal static extern bool _ejdbopen([In] IntPtr db, [In] IntPtr path, int mode);

internal static bool _ejdbopen(IntPtr db, string path, int mode) {
Expand All @@ -171,19 +171,19 @@ public class EJDB : IDisposable {
}
}

[DllImport(EJDB_LIB_NAME, EntryPoint="ejdbclose")]
[DllImport(EJDB_LIB_NAME, EntryPoint = "ejdbclose", CallingConvention = CallingConvention.Cdecl)]
internal static extern bool _ejdbclose([In] IntPtr db);

[DllImport(EJDB_LIB_NAME, EntryPoint="ejdbisopen")]
[DllImport(EJDB_LIB_NAME, EntryPoint = "ejdbisopen", CallingConvention = CallingConvention.Cdecl)]
internal static extern bool _ejdbisopen([In] IntPtr db);

[DllImport(EJDB_LIB_NAME, EntryPoint="ejdbecode")]
[DllImport(EJDB_LIB_NAME, EntryPoint = "ejdbecode", CallingConvention = CallingConvention.Cdecl)]
internal static extern int _ejdbecode([In] IntPtr db);

[DllImport(EJDB_LIB_NAME, EntryPoint="ejdberrmsg")]
[DllImport(EJDB_LIB_NAME, EntryPoint = "ejdberrmsg", CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr _ejdberrmsg(int ecode);

[DllImport(EJDB_LIB_NAME, EntryPoint="ejdbgetcoll")]
[DllImport(EJDB_LIB_NAME, EntryPoint = "ejdbgetcoll", CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr _ejdbgetcoll([In] IntPtr db, [In] IntPtr cname);

internal static IntPtr _ejdbgetcoll(IntPtr db, string cname) {
Expand All @@ -195,10 +195,10 @@ public class EJDB : IDisposable {
}
}

[DllImport(EJDB_LIB_NAME, EntryPoint="ejdbcreatecoll")]
[DllImport(EJDB_LIB_NAME, EntryPoint = "ejdbcreatecoll", CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr _ejdbcreatecoll([In] IntPtr db, [In] IntPtr cname, IntPtr opts);

[DllImport(EJDB_LIB_NAME, EntryPoint="ejdbcreatecoll")]
[DllImport(EJDB_LIB_NAME, EntryPoint = "ejdbcreatecoll", CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr _ejdbcreatecoll([In] IntPtr db, [In] IntPtr cname, ref EJDBCollectionOptionsN opts);

internal static IntPtr _ejdbcreatecoll(IntPtr db, String cname, EJDBCollectionOptionsN? opts) {
Expand All @@ -215,7 +215,7 @@ public class EJDB : IDisposable {
}
}
//EJDB_EXPORT bool ejdbrmcoll(EJDB *jb, const char *colname, bool unlinkfile);
[DllImport(EJDB_LIB_NAME, EntryPoint="ejdbrmcoll")]
[DllImport(EJDB_LIB_NAME, EntryPoint = "ejdbrmcoll", CallingConvention = CallingConvention.Cdecl)]
internal static extern bool _ejdbrmcoll([In] IntPtr db, [In] IntPtr cname, bool unlink);

internal static bool _ejdbrmcoll(IntPtr db, string cname, bool unlink) {
Expand All @@ -227,49 +227,49 @@ public class EJDB : IDisposable {
}
}
//EJDB_EXPORT bson* ejdbcommand(EJDB *jb, bson *cmd);
[DllImport(EJDB_LIB_NAME, EntryPoint="ejdbcommand2")]
[DllImport(EJDB_LIB_NAME, EntryPoint = "ejdbcommand2", CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr _ejdbcommand([In] IntPtr db, [In] byte[] cmd);
//EJDB_EXPORT bool ejdbsavebson3(EJCOLL *jcoll, void *bsdata, bson_oid_t *oid, bool merge);
[DllImport(EJDB_LIB_NAME, EntryPoint="ejdbsavebson3")]
[DllImport(EJDB_LIB_NAME, EntryPoint = "ejdbsavebson3", CallingConvention = CallingConvention.Cdecl)]
internal static extern bool _ejdbsavebson([In] IntPtr coll, [In] byte[] bsdata, [Out] byte[] oid, [In] bool merge);
//EJDB_EXPORT bson* ejdbloadbson(EJCOLL *coll, const bson_oid_t *oid);
[DllImport(EJDB_LIB_NAME, EntryPoint="ejdbloadbson")]
[DllImport(EJDB_LIB_NAME, EntryPoint = "ejdbloadbson", CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr _ejdbloadbson([In] IntPtr coll, [In] byte[] oid);
//EJDB_EXPORT const char* bson_data2(const bson *b, int *bsize);
[DllImport(EJDB_LIB_NAME, EntryPoint="bson_data2")]
[DllImport(EJDB_LIB_NAME, EntryPoint = "bson_data2", CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr _bson_data2([In] IntPtr bsptr, out int size);
//EJDB_EXPORT void bson_del(bson *b);
[DllImport(EJDB_LIB_NAME, EntryPoint="bson_del")]
[DllImport(EJDB_LIB_NAME, EntryPoint = "bson_del", CallingConvention = CallingConvention.Cdecl)]
internal static extern void _bson_del([In] IntPtr bsptr);
//EJDB_EXPORT bool ejdbrmbson(EJCOLL *coll, bson_oid_t *oid);
[DllImport(EJDB_LIB_NAME, EntryPoint="ejdbrmbson")]
[DllImport(EJDB_LIB_NAME, EntryPoint = "ejdbrmbson", CallingConvention = CallingConvention.Cdecl)]
internal static extern bool _ejdbrmbson([In] IntPtr cptr, [In] byte[] oid);
//EJDB_EXPORT bool ejdbsyncdb(EJDB *jb)
[DllImport(EJDB_LIB_NAME, EntryPoint="ejdbsyncdb")]
[DllImport(EJDB_LIB_NAME, EntryPoint = "ejdbsyncdb", CallingConvention = CallingConvention.Cdecl)]
internal static extern bool _ejdbsyncdb([In] IntPtr db);
//EJDB_EXPORT bool ejdbsyncoll(EJDB *jb)
[DllImport(EJDB_LIB_NAME, EntryPoint="ejdbsyncoll")]
[DllImport(EJDB_LIB_NAME, EntryPoint = "ejdbsyncoll", CallingConvention = CallingConvention.Cdecl)]
internal static extern bool _ejdbsyncoll([In] IntPtr coll);
//EJDB_EXPORT bool ejdbsetindex(EJCOLL *coll, const char *ipath, int flags);
[DllImport(EJDB_LIB_NAME, EntryPoint="ejdbsetindex")]
[DllImport(EJDB_LIB_NAME, EntryPoint = "ejdbsetindex", CallingConvention = CallingConvention.Cdecl)]
internal static extern bool _ejdbsetindex([In] IntPtr coll, [In] IntPtr ipathptr, int flags);
//EJDB_EXPORT bson* ejdbmeta(EJDB *jb)
[DllImport(EJDB_LIB_NAME, EntryPoint="ejdbmeta")]
[DllImport(EJDB_LIB_NAME, EntryPoint = "ejdbmeta", CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr _ejdbmeta([In] IntPtr db);
//EJDB_EXPORT bool ejdbtranbegin(EJCOLL *coll);
[DllImport(EJDB_LIB_NAME, EntryPoint="ejdbtranbegin")]
[DllImport(EJDB_LIB_NAME, EntryPoint = "ejdbtranbegin", CallingConvention = CallingConvention.Cdecl)]
internal static extern bool _ejdbtranbegin([In] IntPtr coll);
//EJDB_EXPORT bool ejdbtrancommit(EJCOLL *coll);
[DllImport(EJDB_LIB_NAME, EntryPoint="ejdbtrancommit")]
[DllImport(EJDB_LIB_NAME, EntryPoint = "ejdbtrancommit", CallingConvention = CallingConvention.Cdecl)]
internal static extern bool _ejdbtrancommit([In] IntPtr coll);
//EJDB_EXPORT bool ejdbtranabort(EJCOLL *coll);
[DllImport(EJDB_LIB_NAME, EntryPoint="ejdbtranabort")]
[DllImport(EJDB_LIB_NAME, EntryPoint = "ejdbtranabort", CallingConvention = CallingConvention.Cdecl)]
internal static extern bool _ejdbtranabort([In] IntPtr coll);
//EJDB_EXPORT bool ejdbtranstatus(EJCOLL *jcoll, bool *txactive);
[DllImport(EJDB_LIB_NAME, EntryPoint="ejdbtranstatus")]
[DllImport(EJDB_LIB_NAME, EntryPoint = "ejdbtranstatus", CallingConvention = CallingConvention.Cdecl)]
internal static extern bool _ejdbtranstatus([In] IntPtr coll, out bool txactive);
//EJDB_EXPORT const char *ejdbversion();
[DllImport(EJDB_LIB_NAME, EntryPoint="ejdbversion")]
[DllImport(EJDB_LIB_NAME, EntryPoint = "ejdbversion", CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr _ejdbversion();

internal static bool _ejdbsetindex(IntPtr coll, string ipath, int flags) {
Expand Down
4 changes: 2 additions & 2 deletions Ejdb.DB/EJDBQCursor.cs
Expand Up @@ -33,10 +33,10 @@ public class EJDBQCursor : IDisposable, IEnumerable<BSONIterator> {
//Pointer to the result set list
IntPtr _qresptr;
//EJDB_EXPORT void ejdbqresultdispose(EJQRESULT qr);
[DllImport(EJDB.EJDB_LIB_NAME, EntryPoint="ejdbqresultdispose")]
[DllImport(EJDB.EJDB_LIB_NAME, EntryPoint = "ejdbqresultdispose", CallingConvention = CallingConvention.Cdecl)]
static extern void _ejdbqresultdispose([In] IntPtr qres);
//const void* ejdbqresultbsondata(EJQRESULT qr, int pos, int *size)
[DllImport(EJDB.EJDB_LIB_NAME, EntryPoint="ejdbqresultbsondata")]
[DllImport(EJDB.EJDB_LIB_NAME, EntryPoint = "ejdbqresultbsondata", CallingConvention = CallingConvention.Cdecl)]
static extern IntPtr _ejdbqresultbsondata([In] IntPtr qres, [In] int pos, out int size);

/// <summary>
Expand Down
18 changes: 9 additions & 9 deletions Ejdb.DB/EJDBQuery.cs
Expand Up @@ -70,31 +70,31 @@ public class EJDBQuery : IDisposable {
//
#region NativeRefs
//EJDB_EXPORT void ejdbquerydel(EJQ *q);
[DllImport(EJDB.EJDB_LIB_NAME, EntryPoint="ejdbquerydel")]
[DllImport(EJDB.EJDB_LIB_NAME, EntryPoint = "ejdbquerydel", CallingConvention = CallingConvention.Cdecl)]
static extern void _ejdbquerydel([In] IntPtr qptr);
//EJDB_EXPORT EJQ* ejdbcreatequery2(EJDB *jb, void *qbsdata);
[DllImport(EJDB.EJDB_LIB_NAME, EntryPoint="ejdbcreatequery2")]
[DllImport(EJDB.EJDB_LIB_NAME, EntryPoint = "ejdbcreatequery2", CallingConvention = CallingConvention.Cdecl)]
static extern IntPtr _ejdbcreatequery([In] IntPtr jb, [In] byte[] bsdata);
//EJDB_EXPORT EJQ* ejdbqueryhints(EJDB *jb, EJQ *q, void *hintsbsdata)
[DllImport(EJDB.EJDB_LIB_NAME, EntryPoint="ejdbqueryhints")]
[DllImport(EJDB.EJDB_LIB_NAME, EntryPoint = "ejdbqueryhints", CallingConvention = CallingConvention.Cdecl)]
static extern IntPtr _ejdbqueryhints([In] IntPtr jb, [In] IntPtr qptr, [In] byte[] bsdata);
//EJDB_EXPORT EJQ* ejdbqueryaddor(EJDB *jb, EJQ *q, void *orbsdata)
[DllImport(EJDB.EJDB_LIB_NAME, EntryPoint="ejdbqueryaddor")]
[DllImport(EJDB.EJDB_LIB_NAME, EntryPoint = "ejdbqueryaddor", CallingConvention = CallingConvention.Cdecl)]
static extern IntPtr _ejdbqueryaddor([In] IntPtr jb, [In] IntPtr qptr, [In] byte[] bsdata);
//EJDB_EXPORT EJQRESULT ejdbqryexecute(EJCOLL *jcoll, const EJQ *q, uint32_t *count, int qflags, TCXSTR *log)
[DllImport(EJDB.EJDB_LIB_NAME, EntryPoint="ejdbqryexecute")]
[DllImport(EJDB.EJDB_LIB_NAME, EntryPoint = "ejdbqryexecute", CallingConvention = CallingConvention.Cdecl)]
static extern IntPtr _ejdbqryexecute([In] IntPtr jcoll, [In] IntPtr q, out int count, [In] int qflags, [In] IntPtr logxstr);
//EJDB_EXPORT TCXSTR *tcxstrnew(void)
[DllImport(EJDB.EJDB_LIB_NAME, EntryPoint="tcxstrnew")]
[DllImport(EJDB.EJDB_LIB_NAME, EntryPoint = "tcxstrnew", CallingConvention = CallingConvention.Cdecl)]
static extern IntPtr _tcxstrnew();
//EJDB_EXPORT void tcxstrdel(TCXSTR *xstr);
[DllImport(EJDB.EJDB_LIB_NAME, EntryPoint="tcxstrdel")]
[DllImport(EJDB.EJDB_LIB_NAME, EntryPoint = "tcxstrdel", CallingConvention = CallingConvention.Cdecl)]
static extern IntPtr _tcxstrdel([In] IntPtr strptr);
//EJDB_EXPORT int tcxstrsize(const TCXSTR *xstr);
[DllImport(EJDB.EJDB_LIB_NAME, EntryPoint="tcxstrsize")]
[DllImport(EJDB.EJDB_LIB_NAME, EntryPoint = "tcxstrsize", CallingConvention = CallingConvention.Cdecl)]
static extern int _tcxstrsize([In] IntPtr strptr);
//EJDB_EXPORT int tcxstrptr(const TCXSTR *xstr);
[DllImport(EJDB.EJDB_LIB_NAME, EntryPoint="tcxstrptr")]
[DllImport(EJDB.EJDB_LIB_NAME, EntryPoint = "tcxstrptr", CallingConvention = CallingConvention.Cdecl)]
static extern IntPtr _tcxstrptr([In] IntPtr strptr);
#endregion
/// <summary>
Expand Down
26 changes: 26 additions & 0 deletions Properties/Settings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions Properties/Settings.settings
@@ -0,0 +1,5 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
<Profiles />
<Settings />
</SettingsFile>
5 changes: 5 additions & 0 deletions app.config
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
</configSections>
</configuration>
Binary file added lib/nunit.framework.dll
Binary file not shown.
25 changes: 16 additions & 9 deletions nejdb.csproj
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?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)' == '' ">DebugUnix</Configuration>
Expand Down Expand Up @@ -39,6 +39,7 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
<PlatformTarget>x86</PlatformTarget>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'ReleaseWindows|AnyCPU' ">
<DebugType>none</DebugType>
Expand All @@ -48,14 +49,15 @@
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
<DefineConstants>EJDBDLL;</DefineConstants>
<PlatformTarget>x86</PlatformTarget>
</PropertyGroup>
<ItemGroup>
<Reference Include="nunit.framework">
<HintPath>lib\nunit.framework.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="Mono.Posix" />
<Reference Include="nunit.framework, Version=2.6.0.12051, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77">
<Private>False</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="AssemblyInfo.cs" />
Expand Down Expand Up @@ -84,14 +86,19 @@
<Compile Include="Ejdb.DB\EJDBQCursor.cs" />
<Compile Include="Ejdb.BSON\BSONull.cs" />
<Compile Include="Ejdb.BSON\BSONUndefined.cs" />
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
<DependentUpon>Settings.settings</DependentUpon>
</Compile>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>
<Folder Include="Ejdb.DB\" />
<Folder Include="Ejdb.Tests\" />
<Folder Include="Ejdb.IO\" />
<Folder Include="Ejdb.Utils\" />
<Folder Include="Ejdb.BSON\" />
<None Include="app.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
</ItemGroup>
<ProjectExtensions>
<MonoDevelop>
Expand Down
1 change: 1 addition & 0 deletions sample/Program.cs
Expand Up @@ -64,6 +64,7 @@ class MainClass {
}
q.Dispose();
jb.Dispose();
Console.ReadKey();
}
}
}
26 changes: 26 additions & 0 deletions sample/Properties/Settings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions sample/Properties/Settings.settings
@@ -0,0 +1,5 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
<Profiles />
<Settings />
</SettingsFile>
5 changes: 5 additions & 0 deletions sample/app.config
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
</configSections>
</configuration>
16 changes: 15 additions & 1 deletion sample/sample.csproj
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?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)' == '' ">DebugWindows</Configuration>
Expand All @@ -20,6 +20,7 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Externalconsole>true</Externalconsole>
<PlatformTarget>x86</PlatformTarget>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'ReleaseWindows|AnyCPU' ">
<DebugType>full</DebugType>
Expand All @@ -28,6 +29,7 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Externalconsole>true</Externalconsole>
<PlatformTarget>x86</PlatformTarget>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'DebugUnix|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand All @@ -53,6 +55,11 @@
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
<DependentUpon>Settings.settings</DependentUpon>
</Compile>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>
Expand All @@ -61,4 +68,11 @@
<Name>nejdb</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
</ItemGroup>
</Project>

0 comments on commit 4b9ec9f

Please sign in to comment.