Remove RPC interface Type
AIDL previously supported "rpc" and "flatten" types, which are not used anywhere in the Android tree. This patch removes them, which significantly cuts down code and complexity. Bug: 23517584 Test: Rebuilt AOSP tree against new version Change-Id: I6cf38d43c1ce109ffca987cc14520945aa22431f Signed-off-by: Casey Dahlin <sadmac@google.com>
This commit is contained in:
@@ -31,7 +31,6 @@ LOCAL_SRC_FILES := \
|
||||
aidl_language_y.y \
|
||||
generate_java.cpp \
|
||||
generate_java_binder.cpp \
|
||||
generate_java_rpc.cpp \
|
||||
options.cpp \
|
||||
search_path.cpp \
|
||||
|
||||
|
||||
@@ -28,9 +28,6 @@ Type* CONTEXT_TYPE;
|
||||
Type* MAP_TYPE;
|
||||
Type* LIST_TYPE;
|
||||
Type* CLASSLOADER_TYPE;
|
||||
Type* RPC_DATA_TYPE;
|
||||
Type* RPC_ERROR_TYPE;
|
||||
Type* EVENT_FAKE_TYPE;
|
||||
|
||||
Expression* NULL_VALUE;
|
||||
Expression* THIS_VALUE;
|
||||
@@ -42,7 +39,6 @@ void
|
||||
register_base_types()
|
||||
{
|
||||
VOID_TYPE = new BasicType("void",
|
||||
"XXX", "XXX", "XXX", "XXX", "XXX",
|
||||
"XXX", "XXX", "XXX", "XXX", "XXX");
|
||||
NAMES.Add(VOID_TYPE);
|
||||
|
||||
@@ -50,37 +46,37 @@ register_base_types()
|
||||
NAMES.Add(BOOLEAN_TYPE);
|
||||
|
||||
BYTE_TYPE = new BasicType("byte",
|
||||
"writeByte", "readByte", "writeByteArray", "createByteArray", "readByteArray",
|
||||
"putByte", "getByte", "putByteArray", "createByteArray", "getByteArray");
|
||||
"writeByte", "readByte", "writeByteArray", "createByteArray",
|
||||
"readByteArray");
|
||||
NAMES.Add(BYTE_TYPE);
|
||||
|
||||
CHAR_TYPE = new CharType();
|
||||
NAMES.Add(CHAR_TYPE);
|
||||
|
||||
INT_TYPE = new BasicType("int",
|
||||
"writeInt", "readInt", "writeIntArray", "createIntArray", "readIntArray",
|
||||
"putInteger", "getInteger", "putIntegerArray", "createIntegerArray", "getIntegerArray");
|
||||
"writeInt", "readInt", "writeIntArray", "createIntArray",
|
||||
"readIntArray");
|
||||
NAMES.Add(INT_TYPE);
|
||||
|
||||
LONG_TYPE = new BasicType("long",
|
||||
"writeLong", "readLong", "writeLongArray", "createLongArray", "readLongArray",
|
||||
"putLong", "getLong", "putLongArray", "createLongArray", "getLongArray");
|
||||
"writeLong", "readLong", "writeLongArray", "createLongArray",
|
||||
"readLongArray");
|
||||
NAMES.Add(LONG_TYPE);
|
||||
|
||||
FLOAT_TYPE = new BasicType("float",
|
||||
"writeFloat", "readFloat", "writeFloatArray", "createFloatArray", "readFloatArray",
|
||||
"putFloat", "getFloat", "putFloatArray", "createFloatArray", "getFloatArray");
|
||||
"writeFloat", "readFloat", "writeFloatArray", "createFloatArray",
|
||||
"readFloatArray");
|
||||
NAMES.Add(FLOAT_TYPE);
|
||||
|
||||
DOUBLE_TYPE = new BasicType("double",
|
||||
"writeDouble", "readDouble", "writeDoubleArray", "createDoubleArray", "readDoubleArray",
|
||||
"putDouble", "getDouble", "putDoubleArray", "createDoubleArray", "getDoubleArray");
|
||||
"writeDouble", "readDouble", "writeDoubleArray",
|
||||
"createDoubleArray", "readDoubleArray");
|
||||
NAMES.Add(DOUBLE_TYPE);
|
||||
|
||||
STRING_TYPE = new StringType();
|
||||
NAMES.Add(STRING_TYPE);
|
||||
|
||||
OBJECT_TYPE = new Type("java.lang", "Object", Type::BUILT_IN, false, false, false);
|
||||
OBJECT_TYPE = new Type("java.lang", "Object", Type::BUILT_IN, false, false);
|
||||
NAMES.Add(OBJECT_TYPE);
|
||||
|
||||
CHAR_SEQUENCE_TYPE = new CharSequenceType();
|
||||
@@ -92,7 +88,7 @@ register_base_types()
|
||||
LIST_TYPE = new ListType();
|
||||
NAMES.Add(LIST_TYPE);
|
||||
|
||||
TEXT_UTILS_TYPE = new Type("android.text", "TextUtils", Type::BUILT_IN, false, false, false);
|
||||
TEXT_UTILS_TYPE = new Type("android.text", "TextUtils", Type::BUILT_IN, false, false);
|
||||
NAMES.Add(TEXT_UTILS_TYPE);
|
||||
|
||||
REMOTE_EXCEPTION_TYPE = new RemoteExceptionType();
|
||||
@@ -119,19 +115,9 @@ register_base_types()
|
||||
PARCELABLE_INTERFACE_TYPE = new ParcelableInterfaceType();
|
||||
NAMES.Add(PARCELABLE_INTERFACE_TYPE);
|
||||
|
||||
CONTEXT_TYPE = new Type("android.content", "Context", Type::BUILT_IN, false, false, false);
|
||||
CONTEXT_TYPE = new Type("android.content", "Context", Type::BUILT_IN, false, false);
|
||||
NAMES.Add(CONTEXT_TYPE);
|
||||
|
||||
RPC_DATA_TYPE = new RpcDataType();
|
||||
NAMES.Add(RPC_DATA_TYPE);
|
||||
|
||||
RPC_ERROR_TYPE = new UserDataType("android.support.place.rpc", "RpcError",
|
||||
true, __FILE__, __LINE__);
|
||||
NAMES.Add(RPC_ERROR_TYPE);
|
||||
|
||||
EVENT_FAKE_TYPE = new Type("event", Type::BUILT_IN, false, false, false);
|
||||
NAMES.Add(EVENT_FAKE_TYPE);
|
||||
|
||||
CLASSLOADER_TYPE = new ClassLoaderType();
|
||||
NAMES.Add(CLASSLOADER_TYPE);
|
||||
|
||||
@@ -158,30 +144,27 @@ make_generic_type(const string& package, const string& name,
|
||||
|
||||
// ================================================================
|
||||
|
||||
Type::Type(const string& name, int kind, bool canWriteToParcel, bool canWriteToRpcData,
|
||||
bool canBeOut)
|
||||
Type::Type(const string& name, int kind, bool canWriteToParcel, bool canBeOut)
|
||||
:m_package(),
|
||||
m_name(name),
|
||||
m_declFile(""),
|
||||
m_declLine(-1),
|
||||
m_kind(kind),
|
||||
m_canWriteToParcel(canWriteToParcel),
|
||||
m_canWriteToRpcData(canWriteToRpcData),
|
||||
m_canBeOut(canBeOut)
|
||||
{
|
||||
m_qualifiedName = name;
|
||||
}
|
||||
|
||||
Type::Type(const string& package, const string& name,
|
||||
int kind, bool canWriteToParcel, bool canWriteToRpcData,
|
||||
bool canBeOut, const string& declFile, int declLine)
|
||||
int kind, bool canWriteToParcel, bool canBeOut,
|
||||
const string& declFile, int declLine)
|
||||
:m_package(package),
|
||||
m_name(name),
|
||||
m_declFile(declFile),
|
||||
m_declLine(declLine),
|
||||
m_kind(kind),
|
||||
m_canWriteToParcel(canWriteToParcel),
|
||||
m_canWriteToRpcData(canWriteToRpcData),
|
||||
m_canBeOut(canBeOut)
|
||||
{
|
||||
if (package.length() > 0) {
|
||||
@@ -213,12 +196,6 @@ Type::CreatorName() const
|
||||
return "";
|
||||
}
|
||||
|
||||
string
|
||||
Type::RpcCreatorName() const
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
string
|
||||
Type::InstantiableName() const
|
||||
{
|
||||
@@ -281,26 +258,6 @@ Type::ReadArrayFromParcel(StatementBlock* addTo, Variable* v, Variable* parcel,
|
||||
+ m_qualifiedName + " */"));
|
||||
}
|
||||
|
||||
void
|
||||
Type::WriteToRpcData(StatementBlock* addTo, Expression* k, Variable* v,
|
||||
Variable* data, int flags)
|
||||
{
|
||||
fprintf(stderr, "aidl:internal error %s:%d qualifiedName=%s\n",
|
||||
__FILE__, __LINE__, m_qualifiedName.c_str());
|
||||
addTo->Add(new LiteralExpression("/* WriteToRpcData error "
|
||||
+ m_qualifiedName + " */"));
|
||||
}
|
||||
|
||||
void
|
||||
Type::CreateFromRpcData(StatementBlock* addTo, Expression* k, Variable* v, Variable* data,
|
||||
Variable** cl)
|
||||
{
|
||||
fprintf(stderr, "aidl:internal error %s:%d qualifiedName=%s\n",
|
||||
__FILE__, __LINE__, m_qualifiedName.c_str());
|
||||
addTo->Add(new LiteralExpression("/* ReadFromRpcData error "
|
||||
+ m_qualifiedName + " */"));
|
||||
}
|
||||
|
||||
void
|
||||
Type::SetQualifiedName(const string& qualified)
|
||||
{
|
||||
@@ -324,20 +281,13 @@ Type::BuildWriteToParcelFlags(int flags)
|
||||
|
||||
BasicType::BasicType(const string& name, const string& marshallParcel,
|
||||
const string& unmarshallParcel, const string& writeArrayParcel,
|
||||
const string& createArrayParcel, const string& readArrayParcel,
|
||||
const string& marshallRpc, const string& unmarshallRpc,
|
||||
const string& writeArrayRpc, const string& createArrayRpc, const string& readArrayRpc)
|
||||
:Type(name, BUILT_IN, true, true, false),
|
||||
const string& createArrayParcel, const string& readArrayParcel)
|
||||
:Type(name, BUILT_IN, true, false),
|
||||
m_marshallParcel(marshallParcel),
|
||||
m_unmarshallParcel(unmarshallParcel),
|
||||
m_writeArrayParcel(writeArrayParcel),
|
||||
m_createArrayParcel(createArrayParcel),
|
||||
m_readArrayParcel(readArrayParcel),
|
||||
m_marshallRpc(marshallRpc),
|
||||
m_unmarshallRpc(unmarshallRpc),
|
||||
m_writeArrayRpc(writeArrayRpc),
|
||||
m_createArrayRpc(createArrayRpc),
|
||||
m_readArrayRpc(readArrayRpc)
|
||||
m_readArrayParcel(readArrayParcel)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -378,24 +328,10 @@ BasicType::ReadArrayFromParcel(StatementBlock* addTo, Variable* v, Variable* par
|
||||
addTo->Add(new MethodCall(parcel, m_readArrayParcel, 1, v));
|
||||
}
|
||||
|
||||
void
|
||||
BasicType::WriteToRpcData(StatementBlock* addTo, Expression* k, Variable* v,
|
||||
Variable* data, int flags)
|
||||
{
|
||||
addTo->Add(new MethodCall(data, m_marshallRpc, 2, k, v));
|
||||
}
|
||||
|
||||
void
|
||||
BasicType::CreateFromRpcData(StatementBlock* addTo, Expression* k, Variable* v, Variable* data,
|
||||
Variable** cl)
|
||||
{
|
||||
addTo->Add(new Assignment(v, new MethodCall(data, m_unmarshallRpc, 1, k)));
|
||||
}
|
||||
|
||||
// ================================================================
|
||||
|
||||
BooleanType::BooleanType()
|
||||
:Type("boolean", BUILT_IN, true, true, false)
|
||||
:Type("boolean", BUILT_IN, true, false)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -439,24 +375,10 @@ BooleanType::ReadArrayFromParcel(StatementBlock* addTo, Variable* v, Variable* p
|
||||
addTo->Add(new MethodCall(parcel, "readBooleanArray", 1, v));
|
||||
}
|
||||
|
||||
void
|
||||
BooleanType::WriteToRpcData(StatementBlock* addTo, Expression* k, Variable* v,
|
||||
Variable* data, int flags)
|
||||
{
|
||||
addTo->Add(new MethodCall(data, "putBoolean", 2, k, v));
|
||||
}
|
||||
|
||||
void
|
||||
BooleanType::CreateFromRpcData(StatementBlock* addTo, Expression* k, Variable* v, Variable* data,
|
||||
Variable** cl)
|
||||
{
|
||||
addTo->Add(new Assignment(v, new MethodCall(data, "getBoolean", 1, k)));
|
||||
}
|
||||
|
||||
// ================================================================
|
||||
|
||||
CharType::CharType()
|
||||
:Type("char", BUILT_IN, true, true, false)
|
||||
:Type("char", BUILT_IN, true, false)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -498,24 +420,10 @@ CharType::ReadArrayFromParcel(StatementBlock* addTo, Variable* v, Variable* parc
|
||||
addTo->Add(new MethodCall(parcel, "readCharArray", 1, v));
|
||||
}
|
||||
|
||||
void
|
||||
CharType::WriteToRpcData(StatementBlock* addTo, Expression* k, Variable* v,
|
||||
Variable* data, int flags)
|
||||
{
|
||||
addTo->Add(new MethodCall(data, "putChar", 2, k, v));
|
||||
}
|
||||
|
||||
void
|
||||
CharType::CreateFromRpcData(StatementBlock* addTo, Expression* k, Variable* v, Variable* data,
|
||||
Variable** cl)
|
||||
{
|
||||
addTo->Add(new Assignment(v, new MethodCall(data, "getChar", 1, k)));
|
||||
}
|
||||
|
||||
// ================================================================
|
||||
|
||||
StringType::StringType()
|
||||
:Type("java.lang", "String", BUILT_IN, true, true, false)
|
||||
:Type("java.lang", "String", BUILT_IN, true, false)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -562,24 +470,10 @@ StringType::ReadArrayFromParcel(StatementBlock* addTo, Variable* v, Variable* pa
|
||||
addTo->Add(new MethodCall(parcel, "readStringArray", 1, v));
|
||||
}
|
||||
|
||||
void
|
||||
StringType::WriteToRpcData(StatementBlock* addTo, Expression* k, Variable* v,
|
||||
Variable* data, int flags)
|
||||
{
|
||||
addTo->Add(new MethodCall(data, "putString", 2, k, v));
|
||||
}
|
||||
|
||||
void
|
||||
StringType::CreateFromRpcData(StatementBlock* addTo, Expression* k, Variable* v,
|
||||
Variable* data, Variable**)
|
||||
{
|
||||
addTo->Add(new Assignment(v, new MethodCall(data, "getString", 1, k)));
|
||||
}
|
||||
|
||||
// ================================================================
|
||||
|
||||
CharSequenceType::CharSequenceType()
|
||||
:Type("java.lang", "CharSequence", BUILT_IN, true, true, false)
|
||||
:Type("java.lang", "CharSequence", BUILT_IN, true, false)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -639,7 +533,7 @@ CharSequenceType::CreateFromParcel(StatementBlock* addTo, Variable* v,
|
||||
// ================================================================
|
||||
|
||||
RemoteExceptionType::RemoteExceptionType()
|
||||
:Type("android.os", "RemoteException", BUILT_IN, false, false, false)
|
||||
:Type("android.os", "RemoteException", BUILT_IN, false, false)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -658,7 +552,7 @@ RemoteExceptionType::CreateFromParcel(StatementBlock* addTo, Variable* v, Variab
|
||||
// ================================================================
|
||||
|
||||
RuntimeExceptionType::RuntimeExceptionType()
|
||||
:Type("java.lang", "RuntimeException", BUILT_IN, false, false, false)
|
||||
:Type("java.lang", "RuntimeException", BUILT_IN, false, false)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -678,7 +572,7 @@ RuntimeExceptionType::CreateFromParcel(StatementBlock* addTo, Variable* v, Varia
|
||||
// ================================================================
|
||||
|
||||
IBinderType::IBinderType()
|
||||
:Type("android.os", "IBinder", BUILT_IN, true, false, false)
|
||||
:Type("android.os", "IBinder", BUILT_IN, true, false)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -717,7 +611,7 @@ IBinderType::ReadArrayFromParcel(StatementBlock* addTo, Variable* v, Variable* p
|
||||
// ================================================================
|
||||
|
||||
IInterfaceType::IInterfaceType()
|
||||
:Type("android.os", "IInterface", BUILT_IN, false, false, false)
|
||||
:Type("android.os", "IInterface", BUILT_IN, false, false)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -737,7 +631,7 @@ IInterfaceType::CreateFromParcel(StatementBlock* addTo, Variable* v, Variable* p
|
||||
// ================================================================
|
||||
|
||||
BinderType::BinderType()
|
||||
:Type("android.os", "Binder", BUILT_IN, false, false, false)
|
||||
:Type("android.os", "Binder", BUILT_IN, false, false)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -758,7 +652,7 @@ BinderType::CreateFromParcel(StatementBlock* addTo, Variable* v,
|
||||
// ================================================================
|
||||
|
||||
BinderProxyType::BinderProxyType()
|
||||
:Type("android.os", "BinderProxy", BUILT_IN, false, false, false)
|
||||
:Type("android.os", "BinderProxy", BUILT_IN, false, false)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -779,7 +673,7 @@ BinderProxyType::CreateFromParcel(StatementBlock* addTo, Variable* v,
|
||||
// ================================================================
|
||||
|
||||
ParcelType::ParcelType()
|
||||
:Type("android.os", "Parcel", BUILT_IN, false, false, false)
|
||||
:Type("android.os", "Parcel", BUILT_IN, false, false)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -798,7 +692,7 @@ ParcelType::CreateFromParcel(StatementBlock* addTo, Variable* v, Variable* parce
|
||||
// ================================================================
|
||||
|
||||
ParcelableInterfaceType::ParcelableInterfaceType()
|
||||
:Type("android.os", "Parcelable", BUILT_IN, false, false, false)
|
||||
:Type("android.os", "Parcelable", BUILT_IN, false, false)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -817,7 +711,7 @@ ParcelableInterfaceType::CreateFromParcel(StatementBlock* addTo, Variable* v, Va
|
||||
// ================================================================
|
||||
|
||||
MapType::MapType()
|
||||
:Type("java.util", "Map", BUILT_IN, true, false, true)
|
||||
:Type("java.util", "Map", BUILT_IN, true, true)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -857,7 +751,7 @@ MapType::ReadFromParcel(StatementBlock* addTo, Variable* v, Variable* parcel, Va
|
||||
// ================================================================
|
||||
|
||||
ListType::ListType()
|
||||
:Type("java.util", "List", BUILT_IN, true, true, true)
|
||||
:Type("java.util", "List", BUILT_IN, true, true)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -888,26 +782,12 @@ ListType::ReadFromParcel(StatementBlock* addTo, Variable* v,
|
||||
addTo->Add(new MethodCall(parcel, "readList", 2, v, *cl));
|
||||
}
|
||||
|
||||
void
|
||||
ListType::WriteToRpcData(StatementBlock* addTo, Expression* k, Variable* v,
|
||||
Variable* data, int flags)
|
||||
{
|
||||
addTo->Add(new MethodCall(data, "putList", 2, k, v));
|
||||
}
|
||||
|
||||
void
|
||||
ListType::CreateFromRpcData(StatementBlock* addTo, Expression* k, Variable* v, Variable* data,
|
||||
Variable** cl)
|
||||
{
|
||||
addTo->Add(new Assignment(v, new MethodCall(data, "getList", 1, k)));
|
||||
}
|
||||
|
||||
// ================================================================
|
||||
|
||||
UserDataType::UserDataType(const string& package, const string& name,
|
||||
bool builtIn, bool canWriteToParcel, bool canWriteToRpcData,
|
||||
bool builtIn, bool canWriteToParcel,
|
||||
const string& declFile, int declLine)
|
||||
:Type(package, name, builtIn ? BUILT_IN : USERDATA, canWriteToParcel, canWriteToRpcData,
|
||||
:Type(package, name, builtIn ? BUILT_IN : USERDATA, canWriteToParcel,
|
||||
true, declFile, declLine)
|
||||
{
|
||||
}
|
||||
@@ -918,12 +798,6 @@ UserDataType::CreatorName() const
|
||||
return QualifiedName() + ".CREATOR";
|
||||
}
|
||||
|
||||
string
|
||||
UserDataType::RpcCreatorName() const
|
||||
{
|
||||
return QualifiedName() + ".RPC_CREATOR";
|
||||
}
|
||||
|
||||
void
|
||||
UserDataType::WriteToParcel(StatementBlock* addTo, Variable* v, Variable* parcel, int flags)
|
||||
{
|
||||
@@ -1014,29 +888,12 @@ UserDataType::ReadArrayFromParcel(StatementBlock* addTo, Variable* v, Variable*
|
||||
v, new LiteralExpression(creator)));
|
||||
}
|
||||
|
||||
void
|
||||
UserDataType::WriteToRpcData(StatementBlock* addTo, Expression* k, Variable* v,
|
||||
Variable* data, int flags)
|
||||
{
|
||||
// data.putFlattenable(k, v);
|
||||
addTo->Add(new MethodCall(data, "putFlattenable", 2, k, v));
|
||||
}
|
||||
|
||||
void
|
||||
UserDataType::CreateFromRpcData(StatementBlock* addTo, Expression* k, Variable* v,
|
||||
Variable* data, Variable** cl)
|
||||
{
|
||||
// data.getFlattenable(k, CLASS.RPC_CREATOR);
|
||||
addTo->Add(new Assignment(v, new MethodCall(data, "getFlattenable", 2, k,
|
||||
new FieldVariable(v->type, "RPC_CREATOR"))));
|
||||
}
|
||||
|
||||
// ================================================================
|
||||
|
||||
InterfaceType::InterfaceType(const string& package, const string& name,
|
||||
bool builtIn, bool oneway,
|
||||
const string& declFile, int declLine)
|
||||
:Type(package, name, builtIn ? BUILT_IN : INTERFACE, true, false, false,
|
||||
:Type(package, name, builtIn ? BUILT_IN : INTERFACE, true, false,
|
||||
declFile, declLine)
|
||||
,m_oneway(oneway)
|
||||
{
|
||||
@@ -1075,7 +932,7 @@ InterfaceType::CreateFromParcel(StatementBlock* addTo, Variable* v, Variable* pa
|
||||
|
||||
GenericType::GenericType(const string& package, const string& name,
|
||||
const vector<Type*>& args)
|
||||
:Type(package, name, BUILT_IN, true, true, true)
|
||||
:Type(package, name, BUILT_IN, true, true)
|
||||
{
|
||||
m_args = args;
|
||||
|
||||
@@ -1200,65 +1057,11 @@ GenericListType::ReadFromParcel(StatementBlock* addTo, Variable* v,
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
GenericListType::WriteToRpcData(StatementBlock* addTo, Expression* k, Variable* v,
|
||||
Variable* data, int flags)
|
||||
{
|
||||
Type* generic = GenericArgumentTypes()[0];
|
||||
if (generic == RPC_DATA_TYPE) {
|
||||
addTo->Add(new MethodCall(data, "putRpcDataList", 2, k, v));
|
||||
} else if (generic->RpcCreatorName() != "") {
|
||||
addTo->Add(new MethodCall(data, "putFlattenableList", 2, k, v));
|
||||
} else {
|
||||
addTo->Add(new MethodCall(data, "putList", 2, k, v));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
GenericListType::CreateFromRpcData(StatementBlock* addTo, Expression* k, Variable* v,
|
||||
Variable* data, Variable** cl)
|
||||
{
|
||||
Type* generic = GenericArgumentTypes()[0];
|
||||
if (generic == RPC_DATA_TYPE) {
|
||||
addTo->Add(new Assignment(v, new MethodCall(data, "getRpcDataList", 2, k)));
|
||||
} else if (generic->RpcCreatorName() != "") {
|
||||
addTo->Add(new Assignment(v, new MethodCall(data, "getFlattenableList", 2, k,
|
||||
new LiteralExpression(generic->RpcCreatorName()))));
|
||||
} else {
|
||||
string classArg = GenericArgumentTypes()[0]->QualifiedName();
|
||||
classArg += ".class";
|
||||
addTo->Add(new Assignment(v, new MethodCall(data, "getList", 2, k,
|
||||
new LiteralExpression(classArg))));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ================================================================
|
||||
|
||||
RpcDataType::RpcDataType()
|
||||
:UserDataType("android.support.place.rpc", "RpcData", true, true, true)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
RpcDataType::WriteToRpcData(StatementBlock* addTo, Expression* k, Variable* v,
|
||||
Variable* data, int flags)
|
||||
{
|
||||
addTo->Add(new MethodCall(data, "putRpcData", 2, k, v));
|
||||
}
|
||||
|
||||
void
|
||||
RpcDataType::CreateFromRpcData(StatementBlock* addTo, Expression* k, Variable* v, Variable* data,
|
||||
Variable** cl)
|
||||
{
|
||||
addTo->Add(new Assignment(v, new MethodCall(data, "getRpcData", 1, k)));
|
||||
}
|
||||
|
||||
|
||||
// ================================================================
|
||||
|
||||
ClassLoaderType::ClassLoaderType()
|
||||
:Type("java.lang", "ClassLoader", BUILT_IN, false, false, false)
|
||||
:Type("java.lang", "ClassLoader", BUILT_IN, false, false)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -25,9 +25,9 @@ public:
|
||||
};
|
||||
|
||||
Type(const string& name, int kind, bool canWriteToParcel,
|
||||
bool canWriteToRpcData, bool canBeOut);
|
||||
bool canBeOut);
|
||||
Type(const string& package, const string& name,
|
||||
int kind, bool canWriteToParcel, bool canWriteToRpcData, bool canBeOut,
|
||||
int kind, bool canWriteToParcel, bool canBeOut,
|
||||
const string& declFile = "", int declLine = -1);
|
||||
virtual ~Type();
|
||||
|
||||
@@ -38,12 +38,10 @@ public:
|
||||
inline string DeclFile() const { return m_declFile; }
|
||||
inline int DeclLine() const { return m_declLine; }
|
||||
inline bool CanWriteToParcel() const { return m_canWriteToParcel; }
|
||||
inline bool CanWriteToRpcData() const { return m_canWriteToRpcData; }
|
||||
inline bool CanBeOutParameter() const { return m_canBeOut; }
|
||||
|
||||
virtual string ImportType() const;
|
||||
virtual string CreatorName() const;
|
||||
virtual string RpcCreatorName() const;
|
||||
virtual string InstantiableName() const;
|
||||
|
||||
virtual void WriteToParcel(StatementBlock* addTo, Variable* v,
|
||||
@@ -62,11 +60,6 @@ public:
|
||||
virtual void ReadArrayFromParcel(StatementBlock* addTo, Variable* v,
|
||||
Variable* parcel, Variable** cl);
|
||||
|
||||
virtual void WriteToRpcData(StatementBlock* addTo, Expression* k, Variable* v,
|
||||
Variable* data, int flags);
|
||||
virtual void CreateFromRpcData(StatementBlock* addTo, Expression* k, Variable* v,
|
||||
Variable* data, Variable** cl);
|
||||
|
||||
protected:
|
||||
void SetQualifiedName(const string& qualified);
|
||||
Expression* BuildWriteToParcelFlags(int flags);
|
||||
@@ -82,7 +75,6 @@ private:
|
||||
int m_declLine;
|
||||
int m_kind;
|
||||
bool m_canWriteToParcel;
|
||||
bool m_canWriteToRpcData;
|
||||
bool m_canBeOut;
|
||||
};
|
||||
|
||||
@@ -94,12 +86,7 @@ public:
|
||||
const string& unmarshallParcel,
|
||||
const string& writeArrayParcel,
|
||||
const string& createArrayParcel,
|
||||
const string& readArrayParcel,
|
||||
const string& marshallRpc,
|
||||
const string& unmarshallRpc,
|
||||
const string& writeArrayRpc,
|
||||
const string& createArrayRpc,
|
||||
const string& readArrayRpc);
|
||||
const string& readArrayParcel);
|
||||
|
||||
virtual void WriteToParcel(StatementBlock* addTo, Variable* v,
|
||||
Variable* parcel, int flags);
|
||||
@@ -115,22 +102,12 @@ public:
|
||||
virtual void ReadArrayFromParcel(StatementBlock* addTo, Variable* v,
|
||||
Variable* parcel, Variable** cl);
|
||||
|
||||
virtual void WriteToRpcData(StatementBlock* addTo, Expression* k, Variable* v,
|
||||
Variable* data, int flags);
|
||||
virtual void CreateFromRpcData(StatementBlock* addTo, Expression* k, Variable* v,
|
||||
Variable* data, Variable** cl);
|
||||
|
||||
private:
|
||||
string m_marshallParcel;
|
||||
string m_unmarshallParcel;
|
||||
string m_writeArrayParcel;
|
||||
string m_createArrayParcel;
|
||||
string m_readArrayParcel;
|
||||
string m_marshallRpc;
|
||||
string m_unmarshallRpc;
|
||||
string m_writeArrayRpc;
|
||||
string m_createArrayRpc;
|
||||
string m_readArrayRpc;
|
||||
};
|
||||
|
||||
class BooleanType : public Type
|
||||
@@ -151,11 +128,6 @@ public:
|
||||
Variable* parcel, Variable** cl);
|
||||
virtual void ReadArrayFromParcel(StatementBlock* addTo, Variable* v,
|
||||
Variable* parcel, Variable** cl);
|
||||
|
||||
virtual void WriteToRpcData(StatementBlock* addTo, Expression* k, Variable* v,
|
||||
Variable* data, int flags);
|
||||
virtual void CreateFromRpcData(StatementBlock* addTo, Expression* k, Variable* v,
|
||||
Variable* data, Variable** cl);
|
||||
};
|
||||
|
||||
class CharType : public Type
|
||||
@@ -176,11 +148,6 @@ public:
|
||||
Variable* parcel, Variable** cl);
|
||||
virtual void ReadArrayFromParcel(StatementBlock* addTo, Variable* v,
|
||||
Variable* parcel, Variable** cl);
|
||||
|
||||
virtual void WriteToRpcData(StatementBlock* addTo, Expression* k, Variable* v,
|
||||
Variable* data, int flags);
|
||||
virtual void CreateFromRpcData(StatementBlock* addTo, Expression* k, Variable* v,
|
||||
Variable* data, Variable** cl);
|
||||
};
|
||||
|
||||
|
||||
@@ -204,11 +171,6 @@ public:
|
||||
Variable* parcel, Variable** cl);
|
||||
virtual void ReadArrayFromParcel(StatementBlock* addTo, Variable* v,
|
||||
Variable* parcel, Variable** cl);
|
||||
|
||||
virtual void WriteToRpcData(StatementBlock* addTo, Expression* k, Variable* v,
|
||||
Variable* data, int flags);
|
||||
virtual void CreateFromRpcData(StatementBlock* addTo, Expression* k, Variable* v,
|
||||
Variable* data, Variable** cl);
|
||||
};
|
||||
|
||||
class CharSequenceType : public Type
|
||||
@@ -345,22 +307,16 @@ public:
|
||||
Variable* parcel, Variable** cl);
|
||||
virtual void ReadFromParcel(StatementBlock* addTo, Variable* v,
|
||||
Variable* parcel, Variable** cl);
|
||||
|
||||
virtual void WriteToRpcData(StatementBlock* addTo, Expression* k, Variable* v,
|
||||
Variable* data, int flags);
|
||||
virtual void CreateFromRpcData(StatementBlock* addTo, Expression* k, Variable* v,
|
||||
Variable* data, Variable** cl);
|
||||
};
|
||||
|
||||
class UserDataType : public Type
|
||||
{
|
||||
public:
|
||||
UserDataType(const string& package, const string& name,
|
||||
bool builtIn, bool canWriteToParcel, bool canWriteToRpcData,
|
||||
bool builtIn, bool canWriteToParcel,
|
||||
const string& declFile = "", int declLine = -1);
|
||||
|
||||
virtual string CreatorName() const;
|
||||
virtual string RpcCreatorName() const;
|
||||
|
||||
virtual void WriteToParcel(StatementBlock* addTo, Variable* v,
|
||||
Variable* parcel, int flags);
|
||||
@@ -377,11 +333,6 @@ public:
|
||||
Variable* parcel, Variable** cl);
|
||||
virtual void ReadArrayFromParcel(StatementBlock* addTo, Variable* v,
|
||||
Variable* parcel, Variable** cl);
|
||||
|
||||
virtual void WriteToRpcData(StatementBlock* addTo, Expression* k, Variable* v,
|
||||
Variable* data, int flags);
|
||||
virtual void CreateFromRpcData(StatementBlock* addTo, Expression* k, Variable* v,
|
||||
Variable* data, Variable** cl);
|
||||
};
|
||||
|
||||
class InterfaceType : public Type
|
||||
@@ -427,17 +378,6 @@ private:
|
||||
vector<Type*> m_args;
|
||||
};
|
||||
|
||||
class RpcDataType : public UserDataType
|
||||
{
|
||||
public:
|
||||
RpcDataType();
|
||||
|
||||
virtual void WriteToRpcData(StatementBlock* addTo, Expression* k, Variable* v,
|
||||
Variable* data, int flags);
|
||||
virtual void CreateFromRpcData(StatementBlock* addTo, Expression* k, Variable* v,
|
||||
Variable* data, Variable** cl);
|
||||
};
|
||||
|
||||
class ClassLoaderType : public Type
|
||||
{
|
||||
public:
|
||||
@@ -460,11 +400,6 @@ public:
|
||||
virtual void ReadFromParcel(StatementBlock* addTo, Variable* v,
|
||||
Variable* parcel, Variable** cl);
|
||||
|
||||
virtual void WriteToRpcData(StatementBlock* addTo, Expression* k, Variable* v,
|
||||
Variable* data, int flags);
|
||||
virtual void CreateFromRpcData(StatementBlock* addTo, Expression* k, Variable* v,
|
||||
Variable* data, Variable** cl);
|
||||
|
||||
private:
|
||||
string m_creator;
|
||||
};
|
||||
@@ -527,11 +462,6 @@ extern Type* PARCELABLE_INTERFACE_TYPE;
|
||||
|
||||
extern Type* CONTEXT_TYPE;
|
||||
|
||||
extern Type* RPC_DATA_TYPE;
|
||||
extern Type* RPC_ERROR_TYPE;
|
||||
extern Type* RPC_CONTEXT_TYPE;
|
||||
extern Type* EVENT_FAKE_TYPE;
|
||||
|
||||
extern Expression* NULL_VALUE;
|
||||
extern Expression* THIS_VALUE;
|
||||
extern Expression* SUPER_VALUE;
|
||||
|
||||
@@ -63,12 +63,9 @@ test_document(document_item_type* d)
|
||||
}
|
||||
else if (d->item_type == USER_DATA_TYPE) {
|
||||
user_data_type* b = (user_data_type*)d;
|
||||
if ((b->flattening_methods & PARCELABLE_DATA) != 0) {
|
||||
if (b->parcelable) {
|
||||
printf("parcelable %s %s;\n", b->package, b->name.data);
|
||||
}
|
||||
if ((b->flattening_methods & RPC_DATA) != 0) {
|
||||
printf("flattenable %s %s;\n", b->package, b->name.data);
|
||||
}
|
||||
}
|
||||
else {
|
||||
printf("UNKNOWN d=0x%08lx d->item_type=%d\n", (long)d, d->item_type);
|
||||
@@ -254,8 +251,7 @@ check_filenames(const char* filename, document_item_type* items)
|
||||
user_data_type* p = (user_data_type*)items;
|
||||
err |= check_filename(filename, p->package, &p->name);
|
||||
}
|
||||
else if (items->item_type == INTERFACE_TYPE_BINDER
|
||||
|| items->item_type == INTERFACE_TYPE_RPC) {
|
||||
else if (items->item_type == INTERFACE_TYPE_BINDER) {
|
||||
interface_type* c = (interface_type*)items;
|
||||
err |= check_filename(filename, c->package, &c->name);
|
||||
}
|
||||
@@ -306,11 +302,9 @@ gather_types(const char* filename, document_item_type* items)
|
||||
if (items->item_type == USER_DATA_TYPE) {
|
||||
user_data_type* p = (user_data_type*)items;
|
||||
type = new UserDataType(p->package ? p->package : "", p->name.data,
|
||||
false, ((p->flattening_methods & PARCELABLE_DATA) != 0),
|
||||
((p->flattening_methods & RPC_DATA) != 0), filename, p->name.lineno);
|
||||
false, p->parcelable, filename, p->name.lineno);
|
||||
}
|
||||
else if (items->item_type == INTERFACE_TYPE_BINDER
|
||||
|| items->item_type == INTERFACE_TYPE_RPC) {
|
||||
else if (items->item_type == INTERFACE_TYPE_BINDER) {
|
||||
interface_type* c = (interface_type*)items;
|
||||
type = new InterfaceType(c->package ? c->package : "",
|
||||
c->name.data, false, c->oneway,
|
||||
@@ -334,30 +328,17 @@ gather_types(const char* filename, document_item_type* items)
|
||||
string name = c->name.data;
|
||||
name += ".Stub";
|
||||
Type* stub = new Type(c->package ? c->package : "",
|
||||
name, Type::GENERATED, false, false, false,
|
||||
name, Type::GENERATED, false, false,
|
||||
filename, c->name.lineno);
|
||||
NAMES.Add(stub);
|
||||
|
||||
name = c->name.data;
|
||||
name += ".Stub.Proxy";
|
||||
Type* proxy = new Type(c->package ? c->package : "",
|
||||
name, Type::GENERATED, false, false, false,
|
||||
name, Type::GENERATED, false, false,
|
||||
filename, c->name.lineno);
|
||||
NAMES.Add(proxy);
|
||||
}
|
||||
else if (items->item_type == INTERFACE_TYPE_RPC) {
|
||||
// for interfaces, also add the service base type, we don't
|
||||
// bother checking these for duplicates, because the parser
|
||||
// won't let us do it.
|
||||
interface_type* c = (interface_type*)items;
|
||||
|
||||
string name = c->name.data;
|
||||
name += ".ServiceBase";
|
||||
Type* base = new Type(c->package ? c->package : "",
|
||||
name, Type::GENERATED, false, false, false,
|
||||
filename, c->name.lineno);
|
||||
NAMES.Add(base);
|
||||
}
|
||||
} else {
|
||||
if (old->Kind() == Type::BUILT_IN) {
|
||||
fprintf(stderr, "%s:%d attempt to redefine built in class %s\n",
|
||||
@@ -409,7 +390,7 @@ matches_keyword(const char* str)
|
||||
}
|
||||
|
||||
static int
|
||||
check_method(const char* filename, int kind, method_type* m)
|
||||
check_method(const char* filename, method_type* m)
|
||||
{
|
||||
int err = 0;
|
||||
|
||||
@@ -422,19 +403,10 @@ check_method(const char* filename, int kind, method_type* m)
|
||||
return err;
|
||||
}
|
||||
|
||||
if (returnType == EVENT_FAKE_TYPE) {
|
||||
if (kind != INTERFACE_TYPE_RPC) {
|
||||
fprintf(stderr, "%s:%d event methods only supported for rpc interfaces\n",
|
||||
filename, m->type.type.lineno);
|
||||
err = 1;
|
||||
}
|
||||
} else {
|
||||
if (!(kind == INTERFACE_TYPE_BINDER ? returnType->CanWriteToParcel()
|
||||
: returnType->CanWriteToRpcData())) {
|
||||
fprintf(stderr, "%s:%d return type %s can't be marshalled.\n", filename,
|
||||
if (!returnType->CanWriteToParcel()) {
|
||||
fprintf(stderr, "%s:%d return type %s can't be marshalled.\n", filename,
|
||||
m->type.type.lineno, m->type.type.data);
|
||||
err = 1;
|
||||
}
|
||||
err = 1;
|
||||
}
|
||||
|
||||
if (m->type.dimension > 0 && !returnType->CanBeArray()) {
|
||||
@@ -467,30 +439,13 @@ check_method(const char* filename, int kind, method_type* m)
|
||||
goto next;
|
||||
}
|
||||
|
||||
if (t == EVENT_FAKE_TYPE) {
|
||||
fprintf(stderr, "%s:%d parameter %s (%d) event can not be used as a parameter %s\n",
|
||||
filename, m->type.type.lineno, arg->name.data, index,
|
||||
arg->type.type.data);
|
||||
err = 1;
|
||||
goto next;
|
||||
}
|
||||
|
||||
if (!(kind == INTERFACE_TYPE_BINDER ? t->CanWriteToParcel() : t->CanWriteToRpcData())) {
|
||||
if (!t->CanWriteToParcel()) {
|
||||
fprintf(stderr, "%s:%d parameter %d: '%s %s' can't be marshalled.\n",
|
||||
filename, m->type.type.lineno, index,
|
||||
arg->type.type.data, arg->name.data);
|
||||
err = 1;
|
||||
}
|
||||
|
||||
if (returnType == EVENT_FAKE_TYPE
|
||||
&& convert_direction(arg->direction.data) != IN_PARAMETER) {
|
||||
fprintf(stderr, "%s:%d parameter %d: '%s %s' All paremeters on events must be 'in'.\n",
|
||||
filename, m->type.type.lineno, index,
|
||||
arg->type.type.data, arg->name.data);
|
||||
err = 1;
|
||||
goto next;
|
||||
}
|
||||
|
||||
if (arg->direction.data == NULL
|
||||
&& (arg->type.dimension != 0 || t->CanBeOutParameter())) {
|
||||
fprintf(stderr, "%s:%d parameter %d: '%s %s' can be an out"
|
||||
@@ -552,8 +507,7 @@ check_types(const char* filename, document_item_type* items)
|
||||
int err = 0;
|
||||
while (items) {
|
||||
// (nothing to check for USER_DATA_TYPE)
|
||||
if (items->item_type == INTERFACE_TYPE_BINDER
|
||||
|| items->item_type == INTERFACE_TYPE_RPC) {
|
||||
if (items->item_type == INTERFACE_TYPE_BINDER) {
|
||||
map<string,method_type*> methodNames;
|
||||
interface_type* c = (interface_type*)items;
|
||||
|
||||
@@ -562,7 +516,7 @@ check_types(const char* filename, document_item_type* items)
|
||||
if (member->item_type == METHOD_TYPE) {
|
||||
method_type* m = (method_type*)member;
|
||||
|
||||
err |= check_method(filename, items->item_type, m);
|
||||
err |= check_method(filename, m);
|
||||
|
||||
// prevent duplicate methods
|
||||
if (methodNames.find(m->name.data) == methodNames.end()) {
|
||||
@@ -603,9 +557,6 @@ exactly_one_interface(const char* filename, const document_item_type* items, con
|
||||
if (next->item_type == INTERFACE_TYPE_BINDER) {
|
||||
lineno = ((interface_type*)next)->interface_token.lineno;
|
||||
}
|
||||
else if (next->item_type == INTERFACE_TYPE_RPC) {
|
||||
lineno = ((interface_type*)next)->interface_token.lineno;
|
||||
}
|
||||
fprintf(stderr, "%s:%d aidl can only handle one interface per file\n",
|
||||
filename, lineno);
|
||||
return 1;
|
||||
@@ -615,9 +566,9 @@ exactly_one_interface(const char* filename, const document_item_type* items, con
|
||||
*onlyParcelable = true;
|
||||
if (options.failOnParcelable) {
|
||||
fprintf(stderr, "%s:%d aidl can only generate code for interfaces, not"
|
||||
" parcelables or flattenables,\n", filename,
|
||||
" parcelables,\n", filename,
|
||||
((user_data_type*)items)->keyword_token.lineno);
|
||||
fprintf(stderr, "%s:%d .aidl files that only declare parcelables or flattenables"
|
||||
fprintf(stderr, "%s:%d .aidl files that only declare parcelables"
|
||||
"may not go in the Makefile.\n", filename,
|
||||
((user_data_type*)items)->keyword_token.lineno);
|
||||
return 1;
|
||||
@@ -654,7 +605,7 @@ generate_dep_file(const Options& options, const document_item_type* items)
|
||||
slash = "";
|
||||
}
|
||||
|
||||
if (items->item_type == INTERFACE_TYPE_BINDER || items->item_type == INTERFACE_TYPE_RPC) {
|
||||
if (items->item_type == INTERFACE_TYPE_BINDER) {
|
||||
fprintf(to, "%s: \\\n", options.outputFileName.c_str());
|
||||
} else {
|
||||
// parcelable: there's no output file.
|
||||
@@ -728,7 +679,7 @@ static string
|
||||
generate_outputFileName(const Options& options, const document_item_type* items)
|
||||
{
|
||||
// items has already been checked to have only one interface.
|
||||
if (items->item_type == INTERFACE_TYPE_BINDER || items->item_type == INTERFACE_TYPE_RPC) {
|
||||
if (items->item_type == INTERFACE_TYPE_BINDER) {
|
||||
interface_type* type = (interface_type*)items;
|
||||
|
||||
return generate_outputFileName2(options, type->name, type->package);
|
||||
@@ -815,22 +766,7 @@ parse_preprocessed_file(const string& filename)
|
||||
parcl->name.data = strdup(classname);
|
||||
parcl->semicolon_token.lineno = lineno;
|
||||
parcl->semicolon_token.data = strdup(";");
|
||||
parcl->flattening_methods = PARCELABLE_DATA;
|
||||
doc = (document_item_type*)parcl;
|
||||
}
|
||||
else if (0 == strcmp("flattenable", type)) {
|
||||
user_data_type* parcl = (user_data_type*)malloc(
|
||||
sizeof(user_data_type));
|
||||
memset(parcl, 0, sizeof(user_data_type));
|
||||
parcl->document_item.item_type = USER_DATA_TYPE;
|
||||
parcl->keyword_token.lineno = lineno;
|
||||
parcl->keyword_token.data = strdup(type);
|
||||
parcl->package = packagename ? strdup(packagename) : NULL;
|
||||
parcl->name.lineno = lineno;
|
||||
parcl->name.data = strdup(classname);
|
||||
parcl->semicolon_token.lineno = lineno;
|
||||
parcl->semicolon_token.data = strdup(";");
|
||||
parcl->flattening_methods = RPC_DATA;
|
||||
parcl->parcelable = true;
|
||||
doc = (document_item_type*)parcl;
|
||||
}
|
||||
else if (0 == strcmp("interface", type)) {
|
||||
@@ -1084,12 +1020,9 @@ preprocess_aidl(const Options& options)
|
||||
string line;
|
||||
if (doc->item_type == USER_DATA_TYPE) {
|
||||
user_data_type* parcelable = (user_data_type*)doc;
|
||||
if ((parcelable->flattening_methods & PARCELABLE_DATA) != 0) {
|
||||
if (parcelable->parcelable) {
|
||||
line = "parcelable ";
|
||||
}
|
||||
if ((parcelable->flattening_methods & RPC_DATA) != 0) {
|
||||
line = "flattenable ";
|
||||
}
|
||||
if (parcelable->package) {
|
||||
line += parcelable->package;
|
||||
line += '.';
|
||||
|
||||
@@ -68,8 +68,7 @@ typedef struct method_type {
|
||||
|
||||
enum {
|
||||
USER_DATA_TYPE = 12,
|
||||
INTERFACE_TYPE_BINDER,
|
||||
INTERFACE_TYPE_RPC
|
||||
INTERFACE_TYPE_BINDER
|
||||
};
|
||||
|
||||
typedef struct document_item_type {
|
||||
@@ -78,19 +77,13 @@ typedef struct document_item_type {
|
||||
} document_item_type;
|
||||
|
||||
|
||||
// for user_data_type.flattening_methods
|
||||
enum {
|
||||
PARCELABLE_DATA = 0x1,
|
||||
RPC_DATA = 0x2
|
||||
};
|
||||
|
||||
typedef struct user_data_type {
|
||||
document_item_type document_item;
|
||||
buffer_type keyword_token; // only the first one
|
||||
char* package;
|
||||
buffer_type name;
|
||||
buffer_type semicolon_token;
|
||||
int flattening_methods;
|
||||
bool parcelable;
|
||||
} user_data_type;
|
||||
|
||||
typedef struct interface_type {
|
||||
|
||||
@@ -83,8 +83,6 @@ idvalue (0|[1-9][0-9]*)
|
||||
/* keywords */
|
||||
parcelable { SET_BUFFER(PARCELABLE); return PARCELABLE; }
|
||||
interface { SET_BUFFER(INTERFACE); return INTERFACE; }
|
||||
flattenable { SET_BUFFER(FLATTENABLE); return FLATTENABLE; }
|
||||
rpc { SET_BUFFER(INTERFACE); return RPC; }
|
||||
in { SET_BUFFER(IN); return IN; }
|
||||
out { SET_BUFFER(OUT); return OUT; }
|
||||
inout { SET_BUFFER(INOUT); return INOUT; }
|
||||
|
||||
@@ -20,8 +20,6 @@ static int count_brackets(const char*);
|
||||
%token ARRAY
|
||||
%token PARCELABLE
|
||||
%token INTERFACE
|
||||
%token FLATTENABLE
|
||||
%token RPC
|
||||
%token IN
|
||||
%token OUT
|
||||
%token INOUT
|
||||
@@ -88,7 +86,7 @@ parcelable_decl:
|
||||
b->name = $2.buffer;
|
||||
b->package = g_currentPackage ? strdup(g_currentPackage) : NULL;
|
||||
b->semicolon_token = $3.buffer;
|
||||
b->flattening_methods = PARCELABLE_DATA;
|
||||
b->parcelable = true;
|
||||
$$.user_data = b;
|
||||
}
|
||||
| PARCELABLE ';' {
|
||||
@@ -101,28 +99,6 @@ parcelable_decl:
|
||||
g_currentFilename, $2.buffer.lineno, $2.buffer.data);
|
||||
$$.user_data = NULL;
|
||||
}
|
||||
| FLATTENABLE IDENTIFIER ';' {
|
||||
user_data_type* b = (user_data_type*)malloc(sizeof(user_data_type));
|
||||
b->document_item.item_type = USER_DATA_TYPE;
|
||||
b->document_item.next = NULL;
|
||||
b->keyword_token = $1.buffer;
|
||||
b->name = $2.buffer;
|
||||
b->package = g_currentPackage ? strdup(g_currentPackage) : NULL;
|
||||
b->semicolon_token = $3.buffer;
|
||||
b->flattening_methods = PARCELABLE_DATA | RPC_DATA;
|
||||
$$.user_data = b;
|
||||
}
|
||||
| FLATTENABLE ';' {
|
||||
fprintf(stderr, "%s:%d syntax error in flattenable declaration. Expected type name.\n",
|
||||
g_currentFilename, $1.buffer.lineno);
|
||||
$$.user_data = NULL;
|
||||
}
|
||||
| FLATTENABLE error ';' {
|
||||
fprintf(stderr, "%s:%d syntax error in flattenable declaration. Expected type name, saw \"%s\".\n",
|
||||
g_currentFilename, $2.buffer.lineno, $2.buffer.data);
|
||||
$$.user_data = NULL;
|
||||
}
|
||||
|
||||
;
|
||||
|
||||
interface_header:
|
||||
@@ -146,21 +122,6 @@ interface_header:
|
||||
c->comments_token = &c->oneway_token;
|
||||
$$.interface_obj = c;
|
||||
}
|
||||
| RPC {
|
||||
interface_type* c = (interface_type*)malloc(sizeof(interface_type));
|
||||
c->document_item.item_type = INTERFACE_TYPE_RPC;
|
||||
c->document_item.next = NULL;
|
||||
c->interface_token = $1.buffer;
|
||||
c->oneway = false;
|
||||
memset(&c->oneway_token, 0, sizeof(buffer_type));
|
||||
c->comments_token = &c->interface_token;
|
||||
$$.interface_obj = c;
|
||||
}
|
||||
;
|
||||
|
||||
interface_keywords:
|
||||
INTERFACE
|
||||
| RPC
|
||||
;
|
||||
|
||||
interface_decl:
|
||||
@@ -173,12 +134,12 @@ interface_decl:
|
||||
c->close_brace_token = $5.buffer;
|
||||
$$.interface_obj = c;
|
||||
}
|
||||
| interface_keywords error '{' interface_items '}' {
|
||||
| INTERFACE error '{' interface_items '}' {
|
||||
fprintf(stderr, "%s:%d: syntax error in interface declaration. Expected type name, saw \"%s\"\n",
|
||||
g_currentFilename, $2.buffer.lineno, $2.buffer.data);
|
||||
$$.document_item = NULL;
|
||||
}
|
||||
| interface_keywords error '}' {
|
||||
| INTERFACE error '}' {
|
||||
fprintf(stderr, "%s:%d: syntax error in interface declaration. Expected type name, saw \"%s\"\n",
|
||||
g_currentFilename, $2.buffer.lineno, $2.buffer.data);
|
||||
$$.document_item = NULL;
|
||||
|
||||
@@ -66,9 +66,6 @@ generate_java(const string& filename, const string& originalSrc,
|
||||
if (iface->document_item.item_type == INTERFACE_TYPE_BINDER) {
|
||||
cl = generate_binder_interface_class(iface);
|
||||
}
|
||||
else if (iface->document_item.item_type == INTERFACE_TYPE_RPC) {
|
||||
cl = generate_rpc_interface_class(iface);
|
||||
}
|
||||
|
||||
Document* document = new Document;
|
||||
document->comment = "";
|
||||
|
||||
@@ -13,7 +13,6 @@ int generate_java(const string& filename, const string& originalSrc,
|
||||
interface_type* iface);
|
||||
|
||||
Class* generate_binder_interface_class(const interface_type* iface);
|
||||
Class* generate_rpc_interface_class(const interface_type* iface);
|
||||
|
||||
string gather_comments(extra_text_type* extra);
|
||||
string append(const char* a, const char* b);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user