| I have mixed feelings about mini structures. I get your point about extra
junk in there and not needing the whole set, yet my experience tells me
keeping it all in one struct will make Csound easier to program and maintain
in future (oops, now this function needs member X added to its mini struct,
and this other function needs member X also added to ITS mini struct).
Could you please explain why you wish to distinguish between members of
GLOBALs and items private to Csound? How can Csound be a multiply
instantiable class if all required data is not referenceable through
GLOBALs?
I suggest it's better that all Csound state be in GLOBALs, but hidden, and
all Csound functions be in GLOBALs, but public.
Perhaps we can do something like this:
typedef struct CSOUND_INTERFACE {
int (Function1*)();
int (Function2*)();
} CSOUND_INTERFACE;
typedef struct CSOUND_STATE {
CSOUND_INTERFACE csound;
void *userdata;
int kr;
int sr;
...;
} CSOUND_STATE;
This allows CSOUND_STATE to be safely type cast to CSOUND_INTERFACE. Users
of the API only see CSOUND_INTERFACE, even though it carries a hidden
CSOUND_STATE:
CSOUND_INTERFACE *csoundCreate(void *userdata)
{
CSOUND_STATE *csoundState = (CSOUND_STATE *)
csoundAlloc(sizeof(CSOUND_STATE));
csoundState->csound.Function1 = csoundFunction1;
csoundState->csound.Function2 = csoundFunction2;
...
csoundState->userdata = userdata;
return (CSOUND_INTERFACE *)csoundState;
}
============================================
Michael Gogins
gogins at pipeline period com
Irreducible Productions
CsoundVST, an extended version of Csound for programming music and sound
Available at http://sourceforge.net/projects/csound/
============================================
----- Original Message -----
From: "Richard Dobson"
To: "Csound Developers Discussion List"
Sent: Sunday, November 16, 2003 5:34 AM
Subject: [CSOUND-DEV:3331] Re: Road to Reentrancy
> This was one of the early goals of the code-freeze, so I am very happy to
see
> everyone ready to deal with what is clearly an arduous and time-consuming
job!
> Getting return values from opcode fucntions is part of it of course, but
> re-parametrizing the functions is the other and even bigger task.
>
> My one suggestion (in the absence of inspecting the sources just as I
write) is
> that there will be many situations where a particular subset of global
variables
> travel around together - not least, everything associated with the orch
header
> info. These are worth wrapping into mini structures; in many cases there
will be
> no need to pass the whole GLOBALS struct, but individual elements, or a
> particular group of them. Conversely, I beleive there may be
opportunities to
> eliminate many items from GLOBALS altogether, that really have no business
being
> there (i.e. truly private to the internals of Csound), as their presence
was
> merely a classic C way of avoiding writing functions structured into
levels.
>
> In short, I hope we can use this opportunity to further restructure the
code,
> not just addrress the issue of re-entrancy.
>
>
> Richard Dobson
>
>
>
> Matt J. Ingalls wrote:
> >>2)Remove use of #defines that map to cglob, one by one, and do a global
> >>find and replace to manually replace calls. This basically does what
> >>the cglob-mapping defines do using the preprocessor.
> >>
> >>3)Rename cglob to something else, thus removing it from the global
> >>
> >
> >
> > i would just do 2 & 3 at once. i just tried this with csound4 sources
and
> > got over 3000 errors -- and it looks like that it only attempted
compiling
> > about half the files..
> >
> > so it may end up being A LOT of work to chance every function that uses
an
> > ex-global variable to take a passed GLOBALS struct. the other option
> > [as steven and i already discussed]
> > would be to just swap cglob structs on every API call -- you
> > would have to put up blocks for multiple instances, but it could be MUCH
> > easier than the other option...
> >
> > -m
> >
> >
> |