Fix plugins with MSVC, thanks to Gulam Faruque.
* syx/syx-plugins.c (syx_library_open): use GetModuleHandle to get application handle
* syx/syx-utils.c (syx_to_wstring, syx_to_string): check for NULL input
* msvc/syx-config.h (WITH_PLUGINS): define
:100644 100644 63a9d1d... 6b9c39f... M ChangeLog
:100644 100644 027be87... 7de667e... M msvc/syx-config.h
:100644 100644 0db1829... 4e3179a... M syx/syx-interp.h
:100644 100644 3802731... 2b78333... M syx/syx-plugins.c
:100644 100644 6818878... 3d63759... M syx/syx-utils.c
diff --git a/ChangeLog b/ChangeLog
index 63a9d1d..6b9c39f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2009-05-24 Luca Bruno <letha...@gmail.com>
+
+ Fix plugins with MSVC, thanks to Gulam Faruque.
+
+ * syx/syx-plugins.c (syx_library_open): use GetModuleHandle to get application handle
+
+ * syx/syx-utils.c (syx_to_wstring, syx_to_string): check for NULL input
+
+ * msvc/syx-config.h (WITH_PLUGINS): define
+
2009-05-22 Luca Bruno <letha...@gmail.com>
* msvc/syx-config.h: define HAVE_FSTAT; thanks Gulam Faruque
diff --git a/msvc/syx-config.h b/msvc/syx-config.h
index 027be87..7de667e 100644
--- a/msvc/syx-config.h
+++ b/msvc/syx-config.h
@@ -16,6 +16,8 @@
#define write _write
#define close _close
+#define WITH_PLUGINS 1
+
#define ROOT_PATH "."
#define IMAGE_PATH "default.sim"
#define PLUGIN_PATH "lib"
diff --git a/syx/syx-interp.h b/syx/syx-interp.h
index 0db1829..4e3179a 100644
--- a/syx/syx-interp.h
+++ b/syx/syx-interp.h
@@ -105,7 +105,7 @@ EXPORT void _syx_interp_frame_prepare_new (SyxInterpState *state, SyxOop method)
typedef syx_bool (* SyxPrimitiveFunc) (SyxInterpState *es, SyxOop method);
#define SYX_FUNC_PRIMITIVE(name) \
- syx_bool \
+ EXPORT syx_bool \
name (SyxInterpState *es, SyxOop method)
typedef struct SyxPrimitiveEntry SyxPrimitiveEntry;
diff --git a/syx/syx-plugins.c b/syx/syx-plugins.c
index 3802731..2b78333 100644
--- a/syx/syx-plugins.c
+++ b/syx/syx-plugins.c
@@ -145,7 +145,10 @@ syx_library_open (syx_symbol location)
#ifdef WITH_PLUGINS
#ifndef HAVE_LIBDL
- ret = LoadLibrary (SYX_IFDEF_UNICODE (location));
+ if (location)
+ ret = LoadLibrary (SYX_IFDEF_UNICODE (location));
+ else
+ ret = GetModuleHandle(NULL);
#else /* HAVE_LIBDL */
ret = dlopen (location, RTLD_NOW);
diff --git a/syx/syx-utils.c b/syx/syx-utils.c
index 6818878..3d63759 100644
--- a/syx/syx-utils.c
+++ b/syx/syx-utils.c
@@ -574,8 +574,13 @@ syx_do_it_blocking (syx_symbol code)
syx_wstring
syx_to_wstring (syx_symbol s)
{
- syx_size size = strlen (s);
- syx_wstring ws = (syx_wstring) syx_calloc (size+1, sizeof (wchar_t));
+ syx_size size;
+ syx_wstring ws;
+ if (!s)
+ return NULL;
+
+ size = strlen (s);
+ ws = (syx_wstring) syx_calloc (size+1, sizeof (wchar_t));
mbstowcs (ws, s, size);
return ws;
}
@@ -584,8 +589,13 @@ syx_to_wstring (syx_symbol s)
syx_string
syx_to_string (syx_wsymbol ws)
{
- syx_size size = wcslen (ws);
- syx_string s = (syx_string) syx_calloc (size+1, sizeof (syx_char));
+ syx_size size;
+ syx_string s;
+ if (!ws)
+ return NULL;
+
+ size = wcslen (ws);
+ s = (syx_string) syx_calloc (size+1, sizeof (syx_char));
wcstombs (s, ws, size);
return s;
}