diff options
Diffstat (limited to 'src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore')
-rw-r--r-- | src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.cpp | 11 | ||||
-rw-r--r-- | src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.h | 2 |
2 files changed, 9 insertions, 4 deletions
diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.cpp b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.cpp index 3a9cb27..b8ec2cc 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.cpp @@ -485,18 +485,21 @@ void JSCDataModel::setForeach(const std::string& item, bool JSCDataModel::isLocation(const std::string& expr) { // location needs to be RHS and ++ is only valid for RHS - JSStringRef scriptJS = JSStringCreateWithUTF8CString((expr + "++").c_str()); + return isValidSyntax(expr + "++"); +} + +bool JSCDataModel::isValidSyntax(const std::string& expr) { + JSStringRef scriptJS = JSStringCreateWithUTF8CString(expr.c_str()); JSValueRef exception = NULL; bool valid = JSCheckScriptSyntax(_ctx, scriptJS, NULL, 0, &exception); JSStringRelease(scriptJS); - + if (exception || !valid) { return false; } return true; } - - + bool JSCDataModel::isDeclared(const std::string& expr) { JSStringRef scriptJS = JSStringCreateWithUTF8CString(expr.c_str()); JSValueRef exception = NULL; diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.h b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.h index 6792130..10d5999 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.h +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.h @@ -50,6 +50,8 @@ public: virtual bool validate(const std::string& location, const std::string& schema); virtual bool isLocation(const std::string& expr); + virtual bool isValidSyntax(const std::string& expr); + virtual void setEvent(const Event& event); virtual Data getStringAsData(const std::string& content); |