[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

WIN32OLE type binding

Bruno Le hyaric

6/12/2009 1:01:00 PM

Hi,

My COM Web Browser is making progress...
I can scan COM API, get and set properties value.

The next step is to permit RPC on methods.

Ruby reflexivity let me know :
- the list of methods for an object,
- parameters and their types for each method.

Now I seek for introspection about type binding between Ruby and COM...
I looked at the documentation where I see we can get all COM
classes...but not what I want. Here is an example of what I'm looking
for :

BSTR => String
I4 => Fixnum
F8 => Float
...


does anybody got an advice?
--
Posted via http://www.ruby-....

5 Answers

Gregory Brown

6/12/2009 1:11:00 PM

0

On Fri, Jun 12, 2009 at 9:00 AM, Bruno Le
hyaric<bruno.lehyaric@gmail.com> wrote:
> Hi,
>
> My COM Web Browser is making progress...
> I can scan COM API, get and set properties value.
>
> The next step is to permit RPC on methods.

Can you clarify your question a little bit? I'm not sure whether
you're asking how to call methods on an WIN32OLE object that are
provided by a DLL, or if you're looking for introspection that will
provide a methods signature...

-greg

Bruno Le hyaric

6/12/2009 3:05:00 PM

0

Gregory Brown wrote:
> On Fri, Jun 12, 2009 at 9:00 AM, Bruno Le
> hyaric<bruno.lehyaric@gmail.com> wrote:
>> Hi,
>>
>> My COM Web Browser is making progress...
>> I can scan COM API, get and set properties value.
>>
>> The next step is to permit RPC on methods.
>
> Can you clarify your question a little bit? I'm not sure whether
> you're asking how to call methods on an WIN32OLE object that are
> provided by a DLL, or if you're looking for introspection that will
> provide a methods signature...
>
> -greg

Ok, I have a graphic interface from wich I want to call COM methods.
By introspection I know the signature of methods.
The problem is that my interface (a web page) only permits text input.
So all values I enter are Strings. I need to cast or interpret strings
to match parameters types...

I solve the problem for put properties like that :

# obj : COM object
# prop : name of the property
# value : string value I want to put
def cast_from_string(obj,prop,value)

#call the get property, only to know the type of the Ruby object
type = obj.send prop.to_sym

#match on Ruby types and convert the string accordingly...
case type
when Integer
return value.to_i
when Float
return value.to_f
when TrueClass, FalseClass
return value == true.to_s
else
return value
end
end



So I want to convert String to the matching Ruby type
To do that, I need to have a list of COM types and their matched Ruby
types.
I wonder if there is that information somewhere in WIN32OLE...

I take a screenshot of the web page so you can have an better idea on
what I'm trying to do :)


Attachments:
http://www.ruby-...attachment/3813/...

--
Posted via http://www.ruby-....

Gregory Brown

6/12/2009 3:23:00 PM

0

On Fri, Jun 12, 2009 at 11:05 AM, Bruno Le
hyaric<bruno.lehyaric@gmail.com> wrote:

> So I want to convert String to the matching Ruby type
> To do that, I need to have a list of COM types and their matched Ruby
> types.
> I wonder if there is that information somewhere in WIN32OLE...
>
> I take a screenshot of the web page so you can have an better idea on
> what I'm trying to do :)

> Attachments:
> http://www.ruby-forum.com/attachment/3813/...

Oh I see, when you said COM Web Browser I thought you meant something
like building your own browser calling out to IE.
You literally meant browsing COM objects on the web. Interesting
idea... do you plan to open source this?

Unfortunately, I'm a bit of a WIN32OLE newb and this takes me a bit
out of my element. So maybe someone else can help you here.

Masaki Suketa

6/13/2009 1:27:00 AM

0

Hello,

Bruno Le hyaric wrote:

> So I want to convert String to the matching Ruby type
> To do that, I need to have a list of COM types and their matched Ruby
> types.
> I wonder if there is that information somewhere in WIN32OLE...

Sorry, but there is no way to get that information from Win32OLE.
The only way is reading win32ole.c(ole_variant2val() and
ole_val2variant()).

Regards,
Masaki Suketa

Heesob Park

6/13/2009 1:43:00 AM

0

2009/6/13 Masaki Suketa <masaki.suketa@nifty.ne.jp>:
> Hello,
>
> Bruno Le hyaric wrote:
>
>> So I want to convert String to the matching Ruby type
>> To do that, I need to have a list of COM types and their matched Ruby
>> types.
>> I wonder if there is that information somewhere in WIN32OLE...
>
> Sorry, but there is no way to get that information from Win32OLE.
> The only way is reading win32ole.c(ole_variant2val() and
> ole_val2variant()).
>
Or reading my translation win32ole.rb at
http://121.78.227.9/win32-ole/w...

Regards,
Park Heesob