1// Copyright 2014 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef CONTENT_BROWSER_ANDROID_JAVA_JAVA_TYPE_H_
6#define CONTENT_BROWSER_ANDROID_JAVA_JAVA_TYPE_H_
7
8#include <string>
9
10#include "base/memory/scoped_ptr.h"
11#include "content/common/content_export.h"
12
13namespace content {
14
15// The type of a Java value. A light-weight enum-like structure intended for
16// use by value and in STL containers.
17struct CONTENT_EXPORT JavaType {
18  JavaType();
19  JavaType(const JavaType& other);
20  ~JavaType();
21  JavaType& operator=(const JavaType& other);
22
23  // Java's reflection API represents types as a string using an extended
24  // 'binary name'.
25  static JavaType CreateFromBinaryName(const std::string& binary_name);
26
27  // JNIName is used with FindClass.
28  std::string JNIName() const;
29  // JNISignature is used for creating method signatures.
30  std::string JNISignature() const;
31
32  enum Type {
33    TypeBoolean,
34    TypeByte,
35    TypeChar,
36    TypeShort,
37    TypeInt,
38    TypeLong,
39    TypeFloat,
40    TypeDouble,
41    // This is only used as a return type, so we should never convert from
42    // JavaScript with this type.
43    TypeVoid,
44    TypeArray,
45    // We special-case strings, as they get special handling when coercing.
46    TypeString,
47    TypeObject,
48  };
49
50  Type type;
51  scoped_ptr<JavaType> inner_type;  // Used for TypeArray only.
52  std::string class_jni_name;  // Used for TypeString and TypeObject only.
53};
54
55}  // namespace content
56
57#endif  // CONTENT_BROWSER_ANDROID_JAVA_JAVA_TYPE_H_
58