diff options
author | Dan Pasette <dan@10gen.com> | 2015-01-27 05:48:08 -0500 |
---|---|---|
committer | Dan Pasette <dan@mongodb.com> | 2015-01-27 05:48:08 -0500 |
commit | e926b20df8bcb14985817d2b37c61e2f8889fb27 (patch) | |
tree | 9b717bb3965470297112fcdbf26dc0ece70721e2 /src/third_party/wiredtiger/lang | |
parent | ae258579edb7a9c6185a515bff5b57f8e80d0088 (diff) | |
download | mongo-e926b20df8bcb14985817d2b37c61e2f8889fb27.tar.gz |
Import wiredtiger-wiredtiger-mongodb-2.8-rc6-47-g5b3283e.tar.gz from wiredtiger branch mongodb-2.8
Diffstat (limited to 'src/third_party/wiredtiger/lang')
-rw-r--r-- | src/third_party/wiredtiger/lang/python/wiredtiger.i | 42 |
1 files changed, 34 insertions, 8 deletions
diff --git a/src/third_party/wiredtiger/lang/python/wiredtiger.i b/src/third_party/wiredtiger/lang/python/wiredtiger.i index bf726ceac0a..d35d7d5c456 100644 --- a/src/third_party/wiredtiger/lang/python/wiredtiger.i +++ b/src/third_party/wiredtiger/lang/python/wiredtiger.i @@ -157,7 +157,7 @@ from packing import pack, unpack %define DESTRUCTOR(class, method) %feature("shadow") class::method %{ def method(self, *args): - '''close(self, config) -> int + '''method(self, config) -> int @copydoc class::method''' try: @@ -171,6 +171,26 @@ DESTRUCTOR(__wt_connection, close) DESTRUCTOR(__wt_cursor, close) DESTRUCTOR(__wt_session, close) +/* + * OVERRIDE_METHOD must be used when overriding or extending an existing + * method in the C interface. It creates Python method() that calls + * _method(), which is the extended version of the method. This works + * around potential naming conflicts. Without this technique, for example, + * defining __wt_cursor::equals() creates the wrapper function + * __wt_cursor_equals(), which may be defined in the WT library. + */ +%define OVERRIDE_METHOD(cclass, pyclass, method, pyargs) +%extend cclass { +%pythoncode %{ + def method(self, *args): + '''method pyargs -> int + + @copydoc class::method''' + return self._##method(*args) +%} +}; +%enddef + /* Don't require empty config strings. */ %typemap(default) const char *config { $1 = NULL; } %typemap(default) WT_CURSOR *to_dup { $1 = NULL; } @@ -389,9 +409,9 @@ NOTFOUND_OK(__wt_cursor::remove) NOTFOUND_OK(__wt_cursor::search) NOTFOUND_OK(__wt_cursor::update) -COMPARE_OK(__wt_cursor::compare) -COMPARE_OK(__wt_cursor::equals) -COMPARE_NOTFOUND_OK(__wt_cursor::search_near) +COMPARE_OK(__wt_cursor::_compare) +COMPARE_OK(__wt_cursor::_equals) +COMPARE_NOTFOUND_OK(__wt_cursor::_search_near) /* Lastly, some methods need no (additional) error checking. */ %exception __wt_connection::get_home; @@ -428,6 +448,10 @@ COMPARE_NOTFOUND_OK(__wt_cursor::search_near) %ignore __wt_cursor::equals(WT_CURSOR *, WT_CURSOR *, int *); %ignore __wt_cursor::search_near(WT_CURSOR *, int *); +OVERRIDE_METHOD(__wt_cursor, WT_CURSOR, compare, (self, other)) +OVERRIDE_METHOD(__wt_cursor, WT_CURSOR, equals, (self, other)) +OVERRIDE_METHOD(__wt_cursor, WT_CURSOR, search_near, (self)) + /* SWIG magic to turn Python byte strings into data / size. */ %apply (char *STRING, int LENGTH) { (char *data, int size) }; @@ -685,7 +709,7 @@ typedef int int_void; } /* compare: special handling. */ - int compare(WT_CURSOR *other) { + int _compare(WT_CURSOR *other) { int cmp = 0; int ret = 0; if (other == NULL) { @@ -709,7 +733,7 @@ typedef int int_void; } /* equals: special handling. */ - int equals(WT_CURSOR *other) { + int _equals(WT_CURSOR *other) { int cmp = 0; int ret = 0; if (other == NULL) { @@ -728,7 +752,7 @@ typedef int int_void; } /* search_near: special handling. */ - int search_near() { + int _search_near() { int cmp = 0; int ret = $self->search_near($self, &cmp); /* @@ -828,7 +852,7 @@ typedef int int_void; }; %extend __wt_session { - int log_printf(const char *msg) { + int _log_printf(const char *msg) { return self->log_printf(self, "%s", msg); } @@ -892,6 +916,8 @@ int verbose_build(); %ignore __wt_connection::get_extension_api; %ignore __wt_session::log_printf; +OVERRIDE_METHOD(__wt_session, WT_SESSION, log_printf, (self, msg)) + %ignore wiredtiger_struct_pack; %ignore wiredtiger_struct_size; %ignore wiredtiger_struct_unpack; |