Added support for Javascript RegExp constructor from string.
git-svn-id: http://voip.null.ro/svn/yate@5825 acf43c95-373e-0410-b603-e72c3f656dc1
This commit is contained in:
parent
d2da267b16
commit
5704c84662
|
@ -1060,6 +1060,47 @@ bool JsRegExp::runNative(ObjList& stack, const ExpOperation& oper, GenObject* co
|
|||
return true;
|
||||
}
|
||||
|
||||
JsObject* JsRegExp::runConstructor(ObjList& stack, const ExpOperation& oper, GenObject* context)
|
||||
{
|
||||
ObjList args;
|
||||
switch (extractArgs(stack,oper,context,args)) {
|
||||
case 1:
|
||||
case 2:
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
ExpOperation* pattern = static_cast<ExpOperation*>(args[0]);
|
||||
ExpOperation* flags = static_cast<ExpOperation*>(args[1]);
|
||||
if (!pattern)
|
||||
return 0;
|
||||
bool insensitive = false;
|
||||
bool extended = true;
|
||||
if (flags) {
|
||||
const char* f = *flags;
|
||||
char c = *f++;
|
||||
while (c) {
|
||||
switch (c) {
|
||||
case 'i':
|
||||
c = *f++;
|
||||
insensitive = true;
|
||||
break;
|
||||
case 'b':
|
||||
c = *f++;
|
||||
extended = false;
|
||||
break;
|
||||
default:
|
||||
c = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!ref())
|
||||
return 0;
|
||||
JsRegExp* obj = new JsRegExp(mutex(),*pattern,*pattern,insensitive,extended);
|
||||
obj->params().addParam(new ExpWrapper(this,protoName()));
|
||||
return obj;
|
||||
}
|
||||
|
||||
|
||||
bool JsMath::runNative(ObjList& stack, const ExpOperation& oper, GenObject* context)
|
||||
{
|
||||
|
|
|
@ -2355,6 +2355,15 @@ public:
|
|||
inline Regexp& regexp()
|
||||
{ return m_regexp; }
|
||||
|
||||
/**
|
||||
* RegExp object constructor, it's run on the prototype
|
||||
* @param stack Evaluation stack in use
|
||||
* @param oper Constructor function to evaluate
|
||||
* @param context Pointer to arbitrary object passed from evaluation methods
|
||||
* @return New created and populated Javascript RegExp object
|
||||
*/
|
||||
virtual JsObject* runConstructor(ObjList& stack, const ExpOperation& oper, GenObject* context);
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Clone and rename method
|
||||
|
|
Loading…
Reference in New Issue