fix makefile
parent
813b82ef47
commit
ee80c7abdf
@ -0,0 +1,17 @@
|
|||||||
|
#ifndef YSARRAY_H
|
||||||
|
#define YSARRAY_H
|
||||||
|
|
||||||
|
#import "YSObject.h"
|
||||||
|
|
||||||
|
@interface YSArray : YSObject {
|
||||||
|
@public //public so you can index it directly
|
||||||
|
id *array;
|
||||||
|
int count;
|
||||||
|
}
|
||||||
|
|
||||||
|
-(void) addObject: (id) theObject;
|
||||||
|
-(void) removeObject: (unsigned int) index;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
#endif
|
||||||
@ -0,0 +1,56 @@
|
|||||||
|
#import "YSArray.h"
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
@implementation YSArray
|
||||||
|
-(id) init {
|
||||||
|
self = [super init];
|
||||||
|
array = NULL;
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
-(void) addObject: (id) theObject {
|
||||||
|
printf("%s\n", "YSArray: addObject");
|
||||||
|
|
||||||
|
if (array == NULL) {
|
||||||
|
printf("%s\n", "before malloc");
|
||||||
|
array = malloc(sizeof(id));
|
||||||
|
|
||||||
|
if (array == NULL) {
|
||||||
|
printf("%s\n", "addObject: malloc failed.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("%s\n", "after malloc");
|
||||||
|
} else {
|
||||||
|
printf("%s\n", "before realloc");
|
||||||
|
array = realloc(array, count * sizeof(id));
|
||||||
|
|
||||||
|
if (array == NULL) {
|
||||||
|
printf("%s\n", "addObject: realloc failed.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
array[count++] = theObject;
|
||||||
|
printf("%s\n", "YSArray: object added.");
|
||||||
|
}
|
||||||
|
|
||||||
|
-(void) removeObject: (unsigned int) index {
|
||||||
|
if (count == 0 || count == 1) {
|
||||||
|
array[0] = NULL;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (index >= count) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (index == count - 1) {
|
||||||
|
array[count - 1] = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
//hope count > index;
|
||||||
|
memcpy(&array[index], &array[index + 1], (count - index) * sizeof(id));
|
||||||
|
}
|
||||||
|
@end
|
||||||
@ -1,7 +1,30 @@
|
|||||||
SHELL=/bin/sh
|
SHELL=/bin/sh
|
||||||
CC=gcc
|
CC=gcc
|
||||||
|
|
||||||
yeslib.a:
|
LIB := -L
|
||||||
|
OS :=
|
||||||
|
ifeq ($(OS),windows)
|
||||||
|
LIB += lib/win64
|
||||||
|
CC=x86_64-w64-mingw32-gcc
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(OS),linux)
|
||||||
|
LIB += lib/linux64
|
||||||
|
endif
|
||||||
|
|
||||||
|
LIB += -lobjc
|
||||||
|
|
||||||
|
static:
|
||||||
$(CC) YSObject.m -c
|
$(CC) YSObject.m -c
|
||||||
$(CC) YSZone.m -c
|
$(CC) YSZone.m -c
|
||||||
ar rcs libyeslib.a YSObject.o YSZone.o
|
$(CC) YSArray.m -c
|
||||||
|
ar rcs libyeslib.a YSObject.o YSZone.o YSArray.o
|
||||||
|
|
||||||
|
shared:
|
||||||
|
$(CC) YSObject.m -c
|
||||||
|
$(CC) YSZone.m -c
|
||||||
|
$(CC) YSArray.m -c
|
||||||
|
$(CC) -shared -fPIC -o yeslib.dll YSObject.o YSZone.o YSArray.o $(LIB)
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm *.o
|
||||||
Loading…
Reference in New Issue