Permalink
Browse files

Merge pull request #35 from spicypixel/master

[Fix] Marshal wrapped type arrays as IntPtr in trampolines
  • Loading branch information...
2 parents 88aa41f + 7e2a0d5 commit d6959cc8f539fb629e353983f2a1b7af688e4c94 @marek-safar marek-safar committed Nov 14, 2012
View
4 src/CoreAnimation/CAMediaTimingFunction.cs
@@ -29,9 +29,9 @@
using System;
using System.Drawing;
using System.Runtime.InteropServices;
-using MonoTouch.Foundation;
+using MonoMac.Foundation;
-namespace MonoTouch.CoreAnimation {
+namespace MonoMac.CoreAnimation {
public unsafe partial class CAMediaTimingFunction {
[Obsolete ("This type is not meant to be created by application code")]
View
4 src/CoreImage/CIFilter.cs
@@ -72,7 +72,7 @@ internal void SetValue (string key, NSObject value)
internal static IntPtr CreateFilter (string name)
{
using (var nsname = new NSString (name))
- return MonoTouch.ObjCRuntime.Messaging.IntPtr_objc_msgSend_IntPtr (class_ptr, selFilterWithName_, nsname.Handle);
+ return ObjCRuntime.Messaging.IntPtr_objc_msgSend_IntPtr (class_ptr, selFilterWithName_, nsname.Handle);
}
// helper methods
@@ -137,7 +137,7 @@ internal void SetImage (string key, CIImage value)
// Calls the selName selector for cases where we do not have an instance created
static internal string GetFilterName (IntPtr filterHandle)
{
- return NSString.FromHandle (MonoTouch.ObjCRuntime.Messaging.IntPtr_objc_msgSend (filterHandle, CIFilter.selName));
+ return NSString.FromHandle (ObjCRuntime.Messaging.IntPtr_objc_msgSend (filterHandle, CIFilter.selName));
}
internal static CIFilter FromName (string filterName, IntPtr handle)
View
19 src/CoreImage/CIImage.cs
@@ -28,6 +28,8 @@
#if !MONOMAC
using MonoTouch.UIKit;
using MonoTouch.CoreGraphics;
+#else
+using MonoMac.CoreGraphics;
#endif
namespace MonoMac.CoreImage {
@@ -137,20 +139,35 @@ public static CIImage FromCGImage (CGImage image, CGColorSpace colorSpace)
internal static int CIFormatToInt (CIFormat format)
{
switch (format) {
+#if MONOMAC
+ case CIFormat.ARGB8: return FormatARGB8;
+ case CIFormat.RGBAh: return FormatRGBAh;
+ case CIFormat.RGBA16: return FormatRGBA16;
+ case CIFormat.RGBAf: return FormatRGBAf;
+#else
case CIFormat.ARGB8: return FormatARGB8;
case CIFormat.RGBAh: return FormatRGBAh;
case CIFormat.BGRA8: return FormatBGRA8;
case CIFormat.RGBA8: return FormatRGBA8;
+#endif
default:
throw new ArgumentOutOfRangeException ("format");
}
}
}
-
+#if MONOMAC
+ public enum CIFormat {
+ ARGB8,
+ RGBAh,
+ RGBA16,
+ RGBAf
+ }
+#else
public enum CIFormat {
ARGB8,
RGBAh,
BGRA8,
RGBA8,
}
+#endif
}
View
2 src/Foundation/NSCalendar.cs
@@ -33,7 +33,7 @@
using MonoMac.CoreGraphics;
using MonoMac.CoreMedia;
-namespace MonoTouch.Foundation {
+namespace MonoMac.Foundation {
public enum NSCalendarType {
Gregorian, Buddhist, Chinese, Hebrew, Islamic, IslamicCivil, Japanese, RepublicOfChina, Persian, Indian, ISO8601
}
View
8 src/generator.cs
@@ -1009,8 +1009,12 @@ public string MakeTrampoline (Type t)
var clear = new StringBuilder ();
string returntype;
var returnformat = "return {0};";
-
- if (IsWrappedType (mi.ReturnType)) {
+
+ if (mi.ReturnType.IsArray && IsWrappedType (mi.ReturnType.GetElementType())) {
+ returntype = "IntPtr";
+ returnformat = "return NSArray.FromNSObjects({0}).Handle;";
+ }
+ else if (IsWrappedType (mi.ReturnType)) {
returntype = "IntPtr";
returnformat = "return {0} != null ? {0}.Handle : IntPtr.Zero;";
} else {

0 comments on commit d6959cc

Please sign in to comment.