Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / chromeos / ime / gen_input_methods.py
index 7e3993d..31b1ea2 100755 (executable)
@@ -3,7 +3,7 @@
 # Use of this source code is governed by a BSD-style license that can be
 # found in the LICENSE file.
 
-"""Generate a C++ header from ibus_input_methods.txt.
+"""Generate a C++ header from input_methods.txt.
 
 This program generates a C++ header file containing the information on
 available input methods.  It parses input_methods.txt, and then generates a
@@ -16,8 +16,8 @@ Run it like:
 It will produce output that looks like:
 
 // This file is automatically generated by gen_input_methods.py
-#ifndef CHROME_BROWSER_CHROMEOS_INPUT_METHOD_INPUT_METHODS_H_
-#define CHROME_BROWSER_CHROMEOS_INPUT_METHOD_INPUT_METHODS_H_
+#ifndef CHROMEOS_IME_INPUT_METHODS_H_
+#define CHROMEOS_IME_INPUT_METHODS_H_
 
 namespace chromeos {
 namespace input_method {
@@ -26,20 +26,21 @@ struct InputMethodsInfo {
   const char* input_method_id;
   const char* language_code;
   const char* xkb_keyboard_id;
+  const char* indicator;
   bool is_login_keyboard;
 };
 const InputMethodsInfo kInputMethods[] = {
-  {"xkb:us::eng", "en-US", "us", true},
-  {"xkb:us:dvorak:eng", "en-US", "us(dvorak)", true},
-  {"xkb:be::fra", "fr", "be", true},
-  {"xkb:br::por", "pt-BR", "br", true},
-  {"xkb:ru::rus", "ru", "ru", false},
+  {"xkb:us::eng", "en-US", "us", "US", true},
+  {"xkb:us:dvorak:eng", "en-US", "us(dvorak)", "DV", true},
+  {"xkb:be::fra", "fr", "be", "BE", true},
+  {"xkb:br::por", "pt-BR", "br", "BR", true},
+  {"xkb:ru::rus", "ru", "ru", "RU", false},
 };
 
 }  // namespace input_method
 }  // namespace chromeos
 
-#endif  // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_INPUT_METHODS_H_
+#endif  // CHROMEOS_IME_INPUT_METHODS_H_
 
 """
 
@@ -48,8 +49,8 @@ import re
 import sys
 
 OUTPUT_HEADER = """// Automatically generated by gen_input_methods.py
-#ifndef CHROME_BROWSER_CHROMEOS_INPUT_METHOD_INPUT_METHODS_H_
-#define CHROME_BROWSER_CHROMEOS_INPUT_METHOD_INPUT_METHODS_H_
+#ifndef CHROMEOS_IME_INPUT_METHODS_H_
+#define CHROMEOS_IME_INPUT_METHODS_H_
 
 namespace chromeos {
 namespace input_method {
@@ -58,6 +59,7 @@ struct InputMethodsInfo {
   const char* input_method_id;
   const char* language_code;
   const char* xkb_layout_id;
+  const char* indicator;
   bool is_login_keyboard;
 };
 const InputMethodsInfo kInputMethods[] = {
@@ -65,7 +67,8 @@ const InputMethodsInfo kInputMethods[] = {
 
 CPP_FORMAT = '#if %s\n'
 ENGINE_FORMAT = ('  {"%(input_method_id)s", "%(language_code)s", ' +
-                 '"%(xkb_layout_id)s", %(is_login_keyboard)s},\n')
+                 '"%(xkb_layout_id)s", "%(indicator)s", ' +
+                 '%(is_login_keyboard)s},\n')
 
 OUTPUT_FOOTER = """
 };
@@ -73,7 +76,7 @@ OUTPUT_FOOTER = """
 }  // namespace input_method
 }  // namespace chromeos
 
-#endif  // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_INPUT_METHODS_H_
+#endif  // CHROMEOS_IME_INPUT_METHODS_H_
 """
 
 def CreateEngineHeader(engines):
@@ -107,14 +110,15 @@ def main(argv):
     if not line or re.match(r'#', line):
       continue
     columns = line.split()
-    assert len(columns) == 3 or len(columns) == 4, "Invalid format: " + line
+    assert len(columns) == 4 or len(columns) == 5, "Invalid format: " + line
     engine = {}
     engine['input_method_id'] = columns[0]
     engine['xkb_layout_id'] = columns[1]
     engine['language_code'] = columns[2]
+    engine['indicator'] = columns[3]
     is_login_keyboard = "false"
-    if len(columns) == 4:
-      assert columns[3] == "login", "Invalid attribute: " + columns[3]
+    if len(columns) == 5:
+      assert columns[4] == "login", "Invalid attribute: " + columns[4]
       is_login_keyboard = "true"
     engine['is_login_keyboard'] = is_login_keyboard
     engines.append(engine)