|
From: <br...@us...> - 2009-04-01 02:29:01
|
Revision: 3877
http://openvrml.svn.sourceforge.net/openvrml/?rev=3877&view=rev
Author: braden
Date: 2009-04-01 02:28:51 +0000 (Wed, 01 Apr 2009)
Log Message:
-----------
Added a dlerror work-alike; use it to emit some diagnostic information if loading a module fails.
Modified Paths:
--------------
trunk/ChangeLog
trunk/src/libopenvrml/openvrml/local/dl.cpp
trunk/src/libopenvrml/openvrml/local/dl.h
trunk/src/libopenvrml/openvrml/local/node_metatype_registry_impl.cpp
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2009-03-31 03:25:12 UTC (rev 3876)
+++ trunk/ChangeLog 2009-04-01 02:28:51 UTC (rev 3877)
@@ -1,3 +1,16 @@
+2009-03-31 Braden McDaniel <br...@en...>
+
+ Added a dlerror work-alike; use it to emit some diagnostic
+ information if loading a module fails.
+
+ * src/libopenvrml/openvrml/local/dl.cpp
+ (openvrml::local::dl::error()): Added function.
+ * src/libopenvrml/openvrml/local/dl.h: Added declaration of
+ openvrml::local::dl::error().
+ * src/libopenvrml/openvrml/local/node_metatype_registry_impl.cpp
+ (openvrml_open_node_module(const char *, void *)): Print the
+ result of openvrml::local::dl::error if module loading fails.
+
2009-03-30 Braden McDaniel <br...@en...>
* src/node/vrml97/scaler_interpolator.cpp: Removed errant
Modified: trunk/src/libopenvrml/openvrml/local/dl.cpp
===================================================================
--- trunk/src/libopenvrml/openvrml/local/dl.cpp 2009-03-31 03:25:12 UTC (rev 3876)
+++ trunk/src/libopenvrml/openvrml/local/dl.cpp 2009-04-01 02:28:51 UTC (rev 3877)
@@ -19,7 +19,6 @@
//
# include "dl.h"
-# include <string>
# include <boost/filesystem.hpp>
# include <boost/tokenizer.hpp>
@@ -125,6 +124,31 @@
# endif
}
+const std::string openvrml::local::dl::error()
+{
+# ifdef _WIN32
+ const DWORD err = GetLastError();
+ char * buf = 0;
+ scope_guard buf_guard = make_guard(LocalFree, boost::ref(buf));
+ static const LPCVOID source = 0;
+ static const DWORD buf_size = 0;
+ static va_list * const args = 0;
+ const DWORD buf_chars = FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER
+ | FORMAT_MESSAGE_FROM_SYSTEM,
+ source,
+ err,
+ LANG_USER_DEFAULT,
+ &buf,
+ buf_size,
+ args);
+ assert(buf_chars != 0); // If FormatMessage failed, just give up.
+ const std::string buf_str(buf ? buf : "");
+ return buf_str;
+# else
+ return lt_dlerror();
+# endif
+}
+
int openvrml::local::dl::close(handle h)
{
# ifdef _WIN32
Modified: trunk/src/libopenvrml/openvrml/local/dl.h
===================================================================
--- trunk/src/libopenvrml/openvrml/local/dl.h 2009-03-31 03:25:12 UTC (rev 3876)
+++ trunk/src/libopenvrml/openvrml/local/dl.h 2009-04-01 02:28:51 UTC (rev 3877)
@@ -27,6 +27,7 @@
# else
# include <ltdl.h>
# endif
+# include <string>
namespace openvrml {
@@ -51,6 +52,8 @@
OPENVRML_LOCAL handle open(const char * filename);
+ OPENVRML_LOCAL const std::string error();
+
OPENVRML_LOCAL int close(handle);
OPENVRML_LOCAL void * sym(handle, const char * name);
Modified: trunk/src/libopenvrml/openvrml/local/node_metatype_registry_impl.cpp
===================================================================
--- trunk/src/libopenvrml/openvrml/local/node_metatype_registry_impl.cpp 2009-03-31 03:25:12 UTC (rev 3876)
+++ trunk/src/libopenvrml/openvrml/local/node_metatype_registry_impl.cpp 2009-04-01 02:28:51 UTC (rev 3877)
@@ -21,6 +21,7 @@
# include "node_metatype_registry_impl.h"
# include <openvrml/browser.h>
# include <boost/multi_index/detail/scope_guard.hpp>
+# include <iostream>
# include <sstream>
using namespace boost::multi_index::detail; // for scope_guard
@@ -37,7 +38,10 @@
*static_cast<node_metatype_registry_impl *>(data);
const dl::handle handle = dl::open(filename);
- if (!handle) { return 0; } // Ignore things we can't open.
+ if (!handle) {
+ std::cerr << dl::error() << std::endl;
+ return 0;
+ }
scope_guard handle_guard = make_guard(dl::close, handle);
//
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|