From f8c9ebaa00d7636da09be9475489613ee5718bf9 Mon Sep 17 00:00:00 2001 From: azhornyak Date: Tue, 23 Feb 2021 15:26:11 +0200 Subject: [PATCH] option to check only ecma syntax --- .../JavaScriptCore/JSCDataModel.cpp | 42 +++++++++++-------- .../ecmascript/JavaScriptCore/JSCDataModel.h | 2 +- 2 files changed, 26 insertions(+), 18 deletions(-) diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.cpp b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.cpp index c900f946..c85a32c4 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.cpp @@ -318,17 +318,19 @@ namespace uscxml { JSObjectSetProperty(_ctx, JSContextGetGlobalObject(_ctx), ioProcName, jsIOProc, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete, NULL); JSStringRelease(ioProcName); - JSStringRef nameName = JSStringCreateWithUTF8CString("_name"); - JSStringRef name = JSStringCreateWithUTF8CString(uscxml::fromLocaleToUtf8(_callbacks->getName()).c_str()); - JSObjectSetProperty(_ctx, JSContextGetGlobalObject(_ctx), nameName, JSValueMakeString(_ctx, name), kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete, NULL); - JSStringRelease(nameName); - JSStringRelease(name); - - JSStringRef sessionIdName = JSStringCreateWithUTF8CString("_sessionid"); - JSStringRef sessionId = JSStringCreateWithUTF8CString(uscxml::fromLocaleToUtf8(_callbacks->getSessionId()).c_str()); - JSObjectSetProperty(_ctx, JSContextGetGlobalObject(_ctx), sessionIdName, JSValueMakeString(_ctx, sessionId), kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete, NULL); - JSStringRelease(sessionIdName); - JSStringRelease(sessionId); + if (_callbacks) { + JSStringRef nameName = JSStringCreateWithUTF8CString("_name"); + JSStringRef name = JSStringCreateWithUTF8CString(uscxml::fromLocaleToUtf8(_callbacks->getName()).c_str()); + JSObjectSetProperty(_ctx, JSContextGetGlobalObject(_ctx), nameName, JSValueMakeString(_ctx, name), kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete, NULL); + JSStringRelease(nameName); + JSStringRelease(name); + + JSStringRef sessionIdName = JSStringCreateWithUTF8CString("_sessionid"); + JSStringRef sessionId = JSStringCreateWithUTF8CString(uscxml::fromLocaleToUtf8(_callbacks->getSessionId()).c_str()); + JSObjectSetProperty(_ctx, JSContextGetGlobalObject(_ctx), sessionIdName, JSValueMakeString(_ctx, sessionId), kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete, NULL); + JSStringRelease(sessionIdName); + JSStringRelease(sessionId); + } evalAsValue("_x = {};"); } @@ -671,12 +673,18 @@ namespace uscxml { JSStringRelease(scriptJS); if (exception) { - try { - handleException(exception, script); - } - catch (uscxml::ErrorEvent &e) { - LOG(_callbacks->getLogger(), USCXML_ERROR) << e << std::endl; + if (_callbacks) { + try { + handleException(exception, script); + } + catch (uscxml::ErrorEvent &e) { + LOG(_callbacks->getLogger(), USCXML_ERROR) << e << std::endl; + } } + else { + /* option to use for external syntax check */ + handleException(exception, script); + } return false; } @@ -830,7 +838,7 @@ namespace uscxml { e.name = "error.execution"; e.eventType = uscxml::Event::PLATFORM; - if (!_callbacks->getName().empty()) { + if (_callbacks && !_callbacks->getName().empty()) { e.data.compound["interpreter"] = Data(_callbacks->getName(), Data::VERBATIM); } if (!description.empty()) { diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.h b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.h index 70c71d28..75affdec 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.h +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.h @@ -50,7 +50,7 @@ namespace uscxml { * * ECMAScript data-model via JavaScriptCore. */ -class JSCDataModel : public DataModelImpl { +class USCXML_API JSCDataModel : public DataModelImpl { public: JSCDataModel(); virtual ~JSCDataModel();