[OSC_dev] advice for callback (oscit)

salsaman at xs4all.nl salsaman at xs4all.nl
Fri Dec 26 14:08:19 PST 2008


On Fri, December 26, 2008 17:43, Gaspard Bucher wrote:
> Hi list !
>
> I started extracting the library from rubyk but I jump on a difficult
> problem: in rubyk all values passed between objects and used in OSC
> calls are sub-classes of Value (a smart pointer with reference
> counting). This means every function has the type:
>
> const Value method_name (const Value& param)
>
> A "Value" can be a Number, a Hash, a Matrix, a String or just Nil
> (Array coming soon).
>
> All this is fine in a C++ environment but I do not see how we could
> easily use the "value" stuff in a plain C interface.
>
> ========= oscit C interface ========
>
> The values will be replaced by an array of union [float / int / string
> / xxx]. So the signature of registering methods will be (C interface)
> :
>
> void my_function(OscVal * ret, const OscVal * arg)
>
> You register the function with something like:
>
> register_method("/some/url", my_function, "ffi")
>
> Inside "my_function", values are simply retrieved with:
>
> arg[0]->f = float
> arg[1]->i = int
> etc.
>
> Type checking is done by "oscit", the only verification should be (arg
> == NULL) because methods can either receive the correct signature or
> Nil.
>
> The storage space for return values is also prepared and the function
> should just write:
>
> ret[0]->f = ...
> ret[1]->i = ...
> etc
>
> This setting has the following advantages:
>
> 1. fast to parse
> 2. no dynamic memory allocation during runtime (done once on
> registration for "ret" and "arg")
>
> The drawbacks are:
>
> 1. fixed type signature
> 2. same type signature for argument and return value
>
> Does this seem ok for the "C" users out there ?
>

I am not sure this is needed for me, I already do my own type parsing and
sending of return values.


But it might be OK for some people.


Gabriel.







More information about the OSC_dev mailing list