Csound Csound-dev Csound-tekno Search About

Re: [Cs-dev] more SWIG generated code issues

Date2005-11-17 15:58
FromMichael Gogins
SubjectRe: [Cs-dev] more SWIG generated code issues
The callbacks cannot be used in the current state of the interfaces, in any of the supported languages.

However, it definitely is possible to amend the .i files to support callbacks in ALL of the supported languages. This, again, requires typemaps for the callback objects. I have done similar work on other (business-related) projects for C#, for Java, and for Python. It is moderately difficult.  Each callback signature must have its own hand-coded typemap for each supported language.

I am not eager to do this for all of the supported languages although, of course, I would be happy if someone else did do it.

In the meantime, everything that one might want to do with callbacks can be done by polling, if only the host will drive the Csound performance using csoundPerformKsmps. This gives the host time to poll Csound, get and set variables, etc., in between calls to csoundPerformKsmps.

Regards,
Mike



-----Original Message-----
From: Victor Lazzarini 
Sent: Nov 17, 2005 9:36 AM
To: csound-devel@lists.sourceforge.net
Subject: [Cs-dev] more SWIG generated code issues

I have been looking at and playing a little bit with the SWIG-generated
wrappers for the API (mainly Java), and I have a few comments.

The first is in relation to certain API functions, the ones that are
used to set callbacks for various things; for instance
csoundSetInputValueCallback(). I'm not completely sure it is
possible to use them in Java or Python in the current state.
I don't think we can, because they use C function pointer types
which do not seem to be usable, as there seems to be no converting methods
for them (at least in Java). Can you have something akin to
function pointers in these languages? I see that it might be
possible perhaps in Java. However I don't think it is possible
to use it in the current state.

So my point is: should we keep these API methods, even if they
are useless? Would it not look a little untidy and unelegant to be offering
something that looks interesting, but in the end is not? Would it not
cause confusion?

My second point is that, with much of this functionality lost, a lot of
what a language wrapper can do is also lost. Take for instance, getting
access to a named IO channel. I don't see how I can use the Csound
method

public int GetChannelPtr(SWIGTYPE_p_p_float p, String name, int type)

in Java. It might be possible (and someone please show me how to), but
I don't think there is a way of dealing with SWIGTYPE_p_p_float p, I can't
see any public methods to provide any access to it. But I don't know
any real Java and I am just a C++ programmer guessing it.

A way forward? Do it by hand. I know this might not be attractive to anyone,
but certain things can only be done by hand. For instance a C function or
C++ method could be used to retrieve values from a named channel (in the
case above). A simple set of functions could be created to provide an
interface to invalue and outvalue, creating lists of channels, in the case
of the other control channel system, and so on. In other words, create an
intermediary interface to the C API .In addition, it is possible
that many API functions cannot be translated into Java or Python, and these
are not included.

In any case, I might be wrong and it is possible to use all the SWIG supplied
interface in both Java and Python. In that case just tell me to shut up and 
show me
how to do it.

Thanks

Victor Lazzarini
Music Technology Laboratory
Music Department
National University of Ireland, Maynooth 



-------------------------------------------------------
This SF.Net email is sponsored by the JBoss Inc.  Get Certified Today
Register for a JBoss Training Course.  Free Certification Exam
for All Training Attendees Through End of 2005. For more info visit:
http://ads.osdn.com/?ad_id=7628&alloc_id=16845&op=click
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/csound-devel





-------------------------------------------------------
This SF.Net email is sponsored by the JBoss Inc.  Get Certified Today
Register for a JBoss Training Course.  Free Certification Exam
for All Training Attendees Through End of 2005. For more info visit:
http://ads.osdn.com/?ad_id=7628&alloc_id=16845&op=click
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net