mirror of
https://github.com/atom/atom.git
synced 2026-01-23 05:48:10 -05:00
Add OnigRegExp.getCaptureCount
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
})();
|
||||
|
||||
Reference in New Issue
Block a user