Bizarre hapenning in my plugin

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

Bizarre hapenning in my plugin

Bob.Cowdery

I have some bizarre happenings in my plugin. It must be me, but I have no idea what’s going on.

 

Firstly, the plugin does actually work and is not trivial because it uses PortAudio which it streams through a little signal processing function. I can start it and stop it and it all behaves properly. The start() and stop() take no parameters. The problems start when I try and pass parameters to the other functions.

 

I tried a test function:

 

answerValue: value

 

            <primitive: 'answerValue' module:'SDRPhasingDSPPlugin'>

            Transcript show: 'Primitive answerValue failed'.

            ^ false

 

 

As far as I know you can just do this:

 

answerValue: value

 

            self export: true.

 

            (self cCode: 'return value')

 

This translated to:

 

EXPORT(int) answerValue(int value) {

            return value;

}

 

When I tried this it appeared to work. No failures and I got back what I entered. Then I realised I could put anything as a parameter :

 

x answerValue: ‘abc’ ‘abc’

 

Whatever parameter I gave it got echoed back regardless of whether it was an int or not. I could even say.

 

x answerValue: x a SDRPhasingDSP

 

To prove this I changed the code to

 

answerValue: value

 

            self export: true.

 

            (self cCode: 'return 100’)

 

and still got back what I entered.

 

Incidentally:

 

x getModuleName a SDRPhasingDSP

 

also answers the type of x and not the plugin name.

 

Please put me on the right track someone before I go completely mad.

 

Thanks

Bob

*** Confidentiality Notice *** Proprietary/Confidential
Information belonging to CGI Group Inc. and its affiliates
may be contained in this message. If you are not a recipient
indicated or intended in this message (or responsible for
delivery of this message to such person), or you think for
any reason that this message may have been addressed to you
in error, you may not use or copy or deliver this message
to anyone else.  In such case, you should destroy this
message and are asked to notify the sender by reply email.



Reply | Threaded
Open this post in threaded view
|

Re: Bizarre hapenning in my plugin

johnmci
It's the

self cCode: 'return value'

Really all you are returning is the value to the primitive calling  
interface, 5hat of course is ignored.
What you really want to do is stick an object onto the smalltalk  
stack so it can be returned as expected.
You can manual push/pop things to the stack, but I prefer to use the  
smart syntax.

So lets look at an example of the mac spelling plugin

primitiveGetIgnoredWordsListLengthWithTag: aTag
        "Get ignored word list"
        | length |

        self primitive: 'primitiveGetIgnoredWordsListLengthWithTag'  
parameters:#(SmallInteger).
        length := self sqSpellingGetIgnoredWordsListLengthWithTag: aTag.
        ^length asSmallIntegerObj

First I use the smart syntax to setup the primitive name and the  
parameters.
self primitive:parameters:

Then we return the smalltalk object we expect to
        ^length asSmallIntegerObj

So for that I do length asSmallIntegerObj
or I could say
^length asOop: SmallInteger
or
^frames asPositiveIntegerObj
^rate asFloatObj

or much more complex things like
        interpreterProxy pushRemappableOop: (right asOop: Float).
        interpreterProxy pushRemappableOop: (left asOop: Float).
        interpreterProxy pushRemappableOop: (interpreterProxy  
instantiateClass: (interpreterProxy classArray) indexableSize: 2).
        results := interpreterProxy popRemappableOop.
        interpreterProxy storePointer: 0 ofObject: results withValue:  
interpreterProxy popRemappableOop.
        interpreterProxy storePointer: 1 ofObject: results withValue:  
interpreterProxy popRemappableOop.
        ^ results

the length asSmallIntegerObj  turns into this C code, which converts  
the C object into a Smalltalk object, checks the conversion, then does
the pop  & push to setup the return value on the smalltalk stack, and  
returns null to the C caller...

        _return_value = interpreterProxy->integerObjectOf(length);
        if (interpreterProxy->failed()) {
                return null;
        }
        interpreterProxy->popthenPush(2, _return_value);
        return null;




On 21-Jan-06, at 1:57 PM, Cowdery, Bob [UK] wrote:

> I have some bizarre happenings in my plugin. It must be me, but I  
> have no idea what’s going on.
>
>
> Firstly, the plugin does actually work and is not trivial because  
> it uses PortAudio which it streams through a little signal  
> processing function. I can start it and stop it and it all behaves  
> properly. The start() and stop() take no parameters. The problems  
> start when I try and pass parameters to the other functions.
>
>
> I tried a test function:
>
>
> answerValue: value
>
>
>             <primitive: 'answerValue' module:'SDRPhasingDSPPlugin'>
>
>             Transcript show: 'Primitive answerValue failed'.
>
>             ^ false
>
>
>
> As far as I know you can just do this:
>
>
> answerValue: value
>
>
>             self export: true.
>
>
>             (self cCode: 'return value')
>
>
> This translated to:
>
>
> EXPORT(int) answerValue(int value) {
>
>             return value;
>
> }
>
>
> When I tried this it appeared to work. No failures and I got back  
> what I entered. Then I realised I could put anything as a parameter :
>
>
> x answerValue: ‘abc’ ‘abc’
>
>
> Whatever parameter I gave it got echoed back regardless of whether  
> it was an int or not. I could even say.
>
>
> x answerValue: x a SDRPhasingDSP
>
>
> To prove this I changed the code to
>
>
> answerValue: value
>
>
>             self export: true.
>
>
>             (self cCode: 'return 100’)
>
>
> and still got back what I entered.
>
>
> Incidentally:
>
>
> x getModuleName a SDRPhasingDSP
>
>
> also answers the type of x and not the plugin name.
>
>
> Please put me on the right track someone before I go completely mad.
>
>
> Thanks
>
> Bob
>
> *** Confidentiality Notice *** Proprietary/Confidential
> Information belonging to CGI Group Inc. and its affiliates
> may be contained in this message. If you are not a recipient
> indicated or intended in this message (or responsible for
> delivery of this message to such person), or you think for
> any reason that this message may have been addressed to you
> in error, you may not use or copy or deliver this message
> to anyone else.  In such case, you should destroy this
> message and are asked to notify the sender by reply email.
>
>

--
========================================================================
===
John M. McIntosh <[hidden email]> 1-800-477-2659
Corporate Smalltalk Consulting Ltd.  http://www.smalltalkconsulting.com
========================================================================
===


Reply | Threaded
Open this post in threaded view
|

Re: Bizarre hapenning in my plugin

Andreas.Raab
In reply to this post by Bob.Cowdery
Bob -

I *strongly* recommend you get a copy of the NuBlue book[*] and read the
chapter about "Extending the Virtual Machine", since, from your message,
it is obvious that you are missing fundamental parts of the larger
picture (which are covered by the book).

[*] http://www.amazon.com/exec/obidos/ASIN/0130280917/

Cheers,
   - Andreas

Cowdery, Bob [UK] wrote:

> I have some bizarre happenings in my plugin. It must be me, but I have
> no idea what’s going on.
>
>  
>
> Firstly, the plugin does actually work and is not trivial because it
> uses PortAudio which it streams through a little signal processing
> function. I can start it and stop it and it all behaves properly. The
> start() and stop() take no parameters. The problems start when I try and
> pass parameters to the other functions.
>
>  
>
> I tried a test function:
>
>  
>
> answerValue: value
>
>  
>
>             <primitive: 'answerValue' module:'SDRPhasingDSPPlugin'>
>
>             Transcript show: 'Primitive answerValue failed'.
>
>             ^ false
>
>  
>
>  
>
> As far as I know you can just do this:
>
>  
>
> answerValue: value
>
>  
>
>             self export: true.
>
>  
>
>             (self cCode: 'return value')
>
>  
>
> This translated to:
>
>  
>
> EXPORT(int) answerValue(int value) {
>
>             return value;
>
> }
>
>  
>
> When I tried this it appeared to work. No failures and I got back what I
> entered. Then I realised I could put anything as a parameter :
>
>  
>
> x answerValue: ‘abc’ ‘abc’
>
>  
>
> Whatever parameter I gave it got echoed back regardless of whether it
> was an int or not. I could even say.
>
>  
>
> x answerValue: x a SDRPhasingDSP
>
>  
>
> To prove this I changed the code to
>
>  
>
> answerValue: value
>
>  
>
>             self export: true.
>
>  
>
>             (self cCode: 'return 100’)
>
>  
>
> and still got back what I entered.
>
>  
>
> Incidentally:
>
>  
>
> x getModuleName a SDRPhasingDSP
>
>  
>
> also answers the type of x and not the plugin name.
>
>  
>
> Please put me on the right track someone before I go completely mad.
>
>  
>
> Thanks
>
> Bob
>
> **** Confidentiality Notice **** Proprietary/Confidential
> Information belonging to CGI Group Inc. and its affiliates
> may be contained in this message. If you are not a recipient
> indicated or intended in this message (or responsible for
> delivery of this message to such person), or you think for
> any reason that this message may have been addressed to you
> in error, you may not use or copy or deliver this message
> to anyone else.  In such case, you should destroy this
> message and are asked to notify the sender by reply email.
>
>
> ------------------------------------------------------------------------
>
>


Reply | Threaded
Open this post in threaded view
|

Minnow swiki catatonic? (was Re: Bizarre hapenning in my plugin)

timrowledge
I was attempting to point Bob  to some useful swiki pages when I  
discoverd that minnow is not really interested in talking to me. Can  
anyone give it a hint with a large axe, maybe?

tim
--
tim Rowledge; [hidden email]; http://www.rowledge.org/tim
Multitasking:  Screwing up several things at once...



Reply | Threaded
Open this post in threaded view
|

RE: Bizarre hapenning in my plugin

Bob.Cowdery
In reply to this post by Bob.Cowdery


Andreas wrote:

> I *strongly* recommend you get a copy of the NuBlue book[*] and read
the
> chapter about "Extending the Virtual Machine", since, from your
message,
> it is obvious that you are missing fundamental parts of the larger
> picture (which are covered by the book).

> [*] http://www.amazon.com/exec/obidos/ASIN/0130280917/

I've only been squeaking for 2 months or so and I did buy a book 'Object
Oriented Design with Multimedia Applications' but I guess it was the
wrong one for what I needed. I will try your suggestion. I think I have
been overwhelmed with detail from the stuff I have read but really so
far failed to find the 'big picture' with real world examples. This is
the last hurdle though in what has been an interesting if somewhat brain
taxing journey. The irony is of course looking back on what I have it's
all so simple and logical but never seems that way when the compiler
throws up yet another error or the call fails to do what you expect.

Bob
*** Confidentiality Notice *** Proprietary/Confidential
Information belonging to CGI Group Inc. and its affiliates
may be contained in this message. If you are not a recipient
indicated or intended in this message (or responsible for
delivery of this message to such person), or you think for
any reason that this message may have been addressed to you
in error, you may not use or copy or deliver this message
to anyone else.  In such case, you should destroy this
message and are asked to notify the sender by reply email.

Reply | Threaded
Open this post in threaded view
|

Re: Bizarre hapenning in my plugin

stéphane ducasse-2
In reply to this post by Andreas.Raab
http://www.iam.unibe.ch/~ducasse/FreeBooks/CollectiveNBlueBook/

too for drafts of the book chapters.

Stef


On 22 janv. 06, at 03:22, Andreas Raab wrote:

> Bob -
>
> I *strongly* recommend you get a copy of the NuBlue book[*] and  
> read the chapter about "Extending the Virtual Machine", since, from  
> your message, it is obvious that you are missing fundamental parts  
> of the larger picture (which are covered by the book).
>
> [*] http://www.amazon.com/exec/obidos/ASIN/0130280917/
>
> Cheers,
>   - Andreas
>
> Cowdery, Bob [UK] wrote:
>> I have some bizarre happenings in my plugin. It must be me, but I  
>> have no idea what’s going on.
>>  Firstly, the plugin does actually work and is not trivial because  
>> it uses PortAudio which it streams through a little signal  
>> processing function. I can start it and stop it and it all behaves  
>> properly. The start() and stop() take no parameters. The problems  
>> start when I try and pass parameters to the other functions.
>>  I tried a test function:
>>  answerValue: value
>>              <primitive: 'answerValue' module:'SDRPhasingDSPPlugin'>
>>             Transcript show: 'Primitive answerValue failed'.
>>             ^ false
>>   As far as I know you can just do this:
>>  answerValue: value
>>              self export: true.
>>              (self cCode: 'return value')
>>  This translated to:
>>  EXPORT(int) answerValue(int value) {
>>             return value;
>> }
>>  When I tried this it appeared to work. No failures and I got back  
>> what I entered. Then I realised I could put anything as a parameter :
>>  x answerValue: ‘abc’ ‘abc’
>>  Whatever parameter I gave it got echoed back regardless of  
>> whether it was an int or not. I could even say.
>>  x answerValue: x a SDRPhasingDSP
>>  To prove this I changed the code to
>>  answerValue: value
>>              self export: true.
>>              (self cCode: 'return 100’)
>>  and still got back what I entered.
>>  Incidentally:
>>  x getModuleName a SDRPhasingDSP
>>  also answers the type of x and not the plugin name.
>>  Please put me on the right track someone before I go completely mad.
>>  Thanks
>> Bob
>> **** Confidentiality Notice **** Proprietary/Confidential
>> Information belonging to CGI Group Inc. and its affiliates
>> may be contained in this message. If you are not a recipient
>> indicated or intended in this message (or responsible for
>> delivery of this message to such person), or you think for
>> any reason that this message may have been addressed to you
>> in error, you may not use or copy or deliver this message
>> to anyone else.  In such case, you should destroy this
>> message and are asked to notify the sender by reply email.
>> ---------------------------------------------------------------------
>> ---
>
>