Permalink
Browse files

Implement NSPropertyListSerialization

First pass; one crashers.

Working:

- DataWithPropertyList
- WritePropertyList
- IsValidForFormat

Crashing:

- PropertyListWithData
- PropertyListWithStream
  • Loading branch information...
1 parent 412b13a commit e4927152dd3c0a8f83e2a7032c79926a1af33bb3 @abock abock committed Jan 7, 2013
Showing with 99 additions and 1 deletion.
  1. +21 −0 src/Foundation/Enum.cs
  2. +55 −0 src/Foundation/NSPropertyListSerialization.cs
  3. +23 −1 src/foundation.cs
@@ -79,6 +79,27 @@ public enum NSPropertyListFormat {
Binary = 200
}
+ public enum NSPropertyListMutabilityOptions {
+ Immutable = 0,
+ MutableContainers = 1,
+ MutableContainersAndLeaves = 2
+ }
+
+ // Should mirror NSPropertyListMutabilityOptions
+ public enum NSPropertyListWriteOptions {
+ Immutable = 0,
+ MutableContainers = 1,
+ MutableContainersAndLeaves = 2
+ }
+
+ // Should mirror NSPropertyListMutabilityOptions, but currently
+ // not implemented (always use Immutable/0)
+ public enum NSPropertyListReadOptions {
+ Immutable = 0,
+ MutableContainers = 1,
+ MutableContainersAndLeaves = 2
+ }
+
public enum NSNetServicesStatus {
UnknownError = -72000,
CollisionError = -72001,
@@ -0,0 +1,55 @@
+//
+// NSPropertyListSerialization.cs
+//
+// Authors:
+// Aaron Bockover (abock@xamarin.com)
+//
+// Copyright 2013 Xamarin Inc
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+
+namespace MonoMac.Foundation
+{
+ public partial class NSPropertyListSerialization
+ {
+ public static NSData DataWithPropertyList (NSObject plist, NSPropertyListFormat format, out NSError error)
+ {
+ return DataWithPropertyList (plist, format, NSPropertyListWriteOptions.Immutable, out error);
+ }
+
+ public static int WritePropertyList (NSObject plist, NSOutputStream stream, NSPropertyListFormat format, out NSError error)
+ {
+ return WritePropertyList (plist, stream, format, NSPropertyListWriteOptions.Immutable, out error);
+ }
+
+ public static NSObject PropertyListWithData (NSData data, NSPropertyListFormat format, out NSError error)
+ {
+ return PropertyListWithData (data, NSPropertyListReadOptions.Immutable, format, out error);
+ }
+
+ public static NSObject PropertyListWithStream (NSInputStream stream, NSPropertyListFormat format, out NSError error)
+ {
+ return PropertyListWithStream (stream, NSPropertyListReadOptions.Immutable, format, out error);
+ }
+ }
+}
View
@@ -4,10 +4,11 @@
// Authors:
// Geoff Norton
// Miguel de Icaza
+// Aaron Bockover
//
// Copyright 2009, Novell, Inc.
// Copyright 2010, Novell, Inc.
-// Copyright 2011-2012 Xamarin Inc.
+// Copyright 2011-2013 Xamarin Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@@ -6216,5 +6217,26 @@ interface NSUrlProtocol {
void UnregisterClass (Class protocolClass);
}
+ [BaseType (typeof(NSObject))]
+ public interface NSPropertyListSerialization {
+ [Static, Export ("dataWithPropertyList:format:options:error:")]
+ NSData DataWithPropertyList (NSObject plist, NSPropertyListFormat format,
+ NSPropertyListWriteOptions options, out NSError error);
+
+ [Static, Export ("writePropertyList:toStream:format:options:error:")]
+ int WritePropertyList (NSObject plist, NSOutputStream stream, NSPropertyListFormat format,
+ NSPropertyListWriteOptions options, out NSError error);
+
+ [Static, Export ("propertyListWithData:options:format:error:")]
+ NSObject PropertyListWithData (NSData data, NSPropertyListReadOptions options,
+ NSPropertyListFormat format, out NSError error);
+
+ [Static, Export ("propertyListWithStream:options:format:error:")]
+ NSObject PropertyListWithStream (NSInputStream stream, NSPropertyListReadOptions options,
+ NSPropertyListFormat format, out NSError error);
+
+ [Static, Export ("propertyList:isValidForFormat:")]
+ bool IsValidForFormat (NSObject plist, NSPropertyListFormat format);
+ }
}

0 comments on commit e492715

Please sign in to comment.