Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tools/generator/CodeGenerationOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ internal CodeGenerator CreateCodeGenerator (TextWriter writer)
bool? buildingCoreAssembly;
public bool BuildingCoreAssembly {
get {
return buildingCoreAssembly ?? (buildingCoreAssembly = (SymbolTable.Lookup ("java.lang.Object") is XmlClassGen)).Value;
return buildingCoreAssembly ?? (buildingCoreAssembly = (SymbolTable.Lookup ("java.lang.Object") is ClassGen gen && gen.FromXml)).Value;
}
}

Expand Down
2 changes: 1 addition & 1 deletion tools/generator/CodeGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ internal static void ProcessReferencedType (TypeDefinition td, CodeGenerationOpt
//Console.Error.WriteLine ("WARNING: " + td.FullName + " survived");
}

ISymbol gb = td.IsEnum ? (ISymbol)new EnumSymbol (td.FullNameCorrected ()) : td.IsInterface ? (ISymbol)new ManagedInterfaceGen (td, opt) : new ManagedClassGen (td, opt);
ISymbol gb = td.IsEnum ? (ISymbol)new EnumSymbol (td.FullNameCorrected ()) : td.IsInterface ? (ISymbol)CecilApiImporter.CreateInterface (td, opt) : CecilApiImporter.CreateClass (td, opt);
opt.SymbolTable.AddType (gb);

foreach (var nt in td.NestedTypes)
Expand Down
2 changes: 1 addition & 1 deletion tools/generator/Extensions/ManagedExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public static IEnumerable<Parameter> GetParameters (this MethodDefinition m, Cus
// custom enum types and cannot simply use JNI signature here.
var rawtype = e?.Current.Type;
var type = p.ParameterType.FullName == "System.IO.Stream" && e != null ? e.Current.Type : null;
yield return Parameter.FromManagedParameter (p, type, rawtype);
yield return CecilApiImporter.CreateParameter (p, type, rawtype);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public void WriteClass (ClassGen @class, string indent, GenerationInfo gen_info)

bool requireNew = @class.InheritsObject;
if (!requireNew) {
for (var bg = @class.BaseGen; bg != null && bg is XmlClassGen; bg = bg.BaseGen) {
for (var bg = @class.BaseGen; bg != null && bg is ClassGen classGen && classGen.FromXml; bg = bg.BaseGen) {
if (bg.InheritsObject) {
requireNew = true;
break;
Expand Down Expand Up @@ -367,15 +367,15 @@ internal virtual void WriteConstructor (Ctor constructor, string indent, bool us
if (constructor.Annotation != null)
writer.WriteLine ("{0}{1}", indent, constructor.Annotation);

writer.WriteLine ("{0}{1} unsafe {2} ({3})", indent, constructor.Visibility, constructor.Name, GenBase.GetSignature (constructor, opt));
writer.WriteLine ("{0}{1} unsafe {2} ({3})", indent, constructor.Visibility, constructor.Name, constructor.GetSignature (opt));
writer.WriteLine ("{0}\t: {1} (IntPtr.Zero, JniHandleOwnership.DoNotTransfer)", indent, useBase ? "base" : "this");
writer.WriteLine ("{0}{{", indent);
WriteConstructorBody (constructor, indent + "\t", call_cleanup);
writer.WriteLine ("{0}}}", indent);
writer.WriteLine ();
if (gen_string_overload) {
writer.WriteLine ("{0}[Register (\"{1}\", \"{2}\", \"{3}\"{4})]", indent, ".ctor", jni_sig, String.Empty, constructor.AdditionalAttributeString ());
writer.WriteLine ("{0}{1} unsafe {2} ({3})", indent, constructor.Visibility, constructor.Name, GenBase.GetSignature (constructor, opt).Replace ("Java.Lang.ICharSequence", "string").Replace ("global::string", "string"));
writer.WriteLine ("{0}{1} unsafe {2} ({3})", indent, constructor.Visibility, constructor.Name, constructor.GetSignature (opt).Replace ("Java.Lang.ICharSequence", "string").Replace ("global::string", "string"));
writer.WriteLine ("{0}\t: {1} (IntPtr.Zero, JniHandleOwnership.DoNotTransfer)", indent, useBase ? "base" : "this");
writer.WriteLine ("{0}{{", indent);
WriteConstructorBody (constructor, indent + "\t", call_cleanup);
Expand Down Expand Up @@ -582,7 +582,7 @@ public void WriteInterfaceEventArgs (InterfaceGen @interface, Method m, string i
writer.WriteLine ();
}
} else {
writer.WriteLine ("{0}public delegate {1} {2} ({3});", indent, opt.GetOutputName (m.RetVal.FullName), @interface.GetEventDelegateName (m), GenBase.GetSignature (m, opt));
writer.WriteLine ("{0}public delegate {1} {2} ({3});", indent, opt.GetOutputName (m.RetVal.FullName), @interface.GetEventDelegateName (m), m.GetSignature (opt));
writer.WriteLine ();
}
}
Expand Down Expand Up @@ -645,7 +645,7 @@ public void WriteInterfaceEventHandlerImplContent (InterfaceGen @interface, Meth
writer.WriteLine ("#pragma warning restore 0649");
}
writer.WriteLine ();
writer.WriteLine ("{0}\tpublic {1} {2} ({3})", indent, m.RetVal.FullName, m.Name, GenBase.GetSignature (m, opt));
writer.WriteLine ("{0}\tpublic {1} {2} ({3})", indent, m.RetVal.FullName, m.Name, m.GetSignature (opt));
writer.WriteLine ("{0}\t{{", indent);
if (m.EventName == string.Empty) {
// generate nothing
Expand Down Expand Up @@ -1047,7 +1047,7 @@ public void WriteMethodExplicitInterfaceImplementation (Method method, string in
{
//writer.WriteLine ("// explicitly implemented method from " + iface.FullName);
WriteMethodCustomAttributes (method, indent);
writer.WriteLine ("{0}{1} {2}.{3} ({4})", indent, opt.GetOutputName (method.RetVal.FullName), opt.GetOutputName (iface.FullName), method.Name, GenBase.GetSignature (method, opt));
writer.WriteLine ("{0}{1} {2}.{3} ({4})", indent, opt.GetOutputName (method.RetVal.FullName), opt.GetOutputName (iface.FullName), method.Name, method.GetSignature (opt));
writer.WriteLine ("{0}{{", indent);
writer.WriteLine ("{0}\treturn {1} ({2});", indent, method.Name, method.Parameters.GetCall (opt));
writer.WriteLine ("{0}}}", indent);
Expand All @@ -1059,7 +1059,7 @@ public void WriteMethodExplicitInterfaceInvoker (Method method, string indent, G
//writer.WriteLine ("\t\t// explicitly implemented invoker method from " + iface.FullName);
WriteMethodIdField (method, indent);
writer.WriteLine ("{0}unsafe {1} {2}.{3} ({4})",
indent, opt.GetOutputName (method.RetVal.FullName), opt.GetOutputName (iface.FullName), method.Name, GenBase.GetSignature (method, opt));
indent, opt.GetOutputName (method.RetVal.FullName), opt.GetOutputName (iface.FullName), method.Name, method.GetSignature (opt));
writer.WriteLine ("{0}{{", indent);
WriteMethodBody (method, indent + "\t");
writer.WriteLine ("{0}}}", indent);
Expand All @@ -1070,7 +1070,7 @@ public void WriteMethodAbstractDeclaration (Method method, string indent, Interf
{
if (method.RetVal.IsGeneric && gen != null) {
WriteMethodCustomAttributes (method, indent);
writer.WriteLine ("{0}{1} {2}.{3} ({4})", indent, opt.GetOutputName (method.RetVal.FullName), opt.GetOutputName (gen.FullName), method.Name, GenBase.GetSignature (method, opt));
writer.WriteLine ("{0}{1} {2}.{3} ({4})", indent, opt.GetOutputName (method.RetVal.FullName), opt.GetOutputName (gen.FullName), method.Name, method.GetSignature (opt));
writer.WriteLine ("{0}{{", indent);
writer.WriteLine ("{0}\tthrow new NotImplementedException ();", indent);
writer.WriteLine ("{0}}}", indent);
Expand All @@ -1089,7 +1089,7 @@ public void WriteMethodAbstractDeclaration (Method method, string indent, Interf
method.Visibility,
opt.GetOutputName (method.RetVal.FullName),
name,
GenBase.GetSignature (method, opt));
method.GetSignature (opt));
writer.WriteLine ();

if (gen_as_formatted || method.Parameters.HasCharSequence)
Expand All @@ -1111,13 +1111,13 @@ public void WriteMethodDeclaration (Method method, string indent, GenBase type,
writer.WriteLine ("{0}[global::Java.Interop.JavaInterfaceDefaultMethod]", indent);
writer.WriteLine ("{0}[Register (\"{1}\", \"{2}\", \"{3}:{4}\"{5})]", indent, method.JavaName, method.JniSignature, method.ConnectorName, method.GetAdapterName (opt, adapter), method.AdditionalAttributeString ());
WriteMethodCustomAttributes (method, indent);
writer.WriteLine ("{0}{1} {2} ({3});", indent, opt.GetOutputName (method.RetVal.FullName), method.AdjustedName, GenBase.GetSignature (method, opt));
writer.WriteLine ("{0}{1} {2} ({3});", indent, opt.GetOutputName (method.RetVal.FullName), method.AdjustedName, method.GetSignature (opt));
writer.WriteLine ();
}

public void WriteMethodEventDelegate (Method method, string indent)
{
writer.WriteLine ("{0}public delegate {1} {2}EventHandler ({3});", indent, opt.GetOutputName (method.RetVal.FullName), method.Name, GenBase.GetSignature (method, opt));
writer.WriteLine ("{0}public delegate {1} {2}EventHandler ({3});", indent, opt.GetOutputName (method.RetVal.FullName), method.Name, method.GetSignature (opt));
writer.WriteLine ();
}

Expand All @@ -1126,7 +1126,7 @@ public void WriteMethodExplicitIface (Method method, string indent, GenericSymbo
{
writer.WriteLine ("{0}// This method is explicitly implemented as a member of an instantiated {1}", indent, gen.FullName);
WriteMethodCustomAttributes (method, indent);
writer.WriteLine ("{0}{1} {2}.{3} ({4})", indent, opt.GetOutputName (method.RetVal.FullName), opt.GetOutputName (gen.Gen.FullName), method.Name, GenBase.GetSignature (method, opt));
writer.WriteLine ("{0}{1} {2}.{3} ({4})", indent, opt.GetOutputName (method.RetVal.FullName), opt.GetOutputName (gen.Gen.FullName), method.Name, method.GetSignature (opt));
writer.WriteLine ("{0}{{", indent);
Dictionary<string, string> mappings = new Dictionary<string, string> ();
for (int i = 0; i < gen.TypeParams.Length; i++)
Expand Down Expand Up @@ -1163,7 +1163,7 @@ public void WriteMethodInvoker (Method method, string indent, GenBase type)
WriteMethodCallback (method, indent, type, null, method.IsReturnCharSequence);
WriteMethodIdField (method, indent, invoker: true);
writer.WriteLine ("{0}public unsafe {1}{2} {3} ({4})",
indent, method.IsStatic ? "static " : string.Empty, opt.GetOutputName (method.RetVal.FullName), method.AdjustedName, GenBase.GetSignature (method, opt));
indent, method.IsStatic ? "static " : string.Empty, opt.GetOutputName (method.RetVal.FullName), method.AdjustedName, method.GetSignature (opt));
writer.WriteLine ("{0}{{", indent);
WriteMethodInvokerBody (method, indent + "\t");
writer.WriteLine ("{0}}}", indent);
Expand Down Expand Up @@ -1239,7 +1239,7 @@ void WriteMethodStringOverload (Method method, string indent)
string ret = opt.GetOutputName (method.RetVal.FullName.Replace ("Java.Lang.ICharSequence", "string"));
if (method.Deprecated != null)
writer.WriteLine ("{0}[Obsolete (@\"{1}\")]", indent, method.Deprecated.Replace ("\"", "\"\"").Trim ());
writer.WriteLine ("{0}{1}{2} {3} {4} ({5})", indent, method.Visibility, static_arg, ret, method.Name, GenBase.GetSignature (method, opt).Replace ("Java.Lang.ICharSequence", "string").Replace ("global::string", "string"));
writer.WriteLine ("{0}{1}{2} {3} {4} ({5})", indent, method.Visibility, static_arg, ret, method.Name, method.GetSignature (opt).Replace ("Java.Lang.ICharSequence", "string").Replace ("global::string", "string"));
writer.WriteLine ("{0}{{", indent);
WriteMethodStringOverloadBody (method, indent + "\t", false);
writer.WriteLine ("{0}}}", indent);
Expand All @@ -1255,7 +1255,7 @@ public void WriteMethodExtensionOverload (Method method, string indent, string s
writer.WriteLine ();
writer.WriteLine ("{0}public static {1} {2} (this {3} self, {4})",
indent, ret, method.Name, selfType,
GenBase.GetSignature (method, opt).Replace ("Java.Lang.ICharSequence", "string").Replace ("global::string", "string"));
method.GetSignature (opt).Replace ("Java.Lang.ICharSequence", "string").Replace ("global::string", "string"));
writer.WriteLine ("{0}{{", indent);
WriteMethodStringOverloadBody (method, indent + "\t", true);
writer.WriteLine ("{0}}}", indent);
Expand All @@ -1274,7 +1274,7 @@ public void WriteMethodAsyncWrapper (Method method, string indent)
else
ret = "global::System.Threading.Tasks.Task<" + opt.GetOutputName (method.RetVal.FullName) + ">";

writer.WriteLine ("{0}{1}{2} {3} {4}Async ({5})", indent, method.Visibility, static_arg, ret, method.AdjustedName, GenBase.GetSignature (method, opt));
writer.WriteLine ("{0}{1}{2} {3} {4}Async ({5})", indent, method.Visibility, static_arg, ret, method.AdjustedName, method.GetSignature (opt));
writer.WriteLine ("{0}{{", indent);
writer.WriteLine ("{0}\treturn global::System.Threading.Tasks.Task.Run (() => {1} ({2}));", indent, method.AdjustedName, method.Parameters.GetCall (opt));
writer.WriteLine ("{0}}}", indent);
Expand All @@ -1293,7 +1293,7 @@ public void WriteMethodExtensionAsyncWrapper (Method method, string indent, stri
else
ret = "global::System.Threading.Tasks.Task<" + opt.GetOutputName (method.RetVal.FullName) + ">";

writer.WriteLine ("{0}public static {1} {2}Async (this {3} self{4}{5})", indent, ret, method.AdjustedName, selfType, method.Parameters.Count > 0 ? ", " : string.Empty, GenBase.GetSignature (method, opt));
writer.WriteLine ("{0}public static {1} {2}Async (this {3} self{4}{5})", indent, ret, method.AdjustedName, selfType, method.Parameters.Count > 0 ? ", " : string.Empty, method.GetSignature (opt));
writer.WriteLine ("{0}{{", indent);
writer.WriteLine ("{0}\treturn global::System.Threading.Tasks.Task.Run (() => self.{1} ({2}));", indent, method.AdjustedName, method.Parameters.GetCall (opt));
writer.WriteLine ("{0}}}", indent);
Expand Down Expand Up @@ -1329,7 +1329,7 @@ public void WriteMethod (Method method, string indent, GenBase type, bool genera
writer.WriteLine ("{0}[Register (\"{1}\", \"{2}\", \"{3}\"{4})]",
indent, method.JavaName, method.JniSignature, method.IsVirtual ? method.ConnectorName : String.Empty, method.AdditionalAttributeString ());
WriteMethodCustomAttributes (method, indent);
writer.WriteLine ("{0}{1}{2}{3}{4} unsafe {5} {6} ({7})", indent, method.Visibility, static_arg, virt_ov, seal, ret, method.AdjustedName, GenBase.GetSignature (method, opt));
writer.WriteLine ("{0}{1}{2}{3}{4} unsafe {5} {6} ({7})", indent, method.Visibility, static_arg, virt_ov, seal, ret, method.AdjustedName, method.GetSignature (opt));
writer.WriteLine ("{0}{{", indent);
WriteMethodBody (method, indent + "\t");
writer.WriteLine ("{0}}}", indent);
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Loading