summaryrefslogtreecommitdiff
path: root/lang
diff options
context:
space:
mode:
authorDon Anderson <dda@ddanderson.com>2014-10-23 10:34:14 -0400
committerDon Anderson <dda@ddanderson.com>2014-10-23 10:34:14 -0400
commit3d3c29279730c27fc9f4df95fc3b40bb27bae99f (patch)
tree9c24889f4a8cae66e4229bdaec0a51f0c3501d7c /lang
parentb7c182b26ca907508194a60681d8350fef82555e (diff)
parentf5b9170b7932f28263f617538b31afbc1bb19883 (diff)
downloadmongo-3d3c29279730c27fc9f4df95fc3b40bb27bae99f.tar.gz
Merge branch 'develop' into java-exceptions
Diffstat (limited to 'lang')
-rw-r--r--lang/java/Makefile.am10
-rw-r--r--lang/java/wiredtiger.i2
-rw-r--r--lang/python/wiredtiger.i64
3 files changed, 60 insertions, 16 deletions
diff --git a/lang/java/Makefile.am b/lang/java/Makefile.am
index 58754c1fd56..eb51fa43297 100644
--- a/lang/java/Makefile.am
+++ b/lang/java/Makefile.am
@@ -31,7 +31,15 @@ JAVA_SRC = \
$(JAVADESTFULL)/wiredtiger.java \
$(JAVADESTFULL)/wiredtigerConstants.java \
$(JAVADESTFULL)/wiredtigerJNI.java \
- $(JAVAEXAMPLES)/ex_access.java
+ $(JAVAEXAMPLES)/ex_access.java \
+ $(JAVAEXAMPLES)/ex_all.java \
+ $(JAVAEXAMPLES)/ex_async.java \
+ $(JAVAEXAMPLES)/ex_call_center.java \
+ $(JAVAEXAMPLES)/ex_cursor.java \
+ $(JAVAEXAMPLES)/ex_log.java \
+ $(JAVAEXAMPLES)/ex_schema.java \
+ $(JAVAEXAMPLES)/ex_stat.java \
+ $(JAVAEXAMPLES)/ex_thread.java
JAVA_JUNIT = \
$(JAVATEST)/AutoCloseTest.java \
diff --git a/lang/java/wiredtiger.i b/lang/java/wiredtiger.i
index 023fafde1d0..3a082ec3fb5 100644
--- a/lang/java/wiredtiger.i
+++ b/lang/java/wiredtiger.i
@@ -139,7 +139,7 @@ static void throwWiredTigerException(JNIEnv *jenv, int err) {
%typemap(in) WT_ITEM * (WT_ITEM item) %{
$1 = &item;
$1->data = (*jenv)->GetByteArrayElements(jenv, $input, 0);
- $1->size = (*jenv)->GetArrayLength(jenv, $input);
+ $1->size = (size_t)(*jenv)->GetArrayLength(jenv, $input);
%}
%typemap(argout) WT_ITEM * %{
diff --git a/lang/python/wiredtiger.i b/lang/python/wiredtiger.i
index 0c228c56e5f..5e88855276a 100644
--- a/lang/python/wiredtiger.i
+++ b/lang/python/wiredtiger.i
@@ -381,16 +381,19 @@ COMPARE_OK(__wt_cursor::compare)
COMPARE_OK(__wt_cursor::search_near)
/* Lastly, some methods need no (additional) error checking. */
-%exception __wt_connection::diagnostic_build;
%exception __wt_connection::get_home;
%exception __wt_connection::is_new;
%exception __wt_connection::search_near;
%exception __wt_async_op::_set_key;
%exception __wt_async_op::_set_value;
%exception __wt_cursor::_set_key;
+%exception __wt_cursor::_set_key_str;
%exception __wt_cursor::_set_value;
+%exception __wt_cursor::_set_value_str;
%exception wiredtiger_strerror;
%exception wiredtiger_version;
+%exception diagnostic_build;
+%exception verbose_build;
/* WT_ASYNC_OP customization. */
/* First, replace the varargs get / set methods with Python equivalents. */
@@ -565,6 +568,12 @@ typedef int int_void;
if self.search() != 0:
raise KeyError
return self.get_value()
+
+ def __setitem__(self, key, value):
+ '''Python convenience for inserting'''
+ self.set_key(key)
+ self.set_key(value)
+ self.insert()
%}
};
@@ -577,6 +586,11 @@ typedef int int_void;
$self->set_key($self, &k);
}
+ /* Get / set keys and values */
+ void _set_key_str(char *str) {
+ $self->set_key($self, str);
+ }
+
int_void _set_recno(uint64_t recno) {
WT_ITEM k;
uint8_t recno_buf[20];
@@ -601,6 +615,11 @@ typedef int int_void;
$self->set_value($self, &v);
}
+ /* Get / set keys and values */
+ void _set_value_str(char *str) {
+ $self->set_value($self, str);
+ }
+
/* Don't return values, just throw exceptions on failure. */
int_void _get_key(char **datap, int *sizep) {
WT_ITEM k;
@@ -739,6 +758,8 @@ typedef int int_void;
args = args[0]
if self.is_column:
self._set_recno(long(args[0]))
+ elif self.is_json:
+ self._set_key_str(args[0])
else:
# Keep the Python string pinned
self._key = pack(self.key_format, *args)
@@ -748,11 +769,14 @@ typedef int int_void;
'''set_value(self) -> None
@copydoc WT_CURSOR::set_value'''
- if len(args) == 1 and type(args[0]) == tuple:
- args = args[0]
- # Keep the Python string pinned
- self._value = pack(self.value_format, *args)
- self._set_value(self._value)
+ if self.is_json:
+ self._set_value_str(args[0])
+ else:
+ if len(args) == 1 and type(args[0]) == tuple:
+ args = args[0]
+ # Keep the Python string pinned
+ self._value = pack(self.value_format, *args)
+ self._set_value(self._value)
def __iter__(self):
'''Cursor objects support iteration, equivalent to calling
@@ -784,16 +808,28 @@ typedef int int_void;
int _freecb() {
return (0);
}
-
- int diagnostic_build() {
-%#ifdef HAVE_DIAGNOSTIC
- return 1;
-%#else
- return 0;
-%#endif
- }
};
+%{
+int diagnostic_build() {
+#ifdef HAVE_DIAGNOSTIC
+ return 1;
+#else
+ return 0;
+#endif
+}
+
+int verbose_build() {
+#ifdef HAVE_VERBOSE
+ return 1;
+#else
+ return 0;
+#endif
+}
+%}
+int diagnostic_build();
+int verbose_build();
+
/* Remove / rename parts of the C API that we don't want in Python. */
%immutable __wt_cursor::session;
%immutable __wt_cursor::uri;