-
Notifications
You must be signed in to change notification settings - Fork 555
[Xamarin..Android.Tools.Aidl] Handle out and inout Parameters in CodeGenerator properly #5726
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -277,6 +277,20 @@ protected override bool OnTransact (int code, global::Android.OS.Parcel data, gl | |
w.WriteLine ("\t\t\t\t{0} {1} = default ({0});", ToOutputTypeName (name_cache.ToCSharp (a.Type)), "arg" + i); | ||
if (a.Modifier == null || a.Modifier.Contains ("in")) | ||
w.WriteLine ("\t\t\t\t{0}", GetCreateStatements (a.Type, "data", "arg" + i)); | ||
else if (a.Modifier != null && a.Modifier.Contains ("out")) { | ||
if (a.Type.ArrayDimension > 0) { | ||
w.WriteLine (@" int {0}_length = data.ReadInt(); | ||
if ({0}_length < 0) {{ | ||
{0} = null; | ||
}} | ||
else {{ | ||
{0} = new {1}[{0}_length]; | ||
}}", "arg" + i, ToOutputTypeName (name_cache.ToCSharp (a.Type)).Replace ("[]", "")); | ||
} | ||
else { | ||
w.WriteLine ("\t\t\t\t{0} = new {1}();", "arg" + i, ToOutputTypeName (name_cache.ToCSharp (a.Type))); | ||
} | ||
} | ||
} | ||
string args = String.Join (", ", (from i in Enumerable.Range (0, method.Arguments.Length) select "arg" + i).ToArray ()); | ||
if (isVoidReturn) | ||
|
@@ -289,8 +303,8 @@ protected override bool OnTransact (int code, global::Android.OS.Parcel data, gl | |
w.WriteLine ("\t\t\t\t{0}", GetWriteStatements (method.ReturnType, "reply", "result", "global::Android.OS.ParcelableWriteFlags.ReturnValue")); | ||
for (int i = 0; method.Arguments != null && i < method.Arguments.Length; i++) { | ||
var a = method.Arguments [i]; | ||
if (a.Modifier == null || a.Modifier.Contains ("out")) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I assume this change/removal is why I think this is correct? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change was necessary because before for primitive input parameters like in |
||
w.WriteLine ("\t\t\t\t{0}", GetWriteStatements (a.Type, "data", "arg" + i, "global::Android.OS.ParcelableWriteFlags.None")); | ||
if (a.Modifier != null && a.Modifier.Contains ("out")) | ||
w.WriteLine ("\t\t\t\t{0}", GetWriteStatements (a.Type, "reply", "arg" + i, "global::Android.OS.ParcelableWriteFlags.ReturnValue")); | ||
} | ||
w.WriteLine ("\t\t\t\treturn true;"); | ||
w.WriteLine ("\t\t\t\t}"); | ||
|
@@ -331,13 +345,16 @@ public string GetInterfaceDescriptor () | |
if (!isOneWay) | ||
w.WriteLine ("\t\t\t\tglobal::Android.OS.Parcel __reply = global::Android.OS.Parcel.Obtain ();"); | ||
if (hasReturn) | ||
w.WriteLine ("{0} __result = default ({0});", ToOutputTypeName (name_cache.ToCSharp (method.ReturnType))); | ||
w.WriteLine ("\t\t\t\t{0} __result = default ({0});", ToOutputTypeName (name_cache.ToCSharp (method.ReturnType))); | ||
w.WriteLine (@" | ||
try { | ||
__data.WriteInterfaceToken (descriptor);"); | ||
foreach (var arg in method.Arguments) | ||
foreach (var arg in method.Arguments) { | ||
if (arg.Modifier == null || arg.Modifier.Contains ("in")) | ||
w.WriteLine ("\t\t\t\t\t" + GetWriteStatements (arg.Type, "__data", SafeCSharpName (arg.Name), "global::Android.OS.ParcelableWriteFlags.None")); | ||
else if (arg.Modifier != null && arg.Modifier.Contains ("out") && arg.Type.ArrayDimension > 0) | ||
w.WriteLine ("\t\t\t\t\t" + GetWriteOutStatements (arg.Type, "__data", SafeCSharpName (arg.Name))); | ||
} | ||
w.WriteLine ("\t\t\t\t\tremote.Transact ({1}Stub.Transaction{0}, __data, {2}, 0);", | ||
method.Name, | ||
type.Name, | ||
|
@@ -613,7 +630,15 @@ string GetWriteStatements (TypeName type, string parcel, string arg, string parc | |
return String.Format ("{1}.WriteStrongBinder (((({0} != null)) ? ({0}.AsBinder ()) : (null)));", arg, parcel); | ||
} | ||
} | ||
|
||
|
||
string GetWriteOutStatements (TypeName type, string parcel, string arg) | ||
{ | ||
if (type.ArrayDimension > 0) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. …ditto here: is A quick gander at the AIDL documentation suggests it isn't possible. However, it does suggest that
which implies that a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The way I understand the AIDL dokumentation is that multidimensional arrays like For The CSharpCodeGenerator might not cover all cases for Lists correct and should definetely be unit tested also in this perspect. |
||
return "if (" + arg + " == null) { " + parcel + ".WriteInt(-1); } else { " + parcel + ".WriteInt(" + arg + ".Length); }"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Given that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @mfranke-moba : please add a unit test which causes this line to be triggered. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is already covered by There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, I had missed that. :-( |
||
} else | ||
return ""; | ||
} | ||
|
||
// FIXME: should this be used? | ||
string GetCreatorName (TypeName type) | ||
{ | ||
|
Uh oh!
There was an error while loading. Please reload this page.