 Chromium Code Reviews
 Chromium Code Reviews Issue 12041098:
  Initial commit of the Dart Chrome Extension APIs generators  (Closed) 
  Base URL: http://git.chromium.org/chromium/src.git@file_path_bugfix
    
  
    Issue 12041098:
  Initial commit of the Dart Chrome Extension APIs generators  (Closed) 
  Base URL: http://git.chromium.org/chromium/src.git@file_path_bugfix| OLD | NEW | 
|---|---|
| 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be | 
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. | 
| 4 | 4 | 
| 5 class Code(object): | 5 class Code(object): | 
| 6 """A convenience object for constructing code. | 6 """A convenience object for constructing code. | 
| 7 | 7 | 
| 8 Logically each object should be a block of code. All methods except |Render| | 8 Logically each object should be a block of code. All methods except |Render| | 
| 9 and |IsEmpty| return self. | 9 and |IsEmpty| return self. | 
| 10 """ | 10 """ | 
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 56 | 56 | 
| 57 def Sblock(self, line=''): | 57 def Sblock(self, line=''): | 
| 58 """Starts a code block. | 58 """Starts a code block. | 
| 59 | 59 | 
| 60 Appends a line of code and then increases the indent level. | 60 Appends a line of code and then increases the indent level. | 
| 61 """ | 61 """ | 
| 62 self.Append(line) | 62 self.Append(line) | 
| 63 self._indent_level += self._indent_size | 63 self._indent_level += self._indent_size | 
| 64 return self | 64 return self | 
| 65 | 65 | 
| 66 def SblockBare(self): | |
| 
not at google - send to devlin
2013/01/25 18:14:33
The nice thing about the other operations (with th
 
sashab
2013/01/29 08:27:13
Sure - I'm not going to change the default line ar
 
not at google - send to devlin
2013/01/29 16:37:08
Well, if Append didn't add a line given a blank ar
 
sashab
2013/02/04 05:09:27
Done.
 | |
| 67 """Starts a code block by increasing the indent, without adding a line. | |
| 68 """ | |
| 69 self._indent_level += self._indent_size | |
| 70 return self | |
| 71 | |
| 66 def Eblock(self, line=''): | 72 def Eblock(self, line=''): | 
| 67 """Ends a code block by decreasing and then appending a line (or a blank | 73 """Ends a code block by decreasing and then appending a line (or a blank | 
| 68 line if not given). | 74 line if not given). | 
| 69 """ | 75 """ | 
| 70 # TODO(calamity): Decide if type checking is necessary | 76 # TODO(calamity): Decide if type checking is necessary | 
| 71 #if not isinstance(line, basestring): | 77 #if not isinstance(line, basestring): | 
| 72 # raise TypeError | 78 # raise TypeError | 
| 73 self._indent_level -= self._indent_size | 79 self._indent_level -= self._indent_size | 
| 74 self.Append(line) | 80 self.Append(line) | 
| 75 return self | 81 return self | 
| 76 | 82 | 
| 83 def EblockBare(self): | |
| 84 """Ends a code block by decreasing the indent, without adding a line. | |
| 85 """ | |
| 86 self._indent_level -= self._indent_size | |
| 87 return self | |
| 88 | |
| 77 def Comment(self, comment, comment_prefix='// '): | 89 def Comment(self, comment, comment_prefix='// '): | 
| 78 """Adds the given string as a comment. | 90 """Adds the given string as a comment. | 
| 79 | 91 | 
| 80 Will split the comment if it's too long. Use mainly for variable length | 92 Will split the comment if it's too long. Use mainly for variable length | 
| 81 comments. Otherwise just use code.Append('// ...') for comments. | 93 comments. Otherwise just use code.Append('// ...') for comments. | 
| 82 | 94 | 
| 83 Unaffected by code.Substitute(). | 95 Unaffected by code.Substitute(). | 
| 84 """ | 96 """ | 
| 85 max_len = self._comment_length - self._indent_level - len(comment_prefix) | 97 max_len = self._comment_length - self._indent_level - len(comment_prefix) | 
| 86 while len(comment) >= max_len: | 98 while len(comment) >= max_len: | 
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 121 """Renders Code as a string. | 133 """Renders Code as a string. | 
| 122 """ | 134 """ | 
| 123 return '\n'.join([l.value for l in self._code]) | 135 return '\n'.join([l.value for l in self._code]) | 
| 124 | 136 | 
| 125 class Line(object): | 137 class Line(object): | 
| 126 """A line of code. | 138 """A line of code. | 
| 127 """ | 139 """ | 
| 128 def __init__(self, value, substitute=True): | 140 def __init__(self, value, substitute=True): | 
| 129 self.value = value | 141 self.value = value | 
| 130 self.substitute = substitute | 142 self.substitute = substitute | 
| OLD | NEW |