~ubuntu-branches/ubuntu/utopic/monodevelop/utopic

« back to all changes in this revision

Viewing changes to external/maccore/src/Foundation/NSInputStream.cs

  • Committer: Package Import Robot
  • Author(s): Jo Shields
  • Date: 2012-06-22 20:35:35 UTC
  • mfrom: (10.3.2)
  • Revision ID: package-import@ubuntu.com-20120622203535-zrozwvcf6kfk6l6i
Tags: 3.0.3.2+dfsg-1
* [3fd89ae] Imported Upstream version 3.0.3.2+dfsg
* [379a680] Remove old patches we haven't used for ages from git.
* [d71161d] Remove correct_paths_in_monodevelop-core-addins.pc.patch.
  Upstream claim to have fixed this by moving assembly install locations.
* [15dbfb9] Fix install location for MonoDevelop.Gettext.dll.config.
* [26eb434] Fix install location for MonoDevelop.SourceEditor2.dll.config.
* [4169974] Upstream commit 53282c9 which finally reconciles the 
  MonoDevelop.Gettext.dll install location with the 
  monodevelop-core-addins.pc location.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
using System;
2
2
using System.Runtime.InteropServices;
 
3
using MonoMac.CoreFoundation;
3
4
using MonoMac.Foundation;
4
5
using MonoMac.ObjCRuntime;
5
6
 
7
8
        public partial class NSInputStream : NSStream {
8
9
                static IntPtr selReadMaxLength = Selector.sel_registerName ("read:maxLength:");
9
10
 
 
11
                CFStreamEventType flags;
 
12
                IntPtr callback;
 
13
                CFStreamClientContext context;
 
14
 
10
15
                public int Read (byte [] buffer, uint len) {
11
16
                        return objc_msgSend (Handle, selReadMaxLength, buffer, len);
12
17
                }
13
18
 
14
19
                [DllImport ("/usr/lib/libobjc.dylib")]
15
20
                static extern int objc_msgSend (IntPtr handle, IntPtr sel, [In, Out] byte [] buffer, uint len);
 
21
 
 
22
                [Export ("read:maxLength:")]
 
23
                public virtual int Read (IntPtr buffer, uint len)
 
24
                {
 
25
                        if (buffer == IntPtr.Zero)
 
26
                                throw new ArgumentNullException ("buffer");
 
27
                        
 
28
                        int ret;
 
29
                        if (IsDirectBinding) {
 
30
                                ret = Messaging.int_objc_msgSend_IntPtr_UInt32 (this.Handle, selReadMaxLength, buffer, len);
 
31
                        } else {
 
32
                                ret = Messaging.int_objc_msgSendSuper_IntPtr_UInt32 (this.SuperHandle, selReadMaxLength, buffer, len);
 
33
                        }
 
34
                        
 
35
                        return ret;
 
36
                }
 
37
 
 
38
                protected override void Dispose (bool disposing)
 
39
                {
 
40
                        context.Release ();
 
41
                        context.Info = IntPtr.Zero;
 
42
                        
 
43
                        base.Dispose (disposing);
 
44
                }
 
45
                
 
46
                [Export ("_setCFClientFlags:callback:context:")]
 
47
                protected virtual bool SetCFClientFlags (CFStreamEventType inFlags, IntPtr inCallback, IntPtr inContextPtr)
 
48
                {
 
49
                        CFStreamClientContext inContext;
 
50
                        
 
51
                        if (inContextPtr == IntPtr.Zero)
 
52
                                return false;
 
53
                        
 
54
                        inContext = (CFStreamClientContext) Marshal.PtrToStructure (inContextPtr, typeof (CFStreamClientContext));
 
55
                        if (inContext.Version != 0)
 
56
                                return false;
 
57
                        
 
58
                        context.Release ();
 
59
                        context = inContext;
 
60
                        context.Retain ();
 
61
                        
 
62
                        flags = inFlags;
 
63
                        callback = inCallback;
 
64
 
 
65
                        return true;
 
66
                }
 
67
 
 
68
                [Export ("getBuffer:length:")]
 
69
                protected unsafe virtual bool GetBuffer (out IntPtr buffer, out System.UInt32 len)
 
70
                {
 
71
                        buffer = IntPtr.Zero;
 
72
                        len = 0;
 
73
                        return false;
 
74
                }
 
75
 
 
76
                public void Notify (CFStreamEventType eventType)
 
77
                {
 
78
                        if ((flags & eventType) == 0)
 
79
                                return;
 
80
 
 
81
                        context.Invoke (callback, Handle, eventType);
 
82
                }
16
83
        }
17
84
}