At http://bazaar.launchpad.net/~ndb-connectors/ndb-connectors/devel
------------------------------------------------------------
revno: 296
revision-id: mtaylor@stripped
parent: mtaylor@stripped
committer: Monty Taylor <mtaylor@stripped>
branch nick: devel
timestamp: Sun 2007-11-25 19:09:58 -0800
message:
Added the actual MGM API methods to C#, Ruby, Perl and Lua.
modified:
csharp/Makefile.am makefile.in-20070228073157-gkwqutuh9f3nq7s2-1
csharp/mgmapi.i mgmapi.i-20071125232130-9b1hlszp987p1mhb-1
lua/mgmapi.i mgmapi.i-20071125230711-7m3mkivpp4acghz4-1
perl/mgmapi.i mgmapi.i-20070415084702-pjs702i1rleb6otl-1
ruby/mgmapi.i mgmapi.i-20070415091411-plc5gtpiwg93c2lx-1
=== modified file 'csharp/Makefile.am'
--- a/csharp/Makefile.am 2007-11-26 02:05:33 +0000
+++ b/csharp/Makefile.am 2007-11-26 03:09:58 +0000
@@ -1,6 +1,6 @@
NDBAPI_BUILT_SRC=AbortOption.cs NdbScanOperation.cs ExecType.cs
NdbTransaction.cs Ndb_cluster_connection.cs SWIGTYPE*cs ndb.cs
Ndb.cs NdbOperation.cs ndbPINVOKE.cs
NdbRecAttr.cs NdbError.cs NdbFactory.cs
MYSQL_DLL = MySql.Data.dll
-CLEANFILES = ndbapi.dll *exe ndbapi mgmapi ndbapi.cpp MySql.Cluster.NdbApi.dll ndbapi/*
+CLEANFILES = ndbapi.dll *exe ndbapi.cpp MySql.Cluster.NdbApi.dll ndbapi/* mgmapi/*
mgmapi.cpp MySql.Cluster.MgmApi.dll
lib_LTLIBRARIES = libndbsharp.la libmgmsharp.la
nodist_libndbsharp_la_SOURCES = ndbapi.cpp
@@ -14,6 +14,8 @@
EXTRA_DIST = ndbapi.i mgmapi.i exceptions.cs NdbError.cs test*cs
+clean-local:
+ @rm -rf ndbapi mgmapi
test: test.exe test2.exe
=== modified file 'csharp/mgmapi.i'
--- a/csharp/mgmapi.i 2007-11-25 23:22:57 +0000
+++ b/csharp/mgmapi.i 2007-11-26 03:09:58 +0000
@@ -23,6 +23,18 @@
%include "mgmapi/mgmglobals.i"
+%typemap(out) (BaseEventWrapper *) {
+ $result=$1->theEvent;
+ }
+//%typemap(imtype) (BaseEventWrapper *) "BaseEvent";
+%typemap(cstype) (BaseEventWrapper *) "NdbLogEvent";
+%typemap(ctype) (BaseEventWrapper *) "ndb_logevent *";
+
+%typemap(csout) (BaseEventWrapper *) {
+ long cPtr = $imcall;
+ return (cPtr == 0) ? null : new NdbLogEvent(cPtr,true);
+ }
+
%{
@@ -30,3 +42,90 @@
#define NDB_exception_err(excp,msg,err) { SWIG_CSharpSetPendingExceptionCustom(excp,msg);
}
%}
+
+%insert(runtime) %{
+ // Code to handle throwing of C# CustomApplicationException from C/C++ code.
+ // The equivalent delegate to the callback, CSharpExceptionCallback_t, is
CustomExceptionDelegate
+ // and the equivalent customExceptionCallback instance is customDelegate
+ typedef void (SWIGSTDCALL* CSharpExceptionCallback_t)(int excp, const char *);
+ CSharpExceptionCallback_t customExceptionCallback = NULL;
+
+ extern "C" SWIGEXPORT
+ void SWIGSTDCALL CustomExceptionRegisterCallback(CSharpExceptionCallback_t
customCallback) {
+ customExceptionCallback = customCallback;
+ }
+
+ // Note that SWIG detects any method calls named starting with
+ // SWIG_CSharpSetPendingException for warning 845
+ static void SWIG_CSharpSetPendingExceptionCustom(int excp, const char *msg) {
+ customExceptionCallback(excp, msg);
+ }
+
+
+%}
+
+%pragma(csharp) imclasscode=%{
+
+
+ class CustomExceptionHelper {
+ // C# delegate for the C/C++ customExceptionCallback
+ public delegate void CustomExceptionDelegate(int excp, string message);
+
+ static CustomExceptionDelegate customDelegate =
+ new
CustomExceptionDelegate(SetPendingCustomException);
+
+ [DllImport("$dllimport", EntryPoint="CustomExceptionRegisterCallback")]
+ public static extern
+ void CustomExceptionRegisterCallback(CustomExceptionDelegate customCallback);
+
+ static void SetPendingCustomException(int excp, string message) {
+ // switch the exception classes on excp here
+ if (excp == NdbException.NdbApiException.swigValue) {
+ SWIGPendingException.Set(new NdbApiException(message));
+ } else if (excp == (int)NdbException.BlobUndefinedException.swigValue) {
+ SWIGPendingException.Set(new BlobUndefinedException(message));
+ } else if (excp == (int)NdbException.NdbApiPermanentException.swigValue) {
+ SWIGPendingException.Set(new NdbApiPermanentException(message));
+ } else if (excp == (int)NdbException.NdbApiRuntimeException.swigValue) {
+ SWIGPendingException.Set(new NdbApiRuntimeException(message));
+ } else if (excp == (int)NdbException.NdbApiTemporaryException.swigValue) {
+ SWIGPendingException.Set(new NdbApiTemporaryException(message));
+ } else if (excp ==
(int)NdbException.NdbApiTimeStampOutOfBoundsException.swigValue) {
+ SWIGPendingException.Set(new NdbApiTimeStampOutOfBoundsException(message));
+ } else if (excp == (int)NdbException.NdbApiUserErrorPermanentException.swigValue)
{
+ SWIGPendingException.Set(new NdbApiUserErrorPermanentException(message));
+ } else if (excp ==
(int)NdbException.NdbClusterConnectionPermanentException.swigValue) {
+ SWIGPendingException.Set(new
NdbClusterConnectionPermanentException(message));
+ } else if (excp ==
(int)NdbException.NdbClusterConnectionTemporaryException.swigValue) {
+ SWIGPendingException.Set(new
NdbClusterConnectionTemporaryException(message));
+ } else if (excp == (int)NdbException.NoSuchColumnException.swigValue) {
+ SWIGPendingException.Set(new NoSuchColumnException(message));
+ } else if (excp == (int)NdbException.NoSuchIndexException.swigValue) {
+ SWIGPendingException.Set(new NoSuchIndexException(message));
+ } else if (excp == (int)NdbException.NoSuchTableException.swigValue) {
+ SWIGPendingException.Set(new NoSuchTableException(message));
+ } else {
+ Console.WriteLine("DEFAULT EXCEPTION REACHED!");
+ }
+ }
+
+ static CustomExceptionHelper() {
+ CustomExceptionRegisterCallback(customDelegate);
+ }
+ }
+ static CustomExceptionHelper exceptionHelper = new CustomExceptionHelper();
+
+
+%}
+
+
+
+%include "mgmapi/NdbLogEvent.i"
+%include "mgmapi/NdbLogEventManager.i"
+%include "mgmapi/NdbMgm.i"
+
+%include "mgmapi/NdbMgmFactory.i"
+%include "mgmapi/ClusterState.i"
+%include "mgmapi/NodeState.i"
+%include "mgmapi/NdbMgmReply.i"
+
=== modified file 'lua/mgmapi.i'
--- a/lua/mgmapi.i 2007-11-25 23:22:57 +0000
+++ b/lua/mgmapi.i 2007-11-26 03:09:58 +0000
@@ -27,3 +27,13 @@
#define NDB_exception(code,msg) do { SWIG_fail; } while(0);
#define NDB_exception_err(code,msg,err) do { SWIG_fail; } while(0);
%}
+
+%include "mgmapi/NdbLogEvent.i"
+%include "mgmapi/NdbLogEventManager.i"
+%include "mgmapi/NdbMgm.i"
+
+%include "mgmapi/NdbMgmFactory.i"
+%include "mgmapi/ClusterState.i"
+%include "mgmapi/NodeState.i"
+%include "mgmapi/NdbMgmReply.i"
+
=== modified file 'perl/mgmapi.i'
--- a/perl/mgmapi.i 2007-11-06 22:59:00 +0000
+++ b/perl/mgmapi.i 2007-11-26 03:09:58 +0000
@@ -31,4 +31,12 @@
%}
%include "mgmapi/mgmglobals.i"
-//%include "NdbMgm.i"
+%include "mgmapi/NdbLogEvent.i"
+%include "mgmapi/NdbLogEventManager.i"
+%include "mgmapi/NdbMgm.i"
+
+%include "mgmapi/NdbMgmFactory.i"
+%include "mgmapi/ClusterState.i"
+%include "mgmapi/NodeState.i"
+%include "mgmapi/NdbMgmReply.i"
+
=== modified file 'ruby/mgmapi.i'
--- a/ruby/mgmapi.i 2007-11-06 22:59:00 +0000
+++ b/ruby/mgmapi.i 2007-11-26 03:09:58 +0000
@@ -106,4 +106,13 @@
//%apply ndb_logevent *OUTPUT { ndb_logevent *dst };
-//%include "mgmapi/NdbMgm.i"
+%include "mgmapi/mgmglobals.i"
+%include "mgmapi/NdbLogEvent.i"
+%include "mgmapi/NdbLogEventManager.i"
+%include "mgmapi/NdbMgm.i"
+
+%include "mgmapi/NdbMgmFactory.i"
+%include "mgmapi/ClusterState.i"
+%include "mgmapi/NodeState.i"
+%include "mgmapi/NdbMgmReply.i"
+
| Thread |
|---|
| • Rev 296: Added the actual MGM API methods to C#, Ruby, Perl and Lua. in http://bazaar.launchpad.net/~ndb-connectors/ndb-connectors/devel | Monty Taylor | 26 Nov |