summaryrefslogtreecommitdiff
path: root/ext/win32ole
diff options
context:
space:
mode:
authorsuke <suke@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-10-14 12:44:37 +0000
committersuke <suke@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-10-14 12:44:37 +0000
commitf457364caef3999c920a946a2d0294692a6973c7 (patch)
tree603cd4aea8be2bc6cb10a87e50e17e96c4877626 /ext/win32ole
parent1288965f4e464686a95b701a2573f5a3cc406569 (diff)
* ext/win32ole/win32ole.c (load_conv_function51932): check
having IMultiLanguage2 or IMultiLanguage. [ruby-dev:36716] * ext/win32ole/extconf.rb: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19782 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/win32ole')
-rw-r--r--ext/win32ole/extconf.rb3
-rw-r--r--ext/win32ole/win32ole.c40
2 files changed, 29 insertions, 14 deletions
diff --git a/ext/win32ole/extconf.rb b/ext/win32ole/extconf.rb
index d853429..06a3f14 100644
--- a/ext/win32ole/extconf.rb
+++ b/ext/win32ole/extconf.rb
@@ -24,6 +24,9 @@ def create_win32ole_makefile
have_library("kernel32") and
have_library("advapi32") and
have_header("windows.h")
+ unless have_type("IMultiLanguage2", "mlang.h")
+ have_type("IMultiLanguage", "mlang.h")
+ end
create_makefile("win32ole")
create_docfile(SRCFILES)
else
diff --git a/ext/win32ole/win32ole.c b/ext/win32ole/win32ole.c
index c6db9e0..ee765e0 100644
--- a/ext/win32ole/win32ole.c
+++ b/ext/win32ole/win32ole.c
@@ -128,7 +128,7 @@ const IID IID_IMultiLanguage2 = {0xDCCFC164, 0x2B38, 0x11d2, {0xB7, 0xEC, 0x00,
#define WC2VSTR(x) ole_wc2vstr((x), TRUE)
-#define WIN32OLE_VERSION "1.3.6"
+#define WIN32OLE_VERSION "1.3.7"
typedef HRESULT (STDAPICALLTYPE FNCOCREATEINSTANCEEX)
(REFCLSID, IUnknown*, DWORD, COSERVERINFO*, DWORD, MULTI_QI*);
@@ -217,7 +217,14 @@ static st_table *enc2cp_table;
static IMessageFilterVtbl message_filter;
static IMessageFilter imessage_filter = { &message_filter };
static IMessageFilter* previous_filter;
-static IMultiLanguage2 *pIMultiLanguage2 = NULL;
+
+#if defined(HAVE_TYPE_IMULTILANGUAGE2)
+static IMultiLanguage2 *pIMultiLanguage = NULL;
+#elif defined(HAVE_TYPE_IMULTILANGUAGE)
+static IMultiLanguage *pIMultiLanguage = NULL;
+#else
+static void *pIMultiLanguage = NULL; /* dummy */
+#endif
struct oledata {
IDispatch *pDispatch;
@@ -971,15 +978,23 @@ static UINT ole_encoding2cp(rb_encoding *enc)
static void
load_conv_function51932()
{
- HRESULT hr;
+ HRESULT hr = E_NOINTERFACE;
void *p;
- if (!pIMultiLanguage2) {
+ if (!pIMultiLanguage) {
+#if defined(HAVE_TYPE_IMULTILANGUAGE2)
hr = CoCreateInstance(&CLSID_CMultiLanguage, NULL, CLSCTX_INPROC_SERVER,
&IID_IMultiLanguage2, &p);
+#elif defined(HAVE_TYPE_IMULTILANGUAGE)
+ hr = CoCreateInstance(&CLSID_CMultiLanguage, NULL, CLSCTX_INPROC_SERVER,
+ &IID_IMultiLanguage, &p);
+#else
+ hr = E_NOINTERFACE;
+ p = NULL;
+#endif
if (FAILED(hr)) {
rb_raise(eWIN32OLERuntimeError, "fail to load convert function for CP51932");
}
- pIMultiLanguage2 = p;
+ pIMultiLanguage = p;
}
}
@@ -1098,13 +1113,13 @@ ole_wc2mb(LPWSTR pw)
DWORD dw = 0;
if (cWIN32OLE_cp == 51932) {
load_conv_function51932();
- hr = pIMultiLanguage2->lpVtbl->ConvertStringFromUnicode(pIMultiLanguage2,
+ hr = pIMultiLanguage->lpVtbl->ConvertStringFromUnicode(pIMultiLanguage,
&dw, cWIN32OLE_cp, pw, NULL, NULL, &size);
if (FAILED(hr)) {
ole_raise(hr, eWIN32OLERuntimeError, "fail to convert Unicode to CP%d", cWIN32OLE_cp);
}
pm = ALLOC_N(char, size + 1);
- hr = pIMultiLanguage2->lpVtbl->ConvertStringFromUnicode(pIMultiLanguage2,
+ hr = pIMultiLanguage->lpVtbl->ConvertStringFromUnicode(pIMultiLanguage,
&dw, cWIN32OLE_cp, pw, NULL, pm, &size);
if (FAILED(hr)) {
ole_raise(hr, eWIN32OLERuntimeError, "fail to convert Unicode to CP%d", cWIN32OLE_cp);
@@ -1340,14 +1355,14 @@ ole_vstr2wc(VALUE vstr)
load_conv_function51932();
len = RSTRING_LEN(vstr);
size = 0;
- hr = pIMultiLanguage2->lpVtbl->ConvertStringToUnicode(pIMultiLanguage2,
+ hr = pIMultiLanguage->lpVtbl->ConvertStringToUnicode(pIMultiLanguage,
&dw, cp, RSTRING_PTR(vstr), &len, NULL, &size);
if (FAILED(hr)) {
ole_raise(hr, eWIN32OLERuntimeError, "fail to convert CP%d to Unicode", cp);
}
pw = SysAllocStringLen(NULL, size);
len = RSTRING_LEN(vstr);
- hr = pIMultiLanguage2->lpVtbl->ConvertStringToUnicode(pIMultiLanguage2,
+ hr = pIMultiLanguage->lpVtbl->ConvertStringToUnicode(pIMultiLanguage,
&dw, cp, RSTRING_PTR(vstr), &len, pw, &size);
if (FAILED(hr)) {
ole_raise(hr, eWIN32OLERuntimeError, "fail to convert CP%d to Unicode", cp);
@@ -1372,13 +1387,13 @@ ole_mb2wc(char *pm, int len)
if (cWIN32OLE_cp == 51932) {
load_conv_function51932();
size = 0;
- hr = pIMultiLanguage2->lpVtbl->ConvertStringToUnicode(pIMultiLanguage2,
+ hr = pIMultiLanguage->lpVtbl->ConvertStringToUnicode(pIMultiLanguage,
&dw, cWIN32OLE_cp, pm, &n, NULL, &size);
if (FAILED(hr)) {
ole_raise(hr, eWIN32OLERuntimeError, "fail to convert CP%d to Unicode", cWIN32OLE_cp);
}
pw = SysAllocStringLen(NULL, size);
- hr = pIMultiLanguage2->lpVtbl->ConvertStringToUnicode(pIMultiLanguage2,
+ hr = pIMultiLanguage->lpVtbl->ConvertStringToUnicode(pIMultiLanguage,
&dw, cWIN32OLE_cp, pm, &n, pw, &size);
if (FAILED(hr)) {
ole_raise(hr, eWIN32OLERuntimeError, "fail to convert CP%d to Unicode", cWIN32OLE_cp);
@@ -9139,7 +9154,4 @@ Init_win32ole()
init_enc2cp();
atexit((void (*)(void))free_enc2cp);
ole_init_cp();
- /*
- cWIN32OLE_enc = ole_cp2encoding(cWIN32OLE_cp);
- */
}