Rev 211 | Rev 268 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 211 | Rev 217 | ||
---|---|---|---|
Line 32... | Line 32... | ||
32 | #include "dbg.h" |
32 | #include "dbg.h" |
33 | 33 | ||
34 | //extern FilterRecordPtr gpb; |
34 | //extern FilterRecordPtr gpb; |
35 | 35 | ||
36 | OSErr put_cstring(PIWriteDescriptor token,DescriptorKeyID key,char *s){ |
36 | OSErr put_cstring(PIWriteDescriptor token, DescriptorKeyID key, char* s) { |
- | 37 | OSErr e; |
|
37 | size_t n = strlen(s); |
38 | size_t n = strlen(s); |
38 | Ptr p; |
39 | Ptr p; |
39 | Handle h = PINEWHANDLE((int32)n); |
40 | Handle h = PINEWHANDLE((int32)n); |
40 | p = PILOCKHANDLE(h,false); |
41 | p = PILOCKHANDLE(h, false); |
41 | memcpy(p,s,n); |
42 | memcpy(p, s, n); |
42 | PIUNLOCKHANDLE(h); |
43 | PIUNLOCKHANDLE(h); |
43 | return PIPutText(token,key,h); |
44 | e = PIPutText(token, key, h); |
44 | /* FIXME: not sure if we are supposed to dispose of handle */ |
45 | PIDISPOSEHANDLE(h); /* Not 100% sure if we are supposed to dispose of handle. It doesn't crash though */ |
- | 46 | return e; |
|
45 | } |
47 | } |
46 | 48 | ||
47 | char *get_cstring(PIReadDescriptor token){ |
49 | char* get_cstring(PIReadDescriptor token) { |
48 | int n; |
50 | int n; |
49 | Ptr p; |
51 | Ptr p; |
Line 52... | Line 54... | ||
52 | OSErr e = PIGetText(token,&h); |
54 | OSErr e = PIGetText(token, &h); |
53 | 55 | ||
54 | if(!e && h){ |
56 | if (!e && h) { |
55 | n = PIGETHANDLESIZE(h); |
57 | n = PIGETHANDLESIZE(h); |
56 | p = PILOCKHANDLE(h,false); |
58 | p = PILOCKHANDLE(h, false); |
57 | //sprintf(str,"get_cstring: token=%#x s=%#x h=%#x p=%#x n=%d",token,s,h,p,n); dbg(str); |
- | |
58 | if( (str = (char*)malloc(n+1)) ){ |
59 | if ((str = (char*)malloc(n + 1))) { |
59 | memcpy(str,p,n); |
60 | memcpy(str, p, n); |
60 | str[n] = 0; |
61 | str[n] = 0; |
61 | } |
62 | } |
62 | PIUNLOCKHANDLE(h); |
63 | PIUNLOCKHANDLE(h); |
63 | /* FIXME: not sure if we are supposed to dispose of handle */ |
64 | PIDISPOSEHANDLE(h); /* Not 100% sure if we are supposed to dispose of handle. It doesn't crash though */ |
64 | } |
65 | } |
65 | return str; |
66 | return str; |
66 | } |
67 | } |
67 | 68 | ||
68 | // If parm is NULL, then it is standalone, otherwise it is the main plugin |
69 | // If parm is NULL, then it is standalone, otherwise it is the main plugin |
Line 87... | Line 88... | ||
87 | INPLACEP2CSTR(parm->title), |
88 | INPLACEP2CSTR(parm->title), |
88 | c); |
89 | c); |
89 | hash = printablehash(djb2(data)); |
90 | hash = printablehash(djb2(data)); |
90 | free(data); |
91 | free(data); |
91 | return hash; |
92 | return hash; |
- | 93 | } |
|
92 | } else { |
94 | else { |
93 | // char* debug = malloc(2000); |
95 | // char* debug = malloc(2000); |
94 | // sprintf(debug, "getAeteKey %c in MAIN PLUGIN", c); |
96 | // sprintf(debug, "getAeteKey %c in MAIN PLUGIN", c); |
95 | // simplealert(debug); |
97 | // simplealert(debug); |
96 | 98 | ||
97 | // Attention: AETE keys (xpr#, cTl#) must be equal in scripting.r, scripting.rc and scripting.c(getAeteKey)! |
99 | // Attention: AETE keys (xpr#, cTl#) must be equal in scripting.r, scripting.rc and scripting.c(getAeteKey)! |
Line 119... | Line 121... | ||
119 | token = OpenReader(array); |
121 | token = OpenReader(array); |
120 | if (token) { |
122 | if (token) { |
121 | while (PIGetKey(token, &key, &type, &flags)) { |
123 | while (PIGetKey(token, &key, &type, &flags)) { |
122 | if (key == getAeteKey('R', gdata->standalone ? &gdata->parm : NULL)) { |
124 | if (key == getAeteKey('R', gdata->standalone ? &gdata->parm : NULL)) { |
123 | expr[0] = get_cstring(token); |
125 | expr[0] = get_cstring(token); |
- | 126 | } |
|
124 | } else if (key == getAeteKey('G', gdata->standalone ? &gdata->parm : NULL)) { |
127 | else if (key == getAeteKey('G', gdata->standalone ? &gdata->parm : NULL)) { |
125 | expr[1] = get_cstring(token); |
128 | expr[1] = get_cstring(token); |
- | 129 | } |
|
126 | } else if (key == getAeteKey('B', gdata->standalone ? &gdata->parm : NULL)) { |
130 | else if (key == getAeteKey('B', gdata->standalone ? &gdata->parm : NULL)) { |
127 | expr[2] = get_cstring(token); |
131 | expr[2] = get_cstring(token); |
- | 132 | } |
|
128 | } else if (key == getAeteKey('A', gdata->standalone ? &gdata->parm : NULL)) { |
133 | else if (key == getAeteKey('A', gdata->standalone ? &gdata->parm : NULL)) { |
129 | expr[3] = get_cstring(token); |
134 | expr[3] = get_cstring(token); |
- | 135 | } |
|
130 | } else { |
136 | else { |
131 | int i; |
137 | int i; |
132 | for (i=0; i<=7; ++i) { |
138 | for (i = 0; i <= 7; ++i) { |
133 | if (key == getAeteKey('0'+i, gdata->standalone ? &gdata->parm : NULL)) { |
139 | if (key == getAeteKey('0' + i, gdata->standalone ? &gdata->parm : NULL)) { |
134 | PIGetInt(token, &v); |
140 | PIGetInt(token, &v); |
135 | slider[i] = v; |
141 | slider[i] = v; |
Line 143... | Line 149... | ||
143 | // all Filter Foundry parameters are optional, |
149 | // all Filter Foundry parameters are optional, |
144 | // so we needn't worry if any are missing |
150 | // so we needn't worry if any are missing |
145 | } |
151 | } |
146 | 152 | ||
147 | return gpb->descriptorParameters->playInfo == plugInDialogDisplay ? SCR_SHOW_DIALOG : SCR_HIDE_DIALOG; |
153 | return gpb->descriptorParameters->playInfo == plugInDialogDisplay ? SCR_SHOW_DIALOG : SCR_HIDE_DIALOG; |
- | 154 | } |
|
148 | } else { |
155 | else { |
149 | return SCR_NO_SCRIPT; |
156 | return SCR_NO_SCRIPT; |
150 | } |
157 | } |
151 | } |
158 | } |
152 | 159 | ||
153 | OSErr WriteScriptParamsOnRead(void) |
160 | OSErr WriteScriptParamsOnRead(void) |
Line 156... | Line 163... | ||
156 | OSErr gotErr = noErr; |
163 | OSErr gotErr = noErr; |
157 | extern int ctls[],maps[],nplanes; |
164 | extern int ctls[], maps[], nplanes; |
158 | int i,allctls; |
165 | int i, allctls; |
159 | 166 | ||
160 | if (DescriptorAvailable(NULL)){ /* recording. Do our thing. */ |
167 | if (DescriptorAvailable(NULL)) { /* recording. Do our thing. */ |
- | 168 | // 1. Call openWriteDescriptorProc which will return a PIWriteDescriptor token, such as writeToken. |
|
161 | token = OpenWriter(); |
169 | token = OpenWriter(); |
162 | if (token){ |
170 | if (token) { |
- | 171 | // 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. |
|
- | 172 | ||
163 | // write keys here |
173 | // write keys here |
164 | if(!gdata->standalone){ |
174 | if (!gdata->standalone) { |
165 | if (nplanes > 0) put_cstring(token, getAeteKey('R', gdata->standalone ? &gdata->parm : NULL), expr[0]); |
175 | if (nplanes > 0) put_cstring(token, getAeteKey('R', gdata->standalone ? &gdata->parm : NULL), expr[0]); |
166 | if (nplanes > 1) put_cstring(token, getAeteKey('G', gdata->standalone ? &gdata->parm : NULL), expr[1]); |
176 | if (nplanes > 1) put_cstring(token, getAeteKey('G', gdata->standalone ? &gdata->parm : NULL), expr[1]); |
167 | if (nplanes > 2) put_cstring(token, getAeteKey('B', gdata->standalone ? &gdata->parm : NULL), expr[2]); |
177 | if (nplanes > 2) put_cstring(token, getAeteKey('B', gdata->standalone ? &gdata->parm : NULL), expr[2]); |
Line 308... | Line 318... | ||
308 | OSErr err = noErr; // assume no error |
318 | OSErr err = noErr; // assume no error |
309 | PIDescriptorHandle h = NULL; |
319 | PIDescriptorHandle h = NULL; |
310 | 320 | ||
311 | if (procs->descriptor != NULL) // don't need descriptor passed to us |
321 | if (procs->descriptor != NULL) // don't need descriptor passed to us |
312 | hProcs->disposeProc(procs->descriptor); // dispose. |
322 | hProcs->disposeProc(procs->descriptor); // dispose. |
- | 323 | ||
- | 324 | // 3. Call CloseWriteDescriptorProc with writeToken, which will create a PIDescriptorHandle. |
|
313 | procs->writeDescriptorProcs->closeWriteDescriptorProc(*token, &h); |
325 | procs->writeDescriptorProcs->closeWriteDescriptorProc(*token, &h); |
- | 326 | ||
- | 327 | // 4. Place the PIDescriptorHandle into the descriptor field. The host will dispose of it when finished. |
|
314 | procs->descriptor = h; |
328 | procs->descriptor = h; |
315 | 329 | ||
316 | // Set recordInfo to default. Options are: plugInDialogOptional, |
330 | // 5. Set recordInfo. Options are: plugInDialogOptional, |
317 | // plugInDialogRequire, plugInDialogNone: |
331 | // plugInDialogRequire, plugInDialogNone: |
318 | procs->recordInfo = plugInDialogOptional; |
332 | procs->recordInfo = plugInDialogOptional; |
319 | 333 | ||
320 | *token = NULL; |
334 | *token = NULL; |
321 | 335 |