Nu Class Reference
NuBridgedFunction
The Nu wrapper for imported C functions.
Superclass: NuOperator
Declared in: objc/Nu.h
Because NuBridgedFunction is a subclass of NuOperator, Nu expressions that begin with NuBridgedFunction instances are treated as operator calls.
In general, operators may or may not evaluate their arguments, but for NuBridgedFunctions, all arguments are evaluated. The resulting values are then passed to the bridged C function using the foreign function interface (libFFI).
The C function's return value is converted into a Nu object and returned.
Here is an example showing the use of this class from Nu. The example imports and calls the C function NSApplicationMain.
(set NSApplicationMain
(NuBridgedFunction
functionWithName:"NSApplicationMain"
signature:"ii^*"))
(NSApplicationMain 0 nil)
The signature string used to create a NuBridgedFunction must be a valid Objective-C type signature. In the future, convenience methods may be added to make those signatures easier to generate. But in practice, this has not been much of a problem.
Methods
| + | (NuBridgedFunction *) | functionWithName: | (NSString *) name |
| signature: | (NSString *) signature | ||
in objc/Nu.h
| - | (id) | evalWithArguments: | (id) arguments |
| context: | (NSMutableDictionary *) context | ||
in objc/Nu.h
| - | (NuBridgedFunction *) | initWithName: | (NSString *) name |
| signature: | (NSString *) signature | ||
in objc/Nu.h