Callbacks (sigh :-)

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

Callbacks (sigh :-)

Davide Varvello-2
Hi All,
  I need again some help from you. The context is always squeak/
bluetooth/objective-c, but now I'm trying to reduce the scope to  
better understand how things are working. So, as probably my problems  
are coming from asynchronous communication between squeak and  
objective-c, now I include below two snippets of code:


Squeak object with two methods

MyObj >> run
| bundle delegate |
bundle _ NSBundle bundleWithPath:'/Users/davide/TransferDelegate/
build/TransferDelegate.framework'.
bundle load.

delegate _ (bundle classNamed:'TransferDelegate') new.
delegate printSomethingTo:self.


MyObj >> description
Transcript show:'someone called me'.

----------------

Objective-c file named TransferDelegate.m



#import "TransferDelegate.h"


@implementation TransferDelegate


- (void) printSomethingTo: (NSObject *) aSqueakObject
{
        [aSqueakObject description];
}


@end
-------------------

Ok, now from squeak I evaluate:
MyObj new asObjcProxy async run.

and I expect "someone called me" on Transcript, but unfortunately  
nothing appears.
I know the method printSomethingTo is called because I added some  
code to it that prints a string on a file.
Can you help me to solve this enigma :-) ?
Thanks
  Davide

Reply | Threaded
Open this post in threaded view
|

Re: Callbacks (sigh :-)

Alain Fischer
Hi Davide,

First, you must test that the Squeak callback process is running.
You could test that by running the tests in ObjcBridgeTest.
You must have: "16 run, 16 passed, 0 failed, 0 errors".

But I don't think this is the cause of your problem.

Has I read your exemple, "[aSqueakObject description];" will not write  
anything in the Transcript
because "description" is a NSObject message and is sent at the  
Objective-C SqueakProxy and not
forwarded to Squeak.
Try to:
- rename MyObj>>description as MyObj>>myDescription
- in printSomethingTo: send: "[aSqueakObject myDescription];"

Hope this will help you.
Alain


Le 7 févr. 06, à 14:51, Davide Varvello a écrit :

> Hi All,
>  I need again some help from you. The context is always  
> squeak/bluetooth/objective-c, but now I'm trying to reduce the scope  
> to better understand how things are working. So, as probably my  
> problems are coming from asynchronous communication between squeak and  
> objective-c, now I include below two snippets of code:
>
>
> Squeak object with two methods
>
> MyObj >> run
> | bundle delegate |
> bundle _ NSBundle  
> bundleWithPath:'/Users/davide/TransferDelegate/build/
> TransferDelegate.framework'.
> bundle load.
>
> delegate _ (bundle classNamed:'TransferDelegate') new.
> delegate printSomethingTo:self.
>
>
> MyObj >> description
> Transcript show:'someone called me'.
>
> ----------------
>
> Objective-c file named TransferDelegate.m
>
>
>
> #import "TransferDelegate.h"
>
>
> @implementation TransferDelegate
>
>
> - (void) printSomethingTo: (NSObject *) aSqueakObject
> {
> [aSqueakObject description];
> }
>
>
> @end
> -------------------
>
> Ok, now from squeak I evaluate:
> MyObj new asObjcProxy async run.
>
> and I expect "someone called me" on Transcript, but unfortunately  
> nothing appears.
> I know the method printSomethingTo is called because I added some code  
> to it that prints a string on a file.
> Can you help me to solve this enigma :-) ?
> Thanks
>  Davide
>


Reply | Threaded
Open this post in threaded view
|

Re: Callbacks (sigh :-)

Davide Varvello-2
Hi Alain,
  I'm happy to hear you.

On 7 Feb 2006, at 21:21, Alain Fischer wrote:

> Hi Davide,
>
> First, you must test that the Squeak callback process is running.
> You could test that by running the tests in ObjcBridgeTest.
> You must have: "16 run, 16 passed, 0 failed, 0 errors".
>

All passed.

> But I don't think this is the cause of your problem.
>
> Has I read your exemple, "[aSqueakObject description];" will not  
> write anything in the Transcript
> because "description" is a NSObject message and is sent at the  
> Objective-C SqueakProxy and not
> forwarded to Squeak.
>

No, really!!!!! I'm unlucky


> Try to:
> - rename MyObj>>description as MyObj>>myDescription
> - in printSomethingTo: send: "[aSqueakObject myDescription];"
>

I'll try and feedback you.
Thanks a lot.
Davide

> Hope this will help you.
> Alain
>
>
> Le 7 févr. 06, à 14:51, Davide Varvello a écrit :
>
>> Hi All,
>>  I need again some help from you. The context is always squeak/
>> bluetooth/objective-c, but now I'm trying to reduce the scope to  
>> better understand how things are working. So, as probably my  
>> problems are coming from asynchronous communication between squeak  
>> and objective-c, now I include below two snippets of code:
>>
>>
>> Squeak object with two methods
>>
>> MyObj >> run
>> | bundle delegate |
>> bundle _ NSBundle bundleWithPath:'/Users/davide/TransferDelegate/
>> build/TransferDelegate.framework'.
>> bundle load.
>>
>> delegate _ (bundle classNamed:'TransferDelegate') new.
>> delegate printSomethingTo:self.
>>
>>
>> MyObj >> description
>> Transcript show:'someone called me'.
>>
>> ----------------
>>
>> Objective-c file named TransferDelegate.m
>>
>>
>>
>> #import "TransferDelegate.h"
>>
>>
>> @implementation TransferDelegate
>>
>>
>> - (void) printSomethingTo: (NSObject *) aSqueakObject
>> {
>> [aSqueakObject description];
>> }
>>
>>
>> @end
>> -------------------
>>
>> Ok, now from squeak I evaluate:
>> MyObj new asObjcProxy async run.
>>
>> and I expect "someone called me" on Transcript, but unfortunately  
>> nothing appears.
>> I know the method printSomethingTo is called because I added some  
>> code to it that prints a string on a file.
>> Can you help me to solve this enigma :-) ?
>> Thanks
>>  Davide
>>
>
>


Reply | Threaded
Open this post in threaded view
|

Re: Callbacks (sigh :-)

Davide Varvello-2
Hi Alain,

It Works!!!!

There was two problems. First, the name of methods as you point me  
out, second the instantiation of the objective-c object i.e. I changed:
delegate _ (bundle classNamed:'TransferDelegate') new.
in
delegate _ (bundle classNamed:'TransferDelegate') new asObjcProxy async.

and the call:
MyObj new asObjcProxy async run.
in
MyObj run.


Anyway, thank you Alain again.
I'm attaching the squeak code below, next days I'll post also a  
minimal objective-c class to use with the squeak code.



On 8 Feb 2006, at 09:28, Davide Varvello wrote:

> Hi Alain,
>  I'm happy to hear you.
>
> On 7 Feb 2006, at 21:21, Alain Fischer wrote:
>
>> Hi Davide,
>>
>> First, you must test that the Squeak callback process is running.
>> You could test that by running the tests in ObjcBridgeTest.
>> You must have: "16 run, 16 passed, 0 failed, 0 errors".
>>
>
> All passed.
>
>> But I don't think this is the cause of your problem.
>>
>> Has I read your exemple, "[aSqueakObject description];" will not  
>> write anything in the Transcript
>> because "description" is a NSObject message and is sent at the  
>> Objective-C SqueakProxy and not
>> forwarded to Squeak.
>>
>
> No, really!!!!! I'm unlucky
>
>
>> Try to:
>> - rename MyObj>>description as MyObj>>myDescription
>> - in printSomethingTo: send: "[aSqueakObject myDescription];"
>>
>
> I'll try and feedback you.
> Thanks a lot.
> Davide
>
>> Hope this will help you.
>> Alain
>>
>>
>> Le 7 févr. 06, à 14:51, Davide Varvello a écrit :
>>
>>> Hi All,
>>>  I need again some help from you. The context is always squeak/
>>> bluetooth/objective-c, but now I'm trying to reduce the scope to  
>>> better understand how things are working. So, as probably my  
>>> problems are coming from asynchronous communication between  
>>> squeak and objective-c, now I include below two snippets of code:
>>>
>>>
>>> Squeak object with two methods
>>>
>>> MyObj >> run
>>> | bundle delegate |
>>> bundle _ NSBundle bundleWithPath:'/Users/davide/TransferDelegate/
>>> build/TransferDelegate.framework'.
>>> bundle load.
>>>
>>> delegate _ (bundle classNamed:'TransferDelegate') new.
>>> delegate printSomethingTo:self.
>>>
>>>
>>> MyObj >> description
>>> Transcript show:'someone called me'.
>>>
>>> ----------------
>>>
>>> Objective-c file named TransferDelegate.m
>>>
>>>
>>>
>>> #import "TransferDelegate.h"
>>>
>>>
>>> @implementation TransferDelegate
>>>
>>>
>>> - (void) printSomethingTo: (NSObject *) aSqueakObject
>>> {
>>> [aSqueakObject description];
>>> }
>>>
>>>
>>> @end
>>> -------------------
>>>
>>> Ok, now from squeak I evaluate:
>>> MyObj new asObjcProxy async run.
>>>
>>> and I expect "someone called me" on Transcript, but unfortunately  
>>> nothing appears.
>>> I know the method printSomethingTo is called because I added some  
>>> code to it that prints a string on a file.
>>> Can you help me to solve this enigma :-) ?
>>> Thanks
>>>  Davide
>>>
>>
>>
>
>



MyCallbackableObj.st (1K) Download Attachment