Subversion Repositories filter_foundry

Compare Revisions

Regard whitespace Rev 216 → Rev 217

/trunk/scripting.c
34,6 → 34,7
//extern FilterRecordPtr gpb;
 
OSErr put_cstring(PIWriteDescriptor token,DescriptorKeyID key,char *s){
OSErr e;
size_t n = strlen(s);
Ptr p;
Handle h = PINEWHANDLE((int32)n);
40,8 → 41,9
p = PILOCKHANDLE(h,false);
memcpy(p,s,n);
PIUNLOCKHANDLE(h);
return PIPutText(token,key,h);
/* FIXME: not sure if we are supposed to dispose of handle */
e = PIPutText(token, key, h);
PIDISPOSEHANDLE(h); /* Not 100% sure if we are supposed to dispose of handle. It doesn't crash though */
return e;
}
 
char *get_cstring(PIReadDescriptor token){
54,13 → 56,12
if(!e && h){
n = PIGETHANDLESIZE(h);
p = PILOCKHANDLE(h,false);
//sprintf(str,"get_cstring: token=%#x s=%#x h=%#x p=%#x n=%d",token,s,h,p,n); dbg(str);
if( (str = (char*)malloc(n+1)) ){
memcpy(str,p,n);
str[n] = 0;
}
PIUNLOCKHANDLE(h);
/* FIXME: not sure if we are supposed to dispose of handle */
PIDISPOSEHANDLE(h); /* Not 100% sure if we are supposed to dispose of handle. It doesn't crash though */
}
return str;
}
89,7 → 90,8
hash = printablehash(djb2(data));
free(data);
return hash;
} else {
}
else {
// char* debug = malloc(2000);
// sprintf(debug, "getAeteKey %c in MAIN PLUGIN", c);
// simplealert(debug);
121,13 → 123,17
while (PIGetKey(token, &key, &type, &flags)) {
if (key == getAeteKey('R', gdata->standalone ? &gdata->parm : NULL)) {
expr[0] = get_cstring(token);
} else if (key == getAeteKey('G', gdata->standalone ? &gdata->parm : NULL)) {
}
else if (key == getAeteKey('G', gdata->standalone ? &gdata->parm : NULL)) {
expr[1] = get_cstring(token);
} else if (key == getAeteKey('B', gdata->standalone ? &gdata->parm : NULL)) {
}
else if (key == getAeteKey('B', gdata->standalone ? &gdata->parm : NULL)) {
expr[2] = get_cstring(token);
} else if (key == getAeteKey('A', gdata->standalone ? &gdata->parm : NULL)) {
}
else if (key == getAeteKey('A', gdata->standalone ? &gdata->parm : NULL)) {
expr[3] = get_cstring(token);
} else {
}
else {
int i;
for (i=0; i<=7; ++i) {
if (key == getAeteKey('0'+i, gdata->standalone ? &gdata->parm : NULL)) {
145,7 → 151,8
}
 
return gpb->descriptorParameters->playInfo == plugInDialogDisplay ? SCR_SHOW_DIALOG : SCR_HIDE_DIALOG;
} else {
}
else {
return SCR_NO_SCRIPT;
}
}
158,8 → 165,11
int i,allctls;
 
if (DescriptorAvailable(NULL)){ /* recording. Do our thing. */
// 1. Call openWriteDescriptorProc which will return a PIWriteDescriptor token, such as writeToken.
token = OpenWriter();
if (token){
// 2. Call various Put routines such as PutIntegerProc, PutFloatProc, etc., to add key/value pairs to writeToken. The keys and value types must correspond to those in your terminology resource.
 
// write keys here
if(!gdata->standalone){
if (nplanes > 0) put_cstring(token, getAeteKey('R', gdata->standalone ? &gdata->parm : NULL), expr[0]);
310,10 → 320,14
 
if (procs->descriptor != NULL) // don't need descriptor passed to us
hProcs->disposeProc(procs->descriptor); // dispose.
 
// 3. Call CloseWriteDescriptorProc with writeToken, which will create a PIDescriptorHandle.
procs->writeDescriptorProcs->closeWriteDescriptorProc(*token, &h);
 
// 4. Place the PIDescriptorHandle into the descriptor field. The host will dispose of it when finished.
procs->descriptor = h;
 
// Set recordInfo to default. Options are: plugInDialogOptional,
// 5. Set recordInfo. Options are: plugInDialogOptional,
// plugInDialogRequire, plugInDialogNone:
procs->recordInfo = plugInDialogOptional;