[Swift-commit] cog r3819

swift at ci.uchicago.edu swift at ci.uchicago.edu
Fri Oct 25 16:30:03 CDT 2013


------------------------------------------------------------------------
r3819 | yadunand | 2013-10-25 16:25:05 -0500 (Fri, 25 Oct 2013) | 11 lines


Issue with destructor invoked at end of block fixed.
CoasterSWIGClientSettings, works with no crashes.

Added :
CoasterLoop* CoasterSWIGLoopCreate(void);
int CoasterSWIGLoopDestroy(CoasterLoop* loop);
int CoasterSWIGClientDestroy(CoasterClient *client);
Tests for above changes.


------------------------------------------------------------------------
Index: modules/provider-coaster-c-client/src/CoasterSWIG.h
===================================================================
--- modules/provider-coaster-c-client/src/CoasterSWIG.h	(revision 3818)
+++ modules/provider-coaster-c-client/src/CoasterSWIG.h	(working copy)
@@ -1,14 +1,24 @@
 
 #include "CoasterClient.h"
+//#include "CoasterLoop.h"
 
 #ifdef SWIG
 %module coaster
 %{
   #include "CoasterClient.h"
   #include "CoasterSWIG.h"
+  #include "CoasterLoop.h"
 %}
 #endif
 
-CoasterClient* CoasterSWIGClientCreate(char* serviceURL);
+CoasterLoop* CoasterSWIGLoopCreate(void);
+int CoasterSWIGLoopDestroy(CoasterLoop* loop);
 
+CoasterClient* CoasterSWIGClientCreate(CoasterLoop &loop, char* serviceURL);
+int CoasterSWIGClientDestroy(CoasterClient *client);
+
 int CoasterSWIGClientSettings(CoasterClient *client, char *settings);
+
+
+
+
Index: modules/provider-coaster-c-client/src/CoasterSWIG.cpp
===================================================================
--- modules/provider-coaster-c-client/src/CoasterSWIG.cpp	(revision 3818)
+++ modules/provider-coaster-c-client/src/CoasterSWIG.cpp	(working copy)
@@ -5,9 +5,15 @@
 #include <vector>
 
 #include <CoasterSWIG.h>
-
+#include "CoasterLoop.h"
+#include "CoasterClient.h"
+#include "Settings.h"
+#include "Job.h"
 using namespace std;
 
+/** CoasterSWIGLoopCreate : create, starts and returns
+ *  a pointer to a CoasterLoop object.
+ */
 CoasterLoop* CoasterSWIGLoopCreate(void)
 {
     cout << "CoasterSWIGLoopCreate()..." << endl;
@@ -16,14 +22,25 @@
     return loop;
 }
 
-CoasterClient* CoasterSWIGClientCreate(char* serviceURL)
+int CoasterSWIGLoopDestroy(CoasterLoop* loop)
 {
-  cout << "CoasterSWIGClientCreate(" << serviceURL << ")..." << endl;
-  CoasterLoop loop;
-  loop.start();
-  CoasterClient* result = new CoasterClient(serviceURL, loop);
+    delete(loop);
+    return 0;
 }
 
+CoasterClient* CoasterSWIGClientCreate(CoasterLoop &loop, char* serviceURL)
+{
+    cout << "CoasterSWIGClientCreate(" << serviceURL << ")..." << endl;
+    CoasterClient* client = new CoasterClient(serviceURL, loop);
+    return client;
+}
+
+int CoasterSWIGClientDestroy(CoasterClient *client)
+{
+    delete(client);
+    return 0;
+}
+
 int CoasterSWIGClientSettings(CoasterClient *client, char *settings)
 {
     Settings s;
@@ -50,6 +67,6 @@
 
     //TODO: SegFaulting here. Why ?
     cout << "client->getURL() : " << client->getURL() << endl ;
-    //client->setOptions(s);
+    client->setOptions(s);
     return 0;
 }
Index: modules/provider-coaster-c-client/tests/tcl/coaster-loop-start-stop.tcl
===================================================================
--- modules/provider-coaster-c-client/tests/tcl/coaster-loop-start-stop.tcl	(revision 0)
+++ modules/provider-coaster-c-client/tests/tcl/coaster-loop-start-stop.tcl	(revision 3819)
@@ -0,0 +1,11 @@
+load ../../src/.libs/libcoasterclient.so
+
+set loop_ptr [CoasterSWIGLoopCreate]
+set client_ptr [CoasterSWIGClientCreate $loop_ptr 140.221.8.81:40568]
+
+set rcode [CoasterSWIGClientDestroy $client_ptr]
+set rcode [CoasterSWIGLoopDestroy $loop_ptr]
+
+
+
+
Index: modules/provider-coaster-c-client/tests/tcl/coaster-test-3.tcl
===================================================================
--- modules/provider-coaster-c-client/tests/tcl/coaster-test-3.tcl	(revision 0)
+++ modules/provider-coaster-c-client/tests/tcl/coaster-test-3.tcl	(revision 3819)
@@ -0,0 +1,7 @@
+load ../../src/.libs/libcoasterclient.so
+
+set loop_ptr [CoasterSWIGLoopCreate]
+
+set client_ptr [CoasterSWIGClientCreate $loop_ptr 140.221.8.81:40568]
+
+set x [CoasterSWIGClientSettings $client_ptr "SLOTS=1,MAX_NODES=1"]



More information about the Swift-commit mailing list