------------------------------------------------------------
revno: 103
revision-id: mtaylor@stripped
parent: mtaylor@stripped
committer: Monty Taylor <mtaylor@stripped>
branch nick: exceptions
timestamp: Sat 2007-05-05 01:08:13 -0700
message:
Moved director-based callback code to globals to share amongst all languages.
modified:
csharp/ndbapi.i
svn-v2:10@5fca6d9a-db22-0410-b55c-899b0a28da89-trunk-csharp%2fndb.i
python/ndbapi.i
svn-v2:1@5fca6d9a-db22-0410-b55c-899b0a28da89-trunk-python%2fndb.i
python/testasynch.py testasynch.py-20070227185119-f8ow9m7i9zfgr5jr-1
swig/NdbClusterConnection.i ndb_cluster_connecti-20070228021421-qkr4cbpxymyqdrf3-6
swig/NdbTransaction.i ndbtransaction.i-20070227184716-ecjyhh3jgvmye4de-7
swig/globals.i globals.i-20070228021421-qkr4cbpxymyqdrf3-7
=== modified file 'csharp/ndbapi.i'
--- a/csharp/ndbapi.i 2007-05-05 06:27:19 +0000
+++ b/csharp/ndbapi.i 2007-05-05 08:08:13 +0000
@@ -135,21 +135,6 @@
%}
- %{
-
-#include <NdbTransaction.hpp>
-
- class BaseCallback {
-
- public:
- virtual ~BaseCallback() {}
- virtual void callback(int result, NdbTransaction * trans) {
- printf("In BaseCallback::callback. Return Value: %d. Transaction:
%p\n",result,trans);
- }
-
- };
-
- %}
%include "globals.i"
%include "NdbFactory.i"
@@ -157,27 +142,10 @@
%include "Ndb.i"
-%{
-
- void CSharpCallback(int ret, NdbTransaction * trans, void * anyObject) {
- BaseCallback * cb = (BaseCallback *)anyObject;
- cb->callback(ret, trans);
- }
-
-%}
-
%include "NdbTransaction.i"
-%extend NdbTransaction {
-
- void executeAsynchPrepare(ExecType execType,
- BaseCallback * cb,
- AbortOption abortOption = AbortOnError) {
- self->executeAsynchPrepare(execType,CSharpCallback,(void *)cb,abortOption);
- };
- };
%include "NdbOperation.i"
@@ -185,13 +153,5 @@
%include "NdbRecAttr.i"
%include "NdbError.i"
-%feature("director") BaseCallback;
-
-class BaseCallback {
- public:
- virtual ~BaseCallback() {};
- virtual void callback(int result, NdbTransaction * trans);
-
-};
=== modified file 'python/ndbapi.i'
--- a/python/ndbapi.i 2007-05-01 22:50:04 +0000
+++ b/python/ndbapi.i 2007-05-05 08:08:13 +0000
@@ -17,7 +17,7 @@
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
-%module ndbapi
+%module(directors="1") ndbapi
%include "globals.i"
@@ -156,6 +156,8 @@
Py_INCREF(exception);
}
+
+
%}
%include "NdbFactory.i"
@@ -176,12 +178,14 @@
self->executeAsynchPrepare(execType,PythonCallBack,(void *)pyfunc,abortOption);
Py_INCREF(pyfunc);
};
+
};
%init %{
// PyObject *m, *d; - m==module d==module.__dict__
ndb_init();
+
/*
PyExc_NdbApiException =
PyErr_NewException("mysql.cluster.ndbapi.NdbApiException",NULL,NULL);
PyDict_SetItemString(d,"NdbApiException",PyExc_NdbApiException);
=== modified file 'python/testasynch.py'
--- a/python/testasynch.py 2007-05-05 07:46:55 +0000
+++ b/python/testasynch.py 2007-05-05 08:08:13 +0000
@@ -4,12 +4,15 @@
import mysql.cluster.ndbapi
import threading
-class PythonCallback(object):
+class PythonCallback(ndbapi.BaseCallback):
def __init__(self, recAttr):
self.recAttr=recAttr
- def __call__(self, ret, myTrans):
+ def __call__(self, *args, **kw):
+ self.callback(*args,**kw)
+
+ def callback(self, ret, myTrans):
#print "value = ", self.recAttr.get_value()
x=self.recAttr.get_value()
=== modified file 'swig/NdbClusterConnection.i'
--- a/swig/NdbClusterConnection.i 2007-05-05 07:46:55 +0000
+++ b/swig/NdbClusterConnection.i 2007-05-05 08:08:13 +0000
@@ -40,25 +40,21 @@
if (result) {
const char * msg = "Connect to management server failed";
NDB_exception(NdbApiException,msg);
- goto fail;
}
}
%typemap(check) int no_retries {
if ($1 < 0) {
NDB_exception(NdbClusterConnectionPermanentException,"Retries must be greater than
or equal to zero.");
- goto fail;
}
}
%typemap(check) int retry_delay_in_seconds {
if ($1 < 0) {
NDB_exception(NdbClusterConnectionPermanentException,"Delay must be greater than or
equal to zero.");
- goto fail;
}
}
%typemap(check) int verbose {
if ($1 < 0 || $1 > 1) {
NDB_exception(NdbClusterConnectionPermanentException,"Verbose must be either zero
or one.");
- goto fail;
}
}
int connect(int no_retries=0, int retry_delay_in_seconds=1, int verbose=0);
=== modified file 'swig/NdbTransaction.i'
--- a/swig/NdbTransaction.i 2007-05-05 06:53:53 +0000
+++ b/swig/NdbTransaction.i 2007-05-05 08:08:13 +0000
@@ -72,12 +72,12 @@
#else
%noexception;
#endif
-
+/*
void executeAsynchPrepare(ExecType execType,
NdbAsynchCallback callback,
void* anyObject,
AbortOption abortOption = AbortOnError);
-
+*/
void close();
};
@@ -88,5 +88,10 @@
~NdbTransaction() {
self->close();
}
-};
+ void executeAsynchPrepare(ExecType execType,
+ BaseCallback * cb,
+ AbortOption abortOption = AbortOnError) {
+ self->executeAsynchPrepare(execType,theNdbCallback,(void *)cb,abortOption);
+ };
+ };
=== modified file 'swig/globals.i'
--- a/swig/globals.i 2007-05-03 03:28:55 +0000
+++ b/swig/globals.i 2007-05-05 08:08:13 +0000
@@ -24,6 +24,21 @@
Ndb_cluster_connection * theConnection = NULL;
+ class BaseCallback {
+
+ public:
+ virtual ~BaseCallback() {}
+ virtual void callback(int res, NdbTransaction * trans) {
+ printf("In BaseCallback::callback. Return Value: %d. Transaction: %p\n",res,trans);
+ }
+
+ };
+
+ void theNdbCallback(int ret, NdbTransaction * trans, void * anyObject) {
+ BaseCallback * cb = (BaseCallback *)anyObject;
+ cb->callback(ret, trans);
+ }
+
%}
%include "ndb_constants.h"
@@ -69,3 +84,11 @@
typedef void (* NdbAsynchCallback)(int, NdbTransaction*, void*);
+%feature("director") BaseCallback;
+
+class BaseCallback {
+ public:
+ virtual ~BaseCallback() {};
+ virtual void callback(int res, NdbTransaction * trans);
+
+};
| Thread |
|---|
| • Rev 103: Moved director-based callback code to globals to share amongst all languages. in http://bazaar.launchpad.net/~ndb-connectors/ndb-connectors/e... | Monty Taylor | 5 May |