Csound Csound-dev Csound-tekno Search About

[Cs-dev] Polymorphic Opcodes

Date2015-09-13 14:30
FromEd Costello
Subject[Cs-dev] Polymorphic Opcodes
AttachmentsNone  None  
Hi,

I would like to make my websocket opcode polymorphic.
Currently, it takes the following arguments
xout1, xout2,..., xoutN websocket iport, xin1, xin2, ..., xinN

Is it possible to make this opcode polymorphic so it only takes either inputs or outputs? Or, do I have to make new opcodes for that purpose.
Thanks
Ed
--
Edward Costello

Date2015-09-13 14:35
FromSteven Yi
SubjectRe: [Cs-dev] Polymorphic Opcodes
Hi Ed,

Are you saying, only inputs, or only outputs?  Off the top of my head,
you can just add new OENTRYs, but I'm not quite recalling at the
moment the impact of memory layout and how the output part gets
factored in. You might have to do some offset magic there to read
inputs and outputs.

Could you type out all of the the expected signatures here to clarify?

steven

On Sun, Sep 13, 2015 at 9:30 AM, Ed Costello  wrote:
> Hi,
>
> I would like to make my websocket opcode polymorphic.
> Currently, it takes the following arguments
> xout1, xout2,..., xoutN websocket iport, xin1, xin2, ..., xinN
>
> Is it possible to make this opcode polymorphic so it only takes either
> inputs or outputs? Or, do I have to make new opcodes for that purpose.
> Thanks
> Ed
> --
> Edward Costello
>
> ------------------------------------------------------------------------------
>
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel
>

------------------------------------------------------------------------------
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2015-09-13 14:45
Fromjpff
SubjectRe: [Cs-dev] Polymorphic Opcodes
opcodes can have the same name as long as the signature 9arg /result 
tyoes) differ.  There are many examples in the sources.  It often means 
new code but looks simple to the user.

For example look at arrays.c

On Sun, 13 Sep 2015, Ed Costello wrote:

> Hi,
> I would like to make my websocket opcode polymorphic.
> Currently, it takes the following arguments
> xout1, xout2,..., xoutN websocket iport, xin1, xin2, ..., xinN
> 
> Is it possible to make this opcode polymorphic so it only takes either inputs
> or outputs? Or, do I have to make new opcodes for that purpose.
> Thanks
> Ed
> --
> Edward Costello
> 
>

------------------------------------------------------------------------------
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2015-09-13 19:11
FromEd Costello
SubjectRe: [Cs-dev] Polymorphic Opcodes
AttachmentsNone  None  
What I would like is:

out1, out2, ..., outN websocket iport, in1, in2, ..., inN
websocket iport, in1, in2, ..., inN
out1, out2, ..., outN websocket iport

Are there any examples of polymorphic opcodes that take N or zero outputs?
Ed


On Sun, 13 Sep 2015 at 15:46 jpff <jpff@codemist.co.uk> wrote:
opcodes can have the same name as long as the signature 9arg /result
tyoes) differ.  There are many examples in the sources.  It often means
new code but looks simple to the user.

For example look at arrays.c

On Sun, 13 Sep 2015, Ed Costello wrote:

> Hi,
> I would like to make my websocket opcode polymorphic.
> Currently, it takes the following arguments
> xout1, xout2,..., xoutN websocket iport, xin1, xin2, ..., xinN
>
> Is it possible to make this opcode polymorphic so it only takes either inputs
> or outputs? Or, do I have to make new opcodes for that purpose.
> Thanks
> Ed
> --
> Edward Costello
>
>

------------------------------------------------------------------------------
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/csound-devel
--
Edward Costello

Date2015-09-13 19:25
Fromjpff
SubjectRe: [Cs-dev] Polymorphic Opcodes
As I understand it those signatures should cause no problems



------------------------------------------------------------------------------
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2015-09-13 19:33
Fromjpff
SubjectRe: [Cs-dev] Polymorphic Opcodes
AttachmentsNone  None  
I do not understand the problem.  You have
* websocket *
whixch atches the first and tgird anyway.  So just add
  websocket *
and adjust your code, and add a wrapper

     {
         .opname = "websocket.m",
         .dsblksiz = sizeof(WebSocketOpcode),
         .thread = 3,
         .outypes = "*",
         .intypes = "*",
         .iopadr = (SUBR)WebSocketOpcode_initialise,
         .kopadr = (SUBR)WebSocketOpcode_process,
         .aopadr = NULL
     },
     {
         .opname = "websocket.i",
         .dsblksiz = sizeof(WebSocketOpcode),
         .thread = 3,
         .outypes = "",
         .intypes = "*",
         .iopadr = (SUBR)WebSocketOpcode_initialise0,
         .kopadr = (SUBR)WebSocketOpcode_process0,
         .aopadr = NULL
     }


On Sun, 13 Sep 2015, Ed Costello wrote:

> What I would like is:
> 
> out1, out2, ..., outN websocket iport, in1, in2, ..., inN
> websocket iport, in1, in2, ..., inN
> out1, out2, ..., outN websocket iport
> 
> Are there any examples of polymorphic opcodes that take N or zero outputs?
> Ed
> 
> 
> On Sun, 13 Sep 2015 at 15:46 jpff  wrote:
>       opcodes can have the same name as long as the signature 9arg
>       /result
>       tyoes) differ.  There are many examples in the sources.  It often
>       means
>       new code but looks simple to the user.
>
>       For example look at arrays.c
>
>       On Sun, 13 Sep 2015, Ed Costello wrote:
>
>       > Hi,
>       > I would like to make my websocket opcode polymorphic.
>       > Currently, it takes the following arguments
>       > xout1, xout2,..., xoutN websocket iport, xin1, xin2, ..., xinN
>       >
>       > Is it possible to make this opcode polymorphic so it only takes
>       either inputs
>       > or outputs? Or, do I have to make new opcodes for that purpose.
>       > Thanks
>       > Ed
>       > --
>       > Edward Costello
>       >
>       >
> 
> -----------------------------------------------------------------------------
>       -
>       _______________________________________________
>       Csound-devel mailing list
>       Csound-devel@lists.sourceforge.net
>       https://lists.sourceforge.net/lists/listinfo/csound-devel
> 
> --
> Edward Costello
> 
>

Date2015-09-13 19:46
FromEd Costello
SubjectRe: [Cs-dev] Polymorphic Opcodes
AttachmentsNone  None  
Ok, I'll give that a go,
Thanks
Ed

On Sun, 13 Sep 2015 at 20:33 jpff <jpff@codemist.co.uk> wrote:
I do not understand the problem.  You have
* websocket *
whixch atches the first and tgird anyway.  So just add
  websocket *
and adjust your code, and add a wrapper

     {
         .opname = "websocket.m",
         .dsblksiz = sizeof(WebSocketOpcode),
         .thread = 3,
         .outypes = "*",
         .intypes = "*",
         .iopadr = (SUBR)WebSocketOpcode_initialise,
         .kopadr = (SUBR)WebSocketOpcode_process,
         .aopadr = NULL
     },
     {
         .opname = "websocket.i",
         .dsblksiz = sizeof(WebSocketOpcode),
         .thread = 3,
         .outypes = "",
         .intypes = "*",
         .iopadr = (SUBR)WebSocketOpcode_initialise0,
         .kopadr = (SUBR)WebSocketOpcode_process0,
         .aopadr = NULL
     }


On Sun, 13 Sep 2015, Ed Costello wrote:

> What I would like is:
>
> out1, out2, ..., outN websocket iport, in1, in2, ..., inN
> websocket iport, in1, in2, ..., inN
> out1, out2, ..., outN websocket iport
>
> Are there any examples of polymorphic opcodes that take N or zero outputs?
> Ed
>
>
> On Sun, 13 Sep 2015 at 15:46 jpff <jpff@codemist.co.uk> wrote:
>       opcodes can have the same name as long as the signature 9arg
>       /result
>       tyoes) differ.  There are many examples in the sources.  It often
>       means
>       new code but looks simple to the user.
>
>       For example look at arrays.c
>
>       On Sun, 13 Sep 2015, Ed Costello wrote:
>
>       > Hi,
>       > I would like to make my websocket opcode polymorphic.
>       > Currently, it takes the following arguments
>       > xout1, xout2,..., xoutN websocket iport, xin1, xin2, ..., xinN
>       >
>       > Is it possible to make this opcode polymorphic so it only takes
>       either inputs
>       > or outputs? Or, do I have to make new opcodes for that purpose.
>       > Thanks
>       > Ed
>       > --
>       > Edward Costello
>       >
>       >
>
> -----------------------------------------------------------------------------
>       -
>       _______________________________________________
>       Csound-devel mailing list
>       Csound-devel@lists.sourceforge.net
>       https://lists.sourceforge.net/lists/listinfo/csound-devel
>
> --
> Edward Costello
>
>------------------------------------------------------------------------------
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/csound-devel
--
Edward Costello

Date2015-09-13 19:48
FromVictor Lazzarini
SubjectRe: [Cs-dev] Polymorphic Opcodes
AttachmentsNone  None  
Why don't you use an array as output. It makes more sense to me.

Victor Lazzarini
Dean of Arts, Celtic Studies, and Philosophy
Maynooth University
Ireland

On 13 Sep 2015, at 19:46, Ed Costello <phasereset@gmail.com> wrote:

Ok, I'll give that a go,
Thanks
Ed

On Sun, 13 Sep 2015 at 20:33 jpff <jpff@codemist.co.uk> wrote:
I do not understand the problem.  You have
* websocket *
whixch atches the first and tgird anyway.  So just add
  websocket *
and adjust your code, and add a wrapper

     {
         .opname = "websocket.m",
         .dsblksiz = sizeof(WebSocketOpcode),
         .thread = 3,
         .outypes = "*",
         .intypes = "*",
         .iopadr = (SUBR)WebSocketOpcode_initialise,
         .kopadr = (SUBR)WebSocketOpcode_process,
         .aopadr = NULL
     },
     {
         .opname = "websocket.i",
         .dsblksiz = sizeof(WebSocketOpcode),
         .thread = 3,
         .outypes = "",
         .intypes = "*",
         .iopadr = (SUBR)WebSocketOpcode_initialise0,
         .kopadr = (SUBR)WebSocketOpcode_process0,
         .aopadr = NULL
     }


On Sun, 13 Sep 2015, Ed Costello wrote:

> What I would like is:
>
> out1, out2, ..., outN websocket iport, in1, in2, ..., inN
> websocket iport, in1, in2, ..., inN
> out1, out2, ..., outN websocket iport
>
> Are there any examples of polymorphic opcodes that take N or zero outputs?
> Ed
>
>
> On Sun, 13 Sep 2015 at 15:46 jpff <jpff@codemist.co.uk> wrote:
>       opcodes can have the same name as long as the signature 9arg
>       /result
>       tyoes) differ.  There are many examples in the sources.  It often
>       means
>       new code but looks simple to the user.
>
>       For example look at arrays.c
>
>       On Sun, 13 Sep 2015, Ed Costello wrote:
>
>       > Hi,
>       > I would like to make my websocket opcode polymorphic.
>       > Currently, it takes the following arguments
>       > xout1, xout2,..., xoutN websocket iport, xin1, xin2, ..., xinN
>       >
>       > Is it possible to make this opcode polymorphic so it only takes
>       either inputs
>       > or outputs? Or, do I have to make new opcodes for that purpose.
>       > Thanks
>       > Ed
>       > --
>       > Edward Costello
>       >
>       >
>
> -----------------------------------------------------------------------------
>       -
>       _______________________________________________
>       Csound-devel mailing list
>       Csound-devel@lists.sourceforge.net
>       https://lists.sourceforge.net/lists/listinfo/csound-devel
>
> --
> Edward Costello
>
>------------------------------------------------------------------------------
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/csound-devel
--
Edward Costello
------------------------------------------------------------------------------
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/csound-devel

Date2015-09-13 20:00
FromEd Costello
SubjectRe: [Cs-dev] Polymorphic Opcodes
AttachmentsNone  None  
I can't use a single array because the opcode outputs any combination of k-rate & a-rate vars and k-rate & a-rate arrays.


On Sun, 13 Sep 2015 at 20:48 Victor Lazzarini <Victor.Lazzarini@nuim.ie> wrote:
Why don't you use an array as output. It makes more sense to me.


Victor Lazzarini
Dean of Arts, Celtic Studies, and Philosophy
Maynooth University
Ireland

On 13 Sep 2015, at 19:46, Ed Costello <phasereset@gmail.com> wrote:

Ok, I'll give that a go,
Thanks
Ed

On Sun, 13 Sep 2015 at 20:33 jpff <jpff@codemist.co.uk> wrote:
I do not understand the problem.  You have
* websocket *
whixch atches the first and tgird anyway.  So just add
  websocket *
and adjust your code, and add a wrapper

     {
         .opname = "websocket.m",
         .dsblksiz = sizeof(WebSocketOpcode),
         .thread = 3,
         .outypes = "*",
         .intypes = "*",
         .iopadr = (SUBR)WebSocketOpcode_initialise,
         .kopadr = (SUBR)WebSocketOpcode_process,
         .aopadr = NULL
     },
     {
         .opname = "websocket.i",
         .dsblksiz = sizeof(WebSocketOpcode),
         .thread = 3,
         .outypes = "",
         .intypes = "*",
         .iopadr = (SUBR)WebSocketOpcode_initialise0,
         .kopadr = (SUBR)WebSocketOpcode_process0,
         .aopadr = NULL
     }


On Sun, 13 Sep 2015, Ed Costello wrote:

> What I would like is:
>
> out1, out2, ..., outN websocket iport, in1, in2, ..., inN
> websocket iport, in1, in2, ..., inN
> out1, out2, ..., outN websocket iport
>
> Are there any examples of polymorphic opcodes that take N or zero outputs?
> Ed
>
>
> On Sun, 13 Sep 2015 at 15:46 jpff <jpff@codemist.co.uk> wrote:
>       opcodes can have the same name as long as the signature 9arg
>       /result
>       tyoes) differ.  There are many examples in the sources.  It often
>       means
>       new code but looks simple to the user.
>
>       For example look at arrays.c
>
>       On Sun, 13 Sep 2015, Ed Costello wrote:
>
>       > Hi,
>       > I would like to make my websocket opcode polymorphic.
>       > Currently, it takes the following arguments
>       > xout1, xout2,..., xoutN websocket iport, xin1, xin2, ..., xinN
>       >
>       > Is it possible to make this opcode polymorphic so it only takes
>       either inputs
>       > or outputs? Or, do I have to make new opcodes for that purpose.
>       > Thanks
>       > Ed
>       > --
>       > Edward Costello
>       >
>       >
>
> -----------------------------------------------------------------------------
>       -
>       _______________________________________________
>       Csound-devel mailing list
>       Csound-devel@lists.sourceforge.net
>       https://lists.sourceforge.net/lists/listinfo/csound-devel
>
> --
> Edward Costello
>
>------------------------------------------------------------------------------
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/csound-devel
--
Edward Costello
------------------------------------------------------------------------------
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/csound-devel
------------------------------------------------------------------------------
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/csound-devel
--
Edward Costello

Date2015-09-13 20:02
FromSteven Yi
SubjectRe: [Cs-dev] Polymorphic Opcodes
The one thing that might be confusing is the 0 out-arg option. It'd be
better if you let the version of the opcode that uses 0 to many out
args catch that condition. I think if you try to use the same data
struct for both OENTRYs, you might get a problem with Csound with the
way it calculates memory and assigns addresses. If I remember
correctly, once it hits a var-arg, it will know to add some constant
number to advance the pointer for laying out memory.  If you don't
have that but use the same struct, the in-args will start getting
assigned to the place where out-args are. At least, I'm going off the
top of my head, but I'd just check that.

On Sun, Sep 13, 2015 at 2:46 PM, Ed Costello  wrote:
> Ok, I'll give that a go,
> Thanks
> Ed
>
> On Sun, 13 Sep 2015 at 20:33 jpff  wrote:
>>
>> I do not understand the problem.  You have
>> * websocket *
>> whixch atches the first and tgird anyway.  So just add
>>   websocket *
>> and adjust your code, and add a wrapper
>>
>>      {
>>          .opname = "websocket.m",
>>          .dsblksiz = sizeof(WebSocketOpcode),
>>          .thread = 3,
>>          .outypes = "*",
>>          .intypes = "*",
>>          .iopadr = (SUBR)WebSocketOpcode_initialise,
>>          .kopadr = (SUBR)WebSocketOpcode_process,
>>          .aopadr = NULL
>>      },
>>      {
>>          .opname = "websocket.i",
>>          .dsblksiz = sizeof(WebSocketOpcode),
>>          .thread = 3,
>>          .outypes = "",
>>          .intypes = "*",
>>          .iopadr = (SUBR)WebSocketOpcode_initialise0,
>>          .kopadr = (SUBR)WebSocketOpcode_process0,
>>          .aopadr = NULL
>>      }
>>
>>
>> On Sun, 13 Sep 2015, Ed Costello wrote:
>>
>> > What I would like is:
>> >
>> > out1, out2, ..., outN websocket iport, in1, in2, ..., inN
>> > websocket iport, in1, in2, ..., inN
>> > out1, out2, ..., outN websocket iport
>> >
>> > Are there any examples of polymorphic opcodes that take N or zero
>> > outputs?
>> > Ed
>> >
>> >
>> > On Sun, 13 Sep 2015 at 15:46 jpff  wrote:
>> >       opcodes can have the same name as long as the signature 9arg
>> >       /result
>> >       tyoes) differ.  There are many examples in the sources.  It often
>> >       means
>> >       new code but looks simple to the user.
>> >
>> >       For example look at arrays.c
>> >
>> >       On Sun, 13 Sep 2015, Ed Costello wrote:
>> >
>> >       > Hi,
>> >       > I would like to make my websocket opcode polymorphic.
>> >       > Currently, it takes the following arguments
>> >       > xout1, xout2,..., xoutN websocket iport, xin1, xin2, ..., xinN
>> >       >
>> >       > Is it possible to make this opcode polymorphic so it only takes
>> >       either inputs
>> >       > or outputs? Or, do I have to make new opcodes for that purpose.
>> >       > Thanks
>> >       > Ed
>> >       > --
>> >       > Edward Costello
>> >       >
>> >       >
>> >
>> >
>> > -----------------------------------------------------------------------------
>> >       -
>> >       _______________________________________________
>> >       Csound-devel mailing list
>> >       Csound-devel@lists.sourceforge.net
>> >       https://lists.sourceforge.net/lists/listinfo/csound-devel
>> >
>> > --
>> > Edward Costello
>> >
>>
>> > >------------------------------------------------------------------------------
>> _______________________________________________
>> Csound-devel mailing list
>> Csound-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>
> --
> Edward Costello
>
> ------------------------------------------------------------------------------
>
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel
>

------------------------------------------------------------------------------
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2015-09-13 20:24
Fromjpff
SubjectRe: [Cs-dev] Polymorphic Opcodes
Yes sorry -- it does need a new structure or te glue code copies the data 
about.....

There are similar cases in vbap.c oor vbap1.c I think


------------------------------------------------------------------------------
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2015-09-14 21:47
FromEd Costello
SubjectRe: [Cs-dev] Polymorphic Opcodes
AttachmentsNone  None  
Hi

I've been playing around with various OENTRY combinations trying to get the argument combination I require to work but I can't figure it out,
In the below example from what I gather in the manual, the 0xfffe option specifies that an opcode will be picked based on the types of it's first 2 inputs, so in the first definition of the opcode I have said to accept any number of outputs but just an i and k variable input. In the second one from what I gather it should accept 0 outputs and an i and a rate input. 

static OENTRY localops[] = {
    
    {
        .opname = "websocket",
        .dsblksiz = sizeof(0xfffe),
    },
    {
        .opname = "websocket.ik",
        .dsblksiz = sizeof(WebSocketOpcode),
        .thread = 3,
        .outypes = "*",
        .intypes = "ik",
        .iopadr = (SUBR)WebSocketOpcode_initialise,
        .kopadr = (SUBR)WebSocketOpcode_process,
        .aopadr = NULL
    },
    {
        .opname = "websocket.ia",
        .dsblksiz = sizeof(WebSocketOpcode),
        .thread = 3,
        .outypes = "",
        .intypes = "ia",
        .iopadr = (SUBR)WebSocketOpcode_initialise,
        .kopadr = (SUBR)WebSocketOpcode_process,
        .aopadr = NULL
    }
};

This doesn't work however, when I try adding an output to the opcode I get errors like this:

WARNING: [mType confusion for websocket (277,275), replacing
[m
[mWARNING: [mType confusion for websocket (275,277), replacing
[m
[mWARNING: [mType confusion for websocket (277,275), replacing
[m
[mWARNING: [mType confusion for websocket (275,277), replacing
[m

That argument combination isn't exactly what I want of course, but I can't even get the opcode to work polymorphically based on having 0 or any output variables and was wondering how that bit is done.
Ed

On Sun, 13 Sep 2015 at 21:24 jpff <jpff@codemist.co.uk> wrote:
Yes sorry -- it does need a new structure or te glue code copies the data
about.....

There are similar cases in vbap.c oor vbap1.c I think


------------------------------------------------------------------------------
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/csound-devel
--
Edward Costello

Date2015-09-14 22:52
FromSteven Yi
SubjectRe: [Cs-dev] Polymorphic Opcodes
You shouldn't use the old polymorphism system anymore (the whole
0xfffe etc. business).  With CS6, just define the real OENTRYs to be
used.  Anything from the "." and onwards will be ignored; that was
done for backwards compatibility and to allow devs to use that as a
sort of markup for themselves (documentation).

I did some looking into this.  Two things:

First, I've modified the CMake file to check for the
websocket_cancel_service function. That should guarantee that an
updated version of libwebsockets is installed.

Second, having the zero-arg version won't work, at least with Csound
6. This one is tricky. With Csound 6, the parser depends upon semantic
information early in the parsing process.  The information it uses is
the names of opcodes and whether they have 0 output args or not.  This
gets recorded in a table as either T_OPCODE or T_OPCODE0.  The parser
depends on this information to parser whether an opcode can be used.

The trick with this is that an opcode can't be both T_OPCODE and
T_OPCODE0 in Csound 6.  When you start to parse, it'll try to parse as
one or the other.

Parser3 in Csound 7 should fix this situation as it doesn't do
disambiguation of opcode-call lines until the semantic analysis phase.
It's a little more flexible this way and *should* be able to handle
opcodes with different output-arg arities.

As far as I understand, for polymorphic opcodes, we have opcodes with
different argument types, but not different argument counts, with the
exception of var-args.  Either that, or we have them with at least one
required output argument. It'd require some more investigation, but
logically that must be the case or we'd have found a problem earlier.

In this case, the simplest thing would be to give multiple opcode
names.  I think this would be the only way to do this in Csound6 due
to the parser.


On Mon, Sep 14, 2015 at 4:47 PM, Ed Costello  wrote:
> Hi
>
> I've been playing around with various OENTRY combinations trying to get the
> argument combination I require to work but I can't figure it out,
> In the below example from what I gather in the manual, the 0xfffe option
> specifies that an opcode will be picked based on the types of it's first 2
> inputs, so in the first definition of the opcode I have said to accept any
> number of outputs but just an i and k variable input. In the second one from
> what I gather it should accept 0 outputs and an i and a rate input.
>
> static OENTRY localops[] = {
>
>     {
>         .opname = "websocket",
>         .dsblksiz = sizeof(0xfffe),
>     },
>     {
>         .opname = "websocket.ik",
>         .dsblksiz = sizeof(WebSocketOpcode),
>         .thread = 3,
>         .outypes = "*",
>         .intypes = "ik",
>         .iopadr = (SUBR)WebSocketOpcode_initialise,
>         .kopadr = (SUBR)WebSocketOpcode_process,
>         .aopadr = NULL
>     },
>     {
>         .opname = "websocket.ia",
>         .dsblksiz = sizeof(WebSocketOpcode),
>         .thread = 3,
>         .outypes = "",
>         .intypes = "ia",
>         .iopadr = (SUBR)WebSocketOpcode_initialise,
>         .kopadr = (SUBR)WebSocketOpcode_process,
>         .aopadr = NULL
>     }
> };
>
> This doesn't work however, when I try adding an output to the opcode I get
> errors like this:
>
> WARNING: [mType confusion for websocket (277,275), replacing
> [m
> [mWARNING: [mType confusion for websocket (275,277), replacing
> [m
> [mWARNING: [mType confusion for websocket (277,275), replacing
> [m
> [mWARNING: [mType confusion for websocket (275,277), replacing
> [m
>
> That argument combination isn't exactly what I want of course, but I can't
> even get the opcode to work polymorphically based on having 0 or any output
> variables and was wondering how that bit is done.
> Ed
>
> On Sun, 13 Sep 2015 at 21:24 jpff  wrote:
>>
>> Yes sorry -- it does need a new structure or te glue code copies the data
>> about.....
>>
>> There are similar cases in vbap.c oor vbap1.c I think
>>
>>
>>
>> ------------------------------------------------------------------------------
>> _______________________________________________
>> Csound-devel mailing list
>> Csound-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>
> --
> Edward Costello
>
> ------------------------------------------------------------------------------
>
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel
>

------------------------------------------------------------------------------
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2015-09-15 10:22
FromEd Costello
SubjectRe: [Cs-dev] Polymorphic Opcodes
AttachmentsNone  None  
Ok, so it sounds like a single opcode solution is a no go until Csound 7 comes along. Thanks for updating the CMakelists as well.
Cheers,
Ed

On Mon, 14 Sep 2015 at 23:53 Steven Yi <stevenyi@gmail.com> wrote:
You shouldn't use the old polymorphism system anymore (the whole
0xfffe etc. business).  With CS6, just define the real OENTRYs to be
used.  Anything from the "." and onwards will be ignored; that was
done for backwards compatibility and to allow devs to use that as a
sort of markup for themselves (documentation).

I did some looking into this.  Two things:

First, I've modified the CMake file to check for the
websocket_cancel_service function. That should guarantee that an
updated version of libwebsockets is installed.

Second, having the zero-arg version won't work, at least with Csound
6. This one is tricky. With Csound 6, the parser depends upon semantic
information early in the parsing process.  The information it uses is
the names of opcodes and whether they have 0 output args or not.  This
gets recorded in a table as either T_OPCODE or T_OPCODE0.  The parser
depends on this information to parser whether an opcode can be used.

The trick with this is that an opcode can't be both T_OPCODE and
T_OPCODE0 in Csound 6.  When you start to parse, it'll try to parse as
one or the other.

Parser3 in Csound 7 should fix this situation as it doesn't do
disambiguation of opcode-call lines until the semantic analysis phase.
It's a little more flexible this way and *should* be able to handle
opcodes with different output-arg arities.

As far as I understand, for polymorphic opcodes, we have opcodes with
different argument types, but not different argument counts, with the
exception of var-args.  Either that, or we have them with at least one
required output argument. It'd require some more investigation, but
logically that must be the case or we'd have found a problem earlier.

In this case, the simplest thing would be to give multiple opcode
names.  I think this would be the only way to do this in Csound6 due
to the parser.


On Mon, Sep 14, 2015 at 4:47 PM, Ed Costello <phasereset@gmail.com> wrote:
> Hi
>
> I've been playing around with various OENTRY combinations trying to get the
> argument combination I require to work but I can't figure it out,
> In the below example from what I gather in the manual, the 0xfffe option
> specifies that an opcode will be picked based on the types of it's first 2
> inputs, so in the first definition of the opcode I have said to accept any
> number of outputs but just an i and k variable input. In the second one from
> what I gather it should accept 0 outputs and an i and a rate input.
>
> static OENTRY localops[] = {
>
>     {
>         .opname = "websocket",
>         .dsblksiz = sizeof(0xfffe),
>     },
>     {
>         .opname = "websocket.ik",
>         .dsblksiz = sizeof(WebSocketOpcode),
>         .thread = 3,
>         .outypes = "*",
>         .intypes = "ik",
>         .iopadr = (SUBR)WebSocketOpcode_initialise,
>         .kopadr = (SUBR)WebSocketOpcode_process,
>         .aopadr = NULL
>     },
>     {
>         .opname = "websocket.ia",
>         .dsblksiz = sizeof(WebSocketOpcode),
>         .thread = 3,
>         .outypes = "",
>         .intypes = "ia",
>         .iopadr = (SUBR)WebSocketOpcode_initialise,
>         .kopadr = (SUBR)WebSocketOpcode_process,
>         .aopadr = NULL
>     }
> };
>
> This doesn't work however, when I try adding an output to the opcode I get
> errors like this:
>
> WARNING: [mType confusion for websocket (277,275), replacing
> [m
> [mWARNING: [mType confusion for websocket (275,277), replacing
> [m
> [mWARNING: [mType confusion for websocket (277,275), replacing
> [m
> [mWARNING: [mType confusion for websocket (275,277), replacing
> [m
>
> That argument combination isn't exactly what I want of course, but I can't
> even get the opcode to work polymorphically based on having 0 or any output
> variables and was wondering how that bit is done.
> Ed
>
> On Sun, 13 Sep 2015 at 21:24 jpff <jpff@codemist.co.uk> wrote:
>>
>> Yes sorry -- it does need a new structure or te glue code copies the data
>> about.....
>>
>> There are similar cases in vbap.c oor vbap1.c I think
>>
>>
>>
>> ------------------------------------------------------------------------------
>> _______________________________________________
>> Csound-devel mailing list
>> Csound-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>
> --
> Edward Costello
>
> ------------------------------------------------------------------------------
>
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel
>

------------------------------------------------------------------------------
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/csound-devel
--
Edward Costello