Add OnigRegExp.getCaptureCount

This commit is contained in:
Nathan Sobo
2012-08-06 18:27:14 -06:00
parent d495263b88
commit a85345e392
2 changed files with 11 additions and 0 deletions

View File

@@ -37,6 +37,10 @@ public:
return resultArray;
}
CefRefPtr<CefV8Value> CaptureCount() {
return CefV8Value::CreateInt([m_regex captureCount]);
}
OnigRegexp *m_regex;
IMPLEMENT_REFCOUNTING(OnigRegexpUserData);
@@ -63,6 +67,10 @@ bool OnigRegexpExtension::Execute(const CefString& name,
OnigRegexpUserData *userData = (OnigRegexpUserData *)object->GetUserData().get();
retval = userData->Search(string, index);
}
else if (name == "getCaptureCount") {
OnigRegexpUserData *userData = (OnigRegexpUserData *)object->GetUserData().get();
retval = userData->CaptureCount();
}
return true;
}

View File

@@ -1,15 +1,18 @@
(function() {
native function buildOnigRegExp(source);
native function search(string, index);
native function getCaptureCount();
function OnigRegExp(source) {
var regexp = buildOnigRegExp(source);
regexp.constructor = OnigRegExp;
regexp.__proto__ = OnigRegExp.prototype;
regexp.source = source;
return regexp;
}
OnigRegExp.prototype.search = search;
OnigRegExp.prototype.getCaptureCount = getCaptureCount;
this.OnigRegExp = OnigRegExp;
})();