Skip to content

[JavaCallableWrappers] Remove was_scanned from XmlImporter/XmlExporter. #1325

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

Merged
merged 1 commit into from
Apr 8, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -17,32 +17,27 @@ public static class XmlExporter
OmitXmlDeclaration = true,
};

public static void Export (string filename, IEnumerable<CallableWrapperType> types, bool wasScanned)
public static void Export (string filename, IEnumerable<CallableWrapperType> types)
{
using (var sw = new StreamWriter (filename, false, Encoding.UTF8))
Export (sw, types, wasScanned);
Export (sw, types);
}

public static void Export (TextWriter sw, IEnumerable<CallableWrapperType> types, bool wasScanned)
public static void Export (TextWriter sw, IEnumerable<CallableWrapperType> types)
{
using (var xml = XmlWriter.Create (sw, settings))
Export (xml, types, wasScanned);
Export (xml, types);
}

public static void Export (XmlWriter xml, IEnumerable<CallableWrapperType> types, bool wasScanned)
public static void Export (XmlWriter xml, IEnumerable<CallableWrapperType> types)
{
ExportTypes (xml, types, wasScanned);
ExportTypes (xml, types);
}

static void ExportTypes (XmlWriter xml, IEnumerable<CallableWrapperType> types, bool wasScanned)
static void ExportTypes (XmlWriter xml, IEnumerable<CallableWrapperType> types)
{
xml.WriteStartElement ("types");
xml.WriteAttributeString ("was_scanned", wasScanned.ToString ());

foreach (var type in types)
ExportType (xml, type);

xml.WriteEndElement ();
}

public static void ExportType (XmlWriter xml, CallableWrapperType type)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,31 +11,41 @@ namespace Java.Interop.Tools.JavaCallableWrappers.Adapters;

public static class XmlImporter
{
public static List<CallableWrapperType> Import (string filename, out bool wasScanned)
public static List<CallableWrapperType> Import (string filename)
{
using (var sr = new StreamReader (filename, Encoding.UTF8))
return Import (sr, out wasScanned);
return Import (sr);
}

public static List<CallableWrapperType> Import (TextReader sr, out bool wasScanned)
public static List<CallableWrapperType> Import (TextReader sr)
{
using (var xml = XmlReader.Create (sr))
return Import (xml, out wasScanned);
return Import (xml);
}

public static List<CallableWrapperType> Import (XmlReader xml, out bool wasScanned)
public static List<CallableWrapperType> Import (XmlReader xml)
{
var doc = XDocument.Load (xml);

var types = new List<CallableWrapperType> ();
wasScanned = doc.Root.GetAttributeOrDefault ("was_scanned", false);

foreach (var type in doc.Root.Elements ("type"))
types.Add (ImportType (type));

return types;
}


public static List<CallableWrapperType> Import (XElement xml)
{
var types = new List<CallableWrapperType> ();

foreach (var type in xml.Elements ("type"))
types.Add (ImportType (type));

return types;
}

public static CallableWrapperType ImportType (XElement xml)
{
var name = xml.GetRequiredAttribute ("name");
Expand Down