From kde-commits Wed Oct 31 22:58:55 2012 From: Christoph Cullmann Date: Wed, 31 Oct 2012 22:58:55 +0000 To: kde-commits Subject: [kate] part/script/data: add accessor generator Message-Id: <20121031225855.F2B51A6078 () git ! kde ! org> X-MARC-Message: https://marc.info/?l=kde-commits&m=135172434431603 Git commit 6f5a9245fbc43f8297af495fde34c704559e4b15 by Christoph Cullmann. Committed on 31/10/2012 at 23:58. Pushed by cullmann into branch 'master'. add accessor generator M +14 -2 part/script/data/commands/quickcoding.js A +17 -0 part/script/data/files/quickcoding/cpp/a.template http://commits.kde.org/kate/6f5a9245fbc43f8297af495fde34c704559e4b15 diff --git a/part/script/data/commands/quickcoding.js b/part/script/data/co= mmands/quickcoding.js index 9ac0d77..e0fb6e2 100644 --- a/part/script/data/commands/quickcoding.js +++ b/part/script/data/commands/quickcoding.js @@ -34,6 +34,13 @@ function help (cmd) } = /** + * We want a capitalize function for strings + */ +String.prototype.capitalize =3D function() { + return this.charAt(0).toUpperCase() + this.slice(1); +} + +/** * cpp expansion command */ function quickCodingExpand () @@ -84,10 +91,15 @@ function quickCodingExpand () * e.g. for c#n:Test#p:Parent =3D> { "n" =3D> "Test", "p" =3D> "Parent= " } */ var abbreviationObject =3D {}; - for (i =3D 1; i < abbreviationParts.length; ++i) { + for (var i =3D 1; i < abbreviationParts.length; ++i) { var matches =3D abbreviationParts[i].match (/^(\w+):(.*)$/); - if (matches && matches[1] && matches[2]) + if (matches && matches[1] && matches[2]) { abbreviationObject[matches[1]] =3D matches[2]; + } else { + var matches =3D abbreviationParts[i].match (/^(\w+)$/); + if (matches && matches[1]) + abbreviationObject[matches[1]] =3D true; + } } = /** diff --git a/part/script/data/files/quickcoding/cpp/a.template b/part/scrip= t/data/files/quickcoding/cpp/a.template new file mode 100644 index 0000000..68574de --- /dev/null +++ b/part/script/data/files/quickcoding/cpp/a.template @@ -0,0 +1,17 @@ +/** + * Get value of <%=3D n %>. + * @return <%=3D n %> + */ +<%=3D t %><% if (t.match(/\w$/)) { %> <% } %><%=3D n %> () const<% if (typ= eof(i)!=3D=3D 'undefined') { %> +{ + return m_<%=3D n %>; +}<% } else { %>;<% }%> + +/** + * Set value of <%=3D n %>. + * @param <%=3D n %> new value of <%=3D n %> + */ +void set<% n.capitalize(); %> (<%=3D t %> <%=3D n %>)<% if (typeof(i)!=3D= =3D 'undefined') { %> +{ + m_<%=3D n %> =3D <%=3D n %>; +}<% } else { %>;<% }%>