From beac5b2cd1336ec06ba58f2cd333a86201b40add Mon Sep 17 00:00:00 2001 From: marian Date: Fri, 4 Mar 2016 14:48:48 +0000 Subject: [PATCH] Allow changing RegExp case insensitive and basic posix properties. git-svn-id: http://yate.null.ro/svn/yate/trunk@6100 acf43c95-373e-0410-b603-e72c3f656dc1 --- libs/yscript/jsobjects.cpp | 13 +++++++++++++ libs/yscript/yatescript.h | 9 +++++++++ 2 files changed, 22 insertions(+) diff --git a/libs/yscript/jsobjects.cpp b/libs/yscript/jsobjects.cpp index 135d59b4..7af140a6 100644 --- a/libs/yscript/jsobjects.cpp +++ b/libs/yscript/jsobjects.cpp @@ -1187,6 +1187,19 @@ bool JsRegExp::runNative(ObjList& stack, const ExpOperation& oper, GenObject* co return true; } +bool JsRegExp::runAssign(ObjList& stack, const ExpOperation& oper, GenObject* context) +{ + XDebug(DebugAll,"JsRegExp::runAssign() '%s'='%s' (%s) in '%s' [%p]", + oper.name().c_str(),oper.c_str(),oper.typeOf(),toString().c_str(),this); + if (!JsObject::runAssign(stack,oper,context)) + return false; + if (oper.name() == YSTRING("ignoreCase")) + regexp().setFlags(regexp().isExtended(),oper.toBoolean()); + else if (oper.name() == YSTRING("basicPosix")) + regexp().setFlags(!oper.toBoolean(),regexp().isCaseInsensitive()); + return true; +} + JsObject* JsRegExp::runConstructor(ObjList& stack, const ExpOperation& oper, GenObject* context) { ObjList args; diff --git a/libs/yscript/yatescript.h b/libs/yscript/yatescript.h index 3f3ddb52..d2cdba43 100644 --- a/libs/yscript/yatescript.h +++ b/libs/yscript/yatescript.h @@ -2430,6 +2430,15 @@ public: inline Regexp& regexp() { return m_regexp; } + /** + * Try to assign a value to a single field + * @param stack Evaluation stack in use + * @param oper Field to assign to, contains the field name and new value + * @param context Pointer to arbitrary object passed from evaluation methods + * @return True if assignment succeeded + */ + virtual bool runAssign(ObjList& stack, const ExpOperation& oper, GenObject* context); + /** * RegExp object constructor, it's run on the prototype * @param stack Evaluation stack in use