Added Javascript string method charCodeAt.

git-svn-id: http://yate.null.ro/svn/yate/trunk@6097 acf43c95-373e-0410-b603-e72c3f656dc1
This commit is contained in:
paulc 2016-02-25 15:41:34 +00:00
parent 469cf9a61e
commit efb00bbe2f
1 changed files with 12 additions and 0 deletions

View File

@ -439,6 +439,7 @@ public:
{
append(new String("length"));
append(new String("charAt"));
append(new String("charCodeAt"));
append(new String("indexOf"));
append(new String("substr"));
append(new String("match"));
@ -683,6 +684,17 @@ bool JsContext::runStringFunction(GenObject* obj, const String& name, ObjList& s
ExpEvaluator::pushOne(stack,new ExpOperation(String(str->at(idx))));
return true;
}
if (name == YSTRING("charCodeAt")) {
int idx = 0;
ObjList args;
if (extractArgs(stack,oper,context,args)) {
ExpOperation* op = static_cast<ExpOperation*>(args[0]);
if (op && op->isInteger())
idx = (int)op->number();
}
ExpEvaluator::pushOne(stack,new ExpOperation(String((uint32_t)str->at(idx))));
return true;
}
if (name == YSTRING("indexOf")) {
int idx = -1;
ObjList args;