From a85345e392256851295ee3a85a4abbb27da81030 Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Mon, 6 Aug 2012 18:27:14 -0600 Subject: [PATCH] Add OnigRegExp.getCaptureCount --- Atom/src/OnigRegexpExtension.mm | 8 ++++++++ src/stdlib/onig-reg-exp-extension.js | 3 +++ 2 files changed, 11 insertions(+) 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; })();