~ubuntu-branches/ubuntu/trusty/monodevelop/trusty-proposed

« back to all changes in this revision

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

  • Committer: Package Import Robot
  • Author(s): Jo Shields
  • Date: 2013-05-12 09:46:03 UTC
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: package-import@ubuntu.com-20130512094603-mad323bzcxvmcam0
Tags: upstream-4.0.5+dfsg
ImportĀ upstreamĀ versionĀ 4.0.5+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//
 
2
// Permission is hereby granted, free of charge, to any person obtaining
 
3
// a copy of this software and associated documentation files (the
 
4
// "Software"), to deal in the Software without restriction, including
 
5
// without limitation the rights to use, copy, modify, merge, publish,
 
6
// distribute, sublicense, and/or sell copies of the Software, and to
 
7
// permit persons to whom the Software is furnished to do so, subject to
 
8
// the following conditions:
 
9
// 
 
10
// The above copyright notice and this permission notice shall be
 
11
// included in all copies or substantial portions of the Software.
 
12
// 
 
13
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 
14
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 
15
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 
16
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
 
17
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
 
18
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 
19
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
20
//
 
21
// Copyright 2011, 2012 Xamarin Inc
 
22
//
1
23
using System;
2
24
using System.Collections;
3
25
using System.Collections.Generic;
282
304
                                        throw new ArgumentNullException ("key");
283
305
                                if (value == null)
284
306
                                        throw new ArgumentNullException ("value");
285
 
                                if (IsDirectBinding) {
286
 
                                        MonoMac.ObjCRuntime.Messaging.void_objc_msgSend_IntPtr_IntPtr (this.Handle, selSetObjectForKey_, value.Handle, key.Handle);
287
 
                                } else {
288
 
                                        MonoMac.ObjCRuntime.Messaging.void_objc_msgSendSuper_IntPtr_IntPtr (this.SuperHandle, selSetObjectForKey_, value.Handle, key.Handle);
 
307
#if MONOMAC
 
308
                                if (IsDirectBinding) {
 
309
                                        MonoMac.ObjCRuntime.Messaging.void_objc_msgSend_IntPtr_IntPtr (this.Handle, selSetObjectForKey_Handle, value.Handle, key.Handle);
 
310
                                } else {
 
311
                                        MonoMac.ObjCRuntime.Messaging.void_objc_msgSendSuper_IntPtr_IntPtr (this.SuperHandle, selSetObjectForKey_Handle, value.Handle, key.Handle);
 
312
                                }
 
313
#else
 
314
                                if (IsDirectBinding) {
 
315
                                        MonoMac.ObjCRuntime.Messaging.void_objc_msgSend_IntPtr_IntPtr (this.Handle, Selector.GetHandle (selSetObjectForKey_), value.Handle, key.Handle);
 
316
                                } else {
 
317
                                        MonoMac.ObjCRuntime.Messaging.void_objc_msgSendSuper_IntPtr_IntPtr (this.SuperHandle, Selector.GetHandle (selSetObjectForKey_), value.Handle, key.Handle);
 
318
                                }
 
319
#endif
 
320
                        }
 
321
                }
 
322
 
 
323
                public override NSObject this [NSString key] {
 
324
                        get {
 
325
                                if (key == null)
 
326
                                        throw new ArgumentNullException ("key");
 
327
                                return ObjectForKey (key);
 
328
                        }
 
329
                        set {
 
330
                                if (key == null)
 
331
                                        throw new ArgumentNullException ("key");
 
332
                                if (value == null)
 
333
                                        throw new ArgumentNullException ("value");
 
334
#if MONOMAC
 
335
                                if (IsDirectBinding) {
 
336
                                        MonoMac.ObjCRuntime.Messaging.void_objc_msgSend_IntPtr_IntPtr (this.Handle, selSetObjectForKey_Handle, value.Handle, key.Handle);
 
337
                                } else {
 
338
                                        MonoMac.ObjCRuntime.Messaging.void_objc_msgSendSuper_IntPtr_IntPtr (this.SuperHandle, selSetObjectForKey_Handle, value.Handle, key.Handle);
 
339
                                }
 
340
#else
 
341
                                if (IsDirectBinding) {
 
342
                                        MonoMac.ObjCRuntime.Messaging.void_objc_msgSend_IntPtr_IntPtr (this.Handle, Selector.GetHandle (selSetObjectForKey_), value.Handle, key.Handle);
 
343
                                } else {
 
344
                                        MonoMac.ObjCRuntime.Messaging.void_objc_msgSendSuper_IntPtr_IntPtr (this.SuperHandle, Selector.GetHandle (selSetObjectForKey_), value.Handle, key.Handle);
 
345
                                }
 
346
#endif
 
347
                        }
 
348
                }
 
349
 
 
350
                public override NSObject this [string key] {
 
351
                        get {
 
352
                                if (key == null)
 
353
                                        throw new ArgumentNullException ("key");
 
354
                                using (var nss = new NSString (key)){
 
355
                                        return ObjectForKey (nss);
 
356
                                }
 
357
                        }
 
358
                        set {
 
359
                                if (key == null)
 
360
                                        throw new ArgumentNullException ("key");
 
361
                                if (value == null)
 
362
                                        throw new ArgumentNullException ("value");
 
363
                                using (var nss = new NSString (key)){
 
364
#if MONOMAC
 
365
                                        if (IsDirectBinding) {
 
366
                                                MonoMac.ObjCRuntime.Messaging.void_objc_msgSend_IntPtr_IntPtr (this.Handle, selSetObjectForKey_Handle, value.Handle, nss.Handle);
 
367
                                        } else {
 
368
                                                MonoMac.ObjCRuntime.Messaging.void_objc_msgSendSuper_IntPtr_IntPtr (this.SuperHandle, selSetObjectForKey_Handle, value.Handle, nss.Handle);
 
369
                                        }
 
370
#else
 
371
                                        if (IsDirectBinding) {
 
372
                                                MonoMac.ObjCRuntime.Messaging.void_objc_msgSend_IntPtr_IntPtr (this.Handle, Selector.GetHandle (selSetObjectForKey_), value.Handle, nss.Handle);
 
373
                                        } else {
 
374
                                                MonoMac.ObjCRuntime.Messaging.void_objc_msgSendSuper_IntPtr_IntPtr (this.SuperHandle, Selector.GetHandle (selSetObjectForKey_), value.Handle, nss.Handle);
 
375
                                        }
 
376
#endif
289
377
                                }
290
378
                        }
291
379
                }
314
402
 
315
403
                public static NSMutableDictionary LowlevelFromObjectAndKey (IntPtr obj, IntPtr key)
316
404
                {
317
 
                        return (NSMutableDictionary) Runtime.GetNSObject (MonoMac.ObjCRuntime.Messaging.IntPtr_objc_msgSend_IntPtr_IntPtr (class_ptr, selDictionaryWithObjectForKey_, obj, key));
 
405
#if MONOMAC
 
406
                        return (NSMutableDictionary) Runtime.GetNSObject (MonoMac.ObjCRuntime.Messaging.IntPtr_objc_msgSend_IntPtr_IntPtr (class_ptr, selDictionaryWithObjectForKey_Handle, obj, key));
 
407
#else
 
408
                        return (NSMutableDictionary) Runtime.GetNSObject (MonoMac.ObjCRuntime.Messaging.IntPtr_objc_msgSend_IntPtr_IntPtr (class_ptr, Selector.GetHandle (selDictionaryWithObjectForKey_), obj, key));
 
409
#endif
318
410
                }
319
411
 
320
412
                public void LowlevelSetObject (IntPtr obj, IntPtr key)
321
413
                {
322
 
                        MonoMac.ObjCRuntime.Messaging.void_objc_msgSend_IntPtr_IntPtr (this.Handle, selSetObjectForKey_, obj, key);
 
414
#if MONOMAC
 
415
                        MonoMac.ObjCRuntime.Messaging.void_objc_msgSend_IntPtr_IntPtr (this.Handle, selSetObjectForKey_Handle, obj, key);
 
416
#else
 
417
                        MonoMac.ObjCRuntime.Messaging.void_objc_msgSend_IntPtr_IntPtr (this.Handle, Selector.GetHandle (selSetObjectForKey_), obj, key);
 
418
#endif
323
419
                }
324
420
 
325
421
                public void LowlevelSetObject (NSObject obj, IntPtr key)
326
422
                {
327
423
                        if (obj == null)
328
424
                                throw new ArgumentNullException ("obj");
329
 
                        
330
 
                        MonoMac.ObjCRuntime.Messaging.void_objc_msgSend_IntPtr_IntPtr (this.Handle, selSetObjectForKey_, obj.Handle, key);
 
425
#if MONOMAC
 
426
                        MonoMac.ObjCRuntime.Messaging.void_objc_msgSend_IntPtr_IntPtr (this.Handle, selSetObjectForKey_Handle, obj.Handle, key);
 
427
#else
 
428
                        MonoMac.ObjCRuntime.Messaging.void_objc_msgSend_IntPtr_IntPtr (this.Handle, Selector.GetHandle (selSetObjectForKey_), obj.Handle, key);
 
429
#endif
331
430
                }
332
431
        }
333
432
}