Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

purge trailing whitespace

  • Loading branch information...
commit 87cb06022a1e889d28e923326b494b8d830de5bb 1 parent d6263e3
@andrewschleifer andrewschleifer authored
View
30 objc/block.h
@@ -1,6 +1,6 @@
/*!
@header block.h
-@discussion Declarations for the NuBlock class.
+@discussion Declarations for the NuBlock class.
@copyright Copyright (c) 2007 Neon Design Technology, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
@@ -13,7 +13,7 @@ Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
-limitations under the License.
+limitations under the License.
*/
#import <Foundation/Foundation.h>
@@ -24,24 +24,24 @@ limitations under the License.
@abstract The Nu representation of functions.
@discussion A Nu Block is an anonymous function with a saved execution context.
This is commonly referred to as a closure.
-
- In Nu programs, blocks may be directly created using the <b>do</b> operator.
- Since blocks are objects, they may be passed as method and function arguments and may be assigned to names.
+
+ In Nu programs, blocks may be directly created using the <b>do</b> operator.
+ Since blocks are objects, they may be passed as method and function arguments and may be assigned to names.
When a block is assigned to a name, the block will be called when a list is evaluated that
- contains that name at its head;
- the remainder of the list will be evaluated and passed to the block as the block's arguments.
-
+ contains that name at its head;
+ the remainder of the list will be evaluated and passed to the block as the block's arguments.
+
Blocks are implicitly created by several other operators.
-
+
The Nu <b>function</b> operator uses blocks to create new named functions.
-
- The Nu <b>macro</b> operator uses blocks to create macros.
+
+ The Nu <b>macro</b> operator uses blocks to create macros.
Since macros evaluate in their callers' contexts, no context information is kept for blocks used to create macros.
-
+
The <b>imethod</b> and <b>cmethod</b> operators use blocks to create new method implementations.
When a block is called as a method implementation, its context includes the symbols
<b>self</b> and <b>super</b>. This allows method implementations to send messages to
- the owning object and its superclass.
+ the owning object and its superclass.
*/
@interface NuBlock : NSObject
{
@@ -56,8 +56,8 @@ limitations under the License.
- (NuCell *) parameters;
/*! Get the body of code that is evaluated during block evaluation. */
- (NuCell *) body;
-/*! Get the lexical context of the block.
- This is a dictionary containing the symbols and associated values at the point
+/*! Get the lexical context of the block.
+ This is a dictionary containing the symbols and associated values at the point
where the block was created. */
- (NSMutableDictionary *) context;
/*! Evaluate a block using the specified arguments and calling context. */
View
8 objc/block.m
@@ -52,20 +52,20 @@ - (id) initWithParameters:(NuCell *)p body:(NuCell *)b context:(NSMutableDiction
// Check for the presence of "*args" in parameter list
id plist = parameters;
-
+
if (!( ([parameters length] == 1)
&& ([[[parameters car] stringValue] isEqualToString:@"*args"])))
{
- while (plist && (plist != Nu__null))
+ while (plist && (plist != Nu__null))
{
id parameter = [plist car];
-
+
if ([[parameter stringValue] isEqualToString:@"*args"])
{
printf("Warning: Overriding implicit variable '*args'.\n");
return self;
}
-
+
plist = [plist cdr];
}
}
View
2  objc/bridge.m
@@ -38,7 +38,7 @@
#import "handler.h"
#import <sys/mman.h>
-/*
+/*
* types:
* c char
* i int
View
4 objc/bridgesupport.h
@@ -16,7 +16,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
-/*!
+/*!
@class NuBridgeSupport
@abstract A reader for Apple's BridgeSupport files.
@discussion Methods of this class are used to read Apple's BridgeSupport files.
@@ -27,4 +27,4 @@ limitations under the License.
/*! Import a BridgeSupport description of a framework from a specified path. Store the results in the specified dictionary. */
+ (void)importFramework:(NSString *) framework fromPath:(NSString *) path intoDictionary:(NSMutableDictionary *) BridgeSupport;
-@end
+@end
View
4 objc/dtrace.h
@@ -20,7 +20,7 @@ extern "C" {
__asm__ volatile(".reference " NU_TYPEDEFS); \
__dtrace_probe$nu$list_eval_begin$v1$63686172202a$696e74((char *)arg0, arg1); \
__asm__ volatile(".reference " NU_STABILITY); \
-}
+}
#define NU_LIST_EVAL_BEGIN_ENABLED() \
__dtrace_isenabled$nu$list_eval_begin$v1()
#define NU_LIST_EVAL_END(arg0, arg1) \
@@ -28,7 +28,7 @@ extern "C" {
__asm__ volatile(".reference " NU_TYPEDEFS); \
__dtrace_probe$nu$list_eval_end$v1$63686172202a$696e74((char *)arg0, arg1); \
__asm__ volatile(".reference " NU_STABILITY); \
-}
+}
#define NU_LIST_EVAL_END_ENABLED() \
__dtrace_isenabled$nu$list_eval_end$v1()
View
2  objc/enumerable.h
@@ -26,7 +26,7 @@ limitations under the License.
@discussion This class implements methods that act on enumerated collections of objects.
It is designed to be mixed into a class using the include method that Nu adds to NSObject.
The receiving class must have an objectEnumerator method that returns an NSEnumerator.
- Some methods in this class take a callable object as an argument; callable objects are those
+ Some methods in this class take a callable object as an argument; callable objects are those
that have evalWithArguments:context: defined.
*/
@interface NuEnumerable : NSObject
View
4 objc/exception.h
@@ -1,6 +1,6 @@
/*!
@header exception.h
-@discussion Declarations for the NuException class.
+@discussion Declarations for the NuException class.
@copyright Copyright (c) 2007 Neon Design Technology, Inc.
Original version by Peter Quade <pq@pqua.de>
@@ -16,7 +16,7 @@ Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
-limitations under the License.
+limitations under the License.
*/
#import <Foundation/Foundation.h>
View
20 objc/exception.m
@@ -16,7 +16,7 @@
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
-limitations under the License.
+limitations under the License.
*/
//#define IMPORT_EXCEPTION_HANDLING_FRAMEWORK
@@ -71,11 +71,11 @@ + (void)setDefaultExceptionHandler
NSSetUncaughtExceptionHandler(*Nu_defaultExceptionHandler);
#ifdef IMPORT_EXCEPTION_HANDLING_FRAMEWORK
- [[NSExceptionHandler defaultExceptionHandler]
- setExceptionHandlingMask:(NSHandleUncaughtExceptionMask
- | NSHandleUncaughtSystemExceptionMask
- | NSHandleUncaughtRuntimeErrorMask
- | NSHandleTopLevelExceptionMask
+ [[NSExceptionHandler defaultExceptionHandler]
+ setExceptionHandlingMask:(NSHandleUncaughtExceptionMask
+ | NSHandleUncaughtSystemExceptionMask
+ | NSHandleUncaughtRuntimeErrorMask
+ | NSHandleTopLevelExceptionMask
| NSHandleOtherExceptionMask)];
#endif
}
@@ -115,8 +115,8 @@ - (NuException *)addFunction:(NSString *)function lineNumber:(int)line
- (NuException *)addFunction:(NSString *)function lineNumber:(int)line filename:(NSString *)filename
{
- NuTraceInfo* traceInfo = [[NuTraceInfo alloc] initWithFunction:function
- lineNumber:line
+ NuTraceInfo* traceInfo = [[NuTraceInfo alloc] initWithFunction:function
+ lineNumber:line
filename:filename];
[stackTrace addObject:traceInfo];
@@ -132,7 +132,7 @@ - (NSString *)stringValue
- (NSString*)dumpExcludingTopLevelCount:(int)topLevelCount
{
NSMutableString* dump = [NSMutableString stringWithString:@"Nu uncaught exception: "];
-
+
[dump appendString:[NSString stringWithFormat:@"%@: %@\n", [self name], [self reason]]];
int count = [stackTrace count] - topLevelCount;
@@ -169,7 +169,7 @@ @implementation NuTraceInfo
- (id)initWithFunction:(NSString *)aFunction lineNumber:(int)aLine filename:(NSString *)aFilename
{
self = [super init];
-
+
if (self)
{
filename = [aFilename retain];
View
12 objc/extensions.m
@@ -309,7 +309,7 @@ - (void) setValue:(id) value forKey:(id) key
#endif
@end
-@interface NuStringEnumerator : NSEnumerator
+@interface NuStringEnumerator : NSEnumerator
{
NSString *string;
int index;
@@ -318,7 +318,7 @@ @interface NuStringEnumerator : NSEnumerator
@implementation NuStringEnumerator
-+ (NuStringEnumerator *) enumeratorWithString:(NSString *) string
++ (NuStringEnumerator *) enumeratorWithString:(NSString *) string
{
return [[[self alloc] initWithString:string] autorelease];
}
@@ -511,7 +511,7 @@ - (NSString *) replaceString:(NSString *) target withString:(NSString *) replace
return s;
}
-- (id) objectEnumerator
+- (id) objectEnumerator
{
return [NuStringEnumerator enumeratorWithString:self];
}
@@ -529,7 +529,7 @@ - (const char *) cStringUsingEncoding:(NSStringEncoding) encoding
}
*/
-- (NSString *) stringByReplacingOccurrencesOfString:(NSString *) before withString:(NSString *) after
+- (NSString *) stringByReplacingOccurrencesOfString:(NSString *) before withString:(NSString *) after
{
return [self stringByReplacingString:before withString:after];
}
@@ -577,7 +577,7 @@ - (void) appendCharacter:(unichar) c
@implementation NSData(Nu)
-- (const unsigned char) byteAtIndex:(int) i
+- (const unsigned char) byteAtIndex:(int) i
{
const unsigned char buffer[2];
[self getBytes:&buffer range:NSMakeRange(i,1)];
@@ -794,7 +794,7 @@ + (id) _timestampForFileNamed:(NSString *) filename
if (filename == Nu__null) return nil;
NSError *error;
#ifdef DARWIN
- NSDictionary *attributes = [[NSFileManager defaultManager]
+ NSDictionary *attributes = [[NSFileManager defaultManager]
attributesOfItemAtPath:[filename stringByExpandingTildeInPath]
error:&error];
#else
View
2  objc/ivars.m
@@ -32,7 +32,7 @@ void nu_registerIvarForRelease(Class c, NSString *name)
ivarsToRelease = NSCreateMapTable(NSIntegerMapKeyCallBacks, NSObjectMapValueCallBacks, 0);
#else
ivarsToRelease = NSCreateMapTable(NSIntMapKeyCallBacks, NSObjectMapValueCallBacks, 0);
- #endif
+ #endif
}
NSMutableArray *ivars = NSMapGet(ivarsToRelease, c);
if (!ivars) {
View
162 objc/mach_override.c
@@ -17,9 +17,9 @@
#include <CoreServices/CoreServices.h>
/**************************
-*
+*
* Constants
-*
+*
**************************/
#pragma mark -
#pragma mark (Constants)
@@ -46,9 +46,9 @@ long kIslandTemplate[] = {
#define kOriginalInstructionsSize 16
char kIslandTemplate[] = {
- // kOriginalInstructionsSize nop instructions so that we
- // should have enough space to host original instructions
- 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90,
+ // kOriginalInstructionsSize nop instructions so that we
+ // should have enough space to host original instructions
+ 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90,
0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90,
// Now the real jump instruction
0xE9, 0xEF, 0xBE, 0xAD, 0xDE
@@ -63,9 +63,9 @@ char kIslandTemplate[] = {
#define kAllocateNormal 0
/**************************
-*
+*
* Data Types
-*
+*
**************************/
#pragma mark -
#pragma mark (Data Types)
@@ -76,9 +76,9 @@ typedef struct {
} BranchIsland;
/**************************
-*
+*
* Funky Protos
-*
+*
**************************/
#pragma mark -
#pragma mark (Funky Protos)
@@ -98,7 +98,7 @@ setBranchIslandTarget(
BranchIsland *island,
const void *branchTo,
long instruction );
-#endif
+#endif
#if defined(__i386__)
mach_error_t
@@ -106,23 +106,23 @@ setBranchIslandTarget_i386(
BranchIsland *island,
const void *branchTo,
char* instructions );
-void
+void
atomic_mov64(
uint64_t *targetAddress,
uint64_t value );
- static Boolean
-eatKnownInstructions(
- unsigned char *code,
+ static Boolean
+eatKnownInstructions(
+ unsigned char *code,
uint64_t *newInstruction,
- int *howManyEaten,
+ int *howManyEaten,
char *originalInstructions );
#endif
/*******************************************************************************
-*
+*
* Interface
-*
+*
*******************************************************************************/
#pragma mark -
#pragma mark (Interface)
@@ -137,7 +137,7 @@ mach_override(
assert( originalFunctionSymbolName );
assert( strlen( originalFunctionSymbolName ) );
assert( overrideFunctionAddress );
-
+
// Lookup the original function's code pointer.
long *originalFunctionPtr;
if( originalFunctionLibraryNameHint )
@@ -151,7 +151,7 @@ mach_override(
originalFunctionSymbolName,
(void*) &originalFunctionPtr,
NULL );
-
+
return mach_override_ptr( originalFunctionPtr, overrideFunctionAddress,
originalFunctionReentryIsland );
}
@@ -164,15 +164,15 @@ mach_override_ptr(
{
assert( originalFunctionAddress );
assert( overrideFunctionAddress );
-
+
long *originalFunctionPtr = (long*) originalFunctionAddress;
mach_error_t err = err_none;
-
+
#if defined(__ppc__) || defined(__POWERPC__)
// Ensure first instruction isn't 'mfctr'.
#define kMFCTRMask 0xfc1fffff
#define kMFCTRInstruction 0x7c0903a6
-
+
long originalInstruction = *originalFunctionPtr;
if( !err && ((originalInstruction & kMFCTRMask) == kMFCTRInstruction) )
err = err_cannot_override;
@@ -181,7 +181,7 @@ mach_override_ptr(
char originalInstructions[kOriginalInstructionsSize];
uint64_t jumpRelativeInstruction = 0; // JMP
- Boolean overridePossible = eatKnownInstructions ((unsigned char *)originalFunctionPtr,
+ Boolean overridePossible = eatKnownInstructions ((unsigned char *)originalFunctionPtr,
&jumpRelativeInstruction, &eatenCount, originalInstructions);
if (eatenCount > kOriginalInstructionsSize) {
//printf ("Too many instructions eaten\n");
@@ -189,7 +189,7 @@ mach_override_ptr(
}
if (!overridePossible) err = err_cannot_override;
#endif
-
+
// Make the original function implementation writable.
if( !err ) {
err = vm_protect( mach_task_self(),
@@ -200,12 +200,12 @@ mach_override_ptr(
(vm_address_t) originalFunctionPtr, sizeof(long), false,
(VM_PROT_DEFAULT | VM_PROT_COPY) );
}
-
+
// Allocate and target the escape island to the overriding function.
BranchIsland *escapeIsland = NULL;
- if( !err )
+ if( !err )
err = allocateBranchIsland( &escapeIsland, kAllocateHigh );
-
+
#if defined(__ppc__) || defined(__POWERPC__)
if( !err )
err = setBranchIslandTarget( escapeIsland, overrideFunctionAddress, 0 );
@@ -219,18 +219,18 @@ mach_override_ptr(
#elif defined (__i386__)
if( !err )
err = setBranchIslandTarget_i386( escapeIsland, overrideFunctionAddress, 0 );
-
+
// Build the jump relative instruction to the escape island
if (!err) {
int32_t addressOffset = ((int32_t)escapeIsland - (int32_t)originalFunctionPtr - 5);
addressOffset = OSSwapInt32(addressOffset);
-
- jumpRelativeInstruction |= 0xE900000000000000LL;
+
+ jumpRelativeInstruction |= 0xE900000000000000LL;
jumpRelativeInstruction |= ((uint64_t)addressOffset & 0xffffffff) << 24;
- jumpRelativeInstruction = OSSwapInt64(jumpRelativeInstruction);
+ jumpRelativeInstruction = OSSwapInt64(jumpRelativeInstruction);
}
#endif
-
+
// Optionally allocate & return the reentry island.
BranchIsland *reentryIsland = NULL;
if( !err && originalFunctionReentryIsland ) {
@@ -238,8 +238,8 @@ mach_override_ptr(
if( !err )
*originalFunctionReentryIsland = reentryIsland;
}
-
-#if defined(__ppc__) || defined(__POWERPC__)
+
+#if defined(__ppc__) || defined(__POWERPC__)
// Atomically:
// o If the reentry island was allocated:
// o Insert the original instruction into the reentry island.
@@ -271,7 +271,7 @@ mach_override_ptr(
// Atomically:
// o If the reentry island was allocated:
// o Insert the original instructions into the reentry island.
- // o Target the reentry island at the first non-replaced
+ // o Target the reentry island at the first non-replaced
// instruction of the original function.
// o Replace the original first instructions with the jump relative.
//
@@ -284,7 +284,7 @@ mach_override_ptr(
atomic_mov64((uint64_t *)originalFunctionPtr, jumpRelativeInstruction);
}
#endif
-
+
// Clean up on error.
if( err ) {
if( reentryIsland )
@@ -292,21 +292,21 @@ mach_override_ptr(
if( escapeIsland )
freeBranchIsland( escapeIsland );
}
-
+
return err;
}
/*******************************************************************************
-*
+*
* Implementation
-*
+*
*******************************************************************************/
#pragma mark -
#pragma mark (Implementation)
/***************************************************************************//**
Implementation: Allocates memory for a branch island.
-
+
@param island <- The allocated island.
@param allocateHigh -> Whether to allocate the island at the end of the
address space (for use with the branch absolute
@@ -321,9 +321,9 @@ allocateBranchIsland(
int allocateHigh )
{
assert( island );
-
+
mach_error_t err = err_none;
-
+
if( allocateHigh ) {
vm_size_t pageSize;
err = host_page_size( mach_host_self(), &pageSize );
@@ -334,7 +334,7 @@ allocateBranchIsland(
vm_address_t page = first;
int allocated = 0;
vm_map_t task_self = mach_task_self();
-
+
while( !err && !allocated && page != last ) {
err = vm_allocate( task_self, &page, pageSize, 0 );
if( err == err_none )
@@ -358,13 +358,13 @@ allocateBranchIsland(
}
if( !err )
(**island).allocatedHigh = allocateHigh;
-
+
return err;
}
/***************************************************************************//**
Implementation: Deallocates memory for a branch island.
-
+
@param island -> The island to deallocate.
@result <- mach_error_t
@@ -377,9 +377,9 @@ freeBranchIsland(
assert( island );
assert( (*(long*)&island->instructions[0]) == kIslandTemplate[0] );
assert( island->allocatedHigh );
-
+
mach_error_t err = err_none;
-
+
if( island->allocatedHigh ) {
vm_size_t pageSize;
err = host_page_size( mach_host_self(), &pageSize );
@@ -392,14 +392,14 @@ freeBranchIsland(
} else {
free( island );
}
-
+
return err;
}
/***************************************************************************//**
Implementation: Sets the branch island's target, with an optional
instruction.
-
+
@param island -> The branch island to insert target into.
@param branchTo -> The address of the target.
@param instruction -> Optional instruction to execute prior to branch. Set
@@ -416,12 +416,12 @@ setBranchIslandTarget(
{
// Copy over the template code.
bcopy( kIslandTemplate, island->instructions, sizeof( kIslandTemplate ) );
-
+
// Fill in the address.
((short*)island->instructions)[kAddressLo] = ((long) branchTo) & 0x0000FFFF;
((short*)island->instructions)[kAddressHi]
= (((long) branchTo) >> 16) & 0x0000FFFF;
-
+
// Fill in the (optional) instuction.
if( instruction != 0 ) {
((short*)island->instructions)[kInstructionLo]
@@ -429,13 +429,13 @@ setBranchIslandTarget(
((short*)island->instructions)[kInstructionHi]
= (instruction >> 16) & 0x0000FFFF;
}
-
+
//MakeDataExecutable( island->instructions, sizeof( kIslandTemplate ) );
msync( island->instructions, sizeof( kIslandTemplate ), MS_INVALIDATE );
-
+
return err_none;
}
-#endif
+#endif
#if defined(__i386__)
mach_error_t
@@ -447,16 +447,16 @@ setBranchIslandTarget_i386(
// Copy over the template code.
bcopy( kIslandTemplate, island->instructions, sizeof( kIslandTemplate ) );
-
+
// copy original instructions
if (instructions) {
bcopy (instructions, island->instructions + kInstructions, kOriginalInstructionsSize);
}
-
+
// Fill in the address.
int32_t addressOffset = (char *)branchTo - (island->instructions + kJumpAddress + 4);
- *((int32_t *)(island->instructions + kJumpAddress)) = addressOffset;
-
+ *((int32_t *)(island->instructions + kJumpAddress)) = addressOffset;
+
//MakeDataExecutable( island->instructions, sizeof( kIslandTemplate ) );
msync( island->instructions, sizeof( kIslandTemplate ), MS_INVALIDATE );
@@ -484,10 +484,10 @@ static AsmInstructionMatch possibleInstructions[] = {
{ 0x0 }
};
-static Boolean codeMatchesInstruction(unsigned char *code, AsmInstructionMatch* instruction)
+static Boolean codeMatchesInstruction(unsigned char *code, AsmInstructionMatch* instruction)
{
Boolean match = true;
-
+
int i;
for (i=0; i<instruction->length; i++) {
unsigned char mask = instruction->mask[i];
@@ -496,39 +496,39 @@ static Boolean codeMatchesInstruction(unsigned char *code, AsmInstructionMatch*
match = ((codeValue & mask) == constraint);
if (!match) break;
}
-
+
return match;
}
- static Boolean
-eatKnownInstructions(
- unsigned char *code,
+ static Boolean
+eatKnownInstructions(
+ unsigned char *code,
uint64_t* newInstruction,
- int* howManyEaten,
+ int* howManyEaten,
char* originalInstructions )
{
Boolean allInstructionsKnown = true;
int totalEaten = 0;
unsigned char* ptr = code;
int remainsToEat = 5; // a JMP instruction takes 5 bytes
-
+
if (howManyEaten) *howManyEaten = 0;
while (remainsToEat > 0) {
Boolean curInstructionKnown = false;
-
+
// See if instruction matches one we know
AsmInstructionMatch* curInstr = possibleInstructions;
do {
if ((curInstructionKnown = codeMatchesInstruction(ptr, curInstr))) break;
curInstr++;
} while (curInstr->length > 0);
-
+
// if all instruction matches failed, we don't know current instruction then, stop here
- if (!curInstructionKnown) {
+ if (!curInstructionKnown) {
allInstructionsKnown = false;
break;
}
-
+
// At this point, we've matched curInstr
int eaten = curInstr->length;
ptr += eaten;
@@ -541,7 +541,7 @@ eatKnownInstructions(
if (originalInstructions) {
Boolean enoughSpaceForOriginalInstructions = (totalEaten < kOriginalInstructionsSize);
-
+
if (enoughSpaceForOriginalInstructions) {
memset(originalInstructions, 0x90 /* NOP */, kOriginalInstructionsSize); // fill instructions with NOP
bcopy(code, originalInstructions, totalEaten);
@@ -550,13 +550,13 @@ eatKnownInstructions(
return false;
}
}
-
+
if (allInstructionsKnown) {
// save last 3 bytes of first 64bits of codre we'll replace
uint64_t currentFirst64BitsOfCode = *((uint64_t *)code);
currentFirst64BitsOfCode = OSSwapInt64(currentFirst64BitsOfCode); // back to memory representation
- currentFirst64BitsOfCode &= 0x0000000000FFFFFFLL;
-
+ currentFirst64BitsOfCode &= 0x0000000000FFFFFFLL;
+
// keep only last 3 instructions bytes, first 5 will be replaced by JMP instr
*newInstruction &= 0xFFFFFFFFFF000000LL; // clear last 3 bytes
*newInstruction |= (currentFirst64BitsOfCode & 0x0000000000FFFFFFLL); // set last 3 bytes
@@ -565,7 +565,7 @@ eatKnownInstructions(
return allInstructionsKnown;
}
-asm(
+asm(
".text;"
".align 2, 0x90;"
".globl _atomic_mov64;"
@@ -577,11 +577,11 @@ asm(
" pushl %ecx;"
" pushl %eax;"
" pushl %edx;"
-
+
// atomic push of value to an address
- // we use cmpxchg8b, which compares content of an address with
- // edx:eax. If they are equal, it atomically puts 64bit value
- // ecx:ebx in address.
+ // we use cmpxchg8b, which compares content of an address with
+ // edx:eax. If they are equal, it atomically puts 64bit value
+ // ecx:ebx in address.
// We thus put contents of address in edx:eax to force ecx:ebx
// in address
" mov 8(%ebp), %esi;" // esi contains target address
@@ -590,7 +590,7 @@ asm(
" mov (%esi), %eax;"
" mov 4(%esi), %edx;" // edx:eax now contains value currently contained in target address
" lock; cmpxchg8b (%esi);" // atomic move.
-
+
// restore registers
" popl %edx;"
" popl %eax;"
@@ -602,4 +602,4 @@ asm(
);
#endif
-#endif
+#endif
View
14 objc/mach_override.h
@@ -8,14 +8,14 @@
/***************************************************************************//**
@mainpage mach_override
@author Jonathan 'Wolf' Rentzsch: <http://rentzsch.com>
-
+
This package, coded in C to the Mach API, allows you to override ("patch")
program- and system-supplied functions at runtime. You can fully replace
functions with your implementations, or merely head- or tail-patch the
original implementations.
-
+
Use it by #include'ing mach_override.h from your .c, .m or .mm file(s).
-
+
@todo Discontinue use of Carbon's MakeDataExecutable() and
CompareAndSwap() calls and start using the Mach equivalents, if they
exist. If they don't, write them and roll them in. That way, this
@@ -62,7 +62,7 @@
originalFunctionSymbolName with the implentation pointed to by
overrideFunctionAddress. Optionally returns a pointer to a "reentry island"
which, if jumped to, will resume the original implementation.
-
+
@param originalFunctionSymbolName -> Required symbol name of the
function to override (with
overrideFunctionAddress).
@@ -85,7 +85,7 @@
'mfctr' instruction.
***************************************************************************/
-
+
mach_error_t
mach_override(
char *originalFunctionSymbolName,
@@ -98,7 +98,7 @@ mach_override(
originalFunctionAddress with the implentation pointed to by overrideFunctionAddress.
Optionally returns a pointer to a "reentry island" which, if jumped to, will resume
the original implementation.
-
+
@param originalFunctionAddress -> Required address of the function to
override (with overrideFunctionAddress).
@param overrideFunctionAddress -> Required address to the overriding
@@ -116,7 +116,7 @@ mach_override_ptr(
void *originalFunctionAddress,
const void *overrideFunctionAddress,
void **originalFunctionReentryIsland );
-
+
#ifdef __cplusplus
}
#endif
View
8 objc/macro_0.h
@@ -29,20 +29,20 @@ limitations under the License.
Macros are like functions, but with two important differences:
- First, macro arguments are not evaluated before the macro is called.
- It is up to the macro implementation to decide whether and how
+ First, macro arguments are not evaluated before the macro is called.
+ It is up to the macro implementation to decide whether and how
many times to evaluate each argument. When a Nu macro is evaluated,
the <b>margs</b> name is defined and is bound to a list of
the arguments of the macro.
- Second, macro evaluation occurs in the context of the caller.
+ Second, macro evaluation occurs in the context of the caller.
This means that a macro has access to all names defined in the
code that calls it, and that any name assignments made in a macro will
affect the names in the calling code. To avoid unintentional
name conflicts, any names in a macro body that begin with a double
underscore ("__") are replaced with automatically-generated symbols
that are guaranteed to be unique. In Lisp terminology, these generated
- symbols are called "gensyms".
+ symbols are called "gensyms".
*/
@interface NuMacro_0 : NSObject
{
View
8 objc/macro_1.h
@@ -34,15 +34,15 @@ limitations under the License.
must destructure manually.
<b>macro</b> does not implicitly "quote" the body of the macro.
- Instead the <b>backquote</b> (abbreviated as '`')
+ Instead the <b>backquote</b> (abbreviated as '`')
and <b>bq-comma</b> (abbreviated as ',') operators can be
- used to write a macro body that more closely resembles the
+ used to write a macro body that more closely resembles the
generated code.
For example, the following two macros are equivalent:
-
+
(macro-0 inc! (set (unquote (car margs)) (+ (unquote (car margs)) 1)))
-
+
(macro inc! (n) `(set ,n (+ ,n 1)))
*/
@interface NuMacro_1 : NuMacro_0
View
2  objc/macro_1.m
@@ -175,7 +175,7 @@ - (id) mdestructure:(id)pattern withSequence:(id)sequence
Macro1Debug(@"mdestructure: pat: %@ seq: %@", [pattern stringValue], [sequence stringValue]);
// ((and (not pat) seq)
- if ( ((pattern == nil) || (pattern == Nu__null))
+ if ( ((pattern == nil) || (pattern == Nu__null))
&& !((sequence == Nu__null) || (sequence == nil))) {
[NSException raise:@"NuDestructureException"
format:@"Attempt to match empty pattern to non-empty object %@", [self stringValue]];
View
12 objc/nu.m
@@ -117,11 +117,11 @@ int NuMain(int argc, const char *argv[], const char *envp[])
#if 0
NSSetUncaughtExceptionHandler(&NuMain_exceptionHandler);
- [[NSExceptionHandler defaultExceptionHandler]
- setExceptionHandlingMask:( NSHandleUncaughtExceptionMask
- | NSHandleUncaughtSystemExceptionMask
- | NSHandleUncaughtRuntimeErrorMask
- | NSHandleTopLevelExceptionMask
+ [[NSExceptionHandler defaultExceptionHandler]
+ setExceptionHandlingMask:( NSHandleUncaughtExceptionMask
+ | NSHandleUncaughtSystemExceptionMask
+ | NSHandleUncaughtRuntimeErrorMask
+ | NSHandleTopLevelExceptionMask
| NSHandleOtherExceptionMask)];
#endif
@@ -204,7 +204,7 @@ int NuMain(int argc, const char *argv[], const char *envp[])
}
// if there's no file, run at the terminal
else {
- #if defined(DARWIN) || defined(FREEBSD)
+ #if defined(DARWIN) || defined(FREEBSD)
if (!isatty(stdin->_file))
#elif defined(OPENSOLARIS)
if (!isatty(fileno(stdin)))
View
2  objc/nutypes.h
@@ -1,5 +1,4 @@
-
#ifdef GNUSTEP
#define bool char
@@ -8,4 +7,3 @@
#define false 0
#endif
-
View
6 objc/objc_runtime.m
@@ -1,7 +1,7 @@
/*
@file objc_runtime.m
-@description Nu extensions to the Objective-C runtime.
-Includes replacements for Objective-C 2.0 enhancements that are
+@description Nu extensions to the Objective-C runtime.
+Includes replacements for Objective-C 2.0 enhancements that are
only available in Apple's OS X 10.5 (Leopard).
@copyright Copyright (c) 2007 Neon Design Technology, Inc.
@@ -193,7 +193,7 @@ SEL sel_getUid(const char *str)
#ifdef IPHONE
#import "objc/runtime.h"
IMP nu_class_replaceMethod(Class cls, SEL name, IMP imp, const char *types) {
- return class_replaceMethod(cls, name, imp, types);
+ return class_replaceMethod(cls, name, imp, types);
}
#endif
View
4 objc/object.m
@@ -23,7 +23,7 @@
#import "extensions.h"
#import "enumerable.h"
-@protocol NuCanSetAction
+@protocol NuCanSetAction
- (void) setAction:(SEL) action;
@end
@@ -165,7 +165,7 @@ - (id) cdr
- (id) sendMessage:(id)cdr withContext:(NSMutableDictionary *)context
-{
+{
// By themselves, Objective-C objects evaluate to themselves.
if (!cdr || (cdr == Nu__null))
return self;
View
16 objc/operator.h
@@ -17,26 +17,26 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
#import <Foundation/Foundation.h>
-extern id Nu__null;
+extern id Nu__null;
/*!
@class NuOperator
- @abstract An abstract class for Nu operators.
- @discussion Like everything else in Nu, operators are represented with objects.
+ @abstract An abstract class for Nu operators.
+ @discussion Like everything else in Nu, operators are represented with objects.
Nu operators that are written in Objective-C are implemented with subclasses of this class.
Each operator is intended to have a singleton instance that is bound to a symbol
- in a Nu symbol table. An operator is evaluated with a call to
+ in a Nu symbol table. An operator is evaluated with a call to
its evalWithArguments:context: method.
- When they implement functions, operators evaluate their arguments,
- but many special forms exist that evaluate their arguments zero or multiple times.
+ When they implement functions, operators evaluate their arguments,
+ but many special forms exist that evaluate their arguments zero or multiple times.
*/
@interface NuOperator : NSObject
{
}
-/*! Evaluate an operator with a list of arguments and an execution context.
+/*! Evaluate an operator with a list of arguments and an execution context.
This method calls callWithArguments:context: and should not be overridden.
*/
- (id) evalWithArguments:(id) cdr context:(NSMutableDictionary *) context;
-/*! Call an operator with a list of arguments and an execution context.
+/*! Call an operator with a list of arguments and an execution context.
This method should be overridden by implementations of new operators.
*/
- (id) callWithArguments:(id) cdr context:(NSMutableDictionary *) context;
Please sign in to comment.
Something went wrong with that request. Please try again.