| Further response....
Yes, the interfaces are incomplete. I chose the path of directly exposing all of the API using SWIG, which is automatic. I did this because it was a huge win: you get the ability to control Csound in several languages for almost no work. Lovely.
Things that are wrapped with opaque types can be fixed up. Please do not start coding wrappers by hand. They will get out of date the minute anyone ever changes the API. Will anyone ever change the API? Of course they will.
Excluding APIs is also not so great. It might sound like a good idea, but out of sight, out of mind. Once there is no wrapper, nobody will remember that there could be one, or if they do, they will assume it is not possible with SWIG and go off and do it by hand, and then later on it will break. Reality check: Enough of the API has been working through Python and Java to use Csound from those languages for several years now, automatically tracking changes, with almost no effort expended.
The right way to do this is to fix up the SWIG .i files with typemaps. That is what typemaps are for. We should let these things nag at us until we fix up the APIs we really need with typemaps.
If in spite of all typemaps will not do the job, then hand-written wrappers can be used, BUT THEY MUST GO INTO THE .i FILES so that the SWIG system and the build system will keep automatically tracking changes.
Best,
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 |