[Webkit-unassigned] [Bug 72835] Web Inspector: [protocol] generate C++ classes for protocol JSON named types
bugzilla-daemon at webkit.org
bugzilla-daemon at webkit.org
Mon Dec 5 15:06:10 PST 2011
https://bugs.webkit.org/show_bug.cgi?id=72835
--- Comment #27 from Andrey Kosyakov <caseq at chromium.org> 2011-12-05 15:06:10 PST ---
(From update of attachment 117803)
View in context: https://bugs.webkit.org/attachment.cgi?id=117803&action=review
> Source/WebCore/inspector/CodeGeneratorInspector.py:110
> + def lower_camel_case_to_upper(str):
> + if len(str) > 0 and str[0].islower():
> + str = str[0].upper() + str[1:]
> + return str
String.capitalize()?
> Source/WebCore/inspector/CodeGeneratorInspector.py:138
> + pos = 0
> + while pos < len(output):
> + output[pos] = output[pos].upper()
> + pos += 1
> + return "_".join(output)
Why not just "_".join(output).upper()?
> Source/WebCore/inspector/CodeGeneratorInspector.py:152
> + def split_camel_case_(str):
> + output = []
> + pos_being = 0
> + pos = 1
> + has_oneletter = False
> + while pos < len(str):
> + if str[pos].isupper():
> + output.append(str[pos_being:pos].upper())
> + if pos - pos_being == 1:
> + has_oneletter = True
> + pos_being = pos
> + pos += 1
This looks as it were ported from COBOL. Can this be rewritten into python -- e.g., use regexps?
> Source/WebCore/inspector/CodeGeneratorInspector.py:459
> + output.append("namespace ")
> + output.append(json_type["id"])
> + output.append(" {\n")
Consider using interpolation for better readability.
> Source/WebCore/inspector/CodeGeneratorInspector.py:466
> + item_c_name = enum_item.replace('-', '_')
> + output.append("const char* const ")
> + output.append(Capitalizer.upper_camel_case_to_lower(item_c_name))
> + output.append(" = \"")
> + output.append(enum_item)
> + output.append("\";\n")
ditto
> Source/WebCore/inspector/CodeGeneratorInspector.py:732
> + def fill_recursive(path_part, depth):
> + if depth <= 0 or path_part == '/':
> + return
> + fill_recursive(os.path.dirname(path_part), depth - 1)
> + components.append(os.path.basename(path_part))
Does this have to be recursive? Also, consider os.path.split(). Or, given that you join them back with "/".join() below, you could as well have used a regexp.
--
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
More information about the webkit-unassigned
mailing list