more fix up work. Nothing totally right, yet, but getting closer.

This commit is contained in:
Bill Currie 2001-02-12 09:20:26 +00:00
parent 091e4f77b1
commit 8ad4a755a2
6 changed files with 102 additions and 102 deletions

View file

@ -45,7 +45,7 @@ winding_t *CopyWinding (winding_t *w);
winding_t *NewWinding (int points); winding_t *NewWinding (int points);
@interface SetBrush : Object @interface SetBrush : NSObject <NSCopying>
{ {
BOOL regioned; // not active BOOL regioned; // not active
BOOL selected; BOOL selected;

View file

@ -211,7 +211,7 @@ winding_t *ClipWinding (winding_t *in, plane_t *split)
if (!counts[0]) if (!counts[0])
{ {
free (in); dealloc (in);
return NULL; return NULL;
} }
if (!counts[1]) if (!counts[1])
@ -266,7 +266,7 @@ winding_t *ClipWinding (winding_t *in, plane_t *split)
Error ("ClipWinding: points exceeded estimate"); Error ("ClipWinding: points exceeded estimate");
// free the original winding // free the original winding
free (in); dealloc (in);
return neww; return neww;
} }
@ -615,18 +615,18 @@ initOwner:::
for (i=0 ; i<MAX_FACES ; i++) for (i=0 ; i<MAX_FACES ; i++)
if (faces[i].w) if (faces[i].w)
{ {
free (faces[i].w); dealloc (faces[i].w);
faces[i].w = NULL; faces[i].w = NULL;
} }
return self; return self;
} }
- copyFromZone:(NXZone *)zone - copyWithZone:(NSZone *)zone
{ {
id new; id new;
[self freeWindings]; [self freeWindings];
new = [super copyFromZone: zone]; new = [super copyWithZone: zone];
[self calcWindings]; [self calcWindings];
[new calcWindings]; [new calcWindings];
@ -634,10 +634,10 @@ initOwner:::
return new; return new;
} }
- free - (void) dealloc
{ {
[self freeWindings]; [self freeWindings];
return [super free]; return [super dealloc];
} }
/* /*
@ -1040,12 +1040,12 @@ BOOL fakebrush;
c = [map_i count]; c = [map_i count];
for (i=0 ; i<c ; i++) for (i=0 ; i<c ; i++)
{ {
obj = [map_i objectAt: i]; obj = [map_i objectAtIndex: i];
targname = [obj valueForQKey: "targetname"]; targname = [obj valueForQKey: "targetname"];
if (strcmp (targ, targname)) if (strcmp (targ, targname))
continue; continue;
[[obj objectAt:0] getMins: min maxs: max]; [[obj objectAtIndex:0] getMins: min maxs: max];
dest[0] = (min[0] + max[0]) /2; dest[0] = (min[0] + max[0]) /2;
dest[1] = (min[1] + max[1]) /2; dest[1] = (min[1] + max[1]) /2;
@ -1098,7 +1098,7 @@ BOOL fakebrush;
if (copy) if (copy)
{ {
[copy perform:call]; [copy perform:call];
[copy free]; [copy dealloc];
} }
fakebrush = NO; fakebrush = NO;
return YES; return YES;
@ -1125,10 +1125,10 @@ XYDrawSelf
[xyview_i addToScrollRange: bmins[0] : bmins[1]]; [xyview_i addToScrollRange: bmins[0] : bmins[1]];
[xyview_i addToScrollRange: bmaxs[0] : bmaxs[1]]; [xyview_i addToScrollRange: bmaxs[0] : bmaxs[1]];
worldent = [map_i objectAt: 0]; worldent = [map_i objectAtIndex: 0];
currentent = [map_i currentEntity]; currentent = [map_i currentEntity];
if (parent != worldent && self == [parent objectAt: 0]) if (parent != worldent && self == [parent objectAtIndex: 0])
keybrush = YES; keybrush = YES;
else else
keybrush = NO; keybrush = NO;
@ -1228,7 +1228,7 @@ ZDrawSelf
PSstroke (); PSstroke ();
} }
[zview_i getPoint: (NXPoint *)p1]; [zview_i getPoint: (NSPoint *)p1];
for (i=0 ; i<2 ; i++) for (i=0 ; i<2 ; i++)
if (bmins[i] >= p1[i] || bmaxs[i] <= p1[i]) if (bmins[i] >= p1[i] || bmaxs[i] <= p1[i])
@ -1283,7 +1283,7 @@ CameraDrawSelf
if ([self fakeBrush: @selector(CameraDrawSelf)]) if ([self fakeBrush: @selector(CameraDrawSelf)])
return self; return self;
worldent = [map_i objectAt: 0]; worldent = [map_i objectAtIndex: 0];
currentent = [map_i currentEntity]; currentent = [map_i currentEntity];
if (parent != worldent && worldent == currentent) if (parent != worldent && worldent == currentent)
@ -1623,7 +1623,7 @@ Set the regioned flag based on if the object is containted in region_min/max
char *name; char *name;
// filter away entities // filter away entities
if (parent != [map_i objectAt: 0]) if (parent != [map_i objectAtIndex: 0])
{ {
if (filter_entities) if (filter_entities)
{ {
@ -1816,7 +1816,7 @@ vec3_t sb_mins, sb_maxs;
} }
[parent removeObject: self]; [parent removeObject: self];
[self free]; [self dealloc];
return nil; return nil;
} }

View file

@ -89,7 +89,7 @@ TEX_ImageFromMiptex
*/ */
void TEX_ImageFromMiptex (miptex_t *qtex) void TEX_ImageFromMiptex (miptex_t *qtex)
{ {
NXBitmapImageRep *bm; NSBitmapImageRep *bm;
byte *source; byte *source;
unsigned *dest; unsigned *dest;
int width, height, i, count; int width, height, i, count;
@ -99,19 +99,19 @@ void TEX_ImageFromMiptex (miptex_t *qtex)
width = LittleLong(qtex->width); width = LittleLong(qtex->width);
height = LittleLong(qtex->height); height = LittleLong(qtex->height);
bm = [[NXBitmapImageRep alloc] bm = [[NSBitmapImageRep alloc]
initData: NULL initWithBitmapDataPlanes: NULL
pixelsWide: width pixelsWide: width
pixelsHigh: height pixelsHigh: height
bitsPerSample: 8 bitsPerSample: 8
samplesPerPixel:3 samplesPerPixel:3
hasAlpha: NO hasAlpha: NO
isPlanar: NO isPlanar: NO
colorSpace: NX_RGBColorSpace colorSpaceName: NSCalibratedRGBColorSpace
bytesPerRow: width*4 bytesPerRow: width*4
bitsPerPixel: 32]; bitsPerPixel: 32];
dest = (unsigned *)[bm data]; dest = (unsigned *)[bm bitmapData];
count = width*height; count = width*height;
source = (byte *)qtex + LittleLong(qtex->offsets[0]); source = (byte *)qtex + LittleLong(qtex->offsets[0]);
@ -184,7 +184,7 @@ void TEX_InitFromWad (char *path)
// free any textures // free any textures
for (i=0 ; i<tex_count ; i++) for (i=0 ; i<tex_count ; i++)
[qtextures[i].rep free]; [qtextures[i].rep dealloc];
tex_count = 0; tex_count = 0;
// try and use the cached wadfile // try and use the cached wadfile
@ -292,7 +292,7 @@ qtexture_t *TEX_ForName (char *name)
// Create STORAGE // Create STORAGE
if (textureList_i) if (textureList_i)
[textureList_i empty]; [textureList_i removeAllObjects];
else else
textureList_i = [[Storage alloc] textureList_i = [[Storage alloc]
initCount:0 initCount:0
@ -349,8 +349,8 @@ qtexture_t *TEX_ForName (char *name)
found = 0; found = 0;
for (i = 0;i < max-1;i++) for (i = 0;i < max-1;i++)
{ {
t1p = [textureList_i elementAt:i]; t1p = [textureList_i elementAtIndex:i];
t2p = [textureList_i elementAt:i+1]; t2p = [textureList_i elementAtIndex:i+1];
if (strcmp(t1p->name,t2p->name) < 0) if (strcmp(t1p->name,t2p->name) < 0)
{ {
t1 = *t1p; t1 = *t1p;
@ -372,7 +372,7 @@ qtexture_t *TEX_ForName (char *name)
texpal_t *t; texpal_t *t;
int y; int y;
id view; id view;
NXRect b; NSRect b;
int maxwidth; int maxwidth;
int maxheight; int maxheight;
NXPoint pt; NXPoint pt;
@ -388,7 +388,7 @@ qtexture_t *TEX_ForName (char *name)
for (i = 0;i < max; i++) for (i = 0;i < max; i++)
{ {
t = [textureList_i elementAt:i]; t = [textureList_i elementAtIndex:i];
if (x + t->r.size.width + TEX_INDENT > maxwidth) if (x + t->r.size.width + TEX_INDENT > maxwidth)
{ {
x = TEX_INDENT; x = TEX_INDENT;
@ -454,7 +454,7 @@ qtexture_t *TEX_ForName (char *name)
- setSelectedTexture:(int)which - setSelectedTexture:(int)which
{ {
texpal_t *t; texpal_t *t;
NXRect r; NSRect r;
char string[16]; char string[16];
// wipe the fields // wipe the fields
@ -464,7 +464,7 @@ qtexture_t *TEX_ForName (char *name)
{ {
[textureView_i deselect]; [textureView_i deselect];
selectedTexture = which; selectedTexture = which;
t = [textureList_i elementAt:which]; t = [textureList_i elementAtIndex:which];
r = t->r; r = t->r;
r.size.width += TEX_INDENT*2; r.size.width += TEX_INDENT*2;
r.size.height += TEX_INDENT*2; r.size.height += TEX_INDENT*2;
@ -500,7 +500,7 @@ qtexture_t *TEX_ForName (char *name)
if (selectedTexture == -1) if (selectedTexture == -1)
return -1; return -1;
t = [textureList_i elementAt:selectedTexture]; t = [textureList_i elementAtIndex:selectedTexture];
return t->index; return t->index;
} }
@ -513,7 +513,7 @@ qtexture_t *TEX_ForName (char *name)
if (selectedTexture == -1) if (selectedTexture == -1)
return NULL; return NULL;
t = [textureList_i elementAt:selectedTexture]; t = [textureList_i elementAtIndex:selectedTexture];
return t->name; return t->name;
} }
@ -530,7 +530,7 @@ qtexture_t *TEX_ForName (char *name)
CleanupName(name,name); CleanupName(name,name);
for (i = 0;i < max;i++) for (i = 0;i < max;i++)
{ {
t = [textureList_i elementAt:i]; t = [textureList_i elementAtIndex:i];
if (!strcmp(t->name,name)) if (!strcmp(t->name,name))
{ {
[self setSelectedTexture: i]; [self setSelectedTexture: i];
@ -568,7 +568,7 @@ qtexture_t *TEX_ForName (char *name)
for (i = selectedTexture-1;i >= 0; i--) for (i = selectedTexture-1;i >= 0; i--)
{ {
t = [textureList_i elementAt:i]; t = [textureList_i elementAtIndex:i];
if (!strncmp(t->name,name,len)) if (!strncmp(t->name,name,len))
{ {
[self setTextureByName:t->name]; [self setTextureByName:t->name];
@ -580,7 +580,7 @@ qtexture_t *TEX_ForName (char *name)
for (i = max-1;i >= selectedTexture; i--) for (i = max-1;i >= selectedTexture; i--)
{ {
t = [textureList_i elementAt:i]; t = [textureList_i elementAtIndex:i];
if (!strncmp(t->name,name,len)) if (!strncmp(t->name,name,len))
{ {
[self setTextureByName:t->name]; [self setTextureByName:t->name];
@ -750,7 +750,7 @@ qtexture_t *TEX_ForName (char *name)
for (i = 0; i < max; i++) for (i = 0; i < max; i++)
{ {
t = [textureList_i elementAt:i]; t = [textureList_i elementAtIndex:i];
if (!strcmp(t->name,name)) if (!strcmp(t->name,name))
return i; return i;
} }
@ -778,11 +778,11 @@ qtexture_t *TEX_ForName (char *name)
for (i = 0;i < max; i++) for (i = 0;i < max; i++)
[self setDisplayFlag:i to:0]; [self setDisplayFlag:i to:0];
brushes = [map_i objectAt:0]; brushes = [map_i objectAtIndex:0];
max = [brushes count]; max = [brushes count];
for (i = 0;i < max; i++) for (i = 0;i < max; i++)
{ {
b = (SetBrush *)[brushes objectAt:i]; b = (SetBrush *)[brushes objectAtIndex:i];
numfaces = [b getNumBrushFaces]; numfaces = [b getNumBrushFaces];
for (j = 0; j < numfaces; j++) for (j = 0; j < numfaces; j++)
{ {
@ -810,7 +810,7 @@ qtexture_t *TEX_ForName (char *name)
{ {
texpal_t *tp; texpal_t *tp;
tp = [textureList_i elementAt:index]; tp = [textureList_i elementAtIndex:index];
tp->display = value; tp->display = value;
return self; return self;
}; };

View file

@ -26,7 +26,7 @@ NOTE: I am specifically not using cached image reps, because the data is also ne
return YES; return YES;
} }
- drawSelf:(const NXRect *)rects :(int)rectCount - drawSelf:(const NSRect *)rects :(int)rectCount
{ {
int i; int i;
int max; int max;
@ -34,8 +34,8 @@ NOTE: I am specifically not using cached image reps, because the data is also ne
texpal_t *t; texpal_t *t;
int x; int x;
int y; int y;
NXPoint p; NSPoint p;
NXRect r; NSRect r;
int selected; int selected;
selected = [parent_i getSelectedTexture]; selected = [parent_i getSelectedTexture];
@ -43,7 +43,7 @@ NOTE: I am specifically not using cached image reps, because the data is also ne
PSselectfont("Helvetica-Medium",FONTSIZE); PSselectfont("Helvetica-Medium",FONTSIZE);
PSrotate(0); PSrotate(0);
PSsetgray(NX_LTGRAY); PSsetgray(NSLightGray);
PSrectfill(rects->origin.x, rects->origin.y, PSrectfill(rects->origin.x, rects->origin.y,
rects->size.width, rects->size.height); rects->size.width, rects->size.height);
@ -52,19 +52,19 @@ NOTE: I am specifically not using cached image reps, because the data is also ne
if (deselectIndex != -1) if (deselectIndex != -1)
{ {
t = [list_i elementAt:deselectIndex]; t = [list_i elementAtIndex:deselectIndex];
r = t->r; r = t->r;
r.origin.x -= TEX_INDENT; r.origin.x -= TEX_INDENT;
r.origin.y -= TEX_INDENT; r.origin.y -= TEX_INDENT;
r.size.width += TEX_INDENT*2; r.size.width += TEX_INDENT*2;
r.size.height += TEX_INDENT*2; r.size.height += TEX_INDENT*2;
PSsetgray(NXGrayComponent(NX_COLORLTGRAY)); PSsetgray(NSGrayComponent(NSGray));
PSrectfill(r.origin.x, r.origin.y, PSrectfill(r.origin.x, r.origin.y,
r.size.width, r.size.height); r.size.width, r.size.height);
p = t->r.origin; p = t->r.origin;
p.y += TEX_SPACING; p.y += TEX_SPACING;
[t->image drawAt:&p]; [t->image drawAtPoint:p];
PSsetgray(0); PSsetgray(0);
x = t->r.origin.x; x = t->r.origin.x;
y = t->r.origin.y + 7; y = t->r.origin.y + 7;
@ -79,12 +79,12 @@ NOTE: I am specifically not using cached image reps, because the data is also ne
for (i = 0;i < max; i++) for (i = 0;i < max; i++)
{ {
t = [list_i elementAt:i]; t = [list_i elementAtIndex:i];
r = t->r; r = t->r;
r.origin.x -= TEX_INDENT/2; r.origin.x -= TEX_INDENT/2;
r.size.width += TEX_INDENT; r.size.width += TEX_INDENT;
r.origin.y += 4; r.origin.y += 4;
if (NXIntersectsRect(&rects[0],&r) == YES && if (NSIntersectsRect(rects[0],r) == YES &&
t->display) t->display)
{ {
if (selected == i) if (selected == i)
@ -100,7 +100,7 @@ NOTE: I am specifically not using cached image reps, because the data is also ne
p = t->r.origin; p = t->r.origin;
p.y += TEX_SPACING; p.y += TEX_SPACING;
[t->image drawAt:&p]; [t->image drawAtPoint:p];
x = t->r.origin.x; x = t->r.origin.x;
y = t->r.origin.y + 7; y = t->r.origin.y + 7;
PSmoveto(x,y); PSmoveto(x,y);
@ -117,27 +117,27 @@ NOTE: I am specifically not using cached image reps, because the data is also ne
return self; return self;
} }
- mouseDown:(NXEvent *)theEvent - mouseDown:(NSEvent *)theEvent
{ {
NXPoint loc; NSPoint loc;
int i; int i;
int max; int max;
int oldwindowmask; int oldwindowmask;
texpal_t *t; texpal_t *t;
id list; id list;
NXRect r; NSRect r;
oldwindowmask = [window addToEventMask:NX_LMOUSEDRAGGEDMASK]; oldwindowmask = [[self window] addToEventMask:NSLeftMouseDraggedMask];
loc = theEvent->location; loc = [theEvent locationInWindow];
[self convertPoint:&loc fromView:NULL]; [self convertPoint:loc fromView:NULL];
list = [parent_i getList]; list = [parent_i getList];
max = [list count]; max = [list count];
for (i = 0;i < max; i++) for (i = 0;i < max; i++)
{ {
t = [list elementAt:i]; t = [list elementAtIndex:i];
r = t->r; r = t->r;
if (NXPointInRect(&loc,&r) == YES) if (NSPointInRect(loc,r) == YES)
{ {
[self deselect]; [self deselect];
[parent_i setSelectedTexture:i]; [parent_i setSelectedTexture:i];
@ -145,7 +145,7 @@ NOTE: I am specifically not using cached image reps, because the data is also ne
} }
} }
[window setEventMask:oldwindowmask]; [[self window] setEventMask:oldwindowmask];
return self; return self;
} }

View file

@ -33,13 +33,13 @@ id things_i;
path = [project_i getProgDirectory]; path = [project_i getProgDirectory];
[prog_path_i setStringValue: path]; [prog_path_i setStringValue: [NSString stringWithCString:path]];
[[EntityClassList alloc] initForSourceDirectory: path]; [[EntityClassList alloc] initForSourceDirectory: path];
[self loadEntityComment:[entity_classes_i objectAt:lastSelected]]; [self loadEntityComment:[entity_classes_i objectAtIndex:lastSelected]];
[entity_browser_i loadColumnZero]; [entity_browser_i loadColumnZero];
[[entity_browser_i matrixInColumn:0] selectCellAt:lastSelected :0]; [[entity_browser_i matrixInColumn:0] selectCellAtRow:lastSelected column:0];
[entity_browser_i setDoubleAction: @selector(doubleClickEntity:)]; [entity_browser_i setDoubleAction: @selector(doubleClickEntity:)];
@ -52,7 +52,7 @@ id things_i;
matr = [sender matrixInColumn: 0]; matr = [sender matrixInColumn: 0];
lastSelected = [matr selectedRow]; lastSelected = [matr selectedRow];
[self loadEntityComment:[entity_classes_i objectAt:lastSelected]]; [self loadEntityComment:[entity_classes_i objectAtIndex:lastSelected]];
[quakeed_i makeFirstResponder: quakeed_i]; [quakeed_i makeFirstResponder: quakeed_i];
return self; return self;
@ -67,7 +67,7 @@ id things_i;
- (char *)spawnName - (char *)spawnName
{ {
return [[entity_classes_i objectAt:lastSelected] classname]; return [[entity_classes_i objectAtIndex:lastSelected] classname];
} }
@ -83,7 +83,7 @@ id things_i;
if (!path || !path[0]) if (!path || !path[0])
{ {
path = [project_i getProgDirectory]; path = [project_i getProgDirectory];
[prog_path_i setStringValue: path]; [prog_path_i setStringValue: [NSString stringWithCString:path]];
} }
// Free all entity info in memory... // Free all entity info in memory...
@ -94,11 +94,11 @@ id things_i;
[[EntityClassList alloc] initForSourceDirectory: path]; [[EntityClassList alloc] initForSourceDirectory: path];
lastSelected = 0; lastSelected = 0;
ent = [entity_classes_i objectAt:lastSelected]; ent = [entity_classes_i objectAtIndex:lastSelected];
[self loadEntityComment:[entity_classes_i objectAt:lastSelected]]; [self loadEntityComment:[entity_classes_i objectAtIndex:lastSelected]];
[entity_browser_i loadColumnZero]; [entity_browser_i loadColumnZero];
[[entity_browser_i matrixInColumn:0] selectCellAt:lastSelected :0]; [[entity_browser_i matrixInColumn:0] selectCellAtRow:lastSelected column:0];
[self newCurrentEntity]; // in case flags changed [self newCurrentEntity]; // in case flags changed
@ -113,14 +113,14 @@ id things_i;
classent = [entity_classes_i classForName:class]; classent = [entity_classes_i classForName:class];
if (!classent) if (!classent)
return self; return self;
lastSelected = [entity_classes_i indexOf: classent]; lastSelected = [entity_classes_i indexOfObject: classent];
if (lastSelected < 0) if (lastSelected < 0)
lastSelected = 0; lastSelected = 0;
[self loadEntityComment:classent]; [self loadEntityComment:classent];
[[entity_browser_i matrixInColumn:0] selectCellAt:lastSelected :0]; [[entity_browser_i matrixInColumn:0] selectCellAtRow:lastSelected column:0];
[[entity_browser_i matrixInColumn:0] scrollCellToVisible:lastSelected :0]; [[entity_browser_i matrixInColumn:0] scrollCellToVisibleAtRow:lastSelected column:0];
return self; return self;
} }
@ -136,7 +136,7 @@ id things_i;
ent = [map_i currentEntity]; ent = [map_i currentEntity];
classname = [ent valueForQKey: "classname"]; classname = [ent valueForQKey: "classname"];
if (ent != [map_i objectAt: 0]) if (ent != [map_i objectAtIndex: 0])
[self selectClass: classname]; // don't reset for world [self selectClass: classname]; // don't reset for world
classent = [entity_classes_i classForName:classname]; classent = [entity_classes_i classForName:classname];
flagname = [ent valueForQKey: "spawnflags"]; flagname = [ent valueForQKey: "spawnflags"];
@ -149,11 +149,11 @@ id things_i;
for (r=0 ; r<4 ; r++) for (r=0 ; r<4 ; r++)
for (c=0 ; c<3 ; c++) for (c=0 ; c<3 ; c++)
{ {
cell = [flags_i cellAt: r : c]; cell = [flags_i cellAtRow: r column: c];
if (c < 2) if (c < 2)
{ {
flagname = [classent flagName: c*4 + r]; flagname = [classent flagName: c*4 + r];
[cell setTitle: flagname]; [cell setTitle: [NSString stringWithCString:flagname]];
} }
[cell setIntValue: (flags & (1<< ((c*4)+r)) ) > 0]; [cell setIntValue: (flags & (1<< ((c*4)+r)) ) > 0];
} }
@ -175,8 +175,8 @@ id things_i;
// //
- setSelectedKey:(epair_t *)ep; - setSelectedKey:(epair_t *)ep;
{ {
[keyInput_i setStringValue:ep->key]; [keyInput_i setStringValue:[NSString stringWithCString:ep->key]];
[valueInput_i setStringValue:ep->value]; [valueInput_i setStringValue:[NSString stringWithCString:ep->value]];
[valueInput_i selectText:self]; [valueInput_i selectText:self];
return self; return self;
} }
@ -269,7 +269,7 @@ id things_i;
for (r=0 ; r<4 ; r++) for (r=0 ; r<4 ; r++)
for (c=0 ; c<3 ; c++) for (c=0 ; c<3 ; c++)
{ {
cell = [flags_i cellAt: r : c]; cell = [flags_i cellAtRow: r column: c];
i = ([cell intValue] > 0); i = ([cell intValue] > 0);
flags |= (i<< ((c*4)+r)); flags |= (i<< ((c*4)+r));
} }
@ -304,10 +304,10 @@ id things_i;
i = 0; i = 0;
while(max--) while(max--)
{ {
object = [entity_classes_i objectAt:i]; object = [entity_classes_i objectAtIndex:i];
[matrix addRow]; [matrix addRow];
cell = [matrix cellAt:i++ :0]; cell = [matrix cellAtRow:i++ column:0];
[cell setStringValue:[object classname]]; [cell setStringValue:[NSString stringWithCString:[object classname]]];
[cell setLeaf:YES]; [cell setLeaf:YES];
[cell setLoaded:YES]; [cell setLoaded:YES];
} }

View file

@ -8,19 +8,19 @@
*/ */
#import "UserPath.h" #import "UserPath.h"
#import <mach/mach_init.h> //#import <mach/mach_init.h>
#import <appkit/graphics.h> #import <AppKit/NSGraphics.h>
#import <appkit/errors.h> //#import <AppKit/errors.h>
#import <math.h> #import <math.h>
#import <libc.h> //#import <libc.h>
static NXZone *upZone = NULL; static NSZone *upZone = NULL;
NXZone *userPathZone() NSZone *userPathZone()
/* Creates a unique zone for use by all user paths */ /* Creates a unique zone for use by all user paths */
{ {
if (!upZone) { if (!upZone) {
upZone = NXCreateZone(vm_page_size, vm_page_size, 1); upZone = NSCreateZone(vm_page_size, vm_page_size, 1);
} }
return upZone; return upZone;
@ -31,11 +31,11 @@ UserPath *newUserPath()
{ {
UserPath *up; UserPath *up;
up = (UserPath *)NXZoneMalloc(userPathZone(), sizeof(UserPath)); up = (UserPath *)NSZoneMalloc(userPathZone(), sizeof(UserPath));
up->max = 8192; // JDC up->max = 8192; // JDC
up->points = (float *)NXZoneMalloc(userPathZone(), up->points = (float *)NSZoneMalloc(userPathZone(),
sizeof(float) * up->max); sizeof(float) * up->max);
up->ops = (char *)NXZoneMalloc(userPathZone(), up->ops = (char *)NSZoneMalloc(userPathZone(),
(2 + (up->max / 2)) * sizeof(char)); (2 + (up->max / 2)) * sizeof(char));
up->ping = NO; up->ping = NO;
@ -62,9 +62,9 @@ void growUserPath(UserPath *up)
/* double the size of the internal buffers */ /* double the size of the internal buffers */
printf ("growUserPath\n"); printf ("growUserPath\n");
up->max *= 2; up->max *= 2;
up->points = (float *)NXZoneRealloc(userPathZone(), up->points, up->points = (float *)NSZoneRealloc(userPathZone(), up->points,
sizeof(float) * up->max); sizeof(float) * up->max);
up->ops = (char *)NXZoneRealloc(userPathZone(), up->ops, up->ops = (char *)NSZoneRealloc(userPathZone(), up->ops,
(2 + (up->max / 2)) * sizeof(char)); (2 + (up->max / 2)) * sizeof(char));
return; return;
@ -110,9 +110,9 @@ void endUserPath(UserPath *up, int op)
void UPdebug(UserPath *up, BOOL shouldPing) void UPdebug(UserPath *up, BOOL shouldPing)
/* /*
* Sets ping to YES so that after each time a user path is sent down to the * Sets ping to YES so that after each time a user path is sent down to the
* window server, an NXPing() is sent after. The purpose is to catch PostScript * window server, an NSPing() is sent after. The purpose is to catch PostScript
* errors that may be generated by the user path. sendUserPath brackets the * errors that may be generated by the user path. sendUserPath brackets the
* download and the NXPing() in an NX_DURING... NX_HANDLER construct. Normally * download and the NSPing() in an NS_DURING... NS_HANDLER construct. Normally
* ping is NO. * ping is NO.
*/ */
{ {
@ -124,8 +124,8 @@ void UPdebug(UserPath *up, BOOL shouldPing)
int sendUserPath(UserPath *up) int sendUserPath(UserPath *up)
/* /*
* Call this to send the path down to the server. If ping==YES (set via * Call this to send the path down to the server. If ping==YES (set via
* debug:), the function will send an NXPing() after the Path. In any event, * debug:), the function will send an NSPing() after the Path. In any event,
* code is bracketed by a NX_DURING ... NX_HANDLER construct which will try to * code is bracketed by a NS_DURING ... NS_HANDLER construct which will try to
* catch postscript errors. If ping==NO (the default) it is unlikely to catch * catch postscript errors. If ping==NO (the default) it is unlikely to catch
* errors, with ping==YES it will. Whether you can recover or not is another * errors, with ping==YES it will. Whether you can recover or not is another
* matter. sendUserPath returns 0 on success and -1 on failure. If no previous * matter. sendUserPath returns 0 on success and -1 on failure. If no previous
@ -133,22 +133,22 @@ int sendUserPath(UserPath *up)
* server. * server.
*/ */
{ {
NXHandler exception; NSHandler exception;
exception.code = 0; exception.code = 0;
if (up->opForUserPath != 0) { if (up->opForUserPath != 0) {
NX_DURING NS_DURING
DPSDoUserPath(up->points, up->numberOfPoints, dps_float, up->ops, DPSDoUserPath(up->points, up->numberOfPoints, dps_float, up->ops,
up->numberOfOps, up->bbox, up->opForUserPath); up->numberOfOps, up->bbox, up->opForUserPath);
if (up->ping) { if (up->ping) {
NXPing(); NSPing();
} }
NX_HANDLER NS_HANDLER
exception = NXLocalHandler; exception = NSLocalHandler;
NX_ENDHANDLER NS_ENDHANDLER
if (exception.code) { if (exception.code) {
NXReportError(&exception); NSReportError(&exception);
if (exception.code == dps_err_ps) { if (exception.code == dps_err_ps) {
return -1; return -1;
} }