diff --git a/Atom/src/OnigRegexpExtension.mm b/Atom/src/OnigRegexpExtension.mm index 2a1a2bc06..956cc42e9 100644 --- a/Atom/src/OnigRegexpExtension.mm +++ b/Atom/src/OnigRegexpExtension.mm @@ -37,6 +37,10 @@ public: return resultArray; } + CefRefPtr 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; } diff --git a/src/stdlib/onig-reg-exp-extension.js b/src/stdlib/onig-reg-exp-extension.js index 80c471692..dd8485767 100644 --- a/src/stdlib/onig-reg-exp-extension.js +++ b/src/stdlib/onig-reg-exp-extension.js @@ -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; })();