Commit 9610607d authored by mkosiba's avatar mkosiba Committed by Commit bot

New C++ -> Java enum build rule + parser/generator.

This adds a new build rule for generating Java constants for C++ enums.

BUG=405532
TBR=brettw@chromium.org

Review URL: https://codereview.chromium.org/484603004

Cr-Commit-Position: refs/heads/master@{#294153}
parent 7ae48608
......@@ -39,6 +39,8 @@ LOCAL_SRC_FILES += \
# Java files generated from .template rules. This list should match list of java dependencies in
# android_webview/android_webview.gyp
LOCAL_GENERATED_SOURCES := \
$(call intermediates-dir-for,GYP,shared)/enums/org/chromium/ui/WindowOpenDisposition.java \
$(call intermediates-dir-for,GYP,shared)/enums/org/chromium/ui/gfx/BitmapFormat.java \
$(call intermediates-dir-for,GYP,shared)/templates/org/chromium/base/ApplicationState.java \
$(call intermediates-dir-for,GYP,shared)/templates/org/chromium/base/MemoryPressureLevelList.java \
$(call intermediates-dir-for,GYP,shared)/templates/org/chromium/content/browser/GestureEventType.java \
......@@ -55,8 +57,6 @@ $(call intermediates-dir-for,GYP,shared)/templates/org/chromium/net/CertificateM
$(call intermediates-dir-for,GYP,shared)/templates/org/chromium/net/CertVerifyStatusAndroid.java \
$(call intermediates-dir-for,GYP,shared)/templates/org/chromium/net/NetError.java \
$(call intermediates-dir-for,GYP,shared)/templates/org/chromium/net/PrivateKeyType.java \
$(call intermediates-dir-for,GYP,shared)/templates/org/chromium/ui/WindowOpenDisposition.java \
$(call intermediates-dir-for,GYP,shared)/templates/org/chromium/ui/gfx/BitmapFormat.java \
# content dependencies on java components that are provided by the system on
# android
......
#!/usr/bin/env python
#
# Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import collections
import re
import optparse
import os
from string import Template
import sys
from util import build_utils
class EnumDefinition(object):
def __init__(self, class_name=None, class_package=None, entries=None):
self.class_name = class_name
self.class_package = class_package
self.entries = collections.OrderedDict(entries or [])
self.prefix_to_strip = ''
def AppendEntry(self, key, value):
if key in self.entries:
raise Exception('Multiple definitions of key %s found.' % key)
self.entries[key] = value
def Finalize(self):
self._Validate()
self._AssignEntryIndices()
self._StripPrefix()
def _Validate(self):
assert self.class_name
assert self.class_package
assert self.entries
def _AssignEntryIndices(self):
# Supporting the same set enum value assignments the compiler does is rather
# complicated, so we limit ourselves to these cases:
# - all the enum constants have values assigned,
# - enum constants reference other enum constants or have no value assigned.
if not all(self.entries.values()):
index = 0
for key, value in self.entries.iteritems():
if not value:
self.entries[key] = index
index = index + 1
elif value in self.entries:
self.entries[key] = self.entries[value]
else:
raise Exception('You can only reference other enum constants unless '
'you assign values to all of the constants.')
def _StripPrefix(self):
if not self.prefix_to_strip:
prefix_to_strip = re.sub('(?!^)([A-Z]+)', r'_\1', self.class_name).upper()
prefix_to_strip += '_'
if not all([w.startswith(prefix_to_strip) for w in self.entries.keys()]):
prefix_to_strip = ''
else:
prefix_to_strip = self.prefix_to_strip
entries = ((k.replace(prefix_to_strip, '', 1), v) for (k, v) in
self.entries.iteritems())
self.entries = collections.OrderedDict(entries)
class HeaderParser(object):
single_line_comment_re = re.compile(r'\s*//')
multi_line_comment_start_re = re.compile(r'\s*/\*')
enum_start_re = re.compile(r'^\s*enum\s+(\w+)\s+{\s*$')
enum_line_re = re.compile(r'^\s*(\w+)(\s*\=\s*([^,\n]+))?,?\s*$')
enum_end_re = re.compile(r'^\s*}\s*;\s*$')
generator_directive_re = re.compile(
r'^\s*//\s+GENERATED_JAVA_(\w+)\s*:\s*([\.\w]+)$')
def __init__(self, lines):
self._lines = lines
self._enum_definitions = []
self._in_enum = False
self._current_definition = None
self._generator_directives = {}
def ParseDefinitions(self):
for line in self._lines:
self._ParseLine(line)
return self._enum_definitions
def _ParseLine(self, line):
if not self._in_enum:
self._ParseRegularLine(line)
else:
self._ParseEnumLine(line)
def _ParseEnumLine(self, line):
if HeaderParser.single_line_comment_re.match(line):
return
if HeaderParser.multi_line_comment_start_re.match(line):
raise Exception('Multi-line comments in enums are not supported.')
enum_end = HeaderParser.enum_end_re.match(line)
enum_entry = HeaderParser.enum_line_re.match(line)
if enum_end:
self._ApplyGeneratorDirectives()
self._current_definition.Finalize()
self._enum_definitions.append(self._current_definition)
self._in_enum = False
elif enum_entry:
enum_key = enum_entry.groups()[0]
enum_value = enum_entry.groups()[2]
self._current_definition.AppendEntry(enum_key, enum_value)
def _GetCurrentEnumPackageName(self):
return self._generator_directives.get('ENUM_PACKAGE')
def _GetCurrentEnumPrefixToStrip(self):
return self._generator_directives.get('PREFIX_TO_STRIP', '')
def _ApplyGeneratorDirectives(self):
current_definition = self._current_definition
current_definition.class_package = self._GetCurrentEnumPackageName()
current_definition.prefix_to_strip = self._GetCurrentEnumPrefixToStrip()
self._generator_directives = {}
def _ParseRegularLine(self, line):
enum_start = HeaderParser.enum_start_re.match(line)
generator_directive = HeaderParser.generator_directive_re.match(line)
if enum_start:
if not self._GetCurrentEnumPackageName():
return
self._current_definition = EnumDefinition()
self._current_definition.class_name = enum_start.groups()[0]
self._in_enum = True
elif generator_directive:
directive_name = generator_directive.groups()[0]
directive_value = generator_directive.groups()[1]
self._generator_directives[directive_name] = directive_value
def GetScriptName():
script_components = os.path.abspath(sys.argv[0]).split(os.path.sep)
build_index = script_components.index('build')
return os.sep.join(script_components[build_index:])
def DoGenerate(options, source_paths):
output_paths = []
for source_path in source_paths:
enum_definitions = DoParseHeaderFile(source_path)
for enum_definition in enum_definitions:
package_path = enum_definition.class_package.replace('.', os.path.sep)
file_name = enum_definition.class_name + '.java'
output_path = os.path.join(options.output_dir, package_path, file_name)
output_paths.append(output_path)
if not options.print_output_only:
build_utils.MakeDirectory(os.path.dirname(output_path))
DoWriteOutput(source_path, output_path, enum_definition)
return output_paths
def DoParseHeaderFile(path):
with open(path) as f:
return HeaderParser(f.readlines()).ParseDefinitions()
def GenerateOutput(source_path, enum_definition):
template = Template("""
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// This file is autogenerated by
// ${SCRIPT_NAME}
// From
// ${SOURCE_PATH}
package ${PACKAGE};
public class ${CLASS_NAME} {
${ENUM_ENTRIES}
}
""")
enum_template = Template(' public static final int ${NAME} = ${VALUE};')
enum_entries_string = []
for enum_name, enum_value in enum_definition.entries.iteritems():
values = {
'NAME': enum_name,
'VALUE': enum_value,
}
enum_entries_string.append(enum_template.substitute(values))
enum_entries_string = '\n'.join(enum_entries_string)
values = {
'CLASS_NAME': enum_definition.class_name,
'ENUM_ENTRIES': enum_entries_string,
'PACKAGE': enum_definition.class_package,
'SCRIPT_NAME': GetScriptName(),
'SOURCE_PATH': source_path,
}
return template.substitute(values)
def DoWriteOutput(source_path, output_path, enum_definition):
with open(output_path, 'w') as out_file:
out_file.write(GenerateOutput(source_path, enum_definition))
def AssertFilesList(output_paths, assert_files_list):
actual = set(output_paths)
expected = set(assert_files_list)
if not actual == expected:
need_to_add = list(actual - expected)
need_to_remove = list(expected - actual)
raise Exception('Output files list does not match expectations. Please '
'add %s and remove %s.' % (need_to_add, need_to_remove))
def DoMain(argv):
parser = optparse.OptionParser()
parser.add_option('--assert_file', action="append", default=[],
dest="assert_files_list", help='Assert that the given '
'file is an output. There can be multiple occurrences of '
'this flag.')
parser.add_option('--output_dir', help='Base path for generated files.')
parser.add_option('--print_output_only', help='Only print output paths.',
action='store_true')
options, args = parser.parse_args(argv)
output_paths = DoGenerate(options, args)
if options.assert_files_list:
AssertFilesList(output_paths, options.assert_files_list)
return " ".join(output_paths)
if __name__ == '__main__':
DoMain(sys.argv[1:])
#!/usr/bin/env python
# Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""Tests for enum_preprocess.py.
This test suite containss various tests for the C++ -> Java enum generator.
"""
import collections
import unittest
from java_cpp_enum import EnumDefinition, GenerateOutput, HeaderParser
class TestPreprocess(unittest.TestCase):
def testOutput(self):
definition = EnumDefinition(class_name='ClassName',
class_package='some.package',
entries=[('E1', 1), ('E2', '2 << 2')])
output = GenerateOutput('path/to/file', definition)
expected = """
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// This file is autogenerated by
// build/android/gyp/java_cpp_enum_tests.py
// From
// path/to/file
package some.package;
public class ClassName {
public static final int E1 = 1;
public static final int E2 = 2 << 2;
}
"""
self.assertEqual(expected, output)
def testParseSimpleEnum(self):
test_data = """
// GENERATED_JAVA_ENUM_PACKAGE: test.namespace
enum EnumName {
VALUE_ZERO,
VALUE_ONE,
};
""".split('\n')
definitions = HeaderParser(test_data).ParseDefinitions()
self.assertEqual(1, len(definitions))
definition = definitions[0]
self.assertEqual('EnumName', definition.class_name)
self.assertEqual('test.namespace', definition.class_package)
self.assertEqual(collections.OrderedDict([('VALUE_ZERO', 0),
('VALUE_ONE', 1)]),
definition.entries)
def testParseTwoEnums(self):
test_data = """
// GENERATED_JAVA_ENUM_PACKAGE: test.namespace
enum EnumOne {
ENUM_ONE_A = 1,
// Comment there
ENUM_ONE_B = A,
};
enum EnumIgnore {
C, D, E
};
// GENERATED_JAVA_ENUM_PACKAGE: other.package
// GENERATED_JAVA_PREFIX_TO_STRIP: P_
enum EnumTwo {
P_A,
P_B
};
""".split('\n')
definitions = HeaderParser(test_data).ParseDefinitions()
self.assertEqual(2, len(definitions))
definition = definitions[0]
self.assertEqual('EnumOne', definition.class_name)
self.assertEqual('test.namespace', definition.class_package)
self.assertEqual(collections.OrderedDict([('A', '1'),
('B', 'A')]),
definition.entries)
definition = definitions[1]
self.assertEqual('EnumTwo', definition.class_name)
self.assertEqual('other.package', definition.class_package)
self.assertEqual(collections.OrderedDict([('A', 0),
('B', 1)]),
definition.entries)
def testEnumValueAssignmentNoneDefined(self):
definition = EnumDefinition('c', 'p', [])
definition.AppendEntry('A', None)
definition.AppendEntry('B', None)
definition.AppendEntry('C', None)
definition.Finalize()
self.assertEqual(collections.OrderedDict([('A', 0),
('B', 1),
('C', 2)]),
definition.entries)
def testEnumValueAssignmentAllDefined(self):
definition = EnumDefinition('c', 'p', [])
definition.AppendEntry('A', '1')
definition.AppendEntry('B', '2')
definition.AppendEntry('C', '3')
definition.Finalize()
self.assertEqual(collections.OrderedDict([('A', '1'),
('B', '2'),
('C', '3')]),
definition.entries)
def testEnumValueAssignmentReferences(self):
definition = EnumDefinition('c', 'p', [])
definition.AppendEntry('A', None)
definition.AppendEntry('B', 'A')
definition.AppendEntry('C', None)
definition.AppendEntry('D', 'C')
definition.Finalize()
self.assertEqual(collections.OrderedDict([('A', 0),
('B', 0),
('C', 1),
('D', 1)]),
definition.entries)
def testEnumValueAssignmentRaises(self):
definition = EnumDefinition('c', 'p', [])
definition.AppendEntry('A', None)
definition.AppendEntry('B', '1')
definition.AppendEntry('C', None)
with self.assertRaises(Exception):
definition.Finalize()
def testExplicitPrefixStripping(self):
definition = EnumDefinition('c', 'p', [])
definition.AppendEntry('P_A', None)
definition.AppendEntry('B', None)
definition.AppendEntry('P_C', None)
definition.prefix_to_strip = 'P_'
definition.Finalize()
self.assertEqual(['A', 'B', 'C'], definition.entries.keys())
def testImplicitPrefixStripping(self):
definition = EnumDefinition('ClassName', 'p', [])
definition.AppendEntry('CLASS_NAME_A', None)
definition.AppendEntry('CLASS_NAME_B', None)
definition.AppendEntry('CLASS_NAME_C', None)
definition.Finalize()
self.assertEqual(['A', 'B', 'C'], definition.entries.keys())
def testImplicitPrefixStrippingRequiresAllConstantsToBePrefixed(self):
definition = EnumDefinition('Name', 'p', [])
definition.AppendEntry('A', None)
definition.AppendEntry('B', None)
definition.AppendEntry('NAME_LAST', None)
definition.Finalize()
self.assertEqual(['A', 'B', 'NAME_LAST'], definition.entries.keys())
if __name__ == '__main__':
unittest.main()
# Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# This file is meant to be included into a target to provide an action
# to generate Java source files from a C++ header file containing annotated
# enum definitions using a Python script.
#
# To use this, create a gyp target with the following form:
# {
# 'target_name': 'bitmap_format_java',
# 'type': 'none',
# 'variables': {
# 'source_file': 'ui/android/bitmap_format.h',
# },
# 'includes': [ '../build/android/java_cpp_enum.gypi' ],
# },
#
# Then have the gyp target which compiles the java code depend on the newly
# created target.
{
'variables': {
# Location where all generated Java sources will be placed.
'output_dir': '<(SHARED_INTERMEDIATE_DIR)/enums',
'generator_path': '<(DEPTH)/build/android/gyp/java_cpp_enum.py',
'generator_args': '--output_dir=<(output_dir) <(source_file)',
},
'direct_dependent_settings': {
'variables': {
# Ensure that the output directory is used in the class path
# when building targets that depend on this one.
'generated_src_dirs': [
'<(output_dir)/',
],
},
},
'actions': [
{
'action_name': 'generate_java_constants',
'inputs': [
'<(DEPTH)/build/android/gyp/util/build_utils.py',
'<(generator_path)',
'<(source_file)',
],
'outputs': [
# This is the main reason this is an action and not a rule. Gyp doesn't
# properly expand RULE_INPUT_PATH here and so it's impossible to
# calculate the list of outputs.
'<!@pymod_do_main(java_cpp_enum --print_output_only '
'<@(generator_args))',
],
'action': [
'python', '<(generator_path)', '<@(generator_args)'
],
'message': 'Generating Java from cpp header <(source_file)',
},
],
}
......@@ -261,6 +261,71 @@ template("java_cpp_template") {
}
}
# Declare a target for generating Java classes from C++ enums.
#
# This target generates Java files from C++ enums using a script.
#
# This target will create a single .srcjar. Adding this target to an
# android_library target's srcjar_deps will make the generated java files be
# included in that library's final outputs.
#
# Variables
# sources: list of files to be processed by the script. For each annotated
# enum contained in the sources files the script will generate a .java
# file with the same name as the name of the enum.
#
# outputs: list of outputs, relative to the output_dir. These paths are
# verified at build time by the script. To get the list programatically run:
# python build/android/gyp/java_cpp_enum.py --output_dir=. \
# --print_output_only path/to/header/file.h
#
# Example
# java_cpp_enum("foo_generated_enum") {
# sources = [
# "src/native_foo_header.h",
# ]
# outputs = [
# "org/chromium/FooEnum.java",
# ]
# }
template("java_cpp_enum") {
assert(defined(invoker.sources))
assert(defined(invoker.outputs))
action("${target_name}__generate_enum") {
sources = rebase_path(invoker.sources, root_build_dir)
script = "//build/android/gyp/java_cpp_enum.py"
gen_dir = "${target_gen_dir}/${target_name}/enums"
outputs = get_path_info(
rebase_path(invoker.outputs, ".", gen_dir), "abspath")
args = [
"--output_dir", rebase_path(gen_dir, root_build_dir),
]
foreach(output, rebase_path(outputs, root_build_dir)) {
args += ["--assert_file", output]
}
args += sources
}
generate_enum_outputs = get_target_outputs(":${target_name}__generate_enum")
base_gen_dir = get_label_info(":${target_name}__generate_enum",
"target_gen_dir")
srcjar_path = "${target_gen_dir}/${target_name}.srcjar"
zip("${target_name}__zip_srcjar") {
inputs = generate_enum_outputs
output = srcjar_path
base_dir = base_gen_dir
}
group(target_name) {
deps = [
":${target_name}__zip_srcjar"
]
}
}
# Declare an Android resources target
#
......
......@@ -27,6 +27,7 @@ import gyp
SRC_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# Add paths so that pymod_do_main(...) can import files.
sys.path.insert(1, os.path.join(chrome_src, 'build', 'android', 'gyp'))
sys.path.insert(1, os.path.join(chrome_src, 'tools'))
sys.path.insert(1, os.path.join(chrome_src, 'tools', 'generate_shim_headers'))
sys.path.insert(1, os.path.join(chrome_src, 'tools', 'grit'))
......
......@@ -2,23 +2,14 @@ import("//build/config/android/rules.gni")
assert(is_android)
java_cpp_template("window_open_disposition_srcjar") {
package_name = "org/chromium/ui"
java_cpp_enum("java_enums_srcjar") {
sources = [
"java/WindowOpenDisposition.template",
"../base/window_open_disposition.h",
"../gfx/android/java_bitmap.h",
]
inputs = [
"../base/window_open_disposition_list.h"
]
}
java_cpp_template("bitmap_format_srcjar") {
package_name = "org/chromium/ui/gfx"
sources = [
"java/BitmapFormat.template",
]
inputs = [
"../gfx/android/bitmap_config_list.h"
outputs = [
"org/chromium/ui/WindowOpenDisposition.java",
"org/chromium/ui/gfx/BitmapFormat.java",
]
}
......@@ -121,7 +112,6 @@ android_library("ui_java") {
"//base:base_java",
]
srcjar_deps = [
":window_open_disposition_srcjar",
":bitmap_format_srcjar",
":java_enums_srcjar",
]
}
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package org.chromium.ui.gfx;
// A simple auto-generated interface used to maintain the various
// bitmap configurations as used by both org.chromium.ui.BitmapFormat
// and ui/gfx/android/java_bitmap.h
public interface BitmapFormat {
#define DEFINE_BITMAP_CONFIG(x,y) public final int x = y;
#include "ui/gfx/android/bitmap_config_list.h"
#undef DEFINE_BITMAP_CONFIG
}
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package org.chromium.ui;
public class WindowOpenDisposition {
#define WINDOW_OPEN_DISPOSITION(label, value) public static final int label = value;
#include "ui/base/window_open_disposition_list.h"
#undef WINDOW_OPEN_DISPOSITION
}
\ No newline at end of file
......@@ -85,15 +85,15 @@ public class BitmapHelper {
private static int getBitmapFormatForConfig(Bitmap.Config bitmapConfig) {
switch (bitmapConfig) {
case ALPHA_8:
return BitmapFormat.FORMAT_ALPHA_8;
return BitmapFormat.ALPHA_8;
case ARGB_4444:
return BitmapFormat.FORMAT_ARGB_4444;
return BitmapFormat.ARGB_4444;
case ARGB_8888:
return BitmapFormat.FORMAT_ARGB_8888;
return BitmapFormat.ARGB_8888;
case RGB_565:
return BitmapFormat.FORMAT_RGB_565;
return BitmapFormat.RGB_565;
default:
return BitmapFormat.FORMAT_NO_CONFIG;
return BitmapFormat.NO_CONFIG;
}
}
......@@ -105,13 +105,13 @@ public class BitmapHelper {
*/
private static Bitmap.Config getBitmapConfigForFormat(int bitmapFormatValue) {
switch (bitmapFormatValue) {
case BitmapFormat.FORMAT_ALPHA_8:
case BitmapFormat.ALPHA_8:
return Bitmap.Config.ALPHA_8;
case BitmapFormat.FORMAT_ARGB_4444:
case BitmapFormat.ARGB_4444:
return Bitmap.Config.ARGB_4444;
case BitmapFormat.FORMAT_RGB_565:
case BitmapFormat.RGB_565:
return Bitmap.Config.RGB_565;
case BitmapFormat.FORMAT_ARGB_8888:
case BitmapFormat.ARGB_8888:
default:
return Bitmap.Config.ARGB_8888;
}
......
......@@ -8,28 +8,20 @@
},
'targets': [
{
'target_name': 'window_open_disposition_java',
'target_name': 'bitmap_format_java',
'type': 'none',
'sources': [
'java/WindowOpenDisposition.template',
],
'variables': {
'package_name': 'org/chromium/ui',
'template_deps': ['../base/window_open_disposition_list.h'],
'source_file': '../gfx/android/java_bitmap.h',
},
'includes': [ '../../build/android/java_cpp_template.gypi' ],
'includes': [ '../../build/android/java_cpp_enum.gypi' ],
},
{
'target_name': 'bitmap_format_java',
'target_name': 'window_open_disposition_java',
'type': 'none',
'sources': [
'java/BitmapFormat.template',
],
'variables': {
'package_name': 'org/chromium/ui/gfx',
'template_deps': ['../gfx/android/bitmap_config_list.h'],
'source_file': '../base/window_open_disposition.h',
},
'includes': [ '../../build/android/java_cpp_template.gypi' ],
'includes': [ '../../build/android/java_cpp_enum.gypi' ],
},
{
'target_name': 'ui_java',
......
......@@ -7,12 +7,23 @@
#include "ui/base/ui_base_export.h"
// A Java counterpart will be generated for this enum.
// GENERATED_JAVA_ENUM_PACKAGE: org.chromium.ui
enum WindowOpenDisposition {
#define WINDOW_OPEN_DISPOSITION(label, value) label = value,
#include "window_open_disposition_list.h"
#undef WINDOW_OPEN_DISPOSITION
UNKNOWN,
SUPPRESS_OPEN,
CURRENT_TAB,
// Indicates that only one tab with the url should exist in the same window.
SINGLETON_TAB,
NEW_FOREGROUND_TAB,
NEW_BACKGROUND_TAB,
NEW_POPUP,
NEW_WINDOW,
SAVE_TO_DISK,
OFF_THE_RECORD,
IGNORE_ACTION,
// Update when adding a new disposition.
WINDOW_OPEN_DISPOSITION_LAST = IGNORE_ACTION
};
namespace ui {
......
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Intentionally no include guards because this file is meant to be included
// inside a macro to generate enum values.
WINDOW_OPEN_DISPOSITION(UNKNOWN, 0)
WINDOW_OPEN_DISPOSITION(SUPPRESS_OPEN, 1)
WINDOW_OPEN_DISPOSITION(CURRENT_TAB, 2)
// Indicates that only one tab with the url should exist in the same window.
WINDOW_OPEN_DISPOSITION(SINGLETON_TAB, 3)
WINDOW_OPEN_DISPOSITION(NEW_FOREGROUND_TAB, 4)
WINDOW_OPEN_DISPOSITION(NEW_BACKGROUND_TAB, 5)
WINDOW_OPEN_DISPOSITION(NEW_POPUP, 6)
WINDOW_OPEN_DISPOSITION(NEW_WINDOW, 7)
WINDOW_OPEN_DISPOSITION(SAVE_TO_DISK, 8)
WINDOW_OPEN_DISPOSITION(OFF_THE_RECORD, 9)
WINDOW_OPEN_DISPOSITION(IGNORE_ACTION, 10)
// Update when adding a new disposition.
WINDOW_OPEN_DISPOSITION(WINDOW_OPEN_DISPOSITION_LAST, 10)
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// This file intentionally does not have header guards, it's included
// inside a macro to generate enum values.
#ifndef DEFINE_BITMAP_CONFIG
#error "DEFINE_BITMAP_CONFIG should be defined before including this file"
#endif
DEFINE_BITMAP_CONFIG(FORMAT_NO_CONFIG, 0)
DEFINE_BITMAP_CONFIG(FORMAT_ALPHA_8, 1)
DEFINE_BITMAP_CONFIG(FORMAT_ARGB_4444, 2)
DEFINE_BITMAP_CONFIG(FORMAT_ARGB_8888, 3)
DEFINE_BITMAP_CONFIG(FORMAT_RGB_565, 4)
......@@ -13,13 +13,14 @@
namespace gfx {
// Define Bitmap Config values like BITMAP_CONFIG_ARGB_8888 in a
// way that ensures they're always the same than their Java counterpart.
enum BitmapConfig {
#define DEFINE_BITMAP_CONFIG(x, y) BITMAP_##x = y,
#include "bitmap_config_list.h"
#undef DEFINE_BITMAP_CONFIG
// A Java counterpart will be generated for this enum.
// GENERATED_JAVA_ENUM_PACKAGE: org.chromium.ui.gfx
enum BitmapFormat {
BITMAP_FORMAT_NO_CONFIG,
BITMAP_FORMAT_ALPHA_8,
BITMAP_FORMAT_ARGB_4444,
BITMAP_FORMAT_ARGB_8888,
BITMAP_FORMAT_RGB_565,
};
// This class wraps a JNI AndroidBitmap object to make it easier to use. It
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment