[OSC_dev] handling nil/inf in oscpack
Graham Wakefield
lists at grahamwakefield.net
Tue Mar 25 13:44:45 PDT 2008
FWIW, I made a nasty kludge for the problem by adding this to class
ReceivedMessageArgumentStream:
void hack_next()
{
p_++;
}
And doing this in my handler:
//process
unsigned long argc = m.ArgumentCount();
const char *addr = m.AddressPattern() ? m.AddressPattern() : "";
const char *tags = m.TypeTags() && argc ? m.TypeTags() : "";
osc::ReceivedMessageArgumentStream args = m.ArgumentStream();
//...
for(int i=0; i < argc; i++) {
switch(tags[i])
{
case 'f': {
float v; args >> v;
lua_pushnumber(L, v);
} break;
//.. etc. for other types
case 'T': {
bool v; args >> v;
lua_pushboolean(L, true);
} break;
case 'F': {
bool v; args >> v;
lua_pushboolean(L, false);
} break;
case 'N': {
args.hack_next(); ///<----- yuck
lua_pushnil(L);
} break;
//.. etc.
default: {
args.hack_next(); ///<----- yuck
lua_pushnil(L);
} break;
}
}
But really, I think there should be some method in
ReceivedMessageArgumentStream along the lines of args.ignoreArgument().
Best,
Graham
On Mar 25, 2008, at 1:03 PM, grahamwakefield wrote:
>
> Hi,
>
> I'm writing a generic OSC-service for the Lua language, based on
> oscpack.
> All is working wonderfully, except that I'm stuck on how to iterate
> past
> Nil/Infinitum types in received message streams.
>
> I'm not sure how to increment the ReceivedMessageArgumentStream
> pointer for
> N and I types. In the source, there's a comment:
>
> // not sure if it would be useful to stream Nil and Infinitum
> // for now it's not possible
>
> So my question: if there's a Nil or Infinitum embedded within a
> message
> stream (e.g., type tags = "iNi"), how can I iterate past the Nil/
> Infinitum
> and get the next argument? For T and F, I can use the >> operator
> to move to
> the next argument, but there isn't an equivalent for N or I. Is there
> another way to increment the stream?
>
> Thanks,
>
> Graham
>
> Example:
>
> send("test", 3, nil, 3)
> ->
> received address:"test:
> received types: "iNi"
> received arg 1: 3
> received arg 2: nil
> terminate called after throwing an instance of
> 'osc::WrongArgumentTypeException'
>
>
> --
> View this message in context: http://www.nabble.com/handling-nil-
> inf-in-oscpack-tp16287337p16287337.html
> Sent from the OpenSound Control (OSC) - Dev mailing list archive at
> Nabble.com.
>
> _______________________________________________
> OSC_dev mailing list
> OSC_dev at create.ucsb.edu
> http://lists.create.ucsb.edu/mailman/listinfo/osc_dev
Be seeing you
grrr waaa
www.grahamwakefield.net
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.create.ucsb.edu/pipermail/osc_dev/attachments/20080325/8d7871fc/attachment-0001.html
More information about the OSC_dev
mailing list