Active-X Wizard: Generated public methods

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Active-X Wizard: Generated public methods

Chris Hayes
In some instances, the public methods generated by the Active-X Component
Wizard do not include an explicit return and are, therefore, answering the
receiver rather than the value returned by the private version of the method
they call.  This seems to be happening when the return type of the private
method is an Integer.

Chris


Reply | Threaded
Open this post in threaded view
|

Re: Active-X Wizard: Generated public methods

Blair McGlashan
Chris

You wrote in message news:JsEk6.56$[hidden email]...
> In some instances, the public methods generated by the Active-X Component
> Wizard do not include an explicit return and are, therefore, answering the
> receiver rather than the value returned by the private version of the
method
> they call.  This seems to be happening when the return type of the private
> method is an Integer.

If you can post the name of a COM component or two where this is the case,
then I can check it out.

Thanks

Blair


Reply | Threaded
Open this post in threaded view
|

Re: Active-X Wizard: Generated public methods

Chris Hayes
"Blair McGlashan" <[hidden email]> wrote in message
news:97062n$n3b9q$[hidden email]...
> Chris
>
> You wrote in message news:JsEk6.56$[hidden email]...
> > In some instances, the public methods generated by the Active-X
Component
> > Wizard do not include an explicit return and are, therefore, answering
the
> > receiver rather than the value returned by the private version of the
> method
> > they call.  This seems to be happening when the return type of the
private
> > method is an Integer.
>
> If you can post the name of a COM component or two where this is the case,
> then I can check it out.
>

Hi Blair.

DirectX 8 (dx8vb.dll).  Bring up the wizard and accept the default value for
all options (e.g., high-level wrapper methods = "full").  Generate and then
examine Direct3D8>>getAdapterCount.

Thanks.

Chris


Reply | Threaded
Open this post in threaded view
|

Re: Active-X Wizard: Generated public methods

Blair McGlashan
Chris

You wrote in message news:OuOk6.446$[hidden email]...
> ...
> DirectX 8 (dx8vb.dll).  Bring up the wizard and accept the default value
for
> all options (e.g., high-level wrapper methods = "full").  Generate and
then
> examine Direct3D8>>getAdapterCount.

Thanks. The problem appears to be specifically with methods that return a
result in the normal C way, rather than in the normal COM way (i.e. through
an output parameter because the return value is normally reserved for the
HRESULT error/success code).

See how you get on with the attached patch (which modifies the code
generation so that it always returns the result of a method invocation, even
if it is an HRESULT, if there isn't an [out,retval] argument, except in the
case of propput methods).

Regards

Blair

----------------------------------------------------------------------------
!FUNCDESC methodsFor!

isPropSet
 "Answer whether the receiver describes a property value or reference
assignment
 function (i.e. it is of invocation type INVOKE_PROPERTYPUT[REF])."

 | invkind |
 ^(invkind := self invkind) == INVOKE_PROPERTYPUT
  or: [invkind == INVOKE_PROPERTYPUTREF]! !
!FUNCDESC categoriesFor: #isPropSet!public!testing! !

!TKindInterfaceAnalyzer methodsFor!

printMethodWrapperBody: method args: pairs on: target
 "Private - Generate the main body of a  high-level method for the method
described
 by the <FUNCDESC>, method, calling the low-level method whose keyword and
argument
 pairs are contained in the <sequencedReadableCollection> or <Association>s,
pairs.
 Answers nil to suppress generation of method, else self."

 |  params nRet |

 method hasMultipleOutputs ifTrue: [^self printMultiOutMethodWrapperBody:
method args: pairs on: target].

 params :=  method arguments.

 (nRet := method retvalIndex) ~= 0 ifTrue: [ | answerDesc |
  target
   nextPutAll: '| answer |'; crtab;
   nextPutAll: 'answer := '.
  answerDesc := method classDesc.
  answerDesc key
    printMethodArgument: (pairs at: nRet) value
    elemdesc: (params at: nRet)
    indirections: answerDesc value
    on: target.
  target nextPut: $.; crtab].

 "If there is no output argument, then answer any return value from the raw
method, even if
  it is just an HRESULT because sometimes HRESULT success codes contain
useful information.
  However for compatibility with Smalltalk inst. var. setter methods we
still want to return the
  receiver for property setters."
 (nRet == 0 and: [method isPropSet not and: [method hasReturnValue]])
ifTrue: [target nextPut: $^].

 "Print call to raw method"
 target nextPutAll: 'self'.
 params isEmpty
  ifTrue: [target space; nextPutAll: pairs first key]
  ifFalse: [
   "Print keyword arg pairs"
   (1 to: pairs size) do: [:i | | a |
    a := pairs at: i.
    target crtab: 2; nextPutAll: a key; space.
    i == nRet
     ifTrue: [target nextPutAll: 'answer']
     ifFalse: [ | arg desc |
      arg := params at: i.
      desc := arg classDesc.
      desc key
       printMethodArgument: a value
       elemdesc: arg
       indirections: desc value
       on: target]]].

 nRet ~= 0 ifTrue: [
  target nextPut: $.; crtab; nextPutAll: '^answer asObject'].

 target cr! !
!TKindInterfaceAnalyzer categoriesFor:
#printMethodWrapperBody:args:on:!development!private! !

!TKindInterfaceAnalyzer methodsFor!

methodHasReturnValue: method
 "Private - Answer whether or not the function described by the <FUNCDESC>,
method,
 has a significant return value."

 ^method tdesc vt ~= VT_HRESULT or: [method hasRetval]! !
!TKindInterfaceAnalyzer categoriesFor:
#methodHasReturnValue:!helpers!private! !