problem in generated code: 'Invalid arg 6: Cannot coerce a SDWORD to SDWORD*

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

problem in generated code: 'Invalid arg 6: Cannot coerce a SDWORD to SDWORD*

Oli Bye-2
Hi,

I've used the ActiveX Component Wizard to wrap up TAPI, but I'm having a
type coerce problem in the generated code.

It has generated this public method:-

registerCallNotifications: pAddress fMonitor: fMonitor fOwner: fOwner
lMediaTypes: lMediaTypes lCallbackInstance: lCallbackInstance
    "Answer the <SDWORD> result of invoking the COM Object's
RegisterCallNotifications() method.
    Helpstring: 'method RegisterCallNotifications'"
    | answer |
    answer := (SDWORD new).
    self
    RegisterCallNotifications: pAddress
    fMonitor: fMonitor
    fOwner: fOwner
    lMediaTypes: lMediaTypes
    lCallbackInstance: lCallbackInstance
    plRegister: answer.
    ^answer asObject

Which then calls this private method:-

RegisterCallNotifications: pAddress fMonitor: fMonitor fOwner: fOwner
lMediaTypes: lMediaTypes lCallbackInstance: lCallbackInstance plRegister:
plRegister
    "Private - Invoke the RegisterCallNotifications() method of the COM
object wrapped by the receiver.
    Helpstring: 'method RegisterCallNotifications'
    HRESULT __stdcall RegisterCallNotifications(
    [in] ITAddress* pAddress,
    [in] VARIANT_BOOL fMonitor,
    [in] VARIANT_BOOL fOwner,
    [in] long lMediaTypes,
    [in] long lCallbackInstance,
    [out, retval] long* plRegister);
    "
    <virtual stdcall: hresult 12 TAPI3LibITAddress* varbool varbool sdword
sdword sdword*>
    ^self invalidCall

All looks fine but evaulating the following in the workspace throws an
exception on the last line.

container := tapi queryInterface: IConnectionPointContainer.
point := container findConnectionPoint:
TAPI3LibITTAPIDispatchEventNotification.
handler := LoggingTAPIEventNotification new.
callback := point advise: (handler queryInterface: IUnknown).
reply := tapi registerCallNotifications: address fMonitor: true fOwner:
false lMediaTypes: 8 lCallbackInstance: callback.

12:19:14, 19/11/2001: 'Invalid arg 6: Cannot coerce a SDWORD to SDWORD*'
TAPI3LibITTAPI(ExternalStructure)>>invalidCall
TAPI3LibITTAPI>>RegisterCallNotifications:fMonitor:fOwner:lMediaTypes:lCallb
ackInstance:plRegister:
TAPI3LibITTAPI>>registerCallNotifications:fMonitor:fOwner:lMediaTypes:lCallb
ackInstance:
UndefinedObject>>{unbound}doIt
CompiledExpression>>value:
SmalltalkWorkspace>>evaluateRange:ifFail:debug:
SmalltalkWorkspace>>evaluateItIfFail:debug:
SmalltalkWorkspace>>evaluateItIfFail:
SmalltalkWorkspace>>inspectIt
Symbol>>forwardTo:
[] in Command>>value
BlockClosure>>ifCurtailed:
BlockClosure>>ensure:
Command>>value
SmalltalkWorkspaceDocument(Shell)>>performCommand:
CommandQuery>>perform
DelegatingCommandPolicy(CommandPolicy)>>route:
[] in ShellView(View)>>onCommand:
BlockClosure>>ifCurtailed:
BlockClosure>>ensure:
Cursor>>showWhile:
ShellView(View)>>onCommand:
ShellView(View)>>wmCommand:wParam:lParam:
ShellView(View)>>dispatchMessage:wParam:lParam:
[] in InputState>>wndProc:message:wParam:lParam:cookie:
BlockClosure>>ifCurtailed:
ProcessorScheduler>>callback:evaluate:
InputState>>wndProc:message:wParam:lParam:cookie:
ShellView>>translateAccelerator:
ShellView>>preTranslateKeyboardInput:
ShellView(View)>>preTranslateMessage:
InputState>>preTranslateMessage:
InputState>>pumpMessage:
InputState>>loopWhile:
InputState>>mainLoop
[] in InputState>>forkMain
ExceptionHandler(ExceptionHandlerAbstract)>>markAndTry
[] in ExceptionHandler(ExceptionHandlerAbstract)>>try:
BlockClosure>>ifCurtailed:
BlockClosure>>ensure:
ExceptionHandler(ExceptionHandlerAbstract)>>try:
BlockClosure>>on:do:
[] in BlockClosure>>newProcess


Reply | Threaded
Open this post in threaded view
|

Re: problem in generated code: 'Invalid arg 6: Cannot coerce a SDWORD to SDWORD*

Eric Winger-4
Oli,

I'm not sure why Dolphin is having trouble. I ran a simple little test
on a one arg COM function internal call with the arg being of type
SDWORD*. The following generated code worked fine for me.

getEnable
        "Answer the <SDWORD> result of invoking the COM Object's GetEnable() method."

        | answer |
        answer := (SDWORD new).
        self
                GetEnable: answer.
        ^answer asObject
------
(interface)
GetEnable: pbEnable
        "Private - Invoke the GetEnable() method of the COM object wrapped by the
receiver.

                HRESULT __stdcall GetEnable(
                        [out] long* pbEnable);
        "

        <virtual stdcall: hresult 9 sdword*>
        ^self invalidCall
------
(implementor)
GetEnable: getEnable
        "Implement the IOPCAsyncIO2::GetEnable() interface function."

        ^getEnable value: 1234.



You might try copying the answer to COMTAskMemory

answer := SDWORD new copyToCOMTaskMemory.

to make memory block is valid to COM.



Sorry I can't be more help,

Eric








 > registerCallNotifications: pAddress fMonitor: fMonitor fOwner: fOwner
 > lMediaTypes: lMediaTypes lCallbackInstance: lCallbackInstance
 >     "Answer the <SDWORD> result of invoking the COM Object's
 > RegisterCallNotifications() method.
 >     Helpstring: 'method RegisterCallNotifications'"
 >     | answer |
 >     answer := (SDWORD new).
 >     self
 >     RegisterCallNotifications: pAddress
 >     fMonitor: fMonitor
 >     fOwner: fOwner
 >     lMediaTypes: lMediaTypes
 >     lCallbackInstance: lCallbackInstance
 >     plRegister: answer.
 >     ^answer asObject

Oli Bye wrote:

> Hi,
>
> I've used the ActiveX Component Wizard to wrap up TAPI, but I'm having a
> type coerce problem in the generated code.
>
> It has generated this public method:-
>
> registerCallNotifications: pAddress fMonitor: fMonitor fOwner: fOwner
> lMediaTypes: lMediaTypes lCallbackInstance: lCallbackInstance
>     "Answer the <SDWORD> result of invoking the COM Object's
> RegisterCallNotifications() method.
>     Helpstring: 'method RegisterCallNotifications'"
>     | answer |
>     answer := (SDWORD new).
>     self
>     RegisterCallNotifications: pAddress
>     fMonitor: fMonitor
>     fOwner: fOwner
>     lMediaTypes: lMediaTypes
>     lCallbackInstance: lCallbackInstance
>     plRegister: answer.
>     ^answer asObject
>
> Which then calls this private method:-
>
> RegisterCallNotifications: pAddress fMonitor: fMonitor fOwner: fOwner
> lMediaTypes: lMediaTypes lCallbackInstance: lCallbackInstance plRegister:
> plRegister
>     "Private - Invoke the RegisterCallNotifications() method of the COM
> object wrapped by the receiver.
>     Helpstring: 'method RegisterCallNotifications'
>     HRESULT __stdcall RegisterCallNotifications(
>     [in] ITAddress* pAddress,
>     [in] VARIANT_BOOL fMonitor,
>     [in] VARIANT_BOOL fOwner,
>     [in] long lMediaTypes,
>     [in] long lCallbackInstance,
>     [out, retval] long* plRegister);
>     "
>     <virtual stdcall: hresult 12 TAPI3LibITAddress* varbool varbool sdword
> sdword sdword*>
>     ^self invalidCall
>
> All looks fine but evaulating the following in the workspace throws an
> exception on the last line.
>
> container := tapi queryInterface: IConnectionPointContainer.
> point := container findConnectionPoint:
> TAPI3LibITTAPIDispatchEventNotification.
> handler := LoggingTAPIEventNotification new.
> callback := point advise: (handler queryInterface: IUnknown).
> reply := tapi registerCallNotifications: address fMonitor: true fOwner:
> false lMediaTypes: 8 lCallbackInstance: callback.
>
> 12:19:14, 19/11/2001: 'Invalid arg 6: Cannot coerce a SDWORD to SDWORD*'
> TAPI3LibITTAPI(ExternalStructure)>>invalidCall
> TAPI3LibITTAPI>>RegisterCallNotifications:fMonitor:fOwner:lMediaTypes:lCallb
> ackInstance:plRegister:
> TAPI3LibITTAPI>>registerCallNotifications:fMonitor:fOwner:lMediaTypes:lCallb
> ackInstance:
> UndefinedObject>>{unbound}doIt
> CompiledExpression>>value:
> SmalltalkWorkspace>>evaluateRange:ifFail:debug:
> SmalltalkWorkspace>>evaluateItIfFail:debug:
> SmalltalkWorkspace>>evaluateItIfFail:
> SmalltalkWorkspace>>inspectIt
> Symbol>>forwardTo:
> [] in Command>>value
> BlockClosure>>ifCurtailed:
> BlockClosure>>ensure:
> Command>>value
> SmalltalkWorkspaceDocument(Shell)>>performCommand:
> CommandQuery>>perform
> DelegatingCommandPolicy(CommandPolicy)>>route:
> [] in ShellView(View)>>onCommand:
> BlockClosure>>ifCurtailed:
> BlockClosure>>ensure:
> Cursor>>showWhile:
> ShellView(View)>>onCommand:
> ShellView(View)>>wmCommand:wParam:lParam:
> ShellView(View)>>dispatchMessage:wParam:lParam:
> [] in InputState>>wndProc:message:wParam:lParam:cookie:
> BlockClosure>>ifCurtailed:
> ProcessorScheduler>>callback:evaluate:
> InputState>>wndProc:message:wParam:lParam:cookie:
> ShellView>>translateAccelerator:
> ShellView>>preTranslateKeyboardInput:
> ShellView(View)>>preTranslateMessage:
> InputState>>preTranslateMessage:
> InputState>>pumpMessage:
> InputState>>loopWhile:
> InputState>>mainLoop
> [] in InputState>>forkMain
> ExceptionHandler(ExceptionHandlerAbstract)>>markAndTry
> [] in ExceptionHandler(ExceptionHandlerAbstract)>>try:
> BlockClosure>>ifCurtailed:
> BlockClosure>>ensure:
> ExceptionHandler(ExceptionHandlerAbstract)>>try:
> BlockClosure>>on:do:
> [] in BlockClosure>>newProcess
>
>
>
>
>
>
>


Reply | Threaded
Open this post in threaded view
|

Re: problem in generated code: 'Invalid arg 6: Cannot coerce a SDWORD to SDWORD*

Oli Bye-3
I found the answer in other MSDN documentation.

The TAPI::registerCallNotifications method doesn't really want the
address of the callback, it's just an application specific (i.e. set
it yourself) code that will be returned to the handler that you've
registered with the connection point.

Thanks for the help.