Showing the changes to libraries/script-engine/src/BaseScriptEngine.h (1 of 3 files). Show all
Unified · Split
| @@ -46,25 +46,6 @@ protected: · 45 unmodified lines | |||
| 46 | #ifdef DEBUG_JS | 46 | #ifdef DEBUG_JS |
| 47 | static void _debugDump(const QString& header, const QScriptValue& object, const QString& footer = QString()); | 47 | static void _debugDump(const QString& header, const QScriptValue& object, const QString& footer = QString()); |
| 48 | #endif | 48 | #endif |
| 49 | |||
| 50 | // ExceptionEmitter can be placed above calls that might throw JS exceptions and it'll | ||
| 51 | // automatically signal BaseScriptEngine when falling out of scope (recursion aware). | ||
| 52 | class ExceptionEmitter { | ||
| 53 | public: | ||
| 54 | ExceptionEmitter(BaseScriptEngine* engine, const QString& debugName = QString()); | ||
| 55 | // is there a pending exception? | ||
| 56 | bool hasPending(); | ||
| 57 | QScriptValue pending(); | ||
| 58 | // would it be emitted at scope's end? | ||
| 59 | bool wouldEmit(); | ||
| 60 | // consume and return the pending exception | ||
| 61 | QScriptValue consume(); | ||
| 62 | ~ExceptionEmitter(); | ||
| 63 | protected: | ||
| 64 | BaseScriptEngine* _engine; | ||
| 65 | QString _debugName; | ||
| 66 | QScriptValue _consumedException; | ||
| 67 | }; | ||
| 68 | }; | 49 | }; |
| 69 | 50 | ||
| 70 | // Lambda helps create callable QScriptValues out of std::functions: | 51 | // Lambda helps create callable QScriptValues out of std::functions: |