Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: timburks/nu
base: master
...
head fork: mralexgray/nu
compare: master
Checking mergeability… Don't worry, you can still create the pull request.
  • 2 commits
  • 3 files changed
  • 0 commit comments
  • 1 contributor
Showing with 142 additions and 141 deletions.
  1. +11 −3 Xcode/Nu.xcodeproj/project.pbxproj
  2. +131 −29 objc/Nu.h
  3. +0 −109 objc/Nu.m
View
14 Xcode/Nu.xcodeproj/project.pbxproj
@@ -100,6 +100,7 @@
22EE2C0A13A4731600895861 /* NuAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 22EE2C0913A4731600895861 /* NuAppDelegate.m */; };
4F43427C1420476C00AC1BFD /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 4F43427B1420476C00AC1BFD /* main.m */; };
56E07744170B028400FF0A4B /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 56E07743170B028400FF0A4B /* Default-568h@2x.png */; };
+ 7B28C15D1713A8880068774A /* Nu.m in Sources */ = {isa = PBXBuildFile; fileRef = 22B3B41D13B0359300B3AB31 /* Nu.m */; };
8DC2EF530486A6940098B216 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C1666FE841158C02AAC07 /* InfoPlist.strings */; };
/* End PBXBuildFile section */
@@ -438,6 +439,7 @@
isa = PBXHeadersBuildPhase;
buildActionMask = 2147483647;
files = (
+ 7B28C15C1713A1FB0068774A /* Nu.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -653,7 +655,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
- 22B3B47313B0359300B3AB31 /* Nu.m in Sources */,
+ 7B28C15D1713A8880068774A /* Nu.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -691,6 +693,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
+ ARCHS = "$(ARCHS_STANDARD_64_BIT)";
COMBINE_HIDPI_IMAGES = YES;
COPY_PHASE_STRIP = NO;
DYLIB_COMPATIBILITY_VERSION = 1;
@@ -708,9 +711,11 @@
GCC_PREFIX_HEADER = Nu_Prefix.pch;
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
INFOPLIST_FILE = Info.plist;
- INSTALL_PATH = "$(HOME)/Library/Frameworks";
+ INSTALL_PATH = "@loader_path/Frameworks";
LIBRARY_SEARCH_PATHS = "";
PRODUCT_NAME = Nu;
+ SDKROOT = macosx;
+ SKIP_INSTALL = YES;
WRAPPER_EXTENSION = framework;
};
name = Debug;
@@ -719,6 +724,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
+ ARCHS = "$(ARCHS_STANDARD_64_BIT)";
COMBINE_HIDPI_IMAGES = YES;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DYLIB_COMPATIBILITY_VERSION = 1;
@@ -734,9 +740,11 @@
GCC_PREFIX_HEADER = Nu_Prefix.pch;
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
INFOPLIST_FILE = Info.plist;
- INSTALL_PATH = "$(HOME)/Library/Frameworks";
+ INSTALL_PATH = "@loader_path/Frameworks";
LIBRARY_SEARCH_PATHS = "";
PRODUCT_NAME = Nu;
+ SDKROOT = macosx;
+ SKIP_INSTALL = YES;
WRAPPER_EXTENSION = framework;
};
name = Release;
View
160 objc/Nu.h
@@ -20,8 +20,9 @@
#import <objc/objc.h>
#import <objc/runtime.h>
-#pragma mark -
-#pragma mark Symbol Table
+#define NU_MAX_PARSER_MACRO_DEPTH 1000
+
+#pragma mark - Symbol Table
/*!
@class NuSymbol
@@ -34,7 +35,16 @@
the list is considered to be a special type of list called a property list (no relation to ObjC plists).
Each member of a property list is evaluated and the resulting list is returned with no further evaluation.
*/
+ @class NuSymbolTable;
@interface NuSymbol : NSObject <NSCoding, NSCopying>
+{
+ NuSymbolTable *table;
+ id value;
+@public // only for use by the symbol table
+ bool isLabel;
+ bool isGensym; // in macro evaluation, symbol is replaced with an automatically-generated unique symbol.
+ NSString *stringValue; // let's keep this for efficiency
+}
/*! Get the global value of a symbol. */
- (id) value;
@@ -64,6 +74,9 @@
By default, one NuSymbolTable object is shared by all NuParser objects and execution contexts in a process.
*/
@interface NuSymbolTable : NSObject
+{
+ NSMutableDictionary *symbol_table;
+}
/*! Get the shared NuSymbolTable object. */
+ (NuSymbolTable *) sharedSymbolTable;
@@ -77,8 +90,7 @@
- (void) removeSymbol:(NuSymbol *) symbol;
@end
-#pragma mark -
-#pragma mark List Representation
+#pragma mark - List Representation
/*!
@class NuCell
@@ -94,6 +106,12 @@
In Nu, nil is represented with the <code>[NSNull null]</code> object.
*/
@interface NuCell : NSObject <NSCoding>
+{
+ id car;
+ id cdr;
+ int file;
+ int line;
+}
/*! Create a new cell with a specifed car and cdr. */
+ (id) cellWithCar:(id)car cdr:(id)cdr;
@@ -153,6 +171,9 @@
Comments can then be parsed with Nu code, typically to produce documentation.
*/
@interface NuCellWithComments : NuCell
+{
+ id comments;
+}
/*! Get a string containing the comments that preceded a list element. */
- (id) comments;
@@ -161,8 +182,7 @@
@end
-#pragma mark -
-#pragma mark Parsing
+#pragma mark - Parsing
/*!
@class NuStack
@@ -170,6 +190,9 @@
@discussion A simple stack class used by the Nu parser.
*/
@interface NuStack : NSObject
+{
+ NSMutableArray *storage;
+}
/*! Push an object onto the stack. */
- (void) push:(id) object;
@@ -186,6 +209,33 @@
@discussion Instances of this class are used to parse and evaluate Nu source text.
*/
@interface NuParser : NSObject
+{
+ int state;
+ int start;
+ int depth;
+ int parens;
+ int column;
+
+ NSMutableArray* readerMacroStack;
+ int readerMacroDepth[NU_MAX_PARSER_MACRO_DEPTH];
+
+ int filenum;
+ int linenum;
+ int parseEscapes;
+
+ NuCell *root;
+ NuCell *current;
+ bool addToCar;
+ NSMutableString *hereString;
+ bool hereStringOpened;
+ NuStack *stack;
+ NuStack *opens;
+ NuSymbolTable *symbolTable;
+ NSMutableDictionary *context;
+ NSMutableString *partial;
+ NSMutableString *comments;
+ NSString *pattern; // used for herestrings
+}
/*! Get the symbol table used by a parser. */
- (NuSymbolTable *) symbolTable;
@@ -222,8 +272,7 @@
@end
-#pragma mark -
-#pragma mark Callables: Functions, Macros, Operators
+#pragma mark - Callables: Functions, Macros, Operators
/*!
@class NuBlock
@@ -251,6 +300,11 @@
the owning object and its superclass.
*/
@interface NuBlock : NSObject
+{
+ NuCell *parameters;
+ NuCell *body;
+ NSMutableDictionary *context;
+}
/*! Create a block. Requires a list of parameters, the code to be executed, and an execution context. */
- (id) initWithParameters:(NuCell *)a body:(NuCell *)b context:(NSMutableDictionary *)c;
@@ -297,6 +351,12 @@
symbols are called "gensyms".
*/
@interface NuMacro_0 : NSObject
+{
+@protected
+ NSString *name;
+ NuCell *body;
+ NSMutableSet *gensyms;
+}
/*! Construct a macro. */
+ (id) macroWithName:(NSString *)name body:(NuCell *)body;
@@ -348,6 +408,10 @@
*/
@interface NuMacro_1 : NuMacro_0
+{
+ NuCell *parameters;
+}
+
/*! Construct a macro. */
+ (id) macroWithName:(NSString *)name parameters:(NuCell*)args body:(NuCell *)body;
/*! Initialize a macro. */
@@ -385,8 +449,7 @@
@end
-#pragma mark -
-#pragma mark Bridging C
+#pragma mark - Bridging C
/*!
@class NuBridgedFunction
@@ -421,6 +484,11 @@
But in practice, this has not been much of a problem.
*/
@interface NuBridgedFunction : NuOperator
+{
+ char *name;
+ char *signature;
+ void *function;
+}
/*! Create a wrapper for a C function with the specified name and signature.
The function is looked up using the <b>dlsym()</b> function and the wrapper is
@@ -464,6 +532,10 @@
then writing over its function pointer with a libFFI-generated closure function.
*/
@interface NuBridgedBlock : NSObject
+{
+ NuBlock *nuBlock;
+ id cBlock;
+}
/*! Returns a C block that wraps the supplied nu block using the supplied
Objective-C-style function signature.
@@ -486,8 +558,7 @@
@end
#endif //__BLOCKS__
-#pragma mark -
-#pragma mark Wrapping access to items and objects in memory
+#pragma mark - Wrapping access to items and objects in memory
/*!
@class NuPointer
@@ -495,6 +566,12 @@
@discussion The NuPointer class provides a wrapper for pointers to arbitrary locations in memory.
*/
@interface NuPointer : NSObject
+{
+ void *pointer;
+ NSString *typeString;
+ bool thePointerIsMine;
+}
+
/*! Get the value of the pointer. Don't call this from Nu. */
- (void *) pointer;
@@ -531,6 +608,10 @@
</div>
*/
@interface NuReference : NSObject
+{
+ id *pointer;
+ bool thePointerIsMine;
+}
/*! Get the value of the referenced object. */
- (id) value;
@@ -546,8 +627,7 @@
- (void) retainReferencedObject;
@end
-#pragma mark -
-#pragma mark Interacting with the Objective-C Runtime
+#pragma mark - Interacting with the Objective-C Runtime
/*!
@class NuMethod
@@ -556,6 +636,9 @@
NuMethod objects are used in the Nu language to manipulate Objective-C methods.
*/
@interface NuMethod : NSObject
+{
+ Method m;
+}
/*! Initialize a NuMethod for a given Objective-C method (used from Objective-C) */
- (id) initWithMethod:(Method) method;
@@ -584,6 +667,10 @@
NuClass objects are used in the Nu language to manipulate and extend Objective-C classes.
*/
@interface NuClass : NSObject
+{
+ Class c;
+ BOOL isRegistered;
+}
/*! Create a class wrapper for the specified class (used from Objective-C). */
+ (NuClass *) classWithClass:(Class) class;
@@ -642,6 +729,10 @@
Typically, there is no need to directly interact with this class from Nu.
*/
@interface NuSuper : NSObject
+{
+ id object;
+ Class class;
+}
/*! Create a NuSuper proxy for an object with a specified class.
Note that the object class must be explicitly specified.
@@ -665,6 +756,10 @@
@discussion Preliminary and incomplete.
*/
@interface NuProperty : NSObject
+{
+ objc_property_t p;
+}
+
/*! Create a property wrapper for the specified property (used from Objective-C). */
+ (NuProperty *) propertyWithProperty:(objc_property_t) property;
@@ -688,8 +783,7 @@
@end
#endif
-#pragma mark -
-#pragma mark Error Handling
+#pragma mark - Error Handling
/*!
@class NuException
@@ -699,6 +793,9 @@
This information gets added during unwinding the stack by the NuCells.
*/
@interface NuException : NSException
+{
+ NSMutableArray* stackTrace;
+}
+ (void)setDefaultExceptionHandler;
+ (void)setVerbose:(BOOL)flag;
@@ -726,6 +823,13 @@
@interface NuTraceInfo : NSObject
+{
+ NSString* filename;
+ int lineNumber;
+ NSString* function;
+}
+
+
- (id)initWithFunction:(NSString *)function lineNumber:(int)lineNumber filename:(NSString *)filename;
- (NSString *)filename;
- (int)lineNumber;
@@ -733,8 +837,7 @@
@end
-#pragma mark -
-#pragma mark Mixins
+#pragma mark - Mixins
/*!
@class NuEnumerable
@@ -766,8 +869,7 @@
@end
-#pragma mark -
-#pragma mark Class Extensions
+#pragma mark - Class Extensions
/*!
@category NSObject(Nu)
@@ -1102,8 +1204,7 @@
+ (int) fileExistsNamed:(NSString *) filename;
@end
-#pragma mark -
-#pragma mark Regular Expressions
+#pragma mark - Regular Expressions
// Let's make NSRegularExpression and NSTextCheckingResult look like our previous classes, NuRegex and NuRegexMatch
@@ -1184,17 +1285,19 @@
@end
-#pragma mark -
-#pragma mark Profiler (Experimental)
-
+#pragma mark - Profiler (Experimental)
+@class NuProfileStackElement;
@interface NuProfiler : NSObject
+{
+ NSMutableDictionary *sections;
+ NuProfileStackElement *stack;
+}
+ (NuProfiler *) defaultProfiler;
@end
-#pragma mark -
-#pragma mark Utilities (Optional, may disappear)
+#pragma mark - Utilities (Optional, may disappear)
/*!
@class NuMath
@@ -1230,8 +1333,7 @@
+ (void) srandom:(unsigned long) seed;
@end
-#pragma mark -
-#pragma mark Top Level Interface
+#pragma mark - Top Level Interface
// call this from main() to run the Nu shell.
int NuMain(int argc, const char *argv[]);
View
109 objc/Nu.m
@@ -564,11 +564,6 @@ + (BOOL) loadNuFile:(NSString *) fileName fromBundleWithIdentifier:(NSString *)
#pragma mark - NuBlock.m
@interface NuBlock ()
-{
- NuCell *parameters;
- NuCell *body;
- NSMutableDictionary *context;
-}
@end
@implementation NuBlock
@@ -2013,11 +2008,6 @@ static id add_method_to_class(Class c, NSString *methodName, NSString *signature
}
@interface NuBridgedFunction ()
-{
- char *name;
- char *signature;
- void *function;
-}
@end
@implementation NuBridgedFunction
@@ -2489,10 +2479,6 @@ static id help_add_method_to_class(Class classToExtend, id cdr, NSMutableDiction
static void *construct_block_handler(NuBlock *block, const char *signature);
@interface NuBridgedBlock ()
-{
- NuBlock *nuBlock;
- id cBlock;
-}
@end
@implementation NuBridgedBlock
@@ -2853,12 +2839,6 @@ + (NSString *) stringValue
#pragma mark - NuCell.m
@interface NuCell ()
-{
- id car;
- id cdr;
- int file;
- int line;
-}
@end
@implementation NuCell
@@ -3348,9 +3328,6 @@ - (int) line {return line;}
@end
@interface NuCellWithComments ()
-{
- id comments;
-}
@end
@implementation NuCellWithComments
@@ -3378,10 +3355,6 @@ - (void) setComments:(id) c
// (set x (((Convert classMethods) select: (do (m) (eq (m name) "passRect:"))) objectAtIndex:0))
@interface NuClass ()
-{
- Class c;
- BOOL isRegistered;
-}
@end
@implementation NuClass
@@ -3903,9 +3876,6 @@ static void Nu_defaultExceptionHandler(NSException* e)
static BOOL NuException_verboseExceptionReporting = NO;
@interface NuException ()
-{
- NSMutableArray* stackTrace;
-}
@end
@implementation NuException
@@ -4009,11 +3979,6 @@ - (NSString*)dump
@end
@interface NuTraceInfo ()
-{
- NSString* filename;
- int lineNumber;
- NSString* function;
-}
@end
@implementation NuTraceInfo
@@ -5292,12 +5257,6 @@ + (IMP) handlerWithSelector:(SEL)sel block:(NuBlock *)block signature:(const cha
#pragma mark - NuMacro_0.m
@interface NuMacro_0 ()
-{
-@protected
- NSString *name;
- NuCell *body;
- NSMutableSet *gensyms;
-}
@end
@implementation NuMacro_0
@@ -5530,9 +5489,6 @@ - (id) evalWithArguments:(id)cdr context:(NSMutableDictionary *)calling_context
#endif
@interface NuMacro_1 ()
-{
- NuCell *parameters;
-}
@end
@implementation NuMacro_1
@@ -5914,9 +5870,6 @@ - (id) evalWithArguments:(id)cdr context:(NSMutableDictionary *)calling_context
#pragma mark - NuMethod.m
@interface NuMethod ()
-{
- Method m;
-}
@end
@implementation NuMethod
@@ -9235,36 +9188,8 @@ static id regexWithString(NSString *string)
}
}
-#define NU_MAX_PARSER_MACRO_DEPTH 1000
@interface NuParser ()
-{
- int state;
- int start;
- int depth;
- int parens;
- int column;
-
- NSMutableArray* readerMacroStack;
- int readerMacroDepth[NU_MAX_PARSER_MACRO_DEPTH];
-
- int filenum;
- int linenum;
- int parseEscapes;
-
- NuCell *root;
- NuCell *current;
- bool addToCar;
- NSMutableString *hereString;
- bool hereStringOpened;
- NuStack *stack;
- NuStack *opens;
- NuSymbolTable *symbolTable;
- NSMutableDictionary *context;
- NSMutableString *partial;
- NSMutableString *comments;
- NSString *pattern; // used for herestrings
-}
@end
@implementation NuParser
@@ -10204,11 +10129,6 @@ + (int) main
#pragma mark - NuPointer.m
@interface NuPointer ()
-{
- void *pointer;
- NSString *typeString;
- bool thePointerIsMine;
-}
@end
@implementation NuPointer
@@ -10327,10 +10247,6 @@ - (NSString *) description
@end
@interface NuProfiler ()
-{
- NSMutableDictionary *sections;
- NuProfileStackElement *stack;
-}
@end
@implementation NuProfiler
@@ -10408,9 +10324,6 @@ - (void) reset
#pragma mark - NuProperty.m
@interface NuProperty ()
-{
- objc_property_t p;
-}
@end
@implementation NuProperty
@@ -10437,10 +10350,6 @@ - (NSString *) name
#pragma mark - NuReference.m
@interface NuReference ()
-{
- id *pointer;
- bool thePointerIsMine;
-}
@end
@implementation NuReference
@@ -10655,9 +10564,6 @@ - (NSString *)replaceWithString:(NSString *)replacement inString:(NSString *)str
#pragma mark - NuStack.m
@interface NuStack ()
-{
- NSMutableArray *storage;
-}
@end
@implementation NuStack
@@ -10719,10 +10625,6 @@ - (void) dump
#pragma mark - NuSuper.m
@interface NuSuper ()
-{
- id object;
- Class class;
-}
@end
@implementation NuSuper
@@ -10852,20 +10754,9 @@ static void nu_swizzleContainerClasses()
#pragma mark - NuSymbol.m
@interface NuSymbol ()
-{
- NuSymbolTable *table;
- id value;
-@public // only for use by the symbol table
- bool isLabel;
- bool isGensym; // in macro evaluation, symbol is replaced with an automatically-generated unique symbol.
- NSString *stringValue; // let's keep this for efficiency
-}
@end
@interface NuSymbolTable ()
-{
- NSMutableDictionary *symbol_table;
-}
@end
void load_builtins(NuSymbolTable *);

No commit comments for this range

Something went wrong with that request. Please try again.