3 static void olemethod_free(
void *ptr);
4 static size_t olemethod_size(
const void *ptr);
5 static VALUE ole_method_sub(
VALUE self, ITypeInfo *pOwnerTypeInfo, ITypeInfo *pTypeInfo,
VALUE name);
7 static VALUE ole_methods_sub(ITypeInfo *pOwnerTypeInfo, ITypeInfo *pTypeInfo,
VALUE methods,
int mask);
8 static VALUE olemethod_set_member(
VALUE self, ITypeInfo *pTypeInfo, ITypeInfo *pOwnerTypeInfo,
int index,
VALUE name);
11 static VALUE ole_method_return_type(ITypeInfo *pTypeInfo, UINT method_index);
12 static VALUE folemethod_return_type(
VALUE self);
13 static VALUE ole_method_return_vtype(ITypeInfo *pTypeInfo, UINT method_index);
14 static VALUE folemethod_return_vtype(
VALUE self);
15 static VALUE ole_method_return_type_detail(ITypeInfo *pTypeInfo, UINT method_index);
16 static VALUE folemethod_return_type_detail(
VALUE self);
17 static VALUE ole_method_invkind(ITypeInfo *pTypeInfo, UINT method_index);
18 static VALUE ole_method_invoke_kind(ITypeInfo *pTypeInfo, UINT method_index);
20 static VALUE folemethod_invoke_kind(
VALUE self);
21 static VALUE ole_method_visible(ITypeInfo *pTypeInfo, UINT method_index);
23 static VALUE ole_method_event(ITypeInfo *pTypeInfo, UINT method_index,
VALUE method_name);
25 static VALUE folemethod_event_interface(
VALUE self);
26 static HRESULT ole_method_docinfo_from_type(ITypeInfo *pTypeInfo, UINT method_index, BSTR *
name, BSTR *helpstr,
DWORD *helpcontext, BSTR *helpfile);
27 static VALUE ole_method_helpstring(ITypeInfo *pTypeInfo, UINT method_index);
28 static VALUE folemethod_helpstring(
VALUE self);
29 static VALUE ole_method_helpfile(ITypeInfo *pTypeInfo, UINT method_index);
31 static VALUE ole_method_helpcontext(ITypeInfo *pTypeInfo, UINT method_index);
32 static VALUE folemethod_helpcontext(
VALUE self);
33 static VALUE ole_method_dispid(ITypeInfo *pTypeInfo, UINT method_index);
35 static VALUE ole_method_offset_vtbl(ITypeInfo *pTypeInfo, UINT method_index);
36 static VALUE folemethod_offset_vtbl(
VALUE self);
37 static VALUE ole_method_size_params(ITypeInfo *pTypeInfo, UINT method_index);
38 static VALUE folemethod_size_params(
VALUE self);
39 static VALUE ole_method_size_opt_params(ITypeInfo *pTypeInfo, UINT method_index);
40 static VALUE folemethod_size_opt_params(
VALUE self);
41 static VALUE ole_method_params(ITypeInfo *pTypeInfo, UINT method_index);
47 {
NULL, olemethod_free, olemethod_size,},
52 olemethod_free(
void *ptr)
61 olemethod_size(
const void *ptr)
88 for(i = 0; i < pTypeAttr->cFuncs && method ==
Qnil; i++) {
89 hr = pTypeInfo->lpVtbl->GetFuncDesc(pTypeInfo, i, &pFuncDesc);
93 hr = pTypeInfo->lpVtbl->GetDocumentation(pTypeInfo, pFuncDesc->memid,
96 pTypeInfo->lpVtbl->ReleaseFuncDesc(pTypeInfo, pFuncDesc);
101 olemethod_set_member(
self, pTypeInfo, pOwnerTypeInfo, i, fname);
104 pTypeInfo->lpVtbl->ReleaseFuncDesc(pTypeInfo, pFuncDesc);
118 ITypeInfo *pRefTypeInfo;
125 ole_methods_sub(0, pTypeInfo, methods, mask);
126 for(i=0; i < pTypeAttr->cImplTypes; i++){
127 hr = pTypeInfo->lpVtbl->GetRefTypeOfImplType(pTypeInfo, i, &href);
130 hr = pTypeInfo->lpVtbl->GetRefTypeInfo(pTypeInfo, href, &pRefTypeInfo);
133 ole_methods_sub(pTypeInfo, pRefTypeInfo, methods, mask);
141 olemethod_from_typeinfo(
VALUE self, ITypeInfo *pTypeInfo,
VALUE name)
147 ITypeInfo *pRefTypeInfo;
153 method = ole_method_sub(
self, 0, pTypeInfo, name);
154 if (method !=
Qnil) {
157 for(i=0; i < pTypeAttr->cImplTypes && method ==
Qnil; i++){
158 hr = pTypeInfo->lpVtbl->GetRefTypeOfImplType(pTypeInfo, i, &href);
161 hr = pTypeInfo->lpVtbl->GetRefTypeInfo(pTypeInfo, href, &pRefTypeInfo);
164 method = ole_method_sub(
self, pTypeInfo, pRefTypeInfo, name);
172 ole_methods_sub(ITypeInfo *pOwnerTypeInfo, ITypeInfo *pTypeInfo,
VALUE methods,
int mask)
184 for(i = 0; i < pTypeAttr->cFuncs; i++) {
185 hr = pTypeInfo->lpVtbl->GetFuncDesc(pTypeInfo, i, &pFuncDesc);
189 hr = pTypeInfo->lpVtbl->GetDocumentation(pTypeInfo, pFuncDesc->memid,
192 pTypeInfo->lpVtbl->ReleaseFuncDesc(pTypeInfo, pFuncDesc);
195 if(pFuncDesc->invkind & mask) {
197 olemethod_set_member(method, pTypeInfo, pOwnerTypeInfo,
201 pTypeInfo->lpVtbl->ReleaseFuncDesc(pTypeInfo, pFuncDesc);
214 VALUE obj = olemethod_from_typeinfo(method, pTypeInfo, name);
225 olemethod_set_member(
VALUE self, ITypeInfo *pTypeInfo, ITypeInfo *pOwnerTypeInfo,
int index,
VALUE name)
245 &olemethod_datatype, pmethod);
273 obj = olemethod_from_typeinfo(
self, pTypeInfo, method);
297 folemethod_name(
VALUE self)
303 ole_method_return_type(ITypeInfo *pTypeInfo, UINT method_index)
309 hr = pTypeInfo->lpVtbl->GetFuncDesc(pTypeInfo, method_index, &pFuncDesc);
314 pTypeInfo->lpVtbl->ReleaseFuncDesc(pTypeInfo, pFuncDesc);
329 folemethod_return_type(
VALUE self)
333 return ole_method_return_type(pmethod->
pTypeInfo, pmethod->
index);
337 ole_method_return_vtype(ITypeInfo *pTypeInfo, UINT method_index)
343 hr = pTypeInfo->lpVtbl->GetFuncDesc(pTypeInfo, method_index, &pFuncDesc);
347 vvt =
RB_INT2FIX(pFuncDesc->elemdescFunc.tdesc.vt);
348 pTypeInfo->lpVtbl->ReleaseFuncDesc(pTypeInfo, pFuncDesc);
363 folemethod_return_vtype(
VALUE self)
367 return ole_method_return_vtype(pmethod->
pTypeInfo, pmethod->
index);
371 ole_method_return_type_detail(ITypeInfo *pTypeInfo, UINT method_index)
377 hr = pTypeInfo->lpVtbl->GetFuncDesc(pTypeInfo, method_index, &pFuncDesc);
382 pTypeInfo->lpVtbl->ReleaseFuncDesc(pTypeInfo, pFuncDesc);
397 folemethod_return_type_detail(
VALUE self)
401 return ole_method_return_type_detail(pmethod->
pTypeInfo, pmethod->
index);
405 ole_method_invkind(ITypeInfo *pTypeInfo, UINT method_index)
410 hr = pTypeInfo->lpVtbl->GetFuncDesc(pTypeInfo, method_index, &pFuncDesc);
414 pTypeInfo->lpVtbl->ReleaseFuncDesc(pTypeInfo, pFuncDesc);
419 ole_method_invoke_kind(ITypeInfo *pTypeInfo, UINT method_index)
422 VALUE invkind = ole_method_invkind(pTypeInfo, method_index);
423 if((
RB_FIX2INT(invkind) & INVOKE_PROPERTYGET) &&
424 (
RB_FIX2INT(invkind) & INVOKE_PROPERTYPUT) ) {
426 }
else if(
RB_FIX2INT(invkind) & INVOKE_PROPERTYGET) {
428 }
else if(
RB_FIX2INT(invkind) & INVOKE_PROPERTYPUT) {
430 }
else if(
RB_FIX2INT(invkind) & INVOKE_PROPERTYPUTREF) {
432 }
else if(
RB_FIX2INT(invkind) & INVOKE_FUNC) {
449 folemethod_invkind(
VALUE self)
468 folemethod_invoke_kind(
VALUE self)
472 return ole_method_invoke_kind(pmethod->
pTypeInfo, pmethod->
index);
476 ole_method_visible(ITypeInfo *pTypeInfo, UINT method_index)
481 hr = pTypeInfo->lpVtbl->GetFuncDesc(pTypeInfo, method_index, &pFuncDesc);
484 if (pFuncDesc->wFuncFlags & (FUNCFLAG_FRESTRICTED |
486 FUNCFLAG_FNONBROWSABLE)) {
491 pTypeInfo->lpVtbl->ReleaseFuncDesc(pTypeInfo, pFuncDesc);
505 folemethod_visible(
VALUE self)
513 ole_method_event(ITypeInfo *pTypeInfo, UINT method_index,
VALUE method_name)
520 ITypeInfo *pRefTypeInfo;
529 if(pTypeAttr->typekind != TKIND_COCLASS) {
530 pTypeInfo->lpVtbl->ReleaseTypeAttr(pTypeInfo, pTypeAttr);
533 for (i = 0; i < pTypeAttr->cImplTypes; i++) {
534 hr = pTypeInfo->lpVtbl->GetImplTypeFlags(pTypeInfo, i, &flags);
538 if (flags & IMPLTYPEFLAG_FSOURCE) {
539 hr = pTypeInfo->lpVtbl->GetRefTypeOfImplType(pTypeInfo,
543 hr = pTypeInfo->lpVtbl->GetRefTypeInfo(pTypeInfo,
544 href, &pRefTypeInfo);
547 hr = pRefTypeInfo->lpVtbl->GetFuncDesc(pRefTypeInfo, method_index,
554 hr = pRefTypeInfo->lpVtbl->GetDocumentation(pRefTypeInfo,
558 pRefTypeInfo->lpVtbl->ReleaseFuncDesc(pRefTypeInfo, pFuncDesc);
564 pRefTypeInfo->lpVtbl->ReleaseFuncDesc(pRefTypeInfo, pFuncDesc);
587 folemethod_event(
VALUE self)
608 folemethod_event_interface(
VALUE self)
614 if(folemethod_event(
self) ==
Qtrue) {
623 ole_method_docinfo_from_type(
624 ITypeInfo *pTypeInfo,
634 hr = pTypeInfo->lpVtbl->GetFuncDesc(pTypeInfo, method_index, &pFuncDesc);
637 hr = pTypeInfo->lpVtbl->GetDocumentation(pTypeInfo, pFuncDesc->memid,
639 helpcontext, helpfile);
640 pTypeInfo->lpVtbl->ReleaseFuncDesc(pTypeInfo, pFuncDesc);
645 ole_method_helpstring(ITypeInfo *pTypeInfo, UINT method_index)
649 hr = ole_method_docinfo_from_type(pTypeInfo, method_index,
NULL, &bhelpstring,
668 folemethod_helpstring(
VALUE self)
676 ole_method_helpfile(ITypeInfo *pTypeInfo, UINT method_index)
680 hr = ole_method_docinfo_from_type(pTypeInfo, method_index,
NULL,
NULL,
698 folemethod_helpfile(
VALUE self)
707 ole_method_helpcontext(ITypeInfo *pTypeInfo, UINT method_index)
710 DWORD helpcontext = 0;
711 hr = ole_method_docinfo_from_type(pTypeInfo, method_index,
NULL,
NULL,
728 folemethod_helpcontext(
VALUE self)
732 return ole_method_helpcontext(pmethod->
pTypeInfo, pmethod->
index);
736 ole_method_dispid(ITypeInfo *pTypeInfo, UINT method_index)
741 hr = pTypeInfo->lpVtbl->GetFuncDesc(pTypeInfo, method_index, &pFuncDesc);
745 pTypeInfo->lpVtbl->ReleaseFuncDesc(pTypeInfo, pFuncDesc);
759 folemethod_dispid(
VALUE self)
767 ole_method_offset_vtbl(ITypeInfo *pTypeInfo, UINT method_index)
772 hr = pTypeInfo->lpVtbl->GetFuncDesc(pTypeInfo, method_index, &pFuncDesc);
776 pTypeInfo->lpVtbl->ReleaseFuncDesc(pTypeInfo, pFuncDesc);
790 folemethod_offset_vtbl(
VALUE self)
794 return ole_method_offset_vtbl(pmethod->
pTypeInfo, pmethod->
index);
798 ole_method_size_params(ITypeInfo *pTypeInfo, UINT method_index)
803 hr = pTypeInfo->lpVtbl->GetFuncDesc(pTypeInfo, method_index, &pFuncDesc);
807 pTypeInfo->lpVtbl->ReleaseFuncDesc(pTypeInfo, pFuncDesc);
822 folemethod_size_params(
VALUE self)
826 return ole_method_size_params(pmethod->
pTypeInfo, pmethod->
index);
830 ole_method_size_opt_params(ITypeInfo *pTypeInfo, UINT method_index)
835 hr = pTypeInfo->lpVtbl->GetFuncDesc(pTypeInfo, method_index, &pFuncDesc);
837 return size_opt_params;
838 size_opt_params =
RB_INT2FIX(pFuncDesc->cParamsOpt);
839 pTypeInfo->lpVtbl->ReleaseFuncDesc(pTypeInfo, pFuncDesc);
840 return size_opt_params;
853 folemethod_size_opt_params(
VALUE self)
857 return ole_method_size_opt_params(pmethod->
pTypeInfo, pmethod->
index);
861 ole_method_params(ITypeInfo *pTypeInfo, UINT method_index)
869 hr = pTypeInfo->lpVtbl->GetFuncDesc(pTypeInfo, method_index, &pFuncDesc);
874 bstrs =
ALLOCA_N(BSTR, pFuncDesc->cParams + 1);
875 hr = pTypeInfo->lpVtbl->GetNames(pTypeInfo, pFuncDesc->memid,
876 bstrs, pFuncDesc->cParams + 1,
879 pTypeInfo->lpVtbl->ReleaseFuncDesc(pTypeInfo, pFuncDesc);
882 SysFreeString(bstrs[0]);
883 if (pFuncDesc->cParams > 0) {
884 for(i = 1; i <
len; i++) {
889 pTypeInfo->lpVtbl->ReleaseFuncDesc(pTypeInfo, pFuncDesc);
906 folemethod_params(
VALUE self)
921 folemethod_inspect(
VALUE self)
VALUE eWIN32OLERuntimeError
#define RUBY_TYPED_FREE_IMMEDIATELY
void Init_win32ole_method(void)
void rb_raise(VALUE exc, const char *fmt,...)
#define TypedData_Get_Struct(obj, type, data_type, sval)
VALUE folemethod_s_allocate(VALUE klass)
VALUE rb_ary_push(VALUE ary, VALUE item)
#define OLE_GET_TYPEATTR(X, Y)
VALUE rb_ivar_get(VALUE, ID)
void rb_define_alloc_func(VALUE, rb_alloc_func_t)
int rb_str_cmp(VALUE, VALUE)
VALUE rb_obj_is_kind_of(VALUE, VALUE)
call-seq: obj.is_a?(class) -> true or false obj.kind_of?(class) -> true or false
void ole_raise(HRESULT hr, VALUE ecs, const char *fmt,...)
ITypeInfo * pOwnerTypeInfo
VALUE default_inspect(VALUE self, const char *class_name)
RUBY_EXTERN VALUE rb_cObject
VALUE rb_define_class(const char *name, VALUE super)
Defines a top-level class.
VALUE ole_methods_from_typeinfo(ITypeInfo *pTypeInfo, int mask)
#define ALLOCA_N(type, n)
void rb_define_alias(VALUE klass, const char *name1, const char *name2)
Defines an alias of a method.
VALUE rb_ivar_set(VALUE, ID, VALUE)
struct olemethoddata * olemethod_data_get_struct(VALUE obj)
register unsigned int len
VALUE ole_typedesc2val(ITypeInfo *pTypeInfo, TYPEDESC *pTypeDesc, VALUE typedetails)
VALUE create_win32ole_param(ITypeInfo *pTypeInfo, UINT method_index, UINT index, VALUE name)
typedef HRESULT(STDAPICALLTYPE FNCOCREATEINSTANCEEX)(REFCLSID
VALUE create_win32ole_method(ITypeInfo *pTypeInfo, VALUE name)
#define TypedData_Make_Struct(klass, type, data_type, sval)
#define OLE_RELEASE_TYPEATTR(X, Y)
#define SafeStringValue(v)
#define StringValuePtr(v)
ITypeInfo * itypeinfo(VALUE self)
HRESULT ole_docinfo_from_type(ITypeInfo *pTypeInfo, BSTR *name, BSTR *helpstr, DWORD *helpcontext, BSTR *helpfile)
void rb_define_method(VALUE klass, const char *name, VALUE(*func)(ANYARGS), int argc)