| 1 | /* UiPause.cpp |
| 2 | * |
| 3 | * Copyright (C) 2009-2020,2022-2026 Paul Boersma |
| 4 | * |
| 5 | * This code is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation; either version 3 of the License, or (at |
| 8 | * your option) any later version. |
| 9 | * |
| 10 | * This code is distributed in the hope that it will be useful, but |
| 11 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| 13 | * See the GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this work. If not, see <http://www.gnu.org/licenses/>. |
| 17 | */ |
| 18 | |
| 19 | #include "UiPause.h"cxx . . $ `<file>/sys/UiPause.h`/ |
| 20 | #include "praatP.h"cxx . . $ `<file>/sys/praatP.h`/ |
| 21 | |
| 22 | static autoUiFormcxx . . $ autoUiForm# thePauseFormcxx . . $ thePauseForm.; |
| 23 | static int thePauseForm_clickedcxx . . $ thePauseForm_clicked. = 0; |
| 24 | static int theCancelContinueButtoncxx . . $ theCancelContinueButton. = 0; |
| 25 | static Interpretercxx . . $ Interpreter# thePauseForm_interpreterReferencecxx . . $ thePauseForm_interpreterReference.; // TODO: this should be a weak_ptr to the InterpreterStack |
| 26 | static structMelderFoldercxx . . $ structMelderFolder# thePauseForm_savedFoldercxx . . $ thePauseForm_savedFolder.; // TODO: probably remove |
| 27 | static Editorcxx . . $ Editor# thePauseForm_savedEditorReferencecxx . . $ thePauseForm_savedEditorReference.; |
| 28 | |
| 29 | void UiPause_interpreterGoesAwaycxx . . $ UiPause_interpreterGoesAway(448c181fe9dacca8). (Interpretercxx . . $ Interpreter# interpreter) { |
| 30 | if (interpreter == thePauseForm_interpreterReferencecxx . . $ thePauseForm_interpreterReference.) |
| 31 | thePauseForm_interpreterReferencecxx . . $ thePauseForm_interpreterReference. = nullptr; // undangle |
| 32 | } |
| 33 | |
| 34 | static void thePauseFormOkCallbackcxx . . $ thePauseFormOkCallback(744a0abd3c8513c). (UiFormcxx . . $ UiForm# /* sendingForm */, integercxx . . $ integer# /* narg */, Stackelcxx . . $ Stackel# /* args */, |
| 35 | conststring32cxx . . $ conststring32# /* sendingString */, Interpretercxx . . $ Interpreter# /* interpreter */, |
| 36 | conststring32cxx . . $ conststring32# /* invokingButtonTitle */, bool /* modified */, void *closure, Editorcxx . . $ Editor# optionalEditor) |
| 37 | { |
| 38 | if (! thePauseForm_interpreterReferencecxx . . $ thePauseForm_interpreterReference.) { // interpreter was destroyed? |
| 39 | GuiThing_hidecxx . . $ GuiThing_hide(20e88c25f0ba841). (thePauseFormcxx . . $ thePauseForm. ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). d_dialogFormcxx . . $ structUiForm#d_dialogForm.); // BUG: memory leak |
| 40 | thePauseForm_savedEditorReferencecxx . . $ thePauseForm_savedEditorReference. = nullptr; |
| 41 | thePauseFormcxx . . $ thePauseForm.. releaseToUsercxx . . $ autoSomeThing#releaseToUser(ced63f7c635d850d).(); |
| 42 | return; |
| 43 | } |
| 44 | if (! thePauseFormcxx . . $ thePauseForm.) // BUG: perhaps there was a mistake in the script |
| 45 | return; |
| 46 | Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (thePauseForm_interpreterReference); |
| 47 | Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (Thing_isa (thePauseForm_interpreterReference, classInterpreter)); |
| 48 | if (thePauseForm_interpreterReferencecxx . . $ thePauseForm_interpreterReference. -> optionalDynamicEnvironmentEditorcxx . . $ structInterpreter#optionalDynamicEnvironmentEditor(480fba2ddcd094f3).() != thePauseForm_savedEditorReferencecxx . . $ thePauseForm_savedEditorReference.) { |
| 49 | Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (thePauseForm_savedEditorReference); |
| 50 | Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (! thePauseForm_interpreterReference -> optionalDynamicEnvironmentEditor()); |
| 51 | Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (thePauseForm_interpreterReference -> optionalDynamicEditorEnvironmentClassName()); |
| 52 | // testing the assumption that the environment can be lost but never added during pause |
| 53 | Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (thePauseForm); |
| 54 | if (thePauseFormcxx . . $ thePauseForm. ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). d_dialogFormcxx . . $ structUiForm#d_dialogForm.) { |
| 55 | GuiThing_hidecxx . . $ GuiThing_hide(20e88c25f0ba841). (thePauseFormcxx . . $ thePauseForm. ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). d_dialogFormcxx . . $ structUiForm#d_dialogForm.); // BUG: memory leak |
| 56 | //thePauseForm_interpreterReference -> isInSecondPass = false; // TODO: corrected? and what about isHalted? |
| 57 | } |
| 58 | thePauseFormcxx . . $ thePauseForm.. releaseToUsercxx . . $ autoSomeThing#releaseToUser(ced63f7c635d850d).(); // undangle (will be autodestroyed when unmanaged) |
| 59 | Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (! thePauseForm); |
| 60 | const integercxx . . $ integer# lineNumber = thePauseForm_interpreterReferencecxx . . $ thePauseForm_interpreterReference. -> lineNumbercxx . . $ structInterpreter#lineNumber.; |
| 61 | Interpreter_stopcxx . . $ Interpreter_stop(448c181fe9dacca8). (thePauseForm_interpreterReferencecxx . . $ thePauseForm_interpreterReference.); |
| 62 | Melder_flushErrorcxx . . $ Melder_flushError(6298c93241566110). (U"Cannot continue after pause, because the ", thePauseForm_interpreterReferencecxx . . $ thePauseForm_interpreterReference. -> optionalDynamicEditorEnvironmentClassNamecxx . . $ structInterpreter#optionalDynamicEditorEnvironmentClassName(4fe9f98b54bf9c7d).(), U" has been closed.", |
| 63 | U"\nScript interrupted at line ", lineNumber, U"."); // a top-level error message |
| 64 | return; |
| 65 | } |
| 66 | /* |
| 67 | Get the data from the pause form. |
| 68 | */ |
| 69 | Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (thePauseForm); |
| 70 | thePauseForm_clickedcxx . . $ thePauseForm_clicked. = UiForm_getClickedContinueButtoncxx . . $ UiForm_getClickedContinueButton(4e51e78c3b9b4386). (thePauseFormcxx . . $ thePauseForm..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).()); |
| 71 | if (thePauseForm_clickedcxx . . $ thePauseForm_clicked. != theCancelContinueButtoncxx . . $ theCancelContinueButton.) |
| 72 | UiForm_Interpreter_addVariablescxx . . $ UiForm_Interpreter_addVariables(16bc4cf5fc9b4102). (thePauseFormcxx . . $ thePauseForm..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), (Interpretercxx . . $ Interpreter#) closure); // 'closure', not 'interpreter' or 'theInterpreter'! |
| 73 | Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (thePauseForm_clicked >= 1 && thePauseForm_clicked <= 10); |
| 74 | autostring32cxx . . $ autostring32# clickedText = Melder_dupcxx . . $ Melder_dup(87bf156b1f548402). (thePauseFormcxx . . $ thePauseForm. ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). continueTextscxx . . $ structUiForm#continueTexts. [thePauseForm_clickedcxx . . $ thePauseForm_clicked.].getcxx . . $ _autostring#get(5a2a78a048fb49a8).()); // very safe |
| 75 | if (thePauseFormcxx . . $ thePauseForm. ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). d_dialogFormcxx . . $ structUiForm#d_dialogForm.) { |
| 76 | GuiThing_hidecxx . . $ GuiThing_hide(20e88c25f0ba841). (thePauseFormcxx . . $ thePauseForm. ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). d_dialogFormcxx . . $ structUiForm#d_dialogForm.); // BUG: memory leak |
| 77 | //thePauseForm_interpreterReference -> isInSecondPass = false; // TODO: corrected? and what about isHalted? |
| 78 | } |
| 79 | thePauseFormcxx . . $ thePauseForm.. releaseToUsercxx . . $ autoSomeThing#releaseToUser(ced63f7c635d850d).(); // undangle (will be autodestroyed when unmanaged) |
| 80 | Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (! thePauseForm); |
| 81 | /* |
| 82 | Resume the interpreter. |
| 83 | */ |
| 84 | //Melder_setCurrentFolder (& thePauseForm_savedFolder); // TODO: remove |
| 85 | Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (thePauseForm_interpreterReference); |
| 86 | try { |
| 87 | autoPraatBackgroundcxx . . $ autoPraatBackground# backgroundcxx . . $ autoPraatBackground#autoPraatBackground(49f6e7a06ebc5aa8).; |
| 88 | Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (thePauseForm_interpreterReference -> owningInterpreterStack); |
| 89 | thePauseForm_interpreterReferencecxx . . $ thePauseForm_interpreterReference. -> owningInterpreterStackcxx . . $ structInterpreter#owningInterpreterStack. -> resumeFromTopcxx . . $ structInterpreterStack#resumeFromTop(49f6e7a06ebc5aa8). (); |
| 90 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 91 | /* |
| 92 | These errors will often not be reached, because Interpreter_resume contains some Melder_flushError(). |
| 93 | */ |
| 94 | if (thePauseForm_clickedcxx . . $ thePauseForm_clicked. == theCancelContinueButtoncxx . . $ theCancelContinueButton.) |
| 95 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"This happened after you cancelled the pause form."); |
| 96 | else |
| 97 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"This happened after you clicked “", clickedText.get(), U"” in the pause form."); |
| 98 | } |
| 99 | } |
| 100 | static void thePauseFormCancelCallbackcxx . . $ thePauseFormCancelCallback(d12e536fc199ffc2). (UiFormcxx . . $ UiForm# /* dia */, void * /* closure */) { |
| 101 | if (! thePauseForm_interpreterReferencecxx . . $ thePauseForm_interpreterReference.) { // interpreter was destroyed? |
| 102 | GuiThing_hidecxx . . $ GuiThing_hide(20e88c25f0ba841). (thePauseFormcxx . . $ thePauseForm. ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). d_dialogFormcxx . . $ structUiForm#d_dialogForm.); // BUG: memory leak |
| 103 | thePauseForm_savedEditorReferencecxx . . $ thePauseForm_savedEditorReference. = nullptr; |
| 104 | thePauseFormcxx . . $ thePauseForm.. releaseToUsercxx . . $ autoSomeThing#releaseToUser(ced63f7c635d850d).(); |
| 105 | return; |
| 106 | } |
| 107 | if (! thePauseFormcxx . . $ thePauseForm.) // BUG: perhaps there was a mistake in the script |
| 108 | return; |
| 109 | Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (thePauseForm_interpreterReference); |
| 110 | Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (Thing_isa (thePauseForm_interpreterReference, classInterpreter)); |
| 111 | /* |
| 112 | We arrive here if the user clicked the close box of the dialog window, or if they clicked Stop. |
| 113 | */ |
| 114 | Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (thePauseForm); |
| 115 | if (thePauseFormcxx . . $ thePauseForm. ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). d_dialogFormcxx . . $ structUiForm#d_dialogForm.) { |
| 116 | GuiThing_hidecxx . . $ GuiThing_hide(20e88c25f0ba841). (thePauseFormcxx . . $ thePauseForm. ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). d_dialogFormcxx . . $ structUiForm#d_dialogForm.); // BUG: memory leak |
| 117 | //thePauseForm_interpreterReference -> isInSecondPass = false; // TODO: corrected? and what about isHalted? |
| 118 | } |
| 119 | thePauseFormcxx . . $ thePauseForm.. releaseToUsercxx . . $ autoSomeThing#releaseToUser(ced63f7c635d850d).(); // undangle (will be autodestroyed when unmanaged) |
| 120 | Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (! thePauseForm); |
| 121 | if (theCancelContinueButtoncxx . . $ theCancelContinueButton. != 0) { |
| 122 | /* |
| 123 | The pause window apparently contains a "Cancel"-like button, so it doesn’t contain a Stop button. |
| 124 | Hence, if we arrive here, the user must have clicked the close box of the dialog window. |
| 125 | We divert this click to the "Cancel"-like button, |
| 126 | and it will be the script’s responsibility to handle it. |
| 127 | */ |
| 128 | thePauseForm_clickedcxx . . $ thePauseForm_clicked. = theCancelContinueButtoncxx . . $ theCancelContinueButton.; // there was |
| 129 | if (thePauseForm_interpreterReferencecxx . . $ thePauseForm_interpreterReference. -> optionalDynamicEnvironmentEditorcxx . . $ structInterpreter#optionalDynamicEnvironmentEditor(480fba2ddcd094f3).() != thePauseForm_savedEditorReferencecxx . . $ thePauseForm_savedEditorReference.) { |
| 130 | Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (thePauseForm_savedEditorReference); |
| 131 | Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (! thePauseForm_interpreterReference -> optionalDynamicEnvironmentEditor()); |
| 132 | Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (thePauseForm_interpreterReference -> optionalDynamicEditorEnvironmentClassName()); |
| 133 | // testing the assumption that the environment can be lost but never added during pause |
| 134 | const integercxx . . $ integer# lineNumber = thePauseForm_interpreterReferencecxx . . $ thePauseForm_interpreterReference. -> lineNumbercxx . . $ structInterpreter#lineNumber.; |
| 135 | Interpreter_stopcxx . . $ Interpreter_stop(448c181fe9dacca8). (thePauseForm_interpreterReferencecxx . . $ thePauseForm_interpreterReference.); |
| 136 | Melder_flushErrorcxx . . $ Melder_flushError(6298c93241566110). (U"Cannot continue after pause, because the ", thePauseForm_interpreterReferencecxx . . $ thePauseForm_interpreterReference. -> optionalDynamicEditorEnvironmentClassNamecxx . . $ structInterpreter#optionalDynamicEditorEnvironmentClassName(4fe9f98b54bf9c7d).(), U" has been closed.", |
| 137 | U"\nScript interrupted at line ", lineNumber, U"."); // a top-level error message |
| 138 | } |
| 139 | /* |
| 140 | Resume the interpreter. |
| 141 | */ |
| 142 | //Melder_setCurrentFolder (& thePauseForm_savedFolder); // TODO: remove |
| 143 | try { |
| 144 | autoPraatBackgroundcxx . . $ autoPraatBackground# backgroundcxx . . $ autoPraatBackground#autoPraatBackground(49f6e7a06ebc5aa8).; |
| 145 | Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (thePauseForm_interpreterReference -> owningInterpreterStack); |
| 146 | thePauseForm_interpreterReferencecxx . . $ thePauseForm_interpreterReference. -> owningInterpreterStackcxx . . $ structInterpreter#owningInterpreterStack. -> resumeFromTopcxx . . $ structInterpreterStack#resumeFromTop(49f6e7a06ebc5aa8). (); |
| 147 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 148 | Melder_flushErrorcxx . . $ Melder_flushError(6298c93241566110). (U"This happened after you stopped the pause form."); |
| 149 | } |
| 150 | } else { |
| 151 | /* |
| 152 | The pause window apparently contains no "Cancel"-like button, so it must contain a Stop button. |
| 153 | Perform the normal action for the Stop button, which is to post a message about interruption. |
| 154 | A click in the close box of the dialog window performs the same action as the Stop button. |
| 155 | */ |
| 156 | const integercxx . . $ integer# lineNumber = thePauseForm_interpreterReferencecxx . . $ thePauseForm_interpreterReference. -> lineNumbercxx . . $ structInterpreter#lineNumber.; |
| 157 | Interpreter_stopcxx . . $ Interpreter_stop(448c181fe9dacca8). (thePauseForm_interpreterReferencecxx . . $ thePauseForm_interpreterReference.); |
| 158 | Melder_flushErrorcxx . . $ Melder_flushError(6298c93241566110). (U"You interrupted the script at line ", lineNumber, U"."); // a top-level error message |
| 159 | } |
| 160 | } |
| 161 | void UiPause_begincxx . . $ UiPause_begin(915831b5ca293512). (GuiWindowcxx . . $ GuiWindow# topShell, Editorcxx . . $ Editor# optionalPauseWindowOwningEditor, conststring32cxx . . $ conststring32# title, Interpretercxx . . $ Interpreter# interpreter) { |
| 162 | Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (interpreter); |
| 163 | if (interpreter -> isInSecondPasscxx . . $ structInterpreter#isInSecondPass.) |
| 164 | return; // this can happen in `pauseScript()` and in `pause`. |
| 165 | if (thePauseFormcxx . . $ thePauseForm.) |
| 166 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (Melder_upperCaseAppName(), U" cannot have more than one pause form at a time."); |
| 167 | thePauseFormcxx . . $ thePauseForm. =cxx . . $ autoSomeThing#`operator=`(80cc59814f7161e8). UiForm_createcxx . . $ UiForm_create(b3c832b012a1002d). (topShell, optionalPauseWindowOwningEditor, Melder_catcxx . . $ Melder_cat(7fbf27f4d367f442). (U"Pause: ", title), |
| 168 | thePauseFormOkCallbackcxx . . $ thePauseFormOkCallback(744a0abd3c8513c)., interpreter, // pass interpreter as closure! |
| 169 | nullptr, nullptr |
| 170 | ); |
| 171 | } |
| 172 | void UiPause_realcxx . . $ UiPause_real(cc7657622ff166ed). (conststring32cxx . . $ conststring32# label, conststring32cxx . . $ conststring32# defaultValue) { |
| 173 | if (! thePauseFormcxx . . $ thePauseForm.) |
| 174 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"The function “real” should be between a “beginPause” and an “endPause”."); |
| 175 | UiForm_addRealcxx . . $ UiForm_addReal(d7880526ba4e7a26). (thePauseFormcxx . . $ thePauseForm..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), nullptr, nullptr, label, defaultValue); |
| 176 | } |
| 177 | void UiPause_positivecxx . . $ UiPause_positive(cc7657622ff166ed). (conststring32cxx . . $ conststring32# label, conststring32cxx . . $ conststring32# defaultValue) { |
| 178 | if (! thePauseFormcxx . . $ thePauseForm.) |
| 179 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"The function “positive” should be between a “beginPause” and an “endPause”."); |
| 180 | UiForm_addPositivecxx . . $ UiForm_addPositive(d7880526ba4e7a26). (thePauseFormcxx . . $ thePauseForm..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), nullptr, nullptr, label, defaultValue); |
| 181 | } |
| 182 | void UiPause_integercxx . . $ UiPause_integer(cc7657622ff166ed). (conststring32cxx . . $ conststring32# label, conststring32cxx . . $ conststring32# defaultValue) { |
| 183 | if (! thePauseFormcxx . . $ thePauseForm.) |
| 184 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"The function “integer” should be between a “beginPause” and an “endPause”."); |
| 185 | UiForm_addIntegercxx . . $ UiForm_addInteger(b8ca5bf767b50516). (thePauseFormcxx . . $ thePauseForm..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), nullptr, nullptr, label, defaultValue); |
| 186 | } |
| 187 | void UiPause_natural0cxx . . $ UiPause_natural0(cc7657622ff166ed). (conststring32cxx . . $ conststring32# label, conststring32cxx . . $ conststring32# defaultValue) { |
| 188 | if (! thePauseFormcxx . . $ thePauseForm.) |
| 189 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"The function “natural0” should be between a “beginPause” and an “endPause”."); |
| 190 | UiForm_addNatural0cxx . . $ UiForm_addNatural0(b8ca5bf767b50516). (thePauseFormcxx . . $ thePauseForm..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), nullptr, nullptr, label, defaultValue); |
| 191 | } |
| 192 | void UiPause_natural1cxx . . $ UiPause_natural1(cc7657622ff166ed). (conststring32cxx . . $ conststring32# label, conststring32cxx . . $ conststring32# defaultValue) { |
| 193 | if (! thePauseFormcxx . . $ thePauseForm.) |
| 194 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"The function “natural1” should be between a “beginPause” and an “endPause”."); |
| 195 | UiForm_addNatural1cxx . . $ UiForm_addNatural1(b8ca5bf767b50516). (thePauseFormcxx . . $ thePauseForm..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), nullptr, nullptr, label, defaultValue); |
| 196 | } |
| 197 | void UiPause_naturalcxx . . $ UiPause_natural(cc7657622ff166ed). (conststring32cxx . . $ conststring32# label, conststring32cxx . . $ conststring32# defaultValue) { |
| 198 | if (! thePauseFormcxx . . $ thePauseForm.) |
| 199 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"The function “natural” should be between a “beginPause” and an “endPause”."); |
| 200 | UiForm_addNatural1cxx . . $ UiForm_addNatural1(b8ca5bf767b50516). (thePauseFormcxx . . $ thePauseForm..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), nullptr, nullptr, label, defaultValue); |
| 201 | } |
| 202 | void UiPause_wordcxx . . $ UiPause_word(cc7657622ff166ed). (conststring32cxx . . $ conststring32# label, conststring32cxx . . $ conststring32# defaultValue) { |
| 203 | if (! thePauseFormcxx . . $ thePauseForm.) |
| 204 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"The function “word” should be between a “beginPause” and an “endPause”."); |
| 205 | UiForm_addWordcxx . . $ UiForm_addWord(5d4a87e816a21170). (thePauseFormcxx . . $ thePauseForm..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), nullptr, nullptr, label, defaultValue); |
| 206 | } |
| 207 | void UiPause_sentencecxx . . $ UiPause_sentence(cc7657622ff166ed). (conststring32cxx . . $ conststring32# label, conststring32cxx . . $ conststring32# defaultValue) { |
| 208 | if (! thePauseFormcxx . . $ thePauseForm.) |
| 209 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"The function “sentence” should be between a “beginPause” and an “endPause”."); |
| 210 | UiForm_addSentencecxx . . $ UiForm_addSentence(5d4a87e816a21170). (thePauseFormcxx . . $ thePauseForm..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), nullptr, nullptr, label, defaultValue); |
| 211 | } |
| 212 | void UiPause_textcxx . . $ UiPause_text(a2fa6afbb5f03f2). (conststring32cxx . . $ conststring32# label, conststring32cxx . . $ conststring32# defaultValue, integercxx . . $ integer# numberOfLines) { |
| 213 | if (! thePauseFormcxx . . $ thePauseForm.) |
| 214 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"The function “text” should be between a “beginPause” and an “endPause”."); |
| 215 | UiForm_addTextcxx . . $ UiForm_addText(25528465ffb71beb). (thePauseFormcxx . . $ thePauseForm..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), nullptr, nullptr, label, defaultValue, numberOfLines); |
| 216 | } |
| 217 | void UiPause_booleancxx . . $ UiPause_boolean(7004b68cc6c23ea2). (conststring32cxx . . $ conststring32# label, bool defaultValue) { |
| 218 | if (! thePauseFormcxx . . $ thePauseForm.) |
| 219 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"The function “boolean” should be between a “beginPause” and an “endPause”."); |
| 220 | UiForm_addBooleancxx . . $ UiForm_addBoolean(b90450cfcf0b1b39). (thePauseFormcxx . . $ thePauseForm..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), nullptr, nullptr, label, defaultValue); |
| 221 | } |
| 222 | void UiPause_infilecxx . . $ UiPause_infile(a2fa6afbb5f03f2). (conststring32cxx . . $ conststring32# label, conststring32cxx . . $ conststring32# defaultValue, integercxx . . $ integer# numberOfLines) { |
| 223 | if (! thePauseFormcxx . . $ thePauseForm.) |
| 224 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"The function “infile” should be between a “beginPause” and an “endPause”."); |
| 225 | UiForm_addInfilecxx . . $ UiForm_addInfile(25528465ffb71beb). (thePauseFormcxx . . $ thePauseForm..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), nullptr, nullptr, label, defaultValue, numberOfLines); |
| 226 | } |
| 227 | void UiPause_outfilecxx . . $ UiPause_outfile(a2fa6afbb5f03f2). (conststring32cxx . . $ conststring32# label, conststring32cxx . . $ conststring32# defaultValue, integercxx . . $ integer# numberOfLines) { |
| 228 | if (! thePauseFormcxx . . $ thePauseForm.) |
| 229 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"The function “outfile” should be between a “beginPause” and an “endPause”."); |
| 230 | UiForm_addOutfilecxx . . $ UiForm_addOutfile(25528465ffb71beb). (thePauseFormcxx . . $ thePauseForm..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), nullptr, nullptr, label, defaultValue, numberOfLines); |
| 231 | } |
| 232 | void UiPause_foldercxx . . $ UiPause_folder(a2fa6afbb5f03f2). (conststring32cxx . . $ conststring32# label, conststring32cxx . . $ conststring32# defaultValue, integercxx . . $ integer# numberOfLines) { |
| 233 | if (! thePauseFormcxx . . $ thePauseForm.) |
| 234 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"The function “folder” should be between a “beginPause” and an “endPause”."); |
| 235 | UiForm_addFoldercxx . . $ UiForm_addFolder(25528465ffb71beb). (thePauseFormcxx . . $ thePauseForm..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), nullptr, nullptr, label, defaultValue, numberOfLines); |
| 236 | } |
| 237 | void UiPause_realvectorcxx . . $ UiPause_realvector(ddd988eb2be69905). (conststring32cxx . . $ conststring32# label, kUi_realVectorFormatcxx . . $ kUi_realVectorFormat# defaultFormat, conststring32cxx . . $ conststring32# defaultValue, integercxx . . $ integer# numberOfLines) { |
| 238 | if (! thePauseFormcxx . . $ thePauseForm.) |
| 239 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"The function “realvector” should be between a “beginPause” and an “endPause”."); |
| 240 | UiForm_addRealVectorcxx . . $ UiForm_addRealVector(5c557c1a40061fd6). (thePauseFormcxx . . $ thePauseForm..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), nullptr, nullptr, label, defaultFormat, defaultValue, numberOfLines); |
| 241 | } |
| 242 | void UiPause_positivevectorcxx . . $ UiPause_positivevector(ddd988eb2be69905). (conststring32cxx . . $ conststring32# label, kUi_realVectorFormatcxx . . $ kUi_realVectorFormat# defaultFormat, conststring32cxx . . $ conststring32# defaultValue, integercxx . . $ integer# numberOfLines) { |
| 243 | if (! thePauseFormcxx . . $ thePauseForm.) |
| 244 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"The function “positivevector” should be between a “beginPause” and an “endPause”."); |
| 245 | UiForm_addRealVectorcxx . . $ UiForm_addRealVector(5c557c1a40061fd6). (thePauseFormcxx . . $ thePauseForm..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), nullptr, nullptr, label, defaultFormat, defaultValue, numberOfLines); |
| 246 | } |
| 247 | void UiPause_integervectorcxx . . $ UiPause_integervector(446f5aedaf4459fc). (conststring32cxx . . $ conststring32# label, kUi_integerVectorFormatcxx . . $ kUi_integerVectorFormat# defaultFormat, conststring32cxx . . $ conststring32# defaultValue, integercxx . . $ integer# numberOfLines) { |
| 248 | if (! thePauseFormcxx . . $ thePauseForm.) |
| 249 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"The function “integervector” should be between a “beginPause” and an “endPause”."); |
| 250 | UiForm_addIntegerVectorcxx . . $ UiForm_addIntegerVector(2672c3a1aac61713). (thePauseFormcxx . . $ thePauseForm..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), nullptr, nullptr, label, defaultFormat, defaultValue, numberOfLines); |
| 251 | } |
| 252 | void UiPause_naturalvectorcxx . . $ UiPause_naturalvector(446f5aedaf4459fc). (conststring32cxx . . $ conststring32# label, kUi_integerVectorFormatcxx . . $ kUi_integerVectorFormat# defaultFormat, conststring32cxx . . $ conststring32# defaultValue, integercxx . . $ integer# numberOfLines) { |
| 253 | if (! thePauseFormcxx . . $ thePauseForm.) |
| 254 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"The function “naturalvector” should be between a “beginPause” and an “endPause”."); |
| 255 | UiForm_addIntegerVectorcxx . . $ UiForm_addIntegerVector(2672c3a1aac61713). (thePauseFormcxx . . $ thePauseForm..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), nullptr, nullptr, label, defaultFormat, defaultValue, numberOfLines); |
| 256 | } |
| 257 | void UiPause_choicecxx . . $ UiPause_choice(4a10cabd38284ee2). (conststring32cxx . . $ conststring32# label, int defaultValue) { |
| 258 | if (! thePauseFormcxx . . $ thePauseForm.) |
| 259 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"The function “choice” should be between a “beginPause” and an “endPause”."); |
| 260 | UiForm_addChoicecxx . . $ UiForm_addChoice(d89e2083c962d687). (thePauseFormcxx . . $ thePauseForm..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), nullptr, nullptr, nullptr, label, defaultValue, 1); |
| 261 | } |
| 262 | void UiPause_optionmenucxx . . $ UiPause_optionmenu(4a10cabd38284ee2). (conststring32cxx . . $ conststring32# label, int defaultValue) { |
| 263 | if (! thePauseFormcxx . . $ thePauseForm.) |
| 264 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"The function “optionmenu” should be between a “beginPause” and an “endPause”."); |
| 265 | UiForm_addOptionMenucxx . . $ UiForm_addOptionMenu(d89e2083c962d687). (thePauseFormcxx . . $ thePauseForm..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), nullptr, nullptr, nullptr, label, defaultValue, 1); |
| 266 | } |
| 267 | void UiPause_optioncxx . . $ UiPause_option(ff00d524ab0355ec). (conststring32cxx . . $ conststring32# optionText) { |
| 268 | if (! thePauseFormcxx . . $ thePauseForm.) |
| 269 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"The function “option” should be between a “beginPause” and an “endPause”."); |
| 270 | UiOptioncxx . . $ UiOption# option = UiForm_addOptioncxx . . $ UiForm_addOption(fb534d753ea2b6de). (thePauseFormcxx . . $ thePauseForm..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), optionText); |
| 271 | if (! option) { |
| 272 | thePauseFormcxx . . $ thePauseForm.. resetcxx . . $ autoSomeThing#reset(ced63f7c635d850d).(); |
| 273 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Found the function “option” without a preceding “choice” or “optionmenu”."); |
| 274 | } |
| 275 | } |
| 276 | void UiPause_headingcxx . . $ UiPause_heading(ff00d524ab0355ec). (conststring32cxx . . $ conststring32# label) { |
| 277 | if (! thePauseFormcxx . . $ thePauseForm.) |
| 278 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"The function “comment” should be between a “beginPause” and an “endPause”."); |
| 279 | UiForm_addHeadingcxx . . $ UiForm_addHeading(6d0ce7320d446690). (thePauseFormcxx . . $ thePauseForm..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), nullptr, label); |
| 280 | } |
| 281 | void UiPause_commentcxx . . $ UiPause_comment(ff00d524ab0355ec). (conststring32cxx . . $ conststring32# label) { |
| 282 | //if (thePauseForm_secondPass) |
| 283 | // return; // this can happen in `pauseScript()` and in `pause`. TODO: is this needed? |
| 284 | if (! thePauseFormcxx . . $ thePauseForm.) |
| 285 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"The function “comment” should be between a “beginPause” and an “endPause”."); |
| 286 | UiForm_addCommentcxx . . $ UiForm_addComment(6d0ce7320d446690). (thePauseFormcxx . . $ thePauseForm..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), nullptr, label); |
| 287 | } |
| 288 | void UiPause_captioncxx . . $ UiPause_caption(ff00d524ab0355ec). (conststring32cxx . . $ conststring32# label) { |
| 289 | if (! thePauseFormcxx . . $ thePauseForm.) |
| 290 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"The function “caption” should be between a “beginPause” and an “endPause”."); |
| 291 | UiForm_addCaptioncxx . . $ UiForm_addCaption(6d0ce7320d446690). (thePauseFormcxx . . $ thePauseForm..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), nullptr, label); |
| 292 | } |
| 293 | |
| 294 | int UiPause_endcxx . . $ UiPause_end(79c1d48e2fb715c0). (int numberOfContinueButtons, int defaultContinueButton, int cancelContinueButton, |
| 295 | conststring32cxx . . $ conststring32# continueText1, conststring32cxx . . $ conststring32# continueText2, conststring32cxx . . $ conststring32# continueText3, |
| 296 | conststring32cxx . . $ conststring32# continueText4, conststring32cxx . . $ conststring32# continueText5, conststring32cxx . . $ conststring32# continueText6, |
| 297 | conststring32cxx . . $ conststring32# continueText7, conststring32cxx . . $ conststring32# continueText8, conststring32cxx . . $ conststring32# continueText9, |
| 298 | conststring32cxx . . $ conststring32# continueText10, Interpretercxx . . $ Interpreter# interpreter) |
| 299 | { |
| 300 | //TRACE |
| 301 | Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (interpreter); |
| 302 | tracecxx . . $ `melder/melder_debug.h:60:10`! (U"is in second Pass? ", interpreter -> isInSecondPass); |
| 303 | if (interpreter -> isInSecondPasscxx . . $ structInterpreter#isInSecondPass.) { |
| 304 | Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (interpreter == thePauseForm_interpreterReference); |
| 305 | Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (! thePauseForm); |
| 306 | interpreter -> isInSecondPasscxx . . $ structInterpreter#isInSecondPass. = false; // TODO: needed? |
| 307 | return thePauseForm_clickedcxx . . $ thePauseForm_clicked.; |
| 308 | } else { |
| 309 | if (! thePauseFormcxx . . $ thePauseForm.) |
| 310 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Found the function “endPause” without a preceding “beginPause”."); |
| 311 | thePauseForm_interpreterReferencecxx . . $ thePauseForm_interpreterReference. = interpreter; |
| 312 | thePauseForm_savedEditorReferencecxx . . $ thePauseForm_savedEditorReference. = interpreter -> optionalDynamicEnvironmentEditorcxx . . $ structInterpreter#optionalDynamicEnvironmentEditor(480fba2ddcd094f3).(); |
| 313 | UiForm_setPauseFormcxx . . $ UiForm_setPauseForm(d24abb1496621b13). (thePauseFormcxx . . $ thePauseForm..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), numberOfContinueButtons, defaultContinueButton, cancelContinueButton, |
| 314 | continueText1, continueText2, continueText3, continueText4, continueText5, |
| 315 | continueText6, continueText7, continueText8, continueText9, continueText10, |
| 316 | thePauseFormCancelCallbackcxx . . $ thePauseFormCancelCallback(d12e536fc199ffc2). |
| 317 | ); |
| 318 | theCancelContinueButtoncxx . . $ theCancelContinueButton. = cancelContinueButton; |
| 319 | UiForm_finishcxx . . $ UiForm_finish(b4388889c5fb10c0). (thePauseFormcxx . . $ thePauseForm..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).()); |
| 320 | //if (theCurrentPraatApplication -> batch) goto end; |
| 321 | thePauseForm_clickedcxx . . $ thePauseForm_clicked. = 0; |
| 322 | Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (interpreter -> owningInterpreterStack); |
| 323 | interpreter -> owningInterpreterStackcxx . . $ structInterpreter#owningInterpreterStack. -> haltAllcxx . . $ structInterpreterStack#haltAll(49f6e7a06ebc5aa8). (); |
| 324 | /* |
| 325 | Put the pause form on the screen. |
| 326 | */ |
| 327 | UiForm_destroyWhenUnmanagedcxx . . $ UiForm_destroyWhenUnmanaged(b4388889c5fb10c0). (thePauseFormcxx . . $ thePauseForm..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).()); |
| 328 | UiForm_docxx . . $ UiForm_do(c04b2c306b4dc6f4). (thePauseFormcxx . . $ thePauseForm..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), false); |
| 329 | return 0; |
| 330 | } |
| 331 | } |
| 332 | |
| 333 | void UiPause_pauseScriptcxx . . $ UiPause_pauseScript(2569ff2ad22a95d). (GuiWindowcxx . . $ GuiWindow# topShell, Editorcxx . . $ Editor# optionalPauseWindowOwningEditor, Interpretercxx . . $ Interpreter# interpreter, conststring32cxx . . $ conststring32# text) { |
| 334 | Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (interpreter); |
| 335 | if (interpreter -> isInSecondPasscxx . . $ structInterpreter#isInSecondPass.) { |
| 336 | Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (interpreter == thePauseForm_interpreterReference); |
| 337 | Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (! thePauseForm); |
| 338 | interpreter -> isInSecondPasscxx . . $ structInterpreter#isInSecondPass. = false; |
| 339 | } else { |
| 340 | if (thePauseFormcxx . . $ thePauseForm.) |
| 341 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (Melder_upperCaseAppName(), U" cannot have more than one pause form at a time."); |
| 342 | thePauseFormcxx . . $ thePauseForm. =cxx . . $ autoSomeThing#`operator=`(80cc59814f7161e8). UiForm_createcxx . . $ UiForm_create(b3c832b012a1002d). (topShell, optionalPauseWindowOwningEditor, U"Pause: stop or continue", |
| 343 | thePauseFormOkCallbackcxx . . $ thePauseFormOkCallback(744a0abd3c8513c)., interpreter, // pass interpreter as closure! |
| 344 | nullptr, nullptr |
| 345 | ); |
| 346 | UiForm_addCommentcxx . . $ UiForm_addComment(6d0ce7320d446690). (thePauseFormcxx . . $ thePauseForm..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), nullptr, text); |
| 347 | thePauseForm_interpreterReferencecxx . . $ thePauseForm_interpreterReference. = interpreter; |
| 348 | thePauseForm_savedEditorReferencecxx . . $ thePauseForm_savedEditorReference. = interpreter -> optionalDynamicEnvironmentEditorcxx . . $ structInterpreter#optionalDynamicEnvironmentEditor(480fba2ddcd094f3).(); |
| 349 | UiForm_setPauseFormcxx . . $ UiForm_setPauseForm(d24abb1496621b13). (thePauseFormcxx . . $ thePauseForm..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), 1, 1, 0, |
| 350 | U"Continue", nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, |
| 351 | thePauseFormCancelCallbackcxx . . $ thePauseFormCancelCallback(d12e536fc199ffc2). |
| 352 | ); |
| 353 | theCancelContinueButtoncxx . . $ theCancelContinueButton. = 0; |
| 354 | UiForm_finishcxx . . $ UiForm_finish(b4388889c5fb10c0). (thePauseFormcxx . . $ thePauseForm..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).()); |
| 355 | //if (theCurrentPraatApplication -> batch) goto end; |
| 356 | thePauseForm_clickedcxx . . $ thePauseForm_clicked. = 0; |
| 357 | Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (interpreter -> owningInterpreterStack); |
| 358 | interpreter -> owningInterpreterStackcxx . . $ structInterpreter#owningInterpreterStack. -> haltAllcxx . . $ structInterpreterStack#haltAll(49f6e7a06ebc5aa8). (); |
| 359 | /* |
| 360 | Put the pause form on the screen. |
| 361 | */ |
| 362 | UiForm_destroyWhenUnmanagedcxx . . $ UiForm_destroyWhenUnmanaged(b4388889c5fb10c0). (thePauseFormcxx . . $ thePauseForm..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).()); |
| 363 | UiForm_docxx . . $ UiForm_do(c04b2c306b4dc6f4). (thePauseFormcxx . . $ thePauseForm..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), false); |
| 364 | } |
| 365 | } |
| 366 | |
| 367 | void UiPause_cleanUpcxx . . $ UiPause_cleanUp(49f6e7a06ebc5aa8). () { |
| 368 | #if defined (macintosh) || 1 |
| 369 | thePauseFormcxx . . $ thePauseForm.. resetcxx . . $ autoSomeThing#reset(ced63f7c635d850d).(); // TODO: this works only if pause windows aren't children of editor windows |
| 370 | #else |
| 371 | thePauseForm. releaseToUser(); // BUG: potential memory leak (but it can be a child of an editor window) |
| 372 | #endif |
| 373 | thePauseForm_clickedcxx . . $ thePauseForm_clicked. = 0; |
| 374 | theCancelContinueButtoncxx . . $ theCancelContinueButton. = 0; |
| 375 | thePauseForm_interpreterReferencecxx . . $ thePauseForm_interpreterReference. = nullptr; |
| 376 | //thePauseForm_secondPass = false; // TODO: probably remove |
| 377 | MelderFolder_setToNullcxx . . $ MelderFolder_setToNull(63f38d3b6b86d1dc). (& thePauseForm_savedFoldercxx . . $ thePauseForm_savedFolder.); // TODO: probably remove |
| 378 | thePauseForm_savedEditorReferencecxx . . $ thePauseForm_savedEditorReference. = nullptr; |
| 379 | } |
| 380 | |
| 381 | /* End of file UiPause.cpp */ |