PrototypeFromInterface

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
Leonhard
User
User
Posts: 55
Joined: Fri Jun 16, 2006 7:43 am

PrototypeFromInterface

Post by Leonhard »

I look for a compiler-function to get a property from a interface.

Example:

Code: Select all

Interface IADsPropertyList
  QueryInterface(a, b)
  AddRef()
  Release()
  GetTypeInfoCount(a)
  GetTypeInfo(a, b, c)
  GetIDsOfNames(a, b, c, d, e)
  Invoke(a, b, c, d, e, f, g, h)
  get_PropertyCount(a)
  Next(a)
  Skip(a)
  Reset()
  Item(a.p-variant, b)
  GetPropertyItem(a.p-bstr, b, c)
  PutPropertyItem(a.p-variant)
  ResetPropertyItem(a.p-variant)
  PurgePropertyList()
EndInterface

Define Invoke.PrototypeFromInterface(IADsPropertyList, Invoke)
It would be very nice.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

But wouldn't you have to tie the resulting prototype to an instance of the object in question rather than leave it as a generic 'class' prototype? The first (unseen) parameter to interface methods is always a pointer to the object itself (*self or *this etc.) and so I cannot see how a 'method prototype' can exist outside of an instance of the class. In which case, such a thing would seem rather pointless.

You can try something like the following, although I am far from convinced that it will work :) :

Code: Select all

Interface IADsPropertyList
  QueryInterface(a, b) 
  AddRef() 
  Release() 
  GetTypeInfoCount(a) 
  GetTypeInfo(a, b, c) 
  GetIDsOfNames(a, b, c, d, e) 
  Invoke(a, b, c, d, e, f, g, h) 
  get_PropertyCount(a) 
  Next(a) 
  Skip(a) 
  Reset() 
  Item(a.p-variant, b) 
  GetPropertyItem(a.p-bstr, b, c) 
  PutPropertyItem(a.p-variant) 
  ResetPropertyItem(a.p-variant) 
  PurgePropertyList() 
EndInterface 

Prototype _invoke(*self.IADsPropertyList, a, b, c, d, e, f, g, h)

test.IADsPropertyList
CoCreateInstance_(...blah blah..., @test)

Define Invoke._invoke = PeekL(PeekL(test)+OffsetOf(IADsPropertyList\Invoke()))

Invoke(test, a, b, ... blah blah)
I may look like a mule, but I'm not a complete ass.
Leonhard
User
User
Posts: 55
Joined: Fri Jun 16, 2006 7:43 am

Post by Leonhard »

A little bit big as my way but ok.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

I've tested it as far as obtaining the correct function address - and that is fine. Whether it will execute the method correctly though... that is a different matter! :)
I may look like a mule, but I'm not a complete ass.
Post Reply