| 1 |
#ifndef _praatM_h_ |
| 2 |
#define _praatM_h_ |
| 3 |
/* praatM.h |
| 4 |
* |
| 5 |
* Copyright (C) 1992-2026 Paul Boersma |
| 6 |
* |
| 7 |
* This code is free software; you can redistribute it and/or modify |
| 8 |
* it under the terms of the GNU General Public License as published by |
| 9 |
* the Free Software Foundation; either version 3 of the License, or (at |
| 10 |
* your option) any later version. |
| 11 |
* |
| 12 |
* This code is distributed in the hope that it will be useful, but |
| 13 |
* WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| 15 |
* See the GNU General Public License for more details. |
| 16 |
* |
| 17 |
* You should have received a copy of the GNU General Public License |
| 18 |
* along with this work. If not, see <http://www.gnu.org/licenses/>. |
| 19 |
*/ |
| 20 |
|
| 21 |
#ifdef _EditorM_h_ |
| 22 |
#error Include either praatM.h or EditorM.h, but not both. |
| 23 |
#endif |
| 24 |
|
| 25 |
#include "praat.h" |
| 26 |
|
| 27 |
/* Macros for description of forms (dialog boxes, setting windows). |
| 28 |
FORM prompts the user for arguments to proc. |
| 29 |
Macros for FORM: |
| 30 |
FORM (proc, title, helpString) |
| 31 |
`proc` is the `cb` argument of the corresponding command call. |
| 32 |
`title` is the title of the form, shown in its title bar. |
| 33 |
`helpString` may be null. |
| 34 |
INTEGER (variable, labelText, defaultStringValue) |
| 35 |
NATURAL0 (variable, labelText, defaultStringValue) |
| 36 |
NATURAL1 (variable, labelText, defaultStringValue) |
| 37 |
REAL (variable, labelText, defaultStringValue) |
| 38 |
REAL_OR_UNDEFINED (variable, labelText, defaultStringValue) |
| 39 |
NONNEGATIVE (variable, labelText, defaultStringValue) |
| 40 |
POSITIVE (variable, labelText, defaultStringValue) |
| 41 |
WORD (variable, labelText, defaultStringValue) |
| 42 |
SENTENCE (variable, labelText, defaultStringValue) |
| 43 |
COLOUR (variable, labelText, defaultStringValue) |
| 44 |
CHANNEL (variable, labelText, defaultStringValue) |
| 45 |
BOOLEAN (variable, labelText, defaultBooleanValue) |
| 46 |
the value is 0 (off) or 1 (on). |
| 47 |
COMMENT (labelText) |
| 48 |
TEXTFIELD (variable, labelText, defaultStringValue, numberOfLines) |
| 49 |
REALVECTOR (variable, labelText, WHITESPACE_SEPARATED_, defaultStringValue) |
| 50 |
REALMATRIX (variable, labelText, ONE_ROW_PER_LINE_, defaultStringValue) |
| 51 |
CHOICE (variable, labelText, defaultOptionNumber, base) |
| 52 |
this should be followed by two or more OPTIONs; |
| 53 |
the initial value is between base and the number of choice buttons plus base-1. |
| 54 |
OPTION (labelText) |
| 55 |
OPTIONMENU (variable, labelText, defaultOptionNumber) |
| 56 |
this should be followed by two or more OPTIONs; |
| 57 |
the initial value is between 1 and the number of options. |
| 58 |
OPTION (labelText) |
| 59 |
LIST (variable, labelText, strings, defaultOptionNumber) |
| 60 |
OK |
| 61 |
this statement is obligatory. |
| 62 |
SET_XXXXXX (name, value) |
| 63 |
sets the value of REAL..LIST. |
| 64 |
DO |
| 65 |
The order of the macros should be: |
| 66 |
FORM { |
| 67 |
one or more from REAL..LIST |
| 68 |
OK |
| 69 |
zero or more SETs |
| 70 |
DO |
| 71 |
... |
| 72 |
} |
| 73 |
See Ui.h for more information. |
| 74 |
Between DO and `}`, you can throw an exception if anything is wrong; |
| 75 |
if everything is all right, you just trickle down to END. |
| 76 |
Never do "return", because END will update the selection if an object is created. |
| 77 |
*/ |
| 78 |
|
| 79 |
#define FORM(proc,name,helpTitle) \ |
| 80 |
extern "C" void proc (UiForm sendingForm, integer narg, Stackel args, conststring32 sendingString, \ |
| 81 |
Interpreter interpreter, conststring32 invokingButtonTitle, bool isModified, void *buttonClosure, Editor optionalEditor); \ |
| 82 |
void proc (UiForm _sendingForm_, integer _narg_, Stackel _args_, conststring32 _sendingString_, \ |
| 83 |
Interpreter interpreter, conststring32 _invokingButtonTitle_, bool _isModified_, void *_buttonClosure_, Editor _optionalEditor_) \ |
| 84 |
{ \ |
| 85 |
[[maybe_unused]] integer IOBJECT = 0; \ |
| 86 |
static autoUiForm _dia_; \ |
| 87 |
if (_dia_) \ |
| 88 |
goto _dia_inited_; \ |
| 89 |
_dia_ = UiForm_create (theCurrentPraatApplication -> topShell, _optionalEditor_, name, \ |
| 90 |
proc, _buttonClosure_, _invokingButtonTitle_, helpTitle); |
| 91 |
|
| 92 |
#define REAL(realVariable, labelText, defaultStringValue) \ |
| 93 |
static double realVariable; \ |
| 94 |
UiForm_addReal (_dia_.get(), & realVariable, U"" #realVariable, labelText, defaultStringValue); |
| 95 |
|
| 96 |
#define REAL_OR_UNDEFINED(realVariable, labelText, defaultStringValue) \ |
| 97 |
static double realVariable; \ |
| 98 |
UiForm_addRealOrUndefined (_dia_.get(), & realVariable, U"" #realVariable, labelText, defaultStringValue); |
| 99 |
|
| 100 |
#define NONNEGATIVE(realVariable, labelText, defaultStringValue) \ |
| 101 |
static double realVariable; \ |
| 102 |
UiForm_addNonnegative (_dia_.get(), & realVariable, U"" #realVariable, labelText, defaultStringValue); |
| 103 |
|
| 104 |
#define POSITIVE(realVariable, labelText, defaultStringValue) \ |
| 105 |
static double realVariable; \ |
| 106 |
UiForm_addPositive (_dia_.get(), & realVariable, U"" #realVariable, labelText, defaultStringValue); |
| 107 |
|
| 108 |
#define INTEGER(integerVariable, labelText, defaultStringValue) \ |
| 109 |
static integer integerVariable; \ |
| 110 |
UiForm_addInteger (_dia_.get(), & integerVariable, U"" #integerVariable, labelText, defaultStringValue); |
| 111 |
|
| 112 |
#define NATURAL0(integerVariable, labelText, defaultStringValue) \ |
| 113 |
static integer integerVariable; \ |
| 114 |
UiForm_addNatural0 (_dia_.get(), & integerVariable, U"" #integerVariable, labelText, defaultStringValue); |
| 115 |
|
| 116 |
#define NATURAL1(integerVariable, labelText, defaultStringValue) \ |
| 117 |
static integer integerVariable; \ |
| 118 |
UiForm_addNatural1 (_dia_.get(), & integerVariable, U"" #integerVariable, labelText, defaultStringValue); |
| 119 |
/* TODO: remove: */ |
| 120 |
#define NATURAL NATURAL1 |
| 121 |
|
| 122 |
#define WORD(stringVariable, labelText, defaultStringValue) \ |
| 123 |
static conststring32 stringVariable; \ |
| 124 |
UiForm_addWord (_dia_.get(), & stringVariable, U"" #stringVariable, labelText, defaultStringValue); |
| 125 |
|
| 126 |
#define SENTENCE(stringVariable, labelText, defaultStringValue) \ |
| 127 |
static conststring32 stringVariable; \ |
| 128 |
UiForm_addSentence (_dia_.get(), & stringVariable, U"" #stringVariable, labelText, defaultStringValue); |
| 129 |
|
| 130 |
#define BOOLEAN(booleanVariable, labelText, defaultBooleanValue) \ |
| 131 |
static bool booleanVariable; \ |
| 132 |
UiForm_addBoolean (_dia_.get(), & booleanVariable, U"" #booleanVariable, labelText, defaultBooleanValue); |
| 133 |
|
| 134 |
#define HEADING(labelText) UiForm_addHeading (_dia_.get(), nullptr, labelText); |
| 135 |
|
| 136 |
#define COMMENT(labelText) UiForm_addComment (_dia_.get(), nullptr, labelText); |
| 137 |
|
| 138 |
#define CAPTION(labelText) UiForm_addCaption (_dia_.get(), nullptr, labelText); |
| 139 |
|
| 140 |
#define MUTABLE_COMMENT(stringVariable, labelText) \ |
| 141 |
static conststring32 stringVariable; \ |
| 142 |
UiForm_addComment (_dia_.get(), & stringVariable, labelText); |
| 143 |
|
| 144 |
#define TEXTFIELD(stringVariable, labelText, defaultStringValue, numberOfLines) \ |
| 145 |
static conststring32 stringVariable; \ |
| 146 |
UiForm_addText (_dia_.get(), & stringVariable, U"" #stringVariable, labelText, defaultStringValue, numberOfLines); |
| 147 |
|
| 148 |
#define FORMULA(stringVariable, labelText, defaultStringValue) \ |
| 149 |
static conststring32 stringVariable; \ |
| 150 |
UiForm_addFormula (_dia_.get(), & stringVariable, U"" #stringVariable, labelText, defaultStringValue); |
| 151 |
|
| 152 |
#define INFILE(stringVariable, labelText, defaultStringValue) \ |
| 153 |
static conststring32 stringVariable; \ |
| 154 |
UiForm_addInfile (_dia_.get(), & stringVariable, U"" #stringVariable, labelText, defaultStringValue); |
| 155 |
|
| 156 |
#define OUTFILE(stringVariable, labelText, defaultStringValue) \ |
| 157 |
static conststring32 stringVariable; \ |
| 158 |
UiForm_addOutfile (_dia_.get(), & stringVariable, U"" #stringVariable, labelText, defaultStringValue); |
| 159 |
|
| 160 |
#define FOLDER(stringVariable, labelText, defaultStringValue) \ |
| 161 |
static conststring32 stringVariable; \ |
| 162 |
UiForm_addFolder (_dia_.get(), & stringVariable, U"" #stringVariable, labelText, defaultStringValue); |
| 163 |
|
| 164 |
#define REALVECTOR(realVectorVariable, labelText, defaultFormat, defaultStringValue) \ |
| 165 |
static constVEC realVectorVariable; \ |
| 166 |
UiForm_addRealVector (_dia_.get(), & realVectorVariable, U"" #realVectorVariable, \ |
| 167 |
labelText, kUi_realVectorFormat::defaultFormat, defaultStringValue); |
| 168 |
|
| 169 |
#define POSITIVEVECTOR(realVectorVariable, labelText, defaultFormat, defaultStringValue) \ |
| 170 |
static constVEC realVectorVariable; \ |
| 171 |
UiForm_addPositiveVector (_dia_.get(), & realVectorVariable, U"" #realVectorVariable, \ |
| 172 |
labelText, kUi_realVectorFormat::defaultFormat, defaultStringValue); |
| 173 |
|
| 174 |
#define INTEGERVECTOR(integerVectorVariable, labelText, defaultFormat, defaultStringValue) \ |
| 175 |
static constINTVEC integerVectorVariable; \ |
| 176 |
UiForm_addIntegerVector (_dia_.get(), & integerVectorVariable, U"" #integerVectorVariable, \ |
| 177 |
labelText, kUi_integerVectorFormat::defaultFormat, defaultStringValue); |
| 178 |
|
| 179 |
#define NATURAL0VECTOR(integerVectorVariable, labelText, defaultFormat, defaultStringValue) \ |
| 180 |
static constINTVEC integerVectorVariable; \ |
| 181 |
UiForm_addNatural0Vector (_dia_.get(), & integerVectorVariable, U"" #integerVectorVariable, \ |
| 182 |
labelText, kUi_integerVectorFormat::defaultFormat, defaultStringValue); |
| 183 |
|
| 184 |
#define NATURAL1VECTOR(integerVectorVariable, labelText, defaultFormat, defaultStringValue) \ |
| 185 |
static constINTVEC integerVectorVariable; \ |
| 186 |
UiForm_addNatural1Vector (_dia_.get(), & integerVectorVariable, U"" #integerVectorVariable, \ |
| 187 |
labelText, kUi_integerVectorFormat::defaultFormat, defaultStringValue); |
| 188 |
|
| 189 |
/* TODO: remove */ |
| 190 |
#define NATURALVECTOR(integerVectorVariable, labelText, defaultFormat, defaultStringValue) \ |
| 191 |
static constINTVEC integerVectorVariable; \ |
| 192 |
UiForm_addNatural1Vector (_dia_.get(), & integerVectorVariable, U"" #integerVectorVariable, \ |
| 193 |
labelText, kUi_integerVectorFormat::defaultFormat, defaultStringValue); |
| 194 |
|
| 195 |
#define REALMATRIX(numericMatrixVariable, labelText, defaultNumericMatrixValue) \ |
| 196 |
static constMAT numericMatrixVariable; \ |
| 197 |
UiForm_addRealMatrix (_dia_.get(), & numericMatrixVariable, U"" #numericMatrixVariable, \ |
| 198 |
labelText, defaultNumericMatrixValue.get()); |
| 199 |
|
| 200 |
#define STRINGARRAY(stringArrayVariable, labelText, ...) \ |
| 201 |
static constSTRVEC stringArrayVariable; \ |
| 202 |
{ \ |
| 203 |
static const conststring32 _defaultStringArrayValue [] = __VA_ARGS__; \ |
| 204 |
UiForm_addStringArray (_dia_.get(), & stringArrayVariable, U"" #stringArrayVariable, \ |
| 205 |
labelText, ARRAY_TO_STRVEC (_defaultStringArrayValue)); \ |
| 206 |
} |
| 207 |
|
| 208 |
#define STRINGARRAY_LINES(numberOfLines, stringArrayVariable, labelText, ...) \ |
| 209 |
static constSTRVEC stringArrayVariable; \ |
| 210 |
{ \ |
| 211 |
static const conststring32 _defaultStringArrayValue [] = __VA_ARGS__; \ |
| 212 |
UiForm_addStringArray (_dia_.get(), & stringArrayVariable, U"" #stringArrayVariable, \ |
| 213 |
labelText, ARRAY_TO_STRVEC (_defaultStringArrayValue), numberOfLines); \ |
| 214 |
} |
| 215 |
|
| 216 |
#define CHOICE(intVariable, labelText, defaultOptionNumber) \ |
| 217 |
static int intVariable; \ |
| 218 |
UiForm_addChoice (_dia_.get(), & intVariable, nullptr, U"" #intVariable, \ |
| 219 |
labelText, defaultOptionNumber, 1); |
| 220 |
|
| 221 |
#define CHOICEx(intVariable, labelText, defaultOptionNumber, base) \ |
| 222 |
static int intVariable; \ |
| 223 |
UiForm_addChoice (_dia_.get(), & intVariable, nullptr, U"" #intVariable, \ |
| 224 |
labelText, defaultOptionNumber, base); |
| 225 |
|
| 226 |
#define CHOICESTR(stringVariable, labelText, defaultOptionNumber) \ |
| 227 |
static conststring32 stringVariable; \ |
| 228 |
UiForm_addChoice (_dia_.get(), nullptr, & stringVariable, U"" #stringVariable, \ |
| 229 |
labelText, defaultOptionNumber, 1); |
| 230 |
|
| 231 |
#define OPTIONMENU(intVariable, labelText, defaultOptionNumber) \ |
| 232 |
static int intVariable; \ |
| 233 |
UiForm_addOptionMenu (_dia_.get(), & intVariable, nullptr, U"" #intVariable, \ |
| 234 |
labelText, defaultOptionNumber, 1); |
| 235 |
|
| 236 |
#define OPTIONMENUx(intVariable, labelText, defaultOptionNumber, base) \ |
| 237 |
static int intVariable; \ |
| 238 |
UiForm_addOptionMenu (_dia_.get(), & intVariable, nullptr, U"" #intVariable, \ |
| 239 |
labelText, defaultOptionNumber, base); |
| 240 |
|
| 241 |
#define OPTIONMENUSTR(stringVariable, labelText, defaultOptionNumber) \ |
| 242 |
static conststring32 stringVariable; \ |
| 243 |
UiForm_addOptionMenu (_dia_.get(), nullptr, & stringVariable, U"" #stringVariable, \ |
| 244 |
labelText, defaultOptionNumber, 1); |
| 245 |
|
| 246 |
#define OPTION(optionText) \ |
| 247 |
UiForm_addOption (_dia_.get(), optionText); |
| 248 |
|
| 249 |
#define CHOICE_ENUM(EnumeratedType, enumeratedVariable, labelText, defaultValue) \ |
| 250 |
static enum EnumeratedType enumeratedVariable; \ |
| 251 |
{/* type checks */ \ |
| 252 |
[[maybe_unused]] enum EnumeratedType _compilerTypeCheckDummy = defaultValue; \ |
| 253 |
_compilerTypeCheckDummy = enumeratedVariable; \ |
| 254 |
} \ |
| 255 |
UiForm_addChoiceEnum (_dia_.get(), (int *) & enumeratedVariable, nullptr, U"" #enumeratedVariable, \ |
| 256 |
labelText, (int) defaultValue - (int) EnumeratedType::MIN + 1, (int) EnumeratedType::MIN, \ |
| 257 |
(enum_generic_getValue) EnumeratedType##_getValue \ |
| 258 |
); \ |
| 259 |
for (int ienum = (int) EnumeratedType::MIN; ienum <= (int) EnumeratedType::MAX; ienum ++) \ |
| 260 |
UiForm_addOption (_dia_.get(), EnumeratedType##_getText ((enum EnumeratedType) ienum)); |
| 261 |
|
| 262 |
#define OPTIONMENU_ENUM(EnumeratedType, enumeratedVariable, labelText, defaultValue) \ |
| 263 |
static EnumeratedType enumeratedVariable; \ |
| 264 |
{/* type checks */ \ |
| 265 |
[[maybe_unused]] enum EnumeratedType _compilerTypeCheckDummy = defaultValue; \ |
| 266 |
_compilerTypeCheckDummy = enumeratedVariable; \ |
| 267 |
} \ |
| 268 |
UiForm_addOptionMenuEnum (_dia_.get(), (int *) & enumeratedVariable, nullptr, U"" #enumeratedVariable, \ |
| 269 |
labelText, (int) defaultValue - (int) EnumeratedType::MIN + 1, (int) EnumeratedType::MIN, \ |
| 270 |
(enum_generic_getValue) EnumeratedType##_getValue \ |
| 271 |
); \ |
| 272 |
for (int ienum = (int) EnumeratedType::MIN; ienum <= (int) EnumeratedType::MAX; ienum ++) \ |
| 273 |
UiForm_addOption (_dia_.get(), EnumeratedType##_getText ((enum EnumeratedType) ienum)); |
| 274 |
|
| 275 |
#define OPTIONMENU_ENUMSTR(EnumeratedType, enumeratedVariableAsString, labelText, defaultValue) \ |
| 276 |
static char32 *enumeratedVariableAsString; \ |
| 277 |
{/* type checks */ \ |
| 278 |
[[maybe_unused]] enum EnumeratedType _compilerTypeCheckDummy = defaultValue; \ |
| 279 |
_compilerTypeCheckDummy = enumeratedVariable; \ |
| 280 |
} \ |
| 281 |
UiForm_addOptionMenuEnum (_dia_.get(), nullptr, & enumeratedVariableAsString, U"" #enumeratedVariableAsString, \ |
| 282 |
labelText, (int) defaultValue - (int) EnumeratedType::MIN + 1, (int) EnumeratedType::MIN, \ |
| 283 |
(enum_generic_getValue) EnumeratedType##_getValue \ |
| 284 |
); \ |
| 285 |
for (int ienum = (int) EnumeratedType::MIN; ienum <= (int) EnumeratedType::MAX; ienum ++) \ |
| 286 |
UiForm_addOption (_dia_.get(), EnumeratedType##_getText ((enum EnumeratedType) ienum)); |
| 287 |
|
| 288 |
/* |
| 289 |
LIST will throw if the supplied string is not in the list. |
| 290 |
*/ |
| 291 |
#define LIST(integerVariable, labelText, strings, defaultOptionNumber) \ |
| 292 |
static integer integerVariable; \ |
| 293 |
UiForm_addList (_dia_.get(), & integerVariable, nullptr, U"" #integerVariable, \ |
| 294 |
labelText, strings, defaultOptionNumber); |
| 295 |
|
| 296 |
/* |
| 297 |
LISTSTR will throw if the supplied string is not in the list. |
| 298 |
*/ |
| 299 |
#define LISTSTR(stringVariable, labelText, strings, defaultOptionNumber) \ |
| 300 |
static conststring32 stringVariable; \ |
| 301 |
UiForm_addList (_dia_.get(), nullptr, & stringVariable, U"" #stringVariable, \ |
| 302 |
labelText, strings, defaultOptionNumber); |
| 303 |
|
| 304 |
/* |
| 305 |
If the supplied string is not in the list, LISTNUMSTR will return 0 as well as the supplied string, for later handling. |
| 306 |
*/ |
| 307 |
#define LISTNUMSTR(integerVariable, stringVariable, labelText, strings, defaultOptionNumber) \ |
| 308 |
static integer integerVariable; \ |
| 309 |
static conststring32 stringVariable; \ |
| 310 |
UiForm_addList (_dia_.get(), & integerVariable, & stringVariable, U"" #stringVariable, \ |
| 311 |
labelText, strings, defaultOptionNumber); |
| 312 |
|
| 313 |
#define FILE_IN(labelText) \ |
| 314 |
UiForm_addFileIn (_dia_.get(), labelText); |
| 315 |
|
| 316 |
#define FILE_OUT(labelText, defaultStringValue) \ |
| 317 |
UiForm_addFileOut (_dia_.get(), labelText, defaultStringValue); |
| 318 |
|
| 319 |
#define COLOUR(colourVariable, labelText, defaultStringValue) \ |
| 320 |
static MelderColour colourVariable; \ |
| 321 |
UiForm_addColour (_dia_.get(), & colourVariable, U"" #colourVariable, labelText, defaultStringValue); |
| 322 |
|
| 323 |
#define CHANNEL(integerVariable, labelText, defaultStringValue) \ |
| 324 |
static integer integerVariable; \ |
| 325 |
UiForm_addChannel (_dia_.get(), & integerVariable, U"" #integerVariable, labelText, defaultStringValue); |
| 326 |
|
| 327 |
#define OK \ |
| 328 |
UiForm_finish (_dia_.get()); \ |
| 329 |
_dia_inited_: \ |
| 330 |
if (_narg_ < 0) UiForm_info (_dia_.get(), _narg_); else if (! _args_ && ! _sendingForm_ && ! _sendingString_) { |
| 331 |
|
| 332 |
#define SET_REAL(realVariable, realValue) \ |
| 333 |
UiForm_setReal (_dia_.get(), & realVariable, realValue); |
| 334 |
|
| 335 |
#define SET_INTEGER(integerVariable, integerValue) \ |
| 336 |
UiForm_setInteger (_dia_.get(), & integerVariable, integerValue); |
| 337 |
|
| 338 |
#define SET_BOOLEAN(booleanVariable, booleanValue) \ |
| 339 |
UiForm_setBoolean (_dia_.get(), & booleanVariable, booleanValue); |
| 340 |
|
| 341 |
#define SET_OPTION(optionVariable, optionValue) \ |
| 342 |
UiForm_setOption (_dia_.get(), & optionVariable, optionValue); |
| 343 |
|
| 344 |
#define SET_STRING(stringVariable, stringValue) \ |
| 345 |
UiForm_setString (_dia_.get(), & stringVariable, stringValue); |
| 346 |
|
| 347 |
#define SET_ENUM(enumeratedVariable, EnumeratedType, enumeratedValue) \ |
| 348 |
enumeratedVariable = enumeratedValue; /* just for typechecking */ \ |
| 349 |
UiForm_setOption (_dia_.get(), (int *) & enumeratedVariable, (int) enumeratedValue - (int) EnumeratedType::MIN + 1); |
| 350 |
|
| 351 |
#define SET_LIST(integerVariable, stringVariable, strings, defaultValue) \ |
| 352 |
UiForm_setList (_dia_.get(), & integerVariable, & stringVariable, strings, defaultValue); |
| 353 |
|
| 354 |
#define DO \ |
| 355 |
UiForm_do (_dia_.get(), _isModified_); \ |
| 356 |
} else if (! _sendingForm_) { \ |
| 357 |
trace (U"args ", Melder_pointer (_args_)); \ |
| 358 |
if (_args_) { \ |
| 359 |
UiForm_call (_dia_.get(), _narg_, _args_, interpreter); \ |
| 360 |
} else { \ |
| 361 |
UiForm_parseString (_dia_.get(), _sendingString_, interpreter); \ |
| 362 |
} \ |
| 363 |
} else { \ |
| 364 |
try { \ |
| 365 |
{ |
| 366 |
|
| 367 |
#define DO_ALTERNATIVE(alternative) \ |
| 368 |
UiForm_do (_dia_.get(), _isModified_); \ |
| 369 |
} else if (! _sendingForm_) { \ |
| 370 |
trace (U"alternative args ", Melder_pointer (_args_)); \ |
| 371 |
try { \ |
| 372 |
if (_args_) { \ |
| 373 |
UiForm_call (_dia_.get(), _narg_, _args_, interpreter); \ |
| 374 |
} else { \ |
| 375 |
UiForm_parseString (_dia_.get(), _sendingString_, interpreter); \ |
| 376 |
} \ |
| 377 |
} catch (MelderError) { \ |
| 378 |
if (Melder_hasCrash ()) \ |
| 379 |
throw; \ |
| 380 |
autostring32 _parkedError = Melder_dup_f (Melder_getError ()); \ |
| 381 |
Melder_clearError (); \ |
| 382 |
try { \ |
| 383 |
alternative (nullptr, _narg_, _args_, _sendingString_, interpreter, _invokingButtonTitle_, _isModified_, _buttonClosure_, _optionalEditor_); \ |
| 384 |
} catch (MelderError) { \ |
| 385 |
Melder_clearError (); \ |
| 386 |
Melder_appendError (_parkedError.get()); \ |
| 387 |
throw; \ |
| 388 |
} \ |
| 389 |
} \ |
| 390 |
} else { \ |
| 391 |
try { \ |
| 392 |
{ |
| 393 |
|
| 394 |
#define END_WITH_NEW_DATA \ |
| 395 |
} \ |
| 396 |
} catch (MelderError) { \ |
| 397 |
praat_updateSelection (); \ |
| 398 |
throw; \ |
| 399 |
} \ |
| 400 |
praat_updateSelection (); \ |
| 401 |
} \ |
| 402 |
} |
| 403 |
|
| 404 |
#define END_NO_NEW_DATA \ |
| 405 |
} \ |
| 406 |
} catch (MelderError) { \ |
| 407 |
throw; \ |
| 408 |
} \ |
| 409 |
} \ |
| 410 |
} |
| 411 |
|
| 412 |
#define DIRECT(proc) \ |
| 413 |
extern "C" void proc (UiForm, integer, Stackel, conststring32, Interpreter interpreter, conststring32, bool, void *, Editor); \ |
| 414 |
void proc (UiForm, integer, Stackel, conststring32, [[maybe_unused]] Interpreter interpreter, conststring32, bool, void *, Editor) { \ |
| 415 |
[[maybe_unused]] integer IOBJECT = 0; \ |
| 416 |
{ { \ |
| 417 |
try { |
| 418 |
|
| 419 |
#define FORM_READ(proc,title,help,allowMult) \ |
| 420 |
extern "C" void proc (UiForm sendingForm, integer, structStackel args [], conststring32 sendingString, \ |
| 421 |
Interpreter interpreter, conststring32 invokingButtonTitle, bool, void *okClosure, Editor optionalEditor); \ |
| 422 |
void proc (UiForm _sendingForm_, integer _narg_, structStackel _args_ [], conststring32 _sendingString_, \ |
| 423 |
Interpreter interpreter, conststring32 _invokingButtonTitle_, bool, void *_okClosure_, Editor _optionalEditor_) \ |
| 424 |
{ \ |
| 425 |
{ static autoUiForm _dia_; \ |
| 426 |
if (! _dia_) \ |
| 427 |
_dia_ = UiInfile_create (theCurrentPraatApplication -> topShell, _optionalEditor_, title, proc, _okClosure_, _invokingButtonTitle_, help, allowMult); \ |
| 428 |
if (_narg_ < 0) UiForm_info (_dia_.get(), _narg_); else if (! _args_ && ! _sendingForm_ && ! _sendingString_) { \ |
| 429 |
UiInfile_do (_dia_.get()); \ |
| 430 |
} else { \ |
| 431 |
try { \ |
| 432 |
MelderFile file; \ |
| 433 |
[[maybe_unused]] integer IOBJECT = 0; \ |
| 434 |
structMelderFile _file2 { }; /* don't move this into an inner scope, because the contents of a local variable don't persist into the outer scope */ \ |
| 435 |
if (_args_) { \ |
| 436 |
Melder_require (_narg_ == 1, \ |
| 437 |
U"Command requires exactly 1 argument, the name of the file to read, instead of the given ", _narg_, U" arguments."); \ |
| 438 |
Melder_require (_args_ [1]. which == Stackel_STRING, \ |
| 439 |
U"The file name argument should be a string, not ", _args_ [1]. whichText(), U"."); \ |
| 440 |
Melder_relativePathToFile (_args_ [1]. getString(), & _file2); \ |
| 441 |
file = & _file2; \ |
| 442 |
} else if (_sendingString_) { \ |
| 443 |
Melder_relativePathToFile (_sendingString_, & _file2); \ |
| 444 |
file = & _file2; \ |
| 445 |
} else { \ |
| 446 |
file = UiFile_getFile (_dia_.get()); \ |
| 447 |
} |
| 448 |
|
| 449 |
#define FORM_SAVE(proc,title,help,ext) \ |
| 450 |
extern "C" void proc (UiForm sendingForm, integer, structStackel args [], conststring32 sendingString, \ |
| 451 |
Interpreter interpreter, conststring32 invokingButtonTitle, bool, void *okClosure, Editor optionalEditor); \ |
| 452 |
void proc (UiForm _sendingForm_, integer _narg_, Stackel _args_, conststring32 _sendingString_, \ |
| 453 |
[[maybe_unused]] Interpreter _interpreter_, conststring32 _invokingButtonTitle_, bool, void *_okClosure_, Editor _optionalEditor_) \ |
| 454 |
{ \ |
| 455 |
{ static autoUiForm _dia_; \ |
| 456 |
if (! _dia_) \ |
| 457 |
_dia_ = UiOutfile_create (theCurrentPraatApplication -> topShell, _optionalEditor_, title, proc, _okClosure_, _invokingButtonTitle_, help); \ |
| 458 |
if (_narg_ < 0) UiForm_info (_dia_.get(), _narg_); else if (! _args_ && ! _sendingForm_ && ! _sendingString_) { \ |
| 459 |
praat_write_do (_dia_.get(), ext); \ |
| 460 |
} else { \ |
| 461 |
try { \ |
| 462 |
MelderFile file; \ |
| 463 |
[[maybe_unused]] integer IOBJECT = 0; \ |
| 464 |
structMelderFile _file2 { }; /* don't move this into an inner scope, because the contents of a local variable don't persist into the outer scope */ \ |
| 465 |
if (_args_) { \ |
| 466 |
Melder_require (_narg_ == 1, \ |
| 467 |
U"Command requires exactly 1 argument, the name of the file to write, instead of the given ", _narg_, U" arguments."); \ |
| 468 |
Melder_require (_args_ [1]. which == Stackel_STRING, \ |
| 469 |
U"The file name argument should be a string, not ", _args_ [1]. whichText(), U"."); \ |
| 470 |
Melder_relativePathToFile (_args_ [1]. getString(), & _file2); \ |
| 471 |
file = & _file2; \ |
| 472 |
} else if (_sendingString_) { \ |
| 473 |
Melder_relativePathToFile (_sendingString_, & _file2); \ |
| 474 |
file = & _file2; \ |
| 475 |
} else { \ |
| 476 |
file = UiFile_getFile (_dia_.get()); \ |
| 477 |
} |
| 478 |
|
| 479 |
#define CREATE_MULTIPLE |
| 480 |
#define CREATE_MULTIPLE_END \ |
| 481 |
if (interpreter) \ |
| 482 |
interpreter -> returnType = kInterpreter_ReturnType::OBJECT_; \ |
| 483 |
END_WITH_NEW_DATA |
| 484 |
|
| 485 |
#define CREATE_ONE |
| 486 |
#define CREATE_ONE_END(...) \ |
| 487 |
praat_new (result.move(), __VA_ARGS__); \ |
| 488 |
CREATE_MULTIPLE_END |
| 489 |
|
| 490 |
#define FIND_ONE(klas) \ |
| 491 |
klas me = nullptr; \ |
| 492 |
LOOP { if (CLASS == class##klas || Thing_isSubclass (CLASS, class##klas)) me = (klas) OBJECT; break; } |
| 493 |
|
| 494 |
#define FIND_ONE_WITH_IOBJECT(klas) \ |
| 495 |
klas me = nullptr; integer _klas_position = 0; \ |
| 496 |
LOOP { if (CLASS == class##klas) me = (klas) OBJECT, _klas_position = IOBJECT; break; } \ |
| 497 |
IOBJECT = _klas_position; |
| 498 |
|
| 499 |
#define FIND_ONE_AND_ONE(klas1,klas2) \ |
| 500 |
klas1 me = nullptr; klas2 you = nullptr; \ |
| 501 |
LOOP { if (CLASS == class##klas1) me = (klas1) OBJECT; else if (CLASS == class##klas2) you = (klas2) OBJECT; \ |
| 502 |
if (me && you) break; } |
| 503 |
|
| 504 |
#define FIND_ONE_AND_ONE_WITH_IOBJECT(klas1,klas2) \ |
| 505 |
klas1 me = nullptr; klas2 you = nullptr; integer _klas1_position = 0; \ |
| 506 |
LOOP { if (CLASS == class##klas1) me = (klas1) OBJECT, _klas1_position = IOBJECT; \ |
| 507 |
else if (CLASS == class##klas2) you = (klas2) OBJECT; \ |
| 508 |
if (me && you) break; } \ |
| 509 |
IOBJECT = _klas1_position; |
| 510 |
|
| 511 |
#define FIND_TWO(klas) \ |
| 512 |
klas me = nullptr, you = nullptr; \ |
| 513 |
LOOP if (CLASS == class##klas || Thing_isSubclass (CLASS, class##klas)) (me ? you : me) = (klas) OBJECT; |
| 514 |
|
| 515 |
#define FIND_TWO_AND_ONE(klas1,klas2) \ |
| 516 |
klas1 me = nullptr, you = nullptr; klas2 him = nullptr; \ |
| 517 |
LOOP { if (CLASS == class##klas1) (me ? you : me) = (klas1) OBJECT; else if (CLASS == class##klas2) him = (klas2) OBJECT; \ |
| 518 |
if (me && you && him) break; } |
| 519 |
|
| 520 |
#define FIND_ONE_AND_TWO(klas1,klas2) \ |
| 521 |
klas1 me = nullptr; klas2 you = nullptr, him = nullptr; \ |
| 522 |
LOOP { if (CLASS == class##klas1) me = (klas1) OBJECT; else if (CLASS == class##klas2) (you ? him : you) = (klas2) OBJECT; \ |
| 523 |
if (me && you && him) break; } |
| 524 |
|
| 525 |
#define FIND_ONE_AND_GENERIC(klas1,klas2) \ |
| 526 |
klas1 me = nullptr; klas2 you = nullptr; \ |
| 527 |
LOOP { if (CLASS == class##klas1) me = (klas1) OBJECT; \ |
| 528 |
else if (Thing_isSubclass (CLASS, class##klas2)) { you = (klas2) OBJECT; } } \ |
| 529 |
Melder_assert (me && you); |
| 530 |
|
| 531 |
#define FIND_ONE_AND_ONE_AND_ONE(klas1,klas2,klas3) \ |
| 532 |
klas1 me = nullptr; klas2 you = nullptr; klas3 him = nullptr; \ |
| 533 |
LOOP { if (CLASS == class##klas1) me = (klas1) OBJECT; else if (CLASS == class##klas2) you = (klas2) OBJECT; \ |
| 534 |
else if (CLASS == class##klas3) him = (klas3) OBJECT; \ |
| 535 |
if (me && you && him) break; } |
| 536 |
|
| 537 |
#define FIND_ONE_AND_ONE_AND_ONE_WITH_IOBJECT(klas1,klas2,klas3) \ |
| 538 |
klas1 me = nullptr; klas2 you = nullptr; klas3 him = nullptr; integer _klas1_position = 0;\ |
| 539 |
LOOP { if (CLASS == class##klas1) me = (klas1) OBJECT, _klas1_position = IOBJECT; \ |
| 540 |
else if (CLASS == class##klas2) you = (klas2) OBJECT; \ |
| 541 |
else if (CLASS == class##klas3) him = (klas3) OBJECT; \ |
| 542 |
if (me && you && him) break; } \ |
| 543 |
IOBJECT = _klas1_position; |
| 544 |
|
| 545 |
#define FIND_1_1_1_1(klas1,klas2,klas3,klas4) \ |
| 546 |
klas1 me = nullptr; klas2 you = nullptr; klas3 him = nullptr; klas4 she = nullptr; \ |
| 547 |
LOOP { if (CLASS == class##klas1) me = (klas1) OBJECT; else if (CLASS == class##klas2) you = (klas2) OBJECT; \ |
| 548 |
else if (CLASS == class##klas3) him = (klas3) OBJECT; else if (CLASS == class##klas4) she = (klas4) OBJECT; \ |
| 549 |
if (me && you && him && she) break; } |
| 550 |
|
| 551 |
#define FIND_1_1_1_1_WITH_IOBJECT(klas1,klas2,klas3,klas4) \ |
| 552 |
klas1 me = nullptr; klas2 you = nullptr; klas3 him = nullptr; klas4 she = nullptr; integer _klas1_position = 0; \ |
| 553 |
LOOP { if (CLASS == class##klas1) me = (klas1) OBJECT, _klas1_position = IOBJECT; else if (CLASS == class##klas2) you = (klas2) OBJECT; \ |
| 554 |
else if (CLASS == class##klas3) him = (klas3) OBJECT; else if (CLASS == class##klas4) she = (klas4) OBJECT; \ |
| 555 |
if (me && you && him && she) break; } \ |
| 556 |
IOBJECT = _klas1_position; |
| 557 |
|
| 558 |
#define FIND_ALL(klas) \ |
| 559 |
OrderedOf<struct##klas> list; \ |
| 560 |
LOOP { iam_LOOP (klas); list. addItem_ref (me); } |
| 561 |
|
| 562 |
#define FIND_ALL_LISTED(klas,listClass) \ |
| 563 |
auto##listClass list = listClass##_create (); \ |
| 564 |
LOOP { iam_LOOP (klas); list -> addItem_ref (me); } |
| 565 |
|
| 566 |
#define FIND_ONE_AND_ALL(klas1,klas2) \ |
| 567 |
OrderedOf<struct##klas2> list; klas1 me = nullptr; \ |
| 568 |
LOOP { if (CLASS == class##klas2) list. addItem_ref ((klas2) OBJECT); else if (CLASS == class##klas1) me = (klas1) OBJECT; } |
| 569 |
|
| 570 |
#define FIND_ONE_AND_ALL_LISTED(klas1,klas2,listClass) \ |
| 571 |
auto##listClass list = listClass##_create (); klas1 me = nullptr; \ |
| 572 |
LOOP { if (CLASS == class##klas2) list -> addItem_ref ((klas2) OBJECT); else if (CLASS == class##klas1) me = (klas1) OBJECT; } |
| 573 |
|
| 574 |
#define FIND_ONE_AND_ONE_AND_ALL(klas1,klas2,klas3) \ |
| 575 |
OrderedOf<struct##klas3> list; klas1 me = nullptr; klas2 you = nullptr; \ |
| 576 |
LOOP { if (CLASS == class##klas3) list. addItem_ref ((klas3) OBJECT); else if (CLASS == class##klas1) me = (klas1) OBJECT; \ |
| 577 |
else if (CLASS == class##klas2) you = (klas2) OBJECT; } |
| 578 |
|
| 579 |
/* |
| 580 |
INFO |
| 581 |
*/ |
| 582 |
|
| 583 |
#define INFO_NONE |
| 584 |
#define INFO_NONE_END \ |
| 585 |
if (interpreter) \ |
| 586 |
interpreter -> returnType = kInterpreter_ReturnType::STRING_; \ |
| 587 |
END_NO_NEW_DATA |
| 588 |
|
| 589 |
#define INFO_ONE(klas) FIND_ONE (klas) |
| 590 |
#define INFO_ONE_END \ |
| 591 |
if (interpreter) \ |
| 592 |
interpreter -> returnType = kInterpreter_ReturnType::STRING_; \ |
| 593 |
END_NO_NEW_DATA |
| 594 |
|
| 595 |
#define INFO_ONE_AND_ONE(klas1,klas2) \ |
| 596 |
FIND_ONE_AND_ONE (klas1, klas2) |
| 597 |
#define INFO_ONE_AND_ONE_END \ |
| 598 |
if (interpreter) \ |
| 599 |
interpreter -> returnType = kInterpreter_ReturnType::STRING_; \ |
| 600 |
END_NO_NEW_DATA |
| 601 |
|
| 602 |
#define INFO_TWO(klas) \ |
| 603 |
FIND_TWO (klas) |
| 604 |
#define INFO_TWO_END \ |
| 605 |
if (interpreter) \ |
| 606 |
interpreter -> returnType = kInterpreter_ReturnType::STRING_; \ |
| 607 |
END_NO_NEW_DATA |
| 608 |
|
| 609 |
#define INFO_ONE_AND_ONE_AND_ONE(klas1,klas2,klas3) \ |
| 610 |
FIND_ONE_AND_ONE_AND_ONE (klas1, klas2, klas3) |
| 611 |
#define INFO_ONE_AND_ONE_AND_ONE_END \ |
| 612 |
if (interpreter) \ |
| 613 |
interpreter -> returnType = kInterpreter_ReturnType::STRING_; \ |
| 614 |
END_NO_NEW_DATA |
| 615 |
|
| 616 |
#define HELP(page) \ |
| 617 |
Melder_help (page); \ |
| 618 |
END_NO_NEW_DATA |
| 619 |
|
| 620 |
/* |
| 621 |
Parts. |
| 622 |
*/ |
| 623 |
|
| 624 |
#define EACH_BEGIN__(klas) \ |
| 625 |
LOOP { \ |
| 626 |
iam_LOOP (klas); |
| 627 |
#define EACH_END__ \ |
| 628 |
} \ |
| 629 |
|
| 630 |
#define FIRST_WEAK_BEGIN \ |
| 631 |
try { |
| 632 |
#define FIRST_WEAK_END \ |
| 633 |
} catch (MelderError) { \ |
| 634 |
praat_dataChanged (me); \ |
| 635 |
throw; \ |
| 636 |
} \ |
| 637 |
praat_dataChanged (me); |
| 638 |
|
| 639 |
/* |
| 640 |
PLAY |
| 641 |
*/ |
| 642 |
|
| 643 |
#define PLAY_END__ \ |
| 644 |
END_NO_NEW_DATA |
| 645 |
|
| 646 |
#define PLAY_NONE |
| 647 |
#define PLAY_NONE_END \ |
| 648 |
PLAY_END__ |
| 649 |
|
| 650 |
#define PLAY_EACH(klas) \ |
| 651 |
int _numberOfSelectedSounds = 0; \ |
| 652 |
LOOP { \ |
| 653 |
_numberOfSelectedSounds ++; \ |
| 654 |
} \ |
| 655 |
if (_numberOfSelectedSounds > 1) \ |
| 656 |
MelderAudio_setOutputMaximumAsynchronicity (kMelder_asynchronicityLevel::INTERRUPTABLE); \ |
| 657 |
EACH_BEGIN__ (klas) |
| 658 |
#define PLAY_EACH_END \ |
| 659 |
EACH_END__ \ |
| 660 |
if (_numberOfSelectedSounds > 1) \ |
| 661 |
MelderAudio_setOutputMaximumAsynchronicity (kMelder_asynchronicityLevel::ASYNCHRONOUS); \ |
| 662 |
PLAY_END__ |
| 663 |
|
| 664 |
#define PLAY_ONE(klas) \ |
| 665 |
FIND_ONE (klas) |
| 666 |
#define PLAY_ONE_END \ |
| 667 |
PLAY_END__ |
| 668 |
|
| 669 |
#define PLAY_ONE_AND_ONE(klas1,klas2) \ |
| 670 |
FIND_ONE_AND_ONE (klas1, klas2) |
| 671 |
#define PLAY_ONE_AND_ONE_END \ |
| 672 |
PLAY_END__ |
| 673 |
|
| 674 |
/* |
| 675 |
RECORD |
| 676 |
*/ |
| 677 |
|
| 678 |
#define RECORD_ONE |
| 679 |
#define RECORD_ONE_END(...) \ |
| 680 |
praat_new (result.move(), __VA_ARGS__); \ |
| 681 |
CREATE_MULTIPLE_END |
| 682 |
|
| 683 |
/* |
| 684 |
DRAW |
| 685 |
*/ |
| 686 |
|
| 687 |
#define GRAPHICS_BEGIN__ \ |
| 688 |
autoPraatPictureOpen picture; |
| 689 |
#define GRAPHICS_END__ \ |
| 690 |
END_NO_NEW_DATA |
| 691 |
|
| 692 |
#define GRAPHICS_NONE \ |
| 693 |
GRAPHICS_BEGIN__ |
| 694 |
#define GRAPHICS_NONE_END \ |
| 695 |
GRAPHICS_END__ |
| 696 |
|
| 697 |
#define GRAPHICS_EACH(klas) \ |
| 698 |
GRAPHICS_BEGIN__ \ |
| 699 |
EACH_BEGIN__ (klas) |
| 700 |
#define GRAPHICS_EACH_END \ |
| 701 |
EACH_END__ \ |
| 702 |
GRAPHICS_END__ |
| 703 |
|
| 704 |
#define GRAPHICS_ONE_AND_ONE(klas1,klas2) \ |
| 705 |
GRAPHICS_BEGIN__ \ |
| 706 |
FIND_ONE_AND_ONE (klas1, klas2) |
| 707 |
#define GRAPHICS_ONE_AND_ONE_END \ |
| 708 |
GRAPHICS_END__ |
| 709 |
|
| 710 |
#define GRAPHICS_TWO(klas) \ |
| 711 |
GRAPHICS_BEGIN__ \ |
| 712 |
FIND_TWO (klas) |
| 713 |
#define GRAPHICS_TWO_END \ |
| 714 |
GRAPHICS_END__ |
| 715 |
|
| 716 |
#define GRAPHICS_TWO_AND_ONE(klas1,klas2) \ |
| 717 |
GRAPHICS_BEGIN__ \ |
| 718 |
FIND_TWO_AND_ONE (klas1, klas2) |
| 719 |
#define GRAPHICS_TWO_AND_ONE_END \ |
| 720 |
GRAPHICS_END__ |
| 721 |
|
| 722 |
#define MOVIE_ONE(klas,title,width,height) \ |
| 723 |
Graphics graphics = Movie_create (title, width, height); \ |
| 724 |
FIND_ONE (klas) |
| 725 |
#define MOVIE_ONE_END END_NO_NEW_DATA |
| 726 |
|
| 727 |
#define MOVIE_ONE_AND_ONE(klas1,klas2,title,width,height) \ |
| 728 |
Graphics graphics = Movie_create (title, width, height); \ |
| 729 |
FIND_ONE_AND_ONE (klas1, klas2) |
| 730 |
#define MOVIE_ONE_AND_ONE_END END_NO_NEW_DATA |
| 731 |
|
| 732 |
#define MOVIE_ONE_AND_ONE_AND_ONE(klas1,klas2,klas3,title,width,height) \ |
| 733 |
Graphics graphics = Movie_create (title, width, height); \ |
| 734 |
FIND_ONE_AND_ONE_AND_ONE (klas1, klas2, klas3) |
| 735 |
#define MOVIE_ONE_AND_ONE_AND_ONE_END END_NO_NEW_DATA |
| 736 |
|
| 737 |
/* |
| 738 |
QUERY |
| 739 |
*/ |
| 740 |
|
| 741 |
#define FOR_REAL__(...) \ |
| 742 |
if (interpreter) \ |
| 743 |
interpreter -> returnType = kInterpreter_ReturnType::REAL_; \ |
| 744 |
Melder_information (result, __VA_ARGS__); |
| 745 |
|
| 746 |
#define FOR_INTEGER__(...) \ |
| 747 |
if (interpreter) \ |
| 748 |
interpreter -> returnType = kInterpreter_ReturnType::INTEGER_; \ |
| 749 |
Melder_information (double (result), __VA_ARGS__); |
| 750 |
|
| 751 |
#define FOR_BOOLEAN__(...) \ |
| 752 |
if (interpreter) \ |
| 753 |
interpreter -> returnType = kInterpreter_ReturnType::BOOLEAN_; \ |
| 754 |
Melder_information (double (result), __VA_ARGS__); |
| 755 |
|
| 756 |
#define FOR_COMPLEX__(...) \ |
| 757 |
if (interpreter) \ |
| 758 |
interpreter -> returnType = kInterpreter_ReturnType::STRING_; /* TODO: make true complex types in script */ \ |
| 759 |
Melder_information (result, __VA_ARGS__); |
| 760 |
|
| 761 |
#define FOR_STRING__ \ |
| 762 |
if (interpreter) \ |
| 763 |
interpreter -> returnType = kInterpreter_ReturnType::STRING_; \ |
| 764 |
Melder_information (result); |
| 765 |
|
| 766 |
#define FOR_AUTOSTRING__ \ |
| 767 |
if (interpreter) \ |
| 768 |
interpreter -> returnType = kInterpreter_ReturnType::STRING_; \ |
| 769 |
Melder_information (result.get()); |
| 770 |
|
| 771 |
#define QUERY_END__ \ |
| 772 |
END_NO_NEW_DATA |
| 773 |
|
| 774 |
#define QUERY_FOR_REAL_END__(...) \ |
| 775 |
FOR_REAL__ (__VA_ARGS__) \ |
| 776 |
QUERY_END__ |
| 777 |
|
| 778 |
#define QUERY_WEAK_FOR_REAL_END__(...) \ |
| 779 |
FOR_REAL__ (__VA_ARGS__) \ |
| 780 |
FIRST_WEAK_END \ |
| 781 |
QUERY_END__ |
| 782 |
|
| 783 |
#define QUERY_FOR_INTEGER_END__(...) \ |
| 784 |
FOR_INTEGER__ (__VA_ARGS__) \ |
| 785 |
QUERY_END__ |
| 786 |
|
| 787 |
#define QUERY_WEAK_FOR_INTEGER_END__(...) \ |
| 788 |
FOR_INTEGER__ (__VA_ARGS__) \ |
| 789 |
FIRST_WEAK_END \ |
| 790 |
QUERY_END__ |
| 791 |
|
| 792 |
#define QUERY_FOR_BOOLEAN_END__(...) \ |
| 793 |
FOR_BOOLEAN__ (__VA_ARGS__) \ |
| 794 |
QUERY_END__ |
| 795 |
|
| 796 |
#define QUERY_WEAK_FOR_BOOLEAN_END__(...) \ |
| 797 |
FOR_BOOLEAN__ (__VA_ARGS__) \ |
| 798 |
FIRST_WEAK_END \ |
| 799 |
QUERY_END__ |
| 800 |
|
| 801 |
#define QUERY_FOR_COMPLEX_END__(...) \ |
| 802 |
FOR_COMPLEX__ (__VA_ARGS__) \ |
| 803 |
QUERY_END__ |
| 804 |
|
| 805 |
#define QUERY_WEAK_FOR_COMPLEX_END__(...) \ |
| 806 |
FOR_COMPLEX__ (__VA_ARGS__) \ |
| 807 |
FIRST_WEAK_END \ |
| 808 |
QUERY_END__ |
| 809 |
|
| 810 |
#define QUERY_FOR_STRING_END__ \ |
| 811 |
FOR_STRING__ \ |
| 812 |
QUERY_END__ |
| 813 |
|
| 814 |
#define QUERY_FOR_AUTOSTRING_END__ \ |
| 815 |
FOR_AUTOSTRING__ \ |
| 816 |
QUERY_END__ |
| 817 |
|
| 818 |
#define QUERY_WEAK_FOR_STRING_END__ \ |
| 819 |
FOR_STRING__ \ |
| 820 |
FIRST_WEAK_END \ |
| 821 |
QUERY_END__ |
| 822 |
|
| 823 |
#define QUERY_GRAPHICS_FOR_REAL |
| 824 |
#define QUERY_GRAPHICS_FOR_REAL_END(...) \ |
| 825 |
QUERY_FOR_REAL_END__ (__VA_ARGS__) |
| 826 |
|
| 827 |
#define QUERY_ONE_FOR_REAL(klas) \ |
| 828 |
FIND_ONE (klas) |
| 829 |
#define QUERY_ONE_FOR_REAL_END(...) \ |
| 830 |
QUERY_FOR_REAL_END__ (__VA_ARGS__) |
| 831 |
|
| 832 |
#define QUERY_ONE_WEAK_FOR_REAL(klas) \ |
| 833 |
FIND_ONE (klas) \ |
| 834 |
FIRST_WEAK_BEGIN |
| 835 |
#define QUERY_ONE_WEAK_FOR_REAL_END(...) \ |
| 836 |
QUERY_WEAK_FOR_REAL_END__ (__VA_ARGS__) |
| 837 |
|
| 838 |
#define QUERY_ONE_FOR_INTEGER(klas) \ |
| 839 |
FIND_ONE (klas) |
| 840 |
#define QUERY_ONE_FOR_INTEGER_END(...) \ |
| 841 |
QUERY_FOR_INTEGER_END__ (__VA_ARGS__) |
| 842 |
|
| 843 |
#define QUERY_ONE_WEAK_FOR_INTEGER(klas) \ |
| 844 |
FIND_ONE (klas) \ |
| 845 |
FIRST_WEAK_BEGIN |
| 846 |
#define QUERY_ONE_WEAK_FOR_INTEGER_END(...) \ |
| 847 |
QUERY_WEAK_FOR_INTEGER_END__ (__VA_ARGS__) |
| 848 |
|
| 849 |
#define QUERY_ONE_FOR_BOOLEAN(klas) \ |
| 850 |
FIND_ONE (klas) |
| 851 |
#define QUERY_ONE_FOR_BOOLEAN_END(...) \ |
| 852 |
QUERY_FOR_BOOLEAN_END__ (__VA_ARGS__) |
| 853 |
|
| 854 |
#define QUERY_ONE_WEAK_FOR_BOOLEAN(klas) \ |
| 855 |
FIND_ONE (klas) \ |
| 856 |
FIRST_WEAK_BEGIN |
| 857 |
#define QUERY_ONE_WEAK_FOR_BOOLEAN_END(...) \ |
| 858 |
QUERY_WEAK_FOR_BOOLEAN_END__ (__VA_ARGS__) |
| 859 |
|
| 860 |
#define QUERY_ONE_AND_ONE_FOR_REAL(klas1,klas2) \ |
| 861 |
FIND_ONE_AND_ONE (klas1, klas2) |
| 862 |
#define QUERY_ONE_AND_ONE_FOR_REAL_END(...) \ |
| 863 |
QUERY_FOR_REAL_END__ (__VA_ARGS__) |
| 864 |
|
| 865 |
#define QUERY_ONE_WEAK_AND_ONE_FOR_REAL(klas1,klas2) \ |
| 866 |
FIND_ONE_AND_ONE (klas1, klas2) \ |
| 867 |
FIRST_WEAK_BEGIN |
| 868 |
#define QUERY_ONE_WEAK_AND_ONE_FOR_REAL_END(...) \ |
| 869 |
QUERY_WEAK_FOR_REAL_END__ (__VA_ARGS__) |
| 870 |
|
| 871 |
#define QUERY_ONE_AND_ONE_FOR_INTEGER(klas1,klas2) \ |
| 872 |
FIND_ONE_AND_ONE (klas1, klas2) |
| 873 |
#define QUERY_ONE_AND_ONE_FOR_INTEGER_END(...) \ |
| 874 |
QUERY_FOR_INTEGER_END__ (__VA_ARGS__) |
| 875 |
|
| 876 |
#define QUERY_ONE_WEAK_AND_ONE_FOR_INTEGER(klas1,klas2) \ |
| 877 |
FIND_ONE_AND_ONE (klas1, klas2) \ |
| 878 |
FIRST_WEAK_BEGIN |
| 879 |
#define QUERY_ONE_WEAK_AND_ONE_FOR_INTEGER_END(...) \ |
| 880 |
QUERY_WEAK_FOR_INTEGER_END__ (__VA_ARGS__) |
| 881 |
|
| 882 |
#define QUERY_ONE_AND_ONE_FOR_BOOLEAN(klas1,klas2) \ |
| 883 |
FIND_ONE_AND_ONE (klas1, klas2) |
| 884 |
#define QUERY_ONE_AND_ONE_FOR_BOOLEAN_END(...) \ |
| 885 |
QUERY_FOR_BOOLEAN_END__ (__VA_ARGS__) |
| 886 |
|
| 887 |
#define QUERY_ONE_WEAK_AND_ONE_FOR_BOOLEAN(klas1,klas2) \ |
| 888 |
FIND_ONE_AND_ONE (klas1, klas2) \ |
| 889 |
FIRST_WEAK_BEGIN |
| 890 |
#define QUERY_ONE_WEAK_AND_ONE_FOR_BOOLEAN_END(...) \ |
| 891 |
QUERY_WEAK_FOR_BOOLEAN_END__ (__VA_ARGS__) |
| 892 |
|
| 893 |
#define QUERY_ONE_AND_ONE_AND_ONE_FOR_REAL(klas1,klas2,klas3) \ |
| 894 |
FIND_ONE_AND_ONE_AND_ONE (klas1, klas2, klas3) |
| 895 |
#define QUERY_ONE_AND_ONE_AND_ONE_FOR_REAL_END(...) \ |
| 896 |
QUERY_FOR_REAL_END__ (__VA_ARGS__) |
| 897 |
|
| 898 |
#define QUERY_TWO_FOR_REAL(klas) \ |
| 899 |
FIND_TWO (klas) |
| 900 |
#define QUERY_TWO_FOR_REAL_END(...) \ |
| 901 |
QUERY_FOR_REAL_END__ (__VA_ARGS__) |
| 902 |
|
| 903 |
#define QUERY_TWO_AND_ONE_FOR_REAL(klas1,klas2) \ |
| 904 |
FIND_TWO_AND_ONE (klas1, klas2) |
| 905 |
#define QUERY_TWO_AND_ONE_FOR_REAL_END(...) \ |
| 906 |
QUERY_FOR_REAL_END__ (__VA_ARGS__) |
| 907 |
|
| 908 |
#define QUERY_ONE_AND_ALL_FOR_REAL(klas1,klas2) \ |
| 909 |
FIND_ONE_AND_ALL (klas1, klas2) |
| 910 |
#define QUERY_ONE_AND_ALL_FOR_REAL_END(...) \ |
| 911 |
QUERY_FOR_REAL_END__ (__VA_ARGS__) |
| 912 |
|
| 913 |
#define QUERY_ONE_AND_ONE_AND_ALL_FOR_REAL(klas1,klas2,klas3) \ |
| 914 |
FIND_ONE_AND_ONE_AND_ALL (klas1, klas2, klas3) |
| 915 |
#define QUERY_ONE_AND_ONE_AND_ALL_FOR_REAL_END(...) \ |
| 916 |
QUERY_FOR_REAL_END__ (__VA_ARGS__) |
| 917 |
|
| 918 |
#define QUERY_NONE_FOR_COMPLEX |
| 919 |
#define QUERY_NONE_FOR_COMPLEX_END(...) \ |
| 920 |
QUERY_FOR_COMPLEX_END__ (__VA_ARGS__) |
| 921 |
|
| 922 |
#define QUERY_NONE_FOR_REAL |
| 923 |
#define QUERY_NONE_FOR_REAL_END(...) \ |
| 924 |
QUERY_FOR_REAL_END__ (__VA_ARGS__) |
| 925 |
|
| 926 |
#define QUERY_ONE_FOR_COMPLEX(klas) \ |
| 927 |
FIND_ONE (klas) |
| 928 |
#define QUERY_ONE_FOR_COMPLEX_END(...) \ |
| 929 |
QUERY_FOR_COMPLEX_END__ (__VA_ARGS__) |
| 930 |
|
| 931 |
#define QUERY_ONE_FOR_STRING(klas) \ |
| 932 |
FIND_ONE (klas) |
| 933 |
#define QUERY_ONE_FOR_STRING_END \ |
| 934 |
QUERY_FOR_STRING_END__ |
| 935 |
|
| 936 |
#define QUERY_ONE_FOR_AUTOSTRING(klas) \ |
| 937 |
FIND_ONE (klas) |
| 938 |
#define QUERY_ONE_FOR_AUTOSTRING_END \ |
| 939 |
QUERY_FOR_AUTOSTRING_END__ |
| 940 |
|
| 941 |
#define QUERY_ONE_WEAK_FOR_STRING(klas) \ |
| 942 |
FIND_ONE (klas) \ |
| 943 |
FIRST_WEAK_BEGIN |
| 944 |
#define QUERY_ONE_WEAK_FOR_STRING_END \ |
| 945 |
QUERY_WEAK_FOR_STRING_END__ |
| 946 |
|
| 947 |
#define QUERY_ONE_FOR_REAL_VECTOR(klas) \ |
| 948 |
FIND_ONE (klas) |
| 949 |
#define QUERY_ONE_FOR_REAL_VECTOR_END \ |
| 950 |
if (interpreter) { \ |
| 951 |
interpreter -> returnType = kInterpreter_ReturnType::REALVECTOR_; \ |
| 952 |
interpreter -> returnedRealVector = result.move(); \ |
| 953 |
} else \ |
| 954 |
Melder_information (constVECVU (result.all())); \ |
| 955 |
QUERY_END__ |
| 956 |
|
| 957 |
#define QUERY_ONE_FOR_MATRIX(klas) \ |
| 958 |
FIND_ONE (klas) |
| 959 |
#define QUERY_ONE_FOR_MATRIX_END \ |
| 960 |
if (interpreter) { \ |
| 961 |
interpreter -> returnType = kInterpreter_ReturnType::REALMATRIX_; \ |
| 962 |
interpreter -> returnedRealMatrix = result.move(); \ |
| 963 |
} else \ |
| 964 |
Melder_information (constMATVU (result.all())); \ |
| 965 |
QUERY_END__ |
| 966 |
|
| 967 |
#define QUERY_ONE_FOR_STRING_ARRAY(klas) \ |
| 968 |
FIND_ONE (klas) |
| 969 |
#define QUERY_ONE_FOR_STRING_ARRAY_END \ |
| 970 |
if (interpreter) { \ |
| 971 |
interpreter -> returnType = kInterpreter_ReturnType::STRINGARRAY_; \ |
| 972 |
interpreter -> returnedStringArray = result.move(); \ |
| 973 |
} else \ |
| 974 |
Melder_information (constSTRVEC (result.get())); \ |
| 975 |
QUERY_END__ |
| 976 |
|
| 977 |
#define QUERY_ONE_AND_ONE_FOR_STRING(klas1,klas2) \ |
| 978 |
FIND_ONE_AND_ONE (klas1, klas2) |
| 979 |
#define QUERY_ONE_AND_ONE_FOR_STRING_END \ |
| 980 |
QUERY_FOR_STRING_END__ |
| 981 |
|
| 982 |
|
| 983 |
/* |
| 984 |
MODIFY |
| 985 |
*/ |
| 986 |
|
| 987 |
#define MODIFY_END__ \ |
| 988 |
END_NO_NEW_DATA |
| 989 |
|
| 990 |
/* |
| 991 |
If there is no exception, the object will change fully. |
| 992 |
STRONG exception guarantee: if there is an exception, the object will not change at all. |
| 993 |
This includes cases in which there cannot be an exception. |
| 994 |
User interface optimization: if there is an exception, |
| 995 |
no praat_dataChanged() message will be sent to the editors. |
| 996 |
*/ |
| 997 |
#define FIRST_STRONG_BEGIN__ |
| 998 |
#define FIRST_STRONG_END__ \ |
| 999 |
praat_dataChanged (me); /* To be jumped over if there is an exception. */ |
| 1000 |
|
| 1001 |
/* |
| 1002 |
If there is no exception, the object will change fully. |
| 1003 |
WEAK exception guarantee: if there is an exception, the object may change, |
| 1004 |
although it will end up in a sort-of reasonable (at least inspectable) state. |
| 1005 |
To stay on the safe side, a praat_dataChanged() message is sent to the editors, |
| 1006 |
independently of whether there is an exception. |
| 1007 |
*/ |
| 1008 |
#define FIRST_WEAK_BEGIN__ \ |
| 1009 |
try { |
| 1010 |
#define FIRST_WEAK_END__ \ |
| 1011 |
} catch (MelderError) { \ |
| 1012 |
praat_dataChanged (me); /* Exception: data perhaps partially changed. */ \ |
| 1013 |
throw; \ |
| 1014 |
} \ |
| 1015 |
praat_dataChanged (me); /* No exception: data fully changed. */ |
| 1016 |
|
| 1017 |
#define MODIFY_EACH(klas) \ |
| 1018 |
EACH_BEGIN__ (klas) \ |
| 1019 |
FIRST_STRONG_BEGIN__ |
| 1020 |
#define MODIFY_EACH_END \ |
| 1021 |
FIRST_STRONG_END__ \ |
| 1022 |
EACH_END__ \ |
| 1023 |
MODIFY_END__ |
| 1024 |
|
| 1025 |
#define MODIFY_EACH_WEAK(klas) \ |
| 1026 |
EACH_BEGIN__ (klas) \ |
| 1027 |
FIRST_WEAK_BEGIN__ |
| 1028 |
#define MODIFY_EACH_WEAK_END \ |
| 1029 |
FIRST_WEAK_END__ \ |
| 1030 |
EACH_END__ \ |
| 1031 |
MODIFY_END__ |
| 1032 |
|
| 1033 |
#define MODIFY_ALL(klas) \ |
| 1034 |
FIND_ALL (klas) \ |
| 1035 |
FIRST_STRONG_BEGIN__ |
| 1036 |
#define MODIFY_ALL_END \ |
| 1037 |
for (integer i = 1; i <= list.size; i ++) \ |
| 1038 |
praat_dataChanged (list.at [i]); \ |
| 1039 |
MODIFY_END__ |
| 1040 |
|
| 1041 |
#define MODIFY_FIRST_OF_ONE_AND_ONE(klas1,klas2) \ |
| 1042 |
FIND_ONE_AND_ONE (klas1, klas2) \ |
| 1043 |
FIRST_STRONG_BEGIN__ |
| 1044 |
#define MODIFY_FIRST_OF_ONE_AND_ONE_END \ |
| 1045 |
FIRST_STRONG_END__ \ |
| 1046 |
MODIFY_END__ |
| 1047 |
|
| 1048 |
#define MODIFY_FIRST_OF_ONE_WEAK_AND_ONE(klas1,klas2) \ |
| 1049 |
FIND_ONE_AND_ONE (klas1, klas2) \ |
| 1050 |
FIRST_WEAK_BEGIN__ |
| 1051 |
#define MODIFY_FIRST_OF_ONE_WEAK_AND_ONE_END \ |
| 1052 |
FIRST_WEAK_END__ \ |
| 1053 |
MODIFY_END__ |
| 1054 |
|
| 1055 |
#define MODIFY_FIRST_OF_ONE_WEAK_AND_ONE_WITH_HISTORY(klas1,klas2,historyKlas) \ |
| 1056 |
FIND_ONE_AND_ONE (klas1, klas2) \ |
| 1057 |
auto##historyKlas history; \ |
| 1058 |
try { |
| 1059 |
#define MODIFY_FIRST_OF_ONE_WEAK_AND_ONE_WITH_HISTORY_END \ |
| 1060 |
} catch (MelderError) { \ |
| 1061 |
praat_dataChanged (me); /* e.g. in case of partial learning */ \ |
| 1062 |
Melder_flushError (); /* trickle down to save history */ \ |
| 1063 |
} \ |
| 1064 |
if (history) \ |
| 1065 |
praat_new (history.move(), my name.get()); \ |
| 1066 |
praat_dataChanged (me); /* No exception: data fully changed. */ \ |
| 1067 |
MODIFY_END__ |
| 1068 |
|
| 1069 |
#define MODIFY_FIRST_OF_ONE_AND_ONE_AND_ONE(klas1,klas2,klas3) \ |
| 1070 |
FIND_ONE_AND_ONE_AND_ONE (klas1, klas2, klas3) \ |
| 1071 |
FIRST_STRONG_BEGIN__ |
| 1072 |
#define MODIFY_FIRST_OF_ONE_AND_ONE_AND_ONE_END \ |
| 1073 |
FIRST_STRONG_END__ \ |
| 1074 |
MODIFY_END__ |
| 1075 |
|
| 1076 |
#define MODIFY_FIRST_OF_ONE_AND_TWO(klas1,klas2) \ |
| 1077 |
FIND_ONE_AND_TWO (klas1, klas2) \ |
| 1078 |
FIRST_STRONG_BEGIN__ |
| 1079 |
#define MODIFY_FIRST_OF_ONE_AND_TWO_END \ |
| 1080 |
FIRST_STRONG_END__ \ |
| 1081 |
MODIFY_END__ |
| 1082 |
|
| 1083 |
#define MODIFY_FIRST_OF_ONE_WEAK_AND_TWO(klas1,klas2) \ |
| 1084 |
FIND_ONE_AND_TWO (klas1, klas2) \ |
| 1085 |
FIRST_WEAK_BEGIN__ |
| 1086 |
#define MODIFY_FIRST_OF_ONE_WEAK_AND_TWO_END \ |
| 1087 |
FIRST_WEAK_END__ \ |
| 1088 |
MODIFY_END__ |
| 1089 |
|
| 1090 |
#define MODIFY_FIRST_OF_ONE_AND_ALL(klas1,klas2) \ |
| 1091 |
FIND_ONE_AND_ALL (klas1, klas2) \ |
| 1092 |
FIRST_STRONG_BEGIN__ |
| 1093 |
#define MODIFY_FIRST_OF_ONE_AND_ALL_END \ |
| 1094 |
FIRST_STRONG_END__ \ |
| 1095 |
MODIFY_END__ |
| 1096 |
|
| 1097 |
/* |
| 1098 |
CONVERT |
| 1099 |
*/ |
| 1100 |
|
| 1101 |
#define TO_MULTIPLE__ \ |
| 1102 |
if (interpreter) \ |
| 1103 |
interpreter -> returnType = kInterpreter_ReturnType::OBJECT_; \ |
| 1104 |
|
| 1105 |
#define TO_ONE__(...) \ |
| 1106 |
praat_new (result.move(), __VA_ARGS__); \ |
| 1107 |
TO_MULTIPLE__ |
| 1108 |
|
| 1109 |
#define CONVERT_END__ \ |
| 1110 |
END_WITH_NEW_DATA |
| 1111 |
|
| 1112 |
#define CONVERT_EACH_TO_MULTIPLE(klas) \ |
| 1113 |
EACH_BEGIN__ (klas) |
| 1114 |
#define CONVERT_EACH_TO_MULTIPLE_END \ |
| 1115 |
TO_MULTIPLE__ \ |
| 1116 |
EACH_END__ \ |
| 1117 |
CONVERT_END__ |
| 1118 |
|
| 1119 |
#define CONVERT_EACH_TO_ONE(klas) \ |
| 1120 |
EACH_BEGIN__ (klas) |
| 1121 |
#define CONVERT_EACH_TO_ONE_END(...) \ |
| 1122 |
TO_ONE__ (__VA_ARGS__) \ |
| 1123 |
EACH_END__ \ |
| 1124 |
CONVERT_END__ |
| 1125 |
|
| 1126 |
#define CONVERT_EACH_WEAK_TO_ONE(klas) \ |
| 1127 |
EACH_BEGIN__ (klas) \ |
| 1128 |
FIRST_WEAK_BEGIN |
| 1129 |
#define CONVERT_EACH_WEAK_TO_ONE_END(...) \ |
| 1130 |
TO_ONE__ (__VA_ARGS__) \ |
| 1131 |
FIRST_WEAK_END \ |
| 1132 |
EACH_END__ \ |
| 1133 |
CONVERT_END__ |
| 1134 |
|
| 1135 |
#define CONVERT_ONE_TO_MULTIPLE(klas) \ |
| 1136 |
FIND_ONE (klas) |
| 1137 |
#define CONVERT_ONE_TO_MULTIPLE_END \ |
| 1138 |
TO_MULTIPLE__ \ |
| 1139 |
CONVERT_END__ |
| 1140 |
|
| 1141 |
#define COMBINE_ALL_TO_ONE(klas) \ |
| 1142 |
FIND_ALL (klas) |
| 1143 |
#define COMBINE_ALL_TO_ONE_END(...) \ |
| 1144 |
TO_ONE__ (__VA_ARGS__) \ |
| 1145 |
CONVERT_END__ |
| 1146 |
|
| 1147 |
#define COMBINE_ALL_LISTED_TO_ONE(klas,listClass) \ |
| 1148 |
FIND_ALL_LISTED (klas,listClass) |
| 1149 |
#define COMBINE_ALL_LISTED_TO_ONE_END(...) \ |
| 1150 |
TO_ONE__ (__VA_ARGS__) \ |
| 1151 |
CONVERT_END__ |
| 1152 |
|
| 1153 |
#define CONVERT_ALL_TO_MULTIPLE(klas) \ |
| 1154 |
FIND_ALL(klas) |
| 1155 |
#define CONVERT_ALL_TO_MULTIPLE_END \ |
| 1156 |
TO_MULTIPLE__ \ |
| 1157 |
CONVERT_END__ |
| 1158 |
|
| 1159 |
#define CONVERT_ALL_LISTED_TO_MULTIPLE(klas,listClass) \ |
| 1160 |
FIND_ALL_LISTED (klas,listClass) |
| 1161 |
#define CONVERT_ALL_LISTED_TO_MULTIPLE_END \ |
| 1162 |
TO_MULTIPLE__ \ |
| 1163 |
CONVERT_END__ |
| 1164 |
|
| 1165 |
#define CONVERT_ONE_AND_ONE_TO_ONE(klas1,klas2) \ |
| 1166 |
FIND_ONE_AND_ONE (klas1, klas2) |
| 1167 |
#define CONVERT_ONE_AND_ONE_TO_ONE_END(...) \ |
| 1168 |
TO_ONE__ (__VA_ARGS__) \ |
| 1169 |
CONVERT_END__ |
| 1170 |
|
| 1171 |
#define CONVERT_ONE_AND_ONE_TO_MULTIPLE(klas1,klas2) \ |
| 1172 |
FIND_ONE_AND_ONE (klas1, klas2) |
| 1173 |
#define CONVERT_ONE_AND_ONE_TO_MULTIPLE_END \ |
| 1174 |
TO_MULTIPLE__ \ |
| 1175 |
CONVERT_END__ |
| 1176 |
|
| 1177 |
#define CONVERT_ONE_WEAK_AND_ONE_TO_ONE(klas1,klas2) \ |
| 1178 |
FIND_ONE_AND_ONE (klas1, klas2) \ |
| 1179 |
FIRST_WEAK_BEGIN |
| 1180 |
#define CONVERT_ONE_WEAK_AND_ONE_TO_ONE_END(...) \ |
| 1181 |
TO_ONE__ (__VA_ARGS__) \ |
| 1182 |
FIRST_WEAK_END \ |
| 1183 |
CONVERT_END__ |
| 1184 |
|
| 1185 |
#define CONVERT_TWO_TO_MULTIPLE(klas) \ |
| 1186 |
FIND_TWO (klas) |
| 1187 |
#define CONVERT_TWO_TO_MULTIPLE_END \ |
| 1188 |
TO_MULTIPLE__ \ |
| 1189 |
CONVERT_END__ |
| 1190 |
|
| 1191 |
#define CONVERT_TWO_TO_ONE(klas) \ |
| 1192 |
FIND_TWO (klas) |
| 1193 |
#define CONVERT_TWO_TO_ONE_END(...) \ |
| 1194 |
TO_ONE__ (__VA_ARGS__) \ |
| 1195 |
CONVERT_END__ |
| 1196 |
|
| 1197 |
#define CONVERT_TWO_AND_ONE_TO_ONE(klas1,klas2) \ |
| 1198 |
FIND_TWO_AND_ONE (klas1,klas2) |
| 1199 |
#define CONVERT_TWO_AND_ONE_TO_ONE_END(...) \ |
| 1200 |
TO_ONE__ (__VA_ARGS__) \ |
| 1201 |
CONVERT_END__ |
| 1202 |
|
| 1203 |
#define CONVERT_ONE_AND_TWO_TO_ONE(klas1,klas2) \ |
| 1204 |
FIND_ONE_AND_TWO (klas1,klas2) |
| 1205 |
#define CONVERT_ONE_AND_TWO_TO_ONE_END(...) \ |
| 1206 |
TO_ONE__ (__VA_ARGS__) \ |
| 1207 |
CONVERT_END__ |
| 1208 |
|
| 1209 |
#define CONVERT_ONE_AND_ONE_AND_ONE_TO_ONE(klas1,klas2,klas3) \ |
| 1210 |
FIND_ONE_AND_ONE_AND_ONE (klas1, klas2, klas3) |
| 1211 |
#define CONVERT_ONE_AND_ONE_AND_ONE_TO_ONE_END(...) \ |
| 1212 |
TO_ONE__ (__VA_ARGS__) \ |
| 1213 |
CONVERT_END__ |
| 1214 |
|
| 1215 |
#define CONVERT_ONE_AND_ONE_AND_ONE_TO_MULTIPLE(klas1,klas2,klas3) \ |
| 1216 |
FIND_ONE_AND_ONE_AND_ONE (klas1, klas2, klas3) |
| 1217 |
#define CONVERT_ONE_AND_ONE_AND_ONE_TO_MULTIPLE_END \ |
| 1218 |
TO_MULTIPLE__ \ |
| 1219 |
CONVERT_END__ |
| 1220 |
|
| 1221 |
#define CONVERT_ONE_AND_ONE_AND_ALL_TO_MULTIPLE(klas1,klas2,klas3) \ |
| 1222 |
FIND_ONE_AND_ONE_AND_ALL (klas1, klas2, klas3) |
| 1223 |
#define CONVERT_ONE_AND_ONE_AND_ALL_TO_MULTIPLE_END \ |
| 1224 |
TO_MULTIPLE__ \ |
| 1225 |
CONVERT_END__ |
| 1226 |
|
| 1227 |
#define CONVERT_ONE_AND_ONE_AND_ONE_AND_ONE_TO_ONE(klas1,klas2,klas3,klas4) \ |
| 1228 |
FIND_1_1_1_1 (klas1, klas2, klas3, klas4) |
| 1229 |
#define CONVERT_ONE_AND_ONE_AND_ONE_AND_ONE_TO_ONE_END(...) \ |
| 1230 |
TO_ONE__ (__VA_ARGS__) \ |
| 1231 |
CONVERT_END__ |
| 1232 |
|
| 1233 |
#define CONVERT_ONE_AND_ALL_TO_ONE(klas1,klas2) \ |
| 1234 |
FIND_ONE_AND_ALL (klas1, klas2) |
| 1235 |
#define CONVERT_ONE_AND_ALL_TO_ONE_END(...) \ |
| 1236 |
TO_ONE__ (__VA_ARGS__) \ |
| 1237 |
CONVERT_END__ |
| 1238 |
|
| 1239 |
#define CONVERT_ONE_AND_ALL_TO_MULTIPLE(klas1,klas2) \ |
| 1240 |
FIND_ONE_AND_ALL (klas1, klas2) |
| 1241 |
#define CONVERT_ONE_AND_ALL_TO_MULTIPLE_END \ |
| 1242 |
TO_MULTIPLE__ \ |
| 1243 |
CONVERT_END__ |
| 1244 |
|
| 1245 |
#define CONVERT_ONE_AND_ALL_LISTED_TO_ONE(klas1,klas2,listClass) \ |
| 1246 |
FIND_ONE_AND_ALL_LISTED (klas1, klas2, listClass) |
| 1247 |
#define CONVERT_ONE_AND_ALL_LISTED_TO_ONE_END(...) \ |
| 1248 |
TO_ONE__ (__VA_ARGS__) \ |
| 1249 |
CONVERT_END__ |
| 1250 |
|
| 1251 |
#define CONVERT_ONE_AND_ONE_GENERIC_TO_ONE(klas1,klas2) \ |
| 1252 |
FIND_ONE_AND_GENERIC(klas1,klas2) |
| 1253 |
#define CONVERT_ONE_AND_ONE_GENERIC_TO_ONE_END(...) \ |
| 1254 |
TO_ONE__ (__VA_ARGS__) \ |
| 1255 |
CONVERT_END__ |
| 1256 |
|
| 1257 |
/* |
| 1258 |
READ |
| 1259 |
*/ |
| 1260 |
|
| 1261 |
#define READ_MULTIPLE |
| 1262 |
#define READ_MULTIPLE_END \ |
| 1263 |
if (interpreter) \ |
| 1264 |
interpreter -> returnType = kInterpreter_ReturnType::OBJECT_; \ |
| 1265 |
END_WITH_NEW_DATA |
| 1266 |
|
| 1267 |
#define READ_ONE |
| 1268 |
#define READ_ONE_END \ |
| 1269 |
praat_newWithFile (result.move(), file, MelderFile_name (file)); \ |
| 1270 |
READ_MULTIPLE_END |
| 1271 |
|
| 1272 |
/* |
| 1273 |
SAVE |
| 1274 |
*/ |
| 1275 |
|
| 1276 |
#define SAVE_ONE(klas,trustMessage) \ |
| 1277 |
FIND_ONE (klas) \ |
| 1278 |
Melder_checkTrust (_interpreter_, trustMessage U"\n", file); |
| 1279 |
#define SAVE_ONE_END \ |
| 1280 |
END_NO_NEW_DATA |
| 1281 |
|
| 1282 |
#define SAVE_ONE_BY_NAME(klas,fileName,trustMessage) \ |
| 1283 |
FIND_ONE (klas) \ |
| 1284 |
structMelderFile file { }; \ |
| 1285 |
Melder_relativePathToFile (fileName, & file); \ |
| 1286 |
Melder_checkTrust (interpreter, fileName, trustMessage U"\n", & file); |
| 1287 |
#define SAVE_ONE_BY_NAME_END \ |
| 1288 |
END_NO_NEW_DATA |
| 1289 |
|
| 1290 |
#define SAVE_TWO(klas,trustMessage) \ |
| 1291 |
FIND_TWO (klas) \ |
| 1292 |
Melder_checkTrust (_interpreter_, trustMessage U"\n", file); |
| 1293 |
#define SAVE_TWO_END \ |
| 1294 |
END_NO_NEW_DATA |
| 1295 |
|
| 1296 |
#define SAVE_ALL(klas,trustMessage) \ |
| 1297 |
FIND_ALL (klas) \ |
| 1298 |
Melder_checkTrust (_interpreter_, trustMessage U"\n", file); |
| 1299 |
#define SAVE_ALL_END \ |
| 1300 |
END_NO_NEW_DATA |
| 1301 |
|
| 1302 |
#define SAVE_ALL_LISTED(klas,listClass,trustMessage) \ |
| 1303 |
FIND_ALL_LISTED (klas, listClass) \ |
| 1304 |
Melder_checkTrust (_interpreter_, trustMessage U"\n", file); |
| 1305 |
#define SAVE_ALL_LISTED_END \ |
| 1306 |
END_NO_NEW_DATA |
| 1307 |
|
| 1308 |
/* |
| 1309 |
APPEND |
| 1310 |
*/ |
| 1311 |
|
| 1312 |
#define APPEND_ALL(klas,trustMessage) \ |
| 1313 |
FIND_ALL (klas) \ |
| 1314 |
Melder_checkTrust (interpreter, trustMessage U"\n", file); |
| 1315 |
#define APPEND_ALL_END \ |
| 1316 |
END_NO_NEW_DATA |
| 1317 |
|
| 1318 |
/* |
| 1319 |
EDITOR |
| 1320 |
*/ |
| 1321 |
|
| 1322 |
#define EDITOR_END__ \ |
| 1323 |
praat_installEditor (editor.get(), IOBJECT); \ |
| 1324 |
editor.releaseToUser(); \ |
| 1325 |
END_NO_NEW_DATA |
| 1326 |
|
| 1327 |
#define EDITOR_ONE(indefiniteArticle,klas) \ |
| 1328 |
if (theCurrentPraatApplication -> batch) \ |
| 1329 |
Melder_throw (U"Cannot edit " #indefiniteArticle " " #klas " from batch."); \ |
| 1330 |
FIND_ONE_WITH_IOBJECT (klas) |
| 1331 |
#define EDITOR_ONE_END \ |
| 1332 |
EDITOR_END__ |
| 1333 |
|
| 1334 |
#define EDITOR_ONE_WITH_ONE(indefiniteArticle,klas1,klas2) \ |
| 1335 |
if (theCurrentPraatApplication -> batch) \ |
| 1336 |
Melder_throw (U"Cannot edit " #indefiniteArticle " " #klas1 " from batch."); \ |
| 1337 |
FIND_ONE_AND_ONE_WITH_IOBJECT (klas1, klas2) |
| 1338 |
#define EDITOR_ONE_WITH_ONE_END \ |
| 1339 |
EDITOR_END__ |
| 1340 |
|
| 1341 |
#define EDITOR_ONE_WITH_ONE_AND_ONE(indefiniteArticle,klas1,klas2,klas3) \ |
| 1342 |
if (theCurrentPraatApplication -> batch) \ |
| 1343 |
Melder_throw (U"Cannot edit " #indefiniteArticle " " #klas1 " from batch."); \ |
| 1344 |
FIND_ONE_AND_ONE_AND_ONE_WITH_IOBJECT (klas1, klas2, klas3) |
| 1345 |
#define EDITOR_ONE_WITH_ONE_AND_ONE_END \ |
| 1346 |
EDITOR_END__ |
| 1347 |
|
| 1348 |
/* |
| 1349 |
CREATION_WINDOW |
| 1350 |
*/ |
| 1351 |
|
| 1352 |
#define SINGLETON_CREATION_WINDOW(indefiniteArticle,klas) \ |
| 1353 |
if (theCurrentPraatApplication -> batch) \ |
| 1354 |
Melder_throw (U"Cannot create " #indefiniteArticle " " #klas " in a window from batch."); |
| 1355 |
#define SINGLETON_CREATION_WINDOW_END \ |
| 1356 |
END_NO_NEW_DATA // no new data *yet*, because the window is asynchronous |
| 1357 |
|
| 1358 |
#define CREATION_WINDOW(indefiniteArticle,klas) \ |
| 1359 |
if (theCurrentPraatApplication -> batch) \ |
| 1360 |
Melder_throw (U"Cannot create " #indefiniteArticle " " #klas " in a window from batch."); |
| 1361 |
#define CREATION_WINDOW_END \ |
| 1362 |
creationWindow.releaseToUser(); \ |
| 1363 |
END_NO_NEW_DATA // no new data *yet*, because the window is asynchronous |
| 1364 |
|
| 1365 |
/* |
| 1366 |
WARNING |
| 1367 |
*/ |
| 1368 |
|
| 1369 |
#define WARNING |
| 1370 |
#define WARNING_END \ |
| 1371 |
END_NO_NEW_DATA |
| 1372 |
|
| 1373 |
/* |
| 1374 |
PREFS |
| 1375 |
*/ |
| 1376 |
|
| 1377 |
#define PREFS |
| 1378 |
#define PREFS_END \ |
| 1379 |
END_NO_NEW_DATA |
| 1380 |
|
| 1381 |
/* |
| 1382 |
PRAAT |
| 1383 |
*/ |
| 1384 |
|
| 1385 |
#define PRAAT |
| 1386 |
#define PRAAT_END \ |
| 1387 |
END_NO_NEW_DATA |
| 1388 |
|
| 1389 |
/* End of file praatM.h */ |
| 1390 |
#endif |