summaryrefslogtreecommitdiff
path: root/ext/win32ole/win32ole_method.c
diff options
context:
space:
mode:
authorsuke <suke@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-08-12 14:21:22 +0000
committersuke <suke@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-08-12 14:21:22 +0000
commitaeb8791dab0accdf4847fe9d35bea1e1907803dc (patch)
treec2a0319e7241276509cd2c07b9d96338df65e76f /ext/win32ole/win32ole_method.c
parent7bf7bb84d3f9390f787d3ba594893f904dc47dc1 (diff)
* ext/win32ole/win32ole.c: refactoring. move some methods
into win32ole_type.c / win32ole_method.c * ext/win32ole/win32ole.h: ditto. * ext/win32ole/win32ole_method.c: ditto. * ext/win32ole/win32ole_method.h: ditto. * ext/win32ole/win32ole_type.h: ditto. * ext/win32ole/win32ole_type.h: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47155 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/win32ole/win32ole_method.c')
-rw-r--r--ext/win32ole/win32ole_method.c42
1 files changed, 41 insertions, 1 deletions
diff --git a/ext/win32ole/win32ole_method.c b/ext/win32ole/win32ole_method.c
index 9da7021..dbfc868 100644
--- a/ext/win32ole/win32ole_method.c
+++ b/ext/win32ole/win32ole_method.c
@@ -1,6 +1,8 @@
#include "win32ole.h"
static VALUE ole_method_sub(VALUE self, ITypeInfo *pOwnerTypeInfo, ITypeInfo *pTypeInfo, VALUE name);
+static VALUE olemethod_from_typeinfo(VALUE self, ITypeInfo *pTypeInfo, VALUE name);
+static VALUE ole_methods_sub(ITypeInfo *pOwnerTypeInfo, ITypeInfo *pTypeInfo, VALUE methods, int mask);
static void olemethod_free(struct olemethoddata *polemethod);
static VALUE olemethod_set_member(VALUE self, ITypeInfo *pTypeInfo, ITypeInfo *pOwnerTypeInfo, int index, VALUE name);
static VALUE folemethod_initialize(VALUE self, VALUE oletype, VALUE method);
@@ -85,6 +87,35 @@ ole_method_sub(VALUE self, ITypeInfo *pOwnerTypeInfo, ITypeInfo *pTypeInfo, VALU
}
VALUE
+ole_methods_from_typeinfo(ITypeInfo *pTypeInfo, int mask)
+{
+ HRESULT hr;
+ TYPEATTR *pTypeAttr;
+ WORD i;
+ HREFTYPE href;
+ ITypeInfo *pRefTypeInfo;
+ VALUE methods = rb_ary_new();
+ hr = OLE_GET_TYPEATTR(pTypeInfo, &pTypeAttr);
+ if (FAILED(hr)) {
+ ole_raise(hr, eWIN32OLERuntimeError, "failed to GetTypeAttr");
+ }
+
+ ole_methods_sub(0, pTypeInfo, methods, mask);
+ for(i=0; i < pTypeAttr->cImplTypes; i++){
+ hr = pTypeInfo->lpVtbl->GetRefTypeOfImplType(pTypeInfo, i, &href);
+ if(FAILED(hr))
+ continue;
+ hr = pTypeInfo->lpVtbl->GetRefTypeInfo(pTypeInfo, href, &pRefTypeInfo);
+ if (FAILED(hr))
+ continue;
+ ole_methods_sub(pTypeInfo, pRefTypeInfo, methods, mask);
+ OLE_RELEASE(pRefTypeInfo);
+ }
+ OLE_RELEASE_TYPEATTR(pTypeInfo, pTypeAttr);
+ return methods;
+}
+
+static VALUE
olemethod_from_typeinfo(VALUE self, ITypeInfo *pTypeInfo, VALUE name)
{
HRESULT hr;
@@ -115,7 +146,7 @@ olemethod_from_typeinfo(VALUE self, ITypeInfo *pTypeInfo, VALUE name)
return method;
}
-VALUE
+static VALUE
ole_methods_sub(ITypeInfo *pOwnerTypeInfo, ITypeInfo *pTypeInfo, VALUE methods, int mask)
{
HRESULT hr;
@@ -153,6 +184,15 @@ ole_methods_sub(ITypeInfo *pOwnerTypeInfo, ITypeInfo *pTypeInfo, VALUE methods,
return methods;
}
+VALUE
+create_win32ole_method(ITypeInfo *pTypeInfo, VALUE name)
+{
+
+ VALUE method = folemethod_s_allocate(cWIN32OLE_METHOD);
+ VALUE obj = olemethod_from_typeinfo(method, pTypeInfo, name);
+ return obj;
+}
+
/*
* Document-class: WIN32OLE_METHOD
*