tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jsdelf...@apache.org
Subject svn commit: r895305 - in /tuscany/sca-cpp/trunk: kernel/ modules/http/ modules/json/ modules/server/
Date Sat, 02 Jan 2010 22:13:17 GMT
Author: jsdelfino
Date: Sat Jan  2 22:13:15 2010
New Revision: 895305

URL: http://svn.apache.org/viewvc?rev=895305&view=rev
Log:
Cleaned up lifecycle handling of objects that hold library and file resources. Fixed pool
stack initialization concurrency issue. Re-enabled watch strings to help watch compound values
in debugger.

Modified:
    tuscany/sca-cpp/trunk/kernel/debug.hpp
    tuscany/sca-cpp/trunk/kernel/dynlib.hpp
    tuscany/sca-cpp/trunk/kernel/fstream.hpp
    tuscany/sca-cpp/trunk/kernel/gc.hpp
    tuscany/sca-cpp/trunk/kernel/kernel-test.cpp
    tuscany/sca-cpp/trunk/kernel/list.hpp
    tuscany/sca-cpp/trunk/kernel/monad.hpp
    tuscany/sca-cpp/trunk/kernel/sstream.hpp
    tuscany/sca-cpp/trunk/kernel/stream.hpp
    tuscany/sca-cpp/trunk/kernel/string.hpp
    tuscany/sca-cpp/trunk/kernel/value.hpp
    tuscany/sca-cpp/trunk/kernel/xml.hpp
    tuscany/sca-cpp/trunk/modules/http/curl.hpp
    tuscany/sca-cpp/trunk/modules/json/json.hpp
    tuscany/sca-cpp/trunk/modules/server/mod-cpp.hpp

Modified: tuscany/sca-cpp/trunk/kernel/debug.hpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/kernel/debug.hpp?rev=895305&r1=895304&r2=895305&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/kernel/debug.hpp (original)
+++ tuscany/sca-cpp/trunk/kernel/debug.hpp Sat Jan  2 22:13:15 2010
@@ -31,7 +31,10 @@
 
 #ifdef _DEBUG
 
-//#define _DEBUG_WATCH
+/**
+ * Add string watch members to important classes to help watch them in a debugger.
+ */
+#define _DEBUG_WATCH
 
 /**
  * Increment / decrement a debug counter.

Modified: tuscany/sca-cpp/trunk/kernel/dynlib.hpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/kernel/dynlib.hpp?rev=895305&r1=895304&r2=895305&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/kernel/dynlib.hpp (original)
+++ tuscany/sca-cpp/trunk/kernel/dynlib.hpp Sat Jan  2 22:13:15 2010
@@ -48,52 +48,40 @@
  */
 class lib {
 public:
-    lib() : dl(NULL) {
+    lib() : h(NULL), owner(false) {
     }
 
-    lib(const string& name) : dl(new (gc_new<DynLib>()) DynLib(name)) {
+    lib(const string& name) : name(name), h(dlopen(c_str(name), RTLD_NOW)), owner(true)
{
+        if (h == NULL)
+            h = mkfailure<void*>(string("Could not load library: ") + name + ": " +
dlerror());
+    }
+
+    lib(const lib& l) : name(l.name), h(l.h), owner(false) {
     }
 
     ~lib() {
+        if (!owner)
+            return;
+        if (!hasContent(h) || content(h) == NULL)
+            return;
+        dlclose(content(h));
     }
 
 private:
-    class DynLib {
-    public:
-        DynLib(const string& name) : name(name), h(dlopen(c_str(name), RTLD_NOW)) {
-        }
-
-        ~DynLib() {
-            if (h == NULL)
-                return;
-            dlclose(h);
-        }
-
-        const string name;
-        void* h;
-    };
-
-    gc_ptr<DynLib> dl;
-
-    friend const failable<lib> dynlib(const string& name);
     template<typename S> friend const failable<lambda<S> > dynlambda(const
string& name, const lib& l);
-};
 
-/**
- * Load a dynamic library.
- */
-const failable<lib> dynlib(const string& name) {
-    const lib l(name);
-    if (l.dl->h == NULL)
-        return mkfailure<lib>(string("Could not load library: ") + name + ": " + dlerror());
-    return l;
-}
+    const string name;
+    failable<void*> h;
+    bool owner;
+};
 
 /**
  * Find a lambda function in a dynamic library.
  */
 template<typename S> const failable<lambda<S> > dynlambda(const string&
name, const lib& l) {
-    const void* s = dlsym(l.dl->h, c_str(name));
+    if (!hasContent(l.h))
+        return mkfailure<lambda<S> >(reason(l.h));
+    const void* s = dlsym(content(l.h), c_str(name));
     if (s == NULL)
         return mkfailure<lambda<S> >(string("Could not load symbol: ") + name);
     return lambda<S>((S*)s);

Modified: tuscany/sca-cpp/trunk/kernel/fstream.hpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/kernel/fstream.hpp?rev=895305&r1=895304&r2=895305&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/kernel/fstream.hpp (original)
+++ tuscany/sca-cpp/trunk/kernel/fstream.hpp Sat Jan  2 22:13:15 2010
@@ -38,17 +38,17 @@
  */
 class ofstream : public ostream {
 public:
-    ofstream(const string& path) : file(fopen(c_str(path), "wb")), owned(true) {
+    ofstream(const string& path) : file(fopen(c_str(path), "wb")), owner(true) {
     }
 
-    ofstream(FILE* file) : file(file), owned(false) {
+    ofstream(FILE* file) : file(file), owner(false) {
     }
 
-    ofstream(const ofstream& os) : file(os.file), owned(false) {
+    ofstream(const ofstream& os) : file(os.file), owner(false) {
     }
 
     ~ofstream() {
-        if (!owned)
+        if (!owner)
             return;
         if (file == NULL)
             return;
@@ -63,6 +63,11 @@
         return *this;
     }
 
+    ofstream& write(const string& s) {
+        fwrite(c_str(s), 1, length(s), file);
+        return *this;
+    }
+
     ofstream& flush() {
         fflush(file);
         return *this;
@@ -70,7 +75,7 @@
 
 private:
     FILE* file;
-    bool owned;
+    bool owner;
 };
 
 /*
@@ -78,17 +83,17 @@
  */
 class ifstream : public istream {
 public:
-    ifstream(const string& path) : file(fopen(c_str(path), "rb")), owned(true) {
+    ifstream(const string& path) : file(fopen(c_str(path), "rb")), owner(true) {
     }
 
-    ifstream(FILE* file) : file(file), owned(false) {
+    ifstream(FILE* file) : file(file), owner(false) {
     }
 
-    ifstream(const ifstream& is) : file(is.file), owned(false) {
+    ifstream(const ifstream& is) : file(is.file), owner(false) {
     }
 
     ~ifstream() {
-        if (!owned)
+        if (!owner)
             return;
         if (file == NULL)
             return;
@@ -121,7 +126,7 @@
 
 private:
     FILE* file;
-    bool owned;
+    bool owner;
 };
 
 /**

Modified: tuscany/sca-cpp/trunk/kernel/gc.hpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/kernel/gc.hpp?rev=895305&r1=895304&r2=895305&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/kernel/gc.hpp (original)
+++ tuscany/sca-cpp/trunk/kernel/gc.hpp Sat Jan  2 22:13:15 2010
@@ -103,12 +103,8 @@
         return *this;
     }
 
-    operator apr_pool_t*() const {
-        return p;
-    }
-
 private:
-    friend const bool destroy(gc_pool& pool);
+    friend apr_pool_t* pool(const gc_pool& pool);
     friend class gc_global_pool_t;
     friend class gc_scoped_pool;
 
@@ -116,40 +112,29 @@
 };
 
 /**
+ * Return APR pool used by a gc_pool.
+ */
+apr_pool_t* pool(const gc_pool& pool) {
+    return pool.p;
+}
+
+/**
  * Destroy a memory pool.
  */
-const bool destroy(gc_pool& pool) {
-    apr_pool_destroy(pool.p);
+const bool destroy(const gc_pool& p) {
+    apr_pool_destroy(pool(p));
     return true;
 }
 
 /**
- * Default global memory pool.
+ * Initialize APR.
  */
 class gc_apr_context_t {
 public:
     gc_apr_context_t() {
         apr_initialize();
     }
-    ~gc_apr_context_t() {
-        //apr_terminate();
-    }
-};
-
-gc_apr_context_t gc_apr_context;
-
-class gc_global_pool_t : public gc_pool {
-public:
-    gc_global_pool_t() {
-        apr_pool_create(&p, NULL);
-    }
-
-    ~gc_global_pool_t() {
-        //apr_pool_destroy(p);
-    }
-};
-
-gc_global_pool_t gc_global_pool;
+} gc_apr_context;
 
 /**
  * Maintain a stack of memory pools.
@@ -166,9 +151,29 @@
     apr_pool_t* p = gc_pool_stack;
     if (p != NULL)
         return p;
-    apr_pool_t* g = gc_global_pool;
-    gc_pool_stack = g;
-    return g;
+
+    // Create a parent pool for the current thread
+    apr_pool_create(&p, NULL);
+    gc_pool_stack = p;
+    return p;
+}
+
+/**
+ * Push a pool onto the stack.
+ */
+apr_pool_t* gc_push_pool(apr_pool_t* pool) {
+    apr_pool_t* p = gc_pool_stack;
+    gc_pool_stack = pool;
+    return p;
+}
+
+/**
+ * Pop a pool from the stack.
+ */
+apr_pool_t* gc_pop_pool(apr_pool_t* pool) {
+    apr_pool_t* p = gc_pool_stack;
+    gc_pool_stack = pool;
+    return p;
 }
 
 /**
@@ -178,28 +183,27 @@
 class gc_scoped_pool : public gc_pool {
 public:
 
-    gc_scoped_pool() : gc_pool(NULL), prev(gc_current_pool()), owned(true) {
+    gc_scoped_pool() : gc_pool(NULL), prev(gc_current_pool()), owner(true) {
         apr_pool_create(&p, NULL);
-        gc_pool_stack = p;
+        gc_push_pool(p);
     }
 
-    gc_scoped_pool(apr_pool_t* pool) : gc_pool(pool), prev(gc_current_pool()), owned(false)
{
-        gc_pool_stack = p;
+    gc_scoped_pool(apr_pool_t* pool) : gc_pool(pool), prev(gc_current_pool()), owner(false)
{
+        gc_push_pool(p);
     }
 
     ~gc_scoped_pool() {
-        if (owned)
+        if (owner)
             apr_pool_destroy(p);
-        if (prev != NULL)
-            gc_pool_stack = prev;
+        gc_pop_pool(prev);
     }
 
 private:
-    gc_scoped_pool(const unused gc_scoped_pool& pool) : gc_pool(pool.p), prev(NULL),
owned(false) {
+    gc_scoped_pool(const unused gc_scoped_pool& pool) : gc_pool(pool.p), prev(NULL),
owner(false) {
     }
 
     apr_pool_t* prev;
-    bool owned;
+    bool owner;
 };
 
 /**
@@ -218,6 +222,10 @@
     return static_cast<T*>(m);
 }
 
+template<typename T> T* gc_new(const gc_pool& p) {
+    return gc_new<T>(pool(p));
+}
+
 template<typename T> T* gc_new() {
     return gc_new<T>(gc_current_pool());
 }
@@ -238,6 +246,10 @@
     return (T*)(m + 1);
 }
 
+template<typename T> T* gc_anew(const gc_pool& p, int n) {
+    return gc_anew<T>(pool(p), n);
+}
+
 template<typename T> T* gc_anew(int n) {
     return gc_anew<T>(gc_current_pool(), n);
 }

Modified: tuscany/sca-cpp/trunk/kernel/kernel-test.cpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/kernel/kernel-test.cpp?rev=895305&r1=895304&r2=895305&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/kernel/kernel-test.cpp (original)
+++ tuscany/sca-cpp/trunk/kernel/kernel-test.cpp Sat Jan  2 22:13:15 2010
@@ -540,14 +540,13 @@
 }
 
 bool testDynLib() {
-    const failable<lib> dl(dynlib(string(".libs/libdynlib-test") + dynlibExt));
-    assert(hasContent(dl));
-    const failable<lambda<int(const int)>> sq(dynlambda<int(const int)>("csquare",
content(dl)));
+    const lib dl(string(".libs/libdynlib-test") + dynlibExt);
+    const failable<lambda<int(const int)> > sq(dynlambda<int(const int)>("csquare",
dl));
     assert(hasContent(sq));
     lambda<int(const int)> l(content(sq));
     assert(l(2) == 4);
 
-    const failable<lambda<lambda<int(const int)>()>> sql(dynlambda<lambda<int(const
int)>()>("csquarel", content(dl)));
+    const failable<lambda<lambda<int(const int)>()> > sql(dynlambda<lambda<int(const
int)>()>("csquarel", dl));
     assert(hasContent(sql));
     lambda<lambda<int(const int)>()> ll(content(sql));
     assert(ll()(3) == 9);

Modified: tuscany/sca-cpp/trunk/kernel/list.hpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/kernel/list.hpp?rev=895305&r1=895304&r2=895305&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/kernel/list.hpp (original)
+++ tuscany/sca-cpp/trunk/kernel/list.hpp Sat Jan  2 22:13:15 2010
@@ -198,7 +198,7 @@
 template<typename T> const string watchList(const list<T>& p) {
     if(isNil(p))
         return "()";
-    ostringstream<string::npos> os;
+    odebugstream os;
     os << "(" << car(p) << " ...)";
     return str(os);
 }

Modified: tuscany/sca-cpp/trunk/kernel/monad.hpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/kernel/monad.hpp?rev=895305&r1=895304&r2=895305&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/kernel/monad.hpp (original)
+++ tuscany/sca-cpp/trunk/kernel/monad.hpp Sat Jan  2 22:13:15 2010
@@ -213,6 +213,15 @@
     failable(const failable<V, F>& m) : hasv(m.hasv), v(m.v), f(m.f) {
     }
 
+    const failable<V, F>& operator=(const failable<V, F>& m) {
+        if (&m == this)
+            return *this;
+        hasv = m.hasv;
+        v = m.v;
+        f = m.f;
+        return *this;
+    }
+
     const bool operator!=(const failable<V, F>& m) const {
         return !this->operator==(m);
     }
@@ -229,11 +238,6 @@
     failable(const bool hasv, const F& f) : hasv(hasv), f(f) {
     }
 
-    // Prevent mutation
-    const failable<V, F>& operator=(const failable<V, F>& m) {
-        return *this;
-    }
-
     template<typename A, typename B> friend const bool hasContent(const failable<A,
B>& m);
     template<typename A, typename B> friend const A content(const failable<A, B>&
m);
     template<typename A, typename B> friend const B reason(const failable<A, B>&
m);

Modified: tuscany/sca-cpp/trunk/kernel/sstream.hpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/kernel/sstream.hpp?rev=895305&r1=895304&r2=895305&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/kernel/sstream.hpp (original)
+++ tuscany/sca-cpp/trunk/kernel/sstream.hpp Sat Jan  2 22:13:15 2010
@@ -71,6 +71,12 @@
         return *this;
     }
 
+    ostringstream& write(const string& s) {
+        buf = cons(s, buf);
+        len += s.len;
+        return *this;
+    }
+
     ostringstream& flush() {
         return *this;
     }

Modified: tuscany/sca-cpp/trunk/kernel/stream.hpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/kernel/stream.hpp?rev=895305&r1=895304&r2=895305&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/kernel/stream.hpp (original)
+++ tuscany/sca-cpp/trunk/kernel/stream.hpp Sat Jan  2 22:13:15 2010
@@ -39,6 +39,7 @@
 class ostream {
 public:
     virtual ostream& vprintf(const char* fmt, ...) = 0;
+    virtual ostream& write(const string& s) = 0;
     virtual ostream& flush() = 0;
 };
 
@@ -68,10 +69,18 @@
     return os.vprintf("%d", v);
 }
 
+ostream& operator<<(ostream& os, const unsigned int v) {
+    return os.vprintf("%u", v);
+}
+
 ostream& operator<<(ostream& os, const long int v) {
     return os.vprintf("%ld", v);
 }
 
+ostream& operator<<(ostream& os, const long unsigned int v) {
+    return os.vprintf("%lu", v);
+}
+
 ostream& operator<<(ostream& os, const double v) {
     return os.vprintf("%g", v);
 }
@@ -81,7 +90,7 @@
 }
 
 ostream& operator<<(ostream& os, const string& v) {
-    return os.vprintf("%s", c_str(v));
+    return os.write(v);
 }
 
 class stream_endl {
@@ -143,6 +152,49 @@
     return out << p.ptr;
 }
 
+#ifdef _DEBUG
+
+/**
+ * Debug stream implementation with no dependencies on anything else.
+ */
+class odebugstream : public ostream {
+public:
+    odebugstream() {
+    }
+
+    odebugstream& vprintf(const char* fmt, ...) {
+        va_list args;
+        va_start (args, fmt);
+        string s;
+        s.len = vsnprintf(NULL, 0, fmt, args);
+        s.buf = gc_cnew(s.len + 1);
+        vsnprintf(s.buf, s.len + 1, fmt, args);
+        buf = buf + s;
+        va_end (args);
+        return *this;
+    }
+
+    odebugstream& write(const string& s) {
+        buf = buf + s;
+        return *this;
+    }
+
+    odebugstream& flush() {
+        return *this;
+    }
+
+private:
+    friend const string str(odebugstream& os);
+
+    string buf;
+};
+
+const string str(odebugstream& os) {
+    return os.buf;
+}
+
+#endif
+
 }
 
 #endif /* tuscany_stream_hpp */

Modified: tuscany/sca-cpp/trunk/kernel/string.hpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/kernel/string.hpp?rev=895305&r1=895304&r2=895305&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/kernel/string.hpp (original)
+++ tuscany/sca-cpp/trunk/kernel/string.hpp Sat Jan  2 22:13:15 2010
@@ -172,6 +172,9 @@
     }
 
 private:
+#ifdef _DEBUG
+    friend class odebugstream;
+#endif
     friend class ostringstream;
     friend const string operator+(const string& a, const string& b);
     friend const string operator+(const string& a, const char* b);

Modified: tuscany/sca-cpp/trunk/kernel/value.hpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/kernel/value.hpp?rev=895305&r1=895304&r2=895305&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/kernel/value.hpp (original)
+++ tuscany/sca-cpp/trunk/kernel/value.hpp Sat Jan  2 22:13:15 2010
@@ -509,7 +509,7 @@
 const string watchValue(const value& v) {
     if (v.type == value::List)
         return watchList<value>(v);
-    ostringstream<string::npos> os;
+    odebugstream os;
     os << v;
     return str(os);
 }

Modified: tuscany/sca-cpp/trunk/kernel/xml.hpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/kernel/xml.hpp?rev=895305&r1=895304&r2=895305&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/kernel/xml.hpp (original)
+++ tuscany/sca-cpp/trunk/kernel/xml.hpp Sat Jan  2 22:13:15 2010
@@ -47,13 +47,7 @@
     XMLParser() {
         xmlInitParser();
     }
-
-    ~XMLParser() {
-        xmlCleanupParser();
-    }
-};
-
-XMLParser xmlParser;
+} xmlParser;
 
 /**
  * Encapsulates a libxml2 xmlTextReader and its state.

Modified: tuscany/sca-cpp/trunk/modules/http/curl.hpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/modules/http/curl.hpp?rev=895305&r1=895304&r2=895305&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/modules/http/curl.hpp (original)
+++ tuscany/sca-cpp/trunk/modules/http/curl.hpp Sat Jan  2 22:13:15 2010
@@ -43,50 +43,37 @@
 namespace http {
 
 /**
- * CURL library context, one per process.
+ * CURL library runtime, one per process.
  */
-class CURLContext {
+class CURLRuntime {
 public:
-    CURLContext() {
+    CURLRuntime() {
         curl_global_init(CURL_GLOBAL_ALL);
     }
-    ~CURLContext() {
-        curl_global_cleanup();
-    }
-};
-
-CURLContext curlContext;
+} curlRuntime;
 
 /**
  * Represents a CURL session handle.
  */
 class CURLSession {
 public:
-    CURLSession() : ch(new (gc_new<CURLHandle>()) CURLHandle()) {
+    CURLSession() : h(curl_easy_init()), owner(true) {
     }
 
-    ~CURLSession() {
+    CURLSession(const CURLSession& c) : h(c.h), owner(false) {
     }
 
-    CURLSession(const CURLSession& c) : ch(c.ch) {
+    ~CURLSession() {
+        if (!owner)
+            return;
+        if (h == NULL)
+            return;
+        curl_easy_cleanup(h);
     }
 
 private:
-    class CURLHandle {
-    public:
-        CURLHandle() : h(curl_easy_init()) {
-        }
-        ~CURLHandle() {
-            curl_easy_cleanup(h);
-            h = NULL;
-        }
-    private:
-        CURL* h;
-
-        friend CURL* handle(const CURLSession& c);
-    };
-
-    const gc_ptr<CURLHandle> ch;
+    CURL* h;
+    bool owner;
 
     friend CURL* handle(const CURLSession& c);
 };
@@ -95,7 +82,7 @@
  * Returns the CURL handle used by a CURL session.
  */
 CURL* handle(const CURLSession& c) {
-    return c.ch->h;
+    return c.h;
 }
 
 /**

Modified: tuscany/sca-cpp/trunk/modules/json/json.hpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/modules/json/json.hpp?rev=895305&r1=895304&r2=895305&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/modules/json/json.hpp (original)
+++ tuscany/sca-cpp/trunk/modules/json/json.hpp Sat Jan  2 22:13:15 2010
@@ -46,7 +46,7 @@
 }
 
 /**
- * Encapsulates a JavaScript runtime. Can be shared by multiple threads in
+ * Encapsulates a JavaScript runtime. Shared by multiple threads in
  * a process.
  */
 class JSONRuntime {
@@ -58,9 +58,6 @@
             cleanup();
     }
 
-    ~JSONRuntime() {
-    }
-
     operator JSRuntime*() const {
         return rt;
     }
@@ -75,17 +72,11 @@
     }
 
     JSRuntime* rt;
-};
-
-/**
- * Global JavaScript runtime instance.
- */
-JSONRuntime jsRuntime;
+} jsRuntime;
 
 JSClass jsGlobalClass = { "global", JSCLASS_GLOBAL_FLAGS, JS_PropertyStub, JS_PropertyStub,
JS_PropertyStub,
         JS_PropertyStub, JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, JS_FinalizeStub,
JSCLASS_NO_OPTIONAL_MEMBERS};
 
-
 /**
  * Represents a JavaScript context. Create one per thread.
  */

Modified: tuscany/sca-cpp/trunk/modules/server/mod-cpp.hpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/modules/server/mod-cpp.hpp?rev=895305&r1=895304&r2=895305&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/modules/server/mod-cpp.hpp (original)
+++ tuscany/sca-cpp/trunk/modules/server/mod-cpp.hpp Sat Jan  2 22:13:15 2010
@@ -65,14 +65,11 @@
  * Read a C++ component implementation.
  */
 const failable<lambda<value(const list<value>&)> > readImplementation(const
string& path, const list<value>& px) {
-    const failable<lib> ilib(dynlib(path + dynlibExt));
-    if (!hasContent(ilib))
-        return mkfailure<lambda<value(const list<value>&)> >(reason(ilib));
-
-    const failable<lambda<value(const list<value>&)> > impl(dynlambda<value(const
list<value>&)>("eval", content(ilib)));
+    const lib ilib(*(new (gc_new<lib>()) lib(path + dynlibExt)));
+    const failable<lambda<value(const list<value>&)> > impl(dynlambda<value(const
list<value>&)>("eval", ilib));
     if (!hasContent(impl))
         return impl;
-    return lambda<value(const list<value>&)>(evalImplementation(content(ilib),
content(impl), px));
+    return lambda<value(const list<value>&)>(evalImplementation(ilib, content(impl),
px));
 }
 
 }



Mime
View raw message