#24
authoradam <adamansky@gmail.com>
Mon, 17 Jun 2013 11:25:43 +0000 (18:25 +0700)
committeradam <adamansky@gmail.com>
Mon, 17 Jun 2013 11:25:43 +0000 (18:25 +0700)
14 files changed:
jejdb/configure
jejdb/configure.ac
jejdb/src/java/org/ejdb/driver/EJDB.java
luaejdb/luaejdb-1.0.4-0.rockspec [moved from luaejdb/luaejdb-1.0.3-1.rockspec with 97% similarity]
luaejdb/luaejdb.c
nejdb/Ejdb.DB/EJDB.cs
nejdb/Ejdb.DB/EJDBException.cs [new file with mode: 0644]
nejdb/nejdb.csproj
nejdb/nejdb.userprefs
node/ejdb.js
package.json
pyejdb/pyejdb/__init__.py
pyejdb/setup.py
rbejdb/src/rbejdb.c

index 6776c3a..0eb8438 100755 (executable)
@@ -1,6 +1,6 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.69 for jejdb 1.0.1.
+# Generated by GNU Autoconf 2.69 for jejdb 1.0.2.
 #
 #
 # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc.
@@ -576,8 +576,8 @@ MAKEFLAGS=
 # Identity of this package.
 PACKAGE_NAME='jejdb'
 PACKAGE_TARNAME='jejdb'
-PACKAGE_VERSION='1.0.1'
-PACKAGE_STRING='jejdb 1.0.1'
+PACKAGE_VERSION='1.0.2'
+PACKAGE_STRING='jejdb 1.0.2'
 PACKAGE_BUGREPORT=''
 PACKAGE_URL=''
 
@@ -1193,7 +1193,7 @@ if test "$ac_init_help" = "long"; then
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
-\`configure' configures jejdb 1.0.1 to adapt to many kinds of systems.
+\`configure' configures jejdb 1.0.2 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1254,7 +1254,7 @@ fi
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of jejdb 1.0.1:";;
+     short | recursive ) echo "Configuration of jejdb 1.0.2:";;
    esac
   cat <<\_ACEOF
 
@@ -1339,7 +1339,7 @@ fi
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-jejdb configure 1.0.1
+jejdb configure 1.0.2
 generated by GNU Autoconf 2.69
 
 Copyright (C) 2012 Free Software Foundation, Inc.
@@ -1440,7 +1440,7 @@ cat >config.log <<_ACEOF
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by jejdb $as_me 1.0.1, which was
+It was created by jejdb $as_me 1.0.2, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   $ $0 $@
@@ -3442,7 +3442,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
 # report actual input values of CONFIG_FILES etc. instead of their
 # values after options handling.
 ac_log="
-This file was extended by jejdb $as_me 1.0.1, which was
+This file was extended by jejdb $as_me 1.0.2, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -3495,7 +3495,7 @@ _ACEOF
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
 ac_cs_version="\\
-jejdb config.status 1.0.1
+jejdb config.status 1.0.2
 configured by $0, generated by GNU Autoconf 2.69,
   with options \\"\$ac_cs_config\\"
 
index 502b3a6..63ac05b 100644 (file)
@@ -9,7 +9,7 @@ test -n "$CFLAGS" && MYCFLAGS="$CFLAGS $MYCFLAGS"
 test -n "$CPPFLAGS" && MYCPPFLAGS="$CPPFLAGS $MYCPPFLAGS"
 test -n "$LDFLAGS" && MYLDFLAGS="$LDFLAGS $MYLDFLAGS"
 
-AC_INIT(jejdb, 1.0.1)
+AC_INIT(jejdb, 1.0.2)
 AC_PREFIX_DEFAULT(/usr)
 
 # Package information
index 3433507..4b300a0 100644 (file)
@@ -48,7 +48,7 @@ public class EJDB {
     /**
      * Default open mode
      */
-    public static final int JBO_DEFAULT = (JBOWRITER | JBOCREAT | JBOTSYNC);
+    public static final int JBO_DEFAULT = (JBOWRITER | JBOCREAT);
 
     static {
         System.loadLibrary("jejdb");
@@ -74,7 +74,7 @@ public class EJDB {
     /**
      * Open database using default open mode.
      * <p/>
-     * Default open mode: JBOWRITER | JBOCREAT | JBOTSYNC
+     * Default open mode: JBOWRITER | JBOCREAT
      *
      * @param path EJDB path
      * @throws EJDBException
@@ -86,7 +86,7 @@ public class EJDB {
     /**
      * Open database.
      * <p/>
-     * Default open mode: JBOWRITER | JBOCREAT | JBOTSYNC
+     * Default open mode: JBOWRITER | JBOCREAT
      *
      * @param path EJDB path
      * @param mode Open mode
similarity index 97%
rename from luaejdb/luaejdb-1.0.3-1.rockspec
rename to luaejdb/luaejdb-1.0.4-0.rockspec
index af44176..3c7a03d 100644 (file)
@@ -1,5 +1,5 @@
 package = "luaejdb"
-version = "1.0.3-1"
+version = "1.0.4-0"
 source = {
   url = "https://github.com/Softmotions/ejdb.git"
 }
index c031b17..4c41391 100644 (file)
@@ -14,7 +14,7 @@
 //Cursor user data
 #define EJDBCURSORMT "mtejc"
 
-#define DEFAULT_OPEN_MODE (JBOWRITER | JBOCREAT | JBOTSYNC)
+#define DEFAULT_OPEN_MODE (JBOWRITER | JBOCREAT)
 
 #define TBLSETNUMCONST(_CN) \
     do { \
index 8b76aaa..1ff5442 100644 (file)
 //   if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
 //   Boston, MA 02111-1307 USA.
 // ============================================================================================
-
 using System;
+using System.Runtime.InteropServices;
 
 namespace Ejdb.DB {
 
-       public class EJDB {
+       public class EJDB : IDisposable {
+               //Open modes
+               public const int JBOREADER = 1 << 0;
+               public const int JBOWRITER = 1 << 1;
+               public const int JBOCREAT = 1 << 2;
+               public const int JBOTRUNC = 1 << 3;
+               public const int JBONOLCK = 1 << 4;
+               public const int JBOLCKNB = 1 << 5;
+               public const int JBOTSYNC = 1 << 6;
+               public const int DEFAULT_OPEN_MODE = (JBOWRITER | JBOCREAT);
+               public const string EJDB_LIB_NAME = "tcejdb";
+               IntPtr _db = (IntPtr) 0x0;
+               #region Functions
+               [DllImport(EJDB_LIB_NAME, EntryPoint="ejdbnew")]
+               static extern IntPtr _ejdbnew();
+
+               [DllImport(EJDB_LIB_NAME, EntryPoint="ejdbdel")]
+               static extern IntPtr _ejdbdel(IntPtr db);
+
+               [DllImport(EJDB_LIB_NAME, EntryPoint="ejdbopen", CharSet=CharSet.Auto)]
+               static extern bool _ejdbopen(IntPtr db, string path, int mode);
+
+               [DllImport(EJDB_LIB_NAME, EntryPoint="ejdbclose")]
+               static extern bool _ejdbclose(IntPtr db);
 
-               IntPtr dbptr;
+               [DllImport(EJDB_LIB_NAME, EntryPoint="ejdbisopen")]
+               static extern bool _ejdbisopen(IntPtr db);
+
+               [DllImport(EJDB_LIB_NAME, EntryPoint="ejdbecode")]
+               static extern int _ejdbecode(IntPtr db);
+
+               [DllImport(EJDB_LIB_NAME, EntryPoint="ejdberrmsg")]
+               static extern string _ejdberrmsg(int ecode);
+               #endregion
+               /// <summary>
+               /// Gets the last DB error code or <c>null</c> if underlying native database object does not exist.
+               /// </summary>
+               /// <value>The last DB error code.</value>
+               public int? LastDBErrorCode {
+                       get {
+                               return (_db.ToInt32() != 0x0) ? (int?) _ejdbecode(_db) : null;
+                       }
+               }
 
-               public EJDB() {
+               /// <summary>
+               /// Gets the last DB error message or <c>null</c> if underlying native database object does not exist.
+               /// </summary>
+               public string LastDBErrorMsg {
+                       get {           
+                               int? ecode = LastDBErrorCode;
+                               return ecode != null ? _ejdberrmsg((int) ecode) : null;
+                       }
+               }
+
+               /// <summary>
+               /// Gets a value indicating whether this EJDB databse is open.
+               /// </summary>
+               /// <value><c>true</c> if this instance is open; otherwise, <c>false</c>.</value>
+               public bool IsOpen {
+                       get {
+                               return _ejdbisopen(_db);
+                       }
+               }
+
+               /// <summary>
+               /// Initializes a new instance of the <see cref="Ejdb.DB.EJDB"/> class.
+               /// </summary>
+               /// <param name="path">The main database file path.</param>
+               /// <param name="omode">Open mode.</param>
+               public EJDB(string path, int omode) {
+                       bool rv;
+                       _db = _ejdbnew();
+                       if (_db.ToInt32() == 0x0) {
+                               throw new EJDBException("Unable to create ejdb instance");
+                       }
+                       try {
+                               rv = _ejdbopen(_db, path, omode); 
+                       } catch (Exception) {
+                               Dispose();
+                               throw;
+                       }
+                       if (!rv) {
+                               throw new EJDBException(this);
+                       }
                }
 
                ~EJDB() {
+                       Dispose();
+               }
+
+               public void Dispose() {
+                       if (_db.ToInt32() != 0x0) {
+                               IntPtr db = _db;
+                               _db = (IntPtr) 0x0;
+                               if (db.ToInt32() != 0x0) {
+                                       _ejdbdel(db);
+                               }
+                       }
                }
        }
 }
diff --git a/nejdb/Ejdb.DB/EJDBException.cs b/nejdb/Ejdb.DB/EJDBException.cs
new file mode 100644 (file)
index 0000000..ec55958
--- /dev/null
@@ -0,0 +1,46 @@
+// ============================================================================================
+//   .NET API for EJDB database library http://ejdb.org
+//   Copyright (C) 2012-2013 Softmotions Ltd <info@softmotions.com>
+//
+//   This file is part of EJDB.
+//   EJDB is free software; you can redistribute it and/or modify it under the terms of
+//   the GNU Lesser General Public License as published by the Free Software Foundation; either
+//   version 2.1 of the License or any later version.  EJDB is distributed in the hope
+//   that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
+//   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
+//   License for more details.
+//   You should have received a copy of the GNU Lesser General Public License along with EJDB;
+//   if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+//   Boston, MA 02111-1307 USA.
+// ============================================================================================
+using System;
+
+namespace Ejdb.DB {
+
+       public class EJDBException : Exception {
+
+               public int? Code {
+                       get;
+                       private set;
+               }
+
+               public EJDBException() {
+               }
+
+               public EJDBException(string msg) : base(msg) {
+               }
+
+               public EJDBException(int code, string msg) : base(msg) {
+                       this.Code = code;
+               }
+
+               public EJDBException(EJDB db) : base(db.LastDBErrorMsg) {
+                       this.Code = db.LastDBErrorCode;
+               }
+
+               public override string ToString() {
+                       return string.Format("[EJDBException: Code={0}, Msg={1}]", Code, Message);
+               }
+       }
+}
+
index 88a0bcb..266852e 100644 (file)
@@ -38,6 +38,7 @@
     </Reference>
     <Reference Include="System.Core" />
     <Reference Include="System.Runtime.Serialization" />
+    <Reference Include="Mono.Posix" />
   </ItemGroup>
   <ItemGroup>
     <Compile Include="AssemblyInfo.cs" />
@@ -61,6 +62,7 @@
     <Compile Include="Ejdb.BSON\BSONConstants.cs" />
     <Compile Include="Ejdb.JSON\JSONReader.cs" />
     <Compile Include="Ejdb.JSON\JSONElement.cs" />
+    <Compile Include="Ejdb.DB\EJDBException.cs" />
   </ItemGroup>
   <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
   <ItemGroup>
index d9e7c77..2120258 100644 (file)
@@ -2,15 +2,11 @@
   <MonoDevelop.Ide.Workspace ActiveConfiguration="Debug" />
   <MonoDevelop.Ide.Workbench ActiveDocument="Ejdb.DB/EJDB.cs">
     <Files>
-      <File FileName="Ejdb.BSON/BSONArray.cs" Line="12" Column="61" />
-      <File FileName="Ejdb.JSON/JSONReader.cs" Line="32" Column="4" />
-      <File FileName="Ejdb.JSON/JSONElement.cs" Line="1" Column="1" />
-      <File FileName="Ejdb.BSON/BSONDocument.cs" Line="322" Column="1" />
-      <File FileName="Ejdb.BSON/BSONIterator.cs" Line="1" Column="1" />
-      <File FileName="Ejdb.BSON/BSONType.cs" Line="1" Column="1" />
-      <File FileName="Ejdb.BSON/BSONOid.cs" Line="1" Column="1" />
-      <File FileName="Ejdb.IO/ExtBinaryWriter.cs" Line="1" Column="1" />
-      <File FileName="Ejdb.DB/EJDB.cs" Line="22" Column="3" />
+      <File FileName="Ejdb.Tests/TestBSON.cs" Line="27" Column="37" />
+      <File FileName="Ejdb.DB/EJDB.cs" Line="26" Column="38" />
+      <File FileName="Ejdb.DB/EJDBException.cs" Line="25" Column="4" />
+      <File FileName="Ejdb.BSON/InvalidBSONDataException.cs" Line="22" Column="36" />
+      <File FileName="Ejdb.BSON/BSONType.cs" Line="20" Column="15" />
     </Files>
     <Pads>
       <Pad Id="ProjectPad">
         <State selected="True" />
       </Pad>
       <Pad Id="MonoDevelop.NUnit.TestPad">
-        <State expanded="True">
-          <Node name="nejdb" expanded="True" selected="True">
-            <Node name="Ejdb" expanded="True">
-              <Node name="Tests" expanded="True">
-                <Node name="TestBSON" expanded="True" />
-              </Node>
-            </Node>
-          </Node>
-        </State>
+        <State expanded="True" selected="True" />
       </Pad>
     </Pads>
   </MonoDevelop.Ide.Workbench>
index 31d4b3c..ac55516 100644 (file)
@@ -23,7 +23,7 @@ try {
 }
 var EJDBImpl = ejdblib.NodeEJDB;
 
-const DEFAULT_OPEN_MODE = (ejdblib.JBOWRITER | ejdblib.JBOCREAT | ejdblib.JBOTSYNC);
+const DEFAULT_OPEN_MODE = (ejdblib.JBOWRITER | ejdblib.JBOCREAT);
 var EJDB = function(dbFile, openMode) {
     Object.defineProperty(this, "_impl", {
         value : new EJDBImpl(dbFile, (openMode > 0) ? openMode : DEFAULT_OPEN_MODE),
index dcadaf6..6b452fc 100644 (file)
@@ -1,6 +1,6 @@
 {
     "name" : "ejdb",
-    "version" : "1.1.12-0",
+    "version" : "1.1.13-0",
     "config" : {
         "windownloadurl_ia32" : "http://dl.dropboxusercontent.com/u/4709222/ejdb/tcejdb-1.1.12-mingw32-i686.zip",
         "windownloadurl_x64" : "http://dl.dropboxusercontent.com/u/4709222/ejdb/tcejdb-1.1.12-mingw32-x86_64.zip"
index d8ea13a..8f80df5 100644 (file)
@@ -70,7 +70,7 @@ JBOTRUNC = _pyejdb.JBOTRUNC
 JBONOLCK = _pyejdb.JBONOLCK
 JBOLCKNB = _pyejdb.JBOLCKNB
 JBOTSYNC = _pyejdb.JBOTSYNC
-DEFAULT_OPEN_MODE = JBOWRITER | JBOCREAT | JBOTSYNC
+DEFAULT_OPEN_MODE = JBOWRITER | JBOCREAT
 
 #Query flags
 JBQRYCOUNT = _pyejdb.JBQRYCOUNT
@@ -168,7 +168,7 @@ class EJDB(object):
             JBOLCKNB - Lock without blocking
             JBOTSYNC - Synchronize db on every transaction
 
-    Default open mode: DEFAULT_OPEN_MODE = JBOWRITER | JBOCREAT | JBOTSYNC
+    Default open mode: DEFAULT_OPEN_MODE = JBOWRITER | JBOCREAT
     """
 
     def __init__(self, fpath, mode=DEFAULT_OPEN_MODE):
index c424542..b8eed91 100755 (executable)
@@ -99,7 +99,7 @@ class build_ext(_build_ext):
 
 setup(
     name="pyejdb",
-    version="1.0.12",
+    version="1.0.13",
     url="http://ejdb.org",
     keywords=["ejdb", "tokyocabinet", "nosql", "database", "storage", "embedded", "mongodb", "json"],
     description="Python 2.7/3.x binding for EJDB database engine.",
index abef6fd..ec93a42 100644 (file)
@@ -45,7 +45,7 @@
 
 #include "rbbson.h"
 
-#define DEFAULT_OPEN_MODE (JBOWRITER | JBOCREAT | JBOTSYNC)
+#define DEFAULT_OPEN_MODE (JBOWRITER | JBOCREAT)
 
 typedef struct {
     EJDB* ejdb;