summaryrefslogtreecommitdiff
path: root/ext/win32ole
diff options
context:
space:
mode:
authorsuke <suke@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-07-07 11:49:14 +0000
committersuke <suke@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-07-07 11:49:14 +0000
commit6aff4b8eaa7e2b8bc0bb458dd1882d4b1b197a04 (patch)
treea7eade95ddfc2972d7cec3d2c391d4c4c6bc5e08 /ext/win32ole
parent1d6e2caf10b477739012f92e3c08be23d8459363 (diff)
* ext/win32ole/win32ole.c(Init_win32ole): add
WIN32OLE_TYPE#source_ole_types, WIN32OLE_TYPE#default_ole_types, WIN32OLE_TYPE#default_event_sources. * test/win32ole/test_win32ole_type.rb: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17942 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/win32ole')
-rw-r--r--ext/win32ole/win32ole.c97
1 files changed, 83 insertions, 14 deletions
diff --git a/ext/win32ole/win32ole.c b/ext/win32ole/win32ole.c
index 606c496..dd7d7b1 100644
--- a/ext/win32ole/win32ole.c
+++ b/ext/win32ole/win32ole.c
@@ -118,7 +118,7 @@
#define WC2VSTR(x) ole_wc2vstr((x), TRUE)
-#define WIN32OLE_VERSION "1.2.0"
+#define WIN32OLE_VERSION "1.2.1"
typedef HRESULT (STDAPICALLTYPE FNCOCREATEINSTANCEEX)
(REFCLSID, IUnknown*, DWORD, COSERVERINFO*, DWORD, MULTI_QI*);
@@ -424,8 +424,11 @@ static VALUE foletype_helpfile(VALUE self);
static VALUE ole_type_helpcontext(ITypeInfo *pTypeInfo);
static VALUE foletype_helpcontext(VALUE self);
static VALUE foletype_ole_typelib(VALUE self);
-static VALUE ole_type_impl_ole_types(ITypeInfo *pTypeInfo);
+static VALUE ole_type_impl_ole_types(ITypeInfo *pTypeInfo, int implflags);
static VALUE foletype_impl_ole_types(VALUE self);
+static VALUE foletype_source_ole_types(VALUE self);
+static VALUE foletype_default_event_sources(VALUE self);
+static VALUE foletype_default_ole_types(VALUE self);
static VALUE foletype_inspect(VALUE self);
static VALUE ole_variables(ITypeInfo *pTypeInfo);
static VALUE foletype_variables(VALUE self);
@@ -5756,7 +5759,7 @@ foletype_ole_typelib(VALUE self)
}
static VALUE
-ole_type_impl_ole_types(ITypeInfo *pTypeInfo)
+ole_type_impl_ole_types(ITypeInfo *pTypeInfo, int implflags)
{
HRESULT hr;
ITypeInfo *pRefTypeInfo;
@@ -5782,9 +5785,12 @@ ole_type_impl_ole_types(ITypeInfo *pTypeInfo)
hr = pTypeInfo->lpVtbl->GetRefTypeInfo(pTypeInfo, href, &pRefTypeInfo);
if (FAILED(hr))
continue;
- type = ole_type_from_itypeinfo(pRefTypeInfo);
- if (type != Qnil) {
- rb_ary_push(types, type);
+
+ if ((flags & implflags) == implflags) {
+ type = ole_type_from_itypeinfo(pRefTypeInfo);
+ if (type != Qnil) {
+ rb_ary_push(types, type);
+ }
}
OLE_RELEASE(pRefTypeInfo);
@@ -5807,7 +5813,60 @@ foletype_impl_ole_types(VALUE self)
{
struct oletypedata *ptype;
Data_Get_Struct(self, struct oletypedata, ptype);
- return ole_type_impl_ole_types(ptype->pTypeInfo);
+ return ole_type_impl_ole_types(ptype->pTypeInfo, 0);
+}
+
+/*
+ * call-seq:
+ * WIN32OLE_TYPE#source_ole_types
+ *
+ * Returns the array of WIN32OLE_TYPE object which is implemented by the WIN32OLE_TYPE
+ * object and having IMPLTYPEFLAG_FSOURCE.
+ * tobj = WIN32OLE_TYPE.new('Microsoft Internet Controls', "InternetExplorer")
+ * p tobj.source_ole_types
+ * # => [#<WIN32OLE_TYPE:DWebBrowserEvents2>, #<WIN32OLE_TYPE:DWebBrowserEvents>]
+ */
+static VALUE
+foletype_source_ole_types(VALUE self)
+{
+ struct oletypedata *ptype;
+ Data_Get_Struct(self, struct oletypedata, ptype);
+ return ole_type_impl_ole_types(ptype->pTypeInfo, IMPLTYPEFLAG_FSOURCE);
+}
+
+/*
+ * call-seq:
+ * WIN32OLE_TYPE#default_event_sources
+ *
+ * Returns the array of WIN32OLE_TYPE object which is implemented by the WIN32OLE_TYPE
+ * object and having IMPLTYPEFLAG_FSOURCE and IMPLTYPEFLAG_FDEFAULT.
+ * tobj = WIN32OLE_TYPE.new('Microsoft Internet Controls', "InternetExplorer")
+ * p tobj.default_event_sources # => [#<WIN32OLE_TYPE:DWebBrowserEvents2>]
+ */
+static VALUE
+foletype_default_event_sources(VALUE self)
+{
+ struct oletypedata *ptype;
+ Data_Get_Struct(self, struct oletypedata, ptype);
+ return ole_type_impl_ole_types(ptype->pTypeInfo, IMPLTYPEFLAG_FSOURCE|IMPLTYPEFLAG_FDEFAULT);
+}
+
+/*
+ * call-seq:
+ * WIN32OLE_TYPE#default_ole_types
+ *
+ * Returns the array of WIN32OLE_TYPE object which is implemented by the WIN32OLE_TYPE
+ * object and having IMPLTYPEFLAG_FDEFAULT.
+ * tobj = WIN32OLE_TYPE.new('Microsoft Internet Controls', "InternetExplorer")
+ * p tobj.default_ole_types
+ * # => [#<WIN32OLE_TYPE:IWebBrowser2>, #<WIN32OLE_TYPE:DWebBrowserEvents2>]
+ */
+static VALUE
+foletype_default_ole_types(VALUE self)
+{
+ struct oletypedata *ptype;
+ Data_Get_Struct(self, struct oletypedata, ptype);
+ return ole_type_impl_ole_types(ptype->pTypeInfo, IMPLTYPEFLAG_FDEFAULT);
}
static VALUE
@@ -7564,20 +7623,27 @@ find_default_source(VALUE ole, IID *piid, ITypeInfo **ppTypeInfo)
GUIDKIND_DEFAULT_SOURCE_DISP_IID,
piid);
OLE_RELEASE(pProvideClassInfo2);
- return find_iid(ole, NULL, piid, ppTypeInfo);
+ if (SUCCEEDED(hr)) {
+ hr = find_iid(ole, NULL, piid, ppTypeInfo);
+ }
+ }
+ if (SUCCEEDED(hr)) {
+ return hr;
}
hr = pDispatch->lpVtbl->QueryInterface(pDispatch,
&IID_IProvideClassInfo,
(void**)&pProvideClassInfo);
- if (FAILED(hr))
- return hr;
+ if (SUCCEEDED(hr)) {
- hr = pProvideClassInfo->lpVtbl->GetClassInfo(pProvideClassInfo,
- &pTypeInfo);
- OLE_RELEASE(pProvideClassInfo);
+ hr = pProvideClassInfo->lpVtbl->GetClassInfo(pProvideClassInfo,
+ &pTypeInfo);
+ OLE_RELEASE(pProvideClassInfo);
+ }
+ if (FAILED(hr)) {
+ hr = pDispatch->lpVtbl->GetTypeInfo(pDispatch, 0, cWIN32OLE_lcid, &pTypeInfo );
+ }
if (FAILED(hr))
return hr;
-
hr = OLE_GET_TYPEATTR(pTypeInfo, &pTypeAttr);
if (FAILED(hr)) {
OLE_RELEASE(pTypeInfo);
@@ -8443,6 +8509,9 @@ Init_win32ole()
rb_define_method(cWIN32OLE_TYPE, "ole_methods", foletype_methods, 0);
rb_define_method(cWIN32OLE_TYPE, "ole_typelib", foletype_ole_typelib, 0);
rb_define_method(cWIN32OLE_TYPE, "implemented_ole_types", foletype_impl_ole_types, 0);
+ rb_define_method(cWIN32OLE_TYPE, "source_ole_types", foletype_source_ole_types, 0);
+ rb_define_method(cWIN32OLE_TYPE, "default_event_sources", foletype_default_event_sources, 0);
+ rb_define_method(cWIN32OLE_TYPE, "default_ole_types", foletype_default_ole_types, 0);
rb_define_method(cWIN32OLE_TYPE, "inspect", foletype_inspect, 0);
cWIN32OLE_VARIABLE = rb_define_class("WIN32OLE_VARIABLE", rb_cObject);