-
Notifications
You must be signed in to change notification settings - Fork 236
/
Copy pathNuReference.h
43 lines (39 loc) · 1.48 KB
/
NuReference.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
//
// NuReference.h
// Nu
//
// Created by Tim Burks on 4/24/16.
//
//
#import <Foundation/Foundation.h>
/*!
@class NuReference
@abstract The Nu object wrapper.
@discussion The NuReference class provides a wrapper for pointers to Objective-C objects.
NuReference objects are used in the Nu language to capture arguments that are returned by value from Objective-C methods.
For example, the following Nu method uses a NuReference to capture a returned-by-reference NSError:
<div style="margin-left:2em">
<code>
(- (id) save is<br/>
(set perror ((NuReference alloc) init))<br/>
(set result ((self managedObjectContext) save:perror))<br/>
(unless result<br/>
(NSLog "error: #{((perror value) localizedDescription)}"))<br/>
result)
</code>
</div>
*/
@interface NuReference : NSObject
/*! Get the value of the referenced object. */
- (id) value;
/*! Set the value of the referenced object. */
- (void) setValue:(id) value;
/*! Set the pointer for a reference. Used by the bridge to create NuReference objects from pointers. Don't call this from Nu. */
- (void) setPointer:(id *) pointer;
/*! Get a pointer to the referenced object. Used by the bridge to Objective-C to convert NuReference objects to pointers.
Don't call this from Nu.
*/
- (id *) pointerToReferencedObject;
/*! Retain the referenced object. Used by the bridge to Objective-C to retain values returned by reference. */
- (void) retainReferencedObject;
@end