Remove last using directives from global header scope
Bug: None
Test: Compiles, unittests pass
Change-Id: I66dee2504b28049ecb74526a08345e999d57db8d
diff --git a/aidl_unittest.cpp b/aidl_unittest.cpp
index 8528023..bf205f7 100644
--- a/aidl_unittest.cpp
+++ b/aidl_unittest.cpp
@@ -14,8 +14,9 @@
* limitations under the License.
*/
-#include <string>
#include <memory>
+#include <set>
+#include <string>
#include <vector>
#include <android-base/stringprintf.h>
@@ -30,8 +31,10 @@
using android::aidl::test::FakeIoDelegate;
using android::base::StringPrintf;
+using std::set;
using std::string;
using std::unique_ptr;
+using std::vector;
using android::aidl::internals::parse_preprocessed_file;
namespace android {
diff --git a/ast_java.cpp b/ast_java.cpp
index 484098c..615afb1 100644
--- a/ast_java.cpp
+++ b/ast_java.cpp
@@ -19,6 +19,9 @@
#include "code_writer.h"
#include "type_java.h"
+using std::vector;
+using std::string;
+
namespace android {
namespace aidl {
namespace java {
diff --git a/ast_java.h b/ast_java.h
index db88eab..4b217d3 100644
--- a/ast_java.h
+++ b/ast_java.h
@@ -19,14 +19,9 @@
#include <stdarg.h>
#include <stdio.h>
-#include <set>
#include <string>
#include <vector>
-using std::set;
-using std::string;
-using std::vector;
-
enum {
PACKAGE_PRIVATE = 0x00000000,
PUBLIC = 0x00000001,
@@ -71,30 +66,30 @@
};
struct LiteralExpression : public Expression {
- string value;
+ std::string value;
- LiteralExpression(const string& value);
+ LiteralExpression(const std::string& value);
virtual ~LiteralExpression() = default;
void Write(CodeWriter* to) const override;
};
// TODO: also escape the contents. not needed for now
struct StringLiteralExpression : public Expression {
- string value;
+ std::string value;
- StringLiteralExpression(const string& value);
+ StringLiteralExpression(const std::string& value);
virtual ~StringLiteralExpression() = default;
void Write(CodeWriter* to) const override;
};
struct Variable : public Expression {
const Type* type = nullptr;
- string name;
+ std::string name;
int dimension = 0;
Variable() = default;
- Variable(const Type* type, const string& name);
- Variable(const Type* type, const string& name, int dimension);
+ Variable(const Type* type, const std::string& name);
+ Variable(const Type* type, const std::string& name, int dimension);
virtual ~Variable() = default;
void WriteDeclaration(CodeWriter* to) const;
@@ -104,20 +99,20 @@
struct FieldVariable : public Expression {
Expression* object;
const Type* clazz;
- string name;
+ std::string name;
- FieldVariable(Expression* object, const string& name);
- FieldVariable(const Type* clazz, const string& name);
+ FieldVariable(Expression* object, const std::string& name);
+ FieldVariable(const Type* clazz, const std::string& name);
virtual ~FieldVariable() = default;
void Write(CodeWriter* to) const;
};
struct Field : public ClassElement {
- string comment;
+ std::string comment;
int modifiers = 0;
Variable* variable = nullptr;
- string value;
+ std::string value;
Field() = default;
Field(int modifiers, Variable* variable);
@@ -132,7 +127,7 @@
};
struct StatementBlock : public Statement {
- vector<Statement*> statements;
+ std::vector<Statement*> statements;
StatementBlock() = default;
virtual ~StatementBlock() = default;
@@ -164,16 +159,16 @@
struct MethodCall : public Expression {
Expression* obj = nullptr;
const Type* clazz = nullptr;
- string name;
- vector<Expression*> arguments;
- vector<string> exceptions;
+ std::string name;
+ std::vector<Expression*> arguments;
+ std::vector<std::string> exceptions;
- MethodCall(const string& name);
- MethodCall(const string& name, int argc, ...);
- MethodCall(Expression* obj, const string& name);
- MethodCall(const Type* clazz, const string& name);
- MethodCall(Expression* obj, const string& name, int argc, ...);
- MethodCall(const Type* clazz, const string& name, int argc, ...);
+ MethodCall(const std::string& name);
+ MethodCall(const std::string& name, int argc, ...);
+ MethodCall(Expression* obj, const std::string& name);
+ MethodCall(const Type* clazz, const std::string& name);
+ MethodCall(Expression* obj, const std::string& name, int argc, ...);
+ MethodCall(const Type* clazz, const std::string& name, int argc, ...);
virtual ~MethodCall() = default;
void Write(CodeWriter* to) const override;
@@ -183,17 +178,17 @@
struct Comparison : public Expression {
Expression* lvalue;
- string op;
+ std::string op;
Expression* rvalue;
- Comparison(Expression* lvalue, const string& op, Expression* rvalue);
+ Comparison(Expression* lvalue, const std::string& op, Expression* rvalue);
virtual ~Comparison() = default;
void Write(CodeWriter* to) const override;
};
struct NewExpression : public Expression {
const Type* type;
- vector<Expression*> arguments;
+ std::vector<Expression*> arguments;
NewExpression(const Type* type);
NewExpression(const Type* type, int argc, ...);
@@ -290,18 +285,18 @@
};
struct Case {
- vector<string> cases;
+ std::vector<std::string> cases;
StatementBlock* statements = new StatementBlock;
Case() = default;
- Case(const string& c);
+ Case(const std::string& c);
virtual ~Case() = default;
virtual void Write(CodeWriter* to) const;
};
struct SwitchStatement : public Statement {
Expression* expression;
- vector<Case*> cases;
+ std::vector<Case*> cases;
SwitchStatement(Expression* expression);
virtual ~SwitchStatement() = default;
@@ -315,13 +310,13 @@
};
struct Method : public ClassElement {
- string comment;
+ std::string comment;
int modifiers = 0;
const Type* returnType = nullptr; // nullptr means constructor
size_t returnTypeDimension = 0;
- string name;
- vector<Variable*> parameters;
- vector<const Type*> exceptions;
+ std::string name;
+ std::vector<Variable*> parameters;
+ std::vector<const Type*> exceptions;
StatementBlock* statements = nullptr;
Method() = default;
@@ -331,7 +326,7 @@
};
struct Constant : public ClassElement {
- string name;
+ std::string name;
int value;
Constant() = default;
@@ -343,13 +338,13 @@
struct Class : public ClassElement {
enum { CLASS, INTERFACE };
- string comment;
+ std::string comment;
int modifiers = 0;
int what = CLASS; // CLASS or INTERFACE
const Type* type = nullptr;
const Type* extends = nullptr;
- vector<const Type*> interfaces;
- vector<ClassElement*> elements;
+ std::vector<const Type*> interfaces;
+ std::vector<ClassElement*> elements;
Class() = default;
virtual ~Class() = default;
@@ -358,10 +353,10 @@
};
struct Document {
- string comment;
- string package;
- string originalSrc;
- vector<Class*> classes;
+ std::string comment;
+ std::string package;
+ std::string originalSrc;
+ std::vector<Class*> classes;
Document() = default;
virtual ~Document() = default;
diff --git a/ast_java_unittest.cpp b/ast_java_unittest.cpp
index 3981363..b2aad23 100644
--- a/ast_java_unittest.cpp
+++ b/ast_java_unittest.cpp
@@ -22,6 +22,8 @@
#include "code_writer.h"
#include "type_java.h"
+using std::string;
+
namespace android {
namespace aidl {
namespace java {
diff --git a/generate_java.h b/generate_java.h
index 929d15a..6719030 100644
--- a/generate_java.h
+++ b/generate_java.h
@@ -44,7 +44,7 @@
using Variable = ::android::aidl::java::Variable;
using Type = ::android::aidl::java::Type;
- VariableFactory(const string& base); // base must be short
+ VariableFactory(const std::string& base); // base must be short
Variable* Get(const Type* type);
Variable* Get(int index);
diff --git a/generate_java_binder.cpp b/generate_java_binder.cpp
index 0b59ecd..237b993 100644
--- a/generate_java_binder.cpp
+++ b/generate_java_binder.cpp
@@ -25,6 +25,8 @@
#include "type_java.h"
+using std::string;
+
namespace android {
namespace aidl {
namespace java {
diff --git a/type_java.cpp b/type_java.cpp
index f056610..b792ba7 100644
--- a/type_java.cpp
+++ b/type_java.cpp
@@ -23,6 +23,7 @@
#include "aidl_language.h"
#include "logging.h"
+using std::string;
using android::base::Split;
using android::base::Join;
using android::base::Trim;
diff --git a/type_java.h b/type_java.h
index 82fb580..3a63e8d 100644
--- a/type_java.h
+++ b/type_java.h
@@ -29,19 +29,16 @@
class JavaTypeNamespace;
-using std::string;
-using std::vector;
-
class Type : public ValidatableType {
public:
// WriteToParcel flags
enum { PARCELABLE_WRITE_RETURN_VALUE = 0x0001 };
- Type(const JavaTypeNamespace* types, const string& name, int kind,
+ Type(const JavaTypeNamespace* types, const std::string& name, int kind,
bool canWriteToParcel, bool canBeOut);
- Type(const JavaTypeNamespace* types, const string& package,
- const string& name, int kind, bool canWriteToParcel, bool canBeOut,
- const string& declFile = "", int declLine = -1);
+ Type(const JavaTypeNamespace* types, const std::string& package,
+ const std::string& name, int kind, bool canWriteToParcel, bool canBeOut,
+ const std::string& declFile = "", int declLine = -1);
virtual ~Type() = default;
bool CanBeOutParameter() const override { return m_canBeOut; }
@@ -50,9 +47,9 @@
const ValidatableType* ArrayType() const override { return m_array_type.get(); }
const ValidatableType* NullableType() const override { return nullptr; }
- inline string Package() const { return m_package; }
- virtual string CreatorName() const;
- virtual string InstantiableName() const;
+ inline std::string Package() const { return m_package; }
+ virtual std::string CreatorName() const;
+ virtual std::string InstantiableName() const;
virtual void WriteToParcel(StatementBlock* addTo, Variable* v,
Variable* parcel, int flags) const;
@@ -72,20 +69,20 @@
Type();
Type(const Type&);
- string m_package;
- string m_name;
- string m_qualifiedName;
- string m_declFile;
+ std::string m_package;
+ std::string m_name;
+ std::string m_qualifiedName;
+ std::string m_declFile;
bool m_canWriteToParcel;
bool m_canBeOut;
};
class BasicArrayType : public Type {
public:
- BasicArrayType(const JavaTypeNamespace* types, const string& name,
- const string& writeArrayParcel,
- const string& createArrayParcel,
- const string& readArrayParcel);
+ BasicArrayType(const JavaTypeNamespace* types, const std::string& name,
+ const std::string& writeArrayParcel,
+ const std::string& createArrayParcel,
+ const std::string& readArrayParcel);
void WriteToParcel(StatementBlock* addTo, Variable* v, Variable* parcel,
int flags) const override;
@@ -96,17 +93,19 @@
const ValidatableType* NullableType() const override { return this; }
private:
- string m_writeArrayParcel;
- string m_createArrayParcel;
- string m_readArrayParcel;
+ std::string m_writeArrayParcel;
+ std::string m_createArrayParcel;
+ std::string m_readArrayParcel;
};
class BasicType : public Type {
public:
- BasicType(const JavaTypeNamespace* types, const string& name,
- const string& marshallParcel, const string& unmarshallParcel,
- const string& writeArrayParcel, const string& createArrayParcel,
- const string& readArrayParcel);
+ BasicType(const JavaTypeNamespace* types, const std::string& name,
+ const std::string& marshallParcel,
+ const std::string& unmarshallParcel,
+ const std::string& writeArrayParcel,
+ const std::string& createArrayParcel,
+ const std::string& readArrayParcel);
void WriteToParcel(StatementBlock* addTo, Variable* v, Variable* parcel,
int flags) const override;
@@ -114,8 +113,8 @@
Variable** cl) const override;
private:
- string m_marshallParcel;
- string m_unmarshallParcel;
+ std::string m_marshallParcel;
+ std::string m_unmarshallParcel;
};
class FileDescriptorArrayType : public Type {
@@ -191,7 +190,7 @@
public:
StringArrayType(const JavaTypeNamespace* types);
- string CreatorName() const override;
+ std::string CreatorName() const override;
void WriteToParcel(StatementBlock* addTo, Variable* v, Variable* parcel,
int flags) const override;
@@ -206,7 +205,7 @@
public:
StringType(const JavaTypeNamespace* types);
- string CreatorName() const override;
+ std::string CreatorName() const override;
void WriteToParcel(StatementBlock* addTo, Variable* v, Variable* parcel,
int flags) const override;
@@ -219,7 +218,7 @@
public:
CharSequenceType(const JavaTypeNamespace* types);
- string CreatorName() const override;
+ std::string CreatorName() const override;
void WriteToParcel(StatementBlock* addTo, Variable* v, Variable* parcel,
int flags) const override;
@@ -338,7 +337,7 @@
public:
ListType(const JavaTypeNamespace* types);
- string InstantiableName() const override;
+ std::string InstantiableName() const override;
void WriteToParcel(StatementBlock* addTo, Variable* v, Variable* parcel,
int flags) const override;
@@ -351,11 +350,12 @@
class UserDataArrayType : public Type {
public:
- UserDataArrayType(const JavaTypeNamespace* types, const string& package,
- const string& name, bool builtIn, bool canWriteToParcel,
- const string& declFile = "", int declLine = -1);
+ UserDataArrayType(const JavaTypeNamespace* types, const std::string& package,
+ const std::string& name, bool builtIn,
+ bool canWriteToParcel, const std::string& declFile = "",
+ int declLine = -1);
- string CreatorName() const override;
+ std::string CreatorName() const override;
void WriteToParcel(StatementBlock* addTo, Variable* v, Variable* parcel,
int flags) const override;
@@ -368,11 +368,11 @@
class UserDataType : public Type {
public:
- UserDataType(const JavaTypeNamespace* types, const string& package,
- const string& name, bool builtIn, bool canWriteToParcel,
- const string& declFile = "", int declLine = -1);
+ UserDataType(const JavaTypeNamespace* types, const std::string& package,
+ const std::string& name, bool builtIn, bool canWriteToParcel,
+ const std::string& declFile = "", int declLine = -1);
- string CreatorName() const override;
+ std::string CreatorName() const override;
void WriteToParcel(StatementBlock* addTo, Variable* v, Variable* parcel,
int flags) const override;
@@ -385,9 +385,9 @@
class InterfaceType : public Type {
public:
- InterfaceType(const JavaTypeNamespace* types, const string& package,
- const string& name, bool builtIn, bool oneway,
- const string& declFile, int declLine, const Type* stub,
+ InterfaceType(const JavaTypeNamespace* types, const std::string& package,
+ const std::string& name, bool builtIn, bool oneway,
+ const std::string& declFile, int declLine, const Type* stub,
const Type* proxy);
bool OneWay() const;
@@ -414,8 +414,8 @@
public:
GenericListType(const JavaTypeNamespace* types, const Type* arg);
- string CreatorName() const override;
- string InstantiableName() const override;
+ std::string CreatorName() const override;
+ std::string InstantiableName() const override;
void WriteToParcel(StatementBlock* addTo, Variable* v, Variable* parcel,
int flags) const override;
@@ -437,9 +437,9 @@
void Init() override;
bool AddParcelableType(const AidlParcelable& p,
- const string& filename) override;
+ const std::string& filename) override;
bool AddBinderType(const AidlInterface& b,
- const string& filename) override;
+ const std::string& filename) override;
bool AddListType(const std::string& contained_type_name) override;
bool AddMapType(const std::string& key_type_name,
const std::string& value_type_name) override;