From f14180707d83a9e15106952102d1853b441edabd Mon Sep 17 00:00:00 2001 From: suke Date: Sat, 1 Jun 2002 12:34:30 +0000 Subject: merge win32ole from rough git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2508 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ext/win32ole/.cvsignore | 2 + ext/win32ole/MANIFEST | 24 + ext/win32ole/depend | 1 + ext/win32ole/doc/win32ole.rd | 294 ++ ext/win32ole/extconf.rb | 26 + ext/win32ole/lib/win32ole/property.rb | 16 + ext/win32ole/sample/excel1.rb | 22 + ext/win32ole/sample/excel2.rb | 30 + ext/win32ole/sample/excel3.rb | 13 + ext/win32ole/sample/ie.rb | 11 + ext/win32ole/sample/ieconst.rb | 32 + ext/win32ole/sample/ienavi.rb | 40 + ext/win32ole/sample/oledirs.rb | 23 + ext/win32ole/sample/olegen.rb | 348 ++ ext/win32ole/sample/xml.rb | 7306 +++++++++++++++++++++++++++++++++ ext/win32ole/tests/oleserver.rb | 10 + ext/win32ole/tests/testOLEEVENT.rb | 33 + ext/win32ole/tests/testOLEMETHOD.rb | 83 + ext/win32ole/tests/testOLEPARAM.rb | 67 + ext/win32ole/tests/testOLETYPE.rb | 83 + ext/win32ole/tests/testOLEVARIABLE.rb | 42 + ext/win32ole/tests/testVARIANT.rb | 32 + ext/win32ole/tests/testWIN32OLE.rb | 298 ++ ext/win32ole/tests/testall.rb | 11 + ext/win32ole/win32ole.c | 5292 ++++++++++++++++++++++++ 25 files changed, 14139 insertions(+) create mode 100644 ext/win32ole/.cvsignore create mode 100644 ext/win32ole/MANIFEST create mode 100644 ext/win32ole/depend create mode 100644 ext/win32ole/doc/win32ole.rd create mode 100644 ext/win32ole/extconf.rb create mode 100644 ext/win32ole/lib/win32ole/property.rb create mode 100644 ext/win32ole/sample/excel1.rb create mode 100644 ext/win32ole/sample/excel2.rb create mode 100644 ext/win32ole/sample/excel3.rb create mode 100644 ext/win32ole/sample/ie.rb create mode 100644 ext/win32ole/sample/ieconst.rb create mode 100644 ext/win32ole/sample/ienavi.rb create mode 100644 ext/win32ole/sample/oledirs.rb create mode 100644 ext/win32ole/sample/olegen.rb create mode 100644 ext/win32ole/sample/xml.rb create mode 100644 ext/win32ole/tests/oleserver.rb create mode 100644 ext/win32ole/tests/testOLEEVENT.rb create mode 100644 ext/win32ole/tests/testOLEMETHOD.rb create mode 100644 ext/win32ole/tests/testOLEPARAM.rb create mode 100644 ext/win32ole/tests/testOLETYPE.rb create mode 100644 ext/win32ole/tests/testOLEVARIABLE.rb create mode 100644 ext/win32ole/tests/testVARIANT.rb create mode 100644 ext/win32ole/tests/testWIN32OLE.rb create mode 100644 ext/win32ole/tests/testall.rb create mode 100644 ext/win32ole/win32ole.c (limited to 'ext/win32ole') diff --git a/ext/win32ole/.cvsignore b/ext/win32ole/.cvsignore new file mode 100644 index 0000000000..fc802ff1c2 --- /dev/null +++ b/ext/win32ole/.cvsignore @@ -0,0 +1,2 @@ +Makefile +mkmf.log diff --git a/ext/win32ole/MANIFEST b/ext/win32ole/MANIFEST new file mode 100644 index 0000000000..8e9bd46211 --- /dev/null +++ b/ext/win32ole/MANIFEST @@ -0,0 +1,24 @@ +MANIFEST +depend +doc/win32ole.rd +extconf.rb +lib/win32ole/property.rb +sample/excel1.rb +sample/excel2.rb +sample/excel3.rb +sample/ie.rb +sample/ieconst.rb +sample/ienavi.rb +sample/oledirs.rb +sample/olegen.rb +sample/xml.rb +tests/oleserver.rb +tests/testOLEEVENT.rb +tests/testOLEMETHOD.rb +tests/testOLEPARAM.rb +tests/testOLETYPE.rb +tests/testOLEVARIABLE.rb +tests/testVARIANT.rb +tests/testWIN32OLE.rb +tests/testall.rb +win32ole.c diff --git a/ext/win32ole/depend b/ext/win32ole/depend new file mode 100644 index 0000000000..764b9d8dbb --- /dev/null +++ b/ext/win32ole/depend @@ -0,0 +1 @@ +win32ole.o : $(hdrdir)/ruby.h $(hdrdir)/config.h $(hdrdir)/defines.h diff --git a/ext/win32ole/doc/win32ole.rd b/ext/win32ole/doc/win32ole.rd new file mode 100644 index 0000000000..c563ce5d5b --- /dev/null +++ b/ext/win32ole/doc/win32ole.rd @@ -0,0 +1,294 @@ +=begin += Win32OLE extension module + +== WIN32OLE +=== Constants +: VERSION + The version number of WIN32OLE. + +: ARGV + The argument of the method invoked recently. + This constant is used to get value of argument + when the argument is passed by reference. + +=== Class Method +: connect(oleserver) + returns running OLE automation object or WIN32OLE object from moniker. + +: const_load(ole [,obj]) + defines the constants of OLE automation + server as 'obj' class constants. If 'obj' omitted, the default + is WIN32OLE. + +: new(oleserver) + returns OLE Automation object. + +: ole_free(obj) + invokes Release method of Dispatch interface of WIN32OLE object. + This method should not be used because this method exists for debugging WIN32OLE. + +: ole_reference_count(obj) + returns reference counter of Dispatch interface. + This method should not be used because this method exists for debugging WIN32OLE. + +: ole_show_help(info [,helpcontext]) + displays helpfile. + The first argument specifies WIN32OLE_TYPE object or WIN32OLE_METHOD object + or helpfile. + +=== Method +: self[property] + gets property of OLE object. + +: self[property]= + sets property of OLE object. + +: _invoke(dispid, args, types) + runs the early binding method. + The dispid specifies Dispatch ID, args specifies the array of arguments, + types specifies array of the type of arguments. + +: each {...} + Iterates over each item of OLE collection which has IEnumVARIANT + interface. + +: invoke(method, args,...) + runs OLE method. + +: ole_func_methods + returns array of WIN32OLE_METHOD object which corresponds with function. + +: ole_get_methods + returns array of WIN32OLE_METHOD object which corresponds with get properties. + +: ole_method(method) + returns WIN32OLE_METHOD object which coreesponds with method + which specified by argument. + +: ole_method_help(method) + alias of ole_method. + +: ole_methods + returns WIN32OLE_METHOD object which coreesponds with method. + +: ole_obj_help + returns WIN32OLE_TYPE object. + +: ole_put_methods + returns array of WIN32OLE_METHOD object which corresponds with put properties. + +: setproperty(property, key, val) + set property of OLE object. + This method is used when the property has argument. + + For example, in VB + obj.item("key") = val + in Win32OLE + obj.setproperty("item", "key", val) + + +== WIN32OLE_EVENT class + +=== Class Method + +: new(ole, interface) + The new class method creates OLE event sink object to connect ole. + The ole must be WIN32OLE object, and interface is the interface + name of event. + +: message_loop + The message_loop class method translates and dispatches Windows + message. + +=== Method +: on_event([event]){...} + defines the callback of event. + If event omitted, defines the callback of all events. + +: on_event_with_outargs([event]) {...} + defines the callback of event. + If you want modify argument in callback, + +== WIN32OLE_METHOD + +=== Class Methods +: new(win32ole_type, method) + creates WIN32OLE_METHOD object. + +=== Methods +: dispid + returns Dispatch ID. + +: event? + returns true if the method is event. + +: event_interface + returns interface name of event if the method is event. + +: helpcontext + returns help context. + +: helpfile + returns help file. + +: invkind + returns invkind. + +: invoke_kind + returns invoke kind string. + +: name + returns name of method. + +: offset_vtbl + returns the offset of Vtbl. + +: params + returns array of WIN32OLE_PARAM object. + +: return_type + returns string of return value type of method. + +: return_vtype + returns number of return value type of method. + +: return_type_detail + returns detail information of return value type of method. + +: size_params + returns the size of arguments. + +: size_opt_params + returns the size of optional arguments. + +: visible? + returns true if the method is public. + +== WIN32OLE_PARAM +: default + returns default value. + +: input? + returns true if argument is input. + +: optional? + returns true if argument is optional. + +: output? + returns true if argument is output. + +: name + returns name. + +: ole_type + returns type of argument. + +: ole_type_detail + returns detail information of type of argument. + +: retval? + returns true if argument is return value. + +== WIN32OLE_TYPE +=== Class Methods +: new(typelibrary, class) + returns WIN32OLE_TYPE object. + +: ole_classes(typelibrary) + returns array of WIN32OLE_TYPE objects defined by Type Library. + +: progids + returns array of ProgID. + +: typelibs + returns array of type libraries. + +=== Methods +: guid + returns GUID. + +: helpfile + returns helpfile. + +: helpcontext + returns helpcontext. + +: helpstring + returns help string. + +: major_version + returns major version. + +: minor_version + returns minor version. + +: name + returns name. + +: ole_methods + returns array of WIN32OLE_METHOD objects. + +: ole_type + returns type of class. + +: progid + returns ProgID if it exists. If not found, then returns nil. + +: src_type + returns source class when the OLE class is 'Alias'. + +: typekind + returns number which represents type. + +: variables + returns array of variables defined in OLE class. + +: visible? + returns true if the OLE class is public. + +== WIN32OLE_VARIABLE +=== Methods +: name + returns the name. + +: ole_type + returns type + +: ole_type_detail + returns detail information of type. + +: value + returns value. + +: variable_kind + returns variable kind string. + +: varkind + returns the number which represents variable kind. + +== WIN32OLE::VARIANT +=== Constants + *VT_I4 + *VT_R4 + *VT_R8 + *VT_CY + *VT_DATE + *VT_BSTR + *VT_USERDEFINED + *VT_PTR + *VT_DISPATCH + *VT_ERROR + *VT_BOOL + *VT_VARIANT + *VT_UNKNOWN + *VT_I1 + *VT_UI1 + *VT_UI2 + *VT_UI4 + *VT_INT + *VT_UINT + *VT_ARRAY + *VT_BYREF + +=end + diff --git a/ext/win32ole/extconf.rb b/ext/win32ole/extconf.rb new file mode 100644 index 0000000000..4abfd3c62f --- /dev/null +++ b/ext/win32ole/extconf.rb @@ -0,0 +1,26 @@ +#---------------------------------- +# extconf.rb +# $Revision$ +# $Date$ +#---------------------------------- +require 'mkmf' + +def create_win32ole_makefile + if have_library("ole32") and + have_library("oleaut32") and + have_library("uuid") and + have_library("user32") and + have_library("advapi32") + create_makefile("win32ole") + end +end + +case PLATFORM +when /mswin32/ + $CFLAGS='/W3' +when /mingw/ + $CFLAGS='-DNONAMELESSUNION' +when /cygwin/ + $CFLAGS='-DNONAMELESSUNION' +end +create_win32ole_makefile diff --git a/ext/win32ole/lib/win32ole/property.rb b/ext/win32ole/lib/win32ole/property.rb new file mode 100644 index 0000000000..a68bad9af8 --- /dev/null +++ b/ext/win32ole/lib/win32ole/property.rb @@ -0,0 +1,16 @@ +# OLEProperty +# helper class of Property with arguments. +class OLEProperty + def initialize(obj, dispid, gettypes, settypes) + @obj = obj + @dispid = dispid + @gettypes = gettypes + @settypes = settypes + end + def [](*args) + @obj._getproperty(@dispid, args, @gettypes) + end + def []=(*args) + @obj._setproperty(@dispid, args, @settypes) + end +end diff --git a/ext/win32ole/sample/excel1.rb b/ext/win32ole/sample/excel1.rb new file mode 100644 index 0000000000..e366a52839 --- /dev/null +++ b/ext/win32ole/sample/excel1.rb @@ -0,0 +1,22 @@ +require 'win32ole' + +#application = WIN32OLE.new('Excel.Application.5') +application = WIN32OLE.new('Excel.Application') + +application.visible = TRUE +workbook = application.Workbooks.Add(); +worksheet = workbook.Worksheets(1); +worksheet.Range("A1:D1").value = ["North","South","East","West"]; +worksheet.Range("A2:B2").value = [5.2, 10]; +worksheet.Range("C2").value = 8; +worksheet.Range("D2").value = 20; + +range = worksheet.Range("A1:D2"); +range.Select +chart = workbook.Charts.Add; + +workbook.saved = TRUE; + +application.ActiveWorkbook.Close(0); +application.Quit(); + diff --git a/ext/win32ole/sample/excel2.rb b/ext/win32ole/sample/excel2.rb new file mode 100644 index 0000000000..46f459b36b --- /dev/null +++ b/ext/win32ole/sample/excel2.rb @@ -0,0 +1,30 @@ +require 'win32ole' + +# -4100 is the value for the Excel constant xl3DColumn. +ChartTypeVal = -4100; + +# Creates OLE object to Excel +#excel = WIN32OLE.new("excel.application.5") +excel = WIN32OLE.new("excel.application") + +# Create and rotate the chart + +excel['Visible'] = TRUE; +excel.Workbooks.Add(); +excel.Range("a1")['Value'] = 3; +excel.Range("a2")['Value'] = 2; +excel.Range("a3")['Value'] = 1; +excel.Range("a1:a3").Select(); +excelchart = excel.Charts.Add(); +excelchart['Type'] = ChartTypeVal; + +i = 30 +i.step(180, 10) do |rot| +# excelchart['Rotation'] = rot; + excelchart.rotation=rot; +end +# Done, bye + +excel.ActiveWorkbook.Close(0); +excel.Quit(); + diff --git a/ext/win32ole/sample/excel3.rb b/ext/win32ole/sample/excel3.rb new file mode 100644 index 0000000000..0f96717063 --- /dev/null +++ b/ext/win32ole/sample/excel3.rb @@ -0,0 +1,13 @@ +require 'win32ole' + +#application = WIN32OLE.new('Excel.Application.5') +application = WIN32OLE.new('Excel.Application') + +application.visible = TRUE +workbook = application.Workbooks.Add(); +sheet = workbook.Worksheets(1); +sheetS = workbook.Worksheets +puts "The number of sheets is #{sheetS.count}" +puts "Now add 2 sheets after of `#{sheet.name}`" +sheetS.add({'count'=>2, 'after'=>sheet}) +puts "The number of sheets is #{sheetS.count}" diff --git a/ext/win32ole/sample/ie.rb b/ext/win32ole/sample/ie.rb new file mode 100644 index 0000000000..11dc861e0b --- /dev/null +++ b/ext/win32ole/sample/ie.rb @@ -0,0 +1,11 @@ +require 'win32ole' +url = 'http://www.ruby-lang.org/' +ie = WIN32OLE.new('InternetExplorer.Application') +ie.visible = TRUE +ie.gohome +print "Now navigate Ruby home page... Please enter." +gets +ie.navigate(url) +print "Now quit Internet Explorer... Please enter." +gets +ie.Quit() diff --git a/ext/win32ole/sample/ieconst.rb b/ext/win32ole/sample/ieconst.rb new file mode 100644 index 0000000000..234272c7ed --- /dev/null +++ b/ext/win32ole/sample/ieconst.rb @@ -0,0 +1,32 @@ +require 'win32ole' + +ie = WIN32OLE.new('InternetExplorer.Application') +=begin +WIN32OLE.const_load(ie) +WIN32OLE.constants.sort.each do |c| + puts "#{c} = #{WIN32OLE.const_get(c)}" +end +=end + +module IE_CONST +end + +WIN32OLE.const_load(ie, IE_CONST) +IE_CONST.constants.sort.each do |c| + puts "#{c} = #{IE_CONST.const_get(c)}" +end + +#------------------------------------------------------------ +# Remark!!! CONSTANTS has not tested enoughly!!! +# CONSTANTS is alpha release. +# If there are constants which first letter is not [a-zA-Z], +# like a '_Foo', then maybe you can access the value by +# using CONSTANTS['_Foo'] +#------------------------------------------------------------ +IE_CONST::CONSTANTS.each do |k, v| + puts "#{k} = #{v}" +end + +puts WIN32OLE::VERSION +ie.quit + diff --git a/ext/win32ole/sample/ienavi.rb b/ext/win32ole/sample/ienavi.rb new file mode 100644 index 0000000000..c7fa3f5ec2 --- /dev/null +++ b/ext/win32ole/sample/ienavi.rb @@ -0,0 +1,40 @@ +require 'win32ole' + +$urls = [] + +def navigate(url) + $urls << url +end + +def stop_msg_loop + puts "Now Stop IE..." + $LOOP = FALSE; +end + +def default_handler(event, *args) + case event + when "BeforeNavigate" + puts "Now Navigate #{args[0]}..." + end +end + +ie = WIN32OLE.new('InternetExplorer.Application') +ie.visible = TRUE +ie.gohome + +ev = WIN32OLE_EVENT.new(ie, 'DWebBrowserEvents') + +ev.on_event {|*args| default_handler(*args)} +ev.on_event("NavigateComplete") {|url| navigate(url)} +ev.on_event("Quit") {|*args| stop_msg_loop} + +$LOOP = TRUE +while ($LOOP) + WIN32OLE_EVENT.message_loop +end + +puts "You Navigated the URLs ..." +$urls.each_with_index do |url, i| + puts "(#{i+1}) #{url}" +end + diff --git a/ext/win32ole/sample/oledirs.rb b/ext/win32ole/sample/oledirs.rb new file mode 100644 index 0000000000..1c77e76f14 --- /dev/null +++ b/ext/win32ole/sample/oledirs.rb @@ -0,0 +1,23 @@ +# +# You need WSH(Windows Scripting Host) to run this script. +# + +require "win32ole" + +def listup(items) +# items.each do |i| + for i in items + puts i.name + end +end + +fs = WIN32OLE.new("Scripting.FileSystemObject") + +folder = fs.GetFolder(".") + +puts "--- folder of #{folder.path} ---" +listup(folder.SubFolders) + +puts "--- files of #{folder.path} ---" +listup(folder.Files) + diff --git a/ext/win32ole/sample/olegen.rb b/ext/win32ole/sample/olegen.rb new file mode 100644 index 0000000000..48d86893fe --- /dev/null +++ b/ext/win32ole/sample/olegen.rb @@ -0,0 +1,348 @@ +#----------------------------- +# olegen.rb +# $Date$ +# $Revision$ +#----------------------------- + +require 'win32ole' + +class WIN32COMGen + def initialize(typelib) + @typelib = typelib + @reciever = "" + end + attr_reader :typelib + + def ole_classes(typelib) + begin + @ole = WIN32OLE.new(typelib) + [@ole.ole_obj_help] + rescue + WIN32OLE_TYPE.ole_classes(typelib) + end + end + + def generate_args(method) + args = [] + if method.size_opt_params >= 0 + size_required_params = method.size_params - method.size_opt_params + else + size_required_params = method.size_params - 1 + end + size_required_params.times do |i| + if method.params[i] && method.params[i].optional? + args.push "arg#{i}=nil" + else + args.push "arg#{i}" + end + end + if method.size_opt_params >= 0 + method.size_opt_params.times do |i| + args.push "arg#{i + size_required_params}=nil" + end + else + args.push "*arg" + end + args.join(", ") + end + + def generate_argtype(typedetails) + ts = '' + typedetails.each do |t| + case t + when 'CARRAY', 'VOID', 'UINT', 'RESULT', 'DECIMAL', 'I8', 'UI8' +# raise "Sorry type\"" + t + "\" not supported" + ts << "\"??? NOT SUPPORTED TYPE:`#{t}'\"" + when 'USERDEFINED', 'Unknown Type 9' + ts << 'VT_DISPATCH' + break; + when 'SAFEARRAY' + ts << 'VT_ARRAY|' + when 'PTR' + ts << 'VT_BYREF|' + when 'INT' + ts << 'VT_I4' + else + if String === t + ts << 'VT_' + t + end + end + end + if ts.empty? + ts = 'VT_VARIANT' + elsif ts[-1] == ?| + ts += 'VT_VARIANT' + end + ts + end + + def generate_argtypes(method, proptypes) + types = method.params.collect{|param| + generate_argtype(param.ole_type_detail) + }.join(", ") + if proptypes + types += ", " if types.size > 0 + types += generate_argtype(proptypes) + end + types + end + + def generate_method_body(method, disptype, types=nil) + " ret = #{@reciever}#{disptype}(#{method.dispid}, [" + + generate_args(method).gsub("=nil", "") + + "], [" + + generate_argtypes(method, types) + + "])\n" + + " @lastargs = WIN32OLE::ARGV\n" + + " ret" + end + + def generate_method_help(method, type = nil) + str = " # " + if type + str += type + else + str += method.return_type + end + str += " #{method.name}" + if method.event? + str += " EVENT" + str += " in #{method.event_interface}" + end + if method.helpstring && method.helpstring != "" + str += "\n # " + str += method.helpstring + end + args_help = generate_method_args_help(method) + if args_help + str += "\n" + str += args_help + end + str + end + + def generate_method_args_help(method) + args = [] + method.params.each_with_index {|param, i| + h = " # #{param.ole_type} arg#{i} --- #{param.name}" + inout = [] + inout.push "IN" if param.input? + inout.push "OUT" if param.output? + h += " [#{inout.join('/')}]" + h += " ( = #{param.default})" if param.default + args.push h + } + if args.size > 0 + args.join("\n") + else + nil + end + end + + def generate_method(method, disptype, io = STDOUT, types = nil) + io.puts "\n" + io.puts generate_method_help(method) + if method.invoke_kind == 'PROPERTYPUT' + io.print " def #{method.name}=(" + else + io.print " def #{method.name}(" + end + io.print generate_args(method) + io.puts ")" + io.puts generate_method_body(method, disptype, types) + io.puts " end" + end + + def generate_propputref_methods(klass, io = STDOUT) + klass.ole_methods.select {|method| + method.invoke_kind == 'PROPERTYPUTREF' && method.visible? + }.each do |method| + generate_method(method, io) + end + end + + def generate_properties_with_args(klass, io = STDOUT) + klass.ole_methods.select {|method| + method.invoke_kind == 'PROPERTYGET' && + method.visible? && + method.size_params > 0 + }.each do |method| + types = method.return_type_detail + io.puts "\n" + io.puts generate_method_help(method, types[0]) + io.puts " def #{method.name}" + if klass.ole_type == "Class" + io.print " OLEProperty.new(@dispatch, #{method.dispid}, [" + else + io.print " OLEProperty.new(self, #{method.dispid}, [" + end + io.print generate_argtypes(method, nil) + io.print "], [" + io.print generate_argtypes(method, types) + io.puts "])" + io.puts " end" + end + end + + def generate_propput_methods(klass, io = STDOUT) + klass.ole_methods.select {|method| + method.invoke_kind == 'PROPERTYPUT' && method.visible? && + method.size_params == 1 + }.each do |method| + ms = klass.ole_methods.select {|m| + m.invoke_kind == 'PROPERTYGET' && + m.dispid == method.dispid + } + types = [] + if ms.size == 1 + types = ms[0].return_type_detail + end + generate_method(method, '_setproperty', io, types) + end + end + + def generate_propget_methods(klass, io = STDOUT) + klass.ole_methods.select {|method| + method.invoke_kind == 'PROPERTYGET' && method.visible? && + method.size_params == 0 + }.each do |method| + generate_method(method, '_getproperty', io) + end + end + + def generate_func_methods(klass, io = STDOUT) + klass.ole_methods.select {|method| + method.invoke_kind == "FUNC" && method.visible? + }.each do |method| + generate_method(method, '_invoke', io) + end + end + + def generate_methods(klass, io = STDOUT) + generate_propget_methods(klass, io) + generate_propput_methods(klass, io) + generate_properties_with_args(klass, io) + generate_func_methods(klass, io) +# generate_propputref_methods(klass, io) + end + + def generate_constants(klass, io = STDOUT) + klass.variables.select {|v| + v.visible? && v.variable_kind == 'CONSTANT' + }.each do |v| + io.print " " + io.print v.name.sub(/^./){|c| c.upcase} + io.print " = " + io.puts v.value + end + end + + def class_name(klass) + klass_name = klass.name + if klass.ole_type == "Class" && + klass.guid && + klass.progid + klass_name = klass.progid.gsub(/\./, '_') + end + if /^[A-Z]/ !~ klass_name || Module.constants.include?(klass_name) + klass_name = 'OLE' + klass_name + end + klass_name + end + + def define_initialize(klass) + < xml.rb +# +require 'win32ole' +require 'win32ole/property' + +# +module IXMLDOMImplementation + include WIN32OLE::VARIANT + attr_reader :lastargs + + # BOOL hasFeature + # BSTR arg0 --- feature [IN] + # BSTR arg1 --- version [IN] + def hasFeature(arg0, arg1) + ret = _invoke(145, [arg0, arg1], [VT_BSTR, VT_BSTR]) + @lastargs = WIN32OLE::ARGV + ret + end +end + +# Core DOM node interface +module IXMLDOMNode + include WIN32OLE::VARIANT + attr_reader :lastargs + + # BSTR nodeName + # name of the node + def nodeName() + ret = _getproperty(2, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # VARIANT nodeValue + # value stored in the node + def nodeValue() + ret = _getproperty(3, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # DOMNodeType nodeType + # the node's type + def nodeType() + ret = _getproperty(4, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode parentNode + # parent of the node + def parentNode() + ret = _getproperty(6, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNodeList childNodes + # the collection of the node's children + def childNodes() + ret = _getproperty(7, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode firstChild + # first child of the node + def firstChild() + ret = _getproperty(8, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode lastChild + # first child of the node + def lastChild() + ret = _getproperty(9, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode previousSibling + # left sibling of the node + def previousSibling() + ret = _getproperty(10, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode nextSibling + # right sibling of the node + def nextSibling() + ret = _getproperty(11, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNamedNodeMap attributes + # the collection of the node's attributes + def attributes() + ret = _getproperty(12, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMDocument ownerDocument + # document that contains the node + def ownerDocument() + ret = _getproperty(18, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR nodeTypeString + # the type of node in string form + def nodeTypeString() + ret = _getproperty(21, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR text + # text content of the node and subtree + def text() + ret = _getproperty(24, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BOOL specified + # indicates whether node is a default value + def specified() + ret = _getproperty(22, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode definition + # pointer to the definition of the node in the DTD or schema + def definition() + ret = _getproperty(23, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # VARIANT nodeTypedValue + # get the strongly typed value of the node + def nodeTypedValue() + ret = _getproperty(25, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # VARIANT dataType + # the data type of the node + def dataType() + ret = _getproperty(26, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR xml + # return the XML source for the node and each of its descendants + def xml() + ret = _getproperty(27, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BOOL parsed + # has sub-tree been completely parsed + def parsed() + ret = _getproperty(31, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR namespaceURI + # the URI for the namespace applying to the node + def namespaceURI() + ret = _getproperty(32, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR prefix + # the prefix for the namespace applying to the node + def prefix() + ret = _getproperty(33, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR baseName + # the base name of the node (nodename with the prefix stripped off) + def baseName() + ret = _getproperty(34, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID nodeValue + # value stored in the node + def nodeValue=(arg0) + ret = _setproperty(3, [arg0], [VT_VARIANT]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID text + # text content of the node and subtree + def text=(arg0) + ret = _setproperty(24, [arg0], [VT_BSTR]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID nodeTypedValue + # get the strongly typed value of the node + def nodeTypedValue=(arg0) + ret = _setproperty(25, [arg0], [VT_VARIANT]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID dataType + # the data type of the node + def dataType=(arg0) + ret = _setproperty(26, [arg0], [VT_VARIANT]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode insertBefore + # insert a child node + # IXMLDOMNode arg0 --- newChild [IN] + # VARIANT arg1 --- refChild [IN] + def insertBefore(arg0, arg1) + ret = _invoke(13, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode replaceChild + # replace a child node + # IXMLDOMNode arg0 --- newChild [IN] + # IXMLDOMNode arg1 --- oldChild [IN] + def replaceChild(arg0, arg1) + ret = _invoke(14, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_BYREF|VT_DISPATCH]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode removeChild + # remove a child node + # IXMLDOMNode arg0 --- childNode [IN] + def removeChild(arg0) + ret = _invoke(15, [arg0], [VT_BYREF|VT_DISPATCH]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode appendChild + # append a child node + # IXMLDOMNode arg0 --- newChild [IN] + def appendChild(arg0) + ret = _invoke(16, [arg0], [VT_BYREF|VT_DISPATCH]) + @lastargs = WIN32OLE::ARGV + ret + end + + # BOOL hasChildNodes + def hasChildNodes() + ret = _invoke(17, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode cloneNode + # BOOL arg0 --- deep [IN] + def cloneNode(arg0) + ret = _invoke(19, [arg0], [VT_BOOL]) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR transformNode + # apply the stylesheet to the subtree + # IXMLDOMNode arg0 --- stylesheet [IN] + def transformNode(arg0) + ret = _invoke(28, [arg0], [VT_BYREF|VT_DISPATCH]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNodeList selectNodes + # execute query on the subtree + # BSTR arg0 --- queryString [IN] + def selectNodes(arg0) + ret = _invoke(29, [arg0], [VT_BSTR]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode selectSingleNode + # execute query on the subtree + # BSTR arg0 --- queryString [IN] + def selectSingleNode(arg0) + ret = _invoke(30, [arg0], [VT_BSTR]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID transformNodeToObject + # apply the stylesheet to the subtree, returning the result through a document or a stream + # IXMLDOMNode arg0 --- stylesheet [IN] + # VARIANT arg1 --- outputObject [IN] + def transformNodeToObject(arg0, arg1) + ret = _invoke(35, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT]) + @lastargs = WIN32OLE::ARGV + ret + end +end + +# Constants that define a node's type +module OLEtagDOMNodeType + include WIN32OLE::VARIANT + attr_reader :lastargs + NODE_INVALID = 0 + NODE_ELEMENT = 1 + NODE_ATTRIBUTE = 2 + NODE_TEXT = 3 + NODE_CDATA_SECTION = 4 + NODE_ENTITY_REFERENCE = 5 + NODE_ENTITY = 6 + NODE_PROCESSING_INSTRUCTION = 7 + NODE_COMMENT = 8 + NODE_DOCUMENT = 9 + NODE_DOCUMENT_TYPE = 10 + NODE_DOCUMENT_FRAGMENT = 11 + NODE_NOTATION = 12 +end + +# +module IXMLDOMNodeList + include WIN32OLE::VARIANT + attr_reader :lastargs + + # I4 length + # number of nodes in the collection + def length() + ret = _getproperty(74, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # PTR item + # collection of nodes + # I4 arg0 --- index [IN] + def item + OLEProperty.new(self, 0, [VT_I4], [VT_I4, VT_BYREF|VT_DISPATCH]) + end + + # IXMLDOMNode nextNode + # get next node from iterator + def nextNode() + ret = _invoke(76, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID reset + # reset the position of iterator + def reset() + ret = _invoke(77, [], []) + @lastargs = WIN32OLE::ARGV + ret + end +end + +# +module IXMLDOMNamedNodeMap + include WIN32OLE::VARIANT + attr_reader :lastargs + + # I4 length + # number of nodes in the collection + def length() + ret = _getproperty(74, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # PTR item + # collection of nodes + # I4 arg0 --- index [IN] + def item + OLEProperty.new(self, 0, [VT_I4], [VT_I4, VT_BYREF|VT_DISPATCH]) + end + + # IXMLDOMNode getNamedItem + # lookup item by name + # BSTR arg0 --- name [IN] + def getNamedItem(arg0) + ret = _invoke(83, [arg0], [VT_BSTR]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode setNamedItem + # set item by name + # IXMLDOMNode arg0 --- newItem [IN] + def setNamedItem(arg0) + ret = _invoke(84, [arg0], [VT_BYREF|VT_DISPATCH]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode removeNamedItem + # remove item by name + # BSTR arg0 --- name [IN] + def removeNamedItem(arg0) + ret = _invoke(85, [arg0], [VT_BSTR]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode getQualifiedItem + # lookup the item by name and namespace + # BSTR arg0 --- baseName [IN] + # BSTR arg1 --- namespaceURI [IN] + def getQualifiedItem(arg0, arg1) + ret = _invoke(87, [arg0, arg1], [VT_BSTR, VT_BSTR]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode removeQualifiedItem + # remove the item by name and namespace + # BSTR arg0 --- baseName [IN] + # BSTR arg1 --- namespaceURI [IN] + def removeQualifiedItem(arg0, arg1) + ret = _invoke(88, [arg0, arg1], [VT_BSTR, VT_BSTR]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode nextNode + # get next node from iterator + def nextNode() + ret = _invoke(89, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID reset + # reset the position of iterator + def reset() + ret = _invoke(90, [], []) + @lastargs = WIN32OLE::ARGV + ret + end +end + +# +module IXMLDOMDocument + include WIN32OLE::VARIANT + attr_reader :lastargs + + # BSTR nodeName + # name of the node + def nodeName() + ret = _getproperty(2, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # VARIANT nodeValue + # value stored in the node + def nodeValue() + ret = _getproperty(3, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # DOMNodeType nodeType + # the node's type + def nodeType() + ret = _getproperty(4, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode parentNode + # parent of the node + def parentNode() + ret = _getproperty(6, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNodeList childNodes + # the collection of the node's children + def childNodes() + ret = _getproperty(7, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode firstChild + # first child of the node + def firstChild() + ret = _getproperty(8, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode lastChild + # first child of the node + def lastChild() + ret = _getproperty(9, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode previousSibling + # left sibling of the node + def previousSibling() + ret = _getproperty(10, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode nextSibling + # right sibling of the node + def nextSibling() + ret = _getproperty(11, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNamedNodeMap attributes + # the collection of the node's attributes + def attributes() + ret = _getproperty(12, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMDocument ownerDocument + # document that contains the node + def ownerDocument() + ret = _getproperty(18, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR nodeTypeString + # the type of node in string form + def nodeTypeString() + ret = _getproperty(21, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR text + # text content of the node and subtree + def text() + ret = _getproperty(24, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BOOL specified + # indicates whether node is a default value + def specified() + ret = _getproperty(22, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode definition + # pointer to the definition of the node in the DTD or schema + def definition() + ret = _getproperty(23, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # VARIANT nodeTypedValue + # get the strongly typed value of the node + def nodeTypedValue() + ret = _getproperty(25, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # VARIANT dataType + # the data type of the node + def dataType() + ret = _getproperty(26, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR xml + # return the XML source for the node and each of its descendants + def xml() + ret = _getproperty(27, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BOOL parsed + # has sub-tree been completely parsed + def parsed() + ret = _getproperty(31, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR namespaceURI + # the URI for the namespace applying to the node + def namespaceURI() + ret = _getproperty(32, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR prefix + # the prefix for the namespace applying to the node + def prefix() + ret = _getproperty(33, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR baseName + # the base name of the node (nodename with the prefix stripped off) + def baseName() + ret = _getproperty(34, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMDocumentType doctype + # node corresponding to the DOCTYPE + def doctype() + ret = _getproperty(38, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMImplementation implementation + # info on this DOM implementation + def implementation() + ret = _getproperty(39, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMElement documentElement + # the root of the tree + def documentElement() + ret = _getproperty(40, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # I4 readyState + # get the state of the XML document + def readyState() + ret = _getproperty(-525, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMParseError parseError + # get the last parser error + def parseError() + ret = _getproperty(59, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR url + # get the URL for the loaded XML document + def url() + ret = _getproperty(60, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BOOL async + # flag for asynchronous download + def async() + ret = _getproperty(61, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BOOL validateOnParse + # indicates whether the parser performs validation + def validateOnParse() + ret = _getproperty(65, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BOOL resolveExternals + # indicates whether the parser resolves references to external DTD/Entities/Schema + def resolveExternals() + ret = _getproperty(66, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BOOL preserveWhiteSpace + # indicates whether the parser preserves whitespace + def preserveWhiteSpace() + ret = _getproperty(67, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID nodeValue + # value stored in the node + def nodeValue=(arg0) + ret = _setproperty(3, [arg0], [VT_VARIANT]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID text + # text content of the node and subtree + def text=(arg0) + ret = _setproperty(24, [arg0], [VT_BSTR]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID nodeTypedValue + # get the strongly typed value of the node + def nodeTypedValue=(arg0) + ret = _setproperty(25, [arg0], [VT_VARIANT]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID dataType + # the data type of the node + def dataType=(arg0) + ret = _setproperty(26, [arg0], [VT_VARIANT]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID async + # flag for asynchronous download + def async=(arg0) + ret = _setproperty(61, [arg0], [VT_BOOL]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID validateOnParse + # indicates whether the parser performs validation + def validateOnParse=(arg0) + ret = _setproperty(65, [arg0], [VT_BOOL]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID resolveExternals + # indicates whether the parser resolves references to external DTD/Entities/Schema + def resolveExternals=(arg0) + ret = _setproperty(66, [arg0], [VT_BOOL]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID preserveWhiteSpace + # indicates whether the parser preserves whitespace + def preserveWhiteSpace=(arg0) + ret = _setproperty(67, [arg0], [VT_BOOL]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID onreadystatechange + # register a readystatechange event handler + def onreadystatechange=(arg0) + ret = _setproperty(68, [arg0], [VT_VARIANT]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID ondataavailable + # register an ondataavailable event handler + def ondataavailable=(arg0) + ret = _setproperty(69, [arg0], [VT_VARIANT]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID ontransformnode + # register an ontransformnode event handler + def ontransformnode=(arg0) + ret = _setproperty(70, [arg0], [VT_VARIANT]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode insertBefore + # insert a child node + # IXMLDOMNode arg0 --- newChild [IN] + # VARIANT arg1 --- refChild [IN] + def insertBefore(arg0, arg1) + ret = _invoke(13, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode replaceChild + # replace a child node + # IXMLDOMNode arg0 --- newChild [IN] + # IXMLDOMNode arg1 --- oldChild [IN] + def replaceChild(arg0, arg1) + ret = _invoke(14, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_BYREF|VT_DISPATCH]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode removeChild + # remove a child node + # IXMLDOMNode arg0 --- childNode [IN] + def removeChild(arg0) + ret = _invoke(15, [arg0], [VT_BYREF|VT_DISPATCH]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode appendChild + # append a child node + # IXMLDOMNode arg0 --- newChild [IN] + def appendChild(arg0) + ret = _invoke(16, [arg0], [VT_BYREF|VT_DISPATCH]) + @lastargs = WIN32OLE::ARGV + ret + end + + # BOOL hasChildNodes + def hasChildNodes() + ret = _invoke(17, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode cloneNode + # BOOL arg0 --- deep [IN] + def cloneNode(arg0) + ret = _invoke(19, [arg0], [VT_BOOL]) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR transformNode + # apply the stylesheet to the subtree + # IXMLDOMNode arg0 --- stylesheet [IN] + def transformNode(arg0) + ret = _invoke(28, [arg0], [VT_BYREF|VT_DISPATCH]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNodeList selectNodes + # execute query on the subtree + # BSTR arg0 --- queryString [IN] + def selectNodes(arg0) + ret = _invoke(29, [arg0], [VT_BSTR]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode selectSingleNode + # execute query on the subtree + # BSTR arg0 --- queryString [IN] + def selectSingleNode(arg0) + ret = _invoke(30, [arg0], [VT_BSTR]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID transformNodeToObject + # apply the stylesheet to the subtree, returning the result through a document or a stream + # IXMLDOMNode arg0 --- stylesheet [IN] + # VARIANT arg1 --- outputObject [IN] + def transformNodeToObject(arg0, arg1) + ret = _invoke(35, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMElement createElement + # create an Element node + # BSTR arg0 --- tagName [IN] + def createElement(arg0) + ret = _invoke(41, [arg0], [VT_BSTR]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMDocumentFragment createDocumentFragment + # create a DocumentFragment node + def createDocumentFragment() + ret = _invoke(42, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMText createTextNode + # create a text node + # BSTR arg0 --- data [IN] + def createTextNode(arg0) + ret = _invoke(43, [arg0], [VT_BSTR]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMComment createComment + # create a comment node + # BSTR arg0 --- data [IN] + def createComment(arg0) + ret = _invoke(44, [arg0], [VT_BSTR]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMCDATASection createCDATASection + # create a CDATA section node + # BSTR arg0 --- data [IN] + def createCDATASection(arg0) + ret = _invoke(45, [arg0], [VT_BSTR]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMProcessingInstruction createProcessingInstruction + # create a processing instruction node + # BSTR arg0 --- target [IN] + # BSTR arg1 --- data [IN] + def createProcessingInstruction(arg0, arg1) + ret = _invoke(46, [arg0, arg1], [VT_BSTR, VT_BSTR]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMAttribute createAttribute + # create an attribute node + # BSTR arg0 --- name [IN] + def createAttribute(arg0) + ret = _invoke(47, [arg0], [VT_BSTR]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMEntityReference createEntityReference + # create an entity reference node + # BSTR arg0 --- name [IN] + def createEntityReference(arg0) + ret = _invoke(49, [arg0], [VT_BSTR]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNodeList getElementsByTagName + # build a list of elements by name + # BSTR arg0 --- tagName [IN] + def getElementsByTagName(arg0) + ret = _invoke(50, [arg0], [VT_BSTR]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode createNode + # create a node of the specified node type and name + # VARIANT arg0 --- type [IN] + # BSTR arg1 --- name [IN] + # BSTR arg2 --- namespaceURI [IN] + def createNode(arg0, arg1, arg2) + ret = _invoke(54, [arg0, arg1, arg2], [VT_VARIANT, VT_BSTR, VT_BSTR]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode nodeFromID + # retrieve node from it's ID + # BSTR arg0 --- idString [IN] + def nodeFromID(arg0) + ret = _invoke(56, [arg0], [VT_BSTR]) + @lastargs = WIN32OLE::ARGV + ret + end + + # BOOL load + # load document from the specified XML source + # VARIANT arg0 --- xmlSource [IN] + def load(arg0) + ret = _invoke(58, [arg0], [VT_VARIANT]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID abort + # abort an asynchronous download + def abort() + ret = _invoke(62, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BOOL loadXML + # load the document from a string + # BSTR arg0 --- bstrXML [IN] + def loadXML(arg0) + ret = _invoke(63, [arg0], [VT_BSTR]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID save + # save the document to a specified desination + # VARIANT arg0 --- desination [IN] + def save(arg0) + ret = _invoke(64, [arg0], [VT_VARIANT]) + @lastargs = WIN32OLE::ARGV + ret + end +end + +# +module IXMLDOMDocumentType + include WIN32OLE::VARIANT + attr_reader :lastargs + + # BSTR nodeName + # name of the node + def nodeName() + ret = _getproperty(2, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # VARIANT nodeValue + # value stored in the node + def nodeValue() + ret = _getproperty(3, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # DOMNodeType nodeType + # the node's type + def nodeType() + ret = _getproperty(4, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode parentNode + # parent of the node + def parentNode() + ret = _getproperty(6, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNodeList childNodes + # the collection of the node's children + def childNodes() + ret = _getproperty(7, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode firstChild + # first child of the node + def firstChild() + ret = _getproperty(8, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode lastChild + # first child of the node + def lastChild() + ret = _getproperty(9, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode previousSibling + # left sibling of the node + def previousSibling() + ret = _getproperty(10, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode nextSibling + # right sibling of the node + def nextSibling() + ret = _getproperty(11, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNamedNodeMap attributes + # the collection of the node's attributes + def attributes() + ret = _getproperty(12, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMDocument ownerDocument + # document that contains the node + def ownerDocument() + ret = _getproperty(18, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR nodeTypeString + # the type of node in string form + def nodeTypeString() + ret = _getproperty(21, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR text + # text content of the node and subtree + def text() + ret = _getproperty(24, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BOOL specified + # indicates whether node is a default value + def specified() + ret = _getproperty(22, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode definition + # pointer to the definition of the node in the DTD or schema + def definition() + ret = _getproperty(23, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # VARIANT nodeTypedValue + # get the strongly typed value of the node + def nodeTypedValue() + ret = _getproperty(25, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # VARIANT dataType + # the data type of the node + def dataType() + ret = _getproperty(26, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR xml + # return the XML source for the node and each of its descendants + def xml() + ret = _getproperty(27, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BOOL parsed + # has sub-tree been completely parsed + def parsed() + ret = _getproperty(31, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR namespaceURI + # the URI for the namespace applying to the node + def namespaceURI() + ret = _getproperty(32, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR prefix + # the prefix for the namespace applying to the node + def prefix() + ret = _getproperty(33, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR baseName + # the base name of the node (nodename with the prefix stripped off) + def baseName() + ret = _getproperty(34, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR name + # name of the document type (root of the tree) + def name() + ret = _getproperty(131, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNamedNodeMap entities + # a list of entities in the document + def entities() + ret = _getproperty(132, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNamedNodeMap notations + # a list of notations in the document + def notations() + ret = _getproperty(133, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID nodeValue + # value stored in the node + def nodeValue=(arg0) + ret = _setproperty(3, [arg0], [VT_VARIANT]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID text + # text content of the node and subtree + def text=(arg0) + ret = _setproperty(24, [arg0], [VT_BSTR]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID nodeTypedValue + # get the strongly typed value of the node + def nodeTypedValue=(arg0) + ret = _setproperty(25, [arg0], [VT_VARIANT]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID dataType + # the data type of the node + def dataType=(arg0) + ret = _setproperty(26, [arg0], [VT_VARIANT]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode insertBefore + # insert a child node + # IXMLDOMNode arg0 --- newChild [IN] + # VARIANT arg1 --- refChild [IN] + def insertBefore(arg0, arg1) + ret = _invoke(13, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode replaceChild + # replace a child node + # IXMLDOMNode arg0 --- newChild [IN] + # IXMLDOMNode arg1 --- oldChild [IN] + def replaceChild(arg0, arg1) + ret = _invoke(14, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_BYREF|VT_DISPATCH]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode removeChild + # remove a child node + # IXMLDOMNode arg0 --- childNode [IN] + def removeChild(arg0) + ret = _invoke(15, [arg0], [VT_BYREF|VT_DISPATCH]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode appendChild + # append a child node + # IXMLDOMNode arg0 --- newChild [IN] + def appendChild(arg0) + ret = _invoke(16, [arg0], [VT_BYREF|VT_DISPATCH]) + @lastargs = WIN32OLE::ARGV + ret + end + + # BOOL hasChildNodes + def hasChildNodes() + ret = _invoke(17, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode cloneNode + # BOOL arg0 --- deep [IN] + def cloneNode(arg0) + ret = _invoke(19, [arg0], [VT_BOOL]) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR transformNode + # apply the stylesheet to the subtree + # IXMLDOMNode arg0 --- stylesheet [IN] + def transformNode(arg0) + ret = _invoke(28, [arg0], [VT_BYREF|VT_DISPATCH]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNodeList selectNodes + # execute query on the subtree + # BSTR arg0 --- queryString [IN] + def selectNodes(arg0) + ret = _invoke(29, [arg0], [VT_BSTR]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode selectSingleNode + # execute query on the subtree + # BSTR arg0 --- queryString [IN] + def selectSingleNode(arg0) + ret = _invoke(30, [arg0], [VT_BSTR]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID transformNodeToObject + # apply the stylesheet to the subtree, returning the result through a document or a stream + # IXMLDOMNode arg0 --- stylesheet [IN] + # VARIANT arg1 --- outputObject [IN] + def transformNodeToObject(arg0, arg1) + ret = _invoke(35, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT]) + @lastargs = WIN32OLE::ARGV + ret + end +end + +# +module IXMLDOMElement + include WIN32OLE::VARIANT + attr_reader :lastargs + + # BSTR nodeName + # name of the node + def nodeName() + ret = _getproperty(2, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # VARIANT nodeValue + # value stored in the node + def nodeValue() + ret = _getproperty(3, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # DOMNodeType nodeType + # the node's type + def nodeType() + ret = _getproperty(4, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode parentNode + # parent of the node + def parentNode() + ret = _getproperty(6, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNodeList childNodes + # the collection of the node's children + def childNodes() + ret = _getproperty(7, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode firstChild + # first child of the node + def firstChild() + ret = _getproperty(8, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode lastChild + # first child of the node + def lastChild() + ret = _getproperty(9, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode previousSibling + # left sibling of the node + def previousSibling() + ret = _getproperty(10, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode nextSibling + # right sibling of the node + def nextSibling() + ret = _getproperty(11, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNamedNodeMap attributes + # the collection of the node's attributes + def attributes() + ret = _getproperty(12, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMDocument ownerDocument + # document that contains the node + def ownerDocument() + ret = _getproperty(18, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR nodeTypeString + # the type of node in string form + def nodeTypeString() + ret = _getproperty(21, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR text + # text content of the node and subtree + def text() + ret = _getproperty(24, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BOOL specified + # indicates whether node is a default value + def specified() + ret = _getproperty(22, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode definition + # pointer to the definition of the node in the DTD or schema + def definition() + ret = _getproperty(23, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # VARIANT nodeTypedValue + # get the strongly typed value of the node + def nodeTypedValue() + ret = _getproperty(25, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # VARIANT dataType + # the data type of the node + def dataType() + ret = _getproperty(26, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR xml + # return the XML source for the node and each of its descendants + def xml() + ret = _getproperty(27, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BOOL parsed + # has sub-tree been completely parsed + def parsed() + ret = _getproperty(31, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR namespaceURI + # the URI for the namespace applying to the node + def namespaceURI() + ret = _getproperty(32, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR prefix + # the prefix for the namespace applying to the node + def prefix() + ret = _getproperty(33, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR baseName + # the base name of the node (nodename with the prefix stripped off) + def baseName() + ret = _getproperty(34, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR tagName + # get the tagName of the element + def tagName() + ret = _getproperty(97, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID nodeValue + # value stored in the node + def nodeValue=(arg0) + ret = _setproperty(3, [arg0], [VT_VARIANT]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID text + # text content of the node and subtree + def text=(arg0) + ret = _setproperty(24, [arg0], [VT_BSTR]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID nodeTypedValue + # get the strongly typed value of the node + def nodeTypedValue=(arg0) + ret = _setproperty(25, [arg0], [VT_VARIANT]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID dataType + # the data type of the node + def dataType=(arg0) + ret = _setproperty(26, [arg0], [VT_VARIANT]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode insertBefore + # insert a child node + # IXMLDOMNode arg0 --- newChild [IN] + # VARIANT arg1 --- refChild [IN] + def insertBefore(arg0, arg1) + ret = _invoke(13, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode replaceChild + # replace a child node + # IXMLDOMNode arg0 --- newChild [IN] + # IXMLDOMNode arg1 --- oldChild [IN] + def replaceChild(arg0, arg1) + ret = _invoke(14, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_BYREF|VT_DISPATCH]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode removeChild + # remove a child node + # IXMLDOMNode arg0 --- childNode [IN] + def removeChild(arg0) + ret = _invoke(15, [arg0], [VT_BYREF|VT_DISPATCH]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode appendChild + # append a child node + # IXMLDOMNode arg0 --- newChild [IN] + def appendChild(arg0) + ret = _invoke(16, [arg0], [VT_BYREF|VT_DISPATCH]) + @lastargs = WIN32OLE::ARGV + ret + end + + # BOOL hasChildNodes + def hasChildNodes() + ret = _invoke(17, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode cloneNode + # BOOL arg0 --- deep [IN] + def cloneNode(arg0) + ret = _invoke(19, [arg0], [VT_BOOL]) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR transformNode + # apply the stylesheet to the subtree + # IXMLDOMNode arg0 --- stylesheet [IN] + def transformNode(arg0) + ret = _invoke(28, [arg0], [VT_BYREF|VT_DISPATCH]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNodeList selectNodes + # execute query on the subtree + # BSTR arg0 --- queryString [IN] + def selectNodes(arg0) + ret = _invoke(29, [arg0], [VT_BSTR]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode selectSingleNode + # execute query on the subtree + # BSTR arg0 --- queryString [IN] + def selectSingleNode(arg0) + ret = _invoke(30, [arg0], [VT_BSTR]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID transformNodeToObject + # apply the stylesheet to the subtree, returning the result through a document or a stream + # IXMLDOMNode arg0 --- stylesheet [IN] + # VARIANT arg1 --- outputObject [IN] + def transformNodeToObject(arg0, arg1) + ret = _invoke(35, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VARIANT getAttribute + # look up the string value of an attribute by name + # BSTR arg0 --- name [IN] + def getAttribute(arg0) + ret = _invoke(99, [arg0], [VT_BSTR]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID setAttribute + # set the string value of an attribute by name + # BSTR arg0 --- name [IN] + # VARIANT arg1 --- value [IN] + def setAttribute(arg0, arg1) + ret = _invoke(100, [arg0, arg1], [VT_BSTR, VT_VARIANT]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID removeAttribute + # remove an attribute by name + # BSTR arg0 --- name [IN] + def removeAttribute(arg0) + ret = _invoke(101, [arg0], [VT_BSTR]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMAttribute getAttributeNode + # look up the attribute node by name + # BSTR arg0 --- name [IN] + def getAttributeNode(arg0) + ret = _invoke(102, [arg0], [VT_BSTR]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMAttribute setAttributeNode + # set the specified attribute on the element + # IXMLDOMAttribute arg0 --- DOMAttribute [IN] + def setAttributeNode(arg0) + ret = _invoke(103, [arg0], [VT_BYREF|VT_DISPATCH]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMAttribute removeAttributeNode + # remove the specified attribute + # IXMLDOMAttribute arg0 --- DOMAttribute [IN] + def removeAttributeNode(arg0) + ret = _invoke(104, [arg0], [VT_BYREF|VT_DISPATCH]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNodeList getElementsByTagName + # build a list of elements by name + # BSTR arg0 --- tagName [IN] + def getElementsByTagName(arg0) + ret = _invoke(105, [arg0], [VT_BSTR]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID normalize + # collapse all adjacent text nodes in sub-tree + def normalize() + ret = _invoke(106, [], []) + @lastargs = WIN32OLE::ARGV + ret + end +end + +# +module IXMLDOMAttribute + include WIN32OLE::VARIANT + attr_reader :lastargs + + # BSTR nodeName + # name of the node + def nodeName() + ret = _getproperty(2, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # VARIANT nodeValue + # value stored in the node + def nodeValue() + ret = _getproperty(3, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # DOMNodeType nodeType + # the node's type + def nodeType() + ret = _getproperty(4, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode parentNode + # parent of the node + def parentNode() + ret = _getproperty(6, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNodeList childNodes + # the collection of the node's children + def childNodes() + ret = _getproperty(7, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode firstChild + # first child of the node + def firstChild() + ret = _getproperty(8, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode lastChild + # first child of the node + def lastChild() + ret = _getproperty(9, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode previousSibling + # left sibling of the node + def previousSibling() + ret = _getproperty(10, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode nextSibling + # right sibling of the node + def nextSibling() + ret = _getproperty(11, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNamedNodeMap attributes + # the collection of the node's attributes + def attributes() + ret = _getproperty(12, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMDocument ownerDocument + # document that contains the node + def ownerDocument() + ret = _getproperty(18, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR nodeTypeString + # the type of node in string form + def nodeTypeString() + ret = _getproperty(21, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR text + # text content of the node and subtree + def text() + ret = _getproperty(24, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BOOL specified + # indicates whether node is a default value + def specified() + ret = _getproperty(22, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode definition + # pointer to the definition of the node in the DTD or schema + def definition() + ret = _getproperty(23, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # VARIANT nodeTypedValue + # get the strongly typed value of the node + def nodeTypedValue() + ret = _getproperty(25, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # VARIANT dataType + # the data type of the node + def dataType() + ret = _getproperty(26, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR xml + # return the XML source for the node and each of its descendants + def xml() + ret = _getproperty(27, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BOOL parsed + # has sub-tree been completely parsed + def parsed() + ret = _getproperty(31, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR namespaceURI + # the URI for the namespace applying to the node + def namespaceURI() + ret = _getproperty(32, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR prefix + # the prefix for the namespace applying to the node + def prefix() + ret = _getproperty(33, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR baseName + # the base name of the node (nodename with the prefix stripped off) + def baseName() + ret = _getproperty(34, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR name + # get name of the attribute + def name() + ret = _getproperty(118, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # VARIANT value + # string value of the attribute + def value() + ret = _getproperty(120, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID nodeValue + # value stored in the node + def nodeValue=(arg0) + ret = _setproperty(3, [arg0], [VT_VARIANT]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID text + # text content of the node and subtree + def text=(arg0) + ret = _setproperty(24, [arg0], [VT_BSTR]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID nodeTypedValue + # get the strongly typed value of the node + def nodeTypedValue=(arg0) + ret = _setproperty(25, [arg0], [VT_VARIANT]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID dataType + # the data type of the node + def dataType=(arg0) + ret = _setproperty(26, [arg0], [VT_VARIANT]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID value + # string value of the attribute + def value=(arg0) + ret = _setproperty(120, [arg0], [VT_VARIANT]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode insertBefore + # insert a child node + # IXMLDOMNode arg0 --- newChild [IN] + # VARIANT arg1 --- refChild [IN] + def insertBefore(arg0, arg1) + ret = _invoke(13, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode replaceChild + # replace a child node + # IXMLDOMNode arg0 --- newChild [IN] + # IXMLDOMNode arg1 --- oldChild [IN] + def replaceChild(arg0, arg1) + ret = _invoke(14, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_BYREF|VT_DISPATCH]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode removeChild + # remove a child node + # IXMLDOMNode arg0 --- childNode [IN] + def removeChild(arg0) + ret = _invoke(15, [arg0], [VT_BYREF|VT_DISPATCH]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode appendChild + # append a child node + # IXMLDOMNode arg0 --- newChild [IN] + def appendChild(arg0) + ret = _invoke(16, [arg0], [VT_BYREF|VT_DISPATCH]) + @lastargs = WIN32OLE::ARGV + ret + end + + # BOOL hasChildNodes + def hasChildNodes() + ret = _invoke(17, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode cloneNode + # BOOL arg0 --- deep [IN] + def cloneNode(arg0) + ret = _invoke(19, [arg0], [VT_BOOL]) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR transformNode + # apply the stylesheet to the subtree + # IXMLDOMNode arg0 --- stylesheet [IN] + def transformNode(arg0) + ret = _invoke(28, [arg0], [VT_BYREF|VT_DISPATCH]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNodeList selectNodes + # execute query on the subtree + # BSTR arg0 --- queryString [IN] + def selectNodes(arg0) + ret = _invoke(29, [arg0], [VT_BSTR]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode selectSingleNode + # execute query on the subtree + # BSTR arg0 --- queryString [IN] + def selectSingleNode(arg0) + ret = _invoke(30, [arg0], [VT_BSTR]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID transformNodeToObject + # apply the stylesheet to the subtree, returning the result through a document or a stream + # IXMLDOMNode arg0 --- stylesheet [IN] + # VARIANT arg1 --- outputObject [IN] + def transformNodeToObject(arg0, arg1) + ret = _invoke(35, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT]) + @lastargs = WIN32OLE::ARGV + ret + end +end + +# +module IXMLDOMDocumentFragment + include WIN32OLE::VARIANT + attr_reader :lastargs + + # BSTR nodeName + # name of the node + def nodeName() + ret = _getproperty(2, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # VARIANT nodeValue + # value stored in the node + def nodeValue() + ret = _getproperty(3, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # DOMNodeType nodeType + # the node's type + def nodeType() + ret = _getproperty(4, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode parentNode + # parent of the node + def parentNode() + ret = _getproperty(6, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNodeList childNodes + # the collection of the node's children + def childNodes() + ret = _getproperty(7, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode firstChild + # first child of the node + def firstChild() + ret = _getproperty(8, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode lastChild + # first child of the node + def lastChild() + ret = _getproperty(9, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode previousSibling + # left sibling of the node + def previousSibling() + ret = _getproperty(10, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode nextSibling + # right sibling of the node + def nextSibling() + ret = _getproperty(11, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNamedNodeMap attributes + # the collection of the node's attributes + def attributes() + ret = _getproperty(12, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMDocument ownerDocument + # document that contains the node + def ownerDocument() + ret = _getproperty(18, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR nodeTypeString + # the type of node in string form + def nodeTypeString() + ret = _getproperty(21, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR text + # text content of the node and subtree + def text() + ret = _getproperty(24, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BOOL specified + # indicates whether node is a default value + def specified() + ret = _getproperty(22, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode definition + # pointer to the definition of the node in the DTD or schema + def definition() + ret = _getproperty(23, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # VARIANT nodeTypedValue + # get the strongly typed value of the node + def nodeTypedValue() + ret = _getproperty(25, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # VARIANT dataType + # the data type of the node + def dataType() + ret = _getproperty(26, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR xml + # return the XML source for the node and each of its descendants + def xml() + ret = _getproperty(27, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BOOL parsed + # has sub-tree been completely parsed + def parsed() + ret = _getproperty(31, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR namespaceURI + # the URI for the namespace applying to the node + def namespaceURI() + ret = _getproperty(32, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR prefix + # the prefix for the namespace applying to the node + def prefix() + ret = _getproperty(33, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR baseName + # the base name of the node (nodename with the prefix stripped off) + def baseName() + ret = _getproperty(34, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID nodeValue + # value stored in the node + def nodeValue=(arg0) + ret = _setproperty(3, [arg0], [VT_VARIANT]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID text + # text content of the node and subtree + def text=(arg0) + ret = _setproperty(24, [arg0], [VT_BSTR]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID nodeTypedValue + # get the strongly typed value of the node + def nodeTypedValue=(arg0) + ret = _setproperty(25, [arg0], [VT_VARIANT]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID dataType + # the data type of the node + def dataType=(arg0) + ret = _setproperty(26, [arg0], [VT_VARIANT]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode insertBefore + # insert a child node + # IXMLDOMNode arg0 --- newChild [IN] + # VARIANT arg1 --- refChild [IN] + def insertBefore(arg0, arg1) + ret = _invoke(13, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode replaceChild + # replace a child node + # IXMLDOMNode arg0 --- newChild [IN] + # IXMLDOMNode arg1 --- oldChild [IN] + def replaceChild(arg0, arg1) + ret = _invoke(14, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_BYREF|VT_DISPATCH]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode removeChild + # remove a child node + # IXMLDOMNode arg0 --- childNode [IN] + def removeChild(arg0) + ret = _invoke(15, [arg0], [VT_BYREF|VT_DISPATCH]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode appendChild + # append a child node + # IXMLDOMNode arg0 --- newChild [IN] + def appendChild(arg0) + ret = _invoke(16, [arg0], [VT_BYREF|VT_DISPATCH]) + @lastargs = WIN32OLE::ARGV + ret + end + + # BOOL hasChildNodes + def hasChildNodes() + ret = _invoke(17, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode cloneNode + # BOOL arg0 --- deep [IN] + def cloneNode(arg0) + ret = _invoke(19, [arg0], [VT_BOOL]) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR transformNode + # apply the stylesheet to the subtree + # IXMLDOMNode arg0 --- stylesheet [IN] + def transformNode(arg0) + ret = _invoke(28, [arg0], [VT_BYREF|VT_DISPATCH]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNodeList selectNodes + # execute query on the subtree + # BSTR arg0 --- queryString [IN] + def selectNodes(arg0) + ret = _invoke(29, [arg0], [VT_BSTR]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode selectSingleNode + # execute query on the subtree + # BSTR arg0 --- queryString [IN] + def selectSingleNode(arg0) + ret = _invoke(30, [arg0], [VT_BSTR]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID transformNodeToObject + # apply the stylesheet to the subtree, returning the result through a document or a stream + # IXMLDOMNode arg0 --- stylesheet [IN] + # VARIANT arg1 --- outputObject [IN] + def transformNodeToObject(arg0, arg1) + ret = _invoke(35, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT]) + @lastargs = WIN32OLE::ARGV + ret + end +end + +# +module IXMLDOMText + include WIN32OLE::VARIANT + attr_reader :lastargs + + # BSTR nodeName + # name of the node + def nodeName() + ret = _getproperty(2, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # VARIANT nodeValue + # value stored in the node + def nodeValue() + ret = _getproperty(3, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # DOMNodeType nodeType + # the node's type + def nodeType() + ret = _getproperty(4, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode parentNode + # parent of the node + def parentNode() + ret = _getproperty(6, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNodeList childNodes + # the collection of the node's children + def childNodes() + ret = _getproperty(7, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode firstChild + # first child of the node + def firstChild() + ret = _getproperty(8, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode lastChild + # first child of the node + def lastChild() + ret = _getproperty(9, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode previousSibling + # left sibling of the node + def previousSibling() + ret = _getproperty(10, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode nextSibling + # right sibling of the node + def nextSibling() + ret = _getproperty(11, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNamedNodeMap attributes + # the collection of the node's attributes + def attributes() + ret = _getproperty(12, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMDocument ownerDocument + # document that contains the node + def ownerDocument() + ret = _getproperty(18, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR nodeTypeString + # the type of node in string form + def nodeTypeString() + ret = _getproperty(21, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR text + # text content of the node and subtree + def text() + ret = _getproperty(24, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BOOL specified + # indicates whether node is a default value + def specified() + ret = _getproperty(22, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode definition + # pointer to the definition of the node in the DTD or schema + def definition() + ret = _getproperty(23, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # VARIANT nodeTypedValue + # get the strongly typed value of the node + def nodeTypedValue() + ret = _getproperty(25, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # VARIANT dataType + # the data type of the node + def dataType() + ret = _getproperty(26, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR xml + # return the XML source for the node and each of its descendants + def xml() + ret = _getproperty(27, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BOOL parsed + # has sub-tree been completely parsed + def parsed() + ret = _getproperty(31, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR namespaceURI + # the URI for the namespace applying to the node + def namespaceURI() + ret = _getproperty(32, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR prefix + # the prefix for the namespace applying to the node + def prefix() + ret = _getproperty(33, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR baseName + # the base name of the node (nodename with the prefix stripped off) + def baseName() + ret = _getproperty(34, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR data + # value of the node + def data() + ret = _getproperty(109, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # I4 length + # number of characters in value + def length() + ret = _getproperty(110, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID nodeValue + # value stored in the node + def nodeValue=(arg0) + ret = _setproperty(3, [arg0], [VT_VARIANT]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID text + # text content of the node and subtree + def text=(arg0) + ret = _setproperty(24, [arg0], [VT_BSTR]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID nodeTypedValue + # get the strongly typed value of the node + def nodeTypedValue=(arg0) + ret = _setproperty(25, [arg0], [VT_VARIANT]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID dataType + # the data type of the node + def dataType=(arg0) + ret = _setproperty(26, [arg0], [VT_VARIANT]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID data + # value of the node + def data=(arg0) + ret = _setproperty(109, [arg0], [VT_BSTR]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode insertBefore + # insert a child node + # IXMLDOMNode arg0 --- newChild [IN] + # VARIANT arg1 --- refChild [IN] + def insertBefore(arg0, arg1) + ret = _invoke(13, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode replaceChild + # replace a child node + # IXMLDOMNode arg0 --- newChild [IN] + # IXMLDOMNode arg1 --- oldChild [IN] + def replaceChild(arg0, arg1) + ret = _invoke(14, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_BYREF|VT_DISPATCH]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode removeChild + # remove a child node + # IXMLDOMNode arg0 --- childNode [IN] + def removeChild(arg0) + ret = _invoke(15, [arg0], [VT_BYREF|VT_DISPATCH]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode appendChild + # append a child node + # IXMLDOMNode arg0 --- newChild [IN] + def appendChild(arg0) + ret = _invoke(16, [arg0], [VT_BYREF|VT_DISPATCH]) + @lastargs = WIN32OLE::ARGV + ret + end + + # BOOL hasChildNodes + def hasChildNodes() + ret = _invoke(17, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode cloneNode + # BOOL arg0 --- deep [IN] + def cloneNode(arg0) + ret = _invoke(19, [arg0], [VT_BOOL]) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR transformNode + # apply the stylesheet to the subtree + # IXMLDOMNode arg0 --- stylesheet [IN] + def transformNode(arg0) + ret = _invoke(28, [arg0], [VT_BYREF|VT_DISPATCH]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNodeList selectNodes + # execute query on the subtree + # BSTR arg0 --- queryString [IN] + def selectNodes(arg0) + ret = _invoke(29, [arg0], [VT_BSTR]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode selectSingleNode + # execute query on the subtree + # BSTR arg0 --- queryString [IN] + def selectSingleNode(arg0) + ret = _invoke(30, [arg0], [VT_BSTR]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID transformNodeToObject + # apply the stylesheet to the subtree, returning the result through a document or a stream + # IXMLDOMNode arg0 --- stylesheet [IN] + # VARIANT arg1 --- outputObject [IN] + def transformNodeToObject(arg0, arg1) + ret = _invoke(35, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT]) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR substringData + # retrieve substring of value + # I4 arg0 --- offset [IN] + # I4 arg1 --- count [IN] + def substringData(arg0, arg1) + ret = _invoke(111, [arg0, arg1], [VT_I4, VT_I4]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID appendData + # append string to value + # BSTR arg0 --- data [IN] + def appendData(arg0) + ret = _invoke(112, [arg0], [VT_BSTR]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID insertData + # insert string into value + # I4 arg0 --- offset [IN] + # BSTR arg1 --- data [IN] + def insertData(arg0, arg1) + ret = _invoke(113, [arg0, arg1], [VT_I4, VT_BSTR]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID deleteData + # delete string within the value + # I4 arg0 --- offset [IN] + # I4 arg1 --- count [IN] + def deleteData(arg0, arg1) + ret = _invoke(114, [arg0, arg1], [VT_I4, VT_I4]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID replaceData + # replace string within the value + # I4 arg0 --- offset [IN] + # I4 arg1 --- count [IN] + # BSTR arg2 --- data [IN] + def replaceData(arg0, arg1, arg2) + ret = _invoke(115, [arg0, arg1, arg2], [VT_I4, VT_I4, VT_BSTR]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMText splitText + # split the text node into two text nodes at the position specified + # I4 arg0 --- offset [IN] + def splitText(arg0) + ret = _invoke(123, [arg0], [VT_I4]) + @lastargs = WIN32OLE::ARGV + ret + end +end + +# +module IXMLDOMCharacterData + include WIN32OLE::VARIANT + attr_reader :lastargs + + # BSTR nodeName + # name of the node + def nodeName() + ret = _getproperty(2, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # VARIANT nodeValue + # value stored in the node + def nodeValue() + ret = _getproperty(3, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # DOMNodeType nodeType + # the node's type + def nodeType() + ret = _getproperty(4, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode parentNode + # parent of the node + def parentNode() + ret = _getproperty(6, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNodeList childNodes + # the collection of the node's children + def childNodes() + ret = _getproperty(7, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode firstChild + # first child of the node + def firstChild() + ret = _getproperty(8, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode lastChild + # first child of the node + def lastChild() + ret = _getproperty(9, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode previousSibling + # left sibling of the node + def previousSibling() + ret = _getproperty(10, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode nextSibling + # right sibling of the node + def nextSibling() + ret = _getproperty(11, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNamedNodeMap attributes + # the collection of the node's attributes + def attributes() + ret = _getproperty(12, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMDocument ownerDocument + # document that contains the node + def ownerDocument() + ret = _getproperty(18, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR nodeTypeString + # the type of node in string form + def nodeTypeString() + ret = _getproperty(21, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR text + # text content of the node and subtree + def text() + ret = _getproperty(24, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BOOL specified + # indicates whether node is a default value + def specified() + ret = _getproperty(22, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode definition + # pointer to the definition of the node in the DTD or schema + def definition() + ret = _getproperty(23, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # VARIANT nodeTypedValue + # get the strongly typed value of the node + def nodeTypedValue() + ret = _getproperty(25, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # VARIANT dataType + # the data type of the node + def dataType() + ret = _getproperty(26, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR xml + # return the XML source for the node and each of its descendants + def xml() + ret = _getproperty(27, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BOOL parsed + # has sub-tree been completely parsed + def parsed() + ret = _getproperty(31, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR namespaceURI + # the URI for the namespace applying to the node + def namespaceURI() + ret = _getproperty(32, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR prefix + # the prefix for the namespace applying to the node + def prefix() + ret = _getproperty(33, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR baseName + # the base name of the node (nodename with the prefix stripped off) + def baseName() + ret = _getproperty(34, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR data + # value of the node + def data() + ret = _getproperty(109, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # I4 length + # number of characters in value + def length() + ret = _getproperty(110, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID nodeValue + # value stored in the node + def nodeValue=(arg0) + ret = _setproperty(3, [arg0], [VT_VARIANT]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID text + # text content of the node and subtree + def text=(arg0) + ret = _setproperty(24, [arg0], [VT_BSTR]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID nodeTypedValue + # get the strongly typed value of the node + def nodeTypedValue=(arg0) + ret = _setproperty(25, [arg0], [VT_VARIANT]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID dataType + # the data type of the node + def dataType=(arg0) + ret = _setproperty(26, [arg0], [VT_VARIANT]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID data + # value of the node + def data=(arg0) + ret = _setproperty(109, [arg0], [VT_BSTR]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode insertBefore + # insert a child node + # IXMLDOMNode arg0 --- newChild [IN] + # VARIANT arg1 --- refChild [IN] + def insertBefore(arg0, arg1) + ret = _invoke(13, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode replaceChild + # replace a child node + # IXMLDOMNode arg0 --- newChild [IN] + # IXMLDOMNode arg1 --- oldChild [IN] + def replaceChild(arg0, arg1) + ret = _invoke(14, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_BYREF|VT_DISPATCH]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode removeChild + # remove a child node + # IXMLDOMNode arg0 --- childNode [IN] + def removeChild(arg0) + ret = _invoke(15, [arg0], [VT_BYREF|VT_DISPATCH]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode appendChild + # append a child node + # IXMLDOMNode arg0 --- newChild [IN] + def appendChild(arg0) + ret = _invoke(16, [arg0], [VT_BYREF|VT_DISPATCH]) + @lastargs = WIN32OLE::ARGV + ret + end + + # BOOL hasChildNodes + def hasChildNodes() + ret = _invoke(17, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode cloneNode + # BOOL arg0 --- deep [IN] + def cloneNode(arg0) + ret = _invoke(19, [arg0], [VT_BOOL]) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR transformNode + # apply the stylesheet to the subtree + # IXMLDOMNode arg0 --- stylesheet [IN] + def transformNode(arg0) + ret = _invoke(28, [arg0], [VT_BYREF|VT_DISPATCH]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNodeList selectNodes + # execute query on the subtree + # BSTR arg0 --- queryString [IN] + def selectNodes(arg0) + ret = _invoke(29, [arg0], [VT_BSTR]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode selectSingleNode + # execute query on the subtree + # BSTR arg0 --- queryString [IN] + def selectSingleNode(arg0) + ret = _invoke(30, [arg0], [VT_BSTR]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID transformNodeToObject + # apply the stylesheet to the subtree, returning the result through a document or a stream + # IXMLDOMNode arg0 --- stylesheet [IN] + # VARIANT arg1 --- outputObject [IN] + def transformNodeToObject(arg0, arg1) + ret = _invoke(35, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT]) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR substringData + # retrieve substring of value + # I4 arg0 --- offset [IN] + # I4 arg1 --- count [IN] + def substringData(arg0, arg1) + ret = _invoke(111, [arg0, arg1], [VT_I4, VT_I4]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID appendData + # append string to value + # BSTR arg0 --- data [IN] + def appendData(arg0) + ret = _invoke(112, [arg0], [VT_BSTR]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID insertData + # insert string into value + # I4 arg0 --- offset [IN] + # BSTR arg1 --- data [IN] + def insertData(arg0, arg1) + ret = _invoke(113, [arg0, arg1], [VT_I4, VT_BSTR]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID deleteData + # delete string within the value + # I4 arg0 --- offset [IN] + # I4 arg1 --- count [IN] + def deleteData(arg0, arg1) + ret = _invoke(114, [arg0, arg1], [VT_I4, VT_I4]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID replaceData + # replace string within the value + # I4 arg0 --- offset [IN] + # I4 arg1 --- count [IN] + # BSTR arg2 --- data [IN] + def replaceData(arg0, arg1, arg2) + ret = _invoke(115, [arg0, arg1, arg2], [VT_I4, VT_I4, VT_BSTR]) + @lastargs = WIN32OLE::ARGV + ret + end +end + +# +module IXMLDOMComment + include WIN32OLE::VARIANT + attr_reader :lastargs + + # BSTR nodeName + # name of the node + def nodeName() + ret = _getproperty(2, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # VARIANT nodeValue + # value stored in the node + def nodeValue() + ret = _getproperty(3, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # DOMNodeType nodeType + # the node's type + def nodeType() + ret = _getproperty(4, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode parentNode + # parent of the node + def parentNode() + ret = _getproperty(6, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNodeList childNodes + # the collection of the node's children + def childNodes() + ret = _getproperty(7, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode firstChild + # first child of the node + def firstChild() + ret = _getproperty(8, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode lastChild + # first child of the node + def lastChild() + ret = _getproperty(9, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode previousSibling + # left sibling of the node + def previousSibling() + ret = _getproperty(10, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode nextSibling + # right sibling of the node + def nextSibling() + ret = _getproperty(11, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNamedNodeMap attributes + # the collection of the node's attributes + def attributes() + ret = _getproperty(12, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMDocument ownerDocument + # document that contains the node + def ownerDocument() + ret = _getproperty(18, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR nodeTypeString + # the type of node in string form + def nodeTypeString() + ret = _getproperty(21, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR text + # text content of the node and subtree + def text() + ret = _getproperty(24, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BOOL specified + # indicates whether node is a default value + def specified() + ret = _getproperty(22, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode definition + # pointer to the definition of the node in the DTD or schema + def definition() + ret = _getproperty(23, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # VARIANT nodeTypedValue + # get the strongly typed value of the node + def nodeTypedValue() + ret = _getproperty(25, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # VARIANT dataType + # the data type of the node + def dataType() + ret = _getproperty(26, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR xml + # return the XML source for the node and each of its descendants + def xml() + ret = _getproperty(27, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BOOL parsed + # has sub-tree been completely parsed + def parsed() + ret = _getproperty(31, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR namespaceURI + # the URI for the namespace applying to the node + def namespaceURI() + ret = _getproperty(32, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR prefix + # the prefix for the namespace applying to the node + def prefix() + ret = _getproperty(33, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR baseName + # the base name of the node (nodename with the prefix stripped off) + def baseName() + ret = _getproperty(34, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR data + # value of the node + def data() + ret = _getproperty(109, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # I4 length + # number of characters in value + def length() + ret = _getproperty(110, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID nodeValue + # value stored in the node + def nodeValue=(arg0) + ret = _setproperty(3, [arg0], [VT_VARIANT]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID text + # text content of the node and subtree + def text=(arg0) + ret = _setproperty(24, [arg0], [VT_BSTR]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID nodeTypedValue + # get the strongly typed value of the node + def nodeTypedValue=(arg0) + ret = _setproperty(25, [arg0], [VT_VARIANT]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID dataType + # the data type of the node + def dataType=(arg0) + ret = _setproperty(26, [arg0], [VT_VARIANT]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID data + # value of the node + def data=(arg0) + ret = _setproperty(109, [arg0], [VT_BSTR]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode insertBefore + # insert a child node + # IXMLDOMNode arg0 --- newChild [IN] + # VARIANT arg1 --- refChild [IN] + def insertBefore(arg0, arg1) + ret = _invoke(13, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode replaceChild + # replace a child node + # IXMLDOMNode arg0 --- newChild [IN] + # IXMLDOMNode arg1 --- oldChild [IN] + def replaceChild(arg0, arg1) + ret = _invoke(14, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_BYREF|VT_DISPATCH]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode removeChild + # remove a child node + # IXMLDOMNode arg0 --- childNode [IN] + def removeChild(arg0) + ret = _invoke(15, [arg0], [VT_BYREF|VT_DISPATCH]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode appendChild + # append a child node + # IXMLDOMNode arg0 --- newChild [IN] + def appendChild(arg0) + ret = _invoke(16, [arg0], [VT_BYREF|VT_DISPATCH]) + @lastargs = WIN32OLE::ARGV + ret + end + + # BOOL hasChildNodes + def hasChildNodes() + ret = _invoke(17, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode cloneNode + # BOOL arg0 --- deep [IN] + def cloneNode(arg0) + ret = _invoke(19, [arg0], [VT_BOOL]) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR transformNode + # apply the stylesheet to the subtree + # IXMLDOMNode arg0 --- stylesheet [IN] + def transformNode(arg0) + ret = _invoke(28, [arg0], [VT_BYREF|VT_DISPATCH]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNodeList selectNodes + # execute query on the subtree + # BSTR arg0 --- queryString [IN] + def selectNodes(arg0) + ret = _invoke(29, [arg0], [VT_BSTR]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode selectSingleNode + # execute query on the subtree + # BSTR arg0 --- queryString [IN] + def selectSingleNode(arg0) + ret = _invoke(30, [arg0], [VT_BSTR]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID transformNodeToObject + # apply the stylesheet to the subtree, returning the result through a document or a stream + # IXMLDOMNode arg0 --- stylesheet [IN] + # VARIANT arg1 --- outputObject [IN] + def transformNodeToObject(arg0, arg1) + ret = _invoke(35, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT]) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR substringData + # retrieve substring of value + # I4 arg0 --- offset [IN] + # I4 arg1 --- count [IN] + def substringData(arg0, arg1) + ret = _invoke(111, [arg0, arg1], [VT_I4, VT_I4]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID appendData + # append string to value + # BSTR arg0 --- data [IN] + def appendData(arg0) + ret = _invoke(112, [arg0], [VT_BSTR]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID insertData + # insert string into value + # I4 arg0 --- offset [IN] + # BSTR arg1 --- data [IN] + def insertData(arg0, arg1) + ret = _invoke(113, [arg0, arg1], [VT_I4, VT_BSTR]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID deleteData + # delete string within the value + # I4 arg0 --- offset [IN] + # I4 arg1 --- count [IN] + def deleteData(arg0, arg1) + ret = _invoke(114, [arg0, arg1], [VT_I4, VT_I4]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID replaceData + # replace string within the value + # I4 arg0 --- offset [IN] + # I4 arg1 --- count [IN] + # BSTR arg2 --- data [IN] + def replaceData(arg0, arg1, arg2) + ret = _invoke(115, [arg0, arg1, arg2], [VT_I4, VT_I4, VT_BSTR]) + @lastargs = WIN32OLE::ARGV + ret + end +end + +# +module IXMLDOMCDATASection + include WIN32OLE::VARIANT + attr_reader :lastargs + + # BSTR nodeName + # name of the node + def nodeName() + ret = _getproperty(2, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # VARIANT nodeValue + # value stored in the node + def nodeValue() + ret = _getproperty(3, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # DOMNodeType nodeType + # the node's type + def nodeType() + ret = _getproperty(4, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode parentNode + # parent of the node + def parentNode() + ret = _getproperty(6, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNodeList childNodes + # the collection of the node's children + def childNodes() + ret = _getproperty(7, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode firstChild + # first child of the node + def firstChild() + ret = _getproperty(8, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode lastChild + # first child of the node + def lastChild() + ret = _getproperty(9, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode previousSibling + # left sibling of the node + def previousSibling() + ret = _getproperty(10, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode nextSibling + # right sibling of the node + def nextSibling() + ret = _getproperty(11, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNamedNodeMap attributes + # the collection of the node's attributes + def attributes() + ret = _getproperty(12, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMDocument ownerDocument + # document that contains the node + def ownerDocument() + ret = _getproperty(18, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR nodeTypeString + # the type of node in string form + def nodeTypeString() + ret = _getproperty(21, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR text + # text content of the node and subtree + def text() + ret = _getproperty(24, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BOOL specified + # indicates whether node is a default value + def specified() + ret = _getproperty(22, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode definition + # pointer to the definition of the node in the DTD or schema + def definition() + ret = _getproperty(23, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # VARIANT nodeTypedValue + # get the strongly typed value of the node + def nodeTypedValue() + ret = _getproperty(25, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # VARIANT dataType + # the data type of the node + def dataType() + ret = _getproperty(26, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR xml + # return the XML source for the node and each of its descendants + def xml() + ret = _getproperty(27, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BOOL parsed + # has sub-tree been completely parsed + def parsed() + ret = _getproperty(31, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR namespaceURI + # the URI for the namespace applying to the node + def namespaceURI() + ret = _getproperty(32, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR prefix + # the prefix for the namespace applying to the node + def prefix() + ret = _getproperty(33, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR baseName + # the base name of the node (nodename with the prefix stripped off) + def baseName() + ret = _getproperty(34, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR data + # value of the node + def data() + ret = _getproperty(109, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # I4 length + # number of characters in value + def length() + ret = _getproperty(110, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID nodeValue + # value stored in the node + def nodeValue=(arg0) + ret = _setproperty(3, [arg0], [VT_VARIANT]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID text + # text content of the node and subtree + def text=(arg0) + ret = _setproperty(24, [arg0], [VT_BSTR]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID nodeTypedValue + # get the strongly typed value of the node + def nodeTypedValue=(arg0) + ret = _setproperty(25, [arg0], [VT_VARIANT]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID dataType + # the data type of the node + def dataType=(arg0) + ret = _setproperty(26, [arg0], [VT_VARIANT]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID data + # value of the node + def data=(arg0) + ret = _setproperty(109, [arg0], [VT_BSTR]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode insertBefore + # insert a child node + # IXMLDOMNode arg0 --- newChild [IN] + # VARIANT arg1 --- refChild [IN] + def insertBefore(arg0, arg1) + ret = _invoke(13, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode replaceChild + # replace a child node + # IXMLDOMNode arg0 --- newChild [IN] + # IXMLDOMNode arg1 --- oldChild [IN] + def replaceChild(arg0, arg1) + ret = _invoke(14, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_BYREF|VT_DISPATCH]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode removeChild + # remove a child node + # IXMLDOMNode arg0 --- childNode [IN] + def removeChild(arg0) + ret = _invoke(15, [arg0], [VT_BYREF|VT_DISPATCH]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode appendChild + # append a child node + # IXMLDOMNode arg0 --- newChild [IN] + def appendChild(arg0) + ret = _invoke(16, [arg0], [VT_BYREF|VT_DISPATCH]) + @lastargs = WIN32OLE::ARGV + ret + end + + # BOOL hasChildNodes + def hasChildNodes() + ret = _invoke(17, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode cloneNode + # BOOL arg0 --- deep [IN] + def cloneNode(arg0) + ret = _invoke(19, [arg0], [VT_BOOL]) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR transformNode + # apply the stylesheet to the subtree + # IXMLDOMNode arg0 --- stylesheet [IN] + def transformNode(arg0) + ret = _invoke(28, [arg0], [VT_BYREF|VT_DISPATCH]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNodeList selectNodes + # execute query on the subtree + # BSTR arg0 --- queryString [IN] + def selectNodes(arg0) + ret = _invoke(29, [arg0], [VT_BSTR]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode selectSingleNode + # execute query on the subtree + # BSTR arg0 --- queryString [IN] + def selectSingleNode(arg0) + ret = _invoke(30, [arg0], [VT_BSTR]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID transformNodeToObject + # apply the stylesheet to the subtree, returning the result through a document or a stream + # IXMLDOMNode arg0 --- stylesheet [IN] + # VARIANT arg1 --- outputObject [IN] + def transformNodeToObject(arg0, arg1) + ret = _invoke(35, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT]) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR substringData + # retrieve substring of value + # I4 arg0 --- offset [IN] + # I4 arg1 --- count [IN] + def substringData(arg0, arg1) + ret = _invoke(111, [arg0, arg1], [VT_I4, VT_I4]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID appendData + # append string to value + # BSTR arg0 --- data [IN] + def appendData(arg0) + ret = _invoke(112, [arg0], [VT_BSTR]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID insertData + # insert string into value + # I4 arg0 --- offset [IN] + # BSTR arg1 --- data [IN] + def insertData(arg0, arg1) + ret = _invoke(113, [arg0, arg1], [VT_I4, VT_BSTR]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID deleteData + # delete string within the value + # I4 arg0 --- offset [IN] + # I4 arg1 --- count [IN] + def deleteData(arg0, arg1) + ret = _invoke(114, [arg0, arg1], [VT_I4, VT_I4]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID replaceData + # replace string within the value + # I4 arg0 --- offset [IN] + # I4 arg1 --- count [IN] + # BSTR arg2 --- data [IN] + def replaceData(arg0, arg1, arg2) + ret = _invoke(115, [arg0, arg1, arg2], [VT_I4, VT_I4, VT_BSTR]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMText splitText + # split the text node into two text nodes at the position specified + # I4 arg0 --- offset [IN] + def splitText(arg0) + ret = _invoke(123, [arg0], [VT_I4]) + @lastargs = WIN32OLE::ARGV + ret + end +end + +# +module IXMLDOMProcessingInstruction + include WIN32OLE::VARIANT + attr_reader :lastargs + + # BSTR nodeName + # name of the node + def nodeName() + ret = _getproperty(2, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # VARIANT nodeValue + # value stored in the node + def nodeValue() + ret = _getproperty(3, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # DOMNodeType nodeType + # the node's type + def nodeType() + ret = _getproperty(4, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode parentNode + # parent of the node + def parentNode() + ret = _getproperty(6, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNodeList childNodes + # the collection of the node's children + def childNodes() + ret = _getproperty(7, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode firstChild + # first child of the node + def firstChild() + ret = _getproperty(8, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode lastChild + # first child of the node + def lastChild() + ret = _getproperty(9, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode previousSibling + # left sibling of the node + def previousSibling() + ret = _getproperty(10, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode nextSibling + # right sibling of the node + def nextSibling() + ret = _getproperty(11, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNamedNodeMap attributes + # the collection of the node's attributes + def attributes() + ret = _getproperty(12, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMDocument ownerDocument + # document that contains the node + def ownerDocument() + ret = _getproperty(18, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR nodeTypeString + # the type of node in string form + def nodeTypeString() + ret = _getproperty(21, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR text + # text content of the node and subtree + def text() + ret = _getproperty(24, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BOOL specified + # indicates whether node is a default value + def specified() + ret = _getproperty(22, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode definition + # pointer to the definition of the node in the DTD or schema + def definition() + ret = _getproperty(23, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # VARIANT nodeTypedValue + # get the strongly typed value of the node + def nodeTypedValue() + ret = _getproperty(25, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # VARIANT dataType + # the data type of the node + def dataType() + ret = _getproperty(26, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR xml + # return the XML source for the node and each of its descendants + def xml() + ret = _getproperty(27, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BOOL parsed + # has sub-tree been completely parsed + def parsed() + ret = _getproperty(31, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR namespaceURI + # the URI for the namespace applying to the node + def namespaceURI() + ret = _getproperty(32, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR prefix + # the prefix for the namespace applying to the node + def prefix() + ret = _getproperty(33, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR baseName + # the base name of the node (nodename with the prefix stripped off) + def baseName() + ret = _getproperty(34, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR target + # the target + def target() + ret = _getproperty(127, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR data + # the data + def data() + ret = _getproperty(128, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID nodeValue + # value stored in the node + def nodeValue=(arg0) + ret = _setproperty(3, [arg0], [VT_VARIANT]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID text + # text content of the node and subtree + def text=(arg0) + ret = _setproperty(24, [arg0], [VT_BSTR]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID nodeTypedValue + # get the strongly typed value of the node + def nodeTypedValue=(arg0) + ret = _setproperty(25, [arg0], [VT_VARIANT]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID dataType + # the data type of the node + def dataType=(arg0) + ret = _setproperty(26, [arg0], [VT_VARIANT]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID data + # the data + def data=(arg0) + ret = _setproperty(128, [arg0], [VT_BSTR]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode insertBefore + # insert a child node + # IXMLDOMNode arg0 --- newChild [IN] + # VARIANT arg1 --- refChild [IN] + def insertBefore(arg0, arg1) + ret = _invoke(13, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode replaceChild + # replace a child node + # IXMLDOMNode arg0 --- newChild [IN] + # IXMLDOMNode arg1 --- oldChild [IN] + def replaceChild(arg0, arg1) + ret = _invoke(14, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_BYREF|VT_DISPATCH]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode removeChild + # remove a child node + # IXMLDOMNode arg0 --- childNode [IN] + def removeChild(arg0) + ret = _invoke(15, [arg0], [VT_BYREF|VT_DISPATCH]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode appendChild + # append a child node + # IXMLDOMNode arg0 --- newChild [IN] + def appendChild(arg0) + ret = _invoke(16, [arg0], [VT_BYREF|VT_DISPATCH]) + @lastargs = WIN32OLE::ARGV + ret + end + + # BOOL hasChildNodes + def hasChildNodes() + ret = _invoke(17, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode cloneNode + # BOOL arg0 --- deep [IN] + def cloneNode(arg0) + ret = _invoke(19, [arg0], [VT_BOOL]) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR transformNode + # apply the stylesheet to the subtree + # IXMLDOMNode arg0 --- stylesheet [IN] + def transformNode(arg0) + ret = _invoke(28, [arg0], [VT_BYREF|VT_DISPATCH]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNodeList selectNodes + # execute query on the subtree + # BSTR arg0 --- queryString [IN] + def selectNodes(arg0) + ret = _invoke(29, [arg0], [VT_BSTR]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode selectSingleNode + # execute query on the subtree + # BSTR arg0 --- queryString [IN] + def selectSingleNode(arg0) + ret = _invoke(30, [arg0], [VT_BSTR]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID transformNodeToObject + # apply the stylesheet to the subtree, returning the result through a document or a stream + # IXMLDOMNode arg0 --- stylesheet [IN] + # VARIANT arg1 --- outputObject [IN] + def transformNodeToObject(arg0, arg1) + ret = _invoke(35, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT]) + @lastargs = WIN32OLE::ARGV + ret + end +end + +# +module IXMLDOMEntityReference + include WIN32OLE::VARIANT + attr_reader :lastargs + + # BSTR nodeName + # name of the node + def nodeName() + ret = _getproperty(2, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # VARIANT nodeValue + # value stored in the node + def nodeValue() + ret = _getproperty(3, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # DOMNodeType nodeType + # the node's type + def nodeType() + ret = _getproperty(4, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode parentNode + # parent of the node + def parentNode() + ret = _getproperty(6, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNodeList childNodes + # the collection of the node's children + def childNodes() + ret = _getproperty(7, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode firstChild + # first child of the node + def firstChild() + ret = _getproperty(8, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode lastChild + # first child of the node + def lastChild() + ret = _getproperty(9, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode previousSibling + # left sibling of the node + def previousSibling() + ret = _getproperty(10, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode nextSibling + # right sibling of the node + def nextSibling() + ret = _getproperty(11, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNamedNodeMap attributes + # the collection of the node's attributes + def attributes() + ret = _getproperty(12, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMDocument ownerDocument + # document that contains the node + def ownerDocument() + ret = _getproperty(18, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR nodeTypeString + # the type of node in string form + def nodeTypeString() + ret = _getproperty(21, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR text + # text content of the node and subtree + def text() + ret = _getproperty(24, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BOOL specified + # indicates whether node is a default value + def specified() + ret = _getproperty(22, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode definition + # pointer to the definition of the node in the DTD or schema + def definition() + ret = _getproperty(23, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # VARIANT nodeTypedValue + # get the strongly typed value of the node + def nodeTypedValue() + ret = _getproperty(25, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # VARIANT dataType + # the data type of the node + def dataType() + ret = _getproperty(26, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR xml + # return the XML source for the node and each of its descendants + def xml() + ret = _getproperty(27, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BOOL parsed + # has sub-tree been completely parsed + def parsed() + ret = _getproperty(31, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR namespaceURI + # the URI for the namespace applying to the node + def namespaceURI() + ret = _getproperty(32, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR prefix + # the prefix for the namespace applying to the node + def prefix() + ret = _getproperty(33, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR baseName + # the base name of the node (nodename with the prefix stripped off) + def baseName() + ret = _getproperty(34, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID nodeValue + # value stored in the node + def nodeValue=(arg0) + ret = _setproperty(3, [arg0], [VT_VARIANT]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID text + # text content of the node and subtree + def text=(arg0) + ret = _setproperty(24, [arg0], [VT_BSTR]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID nodeTypedValue + # get the strongly typed value of the node + def nodeTypedValue=(arg0) + ret = _setproperty(25, [arg0], [VT_VARIANT]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID dataType + # the data type of the node + def dataType=(arg0) + ret = _setproperty(26, [arg0], [VT_VARIANT]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode insertBefore + # insert a child node + # IXMLDOMNode arg0 --- newChild [IN] + # VARIANT arg1 --- refChild [IN] + def insertBefore(arg0, arg1) + ret = _invoke(13, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode replaceChild + # replace a child node + # IXMLDOMNode arg0 --- newChild [IN] + # IXMLDOMNode arg1 --- oldChild [IN] + def replaceChild(arg0, arg1) + ret = _invoke(14, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_BYREF|VT_DISPATCH]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode removeChild + # remove a child node + # IXMLDOMNode arg0 --- childNode [IN] + def removeChild(arg0) + ret = _invoke(15, [arg0], [VT_BYREF|VT_DISPATCH]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode appendChild + # append a child node + # IXMLDOMNode arg0 --- newChild [IN] + def appendChild(arg0) + ret = _invoke(16, [arg0], [VT_BYREF|VT_DISPATCH]) + @lastargs = WIN32OLE::ARGV + ret + end + + # BOOL hasChildNodes + def hasChildNodes() + ret = _invoke(17, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode cloneNode + # BOOL arg0 --- deep [IN] + def cloneNode(arg0) + ret = _invoke(19, [arg0], [VT_BOOL]) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR transformNode + # apply the stylesheet to the subtree + # IXMLDOMNode arg0 --- stylesheet [IN] + def transformNode(arg0) + ret = _invoke(28, [arg0], [VT_BYREF|VT_DISPATCH]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNodeList selectNodes + # execute query on the subtree + # BSTR arg0 --- queryString [IN] + def selectNodes(arg0) + ret = _invoke(29, [arg0], [VT_BSTR]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode selectSingleNode + # execute query on the subtree + # BSTR arg0 --- queryString [IN] + def selectSingleNode(arg0) + ret = _invoke(30, [arg0], [VT_BSTR]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID transformNodeToObject + # apply the stylesheet to the subtree, returning the result through a document or a stream + # IXMLDOMNode arg0 --- stylesheet [IN] + # VARIANT arg1 --- outputObject [IN] + def transformNodeToObject(arg0, arg1) + ret = _invoke(35, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT]) + @lastargs = WIN32OLE::ARGV + ret + end +end + +# structure for reporting parser errors +module IXMLDOMParseError + include WIN32OLE::VARIANT + attr_reader :lastargs + + # I4 errorCode + # the error code + def errorCode() + ret = _getproperty(0, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR url + # the URL of the XML document containing the error + def url() + ret = _getproperty(179, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR reason + # the cause of the error + def reason() + ret = _getproperty(180, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR srcText + # the data where the error occurred + def srcText() + ret = _getproperty(181, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # I4 line + # the line number in the XML document where the error occurred + def line() + ret = _getproperty(182, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # I4 linepos + # the character position in the line containing the error + def linepos() + ret = _getproperty(183, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # I4 filepos + # the absolute file position in the XML document containing the error + def filepos() + ret = _getproperty(184, [], []) + @lastargs = WIN32OLE::ARGV + ret + end +end + +# +module IXMLDOMNotation + include WIN32OLE::VARIANT + attr_reader :lastargs + + # BSTR nodeName + # name of the node + def nodeName() + ret = _getproperty(2, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # VARIANT nodeValue + # value stored in the node + def nodeValue() + ret = _getproperty(3, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # DOMNodeType nodeType + # the node's type + def nodeType() + ret = _getproperty(4, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode parentNode + # parent of the node + def parentNode() + ret = _getproperty(6, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNodeList childNodes + # the collection of the node's children + def childNodes() + ret = _getproperty(7, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode firstChild + # first child of the node + def firstChild() + ret = _getproperty(8, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode lastChild + # first child of the node + def lastChild() + ret = _getproperty(9, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode previousSibling + # left sibling of the node + def previousSibling() + ret = _getproperty(10, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode nextSibling + # right sibling of the node + def nextSibling() + ret = _getproperty(11, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNamedNodeMap attributes + # the collection of the node's attributes + def attributes() + ret = _getproperty(12, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMDocument ownerDocument + # document that contains the node + def ownerDocument() + ret = _getproperty(18, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR nodeTypeString + # the type of node in string form + def nodeTypeString() + ret = _getproperty(21, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR text + # text content of the node and subtree + def text() + ret = _getproperty(24, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BOOL specified + # indicates whether node is a default value + def specified() + ret = _getproperty(22, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode definition + # pointer to the definition of the node in the DTD or schema + def definition() + ret = _getproperty(23, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # VARIANT nodeTypedValue + # get the strongly typed value of the node + def nodeTypedValue() + ret = _getproperty(25, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # VARIANT dataType + # the data type of the node + def dataType() + ret = _getproperty(26, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR xml + # return the XML source for the node and each of its descendants + def xml() + ret = _getproperty(27, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BOOL parsed + # has sub-tree been completely parsed + def parsed() + ret = _getproperty(31, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR namespaceURI + # the URI for the namespace applying to the node + def namespaceURI() + ret = _getproperty(32, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR prefix + # the prefix for the namespace applying to the node + def prefix() + ret = _getproperty(33, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR baseName + # the base name of the node (nodename with the prefix stripped off) + def baseName() + ret = _getproperty(34, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # VARIANT publicId + # the public ID + def publicId() + ret = _getproperty(136, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # VARIANT systemId + # the system ID + def systemId() + ret = _getproperty(137, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID nodeValue + # value stored in the node + def nodeValue=(arg0) + ret = _setproperty(3, [arg0], [VT_VARIANT]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID text + # text content of the node and subtree + def text=(arg0) + ret = _setproperty(24, [arg0], [VT_BSTR]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID nodeTypedValue + # get the strongly typed value of the node + def nodeTypedValue=(arg0) + ret = _setproperty(25, [arg0], [VT_VARIANT]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID dataType + # the data type of the node + def dataType=(arg0) + ret = _setproperty(26, [arg0], [VT_VARIANT]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode insertBefore + # insert a child node + # IXMLDOMNode arg0 --- newChild [IN] + # VARIANT arg1 --- refChild [IN] + def insertBefore(arg0, arg1) + ret = _invoke(13, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode replaceChild + # replace a child node + # IXMLDOMNode arg0 --- newChild [IN] + # IXMLDOMNode arg1 --- oldChild [IN] + def replaceChild(arg0, arg1) + ret = _invoke(14, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_BYREF|VT_DISPATCH]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode removeChild + # remove a child node + # IXMLDOMNode arg0 --- childNode [IN] + def removeChild(arg0) + ret = _invoke(15, [arg0], [VT_BYREF|VT_DISPATCH]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode appendChild + # append a child node + # IXMLDOMNode arg0 --- newChild [IN] + def appendChild(arg0) + ret = _invoke(16, [arg0], [VT_BYREF|VT_DISPATCH]) + @lastargs = WIN32OLE::ARGV + ret + end + + # BOOL hasChildNodes + def hasChildNodes() + ret = _invoke(17, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode cloneNode + # BOOL arg0 --- deep [IN] + def cloneNode(arg0) + ret = _invoke(19, [arg0], [VT_BOOL]) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR transformNode + # apply the stylesheet to the subtree + # IXMLDOMNode arg0 --- stylesheet [IN] + def transformNode(arg0) + ret = _invoke(28, [arg0], [VT_BYREF|VT_DISPATCH]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNodeList selectNodes + # execute query on the subtree + # BSTR arg0 --- queryString [IN] + def selectNodes(arg0) + ret = _invoke(29, [arg0], [VT_BSTR]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode selectSingleNode + # execute query on the subtree + # BSTR arg0 --- queryString [IN] + def selectSingleNode(arg0) + ret = _invoke(30, [arg0], [VT_BSTR]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID transformNodeToObject + # apply the stylesheet to the subtree, returning the result through a document or a stream + # IXMLDOMNode arg0 --- stylesheet [IN] + # VARIANT arg1 --- outputObject [IN] + def transformNodeToObject(arg0, arg1) + ret = _invoke(35, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT]) + @lastargs = WIN32OLE::ARGV + ret + end +end + +# +module IXMLDOMEntity + include WIN32OLE::VARIANT + attr_reader :lastargs + + # BSTR nodeName + # name of the node + def nodeName() + ret = _getproperty(2, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # VARIANT nodeValue + # value stored in the node + def nodeValue() + ret = _getproperty(3, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # DOMNodeType nodeType + # the node's type + def nodeType() + ret = _getproperty(4, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode parentNode + # parent of the node + def parentNode() + ret = _getproperty(6, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNodeList childNodes + # the collection of the node's children + def childNodes() + ret = _getproperty(7, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode firstChild + # first child of the node + def firstChild() + ret = _getproperty(8, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode lastChild + # first child of the node + def lastChild() + ret = _getproperty(9, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode previousSibling + # left sibling of the node + def previousSibling() + ret = _getproperty(10, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode nextSibling + # right sibling of the node + def nextSibling() + ret = _getproperty(11, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNamedNodeMap attributes + # the collection of the node's attributes + def attributes() + ret = _getproperty(12, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMDocument ownerDocument + # document that contains the node + def ownerDocument() + ret = _getproperty(18, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR nodeTypeString + # the type of node in string form + def nodeTypeString() + ret = _getproperty(21, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR text + # text content of the node and subtree + def text() + ret = _getproperty(24, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BOOL specified + # indicates whether node is a default value + def specified() + ret = _getproperty(22, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode definition + # pointer to the definition of the node in the DTD or schema + def definition() + ret = _getproperty(23, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # VARIANT nodeTypedValue + # get the strongly typed value of the node + def nodeTypedValue() + ret = _getproperty(25, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # VARIANT dataType + # the data type of the node + def dataType() + ret = _getproperty(26, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR xml + # return the XML source for the node and each of its descendants + def xml() + ret = _getproperty(27, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BOOL parsed + # has sub-tree been completely parsed + def parsed() + ret = _getproperty(31, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR namespaceURI + # the URI for the namespace applying to the node + def namespaceURI() + ret = _getproperty(32, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR prefix + # the prefix for the namespace applying to the node + def prefix() + ret = _getproperty(33, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR baseName + # the base name of the node (nodename with the prefix stripped off) + def baseName() + ret = _getproperty(34, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # VARIANT publicId + # the public ID + def publicId() + ret = _getproperty(140, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # VARIANT systemId + # the system ID + def systemId() + ret = _getproperty(141, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR notationName + # the name of the notation + def notationName() + ret = _getproperty(142, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID nodeValue + # value stored in the node + def nodeValue=(arg0) + ret = _setproperty(3, [arg0], [VT_VARIANT]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID text + # text content of the node and subtree + def text=(arg0) + ret = _setproperty(24, [arg0], [VT_BSTR]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID nodeTypedValue + # get the strongly typed value of the node + def nodeTypedValue=(arg0) + ret = _setproperty(25, [arg0], [VT_VARIANT]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID dataType + # the data type of the node + def dataType=(arg0) + ret = _setproperty(26, [arg0], [VT_VARIANT]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode insertBefore + # insert a child node + # IXMLDOMNode arg0 --- newChild [IN] + # VARIANT arg1 --- refChild [IN] + def insertBefore(arg0, arg1) + ret = _invoke(13, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode replaceChild + # replace a child node + # IXMLDOMNode arg0 --- newChild [IN] + # IXMLDOMNode arg1 --- oldChild [IN] + def replaceChild(arg0, arg1) + ret = _invoke(14, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_BYREF|VT_DISPATCH]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode removeChild + # remove a child node + # IXMLDOMNode arg0 --- childNode [IN] + def removeChild(arg0) + ret = _invoke(15, [arg0], [VT_BYREF|VT_DISPATCH]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode appendChild + # append a child node + # IXMLDOMNode arg0 --- newChild [IN] + def appendChild(arg0) + ret = _invoke(16, [arg0], [VT_BYREF|VT_DISPATCH]) + @lastargs = WIN32OLE::ARGV + ret + end + + # BOOL hasChildNodes + def hasChildNodes() + ret = _invoke(17, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode cloneNode + # BOOL arg0 --- deep [IN] + def cloneNode(arg0) + ret = _invoke(19, [arg0], [VT_BOOL]) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR transformNode + # apply the stylesheet to the subtree + # IXMLDOMNode arg0 --- stylesheet [IN] + def transformNode(arg0) + ret = _invoke(28, [arg0], [VT_BYREF|VT_DISPATCH]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNodeList selectNodes + # execute query on the subtree + # BSTR arg0 --- queryString [IN] + def selectNodes(arg0) + ret = _invoke(29, [arg0], [VT_BSTR]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode selectSingleNode + # execute query on the subtree + # BSTR arg0 --- queryString [IN] + def selectSingleNode(arg0) + ret = _invoke(30, [arg0], [VT_BSTR]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID transformNodeToObject + # apply the stylesheet to the subtree, returning the result through a document or a stream + # IXMLDOMNode arg0 --- stylesheet [IN] + # VARIANT arg1 --- outputObject [IN] + def transformNodeToObject(arg0, arg1) + ret = _invoke(35, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT]) + @lastargs = WIN32OLE::ARGV + ret + end +end + +# XTL runtime object +module IXTLRuntime + include WIN32OLE::VARIANT + attr_reader :lastargs + + # BSTR nodeName + # name of the node + def nodeName() + ret = _getproperty(2, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # VARIANT nodeValue + # value stored in the node + def nodeValue() + ret = _getproperty(3, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # DOMNodeType nodeType + # the node's type + def nodeType() + ret = _getproperty(4, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode parentNode + # parent of the node + def parentNode() + ret = _getproperty(6, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNodeList childNodes + # the collection of the node's children + def childNodes() + ret = _getproperty(7, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode firstChild + # first child of the node + def firstChild() + ret = _getproperty(8, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode lastChild + # first child of the node + def lastChild() + ret = _getproperty(9, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode previousSibling + # left sibling of the node + def previousSibling() + ret = _getproperty(10, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode nextSibling + # right sibling of the node + def nextSibling() + ret = _getproperty(11, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNamedNodeMap attributes + # the collection of the node's attributes + def attributes() + ret = _getproperty(12, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMDocument ownerDocument + # document that contains the node + def ownerDocument() + ret = _getproperty(18, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR nodeTypeString + # the type of node in string form + def nodeTypeString() + ret = _getproperty(21, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR text + # text content of the node and subtree + def text() + ret = _getproperty(24, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BOOL specified + # indicates whether node is a default value + def specified() + ret = _getproperty(22, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode definition + # pointer to the definition of the node in the DTD or schema + def definition() + ret = _getproperty(23, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # VARIANT nodeTypedValue + # get the strongly typed value of the node + def nodeTypedValue() + ret = _getproperty(25, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # VARIANT dataType + # the data type of the node + def dataType() + ret = _getproperty(26, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR xml + # return the XML source for the node and each of its descendants + def xml() + ret = _getproperty(27, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BOOL parsed + # has sub-tree been completely parsed + def parsed() + ret = _getproperty(31, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR namespaceURI + # the URI for the namespace applying to the node + def namespaceURI() + ret = _getproperty(32, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR prefix + # the prefix for the namespace applying to the node + def prefix() + ret = _getproperty(33, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR baseName + # the base name of the node (nodename with the prefix stripped off) + def baseName() + ret = _getproperty(34, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID nodeValue + # value stored in the node + def nodeValue=(arg0) + ret = _setproperty(3, [arg0], [VT_VARIANT]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID text + # text content of the node and subtree + def text=(arg0) + ret = _setproperty(24, [arg0], [VT_BSTR]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID nodeTypedValue + # get the strongly typed value of the node + def nodeTypedValue=(arg0) + ret = _setproperty(25, [arg0], [VT_VARIANT]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID dataType + # the data type of the node + def dataType=(arg0) + ret = _setproperty(26, [arg0], [VT_VARIANT]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode insertBefore + # insert a child node + # IXMLDOMNode arg0 --- newChild [IN] + # VARIANT arg1 --- refChild [IN] + def insertBefore(arg0, arg1) + ret = _invoke(13, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode replaceChild + # replace a child node + # IXMLDOMNode arg0 --- newChild [IN] + # IXMLDOMNode arg1 --- oldChild [IN] + def replaceChild(arg0, arg1) + ret = _invoke(14, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_BYREF|VT_DISPATCH]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode removeChild + # remove a child node + # IXMLDOMNode arg0 --- childNode [IN] + def removeChild(arg0) + ret = _invoke(15, [arg0], [VT_BYREF|VT_DISPATCH]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode appendChild + # append a child node + # IXMLDOMNode arg0 --- newChild [IN] + def appendChild(arg0) + ret = _invoke(16, [arg0], [VT_BYREF|VT_DISPATCH]) + @lastargs = WIN32OLE::ARGV + ret + end + + # BOOL hasChildNodes + def hasChildNodes() + ret = _invoke(17, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode cloneNode + # BOOL arg0 --- deep [IN] + def cloneNode(arg0) + ret = _invoke(19, [arg0], [VT_BOOL]) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR transformNode + # apply the stylesheet to the subtree + # IXMLDOMNode arg0 --- stylesheet [IN] + def transformNode(arg0) + ret = _invoke(28, [arg0], [VT_BYREF|VT_DISPATCH]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNodeList selectNodes + # execute query on the subtree + # BSTR arg0 --- queryString [IN] + def selectNodes(arg0) + ret = _invoke(29, [arg0], [VT_BSTR]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode selectSingleNode + # execute query on the subtree + # BSTR arg0 --- queryString [IN] + def selectSingleNode(arg0) + ret = _invoke(30, [arg0], [VT_BSTR]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID transformNodeToObject + # apply the stylesheet to the subtree, returning the result through a document or a stream + # IXMLDOMNode arg0 --- stylesheet [IN] + # VARIANT arg1 --- outputObject [IN] + def transformNodeToObject(arg0, arg1) + ret = _invoke(35, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT]) + @lastargs = WIN32OLE::ARGV + ret + end + + # I4 uniqueID + # IXMLDOMNode arg0 --- pNode [IN] + def uniqueID(arg0) + ret = _invoke(187, [arg0], [VT_BYREF|VT_DISPATCH]) + @lastargs = WIN32OLE::ARGV + ret + end + + # I4 depth + # IXMLDOMNode arg0 --- pNode [IN] + def depth(arg0) + ret = _invoke(188, [arg0], [VT_BYREF|VT_DISPATCH]) + @lastargs = WIN32OLE::ARGV + ret + end + + # I4 childNumber + # IXMLDOMNode arg0 --- pNode [IN] + def childNumber(arg0) + ret = _invoke(189, [arg0], [VT_BYREF|VT_DISPATCH]) + @lastargs = WIN32OLE::ARGV + ret + end + + # I4 ancestorChildNumber + # BSTR arg0 --- bstrNodeName [IN] + # IXMLDOMNode arg1 --- pNode [IN] + def ancestorChildNumber(arg0, arg1) + ret = _invoke(190, [arg0, arg1], [VT_BSTR, VT_BYREF|VT_DISPATCH]) + @lastargs = WIN32OLE::ARGV + ret + end + + # I4 absoluteChildNumber + # IXMLDOMNode arg0 --- pNode [IN] + def absoluteChildNumber(arg0) + ret = _invoke(191, [arg0], [VT_BYREF|VT_DISPATCH]) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR formatIndex + # I4 arg0 --- lIndex [IN] + # BSTR arg1 --- bstrFormat [IN] + def formatIndex(arg0, arg1) + ret = _invoke(192, [arg0, arg1], [VT_I4, VT_BSTR]) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR formatNumber + # R8 arg0 --- dblNumber [IN] + # BSTR arg1 --- bstrFormat [IN] + def formatNumber(arg0, arg1) + ret = _invoke(193, [arg0, arg1], [VT_R8, VT_BSTR]) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR formatDate + # VARIANT arg0 --- varDate [IN] + # BSTR arg1 --- bstrFormat [IN] + # VARIANT arg2 --- varDestLocale [IN] + def formatDate(arg0, arg1, arg2=nil) + ret = _invoke(194, [arg0, arg1, arg2], [VT_VARIANT, VT_BSTR, VT_VARIANT]) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR formatTime + # VARIANT arg0 --- varTime [IN] + # BSTR arg1 --- bstrFormat [IN] + # VARIANT arg2 --- varDestLocale [IN] + def formatTime(arg0, arg1, arg2=nil) + ret = _invoke(195, [arg0, arg1, arg2], [VT_VARIANT, VT_BSTR, VT_VARIANT]) + @lastargs = WIN32OLE::ARGV + ret + end +end + +# W3C-DOM XML Document +class Microsoft_XMLDOM_1_0 # DOMDocument + include WIN32OLE::VARIANT + attr_reader :lastargs + attr_reader :dispatch + attr_reader :clsid + attr_reader :progid + + def initialize(obj = nil) + @clsid = "{2933BF90-7B36-11D2-B20E-00C04F983E60}" + @progid = "Microsoft.XMLDOM.1.0" + if obj.nil? + @dispatch = WIN32OLE.new @progid + else + @dispatch = obj + end + end + + def method_missing(cmd, *arg) + @dispatch.method_missing(cmd, *arg) + end + + # BSTR nodeName + # name of the node + def nodeName() + ret = @dispatch._getproperty(2, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # VARIANT nodeValue + # value stored in the node + def nodeValue() + ret = @dispatch._getproperty(3, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # DOMNodeType nodeType + # the node's type + def nodeType() + ret = @dispatch._getproperty(4, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode parentNode + # parent of the node + def parentNode() + ret = @dispatch._getproperty(6, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNodeList childNodes + # the collection of the node's children + def childNodes() + ret = @dispatch._getproperty(7, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode firstChild + # first child of the node + def firstChild() + ret = @dispatch._getproperty(8, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode lastChild + # first child of the node + def lastChild() + ret = @dispatch._getproperty(9, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode previousSibling + # left sibling of the node + def previousSibling() + ret = @dispatch._getproperty(10, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode nextSibling + # right sibling of the node + def nextSibling() + ret = @dispatch._getproperty(11, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNamedNodeMap attributes + # the collection of the node's attributes + def attributes() + ret = @dispatch._getproperty(12, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMDocument ownerDocument + # document that contains the node + def ownerDocument() + ret = @dispatch._getproperty(18, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR nodeTypeString + # the type of node in string form + def nodeTypeString() + ret = @dispatch._getproperty(21, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR text + # text content of the node and subtree + def text() + ret = @dispatch._getproperty(24, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BOOL specified + # indicates whether node is a default value + def specified() + ret = @dispatch._getproperty(22, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode definition + # pointer to the definition of the node in the DTD or schema + def definition() + ret = @dispatch._getproperty(23, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # VARIANT nodeTypedValue + # get the strongly typed value of the node + def nodeTypedValue() + ret = @dispatch._getproperty(25, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # VARIANT dataType + # the data type of the node + def dataType() + ret = @dispatch._getproperty(26, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR xml + # return the XML source for the node and each of its descendants + def xml() + ret = @dispatch._getproperty(27, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BOOL parsed + # has sub-tree been completely parsed + def parsed() + ret = @dispatch._getproperty(31, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR namespaceURI + # the URI for the namespace applying to the node + def namespaceURI() + ret = @dispatch._getproperty(32, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR prefix + # the prefix for the namespace applying to the node + def prefix() + ret = @dispatch._getproperty(33, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR baseName + # the base name of the node (nodename with the prefix stripped off) + def baseName() + ret = @dispatch._getproperty(34, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMDocumentType doctype + # node corresponding to the DOCTYPE + def doctype() + ret = @dispatch._getproperty(38, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMImplementation implementation + # info on this DOM implementation + def implementation() + ret = @dispatch._getproperty(39, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMElement documentElement + # the root of the tree + def documentElement() + ret = @dispatch._getproperty(40, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # I4 readyState + # get the state of the XML document + def readyState() + ret = @dispatch._getproperty(-525, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMParseError parseError + # get the last parser error + def parseError() + ret = @dispatch._getproperty(59, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR url + # get the URL for the loaded XML document + def url() + ret = @dispatch._getproperty(60, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BOOL async + # flag for asynchronous download + def async() + ret = @dispatch._getproperty(61, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BOOL validateOnParse + # indicates whether the parser performs validation + def validateOnParse() + ret = @dispatch._getproperty(65, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BOOL resolveExternals + # indicates whether the parser resolves references to external DTD/Entities/Schema + def resolveExternals() + ret = @dispatch._getproperty(66, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BOOL preserveWhiteSpace + # indicates whether the parser preserves whitespace + def preserveWhiteSpace() + ret = @dispatch._getproperty(67, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID nodeValue + # value stored in the node + def nodeValue=(arg0) + ret = @dispatch._setproperty(3, [arg0], [VT_VARIANT]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID text + # text content of the node and subtree + def text=(arg0) + ret = @dispatch._setproperty(24, [arg0], [VT_BSTR]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID nodeTypedValue + # get the strongly typed value of the node + def nodeTypedValue=(arg0) + ret = @dispatch._setproperty(25, [arg0], [VT_VARIANT]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID dataType + # the data type of the node + def dataType=(arg0) + ret = @dispatch._setproperty(26, [arg0], [VT_VARIANT]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID async + # flag for asynchronous download + def async=(arg0) + ret = @dispatch._setproperty(61, [arg0], [VT_BOOL]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID validateOnParse + # indicates whether the parser performs validation + def validateOnParse=(arg0) + ret = @dispatch._setproperty(65, [arg0], [VT_BOOL]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID resolveExternals + # indicates whether the parser resolves references to external DTD/Entities/Schema + def resolveExternals=(arg0) + ret = @dispatch._setproperty(66, [arg0], [VT_BOOL]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID preserveWhiteSpace + # indicates whether the parser preserves whitespace + def preserveWhiteSpace=(arg0) + ret = @dispatch._setproperty(67, [arg0], [VT_BOOL]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID onreadystatechange + # register a readystatechange event handler + def onreadystatechange=(arg0) + ret = @dispatch._setproperty(68, [arg0], [VT_VARIANT]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID ondataavailable + # register an ondataavailable event handler + def ondataavailable=(arg0) + ret = @dispatch._setproperty(69, [arg0], [VT_VARIANT]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID ontransformnode + # register an ontransformnode event handler + def ontransformnode=(arg0) + ret = @dispatch._setproperty(70, [arg0], [VT_VARIANT]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode insertBefore + # insert a child node + # IXMLDOMNode arg0 --- newChild [IN] + # VARIANT arg1 --- refChild [IN] + def insertBefore(arg0, arg1) + ret = @dispatch._invoke(13, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode replaceChild + # replace a child node + # IXMLDOMNode arg0 --- newChild [IN] + # IXMLDOMNode arg1 --- oldChild [IN] + def replaceChild(arg0, arg1) + ret = @dispatch._invoke(14, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_BYREF|VT_DISPATCH]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode removeChild + # remove a child node + # IXMLDOMNode arg0 --- childNode [IN] + def removeChild(arg0) + ret = @dispatch._invoke(15, [arg0], [VT_BYREF|VT_DISPATCH]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode appendChild + # append a child node + # IXMLDOMNode arg0 --- newChild [IN] + def appendChild(arg0) + ret = @dispatch._invoke(16, [arg0], [VT_BYREF|VT_DISPATCH]) + @lastargs = WIN32OLE::ARGV + ret + end + + # BOOL hasChildNodes + def hasChildNodes() + ret = @dispatch._invoke(17, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode cloneNode + # BOOL arg0 --- deep [IN] + def cloneNode(arg0) + ret = @dispatch._invoke(19, [arg0], [VT_BOOL]) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR transformNode + # apply the stylesheet to the subtree + # IXMLDOMNode arg0 --- stylesheet [IN] + def transformNode(arg0) + ret = @dispatch._invoke(28, [arg0], [VT_BYREF|VT_DISPATCH]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNodeList selectNodes + # execute query on the subtree + # BSTR arg0 --- queryString [IN] + def selectNodes(arg0) + ret = @dispatch._invoke(29, [arg0], [VT_BSTR]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode selectSingleNode + # execute query on the subtree + # BSTR arg0 --- queryString [IN] + def selectSingleNode(arg0) + ret = @dispatch._invoke(30, [arg0], [VT_BSTR]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID transformNodeToObject + # apply the stylesheet to the subtree, returning the result through a document or a stream + # IXMLDOMNode arg0 --- stylesheet [IN] + # VARIANT arg1 --- outputObject [IN] + def transformNodeToObject(arg0, arg1) + ret = @dispatch._invoke(35, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMElement createElement + # create an Element node + # BSTR arg0 --- tagName [IN] + def createElement(arg0) + ret = @dispatch._invoke(41, [arg0], [VT_BSTR]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMDocumentFragment createDocumentFragment + # create a DocumentFragment node + def createDocumentFragment() + ret = @dispatch._invoke(42, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMText createTextNode + # create a text node + # BSTR arg0 --- data [IN] + def createTextNode(arg0) + ret = @dispatch._invoke(43, [arg0], [VT_BSTR]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMComment createComment + # create a comment node + # BSTR arg0 --- data [IN] + def createComment(arg0) + ret = @dispatch._invoke(44, [arg0], [VT_BSTR]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMCDATASection createCDATASection + # create a CDATA section node + # BSTR arg0 --- data [IN] + def createCDATASection(arg0) + ret = @dispatch._invoke(45, [arg0], [VT_BSTR]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMProcessingInstruction createProcessingInstruction + # create a processing instruction node + # BSTR arg0 --- target [IN] + # BSTR arg1 --- data [IN] + def createProcessingInstruction(arg0, arg1) + ret = @dispatch._invoke(46, [arg0, arg1], [VT_BSTR, VT_BSTR]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMAttribute createAttribute + # create an attribute node + # BSTR arg0 --- name [IN] + def createAttribute(arg0) + ret = @dispatch._invoke(47, [arg0], [VT_BSTR]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMEntityReference createEntityReference + # create an entity reference node + # BSTR arg0 --- name [IN] + def createEntityReference(arg0) + ret = @dispatch._invoke(49, [arg0], [VT_BSTR]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNodeList getElementsByTagName + # build a list of elements by name + # BSTR arg0 --- tagName [IN] + def getElementsByTagName(arg0) + ret = @dispatch._invoke(50, [arg0], [VT_BSTR]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode createNode + # create a node of the specified node type and name + # VARIANT arg0 --- type [IN] + # BSTR arg1 --- name [IN] + # BSTR arg2 --- namespaceURI [IN] + def createNode(arg0, arg1, arg2) + ret = @dispatch._invoke(54, [arg0, arg1, arg2], [VT_VARIANT, VT_BSTR, VT_BSTR]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode nodeFromID + # retrieve node from it's ID + # BSTR arg0 --- idString [IN] + def nodeFromID(arg0) + ret = @dispatch._invoke(56, [arg0], [VT_BSTR]) + @lastargs = WIN32OLE::ARGV + ret + end + + # BOOL load + # load document from the specified XML source + # VARIANT arg0 --- xmlSource [IN] + def load(arg0) + ret = @dispatch._invoke(58, [arg0], [VT_VARIANT]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID abort + # abort an asynchronous download + def abort() + ret = @dispatch._invoke(62, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BOOL loadXML + # load the document from a string + # BSTR arg0 --- bstrXML [IN] + def loadXML(arg0) + ret = @dispatch._invoke(63, [arg0], [VT_BSTR]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID save + # save the document to a specified desination + # VARIANT arg0 --- desination [IN] + def save(arg0) + ret = @dispatch._invoke(64, [arg0], [VT_VARIANT]) + @lastargs = WIN32OLE::ARGV + ret + end + + # HRESULT ondataavailable EVENT in XMLDOMDocumentEvents + def ondataavailable() + ret = @dispatch._invoke(198, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # HRESULT onreadystatechange EVENT in XMLDOMDocumentEvents + def onreadystatechange() + ret = @dispatch._invoke(-609, [], []) + @lastargs = WIN32OLE::ARGV + ret + end +end + +# W3C-DOM XML Document (Apartment) +class Microsoft_FreeThreadedXMLDOM_1_0 # DOMFreeThreadedDocument + include WIN32OLE::VARIANT + attr_reader :lastargs + attr_reader :dispatch + attr_reader :clsid + attr_reader :progid + + def initialize(obj = nil) + @clsid = "{2933BF91-7B36-11D2-B20E-00C04F983E60}" + @progid = "Microsoft.FreeThreadedXMLDOM.1.0" + if obj.nil? + @dispatch = WIN32OLE.new @progid + else + @dispatch = obj + end + end + + def method_missing(cmd, *arg) + @dispatch.method_missing(cmd, *arg) + end + + # BSTR nodeName + # name of the node + def nodeName() + ret = @dispatch._getproperty(2, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # VARIANT nodeValue + # value stored in the node + def nodeValue() + ret = @dispatch._getproperty(3, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # DOMNodeType nodeType + # the node's type + def nodeType() + ret = @dispatch._getproperty(4, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode parentNode + # parent of the node + def parentNode() + ret = @dispatch._getproperty(6, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNodeList childNodes + # the collection of the node's children + def childNodes() + ret = @dispatch._getproperty(7, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode firstChild + # first child of the node + def firstChild() + ret = @dispatch._getproperty(8, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode lastChild + # first child of the node + def lastChild() + ret = @dispatch._getproperty(9, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode previousSibling + # left sibling of the node + def previousSibling() + ret = @dispatch._getproperty(10, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode nextSibling + # right sibling of the node + def nextSibling() + ret = @dispatch._getproperty(11, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNamedNodeMap attributes + # the collection of the node's attributes + def attributes() + ret = @dispatch._getproperty(12, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMDocument ownerDocument + # document that contains the node + def ownerDocument() + ret = @dispatch._getproperty(18, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR nodeTypeString + # the type of node in string form + def nodeTypeString() + ret = @dispatch._getproperty(21, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR text + # text content of the node and subtree + def text() + ret = @dispatch._getproperty(24, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BOOL specified + # indicates whether node is a default value + def specified() + ret = @dispatch._getproperty(22, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode definition + # pointer to the definition of the node in the DTD or schema + def definition() + ret = @dispatch._getproperty(23, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # VARIANT nodeTypedValue + # get the strongly typed value of the node + def nodeTypedValue() + ret = @dispatch._getproperty(25, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # VARIANT dataType + # the data type of the node + def dataType() + ret = @dispatch._getproperty(26, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR xml + # return the XML source for the node and each of its descendants + def xml() + ret = @dispatch._getproperty(27, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BOOL parsed + # has sub-tree been completely parsed + def parsed() + ret = @dispatch._getproperty(31, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR namespaceURI + # the URI for the namespace applying to the node + def namespaceURI() + ret = @dispatch._getproperty(32, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR prefix + # the prefix for the namespace applying to the node + def prefix() + ret = @dispatch._getproperty(33, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR baseName + # the base name of the node (nodename with the prefix stripped off) + def baseName() + ret = @dispatch._getproperty(34, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMDocumentType doctype + # node corresponding to the DOCTYPE + def doctype() + ret = @dispatch._getproperty(38, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMImplementation implementation + # info on this DOM implementation + def implementation() + ret = @dispatch._getproperty(39, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMElement documentElement + # the root of the tree + def documentElement() + ret = @dispatch._getproperty(40, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # I4 readyState + # get the state of the XML document + def readyState() + ret = @dispatch._getproperty(-525, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMParseError parseError + # get the last parser error + def parseError() + ret = @dispatch._getproperty(59, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR url + # get the URL for the loaded XML document + def url() + ret = @dispatch._getproperty(60, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BOOL async + # flag for asynchronous download + def async() + ret = @dispatch._getproperty(61, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BOOL validateOnParse + # indicates whether the parser performs validation + def validateOnParse() + ret = @dispatch._getproperty(65, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BOOL resolveExternals + # indicates whether the parser resolves references to external DTD/Entities/Schema + def resolveExternals() + ret = @dispatch._getproperty(66, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BOOL preserveWhiteSpace + # indicates whether the parser preserves whitespace + def preserveWhiteSpace() + ret = @dispatch._getproperty(67, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID nodeValue + # value stored in the node + def nodeValue=(arg0) + ret = @dispatch._setproperty(3, [arg0], [VT_VARIANT]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID text + # text content of the node and subtree + def text=(arg0) + ret = @dispatch._setproperty(24, [arg0], [VT_BSTR]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID nodeTypedValue + # get the strongly typed value of the node + def nodeTypedValue=(arg0) + ret = @dispatch._setproperty(25, [arg0], [VT_VARIANT]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID dataType + # the data type of the node + def dataType=(arg0) + ret = @dispatch._setproperty(26, [arg0], [VT_VARIANT]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID async + # flag for asynchronous download + def async=(arg0) + ret = @dispatch._setproperty(61, [arg0], [VT_BOOL]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID validateOnParse + # indicates whether the parser performs validation + def validateOnParse=(arg0) + ret = @dispatch._setproperty(65, [arg0], [VT_BOOL]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID resolveExternals + # indicates whether the parser resolves references to external DTD/Entities/Schema + def resolveExternals=(arg0) + ret = @dispatch._setproperty(66, [arg0], [VT_BOOL]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID preserveWhiteSpace + # indicates whether the parser preserves whitespace + def preserveWhiteSpace=(arg0) + ret = @dispatch._setproperty(67, [arg0], [VT_BOOL]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID onreadystatechange + # register a readystatechange event handler + def onreadystatechange=(arg0) + ret = @dispatch._setproperty(68, [arg0], [VT_VARIANT]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID ondataavailable + # register an ondataavailable event handler + def ondataavailable=(arg0) + ret = @dispatch._setproperty(69, [arg0], [VT_VARIANT]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID ontransformnode + # register an ontransformnode event handler + def ontransformnode=(arg0) + ret = @dispatch._setproperty(70, [arg0], [VT_VARIANT]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode insertBefore + # insert a child node + # IXMLDOMNode arg0 --- newChild [IN] + # VARIANT arg1 --- refChild [IN] + def insertBefore(arg0, arg1) + ret = @dispatch._invoke(13, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode replaceChild + # replace a child node + # IXMLDOMNode arg0 --- newChild [IN] + # IXMLDOMNode arg1 --- oldChild [IN] + def replaceChild(arg0, arg1) + ret = @dispatch._invoke(14, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_BYREF|VT_DISPATCH]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode removeChild + # remove a child node + # IXMLDOMNode arg0 --- childNode [IN] + def removeChild(arg0) + ret = @dispatch._invoke(15, [arg0], [VT_BYREF|VT_DISPATCH]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode appendChild + # append a child node + # IXMLDOMNode arg0 --- newChild [IN] + def appendChild(arg0) + ret = @dispatch._invoke(16, [arg0], [VT_BYREF|VT_DISPATCH]) + @lastargs = WIN32OLE::ARGV + ret + end + + # BOOL hasChildNodes + def hasChildNodes() + ret = @dispatch._invoke(17, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode cloneNode + # BOOL arg0 --- deep [IN] + def cloneNode(arg0) + ret = @dispatch._invoke(19, [arg0], [VT_BOOL]) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR transformNode + # apply the stylesheet to the subtree + # IXMLDOMNode arg0 --- stylesheet [IN] + def transformNode(arg0) + ret = @dispatch._invoke(28, [arg0], [VT_BYREF|VT_DISPATCH]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNodeList selectNodes + # execute query on the subtree + # BSTR arg0 --- queryString [IN] + def selectNodes(arg0) + ret = @dispatch._invoke(29, [arg0], [VT_BSTR]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode selectSingleNode + # execute query on the subtree + # BSTR arg0 --- queryString [IN] + def selectSingleNode(arg0) + ret = @dispatch._invoke(30, [arg0], [VT_BSTR]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID transformNodeToObject + # apply the stylesheet to the subtree, returning the result through a document or a stream + # IXMLDOMNode arg0 --- stylesheet [IN] + # VARIANT arg1 --- outputObject [IN] + def transformNodeToObject(arg0, arg1) + ret = @dispatch._invoke(35, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMElement createElement + # create an Element node + # BSTR arg0 --- tagName [IN] + def createElement(arg0) + ret = @dispatch._invoke(41, [arg0], [VT_BSTR]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMDocumentFragment createDocumentFragment + # create a DocumentFragment node + def createDocumentFragment() + ret = @dispatch._invoke(42, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMText createTextNode + # create a text node + # BSTR arg0 --- data [IN] + def createTextNode(arg0) + ret = @dispatch._invoke(43, [arg0], [VT_BSTR]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMComment createComment + # create a comment node + # BSTR arg0 --- data [IN] + def createComment(arg0) + ret = @dispatch._invoke(44, [arg0], [VT_BSTR]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMCDATASection createCDATASection + # create a CDATA section node + # BSTR arg0 --- data [IN] + def createCDATASection(arg0) + ret = @dispatch._invoke(45, [arg0], [VT_BSTR]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMProcessingInstruction createProcessingInstruction + # create a processing instruction node + # BSTR arg0 --- target [IN] + # BSTR arg1 --- data [IN] + def createProcessingInstruction(arg0, arg1) + ret = @dispatch._invoke(46, [arg0, arg1], [VT_BSTR, VT_BSTR]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMAttribute createAttribute + # create an attribute node + # BSTR arg0 --- name [IN] + def createAttribute(arg0) + ret = @dispatch._invoke(47, [arg0], [VT_BSTR]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMEntityReference createEntityReference + # create an entity reference node + # BSTR arg0 --- name [IN] + def createEntityReference(arg0) + ret = @dispatch._invoke(49, [arg0], [VT_BSTR]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNodeList getElementsByTagName + # build a list of elements by name + # BSTR arg0 --- tagName [IN] + def getElementsByTagName(arg0) + ret = @dispatch._invoke(50, [arg0], [VT_BSTR]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode createNode + # create a node of the specified node type and name + # VARIANT arg0 --- type [IN] + # BSTR arg1 --- name [IN] + # BSTR arg2 --- namespaceURI [IN] + def createNode(arg0, arg1, arg2) + ret = @dispatch._invoke(54, [arg0, arg1, arg2], [VT_VARIANT, VT_BSTR, VT_BSTR]) + @lastargs = WIN32OLE::ARGV + ret + end + + # IXMLDOMNode nodeFromID + # retrieve node from it's ID + # BSTR arg0 --- idString [IN] + def nodeFromID(arg0) + ret = @dispatch._invoke(56, [arg0], [VT_BSTR]) + @lastargs = WIN32OLE::ARGV + ret + end + + # BOOL load + # load document from the specified XML source + # VARIANT arg0 --- xmlSource [IN] + def load(arg0) + ret = @dispatch._invoke(58, [arg0], [VT_VARIANT]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID abort + # abort an asynchronous download + def abort() + ret = @dispatch._invoke(62, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BOOL loadXML + # load the document from a string + # BSTR arg0 --- bstrXML [IN] + def loadXML(arg0) + ret = @dispatch._invoke(63, [arg0], [VT_BSTR]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID save + # save the document to a specified desination + # VARIANT arg0 --- desination [IN] + def save(arg0) + ret = @dispatch._invoke(64, [arg0], [VT_VARIANT]) + @lastargs = WIN32OLE::ARGV + ret + end + + # HRESULT ondataavailable EVENT in XMLDOMDocumentEvents + def ondataavailable() + ret = @dispatch._invoke(198, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # HRESULT onreadystatechange EVENT in XMLDOMDocumentEvents + def onreadystatechange() + ret = @dispatch._invoke(-609, [], []) + @lastargs = WIN32OLE::ARGV + ret + end +end + +# IXMLHttpRequest Interface +module IXMLHttpRequest + include WIN32OLE::VARIANT + attr_reader :lastargs + + # I4 status + # Get HTTP status code + def status() + ret = _getproperty(7, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR statusText + # Get HTTP status text + def statusText() + ret = _getproperty(8, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # DISPATCH responseXML + # Get response body + def responseXML() + ret = _getproperty(9, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR responseText + # Get response body + def responseText() + ret = _getproperty(10, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # VARIANT responseBody + # Get response body + def responseBody() + ret = _getproperty(11, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # VARIANT responseStream + # Get response body + def responseStream() + ret = _getproperty(12, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # I4 readyState + # Get ready state + def readyState() + ret = _getproperty(13, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID onreadystatechange + # Register a complete event handler + def onreadystatechange=(arg0) + ret = _setproperty(14, [arg0], [VT_VARIANT]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID open + # Open HTTP connection + # BSTR arg0 --- bstrMethod [IN] + # BSTR arg1 --- bstrUrl [IN] + # VARIANT arg2 --- varAsync [IN] + # VARIANT arg3 --- bstrUser [IN] + # VARIANT arg4 --- bstrPassword [IN] + def open(arg0, arg1, arg2=nil, arg3=nil, arg4=nil) + ret = _invoke(1, [arg0, arg1, arg2, arg3, arg4], [VT_BSTR, VT_BSTR, VT_VARIANT, VT_VARIANT, VT_VARIANT]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID setRequestHeader + # Add HTTP request header + # BSTR arg0 --- bstrHeader [IN] + # BSTR arg1 --- bstrValue [IN] + def setRequestHeader(arg0, arg1) + ret = _invoke(2, [arg0, arg1], [VT_BSTR, VT_BSTR]) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR getResponseHeader + # Get HTTP response header + # BSTR arg0 --- bstrHeader [IN] + def getResponseHeader(arg0) + ret = _invoke(3, [arg0], [VT_BSTR]) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR getAllResponseHeaders + # Get all HTTP response headers + def getAllResponseHeaders() + ret = _invoke(4, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID send + # Send HTTP request + # VARIANT arg0 --- varBody [IN] + def send(arg0=nil) + ret = _invoke(5, [arg0], [VT_VARIANT]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID abort + # Abort HTTP request + def abort() + ret = _invoke(6, [], []) + @lastargs = WIN32OLE::ARGV + ret + end +end + +# XML HTTP Request class. +class Microsoft_XMLHTTP_1 # XMLHTTPRequest + include WIN32OLE::VARIANT + attr_reader :lastargs + attr_reader :dispatch + attr_reader :clsid + attr_reader :progid + + def initialize(obj = nil) + @clsid = "{ED8C108E-4349-11D2-91A4-00C04F7969E8}" + @progid = "Microsoft.XMLHTTP.1" + if obj.nil? + @dispatch = WIN32OLE.new @progid + else + @dispatch = obj + end + end + + def method_missing(cmd, *arg) + @dispatch.method_missing(cmd, *arg) + end + + # I4 status + # Get HTTP status code + def status() + ret = @dispatch._getproperty(7, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR statusText + # Get HTTP status text + def statusText() + ret = @dispatch._getproperty(8, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # DISPATCH responseXML + # Get response body + def responseXML() + ret = @dispatch._getproperty(9, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR responseText + # Get response body + def responseText() + ret = @dispatch._getproperty(10, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # VARIANT responseBody + # Get response body + def responseBody() + ret = @dispatch._getproperty(11, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # VARIANT responseStream + # Get response body + def responseStream() + ret = @dispatch._getproperty(12, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # I4 readyState + # Get ready state + def readyState() + ret = @dispatch._getproperty(13, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID onreadystatechange + # Register a complete event handler + def onreadystatechange=(arg0) + ret = @dispatch._setproperty(14, [arg0], [VT_VARIANT]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID open + # Open HTTP connection + # BSTR arg0 --- bstrMethod [IN] + # BSTR arg1 --- bstrUrl [IN] + # VARIANT arg2 --- varAsync [IN] + # VARIANT arg3 --- bstrUser [IN] + # VARIANT arg4 --- bstrPassword [IN] + def open(arg0, arg1, arg2=nil, arg3=nil, arg4=nil) + ret = @dispatch._invoke(1, [arg0, arg1, arg2, arg3, arg4], [VT_BSTR, VT_BSTR, VT_VARIANT, VT_VARIANT, VT_VARIANT]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID setRequestHeader + # Add HTTP request header + # BSTR arg0 --- bstrHeader [IN] + # BSTR arg1 --- bstrValue [IN] + def setRequestHeader(arg0, arg1) + ret = @dispatch._invoke(2, [arg0, arg1], [VT_BSTR, VT_BSTR]) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR getResponseHeader + # Get HTTP response header + # BSTR arg0 --- bstrHeader [IN] + def getResponseHeader(arg0) + ret = @dispatch._invoke(3, [arg0], [VT_BSTR]) + @lastargs = WIN32OLE::ARGV + ret + end + + # BSTR getAllResponseHeaders + # Get all HTTP response headers + def getAllResponseHeaders() + ret = @dispatch._invoke(4, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID send + # Send HTTP request + # VARIANT arg0 --- varBody [IN] + def send(arg0=nil) + ret = @dispatch._invoke(5, [arg0], [VT_VARIANT]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID abort + # Abort HTTP request + def abort() + ret = @dispatch._invoke(6, [], []) + @lastargs = WIN32OLE::ARGV + ret + end +end + +# XML Data Source Object +class Microsoft_XMLDSO_1_0 # XMLDSOControl + include WIN32OLE::VARIANT + attr_reader :lastargs + attr_reader :dispatch + attr_reader :clsid + attr_reader :progid + + def initialize(obj = nil) + @clsid = "{550DDA30-0541-11D2-9CA9-0060B0EC3D39}" + @progid = "Microsoft.XMLDSO.1.0" + if obj.nil? + @dispatch = WIN32OLE.new @progid + else + @dispatch = obj + end + end + + def method_missing(cmd, *arg) + @dispatch.method_missing(cmd, *arg) + end + + # IXMLDOMDocument XMLDocument + def XMLDocument() + ret = @dispatch._getproperty(65537, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # I4 JavaDSOCompatible + def JavaDSOCompatible() + ret = @dispatch._getproperty(65538, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # I4 readyState + def readyState() + ret = @dispatch._getproperty(-525, [], []) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID XMLDocument + def XMLDocument=(arg0) + ret = @dispatch._setproperty(65537, [arg0], [VT_BYREF|VT_DISPATCH]) + @lastargs = WIN32OLE::ARGV + ret + end + + # VOID JavaDSOCompatible + def JavaDSOCompatible=(arg0) + ret = @dispatch._setproperty(65538, [arg0], [VT_I4]) + @lastargs = WIN32OLE::ARGV + ret + end +end + +# Constants that define types for IXMLElement. +module OLEtagXMLEMEM_TYPE + include WIN32OLE::VARIANT + attr_reader :lastargs + XMLELEMTYPE_ELEMENT = 0 + XMLELEMTYPE_TEXT = 1 + XMLELEMTYPE_COMMENT = 2 + XMLELEMTYPE_DOCUMENT = 3 + XMLELEMTYPE_DTD = 4 + XMLELEMTYPE_PI = 5 + XMLELEMTYPE_OTHER = 6 +end + +# XMLDocument extends IXML Document. It is obsolete. You should use DOMDocument. This object should not be confused with the XMLDocument property on the XML data island. +class Msxml # XMLDocument + include WIN32OLE::VARIANT + attr_reader :lastargs + attr_reader :dispatch + attr_reader :clsid + attr_reader :progid + + def initialize(obj = nil) + @clsid = "{CFC399AF-D876-11D0-9C10-00C04FC99C8E}" + @progid = "Msxml" + if obj.nil? + @dispatch = WIN32OLE.new @progid + else + @dispatch = obj + end + end + + def method_missing(cmd, *arg) + @dispatch.method_missing(cmd, *arg) + end + + # HRESULT url + # set URL to load an XML document from the URL. + # BSTR arg0 --- p [IN] + def url=(arg0) + ret = @dispatch._setproperty(65641, [arg0], [VT_BSTR, VT_HRESULT]) + @lastargs = WIN32OLE::ARGV + ret + end + + # HRESULT charset + # get encoding. + # BSTR arg0 --- p [IN] + def charset=(arg0) + ret = @dispatch._setproperty(65645, [arg0], [VT_BSTR, VT_HRESULT]) + @lastargs = WIN32OLE::ARGV + ret + end + + # HRESULT async + # get asynchronous loading flag. + # BOOL arg0 --- pf [IN] + def async=(arg0) + ret = @dispatch._setproperty(65649, [arg0], [VT_BOOL, VT_HRESULT]) + @lastargs = WIN32OLE::ARGV + ret + end + + # HRESULT root + # get root IXMLElement of the XML document. + # IXMLElement2,IXMLElement2 arg0 --- p [OUT] + def root + OLEProperty.new(@dispatch, 65637, [VT_BYREF|VT_BYREF|VT_DISPATCH], [VT_BYREF|VT_BYREF|VT_DISPATCH, VT_HRESULT]) + end + + # HRESULT url + # set URL to load an XML document from the URL. + # BSTR arg0 --- p [OUT] + def url + OLEProperty.new(@dispatch, 65641, [VT_BYREF|VT_BSTR], [VT_BYREF|VT_BSTR, VT_HRESULT]) + end + + # HRESULT readyState + # get ready state. + # I4 arg0 --- pl [OUT] + def readyState + OLEProperty.new(@dispatch, 65643, [VT_BYREF|VT_I4], [VT_BYREF|VT_I4, VT_HRESULT]) + end + + # HRESULT charset + # get encoding. + # BSTR arg0 --- p [OUT] + def charset + OLEProperty.new(@dispatch, 65645, [VT_BYREF|VT_BSTR], [VT_BYREF|VT_BSTR, VT_HRESULT]) + end + + # HRESULT version + # get XML version number. + # BSTR arg0 --- p [OUT] + def version + OLEProperty.new(@dispatch, 65646, [VT_BYREF|VT_BSTR], [VT_BYREF|VT_BSTR, VT_HRESULT]) + end + + # HRESULT doctype + # get document type. + # BSTR arg0 --- p [OUT] + def doctype + OLEProperty.new(@dispatch, 65647, [VT_BYREF|VT_BSTR], [VT_BYREF|VT_BSTR, VT_HRESULT]) + end + + # HRESULT async + # get asynchronous loading flag. + # BOOL arg0 --- pf [OUT] + def async + OLEProperty.new(@dispatch, 65649, [VT_BYREF|VT_BOOL], [VT_BYREF|VT_BOOL, VT_HRESULT]) + end + + # HRESULT createElement + # create different types of IXMLElements. + # VARIANT arg0 --- vType [IN] + # VARIANT arg1 --- var1 [IN] + # IXMLElement2,IXMLElement2 arg2 --- ppElem [OUT] + def createElement(arg0, arg1=nil, arg2=nil) + ret = @dispatch._invoke(65644, [arg0, arg1, arg2], [VT_VARIANT, VT_VARIANT, VT_BYREF|VT_BYREF|VT_DISPATCH]) + @lastargs = WIN32OLE::ARGV + ret + end +end diff --git a/ext/win32ole/tests/oleserver.rb b/ext/win32ole/tests/oleserver.rb new file mode 100644 index 0000000000..bf721373e5 --- /dev/null +++ b/ext/win32ole/tests/oleserver.rb @@ -0,0 +1,10 @@ +require 'win32ole' +def oletypelib_name(pat) + WIN32OLE_TYPE.typelibs.each do |lib| + return lib if pat =~ lib + end +end +module OLESERVER + MS_EXCEL_TYPELIB = oletypelib_name(/^Microsoft Excel .* Object Library$/) + MS_XML_TYPELIB = oletypelib_name(/^Microsoft XML/) +end diff --git a/ext/win32ole/tests/testOLEEVENT.rb b/ext/win32ole/tests/testOLEEVENT.rb new file mode 100644 index 0000000000..15b7ca8413 --- /dev/null +++ b/ext/win32ole/tests/testOLEEVENT.rb @@ -0,0 +1,33 @@ +require 'rubyunit' +require 'win32ole' + +class TestWIN32OLE_EVENT < RUNIT::TestCase + def setup + @excel = WIN32OLE.new("Excel.Application") + @excel.visible = true + end + def test_on_event + book = @excel.workbooks.Add + value = "" + begin + ev = WIN32OLE_EVENT.new(book, 'WorkbookEvents') + ev.on_event('SheetChange'){|arg1, arg2| + begin + value = arg1.value + rescue + value = $!.message + end + } + book.Worksheets(1).Range("A1").value = "OK" + ensure + book.saved = true + end + assert_equal("OK", value) + end + def teardown + @excel.quit + @excel = nil + GC.start + end +end + diff --git a/ext/win32ole/tests/testOLEMETHOD.rb b/ext/win32ole/tests/testOLEMETHOD.rb new file mode 100644 index 0000000000..4f65ec96b4 --- /dev/null +++ b/ext/win32ole/tests/testOLEMETHOD.rb @@ -0,0 +1,83 @@ +# You need RubyUnit and MS Excel and MSI to run this test script + +require 'rubyunit' + +require 'win32ole' +require 'oleserver' + +class TestOLEMETHOD < RUNIT::TestCase + include OLESERVER + def setup + @excel_app = WIN32OLE_TYPE.new(MS_EXCEL_TYPELIB, 'Application') + end + def test_s_new + m = WIN32OLE_METHOD.new(@excel_app, 'Quit') + assert_instance_of(WIN32OLE_METHOD, m) + m = WIN32OLE_METHOD.new(@excel_app, 'WorkbookOpen') + assert_instance_of(WIN32OLE_METHOD, m) + m = WIN32OLE_METHOD.new(@excel_app, 'workbookopen') + assert_instance_of(WIN32OLE_METHOD, m) + end + def test_name + m = WIN32OLE_METHOD.new(@excel_app, 'Quit') + assert_equal('Quit', m.name) + end + def test_return_type + m = WIN32OLE_METHOD.new(@excel_app, 'ActiveCell') + assert_equal('Range', m.return_type) + m = WIN32OLE_METHOD.new(@excel_app, 'ActivePrinter') + assert_equal('BSTR', m.return_type) + end + def test_return_vtype + m = WIN32OLE_METHOD.new(@excel_app, 'ActiveCell') + assert_equal(WIN32OLE::VARIANT::VT_PTR, m.return_vtype) + m = WIN32OLE_METHOD.new(@excel_app, 'ActivePrinter') + assert_equal(WIN32OLE::VARIANT::VT_BSTR, m.return_vtype) + end + def test_return_type_detail + m = WIN32OLE_METHOD.new(@excel_app, 'ActiveCell') + assert_equal(['PTR', 'USERDEFINED', 'Range'], m.return_type_detail) + m = WIN32OLE_METHOD.new(@excel_app, 'ActivePrinter') + assert_equal(['BSTR'], m.return_type_detail) + end + + def test_invoke_kind + m = WIN32OLE_METHOD.new(@excel_app, 'ActiveCell') + assert_equal('PROPERTYGET', m.invoke_kind) + end + def test_visible + m = WIN32OLE_METHOD.new(@excel_app, 'ActiveCell') + assert(m.visible?) + m = WIN32OLE_METHOD.new(@excel_app, 'AddRef') + assert(!m.visible?) + end + def test_event + m = WIN32OLE_METHOD.new(@excel_app, 'WorkbookOpen') + assert(m.event?) + m = WIN32OLE_METHOD.new(@excel_app, 'ActiveCell') + assert(!m.event?) + end + def test_event_interface + m = WIN32OLE_METHOD.new(@excel_app, 'WorkbookOpen') + assert_equal('AppEvents', m.event_interface) + m = WIN32OLE_METHOD.new(@excel_app, 'ActiveCell') + assert_nil(m.event_interface) + end + def test_helpstring + domdoc = WIN32OLE_TYPE.new(MS_XML_TYPELIB, 'DOMDocument') + m = WIN32OLE_METHOD.new(domdoc, 'abort') + assert_equal('abort an asynchronous download', m.helpstring) + end + def test_helpfile + m = WIN32OLE_METHOD.new(@excel_app, 'ActiveCell') + assert_match(/VBAXL.*\.(HLP|CHM)$/i, m.helpfile) + end + def test_helpcontext + m = WIN32OLE_METHOD.new(@excel_app, 'ActiveCell') + assert(m.helpcontext > 0) + end + def test_offset_vtbl + m = WIN32OLE_METHOD.new(@excel_app, 'QueryInterface') + assert_equal(0, m.offset_vtbl) + end +end diff --git a/ext/win32ole/tests/testOLEPARAM.rb b/ext/win32ole/tests/testOLEPARAM.rb new file mode 100644 index 0000000000..62fd2a1890 --- /dev/null +++ b/ext/win32ole/tests/testOLEPARAM.rb @@ -0,0 +1,67 @@ +# You need RubyUnit and MS Excel and MSI to run this test script + +require 'rubyunit' + +require 'win32ole' +require 'oleserver' + +class TestOLEPARAM < RUNIT::TestCase + include OLESERVER + def test_name + classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB) + sh = classes.find {|c| c.name == 'Worksheet'} + saveas = sh.ole_methods.find {|m| m.name == 'SaveAs'} + param_names = saveas.params.collect{|p| p.name} + assert(param_names.size > 0) + assert(param_names.include?('Filename')) + end + def test_ole_type + classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB) + methods = classes.find {|c| c.name == 'Worksheet'}.ole_methods + f = methods.find {|m| m.name == 'SaveAs'} + assert_equal('BSTR', f.params[0].ole_type) + methods = classes.find {|c| c.name == 'Workbook'}.ole_methods + f = methods.find {|m| m.name == 'SaveAs'} + assert_equal('XlSaveAsAccessMode', f.params[6].ole_type) + end + def test_ole_type_detail + classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB) + methods = classes.find {|c| c.name == 'Worksheet'}.ole_methods + f = methods.find {|m| m.name == 'SaveAs'} + assert_equal(['BSTR'], f.params[0].ole_type_detail) + methods = classes.find {|c| c.name == 'Workbook'}.ole_methods + f = methods.find {|m| m.name == 'SaveAs'} + assert_equal(['USERDEFINED', 'XlSaveAsAccessMode'], f.params[6].ole_type_detail) + end + def test_input + classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB) + methods = classes.find {|c| c.name == 'Worksheet'}.ole_methods + f = methods.find {|m| m.name == 'SaveAs'} + assert(f.params[0].input?) + end + + def test_output + classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB) + methods = classes.find {|c| c.name == 'Worksheet'}.ole_methods + f = methods.find {|m| m.name == 'SaveAs'} + assert(!f.params[0].output?) + end + def test_optional + classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB) + methods = classes.find {|c| c.name == 'Worksheet'}.ole_methods + f = methods.find {|m| m.name == 'SaveAs'} + assert(!f.params[0].optional?) + methods = classes.find {|c| c.name == 'Workbook'}.ole_methods + f = methods.find {|m| m.name == 'SaveAs'} + assert(f.params[0].optional?) + end + def test_ole_type_detail + classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB) + methods = classes.find {|c| c.name == 'Worksheet'}.ole_methods + f = methods.find {|m| m.name == 'SaveAs'} + assert_equal(nil, f.params[0].default) + methods = classes.find {|c| c.name == 'Workbook'}.ole_methods + f = methods.find {|m| m.name == 'SaveAs'} + assert_equal(1, f.params[6].default) + end +end diff --git a/ext/win32ole/tests/testOLETYPE.rb b/ext/win32ole/tests/testOLETYPE.rb new file mode 100644 index 0000000000..9840aac940 --- /dev/null +++ b/ext/win32ole/tests/testOLETYPE.rb @@ -0,0 +1,83 @@ +# You need RubyUnit and MS Excel and MSI to run this test script + +require 'rubyunit' + +require 'win32ole' +require 'oleserver' + +class TestOLETYPE < RUNIT::TestCase + include OLESERVER + def test_s_new + type = WIN32OLE_TYPE.new(MS_EXCEL_TYPELIB, 'Application') + assert_instance_of(WIN32OLE_TYPE, type) + end + def test_s_ole_classes + classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB) + assert(classes.size > 0) + end + def test_s_typelibs + libs = WIN32OLE_TYPE.typelibs + assert(libs.include?(MS_EXCEL_TYPELIB)) + assert(libs.include?(MS_XML_TYPELIB)) + end + def test_s_progids + progids = WIN32OLE_TYPE.progids + assert(progids.include?('Excel.Application')) + end + def test_name + classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB) + class_names = classes.collect{|c| + c.name + } + assert(class_names.include?('Application')) + end + def test_ole_type + classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB) + app = classes.find {|c| c.name == 'Application'} + assert_equal('Class', app.ole_type) + app = classes.find {|c| c.name == '_Application'} + assert_equal('Dispatch', app.ole_type) + end + def test_typekind + classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB) + app = classes.find {|c| c.name == 'Application'} + assert_equal(5, app.typekind) + end + def test_visible + classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB) + app = classes.find {|c| c.name == 'Application'} + assert(app.visible?) + app = classes.find {|c| c.name == 'IAppEvents'} + assert(!app.visible?) + end + def test_src_type + classes = WIN32OLE_TYPE.ole_classes(MS_XML_TYPELIB) + domnode = classes.find {|c| c.name == 'DOMNodeType'} + assert_equal('tagDOMNodeType', domnode.src_type) + end + def test_helpstring + classes = WIN32OLE_TYPE.ole_classes(MS_XML_TYPELIB) + domdoc = classes.find {|c| c.name == 'DOMDocument'} + assert_equal('W3C-DOM XML Document', domdoc.helpstring) + end + def test_variables + classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB) + xlchart = classes.find {|c| c.name == 'XlChartType'} + assert(xlchart.variables.size > 0) + end + def test_ole_methods + classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB) + worksheet = classes.find {|c| c.name == 'Worksheet'} + assert(worksheet.ole_methods.size > 0) + end + def test_helpfile + classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB) + worksheet = classes.find {|c| c.name == 'Worksheet'} + assert_match(/VBAXL.*\.(CHM|HLP)$/, worksheet.helpfile) + end + def test_helpcontext + classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB) + worksheet = classes.find {|c| c.name == 'Worksheet'} + assert_equal(131088, worksheet.helpcontext) + end +end diff --git a/ext/win32ole/tests/testOLEVARIABLE.rb b/ext/win32ole/tests/testOLEVARIABLE.rb new file mode 100644 index 0000000000..b237d9b616 --- /dev/null +++ b/ext/win32ole/tests/testOLEVARIABLE.rb @@ -0,0 +1,42 @@ +# You need RubyUnit and MS Excel and MSI to run this test script + +require 'rubyunit' + +require 'win32ole' +require 'oleserver' + +class TestOLEVARIABLE < RUNIT::TestCase + include OLESERVER + def test_name + classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB) + chart = classes.find {|c| c.name == 'XlChartType'} + var_names = chart.variables.collect {|m| m.name} + assert(var_names.size > 0) + assert(var_names.include?('xl3DColumn')) + end + def test_ole_type + classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB) + chart = classes.find {|c| c.name == 'XlChartType'} + var = chart.variables.find {|m| m.name == 'xl3DColumn'} + assert_equal('INT', var.ole_type) + end + def test_ole_type_detail + classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB) + chart = classes.find {|c| c.name == 'XlChartType'} + var = chart.variables.find {|m| m.name == 'xl3DColumn'} + assert_equal(['INT'], var.ole_type_detail) + end + + def test_value + classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB) + chart = classes.find {|c| c.name == 'XlChartType'} + var = chart.variables.find {|m| m.name == 'xl3DColumn'} + assert_equal(-4100, var.value) + end + def test_visible + classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB) + chart = classes.find {|c| c.name == 'XlChartType'} + var = chart.variables.find {|m| m.name == 'xl3DColumn'} + assert(var.visible?) + end +end diff --git a/ext/win32ole/tests/testVARIANT.rb b/ext/win32ole/tests/testVARIANT.rb new file mode 100644 index 0000000000..f274778f27 --- /dev/null +++ b/ext/win32ole/tests/testVARIANT.rb @@ -0,0 +1,32 @@ +# You need RubyUnit and MS Excel and MSI to run this test script + +require 'rubyunit' + +require 'win32ole' + +class TestWin32OLE_VARIANT < RUNIT::TestCase + include WIN32OLE::VARIANT + def test_variant + assert_equal(2, VT_I2) + assert_equal(3, VT_I4) + assert_equal(4, VT_R4) + assert_equal(5, VT_R8) + assert_equal(6, VT_CY) + assert_equal(7, VT_DATE) + assert_equal(8, VT_BSTR) + assert_equal(9, VT_DISPATCH) + assert_equal(10, VT_ERROR) + assert_equal(11, VT_BOOL) + assert_equal(12, VT_VARIANT) + assert_equal(13, VT_UNKNOWN) + assert_equal(16, VT_I1) + assert_equal(17, VT_UI1) + assert_equal(18, VT_UI2) + assert_equal(19, VT_UI4) + assert_equal(22, VT_INT) + assert_equal(23, VT_UINT) + assert_equal(0x2000, VT_ARRAY) + assert_equal(0x4000, VT_BYREF) + end +end + diff --git a/ext/win32ole/tests/testWIN32OLE.rb b/ext/win32ole/tests/testWIN32OLE.rb new file mode 100644 index 0000000000..7907fe36a9 --- /dev/null +++ b/ext/win32ole/tests/testWIN32OLE.rb @@ -0,0 +1,298 @@ +# You need RubyUnit and MS Excel and MSI to run this test script + +require 'runit/testcase' +require 'runit/cui/testrunner' + +require 'win32ole' +require 'oleserver' + +module EXCEL_CONST +end + +module CONST1 +end + +module CONST2 +end + +module CONST3 +end + +class TestWin32OLE < RUNIT::TestCase + include OLESERVER + def setup + @excel = WIN32OLE.new("Excel.Application") + @excel.visible = true + end + def test_s_new + assert_instance_of(WIN32OLE, @excel) + end + def test_s_new_DCOM + rexcel = WIN32OLE.new("Excel.Application", "localhost") + assert_instance_of(WIN32OLE, rexcel) + rexcel.visible = true + rexcel.quit + end + def test_s_new_from_clsid + excel = WIN32OLE.new("{00024500-0000-0000-C000-000000000046}") + assert_instance_of(WIN32OLE, excel) + excel.quit + exc = assert_exception(WIN32OLERuntimeError) { + WIN32OLE.new("{000}") + } + assert_match(/Unknown OLE server : `\{000\}'/, exc.message) + end + def test_s_connect + excel2 = WIN32OLE.connect('Excel.Application') + assert_instance_of(WIN32OLE, excel2) + end + + def test_s_const_load + assert(!defined?(EXCEL_CONST::XlTop)) + WIN32OLE.const_load(@excel, EXCEL_CONST) + assert_equal(-4160, EXCEL_CONST::XlTop) + + assert(!defined?(CONST1::XlTop)) + WIN32OLE.const_load(MS_EXCEL_TYPELIB, CONST1) + assert_equal(-4160, CONST1::XlTop) + end + + def test_get_win32ole_object + workbooks = @excel.Workbooks; + assert_instance_of(WIN32OLE, workbooks) + end + def test_each + workbooks = @excel.Workbooks + assert_no_exception { + i = 0; + workbooks.each do |workbook| + print i += 1 + end + } + workbooks.add + workbooks.add + i = 0 + workbooks.each do |workbook| + i+=1 + end + assert_equal(2, i) + workbooks.each do |workbook| + workbook.saved = true + end + end + def test_setproperty_bracket + book = @excel.workbooks.add + sheet = book.worksheets(1) + begin + sheet.range("A1")['Value'] = 10 + assert_equal(10, sheet.range("A1").value) + sheet['Cells', 1, 2] = 10 + assert_equal(10, sheet.range("B1").value) + ensure + book.saved = true + end + end + def test_convert_bignum + book = @excel.workbooks.add + sheet = book.worksheets(1) + begin + sheet.range("A1").value = 999999999 + sheet.range("A2").value = 9999999999 + sheet.range("A3").value = "=A1*10 + 9" + assert_equal(9999999999, sheet.range("A2").value) + assert_equal(9999999999, sheet.range("A3").value) + + ensure + book.saved = true + end + end + + def test_ole_invoke_with_named_arg + book = @excel.workbooks.add + sheets = book.worksheets + sheet = book.worksheets(1) + num = sheets.count + begin + sheets.add({'count' => 2, 'after'=>sheet}) + assert_equal(2, sheets.count - num); + ensure + book.saved = true + end + end + + def test_ole_invoke_with_named_arg_last + book = @excel.workbooks.add + sheets = book.worksheets + sheet = book.worksheets(1) + num = sheets.count + begin + sheets.add(sheet, {'count' => 2}) + assert_equal(2, sheets.count - num); + ensure + book.saved = true + end + end + + def test_setproperty + @excel.setproperty('Visible', false) + assert_equal(false, @excel.Visible) + @excel.setproperty('Visible', true) + assert_equal(true, @excel.Visible) + book = @excel.workbooks.add + sheet = book.worksheets(1) + begin + sheet.setproperty('Cells', 1, 2, 10) + assert_equal(10, sheet.range("B1").value) + ensure + book.saved = true + end + end + def test_no_exist_property + isok = false + begin + @excel.unknown_prop = 1 + rescue WIN32OLERuntimeError + isok = true + end + assert(isok) + + isok = false + begin + @excel['unknown_prop'] = 2 + rescue WIN32OLERuntimeError + isok = true + end + assert(isok) + end + + def test_setproperty_with_equal + book = @excel.workbooks.add + sheet = book.worksheets(1) + begin + sheet.range("B1").value = 10 + assert_equal(10, sheet.range("B1").value) + sheet.range("C1:D1").value = [11, 12] + assert_equal(11, sheet.range("C1").value) + assert_equal(12, sheet.range("D1").value) + ensure + book.saved = true + end + end + def test_invoke + workbooks = @excel.invoke( 'workbooks' ) + assert_instance_of(WIN32OLE, workbooks) + book = workbooks.invoke( 'add' ) + assert_instance_of(WIN32OLE, book) + end + def test_ole_methods + methods = @excel.ole_methods + method_names = methods.collect{|m| m.name} + assert(method_names.include?("Quit")) + end + def test_ole_method_help + quit_info = @excel.ole_method_help("Quit") + assert_equal(0, quit_info.size_params) + assert_equal(0, quit_info.size_opt_params) + + workbooks = @excel.Workbooks + add_info = workbooks.ole_method_help("Add") + assert_equal(1, add_info.size_params) + assert_equal(1, add_info.size_opt_params) + assert(add_info.params[0].input?) + assert(add_info.params[0].optional?) + assert_equal('VARIANT', add_info.params[0].ole_type) + end +# def test_ole_put_methods +# methods_list = @excel.ole_put_methods +# puts methods_list +# end + def teardown + @excel.quit + @excel = nil + GC.start + end +end + +class TestWin32OLE_WITH_MSI < RUNIT::TestCase + def setup + installer = WIN32OLE.new("WindowsInstaller.Installer") + @record = installer.CreateRecord(2) + end + + # Sorry, this test fails. + # Win32OLE does not support this style to set property. + # Use Win32OLE#setproperty or Win32OLE#[]= . + # def test_invoke + # @record.invoke("StringData", 1, 'cccc') + # assert_equal('cccc', @record.StringData(1)) + # end + + def test_setproperty + @record.setproperty( "StringData", 1, 'dddd') + assert_equal('dddd', @record.StringData(1)) + end + def test_bracket_equal_with_arg + @record[ "StringData", 1 ] = 'ffff' + assert_equal('ffff', @record.StringData(1)) + end +end + +# --------------------- +# +# a subclass of Win32OLE +# override new() and connect() +class MyExcel and Jan Dubois + * + * You may distribute under the terms of either the GNU General Public + * License or the Artistic License, as specified in the README file + * of the Perl distribution. + * + */ + +/* + $Date$ + modified for win32ole (ruby) by Masaki.Suketa + */ + +#include "ruby.h" +#include "st.h" +#include +#include +#include +#ifdef HAVE_STDARG_PROTOTYPES +#include +#define va_init_list(a,b) va_start(a,b) +#else +#include +#define va_init_list(a,b) va_start(a) +#endif + +#define DOUT fprintf(stderr,"[%d]\n",__LINE__) +#define DOUTS(x) fprintf(stderr,"[%d]:" #x "=%s\n",__LINE__,x) +#define DOUTMSG(x) fprintf(stderr, "[%d]:" #x "\n",__LINE__) +#define DOUTI(x) fprintf(stderr, "[%ld]:" #x "=%d\n",__LINE__,x) +#define DOUTD(x) fprintf(stderr, "[%d]:" #x "=%f\n",__LINE__,x) + +#if defined NONAMELESSUNION && __GNUC__ +#define V_UNION1(X, Y) ((X)->u.Y) +#else +#define V_UNION1(X, Y) ((X)->Y) +#endif + +#if defined NONAMELESSUNION && __GNUC__ +#undef V_UNION +#define V_UNION(X,Y) ((X)->n1.n2.n3.Y) + +#undef V_VT +#define V_VT(X) ((X)->n1.n2.vt) + +#undef V_BOOL +#define V_BOOL(X) V_UNION(X,boolVal) +#endif + +#define OLE_RELEASE(X) ((X)->lpVtbl->Release(X)) +#define OLE_ADDREF(X) ((X)->lpVtbl->AddRef(X)) +#define OLE_GET_TYPEATTR(X, Y) ((X)->lpVtbl->GetTypeAttr((X), (Y))) +#define OLE_RELEASE_TYPEATTR(X, Y) ((X)->lpVtbl->ReleaseTypeAttr((X), (Y))) + +#define OLE_FREE(x) if(gOLEInitialized == Qtrue) {\ + if((x)) {\ + OLE_RELEASE((x));\ + (x) = 0;\ + }\ + }\ + ole_msg_loop();\ + CoFreeUnusedLibraries() + +#define WC2VSTR(x) ole_wc2vstr((x), TRUE) + +#define WIN32OLE_VERSION "0.5.2" + +typedef HRESULT (STDAPICALLTYPE FNCOCREATEINSTANCEEX) + (REFCLSID, IUnknown*, DWORD, COSERVERINFO*, DWORD, MULTI_QI*); + +typedef HWND (WINAPI FNHTMLHELP)(HWND hwndCaller, LPCSTR pszFile, + UINT uCommand, DWORD dwData); +typedef struct { + struct IEventSinkVtbl * lpVtbl; +} IEventSink, *PEVENTSINK; + +typedef struct IEventSinkVtbl IEventSinkVtbl; + +struct IEventSinkVtbl { + STDMETHOD(QueryInterface)( + PEVENTSINK, + REFIID, + LPVOID *); + STDMETHOD_(ULONG, AddRef)(PEVENTSINK); + STDMETHOD_(ULONG, Release)(PEVENTSINK); + + STDMETHOD(GetTypeInfoCount)( + PEVENTSINK, + UINT *); + STDMETHOD(GetTypeInfo)( + PEVENTSINK, + UINT, + LCID, + ITypeInfo **); + STDMETHOD(GetIDsOfNames)( + PEVENTSINK, + REFIID, + OLECHAR **, + UINT, + LCID, + DISPID *); + STDMETHOD(Invoke)( + PEVENTSINK, + DISPID, + REFIID, + LCID, + WORD, + DISPPARAMS *, + VARIANT *, + EXCEPINFO *, + UINT *); +}; + +typedef struct tagIEVENTSINKOBJ { + IEventSinkVtbl *lpVtbl; + DWORD m_cRef; + IID m_iid; + int m_event_id; + DWORD m_dwCookie; + IConnectionPoint *pConnectionPoint; + ITypeInfo *pTypeInfo; +}IEVENTSINKOBJ, *PIEVENTSINKOBJ; + +VALUE cWIN32OLE; +VALUE cWIN32OLE_TYPE; +VALUE cWIN32OLE_VARIABLE; +VALUE cWIN32OLE_METHOD; +VALUE cWIN32OLE_PARAM; +VALUE cWIN32OLE_EVENT; +VALUE eWIN32OLE_RUNTIME_ERROR; +VALUE mWIN32OLE_VARIANT; + +static VALUE ary_ole_event; +static ID id_events; +static BOOL gOLEInitialized = Qfalse; +static HINSTANCE ghhctrl = NULL; +static HINSTANCE gole32 = NULL; +static FNCOCREATEINSTANCEEX *gCoCreateInstanceEx = NULL; + +struct oledata { + IDispatch *pDispatch; +}; + +struct oletypedata { + ITypeInfo *pTypeInfo; +}; + +struct olemethoddata { + ITypeInfo *pOwnerTypeInfo; + ITypeInfo *pTypeInfo; + UINT index; +}; + +struct olevariabledata { + ITypeInfo *pTypeInfo; + UINT index; +}; + +struct oleparamdata { + ITypeInfo *pTypeInfo; + UINT method_index; + UINT index; +}; + +struct oleeventdata { + IEVENTSINKOBJ *pEvent; +}; + +struct oleparam { + DISPPARAMS dp; + OLECHAR** pNamedArgs; +}; + +static VALUE folemethod_s_allocate _((VALUE)); +static VALUE olemethod_set_member _((VALUE, ITypeInfo *, ITypeInfo *, int, VALUE)); +static VALUE foletype_s_allocate _((VALUE)); +static VALUE oletype_set_member _((VALUE, ITypeInfo *, VALUE)); +static VALUE olemethod_from_typeinfo _((VALUE, ITypeInfo *, VALUE)); +static HRESULT ole_docinfo_from_type _((ITypeInfo *, BSTR *, BSTR *, DWORD *, BSTR *)); + +static void +time2d(hh, mm, ss, pv) + int hh, mm, ss; + double *pv; +{ + *pv = (hh * 60.0 * 60.0 + mm * 60.0 + ss) / 86400.0; +} + +static void +d2time(v, hh, mm, ss) + double v; + int *hh, *mm, *ss; +{ + double d_hh, d_mm, d_ss; + int i_hh, i_mm, i_ss; + + double d = v * 86400.0; + + d_hh = d / 3600.0; + i_hh = (int)d_hh; + + d = d - i_hh * 3600.0; + + d_mm = d / 60.0; + i_mm = (int)d_mm; + + d = d - i_mm * 60.0; + + d_ss = d * 10.0 + 5; + + i_ss = (int)d_ss / 10; + + if(i_ss == 60) { + i_mm += 1; + i_ss = 0; + } + + if (i_mm == 60) { + i_hh += 1; + i_mm = 0; + } + if (i_hh == 24) { + i_hh = 0; + } + + *hh = i_hh; + *mm = i_mm; + *ss = i_ss; +} + +static void +civil2jd(y, m, d, jd) + int y, m, d; + long *jd; +{ + long a, b; + if (m <= 2) { + y -= 1; + m += 12; + } + a = (long)(y / 100.0); + b = 2 - a + (long)(a / 4.0); + *jd = (long)(365.25 * (double)(y + 4716)) + + (long)(30.6001 * (m + 1)) + + d + b - 1524; +} + +static void +jd2civil(day, yy, mm, dd) + long day; + int *yy, *mm, *dd; +{ + long x, a, b, c, d, e; + x = (long)(((double)day - 1867216.25) / 36524.25); + a = day + 1 + x - (long)(x / 4.0); + b = a + 1524; + c = (long)(((double)b -122.1) /365.25); + d = (long)(365.25 * c); + e = (long)((double)(b - d) / 30.6001); + *dd = b - d - (long)(30.6001 * e); + if (e <= 13) { + *mm = e - 1; + *yy = c - 4716; + } + else { + *mm = e - 13; + *yy = c - 4715; + } +} + +static void +double2time(v, y, m, d, hh, mm, ss) + double v; + int *y, *m, *d, *hh, *mm, *ss; +{ + long day; + double t; + + day = (long)v; + t = v - day; + jd2civil(2415019 + day, y, m, d); + + d2time(t, hh, mm, ss); +} + +static double +time_object2date(tmobj) + VALUE tmobj; +{ + long y, m, d, hh, mm, ss; + long day; + double t; + y = FIX2INT(rb_funcall(tmobj, rb_intern("year"), 0)); + m = FIX2INT(rb_funcall(tmobj, rb_intern("month"), 0)); + d = FIX2INT(rb_funcall(tmobj, rb_intern("mday"), 0)); + hh = FIX2INT(rb_funcall(tmobj, rb_intern("hour"), 0)); + mm = FIX2INT(rb_funcall(tmobj, rb_intern("min"), 0)); + ss = FIX2INT(rb_funcall(tmobj, rb_intern("sec"), 0)); + civil2jd(y, m, d, &day); + time2d(hh, mm, ss, &t); + return t + day - 2415019; +} + +static VALUE +date2time_str(date) + double date; +{ + int y, m, d, hh, mm, ss; + char szTime[20]; + double2time(date, &y, &m, &d, &hh, &mm, &ss); + sprintf(szTime, + "%4.4d/%02.2d/%02.2d %02.2d:%02.2d:%02.2d", + y, m, d, hh, mm, ss); + return rb_str_new2(szTime); +} + +static void ole_val2variant(); + +static char * +ole_wc2mb(pw) + LPWSTR pw; +{ + int size; + LPSTR pm; + size = WideCharToMultiByte(CP_ACP, 0, pw, -1, NULL, 0, NULL, NULL); + if (size) { + pm = ALLOC_N(char, size); + WideCharToMultiByte(CP_ACP, 0, pw, -1, pm, size, NULL, NULL); + } + else { + pm = ALLOC_N(char, 1); + *pm = '\0'; + } + return pm; +} + +static VALUE +ole_hresult2msg(hr) + HRESULT hr; +{ + VALUE msg = Qnil; + char *p_msg; + DWORD dwCount; + + char strhr[100]; + sprintf(strhr, " HRESULT error code:0x%08x\n ", hr); + msg = rb_str_new2(strhr); + + dwCount = FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | + FORMAT_MESSAGE_FROM_SYSTEM | + FORMAT_MESSAGE_IGNORE_INSERTS, + NULL, hr, LOCALE_SYSTEM_DEFAULT, + (LPTSTR)&p_msg, 0, NULL); + if (dwCount > 0) { + /* remove dots and CRs/LFs */ + while (dwCount > 0 && + (p_msg[dwCount-1] < ' ' || p_msg[dwCount-1] == '.')) { + p_msg[--dwCount] = '\0'; + } + if (p_msg[0] != '\0') { + rb_str_cat2(msg, p_msg); + } + } + return msg; +} + +static VALUE +ole_excepinfo2msg(pExInfo) + EXCEPINFO *pExInfo; +{ + char error_code[40]; + char *pSource = NULL; + char *pDescription = NULL; + VALUE error_msg; + if(pExInfo->pfnDeferredFillIn != NULL) { + (*pExInfo->pfnDeferredFillIn)(pExInfo); + } + if (pExInfo->bstrSource != NULL) { + pSource = ole_wc2mb(pExInfo->bstrSource); + } + if (pExInfo->bstrDescription != NULL) { + pDescription = ole_wc2mb(pExInfo->bstrDescription); + } + if(pExInfo->wCode == 0) { + sprintf(error_code, "\n OLE error code:%lX in ", pExInfo->scode); + } + else{ + sprintf(error_code, "\n OLE error code:%u in ", pExInfo->wCode); + } + error_msg = rb_str_new2(error_code); + if(pSource != NULL) { + rb_str_cat(error_msg, pSource, strlen(pSource)); + } + else { + rb_str_cat(error_msg, "", 9); + } + rb_str_cat2(error_msg, "\n "); + if(pDescription != NULL) { + rb_str_cat2(error_msg, pDescription); + } + else { + rb_str_cat2(error_msg, ""); + } + if(pSource) free(pSource); + if(pDescription) free(pDescription); + SysFreeString(pExInfo->bstrDescription); + SysFreeString(pExInfo->bstrSource); + SysFreeString(pExInfo->bstrHelpFile); + return error_msg; +} + +static void +#ifdef HAVE_STDARG_PROTOTYPES +ole_raise(HRESULT hr, VALUE ecs, const char *fmt, ...) +#else +ole_raise(hr, exc, fmt, va_alist) + HRESULT hr; + VALUE exc; + const char *fmt; + va_dcl +#endif +{ + va_list args; + char buf[BUFSIZ]; + VALUE err_msg; + va_init_list(args, fmt); + vsnprintf(buf, BUFSIZ, fmt, args); + va_end(args); + + err_msg = ole_hresult2msg(hr); + if(err_msg != Qnil) { + rb_raise(ecs, "%s\n%s", buf, StringValuePtr(err_msg)); + } + else { + rb_raise(ecs, "%s", buf); + } +} + +void +ole_uninitialize() +{ + OleUninitialize(); + gOLEInitialized = Qfalse; +} + +static void +ole_initialize() +{ + HRESULT hr; + int rc; + + if(gOLEInitialized == Qfalse) { + hr = OleInitialize(NULL); + if(FAILED(hr)) { + ole_raise(hr, rb_eRuntimeError, "Fail : OLE initialize"); + } + gOLEInitialized = Qtrue; + rc = atexit((void (*)(void))ole_uninitialize); + } +} + +static void +ole_msg_loop() { + MSG msg; + while(PeekMessage(&msg,NULL,0,0,PM_REMOVE)) { + TranslateMessage(&msg); + DispatchMessage(&msg); + } +} + +static void +ole_free(pole) + struct oledata *pole; +{ + OLE_FREE(pole->pDispatch); +} + +static void +oletype_free(poletype) + struct oletypedata *poletype; +{ + OLE_FREE(poletype->pTypeInfo); +} + +static void +olemethod_free(polemethod) + struct olemethoddata *polemethod; +{ + OLE_FREE(polemethod->pTypeInfo); + OLE_FREE(polemethod->pOwnerTypeInfo); +} + +static void +olevariable_free(polevar) + struct olevariabledata *polevar; +{ + OLE_FREE(polevar->pTypeInfo); +} + +static void +oleparam_free(pole) + struct oleparamdata *pole; +{ + OLE_FREE(pole->pTypeInfo); +} + +static LPWSTR +ole_mb2wc(pm, len) + char *pm; + int len; +{ + int size; + LPWSTR pw; + size = MultiByteToWideChar(CP_ACP, 0, pm, len, NULL, 0); + pw = SysAllocStringLen(NULL, size - 1); + MultiByteToWideChar(CP_ACP, 0, pm, len, pw, size); + return pw; +} + +static VALUE +ole_wc2vstr(pw, isfree) + LPWSTR pw; + BOOL isfree; +{ + char *p = ole_wc2mb(pw); + VALUE vstr = rb_str_new2(p); + if(isfree) + SysFreeString(pw); + free(p); + return vstr; +} + +static VALUE +ole_ary_m_entry(val, pid) + VALUE val; + long *pid; +{ + VALUE obj = Qnil; + int i = 0; + obj = val; + while(TYPE(obj) == T_ARRAY) { + obj = rb_ary_entry(obj, pid[i]); + i++; + } + return obj; +} + +static void +ole_set_safe_array(n, psa, pid, pub, val, dim) + long n; + SAFEARRAY *psa; + long *pid; + long *pub; + VALUE val; + long dim; +{ + VALUE val1; + VARIANT var; + VariantInit(&var); + if(n < 0) return; + if(n == dim) { + val1 = ole_ary_m_entry(val, pid); + ole_val2variant(val1, &var); + SafeArrayPutElement(psa, pid, &var); + } + pid[n] += 1; + if (pid[n] < pub[n]) { + ole_set_safe_array(dim, psa, pid, pub, val, dim); + } + else { + pid[n] = 0; + ole_set_safe_array(n-1, psa, pid, pub, val, dim); + } +} + +static void +ole_val2variant(val, var) + VALUE val; + VARIANT *var; +{ + struct oledata *pole; + if(rb_obj_is_kind_of(val, cWIN32OLE)) { + Data_Get_Struct(val, struct oledata, pole); + OLE_ADDREF(pole->pDispatch); + V_VT(var) = VT_DISPATCH; + V_DISPATCH(var) = pole->pDispatch; + return; + } + if (rb_obj_is_kind_of(val, rb_cTime)) { + V_VT(var) = VT_DATE; + V_DATE(var) = time_object2date(val); + return; + } + switch (TYPE(val)) { + case T_ARRAY: + { + VALUE val1; + long dim = 0; + int i = 0; + + HRESULT hr; + SAFEARRAYBOUND *psab; + SAFEARRAY *psa; + long *pub, *pid; + + val1 = val; + while(TYPE(val1) == T_ARRAY) { + val1 = rb_ary_entry(val1, 0); + dim += 1; + } + psab = ALLOC_N(SAFEARRAYBOUND, dim); + pub = ALLOC_N(long, dim); + pid = ALLOC_N(long, dim); + + if(!psab || !pub || !pid) { + if(pub) free(pub); + if(psab) free(psab); + if(pid) free(pid); + rb_raise(rb_eRuntimeError, "memory allocate error"); + } + val1 = val; + i = 0; + while(TYPE(val1) == T_ARRAY) { + psab[i].cElements = RARRAY(val1)->len; + psab[i].lLbound = 0; + pub[i] = psab[i].cElements; + pid[i] = 0; + i ++; + val1 = rb_ary_entry(val1, 0); + } + /* Create and fill VARIANT array */ + psa = SafeArrayCreate(VT_VARIANT, dim, psab); + if (psa == NULL) + hr = E_OUTOFMEMORY; + else + hr = SafeArrayLock(psa); + if (SUCCEEDED(hr)) { + ole_set_safe_array(dim-1, psa, pid, pub, val, dim-1); + hr = SafeArrayUnlock(psa); + } + if(pub) free(pub); + if(psab) free(psab); + if(pid) free(pid); + + if (SUCCEEDED(hr)) { + V_VT(var) = VT_VARIANT | VT_ARRAY; + V_ARRAY(var) = psa; + } + else if (psa != NULL) + SafeArrayDestroy(psa); + break; + } + case T_STRING: + V_VT(var) = VT_BSTR; + V_BSTR(var) = ole_mb2wc(StringValuePtr(val), -1); + break; + case T_FIXNUM: + V_VT(var) = VT_I4; + V_I4(var) = NUM2INT(val); + break; + case T_BIGNUM: + V_VT(var) = VT_R8; + V_R8(var) = rb_big2dbl(val); + break; + case T_FLOAT: + V_VT(var) = VT_R8; + V_R8(var) = NUM2DBL(val); + break; + case T_TRUE: + V_VT(var) = VT_BOOL; + V_BOOL(var) = VARIANT_TRUE; + break; + case T_FALSE: + V_VT(var) = VT_BOOL; + V_BOOL(var) = VARIANT_FALSE; + break; + case T_NIL: + V_VT(var) = VT_ERROR; + V_ERROR(var) = DISP_E_PARAMNOTFOUND; + break; + default: + rb_raise(rb_eTypeError, "not valid value"); + break; + } +} + +static VALUE +ole_set_member(self, dispatch) + VALUE self; + IDispatch * dispatch; +{ + struct oledata *pole; + Data_Get_Struct(self, struct oledata, pole); + if (pole->pDispatch) { + OLE_RELEASE(pole->pDispatch); + pole->pDispatch = NULL; + } + pole->pDispatch = dispatch; + return self; +} + +static VALUE +fole_s_allocate(klass) + VALUE klass; +{ + struct oledata *pole; + VALUE obj; + ole_initialize(); + obj = Data_Make_Struct(klass,struct oledata,0,ole_free,pole); + pole->pDispatch = NULL; + return obj; +} + +static VALUE +create_win32ole_object(klass, pDispatch, argc, argv) + VALUE klass; + IDispatch *pDispatch; + int argc; + VALUE *argv; +{ + VALUE obj = fole_s_allocate(klass); + ole_set_member(obj, pDispatch); + return obj; +} + +static VALUE +ole_variant2val(pvar) + VARIANT *pvar; +{ + VALUE obj = Qnil; + HRESULT hr; + while ( V_VT(pvar) == (VT_BYREF | VT_VARIANT) ) + pvar = V_VARIANTREF(pvar); + + if(V_ISARRAY(pvar)) { + SAFEARRAY *psa = V_ISBYREF(pvar) ? *V_ARRAYREF(pvar) : V_ARRAY(pvar); + long i; + long *pID, *pLB, *pUB; + VARIANT variant; + VALUE val; + VALUE val2; + + int dim = SafeArrayGetDim(psa); + VariantInit(&variant); + V_VT(&variant) = (V_VT(pvar) & ~VT_ARRAY) | VT_BYREF; + + pID = ALLOC_N(long, dim); + pLB = ALLOC_N(long, dim); + pUB = ALLOC_N(long, dim); + + if(!pID || !pLB || !pUB) { + if(pID) free(pID); + if(pLB) free(pLB); + if(pUB) free(pUB); + rb_raise(rb_eRuntimeError, "memory allocate error"); + } + + obj = Qnil; + + for(i = 0; i < dim; ++i) { + SafeArrayGetLBound(psa, i+1, &pLB[i]); + SafeArrayGetLBound(psa, i+1, &pID[i]); + SafeArrayGetUBound(psa, i+1, &pUB[i]); + } + + hr = SafeArrayLock(psa); + if (SUCCEEDED(hr)) { + val2 = rb_ary_new(); + while (i >= 0) { + hr = SafeArrayPtrOfIndex(psa, pID, &V_BYREF(&variant)); + if (FAILED(hr)) + break; + + val = ole_variant2val(&variant); + rb_ary_push(val2, val); + for (i = dim-1 ; i >= 0 ; --i) { + if (++pID[i] <= pUB[i]) + break; + + pID[i] = pLB[i]; + if (i > 0) { + if (obj == Qnil) + obj = rb_ary_new(); + rb_ary_push(obj, val2); + val2 = rb_ary_new(); + } + } + } + SafeArrayUnlock(psa); + } + if(pID) free(pID); + if(pLB) free(pLB); + if(pUB) free(pUB); + return (obj == Qnil) ? val2 : obj; + } + switch(V_VT(pvar) & ~VT_BYREF){ + case VT_EMPTY: + break; + case VT_NULL: + break; + case VT_UI1: + if(V_ISBYREF(pvar)) + obj = INT2NUM((long)*V_UI1REF(pvar)); + else + obj = INT2NUM((long)V_UI1(pvar)); + break; + + case VT_I2: + if(V_ISBYREF(pvar)) + obj = INT2NUM((long)*V_I2REF(pvar)); + else + obj = INT2NUM((long)V_I2(pvar)); + break; + + case VT_I4: + if(V_ISBYREF(pvar)) + obj = INT2NUM((long)*V_I4REF(pvar)); + else + obj = INT2NUM((long)V_I4(pvar)); + break; + + case VT_R4: + if(V_ISBYREF(pvar)) + obj = rb_float_new(*V_R4REF(pvar)); + else + obj = rb_float_new(V_R4(pvar)); + break; + + case VT_R8: + if(V_ISBYREF(pvar)) + obj = rb_float_new(*V_R8REF(pvar)); + else + obj = rb_float_new(V_R8(pvar)); + break; + + case VT_BSTR: + { + char *p; + if(V_ISBYREF(pvar)) + p = ole_wc2mb(*V_BSTRREF(pvar)); + else + p = ole_wc2mb(V_BSTR(pvar)); + obj = rb_str_new2(p); + if(p) free(p); + break; + } + + case VT_ERROR: + if(V_ISBYREF(pvar)) + obj = INT2NUM(*V_ERRORREF(pvar)); + else + obj = INT2NUM(V_ERROR(pvar)); + break; + + case VT_BOOL: + if (V_ISBYREF(pvar)) + obj = (*V_BOOLREF(pvar) ? Qtrue : Qfalse); + else + obj = (V_BOOL(pvar) ? Qtrue : Qfalse); + break; + + case VT_DISPATCH: + { + IDispatch *pDispatch; + + if (V_ISBYREF(pvar)) + pDispatch = *V_DISPATCHREF(pvar); + else + pDispatch = V_DISPATCH(pvar); + + if (pDispatch != NULL ) { + OLE_ADDREF(pDispatch); + obj = create_win32ole_object(cWIN32OLE, pDispatch, 0, 0); + } + break; + } + + case VT_UNKNOWN: + { + + /* get IDispatch interface from IUnknown interface */ + IUnknown *punk; + IDispatch *pDispatch; + HRESULT hr; + + if (V_ISBYREF(pvar)) + punk = *V_UNKNOWNREF(pvar); + else + punk = V_UNKNOWN(pvar); + + if(punk != NULL) { + hr = punk->lpVtbl->QueryInterface(punk, &IID_IDispatch, + (void **)&pDispatch); + if(SUCCEEDED(hr)) { + obj = create_win32ole_object(cWIN32OLE, pDispatch, 0, 0); + } + } + break; + } + + case VT_DATE: + { + DATE date; + if(V_ISBYREF(pvar)) + date = *V_DATEREF(pvar); + else + date = V_DATE(pvar); + + obj = date2time_str(date); + break; + } + case VT_CY: + default: + { + HRESULT hr; + VARIANT variant; + VariantInit(&variant); + hr = VariantChangeTypeEx(&variant, pvar, + LOCALE_SYSTEM_DEFAULT, 0, VT_BSTR); + if (SUCCEEDED(hr) && V_VT(&variant) == VT_BSTR) { + char *p = ole_wc2mb(V_BSTR(&variant)); + obj = rb_str_new2(p); + if(p) free(p); + } + VariantClear(&variant); + break; + } + } + return obj; +} + +static LONG reg_open_key(hkey, name, phkey) + HKEY hkey; + const char *name; + HKEY *phkey; +{ + return RegOpenKeyEx(hkey, name, 0, KEY_READ, phkey); +} + +static LONG reg_open_vkey(hkey, key, phkey) + HKEY hkey; + VALUE key; + HKEY *phkey; +{ + return reg_open_key(hkey, StringValuePtr(key), phkey); +} + +static VALUE +reg_enum_key(hkey, i) + HKEY hkey; + DWORD i; +{ + char buf[BUFSIZ]; + LONG size_buf = sizeof(buf); + FILETIME ft; + LONG err = RegEnumKeyEx(hkey, i, buf, &size_buf, + NULL, NULL, NULL, &ft); + if(err == ERROR_SUCCESS) { + return rb_str_new2(buf); + } + return Qnil; +} + +static VALUE +reg_get_val(hkey, subkey) + HKEY hkey; + const char *subkey; +{ + char buf[BUFSIZ]; + LONG size_buf = sizeof(buf); + LONG err = RegQueryValue(hkey, subkey, buf, &size_buf); + if (err == ERROR_SUCCESS) { + return rb_str_new2(buf); + } + return Qnil; +} + +static VALUE +typelib_file_from_clsid(ole) + VALUE ole; +{ + OLECHAR *pbuf; + CLSID clsid; + HRESULT hr; + HKEY hroot, hclsid; + LONG err; + VALUE typelib; + VALUE vclsid; + char *pclsid = NULL; + + pbuf = ole_mb2wc(StringValuePtr(ole), -1); + hr = CLSIDFromProgID(pbuf, &clsid); + SysFreeString(pbuf); + if (FAILED(hr)) { + return Qnil; + } + StringFromCLSID(&clsid, &pbuf); + vclsid = WC2VSTR(pbuf); + err = reg_open_key(HKEY_CLASSES_ROOT, "CLSID", &hroot); + if (err != ERROR_SUCCESS) { + return Qnil; + } + err = reg_open_key(hroot, StringValuePtr(vclsid), &hclsid); + if (err != ERROR_SUCCESS) { + RegCloseKey(hroot); + return Qnil; + } + typelib = reg_get_val(hclsid, "InprocServer32"); + RegCloseKey(hroot); + RegCloseKey(hclsid); + return typelib; +} + +static VALUE +typelib_file_from_typelib(ole) + VALUE ole; +{ + HKEY htypelib, hclsid, hversion, hlang; + double fver; + DWORD i, j, k; + LONG err; + BOOL found = FALSE; + VALUE typelib; + VALUE file = Qnil; + VALUE clsid; + VALUE ver; + VALUE lang; + + err = reg_open_key(HKEY_CLASSES_ROOT, "TypeLib", &htypelib); + if(err != ERROR_SUCCESS) { + return Qnil; + } + for(i = 0; !found; i++) { + clsid = reg_enum_key(htypelib, i); + if (clsid == Qnil) + break; + err = reg_open_vkey(htypelib, clsid, &hclsid); + if (err != ERROR_SUCCESS) + continue; + fver = 0; + for(j = 0; !found; j++) { + ver = reg_enum_key(hclsid, j); + if (ver == Qnil) + break; + err = reg_open_vkey(hclsid, ver, &hversion); + if (err != ERROR_SUCCESS || fver > atof(StringValuePtr(ver))) + continue; + fver = atof(StringValuePtr(ver)); + typelib = reg_get_val(hversion, NULL); + if (typelib == Qnil) + continue; + if (rb_str_cmp(typelib, ole) == 0) { + for(k = 0; !found; k++) { + lang = reg_enum_key(hversion, k); + if (lang == Qnil) + break; + err = reg_open_vkey(hversion, lang, &hlang); + if (err == ERROR_SUCCESS) { + if ((file = reg_get_val(hlang, "win32")) != Qnil) + found = TRUE; + RegCloseKey(hlang); + } + } + } + RegCloseKey(hversion); + } + RegCloseKey(hclsid); + } + RegCloseKey(htypelib); + return file; +} + +static VALUE +typelib_file(ole) + VALUE ole; +{ + VALUE file = typelib_file_from_clsid(ole); + if (file != Qnil) { + return file; + } + return typelib_file_from_typelib(ole); +} + +static void +ole_const_load(pTypeLib, klass, self) + ITypeLib *pTypeLib; + VALUE klass; + VALUE self; +{ + unsigned int count; + unsigned int index; + int iVar; + ITypeInfo *pTypeInfo; + TYPEATTR *pTypeAttr; + VARDESC *pVarDesc; + HRESULT hr; + unsigned int len; + BSTR bstr; + char *pName = NULL; + VALUE val; + VALUE constant; + ID id; + constant = rb_hash_new(); + count = pTypeLib->lpVtbl->GetTypeInfoCount(pTypeLib); + for (index = 0; index < count; index++) { + hr = pTypeLib->lpVtbl->GetTypeInfo(pTypeLib, index, &pTypeInfo); + if (FAILED(hr)) + continue; + hr = OLE_GET_TYPEATTR(pTypeInfo, &pTypeAttr); + if(FAILED(hr)) { + OLE_RELEASE(pTypeInfo); + continue; + } + for(iVar = 0; iVar < pTypeAttr->cVars; iVar++) { + hr = pTypeInfo->lpVtbl->GetVarDesc(pTypeInfo, iVar, &pVarDesc); + if(FAILED(hr)) + continue; + if(pVarDesc->varkind == VAR_CONST && + !(pVarDesc->wVarFlags & (VARFLAG_FHIDDEN | + VARFLAG_FRESTRICTED | + VARFLAG_FNONBROWSABLE))) { + hr = pTypeInfo->lpVtbl->GetNames(pTypeInfo, pVarDesc->memid, &bstr, + 1, &len); + if(FAILED(hr) || len == 0 || !bstr) + continue; + pName = ole_wc2mb(bstr); + val = ole_variant2val(V_UNION1(pVarDesc, lpvarValue)); + *pName = toupper(*pName); + id = rb_intern(pName); + if (rb_is_const_id(id)) { + rb_define_const(klass, pName, val); + } + else { + rb_hash_aset(constant, rb_str_new2(pName), val); + } + SysFreeString(bstr); + if(pName) { + free(pName); + pName = NULL; + } + } + pTypeInfo->lpVtbl->ReleaseVarDesc(pTypeInfo, pVarDesc); + } + pTypeInfo->lpVtbl->ReleaseTypeAttr(pTypeInfo, pTypeAttr); + OLE_RELEASE(pTypeInfo); + } + rb_define_const(klass, "CONSTANTS", constant); +} + +static HRESULT +clsid_from_remote(host, com, pclsid) + VALUE host; + VALUE com; + CLSID *pclsid; +{ + HKEY hlm; + HKEY hpid; + VALUE subkey; + LONG err; + char clsid[100]; + OLECHAR *pbuf; + DWORD len; + DWORD dwtype; + HRESULT hr = S_OK; + err = RegConnectRegistry(StringValuePtr(host), HKEY_LOCAL_MACHINE, &hlm); + if (err != ERROR_SUCCESS) + return HRESULT_FROM_WIN32(err); + subkey = rb_str_new2("SOFTWARE\\Classes\\"); + rb_str_concat(subkey, com); + rb_str_cat2(subkey, "\\CLSID"); + err = RegOpenKeyEx(hlm, StringValuePtr(subkey), 0, KEY_READ, &hpid); + if (err != ERROR_SUCCESS) + hr = HRESULT_FROM_WIN32(err); + else { + len = sizeof(clsid); + err = RegQueryValueEx(hpid, "", NULL, &dwtype, clsid, &len); + if (err == ERROR_SUCCESS && dwtype == REG_SZ) { + pbuf = ole_mb2wc(clsid, -1); + hr = CLSIDFromString(pbuf, pclsid); + SysFreeString(pbuf); + } + else { + hr = HRESULT_FROM_WIN32(err); + } + RegCloseKey(hpid); + } + RegCloseKey(hlm); + return hr; +} + +static VALUE +ole_create_dcom(argc, argv, self) + int argc; + VALUE *argv; + VALUE self; +{ + VALUE ole, host, others; + HRESULT hr; + CLSID clsid; + OLECHAR *pbuf; + + COSERVERINFO serverinfo; + MULTI_QI multi_qi; + DWORD clsctx = CLSCTX_REMOTE_SERVER; + + if (!gole32) + gole32 = LoadLibrary("OLE32"); + if (!gole32) + rb_raise(rb_eRuntimeError, "Fail to load OLE32."); + if (!gCoCreateInstanceEx) + gCoCreateInstanceEx = (FNCOCREATEINSTANCEEX*) + GetProcAddress(gole32, "CoCreateInstanceEx"); + if (!gCoCreateInstanceEx) + rb_raise(rb_eRuntimeError, "CoCreateInstanceEx is not supported in this environment."); + rb_scan_args(argc, argv, "2*", &ole, &host, &others); + + pbuf = ole_mb2wc(StringValuePtr(ole), -1); + hr = CLSIDFromProgID(pbuf, &clsid); + if (FAILED(hr)) + hr = clsid_from_remote(host, ole, &clsid); + if (FAILED(hr)) + hr = CLSIDFromString(pbuf, &clsid); + SysFreeString(pbuf); + if (FAILED(hr)) + ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, + "Unknown OLE server : `%s'", + StringValuePtr(ole)); + memset(&serverinfo, 0, sizeof(COSERVERINFO)); + serverinfo.pwszName = ole_mb2wc(StringValuePtr(host), -1); + memset(&multi_qi, 0, sizeof(MULTI_QI)); + multi_qi.pIID = &IID_IDispatch; + hr = gCoCreateInstanceEx(&clsid, NULL, clsctx, &serverinfo, 1, &multi_qi); + SysFreeString(serverinfo.pwszName); + if (FAILED(hr)) + ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, + "Fail to create DCOM server : `%s' in `%s'", + StringValuePtr(ole), + StringValuePtr(host)); + + ole_set_member(self, (IDispatch*)multi_qi.pItf); + return self; +} + +static VALUE +ole_bind_obj(moniker, argc, argv, self) + VALUE moniker; + int argc; + VALUE *argv; + VALUE self; +{ + IBindCtx *pBindCtx; + IMoniker *pMoniker; + IDispatch *pDispatch; + HRESULT hr; + OLECHAR *pbuf; + ULONG eaten = 0; + + ole_initialize(); + + hr = CreateBindCtx(0, &pBindCtx); + if(FAILED(hr)) { + ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, + "Fail to create bind context"); + } + + pbuf = ole_mb2wc(StringValuePtr(moniker), -1); + hr = MkParseDisplayName(pBindCtx, pbuf, &eaten, &pMoniker); + SysFreeString(pbuf); + if(FAILED(hr)) { + OLE_RELEASE(pBindCtx); + ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, + "Faile to parse display name of moniker:%s", + StringValuePtr(moniker)); + } + hr = pMoniker->lpVtbl->BindToObject(pMoniker, pBindCtx, NULL, + &IID_IDispatch, + (void**)&pDispatch); + OLE_RELEASE(pMoniker); + OLE_RELEASE(pBindCtx); + + if(FAILED(hr)) { + ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, + "Faile to bind moniker:%s", + StringValuePtr(moniker)); + } + return create_win32ole_object(self, pDispatch, argc, argv); +} + +/* + * WIN32OLE.connect( ole ) --> aWIN32OLE + * ---- + * Returns running OLE Automation object or WIN32OLE object from moniker. + * 1st argument should be OLE program id or class id or moniker. + */ +static VALUE +fole_s_connect(argc, argv, self) + int argc; + VALUE *argv; + VALUE self; +{ + VALUE svr_name; + VALUE others; + HRESULT hr; + CLSID clsid; + OLECHAR *pBuf; + IDispatch *pDispatch; + IUnknown *pUnknown; + + /* initialize to use OLE */ + ole_initialize(); + + rb_scan_args(argc, argv, "1*", &svr_name, &others); + + /* get CLSID from OLE server name */ + pBuf = ole_mb2wc(StringValuePtr(svr_name), -1); + hr = CLSIDFromProgID(pBuf, &clsid); + if(FAILED(hr)) { + hr = CLSIDFromString(pBuf, &clsid); + } + SysFreeString(pBuf); + if(FAILED(hr)) { + return ole_bind_obj(svr_name, argc, argv, self); + } + + hr = GetActiveObject(&clsid, 0, &pUnknown); + if (FAILED(hr)) { + ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, + "Not Running OLE server : `%s'", StringValuePtr(svr_name)); + } + hr = pUnknown->lpVtbl->QueryInterface(pUnknown, &IID_IDispatch, + (void **)&pDispatch); + if(FAILED(hr)) { + OLE_RELEASE(pUnknown); + ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, + "Fail to create WIN32OLE server : `%s'", + StringValuePtr(svr_name)); + } + + OLE_RELEASE(pUnknown); + + return create_win32ole_object(self, pDispatch, argc, argv); +} + +/* + * WIN32OLE.const_load( ole, mod = WIN32OLE) + * ---- + * Defines the constants of OLE Automation server as mod's constants. + * If 2nd argument is omitted, the default is WIN32OLE. + */ +static VALUE +fole_s_const_load(argc, argv, self) + int argc; + VALUE *argv; + VALUE self; +{ + VALUE ole; + VALUE klass; + struct oledata *pole; + ITypeInfo *pTypeInfo; + ITypeLib *pTypeLib; + unsigned int index; + HRESULT hr; + OLECHAR *pBuf; + VALUE file; + LCID lcid = LOCALE_SYSTEM_DEFAULT; + + rb_scan_args(argc, argv, "11", &ole, &klass); + if (TYPE(klass) != T_CLASS && + TYPE(klass) != T_MODULE && + TYPE(klass) != T_NIL) { + rb_raise(rb_eTypeError, "2nd paramator must be Class or Module."); + } + if (rb_obj_is_kind_of(ole, cWIN32OLE)) { + Data_Get_Struct(ole, struct oledata, pole); + hr = pole->pDispatch->lpVtbl->GetTypeInfo(pole->pDispatch, + 0, lcid, &pTypeInfo); + if(FAILED(hr)) { + ole_raise(hr, rb_eRuntimeError, "fail to GetTypeInfo"); + } + hr = pTypeInfo->lpVtbl->GetContainingTypeLib(pTypeInfo, &pTypeLib, &index); + if(FAILED(hr)) { + OLE_RELEASE(pTypeInfo); + ole_raise(hr, rb_eRuntimeError, "fail to GetContainingTypeLib"); + } + OLE_RELEASE(pTypeInfo); + if(TYPE(klass) != T_NIL) { + ole_const_load(pTypeLib, klass, self); + } + else { + ole_const_load(pTypeLib, cWIN32OLE, self); + } + OLE_RELEASE(pTypeLib); + } + else if(TYPE(ole) == T_STRING) { + file = typelib_file(ole); + if (file == Qnil) { + file = ole; + } + pBuf = ole_mb2wc(StringValuePtr(file), -1); + hr = LoadTypeLibEx(pBuf, REGKIND_NONE, &pTypeLib); + SysFreeString(pBuf); + if (FAILED(hr)) + ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "Fail to LoadTypeLibEx"); + if(TYPE(klass) != T_NIL) { + ole_const_load(pTypeLib, klass, self); + } + else { + ole_const_load(pTypeLib, cWIN32OLE, self); + } + OLE_RELEASE(pTypeLib); + } + else { + rb_raise(rb_eTypeError, "1st paramator must be WIN32OLE instance"); + } + return Qnil; +} + +static VALUE +ole_classes_from_typelib(pTypeLib, classes) + ITypeLib *pTypeLib; + VALUE classes; +{ + + long count; + int i; + HRESULT hr; + BSTR bstr; + ITypeInfo *pTypeInfo; + VALUE type; + + count = pTypeLib->lpVtbl->GetTypeInfoCount(pTypeLib); + for (i = 0; i < count; i++) { + hr = pTypeLib->lpVtbl->GetDocumentation(pTypeLib, i, + &bstr, NULL, NULL, NULL); + if (FAILED(hr)) + continue; + + hr = pTypeLib->lpVtbl->GetTypeInfo(pTypeLib, i, &pTypeInfo); + if (FAILED(hr)) + continue; + + type = foletype_s_allocate(cWIN32OLE_TYPE); + oletype_set_member(type, pTypeInfo, WC2VSTR(bstr)); + + rb_ary_push(classes, type); + OLE_RELEASE(pTypeInfo); + } + return classes; +} + +static ULONG +reference_count(pole) + struct oledata * pole; +{ + ULONG n = 0; + if(pole->pDispatch) { + OLE_ADDREF(pole->pDispatch); + n = OLE_RELEASE(pole->pDispatch); + } + return n; +} + +/* + * WIN32OLE.ole_reference_count(aWIN32OLE) --> number + * ---- + * Returns reference counter of Dispatch interface of WIN32OLE object. + * You should not use this method because this method + * exists only for debugging WIN32OLE. + */ +static VALUE +fole_s_reference_count(self, obj) + VALUE self; + VALUE obj; +{ + struct oledata * pole; + Data_Get_Struct(obj, struct oledata, pole); + return INT2NUM(reference_count(pole)); +} + +/* + * WIN32OLE.ole_free(aWIN32OLE) --> number + * ---- + * Invokes Release method of Dispatch interface of WIN32OLE object. + * You should not use this method because this method + * exists only for debugging WIN32OLE. + * The return value is reference counter of OLE object. + */ +static VALUE +fole_s_free(self, obj) + VALUE self; + VALUE obj; +{ + ULONG n = 0; + struct oledata * pole; + Data_Get_Struct(obj, struct oledata, pole); + if(pole->pDispatch) { + if (reference_count(pole) > 0) { + n = OLE_RELEASE(pole->pDispatch); + } + } + return INT2NUM(n); +} + +static HWND +ole_show_help(helpfile, helpcontext) + VALUE helpfile; + VALUE helpcontext; +{ + FNHTMLHELP *pfnHtmlHelp; + HWND hwnd = 0; + + if(!ghhctrl) + ghhctrl = LoadLibrary("HHCTRL.OCX"); + if (!ghhctrl) + return hwnd; + pfnHtmlHelp = (FNHTMLHELP*)GetProcAddress(ghhctrl, "HtmlHelpA"); + if (!pfnHtmlHelp) + return hwnd; + hwnd = pfnHtmlHelp(GetDesktopWindow(), StringValuePtr(helpfile), + 0x0f, NUM2INT(helpcontext)); + if (hwnd == 0) + hwnd = pfnHtmlHelp(GetDesktopWindow(), StringValuePtr(helpfile), + 0, NUM2INT(helpcontext)); + return hwnd; +} + +/* + * WIN32OLE.ole_show_help(obj [,helpcontext]) + * ---- + * Displays helpfile. The 1st argument specifies WIN32OLE_TYPE + * object or WIN32OLE_METHOD object or helpfile. + */ +static VALUE +fole_s_show_help(argc, argv, self) + int argc; + VALUE *argv; + VALUE self; +{ + VALUE target; + VALUE helpcontext; + VALUE helpfile; + VALUE name; + HWND hwnd; + rb_scan_args(argc, argv, "11", &target, &helpcontext); + if (rb_obj_is_kind_of(target, cWIN32OLE_TYPE) || + rb_obj_is_kind_of(target, cWIN32OLE_METHOD)) { + helpfile = rb_funcall(target, rb_intern("helpfile"), 0); + if(strlen(StringValuePtr(helpfile)) == 0) { + name = rb_ivar_get(target, rb_intern("name")); + rb_raise(rb_eRuntimeError, "no helpfile of `%s'", + StringValuePtr(name)); + } + helpcontext = rb_funcall(target, rb_intern("helpcontext"), 0); + } else { + helpfile = target; + } + if (TYPE(helpfile) != T_STRING) { + rb_raise(rb_eTypeError, "1st parametor must be (String|WIN32OLE_TYPE|WIN32OLE_METHOD)."); + } + hwnd = ole_show_help(helpfile, helpcontext); + if(hwnd == 0) { + rb_raise(rb_eRuntimeError, "fail to open help file:%s", + StringValuePtr(helpfile)); + } + return Qnil; +} + +static VALUE +fole_initialize(argc, argv, self) + int argc; + VALUE *argv; + VALUE self; +{ + VALUE svr_name; + VALUE host; + VALUE others; + HRESULT hr; + CLSID clsid; + OLECHAR *pBuf; + IDispatch *pDispatch; + + rb_call_super(0, 0); + rb_scan_args(argc, argv, "11*", &svr_name, &host, &others); + + if (!NIL_P(host)) + return ole_create_dcom(argc, argv, self); + + /* get CLSID from OLE server name */ + pBuf = ole_mb2wc(StringValuePtr(svr_name), -1); + hr = CLSIDFromProgID(pBuf, &clsid); + if(FAILED(hr)) { + hr = CLSIDFromString(pBuf, &clsid); + } + SysFreeString(pBuf); + if(FAILED(hr)) { + ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, + "Unknown OLE server : `%s'", + StringValuePtr(svr_name)); + } + + /* get IDispatch interface */ + hr = CoCreateInstance(&clsid, NULL, CLSCTX_INPROC_SERVER | CLSCTX_LOCAL_SERVER, + &IID_IDispatch, (void**)&pDispatch); + if(FAILED(hr)) { + ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, + "Fail to create WIN32OLE object from `%s'", + StringValuePtr(svr_name)); + } + + ole_set_member(self, pDispatch); + return self; +} + +static VALUE +hash2named_arg(pair, pOp) + VALUE pair; + struct oleparam* pOp; +{ + unsigned int index, i; + VALUE key, value; + index = pOp->dp.cNamedArgs; + + /*------------------------------------- + the data-type of key must be String + ---------------------------------------*/ + key = rb_ary_entry(pair, 0); + if(TYPE(key) != T_STRING) { + /* clear name of dispatch parameters */ + for(i = 1; i < index + 1; i++) { + SysFreeString(pOp->pNamedArgs[i]); + } + /* clear dispatch parameters */ + for(i = 0; i < index; i++ ) { + VariantClear(&(pOp->dp.rgvarg[i])); + } + /* raise an exception */ + Check_Type(key, T_STRING); + } + + /* pNamedArgs[0] is , so "index + 1" */ + pOp->pNamedArgs[index + 1] = ole_mb2wc(StringValuePtr(key), -1); + + value = rb_ary_entry(pair, 1); + VariantInit(&(pOp->dp.rgvarg[index])); + ole_val2variant(value, &(pOp->dp.rgvarg[index])); + + pOp->dp.cNamedArgs += 1; + return Qnil; +} + +static VALUE +ole_invoke(argc, argv, self, wFlags) + int argc; + VALUE *argv; + VALUE self; + USHORT wFlags; +{ + LCID lcid = LOCALE_SYSTEM_DEFAULT; + struct oledata *pole; + HRESULT hr; + VALUE cmd; + VALUE paramS; + VALUE param; + VALUE obj; + VALUE v; + + BSTR wcmdname; + + DISPID DispID; + DISPID* pDispID; + EXCEPINFO excepinfo; + VARIANT result; + VALUE args; + VARIANTARG* realargs = NULL; + unsigned int argErr = 0; + unsigned int i; + unsigned int cNamedArgs; + struct oleparam op; + memset(&excepinfo, 0, sizeof(EXCEPINFO)); + + VariantInit(&result); + + op.dp.rgvarg = NULL; + op.dp.rgdispidNamedArgs = NULL; + op.dp.cNamedArgs = 0; + op.dp.cArgs = 0; + + rb_scan_args(argc, argv, "1*", &cmd, ¶mS); + Data_Get_Struct(self, struct oledata, pole); + if(!pole->pDispatch) { + rb_raise(rb_eRuntimeError, "Fail to get dispatch interface."); + } + wcmdname = ole_mb2wc(StringValuePtr(cmd), -1); + hr = pole->pDispatch->lpVtbl->GetIDsOfNames( pole->pDispatch, &IID_NULL, + &wcmdname, 1, lcid, &DispID); + SysFreeString(wcmdname); + if(FAILED(hr)) { + ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, + "Unknown property or method : `%s'", + StringValuePtr(cmd)); + } + + /* pick up last argument of method */ + param = rb_ary_entry(paramS, argc-2); + + op.dp.cNamedArgs = 0; + + /* if last arg is hash object */ + if(TYPE(param) == T_HASH) { + /*------------------------------------------ + hash object ==> named dispatch parameters + --------------------------------------------*/ + cNamedArgs = NUM2INT(rb_funcall(param, rb_intern("length"), 0)); + op.dp.cArgs = cNamedArgs + argc - 2; + op.pNamedArgs = ALLOCA_N(OLECHAR*, cNamedArgs + 1); + op.dp.rgvarg = ALLOCA_N(VARIANTARG, op.dp.cArgs); + rb_iterate(rb_each, param, hash2named_arg, (VALUE)&op); + + pDispID = ALLOCA_N(DISPID, cNamedArgs + 1); + op.pNamedArgs[0] = ole_mb2wc(StringValuePtr(cmd), -1); + hr = pole->pDispatch->lpVtbl->GetIDsOfNames(pole->pDispatch, + &IID_NULL, + op.pNamedArgs, + op.dp.cNamedArgs + 1, + lcid, pDispID); + for(i = 0; i < op.dp.cNamedArgs + 1; i++) { + SysFreeString(op.pNamedArgs[i]); + op.pNamedArgs[i] = NULL; + } + if(FAILED(hr)) { + /* clear dispatch parameters */ + for(i = 0; i < op.dp.cArgs; i++ ) { + VariantClear(&op.dp.rgvarg[i]); + } + ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, + "FAIL to get named argument info : `%s'", + StringValuePtr(cmd)); + } + op.dp.rgdispidNamedArgs = &(pDispID[1]); + } + else { + cNamedArgs = 0; + op.dp.cArgs = argc - 1; + op.pNamedArgs = ALLOCA_N(OLECHAR*, cNamedArgs + 1); + if (op.dp.cArgs > 0) { + op.dp.rgvarg = ALLOCA_N(VARIANTARG, op.dp.cArgs); + } + } + /*-------------------------------------- + non hash args ==> dispatch parameters + ----------------------------------------*/ + if(op.dp.cArgs > cNamedArgs) { + realargs = ALLOCA_N(VARIANTARG, op.dp.cArgs-cNamedArgs+1); + for(i = cNamedArgs; i < op.dp.cArgs; i++) { + int n = op.dp.cArgs - i + cNamedArgs - 1; + VariantInit(&realargs[n]); + VariantInit(&op.dp.rgvarg[n]); + param = rb_ary_entry(paramS, i-cNamedArgs); + + ole_val2variant(param, &realargs[n]); + V_VT(&op.dp.rgvarg[n]) = VT_VARIANT | VT_BYREF; + V_VARIANTREF(&op.dp.rgvarg[n]) = &realargs[n]; + + } + } + /* apparent you need to call propput, you need this */ + if (wFlags & DISPATCH_PROPERTYPUT) { + if (op.dp.cArgs == 0) + return ResultFromScode(E_INVALIDARG); + + op.dp.cNamedArgs = 1; + op.dp.rgdispidNamedArgs = ALLOCA_N( DISPID, 1 ); + op.dp.rgdispidNamedArgs[0] = DISPID_PROPERTYPUT; + } + + hr = pole->pDispatch->lpVtbl->Invoke(pole->pDispatch, DispID, + &IID_NULL, lcid, wFlags, &op.dp, + &result, &excepinfo, &argErr); + if (FAILED(hr)) { + /* mega kludge. if a method in WORD is called and we ask + * for a result when one is not returned then + * hResult == DISP_E_EXCEPTION. this only happens on + * functions whose DISPID > 0x8000 */ + if (hr == DISP_E_EXCEPTION && DispID > 0x8000) { + memset(&excepinfo, 0, sizeof(EXCEPINFO)); + hr = pole->pDispatch->lpVtbl->Invoke(pole->pDispatch, DispID, + &IID_NULL, lcid, wFlags, + &op.dp, NULL, + &excepinfo, &argErr); + + } + } + /* clear dispatch parameter */ + if(op.dp.cArgs > cNamedArgs) { + args = rb_cvar_get(cWIN32OLE, rb_intern("ARGV")); + rb_funcall(args, rb_intern("clear"), 0); + for(i = cNamedArgs; i < op.dp.cArgs; i++) { + int n = op.dp.cArgs - i + cNamedArgs - 1; + rb_ary_push(args, ole_variant2val(&realargs[n])); + VariantClear(&realargs[n]); + } + } + else { + for(i = 0; i < op.dp.cArgs; i++) { + VariantClear(&op.dp.rgvarg[i]); + } + } + + if (FAILED(hr)) { + v = ole_excepinfo2msg(&excepinfo); + ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "%s%s", + StringValuePtr(cmd), StringValuePtr(v)); + } + obj = ole_variant2val(&result); + VariantClear(&result); + return obj; +} + +static VALUE +fole_invoke(argc, argv, self) + int argc; + VALUE *argv; + VALUE self; +{ + return ole_invoke(argc, argv, self, DISPATCH_METHOD|DISPATCH_PROPERTYGET); +} + +static VALUE +ole_invoke2(self, dispid, args, types, dispkind) + VALUE self; + VALUE dispid; + VALUE args; + VALUE types; + USHORT dispkind; +{ + HRESULT hr; + struct oledata *pole; + unsigned int argErr = 0; + EXCEPINFO excepinfo; + VARIANT result; + DISPPARAMS dispParams; + VARIANTARG* realargs = NULL; + int i, j; + VALUE obj = Qnil; + VALUE tp, param; + VALUE v; + VARTYPE vt; + + Check_Type(args, T_ARRAY); + Check_Type(types, T_ARRAY); + + memset(&excepinfo, 0, sizeof(EXCEPINFO)); + memset(&dispParams, 0, sizeof(DISPPARAMS)); + VariantInit(&result); + Data_Get_Struct(self, struct oledata, pole); + + dispParams.cArgs = RARRAY(args)->len; + dispParams.rgvarg = ALLOCA_N(VARIANTARG, dispParams.cArgs); + realargs = ALLOCA_N(VARIANTARG, dispParams.cArgs); + for (i = 0, j = dispParams.cArgs - 1; i < (int)dispParams.cArgs; i++, j--) + { + VariantInit(&realargs[i]); + VariantInit(&dispParams.rgvarg[i]); + tp = rb_ary_entry(types, j); + vt = (VARTYPE)FIX2INT(tp); + V_VT(&dispParams.rgvarg[i]) = vt; + param = rb_ary_entry(args, j); + if (param == Qnil) + { + + V_VT(&dispParams.rgvarg[i]) = V_VT(&realargs[i]) = VT_ERROR; + V_ERROR(&dispParams.rgvarg[i]) = V_ERROR(&realargs[i]) = DISP_E_PARAMNOTFOUND; + } + else + { + if (vt & VT_ARRAY) + { + int ent; + LPBYTE pb; + short* ps; + LPLONG pl; + VARIANT* pv; + CY *py; + VARTYPE v; + SAFEARRAYBOUND rgsabound[1]; + Check_Type(param, T_ARRAY); + rgsabound[0].lLbound = 0; + rgsabound[0].cElements = RARRAY(param)->len; + v = vt & ~(VT_ARRAY | VT_BYREF); + V_ARRAY(&realargs[i]) = SafeArrayCreate(v, 1, rgsabound); + V_VT(&realargs[i]) = VT_ARRAY | v; + SafeArrayLock(V_ARRAY(&realargs[i])); + pb = V_ARRAY(&realargs[i])->pvData; + ps = V_ARRAY(&realargs[i])->pvData; + pl = V_ARRAY(&realargs[i])->pvData; + py = V_ARRAY(&realargs[i])->pvData; + pv = V_ARRAY(&realargs[i])->pvData; + for (ent = 0; ent < (int)rgsabound[0].cElements; ent++) + { + VARIANT velem; + VALUE elem = rb_ary_entry(param, ent); + ole_val2variant(elem, &velem); + if (v != VT_VARIANT) + { + VariantChangeTypeEx(&velem, &velem, + LOCALE_SYSTEM_DEFAULT, 0, v); + } + switch (v) + { + /* 128 bits */ + case VT_VARIANT: + *pv++ = velem; + break; + /* 64 bits */ + case VT_R8: + case VT_CY: + case VT_DATE: + *py++ = V_CY(&velem); + break; + /* 16 bits */ + case VT_BOOL: + case VT_I2: + case VT_UI2: + *ps++ = V_I2(&velem); + break; + /* 8 bites */ + case VT_UI1: + case VT_I1: + *pb++ = V_UI1(&velem); + break; + /* 32 bits */ + default: + *pl++ = V_I4(&velem); + break; + } + } + SafeArrayUnlock(V_ARRAY(&realargs[i])); + } + else + { + ole_val2variant(param, &realargs[i]); + if ((vt & (~VT_BYREF)) != VT_VARIANT) + { + hr = VariantChangeTypeEx(&realargs[i], &realargs[i], + LOCALE_SYSTEM_DEFAULT, 0, + (VARTYPE)(vt & (~VT_BYREF))); + if (hr != S_OK) + { + rb_raise(rb_eTypeError, "not valid value"); + } + } + } + if ((vt & VT_BYREF) || vt == VT_VARIANT) + { + if (vt == VT_VARIANT) + V_VT(&dispParams.rgvarg[i]) = VT_VARIANT | VT_BYREF; + switch (vt & (~VT_BYREF)) + { + /* 128 bits */ + case VT_VARIANT: + V_VARIANTREF(&dispParams.rgvarg[i]) = &realargs[i]; + break; + /* 64 bits */ + case VT_R8: + case VT_CY: + case VT_DATE: + V_CYREF(&dispParams.rgvarg[i]) = &V_CY(&realargs[i]); + break; + /* 16 bits */ + case VT_BOOL: + case VT_I2: + case VT_UI2: + V_I2REF(&dispParams.rgvarg[i]) = &V_I2(&realargs[i]); + break; + /* 8 bites */ + case VT_UI1: + case VT_I1: + V_UI1REF(&dispParams.rgvarg[i]) = &V_UI1(&realargs[i]); + break; + /* 32 bits */ + default: + V_I4REF(&dispParams.rgvarg[i]) = &V_I4(&realargs[i]); + break; + } + } + else + { + /* copy 64 bits of data */ + V_CY(&dispParams.rgvarg[i]) = V_CY(&realargs[i]); + } + } + } + + if (dispkind & DISPATCH_PROPERTYPUT) { + dispParams.cNamedArgs = 1; + dispParams.rgdispidNamedArgs = ALLOCA_N( DISPID, 1 ); + dispParams.rgdispidNamedArgs[0] = DISPID_PROPERTYPUT; + } + + hr = pole->pDispatch->lpVtbl->Invoke(pole->pDispatch, FIX2INT(dispid), + &IID_NULL, LOCALE_SYSTEM_DEFAULT, + dispkind, + &dispParams, &result, + &excepinfo, &argErr); + + if (FAILED(hr)) { + v = ole_excepinfo2msg(&excepinfo); + ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "_invoke %s", + StringValuePtr(v)); + } + + /* clear dispatch parameter */ + if(dispParams.cArgs > 0) { + VALUE argv = rb_cvar_get(cWIN32OLE, rb_intern("ARGV")); + rb_funcall(argv, rb_intern("clear"), 0); + for(i = dispParams.cArgs - 1; i >= 0; i--) { + rb_ary_push(argv, ole_variant2val(&realargs[i])); + VariantClear(&realargs[i]); + } + } + + obj = ole_variant2val(&result); + VariantClear(&result); + return obj; +} + +/* + * WIN32OLE#_invoke(dispid, args, types) + * ---- + * Runs the early binding method. + * The 1st argument specifies dispatch ID, + * the 2nd argument specifies the array of arguments, + * the 3rd argument specifies the array of the type of arguments. + */ +static VALUE +fole_invoke2(self, dispid, args, types) + VALUE self; + VALUE dispid; + VALUE args; + VALUE types; +{ + return ole_invoke2(self, dispid, args, types, DISPATCH_METHOD); +} + +/* + * WIN32OLE#_getproperty(dispid, args, types) + * ---- + * Runs the early binding method to get property. + * The 1st argument specifies dispatch ID, + * the 2nd argument specifies the array of arguments, + * the 3rd argument specifies the array of the type of arguments. + */ +static VALUE +fole_getproperty2(self, dispid, args, types) + VALUE self; + VALUE dispid; + VALUE args; + VALUE types; +{ + return ole_invoke2(self, dispid, args, types, DISPATCH_PROPERTYGET); +} + +/* + * WIN32OLE#_setproperty(dispid, args, types) + * ---- + * Runs the early binding method to set property. + * The 1st argument specifies dispatch ID, + * the 2nd argument specifies the array of arguments, + * the 3rd argument specifies the array of the type of arguments. + */ +static VALUE +fole_setproperty2(self, dispid, args, types) + VALUE self; + VALUE dispid; + VALUE args; + VALUE types; +{ + return ole_invoke2(self, dispid, args, types, DISPATCH_PROPERTYPUT); +} + +/* + * WIN32OLE['property']=val + * + * WIN32OLE.setproperty('property', [arg1, arg2,] val) + * ----- + * Sets property of OLE object. + * When you want to set property with argument, you can use setproperty method. + */ +static VALUE +fole_setproperty(argc, argv, self) + int argc; + VALUE *argv; + VALUE self; +{ + return ole_invoke(argc, argv, self, DISPATCH_PROPERTYPUT); +} + +/* + * WIN32OLE['property'] + * ----- + * Returns property of OLE object. + */ +static VALUE +fole_getproperty(self, property) + VALUE self, property; +{ + return ole_invoke(1, &property, self, DISPATCH_PROPERTYGET); +} + +static VALUE +ole_propertyput(self, property, value) + VALUE self, property, value; +{ + struct oledata *pole; + unsigned argErr; + unsigned int index; + HRESULT hr; + EXCEPINFO excepinfo; + DISPID dispID = DISPID_VALUE; + DISPID dispIDParam = DISPID_PROPERTYPUT; + USHORT wFlags = DISPATCH_PROPERTYPUT; + DISPPARAMS dispParams; + VARIANTARG propertyValue[2]; + OLECHAR* pBuf[1]; + VALUE v; + LCID lcid = LOCALE_SYSTEM_DEFAULT; + dispParams.rgdispidNamedArgs = &dispIDParam; + dispParams.rgvarg = propertyValue; + dispParams.cNamedArgs = 1; + dispParams.cArgs = 1; + + VariantInit(&propertyValue[0]); + VariantInit(&propertyValue[1]); + memset(&excepinfo, 0, sizeof(excepinfo)); + + Data_Get_Struct(self, struct oledata, pole); + + /* get ID from property name */ + pBuf[0] = ole_mb2wc(StringValuePtr(property), -1); + hr = pole->pDispatch->lpVtbl->GetIDsOfNames(pole->pDispatch, &IID_NULL, + pBuf, 1, lcid, &dispID); + SysFreeString(pBuf[0]); + pBuf[0] = NULL; + + if(FAILED(hr)) { + ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, + "Unknown property or method : `%s'", + StringValuePtr(property)); + } + /* set property value */ + ole_val2variant(value, &propertyValue[0]); + hr = pole->pDispatch->lpVtbl->Invoke(pole->pDispatch, dispID, &IID_NULL, + lcid, wFlags, &dispParams, + NULL, &excepinfo, &argErr); + + for(index = 0; index < dispParams.cArgs; ++index) { + VariantClear(&propertyValue[index]); + } + if (FAILED(hr)) { + v = ole_excepinfo2msg(&excepinfo); + ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, StringValuePtr(v)); + } + return Qnil; +} + +/* + * WIN32OLE#each {|i|...} + * ----- + * Iterates over each item of OLE collection which has IEnumVARIANT interface. + */ +static VALUE +fole_each(self) + VALUE self; +{ + LCID lcid = LOCALE_SYSTEM_DEFAULT; + + struct oledata *pole; + + unsigned int argErr; + EXCEPINFO excepinfo; + DISPPARAMS dispParams; + VARIANT result, variant; + HRESULT hr; + IEnumVARIANT *pEnum = NULL; + + VALUE obj; + + VariantInit(&result); + dispParams.rgvarg = NULL; + dispParams.rgdispidNamedArgs = NULL; + dispParams.cNamedArgs = 0; + dispParams.cArgs = 0; + memset(&excepinfo, 0, sizeof(excepinfo)); + + Data_Get_Struct(self, struct oledata, pole); + hr = pole->pDispatch->lpVtbl->Invoke(pole->pDispatch, DISPID_NEWENUM, + &IID_NULL, lcid, + DISPATCH_METHOD | DISPATCH_PROPERTYGET, + &dispParams, &result, + &excepinfo, &argErr); + + if (FAILED(hr)) { + VariantClear(&result); + ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "Fail to get IEnum Interface"); + } + + if (V_VT(&result) == VT_UNKNOWN) + hr = V_UNKNOWN(&result)->lpVtbl->QueryInterface(V_UNKNOWN(&result), + &IID_IEnumVARIANT, + (void**)&pEnum); + else if (V_VT(&result) == VT_DISPATCH) + hr = V_DISPATCH(&result)->lpVtbl->QueryInterface(V_DISPATCH(&result), + &IID_IEnumVARIANT, + (void**)&pEnum); + if (FAILED(hr) || !pEnum) { + VariantClear(&result); + ole_raise(hr, rb_eRuntimeError, "Fail to get IEnum Interface"); + } + + VariantInit(&variant); + while(pEnum->lpVtbl->Next(pEnum, 1, &variant, NULL) == S_OK) { + obj = ole_variant2val(&variant); + rb_yield(obj); + VariantClear(&variant); + VariantInit(&variant); + } + VariantClear(&result); + OLE_RELEASE(pEnum); + return Qnil; +} + +/* + * WIN32OLE#method_missing(id [,arg1, arg2, ...]) + * ---- + * Calls WIN32OLE#invoke method. + */ +static VALUE +fole_missing(argc, argv, self) + int argc; + VALUE *argv; + VALUE self; +{ + ID id; + char* mname; + int n; + id = rb_to_id(argv[0]); + mname = rb_id2name(id); + if(!mname) { + rb_raise(rb_eRuntimeError, "Fail : Unknown method or property"); + } + n = strlen(mname); + if(mname[n-1] == '=') { + argv[0] = rb_str_new(mname, n-1); + + return ole_propertyput(self, argv[0], argv[1]); + } + else { + argv[0] = rb_str_new2(mname); + return ole_invoke(argc, argv, self, DISPATCH_METHOD|DISPATCH_PROPERTYGET); + } +} + +static VALUE +ole_methods_sub(pOwnerTypeInfo, pTypeInfo, methods, mask) + ITypeInfo *pOwnerTypeInfo; + ITypeInfo *pTypeInfo; + VALUE methods; + int mask; +{ + HRESULT hr; + TYPEATTR *pTypeAttr; + BSTR bstr; + char *pstr; + FUNCDESC *pFuncDesc; + VALUE method; + DWORD i; + hr = OLE_GET_TYPEATTR(pTypeInfo, &pTypeAttr); + if (FAILED(hr)) { + ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "Fail to GetTypeAttr"); + } + for(i = 0; i < pTypeAttr->cFuncs; i++) { + pstr = NULL; + hr = pTypeInfo->lpVtbl->GetFuncDesc(pTypeInfo, i, &pFuncDesc); + if (FAILED(hr)) + continue; + + hr = pTypeInfo->lpVtbl->GetDocumentation(pTypeInfo, pFuncDesc->memid, + &bstr, NULL, NULL, NULL); + if (FAILED(hr)) { + pTypeInfo->lpVtbl->ReleaseFuncDesc(pTypeInfo, pFuncDesc); + continue; + } + if(pFuncDesc->invkind & mask) { + method = folemethod_s_allocate(cWIN32OLE_METHOD); + olemethod_set_member(method, pTypeInfo, pOwnerTypeInfo, + i, WC2VSTR(bstr)); + rb_ary_push(methods, method); + } + pTypeInfo->lpVtbl->ReleaseFuncDesc(pTypeInfo, pFuncDesc); + pFuncDesc=NULL; + } + OLE_RELEASE_TYPEATTR(pTypeInfo, pTypeAttr); + + return methods; +} + +static VALUE +ole_methods_from_typeinfo(pTypeInfo, mask) + 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, eWIN32OLE_RUNTIME_ERROR, "Fail 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 +ole_methods(self,mask) + VALUE self; + int mask; +{ + int iVar; + int count; + ITypeInfo *pTypeInfo; + HRESULT hr; + VALUE methods; + struct oledata *pole; + LCID lcid = LOCALE_SYSTEM_DEFAULT; + + Data_Get_Struct(self, struct oledata, pole); + methods = rb_ary_new(); + count = 0; + + hr = pole->pDispatch->lpVtbl->GetTypeInfoCount(pole->pDispatch, &count); + if (FAILED(hr)) + return methods; + for( iVar=0; iVarpDispatch->lpVtbl->GetTypeInfo( pole->pDispatch, 0, lcid, &pTypeInfo ); + if(FAILED(hr)) + continue; + rb_ary_concat(methods, ole_methods_from_typeinfo(pTypeInfo, mask)); + OLE_RELEASE(pTypeInfo); + } + return methods; +} + +/* + * WIN32OLE#ole_methods + * ---- + * Returns OLE methods + */ +static VALUE +fole_methods( self ) + VALUE self; +{ + return ole_methods( self, INVOKE_FUNC | INVOKE_PROPERTYGET | INVOKE_PROPERTYPUT); +} + +/* + * WIN32OLE#ole_get_methods + * ---- + * Returns get properties. + */ +static VALUE +fole_get_methods( argc, argv, self ) + int argc; + VALUE *argv; + VALUE self; +{ + return ole_methods( self, INVOKE_PROPERTYGET); +} + +/* + * WIN32OLE#ole_put_methods + * ---- + * Returns put properties. + */ +static VALUE +fole_put_methods( argc, argv, self ) + int argc; + VALUE *argv; + VALUE self; +{ + return ole_methods( self, INVOKE_PROPERTYPUT); +} + +/* + * WIN32OLE#ole_func_methods + * --- + * Returns OLE func methods. + */ +static VALUE +fole_func_methods( argc, argv, self ) + int argc; + VALUE *argv; + VALUE self; +{ + return ole_methods( self, INVOKE_FUNC); +} + +/* + * WIN32OLE#ole_obj_help + * ---- + * Returns WIN32OLE_TYPE object. + */ +static VALUE +fole_obj_help( self ) + VALUE self; +{ + unsigned int index; + ITypeInfo *pTypeInfo; + ITypeLib *pTypeLib; + HRESULT hr; + struct oledata *pole; + BSTR bstr; + LCID lcid = LOCALE_SYSTEM_DEFAULT; + VALUE type = Qnil; + + Data_Get_Struct(self, struct oledata, pole); + + hr = pole->pDispatch->lpVtbl->GetTypeInfo( pole->pDispatch, 0, lcid, &pTypeInfo ); + if(FAILED(hr)) { + ole_raise(hr, rb_eRuntimeError, "fail to GetTypeInfo"); + } + hr = pTypeInfo->lpVtbl->GetContainingTypeLib( pTypeInfo, &pTypeLib, &index ); + if(FAILED(hr)) { + OLE_RELEASE(pTypeInfo); + ole_raise(hr, rb_eRuntimeError, "fail to GetContainingTypeLib"); + } + hr = pTypeLib->lpVtbl->GetDocumentation( pTypeLib, index, + &bstr, NULL, NULL, NULL); + if (SUCCEEDED(hr)) { + type = foletype_s_allocate(cWIN32OLE_TYPE); + oletype_set_member(type, pTypeInfo, WC2VSTR(bstr)); + } + OLE_RELEASE(pTypeLib); + OLE_RELEASE(pTypeInfo); + + return type; +} + +static HRESULT +ole_docinfo_from_type(pTypeInfo, name, helpstr, helpcontext, helpfile) + ITypeInfo *pTypeInfo; + BSTR *name; + BSTR *helpstr; + DWORD *helpcontext; + BSTR *helpfile; +{ + HRESULT hr; + ITypeLib *pTypeLib; + UINT i; + + hr = pTypeInfo->lpVtbl->GetContainingTypeLib(pTypeInfo, &pTypeLib, &i); + if (FAILED(hr)) { + return hr; + } + + hr = pTypeLib->lpVtbl->GetDocumentation(pTypeLib, i, + name, helpstr, + helpcontext, helpfile); + if (FAILED(hr)) { + OLE_RELEASE(pTypeLib); + return hr; + } + OLE_RELEASE(pTypeLib); + return hr; +} + +static VALUE +ole_usertype2val(pTypeInfo, pTypeDesc, typedetails) + ITypeInfo *pTypeInfo; + TYPEDESC *pTypeDesc; + VALUE typedetails; +{ + HRESULT hr; + BSTR bstr; + ITypeInfo *pRefTypeInfo; + VALUE type = Qnil; + + hr = pTypeInfo->lpVtbl->GetRefTypeInfo(pTypeInfo, + V_UNION1(pTypeDesc, hreftype), + &pRefTypeInfo); + if(FAILED(hr)) + return Qnil; + hr = ole_docinfo_from_type(pRefTypeInfo, &bstr, NULL, NULL, NULL); + if(FAILED(hr)) { + OLE_RELEASE(pRefTypeInfo); + return Qnil; + } + OLE_RELEASE(pRefTypeInfo); + type = WC2VSTR(bstr); + if(typedetails != Qnil) + rb_ary_push(typedetails, type); + return type; +} + +static VALUE ole_typedesc2val(); +static VALUE +ole_ptrtype2val(pTypeInfo, pTypeDesc, typedetails) + ITypeInfo *pTypeInfo; + TYPEDESC *pTypeDesc; + VALUE typedetails; +{ + TYPEDESC *p = pTypeDesc; + VALUE type = rb_str_new2(""); + while(p->vt == VT_PTR || p->vt == VT_SAFEARRAY) { + p = V_UNION1(p, lptdesc); + if(strlen(StringValuePtr(type)) == 0) { + type = ole_typedesc2val(pTypeInfo, p, typedetails); + } else { + rb_str_cat(type, ",", 1); + rb_str_concat(type, ole_typedesc2val(pTypeInfo, p, typedetails)); + } + } + return type; +} + +static VALUE +ole_typedesc2val(pTypeInfo, pTypeDesc, typedetails) + ITypeInfo *pTypeInfo; + TYPEDESC *pTypeDesc; + VALUE typedetails; +{ + VALUE str; + switch(pTypeDesc->vt) { + case VT_I2: + if(typedetails != Qnil) + rb_ary_push(typedetails, rb_str_new2("I2")); + return rb_str_new2("I2"); + case VT_I4: + if(typedetails != Qnil) + rb_ary_push(typedetails, rb_str_new2("I4")); + return rb_str_new2("I4"); + case VT_R4: + if(typedetails != Qnil) + rb_ary_push(typedetails, rb_str_new2("R4")); + return rb_str_new2("R4"); + case VT_R8: + if(typedetails != Qnil) + rb_ary_push(typedetails, rb_str_new2("R8")); + return rb_str_new2("R8"); + case VT_CY: + if(typedetails != Qnil) + rb_ary_push(typedetails, rb_str_new2("CY")); + return rb_str_new2("CY"); + case VT_DATE: + if(typedetails != Qnil) + rb_ary_push(typedetails, rb_str_new2("DATE")); + return rb_str_new2("DATE"); + case VT_BSTR: + if(typedetails != Qnil) + rb_ary_push(typedetails, rb_str_new2("BSTR")); + return rb_str_new2("BSTR"); + case VT_BOOL: + if(typedetails != Qnil) + rb_ary_push(typedetails, rb_str_new2("BOOL")); + return rb_str_new2("BOOL"); + case VT_VARIANT: + if(typedetails != Qnil) + rb_ary_push(typedetails, rb_str_new2("VARIANT")); + return rb_str_new2("VARIANT"); + case VT_DECIMAL: + if(typedetails != Qnil) + rb_ary_push(typedetails, rb_str_new2("DECIMAL")); + return rb_str_new2("DECIMAL"); + case VT_I1: + if(typedetails != Qnil) + rb_ary_push(typedetails, rb_str_new2("I1")); + return rb_str_new2("I1"); + case VT_UI1: + if(typedetails != Qnil) + rb_ary_push(typedetails, rb_str_new2("UI1")); + return rb_str_new2("UI1"); + case VT_UI2: + if(typedetails != Qnil) + rb_ary_push(typedetails, rb_str_new2("UI2")); + return rb_str_new2("UI2"); + case VT_UI4: + if(typedetails != Qnil) + rb_ary_push(typedetails, rb_str_new2("UI4")); + return rb_str_new2("UI4"); + case VT_I8: + if(typedetails != Qnil) + rb_ary_push(typedetails, rb_str_new2("I8")); + return rb_str_new2("I8"); + case VT_UI8: + if(typedetails != Qnil) + rb_ary_push(typedetails, rb_str_new2("UI8")); + return rb_str_new2("UI8"); + case VT_INT: + if(typedetails != Qnil) + rb_ary_push(typedetails, rb_str_new2("INT")); + return rb_str_new2("INT"); + case VT_UINT: + if(typedetails != Qnil) + rb_ary_push(typedetails, rb_str_new2("UINT")); + return rb_str_new2("UINT"); + case VT_VOID: + if(typedetails != Qnil) + rb_ary_push(typedetails, rb_str_new2("VOID")); + return rb_str_new2("VOID"); + case VT_HRESULT: + if(typedetails != Qnil) + rb_ary_push(typedetails, rb_str_new2("HRESULT")); + return rb_str_new2("HRESULT"); + case VT_PTR: + if(typedetails != Qnil) + rb_ary_push(typedetails, rb_str_new2("PTR")); + return ole_ptrtype2val(pTypeInfo, pTypeDesc, typedetails); + case VT_SAFEARRAY: + if(typedetails != Qnil) + rb_ary_push(typedetails, rb_str_new2("SAFEARRAY")); + return ole_ptrtype2val(pTypeInfo, pTypeDesc, typedetails); + case VT_CARRAY: + if(typedetails != Qnil) + rb_ary_push(typedetails, rb_str_new2("CARRAY")); + return rb_str_new2("CARRAY"); + case VT_USERDEFINED: + if(typedetails != Qnil) + rb_ary_push(typedetails, rb_str_new2("USERDEFINED")); + str = ole_usertype2val(pTypeInfo, pTypeDesc, typedetails); + if (str != Qnil) { + return str; + } + return rb_str_new2("USERDEFINED"); + case VT_UNKNOWN: + return rb_str_new2("UNKNOWN"); + case VT_DISPATCH: + if(typedetails != Qnil) + rb_ary_push(typedetails, rb_str_new2("DISPATCH")); + return rb_str_new2("DISPATCH"); + default: + str = rb_str_new2("Unknown Type "); + rb_str_concat(str, rb_fix2str(INT2FIX(pTypeDesc->vt), 10)); + return str; + } + return Qnil; +} + +/* + * WIN32OLE#ole_method_help(method) + * ----- + * Returns WIN32OLE_METHOD object corresponding with method + * specified by 1st argument. + */ +static VALUE +fole_method_help( self, cmdname ) + VALUE self; + VALUE cmdname; +{ + ITypeInfo *pTypeInfo; + HRESULT hr; + struct oledata *pole; + VALUE method, obj; + LCID lcid = LOCALE_SYSTEM_DEFAULT; + + Check_SafeStr(cmdname); + Data_Get_Struct(self, struct oledata, pole); + hr = pole->pDispatch->lpVtbl->GetTypeInfo( pole->pDispatch, 0, lcid, &pTypeInfo ); + if(FAILED(hr)) { + ole_raise(hr, rb_eRuntimeError, "fail to GetTypeInfo"); + } + method = folemethod_s_allocate(cWIN32OLE_METHOD); + obj = olemethod_from_typeinfo(method, pTypeInfo, cmdname); + OLE_RELEASE(pTypeInfo); + if (obj == Qnil) + rb_raise(eWIN32OLE_RUNTIME_ERROR, "Not found %s", + StringValuePtr(cmdname)); + return obj; +} + +/* + * WIN32OLE.ole_classes(typelibrary) + * ---- + * Returns array of WIN32OLE_TYPE objects defined by type library. + */ +static VALUE +foletype_s_ole_classes(self, typelib) + VALUE self; + VALUE typelib; +{ + VALUE file, classes; + OLECHAR * pbuf; + ITypeLib *pTypeLib; + HRESULT hr; + + classes = rb_ary_new(); + if(TYPE(typelib) == T_STRING) { + file = typelib_file(typelib); + if (file == Qnil) { + file = typelib; + } + pbuf = ole_mb2wc(StringValuePtr(file), -1); + hr = LoadTypeLibEx(pbuf, REGKIND_NONE, &pTypeLib); + if (FAILED(hr)) + ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "Fail to LoadTypeLibEx"); + SysFreeString(pbuf); + ole_classes_from_typelib(pTypeLib, classes); + OLE_RELEASE(pTypeLib); + } else { + rb_raise(rb_eTypeError, "1st argument should be TypeLib string"); + } + return classes; +} + +/* + * WIN32OLE_TYPE.typelibs + * ---- + * Returns array of type libraries. + */ +static VALUE +foletype_s_typelibs(self) + VALUE self; +{ + HKEY htypelib, hclsid; + double fversion; + DWORD i, j; + LONG err; + VALUE clsid; + VALUE ver; + VALUE v = Qnil; + VALUE typelibs = rb_ary_new(); + + err = reg_open_key(HKEY_CLASSES_ROOT, "TypeLib", &htypelib); + if(err != ERROR_SUCCESS) { + return typelibs; + } + for(i = 0; ; i++) { + clsid = reg_enum_key(htypelib, i); + if (clsid == Qnil) + break; + err = reg_open_vkey(htypelib, clsid, &hclsid); + if (err != ERROR_SUCCESS) + continue; + fversion = 0; + for(j = 0; ; j++) { + ver = reg_enum_key(hclsid, j); + if (ver == Qnil) + break; + if (fversion > atof(StringValuePtr(ver))) + continue; + fversion = atof(StringValuePtr(ver)); + if ( (v = reg_get_val(hclsid, StringValuePtr(ver))) != Qnil ) { + rb_ary_push(typelibs, v); + } + } + RegCloseKey(hclsid); + } + RegCloseKey(htypelib); + return typelibs; +} + +/* + * WIN32OLE_TYPE.progids + * --- + * Returns array of ProgID. + */ +static VALUE +foletype_s_progids(self) + VALUE self; +{ + HKEY hclsids, hclsid; + DWORD i; + LONG err; + VALUE clsid; + VALUE v = rb_str_new2(""); + VALUE progids = rb_ary_new(); + + err = reg_open_key(HKEY_CLASSES_ROOT, "CLSID", &hclsids); + if(err != ERROR_SUCCESS) { + return progids; + } + for(i = 0; ; i++) { + clsid = reg_enum_key(hclsids, i); + if (clsid == Qnil) + break; + err = reg_open_vkey(hclsids, clsid, &hclsid); + if (err != ERROR_SUCCESS) + continue; + if ((v = reg_get_val(hclsid, "ProgID")) != Qnil) + rb_ary_push(progids, v); + if ((v = reg_get_val(hclsid, "VersionIndependentProgID")) != Qnil) + rb_ary_push(progids, v); + RegCloseKey(hclsid); + } + RegCloseKey(hclsids); + return progids; +} + +static VALUE +foletype_s_allocate(klass) + VALUE klass; +{ + struct oletypedata *poletype; + VALUE obj; + ole_initialize(); + obj = Data_Make_Struct(klass,struct oletypedata,0,oletype_free,poletype); + poletype->pTypeInfo = NULL; + return obj; +} + +static VALUE +oletype_set_member(self, pTypeInfo, name) + VALUE self; + ITypeInfo *pTypeInfo; + VALUE name; +{ + struct oletypedata *ptype; + Data_Get_Struct(self, struct oletypedata, ptype); + rb_ivar_set(self, rb_intern("name"), name); + ptype->pTypeInfo = pTypeInfo; + if(pTypeInfo) OLE_ADDREF(pTypeInfo); + return self; +} + +static VALUE +oleclass_from_typelib(self, pTypeLib, oleclass) + VALUE self; + ITypeLib *pTypeLib; + VALUE oleclass; +{ + + long count; + int i; + HRESULT hr; + BSTR bstr; + VALUE typelib; + ITypeInfo *pTypeInfo; + + VALUE found = Qfalse; + + count = pTypeLib->lpVtbl->GetTypeInfoCount(pTypeLib); + for (i = 0; i < count && found == Qfalse; i++) { + hr = pTypeLib->lpVtbl->GetTypeInfo(pTypeLib, i, &pTypeInfo); + if (FAILED(hr)) + continue; + hr = pTypeLib->lpVtbl->GetDocumentation(pTypeLib, i, + &bstr, NULL, NULL, NULL); + if (FAILED(hr)) + continue; + typelib = WC2VSTR(bstr); + if (rb_str_cmp(oleclass, typelib) == 0) { + oletype_set_member(self, pTypeInfo, typelib); + found = Qtrue; + } + OLE_RELEASE(pTypeInfo); + } + return found; +} + +static VALUE +foletype_initialize(self, typelib, oleclass) + VALUE self; + VALUE typelib; + VALUE oleclass; +{ + VALUE file; + OLECHAR * pbuf; + ITypeLib *pTypeLib; + HRESULT hr; + + Check_SafeStr(oleclass); + Check_SafeStr(typelib); + file = typelib_file(typelib); + if (file == Qnil) { + file = typelib; + } + pbuf = ole_mb2wc(StringValuePtr(file), -1); + hr = LoadTypeLibEx(pbuf, REGKIND_NONE, &pTypeLib); + if (FAILED(hr)) + ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "Fail to LoadTypeLibEx"); + SysFreeString(pbuf); + if (oleclass_from_typelib(self, pTypeLib, oleclass) == Qfalse) { + OLE_RELEASE(pTypeLib); + rb_raise(eWIN32OLE_RUNTIME_ERROR, "Not found `%s` in `%s`", + StringValuePtr(oleclass), StringValuePtr(typelib)); + } + OLE_RELEASE(pTypeLib); + return self; +} + +/* + * WIN32OLE_TYPE#name + * --- + * Returns name. + */ +static VALUE +foletype_name(self) + VALUE self; +{ + return rb_ivar_get(self, rb_intern("name")); +} + +static VALUE +ole_ole_type(pTypeInfo) + ITypeInfo *pTypeInfo; +{ + HRESULT hr; + TYPEATTR *pTypeAttr; + VALUE type = Qnil; + hr = OLE_GET_TYPEATTR(pTypeInfo, &pTypeAttr); + if(FAILED(hr)){ + return type; + } + switch(pTypeAttr->typekind) { + case TKIND_ENUM: + type = rb_str_new2("Enum"); + break; + case TKIND_RECORD: + type = rb_str_new2("Record"); + break; + case TKIND_MODULE: + type = rb_str_new2("Module"); + break; + case TKIND_INTERFACE: + type = rb_str_new2("Interface"); + break; + case TKIND_DISPATCH: + type = rb_str_new2("Dispatch"); + break; + case TKIND_COCLASS: + type = rb_str_new2("Class"); + break; + case TKIND_ALIAS: + type = rb_str_new2("Alias"); + break; + case TKIND_UNION: + type = rb_str_new2("Union"); + break; + case TKIND_MAX: + type = rb_str_new2("Max"); + break; + default: + type = Qnil; + break; + } + OLE_RELEASE_TYPEATTR(pTypeInfo, pTypeAttr); + return type; +} + +/* + * WIN32OLE_TYPE#ole_type + * ---- + * returns type of class. + */ +static VALUE +foletype_ole_type(self) + VALUE self; +{ + struct oletypedata *ptype; + Data_Get_Struct(self, struct oletypedata, ptype); + return ole_ole_type(ptype->pTypeInfo); +} + +static VALUE +ole_type_guid(pTypeInfo) + ITypeInfo *pTypeInfo; +{ + HRESULT hr; + TYPEATTR *pTypeAttr; + int len; + OLECHAR bstr[80]; + VALUE guid = Qnil; + hr = OLE_GET_TYPEATTR(pTypeInfo, &pTypeAttr); + if (FAILED(hr)) + return guid; + len = StringFromGUID2(&pTypeAttr->guid, bstr, sizeof(bstr)/sizeof(OLECHAR)); + if (len > 3) { + guid = ole_wc2vstr(bstr, FALSE); + } + OLE_RELEASE_TYPEATTR(pTypeInfo, pTypeAttr); + return guid; +} + +/* + * WIN32OLE_TYPE#guid + * ---- + * Returns GUID. + */ +static VALUE +foletype_guid(self) +{ + struct oletypedata *ptype; + Data_Get_Struct(self, struct oletypedata, ptype); + return ole_type_guid(ptype->pTypeInfo); +} + +static VALUE +ole_type_progid(pTypeInfo) + ITypeInfo *pTypeInfo; +{ + HRESULT hr; + TYPEATTR *pTypeAttr; + OLECHAR *pbuf; + VALUE progid = Qnil; + hr = OLE_GET_TYPEATTR(pTypeInfo, &pTypeAttr); + if (FAILED(hr)) + return progid; + hr = ProgIDFromCLSID(&pTypeAttr->guid, &pbuf); + if (SUCCEEDED(hr)) + progid = WC2VSTR(pbuf); + OLE_RELEASE_TYPEATTR(pTypeInfo, pTypeAttr); + return progid; +} + +/* + * WIN32OLE_TYPE#progid + * ---- + * Returns ProgID if it exists. If not found, then returns nil. + */ +static VALUE +foletype_progid(self) +{ + struct oletypedata *ptype; + Data_Get_Struct(self, struct oletypedata, ptype); + return ole_type_progid(ptype->pTypeInfo); +} + + +static VALUE +ole_type_visible(pTypeInfo) + ITypeInfo *pTypeInfo; +{ + HRESULT hr; + TYPEATTR *pTypeAttr; + VALUE visible; + hr = OLE_GET_TYPEATTR(pTypeInfo, &pTypeAttr); + if (FAILED(hr)) + return Qtrue; + if (pTypeAttr->wTypeFlags & (TYPEFLAG_FHIDDEN | TYPEFLAG_FRESTRICTED)) { + visible = Qfalse; + } else { + visible = Qtrue; + } + OLE_RELEASE_TYPEATTR(pTypeInfo, pTypeAttr); + return visible; +} + +/* + * WIN32OLE_TYPE#visible + * ---- + * returns true if the OLE class is public. + */ +static VALUE +foletype_visible(self) + VALUE self; +{ + struct oletypedata *ptype; + Data_Get_Struct(self, struct oletypedata, ptype); + return ole_type_visible(ptype->pTypeInfo); +} + +static VALUE +ole_type_major_version(pTypeInfo) + ITypeInfo *pTypeInfo; +{ + VALUE ver; + TYPEATTR *pTypeAttr; + HRESULT hr; + hr = OLE_GET_TYPEATTR(pTypeInfo, &pTypeAttr); + if (FAILED(hr)) + ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "Fail to GetTypeAttr"); + ver = INT2FIX(pTypeAttr->wMajorVerNum); + OLE_RELEASE_TYPEATTR(pTypeInfo, pTypeAttr); + return ver; +} + +/* + * WIN32OLE_TYPE#major_version + * ---- + * Returns major version. + */ +static VALUE +foletype_major_version(self) + VALUE self; +{ + struct oletypedata *ptype; + Data_Get_Struct(self, struct oletypedata, ptype); + return ole_type_major_version(ptype->pTypeInfo); +} + +static VALUE +ole_type_minor_version(pTypeInfo) + ITypeInfo *pTypeInfo; +{ + VALUE ver; + TYPEATTR *pTypeAttr; + HRESULT hr; + hr = OLE_GET_TYPEATTR(pTypeInfo, &pTypeAttr); + if (FAILED(hr)) + ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "Fail to GetTypeAttr"); + ver = INT2FIX(pTypeAttr->wMinorVerNum); + OLE_RELEASE_TYPEATTR(pTypeInfo, pTypeAttr); + return ver; +} + +/* + * WIN32OLE_TYPE#minor_version + * ---- + * Returns minor version. + */ +static VALUE +foletype_minor_version(self) + VALUE self; +{ + struct oletypedata *ptype; + Data_Get_Struct(self, struct oletypedata, ptype); + return ole_type_minor_version(ptype->pTypeInfo); +} + +static VALUE +ole_type_typekind(pTypeInfo) + ITypeInfo *pTypeInfo; +{ + VALUE typekind; + TYPEATTR *pTypeAttr; + HRESULT hr; + hr = OLE_GET_TYPEATTR(pTypeInfo, &pTypeAttr); + if (FAILED(hr)) + ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "Fail to GetTypeAttr"); + typekind = INT2FIX(pTypeAttr->typekind); + OLE_RELEASE_TYPEATTR(pTypeInfo, pTypeAttr); + return typekind; +} + +/* + * WIN32OLE_TYPE#typekind + * ---- + * Returns number which represents type. + */ +static VALUE +foletype_typekind(self) + VALUE self; +{ + struct oletypedata *ptype; + Data_Get_Struct(self, struct oletypedata, ptype); + return ole_type_typekind(ptype->pTypeInfo); +} + +static VALUE +ole_type_helpstring(pTypeInfo) + ITypeInfo *pTypeInfo; +{ + HRESULT hr; + BSTR bhelpstr; + hr = ole_docinfo_from_type(pTypeInfo, NULL, &bhelpstr, NULL, NULL); + if(FAILED(hr)) { + return Qnil; + } + return WC2VSTR(bhelpstr); +} + +/* + * WIN32OLE_TYPE#helpstring + * --- + * Returns help string. + */ +static VALUE +foletype_helpstring(self) + VALUE self; +{ + struct oletypedata *ptype; + Data_Get_Struct(self, struct oletypedata, ptype); + return ole_type_helpstring(ptype->pTypeInfo); +} + +static VALUE +ole_type_src_type(pTypeInfo) + ITypeInfo *pTypeInfo; +{ + HRESULT hr; + TYPEATTR *pTypeAttr; + VALUE alias = Qnil; + hr = OLE_GET_TYPEATTR(pTypeInfo, &pTypeAttr); + if (FAILED(hr)) + return alias; + if(pTypeAttr->typekind != TKIND_ALIAS) { + OLE_RELEASE_TYPEATTR(pTypeInfo, pTypeAttr); + return alias; + } + alias = ole_typedesc2val(pTypeInfo, &(pTypeAttr->tdescAlias), Qnil); + OLE_RELEASE_TYPEATTR(pTypeInfo, pTypeAttr); + return alias; +} + +/* + * WIN32OLE_TYPE#src_type + * ---- + * Returns source class when the OLE class is 'Alias'. + */ +static VALUE +foletype_src_type(self) + VALUE self; +{ + struct oletypedata *ptype; + Data_Get_Struct(self, struct oletypedata, ptype); + return ole_type_src_type(ptype->pTypeInfo); +} + +static VALUE +ole_type_helpfile(pTypeInfo) + ITypeInfo *pTypeInfo; +{ + HRESULT hr; + BSTR bhelpfile; + hr = ole_docinfo_from_type(pTypeInfo, NULL, NULL, NULL, &bhelpfile); + if(FAILED(hr)) { + return Qnil; + } + return WC2VSTR(bhelpfile); +} + +/* + * WIN32OLE_TYPE#helpfile + * ---- + * Returns helpfile + */ +static VALUE +foletype_helpfile(self) + VALUE self; +{ + struct oletypedata *ptype; + Data_Get_Struct(self, struct oletypedata, ptype); + return ole_type_helpfile(ptype->pTypeInfo); +} + +static VALUE +ole_type_helpcontext(pTypeInfo) + ITypeInfo *pTypeInfo; +{ + HRESULT hr; + DWORD helpcontext; + hr = ole_docinfo_from_type(pTypeInfo, NULL, NULL, + &helpcontext, NULL); + if(FAILED(hr)) + return Qnil; + return INT2FIX(helpcontext); +} + +/* + * WIN32OLE_TYPE#helpcontext + * --- + * Returns helpcontext. + */ +static VALUE +foletype_helpcontext(self) + VALUE self; +{ + struct oletypedata *ptype; + Data_Get_Struct(self, struct oletypedata, ptype); + return ole_type_helpcontext(ptype->pTypeInfo); +} + +static VALUE +ole_variables(pTypeInfo) + ITypeInfo *pTypeInfo; +{ + HRESULT hr; + TYPEATTR *pTypeAttr; + WORD i; + UINT len; + BSTR bstr; + char *pstr; + VARDESC *pVarDesc; + struct olevariabledata *pvar; + VALUE var; + VALUE variables = rb_ary_new(); + hr = OLE_GET_TYPEATTR(pTypeInfo, &pTypeAttr); + if (FAILED(hr)) { + ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "Fail to GetTypeAttr"); + } + + for(i = 0; i < pTypeAttr->cVars; i++) { + hr = pTypeInfo->lpVtbl->GetVarDesc(pTypeInfo, i, &pVarDesc); + if(FAILED(hr)) + continue; + len = 0; + pstr = NULL; + hr = pTypeInfo->lpVtbl->GetNames(pTypeInfo, pVarDesc->memid, &bstr, + 1, &len); + if(FAILED(hr) || len == 0 || !bstr) + continue; + + var = Data_Make_Struct(cWIN32OLE_VARIABLE, struct olevariabledata, + 0,olevariable_free,pvar); + pvar->pTypeInfo = pTypeInfo; + OLE_ADDREF(pTypeInfo); + pvar->index = i; + rb_ivar_set(var, rb_intern("name"), WC2VSTR(bstr)); + rb_ary_push(variables, var); + + pTypeInfo->lpVtbl->ReleaseVarDesc(pTypeInfo, pVarDesc); + pVarDesc = NULL; + } + OLE_RELEASE_TYPEATTR(pTypeInfo, pTypeAttr); + return variables; +} + +/* + * WIN32OLE_TYPE#variables + * ---- + * Returns array of variables defined in OLE class. + */ +static VALUE +foletype_variables(self) + VALUE self; +{ + struct oletypedata *ptype; + Data_Get_Struct(self, struct oletypedata, ptype); + return ole_variables(ptype->pTypeInfo); +} + +/* + * WIN32OLE_TYPE#ole_methods + * ---- + * Returns array of WIN32OLE_METHOD objects. + */ +static VALUE +foletype_methods(argc, argv, self) + int argc; + VALUE *argv; + VALUE self; +{ + struct oletypedata *ptype; + Data_Get_Struct(self, struct oletypedata, ptype); + return ole_methods_from_typeinfo(ptype->pTypeInfo, INVOKE_FUNC | INVOKE_PROPERTYGET | INVOKE_PROPERTYPUT | INVOKE_PROPERTYPUTREF); +} + +/* + * WIN32OLE_VARIABLE#name + * --- + * Returns the name. + */ +static VALUE +folevariable_name(self) + VALUE self; +{ + return rb_ivar_get(self, rb_intern("name")); +} + +static ole_variable_ole_type(pTypeInfo, var_index) + ITypeInfo *pTypeInfo; + UINT var_index; +{ + VARDESC *pVarDesc; + HRESULT hr; + VALUE type; + hr = pTypeInfo->lpVtbl->GetVarDesc(pTypeInfo, var_index, &pVarDesc); + if (FAILED(hr)) + ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "Fail to GetVarDesc"); + type = ole_typedesc2val(pTypeInfo, &(pVarDesc->elemdescVar.tdesc), Qnil); + pTypeInfo->lpVtbl->ReleaseVarDesc(pTypeInfo, pVarDesc); + return type; +} + +/* + * WIN32OLE_VARIABLE#ole_type + * ---- + * Returns type. + */ +static VALUE +folevariable_ole_type(self) + VALUE self; +{ + struct olevariabledata *pvar; + Data_Get_Struct(self, struct olevariabledata, pvar); + return ole_variable_ole_type(pvar->pTypeInfo, pvar->index); +} + +static ole_variable_ole_type_detail(pTypeInfo, var_index) + ITypeInfo *pTypeInfo; + UINT var_index; +{ + VARDESC *pVarDesc; + HRESULT hr; + VALUE type = rb_ary_new(); + hr = pTypeInfo->lpVtbl->GetVarDesc(pTypeInfo, var_index, &pVarDesc); + if (FAILED(hr)) + ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "Fail to GetVarDesc"); + ole_typedesc2val(pTypeInfo, &(pVarDesc->elemdescVar.tdesc), type); + pTypeInfo->lpVtbl->ReleaseVarDesc(pTypeInfo, pVarDesc); + return type; +} + +/* + * WIN32OLE_VARIABLE#ole_type_detail + * --- + * Returns detail information of type. The information is array of type. + */ +static VALUE +folevariable_ole_type_detail(self) + VALUE self; +{ + struct olevariabledata *pvar; + Data_Get_Struct(self, struct olevariabledata, pvar); + return ole_variable_ole_type_detail(pvar->pTypeInfo, pvar->index); +} + +static ole_variable_value(pTypeInfo, var_index) + ITypeInfo *pTypeInfo; + UINT var_index; +{ + VARDESC *pVarDesc; + HRESULT hr; + VALUE val = Qnil; + hr = pTypeInfo->lpVtbl->GetVarDesc(pTypeInfo, var_index, &pVarDesc); + if (FAILED(hr)) + return Qnil; + if(pVarDesc->varkind == VAR_CONST) + val = ole_variant2val(V_UNION1(pVarDesc, lpvarValue)); + pTypeInfo->lpVtbl->ReleaseVarDesc(pTypeInfo, pVarDesc); + return val; +} + +/* + * WIN32OLE_VARIABLE#value + * ---- + * Returns value if value is exists. If the value does not exist, + * this method returns nil. + */ +static VALUE +folevariable_value(self) + VALUE self; +{ + struct olevariabledata *pvar; + Data_Get_Struct(self, struct olevariabledata, pvar); + return ole_variable_value(pvar->pTypeInfo, pvar->index); +} + +static ole_variable_visible(pTypeInfo, var_index) + ITypeInfo *pTypeInfo; + UINT var_index; +{ + VARDESC *pVarDesc; + HRESULT hr; + VALUE visible = Qfalse; + hr = pTypeInfo->lpVtbl->GetVarDesc(pTypeInfo, var_index, &pVarDesc); + if (FAILED(hr)) + return visible; + if (!(pVarDesc->wVarFlags & (VARFLAG_FHIDDEN | + VARFLAG_FRESTRICTED | + VARFLAG_FNONBROWSABLE))) { + visible = Qtrue; + } + pTypeInfo->lpVtbl->ReleaseVarDesc(pTypeInfo, pVarDesc); + return visible; +} + +/* + * WIN32OLE_VARIABLE#visible? + * ---- + * Returns true if the variable is public. + */ +static VALUE +folevariable_visible(self) + VALUE self; +{ + struct olevariabledata *pvar; + Data_Get_Struct(self, struct olevariabledata, pvar); + return ole_variable_visible(pvar->pTypeInfo, pvar->index); +} + +static VALUE +ole_variable_kind(pTypeInfo, var_index) + ITypeInfo *pTypeInfo; + UINT var_index; +{ + VARDESC *pVarDesc; + HRESULT hr; + VALUE kind = rb_str_new2("UNKNOWN"); + hr = pTypeInfo->lpVtbl->GetVarDesc(pTypeInfo, var_index, &pVarDesc); + if (FAILED(hr)) + return kind; + switch(pVarDesc->varkind) { + case VAR_PERINSTANCE: + kind = rb_str_new2("PERINSTANCE"); + break; + case VAR_STATIC: + kind = rb_str_new2("STATIC"); + break; + case VAR_CONST: + kind = rb_str_new2("CONSTANT"); + break; + case VAR_DISPATCH: + kind = rb_str_new2("DISPATCH"); + break; + default: + break; + } + pTypeInfo->lpVtbl->ReleaseVarDesc(pTypeInfo, pVarDesc); + return kind; +} + +/* + * WIN32OLE_VARIABLE#variable_kind + * ---- + * Returns variable kind string. + */ +static VALUE +folevariable_variable_kind(self) + VALUE self; +{ + struct olevariabledata *pvar; + Data_Get_Struct(self, struct olevariabledata, pvar); + return ole_variable_kind(pvar->pTypeInfo, pvar->index); +} + +static VALUE +ole_variable_varkind(pTypeInfo, var_index) + ITypeInfo *pTypeInfo; + UINT var_index; +{ + VARDESC *pVarDesc; + HRESULT hr; + VALUE kind = Qnil; + hr = pTypeInfo->lpVtbl->GetVarDesc(pTypeInfo, var_index, &pVarDesc); + if (FAILED(hr)) + return kind; + pTypeInfo->lpVtbl->ReleaseVarDesc(pTypeInfo, pVarDesc); + kind = INT2FIX(pVarDesc->varkind); + return kind; +} + +/* + * WIN32OLE_VARIABLE#varkind + * ---- + * Returns the number which represents variable kind. + */ +static VALUE +folevariable_varkind(self) + VALUE self; +{ + struct olevariabledata *pvar; + Data_Get_Struct(self, struct olevariabledata, pvar); + return ole_variable_varkind(pvar->pTypeInfo, pvar->index); +} + +static VALUE +ole_method_sub(self, pOwnerTypeInfo, pTypeInfo, name) + VALUE self; + ITypeInfo *pOwnerTypeInfo; + ITypeInfo *pTypeInfo; + VALUE name; +{ + HRESULT hr; + TYPEATTR *pTypeAttr; + BSTR bstr; + FUNCDESC *pFuncDesc; + DWORD i; + VALUE fname; + VALUE method = Qnil; + hr = OLE_GET_TYPEATTR(pTypeInfo, &pTypeAttr); + if (FAILED(hr)) { + ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "Fail to GetTypeAttr"); + } + for(i = 0; i < pTypeAttr->cFuncs && method == Qnil; i++) { + hr = pTypeInfo->lpVtbl->GetFuncDesc(pTypeInfo, i, &pFuncDesc); + if (FAILED(hr)) + continue; + + hr = pTypeInfo->lpVtbl->GetDocumentation(pTypeInfo, pFuncDesc->memid, + &bstr, NULL, NULL, NULL); + if (FAILED(hr)) { + pTypeInfo->lpVtbl->ReleaseFuncDesc(pTypeInfo, pFuncDesc); + continue; + } + fname = WC2VSTR(bstr); + if (strcasecmp(StringValuePtr(name), StringValuePtr(fname)) == 0) { + olemethod_set_member(self, pTypeInfo, pOwnerTypeInfo, i, fname); + method = self; + } + pTypeInfo->lpVtbl->ReleaseFuncDesc(pTypeInfo, pFuncDesc); + pFuncDesc=NULL; + } + OLE_RELEASE_TYPEATTR(pTypeInfo, pTypeAttr); + return method; +} + +static VALUE +olemethod_from_typeinfo(self, pTypeInfo, name) + VALUE self; + ITypeInfo *pTypeInfo; + VALUE name; +{ + HRESULT hr; + TYPEATTR *pTypeAttr; + WORD i; + HREFTYPE href; + ITypeInfo *pRefTypeInfo; + VALUE method = Qnil; + hr = OLE_GET_TYPEATTR(pTypeInfo, &pTypeAttr); + if (FAILED(hr)) { + ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "Fail to GetTypeAttr"); + } + method = ole_method_sub(self, 0, pTypeInfo, name); + if (method != Qnil) { + return method; + } + for(i=0; i < pTypeAttr->cImplTypes && method == Qnil; i++){ + hr = pTypeInfo->lpVtbl->GetRefTypeOfImplType(pTypeInfo, i, &href); + if(FAILED(hr)) + continue; + hr = pTypeInfo->lpVtbl->GetRefTypeInfo(pTypeInfo, href, &pRefTypeInfo); + if (FAILED(hr)) + continue; + method = ole_method_sub(self, pTypeInfo, pRefTypeInfo, name); + OLE_RELEASE(pRefTypeInfo); + } + OLE_RELEASE_TYPEATTR(pTypeInfo, pTypeAttr); + return method; +} + +static VALUE +olemethod_set_member(self, pTypeInfo, pOwnerTypeInfo, index, name) + VALUE self; + ITypeInfo *pTypeInfo; + ITypeInfo *pOwnerTypeInfo; + int index; + VALUE name; +{ + struct olemethoddata *pmethod; + Data_Get_Struct(self, struct olemethoddata, pmethod); + pmethod->pTypeInfo = pTypeInfo; + OLE_ADDREF(pTypeInfo); + pmethod->pOwnerTypeInfo = pOwnerTypeInfo; + if(pOwnerTypeInfo) OLE_ADDREF(pOwnerTypeInfo); + pmethod->index = index; + rb_ivar_set(self, rb_intern("name"), name); + return self; +} + +static VALUE +folemethod_s_allocate(klass) + VALUE klass; +{ + struct olemethoddata *pmethod; + VALUE obj; + obj = Data_Make_Struct(klass, + struct olemethoddata, + 0, olemethod_free, pmethod); + pmethod->pTypeInfo = NULL; + pmethod->pOwnerTypeInfo = NULL; + pmethod->index = 0; + return obj; +} + +static VALUE +folemethod_initialize(self, oletype, method) + VALUE self; + VALUE oletype; + VALUE method; +{ + struct oletypedata *ptype; + VALUE obj = Qnil; + if (rb_obj_is_kind_of(oletype, cWIN32OLE_TYPE)) { + Check_SafeStr(method); + Data_Get_Struct(oletype, struct oletypedata, ptype); + obj = olemethod_from_typeinfo(self, ptype->pTypeInfo, method); + if (obj == Qnil) { + rb_raise(eWIN32OLE_RUNTIME_ERROR, "Not found %s", + StringValuePtr(method)); + } + } + else { + rb_raise(rb_eTypeError, "1st argument should be WIN32OLE_TYPE object."); + } + return obj; +} + +/* + * WIN32OLE_METHOD#name + * ---- + * Returns the name of the method. + */ +static VALUE +folemethod_name(self) + VALUE self; +{ + return rb_ivar_get(self, rb_intern("name")); +} + +static VALUE +ole_method_return_type(pTypeInfo, method_index) + ITypeInfo *pTypeInfo; + UINT method_index; +{ + FUNCDESC *pFuncDesc; + HRESULT hr; + VALUE type; + + hr = pTypeInfo->lpVtbl->GetFuncDesc(pTypeInfo, method_index, &pFuncDesc); + if (FAILED(hr)) + ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "Fail to GetFuncDesc"); + + type = ole_typedesc2val(pTypeInfo, &(pFuncDesc->elemdescFunc.tdesc), Qnil); + pTypeInfo->lpVtbl->ReleaseFuncDesc(pTypeInfo, pFuncDesc); + return type; +} + +/* + * WIN32OLE_METHOD#return_type + * ---- + * Returns string of return value type of method. + */ +static VALUE +folemethod_return_type(self) + VALUE self; +{ + struct olemethoddata *pmethod; + Data_Get_Struct(self, struct olemethoddata, pmethod); + return ole_method_return_type(pmethod->pTypeInfo, pmethod->index); +} + +static VALUE +ole_method_return_vtype(pTypeInfo, method_index) + ITypeInfo *pTypeInfo; + UINT method_index; +{ + FUNCDESC *pFuncDesc; + HRESULT hr; + VALUE vt; + + hr = pTypeInfo->lpVtbl->GetFuncDesc(pTypeInfo, method_index, &pFuncDesc); + if (FAILED(hr)) + ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "Fail to GetFuncDesc"); + + vt = INT2FIX(pFuncDesc->elemdescFunc.tdesc.vt); + pTypeInfo->lpVtbl->ReleaseFuncDesc(pTypeInfo, pFuncDesc); + return vt; +} + +/* + * WIN32OLE_METHOD#return_vtype + * ---- + * Returns number of return value type of method. + */ +static VALUE +folemethod_return_vtype(self) + VALUE self; +{ + struct olemethoddata *pmethod; + Data_Get_Struct(self, struct olemethoddata, pmethod); + return ole_method_return_vtype(pmethod->pTypeInfo, pmethod->index); +} + +static VALUE +ole_method_return_type_detail(pTypeInfo, method_index) + ITypeInfo *pTypeInfo; + UINT method_index; +{ + FUNCDESC *pFuncDesc; + HRESULT hr; + VALUE type = rb_ary_new(); + + hr = pTypeInfo->lpVtbl->GetFuncDesc(pTypeInfo, method_index, &pFuncDesc); + if (FAILED(hr)) + return type; + + ole_typedesc2val(pTypeInfo, &(pFuncDesc->elemdescFunc.tdesc), type); + pTypeInfo->lpVtbl->ReleaseFuncDesc(pTypeInfo, pFuncDesc); + return type; +} + +/* + * WIN32OLE_METHOD#return_type_detail + * ----- + * Returns detail information of return value type of method. + * The information is array. + */ +static VALUE +folemethod_return_type_detail(self) + VALUE self; +{ + struct olemethoddata *pmethod; + Data_Get_Struct(self, struct olemethoddata, pmethod); + return ole_method_return_type_detail(pmethod->pTypeInfo, pmethod->index); +} + +static VALUE +ole_method_invkind(pTypeInfo, method_index) + ITypeInfo *pTypeInfo; + UINT method_index; +{ + FUNCDESC *pFuncDesc; + HRESULT hr; + VALUE invkind; + hr = pTypeInfo->lpVtbl->GetFuncDesc(pTypeInfo, method_index, &pFuncDesc); + if(FAILED(hr)) + ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "Fail to GetFuncDesc"); + invkind = INT2FIX(pFuncDesc->invkind); + pTypeInfo->lpVtbl->ReleaseFuncDesc(pTypeInfo, pFuncDesc); + return invkind; +} + +static VALUE +ole_method_invoke_kind(pTypeInfo, method_index) + ITypeInfo *pTypeInfo; + WORD method_index; +{ + VALUE type = rb_str_new2("UNKNOWN"); + VALUE invkind = ole_method_invkind(pTypeInfo, method_index); + if((FIX2INT(invkind) & INVOKE_PROPERTYGET) && + (FIX2INT(invkind) & INVOKE_PROPERTYPUT) ) { + type = rb_str_new2("PROPERTY"); + } else if(FIX2INT(invkind) & INVOKE_PROPERTYGET) { + type = rb_str_new2("PROPERTYGET"); + } else if(FIX2INT(invkind) & INVOKE_PROPERTYPUT) { + type = rb_str_new2("PROPERTYPUT"); + } else if(FIX2INT(invkind) & INVOKE_PROPERTYPUTREF) { + type = rb_str_new2("PROPERTYPUTREF"); + } else if(FIX2INT(invkind) & INVOKE_FUNC) { + type = rb_str_new2("FUNC"); + } + return type; +} + +/* + * WIN32OLE_MTHOD#invkind + * ---- + * Returns invkind. + */ +static VALUE +folemethod_invkind(self) + VALUE self; +{ + struct olemethoddata *pmethod; + Data_Get_Struct(self, struct olemethoddata, pmethod); + return ole_method_invkind(pmethod->pTypeInfo, pmethod->index); +} + +/* + * WIN32OLE_METHOD#invoke_kind + * ---- + * Returns invoke kind string. + */ +static VALUE +folemethod_invoke_kind(self) + VALUE self; +{ + struct olemethoddata *pmethod; + Data_Get_Struct(self, struct olemethoddata, pmethod); + return ole_method_invoke_kind(pmethod->pTypeInfo, pmethod->index); +} + +static VALUE +ole_method_visible(pTypeInfo, method_index) + ITypeInfo *pTypeInfo; + UINT method_index; +{ + FUNCDESC *pFuncDesc; + HRESULT hr; + VALUE visible; + hr = pTypeInfo->lpVtbl->GetFuncDesc(pTypeInfo, method_index, &pFuncDesc); + if(FAILED(hr)) + return Qfalse; + if (pFuncDesc->wFuncFlags & (FUNCFLAG_FRESTRICTED | + FUNCFLAG_FHIDDEN | + FUNCFLAG_FNONBROWSABLE)) { + visible = Qfalse; + } else { + visible = Qtrue; + } + pTypeInfo->lpVtbl->ReleaseFuncDesc(pTypeInfo, pFuncDesc); + return visible; +} + +/* + * WIN32OLE_METHOD#visible? + * ---- + * Returns true if the method is public. + */ +static VALUE +folemethod_visible(self) + VALUE self; +{ + struct olemethoddata *pmethod; + Data_Get_Struct(self, struct olemethoddata, pmethod); + return ole_method_visible(pmethod->pTypeInfo, pmethod->index); +} + +static ole_method_event(pTypeInfo, method_index, method_name) + ITypeInfo *pTypeInfo; + WORD method_index; + VALUE method_name; +{ + TYPEATTR *pTypeAttr; + HRESULT hr; + DWORD i; + int flags; + HREFTYPE href; + ITypeInfo *pRefTypeInfo; + FUNCDESC *pFuncDesc; + BSTR bstr; + VALUE name; + VALUE event = Qfalse; + + hr = OLE_GET_TYPEATTR(pTypeInfo, &pTypeAttr); + if (FAILED(hr)) + return event; + if(pTypeAttr->typekind != TKIND_COCLASS) { + pTypeInfo->lpVtbl->ReleaseTypeAttr(pTypeInfo, pTypeAttr); + return event; + } + for (i = 0; i < pTypeAttr->cImplTypes; i++) { + hr = pTypeInfo->lpVtbl->GetImplTypeFlags(pTypeInfo, i, &flags); + if (FAILED(hr)) + continue; + + if (flags & IMPLTYPEFLAG_FSOURCE) { + hr = pTypeInfo->lpVtbl->GetRefTypeOfImplType(pTypeInfo, + i, &href); + if (FAILED(hr)) + continue; + hr = pTypeInfo->lpVtbl->GetRefTypeInfo(pTypeInfo, + href, &pRefTypeInfo); + if (FAILED(hr)) + continue; + hr = pRefTypeInfo->lpVtbl->GetFuncDesc(pRefTypeInfo, method_index, + &pFuncDesc); + if (FAILED(hr)) { + OLE_RELEASE(pRefTypeInfo); + continue; + } + + hr = pRefTypeInfo->lpVtbl->GetDocumentation(pRefTypeInfo, + pFuncDesc->memid, + &bstr, NULL, NULL, NULL); + if (FAILED(hr)) { + pRefTypeInfo->lpVtbl->ReleaseFuncDesc(pRefTypeInfo, pFuncDesc); + OLE_RELEASE(pRefTypeInfo); + continue; + } + + name = WC2VSTR(bstr); + pRefTypeInfo->lpVtbl->ReleaseFuncDesc(pRefTypeInfo, pFuncDesc); + OLE_RELEASE(pRefTypeInfo); + if (rb_str_cmp(method_name, name) == 0) { + event = Qtrue; + break; + } + } + } + OLE_RELEASE_TYPEATTR(pTypeInfo, pTypeAttr); + return event; +} + +/* + * WIN32OLE_METHOD#event? + * ---- + * Returns true if the method is event. + */ +static VALUE +folemethod_event(self) + VALUE self; +{ + struct olemethoddata *pmethod; + Data_Get_Struct(self, struct olemethoddata, pmethod); + if (!pmethod->pOwnerTypeInfo) + return Qfalse; + return ole_method_event(pmethod->pOwnerTypeInfo, + pmethod->index, + rb_ivar_get(self, rb_intern("name"))); +} + +static VALUE +folemethod_event_interface(self) + VALUE self; +{ + BSTR name; + struct olemethoddata *pmethod; + HRESULT hr; + Data_Get_Struct(self, struct olemethoddata, pmethod); + if(folemethod_event(self) == Qtrue) { + hr = ole_docinfo_from_type(pmethod->pTypeInfo, &name, NULL, NULL, NULL); + if(SUCCEEDED(hr)) + return WC2VSTR(name); + } + return Qnil; +} + +static VALUE +ole_method_docinfo_from_type(pTypeInfo, method_index, name, helpstr, + helpcontext, helpfile) + ITypeInfo *pTypeInfo; + UINT method_index; + BSTR *name; + BSTR *helpstr; + DWORD *helpcontext; + BSTR *helpfile; +{ + FUNCDESC *pFuncDesc; + HRESULT hr; + hr = pTypeInfo->lpVtbl->GetFuncDesc(pTypeInfo, method_index, &pFuncDesc); + if (FAILED(hr)) + return hr; + hr = pTypeInfo->lpVtbl->GetDocumentation(pTypeInfo, pFuncDesc->memid, + name, helpstr, + helpcontext, helpfile); + pTypeInfo->lpVtbl->ReleaseFuncDesc(pTypeInfo, pFuncDesc); + return hr; +} + +static VALUE +ole_method_helpstring(pTypeInfo, method_index) + ITypeInfo *pTypeInfo; + UINT method_index; +{ + HRESULT hr; + BSTR bhelpstring; + hr = ole_method_docinfo_from_type(pTypeInfo, method_index, NULL, &bhelpstring, + NULL, NULL); + if (FAILED(hr)) + return Qnil; + return WC2VSTR(bhelpstring); +} + +static VALUE +folemethod_helpstring(self) + VALUE self; +{ + struct olemethoddata *pmethod; + Data_Get_Struct(self, struct olemethoddata, pmethod); + return ole_method_helpstring(pmethod->pTypeInfo, pmethod->index); +} + +static VALUE +ole_method_helpfile(pTypeInfo, method_index) + ITypeInfo *pTypeInfo; + UINT method_index; +{ + HRESULT hr; + BSTR bhelpfile; + hr = ole_method_docinfo_from_type(pTypeInfo, method_index, NULL, NULL, + NULL, &bhelpfile); + if (FAILED(hr)) + return Qnil; + return WC2VSTR(bhelpfile); +} + +/* + * WIN32OLE_METHOD#helpfile + * --- + * Returns help file. + */ +static VALUE +folemethod_helpfile(self) + VALUE self; +{ + struct olemethoddata *pmethod; + Data_Get_Struct(self, struct olemethoddata, pmethod); + + return ole_method_helpfile(pmethod->pTypeInfo, pmethod->index); +} + +static VALUE +ole_method_helpcontext(pTypeInfo, method_index) + ITypeInfo *pTypeInfo; + UINT method_index; +{ + HRESULT hr; + DWORD helpcontext = 0; + hr = ole_method_docinfo_from_type(pTypeInfo, method_index, NULL, NULL, + &helpcontext, NULL); + if (FAILED(hr)) + return Qnil; + return INT2FIX(helpcontext); +} + +/* + * WIN32OLE_METHOD#helpcontext + * ----- + * Returns help context. + */ +static VALUE +folemethod_helpcontext(self) + VALUE self; +{ + struct olemethoddata *pmethod; + Data_Get_Struct(self, struct olemethoddata, pmethod); + return ole_method_helpcontext(pmethod->pTypeInfo, pmethod->index); +} + +static VALUE +ole_method_dispid(pTypeInfo, method_index) + ITypeInfo *pTypeInfo; + UINT method_index; +{ + FUNCDESC *pFuncDesc; + HRESULT hr; + VALUE dispid = Qnil; + hr = pTypeInfo->lpVtbl->GetFuncDesc(pTypeInfo, method_index, &pFuncDesc); + if (FAILED(hr)) + return dispid; + dispid = INT2FIX(pFuncDesc->memid); + pTypeInfo->lpVtbl->ReleaseFuncDesc(pTypeInfo, pFuncDesc); + return dispid; +} + +/* + * WIN32OLE_METHOD#dispid + * ---- + * Returns dispatch ID. + */ +static VALUE +folemethod_dispid(self) + VALUE self; +{ + struct olemethoddata *pmethod; + Data_Get_Struct(self, struct olemethoddata, pmethod); + return ole_method_dispid(pmethod->pTypeInfo, pmethod->index); +} + +static VALUE +ole_method_offset_vtbl(pTypeInfo, method_index) + ITypeInfo *pTypeInfo; + UINT method_index; +{ + FUNCDESC *pFuncDesc; + HRESULT hr; + VALUE offset_vtbl = Qnil; + hr = pTypeInfo->lpVtbl->GetFuncDesc(pTypeInfo, method_index, &pFuncDesc); + if (FAILED(hr)) + return offset_vtbl; + offset_vtbl = INT2FIX(pFuncDesc->oVft); + pTypeInfo->lpVtbl->ReleaseFuncDesc(pTypeInfo, pFuncDesc); + return offset_vtbl; +} + +/* + * WIN32OLE_METHOD#offset_vtbl + * ---- + * Returns the offset ov VTBL. + */ +static VALUE +folemethod_offset_vtbl(self) + VALUE self; +{ + struct olemethoddata *pmethod; + Data_Get_Struct(self, struct olemethoddata, pmethod); + return ole_method_offset_vtbl(pmethod->pTypeInfo, pmethod->index); +} + +static VALUE +ole_method_size_params(pTypeInfo, method_index) + ITypeInfo *pTypeInfo; + UINT method_index; +{ + FUNCDESC *pFuncDesc; + HRESULT hr; + VALUE size_params = Qnil; + hr = pTypeInfo->lpVtbl->GetFuncDesc(pTypeInfo, method_index, &pFuncDesc); + if (FAILED(hr)) + return size_params; + size_params = INT2FIX(pFuncDesc->cParams); + pTypeInfo->lpVtbl->ReleaseFuncDesc(pTypeInfo, pFuncDesc); + return size_params; +} + +/* + * WIN32OLE_METHOD#size_params + * ---- + * Returns the size of arguments. + */ +static VALUE +folemethod_size_params(self) + VALUE self; +{ + struct olemethoddata *pmethod; + Data_Get_Struct(self, struct olemethoddata, pmethod); + return ole_method_size_params(pmethod->pTypeInfo, pmethod->index); +} + +/* + * WIN32OLE_METHOD#size_opt_params + * ---- + * Returns the size of optional parameters. + */ +static VALUE +ole_method_size_opt_params(pTypeInfo, method_index) + ITypeInfo *pTypeInfo; + UINT method_index; +{ + FUNCDESC *pFuncDesc; + HRESULT hr; + VALUE size_opt_params = Qnil; + hr = pTypeInfo->lpVtbl->GetFuncDesc(pTypeInfo, method_index, &pFuncDesc); + if (FAILED(hr)) + return size_opt_params; + size_opt_params = INT2FIX(pFuncDesc->cParamsOpt); + pTypeInfo->lpVtbl->ReleaseFuncDesc(pTypeInfo, pFuncDesc); + return size_opt_params; +} + +static VALUE +folemethod_size_opt_params(self) + VALUE self; +{ + struct olemethoddata *pmethod; + Data_Get_Struct(self, struct olemethoddata, pmethod); + return ole_method_size_opt_params(pmethod->pTypeInfo, pmethod->index); +} + +static VALUE +ole_method_params(pTypeInfo, method_index) + ITypeInfo *pTypeInfo; + UINT method_index; +{ + FUNCDESC *pFuncDesc; + HRESULT hr; + BSTR *bstrs; + UINT len, i; + struct oleparamdata *pparam; + VALUE param; + VALUE params = rb_ary_new(); + hr = pTypeInfo->lpVtbl->GetFuncDesc(pTypeInfo, method_index, &pFuncDesc); + if (FAILED(hr)) + return params; + + len = 0; + bstrs = ALLOCA_N(BSTR, pFuncDesc->cParams + 1); + hr = pTypeInfo->lpVtbl->GetNames(pTypeInfo, pFuncDesc->memid, + bstrs, pFuncDesc->cParams + 1, + &len); + if (FAILED(hr)) { + pTypeInfo->lpVtbl->ReleaseFuncDesc(pTypeInfo, pFuncDesc); + return params; + } + SysFreeString(bstrs[0]); + if (pFuncDesc->cParams > 0) { + for(i = 1; i < len; i++) { + param = Data_Make_Struct(cWIN32OLE_PARAM, struct oleparamdata, 0, + oleparam_free, pparam); + pparam->pTypeInfo = pTypeInfo; + OLE_ADDREF(pTypeInfo); + pparam->method_index = method_index; + pparam->index = i - 1; + rb_ivar_set(param, rb_intern("name"), WC2VSTR(bstrs[i])); + rb_ary_push(params, param); + } + } + pTypeInfo->lpVtbl->ReleaseFuncDesc(pTypeInfo, pFuncDesc); + return params; +} + +/* + * WIN32OLE_METHOD#params + * ---- + * returns array of WIN32OLE_PARAM object corresponding with method parameters. + */ +static VALUE +folemethod_params(self) + VALUE self; +{ + struct olemethoddata *pmethod; + Data_Get_Struct(self, struct olemethoddata, pmethod); + return ole_method_params(pmethod->pTypeInfo, pmethod->index); +} + +/* + * WIN32OLE_PARAM#name + * ---- + * Returns name. + */ +static VALUE +foleparam_name(self) + VALUE self; +{ + return rb_ivar_get(self, rb_intern("name")); +} + +static VALUE +ole_param_ole_type(pTypeInfo, method_index, index) + ITypeInfo *pTypeInfo; + UINT method_index; + UINT index; +{ + FUNCDESC *pFuncDesc; + HRESULT hr; + VALUE type = rb_str_new2("UNKNOWN"); + hr = pTypeInfo->lpVtbl->GetFuncDesc(pTypeInfo, method_index, &pFuncDesc); + if (FAILED(hr)) + return type; + type = ole_typedesc2val(pTypeInfo, + &(pFuncDesc->lprgelemdescParam[index].tdesc), Qnil); + pTypeInfo->lpVtbl->ReleaseFuncDesc(pTypeInfo, pFuncDesc); + return type; +} + +static VALUE +foleparam_ole_type(self) + VALUE self; +{ + struct oleparamdata *pparam; + Data_Get_Struct(self, struct oleparamdata, pparam); + return ole_param_ole_type(pparam->pTypeInfo, pparam->method_index, + pparam->index); +} + +static VALUE +ole_param_ole_type_detail(pTypeInfo, method_index, index) + ITypeInfo *pTypeInfo; + UINT method_index; + UINT index; +{ + FUNCDESC *pFuncDesc; + HRESULT hr; + VALUE typedetail = rb_ary_new(); + hr = pTypeInfo->lpVtbl->GetFuncDesc(pTypeInfo, method_index, &pFuncDesc); + if (FAILED(hr)) + return typedetail; + ole_typedesc2val(pTypeInfo, + &(pFuncDesc->lprgelemdescParam[index].tdesc), typedetail); + pTypeInfo->lpVtbl->ReleaseFuncDesc(pTypeInfo, pFuncDesc); + return typedetail; +} + +static VALUE +foleparam_ole_type_detail(self) + VALUE self; +{ + struct oleparamdata *pparam; + Data_Get_Struct(self, struct oleparamdata, pparam); + return ole_param_ole_type_detail(pparam->pTypeInfo, pparam->method_index, + pparam->index); +} + +static VALUE +ole_param_flag_mask(pTypeInfo, method_index, index, mask) + ITypeInfo *pTypeInfo; + UINT method_index; + UINT index; + USHORT mask; +{ + FUNCDESC *pFuncDesc; + HRESULT hr; + VALUE ret = Qfalse; + hr = pTypeInfo->lpVtbl->GetFuncDesc(pTypeInfo, method_index, &pFuncDesc); + if(FAILED(hr)) + return ret; + if (V_UNION1((&(pFuncDesc->lprgelemdescParam[index])), paramdesc).wParamFlags &mask) + ret = Qtrue; + pTypeInfo->lpVtbl->ReleaseFuncDesc(pTypeInfo, pFuncDesc); + return ret; +} + +/* + * WIN32OLE_PARAM#input? + * ---- + * Returns true if the parameter is input. + */ +static VALUE foleparam_input(self) + VALUE self; +{ + struct oleparamdata *pparam; + Data_Get_Struct(self, struct oleparamdata, pparam); + return ole_param_flag_mask(pparam->pTypeInfo, pparam->method_index, + pparam->index, PARAMFLAG_FIN); +} + +/* + * WIN32OLE#output? + * ---- + * Returns true if argument is output. + */ +static VALUE foleparam_output(self) + VALUE self; +{ + struct oleparamdata *pparam; + Data_Get_Struct(self, struct oleparamdata, pparam); + return ole_param_flag_mask(pparam->pTypeInfo, pparam->method_index, + pparam->index, PARAMFLAG_FOUT); +} + +/* + * WIN32OLE_PARAM#optional? + * ----- + * Returns true if argument is output. + */ +static VALUE foleparam_optional(self) + VALUE self; +{ + struct oleparamdata *pparam; + Data_Get_Struct(self, struct oleparamdata, pparam); + return ole_param_flag_mask(pparam->pTypeInfo, pparam->method_index, + pparam->index, PARAMFLAG_FOPT); +} + +static VALUE foleparam_retval(self) + VALUE self; +{ + struct oleparamdata *pparam; + Data_Get_Struct(self, struct oleparamdata, pparam); + return ole_param_flag_mask(pparam->pTypeInfo, pparam->method_index, + pparam->index, PARAMFLAG_FRETVAL); +} + +static VALUE +ole_param_default(pTypeInfo, method_index, index) + ITypeInfo *pTypeInfo; + UINT method_index; + UINT index; +{ + FUNCDESC *pFuncDesc; + ELEMDESC *pElemDesc; + PARAMDESCEX * pParamDescEx; + HRESULT hr; + USHORT wParamFlags; + USHORT mask = PARAMFLAG_FOPT|PARAMFLAG_FHASDEFAULT; + VALUE defval = Qnil; + hr = pTypeInfo->lpVtbl->GetFuncDesc(pTypeInfo, method_index, &pFuncDesc); + if (FAILED(hr)) + return defval; + pElemDesc = &pFuncDesc->lprgelemdescParam[index]; + wParamFlags = V_UNION1(pElemDesc, paramdesc).wParamFlags; + if ((wParamFlags & mask) == mask) { + pParamDescEx = V_UNION1(pElemDesc, paramdesc).pparamdescex; + defval = ole_variant2val(&pParamDescEx->varDefaultValue); + } + pTypeInfo->lpVtbl->ReleaseFuncDesc(pTypeInfo, pFuncDesc); + return defval; +} + +/* + * WIN32OLE_PARAM#default + * ---- + * Returns default value. If the default value does not exist, + * this method returns nil. + */ +static VALUE foleparam_default(self) + VALUE self; +{ + struct oleparamdata *pparam; + Data_Get_Struct(self, struct oleparamdata, pparam); + return ole_param_default(pparam->pTypeInfo, pparam->method_index, + pparam->index); +} + +static IEventSinkVtbl vtEventSink; +static BOOL g_IsEventSinkVtblInitialized = FALSE; + +void EVENTSINK_Destructor(PIEVENTSINKOBJ); + +STDMETHODIMP +EVENTSINK_QueryInterface( + PEVENTSINK pEV, + REFIID iid, + LPVOID* ppv + ) { + if (IsEqualIID(iid, &IID_IUnknown) || + IsEqualIID(iid, &IID_IDispatch) || + IsEqualIID(iid, &((PIEVENTSINKOBJ)pEV)->m_iid)) { + *ppv = pEV; + } + else { + *ppv = NULL; + return E_NOINTERFACE; + } + ((LPUNKNOWN)*ppv)->lpVtbl->AddRef((LPUNKNOWN)*ppv); + return NOERROR; +} + +STDMETHODIMP_(ULONG) +EVENTSINK_AddRef( + PEVENTSINK pEV + ){ + PIEVENTSINKOBJ pEVObj = (PIEVENTSINKOBJ)pEV; + return ++pEVObj->m_cRef; +} + +STDMETHODIMP_(ULONG) EVENTSINK_Release( + PEVENTSINK pEV + ) { + PIEVENTSINKOBJ pEVObj = (PIEVENTSINKOBJ)pEV; + --pEVObj->m_cRef; + if(pEVObj->m_cRef != 0) + return pEVObj->m_cRef; + EVENTSINK_Destructor(pEVObj); + return 0; +} + +STDMETHODIMP EVENTSINK_GetTypeInfoCount( + PEVENTSINK pEV, + UINT *pct + ) { + *pct = 0; + return NOERROR; +} + +STDMETHODIMP EVENTSINK_GetTypeInfo( + PEVENTSINK pEV, + UINT info, + LCID lcid, + ITypeInfo **pInfo + ) { + *pInfo = NULL; + return DISP_E_BADINDEX; +} + +STDMETHODIMP EVENTSINK_GetIDsOfNames( + PEVENTSINK pEV, + REFIID riid, + OLECHAR **szNames, + UINT cNames, + LCID lcid, + DISPID *pDispID + ) { + return DISP_E_UNKNOWNNAME; +} + +static VALUE +ole_search_event(ary, ev, is_default) + VALUE ary; + VALUE ev; + BOOL *is_default; +{ + VALUE event; + VALUE def_event; + VALUE event_name; + int i, len; + *is_default = FALSE; + def_event = Qnil; + len = RARRAY(ary)->len; + for(i = 0; i < len; i++) { + event = rb_ary_entry(ary, i); + event_name = rb_ary_entry(event, 1); + if(NIL_P(event_name)) { + *is_default = TRUE; + def_event = event; + } + else if (rb_str_cmp(ev, event_name) == 0) { + *is_default = FALSE; + return event; + } + } + return def_event; +} + +static void +val2ptr_variant(val, var) + VALUE val; + VARIANT *var; +{ + switch (TYPE(val)) { + case T_STRING: + if (V_VT(var) == (VT_BSTR | VT_BYREF)) { + *V_BSTRREF(var) = ole_mb2wc(StringValuePtr(val), -1); + } + break; + case T_FIXNUM: + switch(V_VT(var)) { + case (VT_UI1 | VT_BYREF) : + *V_UI1REF(var) = NUM2CHR(val); + break; + case (VT_I2 | VT_BYREF) : + *V_I2REF(var) = (short)NUM2INT(val); + break; + case (VT_I4 | VT_BYREF) : + *V_I4REF(var) = NUM2INT(val); + break; + case (VT_R4 | VT_BYREF) : + *V_R4REF(var) = (float)NUM2INT(val); + break; + case (VT_R8 | VT_BYREF) : + *V_R8REF(var) = NUM2INT(val); + break; + default: + break; + } + break; + case T_FLOAT: + switch(V_VT(var)) { + case (VT_I2 | VT_BYREF) : + *V_I2REF(var) = (short)NUM2INT(val); + break; + case (VT_I4 | VT_BYREF) : + *V_I4REF(var) = NUM2INT(val); + break; + case (VT_R4 | VT_BYREF) : + *V_R4REF(var) = (float)NUM2DBL(val); + break; + case (VT_R8 | VT_BYREF) : + *V_R8REF(var) = NUM2DBL(val); + break; + default: + break; + } + break; + case T_BIGNUM: + if (V_VT(var) == (VT_R8 | VT_BYREF)) { + *V_R8REF(var) = rb_big2dbl(val); + } + break; + case T_TRUE: + if (V_VT(var) == (VT_BOOL | VT_BYREF)) { + *V_BOOLREF(var) = VARIANT_TRUE; + } + break; + case T_FALSE: + if (V_VT(var) == (VT_BOOL | VT_BYREF)) { + *V_BOOLREF(var) = VARIANT_FALSE; + } + break; + default: + break; + } +} + +static void +ary2ptr_dispparams(ary, pdispparams) + VALUE ary; + DISPPARAMS *pdispparams; +{ + int i; + VALUE v; + VARIANT *pvar; + for(i = 0; i < RARRAY(ary)->len && i < pdispparams->cArgs; i++) { + v = rb_ary_entry(ary, i); + pvar = &pdispparams->rgvarg[pdispparams->cArgs-i-1]; + val2ptr_variant(v, pvar); + } +} + +STDMETHODIMP EVENTSINK_Invoke( + PEVENTSINK pEventSink, + DISPID dispid, + REFIID riid, + LCID lcid, + WORD wFlags, + DISPPARAMS *pdispparams, + VARIANT *pvarResult, + EXCEPINFO *pexcepinfo, + UINT *puArgErr + ) { + + HRESULT hr; + BSTR bstr; + unsigned int count; + unsigned int i; + ITypeInfo *pTypeInfo; + VARIANT *pvar; + VALUE ary, obj, event, handler, args, argv, ev; + BOOL is_default_handler = FALSE; + + PIEVENTSINKOBJ pEV = (PIEVENTSINKOBJ)pEventSink; + pTypeInfo = pEV->pTypeInfo; + + obj = rb_ary_entry(ary_ole_event, pEV->m_event_id); + if (!rb_obj_is_kind_of(obj, cWIN32OLE_EVENT)) { + return NOERROR; + } + + ary = rb_ivar_get(obj, id_events); + if (NIL_P(ary) || TYPE(ary) != T_ARRAY) { + return NOERROR; + } + hr = pTypeInfo->lpVtbl->GetNames(pTypeInfo, dispid, + &bstr, 1, &count); + if (FAILED(hr)) { + return NOERROR; + } + ev = WC2VSTR(bstr); + event = ole_search_event(ary, ev, &is_default_handler); + if (NIL_P(event)) { + return NOERROR; + } + args = rb_ary_new(); + if (is_default_handler) { + rb_ary_push(args, ev); + } + + /* make argument of event handler */ + for (i = 0; i < pdispparams->cArgs; ++i) { + pvar = &pdispparams->rgvarg[pdispparams->cArgs-i-1]; + rb_ary_push(args, ole_variant2val(pvar)); + } + handler = rb_ary_entry(event, 0); + + if (rb_ary_entry(event, 3) == Qtrue) { + argv = rb_ary_new(); + rb_ary_push(args, argv); + rb_apply(handler, rb_intern("call"), args); + ary2ptr_dispparams(argv, pdispparams); + } + else { + rb_apply(handler, rb_intern("call"), args); + } + return NOERROR; +} + +PIEVENTSINKOBJ +EVENTSINK_Constructor() { + PIEVENTSINKOBJ pEv; + if (!g_IsEventSinkVtblInitialized) { + vtEventSink.QueryInterface=EVENTSINK_QueryInterface; + vtEventSink.AddRef = EVENTSINK_AddRef; + vtEventSink.Release = EVENTSINK_Release; + vtEventSink.Invoke = EVENTSINK_Invoke; + vtEventSink.GetIDsOfNames = EVENTSINK_GetIDsOfNames; + vtEventSink.GetTypeInfoCount = EVENTSINK_GetTypeInfoCount; + vtEventSink.GetTypeInfo = EVENTSINK_GetTypeInfo; + + g_IsEventSinkVtblInitialized = TRUE; + } + pEv = ALLOC_N(IEVENTSINKOBJ, 1); + if(pEv == NULL) return NULL; + pEv->lpVtbl = &vtEventSink; + pEv->m_cRef = 0; + pEv->m_event_id = 0; + pEv->m_dwCookie = 0; + pEv->pConnectionPoint = NULL; + pEv->pTypeInfo = NULL; + return pEv; +} + +void EVENTSINK_Destructor( + PIEVENTSINKOBJ pEVObj + ) { + if(pEVObj != NULL) { + free(pEVObj); + } +} + +static HRESULT +find_iid(ole, pitf, piid, ppTypeInfo) + VALUE ole; + char *pitf; + IID *piid; + ITypeInfo **ppTypeInfo; +{ + HRESULT hr; + IDispatch *pDispatch; + ITypeInfo *pTypeInfo; + ITypeLib *pTypeLib; + TYPEATTR *pTypeAttr; + HREFTYPE RefType; + ITypeInfo *pImplTypeInfo; + TYPEATTR *pImplTypeAttr; + + struct oledata *pole; + unsigned int index; + unsigned int count; + unsigned int type; + BSTR bstr; + char *pstr; + + BOOL is_found = FALSE; + LCID lcid = LOCALE_SYSTEM_DEFAULT; + + Data_Get_Struct(ole, struct oledata, pole); + + pDispatch = pole->pDispatch; + + hr = pDispatch->lpVtbl->GetTypeInfo(pDispatch, 0, lcid, &pTypeInfo); + if (FAILED(hr)) + return hr; + + hr = pTypeInfo->lpVtbl->GetContainingTypeLib(pTypeInfo, + &pTypeLib, + &index); + OLE_RELEASE(pTypeInfo); + if (FAILED(hr)) + return hr; + + if (!pitf) { + hr = pTypeLib->lpVtbl->GetTypeInfoOfGuid(pTypeLib, + piid, + ppTypeInfo); + OLE_RELEASE(pTypeLib); + return hr; + } + count = pTypeLib->lpVtbl->GetTypeInfoCount(pTypeLib); + for (index = 0; index < count; index++) { + hr = pTypeLib->lpVtbl->GetTypeInfo(pTypeLib, + index, + &pTypeInfo); + if (FAILED(hr)) + break; + hr = OLE_GET_TYPEATTR(pTypeInfo, &pTypeAttr); + + if(FAILED(hr)) { + OLE_RELEASE(pTypeInfo); + break; + } + if(pTypeAttr->typekind == TKIND_COCLASS) { + for (type = 0; type < pTypeAttr->cImplTypes; type++) { + hr = pTypeInfo->lpVtbl->GetRefTypeOfImplType(pTypeInfo, + type, + &RefType); + if (FAILED(hr)) + break; + hr = pTypeInfo->lpVtbl->GetRefTypeInfo(pTypeInfo, + RefType, + &pImplTypeInfo); + if (FAILED(hr)) + break; + + hr = pImplTypeInfo->lpVtbl->GetDocumentation(pImplTypeInfo, + -1, + &bstr, + NULL, NULL, NULL); + if (FAILED(hr)) { + OLE_RELEASE(pImplTypeInfo); + break; + } + pstr = ole_wc2mb(bstr); + if (strcmp(pitf, pstr) == 0) { + hr = pImplTypeInfo->lpVtbl->GetTypeAttr(pImplTypeInfo, + &pImplTypeAttr); + if (SUCCEEDED(hr)) { + is_found = TRUE; + *piid = pImplTypeAttr->guid; + if (ppTypeInfo) { + *ppTypeInfo = pImplTypeInfo; + (*ppTypeInfo)->lpVtbl->AddRef((*ppTypeInfo)); + } + pImplTypeInfo->lpVtbl->ReleaseTypeAttr(pImplTypeInfo, + pImplTypeAttr); + } + } + free(pstr); + OLE_RELEASE(pImplTypeInfo); + if (is_found || FAILED(hr)) + break; + } + } + + OLE_RELEASE_TYPEATTR(pTypeInfo, pTypeAttr); + OLE_RELEASE(pTypeInfo); + if (is_found || FAILED(hr)) + break; + } + OLE_RELEASE(pTypeLib); + if(!is_found) + return E_NOINTERFACE; + return hr; +} + +static HRESULT +find_default_source(ole, piid, ppTypeInfo) + VALUE ole; + IID *piid; + ITypeInfo **ppTypeInfo; +{ + HRESULT hr; + IProvideClassInfo2 *pProvideClassInfo2; + IProvideClassInfo *pProvideClassInfo; + + IDispatch *pDispatch; + ITypeInfo *pTypeInfo; + TYPEATTR *pTypeAttr; + unsigned int i; + int iFlags; + HREFTYPE hRefType; + + struct oledata *pole; + + Data_Get_Struct(ole, struct oledata, pole); + pDispatch = pole->pDispatch; + hr = pDispatch->lpVtbl->QueryInterface(pDispatch, + &IID_IProvideClassInfo2, + (void**)&pProvideClassInfo2); + if (SUCCEEDED(hr)) { + hr = pProvideClassInfo2->lpVtbl->GetGUID(pProvideClassInfo2, + GUIDKIND_DEFAULT_SOURCE_DISP_IID, + piid); + OLE_RELEASE(pProvideClassInfo2); + return find_iid(ole, NULL, piid, ppTypeInfo); + } + hr = pDispatch->lpVtbl->QueryInterface(pDispatch, + &IID_IProvideClassInfo, + (void**)&pProvideClassInfo); + if (FAILED(hr)) + return hr; + + hr = pProvideClassInfo->lpVtbl->GetClassInfo(pProvideClassInfo, + &pTypeInfo); + OLE_RELEASE(pProvideClassInfo); + if (FAILED(hr)) + return hr; + + hr = OLE_GET_TYPEATTR(pTypeInfo, &pTypeAttr); + if (FAILED(hr)) { + OLE_RELEASE(pTypeInfo); + return hr; + } + /* Enumerate all implemented types of the COCLASS */ + for (i = 0; i < pTypeAttr->cImplTypes; i++) { + hr = pTypeInfo->lpVtbl->GetImplTypeFlags(pTypeInfo, i, &iFlags); + if (FAILED(hr)) + continue; + + /* + looking for the [default] [source] + we just hope that it is a dispinterface :-) + */ + if ((iFlags & IMPLTYPEFLAG_FDEFAULT) && + (iFlags & IMPLTYPEFLAG_FSOURCE)) { + + hr = pTypeInfo->lpVtbl->GetRefTypeOfImplType(pTypeInfo, + i, &hRefType); + if (FAILED(hr)) + continue; + hr = pTypeInfo->lpVtbl->GetRefTypeInfo(pTypeInfo, + hRefType, ppTypeInfo); + if (SUCCEEDED(hr)) + break; + } + } + + OLE_RELEASE_TYPEATTR(pTypeInfo, pTypeAttr); + OLE_RELEASE(pTypeInfo); + + /* Now that would be a bad surprise, if we didn't find it, wouldn't it? */ + if (!*ppTypeInfo) { + if (SUCCEEDED(hr)) + hr = E_UNEXPECTED; + return hr; + } + + // Determine IID of default source interface + hr = (*ppTypeInfo)->lpVtbl->GetTypeAttr(*ppTypeInfo, &pTypeAttr); + if (SUCCEEDED(hr)) { + *piid = pTypeAttr->guid; + (*ppTypeInfo)->lpVtbl->ReleaseTypeAttr(*ppTypeInfo, pTypeAttr); + } + else + OLE_RELEASE(*ppTypeInfo); + + return hr; + +} + +static void +ole_event_free(poleev) + struct oleeventdata *poleev; +{ + ITypeInfo *pti = NULL; + IConnectionPoint *pcp = NULL; + + if(poleev->pEvent) { + pti = poleev->pEvent->pTypeInfo; + if(pti) OLE_RELEASE(pti); + pcp = poleev->pEvent->pConnectionPoint; + if(pcp) { + pcp->lpVtbl->Unadvise(pcp, poleev->pEvent->m_dwCookie); + OLE_RELEASE(pcp); + } + ole_msg_loop(); + CoFreeUnusedLibraries(); + } +} + +static VALUE +fev_s_allocate(klass) + VALUE klass; +{ + VALUE obj; + struct oleeventdata *poleev; + obj = Data_Make_Struct(klass,struct oleeventdata,0,ole_event_free,poleev); + poleev->pEvent = NULL; + return obj; +} + +static VALUE +fev_initialize(argc, argv, self) + int argc; + VALUE *argv; + VALUE self; +{ + VALUE ole, itf; + struct oledata *pole; + char *pitf; + HRESULT hr; + IID iid; + ITypeInfo *pTypeInfo; + IDispatch *pDispatch; + IConnectionPointContainer *pContainer; + IConnectionPoint *pConnectionPoint; + IEVENTSINKOBJ *pIEV; + DWORD dwCookie; + struct oleeventdata *poleev; + + rb_scan_args(argc, argv, "11", &ole, &itf); + + if (!rb_obj_is_kind_of(ole, cWIN32OLE)) { + rb_raise(rb_eTypeError, "1st parametor must be WIN32OLE object."); + } + + if(TYPE(itf) != T_NIL) { + Check_SafeStr(itf); + pitf = StringValuePtr(itf); + hr = find_iid(ole, pitf, &iid, &pTypeInfo); + } + else { + hr = find_default_source(ole, &iid, &pTypeInfo); + } + if (FAILED(hr)) { + ole_raise(hr, rb_eRuntimeError, "not found interface"); + } + + Data_Get_Struct(ole, struct oledata, pole); + pDispatch = pole->pDispatch; + hr = pDispatch->lpVtbl->QueryInterface(pDispatch, + &IID_IConnectionPointContainer, + (void**)&pContainer); + if (FAILED(hr)) { + OLE_RELEASE(pTypeInfo); + ole_raise(hr, rb_eRuntimeError, + "fail to query IConnectionPointContainer"); + } + + hr = pContainer->lpVtbl->FindConnectionPoint(pContainer, + &iid, + &pConnectionPoint); + OLE_RELEASE(pContainer); + if (FAILED(hr)) { + OLE_RELEASE(pTypeInfo); + ole_raise(hr, rb_eRuntimeError, "fail to query IConnectionPoint"); + } + pIEV = EVENTSINK_Constructor(); + pIEV->m_iid = iid; + hr = pConnectionPoint->lpVtbl->Advise(pConnectionPoint, + (IUnknown*)pIEV, + &dwCookie); + if (FAILED(hr)) { + ole_raise(hr, rb_eRuntimeError, "Advise Error"); + } + + Data_Get_Struct(self, struct oleeventdata, poleev); + poleev->pEvent = pIEV; + poleev->pEvent->m_event_id + = NUM2INT(rb_funcall(ary_ole_event, rb_intern("length"), 0)); + poleev->pEvent->pConnectionPoint = pConnectionPoint; + poleev->pEvent->pTypeInfo = pTypeInfo; + poleev->pEvent->m_dwCookie = dwCookie; + + rb_ary_push(ary_ole_event, self); + return self; +} + +/* + * WIN32OLE_EVENT.message_loop + * --- + * Translates and dispatches Windows message. + */ +static VALUE +fev_s_msg_loop(klass) + VALUE klass; +{ + ole_msg_loop(); + return Qnil; +} + + +static void +add_event_call_back(obj, data) + VALUE obj; + VALUE data; +{ + VALUE ary = rb_ivar_get(obj, id_events); + if (NIL_P(ary) || TYPE(ary) != T_ARRAY) { + ary = rb_ary_new(); + rb_ivar_set(obj, id_events, ary); + } + rb_ary_push(ary, data); +} + +static VALUE +ev_on_event(argc, argv, self, is_ary_arg) + int argc; + VALUE *argv; + VALUE self; + VALUE is_ary_arg; +{ + VALUE event, args, data; + rb_scan_args(argc, argv, "01*", &event, &args); + if(!NIL_P(event)) { + Check_SafeStr(event); + } + data = rb_ary_new3(4, rb_f_lambda(), event, args, is_ary_arg); + add_event_call_back(self, data); + return Qnil; +} + +/* + * WIN32OLE_EVENT#on_event([event]){...} + * ---- + * defines the callback event. + * If argument is omitted, this method defines the callback of all events. + */ +static VALUE +fev_on_event(argc, argv, self) + int argc; + VALUE *argv; + VALUE self; +{ + return ev_on_event(argc, argv, self, Qfalse); +} + +/* + * WIN32OLE_EVENT#on_event_with_outargs([event]){...} + * ---- + * defines the callback of event. + * If you want modify argument in callback, + * you should use this method instead of WIN32OLE_EVENT#on_event. + */ +static VALUE +fev_on_event_with_outargs(argc, argv, self) + int argc; + VALUE *argv; + VALUE self; +{ + return ev_on_event(argc, argv, self, Qtrue); +} + + +void +Init_win32ole() +{ + ary_ole_event = rb_ary_new(); + rb_global_variable(&ary_ole_event); + id_events = rb_intern("events"); + + cWIN32OLE = rb_define_class("WIN32OLE", rb_cObject); + + rb_define_singleton_method(cWIN32OLE, "allocate", fole_s_allocate, 0); + + rb_define_method(cWIN32OLE, "initialize", fole_initialize, -1); + rb_enable_super(cWIN32OLE, "initialize"); + + rb_define_singleton_method(cWIN32OLE, "connect", fole_s_connect, -1); + rb_define_singleton_method(cWIN32OLE, "const_load", fole_s_const_load, -1); + + rb_define_singleton_method(cWIN32OLE, "ole_free", fole_s_free, 1); + rb_define_singleton_method(cWIN32OLE, "ole_reference_count", fole_s_reference_count, 1); + rb_define_singleton_method(cWIN32OLE, "ole_show_help", fole_s_show_help, -1); + + + rb_define_method(cWIN32OLE, "invoke", fole_invoke, -1); + rb_define_method(cWIN32OLE, "[]", fole_getproperty, 1); + rb_define_method(cWIN32OLE, "_invoke", fole_invoke2, 3); + rb_define_method(cWIN32OLE, "_getproperty", fole_getproperty2, 3); + rb_define_method(cWIN32OLE, "_setproperty", fole_setproperty2, 3); + + /* support propput method that takes an argument */ + rb_define_method(cWIN32OLE, "[]=", fole_setproperty, -1); + + rb_define_method(cWIN32OLE, "each", fole_each, 0); + rb_define_method(cWIN32OLE, "method_missing", fole_missing, -1); + + /* support setproperty method much like Perl ;-) */ + rb_define_method(cWIN32OLE, "setproperty", fole_setproperty, -1); + + rb_define_method(cWIN32OLE, "ole_methods", fole_methods, 0); + rb_define_method(cWIN32OLE, "ole_get_methods", fole_get_methods, 0); + rb_define_method(cWIN32OLE, "ole_put_methods", fole_put_methods, 0); + rb_define_method(cWIN32OLE, "ole_func_methods", fole_func_methods, 0); + + rb_define_method(cWIN32OLE, "ole_method", fole_method_help, 1); + rb_define_alias(cWIN32OLE, "ole_method_help", "ole_method"); + rb_define_method(cWIN32OLE, "ole_obj_help", fole_obj_help, 0); + + rb_define_const(cWIN32OLE, "VERSION", rb_str_new2(WIN32OLE_VERSION)); + rb_define_const(cWIN32OLE, "ARGV", rb_ary_new()); + + mWIN32OLE_VARIANT = rb_define_module_under(cWIN32OLE, "VARIANT"); + rb_define_const(mWIN32OLE_VARIANT, "VT_I2", INT2FIX(VT_I2)); + rb_define_const(mWIN32OLE_VARIANT, "VT_I4", INT2FIX(VT_I4)); + rb_define_const(mWIN32OLE_VARIANT, "VT_R4", INT2FIX(VT_R4)); + rb_define_const(mWIN32OLE_VARIANT, "VT_R8", INT2FIX(VT_R8)); + rb_define_const(mWIN32OLE_VARIANT, "VT_CY", INT2FIX(VT_CY)); + rb_define_const(mWIN32OLE_VARIANT, "VT_DATE", INT2FIX(VT_DATE)); + rb_define_const(mWIN32OLE_VARIANT, "VT_BSTR", INT2FIX(VT_BSTR)); + rb_define_const(mWIN32OLE_VARIANT, "VT_USERDEFINED", INT2FIX(VT_USERDEFINED)); + rb_define_const(mWIN32OLE_VARIANT, "VT_PTR", INT2FIX(VT_PTR)); + rb_define_const(mWIN32OLE_VARIANT, "VT_DISPATCH", INT2FIX(VT_DISPATCH)); + rb_define_const(mWIN32OLE_VARIANT, "VT_ERROR", INT2FIX(VT_ERROR)); + rb_define_const(mWIN32OLE_VARIANT, "VT_BOOL", INT2FIX(VT_BOOL)); + rb_define_const(mWIN32OLE_VARIANT, "VT_VARIANT", INT2FIX(VT_VARIANT)); + rb_define_const(mWIN32OLE_VARIANT, "VT_UNKNOWN", INT2FIX(VT_UNKNOWN)); + rb_define_const(mWIN32OLE_VARIANT, "VT_I1", INT2FIX(VT_I1)); + rb_define_const(mWIN32OLE_VARIANT, "VT_UI1", INT2FIX(VT_UI1)); + rb_define_const(mWIN32OLE_VARIANT, "VT_UI2", INT2FIX(VT_UI2)); + rb_define_const(mWIN32OLE_VARIANT, "VT_UI4", INT2FIX(VT_UI4)); + rb_define_const(mWIN32OLE_VARIANT, "VT_INT", INT2FIX(VT_INT)); + rb_define_const(mWIN32OLE_VARIANT, "VT_UINT", INT2FIX(VT_UINT)); + rb_define_const(mWIN32OLE_VARIANT, "VT_ARRAY", INT2FIX(VT_ARRAY)); + rb_define_const(mWIN32OLE_VARIANT, "VT_BYREF", INT2FIX(VT_BYREF)); + + cWIN32OLE_TYPE = rb_define_class("WIN32OLE_TYPE", rb_cObject); + rb_define_singleton_method(cWIN32OLE_TYPE, "ole_classes", foletype_s_ole_classes, 1); + rb_define_singleton_method(cWIN32OLE_TYPE, "typelibs", foletype_s_typelibs, 0); + rb_define_singleton_method(cWIN32OLE_TYPE, "progids", foletype_s_progids, 0); + rb_define_singleton_method(cWIN32OLE_TYPE, "allocate", foletype_s_allocate, 0); + rb_define_method(cWIN32OLE_TYPE, "initialize", foletype_initialize, 2); + rb_enable_super(cWIN32OLE_TYPE, "initialize"); + rb_define_method(cWIN32OLE_TYPE, "name", foletype_name, 0); + rb_define_method(cWIN32OLE_TYPE, "ole_type", foletype_ole_type, 0); + rb_define_method(cWIN32OLE_TYPE, "guid", foletype_guid, 0); + rb_define_method(cWIN32OLE_TYPE, "progid", foletype_progid, 0); + rb_define_method(cWIN32OLE_TYPE, "visible?", foletype_visible, 0); + + rb_define_method(cWIN32OLE_TYPE, "major_version", foletype_major_version, 0); + rb_define_method(cWIN32OLE_TYPE, "minor_version", foletype_minor_version, 0); + rb_define_method(cWIN32OLE_TYPE, "typekind", foletype_typekind, 0); + rb_define_method(cWIN32OLE_TYPE, "helpstring", foletype_helpstring, 0); + rb_define_method(cWIN32OLE_TYPE, "src_type", foletype_src_type, 0); + rb_define_method(cWIN32OLE_TYPE, "helpfile", foletype_helpfile, 0); + rb_define_method(cWIN32OLE_TYPE, "helpcontext", foletype_helpcontext, 0); + rb_define_method(cWIN32OLE_TYPE, "variables", foletype_variables, 0); + rb_define_method(cWIN32OLE_TYPE, "ole_methods", foletype_methods, -1); + + cWIN32OLE_VARIABLE = rb_define_class("WIN32OLE_VARIABLE", rb_cObject); + rb_define_method(cWIN32OLE_VARIABLE, "name", folevariable_name, 0); + rb_define_method(cWIN32OLE_VARIABLE, "ole_type", folevariable_ole_type, 0); + rb_define_method(cWIN32OLE_VARIABLE, "ole_type_detail", folevariable_ole_type_detail, 0); + rb_define_method(cWIN32OLE_VARIABLE, "value", folevariable_value, 0); + rb_define_method(cWIN32OLE_VARIABLE, "visible?", folevariable_visible, 0); + rb_define_method(cWIN32OLE_VARIABLE, "variable_kind", folevariable_variable_kind, 0); + rb_define_method(cWIN32OLE_VARIABLE, "varkind", folevariable_varkind, 0); + + cWIN32OLE_METHOD = rb_define_class("WIN32OLE_METHOD", rb_cObject); + rb_define_singleton_method(cWIN32OLE_METHOD, "allocate", folemethod_s_allocate, 0); + rb_define_method(cWIN32OLE_METHOD, "initialize", folemethod_initialize, 2); + rb_enable_super(cWIN32OLE_METHOD, "initialize"); + + rb_define_method(cWIN32OLE_METHOD, "name", folemethod_name, 0); + rb_define_method(cWIN32OLE_METHOD, "return_type", folemethod_return_type, 0); + rb_define_method(cWIN32OLE_METHOD, "return_vtype", folemethod_return_vtype, 0); + rb_define_method(cWIN32OLE_METHOD, "return_type_detail", folemethod_return_type_detail, 0); + rb_define_method(cWIN32OLE_METHOD, "invoke_kind", folemethod_invoke_kind, 0); + rb_define_method(cWIN32OLE_METHOD, "invkind", folemethod_invkind, 0); + rb_define_method(cWIN32OLE_METHOD, "visible?", folemethod_visible, 0); + rb_define_method(cWIN32OLE_METHOD, "event?", folemethod_event, 0); + rb_define_method(cWIN32OLE_METHOD, "event_interface", folemethod_event_interface, 0); + rb_define_method(cWIN32OLE_METHOD, "helpstring", folemethod_helpstring, 0); + rb_define_method(cWIN32OLE_METHOD, "helpfile", folemethod_helpfile, 0); + rb_define_method(cWIN32OLE_METHOD, "helpcontext", folemethod_helpcontext, 0); + rb_define_method(cWIN32OLE_METHOD, "dispid", folemethod_dispid, 0); + rb_define_method(cWIN32OLE_METHOD, "offset_vtbl", folemethod_offset_vtbl, 0); + rb_define_method(cWIN32OLE_METHOD, "size_params", folemethod_size_params, 0); + rb_define_method(cWIN32OLE_METHOD, "size_opt_params", folemethod_size_opt_params, 0); + rb_define_method(cWIN32OLE_METHOD, "params", folemethod_params, 0); + + cWIN32OLE_PARAM = rb_define_class("WIN32OLE_PARAM", rb_cObject); + rb_define_method(cWIN32OLE_PARAM, "name", foleparam_name, 0); + rb_define_method(cWIN32OLE_PARAM, "ole_type", foleparam_ole_type, 0); + rb_define_method(cWIN32OLE_PARAM, "ole_type_detail", foleparam_ole_type_detail, 0); + rb_define_method(cWIN32OLE_PARAM, "input?", foleparam_input, 0); + rb_define_method(cWIN32OLE_PARAM, "output?", foleparam_output, 0); + rb_define_method(cWIN32OLE_PARAM, "optional?", foleparam_optional, 0); + rb_define_method(cWIN32OLE_PARAM, "retval?", foleparam_retval, 0); + rb_define_method(cWIN32OLE_PARAM, "default", foleparam_default, 0); + + cWIN32OLE_EVENT = rb_define_class("WIN32OLE_EVENT", rb_cObject); + + rb_define_singleton_method(cWIN32OLE_EVENT, "allocate", fev_s_allocate, 0); + rb_define_method(cWIN32OLE_EVENT, "initialize", fev_initialize, -1); + rb_enable_super(cWIN32OLE_EVENT, "initialize"); + rb_define_singleton_method(cWIN32OLE_EVENT, "message_loop", fev_s_msg_loop, 0); + + rb_define_method(cWIN32OLE_EVENT, "on_event", fev_on_event, -1); + rb_define_method(cWIN32OLE_EVENT, "on_event_with_outargs", fev_on_event_with_outargs, -1); + eWIN32OLE_RUNTIME_ERROR = rb_define_class("WIN32OLERuntimeError", rb_eRuntimeError); +} -- cgit v1.2.3