[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [kate] part/script/data: add accessor generator
From:       Christoph Cullmann <cullmann () kde ! org>
Date:       2012-10-31 22:58:55
Message-ID: 20121031225855.F2B51A6078 () git ! kde ! org
[Download RAW message or body]

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/commands/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 = 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 => { "n" => "Test", "p" => "Parent" }
      */
     var abbreviationObject = {};
-    for (i = 1; i < abbreviationParts.length; ++i) {
+    for (var i = 1; i < abbreviationParts.length; ++i) {
         var matches = abbreviationParts[i].match (/^(\w+):(.*)$/);
-        if (matches && matches[1] && matches[2])
+        if (matches && matches[1] && matches[2]) {
             abbreviationObject[matches[1]] = matches[2];
+        } else {
+            var matches = abbreviationParts[i].match (/^(\w+)$/);
+            if (matches && matches[1])
+                abbreviationObject[matches[1]] = true;
+        }
     }
     
     /**
diff --git a/part/script/data/files/quickcoding/cpp/a.template \
b/part/script/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 <%= n %>.
+ * @return <%= n %>
+ */
+<%= t %><% if (t.match(/\w$/)) { %> <% } %><%= n %> () const<% if (typeof(i)!== \
'undefined') { %> +{
+    return m_<%= n %>;
+}<% } else { %>;<% }%>
+
+/**
+ * Set value of <%= n %>.
+ * @param <%= n %> new value of <%= n %>
+ */
+void set<% n.capitalize(); %> (<%= t %> <%= n %>)<% if (typeof(i)!== 'undefined') { \
%> +{
+    m_<%= n %> = <%= n %>;
+}<% } else { %>;<% }%>


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic